mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
Port Dolphin from Nepomuk to Nepomuk2 according to the Nepomuk2Port mini guide on techbase - http://techbase.kde.org/Projects/Nepomuk/Nepomuk2Port
REVIEW: 106825
This commit is contained in:
parent
c239ae19de
commit
a9b04801db
|
@ -1,6 +1,6 @@
|
|||
macro_optional_find_package(Nepomuk)
|
||||
macro_log_feature(Nepomuk_FOUND "Nepomuk" "Nepomuk" "http://www.kde.org" FALSE "" "For adding desktop-wide tagging support to dolphin")
|
||||
macro_bool_to_01(Nepomuk_FOUND HAVE_NEPOMUK)
|
||||
macro_optional_find_package(NepomukCore)
|
||||
macro_log_feature(NepomukCore_FOUND "Nepomuk" "Nepomuk" "http://www.kde.org" FALSE "" "For adding desktop-wide tagging support to dolphin")
|
||||
macro_bool_to_01(NepomukCore_FOUND HAVE_NEPOMUK)
|
||||
configure_file(config-nepomuk.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-nepomuk.h )
|
||||
|
||||
macro_bool_to_01(X11_Xrender_FOUND HAVE_XRENDER)
|
||||
|
@ -8,10 +8,10 @@ configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h )
|
|||
|
||||
include_directories( ${KACTIVITIES_INCLUDE_DIRS} )
|
||||
|
||||
if (Nepomuk_FOUND)
|
||||
if (NepomukCore_FOUND)
|
||||
# Yes, Soprano includes is what we need here
|
||||
include_directories( ${SOPRANO_INCLUDE_DIR} ${NEPOMUK_INCLUDE_DIR} )
|
||||
endif (Nepomuk_FOUND)
|
||||
include_directories( ${SOPRANO_INCLUDE_DIR} ${NEPOMUK_CORE_INCLUDE_DIR} )
|
||||
endif (NepomukCore_FOUND)
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
|
@ -73,21 +73,12 @@ set(dolphinprivate_LIB_SRCS
|
|||
views/zoomlevelinfo.cpp
|
||||
)
|
||||
|
||||
if (Nepomuk_FOUND)
|
||||
if (NepomukCore_FOUND)
|
||||
set(dolphinprivate_LIB_SRCS
|
||||
${dolphinprivate_LIB_SRCS}
|
||||
kitemviews/private/knepomukrolesprovider.cpp
|
||||
kitemviews/private/nepomuk/resourcewatcher.cpp
|
||||
)
|
||||
|
||||
qt4_add_dbus_interface(dolphinprivate_LIB_SRCS
|
||||
kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcherConnection.xml
|
||||
resourcewatcherconnectioninterface)
|
||||
|
||||
qt4_add_dbus_interface(dolphinprivate_LIB_SRCS
|
||||
kitemviews/private/nepomuk/org.kde.nepomuk.ResourceWatcher.xml
|
||||
resourcewatchermanagerinterface)
|
||||
endif (Nepomuk_FOUND)
|
||||
endif (NepomukCore_FOUND)
|
||||
|
||||
kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
|
||||
settings/dolphin_compactmodesettings.kcfgc
|
||||
|
@ -107,15 +98,13 @@ target_link_libraries(
|
|||
${KDE4_KNEWSTUFF3_LIBS}
|
||||
)
|
||||
|
||||
if (Nepomuk_FOUND)
|
||||
if (NepomukCore_FOUND)
|
||||
target_link_libraries(
|
||||
dolphinprivate
|
||||
${NEPOMUK_LIBRARIES}
|
||||
${NEPOMUK_QUERY_LIBRARIES}
|
||||
nepomukutils
|
||||
${NEPOMUK_CORE_LIBRARY}
|
||||
${SOPRANO_LIBRARIES}
|
||||
)
|
||||
endif (Nepomuk_FOUND)
|
||||
endif (NepomukCore_FOUND)
|
||||
|
||||
if(X11_Xrender_FOUND)
|
||||
target_link_libraries(dolphinprivate ${X11_Xrender_LIB})
|
||||
|
@ -235,14 +224,12 @@ target_link_libraries(kdeinit_dolphin
|
|||
${KDE4_PHONON_LIBS}
|
||||
)
|
||||
|
||||
if (Nepomuk_FOUND)
|
||||
if (NepomukCore_FOUND)
|
||||
target_link_libraries(kdeinit_dolphin
|
||||
${NEPOMUK_LIBRARIES}
|
||||
${NEPOMUK_CORE_LIBRARY}
|
||||
${SOPRANO_LIBRARIES}
|
||||
${NEPOMUK_QUERY_LIBRARIES}
|
||||
nepomukutils
|
||||
)
|
||||
endif (Nepomuk_FOUND)
|
||||
endif (NepomukCore_FOUND)
|
||||
|
||||
if (KActivities_FOUND)
|
||||
target_link_libraries(
|
||||
|
@ -313,12 +300,12 @@ 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 (Nepomuk_FOUND)
|
||||
target_link_libraries(kcm_dolphinviewmodes ${NEPOMUK_LIBRARIES})
|
||||
target_link_libraries(kcm_dolphinnavigation ${NEPOMUK_LIBRARIES})
|
||||
target_link_libraries(kcm_dolphinservices ${NEPOMUK_LIBRARIES})
|
||||
target_link_libraries(kcm_dolphingeneral ${NEPOMUK_LIBRARIES})
|
||||
endif (Nepomuk_FOUND)
|
||||
if (NepomukCore_FOUND)
|
||||
target_link_libraries(kcm_dolphinviewmodes ${NEPOMUK_CORE_LIBRARY})
|
||||
target_link_libraries(kcm_dolphinnavigation ${NEPOMUK_CORE_LIBRARY})
|
||||
target_link_libraries(kcm_dolphinservices ${NEPOMUK_CORE_LIBRARY})
|
||||
target_link_libraries(kcm_dolphingeneral ${NEPOMUK_CORE_LIBRARY})
|
||||
endif (NepomukCore_FOUND)
|
||||
|
||||
install(TARGETS kcm_dolphinviewmodes DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
install(TARGETS kcm_dolphinnavigation DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include "private/knepomukrolesprovider.h"
|
||||
#include "private/nepomuk/resourcewatcher.h"
|
||||
#include <Nepomuk2/ResourceWatcher>
|
||||
#endif
|
||||
|
||||
// Required includes for subItemsCount():
|
||||
|
@ -276,15 +276,15 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
|
|||
if (hasNepomukRole && !m_nepomukResourceWatcher) {
|
||||
Q_ASSERT(m_nepomukUriItems.isEmpty());
|
||||
|
||||
m_nepomukResourceWatcher = new Nepomuk::ResourceWatcher(this);
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(propertyChanged(Nepomuk::Resource,Nepomuk::Types::Property,QVariantList,QVariantList)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource)));
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(propertyRemoved(Nepomuk::Resource,Nepomuk::Types::Property,QVariant)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource)));
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(propertyAdded(Nepomuk::Resource,Nepomuk::Types::Property,QVariant)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource)));
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(resourceCreated(Nepomuk::Resource,QList<QUrl>)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk::Resource)));
|
||||
m_nepomukResourceWatcher = new Nepomuk2::ResourceWatcher(this);
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(propertyChanged(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariantList,QVariantList)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource)));
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(propertyRemoved(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariant)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource)));
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(propertyAdded(Nepomuk2::Resource,Nepomuk2::Types::Property,QVariant)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource)));
|
||||
connect(m_nepomukResourceWatcher, SIGNAL(resourceCreated(Nepomuk2::Resource,QList<QUrl>)),
|
||||
this, SLOT(applyChangedNepomukRoles(Nepomuk2::Resource)));
|
||||
} else if (!hasNepomukRole && m_nepomukResourceWatcher) {
|
||||
delete m_nepomukResourceWatcher;
|
||||
m_nepomukResourceWatcher = 0;
|
||||
|
@ -351,14 +351,14 @@ void KFileItemModelRolesUpdater::slotItemsRemoved(const KItemRangeList& itemRang
|
|||
if (m_nepomukResourceWatcher) {
|
||||
// Don't let the ResourceWatcher watch for removed items
|
||||
if (allItemsRemoved) {
|
||||
m_nepomukResourceWatcher->setResources(QList<Nepomuk::Resource>());
|
||||
m_nepomukResourceWatcher->setResources(QList<Nepomuk2::Resource>());
|
||||
m_nepomukResourceWatcher->stop();
|
||||
m_nepomukUriItems.clear();
|
||||
} else {
|
||||
QList<Nepomuk::Resource> newResources;
|
||||
const QList<Nepomuk::Resource> oldResources = m_nepomukResourceWatcher->resources();
|
||||
foreach (const Nepomuk::Resource& resource, oldResources) {
|
||||
const QUrl uri = resource.resourceUri();
|
||||
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);
|
||||
if (m_model->index(itemUrl) >= 0) {
|
||||
newResources.append(resource);
|
||||
|
@ -588,10 +588,10 @@ void KFileItemModelRolesUpdater::resolveChangedItems()
|
|||
startUpdating(itemRanges);
|
||||
}
|
||||
|
||||
void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk::Resource& resource)
|
||||
void KFileItemModelRolesUpdater::applyChangedNepomukRoles(const Nepomuk2::Resource& resource)
|
||||
{
|
||||
#ifdef HAVE_NEPOMUK
|
||||
const KUrl itemUrl = m_nepomukUriItems.value(resource.resourceUri());
|
||||
const KUrl itemUrl = m_nepomukUriItems.value(resource.uri());
|
||||
const KFileItem item = m_model->fileItem(itemUrl);
|
||||
|
||||
if (item.isNull()) {
|
||||
|
@ -1071,19 +1071,19 @@ QHash<QByteArray, QVariant> KFileItemModelRolesUpdater::rolesData(const KFileIte
|
|||
#ifdef HAVE_NEPOMUK
|
||||
if (m_nepomukResourceWatcher) {
|
||||
const KNepomukRolesProvider& rolesProvider = KNepomukRolesProvider::instance();
|
||||
Nepomuk::Resource resource(item.nepomukUri());
|
||||
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.resourceUri();
|
||||
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.resourceUri();
|
||||
uri = resource.uri();
|
||||
}
|
||||
if (!uri.isEmpty() && !m_nepomukUriItems.contains(uri)) {
|
||||
m_nepomukResourceWatcher->addResource(resource);
|
||||
|
|
|
@ -39,7 +39,7 @@ class QPixmap;
|
|||
class QTimer;
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
namespace Nepomuk
|
||||
namespace Nepomuk2
|
||||
{
|
||||
class ResourceWatcher;
|
||||
class Resource;
|
||||
|
@ -47,7 +47,7 @@ class QTimer;
|
|||
#else
|
||||
// Required for the slot applyChangedNepomukRoles() that
|
||||
// cannot be ifdefined due to moc.
|
||||
namespace Nepomuk
|
||||
namespace Nepomuk2
|
||||
{
|
||||
class Resource;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ private slots:
|
|||
*/
|
||||
void resolveChangedItems();
|
||||
|
||||
void applyChangedNepomukRoles(const Nepomuk::Resource& resource);
|
||||
void applyChangedNepomukRoles(const Nepomuk2::Resource& resource);
|
||||
|
||||
/**
|
||||
* Is invoked if a directory watched by KDirWatch got dirty. Updates
|
||||
|
@ -274,7 +274,7 @@ private:
|
|||
mutable QSet<QString> m_watchedDirs; // Required as sadly KDirWatch does not offer a getter method
|
||||
// to get all watched directories.
|
||||
#ifdef HAVE_NEPOMUK
|
||||
Nepomuk::ResourceWatcher* m_nepomukResourceWatcher;
|
||||
Nepomuk2::ResourceWatcher* m_nepomukResourceWatcher;
|
||||
mutable QHash<QUrl, KUrl> m_nepomukUriItems;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
#include <KGlobal>
|
||||
#include <KLocale>
|
||||
|
||||
#include <Nepomuk/Resource>
|
||||
#include <Nepomuk/Tag>
|
||||
#include <Nepomuk/Types/Property>
|
||||
#include <Nepomuk/Variant>
|
||||
#include <Nepomuk2/Resource>
|
||||
#include <Nepomuk2/Tag>
|
||||
#include <Nepomuk2/Types/Property>
|
||||
#include <Nepomuk2/Variant>
|
||||
|
||||
#include <QTime>
|
||||
|
||||
|
@ -51,7 +51,7 @@ QSet<QByteArray> KNepomukRolesProvider::roles() const
|
|||
return m_roles;
|
||||
}
|
||||
|
||||
QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Resource& resource,
|
||||
QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk2::Resource& resource,
|
||||
const QSet<QByteArray>& roles) const
|
||||
{
|
||||
if (!resource.isValid()) {
|
||||
|
@ -63,17 +63,17 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Res
|
|||
int width = -1;
|
||||
int height = -1;
|
||||
|
||||
QHashIterator<QUrl, Nepomuk::Variant> it(resource.properties());
|
||||
QHashIterator<QUrl, Nepomuk2::Variant> it(resource.properties());
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
|
||||
const Nepomuk::Types::Property property = it.key();
|
||||
const Nepomuk2::Types::Property property = it.key();
|
||||
const QByteArray role = m_roleForUri.value(property.uri());
|
||||
if (role.isEmpty() || !roles.contains(role)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Nepomuk::Variant value = it.value();
|
||||
const Nepomuk2::Variant value = it.value();
|
||||
|
||||
if (role == "imageSize") {
|
||||
// Merge the two Nepomuk properties for width and height
|
||||
|
@ -101,7 +101,7 @@ QHash<QByteArray, QVariant> KNepomukRolesProvider::roleValues(const Nepomuk::Res
|
|||
const QString duration = durationFromValue(value.toInt());
|
||||
values.insert(role, duration);
|
||||
} else if (value.isResource()) {
|
||||
const Nepomuk::Resource resource = value.toResource();
|
||||
const Nepomuk2::Resource resource = value.toResource();
|
||||
values.insert(role, resource.genericLabel());
|
||||
} else {
|
||||
values.insert(role, value.toString());
|
||||
|
@ -155,7 +155,7 @@ QString KNepomukRolesProvider::tagsFromValues(const QStringList& values) const
|
|||
tags.append(QLatin1String(", "));
|
||||
}
|
||||
|
||||
const Nepomuk::Tag tag(values[i]);
|
||||
const Nepomuk2::Tag tag(values[i]);
|
||||
tags += tag.genericLabel();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <QSet>
|
||||
#include <QUrl>
|
||||
|
||||
namespace Nepomuk
|
||||
namespace Nepomuk2
|
||||
{
|
||||
class Resource;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ 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 Nepomuk::Resource& resource,
|
||||
QHash<QByteArray, QVariant> roleValues(const Nepomuk2::Resource& resource,
|
||||
const QSet<QByteArray>& roles) const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
The files in this directory are a copy of kde-runtime/nepomuk. They
|
||||
are updated manually until the Nepomuk resoure-watcher is made
|
||||
public in a future release of the Nepomuk API.
|
|
@ -1,14 +0,0 @@
|
|||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.kde.nepomuk.ResourceWatcher">
|
||||
<method name="stopWatcher">
|
||||
<arg name="objectName" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="watch">
|
||||
<arg name="resources" type="as" direction="in"/>
|
||||
<arg name="properties" type="as" direction="in"/>
|
||||
<arg name="types" type="as" direction="in"/>
|
||||
<arg name="queryobject" type="o" direction="out" />
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
|
@ -1,65 +0,0 @@
|
|||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.kde.nepomuk.ResourceWatcherConnection">
|
||||
<signal name="resourceCreated">
|
||||
<arg name="uri" type="s" direction="out"/>
|
||||
<arg name="types" type="as" direction="out"/>
|
||||
</signal>
|
||||
<signal name="resourceRemoved">
|
||||
<arg name="uri" type="s" direction="out"/>
|
||||
<arg name="types" type="as" direction="out"/>
|
||||
</signal>
|
||||
<signal name="resourceTypesAdded">
|
||||
<arg name="resUri" type="s" direction="out"/>
|
||||
<arg name="types" type="as" direction="out"/>
|
||||
</signal>
|
||||
<signal name="resourceTypesRemoved">
|
||||
<arg name="resUri" type="s" direction="out"/>
|
||||
<arg name="types" type="as" direction="out"/>
|
||||
</signal>
|
||||
<signal name="propertyAdded">
|
||||
<arg name="resource" type="s" direction="out"/>
|
||||
<arg name="property" type="s" direction="out"/>
|
||||
<arg name="values" type="av" direction="out"/>
|
||||
</signal>
|
||||
<signal name="propertyRemoved">
|
||||
<arg name="resource" type="s" direction="out"/>
|
||||
<arg name="property" type="s" direction="out"/>
|
||||
<arg name="values" type="av" direction="out"/>
|
||||
</signal>
|
||||
<signal name="propertyChanged">
|
||||
<arg name="resource" type="s" direction="out"/>
|
||||
<arg name="property" type="s" direction="out"/>
|
||||
<arg name="addedValues" type="av" direction="out"/>
|
||||
<arg name="removedValues" type="av" direction="out"/>
|
||||
</signal>
|
||||
<method name="setResources">
|
||||
<arg name="resources" type="as" direction="in"/>
|
||||
</method>
|
||||
<method name="addResource">
|
||||
<arg name="resource" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="removeResource">
|
||||
<arg name="resource" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="setProperties">
|
||||
<arg name="properties" type="as" direction="in"/>
|
||||
</method>
|
||||
<method name="addProperty">
|
||||
<arg name="property" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="removeProperty">
|
||||
<arg name="property" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="setTypes">
|
||||
<arg name="types" type="as" direction="in"/>
|
||||
</method>
|
||||
<method name="addType">
|
||||
<arg name="type" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="removeType">
|
||||
<arg name="type" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="close" />
|
||||
</interface>
|
||||
</node>
|
|
@ -1,299 +0,0 @@
|
|||
/*
|
||||
This file is part of the Nepomuk KDE project.
|
||||
Copyright (C) 2011 Vishesh Handa <handa.vish@gmail.com>
|
||||
Copyright (C) 2011-2012 Sebastian Trueg <trueg@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#include "resourcewatcher.h"
|
||||
#include "resourcewatcherconnectioninterface.h"
|
||||
#include "resourcewatchermanagerinterface.h"
|
||||
|
||||
#include <QtDBus/QDBusObjectPath>
|
||||
|
||||
#include <nepomuk/resource.h>
|
||||
#include <nepomuk/resourcemanager.h>
|
||||
|
||||
#include <KUrl>
|
||||
#include <KDebug>
|
||||
|
||||
namespace {
|
||||
QString convertUri(const QUrl& uri) {
|
||||
return KUrl(uri).url();
|
||||
}
|
||||
|
||||
QStringList convertUris(const QList<QUrl>& uris) {
|
||||
QStringList cs;
|
||||
foreach(const QUrl& uri, uris) {
|
||||
cs << convertUri(uri);
|
||||
}
|
||||
return cs;
|
||||
}
|
||||
|
||||
QList<QUrl> convertUris(const QStringList& uris) {
|
||||
QList<QUrl> us;
|
||||
foreach(const QString& uri, uris) {
|
||||
us << KUrl(uri);
|
||||
}
|
||||
return us;
|
||||
}
|
||||
}
|
||||
|
||||
class Nepomuk::ResourceWatcher::Private {
|
||||
public:
|
||||
QList<QUrl> m_types;
|
||||
QList<QUrl> m_resources;
|
||||
QList<QUrl> m_properties;
|
||||
|
||||
org::kde::nepomuk::ResourceWatcherConnection * m_connectionInterface;
|
||||
org::kde::nepomuk::ResourceWatcher * m_watchManagerInterface;
|
||||
};
|
||||
|
||||
Nepomuk::ResourceWatcher::ResourceWatcher(QObject* parent)
|
||||
: QObject(parent),
|
||||
d(new Private)
|
||||
{
|
||||
d->m_watchManagerInterface
|
||||
= new org::kde::nepomuk::ResourceWatcher( "org.kde.nepomuk.DataManagement",
|
||||
"/resourcewatcher",
|
||||
QDBusConnection::sessionBus() );
|
||||
d->m_connectionInterface = 0;
|
||||
}
|
||||
|
||||
Nepomuk::ResourceWatcher::~ResourceWatcher()
|
||||
{
|
||||
stop();
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool Nepomuk::ResourceWatcher::start()
|
||||
{
|
||||
stop();
|
||||
|
||||
//
|
||||
// Convert to list of strings
|
||||
//
|
||||
QList<QString> uris = convertUris(d->m_resources);
|
||||
QList<QString> props = convertUris(d->m_properties);
|
||||
QList<QString> types_ = convertUris(d->m_types);
|
||||
|
||||
//
|
||||
// Watch for the RW service to (re-)appear and then re-connect to make sure we always get updates
|
||||
// We create this watcher even if we fail to connect below. Thus, once the rw service comes up we
|
||||
// can re-attach.
|
||||
//
|
||||
connect(ResourceManager::instance(), SIGNAL(nepomukSystemStarted()), this, SLOT(start()));
|
||||
|
||||
//
|
||||
// Create the dbus object to watch
|
||||
//
|
||||
QDBusPendingReply<QDBusObjectPath> reply = d->m_watchManagerInterface->watch( uris, props, types_ );
|
||||
QDBusObjectPath path = reply.value();
|
||||
|
||||
if(!path.path().isEmpty()) {
|
||||
d->m_connectionInterface = new org::kde::nepomuk::ResourceWatcherConnection( "org.kde.nepomuk.DataManagement",
|
||||
path.path(),
|
||||
QDBusConnection::sessionBus() );
|
||||
connect( d->m_connectionInterface, SIGNAL(propertyAdded(QString,QString,QVariantList)),
|
||||
this, SLOT(slotPropertyAdded(QString,QString,QVariantList)) );
|
||||
connect( d->m_connectionInterface, SIGNAL(propertyRemoved(QString,QString,QVariantList)),
|
||||
this, SLOT(slotPropertyRemoved(QString,QString,QVariantList)) );
|
||||
connect( d->m_connectionInterface, SIGNAL(resourceCreated(QString,QStringList)),
|
||||
this, SLOT(slotResourceCreated(QString,QStringList)) );
|
||||
connect( d->m_connectionInterface, SIGNAL(propertyChanged(QString,QString,QVariantList,QVariantList)),
|
||||
this, SLOT(slotPropertyChanged(QString,QString,QVariantList,QVariantList)) );
|
||||
connect( d->m_connectionInterface, SIGNAL(resourceRemoved(QString,QStringList)),
|
||||
this, SLOT(slotResourceRemoved(QString,QStringList)) );
|
||||
connect( d->m_connectionInterface, SIGNAL(resourceTypesAdded(QString,QStringList)),
|
||||
this, SLOT(slotResourceTypesAdded(QString,QStringList)) );
|
||||
connect( d->m_connectionInterface, SIGNAL(resourceTypesRemoved(QString,QStringList)),
|
||||
this, SLOT(slotResourceTypesRemoved(QString,QStringList)) );
|
||||
|
||||
kDebug() << "Successfully connected to watch service";
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
kDebug() << "Failed to connect to watch service" << reply.error().message();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::stop()
|
||||
{
|
||||
if (d->m_connectionInterface) {
|
||||
d->m_connectionInterface->close();
|
||||
delete d->m_connectionInterface;
|
||||
d->m_connectionInterface = 0;
|
||||
}
|
||||
|
||||
disconnect(ResourceManager::instance(), SIGNAL(nepomukSystemStarted()), this, SLOT(start()));
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::addProperty(const Nepomuk::Types::Property& property)
|
||||
{
|
||||
d->m_properties << property.uri();
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->addProperty(convertUri(property.uri()));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::addResource(const Nepomuk::Resource& res)
|
||||
{
|
||||
d->m_resources << res.resourceUri();
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->addResource(convertUri(res.resourceUri()));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::addType(const Nepomuk::Types::Class& type)
|
||||
{
|
||||
d->m_types << type.uri();
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->addType(convertUri(type.uri()));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::removeProperty(const Nepomuk::Types::Property& property)
|
||||
{
|
||||
d->m_properties.removeAll(property.uri());
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->removeProperty(convertUri(property.uri()));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::removeResource(const Nepomuk::Resource& res)
|
||||
{
|
||||
d->m_resources.removeAll(res.resourceUri());
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->removeResource(convertUri(res.resourceUri()));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::removeType(const Nepomuk::Types::Class& type)
|
||||
{
|
||||
d->m_types.removeAll(type.uri());
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->removeType(convertUri(type.uri()));
|
||||
}
|
||||
}
|
||||
|
||||
QList< Nepomuk::Types::Property > Nepomuk::ResourceWatcher::properties() const
|
||||
{
|
||||
QList< Nepomuk::Types::Property > props;
|
||||
foreach(const QUrl& uri, d->m_properties)
|
||||
props << Types::Property(uri);
|
||||
return props;
|
||||
}
|
||||
|
||||
QList<Nepomuk::Resource> Nepomuk::ResourceWatcher::resources() const
|
||||
{
|
||||
QList<Nepomuk::Resource> resources;
|
||||
foreach(const QUrl& uri, d->m_resources)
|
||||
resources << Resource::fromResourceUri(uri);
|
||||
return resources;
|
||||
}
|
||||
|
||||
QList< Nepomuk::Types::Class > Nepomuk::ResourceWatcher::types() const
|
||||
{
|
||||
QList<Nepomuk::Types::Class> types;
|
||||
foreach(const QUrl& uri, d->m_types)
|
||||
types << Types::Class(uri);
|
||||
return types;
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::setProperties(const QList< Nepomuk::Types::Property >& properties_)
|
||||
{
|
||||
d->m_properties.clear();
|
||||
foreach(const Nepomuk::Types::Property& p, properties_) {
|
||||
d->m_properties << p.uri();
|
||||
}
|
||||
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->setProperties(convertUris(d->m_properties));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::setResources(const QList< Nepomuk::Resource >& resources_)
|
||||
{
|
||||
d->m_resources.clear();
|
||||
foreach(const Nepomuk::Resource& res, resources_) {
|
||||
d->m_resources << res.resourceUri();
|
||||
}
|
||||
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->setResources(convertUris(d->m_resources));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::setTypes(const QList< Nepomuk::Types::Class >& types_)
|
||||
{
|
||||
d->m_types.clear();
|
||||
foreach(const Nepomuk::Types::Class& t, types_) {
|
||||
d->m_types << t.uri();
|
||||
}
|
||||
|
||||
if(d->m_connectionInterface) {
|
||||
d->m_connectionInterface->setTypes(convertUris(d->m_types));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::slotResourceCreated(const QString &res, const QStringList &types)
|
||||
{
|
||||
emit resourceCreated(Nepomuk::Resource::fromResourceUri(KUrl(res)), convertUris(types));
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::slotResourceRemoved(const QString &res, const QStringList &types)
|
||||
{
|
||||
emit resourceRemoved(KUrl(res), convertUris(types));
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::slotResourceTypesAdded(const QString &res, const QStringList &types)
|
||||
{
|
||||
foreach(const QString& type, types) {
|
||||
emit resourceTypeAdded(KUrl(res), KUrl(type));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::slotResourceTypesRemoved(const QString &res, const QStringList &types)
|
||||
{
|
||||
foreach(const QString& type, types) {
|
||||
emit resourceTypeRemoved(KUrl(res), KUrl(type));
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::slotPropertyAdded(const QString& res, const QString& prop, const QVariantList &objects)
|
||||
{
|
||||
foreach(const QVariant& v, objects) {
|
||||
emit propertyAdded( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ), v );
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::slotPropertyRemoved(const QString& res, const QString& prop, const QVariantList &objects)
|
||||
{
|
||||
foreach(const QVariant& v, objects) {
|
||||
emit propertyRemoved( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ), v );
|
||||
}
|
||||
}
|
||||
|
||||
void Nepomuk::ResourceWatcher::slotPropertyChanged(const QString& res, const QString& prop, const QVariantList& oldObjs, const QVariantList& newObjs)
|
||||
{
|
||||
emit propertyChanged( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ),
|
||||
oldObjs, newObjs );
|
||||
}
|
||||
|
||||
#include "resourcewatcher.moc"
|
||||
|
|
@ -1,319 +0,0 @@
|
|||
/*
|
||||
This file is part of the Nepomuk KDE project.
|
||||
Copyright (C) 2011 Vishesh Handa <handa.vish@gmail.com>
|
||||
Copyright (C) 2011 Sebastian Trueg <trueg@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RESOURCEWATCHER_H
|
||||
#define RESOURCEWATCHER_H
|
||||
|
||||
#include <Nepomuk/Types/Class>
|
||||
#include <Nepomuk/Types/Property>
|
||||
#include <Nepomuk/Resource>
|
||||
|
||||
#include <QtDBus/QDBusVariant>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
//#include "nepomukdatamanagement_export.h"
|
||||
|
||||
namespace Nepomuk {
|
||||
|
||||
/**
|
||||
* \class ResourceWatcher resourcewatcher.h
|
||||
*
|
||||
* \brief Selectively monitor the nepomuk repository for changes.
|
||||
*
|
||||
* Resources may be monitored on the basis of types, properties, and uris.
|
||||
*
|
||||
* Changes may be monitored in one of the following ways:
|
||||
* -# By resources -
|
||||
* Specify the exact resources that should be watched. Any changes made to the specified resources
|
||||
* (Excluding \ref nepomuk_dms_metadata) will be notified through the propertyAdded() and propertyRemoved()
|
||||
* signals. Notifications will also be sent if any of the watched resources is deleted.
|
||||
* -# By resources and properties -
|
||||
* Specify the exact resources and their properties. Any changes made to the specified resources
|
||||
* which touch one of the specified properties will be notified through the propertyAdded() and propertyRemoved()
|
||||
* signals.
|
||||
* -# By types -
|
||||
* Specific types may be specified via add/setType. If types are set, then notifications will be
|
||||
* sent for all new resources of that type. This includes property changes and resource creation and removal.
|
||||
* TODO: add flags that allow to only watch for resource creation and removal.
|
||||
* -# By types and properties -
|
||||
* Both the types and properties may be specified. Notifications will be sent for property changes
|
||||
* in resource with the specified types.
|
||||
*
|
||||
* \section nepomuk_rw_examples Resource Watcher Usage Example
|
||||
*
|
||||
* The following code creates a new ResourceWatcher, configures it to listen to changes on the \c nmm:performer
|
||||
* property on one specific resource \c res.
|
||||
*
|
||||
* \code
|
||||
* Nepomuk::ResourceWatcher* watcher = new Nepomuk::ResourceWatcher(this);
|
||||
* watcher->addResource(res);
|
||||
* watcher->addProperty(NMM:performer());
|
||||
* connect(watcher, SIGNAL(propertyAdded(Nepomuk::Resource, Nepomuk::Types::Property, QVariant)),
|
||||
* this, SLOT(slotPropertyChanged()));
|
||||
* connect(watcher, SIGNAL(propertyRemoved(Nepomuk::Resource, Nepomuk::Types::Property, QVariant)),
|
||||
* this, SLOT(slotPropertyChanged()));
|
||||
* rwatcher->start();
|
||||
* \endcode
|
||||
*
|
||||
* \author Vishesh Handa <handa.vish@gmail.com>, Sebastian Trueg <trueg@kde.org>
|
||||
*
|
||||
* \ingroup nepomuk_datamanagement
|
||||
*/
|
||||
class ResourceWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Create a new %ResourceWatcher instance.
|
||||
*
|
||||
* This instance will not emit any signals before it has been configured
|
||||
* and started.
|
||||
*/
|
||||
ResourceWatcher( QObject* parent = 0 );
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*/
|
||||
virtual ~ResourceWatcher();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* \brief Add a type to be watched.
|
||||
*
|
||||
* Every resource of this type will be watched for changes.
|
||||
*
|
||||
* \sa setTypes()
|
||||
*/
|
||||
void addType( const Types::Class & type );
|
||||
|
||||
/**
|
||||
* \brief Add a resource to be watched.
|
||||
*
|
||||
* Every change to this resource will be
|
||||
* signalled, depending on the configured properties().
|
||||
*
|
||||
* \sa setResources()
|
||||
*/
|
||||
void addResource( const Nepomuk::Resource & res );
|
||||
|
||||
/**
|
||||
* \brief Add a property to be watched.
|
||||
*
|
||||
* Every change to a value of this property
|
||||
* will be signalled, depending on the configured resources() or types().
|
||||
*
|
||||
* \sa setProperties()
|
||||
*/
|
||||
void addProperty( const Types::Property & property );
|
||||
|
||||
/**
|
||||
* \brief Remove a type to be watched.
|
||||
*
|
||||
* Every resource of this type will be watched for changes.
|
||||
*
|
||||
* \sa setTypes()
|
||||
*/
|
||||
void removeType( const Types::Class & type );
|
||||
|
||||
/**
|
||||
* \brief Remove a resource to be watched.
|
||||
*
|
||||
* Every change to this resource will be
|
||||
* signalled, depending on the configured properties().
|
||||
*
|
||||
* \sa setResources()
|
||||
*/
|
||||
void removeResource( const Nepomuk::Resource & res );
|
||||
|
||||
/**
|
||||
* \brief Remove a property to be watched.
|
||||
*
|
||||
* Every change to a value of this property
|
||||
* will be signalled, depending on the configured resources() or types().
|
||||
*
|
||||
* \sa setProperties()
|
||||
*/
|
||||
void removeProperty( const Types::Property & property );
|
||||
|
||||
/**
|
||||
* \brief Set the types to be watched.
|
||||
*
|
||||
* Every resource having one of these types will be watched for changes.
|
||||
*
|
||||
* \sa addType()
|
||||
*/
|
||||
void setTypes( const QList<Types::Class> & types_ );
|
||||
|
||||
/**
|
||||
* \brief Set the resources to be watched.
|
||||
*
|
||||
* Every change to one of these resources will be
|
||||
* signalled, depending on the configured properties().
|
||||
*
|
||||
* \sa addResource()
|
||||
*/
|
||||
void setResources( const QList<Nepomuk::Resource> & resources_ );
|
||||
|
||||
/**
|
||||
* \brief Set the properties to be watched.
|
||||
*
|
||||
* Every change to a value of any of these properties
|
||||
* will be signalled, depending on the configured resources() or types().
|
||||
*
|
||||
* \sa addProperty()
|
||||
*/
|
||||
void setProperties( const QList<Types::Property> & properties_ );
|
||||
|
||||
/**
|
||||
* \brief The types that have been configured via addType() and setTypes().
|
||||
*
|
||||
* Every resource having one of these types will be watched
|
||||
* for changes.
|
||||
*/
|
||||
QList<Types::Class> types() const;
|
||||
|
||||
/**
|
||||
* \brief The resources that have been configured via addResource() and setResources().
|
||||
*
|
||||
* Every change to one of these resources will be
|
||||
* signalled, depending on the configured properties().
|
||||
*/
|
||||
QList<Nepomuk::Resource> resources() const;
|
||||
|
||||
/**
|
||||
* \brief The properties that have been configured via addProperty() and setProperties().
|
||||
*
|
||||
* Every change to a value of any of these properties
|
||||
* will be signalled, depending on the configured resources() or types().
|
||||
*/
|
||||
QList<Types::Property> properties() const;
|
||||
|
||||
/**
|
||||
* \brief Start the signalling of changes.
|
||||
*
|
||||
* Before calling this method no signal will be emitted. In
|
||||
* combination with stop() this allows to suspend the watching.
|
||||
* Calling start() multiple times has no effect.
|
||||
*/
|
||||
bool start();
|
||||
|
||||
/**
|
||||
* \brief Stop the signalling of changes.
|
||||
*
|
||||
* Allows to stop the watcher which has been started
|
||||
* via start(). Calling stop() multiple times has no effect.
|
||||
*/
|
||||
void stop();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* \brief This signal is emitted when a new resource is created.
|
||||
* \param resource The newly created resource.
|
||||
* \param types The types the new resource has. If types() have been configured this list will always
|
||||
* contain one of the configured types.
|
||||
*/
|
||||
void resourceCreated( const Nepomuk::Resource & resource, const QList<QUrl>& types ); //FIXME: Use either Resource or uri, not a mix
|
||||
|
||||
/**
|
||||
* \brief This signal is emitted when a resource is deleted.
|
||||
* \param uri The resource URI of the removed resource.
|
||||
* \param types The types the removed resource had. If types() have been configured this list will always
|
||||
* contain one of the configured types.
|
||||
*/
|
||||
void resourceRemoved( const QUrl & uri, const QList<QUrl>& types );
|
||||
|
||||
/**
|
||||
* \brief This signal is emitted when a type has been added to a resource. This does not include creation which
|
||||
* is signalled via resourceCreated(). It only applies to changes in a resource's types.
|
||||
* \param res The changed resource.
|
||||
* \param type The newly added type. If types() have been configured it will be one of them.
|
||||
*/
|
||||
void resourceTypeAdded( const Nepomuk::Resource & res, const Nepomuk::Types::Class & type );
|
||||
|
||||
/**
|
||||
* \brief This signal is emitted when a type has been removed from a resource.
|
||||
*
|
||||
* This does not include removal of entire resources which is signalled via resourceRemoved().
|
||||
* It only applies to changes in a resource's types.
|
||||
* \param res The changed resource.
|
||||
* \param type The removed type. If types() have been configured it will be one of them.
|
||||
*/
|
||||
void resourceTypeRemoved( const Nepomuk::Resource & res, const Nepomuk::Types::Class & type );
|
||||
|
||||
/**
|
||||
* \brief This signal is emitted when a property value is added.
|
||||
* \param resource The changed resource.
|
||||
* \param property The property which has a new value.
|
||||
* \param value The newly added property value.
|
||||
*/
|
||||
void propertyAdded( const Nepomuk::Resource & resource,
|
||||
const Nepomuk::Types::Property & property,
|
||||
const QVariant & value );
|
||||
|
||||
/**
|
||||
* \brief This signal is emitted when a property value is removed.
|
||||
* \param resource The changed resource.
|
||||
* \param property The property which was changed.
|
||||
* \param value The removed property value.
|
||||
*/
|
||||
void propertyRemoved( const Nepomuk::Resource & resource,
|
||||
const Nepomuk::Types::Property & property,
|
||||
const QVariant & value );
|
||||
|
||||
/**
|
||||
* \brief This signal is emitted when a property value is changed.
|
||||
*
|
||||
* This signal is essentially a combination of the propertyAdded and propertyRemoved signals.
|
||||
*
|
||||
* Be aware that removing and then adding a property will result in two separate
|
||||
* propertyChanged signals. They are never combined.
|
||||
*
|
||||
* Specially, since one could theoretically take forever between the removal and the
|
||||
* setting of the property.
|
||||
*
|
||||
* \param resource The changed resource.
|
||||
* \param property The property which was changed.
|
||||
* \param addedValues The values that have been added.
|
||||
* \param removedValues The values that have been removed.
|
||||
*/
|
||||
void propertyChanged( const Nepomuk::Resource & resource,
|
||||
const Nepomuk::Types::Property & property,
|
||||
const QVariantList & addedValues,
|
||||
const QVariantList & removedValues );
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotResourceCreated(const QString& res, const QStringList& types);
|
||||
void slotResourceRemoved(const QString& res, const QStringList& types);
|
||||
void slotResourceTypesAdded(const QString& res, const QStringList& types);
|
||||
void slotResourceTypesRemoved(const QString& res, const QStringList& types);
|
||||
void slotPropertyAdded(const QString& res, const QString& prop, const QVariantList& objects);
|
||||
void slotPropertyRemoved(const QString& res, const QString& prop, const QVariantList& objects);
|
||||
void slotPropertyChanged(const QString& res, const QString& prop,
|
||||
const QVariantList & oldObjs,
|
||||
const QVariantList & newObjs);
|
||||
private:
|
||||
class Private;
|
||||
Private * d;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // RESOURCEWATCHER_H
|
|
@ -51,13 +51,13 @@
|
|||
#include <views/viewproperties.h>
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk/Query/ComparisonTerm>
|
||||
#include <Nepomuk/Query/LiteralTerm>
|
||||
#include <Nepomuk/Query/FileQuery>
|
||||
#include <Nepomuk/Query/ResourceTypeTerm>
|
||||
#include <Nepomuk/Vocabulary/NFO>
|
||||
#include <Nepomuk/Vocabulary/NIE>
|
||||
#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>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
@ -87,7 +87,7 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
|
|||
m_storageSetupInProgress()
|
||||
{
|
||||
#ifdef HAVE_NEPOMUK
|
||||
if (Nepomuk::ResourceManager::instance()->initialized()) {
|
||||
if (Nepomuk2::ResourceManager::instance()->initialized()) {
|
||||
KConfig config("nepomukserverrc");
|
||||
m_fileIndexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false);
|
||||
}
|
||||
|
@ -1150,15 +1150,15 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
|
|||
#ifdef HAVE_NEPOMUK
|
||||
const QString path = url.pathOrUrl();
|
||||
if (path.endsWith(QLatin1String("documents"))) {
|
||||
searchUrl = searchUrlForTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Document()));
|
||||
searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document()));
|
||||
} else if (path.endsWith(QLatin1String("images"))) {
|
||||
searchUrl = searchUrlForTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Image()));
|
||||
searchUrl = searchUrlForTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image()));
|
||||
} else if (path.endsWith(QLatin1String("audio"))) {
|
||||
searchUrl = searchUrlForTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk::Query::LiteralTerm("audio")));
|
||||
searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk2::Query::LiteralTerm("audio")));
|
||||
} else if (path.endsWith(QLatin1String("videos"))) {
|
||||
searchUrl = searchUrlForTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk::Query::LiteralTerm("video")));
|
||||
searchUrl = searchUrlForTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk2::Query::LiteralTerm("video")));
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
@ -1170,9 +1170,9 @@ KUrl PlacesItemModel::createSearchUrl(const KUrl& url)
|
|||
}
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
KUrl PlacesItemModel::searchUrlForTerm(const Nepomuk::Query::Term& term)
|
||||
KUrl PlacesItemModel::searchUrlForTerm(const Nepomuk2::Query::Term& term)
|
||||
{
|
||||
const Nepomuk::Query::FileQuery query(term);
|
||||
const Nepomuk2::Query::FileQuery query(term);
|
||||
return query.toSearchUrl();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@ class QAction;
|
|||
class QTimer;
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
namespace Nepomuk
|
||||
namespace Nepomuk2
|
||||
{
|
||||
namespace Query
|
||||
{
|
||||
|
@ -255,7 +255,7 @@ private:
|
|||
* @return URL that can be listed by KIO and results in searching
|
||||
* for the given term.
|
||||
*/
|
||||
static KUrl searchUrlForTerm(const Nepomuk::Query::Term& term);
|
||||
static KUrl searchUrlForTerm(const Nepomuk2::Query::Term& term);
|
||||
#endif
|
||||
|
||||
#ifdef PLACESITEMMODEL_DEBUG
|
||||
|
|
|
@ -28,14 +28,14 @@
|
|||
#include <QVBoxLayout>
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/Query/AndTerm>
|
||||
#include <Nepomuk/Query/ComparisonTerm>
|
||||
#include <Nepomuk/Query/LiteralTerm>
|
||||
#include <Nepomuk/Query/OrTerm>
|
||||
#include <Nepomuk/Query/Query>
|
||||
#include <Nepomuk/Query/ResourceTypeTerm>
|
||||
#include <Nepomuk/Vocabulary/NFO>
|
||||
#include <Nepomuk/Vocabulary/NIE>
|
||||
#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
|
||||
|
||||
|
@ -121,33 +121,33 @@ DolphinFacetsWidget::~DolphinFacetsWidget()
|
|||
}
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
Nepomuk::Query::Term DolphinFacetsWidget::facetsTerm() const
|
||||
Nepomuk2::Query::Term DolphinFacetsWidget::facetsTerm() const
|
||||
{
|
||||
Nepomuk::Query::AndTerm andTerm;
|
||||
Nepomuk2::Query::AndTerm andTerm;
|
||||
|
||||
const bool hasTypeFilter = m_documents->isChecked() ||
|
||||
m_images->isChecked() ||
|
||||
m_audio->isChecked() ||
|
||||
m_videos->isChecked();
|
||||
if (hasTypeFilter) {
|
||||
Nepomuk::Query::OrTerm orTerm;
|
||||
Nepomuk2::Query::OrTerm orTerm;
|
||||
|
||||
if (m_documents->isChecked()) {
|
||||
orTerm.addSubTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Document()));
|
||||
orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Document()));
|
||||
}
|
||||
|
||||
if (m_images->isChecked()) {
|
||||
orTerm.addSubTerm(Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::NFO::Image()));
|
||||
orTerm.addSubTerm(Nepomuk2::Query::ResourceTypeTerm(Nepomuk2::Vocabulary::NFO::Image()));
|
||||
}
|
||||
|
||||
if (m_audio->isChecked()) {
|
||||
orTerm.addSubTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk::Query::LiteralTerm("audio")));
|
||||
orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk2::Query::LiteralTerm("audio")));
|
||||
}
|
||||
|
||||
if (m_videos->isChecked()) {
|
||||
orTerm.addSubTerm(Nepomuk::Query::ComparisonTerm(Nepomuk::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk::Query::LiteralTerm("video")));
|
||||
orTerm.addSubTerm(Nepomuk2::Query::ComparisonTerm(Nepomuk2::Vocabulary::NIE::mimeType(),
|
||||
Nepomuk2::Query::LiteralTerm("video")));
|
||||
}
|
||||
|
||||
andTerm.addSubTerm(orTerm);
|
||||
|
@ -166,9 +166,9 @@ Nepomuk::Query::Term DolphinFacetsWidget::facetsTerm() const
|
|||
}
|
||||
|
||||
const int rating = stars * 2;
|
||||
Nepomuk::Query::ComparisonTerm term(Soprano::Vocabulary::NAO::numericRating(),
|
||||
Nepomuk::Query::LiteralTerm(rating),
|
||||
Nepomuk::Query::ComparisonTerm::GreaterOrEqual);
|
||||
Nepomuk2::Query::ComparisonTerm term(Soprano::Vocabulary::NAO::numericRating(),
|
||||
Nepomuk2::Query::LiteralTerm(rating),
|
||||
Nepomuk2::Query::ComparisonTerm::GreaterOrEqual);
|
||||
andTerm.addSubTerm(term);
|
||||
}
|
||||
|
||||
|
@ -184,9 +184,9 @@ Nepomuk::Query::Term DolphinFacetsWidget::facetsTerm() const
|
|||
date.addDays(1 - date.dayOfYear());
|
||||
}
|
||||
|
||||
Nepomuk::Query::ComparisonTerm term(Nepomuk::Vocabulary::NIE::lastModified(),
|
||||
Nepomuk::Query::LiteralTerm(QDateTime(date)),
|
||||
Nepomuk::Query::ComparisonTerm::GreaterOrEqual);
|
||||
Nepomuk2::Query::ComparisonTerm term(Nepomuk2::Vocabulary::NIE::lastModified(),
|
||||
Nepomuk2::Query::LiteralTerm(QDateTime(date)),
|
||||
Nepomuk2::Query::ComparisonTerm::GreaterOrEqual);
|
||||
andTerm.addSubTerm(term);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include <config-nepomuk.h>
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/Query/Term>
|
||||
#include <Nepomuk2/Query/Term>
|
||||
#endif
|
||||
|
||||
class QButtonGroup;
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
virtual ~DolphinFacetsWidget();
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
Nepomuk::Query::Term facetsTerm() const;
|
||||
Nepomuk2::Query::Term facetsTerm() const;
|
||||
#endif
|
||||
|
||||
signals:
|
||||
|
|
|
@ -42,16 +42,16 @@
|
|||
|
||||
#include <config-nepomuk.h>
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/Query/AndTerm>
|
||||
#include <Nepomuk/Query/FileQuery>
|
||||
#include <Nepomuk/Query/LiteralTerm>
|
||||
#include <Nepomuk/Query/OrTerm>
|
||||
#include <Nepomuk/Query/Query>
|
||||
#include <Nepomuk/Query/QueryParser>
|
||||
#include <Nepomuk/Query/ResourceTypeTerm>
|
||||
#include <Nepomuk/Query/ComparisonTerm>
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk/Vocabulary/NFO>
|
||||
#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>
|
||||
#endif
|
||||
|
||||
DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
|
||||
|
@ -402,30 +402,30 @@ KUrl DolphinSearchBox::nepomukUrlForSearching() const
|
|||
// dependent on whether a searching for content or
|
||||
// filename is done
|
||||
const QString text = m_searchInput->text();
|
||||
Nepomuk::Query::Term searchLabelTerm;
|
||||
Nepomuk2::Query::Term searchLabelTerm;
|
||||
if (m_contentButton->isChecked()) {
|
||||
// Let Nepomuk parse the query
|
||||
searchLabelTerm = Nepomuk::Query::QueryParser::parseQuery(text, Nepomuk::Query::QueryParser::DetectFilenamePattern).term();
|
||||
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 = Nepomuk::Query::ComparisonTerm(
|
||||
Nepomuk::Vocabulary::NFO::fileName(),
|
||||
Nepomuk::Query::LiteralTerm(regex),
|
||||
Nepomuk::Query::ComparisonTerm::Regexp);
|
||||
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
|
||||
// created term from the input-field.
|
||||
Nepomuk::Query::Term facetsTerm = m_facetsWidget->facetsTerm();
|
||||
Nepomuk2::Query::Term facetsTerm = m_facetsWidget->facetsTerm();
|
||||
|
||||
Nepomuk::Query::FileQuery fileQuery;
|
||||
fileQuery.setFileMode(Nepomuk::Query::FileQuery::QueryFilesAndFolders);
|
||||
Nepomuk2::Query::FileQuery fileQuery;
|
||||
fileQuery.setFileMode(Nepomuk2::Query::FileQuery::QueryFilesAndFolders);
|
||||
if (facetsTerm.isValid()) {
|
||||
Nepomuk::Query::AndTerm andTerm;
|
||||
Nepomuk2::Query::AndTerm andTerm;
|
||||
andTerm.addSubTerm(searchLabelTerm);
|
||||
andTerm.addSubTerm(facetsTerm);
|
||||
fileQuery.setTerm(andTerm);
|
||||
|
@ -450,7 +450,7 @@ void DolphinSearchBox::applyReadOnlyState()
|
|||
{
|
||||
#ifdef HAVE_NEPOMUK
|
||||
if (m_readOnly) {
|
||||
m_searchLabel->setText(Nepomuk::Query::Query::titleFromQueryUrl(m_readOnlyQuery));
|
||||
m_searchLabel->setText(Nepomuk2::Query::Query::titleFromQueryUrl(m_readOnlyQuery));
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifdef HAVE_NEPOMUK
|
||||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk2/ResourceManager>
|
||||
#endif
|
||||
|
||||
#include <KGlobal>
|
||||
|
@ -90,7 +90,7 @@ DolphinSearchInformation::DolphinSearchInformation() :
|
|||
m_indexingEnabled(false)
|
||||
{
|
||||
#ifdef HAVE_NEPOMUK
|
||||
if (Nepomuk::ResourceManager::instance()->initialized()) {
|
||||
if (Nepomuk2::ResourceManager::instance()->initialized()) {
|
||||
KConfig config("nepomukserverrc");
|
||||
m_indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <QVBoxLayout>
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk2/ResourceManager>
|
||||
#endif
|
||||
|
||||
AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
|
||||
|
@ -53,7 +53,7 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
|
|||
bool nepomukRunning = false;
|
||||
bool indexingEnabled = false;
|
||||
#ifdef HAVE_NEPOMUK
|
||||
nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized());
|
||||
nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized());
|
||||
if (nepomukRunning) {
|
||||
KConfig config("nepomukserverrc");
|
||||
indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <config-nepomuk.h>
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk2/ResourceManager>
|
||||
#endif
|
||||
|
||||
#include <KComponentData>
|
||||
|
|
|
@ -68,7 +68,7 @@ if (Nepomuk_FOUND)
|
|||
../search/dolphin_searchsettings.kcfgc
|
||||
)
|
||||
kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS})
|
||||
target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${SOPRANO_LIBRARIES} ${NEPOMUK_LIBRARIES} ${NEPOMUK_QUERY_LIBRARIES} nepomukutils ${QT_QTTEST_LIBRARY})
|
||||
target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${SOPRANO_LIBRARIES} ${NEPOMUK_CORE_LIBRARY} nepomukutils ${QT_QTTEST_LIBRARY})
|
||||
endif (Nepomuk_FOUND)
|
||||
|
||||
# KStandardItemModelTest
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
#include "zoomlevelinfo.h"
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk2/ResourceManager>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
@ -843,7 +843,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
|
|||
bool nepomukRunning = false;
|
||||
bool indexingEnabled = false;
|
||||
#ifdef HAVE_NEPOMUK
|
||||
nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized());
|
||||
nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized());
|
||||
if (nepomukRunning) {
|
||||
KConfig config("nepomukserverrc");
|
||||
indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <KIcon>
|
||||
|
||||
#ifdef HAVE_NEPOMUK
|
||||
#include <Nepomuk/ResourceManager>
|
||||
#include <Nepomuk2/ResourceManager>
|
||||
#endif
|
||||
|
||||
#include <KDebug>
|
||||
|
@ -237,7 +237,7 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
|
|||
bool nepomukRunning = false;
|
||||
bool indexingEnabled = false;
|
||||
#ifdef HAVE_NEPOMUK
|
||||
nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized());
|
||||
nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized());
|
||||
if (nepomukRunning) {
|
||||
KConfig config("nepomukserverrc");
|
||||
indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false);
|
||||
|
|
Loading…
Reference in a new issue