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)
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} )

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
#define DOLPHIN_MAINWINDOW_H
#include <config-nepomuk.h>
#include <config-baloo.h>
#include <KFileItemDelegate>
#include <kio/fileundomanager.h>

View file

@ -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()

View file

@ -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;

View file

@ -673,7 +673,7 @@ QList<KFileItemModel::RoleInfo> 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 },

View file

@ -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<RoleInfo> 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;
};

View file

@ -40,10 +40,11 @@
#include <algorithm>
#ifdef HAVE_NEPOMUK
#include "private/knepomukrolesprovider.h"
#include <Nepomuk2/ResourceWatcher>
#include <Nepomuk2/ResourceManager>
#ifdef HAVE_BALOO
#include "private/kbaloorolesprovider.h"
#include <baloo/file.h>
#include <baloo/filefetchjob.h>
#include <baloo/filemonitor.h>
#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<QByteArray>& roles)
if (m_roles != roles) {
m_roles = roles;
#ifdef HAVE_NEPOMUK
if (Nepomuk2::ResourceManager::instance()->initialized()) {
#ifdef HAVE_BALOO
// 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)
// 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 KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance();
bool hasNepomukRole = false;
const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance();
bool hasBalooRole = false;
QSetIterator<QByteArray> it(roles);
while (it.hasNext()) {
const QByteArray& role = it.next();
if (rolesProvider.roles().contains(role)) {
hasNepomukRole = true;
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<Nepomuk2::Resource>());
m_nepomukResourceWatcher->stop();
m_nepomukUriItems.clear();
m_balooFileMonitor->clear();
} else {
QList<Nepomuk2::Resource> newResources;
const QList<Nepomuk2::Resource> 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<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();
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<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.
// See bug 322348
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()) {
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<QByteArray>)),
this, SLOT(slotItemsChanged(KItemRangeList,QSet<QByteArray>)));
#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<QByteArray, QVariant> 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<QByteArray, QVariant> 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<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());
}
#ifdef HAVE_BALOO
if (m_balooFileMonitor) {
m_balooFileMonitor->addFile(item.localPath());
applyChangedBalooRoles(item.localPath());
}
#endif
return data;
}

View file

@ -20,7 +20,7 @@
#ifndef KFILEITEMMODELROLESUPDATER_H
#define KFILEITEMMODELROLESUPDATER_H
#include <config-nepomuk.h>
#include <config-baloo.h>
#include <KFileItem>
#include <kitemviews/kitemmodelbase.h>
@ -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<QUrl, KUrl> m_nepomukUriItems;
#ifdef HAVE_BALOO
Baloo::FileMonitor* m_balooFileMonitor;
#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) 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 *
@ -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 <libdolphin_export.h>
@ -26,25 +27,24 @@
#include <QSet>
#include <QUrl>
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<QByteArray> 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<QByteArray, QVariant> roleValues(const Nepomuk2::Resource& resource,
QHash<QByteArray, QVariant> roleValues(const Baloo::File& file,
const QSet<QByteArray>& 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<QByteArray> m_roles;
QHash<QUrl, QByteArray> m_roleForUri;
QHash<QString, QByteArray> m_roleForProperty;
friend class KNepomukRolesProviderSingleton;
friend class KBalooRolesProviderSingleton;
};
#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"
#ifndef HAVE_NEPOMUK
#ifndef HAVE_BALOO
#include <kfilemetadataconfigurationwidget.h>
#else
#include <nepomuk2/filemetadataconfigwidget.h>
#include <baloo/filemetadataconfigwidget.h>
#endif
#include <KLocale>
@ -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

View file

@ -22,12 +22,12 @@
#include <KDialog>
#include <KFileItem>
#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
};

View file

@ -31,10 +31,10 @@
#include <kseparator.h>
#include <KStringHandler>
#ifndef HAVE_NEPOMUK
#ifndef HAVE_BALOO
#include <KFileMetaDataWidget>
#else
#include <nepomuk2/filemetadatawidget.h>
#include <baloo/filemetadatawidget.h>
#endif
#include <panels/places/placesitem.h>
@ -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);
}
}

View file

@ -20,7 +20,7 @@
#ifndef INFORMATIONPANELCONTENT_H
#define INFORMATIONPANELCONTENT_H
#include "config-nepomuk.h"
#include "config-baloo.h"
#include <KConfig>
#include <KFileItem>
#include <KUrl>
@ -41,10 +41,10 @@ namespace KIO {
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;

View file

@ -51,22 +51,17 @@
#include <views/dolphinview.h>
#include <views/viewproperties.h>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/ResourceManager>
#include <Nepomuk2/Query/ComparisonTerm>
#include <Nepomuk2/Query/LiteralTerm>
#include <Nepomuk2/Query/FileQuery>
#include <Nepomuk2/Query/ResourceTypeTerm>
#include <Nepomuk2/Vocabulary/NFO>
#include <Nepomuk2/Vocabulary/NIE>
#ifdef HAVE_BALOO
#include <baloo/query.h>
#include <baloo/indexerconfig.h>
#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

View file

@ -20,7 +20,7 @@
#ifndef PLACESITEMMODEL_H
#define PLACESITEMMODEL_H
#include <config-nepomuk.h>
#include <config-baloo.h>
#include <kitemviews/kstandarditemmodel.h>
@ -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

View file

@ -27,18 +27,6 @@
#include <QHBoxLayout>
#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) :
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);

View file

@ -22,9 +22,9 @@
#include <QWidget>
#include <config-nepomuk.h>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/Query/Term>
#include <config-baloo.h>
#ifdef HAVE_BALOO
#include <baloo/term.h>
#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:

View file

@ -21,7 +21,6 @@
#include "dolphin_searchsettings.h"
#include "dolphinfacetswidget.h"
#include "dolphinsearchinformation.h"
#include <KIcon>
#include <KLineEdit>
@ -40,18 +39,11 @@
#include <QToolButton>
#include <QVBoxLayout>
#include <config-nepomuk.h>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/Query/AndTerm>
#include <Nepomuk2/Query/FileQuery>
#include <Nepomuk2/Query/LiteralTerm>
#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>
#include <config-baloo.h>
#ifdef HAVE_BALOO
#include <baloo/query.h>
#include <baloo/term.h>
#include <baloo/indexerconfig.h>
#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
{

View file

@ -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();

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 <config-nepomuk.h>
#include <config-baloo.h>
#include <KLocale>
#include "kitemviews/kfileitemmodel.h"
@ -27,8 +27,8 @@
#include <QLabel>
#include <QVBoxLayout>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/ResourceManager>
#ifdef HAVE_BALOO
#include <baloo/indexerconfig.h>
#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) {

View file

@ -27,10 +27,7 @@
#include "dolphin_iconsmodesettings.h"
#include "viewpropsprogressinfo.h"
#include <config-nepomuk.h>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/ResourceManager>
#endif
#include <config-baloo.h>
#include <KComponentData>
#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})
# 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

View file

@ -20,7 +20,7 @@
#include "dolphinview.h"
#include <config-nepomuk.h>
#include <config-baloo.h>
#include <QAbstractItemView>
#include <QApplication>
@ -74,8 +74,8 @@
#include "views/tooltips/tooltipmanager.h"
#include "zoomlevelinfo.h"
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/ResourceManager>
#ifdef HAVE_BALOO
#include <baloo/indexerconfig.h>
#endif
namespace {
@ -870,14 +870,10 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
KItemListView* view = m_container->controller()->view();
const QSet<QByteArray> 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);
}

View file

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

View file

@ -20,7 +20,7 @@
#include "dolphinviewactionhandler.h"
#include <config-nepomuk.h>
#include <config-baloo.h>
#include "settings/viewpropertiesdialog.h"
#include "views/dolphinview.h"
@ -39,12 +39,12 @@
#include <KPropertiesDialog>
#include <KIcon>
#ifdef HAVE_NEPOMUK
#include <Nepomuk2/ResourceManager>
#endif
#include <KDebug>
#ifdef HAVE_BALOO
#include <baloo/indexerconfig.h>
#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<KFileItemModel::RoleInfo> 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);

View file

@ -34,10 +34,10 @@
#include <QTextLayout>
#include <QTextLine>
#ifndef HAVE_NEPOMUK
#ifndef HAVE_BALOO
#include <KFileMetaDataWidget>
#else
#include <nepomuk2/filemetadatawidget.h>
#include <baloo/filemetadatawidget.h>
#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);

View file

@ -23,15 +23,15 @@
#define FILEMETADATATOOLTIP_H
#include <QWidget>
#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
};

View file

@ -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);