diff options
| author | Vishesh Handa <[email protected]> | 2013-05-06 18:41:21 +0530 |
|---|---|---|
| committer | Vishesh Handa <[email protected]> | 2013-05-07 01:36:37 +0530 |
| commit | 38bb5f1547e2a18d40a01fabf9b4478f5fe66130 (patch) | |
| tree | 9a3b4f69e52949376d9e90090cc5a902854aba06 /src | |
| parent | ff3b009e68f485a1a65a7535b01eeeb7128463d2 (diff) | |
Dolphin Places: React to Nepomuk system changes
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/kitemviews/kstandarditemmodel.cpp | 9 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemmodel.h | 1 | ||||
| -rw-r--r-- | src/panels/places/placesitemmodel.cpp | 40 | ||||
| -rw-r--r-- | src/panels/places/placesitemmodel.h | 3 |
4 files changed, 52 insertions, 1 deletions
diff --git a/src/kitemviews/kstandarditemmodel.cpp b/src/kitemviews/kstandarditemmodel.cpp index dbf608c92..959d62cb8 100644 --- a/src/kitemviews/kstandarditemmodel.cpp +++ b/src/kitemviews/kstandarditemmodel.cpp @@ -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()) { diff --git a/src/kitemviews/kstandarditemmodel.h b/src/kitemviews/kstandarditemmodel.h index 34032bf07..0debd6a6f 100644 --- a/src/kitemviews/kstandarditemmodel.h +++ b/src/kitemviews/kstandarditemmodel.h @@ -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 diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 1acbb5771..caf6b7566 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -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' ]]" diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h index e42187860..693836033 100644 --- a/src/panels/places/placesitemmodel.h +++ b/src/panels/places/placesitemmodel.h @@ -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; |
