diff --git a/dolphin/src/CMakeLists.txt b/dolphin/src/CMakeLists.txt index fb8a30b42a..226f5794db 100644 --- a/dolphin/src/CMakeLists.txt +++ b/dolphin/src/CMakeLists.txt @@ -1,37 +1,36 @@ -macro_optional_find_package(NepomukCore) -set_package_properties(NepomukCore PROPERTIES DESCRIPTION "Nepomuk Core libraries" +macro_optional_find_package(Baloo) +set_package_properties(Baloo PROPERTIES DESCRIPTION "Baloo Core libraries" URL "http://www.kde.org" TYPE OPTIONAL - PURPOSE "For adding desktop-wide tagging support to dolphin" + PURPOSE "For adding desktop-wide search and tagging support to dolphin" ) -macro_optional_find_package(NepomukWidgets) -set_package_properties(NepomukWidgets PROPERTIES DESCRIPTION "Nepomuk Widgets" +macro_optional_find_package(BalooWidgets) +set_package_properties(BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets" URL "http://www.kde.org" TYPE OPTIONAL - PURPOSE "For adding desktop-wide tagging support to dolphin" ) -if(NepomukCore_FOUND AND NepomukWidgets_FOUND) - set(HAVE_NEPOMUK TRUE) +macro_optional_find_package(KFileMetaData) +set_package_properties(KFileMetaData PROPERTIES + URL "https://projects.kde.org/kfilemetadata" + TYPE OPTIONAL + PURPOSE "For accessing file metadata labels" + ) + +if (Baloo_FOUND AND BalooWidgets_FOUND AND KFileMetaData_FOUND) + set(HAVE_BALOO TRUE) endif() -configure_file(config-nepomuk.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-nepomuk.h ) +configure_file(config-baloo.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-baloo.h ) macro_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER) configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h ) -include_directories( ${KACTIVITIES_INCLUDE_DIRS} ) +include_directories( ${KACTIVITIES_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ) -if(HAVE_NEPOMUK) - find_package(Soprano 2.7.56) - set_package_properties(Soprano PROPERTIES DESCRIPTION "Qt-based RDF storage and parsing solution" - URL "http://soprano.sourceforge.net" - TYPE REQUIRED - PURPOSE "Required for everything (storage and general data management)" - ) - - include_directories( ${SOPRANO_INCLUDE_DIR} ${NEPOMUK_CORE_INCLUDE_DIR} ${NEPOMUK_WIDGETS_INCLUDE_DIR} ) +if(HAVE_BALOO) + include_directories(${BALOO_INCLUDE_DIR} ${BALOO_WIDGETS_INCLUDE_DIR}) endif() add_subdirectory(tests) @@ -98,10 +97,10 @@ set(dolphinprivate_LIB_SRCS dolphinnewfilemenu.cpp ) -if(HAVE_NEPOMUK) +if(HAVE_BALOO) set(dolphinprivate_LIB_SRCS ${dolphinprivate_LIB_SRCS} - kitemviews/private/knepomukrolesprovider.cpp + kitemviews/private/kbaloorolesprovider.cpp ) endif() @@ -123,12 +122,12 @@ target_link_libraries( ${KDE4_KNEWSTUFF3_LIBS} ) -if(HAVE_NEPOMUK) +if(HAVE_BALOO) target_link_libraries( dolphinprivate - ${NEPOMUK_CORE_LIBRARY} - ${NEPOMUK_WIDGETS_LIBRARY} - ${SOPRANO_LIBRARIES} + ${BALOO_LIBRARIES} + ${BALOO_WIDGETS_LIBRARY} + ${KFILEMETADATA_LIBRARY} ) endif() @@ -193,7 +192,6 @@ set(dolphin_SRCS panels/folders/folderspanel.cpp search/dolphinfacetswidget.cpp search/dolphinsearchbox.cpp - search/dolphinsearchinformation.cpp settings/general/behaviorsettingspage.cpp settings/general/configurepreviewplugindialog.cpp settings/general/confirmationssettingspage.cpp @@ -249,11 +247,10 @@ target_link_libraries(kdeinit_dolphin ${KDE4_PHONON_LIBS} ) -if(HAVE_NEPOMUK) +if(HAVE_BALOO) target_link_libraries(kdeinit_dolphin - ${NEPOMUK_CORE_LIBRARY} - ${NEPOMUK_WIDGETS_LIBRARY} - ${SOPRANO_LIBRARIES} + ${BALOO_LIBRARIES} + ${BALOO_WIDGETS_LIBRARY} ) endif() @@ -326,12 +323,6 @@ target_link_libraries(kcm_dolphinviewmodes ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS target_link_libraries(kcm_dolphinnavigation ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} dolphinprivate) target_link_libraries(kcm_dolphinservices ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KNEWSTUFF3_LIBRARY} dolphinprivate) target_link_libraries(kcm_dolphingeneral ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS} dolphinprivate) -if(HAVE_NEPOMUK) - target_link_libraries(kcm_dolphinviewmodes ${NEPOMUK_CORE_LIBRARY} ${NEPOMUK_WIDGETS_LIBRARY}) - target_link_libraries(kcm_dolphinnavigation ${NEPOMUK_CORE_LIBRARY} ${NEPOMUK_WIDGETS_LIBRARY}) - target_link_libraries(kcm_dolphinservices ${NEPOMUK_CORE_LIBRARY} ${NEPOMUK_WIDGETS_LIBRARY}) - target_link_libraries(kcm_dolphingeneral ${NEPOMUK_CORE_LIBRARY} ${NEPOMUK_WIDGETS_LIBRARY}) -endif() install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} ) diff --git a/dolphin/src/config-baloo.h.cmake b/dolphin/src/config-baloo.h.cmake new file mode 100644 index 0000000000..ad95b2f078 --- /dev/null +++ b/dolphin/src/config-baloo.h.cmake @@ -0,0 +1 @@ +#cmakedefine HAVE_BALOO diff --git a/dolphin/src/config-nepomuk.h.cmake b/dolphin/src/config-nepomuk.h.cmake deleted file mode 100644 index fe7364f603..0000000000 --- a/dolphin/src/config-nepomuk.h.cmake +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine HAVE_NEPOMUK diff --git a/dolphin/src/dolphinmainwindow.h b/dolphin/src/dolphinmainwindow.h index 6b046c2ea0..cb976129f3 100644 --- a/dolphin/src/dolphinmainwindow.h +++ b/dolphin/src/dolphinmainwindow.h @@ -22,7 +22,7 @@ #ifndef DOLPHIN_MAINWINDOW_H #define DOLPHIN_MAINWINDOW_H -#include +#include #include #include diff --git a/dolphin/src/dolphinviewcontainer.cpp b/dolphin/src/dolphinviewcontainer.cpp index cc26198a0f..768fd5ef90 100644 --- a/dolphin/src/dolphinviewcontainer.cpp +++ b/dolphin/src/dolphinviewcontainer.cpp @@ -455,7 +455,7 @@ void DolphinViewContainer::slotDirectoryLoadingCompleted() } if (isSearchUrl(url()) && m_view->itemsCount() == 0) { - // The dir lister has been completed on a Nepomuk-URI and no items have been found. Instead + // The dir lister has been completed on a Baloo-URI and no items have been found. Instead // of showing the default status bar information ("0 items") a more helpful information is given: m_statusBar->setText(i18nc("@info:status", "No items found.")); } else { @@ -708,7 +708,7 @@ void DolphinViewContainer::showErrorMessage(const QString& msg) bool DolphinViewContainer::isSearchUrl(const KUrl& url) const { const QString protocol = url.protocol(); - return protocol.contains("search") || (protocol == QLatin1String("nepomuk")); + return protocol.contains("search"); } void DolphinViewContainer::saveViewState() diff --git a/dolphin/src/dolphinviewcontainer.h b/dolphin/src/dolphinviewcontainer.h index e5597ccc61..31612f10af 100644 --- a/dolphin/src/dolphinviewcontainer.h +++ b/dolphin/src/dolphinviewcontainer.h @@ -317,7 +317,7 @@ private slots: private: /** - * @return True if the URL protocol is a search URL (e. g. nepomuksearch:// or filenamesearch://). + * @return True if the URL protocol is a search URL (e. g. baloosearch:// or filenamesearch://). */ bool isSearchUrl(const KUrl& url) const; diff --git a/dolphin/src/kitemviews/kfileitemmodel.cpp b/dolphin/src/kitemviews/kfileitemmodel.cpp index b3c56e1c63..734950257a 100644 --- a/dolphin/src/kitemviews/kfileitemmodel.cpp +++ b/dolphin/src/kitemviews/kfileitemmodel.cpp @@ -673,7 +673,7 @@ QList KFileItemModel::rolesInformation() // menus tries to put the actions into sub menus otherwise. info.group = QString(); } - info.requiresNepomuk = map[i].requiresNepomuk; + info.requiresBaloo = map[i].requiresBaloo; info.requiresIndexer = map[i].requiresIndexer; rolesInfo.append(info); } @@ -2081,7 +2081,7 @@ void KFileItemModel::emitSortProgress(int resolvedCount) const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count) { static const RoleInfoMap rolesInfoMap[] = { - // | role | roleType | role translation | group translation | requires Nepomuk | requires indexer + // | role | roleType | role translation | group translation | requires Baloo | requires indexer { 0, NoRole, 0, 0, 0, 0, false, false }, { "text", NameRole, I18N_NOOP2_NOSTRIP("@label", "Name"), 0, 0, false, false }, { "size", SizeRole, I18N_NOOP2_NOSTRIP("@label", "Size"), 0, 0, false, false }, diff --git a/dolphin/src/kitemviews/kfileitemmodel.h b/dolphin/src/kitemviews/kfileitemmodel.h index 0224290238..15f4b67d3d 100644 --- a/dolphin/src/kitemviews/kfileitemmodel.h +++ b/dolphin/src/kitemviews/kfileitemmodel.h @@ -187,14 +187,14 @@ public: { QByteArray role; QString translation; QString group; - bool requiresNepomuk; + bool requiresBaloo; bool requiresIndexer; }; /** * @return Provides static information for all available roles that * are supported by KFileItemModel. Some roles can only be - * determined if Nepomuk is enabled and/or the Nepomuk + * determined if Baloo is enabled and/or the Baloo * indexing is enabled. */ static QList rolesInformation(); @@ -287,7 +287,7 @@ private: // User visible roles: NoRole, NameRole, SizeRole, DateRole, PermissionsRole, OwnerRole, GroupRole, TypeRole, DestinationRole, PathRole, - // User visible roles available with Nepomuk: + // User visible roles available with Baloo: CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole, WordCountRole, LineCountRole, ArtistRole, AlbumRole, DurationRole, TrackRole, CopiedFromRole, @@ -432,7 +432,7 @@ private: const char* const roleTranslation; const char* const groupTranslationContext; const char* const groupTranslation; - const bool requiresNepomuk; + const bool requiresBaloo; const bool requiresIndexer; }; diff --git a/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp b/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp index f11d5a5d30..0865d40e72 100644 --- a/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/dolphin/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -40,10 +40,11 @@ #include -#ifdef HAVE_NEPOMUK - #include "private/knepomukrolesprovider.h" - #include - #include +#ifdef HAVE_BALOO + #include "private/kbaloorolesprovider.h" + #include + #include + #include #endif // #define KFILEITEMMODELROLESUPDATER_DEBUG @@ -88,9 +89,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO m_recentlyChangedItems(), m_changedItems(), m_directoryContentsCounter(0) - #ifdef HAVE_NEPOMUK - , m_nepomukResourceWatcher(0), - m_nepomukUriItems() + #ifdef HAVE_BALOO + , m_balooFileMonitor(0) #endif { Q_ASSERT(model); @@ -122,8 +122,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO m_resolvableRoles.insert("size"); m_resolvableRoles.insert("type"); m_resolvableRoles.insert("isExpandable"); -#ifdef HAVE_NEPOMUK - m_resolvableRoles += KNepomukRolesProvider::instance().roles(); +#ifdef HAVE_BALOO + m_resolvableRoles += KBalooRolesProvider::instance().roles(); #endif m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this); @@ -262,34 +262,29 @@ void KFileItemModelRolesUpdater::setRoles(const QSet& roles) if (m_roles != roles) { m_roles = roles; -#ifdef HAVE_NEPOMUK - if (Nepomuk2::ResourceManager::instance()->initialized()) { - // Check whether there is at least one role that must be resolved - // with the help of Nepomuk. If this is the case, a (quite expensive) - // resolving will be done in KFileItemModelRolesUpdater::rolesData() and - // the role gets watched for changes. - const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance(); - bool hasNepomukRole = false; - QSetIterator it(roles); - while (it.hasNext()) { - const QByteArray& role = it.next(); - if (rolesProvider.roles().contains(role)) { - hasNepomukRole = true; - break; - } +#ifdef HAVE_BALOO + // Check whether there is at least one role that must be resolved + // with the help of Baloo. If this is the case, a (quite expensive) + // resolving will be done in KFileItemModelRolesUpdater::rolesData() and + // the role gets watched for changes. + const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance(); + bool hasBalooRole = false; + QSetIterator it(roles); + while (it.hasNext()) { + const QByteArray& role = it.next(); + if (rolesProvider.roles().contains(role)) { + hasBalooRole = true; + break; } + } - if (hasNepomukRole && !m_nepomukResourceWatcher) { - Q_ASSERT(m_nepomukUriItems.isEmpty()); - - m_nepomukResourceWatcher = new Nepomuk2::ResourceWatcher(this); - connect(m_nepomukResourceWatcher, SIGNAL(propertyChanged(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariantList,QVariantList)), - this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource,Nepomuk2::Types::Property))); - } else if (!hasNepomukRole && m_nepomukResourceWatcher) { - delete m_nepomukResourceWatcher; - m_nepomukResourceWatcher = 0; - m_nepomukUriItems.clear(); - } + if (hasBalooRole && !m_balooFileMonitor) { + m_balooFileMonitor = new Baloo::FileMonitor(this); + connect(m_balooFileMonitor, SIGNAL(fileMetaDataChanged(QString)), + this, SLOT(applyChangedBalooRoles(QString))); + } else if (!hasBalooRole && m_balooFileMonitor) { + delete m_balooFileMonitor; + m_balooFileMonitor = 0; } #endif @@ -357,30 +352,19 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang const bool allItemsRemoved = (m_model->count() == 0); -#ifdef HAVE_NEPOMUK - if (m_nepomukResourceWatcher) { - // Don't let the ResourceWatcher watch for removed items +#ifdef HAVE_BALOO + if (m_balooFileMonitor) { + // Don't let the FileWatcher watch for removed items if (allItemsRemoved) { - m_nepomukResourceWatcher->setResources(QList()); - m_nepomukResourceWatcher->stop(); - m_nepomukUriItems.clear(); + m_balooFileMonitor->clear(); } else { - QList newResources; - const QList oldResources = m_nepomukResourceWatcher->resources(); - foreach (const Nepomuk2::Resource& resource, oldResources) { - const QUrl uri = resource.uri(); - const KUrl itemUrl = m_nepomukUriItems.value(uri); + QStringList newFileList; + foreach (const QString& itemUrl, m_balooFileMonitor->files()) { if (m_model->index(itemUrl) >= 0) { - newResources.append(resource); - } else { - m_nepomukUriItems.remove(uri); + newFileList.append(itemUrl); } } - m_nepomukResourceWatcher->setResources(newResources); - if (newResources.isEmpty()) { - Q_ASSERT(m_nepomukUriItems.isEmpty()); - m_nepomukResourceWatcher->stop(); - } + m_balooFileMonitor->setFiles(newFileList); } } #endif @@ -708,14 +692,9 @@ void KFileItemModelRolesUpdater::resolveRecentlyChangedItems() updateChangedItems(); } -void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resource& resource, const Nepomuk2::Types::Property& property) +void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl) { -#ifdef HAVE_NEPOMUK - if (!Nepomuk2::ResourceManager::instance()->initialized()) { - return; - } - - const KUrl itemUrl = m_nepomukUriItems.value(resource.uri()); +#ifdef HAVE_BALOO const KFileItem item = m_model->fileItem(itemUrl); if (item.isNull()) { @@ -724,18 +703,34 @@ void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resour return; } - QHash data = rolesData(item); + Baloo::FileFetchJob* job = new Baloo::FileFetchJob(item.localPath()); + connect(job, SIGNAL(finished(KJob*)), this, SLOT(applyChangedBalooRolesJobFinished(KJob*))); + job->setProperty("item", QVariant::fromValue(item)); + job->start(); +#else +#ifndef Q_CC_MSVC + Q_UNUSED(itemUrl); +#endif +#endif +} - const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance(); - const QByteArray role = rolesProvider.roleForPropertyUri(property.uri()); - if (!role.isEmpty() && m_roles.contains(role)) { - // Overwrite the changed role value with an empty QVariant, because the roles +void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob) +{ +#ifdef HAVE_BALOO + const KFileItem item = kjob->property("item").value(); + + const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance(); + QHash data; + + foreach (const QByteArray& role, rolesProvider.roles()) { + // Overwrite all the role values with an empty QVariant, because the roles // provider doesn't overwrite it when the property value list is empty. // See bug 322348 data.insert(role, QVariant()); } - QHashIterator it(rolesProvider.roleValues(resource, m_roles)); + Baloo::FileFetchJob* job = static_cast(kjob); + QHashIterator it(rolesProvider.roleValues(job->file(), m_roles)); while (it.hasNext()) { it.next(); data.insert(it.key(), it.value()); @@ -747,10 +742,6 @@ void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resour m_model->setData(index, data); connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet)), this, SLOT(slotItemsChanged(KItemRangeList,QSet))); -#else -#ifndef Q_CC_MSVC - Q_UNUSED(resource); -#endif #endif } @@ -762,7 +753,6 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin if (getSizeRole || getIsExpandableRole) { const int index = m_model->index(KUrl(path)); if (index >= 0) { - QHash data; if (getSizeRole) { @@ -1004,7 +994,7 @@ void KFileItemModelRolesUpdater::applySortRole(int index) const QString path = item.localPath(); data.insert("size", m_directoryContentsCounter->countDirectoryContentsSynchronously(path)); } else { - // Probably the sort role is a Nepomuk role - just determine all roles. + // Probably the sort role is a baloo role - just determine all roles. data = rolesData(item); } @@ -1087,35 +1077,12 @@ QHash KFileItemModelRolesUpdater::rolesData(const KFileIte data.insert("iconOverlays", item.overlays()); -#ifdef HAVE_NEPOMUK - if (m_nepomukResourceWatcher) { - const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance(); - Nepomuk2::Resource resource(item.nepomukUri()); - QHashIterator it(rolesProvider.roleValues(resource, m_roles)); - while (it.hasNext()) { - it.next(); - data.insert(it.key(), it.value()); - } - - QUrl uri = resource.uri(); - if (uri.isEmpty()) { - // TODO: Is there another way to explicitly create a resource? - // We need a resource to be able to track it for changes. - resource.setRating(0); - uri = resource.uri(); - } - if (!uri.isEmpty() && !m_nepomukUriItems.contains(uri)) { - m_nepomukResourceWatcher->addResource(resource); - - if (m_nepomukUriItems.isEmpty()) { - m_nepomukResourceWatcher->start(); - } - - m_nepomukUriItems.insert(uri, item.url()); - } +#ifdef HAVE_BALOO + if (m_balooFileMonitor) { + m_balooFileMonitor->addFile(item.localPath()); + applyChangedBalooRoles(item.localPath()); } #endif - return data; } diff --git a/dolphin/src/kitemviews/kfileitemmodelrolesupdater.h b/dolphin/src/kitemviews/kfileitemmodelrolesupdater.h index 19207575ed..a9e979ae18 100644 --- a/dolphin/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/dolphin/src/kitemviews/kfileitemmodelrolesupdater.h @@ -20,7 +20,7 @@ #ifndef KFILEITEMMODELROLESUPDATER_H #define KFILEITEMMODELROLESUPDATER_H -#include +#include #include #include @@ -38,26 +38,10 @@ class KJob; class QPixmap; class QTimer; -#ifdef HAVE_NEPOMUK - namespace Nepomuk2 +#ifdef HAVE_BALOO + namespace Baloo { - class ResourceWatcher; - class Resource; - namespace Types - { - class Property; - } - } -#else - // Required for the slot applyChangedNepomukRoles() that - // cannot be ifdefined due to moc. - namespace Nepomuk2 - { - class Resource; - namespace Types - { - class Property; - } + class FileMonitor; } #endif @@ -216,7 +200,8 @@ private slots: */ void resolveRecentlyChangedItems(); - void applyChangedNepomukRoles(const Nepomuk2::Resource& resource, const Nepomuk2::Types::Property& property); + void applyChangedBalooRoles(const QString& file); + void applyChangedBalooRolesJobFinished(KJob* job); void slotDirectoryContentsCountReceived(const QString& path, int count); @@ -346,9 +331,8 @@ private: KDirectoryContentsCounter* m_directoryContentsCounter; -#ifdef HAVE_NEPOMUK - Nepomuk2::ResourceWatcher* m_nepomukResourceWatcher; - mutable QHash m_nepomukUriItems; +#ifdef HAVE_BALOO + Baloo::FileMonitor* m_balooFileMonitor; #endif }; diff --git a/dolphin/src/kitemviews/private/kbaloorolesprovider.cpp b/dolphin/src/kitemviews/private/kbaloorolesprovider.cpp new file mode 100644 index 0000000000..c0ae0c5441 --- /dev/null +++ b/dolphin/src/kitemviews/private/kbaloorolesprovider.cpp @@ -0,0 +1,184 @@ +/*************************************************************************** + * Copyright (C) 2012 by Peter Penz * + * Copyright (C) 2013 by Vishesh Handa * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "kbaloorolesprovider.h" + +#include +#include +#include + +#include +#include + +#include +#include + +struct KBalooRolesProviderSingleton +{ + KBalooRolesProvider instance; +}; +K_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider) + + +KBalooRolesProvider& KBalooRolesProvider::instance() +{ + return s_balooRolesProvider->instance; +} + +KBalooRolesProvider::~KBalooRolesProvider() +{ +} + +QSet KBalooRolesProvider::roles() const +{ + return m_roles; +} + +QHash KBalooRolesProvider::roleValues(const Baloo::File& file, + const QSet& roles) const +{ + QHash values; + + int width = -1; + int height = -1; + + QMapIterator it(file.properties()); + while (it.hasNext()) { + it.next(); + + const KFileMetaData::PropertyInfo pi(it.key()); + const QString property = pi.name(); + const QByteArray role = roleForProperty(property); + if (role.isEmpty() || !roles.contains(role)) { + continue; + } + + const QVariant value = it.value(); + + if (role == "imageSize") { + // Merge the two properties for width and height + // as one string into the "imageSize" role + if (property == QLatin1String("width")) { + width = value.toInt(); + } + else if (property == QLatin1String("height")) { + height = value.toInt(); + } + + if (width >= 0 && height >= 0) { + QString widthAndHeight = QString::number(width); + widthAndHeight += QLatin1String(" x "); + widthAndHeight += QString::number(height); + values.insert(role, widthAndHeight); + } + } else if (role == "orientation") { + const QString orientation = orientationFromValue(value.toInt()); + values.insert(role, orientation); + } else if (role == "duration") { + const QString duration = durationFromValue(value.toInt()); + values.insert(role, duration); + } else { + values.insert(role, value.toString()); + } + } + + if (roles.contains("tags")) { + values.insert("tags", tagsFromValues(file.tags())); + } + if (roles.contains("rating")) { + values.insert("rating", QString::number(file.rating())); + } + if (roles.contains("comment")) { + values.insert("comment", file.userComment()); + } + + return values; +} + +QByteArray KBalooRolesProvider::roleForProperty(const QString& property) const +{ + return m_roleForProperty.value(property); +} + +KBalooRolesProvider::KBalooRolesProvider() : + m_roles(), + m_roleForProperty() +{ + struct PropertyInfo + { + const char* const property; + const char* const role; + }; + + // Mapping from the URIs to the KFileItemModel roles. Note that this must not be + // a 1:1 mapping: One role may contain several URI-values (e.g. the URIs for height and + // width of an image are mapped to the role "imageSize") + static const PropertyInfo propertyInfoList[] = { + { "rating", "rating" }, + { "tag", "tags" }, + { "comment", "comment" }, + { "wordCount", "wordCount" }, + { "lineCount", "lineCount" }, + { "width", "imageSize" }, + { "height", "imageSize" }, + { "nexif.orientation", "orientation", }, + { "artist", "artist" }, + { "album", "album" }, + { "duration", "duration" }, + { "trackNumber", "track" } + // { "http://www.semanticdesktop.org/ontologies/2010/04/30/ndo#copiedFrom", "copiedFrom" } + }; + + for (unsigned int i = 0; i < sizeof(propertyInfoList) / sizeof(PropertyInfo); ++i) { + m_roleForProperty.insert(propertyInfoList[i].property, propertyInfoList[i].role); + m_roles.insert(propertyInfoList[i].role); + } +} + +QString KBalooRolesProvider::tagsFromValues(const QStringList& values) const +{ + return values.join(", "); +} + +QString KBalooRolesProvider::orientationFromValue(int value) const +{ + QString string; + switch (value) { + case 1: string = i18nc("@item:intable Image orientation", "Unchanged"); break; + case 2: string = i18nc("@item:intable Image orientation", "Horizontally flipped"); break; + case 3: string = i18nc("@item:intable image orientation", "180° rotated"); break; + case 4: string = i18nc("@item:intable image orientation", "Vertically flipped"); break; + case 5: string = i18nc("@item:intable image orientation", "Transposed"); break; + case 6: string = i18nc("@item:intable image orientation", "90° rotated"); break; + case 7: string = i18nc("@item:intable image orientation", "Transversed"); break; + case 8: string = i18nc("@item:intable image orientation", "270° rotated"); break; + default: + break; + } + return string; +} + +QString KBalooRolesProvider::durationFromValue(int value) const +{ + QTime duration; + duration = duration.addSecs(value); + return duration.toString("hh:mm:ss"); +} + diff --git a/dolphin/src/kitemviews/private/knepomukrolesprovider.h b/dolphin/src/kitemviews/private/kbaloorolesprovider.h similarity index 79% rename from dolphin/src/kitemviews/private/knepomukrolesprovider.h rename to dolphin/src/kitemviews/private/kbaloorolesprovider.h index 68a4027e15..f1ad5c7407 100644 --- a/dolphin/src/kitemviews/private/knepomukrolesprovider.h +++ b/dolphin/src/kitemviews/private/kbaloorolesprovider.h @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2012 by Peter Penz * + * Copyright (C) 2013 by Vishesh Handa * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -17,8 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#ifndef KNEPOMUKROLESPROVIDER_H -#define KNEPOMUKROLESPROVIDER_H +#ifndef KBALOO_ROLESPROVIDER_H +#define KBALOO_ROLESPROVIDER_H #include @@ -26,25 +27,24 @@ #include #include -namespace Nepomuk2 -{ - class Resource; +namespace Baloo { + class File; } /** * @brief Allows accessing metadata of a file by providing KFileItemModel roles. * * Is a helper class for KFileItemModelRolesUpdater to retrieve roles that - * are only accessible with Nepomuk. + * are only accessible with Baloo. */ -class LIBDOLPHINPRIVATE_EXPORT KNepomukRolesProvider +class LIBDOLPHINPRIVATE_EXPORT KBalooRolesProvider { public: - static KNepomukRolesProvider& instance(); - virtual ~KNepomukRolesProvider(); + static KBalooRolesProvider& instance(); + virtual ~KBalooRolesProvider(); /** - * @return Roles that can be provided by KNepomukRolesProvider. + * @return Roles that can be provided by KBalooRolesProvider. */ QSet roles() const; @@ -52,13 +52,13 @@ public: * @return Values for the roles \a roles that can be determined from the file * with the URL \a url. */ - QHash roleValues(const Nepomuk2::Resource& resource, + QHash roleValues(const Baloo::File& file, const QSet& roles) const; - QByteArray roleForPropertyUri(const QUrl& uri) const; + QByteArray roleForProperty(const QString& property) const; protected: - KNepomukRolesProvider(); + KBalooRolesProvider(); private: /** @@ -81,9 +81,9 @@ private: private: QSet m_roles; - QHash m_roleForUri; + QHash m_roleForProperty; - friend class KNepomukRolesProviderSingleton; + friend class KBalooRolesProviderSingleton; }; #endif diff --git a/dolphin/src/kitemviews/private/knepomukrolesprovider.cpp b/dolphin/src/kitemviews/private/knepomukrolesprovider.cpp deleted file mode 100644 index e237f948f3..0000000000 --- a/dolphin/src/kitemviews/private/knepomukrolesprovider.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2012 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "knepomukrolesprovider.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include - -struct KNepomukRolesProviderSingleton -{ - KNepomukRolesProvider instance; -}; -K_GLOBAL_STATIC(KNepomukRolesProviderSingleton, s_nepomukRolesProvider) - - -KNepomukRolesProvider& KNepomukRolesProvider::instance() -{ - return s_nepomukRolesProvider->instance; -} - -KNepomukRolesProvider::~KNepomukRolesProvider() -{ -} - -QSet KNepomukRolesProvider::roles() const -{ - return m_roles; -} - -QHash KNepomukRolesProvider::roleValues(const Nepomuk2::Resource& resource, - const QSet& roles) const -{ - if (!resource.isValid()) { - return QHash(); - } - - QHash values; - - int width = -1; - int height = -1; - - QHashIterator it(resource.properties()); - while (it.hasNext()) { - it.next(); - - const Nepomuk2::Types::Property property = it.key(); - const QByteArray role = roleForPropertyUri(property.uri()); - if (role.isEmpty() || !roles.contains(role)) { - continue; - } - - const Nepomuk2::Variant value = it.value(); - - if (role == "imageSize") { - // Merge the two Nepomuk properties for width and height - // as one string into the "imageSize" role - const QString uri = property.uri().toString(); - if (uri.endsWith(QLatin1String("#width"))) { - width = value.toInt(); - } else if (uri.endsWith(QLatin1String("#height"))) { - height = value.toInt(); - } - - if (width >= 0 && height >= 0) { - const QString widthAndHeight = QString::number(width) + - QLatin1String(" x ") + - QString::number(height); - values.insert(role, widthAndHeight); - } - } else if (role == "tags") { - const QString tags = tagsFromValues(value.toStringList()); - values.insert(role, tags); - } else if (role == "orientation") { - const QString orientation = orientationFromValue(value.toInt()); - values.insert(role, orientation); - } else if (role == "duration") { - const QString duration = durationFromValue(value.toInt()); - values.insert(role, duration); - } else if (value.isResource()) { - const Nepomuk2::Resource resource = value.toResource(); - values.insert(role, resource.genericLabel()); - } else if (value.isResourceList()) { - const QList resList = value.toResourceList(); - QStringList strList; - foreach (const Nepomuk2::Resource& res, resList) { - strList << res.genericLabel(); - } - values.insert(role, strList.join(QLatin1String(", "))); - } else { - values.insert(role, value.toString()); - } - } - - return values; -} - -QByteArray KNepomukRolesProvider::roleForPropertyUri(const QUrl& uri) const -{ - return m_roleForUri.value(uri); -} - -KNepomukRolesProvider::KNepomukRolesProvider() : - m_roles(), - m_roleForUri() -{ - struct UriInfo - { - const char* const uri; - const char* const role; - }; - - // Mapping from the URIs to the KFileItemModel roles. Note that this must not be - // a 1:1 mapping: One role may contain several URI-values (e.g. the URIs for height and - // width of an image are mapped to the role "imageSize") - static const UriInfo uriInfoList[] = { - { "http://www.semanticdesktop.org/ontologies/2007/08/15/nao#numericRating", "rating" }, - { "http://www.semanticdesktop.org/ontologies/2007/08/15/nao#hasTag", "tags" }, - { "http://www.semanticdesktop.org/ontologies/2007/08/15/nao#description", "comment" }, - { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#wordCount", "wordCount" }, - { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#lineCount", "lineCount" }, - { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#width", "imageSize" }, - { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#height", "imageSize" }, - { "http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#orientation", "orientation", }, - { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#performer", "artist" }, - { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#musicAlbum", "album" }, - { "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#duration", "duration" }, - { "http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#trackNumber", "track" }, - { "http://www.semanticdesktop.org/ontologies/2010/04/30/ndo#copiedFrom", "copiedFrom" } - }; - - for (unsigned int i = 0; i < sizeof(uriInfoList) / sizeof(UriInfo); ++i) { - m_roleForUri.insert(QUrl(uriInfoList[i].uri), uriInfoList[i].role); - m_roles.insert(uriInfoList[i].role); - } -} - -QString KNepomukRolesProvider::tagsFromValues(const QStringList& values) const -{ - QString tags; - - for (int i = 0; i < values.count(); ++i) { - if (i > 0) { - tags.append(QLatin1String(", ")); - } - - const Nepomuk2::Tag tag(values[i]); - tags += tag.genericLabel(); - } - - return tags; -} - -QString KNepomukRolesProvider::orientationFromValue(int value) const -{ - QString string; - switch (value) { - case 1: string = i18nc("@item:intable Image orientation", "Unchanged"); break; - case 2: string = i18nc("@item:intable Image orientation", "Horizontally flipped"); break; - case 3: string = i18nc("@item:intable image orientation", "180° rotated"); break; - case 4: string = i18nc("@item:intable image orientation", "Vertically flipped"); break; - case 5: string = i18nc("@item:intable image orientation", "Transposed"); break; - case 6: string = i18nc("@item:intable image orientation", "90° rotated"); break; - case 7: string = i18nc("@item:intable image orientation", "Transversed"); break; - case 8: string = i18nc("@item:intable image orientation", "270° rotated"); break; - default: - break; - } - return string; -} - -QString KNepomukRolesProvider::durationFromValue(int value) const -{ - QTime duration; - duration = duration.addSecs(value); - return duration.toString("hh:mm:ss"); -} - diff --git a/dolphin/src/panels/information/filemetadataconfigurationdialog.cpp b/dolphin/src/panels/information/filemetadataconfigurationdialog.cpp index 0d1395b046..4ad9066c4e 100644 --- a/dolphin/src/panels/information/filemetadataconfigurationdialog.cpp +++ b/dolphin/src/panels/information/filemetadataconfigurationdialog.cpp @@ -19,10 +19,10 @@ #include "filemetadataconfigurationdialog.h" -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO #include #else -#include +#include #endif #include @@ -44,10 +44,10 @@ FileMetaDataConfigurationDialog::FileMetaDataConfigurationDialog(QWidget* parent "be shown:"), this); m_descriptionLabel->setWordWrap(true); -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO m_configWidget = new KFileMetaDataConfigurationWidget(this); #else - m_configWidget = new Nepomuk2::FileMetaDataConfigWidget(this); + m_configWidget = new Baloo::FileMetaDataConfigWidget(this); #endif diff --git a/dolphin/src/panels/information/filemetadataconfigurationdialog.h b/dolphin/src/panels/information/filemetadataconfigurationdialog.h index e897d245b7..a3ce9548bb 100644 --- a/dolphin/src/panels/information/filemetadataconfigurationdialog.h +++ b/dolphin/src/panels/information/filemetadataconfigurationdialog.h @@ -22,12 +22,12 @@ #include #include -#include "config-nepomuk.h" +#include "config-baloo.h" -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO class KFileMetaDataConfigurationWidget; #else -namespace Nepomuk2 { +namespace Baloo { class FileMetaDataConfigWidget; } #endif @@ -71,10 +71,10 @@ protected slots: private: QLabel* m_descriptionLabel; -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO KFileMetaDataConfigurationWidget* m_configWidget; #else - Nepomuk2::FileMetaDataConfigWidget* m_configWidget; + Baloo::FileMetaDataConfigWidget* m_configWidget; #endif }; diff --git a/dolphin/src/panels/information/informationpanelcontent.cpp b/dolphin/src/panels/information/informationpanelcontent.cpp index f2f7378d7f..b2dd1582ef 100644 --- a/dolphin/src/panels/information/informationpanelcontent.cpp +++ b/dolphin/src/panels/information/informationpanelcontent.cpp @@ -31,10 +31,10 @@ #include #include -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO #include #else -#include +#include #endif #include @@ -112,10 +112,10 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : const bool previewsShown = InformationPanelSettings::previewsShown(); m_preview->setVisible(previewsShown); -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO m_metaDataWidget = new KFileMetaDataWidget(parent); #else - m_metaDataWidget = new Nepomuk2::FileMetaDataWidget(parent); + m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); #endif m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont()); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); @@ -166,7 +166,7 @@ void InformationPanelContent::showItem(const KFileItem& item) } const KUrl itemUrl = item.url(); - const bool isSearchUrl = itemUrl.protocol().contains("search") && item.nepomukUri().isEmpty(); + const bool isSearchUrl = itemUrl.protocol().contains("search") && item.localPath().isEmpty(); if (!applyPlace(itemUrl)) { setNameLabelText(item.text()); if (isSearchUrl) { @@ -355,7 +355,7 @@ void InformationPanelContent::slotHasVideoChanged(bool hasVideo) void InformationPanelContent::refreshMetaData() { - if (!m_item.isNull() && m_item.nepomukUri().isValid()) { + if (!m_item.isNull()) { showItem(m_item); } } diff --git a/dolphin/src/panels/information/informationpanelcontent.h b/dolphin/src/panels/information/informationpanelcontent.h index cad6b51b0f..67fdf6c5ab 100644 --- a/dolphin/src/panels/information/informationpanelcontent.h +++ b/dolphin/src/panels/information/informationpanelcontent.h @@ -20,7 +20,7 @@ #ifndef INFORMATIONPANELCONTENT_H #define INFORMATIONPANELCONTENT_H -#include "config-nepomuk.h" +#include "config-baloo.h" #include #include #include @@ -38,13 +38,13 @@ class QLabel; class QScrollArea; namespace KIO { - class PreviewJob; + class PreviewJob; } -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO class KFileMetaDataWidget; #else -namespace Nepomuk2 { +namespace Baloo { class FileMetaDataWidget; } #endif @@ -147,10 +147,10 @@ private: PixmapViewer* m_preview; PhononWidget* m_phononWidget; QLabel* m_nameLabel; -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO KFileMetaDataWidget* m_metaDataWidget; #else - Nepomuk2::FileMetaDataWidget* m_metaDataWidget; + Baloo::FileMetaDataWidget* m_metaDataWidget; #endif QScrollArea* m_metaDataArea; diff --git a/dolphin/src/panels/places/placesitemmodel.cpp b/dolphin/src/panels/places/placesitemmodel.cpp index 681479dfba..baa770dfdb 100644 --- a/dolphin/src/panels/places/placesitemmodel.cpp +++ b/dolphin/src/panels/places/placesitemmodel.cpp @@ -51,22 +51,17 @@ #include #include -#ifdef HAVE_NEPOMUK - #include - #include - #include - #include - #include - #include - #include +#ifdef HAVE_BALOO + #include + #include #endif namespace { // As long as KFilePlacesView from kdelibs is available in parallel, the // system-bookmarks for "Recently Accessed" and "Search For" should be // shown only inside the Places Panel. This is necessary as the stored - // URLs needs to get translated to a Nepomuk-search-URL on-the-fly to - // be independent from changes in the Nepomuk-search-URL-syntax. + // URLs needs to get translated to a Baloo-search-URL on-the-fly to + // be independent from changes in the Baloo-search-URL-syntax. // Hence a prefix to the application-name of the stored bookmarks is // added, which is only read by PlacesItemModel. const char* AppNamePrefix = "-places-panel"; @@ -87,16 +82,9 @@ PlacesItemModel::PlacesItemModel(QObject* parent) : m_updateBookmarksTimer(0), m_storageSetupInProgress() { -#ifdef HAVE_NEPOMUK - 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); - } - +#ifdef HAVE_BALOO + Baloo::IndexerConfig config; + m_fileIndexingEnabled = config.fileIndexingEnabled(); #endif const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml"); m_bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces"); @@ -959,35 +947,6 @@ void PlacesItemModel::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' ]]" @@ -1145,7 +1104,7 @@ bool PlacesItemModel::equalBookmarkIdentifiers(const KBookmark& b1, const KBookm KUrl PlacesItemModel::createTimelineUrl(const KUrl& url) { - // TODO: Clarify with the Nepomuk-team whether it makes sense + // TODO: Clarify with the Baloo-team whether it makes sense // provide default-timeline-URLs like 'yesterday', 'this month' // and 'last month'. KUrl timelineUrl; @@ -1195,18 +1154,16 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url) { KUrl searchUrl; -#ifdef HAVE_NEPOMUK +#ifdef HAVE_BALOO const QString path = url.pathOrUrl(); if (path.endsWith(QLatin1String("documents"))) { - searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document())); + searchUrl = searchUrlForType("Document"); } else if (path.endsWith(QLatin1String("images"))) { - searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image())); + searchUrl = searchUrlForType("Image"); } else if (path.endsWith(QLatin1String("audio"))) { - searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), - Nepomuk2::Query::LiteralTerm("audio"))); + searchUrl = searchUrlForType("Audio"); } else if (path.endsWith(QLatin1String("videos"))) { - searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), - Nepomuk2::Query::LiteralTerm("video"))); + searchUrl = searchUrlForType("Video"); } else { Q_ASSERT(false); } @@ -1217,10 +1174,13 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url) return searchUrl; } -#ifdef HAVE_NEPOMUK -KUrl PlacesItemModel::searchUrlForTerm(const Nepomuk2::Query::Term& term) +#ifdef HAVE_BALOO +KUrl PlacesItemModel::searchUrlForType(const QString& type) { - const Nepomuk2::Query::FileQuery query(term); + Baloo::Query query; + query.addType("File"); + query.addType(type); + return query.toSearchUrl(); } #endif diff --git a/dolphin/src/panels/places/placesitemmodel.h b/dolphin/src/panels/places/placesitemmodel.h index cd37e73535..4a374e502f 100644 --- a/dolphin/src/panels/places/placesitemmodel.h +++ b/dolphin/src/panels/places/placesitemmodel.h @@ -20,7 +20,7 @@ #ifndef PLACESITEMMODEL_H #define PLACESITEMMODEL_H -#include +#include #include @@ -37,16 +37,6 @@ class PlacesItem; class QAction; class QTimer; -#ifdef HAVE_NEPOMUK - namespace Nepomuk2 - { - namespace Query - { - class Term; - } - } -#endif - // #define PLACESITEMMODEL_DEBUG /** @@ -127,7 +117,7 @@ public: /** * @return Converts the URL, which contains "virtual" URLs for system-items like - * "search:/documents" into a Nepomuk-Query-URL that will be handled by + * "search:/documents" into a Query-URL that will be handled by * the corresponding IO-slave. Virtual URLs for bookmarks are used to * be independent from internal format changes. */ @@ -163,9 +153,6 @@ private slots: * timeout of m_saveBookmarksTimer to prevent unnecessary savings. */ void saveBookmarks(); - - void slotNepomukStarted(); - void slotNepomukStopped(); private: struct SystemBookmarkData; @@ -252,13 +239,13 @@ private: */ static KUrl createSearchUrl(const KUrl& url); -#ifdef HAVE_NEPOMUK +#ifdef HAVE_BALOO /** - * Helper method for createSearchUrl(). + * Helper method for createSearchUrl() * @return URL that can be listed by KIO and results in searching - * for the given term. + * for the given type */ - static KUrl searchUrlForTerm(const Nepomuk2::Query::Term& term); + static KUrl searchUrlForType(const QString& type); #endif #ifdef PLACESITEMMODEL_DEBUG diff --git a/dolphin/src/search/dolphinfacetswidget.cpp b/dolphin/src/search/dolphinfacetswidget.cpp index d786117c91..b7315a01c3 100644 --- a/dolphin/src/search/dolphinfacetswidget.cpp +++ b/dolphin/src/search/dolphinfacetswidget.cpp @@ -27,18 +27,6 @@ #include #include -#ifdef HAVE_NEPOMUK - #include - #include - #include - #include - #include - #include - #include - #include - #include -#endif - DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) : QWidget(parent), m_documents(0), @@ -120,39 +108,9 @@ DolphinFacetsWidget::~DolphinFacetsWidget() { } -#ifdef HAVE_NEPOMUK -Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const +#ifdef HAVE_BALOO +Baloo::Term DolphinFacetsWidget::ratingTerm() const { - Nepomuk2::Query::AndTerm andTerm; - - const bool hasTypeFilter = m_documents->isChecked() || - m_images->isChecked() || - m_audio->isChecked() || - m_videos->isChecked(); - if (hasTypeFilter) { - Nepomuk2::Query::OrTerm orTerm; - - if (m_documents->isChecked()) { - orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document())); - } - - if (m_images->isChecked()) { - orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image())); - } - - if (m_audio->isChecked()) { - orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), - Nepomuk2::Query::LiteralTerm("audio"))); - } - - if (m_videos->isChecked()) { - orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), - Nepomuk2::Query::LiteralTerm("video"))); - } - - andTerm.addSubTerm(orTerm); - } - if (!m_anyRating->isChecked()) { int stars = 1; // represents m_oneOrMore if (m_twoOrMore->isChecked()) { @@ -166,12 +124,15 @@ Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const } const int rating = stars * 2; - Nepomuk2::Query::ComparisonTerm term(Soprano::Vocabulary::NAO::numericRating(), - Nepomuk2::Query::LiteralTerm(rating), - Nepomuk2::Query::ComparisonTerm::GreaterOrEqual); - andTerm.addSubTerm(term); + + Baloo::Term term("rating", rating, Baloo::Term::GreaterEqual); + return term; } + return Baloo::Term(); + + /* + // FIXME: Handle date time filters if (!m_anytime->isChecked()) { QDate date = QDate::currentDate(); // represents m_today if (m_yesterday->isChecked()) { @@ -189,11 +150,34 @@ Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const Nepomuk2::Query::ComparisonTerm::GreaterOrEqual); andTerm.addSubTerm(term); } - - return andTerm; + */ } + +QStringList DolphinFacetsWidget::facetTypes() const +{ + QStringList types; + if (m_documents->isChecked()) { + types << "Document"; + } + + if (m_images->isChecked()) { + types << "Image"; + } + + if (m_audio->isChecked()) { + types << "Audio"; + } + + if (m_videos->isChecked()) { + types << "Video"; + } + + return types; +} + #endif + QCheckBox* DolphinFacetsWidget::createCheckBox(const QString& text) { QCheckBox* checkBox = new QCheckBox(text); diff --git a/dolphin/src/search/dolphinfacetswidget.h b/dolphin/src/search/dolphinfacetswidget.h index 57bed9e686..526fe1c798 100644 --- a/dolphin/src/search/dolphinfacetswidget.h +++ b/dolphin/src/search/dolphinfacetswidget.h @@ -22,9 +22,9 @@ #include -#include -#ifdef HAVE_NEPOMUK - #include +#include +#ifdef HAVE_BALOO + #include #endif class QButtonGroup; @@ -55,8 +55,9 @@ public: explicit DolphinFacetsWidget(QWidget* parent = 0); virtual ~DolphinFacetsWidget(); -#ifdef HAVE_NEPOMUK - Nepomuk2::Query::Term facetsTerm() const; +#ifdef HAVE_BALOO + Baloo::Term ratingTerm() const; + QStringList facetTypes() const; #endif signals: diff --git a/dolphin/src/search/dolphinsearchbox.cpp b/dolphin/src/search/dolphinsearchbox.cpp index cf1f0c8e52..e6377639bd 100644 --- a/dolphin/src/search/dolphinsearchbox.cpp +++ b/dolphin/src/search/dolphinsearchbox.cpp @@ -21,7 +21,6 @@ #include "dolphin_searchsettings.h" #include "dolphinfacetswidget.h" -#include "dolphinsearchinformation.h" #include #include @@ -40,18 +39,11 @@ #include #include -#include -#ifdef HAVE_NEPOMUK - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include +#include +#ifdef HAVE_BALOO + #include + #include + #include #endif DolphinSearchBox::DolphinSearchBox(QWidget* parent) : @@ -115,8 +107,8 @@ void DolphinSearchBox::setSearchPath(const KUrl& url) m_fromHereButton->setVisible(showSearchFromButtons); m_everywhereButton->setVisible(showSearchFromButtons); - const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - const bool hasFacetsSupport = searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath); + const Baloo::IndexerConfig searchInfo; + const bool hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile()); m_facetsWidget->setEnabled(hasFacetsSupport); } @@ -128,9 +120,9 @@ KUrl DolphinSearchBox::searchPath() const KUrl DolphinSearchBox::urlForSearching() const { KUrl url; - const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); - if (searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath)) { - url = nepomukUrlForSearching(); + const Baloo::IndexerConfig searchInfo; + if (searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile())) { + url = balooUrlForSearching(); } else { url.setProtocol("filenamesearch"); url.addQueryItem("search", m_searchInput->text()); @@ -430,52 +422,34 @@ void DolphinSearchBox::init() applyReadOnlyState(); } -KUrl DolphinSearchBox::nepomukUrlForSearching() const +KUrl DolphinSearchBox::balooUrlForSearching() const { -#ifdef HAVE_NEPOMUK - // Create the term for the text from the input-field - // dependent on whether a searching for content or - // filename is done +#ifdef HAVE_BALOO const QString text = m_searchInput->text(); - Nepomuk2::Query::Term searchLabelTerm; - if (m_contentButton->isChecked()) { - // Let Nepomuk parse the query - searchLabelTerm = Nepomuk2::Query::QueryParser::parseQuery(text, Nepomuk2::Query::QueryParser::DetectFilenamePattern).term(); - } else { - // Search the text in the filename only - QString regex = QRegExp::escape(text); - regex.replace("\\*", QLatin1String(".*")); - regex.replace("\\?", QLatin1String(".")); - regex.replace("\\", "\\\\"); - searchLabelTerm = Nepomuk2::Query::ComparisonTerm( - Nepomuk2::Vocabulary::NFO::fileName(), - Nepomuk2::Query::LiteralTerm(regex), - Nepomuk2::Query::ComparisonTerm::Regexp); + + Baloo::Query query; + query.addType("File"); + query.addTypes(m_facetsWidget->facetTypes()); + + Baloo::Term term(Baloo::Term::And); + + Baloo::Term ratingTerm = m_facetsWidget->ratingTerm(); + if (ratingTerm.isValid()) { + term.addSubTerm(ratingTerm); } - // Get the term from the facets and merge it with the - // created term from the input-field. - Nepomuk2::Query::Term facetsTerm = m_facetsWidget->facetsTerm(); - - Nepomuk2::Query::FileQuery fileQuery; - fileQuery.setFileMode(Nepomuk2::Query::FileQuery::QueryFilesAndFolders); - if (facetsTerm.isValid()) { - Nepomuk2::Query::AndTerm andTerm; - andTerm.addSubTerm(searchLabelTerm); - andTerm.addSubTerm(facetsTerm); - fileQuery.setTerm(andTerm); + if (m_contentButton->isChecked()) { + query.setSearchString(text); } else { - fileQuery.setTerm(searchLabelTerm); + term.addSubTerm(Baloo::Term("filename", text)); } if (m_fromHereButton->isChecked()) { - const bool recursive = true; - fileQuery.addIncludeFolder(m_searchPath, recursive); + query.addCustomOption("includeFolder", m_searchPath.toLocalFile()); } - return fileQuery.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", - "Query Results from '%1'", - text)); + return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", + "Query Results from '%1'", text)); #else return KUrl(); #endif @@ -483,9 +457,9 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const void DolphinSearchBox::applyReadOnlyState() { -#ifdef HAVE_NEPOMUK +#ifdef HAVE_BALOO if (m_readOnly) { - m_searchLabel->setText(Nepomuk2::Query::Query::titleFromQueryUrl(m_readOnlyQuery)); + m_searchLabel->setText(Baloo::Query::titleFromQueryUrl(m_readOnlyQuery)); } else { #else { diff --git a/dolphin/src/search/dolphinsearchbox.h b/dolphin/src/search/dolphinsearchbox.h index e4c14b7cbc..6dc09f19e7 100644 --- a/dolphin/src/search/dolphinsearchbox.h +++ b/dolphin/src/search/dolphinsearchbox.h @@ -33,13 +33,13 @@ class QLabel; class QVBoxLayout; /** - * @brief Input box for searching files with or without Nepomuk. + * @brief Input box for searching files with or without Baloo. * * The widget allows to specify: * - Where to search: Everywhere or below the current directory * - What to search: Filenames or content * - * If Nepomuk is available and the current folder is indexed, further + * If Baloo is available and the current folder is indexed, further * options are offered. */ class DolphinSearchBox : public QWidget { @@ -151,9 +151,9 @@ private: void init(); /** - * @return URL that represents the Nepomuk query for starting the search. + * @return URL that represents the Baloo query for starting the search. */ - KUrl nepomukUrlForSearching() const; + KUrl balooUrlForSearching() const; void applyReadOnlyState(); diff --git a/dolphin/src/search/dolphinsearchinformation.cpp b/dolphin/src/search/dolphinsearchinformation.cpp deleted file mode 100644 index b723f1ec00..0000000000 --- a/dolphin/src/search/dolphinsearchinformation.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "dolphinsearchinformation.h" - -#include -#ifdef HAVE_NEPOMUK - #include - #include - #include -#endif - -#include -#include -#include -#include - -struct DolphinSearchInformationSingleton -{ - DolphinSearchInformation instance; -}; -K_GLOBAL_STATIC(DolphinSearchInformationSingleton, s_dolphinSearchInformation) - - -DolphinSearchInformation& DolphinSearchInformation::instance() -{ - return s_dolphinSearchInformation->instance; -} - -DolphinSearchInformation::~DolphinSearchInformation() -{ -} - -bool DolphinSearchInformation::isIndexingEnabled() const -{ - return m_indexingEnabled; -} - -namespace { - /// recursively check if a folder is hidden - bool isDirHidden( QDir& dir ) { - if (QFileInfo(dir.path()).isHidden()) { - return true; - } else if (dir.cdUp()) { - return isDirHidden(dir); - } else { - return false; - } - } - - bool isDirHidden(const QString& path) { - QDir dir(path); - return isDirHidden(dir); - } -} - -bool DolphinSearchInformation::isPathIndexed(const KUrl& url) const -{ -#ifdef HAVE_NEPOMUK - const KConfig strigiConfig("nepomukstrigirc"); - const QStringList indexedFolders = strigiConfig.group("General").readPathEntry("folders", QStringList()); - - // Nepomuk does not index hidden folders - if (isDirHidden(url.toLocalFile())) { - return false; - } - - // Check whether the path is part of an indexed folder - bool isIndexed = false; - foreach (const QString& indexedFolder, indexedFolders) { - const KUrl indexedPath(indexedFolder); - if (indexedPath.isParentOf(url)) { - isIndexed = true; - break; - } - } - - if (isIndexed) { - // The path is part of an indexed folder. Check whether no - // excluded folder is part of the path. - const QStringList excludedFolders = strigiConfig.group("General").readPathEntry("exclude folders", QStringList()); - foreach (const QString& excludedFolder, excludedFolders) { - const KUrl excludedPath(excludedFolder); - if (excludedPath.isParentOf(url)) { - isIndexed = false; - break; - } - } - } - - return isIndexed; -#else - Q_UNUSED(url); - return false; -#endif -} - -DolphinSearchInformation::DolphinSearchInformation() : - m_indexingEnabled(false) -{ -#ifdef HAVE_NEPOMUK - if (Nepomuk2::ResourceManager::instance()->initialized()) { - KConfig config("nepomukserverrc"); - m_indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true); - } -#endif -} - diff --git a/dolphin/src/search/dolphinsearchinformation.h b/dolphin/src/search/dolphinsearchinformation.h deleted file mode 100644 index 6fb1947cac..0000000000 --- a/dolphin/src/search/dolphinsearchinformation.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef DOLPHINSEARCHINFORMATION_H -#define DOLPHINSEARCHINFORMATION_H - -class KUrl; - -/** - * @brief Allows to access search-engine related information. - */ -class DolphinSearchInformation -{ -public: - static DolphinSearchInformation& instance(); - virtual ~DolphinSearchInformation(); - - /** - * @return True if the Nepomuk indexer is enabled. If Nepomuk is - * disabled, always false is returned. - */ - bool isIndexingEnabled() const; - - /** - * @return True if the complete directory tree specified by path - * is indexed by the Nepomuk indexer. If Nepomuk is disabled, - * always false is returned. - */ - bool isPathIndexed(const KUrl& url) const; - -protected: - DolphinSearchInformation(); - -private: - bool m_indexingEnabled; - - friend class DolphinSearchInformationSingleton; -}; - -#endif - diff --git a/dolphin/src/settings/additionalinfodialog.cpp b/dolphin/src/settings/additionalinfodialog.cpp index 0efa8a5fe4..e9d5f606d9 100644 --- a/dolphin/src/settings/additionalinfodialog.cpp +++ b/dolphin/src/settings/additionalinfodialog.cpp @@ -19,7 +19,7 @@ #include "additionalinfodialog.h" -#include +#include #include #include "kitemviews/kfileitemmodel.h" @@ -27,8 +27,8 @@ #include #include -#ifdef HAVE_NEPOMUK - #include +#ifdef HAVE_BALOO + #include #endif AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent, @@ -50,14 +50,10 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent, header->setWordWrap(true); // Add checkboxes - bool nepomukRunning = false; bool indexingEnabled = false; -#ifdef HAVE_NEPOMUK - nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); - if (nepomukRunning) { - KConfig config("nepomukserverrc"); - indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true); - } +#ifdef HAVE_BALOO + Baloo::IndexerConfig config; + indexingEnabled = config.fileIndexingEnabled(); #endif m_listWidget = new QListWidget(mainWidget); @@ -67,8 +63,8 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent, QListWidgetItem* item = new QListWidgetItem(info.translation, m_listWidget); item->setCheckState(visibleRoles.contains(info.role) ? Qt::Checked : Qt::Unchecked); - const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) || - (info.requiresNepomuk && nepomukRunning) || + const bool enable = (!info.requiresBaloo && !info.requiresIndexer) || + (info.requiresBaloo) || (info.requiresIndexer && indexingEnabled); if (!enable) { diff --git a/dolphin/src/settings/viewpropertiesdialog.cpp b/dolphin/src/settings/viewpropertiesdialog.cpp index c5002ff9f2..574f8e18e4 100644 --- a/dolphin/src/settings/viewpropertiesdialog.cpp +++ b/dolphin/src/settings/viewpropertiesdialog.cpp @@ -27,10 +27,7 @@ #include "dolphin_iconsmodesettings.h" #include "viewpropsprogressinfo.h" -#include -#ifdef HAVE_NEPOMUK -#include -#endif +#include #include #include diff --git a/dolphin/src/tests/CMakeLists.txt b/dolphin/src/tests/CMakeLists.txt index fca0819f81..4ba68dd730 100644 --- a/dolphin/src/tests/CMakeLists.txt +++ b/dolphin/src/tests/CMakeLists.txt @@ -89,19 +89,18 @@ kde4_add_unit_test(kitemlistkeyboardsearchmanagertest TEST ${kitemlistkeyboardse target_link_libraries(kitemlistkeyboardsearchmanagertest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) # DolphinSearchBox -if (Nepomuk_FOUND) +if (Baloo_FOUND) set(dolphinsearchboxtest_SRCS dolphinsearchboxtest.cpp ../search/dolphinfacetswidget.cpp ../search/dolphinsearchbox.cpp - ../search/dolphinsearchinformation.cpp ) kde4_add_kcfg_files(dolphinsearchboxtest_SRCS ../search/dolphin_searchsettings.kcfgc ) kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS}) - target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${SOPRANO_LIBRARIES} ${NEPOMUK_CORE_LIBRARY} nepomukutils ${QT_QTTEST_LIBRARY}) -endif (Nepomuk_FOUND) + target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${BALOO_LIBRARIES} ${QT_QTTEST_LIBRARY}) +endif (Baloo_FOUND) # KStandardItemModelTest set(kstandarditemmodeltest_SRCS diff --git a/dolphin/src/views/dolphinview.cpp b/dolphin/src/views/dolphinview.cpp index 303731c6d4..63b53f2e26 100644 --- a/dolphin/src/views/dolphinview.cpp +++ b/dolphin/src/views/dolphinview.cpp @@ -20,7 +20,7 @@ #include "dolphinview.h" -#include +#include #include #include @@ -74,8 +74,8 @@ #include "views/tooltips/tooltipmanager.h" #include "zoomlevelinfo.h" -#ifdef HAVE_NEPOMUK - #include +#ifdef HAVE_BALOO + #include #endif namespace { @@ -870,14 +870,10 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) KItemListView* view = m_container->controller()->view(); const QSet visibleRolesSet = view->visibleRoles().toSet(); - bool nepomukRunning = false; bool indexingEnabled = false; -#ifdef HAVE_NEPOMUK - nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); - if (nepomukRunning) { - KConfig config("nepomukserverrc"); - indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true); - } +#ifdef HAVE_BALOO + Baloo::IndexerConfig config; + indexingEnabled = config.fileIndexingEnabled(); #endif QString groupName; @@ -908,8 +904,8 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) action->setChecked(visibleRolesSet.contains(info.role)); action->setData(info.role); - const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) || - (info.requiresNepomuk && nepomukRunning) || + const bool enable = (!info.requiresBaloo && !info.requiresIndexer) || + (info.requiresBaloo) || (info.requiresIndexer && indexingEnabled); action->setEnabled(enable); } diff --git a/dolphin/src/views/dolphinview.h b/dolphin/src/views/dolphinview.h index b43957f226..3731464a35 100644 --- a/dolphin/src/views/dolphinview.h +++ b/dolphin/src/views/dolphinview.h @@ -21,7 +21,7 @@ #ifndef DOLPHINVIEW_H #define DOLPHINVIEW_H -#include +#include #include "libdolphin_export.h" diff --git a/dolphin/src/views/dolphinviewactionhandler.cpp b/dolphin/src/views/dolphinviewactionhandler.cpp index 051174f6db..48ec95c70e 100644 --- a/dolphin/src/views/dolphinviewactionhandler.cpp +++ b/dolphin/src/views/dolphinviewactionhandler.cpp @@ -20,7 +20,7 @@ #include "dolphinviewactionhandler.h" -#include +#include #include "settings/viewpropertiesdialog.h" #include "views/dolphinview.h" @@ -39,12 +39,12 @@ #include #include -#ifdef HAVE_NEPOMUK - #include -#endif - #include +#ifdef HAVE_BALOO + #include +#endif + DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) : QObject(parent), m_actionCollection(collection), @@ -237,14 +237,10 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt KActionMenu* groupMenu = 0; QActionGroup* groupMenuGroup = 0; - bool nepomukRunning = false; bool indexingEnabled = false; -#ifdef HAVE_NEPOMUK - nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); - if (nepomukRunning) { - KConfig config("nepomukserverrc"); - indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true); - } +#ifdef HAVE_BALOO + Baloo::IndexerConfig config; + indexingEnabled = config.fileIndexingEnabled(); #endif const QList rolesInfo = KFileItemModel::rolesInformation(); @@ -284,8 +280,8 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt action->setText(info.translation); action->setData(info.role); - const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) || - (info.requiresNepomuk && nepomukRunning) || + const bool enable = (!info.requiresBaloo && !info.requiresIndexer) || + (info.requiresBaloo) || (info.requiresIndexer && indexingEnabled); action->setEnabled(enable); diff --git a/dolphin/src/views/tooltips/filemetadatatooltip.cpp b/dolphin/src/views/tooltips/filemetadatatooltip.cpp index 67911eea2c..b726996641 100644 --- a/dolphin/src/views/tooltips/filemetadatatooltip.cpp +++ b/dolphin/src/views/tooltips/filemetadatatooltip.cpp @@ -34,10 +34,10 @@ #include #include -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO #include #else -#include +#include #endif // For the blurred tooltip background @@ -70,10 +70,10 @@ FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) : m_name->setMaximumWidth(fontMetrics.averageCharWidth() * 40); // Create widget for the meta data -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO m_fileMetaDataWidget = new KFileMetaDataWidget(this); #else - m_fileMetaDataWidget = new Nepomuk2::FileMetaDataWidget(this); + m_fileMetaDataWidget = new Baloo::FileMetaDataWidget(this); #endif m_fileMetaDataWidget->setForegroundRole(QPalette::ToolTipText); m_fileMetaDataWidget->setReadOnly(true); diff --git a/dolphin/src/views/tooltips/filemetadatatooltip.h b/dolphin/src/views/tooltips/filemetadatatooltip.h index e7cb3f0394..7197871fce 100644 --- a/dolphin/src/views/tooltips/filemetadatatooltip.h +++ b/dolphin/src/views/tooltips/filemetadatatooltip.h @@ -23,15 +23,15 @@ #define FILEMETADATATOOLTIP_H #include -#include "config-nepomuk.h" +#include "config-baloo.h" class KFileItemList; class QLabel; -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO class KFileMetaDataWidget; #else -namespace Nepomuk2 { +namespace Baloo { class FileMetaDataWidget; } #endif @@ -76,10 +76,10 @@ protected: private: QLabel* m_preview; QLabel* m_name; -#ifndef HAVE_NEPOMUK +#ifndef HAVE_BALOO KFileMetaDataWidget* m_fileMetaDataWidget; #else - Nepomuk2::FileMetaDataWidget* m_fileMetaDataWidget; + Baloo::FileMetaDataWidget* m_fileMetaDataWidget; #endif }; diff --git a/dolphin/src/views/viewproperties.h b/dolphin/src/views/viewproperties.h index b3d3070ed5..69b507f1b2 100644 --- a/dolphin/src/views/viewproperties.h +++ b/dolphin/src/views/viewproperties.h @@ -160,7 +160,7 @@ private: /** * @return A hash-value for an URL that can be used as directory name. - * Is used to be able to remember view-properties for long nepomuksearch-URLs. + * Is used to be able to remember view-properties for long baloo-URLs. */ static QString directoryHashForUrl(const KUrl& url);