[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: PATCH: mark any message
From: Stephan Kulow <coolo () kde ! org>
Date: 2001-05-15 17:19:07
[Download RAW message or body]
Hi!
I sent my patch in a revised version. This adds support for a property to
kmfolder to mark any message in it important. This is for outbox folder and
TODO folders. If a folder with that property set contains messages, it's shown
bold in the folder tree.
The remaining problem that it would require a todo item on Don's list to full
functionality, but I like that feature that much that I'd like to commit it
nonetheless as I regulary forget to send my queued messages and with this
patch I can't :)
Greetings, Stephan
--
People in cars cause accidents. Accidents in cars cause people.
["kmail-patch1" (text/plain)]
Index: kmfolder.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolder.cpp,v
retrieving revision 1.155
diff -u -u -b -B -w -r1.155 kmfolder.cpp
--- kmfolder.cpp 2001/05/11 12:32:27 1.155
+++ kmfolder.cpp 2001/05/15 17:17:45
@@ -89,6 +89,9 @@
mConvertToUtf8 = FALSE;
mAccount = NULL;
mMailingListEnabled = FALSE;
+ mMarkAnyMessage = false;
+
+ readConfig();
}
@@ -1716,8 +1720,8 @@
}
//-----------------------------------------------------------------------------
-void KMFolder::msgStatusChanged(const KMMsgStatus oldStatus,
- const KMMsgStatus newStatus)
+void KMFolder::msgStatusChanged(KMMsgStatus oldStatus,
+ KMMsgStatus newStatus)
{
int oldUnread = 0;
int newUnread = 0;
@@ -1785,6 +1789,7 @@
mMailingListPostingAddress = config->readEntry("MailingListPostingAddress");
mMailingListAdminAddress = config->readEntry("MailingListAdminAddress");
mMailingListIdentity = config->readEntry("MailingListIdentity");
+ mMarkAnyMessage = config->readBoolEntry( "MarkAnyMessage" );
}
//-----------------------------------------------------------------------------
@@ -1797,6 +1802,7 @@
config->writeEntry("MailingListPostingAddress", mMailingListPostingAddress);
config->writeEntry("MailingListAdminAddress", mMailingListAdminAddress);
config->writeEntry("MailingListIdentity", mMailingListIdentity);
+ config->writeEntry( "MarkAnyMessage", mMarkAnyMessage );
}
//-----------------------------------------------------------------------------
Index: kmfolder.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolder.h,v
retrieving revision 1.47
diff -u -u -b -B -w -r1.47 kmfolder.h
--- kmfolder.h 2001/04/24 11:22:28 1.47
+++ kmfolder.h 2001/05/15 17:17:45
@@ -150,6 +150,8 @@
contained by this folder */
virtual int countUnreadRecursive();
+ virtual bool isAnyMessageMarked() const { return mMarkAnyMessage; }
+
// Called by KMMsgBase::setStatus when status of a message has changed
// required to keep the number unread messages variable current.
virtual void msgStatusChanged( KMMsgStatus oldStatus,
@@ -248,19 +250,23 @@
void setMailingListPostAddress(const QString &address)
{ mMailingListPostingAddress = address; writeConfig(); }
- const QString& mailingListPostAddress() const
+ QString mailingListPostAddress() const
{ return mMailingListPostingAddress; }
void setMailingListAdminAddress(const QString &address)
{ mMailingListAdminAddress = address; writeConfig(); }
- const QString& mailingListAdminAddress() const
+ QString mailingListAdminAddress() const
{ return mMailingListAdminAddress; }
void setMailingListIdentity(const QString &identity)
{ mMailingListIdentity = identity; writeConfig(); }
- const QString& mailingListIdentity() const
+ QString mailingListIdentity() const
{ return mMailingListIdentity; }
+ void setMarkAnyMessage( bool mark ) {
+ mMarkAnyMessage = mark;
+ }
+
/** Tell the folder that a header field that is usually used for
the index (subject, from, ...) has changed of given message.
This method is usually called from within KMMessage::setSubject/set... */
@@ -397,6 +403,8 @@
LockType mLockType;
QString mProcmailLockFileName;
bool mConvertToUtf8;
+
+ bool mMarkAnyMessage;
};
#endif /*kmfolder_h*/
Index: kmfolderdia.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolderdia.cpp,v
retrieving revision 1.39
diff -u -u -b -B -w -r1.39 kmfolderdia.cpp
--- kmfolderdia.cpp 2001/05/15 11:13:58 1.39
+++ kmfolderdia.cpp 2001/05/15 17:17:46
@@ -142,7 +142,6 @@
markAnyMessage = new QCheckBox( i18n( "&Mark any message in this folder" ), \
mcGroup ); mcLayout->addWidget( markAnyMessage );
- mcGroup->hide();
// hl = new QHBoxLayout();
// topLayout->addLayout( hl );
@@ -161,7 +160,7 @@
// mailingListAdminAddress->setEnabled(folder->isMailingList());
// mailingListIdentity->setEnabled(folder->isMailingList());
holdsMailingList->setChecked(folder->isMailingList());
- // markAnyMessage->setChecked( folder->isAnyMessageMarked() );
+ markAnyMessage->setChecked( folder->isAnyMessageMarked() );
for (int i=0; i < mailingListIdentity->count(); ++i)
if (mailingListIdentity->text(i) == folder->mailingListIdentity()) {
@@ -249,7 +248,7 @@
// folder->setMailingListAdminAddress( mailingListAdminAddress->text() );
folder->setMailingListAdminAddress( QString::null );
folder->setMailingListIdentity( mailingListIdentity->currentText() );
-// folder->setMarkAnyMessage( markAnyMessage->isChecked() );
+ folder->setMarkAnyMessage( markAnyMessage->isChecked() );
}
KDialogBase::slotOk();
Index: kmfoldertree.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfoldertree.cpp,v
retrieving revision 1.116
diff -u -u -b -B -w -r1.116 kmfoldertree.cpp
--- kmfoldertree.cpp 2001/05/15 11:13:58 1.116
+++ kmfoldertree.cpp 2001/05/15 17:17:47
@@ -42,6 +42,53 @@
QPixmap* KMFolderTree::pixTr = 0;
QPixmap* KMFolderTree::pixSent = 0;
+/* Construct the root item */
+KMFolderTreeItem::KMFolderTreeItem( QListView *parent,
+ KMPaintInfo *aPaintInfo )
+ : QListViewItem( parent, i18n("Mail") ),
+ folder( 0 ),
+ mPaintInfo( aPaintInfo )
+{
+ init();
+}
+
+KMFolderTreeItem::KMFolderTreeItem( QListView *parent,
+ KMFolder* folder,
+ KMPaintInfo *aPaintInfo )
+ : QListViewItem( parent, i18n("Mail") ),
+ folder( folder ),
+ mPaintInfo( aPaintInfo )
+{
+ init();
+}
+
+/* Construct a child item */
+KMFolderTreeItem::KMFolderTreeItem( QListViewItem* parent,
+ KMFolder* _folder,
+ KMPaintInfo *aPaintInfo )
+ : QListViewItem( parent, (_folder) ? _folder->label() : QString::null ),
+ folder( _folder ),
+ mPaintInfo( aPaintInfo )
+{
+ init();
+}
+
+void KMFolderTreeItem::init()
+{
+ mImapState = imapNoInformation;
+ mCount = 0;
+ if ( !folder )
+ return;
+
+ // coolo - we need to keep the count here as long as it's not present
+ // if unopened
+ if ( folder->isAnyMessageMarked() ) {
+ folder->open();
+ mCount = folder->count();
+ folder->close();
+ }
+}
+
//-----------------------------------------------------------------------------
KMFolderTreeItem::~KMFolderTreeItem()
@@ -87,11 +134,16 @@
QString t = text( column );
if ( !t.isEmpty() ) {
- if( folder && (folder->countUnreadRecursive() > 0) ) {
+ if( folder ) {
+ int count = folder->isAnyMessageMarked() ?
+ mCount :
+ folder->countUnreadRecursive();
+ if ( count > 0 ) {
QFont f = p->font();
f.setWeight(QFont::Bold);
p->setFont(f);
}
+ }
QRect br;
p->drawText( r, 0, width-marg-r, height(),
align | AlignVCenter, t, -1, &br );
@@ -190,7 +242,6 @@
// Espen 2000-05-14: Getting rid of thick ugly frames
setLineWidth(0);
- mUpdateTimer = NULL;
setSelectionMode( Extended );
connect(this, SIGNAL(currentChanged(QListViewItem*)),
@@ -356,7 +407,6 @@
KMFolderTree::~KMFolderTree()
{
disconnect(kernel->folderMgr(), SIGNAL(changed()), this, \
SLOT(doFolderListChanged()));
- delete mUpdateTimer;
}
//-----------------------------------------------------------------------------
@@ -520,12 +570,7 @@
// when the user manually checks for mail and none was found.
void KMFolderTree::refresh(KMFolder* )
{
- if (!mUpdateTimer)
- {
- mUpdateTimer = new QTimer(this);
- connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(delayedUpdate()));
- }
- mUpdateTimer->changeInterval(200);
+ QTimer::singleShot( 200, this, SLOT( delayedUpdate() ) );
}
//-----------------------------------------------------------------------------
@@ -545,15 +590,23 @@
continue;
}
+ if ( fti->folder->isAnyMessageMarked() ) { // update count too
+ fti->folder->open();
+ fti->mCount = fti->folder->count();
+ fti->folder->close();
+ }
QString extendedName;
- if (fti->folder->countUnread() > 0) {
+ int count =
+ fti->folder->isAnyMessageMarked() ?
+ fti->mCount :
+ fti->folder->countUnread();
+ if (count > 0) {
QString num;
- num.setNum(fti->folder->countUnread());
+ num.setNum(count );
extendedName = " (" + num + ")";
if (!fti->folder->isSystemFolder())
fti->setPixmap( 0, *pixFull );
- }
- else {
+ } else {
extendedName = "";
if (!fti->folder->isSystemFolder())
fti->setPixmap( 0, *pixPlain );
@@ -569,7 +622,6 @@
++it;
}
setUpdatesEnabled(upd);
- mUpdateTimer->stop();
}
//-----------------------------------------------------------------------------
@@ -620,6 +672,7 @@
++it;
KMFolderTreeItem* fti = static_cast<KMFolderTreeItem*>(it.current());
if (fti && fti->folder && (fti->folder->countUnread() > 0)) {
+ kdDebug() << "nextUnreadFolder " << fti->folder->label() << " " << \
fti->folder->countUnread() << endl; if ( confirm ) {
if ( KMessageBox::questionYesNo( this,
i18n( "Go to the next unread message in folder %1?" ).
@@ -642,12 +695,15 @@
void KMFolderTree::firstUnreadFolder(bool confirm)
{
+ kdDebug() << "firstUnreadFolder\n";
+
QListViewItemIterator it( firstChild() );
while (it.current())
{
++it;
KMFolderTreeItem* fti = static_cast<KMFolderTreeItem*>(it.current());
if (fti && fti->folder && (fti->folder->countUnread() > 0)) {
+ kdDebug() << "firstUnreadFolder " << fti->folder->label() << " " << \
fti->folder->countUnread() << endl; if ( confirm ) {
if ( KMessageBox::questionYesNo( this,
i18n( "Go to the next unread \
message in folder %1?" ). @@ -759,10 +815,15 @@
if (fti->folder->account() && fti->mImapState
!= KMFolderTreeItem::imapInProgress)
fti->folder->account()->getFolder(fti);
- if (folder && (folder->countUnread() > 0) ) {
+ if ( folder ) {
+ int count = folder->isAnyMessageMarked() ?
+ fti->mCount :
+ folder->countUnread();
+ if ( count > 0) {
QString num;
- num.setNum(folder->countUnread());
+ num.setNum(count);
extendedName = " (" + num + ")";
+ }
}
if (extendedName != fti->unread) {
fti->unread = extendedName;
Index: kmfoldertree.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfoldertree.h,v
retrieving revision 1.36
diff -u -u -b -B -w -r1.36 kmfoldertree.h
--- kmfoldertree.h 2001/04/29 19:21:15 1.36
+++ kmfoldertree.h 2001/05/15 17:17:47
@@ -19,48 +19,33 @@
public:
KMFolder* folder;
QString unread;
+ int mCount;
KMPaintInfo *mPaintInfo;
enum imapState { imapNoInformation=0, imapInProgress=1, imapFinished=2 };
imapState mImapState;
/* Construct the root item */
KMFolderTreeItem( QListView *parent,
- KMPaintInfo *aPaintInfo )
- : QListViewItem( parent, i18n("Mail") ),
- folder( 0 ),
- unread( QString::null ),
- mPaintInfo( aPaintInfo ),
- mImapState( imapNoInformation )
- {}
+ KMPaintInfo *aPaintInfo );
KMFolderTreeItem( QListView *parent,
KMFolder* folder,
- KMPaintInfo *aPaintInfo )
- : QListViewItem( parent, i18n("Mail") ),
- folder( folder ),
- unread( QString::null ),
- mPaintInfo( aPaintInfo ),
- mImapState( imapNoInformation )
- {}
-
+ KMPaintInfo *aPaintInfo );
/* Construct a child item */
KMFolderTreeItem( QListViewItem* parent,
KMFolder* folder,
- KMPaintInfo *aPaintInfo )
- : QListViewItem( parent, (folder) ? folder->label() : QString::null ),
- folder( folder ),
- unread( QString::null ),
- mPaintInfo( aPaintInfo ),
- mImapState( imapNoInformation )
- {}
+ KMPaintInfo *aPaintInfo );
+
+ // common to all constructors
+ void init();
virtual ~KMFolderTreeItem();
- void paintBranches( QPainter * p, const QColorGroup & cg,
+ virtual void paintBranches( QPainter * p, const QColorGroup & cg,
int w, int y, int h, GUIStyle s )
{
QListViewItem::paintBranches( p, cg, w, y, h, s);
}
- void paintCell( QPainter * p, const QColorGroup & cg,
+ virtual void paintCell( QPainter * p, const QColorGroup & cg,
int column, int width, int align );
virtual QString key( int, bool ) const;
};
@@ -194,7 +179,6 @@
void writeIsListViewItemOpen(KMFolderTreeItem *fti);
KMFolderNodeList mList;
- QTimer* mUpdateTimer;
static QPixmap *pixDir, *pixNode, *pixPlain, *pixFld, *pixFull, *pixIn,
*pixOut, *pixTr, *pixSent;
Index: kmkernel.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmkernel.cpp,v
retrieving revision 1.47
diff -u -u -b -B -w -r1.47 kmkernel.cpp
--- kmkernel.cpp 2001/05/08 08:03:02 1.47
+++ kmkernel.cpp 2001/05/15 17:17:48
@@ -407,6 +407,7 @@
the_outboxFolder->setType("Out");
the_outboxFolder->setWhoField("To");
the_outboxFolder->setSystemFolder(TRUE);
+ the_outboxFolder->setMarkAnyMessage( TRUE );
the_outboxFolder->open();
the_sentFolder = the_folderMgr->findOrCreate(cfg->readEntry("sentFolder", \
"sent-mail"));
_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic