]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/places/placesitemmodel.cpp
Merge remote-tracking branch 'origin/KDE/4.10'
[dolphin.git] / src / panels / places / placesitemmodel.cpp
index 31285aea285b1a75dc54eb6297e30706ba47c773..eae2095c994ff37fe78fb8dc9a82a1be2cdda644 100644 (file)
@@ -88,9 +88,13 @@ 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", false);
+        m_fileIndexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
     }
 
 #endif
@@ -440,6 +444,11 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
                 text = url.host();
             }
 
+            if (url.isLocalFile() && !QFileInfo(url.toLocalFile()).isDir()) {
+                // Only directories are allowed
+                continue;
+            }
+
             PlacesItem* newItem = createPlacesItem(text, url);
             const int dropIndex = groupedDropIndex(index, newItem);
             insertItem(dropIndex, newItem);
@@ -578,14 +587,14 @@ void PlacesItemModel::slotDeviceRemoved(const QString& udi)
             delete item;
             return;
         }
-     }
-
-     for (int i = 0; i < count(); ++i) {
-         if (placesItem(i)->udi() == udi) {
-             removeItem(i);
-             return;
-         }
-     }
+    }
+
+    for (int i = 0; i < count(); ++i) {
+        if (placesItem(i)->udi() == udi) {
+            removeItem(i);
+            return;
+        }
+    }
 }
 
 void PlacesItemModel::slotStorageTeardownDone(Solid::ErrorType error, const QVariant& errorData)
@@ -608,17 +617,13 @@ void PlacesItemModel::slotStorageSetupDone(Solid::ErrorType error,
     }
 
     if (error) {
-        // TODO: Request message-freeze exception
         if (errorData.isValid()) {
-        //    emit errorMessage(i18nc("@info", "An error occurred while accessing '%1', the system responded: %2",
-        //                            item->text(),
-        //                            errorData.toString()));
-            emit errorMessage(QString("An error occurred while accessing '%1', the system responded: %2")
-                              .arg(item->text()).arg(errorData.toString()));
+            emit errorMessage(i18nc("@info", "An error occurred while accessing '%1', the system responded: %2",
+                                    item->text(),
+                                    errorData.toString()));
         } else {
-        //    emit errorMessage(i18nc("@info", "An error occurred while accessing '%1'",
-        //                            item->text()));
-            emit errorMessage(QString("An error occurred while accessing '%1'").arg(item->text()));
+            emit errorMessage(i18nc("@info", "An error occurred while accessing '%1'",
+                                    item->text()));
         }
         emit storageSetupDone(index, false);
     } else {
@@ -949,6 +954,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' ]]"