[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: [PATCH] increase moveMsg performance
From:       Carsten Burghardt <cb () magic-shop ! de>
Date:       2002-09-08 17:01:19
[Download RAW message or body]

On Friday 06 September 2002 07:35, Carsten Burghardt wrote:
> Nice. I'll update my cvs today and spend the evening with resolving
> conflicts....

The attached version applies against current cvs.

-- 
Regards,

Carsten Burghardt
["movemsg2.diff" (text/x-diff)]

Index: kdenetwork/kmail/kmcommands.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmcommands.cpp,v
retrieving revision 1.6
diff -u -3 -p -r1.6 kmcommands.cpp
--- kdenetwork/kmail/kmcommands.cpp	2002/09/08 00:40:18	1.6
+++ kdenetwork/kmail/kmcommands.cpp	2002/09/08 16:58:19
@@ -1070,8 +1070,9 @@ void KMMoveCommand::execute()
   if (mDestFolder == mSrcFolder)
     return;
 
-  if (mDestFolder && mDestFolder->open() != 0)
-    return;
+  if (mDestFolder && mDestFolder->protocol() != "imap")
+    if (mDestFolder->open() != 0) // no need to open imap-folders
+      return;
   kernel->kbp()->busy();
 
   KMMsgBase *curMsg = 0;
@@ -1127,7 +1128,7 @@ void KMMoveCommand::execute()
   if (mHeaders)
     mHeaders->finalizeMove( curMsg, contentX, contentY );
 
-  if (mDestFolder) {
+  if (mDestFolder && mDestFolder->protocol() != "imap") {
      mDestFolder->sync();
      mDestFolder->close();
   }
Index: kdenetwork/kmail/kmfolder.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolder.cpp,v
retrieving revision 1.226
diff -u -3 -p -r1.226 kmfolder.cpp
--- kdenetwork/kmail/kmfolder.cpp	2002/07/29 09:21:01	1.226
+++ kdenetwork/kmail/kmfolder.cpp	2002/09/08 16:58:20
@@ -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: kdenetwork/kmail/kmfolderimap.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfolderimap.cpp,v
retrieving revision 1.68
diff -u -3 -p -r1.68 kmfolderimap.cpp
--- kdenetwork/kmail/kmfolderimap.cpp	2002/09/03 18:59:15	1.68
+++ kdenetwork/kmail/kmfolderimap.cpp	2002/09/08 16:58:20
@@ -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(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(this);
+    emit numUnreadMsgsChanged(this);
+  }
 }
 
 //-----------------------------------------------------------------------------
@@ -223,8 +254,7 @@ int KMFolderImap::addMsg(QPtrList<KMMess
 
         } else {
 
-          /* get the messages and the uids
-             don't unGet the messages because we need to access the serial number in addMsgQuiet */
+          // get the messages and the uids
           QValueList<int> uids;
           getUids(msgList, uids);
 
Index: kdenetwork/kmail/kmfoldertree.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfoldertree.cpp,v
retrieving revision 1.199
diff -u -3 -p -r1.199 kmfoldertree.cpp
--- kdenetwork/kmail/kmfoldertree.cpp	2002/09/01 20:34:27	1.199
+++ kdenetwork/kmail/kmfoldertree.cpp	2002/09/08 16:58:21
@@ -82,15 +82,6 @@ void KMFolderTreeItem::init()
 }
 
 //-----------------------------------------------------------------------------
-int KMFolderTreeItem::countUnreadRecursive()
-{
-  if (mFolder)
-    return mFolder->countUnreadRecursive();
-  else
-    return 0;
-}
-
-//-----------------------------------------------------------------------------
 bool KMFolderTreeItem::acceptDrag(QDropEvent*) const
 {
   if ( !mFolder ||
@@ -446,13 +437,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*)),
Index: kdenetwork/kmail/kmfoldertree.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmfoldertree.h,v
retrieving revision 1.59
diff -u -3 -p -r1.59 kmfoldertree.h
--- kdenetwork/kmail/kmfoldertree.h	2002/09/01 20:34:27	1.59
+++ kdenetwork/kmail/kmfoldertree.h	2002/09/08 16:58:21
@@ -32,9 +32,6 @@ public:
   KMFolderTreeItem( KFolderTreeItem* parent, QString name,
                     KMFolder* folder );
 
-  /** gets the recursive unread-count */
-  virtual int countUnreadRecursive();
-
   /** associated folder */
   KMFolder* folder() { return mFolder; }
 
Index: kdenetwork/kmail/kmheaders.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmheaders.cpp,v
retrieving revision 1.442
diff -u -3 -p -r1.442 kmheaders.cpp
--- kdenetwork/kmail/kmheaders.cpp	2002/09/05 18:52:49	1.442
+++ kdenetwork/kmail/kmheaders.cpp	2002/09/08 16:58:22
@@ -2939,14 +2939,8 @@ bool KMHeaders::readSortOrder(bool set_s
 	    center( contentsX(), itemPos(mItems[first_unread]), 0, 9.0 );
 	}
     } else {
-      // make sure the changes to current item are not shown
-      disconnect(this,SIGNAL(currentChanged(QListViewItem*)),
-          this,SLOT(highlightMessage(QListViewItem*)));
       setTopItemByIndex(mTopItem);
       setCurrentItemByIndex((mCurrentItem >= 0) ? mCurrentItem : 0);
-      // reconnect again
-      connect(this,SIGNAL(currentChanged(QListViewItem*)),
-          this,SLOT(highlightMessage(QListViewItem*)));
     }
     END_TIMER(selection);
     SHOW_TIMER(selection);

_______________________________________________
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