From 9e1c2614265a9cd4c1282b8b720b4c442133c33c Mon Sep 17 00:00:00 2001 From: Stefan Taferner Date: Sun, 8 Mar 1998 15:57:18 +0000 Subject: [PATCH] * highlighting of column header which is current sort column * workaround for initial-size bug in Qt-1.32 for composer/attachments * confirm dialog for emptying folders * sender names now without email addr in message list svn path=/trunk/kdenetwork/kmail/; revision=5900 --- KMail.kdelnk | 2 +- Makefile.am | 2 +- kmcomposewin.cpp | 58 +++++++++++++++++++++++++++++++++++++++++------- kmcomposewin.h | 33 +++++++++++++++++++++------ kmheaders.cpp | 20 +++++++---------- kmheaders.h | 1 - kmmainwin.cpp | 22 +++++++++++++----- kmmsglist.h | 2 +- kmversion.h | 2 +- 9 files changed, 105 insertions(+), 37 deletions(-) diff --git a/KMail.kdelnk b/KMail.kdelnk index dd45c1092..3ab0af0ba 100644 --- a/KMail.kdelnk +++ b/KMail.kdelnk @@ -8,7 +8,7 @@ Name[fi]=S Name[hu]=Levelező program Name[pt]=Cliente de Mail Type=Application -Exec=kmail +Exec=kmail -caption "%c" %i %m Icon=kmail.xpm DocPath=kmail.html Comment=Mail Client diff --git a/Makefile.am b/Makefile.am index 9a9d2cfe6..0e61d0ac4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,7 @@ uninstall-local: rm -f $(appsdir)/KMail.kdelnk rm -f $(kde_icondir)/kmail.xpm rm -f $(kde_minidir)/kmail.xpm - + messages: @XGETTEXT@ -ki18n -C -x../../kdelibs/po/kde.pot $(kmail_SOURCES) && mv messages.po ../po/kmail.pot diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index 2e0f3af44..038e1cff1 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -2,7 +2,6 @@ // Author: Markus Wuebben // This code is published under the GPL. -#include #include "kmcomposewin.h" #include "kmmessage.h" #include "kmmsgpart.h" @@ -329,6 +328,7 @@ void KMComposeWin::rethinkFields(void) mGrid->setColStretch(2, 1); mGrid->setRowStretch(mNumHeaders, 100); + mEdtList.clear(); row = 0; rethinkHeaderLine(showHeaders,HDR_FROM, row, i18n("&From:"), &mLblFrom, &mEdtFrom, &mBtnFrom); @@ -379,7 +379,9 @@ void KMComposeWin::rethinkHeaderLine(int aValue, int aMask, int& aRow, aEdt->show(); aEdt->setMinimumSize(100, aLbl->height()+2); aEdt->setMaximumSize(1000, aLbl->height()+2); - aEdt->setFocusPolicy(QWidget::StrongFocus); + aEdt->setFocusPolicy(QWidget::ClickFocus); + //aEdt->setFocusPolicy(QWidget::StrongFocus); + mEdtList.append(aEdt); if (aBtn) { @@ -613,8 +615,9 @@ void KMComposeWin::updateCursorPosition() { void KMComposeWin::setupEditor(void) { QPopupMenu* menu; - mEditor = new KEdit(kapp, &mMainWidget); + mEditor = new KMEdit(kapp, &mMainWidget); mEditor->toggleModified(FALSE); + mEditor->setFocusPolicy(QWidget::ClickFocus); // Word wrapping setup if(mWordWrap) @@ -964,6 +967,7 @@ void KMComposeWin::addAttach(const QString aUrl) // add the new attachment to the list addAttach(msgPart); + rethinkFields(); //work around initial-size bug in Qt-1.32 } @@ -1743,10 +1747,29 @@ void KMComposeWin::setEditCharset(){ cout<<"Setting font to: "<setFont(kcharset.setQFont(fnt)); } - #endif //CHARSETS +//----------------------------------------------------------------------------- +void KMComposeWin::focusNextPrevEdit(const QLineEdit* aCur, bool aNext) +{ + QLineEdit* cur; + + if (!aCur) cur=mEdtList.last(); + else + { + for (cur=mEdtList.first(); aCur!=cur && cur; cur=mEdtList.next()) + ; + if (!cur) return; + if (aNext) cur = mEdtList.next(); + else cur = mEdtList.prev(); + } + if (!cur) return; + cur->setFocus(); +} + + + //============================================================================= // // Class KMLineEdit @@ -1794,7 +1817,7 @@ void KMLineEdit::cut() if(hasMarkedText()) { QString t = markedText(); - QKeyEvent k( Event_KeyPress, Key_D , 0 , ControlButton); + QKeyEvent k(Event_KeyPress, Key_D, 0, ControlButton); keyPressEvent(&k); QApplication::clipboard()->setText(t); } @@ -1803,7 +1826,7 @@ void KMLineEdit::cut() //----------------------------------------------------------------------------- void KMLineEdit::paste() { - QKeyEvent k( Event_KeyPress, Key_V , 0 , ControlButton); + QKeyEvent k(Event_KeyPress, Key_V, 0, ControlButton); keyPressEvent(&k); } @@ -1815,7 +1838,26 @@ void KMLineEdit::markAll() +//============================================================================= +// +// Class KMEdit +// +//============================================================================= +KMEdit::KMEdit(KApplication *a,QWidget *parent, const char *name, + const char *filename): + KMEditInherited(a, parent, name, filename) +{ + initMetaObject(); +} - - +//----------------------------------------------------------------------------- +void KMEdit::keyPressEvent(QKeyEvent* e) +{ + if (e->key()==Key_Tab && (e->state() & ShiftButton)) + { + printf("shift-tab\n"); + parent()->focusNextPrevEdit(NULL,FALSE); + } + else KMEditInherited::keyPressEvent(e); +} diff --git a/kmcomposewin.h b/kmcomposewin.h index 07295e0b0..a195baa69 100644 --- a/kmcomposewin.h +++ b/kmcomposewin.h @@ -16,6 +16,7 @@ #include #include #include "kmmsgpart.h" +#include #ifdef HAS_KSPELL #include #endif @@ -34,10 +35,26 @@ class QPushButton; class QCloseEvent; class KSpell; class KSpellConfig; +class KMComposeWin; typedef QList KMMsgPartList; +//----------------------------------------------------------------------------- +#define KMEditInherited KEdit +class KMEdit: public KEdit +{ + Q_OBJECT +public: + KMEdit(KApplication *a=NULL,QWidget *parent=NULL, const char *name=NULL, + const char *filename=NULL); + KMComposeWin* parent(void) const + { return (KMComposeWin*)KMEditInherited::parent(); } +protected: + virtual void keyPressEvent(QKeyEvent*); +}; + + //----------------------------------------------------------------------------- class KMLineEdit : public QLineEdit { @@ -52,8 +69,6 @@ public slots: void paste(); void markAll(); -private: - protected: virtual void mousePressEvent(QMouseEvent *); }; @@ -165,11 +180,14 @@ public slots: /** Append current message to ~/dead.letter */ virtual void deadLetter(void); - void updateCursorPosition(); + void updateCursorPosition(); + + void slotConfigureCharsets(); + void slotSetCharsets(const char *message,const char *composer, + bool ascii,bool quote,bool def); - void slotConfigureCharsets(); - void slotSetCharsets(const char *message,const char *composer, - bool ascii,bool quote,bool def); + /** Move focus to next/prev edit widget */ + virtual void focusNextPrevEdit(const QLineEdit* current, bool next); protected: /** Install grid management and header fields. If fields exist that @@ -250,7 +268,7 @@ protected: /* end Added for KRN */ QPopupMenu *mMnuView, *mMnuOptions; - KEdit* mEditor; + KMEdit* mEditor; QGridLayout* mGrid; KDNDDropZone *mDropZone; KMMessage *mMsg; @@ -269,6 +287,7 @@ protected: short mBtnIdSign, mBtnIdEncrypt; short mMnuIdUrgent, mMnuIdConfDeliver, mMnuIdConfRead; QString mForeColor, mBackColor; + QList mEdtList; #ifdef HAS_KSPELL KSpell* mKSpell; KSpellConfig* mKSpellConfig; diff --git a/kmheaders.cpp b/kmheaders.cpp index 1d637f3f4..e78c1a385 100644 --- a/kmheaders.cpp +++ b/kmheaders.cpp @@ -32,7 +32,7 @@ KMHeaders::KMHeaders(KMMainWin *aOwner, QWidget *parent, mOwner = aOwner; mFolder = NULL; getMsgIndex = -1; - mSortField = KMMsgList::sfDate; + mSortCol = KMMsgList::sfDate; setColumn(0, i18n("F"), 17, KMHeadersInherited::PixmapColumn); setColumn(1, i18n("Sender"), 200); @@ -88,9 +88,8 @@ void KMHeaders::readFolderConfig (void) setColumnWidth(1, config->readNumEntry("SenderWidth", 200)); setColumnWidth(2, config->readNumEntry("SubjectWidth", 270)); setColumnWidth(3, config->readNumEntry("DateWidth", 300)); - mSortField = (KMMsgList::SortField) - config->readNumEntry("SortColumn", (int)KMMsgList::sfDate); - mFolder->sort(mSortField); + mSortCol = config->readNumEntry("SortColumn", (int)KMMsgList::sfDate); + mFolder->sort((KMMsgList::SortField)mSortCol); } @@ -104,7 +103,7 @@ void KMHeaders::writeFolderConfig (void) config->writeEntry("SenderWidth", columnWidth(1)); config->writeEntry("SubjectWidth", columnWidth(2)); config->writeEntry("DateWidth", columnWidth(3)); - config->writeEntry("SortColumn", (int)mSortField); + config->writeEntry("SortColumn", mSortCol); } @@ -208,14 +207,10 @@ void KMHeaders::headerClicked(int column) if (idx >= 0) cur = (*mFolder)[idx]; else cur = NULL; - if (column==0) mSortField = KMMsgList::sfStatus; - else if (column==1) mSortField = KMMsgList::sfFrom; - else if (column==2) mSortField = KMMsgList::sfSubject; - else if (column==3) mSortField = KMMsgList::sfDate; - else return; + mSortCol = column; kbp->busy(); - mFolder->sort(mSortField); + mFolder->sort((KMMsgList::SortField)mSortCol); kbp->idle(); if (cur) idx = mFolder->find(cur); @@ -604,7 +599,8 @@ void KMHeaders::updateMessageList(void) assert(mb != NULL); // otherwise using count() above is wrong flag = mb->status(); - hdr.sprintf("%c\n%s\n %s\n%s", (char)flag, (const char*)mb->from(), + hdr.sprintf("%c\n%s\n %s\n%s", (char)flag, + (const char*)KMMessage::stripEmailAddr(mb->from()), (const char*)mb->subject(), (const char*)mb->dateStr()); insertItem(hdr); diff --git a/kmheaders.h b/kmheaders.h index 79770eebf..57400153d 100644 --- a/kmheaders.h +++ b/kmheaders.h @@ -108,7 +108,6 @@ private: int getMsgIndex; bool getMsgMulti; KMMessageList mSelMsgList; - KMMsgList::SortField mSortField; }; #endif diff --git a/kmmainwin.cpp b/kmmainwin.cpp index fb0b9075e..bb5efe3d0 100644 --- a/kmmainwin.cpp +++ b/kmmainwin.cpp @@ -18,7 +18,6 @@ #include "kmglobal.h" #include "kmfolderseldlg.h" #include "kmfiltermgr.h" -#include "kmversion.h" #include "kmsender.h" #include "kmaddrbookdlg.h" #include "kmaddrbook.h" @@ -324,10 +323,22 @@ void KMMainWin::slotModifyFolder() //----------------------------------------------------------------------------- void KMMainWin::slotEmptyFolder() { - kbp->busy(); - mFolder->expunge(); - mHeaders->setFolder(mFolder); - kbp->idle(); + QString str(256); + + if (!mFolder) return; + + str.sprintf(i18n("Are you sure you want to discard the\n" + "contents of the folder \"%s\" ?"), + (const char*)mFolder->label()); + if ((KMsgBox::yesNo(this,i18n("Confirmation"),str))==1) + { + kbp->busy(); + mHeaders->setFolder(NULL); + mMsgView->clear(); + mFolder->expunge(); + mHeaders->setFolder(mFolder); + kbp->idle(); + } } @@ -350,6 +361,7 @@ void KMMainWin::slotRemoveFolder() if ((KMsgBox::yesNo(this,i18n("Confirmation"),str))==1) { mHeaders->setFolder(NULL); + mMsgView->clear(); folderMgr->remove(mFolder); } } diff --git a/kmmsglist.h b/kmmsglist.h index 9c367c42b..46629e540 100644 --- a/kmmsglist.h +++ b/kmmsglist.h @@ -14,7 +14,7 @@ class KMMsgList: public QArray { public: /** Valid parameters for sort() */ - typedef enum { sfStatus=0, sfSubject=1, sfFrom=2, sfDate=3 } SortField; + typedef enum { sfStatus=0, sfFrom=1, sfSubject=2, sfDate=3 } SortField; /** Constructor with optional initial size. */ KMMsgList(int initialSize=32); diff --git a/kmversion.h b/kmversion.h index ce35554c3..d31fd7c17 100644 --- a/kmversion.h +++ b/kmversion.h @@ -3,6 +3,6 @@ #ifndef kmversion_h #define kmversion_h -#define KMAIL_VERSION "0.6.0" +#define KMAIL_VERSION "0.6.1" #endif /*kmversion_h*/