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

List:       kde-commits
Subject:    [kdepim/KDE/4.10] libkdepim: Delay akonadi and nepomuk lookups to compress them.
From:       Till Adam <adam () kde ! org>
Date:       2013-01-22 19:31:48
Message-ID: 20130122193148.AD15AA6091 () git ! kde ! org
[Download RAW message or body]

Git commit b41d297b2bd2e22a49ab4c73bb1b2244e1327d61 by Till Adam.
Committed on 22/01/2013 at 15:38.
Pushed by tilladam into branch 'KDE/4.10'.

Delay akonadi and nepomuk lookups to compress them.

Introduce a per-addresseelineedit timer that delays completion
lookups via both akonadi and nepomuk directly by 500ms, so they
can be compressed. This avoids running too many queries when one types
quickly into an addresseelineedit, which helps with performance.

REVIEW: 108549

M  +20   -7    libkdepim/addresseelineedit.cpp
M  +1    -0    libkdepim/addresseelineedit.h

http://commits.kde.org/kdepim/b41d297b2bd2e22a49ab4c73bb1b2244e1327d61

diff --git a/libkdepim/addresseelineedit.cpp b/libkdepim/addresseelineedit.cpp
index 188470a..36aa01f 100644
--- a/libkdepim/addresseelineedit.cpp
+++ b/libkdepim/addresseelineedit.cpp
@@ -227,6 +227,8 @@ class AddresseeLineEdit::Private
         m_searchExtended( false ),
         m_useSemicolonAsSeparator( false )
     {
+        m_delayedQueryTimer.setSingleShot(true);
+        connect( &m_delayedQueryTimer, SIGNAL(timeout()), q, SLOT(slotTriggerDelayedQueries()) );
     }
 
     void init();
@@ -258,6 +260,7 @@ class AddresseeLineEdit::Private
     void stopNepomukSearch();
     void slotNepomukHits( const QList<Nepomuk2::Query::Result>& result );
     void slotNepomukSearchFinished();
+    void slotTriggerDelayedQueries();
     static KCompletion::CompOrder completionOrder();
 
     AddresseeLineEdit *q;
@@ -270,6 +273,7 @@ class AddresseeLineEdit::Private
     bool m_lastSearchMode;
     bool m_searchExtended; //has \" been added?
     bool m_useSemicolonAsSeparator;
+    QTimer m_delayedQueryTimer;
 };
 
 void AddresseeLineEdit::Private::init()
@@ -621,16 +625,25 @@ void AddresseeLineEdit::Private::updateSearchString()
   }
 }
 
+void AddresseeLineEdit::Private::slotTriggerDelayedQueries()
+{
+    if (m_searchString.isEmpty())
+        return;
+
+    // If Nepomuk is running, we send a ContactSearch job to
+    // Akonadi, which will forward the query to Nepomuk, be
+    // notified of matching items and return those to us.
+    akonadiPerformSearch();
+    // additionally, we ask Nepomuk directly, to get hits that
+    // did not come in through Akonadi
+    startNepomukSearch();
+}
+
 void AddresseeLineEdit::Private::startSearches()
 {
     if ( Nepomuk2::ResourceManager::instance()->initialized() ) {
-      // If Nepomuk is running, we send a ContactSearch job to
-      // Akonadi, which will forward the query to Nepomuk, be
-      // notified of matching items and return those to us.
-      akonadiPerformSearch();
-      // additionally, we ask Nepomuk directly, to get hits that
-      // did not come in through Akonadi
-      startNepomukSearch();
+        if (!m_delayedQueryTimer.isActive())
+            m_delayedQueryTimer.start(500);
     } else {
       // If Nepomuk is not available, we instead simply fetch
       // all contacts from Akonadi and filter them ourselves.
diff --git a/libkdepim/addresseelineedit.h b/libkdepim/addresseelineedit.h
index a195d85..4e6784b 100644
--- a/libkdepim/addresseelineedit.h
+++ b/libkdepim/addresseelineedit.h
@@ -198,6 +198,7 @@ class KDEPIM_EXPORT AddresseeLineEdit : public KLineEdit
     Q_PRIVATE_SLOT( d, void slotAkonadiCollectionsReceived( const Akonadi::Collection::List & ) )
     Q_PRIVATE_SLOT( d, void slotNepomukHits( const QList<Nepomuk2::Query::Result>& ) )
     Q_PRIVATE_SLOT( d, void slotNepomukSearchFinished() )
+    Q_PRIVATE_SLOT( d, void slotTriggerDelayedQueries() )
     //@endcond
 };
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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