Page MenuHomePhorge

No OneTemporary

diff --git a/nepomuk/CMakeLists.txt b/nepomuk/CMakeLists.txt
index 3319b9d53a..04cdc72b81 100644
--- a/nepomuk/CMakeLists.txt
+++ b/nepomuk/CMakeLists.txt
@@ -1,199 +1,209 @@
project(nepomuk)
include(SopranoAddOntology)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=300000)
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
if(KDE_NO_DEPRECATED)
add_definitions(-DDISABLE_NEPOMUK_LEGACY=1)
endif(KDE_NO_DEPRECATED)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/core
${CMAKE_CURRENT_SOURCE_DIR}/types
${CMAKE_CURRENT_SOURCE_DIR}/ui
${CMAKE_CURRENT_SOURCE_DIR}/query
${CMAKE_CURRENT_SOURCE_DIR}/utils
${CMAKE_SOURCE_DIR}
${KDE4_KIO_INCLUDES}
${QT_INCLUDES}
${SOPRANO_INCLUDE_DIR}
)
set(nepomuk_core_SRCS
core/variant.cpp
core/resourcedata.cpp
core/resourcemanager.cpp
core/nepomukmainmodel.cpp
core/dbusconnectionpool.cpp
core/resource.cpp
core/thing.cpp
core/file.cpp
core/tag.cpp
core/nepomukservice.cpp
core/dbustypes.cpp
+ core/resourcewatcher.cpp
)
+qt4_add_dbus_interface(nepomuk_core_SRCS
+ core/org.kde.nepomuk.ResourceWatcherConnection.xml
+ resourcewatcherconnectioninterface)
+
+qt4_add_dbus_interface(nepomuk_core_SRCS
+ core/org.kde.nepomuk.ResourceWatcher.xml
+ resourcewatchermanagerinterface)
+
+
if(NOT KDE_NO_DEPRECATED)
set(nepomuk_core_SRCS
${nepomuk_core_SRCS}
core/tools.cpp
)
endif(NOT KDE_NO_DEPRECATED)
set(nepomuk_ui_SRCS
ui/ktagcloudwidget.cpp
ui/kblocklayout.cpp
ui/kmetadatatagcloud.cpp
ui/ktagdisplaywidget.cpp
ui/nepomukmassupdatejob.cpp
ui/tagwidget.cpp
ui/kedittagsdialog.cpp
ui/tagcheckbox.cpp
)
set(nepomuk_types_SRCS
types/entity.cpp
types/ontology.cpp
types/class.cpp
types/property.cpp
types/literal.cpp
types/entitymanager.cpp
)
if(NOT KDE_NO_DEPRECATED)
set(nepomuk_types_SRCS
${nepomuk_types_SRCS}
types/desktopontologyloader.cpp
types/fileontologyloader.cpp
types/global.cpp
types/nepomukontologyloader.cpp
types/ontologyloader.cpp
types/ontologymanager.cpp
)
endif(NOT KDE_NO_DEPRECATED)
set(nepomuk_query_SRCS
query/term.cpp
query/negationterm.cpp
query/orterm.cpp
query/andterm.cpp
query/comparisonterm.cpp
query/simpleterm.cpp
query/groupterm.cpp
query/resourceterm.cpp
query/literalterm.cpp
query/resourcetypeterm.cpp
query/optionalterm.cpp
query/query.cpp
query/query_p.cpp
query/filequery.cpp
query/queryparser.cpp
query/dateparser.cpp
query/result.cpp
query/queryserviceclient.cpp
query/dbusoperators.cpp
)
set(nepomuk_LIB_SRCS
${nepomuk_core_SRCS}
${nepomuk_ui_SRCS}
${nepomuk_types_SRCS}
# ${nepomuk_query_SRCS}
)
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig" "NIE" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nfo.trig" "NFO" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/ncal.trig" "NCAL" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nco.trig" "NCO" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nmo.trig" "NMO" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nmm.trig" "NMM" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nexif.trig" "NEXIF" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/pimo/pimo.trig" "PIMO" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/pimo/tmo.trig" "TMO" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/nuao.trig" "NUAO" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
soprano_add_ontology(nepomuk_LIB_SRCS "${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nepomuk/ndo.trig" "NDO" "Nepomuk::Vocabulary" "trig" VISIBILITY "nepomuk")
kde4_add_library(nepomuk ${LIBRARY_TYPE} ${nepomuk_LIB_SRCS})
target_link_libraries(nepomuk
${SOPRANO_LIBRARIES}
${SOPRANO_CLIENT_LIBRARIES}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTDBUS_LIBRARY}
kdecore
kdeui
)
target_link_libraries(nepomuk
LINK_INTERFACE_LIBRARIES
kdeui
${SOPRANO_LIBRARIES})
set_target_properties(nepomuk PROPERTIES
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
install(TARGETS nepomuk EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES
nepomuk_export.h
core/variant.h
core/resourcemanager.h
core/nepomukservice.h
core/resource.h
core/thing.h
core/tag.h
core/file.h
types/entity.h
types/class.h
types/property.h
types/ontology.h
types/literal.h
ui/ktagcloudwidget.h
ui/kmetadatatagcloud.h
ui/kmetadatatagwidget.h
ui/ktagdisplaywidget.h
ui/nepomukmassupdatejob.h
ui/tagwidget.h
# Vocabularies
${CMAKE_CURRENT_BINARY_DIR}/nie.h
${CMAKE_CURRENT_BINARY_DIR}/nfo.h
${CMAKE_CURRENT_BINARY_DIR}/ncal.h
${CMAKE_CURRENT_BINARY_DIR}/nco.h
${CMAKE_CURRENT_BINARY_DIR}/nmo.h
${CMAKE_CURRENT_BINARY_DIR}/nmm.h
${CMAKE_CURRENT_BINARY_DIR}/nexif.h
${CMAKE_CURRENT_BINARY_DIR}/pimo.h
${CMAKE_CURRENT_BINARY_DIR}/tmo.h
${CMAKE_CURRENT_BINARY_DIR}/nuao.h
${CMAKE_CURRENT_BINARY_DIR}/ndo.h
DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
)
if(NOT KDE_NO_DEPRECATED)
install(FILES
core/tools.h
types/desktopontologyloader.h
types/fileontologyloader.h
types/global.h
types/nepomukontologyloader.h
types/ontologyloader.h
types/ontologymanager.h
DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
)
endif(NOT KDE_NO_DEPRECATED)
add_subdirectory(rcgen)
add_subdirectory(query)
add_subdirectory(utils)
add_subdirectory(test)
diff --git a/nepomuk/core/org.kde.nepomuk.ResourceWatcher.xml b/nepomuk/core/org.kde.nepomuk.ResourceWatcher.xml
new file mode 100644
index 0000000000..7f414443b9
--- /dev/null
+++ b/nepomuk/core/org.kde.nepomuk.ResourceWatcher.xml
@@ -0,0 +1,14 @@
+<!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>
diff --git a/nepomuk/core/org.kde.nepomuk.ResourceWatcherConnection.xml b/nepomuk/core/org.kde.nepomuk.ResourceWatcherConnection.xml
new file mode 100644
index 0000000000..3a452e3fc2
--- /dev/null
+++ b/nepomuk/core/org.kde.nepomuk.ResourceWatcherConnection.xml
@@ -0,0 +1,38 @@
+<!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="resourceTypeAdded">
+ <arg name="resUri" type="s" direction="out"/>
+ <arg name="type" type="s" direction="out"/>
+ </signal>
+ <signal name="resourceTypeRemoved">
+ <arg name="resUri" type="s" direction="out"/>
+ <arg name="type" type="s" direction="out"/>
+ </signal>
+ <signal name="propertyAdded">
+ <arg name="resource" type="s" direction="out"/>
+ <arg name="property" type="s" direction="out"/>
+ <arg name="value" type="v" direction="out"/>
+ </signal>
+ <signal name="propertyRemoved">
+ <arg name="resource" type="s" direction="out"/>
+ <arg name="property" type="s" direction="out"/>
+ <arg name="value" type="v" direction="out"/>
+ </signal>
+ <signal name="propertyChanged">
+ <arg name="resource" type="s" direction="out"/>
+ <arg name="property" type="s" direction="out"/>
+ <arg name="oldValues" type="av" direction="out"/>
+ <arg name="newValues" type="av" direction="out"/>
+ </signal>
+ <method name="close" />
+ </interface>
+</node>
diff --git a/nepomuk/core/resourcewatcher.cpp b/nepomuk/core/resourcewatcher.cpp
new file mode 100644
index 0000000000..15a59f1c2e
--- /dev/null
+++ b/nepomuk/core/resourcewatcher.cpp
@@ -0,0 +1,212 @@
+/*
+ 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
+*/
+
+
+#include "resourcewatcher.h"
+#include "resourcewatcherconnectioninterface.h"
+#include "resourcewatchermanagerinterface.h"
+
+#include <QtDBus/QDBusObjectPath>
+
+#include "resource.h"
+
+#include "kurl.h"
+#include "kdebug.h"
+
+namespace {
+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<Types::Class> m_types;
+ QList<Nepomuk::Resource> m_resources;
+ QList<Types::Property> 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()
+{
+ //
+ // Convert to list of strings
+ //
+ QList<QString> uris;
+ foreach( const Nepomuk::Resource & res, d->m_resources ) {
+ uris << KUrl(res.resourceUri()).url();
+ }
+
+ QList<QString> props;
+ foreach( const Types::Property & prop, d->m_properties ) {
+ props << KUrl(prop.uri()).url();
+ }
+
+ QList<QString> types_;
+ foreach( const Types::Class & cl, d->m_types ) {
+ types_ << KUrl(cl.uri()).url();
+ }
+
+ //
+ // 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,QDBusVariant)),
+ this, SLOT(slotPropertyAdded(QString,QString,QDBusVariant)) );
+ connect( d->m_connectionInterface, SIGNAL(propertyRemoved(QString,QString,QDBusVariant)),
+ this, SLOT(slotPropertyRemoved(QString,QString,QDBusVariant)) );
+ 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(resourceTypeAdded(QString,QString)),
+ this, SLOT(slotResourceTypeAdded(QString,QString)) );
+ connect( d->m_connectionInterface, SIGNAL(resourceTypeRemoved(QString,QString)),
+ this, SLOT(slotResourceTypeRemoved(QString,QString)) );
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+void Nepomuk::ResourceWatcher::stop()
+{
+ if (d->m_connectionInterface) {
+ d->m_connectionInterface->close();
+ delete d->m_connectionInterface;
+ d->m_connectionInterface = 0;
+ }
+}
+
+void Nepomuk::ResourceWatcher::addProperty(const Nepomuk::Types::Property& property)
+{
+ d->m_properties << property;
+}
+
+void Nepomuk::ResourceWatcher::addResource(const Nepomuk::Resource& res)
+{
+ d->m_resources << res;
+}
+
+void Nepomuk::ResourceWatcher::addType(const Nepomuk::Types::Class& type)
+{
+ d->m_types << type;
+}
+
+QList< Nepomuk::Types::Property > Nepomuk::ResourceWatcher::properties() const
+{
+ return d->m_properties;
+}
+
+QList<Nepomuk::Resource> Nepomuk::ResourceWatcher::resources() const
+{
+ return d->m_resources;
+}
+
+QList< Nepomuk::Types::Class > Nepomuk::ResourceWatcher::types() const
+{
+ return d->m_types;
+}
+
+void Nepomuk::ResourceWatcher::setProperties(const QList< Nepomuk::Types::Property >& properties_)
+{
+ d->m_properties = properties_;
+}
+
+void Nepomuk::ResourceWatcher::setResources(const QList< Nepomuk::Resource >& resources_)
+{
+ d->m_resources = resources_;
+}
+
+void Nepomuk::ResourceWatcher::setTypes(const QList< Nepomuk::Types::Class >& types_)
+{
+ d->m_types = 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::slotResourceTypeAdded(const QString &res, const QString &type)
+{
+ emit resourceTypeAdded(KUrl(res), KUrl(type));
+}
+
+void Nepomuk::ResourceWatcher::slotResourceTypeRemoved(const QString &res, const QString &type)
+{
+ emit resourceTypeRemoved(KUrl(res), KUrl(type));
+}
+
+void Nepomuk::ResourceWatcher::slotPropertyAdded(const QString& res, const QString& prop, const QDBusVariant& object)
+{
+ emit propertyAdded( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ), object.variant() );
+}
+
+void Nepomuk::ResourceWatcher::slotPropertyRemoved(const QString& res, const QString& prop, const QDBusVariant& object)
+{
+ emit propertyRemoved( Resource::fromResourceUri(KUrl(res)), Types::Property( KUrl(prop) ), object.variant() );
+}
+
+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"
+
diff --git a/nepomuk/core/resourcewatcher.h b/nepomuk/core/resourcewatcher.h
new file mode 100644
index 0000000000..a1d6e5f439
--- /dev/null
+++ b/nepomuk/core/resourcewatcher.h
@@ -0,0 +1,286 @@
+/*
+ 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 "../types/class.h"
+#include "../types/property.h"
+#include "resource.h"
+
+#include <QtDBus/QDBusVariant>
+#include <QtCore/QVariant>
+
+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();
+
+ /**
+ * \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 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;
+
+ public Q_SLOTS:
+ /**
+ * \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 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 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 cannot be emitted for all changes. It doesn't work if a property is first
+ * removed and then set, cause the Data Mangement Service does not maintain an internal
+ * cache for the purpose of emitting the propertyChanged signal.
+ *
+ * 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 oldValue The removed property value.
+ */
+ void propertyChanged( const Nepomuk::Resource & resource,
+ const Nepomuk::Types::Property & property,
+ const QVariantList & oldValue,
+ const QVariantList & newValue );
+
+ private Q_SLOTS:
+ void slotResourceCreated(const QString& res, const QStringList& types);
+ void slotResourceRemoved(const QString& res, const QStringList& types);
+ void slotResourceTypeAdded(const QString& res, const QString& type);
+ void slotResourceTypeRemoved(const QString& res, const QString& type);
+ void slotPropertyAdded(const QString& res, const QString& prop, const QDBusVariant& object);
+ void slotPropertyRemoved(const QString& res, const QString& prop, const QDBusVariant& object);
+ void slotPropertyChanged(const QString& res, const QString& prop,
+ const QVariantList & oldObjs,
+ const QVariantList & newObjs);
+ private:
+ class Private;
+ Private * d;
+ };
+}
+
+#endif // RESOURCEWATCHER_H

File Metadata

Mime Type
text/x-diff
Expires
Fri, Nov 1, 8:18 AM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10074891
Default Alt Text
(28 KB)

Event Timeline