X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1d9d83b4342031c94a55cc4e6b73ade461b7c17d..51b978f7fd7ed02b509f34f2579bf016f78bc5e0:/src/panels/places/placesitemmodel.cpp diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 31285aea2..eae2095c9 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -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' ]]"