Port Dolphin to Baloo

Nepomuk is being replaced with Baloo
This commit is contained in:
Vishesh Handa 2014-02-06 20:29:09 +01:00
parent 15f409de33
commit 5707e1e92c
34 changed files with 474 additions and 840 deletions

View file

@ -1,37 +1,36 @@
macro_optional_find_package(NepomukCore) macro_optional_find_package(Baloo)
set_package_properties(NepomukCore PROPERTIES DESCRIPTION "Nepomuk Core libraries" set_package_properties(Baloo PROPERTIES DESCRIPTION "Baloo Core libraries"
URL "http://www.kde.org" URL "http://www.kde.org"
TYPE OPTIONAL 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) macro_optional_find_package(BalooWidgets)
set_package_properties(NepomukWidgets PROPERTIES DESCRIPTION "Nepomuk Widgets" set_package_properties(BalooWidgets PROPERTIES DESCRIPTION "Baloos Widgets"
URL "http://www.kde.org" URL "http://www.kde.org"
TYPE OPTIONAL TYPE OPTIONAL
PURPOSE "For adding desktop-wide tagging support to dolphin"
) )
if(NepomukCore_FOUND AND NepomukWidgets_FOUND) macro_optional_find_package(KFileMetaData)
set(HAVE_NEPOMUK TRUE) 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() 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) macro_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER)
configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h ) 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) if(HAVE_BALOO)
find_package(Soprano 2.7.56) include_directories(${BALOO_INCLUDE_DIR} ${BALOO_WIDGETS_INCLUDE_DIR})
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} )
endif() endif()
add_subdirectory(tests) add_subdirectory(tests)
@ -98,10 +97,10 @@ set(dolphinprivate_LIB_SRCS
dolphinnewfilemenu.cpp dolphinnewfilemenu.cpp
) )
if(HAVE_NEPOMUK) if(HAVE_BALOO)
set(dolphinprivate_LIB_SRCS set(dolphinprivate_LIB_SRCS
${dolphinprivate_LIB_SRCS} ${dolphinprivate_LIB_SRCS}
kitemviews/private/knepomukrolesprovider.cpp kitemviews/private/kbaloorolesprovider.cpp
) )
endif() endif()
@ -123,12 +122,12 @@ target_link_libraries(
${KDE4_KNEWSTUFF3_LIBS} ${KDE4_KNEWSTUFF3_LIBS}
) )
if(HAVE_NEPOMUK) if(HAVE_BALOO)
target_link_libraries( target_link_libraries(
dolphinprivate dolphinprivate
${NEPOMUK_CORE_LIBRARY} ${BALOO_LIBRARIES}
${NEPOMUK_WIDGETS_LIBRARY} ${BALOO_WIDGETS_LIBRARY}
${SOPRANO_LIBRARIES} ${KFILEMETADATA_LIBRARY}
) )
endif() endif()
@ -193,7 +192,6 @@ set(dolphin_SRCS
panels/folders/folderspanel.cpp panels/folders/folderspanel.cpp
search/dolphinfacetswidget.cpp search/dolphinfacetswidget.cpp
search/dolphinsearchbox.cpp search/dolphinsearchbox.cpp
search/dolphinsearchinformation.cpp
settings/general/behaviorsettingspage.cpp settings/general/behaviorsettingspage.cpp
settings/general/configurepreviewplugindialog.cpp settings/general/configurepreviewplugindialog.cpp
settings/general/confirmationssettingspage.cpp settings/general/confirmationssettingspage.cpp
@ -249,11 +247,10 @@ target_link_libraries(kdeinit_dolphin
${KDE4_PHONON_LIBS} ${KDE4_PHONON_LIBS}
) )
if(HAVE_NEPOMUK) if(HAVE_BALOO)
target_link_libraries(kdeinit_dolphin target_link_libraries(kdeinit_dolphin
${NEPOMUK_CORE_LIBRARY} ${BALOO_LIBRARIES}
${NEPOMUK_WIDGETS_LIBRARY} ${BALOO_WIDGETS_LIBRARY}
${SOPRANO_LIBRARIES}
) )
endif() 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_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_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) 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_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} )
install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} ) install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} )

View file

@ -0,0 +1 @@
#cmakedefine HAVE_BALOO

View file

@ -1 +0,0 @@
#cmakedefine HAVE_NEPOMUK

View file

@ -22,7 +22,7 @@
#ifndef DOLPHIN_MAINWINDOW_H #ifndef DOLPHIN_MAINWINDOW_H
#define DOLPHIN_MAINWINDOW_H #define DOLPHIN_MAINWINDOW_H
#include <config-nepomuk.h> #include <config-baloo.h>
#include <KFileItemDelegate> #include <KFileItemDelegate>
#include <kio/fileundomanager.h> #include <kio/fileundomanager.h>

View file

@ -455,7 +455,7 @@ void DolphinViewContainer::slotDirectoryLoadingCompleted()
} }
if (isSearchUrl(url()) && m_view->itemsCount() == 0) { 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: // of showing the default status bar information ("0 items") a more helpful information is given:
m_statusBar->setText(i18nc("@info:status", "No items found.")); m_statusBar->setText(i18nc("@info:status", "No items found."));
} else { } else {
@ -708,7 +708,7 @@ void DolphinViewContainer::showErrorMessage(const QString& msg)
bool DolphinViewContainer::isSearchUrl(const KUrl& url) const bool DolphinViewContainer::isSearchUrl(const KUrl& url) const
{ {
const QString protocol = url.protocol(); const QString protocol = url.protocol();
return protocol.contains("search") || (protocol == QLatin1String("nepomuk")); return protocol.contains("search");
} }
void DolphinViewContainer::saveViewState() void DolphinViewContainer::saveViewState()

View file

@ -317,7 +317,7 @@ private slots:
private: 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; bool isSearchUrl(const KUrl& url) const;

View file

@ -673,7 +673,7 @@ QList<KFileItemModel::RoleInfo> KFileItemModel::rolesInformation()
// menus tries to put the actions into sub menus otherwise. // menus tries to put the actions into sub menus otherwise.
info.group = QString(); info.group = QString();
} }
info.requiresNepomuk = map[i].requiresNepomuk; info.requiresBaloo = map[i].requiresBaloo;
info.requiresIndexer = map[i].requiresIndexer; info.requiresIndexer = map[i].requiresIndexer;
rolesInfo.append(info); rolesInfo.append(info);
} }
@ -2081,7 +2081,7 @@ void KFileItemModel::emitSortProgress(int resolvedCount)
const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count) const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
{ {
static const RoleInfoMap rolesInfoMap[] = { 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 }, { 0, NoRole, 0, 0, 0, 0, false, false },
{ "text", NameRole, I18N_NOOP2_NOSTRIP("@label", "Name"), 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 }, { "size", SizeRole, I18N_NOOP2_NOSTRIP("@label", "Size"), 0, 0, false, false },

View file

@ -187,14 +187,14 @@ public:
{ QByteArray role; { QByteArray role;
QString translation; QString translation;
QString group; QString group;
bool requiresNepomuk; bool requiresBaloo;
bool requiresIndexer; bool requiresIndexer;
}; };
/** /**
* @return Provides static information for all available roles that * @return Provides static information for all available roles that
* are supported by KFileItemModel. Some roles can only be * 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. * indexing is enabled.
*/ */
static QList<RoleInfo> rolesInformation(); static QList<RoleInfo> rolesInformation();
@ -287,7 +287,7 @@ private:
// User visible roles: // User visible roles:
NoRole, NameRole, SizeRole, DateRole, PermissionsRole, OwnerRole, NoRole, NameRole, SizeRole, DateRole, PermissionsRole, OwnerRole,
GroupRole, TypeRole, DestinationRole, PathRole, GroupRole, TypeRole, DestinationRole, PathRole,
// User visible roles available with Nepomuk: // User visible roles available with Baloo:
CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole, CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole,
WordCountRole, LineCountRole, ArtistRole, AlbumRole, DurationRole, TrackRole, WordCountRole, LineCountRole, ArtistRole, AlbumRole, DurationRole, TrackRole,
CopiedFromRole, CopiedFromRole,
@ -432,7 +432,7 @@ private:
const char* const roleTranslation; const char* const roleTranslation;
const char* const groupTranslationContext; const char* const groupTranslationContext;
const char* const groupTranslation; const char* const groupTranslation;
const bool requiresNepomuk; const bool requiresBaloo;
const bool requiresIndexer; const bool requiresIndexer;
}; };

View file

@ -40,10 +40,11 @@
#include <algorithm> #include <algorithm>
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
#include "private/knepomukrolesprovider.h" #include "private/kbaloorolesprovider.h"
#include <Nepomuk2/ResourceWatcher> #include <baloo/file.h>
#include <Nepomuk2/ResourceManager> #include <baloo/filefetchjob.h>
#include <baloo/filemonitor.h>
#endif #endif
// #define KFILEITEMMODELROLESUPDATER_DEBUG // #define KFILEITEMMODELROLESUPDATER_DEBUG
@ -88,9 +89,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
m_recentlyChangedItems(), m_recentlyChangedItems(),
m_changedItems(), m_changedItems(),
m_directoryContentsCounter(0) m_directoryContentsCounter(0)
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
, m_nepomukResourceWatcher(0), , m_balooFileMonitor(0)
m_nepomukUriItems()
#endif #endif
{ {
Q_ASSERT(model); Q_ASSERT(model);
@ -122,8 +122,8 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
m_resolvableRoles.insert("size"); m_resolvableRoles.insert("size");
m_resolvableRoles.insert("type"); m_resolvableRoles.insert("type");
m_resolvableRoles.insert("isExpandable"); m_resolvableRoles.insert("isExpandable");
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
m_resolvableRoles += KNepomukRolesProvider::instance().roles(); m_resolvableRoles += KBalooRolesProvider::instance().roles();
#endif #endif
m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this); m_directoryContentsCounter = new KDirectoryContentsCounter(m_model, this);
@ -262,34 +262,29 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
if (m_roles != roles) { if (m_roles != roles) {
m_roles = roles; m_roles = roles;
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
if (Nepomuk2::ResourceManager::instance()->initialized()) { // Check whether there is at least one role that must be resolved
// 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)
// with the help of Nepomuk. If this is the case, a (quite expensive) // resolving will be done in KFileItemModelRolesUpdater::rolesData() and
// resolving will be done in KFileItemModelRolesUpdater::rolesData() and // the role gets watched for changes.
// the role gets watched for changes. const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance(); bool hasBalooRole = false;
bool hasNepomukRole = false; QSetIterator<QByteArray> it(roles);
QSetIterator<QByteArray> it(roles); while (it.hasNext()) {
while (it.hasNext()) { const QByteArray& role = it.next();
const QByteArray& role = it.next(); if (rolesProvider.roles().contains(role)) {
if (rolesProvider.roles().contains(role)) { hasBalooRole = true;
hasNepomukRole = true; break;
break;
}
} }
}
if (hasNepomukRole && !m_nepomukResourceWatcher) { if (hasBalooRole && !m_balooFileMonitor) {
Q_ASSERT(m_nepomukUriItems.isEmpty()); m_balooFileMonitor = new Baloo::FileMonitor(this);
connect(m_balooFileMonitor, SIGNAL(fileMetaDataChanged(QString)),
m_nepomukResourceWatcher = new Nepomuk2::ResourceWatcher(this); this, SLOT(applyChangedBalooRoles(QString)));
connect(m_nepomukResourceWatcher, SIGNAL(propertyChanged(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariantList,QVariantList)), } else if (!hasBalooRole && m_balooFileMonitor) {
this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource,Nepomuk2::Types::Property))); delete m_balooFileMonitor;
} else if (!hasNepomukRole && m_nepomukResourceWatcher) { m_balooFileMonitor = 0;
delete m_nepomukResourceWatcher;
m_nepomukResourceWatcher = 0;
m_nepomukUriItems.clear();
}
} }
#endif #endif
@ -357,30 +352,19 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang
const bool allItemsRemoved = (m_model->count() == 0); const bool allItemsRemoved = (m_model->count() == 0);
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
if (m_nepomukResourceWatcher) { if (m_balooFileMonitor) {
// Don't let the ResourceWatcher watch for removed items // Don't let the FileWatcher watch for removed items
if (allItemsRemoved) { if (allItemsRemoved) {
m_nepomukResourceWatcher->setResources(QList<Nepomuk2::Resource>()); m_balooFileMonitor->clear();
m_nepomukResourceWatcher->stop();
m_nepomukUriItems.clear();
} else { } else {
QList<Nepomuk2::Resource> newResources; QStringList newFileList;
const QList<Nepomuk2::Resource> oldResources = m_nepomukResourceWatcher->resources(); foreach (const QString& itemUrl, m_balooFileMonitor->files()) {
foreach (const Nepomuk2::Resource& resource, oldResources) {
const QUrl uri = resource.uri();
const KUrl itemUrl = m_nepomukUriItems.value(uri);
if (m_model->index(itemUrl) >= 0) { if (m_model->index(itemUrl) >= 0) {
newResources.append(resource); newFileList.append(itemUrl);
} else {
m_nepomukUriItems.remove(uri);
} }
} }
m_nepomukResourceWatcher->setResources(newResources); m_balooFileMonitor->setFiles(newFileList);
if (newResources.isEmpty()) {
Q_ASSERT(m_nepomukUriItems.isEmpty());
m_nepomukResourceWatcher->stop();
}
} }
} }
#endif #endif
@ -708,14 +692,9 @@ void KFileItemModelRolesUpdater::resolveRecentlyChangedItems()
updateChangedItems(); updateChangedItems();
} }
void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resource& resource, const Nepomuk2::Types::Property& property) void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl)
{ {
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
if (!Nepomuk2::ResourceManager::instance()->initialized()) {
return;
}
const KUrl itemUrl = m_nepomukUriItems.value(resource.uri());
const KFileItem item = m_model->fileItem(itemUrl); const KFileItem item = m_model->fileItem(itemUrl);
if (item.isNull()) { if (item.isNull()) {
@ -724,18 +703,34 @@ void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resour
return; return;
} }
QHash<QByteArray, QVariant> 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(); void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob)
const QByteArray role = rolesProvider.roleForPropertyUri(property.uri()); {
if (!role.isEmpty() && m_roles.contains(role)) { #ifdef HAVE_BALOO
// Overwrite the changed role value with an empty QVariant, because the roles const KFileItem item = kjob->property("item").value<KFileItem>();
const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
QHash<QByteArray, QVariant> 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. // provider doesn't overwrite it when the property value list is empty.
// See bug 322348 // See bug 322348
data.insert(role, QVariant()); data.insert(role, QVariant());
} }
QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(resource, m_roles)); Baloo::FileFetchJob* job = static_cast<Baloo::FileFetchJob*>(kjob);
QHashIterator<QByteArray, QVariant> it(rolesProvider.roleValues(job->file(), m_roles));
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
data.insert(it.key(), it.value()); data.insert(it.key(), it.value());
@ -747,10 +742,6 @@ void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resour
m_model->setData(index, data); m_model->setData(index, data);
connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)), connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>))); this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
#else
#ifndef Q_CC_MSVC
Q_UNUSED(resource);
#endif
#endif #endif
} }
@ -762,7 +753,6 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin
if (getSizeRole || getIsExpandableRole) { if (getSizeRole || getIsExpandableRole) {
const int index = m_model->index(KUrl(path)); const int index = m_model->index(KUrl(path));
if (index >= 0) { if (index >= 0) {
QHash<QByteArray, QVariant> data; QHash<QByteArray, QVariant> data;
if (getSizeRole) { if (getSizeRole) {
@ -1004,7 +994,7 @@ void KFileItemModelRolesUpdater::applySortRole(int index)
const QString path = item.localPath(); const QString path = item.localPath();
data.insert("size", m_directoryContentsCounter->countDirectoryContentsSynchronously(path)); data.insert("size", m_directoryContentsCounter->countDirectoryContentsSynchronously(path));
} else { } 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); data = rolesData(item);
} }
@ -1087,35 +1077,12 @@ QHash<QByteArray, QVariant> KFileItemModelRolesUpdater::rolesData(const KFileIte
data.insert("iconOverlays", item.overlays()); data.insert("iconOverlays", item.overlays());
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
if (m_nepomukResourceWatcher) { if (m_balooFileMonitor) {
const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance(); m_balooFileMonitor->addFile(item.localPath());
Nepomuk2::Resource resource(item.nepomukUri()); applyChangedBalooRoles(item.localPath());
QHashIterator<QByteArray, QVariant> 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());
}
} }
#endif #endif
return data; return data;
} }

View file

@ -20,7 +20,7 @@
#ifndef KFILEITEMMODELROLESUPDATER_H #ifndef KFILEITEMMODELROLESUPDATER_H
#define KFILEITEMMODELROLESUPDATER_H #define KFILEITEMMODELROLESUPDATER_H
#include <config-nepomuk.h> #include <config-baloo.h>
#include <KFileItem> #include <KFileItem>
#include <kitemviews/kitemmodelbase.h> #include <kitemviews/kitemmodelbase.h>
@ -38,26 +38,10 @@ class KJob;
class QPixmap; class QPixmap;
class QTimer; class QTimer;
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
namespace Nepomuk2 namespace Baloo
{ {
class ResourceWatcher; class FileMonitor;
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;
}
} }
#endif #endif
@ -216,7 +200,8 @@ private slots:
*/ */
void resolveRecentlyChangedItems(); 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); void slotDirectoryContentsCountReceived(const QString& path, int count);
@ -346,9 +331,8 @@ private:
KDirectoryContentsCounter* m_directoryContentsCounter; KDirectoryContentsCounter* m_directoryContentsCounter;
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
Nepomuk2::ResourceWatcher* m_nepomukResourceWatcher; Baloo::FileMonitor* m_balooFileMonitor;
mutable QHash<QUrl, KUrl> m_nepomukUriItems;
#endif #endif
}; };

View file

@ -0,0 +1,184 @@
/***************************************************************************
* Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2013 by Vishesh Handa <me@vhanda.in> *
* *
* 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 <KDebug>
#include <KGlobal>
#include <KLocale>
#include <baloo/file.h>
#include <kfilemetadata/propertyinfo.h>
#include <QTime>
#include <QMap>
struct KBalooRolesProviderSingleton
{
KBalooRolesProvider instance;
};
K_GLOBAL_STATIC(KBalooRolesProviderSingleton, s_balooRolesProvider)
KBalooRolesProvider& KBalooRolesProvider::instance()
{
return s_balooRolesProvider->instance;
}
KBalooRolesProvider::~KBalooRolesProvider()
{
}
QSet<QByteArray> KBalooRolesProvider::roles() const
{
return m_roles;
}
QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& file,
const QSet<QByteArray>& roles) const
{
QHash<QByteArray, QVariant> values;
int width = -1;
int height = -1;
QMapIterator<KFileMetaData::Property::Property, QVariant> 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");
}

View file

@ -1,5 +1,6 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> * * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
* Copyright (C) 2013 by Vishesh Handa <me@vhanda.in> *
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * 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 * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/ ***************************************************************************/
#ifndef KNEPOMUKROLESPROVIDER_H #ifndef KBALOO_ROLESPROVIDER_H
#define KNEPOMUKROLESPROVIDER_H #define KBALOO_ROLESPROVIDER_H
#include <libdolphin_export.h> #include <libdolphin_export.h>
@ -26,25 +27,24 @@
#include <QSet> #include <QSet>
#include <QUrl> #include <QUrl>
namespace Nepomuk2 namespace Baloo {
{ class File;
class Resource;
} }
/** /**
* @brief Allows accessing metadata of a file by providing KFileItemModel roles. * @brief Allows accessing metadata of a file by providing KFileItemModel roles.
* *
* Is a helper class for KFileItemModelRolesUpdater to retrieve roles that * 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: public:
static KNepomukRolesProvider& instance(); static KBalooRolesProvider& instance();
virtual ~KNepomukRolesProvider(); virtual ~KBalooRolesProvider();
/** /**
* @return Roles that can be provided by KNepomukRolesProvider. * @return Roles that can be provided by KBalooRolesProvider.
*/ */
QSet<QByteArray> roles() const; QSet<QByteArray> roles() const;
@ -52,13 +52,13 @@ public:
* @return Values for the roles \a roles that can be determined from the file * @return Values for the roles \a roles that can be determined from the file
* with the URL \a url. * with the URL \a url.
*/ */
QHash<QByteArray, QVariant> roleValues(const Nepomuk2::Resource& resource, QHash<QByteArray, QVariant> roleValues(const Baloo::File& file,
const QSet<QByteArray>& roles) const; const QSet<QByteArray>& roles) const;
QByteArray roleForPropertyUri(const QUrl& uri) const; QByteArray roleForProperty(const QString& property) const;
protected: protected:
KNepomukRolesProvider(); KBalooRolesProvider();
private: private:
/** /**
@ -81,9 +81,9 @@ private:
private: private:
QSet<QByteArray> m_roles; QSet<QByteArray> m_roles;
QHash<QUrl, QByteArray> m_roleForUri; QHash<QString, QByteArray> m_roleForProperty;
friend class KNepomukRolesProviderSingleton; friend class KBalooRolesProviderSingleton;
}; };
#endif #endif

View file

@ -1,201 +0,0 @@
/***************************************************************************
* Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
* *
* 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 <KDebug>
#include <KGlobal>
#include <KLocale>
#include <Nepomuk2/Resource>
#include <Nepomuk2/Tag>
#include <Nepomuk2/Types/Property>
#include <Nepomuk2/Variant>
#include <QTime>
struct KNepomukRolesProviderSingleton
{
KNepomukRolesProvider instance;
};
K_GLOBAL_STATIC(KNepomukRolesProviderSingleton, s_nepomukRolesProvider)
KNepomukRolesProvider& KNepomukRolesProvider::instance()
{
return s_nepomukRolesProvider->instance;
}
KNepomukRolesProvider::~KNepomukRolesProvider()
{
}
QSet<QByteArray> KNepomukRolesProvider::roles() const
{
return m_roles;
}
QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk2::Resource& resource,
const QSet<QByteArray>& roles) const
{
if (!resource.isValid()) {
return QHash<QByteArray, QVariant>();
}
QHash<QByteArray, QVariant> values;
int width = -1;
int height = -1;
QHashIterator<QUrl, Nepomuk2::Variant> 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<Nepomuk2::Resource> 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");
}

View file

@ -19,10 +19,10 @@
#include "filemetadataconfigurationdialog.h" #include "filemetadataconfigurationdialog.h"
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
#include <kfilemetadataconfigurationwidget.h> #include <kfilemetadataconfigurationwidget.h>
#else #else
#include <nepomuk2/filemetadataconfigwidget.h> #include <baloo/filemetadataconfigwidget.h>
#endif #endif
#include <KLocale> #include <KLocale>
@ -44,10 +44,10 @@ FileMetaDataConfigurationDialog::FileMetaDataConfigurationDialog(QWidget* parent
"be shown:"), this); "be shown:"), this);
m_descriptionLabel->setWordWrap(true); m_descriptionLabel->setWordWrap(true);
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
m_configWidget = new KFileMetaDataConfigurationWidget(this); m_configWidget = new KFileMetaDataConfigurationWidget(this);
#else #else
m_configWidget = new Nepomuk2::FileMetaDataConfigWidget(this); m_configWidget = new Baloo::FileMetaDataConfigWidget(this);
#endif #endif

View file

@ -22,12 +22,12 @@
#include <KDialog> #include <KDialog>
#include <KFileItem> #include <KFileItem>
#include "config-nepomuk.h" #include "config-baloo.h"
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
class KFileMetaDataConfigurationWidget; class KFileMetaDataConfigurationWidget;
#else #else
namespace Nepomuk2 { namespace Baloo {
class FileMetaDataConfigWidget; class FileMetaDataConfigWidget;
} }
#endif #endif
@ -71,10 +71,10 @@ protected slots:
private: private:
QLabel* m_descriptionLabel; QLabel* m_descriptionLabel;
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
KFileMetaDataConfigurationWidget* m_configWidget; KFileMetaDataConfigurationWidget* m_configWidget;
#else #else
Nepomuk2::FileMetaDataConfigWidget* m_configWidget; Baloo::FileMetaDataConfigWidget* m_configWidget;
#endif #endif
}; };

View file

@ -31,10 +31,10 @@
#include <kseparator.h> #include <kseparator.h>
#include <KStringHandler> #include <KStringHandler>
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
#include <KFileMetaDataWidget> #include <KFileMetaDataWidget>
#else #else
#include <nepomuk2/filemetadatawidget.h> #include <baloo/filemetadatawidget.h>
#endif #endif
#include <panels/places/placesitem.h> #include <panels/places/placesitem.h>
@ -112,10 +112,10 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
const bool previewsShown = InformationPanelSettings::previewsShown(); const bool previewsShown = InformationPanelSettings::previewsShown();
m_preview->setVisible(previewsShown); m_preview->setVisible(previewsShown);
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
m_metaDataWidget = new KFileMetaDataWidget(parent); m_metaDataWidget = new KFileMetaDataWidget(parent);
#else #else
m_metaDataWidget = new Nepomuk2::FileMetaDataWidget(parent); m_metaDataWidget = new Baloo::FileMetaDataWidget(parent);
#endif #endif
m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont()); m_metaDataWidget->setFont(KGlobalSettings::smallestReadableFont());
m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
@ -166,7 +166,7 @@ void InformationPanelContent::showItem(const KFileItem& item)
} }
const KUrl itemUrl = item.url(); 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)) { if (!applyPlace(itemUrl)) {
setNameLabelText(item.text()); setNameLabelText(item.text());
if (isSearchUrl) { if (isSearchUrl) {
@ -355,7 +355,7 @@ void InformationPanelContent::slotHasVideoChanged(bool hasVideo)
void InformationPanelContent::refreshMetaData() void InformationPanelContent::refreshMetaData()
{ {
if (!m_item.isNull() && m_item.nepomukUri().isValid()) { if (!m_item.isNull()) {
showItem(m_item); showItem(m_item);
} }
} }

View file

@ -20,7 +20,7 @@
#ifndef INFORMATIONPANELCONTENT_H #ifndef INFORMATIONPANELCONTENT_H
#define INFORMATIONPANELCONTENT_H #define INFORMATIONPANELCONTENT_H
#include "config-nepomuk.h" #include "config-baloo.h"
#include <KConfig> #include <KConfig>
#include <KFileItem> #include <KFileItem>
#include <KUrl> #include <KUrl>
@ -38,13 +38,13 @@ class QLabel;
class QScrollArea; class QScrollArea;
namespace KIO { namespace KIO {
class PreviewJob; class PreviewJob;
} }
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
class KFileMetaDataWidget; class KFileMetaDataWidget;
#else #else
namespace Nepomuk2 { namespace Baloo {
class FileMetaDataWidget; class FileMetaDataWidget;
} }
#endif #endif
@ -147,10 +147,10 @@ private:
PixmapViewer* m_preview; PixmapViewer* m_preview;
PhononWidget* m_phononWidget; PhononWidget* m_phononWidget;
QLabel* m_nameLabel; QLabel* m_nameLabel;
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
KFileMetaDataWidget* m_metaDataWidget; KFileMetaDataWidget* m_metaDataWidget;
#else #else
Nepomuk2::FileMetaDataWidget* m_metaDataWidget; Baloo::FileMetaDataWidget* m_metaDataWidget;
#endif #endif
QScrollArea* m_metaDataArea; QScrollArea* m_metaDataArea;

View file

@ -51,22 +51,17 @@
#include <views/dolphinview.h> #include <views/dolphinview.h>
#include <views/viewproperties.h> #include <views/viewproperties.h>
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
#include <Nepomuk2/ResourceManager> #include <baloo/query.h>
#include <Nepomuk2/Query/ComparisonTerm> #include <baloo/indexerconfig.h>
#include <Nepomuk2/Query/LiteralTerm>
#include <Nepomuk2/Query/FileQuery>
#include <Nepomuk2/Query/ResourceTypeTerm>
#include <Nepomuk2/Vocabulary/NFO>
#include <Nepomuk2/Vocabulary/NIE>
#endif #endif
namespace { namespace {
// As long as KFilePlacesView from kdelibs is available in parallel, the // As long as KFilePlacesView from kdelibs is available in parallel, the
// system-bookmarks for "Recently Accessed" and "Search For" should be // system-bookmarks for "Recently Accessed" and "Search For" should be
// shown only inside the Places Panel. This is necessary as the stored // 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 // URLs needs to get translated to a Baloo-search-URL on-the-fly to
// be independent from changes in the Nepomuk-search-URL-syntax. // be independent from changes in the Baloo-search-URL-syntax.
// Hence a prefix to the application-name of the stored bookmarks is // Hence a prefix to the application-name of the stored bookmarks is
// added, which is only read by PlacesItemModel. // added, which is only read by PlacesItemModel.
const char* AppNamePrefix = "-places-panel"; const char* AppNamePrefix = "-places-panel";
@ -87,16 +82,9 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
m_updateBookmarksTimer(0), m_updateBookmarksTimer(0),
m_storageSetupInProgress() m_storageSetupInProgress()
{ {
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
Nepomuk2::ResourceManager* rm = Nepomuk2::ResourceManager::instance(); Baloo::IndexerConfig config;
connect(rm, SIGNAL(nepomukSystemStarted()), this, SLOT(slotNepomukStarted())); m_fileIndexingEnabled = config.fileIndexingEnabled();
connect(rm, SIGNAL(nepomukSystemStopped()), this, SLOT(slotNepomukStopped()));
if (rm->initialized()) {
KConfig config("nepomukserverrc");
m_fileIndexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
}
#endif #endif
const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml"); const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml");
m_bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces"); m_bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");
@ -959,35 +947,6 @@ void PlacesItemModel::clear() {
KStandardItemModel::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() void PlacesItemModel::initializeAvailableDevices()
{ {
QString predicate("[[[[ StorageVolume.ignored == false AND [ StorageVolume.usage == 'FileSystem' OR StorageVolume.usage == 'Encrypted' ]]" 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) 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' // provide default-timeline-URLs like 'yesterday', 'this month'
// and 'last month'. // and 'last month'.
KUrl timelineUrl; KUrl timelineUrl;
@ -1195,18 +1154,16 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
{ {
KUrl searchUrl; KUrl searchUrl;
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
const QString path = url.pathOrUrl(); const QString path = url.pathOrUrl();
if (path.endsWith(QLatin1String("documents"))) { if (path.endsWith(QLatin1String("documents"))) {
searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document())); searchUrl = searchUrlForType("Document");
} else if (path.endsWith(QLatin1String("images"))) { } else if (path.endsWith(QLatin1String("images"))) {
searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image())); searchUrl = searchUrlForType("Image");
} else if (path.endsWith(QLatin1String("audio"))) { } else if (path.endsWith(QLatin1String("audio"))) {
searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), searchUrl = searchUrlForType("Audio");
Nepomuk2::Query::LiteralTerm("audio")));
} else if (path.endsWith(QLatin1String("videos"))) { } else if (path.endsWith(QLatin1String("videos"))) {
searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(), searchUrl = searchUrlForType("Video");
Nepomuk2::Query::LiteralTerm("video")));
} else { } else {
Q_ASSERT(false); Q_ASSERT(false);
} }
@ -1217,10 +1174,13 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
return searchUrl; return searchUrl;
} }
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
KUrl PlacesItemModel::searchUrlForTerm(const Nepomuk2::Query::Term& term) KUrl PlacesItemModel::searchUrlForType(const QString& type)
{ {
const Nepomuk2::Query::FileQuery query(term); Baloo::Query query;
query.addType("File");
query.addType(type);
return query.toSearchUrl(); return query.toSearchUrl();
} }
#endif #endif

View file

@ -20,7 +20,7 @@
#ifndef PLACESITEMMODEL_H #ifndef PLACESITEMMODEL_H
#define PLACESITEMMODEL_H #define PLACESITEMMODEL_H
#include <config-nepomuk.h> #include <config-baloo.h>
#include <kitemviews/kstandarditemmodel.h> #include <kitemviews/kstandarditemmodel.h>
@ -37,16 +37,6 @@ class PlacesItem;
class QAction; class QAction;
class QTimer; class QTimer;
#ifdef HAVE_NEPOMUK
namespace Nepomuk2
{
namespace Query
{
class Term;
}
}
#endif
// #define PLACESITEMMODEL_DEBUG // #define PLACESITEMMODEL_DEBUG
/** /**
@ -127,7 +117,7 @@ public:
/** /**
* @return Converts the URL, which contains "virtual" URLs for system-items like * @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 * the corresponding IO-slave. Virtual URLs for bookmarks are used to
* be independent from internal format changes. * be independent from internal format changes.
*/ */
@ -163,9 +153,6 @@ private slots:
* timeout of m_saveBookmarksTimer to prevent unnecessary savings. * timeout of m_saveBookmarksTimer to prevent unnecessary savings.
*/ */
void saveBookmarks(); void saveBookmarks();
void slotNepomukStarted();
void slotNepomukStopped();
private: private:
struct SystemBookmarkData; struct SystemBookmarkData;
@ -252,13 +239,13 @@ private:
*/ */
static KUrl createSearchUrl(const KUrl& url); 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 * @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 #endif
#ifdef PLACESITEMMODEL_DEBUG #ifdef PLACESITEMMODEL_DEBUG

View file

@ -27,18 +27,6 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/Query/AndTerm>
#include <Nepomuk2/Query/ComparisonTerm>
#include <Nepomuk2/Query/LiteralTerm>
#include <Nepomuk2/Query/OrTerm>
#include <Nepomuk2/Query/Query>
#include <Nepomuk2/Query/ResourceTypeTerm>
#include <Nepomuk2/Vocabulary/NFO>
#include <Nepomuk2/Vocabulary/NIE>
#include <Soprano/Vocabulary/NAO>
#endif
DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) : DolphinFacetsWidget::DolphinFacetsWidget(QWidget* parent) :
QWidget(parent), QWidget(parent),
m_documents(0), m_documents(0),
@ -120,39 +108,9 @@ DolphinFacetsWidget::~DolphinFacetsWidget()
{ {
} }
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const 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()) { if (!m_anyRating->isChecked()) {
int stars = 1; // represents m_oneOrMore int stars = 1; // represents m_oneOrMore
if (m_twoOrMore->isChecked()) { if (m_twoOrMore->isChecked()) {
@ -166,12 +124,15 @@ Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const
} }
const int rating = stars * 2; const int rating = stars * 2;
Nepomuk2::Query::ComparisonTerm term(Soprano::Vocabulary::NAO::numericRating(),
Nepomuk2::Query::LiteralTerm(rating), Baloo::Term term("rating", rating, Baloo::Term::GreaterEqual);
Nepomuk2::Query::ComparisonTerm::GreaterOrEqual); return term;
andTerm.addSubTerm(term);
} }
return Baloo::Term();
/*
// FIXME: Handle date time filters
if (!m_anytime->isChecked()) { if (!m_anytime->isChecked()) {
QDate date = QDate::currentDate(); // represents m_today QDate date = QDate::currentDate(); // represents m_today
if (m_yesterday->isChecked()) { if (m_yesterday->isChecked()) {
@ -189,11 +150,34 @@ Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const
Nepomuk2::Query::ComparisonTerm::GreaterOrEqual); Nepomuk2::Query::ComparisonTerm::GreaterOrEqual);
andTerm.addSubTerm(term); 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 #endif
QCheckBox* DolphinFacetsWidget::createCheckBox(const QString& text) QCheckBox* DolphinFacetsWidget::createCheckBox(const QString& text)
{ {
QCheckBox* checkBox = new QCheckBox(text); QCheckBox* checkBox = new QCheckBox(text);

View file

@ -22,9 +22,9 @@
#include <QWidget> #include <QWidget>
#include <config-nepomuk.h> #include <config-baloo.h>
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
#include <Nepomuk2/Query/Term> #include <baloo/term.h>
#endif #endif
class QButtonGroup; class QButtonGroup;
@ -55,8 +55,9 @@ public:
explicit DolphinFacetsWidget(QWidget* parent = 0); explicit DolphinFacetsWidget(QWidget* parent = 0);
virtual ~DolphinFacetsWidget(); virtual ~DolphinFacetsWidget();
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
Nepomuk2::Query::Term facetsTerm() const; Baloo::Term ratingTerm() const;
QStringList facetTypes() const;
#endif #endif
signals: signals:

View file

@ -21,7 +21,6 @@
#include "dolphin_searchsettings.h" #include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h" #include "dolphinfacetswidget.h"
#include "dolphinsearchinformation.h"
#include <KIcon> #include <KIcon>
#include <KLineEdit> #include <KLineEdit>
@ -40,18 +39,11 @@
#include <QToolButton> #include <QToolButton>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <config-nepomuk.h> #include <config-baloo.h>
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
#include <Nepomuk2/Query/AndTerm> #include <baloo/query.h>
#include <Nepomuk2/Query/FileQuery> #include <baloo/term.h>
#include <Nepomuk2/Query/LiteralTerm> #include <baloo/indexerconfig.h>
#include <Nepomuk2/Query/OrTerm>
#include <Nepomuk2/Query/Query>
#include <Nepomuk2/Query/QueryParser>
#include <Nepomuk2/Query/ResourceTypeTerm>
#include <Nepomuk2/Query/ComparisonTerm>
#include <Nepomuk2/ResourceManager>
#include <Nepomuk2/Vocabulary/NFO>
#endif #endif
DolphinSearchBox::DolphinSearchBox(QWidget* parent) : DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
@ -115,8 +107,8 @@ void DolphinSearchBox::setSearchPath(const KUrl& url)
m_fromHereButton->setVisible(showSearchFromButtons); m_fromHereButton->setVisible(showSearchFromButtons);
m_everywhereButton->setVisible(showSearchFromButtons); m_everywhereButton->setVisible(showSearchFromButtons);
const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); const Baloo::IndexerConfig searchInfo;
const bool hasFacetsSupport = searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath); const bool hasFacetsSupport = searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile());
m_facetsWidget->setEnabled(hasFacetsSupport); m_facetsWidget->setEnabled(hasFacetsSupport);
} }
@ -128,9 +120,9 @@ KUrl DolphinSearchBox::searchPath() const
KUrl DolphinSearchBox::urlForSearching() const KUrl DolphinSearchBox::urlForSearching() const
{ {
KUrl url; KUrl url;
const DolphinSearchInformation& searchInfo = DolphinSearchInformation::instance(); const Baloo::IndexerConfig searchInfo;
if (searchInfo.isIndexingEnabled() && searchInfo.isPathIndexed(m_searchPath)) { if (searchInfo.fileIndexingEnabled() && searchInfo.shouldBeIndexed(m_searchPath.toLocalFile())) {
url = nepomukUrlForSearching(); url = balooUrlForSearching();
} else { } else {
url.setProtocol("filenamesearch"); url.setProtocol("filenamesearch");
url.addQueryItem("search", m_searchInput->text()); url.addQueryItem("search", m_searchInput->text());
@ -430,52 +422,34 @@ void DolphinSearchBox::init()
applyReadOnlyState(); applyReadOnlyState();
} }
KUrl DolphinSearchBox::nepomukUrlForSearching() const KUrl DolphinSearchBox::balooUrlForSearching() const
{ {
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
// Create the term for the text from the input-field
// dependent on whether a searching for content or
// filename is done
const QString text = m_searchInput->text(); const QString text = m_searchInput->text();
Nepomuk2::Query::Term searchLabelTerm;
if (m_contentButton->isChecked()) { Baloo::Query query;
// Let Nepomuk parse the query query.addType("File");
searchLabelTerm = Nepomuk2::Query::QueryParser::parseQuery(text, Nepomuk2::Query::QueryParser::DetectFilenamePattern).term(); query.addTypes(m_facetsWidget->facetTypes());
} else {
// Search the text in the filename only Baloo::Term term(Baloo::Term::And);
QString regex = QRegExp::escape(text);
regex.replace("\\*", QLatin1String(".*")); Baloo::Term ratingTerm = m_facetsWidget->ratingTerm();
regex.replace("\\?", QLatin1String(".")); if (ratingTerm.isValid()) {
regex.replace("\\", "\\\\"); term.addSubTerm(ratingTerm);
searchLabelTerm = Nepomuk2::Query::ComparisonTerm(
Nepomuk2::Vocabulary::NFO::fileName(),
Nepomuk2::Query::LiteralTerm(regex),
Nepomuk2::Query::ComparisonTerm::Regexp);
} }
// Get the term from the facets and merge it with the if (m_contentButton->isChecked()) {
// created term from the input-field. query.setSearchString(text);
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);
} else { } else {
fileQuery.setTerm(searchLabelTerm); term.addSubTerm(Baloo::Term("filename", text));
} }
if (m_fromHereButton->isChecked()) { if (m_fromHereButton->isChecked()) {
const bool recursive = true; query.addCustomOption("includeFolder", m_searchPath.toLocalFile());
fileQuery.addIncludeFolder(m_searchPath, recursive);
} }
return fileQuery.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.", return query.toSearchUrl(i18nc("@title UDS_DISPLAY_NAME for a KIO directory listing. %1 is the query the user entered.",
"Query Results from '%1'", "Query Results from '%1'", text));
text));
#else #else
return KUrl(); return KUrl();
#endif #endif
@ -483,9 +457,9 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const
void DolphinSearchBox::applyReadOnlyState() void DolphinSearchBox::applyReadOnlyState()
{ {
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
if (m_readOnly) { if (m_readOnly) {
m_searchLabel->setText(Nepomuk2::Query::Query::titleFromQueryUrl(m_readOnlyQuery)); m_searchLabel->setText(Baloo::Query::titleFromQueryUrl(m_readOnlyQuery));
} else { } else {
#else #else
{ {

View file

@ -33,13 +33,13 @@ class QLabel;
class QVBoxLayout; 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: * The widget allows to specify:
* - Where to search: Everywhere or below the current directory * - Where to search: Everywhere or below the current directory
* - What to search: Filenames or content * - 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. * options are offered.
*/ */
class DolphinSearchBox : public QWidget { class DolphinSearchBox : public QWidget {
@ -151,9 +151,9 @@ private:
void init(); 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(); void applyReadOnlyState();

View file

@ -1,124 +0,0 @@
/***************************************************************************
* Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
* *
* 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 <config-nepomuk.h>
#ifdef HAVE_NEPOMUK
#include <KConfig>
#include <KConfigGroup>
#include <Nepomuk2/ResourceManager>
#endif
#include <KGlobal>
#include <KUrl>
#include <QFileInfo>
#include <QDir>
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
}

View file

@ -1,57 +0,0 @@
/***************************************************************************
* Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
* *
* 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

View file

@ -19,7 +19,7 @@
#include "additionalinfodialog.h" #include "additionalinfodialog.h"
#include <config-nepomuk.h> #include <config-baloo.h>
#include <KLocale> #include <KLocale>
#include "kitemviews/kfileitemmodel.h" #include "kitemviews/kfileitemmodel.h"
@ -27,8 +27,8 @@
#include <QLabel> #include <QLabel>
#include <QVBoxLayout> #include <QVBoxLayout>
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
#include <Nepomuk2/ResourceManager> #include <baloo/indexerconfig.h>
#endif #endif
AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent, AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
@ -50,14 +50,10 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
header->setWordWrap(true); header->setWordWrap(true);
// Add checkboxes // Add checkboxes
bool nepomukRunning = false;
bool indexingEnabled = false; bool indexingEnabled = false;
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); Baloo::IndexerConfig config;
if (nepomukRunning) { indexingEnabled = config.fileIndexingEnabled();
KConfig config("nepomukserverrc");
indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
}
#endif #endif
m_listWidget = new QListWidget(mainWidget); m_listWidget = new QListWidget(mainWidget);
@ -67,8 +63,8 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
QListWidgetItem* item = new QListWidgetItem(info.translation, m_listWidget); QListWidgetItem* item = new QListWidgetItem(info.translation, m_listWidget);
item->setCheckState(visibleRoles.contains(info.role) ? Qt::Checked : Qt::Unchecked); item->setCheckState(visibleRoles.contains(info.role) ? Qt::Checked : Qt::Unchecked);
const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) || const bool enable = (!info.requiresBaloo && !info.requiresIndexer) ||
(info.requiresNepomuk && nepomukRunning) || (info.requiresBaloo) ||
(info.requiresIndexer && indexingEnabled); (info.requiresIndexer && indexingEnabled);
if (!enable) { if (!enable) {

View file

@ -27,10 +27,7 @@
#include "dolphin_iconsmodesettings.h" #include "dolphin_iconsmodesettings.h"
#include "viewpropsprogressinfo.h" #include "viewpropsprogressinfo.h"
#include <config-nepomuk.h> #include <config-baloo.h>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/ResourceManager>
#endif
#include <KComponentData> #include <KComponentData>
#include <KLocale> #include <KLocale>

View file

@ -89,19 +89,18 @@ kde4_add_unit_test(kitemlistkeyboardsearchmanagertest TEST ${kitemlistkeyboardse
target_link_libraries(kitemlistkeyboardsearchmanagertest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) target_link_libraries(kitemlistkeyboardsearchmanagertest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY})
# DolphinSearchBox # DolphinSearchBox
if (Nepomuk_FOUND) if (Baloo_FOUND)
set(dolphinsearchboxtest_SRCS set(dolphinsearchboxtest_SRCS
dolphinsearchboxtest.cpp dolphinsearchboxtest.cpp
../search/dolphinfacetswidget.cpp ../search/dolphinfacetswidget.cpp
../search/dolphinsearchbox.cpp ../search/dolphinsearchbox.cpp
../search/dolphinsearchinformation.cpp
) )
kde4_add_kcfg_files(dolphinsearchboxtest_SRCS kde4_add_kcfg_files(dolphinsearchboxtest_SRCS
../search/dolphin_searchsettings.kcfgc ../search/dolphin_searchsettings.kcfgc
) )
kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS}) kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS})
target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${SOPRANO_LIBRARIES} ${NEPOMUK_CORE_LIBRARY} nepomukutils ${QT_QTTEST_LIBRARY}) target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${BALOO_LIBRARIES} ${QT_QTTEST_LIBRARY})
endif (Nepomuk_FOUND) endif (Baloo_FOUND)
# KStandardItemModelTest # KStandardItemModelTest
set(kstandarditemmodeltest_SRCS set(kstandarditemmodeltest_SRCS

View file

@ -20,7 +20,7 @@
#include "dolphinview.h" #include "dolphinview.h"
#include <config-nepomuk.h> #include <config-baloo.h>
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QApplication> #include <QApplication>
@ -74,8 +74,8 @@
#include "views/tooltips/tooltipmanager.h" #include "views/tooltips/tooltipmanager.h"
#include "zoomlevelinfo.h" #include "zoomlevelinfo.h"
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
#include <Nepomuk2/ResourceManager> #include <baloo/indexerconfig.h>
#endif #endif
namespace { namespace {
@ -870,14 +870,10 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
KItemListView* view = m_container->controller()->view(); KItemListView* view = m_container->controller()->view();
const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet(); const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
bool nepomukRunning = false;
bool indexingEnabled = false; bool indexingEnabled = false;
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); Baloo::IndexerConfig config;
if (nepomukRunning) { indexingEnabled = config.fileIndexingEnabled();
KConfig config("nepomukserverrc");
indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
}
#endif #endif
QString groupName; QString groupName;
@ -908,8 +904,8 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
action->setChecked(visibleRolesSet.contains(info.role)); action->setChecked(visibleRolesSet.contains(info.role));
action->setData(info.role); action->setData(info.role);
const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) || const bool enable = (!info.requiresBaloo && !info.requiresIndexer) ||
(info.requiresNepomuk && nepomukRunning) || (info.requiresBaloo) ||
(info.requiresIndexer && indexingEnabled); (info.requiresIndexer && indexingEnabled);
action->setEnabled(enable); action->setEnabled(enable);
} }

View file

@ -21,7 +21,7 @@
#ifndef DOLPHINVIEW_H #ifndef DOLPHINVIEW_H
#define DOLPHINVIEW_H #define DOLPHINVIEW_H
#include <config-nepomuk.h> #include <config-baloo.h>
#include "libdolphin_export.h" #include "libdolphin_export.h"

View file

@ -20,7 +20,7 @@
#include "dolphinviewactionhandler.h" #include "dolphinviewactionhandler.h"
#include <config-nepomuk.h> #include <config-baloo.h>
#include "settings/viewpropertiesdialog.h" #include "settings/viewpropertiesdialog.h"
#include "views/dolphinview.h" #include "views/dolphinview.h"
@ -39,12 +39,12 @@
#include <KPropertiesDialog> #include <KPropertiesDialog>
#include <KIcon> #include <KIcon>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/ResourceManager>
#endif
#include <KDebug> #include <KDebug>
#ifdef HAVE_BALOO
#include <baloo/indexerconfig.h>
#endif
DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) : DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) :
QObject(parent), QObject(parent),
m_actionCollection(collection), m_actionCollection(collection),
@ -237,14 +237,10 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
KActionMenu* groupMenu = 0; KActionMenu* groupMenu = 0;
QActionGroup* groupMenuGroup = 0; QActionGroup* groupMenuGroup = 0;
bool nepomukRunning = false;
bool indexingEnabled = false; bool indexingEnabled = false;
#ifdef HAVE_NEPOMUK #ifdef HAVE_BALOO
nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized()); Baloo::IndexerConfig config;
if (nepomukRunning) { indexingEnabled = config.fileIndexingEnabled();
KConfig config("nepomukserverrc");
indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
}
#endif #endif
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation(); const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
@ -284,8 +280,8 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
action->setText(info.translation); action->setText(info.translation);
action->setData(info.role); action->setData(info.role);
const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) || const bool enable = (!info.requiresBaloo && !info.requiresIndexer) ||
(info.requiresNepomuk && nepomukRunning) || (info.requiresBaloo) ||
(info.requiresIndexer && indexingEnabled); (info.requiresIndexer && indexingEnabled);
action->setEnabled(enable); action->setEnabled(enable);

View file

@ -34,10 +34,10 @@
#include <QTextLayout> #include <QTextLayout>
#include <QTextLine> #include <QTextLine>
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
#include <KFileMetaDataWidget> #include <KFileMetaDataWidget>
#else #else
#include <nepomuk2/filemetadatawidget.h> #include <baloo/filemetadatawidget.h>
#endif #endif
// For the blurred tooltip background // For the blurred tooltip background
@ -70,10 +70,10 @@ FileMetaDataToolTip::FileMetaDataToolTip(QWidget* parent) :
m_name->setMaximumWidth(fontMetrics.averageCharWidth() * 40); m_name->setMaximumWidth(fontMetrics.averageCharWidth() * 40);
// Create widget for the meta data // Create widget for the meta data
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
m_fileMetaDataWidget = new KFileMetaDataWidget(this); m_fileMetaDataWidget = new KFileMetaDataWidget(this);
#else #else
m_fileMetaDataWidget = new Nepomuk2::FileMetaDataWidget(this); m_fileMetaDataWidget = new Baloo::FileMetaDataWidget(this);
#endif #endif
m_fileMetaDataWidget->setForegroundRole(QPalette::ToolTipText); m_fileMetaDataWidget->setForegroundRole(QPalette::ToolTipText);
m_fileMetaDataWidget->setReadOnly(true); m_fileMetaDataWidget->setReadOnly(true);

View file

@ -23,15 +23,15 @@
#define FILEMETADATATOOLTIP_H #define FILEMETADATATOOLTIP_H
#include <QWidget> #include <QWidget>
#include "config-nepomuk.h" #include "config-baloo.h"
class KFileItemList; class KFileItemList;
class QLabel; class QLabel;
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
class KFileMetaDataWidget; class KFileMetaDataWidget;
#else #else
namespace Nepomuk2 { namespace Baloo {
class FileMetaDataWidget; class FileMetaDataWidget;
} }
#endif #endif
@ -76,10 +76,10 @@ protected:
private: private:
QLabel* m_preview; QLabel* m_preview;
QLabel* m_name; QLabel* m_name;
#ifndef HAVE_NEPOMUK #ifndef HAVE_BALOO
KFileMetaDataWidget* m_fileMetaDataWidget; KFileMetaDataWidget* m_fileMetaDataWidget;
#else #else
Nepomuk2::FileMetaDataWidget* m_fileMetaDataWidget; Baloo::FileMetaDataWidget* m_fileMetaDataWidget;
#endif #endif
}; };

View file

@ -160,7 +160,7 @@ private:
/** /**
* @return A hash-value for an URL that can be used as directory name. * @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); static QString directoryHashForUrl(const KUrl& url);