[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: Re: [PATCH] increase moveMsg performance
From: Carsten Burghardt <burghardt () kde ! org>
Date: 2002-08-31 9:51:13
[Download RAW message or body]
On Thursday 29 August 2002 20:58, Michael Häckel wrote:
> On Thursday 29 August 2002 08:06, Carsten Burghardt wrote:
> > > You forgot to update the number of unread messages, when unread
> > > messages are moved. This number is probably the reason why I added that
> > > getFolder call.
> >
> > See my last mail. Attached is the corrected version.
>
> There appears do be a painting bug when total and unread column are
> disabled.
>
> When selecting the destination folder with the new messages, the number of
> unread messages is no longer bold. When scrolling the header list, it
> becomes bold again.
>
> Besides that it looks good.
mGuessedUnreadMsgs returned the wrong count, this is fixed with the attached
version.
I noticed one problem but I don't know yet what the reason might be and if
it's caused by the patch: if you move messages into an empty folder and
afterwards click on that folder, the first message is selected but the
content is not displayed in the readerwin. If you click on a different
message and then back it works as exptected. Perhaps the message is still
"get`ed"?
--
Regards,
Carsten Burghardt
["movemsg.diff" (text/x-diff)]
Index: kmfolder.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolder.cpp,v
retrieving revision 1.226
diff -u -3 -p -r1.226 kmfolder.cpp
--- kmfolder.cpp 2002/07/29 09:21:01 1.226
+++ kmfolder.cpp 2002/08/31 09:45:31
@@ -956,15 +956,19 @@ int KMFolder::moveMsg(KMMessage* aMsg, i
assert(aMsg != NULL);
msgParent = aMsg->parent();
- if (msgParent)
- msgParent->open();
+ if (protocol() != "imap") {
+ if (msgParent)
+ msgParent->open();
- open();
+ open();
+ }
rc = addMsg(aMsg, aIndex_ret);
- close();
+ if (protocol() != "imap") {
+ close();
- if (msgParent)
- msgParent->close();
+ if (msgParent)
+ msgParent->close();
+ }
return rc;
}
@@ -979,15 +983,19 @@ int KMFolder::moveMsg(QPtrList<KMMessage
assert(aMsg != NULL);
msgParent = aMsg->parent();
- if (msgParent)
- msgParent->open();
+ if (protocol() != "imap") {
+ if (msgParent)
+ msgParent->open();
- open();
+ open();
+ }
rc = static_cast<KMFolderImap*>(this)->addMsg(msglist, aIndex_ret);
- close();
+ if (protocol() != "imap") {
+ close();
- if (msgParent)
- msgParent->close();
+ if (msgParent)
+ msgParent->close();
+ }
return rc;
}
@@ -1160,7 +1168,7 @@ int KMFolder::count(bool cache) const
//-----------------------------------------------------------------------------
int KMFolder::countUnread()
{
- if (mGuessedUnreadMsgs > -1)
+ if (mGuessedUnreadMsgs > 0)
return mGuessedUnreadMsgs;
if (mUnreadMsgs > -1)
return mUnreadMsgs;
Index: kmfolderimap.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolderimap.cpp,v
retrieving revision 1.67
diff -u -3 -p -r1.67 kmfolderimap.cpp
--- kmfolderimap.cpp 2002/08/25 18:08:03 1.67
+++ kmfolderimap.cpp 2002/08/31 09:45:31
@@ -166,23 +166,54 @@ void KMFolderImap::addMsgQuiet(KMMessage
{
KMFolder *folder = aMsg->parent();
if (folder) kernel->undoStack()->pushAction( aMsg->getMsgSerNum(), folder, this );
+ // correct the unread-count if the folder won't be get'ted
+ if (!mIsSelected &&
+ aMsg->status()==KMMsgStatusUnread ||
+ aMsg->status()==KMMsgStatusNew) {
+ if (mUnreadMsgs == -1) mUnreadMsgs = 1;
+ else ++mUnreadMsgs;
+ }
if (folder) folder->take(folder->find(aMsg));
delete aMsg;
- getFolder();
+ if (mIsSelected) {
+ // folder is selected, so we can fetch the (new) content
+ getFolder();
+ } else {
+ // increase the cached total count
+ ++mTotalMsgs;
+ emit msgAdded( static_cast<KMFolder*>(this) );
+ emit numUnreadMsgsChanged( this );
+ }
}
//-----------------------------------------------------------------------------
void KMFolderImap::addMsgQuiet(QPtrList<KMMessage> msgList)
{
+ int count = msgList.count();
KMFolder *folder = msgList.first()->parent();
for ( KMMessage* msg = msgList.first(); msg; msg = msgList.next() )
{
kernel->undoStack()->pushAction( msg->getMsgSerNum(), folder, this );
+ // correct the unread-count if the folder won't be get'ted
+ if (!mIsSelected &&
+ msg->status()==KMMsgStatusUnread ||
+ msg->status()==KMMsgStatusNew) {
+ if (mUnreadMsgs == -1) mUnreadMsgs = 1;
+ else ++mUnreadMsgs;
+ }
}
if (folder) folder->take(msgList);
msgList.setAutoDelete(true);
msgList.clear();
- getFolder();
+ if (mIsSelected) {
+ // folder is selected, so we can fetch the (new) content
+ getFolder();
+ } else {
+ // increase the cached total count
+ mTotalMsgs += count;
+ emit msgAdded( static_cast<KMFolder*>(this) );
+ emit numUnreadMsgsChanged( this );
+ }
}
//-----------------------------------------------------------------------------
Index: kmfoldertree.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfoldertree.cpp,v
retrieving revision 1.193
diff -u -3 -p -r1.193 kmfoldertree.cpp
--- kmfoldertree.cpp 2002/08/23 05:37:19 1.193
+++ kmfoldertree.cpp 2002/08/31 09:45:32
@@ -450,13 +450,14 @@ void KMFolderTree::reload(bool openFolde
this,SLOT(slotUpdateCounts(KMFolderImap*, bool)));
connect(fti->folder(), SIGNAL(folderComplete(KMFolderImap*, bool)),
this,SLOT(slotUpdateCounts(KMFolderImap*, bool)));
- } else {
- // others-only, imap doesn't need this because of the folderComplete-signal
- disconnect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
- this,SLOT(slotUpdateCounts(KMFolder*)));
- connect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
- this,SLOT(slotUpdateCounts(KMFolder*)));
}
+ // msgAdded
+ disconnect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
+ this,SLOT(slotUpdateCounts(KMFolder*)));
+ connect(fti->folder(), SIGNAL(msgAdded(KMFolder*)),
+ this,SLOT(slotUpdateCounts(KMFolder*)));
+
+ // msgRemoved
disconnect(fti->folder(), SIGNAL(msgRemoved(KMFolder*)),
this,SLOT(slotUpdateCounts(KMFolder*)));
connect(fti->folder(), SIGNAL(msgRemoved(KMFolder*)),
@@ -1366,6 +1367,7 @@ void KMFolderTree::slotUpdateCounts(KMFo
count = 0;
else
count = fti->folder()->countUnread();
+ kdDebug() << fti->folder()->name() << ":" << count << endl;
// set it
bool repaint = false;
Index: kmheaders.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmheaders.cpp,v
retrieving revision 1.436
diff -u -3 -p -r1.436 kmheaders.cpp
--- kmheaders.cpp 2002/08/25 13:22:14 1.436
+++ kmheaders.cpp 2002/08/31 09:45:33
@@ -1742,10 +1742,13 @@ void KMHeaders::moveMsgToFolder (KMFolde
this,SLOT(highlightMessage(QListViewItem*)));
kernel->kbp()->busy();
- if (destFolder && destFolder->open() != 0)
+ if (destFolder && destFolder->protocol() != "imap")
{
- kernel->kbp()->idle();
- return;
+ // no need to open with imap
+ if (destFolder->open() != 0) {
+ kernel->kbp()->idle();
+ return;
+ }
}
int contentX, contentY;
@@ -1832,7 +1835,9 @@ void KMHeaders::moveMsgToFolder (KMFolde
connect(this,SIGNAL(currentChanged(QListViewItem*)),
this,SLOT(highlightMessage(QListViewItem*)));
- if (destFolder) {
+ if (destFolder && destFolder->protocol() != "imap")
+ {
+ // no need for imap
destFolder->sync();
destFolder->close();
}
_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.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