]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Dolphin Places: React to Nepomuk system changes
authorVishesh Handa <me@vhanda.in>
Mon, 6 May 2013 13:11:21 +0000 (18:41 +0530)
committerVishesh Handa <me@vhanda.in>
Mon, 6 May 2013 20:06:37 +0000 (01:36 +0530)
Reload the places panel when Nepomuk starts up and shutsdown. This way
the user does not need to restart Dolphin to see the custom searches and
places after Nepomuk switches on.

BUG: 304918
REVIEW: 110323

src/kitemviews/kstandarditemmodel.cpp
src/kitemviews/kstandarditemmodel.h
src/panels/places/placesitemmodel.cpp
src/panels/places/placesitemmodel.h

index dbf608c92734fc8fa9808849030499675425443c..959d62cb8ad55a643f9263c25ea1c97570489d41 100644 (file)
@@ -122,6 +122,15 @@ void KStandardItemModel::removeItem(int index)
     }
 }
 
+void KStandardItemModel::clear()
+{
+    int size = m_items.size();
+    m_items.clear();
+    m_indexesForItems.clear();
+
+    emit itemsRemoved(KItemRangeList() << KItemRange(0, size));
+}
+
 KStandardItem* KStandardItemModel::item(int index) const
 {
     if (index < 0 || index >= m_items.count()) {
index 34032bf07319fde4814612e3f0a976664dee623b..0debd6a6fccc3e5c6a78b62f374fce3012e3ee7b 100644 (file)
@@ -78,6 +78,7 @@ public:
     virtual QString roleDescription(const QByteArray& role) const;
     virtual QList<QPair<int, QVariant> > groups() const;
 
+    virtual void clear();
 protected:
     /**
      * Is invoked after an item has been inserted and before the signal
index 1acbb57719c3a109f94e5aabec8b6b82d3319d3e..caf6b75662c4953fce522d86faf4f8dbfba0fe1e 100644 (file)
@@ -88,7 +88,11 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
     m_storageSetupInProgress()
 {
 #ifdef HAVE_NEPOMUK
-    if (Nepomuk2::ResourceManager::instance()->initialized()) {
+    Nepomuk2::ResourceManager* rm = Nepomuk2::ResourceManager::instance();
+    connect(rm, SIGNAL(nepomukSystemStarted()), this, SLOT(slotNepomukStarted()));
+    connect(rm, SIGNAL(nepomukSystemStopped()), this, SLOT(slotNepomukStopped()));
+
+    if (rm->initialized()) {
         KConfig config("nepomukserverrc");
         m_fileIndexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
     }
@@ -949,6 +953,40 @@ void PlacesItemModel::createSystemBookmarks()
     }
 }
 
+void PlacesItemModel::clear() {
+    m_bookmarkedItems.clear();
+    KStandardItemModel::clear();
+}
+
+void PlacesItemModel::slotNepomukStarted()
+{
+    KConfig config("nepomukserverrc");
+    m_fileIndexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
+    if (m_fileIndexingEnabled) {
+        m_systemBookmarks.clear();
+        m_systemBookmarksIndexes.clear();
+        createSystemBookmarks();
+
+        clear();
+        loadBookmarks();
+    }
+}
+
+void PlacesItemModel::slotNepomukStopped()
+{
+    if (m_fileIndexingEnabled) {
+        m_fileIndexingEnabled = false;
+
+        m_systemBookmarks.clear();
+        m_systemBookmarksIndexes.clear();
+        createSystemBookmarks();
+
+        clear();
+        loadBookmarks();
+    }
+}
+
+
 void PlacesItemModel::initializeAvailableDevices()
 {
     QString predicate("[[[[ StorageVolume.ignored == false AND [ StorageVolume.usage == 'FileSystem' OR StorageVolume.usage == 'Encrypted' ]]"
index e42187860f5641f8af1e21566ea053fccb8d44d2..693836033265e2978f6981d9a10b05d37ef117ff 100644 (file)
@@ -133,6 +133,7 @@ public:
      */
     static KUrl convertedUrl(const KUrl& url);
 
+    virtual void clear();
 signals:
     void errorMessage(const QString& message);
     void storageSetupDone(int index, bool success);
@@ -163,6 +164,8 @@ private slots:
      */
     void saveBookmarks();
 
+    void slotNepomukStarted();
+    void slotNepomukStopped();
 private:
     struct SystemBookmarkData;