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

List:       kde-commits
Subject:    playground/pim/mailody/src
From:       Tom Albers <tomalbers () kde ! nl>
Date:       2007-02-28 22:03:51
Message-ID: 1172700231.551306.20050.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 638121 by toma:

- QObject is faster then QWidget, QChar is faster then QString
  Improved loading of 8700 messages from 1500ms to 1285ms

  800ms is used to parse the headers for essential data (messageid, reply to data and date). 
  I would love to know how to make that faster.

-Fix searchline not working when switching mailboxes.


 M  +18 -19    mainwindow.cpp  
 M  +12 -20    messagedata.cpp  
 M  +1 -1      messagedata.h  


--- trunk/playground/pim/mailody/src/mainwindow.cpp #638120:638121
@@ -654,7 +654,7 @@
                                        const QStringList& values)
 {
     // kdDebug() << k_funcinfo << mailbox
-    //        << " msg: " << values.count() << endl;
+    //         << " msg: " << values.count() << endl;
 
     MailBoxListViewItem* mbi =
             static_cast<MailBoxListViewItem*>(m_mailboxList->currentItem());
@@ -699,28 +699,29 @@
     bool sort_on_child = m_childSortAction->isChecked();
     QDateTime currentTime = QDateTime::currentDateTime();
 
-    struct timeval tv1, tv2;
-    gettimeofday(&tv1, 0);
+    //struct timeval tv1, tv2;
+    //gettimeofday(&tv1, 0);
 
     QStringList::ConstIterator it = values.begin();
     while (it != values.end())
     {
-        int uid = (*it).toInt();
+        const int uid = (*it).toInt();
         ++it;
 
-        QString mb = (*it);
+        const QString mb = *it;
         ++it;
 
-        QString headers = (*it);
+        const QString headers = *it;
         ++it;
 
-        QString flags = (*it);
+        const QString flags = *it;
         ++it;
 
         HeaderListViewItem* exists = m_headerMap[qMakePair(mb,uid)];
         if (!exists)
         {
             MessageData* r = new MessageData(this, "message", uid, mb, headers);
+
             HeaderListViewItem* threadTo = m_threadMap[r->inreplyto()];
             if (!threadTo || r->inreplyto().isEmpty())
                 exists = new HeaderListViewItem(m_headerList, r);
@@ -748,15 +749,15 @@
         }
     }
 
-    gettimeofday(&tv2, 0);
-    // Global::timing("filling", tv1, tv2);
+    //gettimeofday(&tv2, 0);
+    //Global::timing("filling", tv1, tv2);
 
     // since the parents might have new sortdates, we need a resort.
-    gettimeofday(&tv1, 0);
+    //gettimeofday(&tv1, 0);
     if (sort_on_child)
         m_headerList->sort();
-    gettimeofday(&tv2, 0);
-    // Global::timing("sorting", tv1, tv2);
+    //gettimeofday(&tv2, 0);
+    //Global::timing("sorting", tv1, tv2);
 
     // hide the deleted;
     if (m_hideDeletedAction->isChecked())
@@ -769,7 +770,6 @@
 
     searchLineUpdate();
     slotClearStatusBar();
-
     m_addheaderlist_val.clear();
 }
 
@@ -1184,8 +1184,7 @@
     }
 
     // Now we know all uids, we can remove the items from the list
-    // which are no longer in that mailbox. Remove them also from the
-    // database!
+    // which are no longer in that mailbox.
     QMap< QPair<QString,int>, HeaderListViewItem*>::Iterator ita;
     QValueList< QPair<QString,int> > deleted;
     for (ita = m_headerMap.begin(); ita != m_headerMap.end(); ++ita)
@@ -1193,15 +1192,12 @@
             deleted.append(ita.key());
 
     // we know what to delete...
-    m_db->beginTransaction();
     QValueList< QPair<QString,int> >::Iterator ita2=deleted.begin();
     while (ita2 != deleted.end())
     {
         HeaderListViewItem* tmp = m_headerMap[(*ita2)];
         if (tmp)
         {
-            m_db->deleteMessage( (*ita2).second, (*ita2).first );
-
             //before we delete the item, move the childeren
             //fir now to the top level..
             while (tmp->childCount() > 0)
@@ -1218,7 +1214,6 @@
         }
         ++ita2;
     }
-    m_db->commitTransaction();
 
     // scroll down as long as we do not store the last selected mail.
     if (!m_headerList->selectedItems().count())
@@ -2218,6 +2213,10 @@
 {
     if (!m_searchLine->text().isEmpty())
     {
+        // make sure the headers are visible. slotSearchLineChange() is not
+        // called when switching mailboxes.
+        m_headerList->allHeadersVisible();
+
         m_searchLine->updateSearch();
         m_searchLine->setPaletteBackgroundColor(
                 KGlobalSettings::activeTitleColor());
--- trunk/playground/pim/mailody/src/messagedata.cpp #638120:638121
@@ -40,34 +40,29 @@
 
 MessageData::MessageData( QWidget* parent,  const char* name,
                         int uid, const QString& mb  )
-    : QWidget(parent, name),
+    : QObject(parent, name),
     m_block(false),
-    m_delete(false)
+    m_delete(false),
+    m_uid(uid),
+    m_mb(mb)
 {
     m_datamanager = ImapManager::instance();
-
-    m_uid = uid;
-    m_mb = mb;
-    QStringList headers;
     m_headers = m_datamanager->getHeader( mb, uid );
-
     initialise_needed();
 }
 
 MessageData::MessageData( QWidget* parent,  const char* name,
                         int uid, const QString& mb,
                         const QString& headers)
-    : QWidget(parent, name),
+    : QObject(parent, name),
     m_block(false),
     m_delete(false),
-    m_initialized_all(false)
+    m_initialized_all(false),
+    m_headers(headers),
+    m_uid(uid),
+    m_mb(mb)
 {
     m_datamanager = ImapManager::instance();
-
-    m_uid = uid;
-    m_mb = mb;
-    m_headers = headers;
-
     initialise_needed();
 }
 
@@ -78,19 +73,16 @@
 
 void MessageData::initialise_needed()
 {
-    if (m_headers.isEmpty())
-        return;
-
     m_headers = "\n" + m_headers + "\n";
     int i = -1;
     if ((i = m_headers.find("\nmessage-id:",0,false)) != -1)
-        m_messageID = m_headers.mid(i+13,(m_headers.find("\n",i+12))-i-13);
+        m_messageID = m_headers.mid(i+13,(m_headers.find('\n',i+12))-i-13);
     if ((i = m_headers.find("\nin-reply-to:",0,false)) != -1)
-        m_inreplyto = m_headers.mid(i+14,(m_headers.find("\n",i+13))-i-14);
+        m_inreplyto = m_headers.mid(i+14,(m_headers.find('\n',i+13))-i-14);
     if ((i = m_headers.find("\ndate:",0,false)) != -1)
     {
         m_date.setTime_t(KRFCDate::parseDate(
-                m_headers.mid(i+6,(m_headers.find("\n",i+5))-i-6)));
+                m_headers.mid(i+6,(m_headers.find('\n',i+5))-i-6)));
         m_sortDate = m_date;
     }
 }
--- trunk/playground/pim/mailody/src/messagedata.h #638120:638121
@@ -42,7 +42,7 @@
  * and fill the variables.
  * @author Tom Albers <tomalbers@kde.nl>
  */
-class MessageData : public QWidget
+class MessageData : public QObject
 {
     Q_OBJECT
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic