Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > 69501fee79f575b9818fcbd4bf2bb6c4 > files > 24

kdelibs4-4.2.4-0.2mdv2009.0.src.rpm

diff -u -r -N nepomuk/.svn/all-wcprops nepomuk-svn/.svn/all-wcprops
--- nepomuk/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/all-wcprops	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,29 @@
+K 25
+svn:wc:ra_dav:version-url
+V 51
+/home/kde/!svn/ver/928345/trunk/KDE/kdelibs/nepomuk
+END
+TODO
+K 25
+svn:wc:ra_dav:version-url
+V 56
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/TODO
+END
+nepomuk_export.h
+K 25
+svn:wc:ra_dav:version-url
+V 68
+/home/kde/!svn/ver/676285/trunk/KDE/kdelibs/nepomuk/nepomuk_export.h
+END
+Mainpage.dox
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/home/kde/!svn/ver/842406/trunk/KDE/kdelibs/nepomuk/Mainpage.dox
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 66
+/home/kde/!svn/ver/928345/trunk/KDE/kdelibs/nepomuk/CMakeLists.txt
+END
diff -u -r -N nepomuk/.svn/entries nepomuk-svn/.svn/entries
--- nepomuk/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/entries	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,170 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk
+https://svn.kde.org/home/kde
+
+
+
+2009-02-19T12:46:13.650297Z
+928345
+mlaurent
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+TODO
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+f4054a5c6b0b8d5f9a19549e486e2511
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+157
+
+nepomuk_export.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+f00d4e3d979d47539f383b48d0d06021
+2007-06-16T14:47:10.228768Z
+676285
+chehrlic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1497
+
+core
+dir
+
+Mainpage.dox
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+96ee2bfbe2ce65c5a6256e5158ba295a
+2008-08-05T10:09:47.216550Z
+842406
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16735
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+f9fabd4aa64bc6fced23e2a274d4ff28
+2009-02-19T12:46:13.650297Z
+928345
+mlaurent
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+162
+
+rcgen
+dir
+
diff -u -r -N nepomuk/.svn/format nepomuk-svn/.svn/format
--- nepomuk/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/format	2009-02-27 13:37:43.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/.svn/prop-base/CMakeLists.txt.svn-base nepomuk-svn/.svn/prop-base/CMakeLists.txt.svn-base
--- nepomuk/.svn/prop-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/prop-base/CMakeLists.txt.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mime-type
+V 10
+text/plain
+END
diff -u -r -N nepomuk/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,9 @@
+project(nepomuk)
+
+install(FILES
+  nepomuk_export.h
+  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
+)
+
+add_subdirectory(rcgen)
+add_subdirectory(core)
diff -u -r -N nepomuk/.svn/text-base/Mainpage.dox.svn-base nepomuk-svn/.svn/text-base/Mainpage.dox.svn-base
--- nepomuk/.svn/text-base/Mainpage.dox.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/text-base/Mainpage.dox.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,456 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * 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.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+
+/** \mainpage The Nepomuk Meta Data Library
+
+<p><b>
+Overview |
+\ref hacking "Using" |
+\ref examples "Examples" |
+\ref page_ontology "Desktop Ontologies" |
+\ref nepomuk-rcgen "Resource Generator"
+</b></p>
+
+This is the KDE Meta Data library (not to confuse with KFileMetaData).
+
+
+\section overview The General Idea
+
+Three types of meta data can be identified:
+
+-# Meta data that is stored with the data itself and is available at all
+times. This includes id3 tags, the number of pages in a pdf document, or
+even the size of a file or the subject of an email.
+-# Meta data that is created by the user manually like annotations or tags
+that are assigned to files, emails, or whatever resources.
+-# Meta data that can be gathered automatically by applications such as the
+source of a downloaded file or the email an attachment was saved from or the
+original when copying a file locally.
+
+Type 1 is already handled in many implementations. KDE itself includes the
+KMetaFileInfo classes that allow extracting this kind of meta information from
+files and the Strigi system even creates a searchable index of this information.
+
+Nepomuk is intended for meta data of type 2 and 3. It provides an easy way to
+create and read meta data for arbitrary resources (this includes for example files
+or emails, but also contacts or maybe even a paragraph in a pdf file).
+
+The simplest type of meta data that can be handled with Nepomuk is a comment. It
+is a simple string associated with a resource (a file for example). This comment
+is created by the user using an application that is based on Nepomuk.
+
+Nepomuk's core is designed to allow arbitrary types of meta data, i.e. any resource
+can be related with any other resource or value by simply naming the relation and
+providing the value.
+The power of Nepomuk, however, lies in that it provides a class for each type
+of resource. Each of these classes provide convenience methods to allow a simple
+handling of the meta data. These classes are automatically generated from a
+description of types and properties, i.e. an ontology (see \ref page_ontology).
+
+Nepomuk is resource based. Thus, working with Nepomuk is always done with instances
+representing a certain resource. This resource has a list of properties. Properties
+are named and have a certain type. The type can either be another resource (compare
+a file that was an attachment from an email) or a literal (this means for example a
+string, or an integer; the comment mentioned earlier would be a string literal).
+Each property can either have a cardinality of 1 (again a file can only be saved from
+one email) or greater than 1 (i.e. infinite, like one file can have arbitrary many
+associated comments). See \ref hacking on how Nepomuk handles literals and cardinalities
+greater than 1.
+
+\section toc Further Reading
+
+- \ref page_ontology
+- \ref hacking
+- \ref examples
+- \ref nepomuk-rcgen
+- <a href="http://techbase.kde.org/Development/Tutorials#Nepomuk">The Nepomuk techbase tutorials</a>
+
+\authors
+Sebastian Trueg \<trueg@kde.org\>
+
+\maintainers
+Sebastian Trueg \<trueg@kde.org\>
+
+\licenses
+\lgpl
+
+*/
+
+
+/** \page hacking Using Nepomuk
+
+<p><b>
+\ref index "Overview" |
+Using |
+\ref examples "Examples" |
+\ref page_ontology "Desktop Ontologies" |
+\ref nepomuk-rcgen "Resource Generator"
+</b></p>
+
+\section hacking_resources Handling Resources
+
+In general there are two ways of using Nepomuk.
+
+-# The preferred way: use the Resource subclasses as generated from \ref page_ontology
+   This is also the much simpler way since Nepomuk takes care of all type casting and
+   list handling automatically.
+-# Using Nepomuk::Resource directly. This is much harder since in this case
+   the type names (i.e. their URIs as defined in \ref page_ontology) have to be known.
+   On the other hand it allows to use additional resource types not defined in the ontology
+   and handle resources without knowing their type.
+
+Since all resource classes are derived from Nepomuk::Resource and only add additional methods
+both ways can be used interchangeably.
+
+Resource objects (and thus also all objects of classes derived from Resource) with the same
+URI share their data. Thus, if one is changed the other one is, too.
+
+
+\subsection hacking_theeasyway Using Resource Subclasses
+
+Using Resource subclasses directly is very simple. All that is necessary to handle a
+resource is to know its type and its URI (the URI can vary a lot between resource types;
+The simplest example is certainly a local file: the URI is the path to the file).
+
+To access or create meta data for a resource one simply creates an instance of the
+corresponding class and passes the resource URI to its constructor.
+
+In case of a file this would look as follows.
+
+\code
+Nepomuk::File f( "/home/foo/bar.txt" );
+\endcode
+
+Now meta data can be read and set via the methods provided by Nepomuk::File
+such as Nepomuk::File::setAnnotation.
+
+Each resource class also provides a static method which returns all existing instances
+of this type.
+See Nepomuk::File::allFiles for an example.
+
+See also \ref nepomuk-rcgen
+
+
+\subsection hacking_thehardway Using Resource Directly
+
+Using the Nepomuk::Resource class directly forces one to learn a little more about
+the internals of Nepomuk. Resource provides four methods to handle the properties of a
+resource (reminder: all Resource subclasses as generated from \ref page_ontology are based
+one these methods):
+
+- Nepomuk::Resource::property
+- Nepomuk::Resource::setProperty
+- Nepomuk::Resource::removeProperty
+- Nepomuk::Resource::properties
+
+Each property's value is represented by a Nepomuk::Variant object which can contain
+another Resource or a literal (string, int, ...) or even a list of the former two. Other than
+with the Resource subclasses no automatic type conversion is performed.
+
+In case of a property that can have multiple values (cardinality greater than 1) Nepomuk::Resource::setProperty
+has to be called with a list to set more than one (the Resource subclasses simplify this by
+adding add methods in addition to the set method) and Nepomuk::Resource::getProperty
+will also return a list (in both cases encapsulated in a Variant object).
+
+When creating a Resource object there are two cases that are dealt with differently:
+
+- The resource does not exist yet, i.e. no information about it is stored. In this case Nepomuk
+  does not know the type of the resource and will fall back to %http://www.w3.org/2000/01/rdf-schema\#Resource.
+- If the resource already exists the type may be empty. It will then be read from the local meta
+  data store (where it was saved before by Nepomuk automatically).
+
+As a rule of thumb one should always define the type when creating meta data and leave it empty when
+reading meta data.
+
+When using the plain Nepomuk::Resource class one is completely free to choose the
+resource URIs, the type URIs, and the property URIs. However, to preserve compatibility with
+other applications one is encouraged to stick to those define in \ref page_ontology.
+
+\section hacking_general Nepomuk Details
+
+Nepomuk is designed so the user (the developer of a client application) does not have to care about loading or
+saving the data. All data is stored directly into the RDF storage and also read from it directly.
+
+Although in normal operation it is sufficient to only work with Nepomuk::Resource and
+its subclasses errors might occur. This is where the Nepomuk::ResourceManager comes
+in: it provides the Nepomuk::ResourceManager::init method which can be called manually
+(the resource manager will be initialized automatically anyway) to check if the initialization was
+successful and Nepomuk can be used. In addition it provides the Nepomuk::ResourceManager::error
+signal which is emitted whenever an error occurs.
+
+
+See \ref examples for further examples.
+*/
+
+
+/** \page examples Nepomuk Examples
+
+<p><b>
+\ref index "Overview" |
+\ref hacking "Using" |
+Examples |
+\ref page_ontology "Desktop Ontologies" |
+\ref nepomuk-rcgen "Resource Generator"
+</b></p>
+
+Add an annotation (a comment) to a file.
+
+\code
+Nepomuk::File f( "/home/foo/bar.txt" );
+f.setAnnotation( "This is just a test file that contains nothing of interest." );
+\endcode
+
+The following example creates a new tag. The tag can be accessed through its name
+which works as an identifier. Nepomuk automatically creates a new unique URI if this
+tag does not already exist.
+
+\code
+Nepomuk::Tag tag( "MyTag" );
+Nepomuk::File f( "/home/foo/bar.txt" );
+f.addTag( tag );
+\endcode
+
+Reading the information using plain Resource methods:
+
+\code
+Nepomuk::Resource f( "/home/foo/bar.txt" );
+QString annotation = f.getProperty( Soprano::Vocabulary::NAO::decription() ).toString();
+QList<Resource> tags = f.getProperty( Soprano::Vocabulary::NAO::hasTag() ).toResourceList();
+QListIterator<Resource> it( tags );
+while( it.hasNext() )
+  kdDebug() << "File tagged with tag: "
+            << it.next().genericLabel();
+\endcode
+
+Reading the information using the convenience classes (be aware that these classes need to be generated
+from an ontology using the \ref nepomuk-rcgen "Resource Generator"):
+
+\code
+Nepomuk::File f( "/home/foo/bar.txt" );
+QString description = f.getDescription();
+QList<Tag> tags = f.getTags();
+QListIterator<Tag> it( tags );
+while( it.hasNext() )
+  kdDebug() << "File tagged with tag: " << it.next().genericLabel();
+\endcode
+
+Present all defined properties of an arbitrary resource to the user including
+internationalized labels:
+
+\code
+Nepomuk::Resource f( "/home/foo/bar.txt" );
+QHash<QUrl, Variant> properties = f.properties();
+QHashIterator<QUrl, Variant> it( properties );
+while( it.hasNext() ) {
+  it.next();
+  kdDebug() << Nepomuk::Types::Property( it.key() ).label() << ": " << it.value().toString() << endl;
+}
+\endcode
+*/
+
+/** \page page_ontology The Desktop Ontologies
+
+<p><b>
+\ref index "Overview" |
+\ref hacking "Using" |
+\ref examples "Examples" |
+Desktop Ontologies |
+\ref nepomuk-rcgen "Resource Generator"
+</b></p>
+
+The Desktop ontologies define the possible types and properties that can be used as metadata.
+The ontologies are based on RDF/S and NRL (The Nepomuk Representation Language which adds some
+OWL-like properties like cardinality or also named graphs). The types and properties can either
+be used directly with the Resource class or through generated classes.
+*/
+
+
+/** \page nepomuk-rcgen The Nepomuk Resource Generator
+
+<p><b>
+\ref index "Overview" |
+\ref hacking "Using" |
+\ref examples "Examples" |
+\ref page_ontology "Desktop Ontologies" |
+Resource Generator
+</b></p>
+
+The power of Nepomuk lies in the generated classes which allows the application developer to set
+and retrieve metadata according to standards without knowing any specific RDF URIs or names of properties.
+The idea is that the resource generator (which is installed along with the Nepomuk libraries) creates
+Resource subclasses that provide wrapper methods for Resource::getProperty and Resource::setProperty from
+ontology descriptions.
+
+
+\section rcgen_syntax Syntax
+
+The resource generator executable is called nepomuk-rcgen and has the following syntax:
+
+\code
+nepomuk-rcgen --writeall [--templates <tmpl1> [<tmpl2> [<tmpl3> ...]]] --target <sourcefolder> --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]
+\endcode
+
+This writes all header and source files that have been generated from the ontology in &lt;ontologyfile&gt; to
+the destination folder &lt;sourcefolder&gt;.
+Optionally templates can be specified (see \ref rcgen_templates for details on templates).
+
+
+\code
+nepomuk-rcgen --listsources [--prefix <listprefix>] --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]
+\endcode
+
+This command simply lists all source files that would be generated from the ontology in &lt;ontologyfile&gt;
+on stdout. It can be used to create build lists.
+
+\code
+nepomuk-rcgen --listheaders [--prefix <listprefix>] --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]
+\endcode
+
+This command simply lists all header files that would be generated from the ontology in &lt;ontologyfile&gt;
+on stdout. It can be used to create installation lists.
+
+\code
+nepomuk-rcgen --listincludes --ontologies <ontologyfile> [<ontologyfile> [<ontologyfile> ...]]
+\endcode
+
+This will list all headers that would be generated from &lt;ontologyfile&gt; as include statement on stdout.
+This is a rarely used command that can help to create a header that automatically includes all classes
+from this ontology.
+
+
+\section rcgen_cmake Usage through CMake
+
+The simplest way to use the resource generator is through CMake. Nepomuk provides a macro to automatically
+create a list of source and header files from an ontology file and use them to create arbitrary targets
+(either link them into an installable library or directly link them into the using application).
+
+To use the Nepomuk cmake magic one has to include the NepomukMacros:
+
+\code
+include(NepomukMacros)
+\endcode
+
+This will provide a macro called NEPOMUK_GENERATE_FROM_ONTOLOGY with the following parameters:
+
+-# The ontology file to be parsed
+-# The target directory where to put the new files
+-# A variable in which the list of generated headers will be stored
+-# A variable in which the list of generated sources will be stored
+-# A variable in which the list of includes will be stored (mostly unused)
+-# An optional list of template files
+
+HELP: This macro needs improvement to make parameters optional!
+
+
+\subsection rcgen_cmake_example Example
+
+\code
+project(metadata_test)
+
+include(NepomukMacros)
+
+NEPOMUK_GENERATE_FROM_ONTOLOGY(
+  myontology.nrl
+  ${metadata_test_BINARY_DIR}
+  TEST_HEADERS
+  TEST_SOURCES
+  TEST_INCLUDES
+)
+
+kde4_add_library(metadata_test SHARED ${TEST_SOURCES})
+target_link_libraries(metadata_test
+  kmetadata
+)
+
+install(TARGETS metadata_test DESTINATION ${LIB_INSTALL_DIR})
+install(FILES ${TEST_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/kmetadata)
+\endcode
+
+
+\section rcgen_templates Templates
+
+@warning Template usage is discouraged. Their main purpose is to support the creation of the
+basic properties of the Resource class.
+
+An rcgen template has to provide the full skeleton for a generated class including
+the proper namespace, the constructor, and the destructor. They will be assigned to the specific
+classes according to their filename: The part before the first dot needs to match the class name
+in lower case. If the class name if followed by ".h" the template is assigned to the header, if it
+is followed by  ".cpp", the template is assigned to the source. The following variables
+will be replaced:
+
+\subsection rcgen_templates_header Header template
+
+\code
+NEPOMUK_OTHERCLASSES
+\endcode
+
+Will be replaced by the declarations of the classes used in the header file.
+
+\code
+NEPOMUK_METHODS
+\endcode
+
+Will be replaced by the declarations of the getter and setter methods that are
+generated for the class.
+
+
+\subsection rcgen_templates_sources Source template
+
+\code
+NEPOMUK_INCLUDES
+\endcode
+
+Will be replaced by all the necessary includes for the types used in the class.
+
+\code
+NEPOMUK_METHODS
+\endcode
+
+Will be replaced with the definitions of the getter and setter methods that are
+generated for the class.
+
+
+\subsection rcgen_templates_misc All
+
+The following variables are also replaced:
+
+\code
+NEPOMUK_RESOURCENAME
+NEPOMUK_RESOURCENAMELOWER
+NEPOMUK_RESOURCETYPEURI
+NEPOMUK_PARENTRESOURCE
+NEPOMUK_PARENTRESOURCELOWER
+NEPOMUK_RESOURCECOMMENT
+\endcode
+
+*/
+
+// DOXYGEN_SET_RECURSIVE = NO
+// DOXYGEN_SET_FILE_PATTERNS = *.h
+// DOXYGEN_SET_INPUT = @topdir@/nepomuk/Mainpage.dox
+// DOXYGEN_SET_INPUT += @topdir@/nepomuk/core
+// DOXYGEN_SET_INPUT += @topdir@/nepomuk/core/ui
+// DOXYGEN_SET_INPUT += @topdir@/nepomuk/core/ontology
+// DOXYGEN_SET_EXCLUDE = @topdir@/nepomuk/core/resourcedata.h
+// DOXYGEN_SET_EXCLUDE += @topdir@/nepomuk/core/nepomukmainmodel.h
+// DOXYGEN_SET_EXCLUDE += @topdir@/nepomuk/core/resourcefiltermodel.h
+// DOXYGEN_SET_EXCLUDE += @topdir@/nepomuk/core/nie.h
+// DOXYGEN_SET_EXCLUDE += @topdir@/nepomuk/core/ontology/entitymanager.h
+// DOXYGEN_SET_EXCLUDE += @topdir@/nepomuk/core/ui/nepomukmassupdatejob.h
+// DOXYGEN_SET_EXCLUDE += @topdir@/nepomuk/core/ui/kautoscrollarea.h
+// DOXYGEN_SET_EXCLUDE += @topdir@/nepomuk/core/ui/kblocklayout.h
+// DOXYGEN_SET_PROJECT_NAME = Nepomuk
+// vim:ts=4:sw=4:expandtab:filetype=doxygen
diff -u -r -N nepomuk/.svn/text-base/TODO.svn-base nepomuk-svn/.svn/text-base/TODO.svn-base
--- nepomuk/.svn/text-base/TODO.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/text-base/TODO.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,2 @@
+* Add support for multiple types (Merge multiple types in one hierarchy branch?)
+* rcgen: Add the possibility to specify multiple ontology files in one run.
diff -u -r -N nepomuk/.svn/text-base/nepomuk_export.h.svn-base nepomuk-svn/.svn/text-base/nepomuk_export.h.svn-base
--- nepomuk/.svn/text-base/nepomuk_export.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/.svn/text-base/nepomuk_export.h.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,46 @@
+/*  This file is part of the KDE project
+    Copyright (C) 2007 David Faure <faure@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef NEPOMUK_EXPORT_H
+#define NEPOMUK_EXPORT_H
+
+/* needed for KDE_EXPORT and KDE_IMPORT macros */
+#include <kdemacros.h>
+
+#ifndef NEPOMUK_EXPORT
+# if defined(MAKE_NEPOMUK_LIB)
+   /* We are building this library */
+#  define NEPOMUK_EXPORT KDE_EXPORT
+# else
+   /* We are using this library */
+#  define NEPOMUK_EXPORT KDE_IMPORT
+# endif
+#endif
+
+#ifndef NEPOMUK_MIDDLEWARE_EXPORT
+# if defined(MAKE_NEPOMUK_MIDDLEWARE_LIB)
+   /* We are building this library */
+#  define NEPOMUK_MIDDLEWARE_EXPORT KDE_EXPORT
+# else
+   /* We are using this library */
+#  define NEPOMUK_MIDDLEWARE_EXPORT KDE_IMPORT
+# endif
+#endif
+
+#endif
diff -u -r -N nepomuk/CMakeLists.txt nepomuk-svn/CMakeLists.txt
--- nepomuk/CMakeLists.txt	2008-09-17 22:55:21.000000000 +0200
+++ nepomuk-svn/CMakeLists.txt	2009-02-27 13:37:52.000000000 +0100
@@ -2,7 +2,7 @@
 
 install(FILES
   nepomuk_export.h
-  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk
+  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
 )
 
 add_subdirectory(rcgen)
diff -u -r -N nepomuk/core/.svn/all-wcprops nepomuk-svn/core/.svn/all-wcprops
--- nepomuk/core/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/all-wcprops	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,179 @@
+K 25
+svn:wc:ra_dav:version-url
+V 56
+/home/kde/!svn/ver/928345/trunk/KDE/kdelibs/nepomuk/core
+END
+nepomukservice.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/861478/trunk/KDE/kdelibs/nepomuk/core/nepomukservice.cpp
+END
+tools.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 66
+/home/kde/!svn/ver/886480/trunk/KDE/kdelibs/nepomuk/core/tools.cpp
+END
+graphwrapper.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/graphwrapper.cpp
+END
+pimo.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/home/kde/!svn/ver/868537/trunk/KDE/kdelibs/nepomuk/core/pimo.cpp
+END
+nepomukservice.h
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/home/kde/!svn/ver/905230/trunk/KDE/kdelibs/nepomuk/core/nepomukservice.h
+END
+nepomukmainmodel.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/nepomukmainmodel.cpp
+END
+variant.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 68
+/home/kde/!svn/ver/917271/trunk/KDE/kdelibs/nepomuk/core/variant.cpp
+END
+tools.h
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/home/kde/!svn/ver/792139/trunk/KDE/kdelibs/nepomuk/core/tools.h
+END
+resourcemanager_p.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/resourcemanager_p.h
+END
+thing.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 66
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/thing.cpp
+END
+variant.h
+K 25
+svn:wc:ra_dav:version-url
+V 66
+/home/kde/!svn/ver/914382/trunk/KDE/kdelibs/nepomuk/core/variant.h
+END
+nepomukmainmodel.h
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/nepomukmainmodel.h
+END
+pimo.h
+K 25
+svn:wc:ra_dav:version-url
+V 63
+/home/kde/!svn/ver/868537/trunk/KDE/kdelibs/nepomuk/core/pimo.h
+END
+nie.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/home/kde/!svn/ver/786520/trunk/KDE/kdelibs/nepomuk/core/nie.cpp
+END
+tag.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/tag.cpp
+END
+thing.h
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/thing.h
+END
+resourcefiltermodel.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 80
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/resourcefiltermodel.cpp
+END
+tag.h
+K 25
+svn:wc:ra_dav:version-url
+V 62
+/home/kde/!svn/ver/913723/trunk/KDE/kdelibs/nepomuk/core/tag.h
+END
+nie.h
+K 25
+svn:wc:ra_dav:version-url
+V 62
+/home/kde/!svn/ver/786520/trunk/KDE/kdelibs/nepomuk/core/nie.h
+END
+resourcedata.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/resourcedata.cpp
+END
+resourcemanager.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/resourcemanager.cpp
+END
+resourcefiltermodel.h
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/resourcefiltermodel.h
+END
+TODO
+K 25
+svn:wc:ra_dav:version-url
+V 61
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/TODO
+END
+resourcedata.h
+K 25
+svn:wc:ra_dav:version-url
+V 71
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/resourcedata.h
+END
+graphwrapper_p.h
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/graphwrapper_p.h
+END
+resourcemanager.h
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/core/resourcemanager.h
+END
+resource.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 69
+/home/kde/!svn/ver/917768/trunk/KDE/kdelibs/nepomuk/core/resource.cpp
+END
+resource.h
+K 25
+svn:wc:ra_dav:version-url
+V 67
+/home/kde/!svn/ver/914382/trunk/KDE/kdelibs/nepomuk/core/resource.h
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 71
+/home/kde/!svn/ver/913712/trunk/KDE/kdelibs/nepomuk/core/CMakeLists.txt
+END
diff -u -r -N nepomuk/core/.svn/entries nepomuk-svn/core/.svn/entries
--- nepomuk/core/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/entries	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,1023 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/core
+https://svn.kde.org/home/kde
+
+
+
+2009-02-19T12:46:13.650297Z
+928345
+mlaurent
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+tools.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+e47e073dae8d5c9833d9898a0e0d605e
+2008-11-19T11:33:19.009228Z
+886480
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2899
+
+nepomukmainmodel.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+f31d1674d1a6f1a21a419c76999112ed
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8441
+
+nepomukservice.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+1f7f5f0a108b94eb043aff59025c7869
+2009-01-04T00:11:21.868661Z
+905230
+alexmerry
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4568
+
+pimo.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+487b766ae00cb23efc7d23e92a0243f1
+2008-10-06T14:52:12.594714Z
+868537
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2358
+
+resourcemanager_p.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+53ea85c624477cabaac8fac4da9a9374
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3363
+
+variant.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+cebd2dd9f5ca9b090c95f94189a3f8d1
+2009-01-21T00:46:10.515245Z
+914382
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10135
+
+thing.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+5a532b333ec5e7cf8c692f55d28dcdc6
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3164
+
+tag.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+c8837556a8e3e7af0a0f22f663a64e15
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2815
+
+nie.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+0c5e3075e8301fe6846ee8aa2cc85c64
+2008-03-17T10:03:50.242416Z
+786520
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9452
+
+resourcedata.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+ceac97668033619940983d0e3721e472
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+23020
+
+resourcefiltermodel.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+bf1337eba2f039d772ca255d1ca0b836
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3670
+
+resourcemanager.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+5fd76b0c9ab95a2e2f08f5e089a16651
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8171
+
+resource.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+f081ff56496a834f5156b9760deb3e86
+2009-01-21T00:46:10.515245Z
+914382
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+23453
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+e1aeace5d3c05178d0cdd11693494be9
+2009-01-19T19:08:56.913566Z
+913712
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2065
+
+test
+dir
+
+nepomukservice.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+dbf90d94c07a9a04495219121223162c
+2008-09-16T09:10:25.560325Z
+861478
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1839
+
+graphwrapper.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+6f43cfb468162c814f164832fb293ce8
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4186
+
+variant.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+53f921f3147329bfdf2f6ca47f0dd920
+2009-01-27T13:46:01.396556Z
+917271
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+28579
+
+tools.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+7c4ed5a1ef2d8a783903ae8fb15535b9
+2008-03-31T11:39:23.471440Z
+792139
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3426
+
+pimo.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+a23b297a6177cce713077fed2dbc22af
+2008-10-06T14:52:12.594714Z
+868537
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3881
+
+nepomukmainmodel.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+7311ce8829eff122837162160ce3acab
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3884
+
+resourcefiltermodel.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+f36a9706876ae9a29ad8e43864c3d66d
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5684
+
+thing.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+a02837eedec70c308eec69cd701ccaab
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5905
+
+nie.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+2dff6ea6f71a1893e2be5d467bdc46b1
+2008-03-17T10:03:50.242416Z
+786520
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+19101
+
+tag.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+c5f0afecb4042fe0b5860e6854a54718
+2009-01-19T19:26:39.891369Z
+913723
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4367
+
+resourcemanager.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+1cfbea086ca35ea366a6504b5fe78888
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+13340
+
+TODO
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+28a2221fd7fd4faa3a2a43c60e7dfad5
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+369
+
+graphwrapper_p.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+645b19a4328b4d81d27df91f8d7dc4d0
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2902
+
+resourcedata.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+c784f2c125084d9af36f77e3fbfbe011
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6674
+
+resource.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+6a05ee6e4692e6a2c13b2c29ae746921
+2009-01-28T14:32:26.949852Z
+917768
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+21654
+
+ontology
+dir
+
+ui
+dir
+
diff -u -r -N nepomuk/core/.svn/format nepomuk-svn/core/.svn/format
--- nepomuk/core/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/format	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/core/.svn/prop-base/CMakeLists.txt.svn-base nepomuk-svn/core/.svn/prop-base/CMakeLists.txt.svn-base
--- nepomuk/core/.svn/prop-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/CMakeLists.txt.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mime-type
+V 10
+text/plain
+END
diff -u -r -N nepomuk/core/.svn/prop-base/pimo.cpp.svn-base nepomuk-svn/core/.svn/prop-base/pimo.cpp.svn-base
--- nepomuk/core/.svn/prop-base/pimo.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/pimo.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/prop-base/pimo.h.svn-base nepomuk-svn/core/.svn/prop-base/pimo.h.svn-base
--- nepomuk/core/.svn/prop-base/pimo.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/pimo.h.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/prop-base/resource.cpp.svn-base nepomuk-svn/core/.svn/prop-base/resource.cpp.svn-base
--- nepomuk/core/.svn/prop-base/resource.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/resource.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/prop-base/resource.h.svn-base nepomuk-svn/core/.svn/prop-base/resource.h.svn-base
--- nepomuk/core/.svn/prop-base/resource.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/resource.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/prop-base/tag.cpp.svn-base nepomuk-svn/core/.svn/prop-base/tag.cpp.svn-base
--- nepomuk/core/.svn/prop-base/tag.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/tag.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/prop-base/tag.h.svn-base nepomuk-svn/core/.svn/prop-base/tag.h.svn-base
--- nepomuk/core/.svn/prop-base/tag.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/tag.h.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/prop-base/thing.cpp.svn-base nepomuk-svn/core/.svn/prop-base/thing.cpp.svn-base
--- nepomuk/core/.svn/prop-base/thing.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/thing.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/prop-base/thing.h.svn-base nepomuk-svn/core/.svn/prop-base/thing.h.svn-base
--- nepomuk/core/.svn/prop-base/thing.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/prop-base/thing.h.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/core/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/core/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,93 @@
+project(nepomukcore)
+
+# Some problems with conflicting qHash implementations
+KDE4_NO_ENABLE_FINAL(nepomukcore)
+
+include_directories(
+  ${nepomuk_SOURCE_DIR}
+  ${CMAKE_SOURCE_DIR}/nepomuk/
+  ${nepomukcore_SOURCE_DIR}
+  ${kdecore_SOURCE_DIR}/utils
+  ${CMAKE_SOURCE_DIR}
+  ${KDE4_INCLUDES}
+  ${KDE4_KIO_INCLUDES}
+  ${QT_INCLUDES}
+  ${SOPRANO_INCLUDE_DIR}
+)
+
+set(nepomuk_LIB_SRCS
+  variant.cpp
+  resourcedata.cpp
+  resourcemanager.cpp
+  resourcefiltermodel.cpp
+  nepomukmainmodel.cpp
+  tools.cpp
+  ui/kratingwidget.cpp
+  ui/ktagcloudwidget.cpp
+  ui/kblocklayout.cpp
+  ui/kmetadatatagcloud.cpp
+  ui/kmetadatatagwidget.cpp
+  ui/kautoscrollarea.cpp
+  ui/ktagdisplaywidget.cpp
+  ui/kratingpainter.cpp
+  ui/nepomukmassupdatejob.cpp
+  resource.cpp
+  thing.cpp
+  tag.cpp
+  ontology/entity.cpp
+  ontology/ontology.cpp
+  ontology/class.cpp
+  ontology/property.cpp
+  ontology/literal.cpp
+  ontology/ontologyloader.cpp
+  ontology/ontologymanager.cpp
+  ontology/nepomukontologyloader.cpp
+  ontology/fileontologyloader.cpp
+  ontology/desktopontologyloader.cpp
+  ontology/global.cpp
+  ontology/entitymanager.cpp
+  nie.cpp
+  pimo.cpp
+  nepomukservice.cpp
+  graphwrapper.cpp
+)
+
+
+kde4_add_library(nepomuk SHARED ${nepomuk_LIB_SRCS})
+
+add_dependencies(nepomuk nepomuk-rcgen)
+
+target_link_libraries(nepomuk
+  ${SOPRANO_LIBRARIES}
+  ${SOPRANO_CLIENT_LIBRARIES}
+  ${QT_QTCORE_LIBRARY}
+  ${QT_QTGUI_LIBRARY}
+  ${QT_QTDBUS_LIBRARY}
+  ${KDE4_KDECORE_LIBRARY}
+  kdeui
+)
+# FIXME: Do we need to include soprano libs in the link interface?
+#        And if so, which one(s)?
+target_link_libraries(nepomuk  LINK_INTERFACE_LIBRARIES  ${KDE4_KDEUI_LIBS} )
+
+
+set_target_properties(nepomuk PROPERTIES
+   VERSION ${GENERIC_LIB_VERSION}
+   SOVERSION ${GENERIC_LIB_SOVERSION}
+)
+
+install(TARGETS nepomuk EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
+install(FILES
+  variant.h
+  resourcemanager.h
+  tools.h
+  nepomukservice.h
+  resource.h
+  thing.h
+  tag.h
+  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
+)
+
+add_subdirectory(ui)
+add_subdirectory(ontology)
+add_subdirectory(test)
diff -u -r -N nepomuk/core/.svn/text-base/TODO.svn-base nepomuk-svn/core/.svn/text-base/TODO.svn-base
--- nepomuk/core/.svn/text-base/TODO.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/TODO.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,4 @@
+* Replace nao:label with rdfs:label and introduce nao:prefLabal.
+  This has to be accompanied with a module that changes all nao:label occurences to rdfs:label or nao:prefLabel.
+* PROBLEM: if we have for example multiple rdfs:label statements for one resource Resource::label().toString() will return
+           a comma-separated list which is not what we want at all!
diff -u -r -N nepomuk/core/.svn/text-base/graphwrapper.cpp.svn-base nepomuk-svn/core/.svn/text-base/graphwrapper.cpp.svn-base
--- nepomuk/core/.svn/text-base/graphwrapper.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/graphwrapper.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,141 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "graphwrapper_p.h"
+
+#include <Soprano/Model>
+#include <Soprano/Node>
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/NAO>
+
+#include <QtCore/QDateTime>
+#include <QtCore/QUuid>
+#include <QtCore/QRegExp>
+
+namespace {
+    QUrl createGraphUri() {
+        return QUrl( "urn:nepomuk:local:" + QUuid::createUuid().toString().remove( QRegExp( "[\\{\\}]" ) ) );
+    }
+
+    QUrl createUniqueGraphUri( Soprano::Model* model ) {
+        while( 1 ) {
+            QUrl uri = createGraphUri();
+            if ( !model->executeQuery( QString("ask where { { <%1> ?p1 ?o1 . } UNION { ?r2 <%1> ?o2 . } UNION { ?r3 ?p3 <%1> . } }")
+                                       .arg( QString::fromAscii( uri.toEncoded() ) ), Soprano::Query::QueryLanguageSparql ).boolValue() ) {
+                return uri;
+            }
+        }
+    }
+}
+
+
+Nepomuk::GraphWrapper::GraphWrapper( QObject* parent )
+    : QObject( parent ),
+      m_currentGraphStored( true )
+{
+    connect( &m_timer, SIGNAL(timeout()),
+             this, SLOT(slotTimeout()) );
+    m_timer.setSingleShot( true );
+}
+
+
+Nepomuk::GraphWrapper::~GraphWrapper()
+{
+}
+
+
+void Nepomuk::GraphWrapper::setModel( Soprano::Model* model )
+{
+    if( m_model != model ) {
+        m_model = model;
+        m_currentGraph = QUrl();
+    }
+}
+
+
+QUrl Nepomuk::GraphWrapper::lookupCurrentGraph() const
+{
+    return m_currentGraph;
+}
+
+
+QUrl Nepomuk::GraphWrapper::currentGraph()
+{
+    if( !m_currentGraph.isValid() ) {
+        createNewGraph();
+    }
+
+    if( !m_currentGraphStored ) {
+        storeGraph( m_currentGraph );
+        m_currentGraphStored = true;
+    }
+    return m_currentGraph;
+}
+
+
+void Nepomuk::GraphWrapper::slotTimeout()
+{
+    // generate a new graph every event loop if the last one was used
+    if( m_currentGraphStored ) {
+        createNewGraph();
+    }
+}
+
+
+void Nepomuk::GraphWrapper::createNewGraph()
+{
+    m_currentGraph = createUniqueGraphUri( m_model );
+    m_currentGraphStored = false;
+}
+
+
+void Nepomuk::GraphWrapper::storeGraph( const QUrl& graph )
+{
+    QUrl metadataGraph = createUniqueGraphUri( m_model );
+
+    m_model->addStatement( graph,
+                           Soprano::Vocabulary::RDF::type(),
+                           Soprano::Vocabulary::NRL::InstanceBase(),
+                           metadataGraph );
+    m_model->addStatement( graph,
+                           Soprano::Vocabulary::NAO::created(),
+                           Soprano::LiteralValue( QDateTime::currentDateTime() ),
+                           metadataGraph );
+    m_model->addStatement( metadataGraph,
+                           Soprano::Vocabulary::RDF::type(),
+                           Soprano::Vocabulary::NRL::GraphMetadata(),
+                           metadataGraph );
+    m_model->addStatement( metadataGraph,
+                           Soprano::Vocabulary::NRL::coreGraphMetadataFor(),
+                           graph,
+                           metadataGraph );
+
+    //
+    // We update the graph every 200 mseconds but only when entering
+    // the event loop.
+    // I think it is ok for the user to think that two things
+    // created a quarter of a second apart are created at the same time
+    //
+    m_timer.start( 200 );
+}
+
+#include "graphwrapper_p.moc"
diff -u -r -N nepomuk/core/.svn/text-base/graphwrapper_p.h.svn-base nepomuk-svn/core/.svn/text-base/graphwrapper_p.h.svn-base
--- nepomuk/core/.svn/text-base/graphwrapper_p.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/graphwrapper_p.h.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,86 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_GRAPH_WRAPPER_H_
+#define _NEPOMUK_GRAPH_WRAPPER_H_
+
+#include <QtCore/QObject>
+#include <QtCore/QTimer>
+#include <QtCore/QUrl>
+
+namespace Soprano {
+    class Model;
+}
+
+namespace Nepomuk {
+    /**
+     * Creates a new graph whenever the event loop is entered.
+     * This way we do not create a new graph for each statement
+     * added to the main model but group sets of added statements
+     * into graphs.
+     *
+     * We need separate graphs to be able to track their creation time.
+     *
+     * IDEA: We actually need multiple graphs to be able to save the creation date of statements (annotations)
+     *       At the same time we do not want to create one graph for each created statement as we do in KDE 4.1
+     *       A timeout is a bad idea, too, since some batch operations may take longer than our timeout which
+     *       would lead to different graphs for the same batch.
+     *       Thus, why not using the event loop? Just use a timer whenever statements are added to 
+     *       trigger the creation of a new graph on the next adding. Long batch operations as done in the 
+     *       Akonadi feeders would result in a single graph while separate user actions in a GUI would always
+     *       lead to separate graphs.
+     */
+    class GraphWrapper : public QObject
+    {
+        Q_OBJECT
+
+    public:
+        GraphWrapper( QObject* parent = 0 );
+        ~GraphWrapper();
+
+        /**
+         * Only look at the graph.
+         */
+        QUrl lookupCurrentGraph() const;
+
+        /**
+         * Get the current graph. This will also store
+         * the graph in the main model if not done already.
+         */
+        QUrl currentGraph();
+
+        void setModel( Soprano::Model* model );
+
+    private Q_SLOTS:
+        void slotTimeout();
+
+    private:
+        void createNewGraph();
+        void storeGraph( const QUrl& );
+
+        QUrl m_currentGraph;
+        bool m_currentGraphStored;
+        QTimer m_timer;
+
+        Soprano::Model* m_model;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/nepomukmainmodel.cpp.svn-base nepomuk-svn/core/.svn/text-base/nepomukmainmodel.cpp.svn-base
--- nepomuk/core/.svn/text-base/nepomukmainmodel.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/nepomukmainmodel.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,276 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "nepomukmainmodel.h"
+#include "resourcemanager.h"
+
+#include <Soprano/Node>
+#include <Soprano/Statement>
+#include <Soprano/StatementIterator>
+#include <Soprano/NodeIterator>
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Client/DBusModel>
+#include <Soprano/Client/DBusClient>
+#include <Soprano/Client/LocalSocketClient>
+#include <Soprano/Query/QueryLanguage>
+#include <Soprano/Util/DummyModel>
+#include <Soprano/Util/MutexModel>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/NAO>
+
+#include <kglobal.h>
+#include <kstandarddirs.h>
+#include <kdebug.h>
+
+#include <QtCore/QTimer>
+
+
+// FIXME: connect to some NepomukServer signal which emit enabled/disabled information
+//        when the server shuts down and is started again
+// FIXME: disconnect localSocketClient after n seconds of idling (but take care of not
+//        disconnecting when iterators are open)
+
+using namespace Soprano;
+
+
+namespace {
+class GlobalModelContainer
+{
+public:
+    GlobalModelContainer()
+        : dbusClient( "org.kde.nepomuk.services.nepomukstorage" ),
+          dbusModel( 0 ),
+          localSocketModel( 0 ),
+          mutexModel( 0 ),
+          dummyModel( 0 ),
+          m_socketConnectFailed( false ) {
+    }
+
+    ~GlobalModelContainer() {
+        delete mutexModel;
+        delete dbusModel;
+        delete localSocketModel;
+        delete dummyModel;
+    }
+
+    Soprano::Client::DBusClient dbusClient;
+    Soprano::Client::LocalSocketClient localSocketClient;
+    Soprano::Client::DBusModel* dbusModel;
+    Soprano::Model* localSocketModel;
+    Soprano::Util::MutexModel* mutexModel;
+
+    Soprano::Util::DummyModel* dummyModel;
+
+    void init() {
+        if ( !dbusModel ) {
+            dbusModel = dbusClient.createModel( "main" );
+        }
+
+        if ( !mutexModel ) {
+            mutexModel = new Soprano::Util::MutexModel( Soprano::Util::MutexModel::ReadWriteMultiThreading );
+        }
+
+        // we may get disconnected from the server but we don't want to try
+        // to connect every time the model is requested
+        if ( !m_socketConnectFailed && !localSocketClient.isConnected() ) {
+            if ( mutexModel->parentModel() == localSocketModel )
+                mutexModel->setParentModel( 0 );
+            delete localSocketModel;
+            localSocketModel = 0;
+            QString socketName = KGlobal::dirs()->locateLocal( "data", "nepomuk/socket" );
+            if ( localSocketClient.connect( socketName ) ) {
+                localSocketModel = localSocketClient.createModel( "main" );
+            }
+            else {
+                m_socketConnectFailed = true;
+                kDebug() << "Failed to connect to Nepomuk server via local socket" << socketName;
+            }
+        }
+    }
+
+    Soprano::Model* model() {
+        init();
+
+        // we always prefer the faster local socket client
+        if ( localSocketModel ) {
+            if ( mutexModel->parentModel() != localSocketModel ) {
+                mutexModel->setParentModel( localSocketModel );
+            }
+        }
+        else if ( dbusModel ) {
+            if ( mutexModel->parentModel() != dbusModel ) {
+                mutexModel->setParentModel( dbusModel );
+            }
+        }
+        else {
+            if ( !dummyModel ) {
+                dummyModel = new Soprano::Util::DummyModel();
+            }
+            return dummyModel;
+        }
+
+        return mutexModel;
+    }
+
+private:
+    bool m_socketConnectFailed;
+};
+}
+
+Q_GLOBAL_STATIC( GlobalModelContainer, modelContainer )
+
+
+class Nepomuk::MainModel::Private
+{
+public:
+    Private( MainModel* p )
+        : q(p) {
+    }
+
+private:
+    MainModel* q;
+};
+
+
+Nepomuk::MainModel::MainModel( QObject* parent )
+    : Soprano::Model(),
+      d( new Private(this) )
+{
+    setParent( parent );
+
+    modelContainer()->init();
+
+    if ( modelContainer()->dbusModel ) {
+        // we have to use the dbus model for signals in any case
+        connect( modelContainer()->dbusModel, SIGNAL( statementsAdded() ),
+                 this, SIGNAL( statementsAdded() ) );
+        connect( modelContainer()->dbusModel, SIGNAL( statementsRemoved() ),
+                 this, SIGNAL( statementsRemoved() ) );
+        connect( modelContainer()->dbusModel, SIGNAL( statementAdded(const Soprano::Statement&) ),
+                 this, SIGNAL( statementAdded(const Soprano::Statement&) ) );
+        connect( modelContainer()->dbusModel, SIGNAL( statementRemoved(const Soprano::Statement&) ),
+                 this, SIGNAL( statementRemoved(const Soprano::Statement&) ) );
+    }
+}
+
+
+Nepomuk::MainModel::~MainModel()
+{
+    delete d;
+}
+
+
+bool Nepomuk::MainModel::isValid() const
+{
+    return modelContainer()->dbusClient.isValid() || modelContainer()->localSocketClient.isConnected();
+}
+
+
+Soprano::StatementIterator Nepomuk::MainModel::listStatements( const Statement& partial ) const
+{
+    Soprano::StatementIterator it = modelContainer()->model()->listStatements( partial );
+    setError( modelContainer()->model()->lastError() );
+    return it;
+}
+
+
+Soprano::NodeIterator Nepomuk::MainModel::listContexts() const
+{
+    Soprano::NodeIterator it = modelContainer()->model()->listContexts();
+    setError( modelContainer()->model()->lastError() );
+    return it;
+}
+
+
+Soprano::QueryResultIterator Nepomuk::MainModel::executeQuery( const QString& query,
+                                                               Soprano::Query::QueryLanguage language,
+                                                               const QString& userQueryLanguage ) const
+{
+    Soprano::QueryResultIterator it = modelContainer()->model()->executeQuery( query, language, userQueryLanguage );
+    setError( modelContainer()->model()->lastError() );
+    return it;
+}
+
+
+bool Nepomuk::MainModel::containsStatement( const Statement& statement ) const
+{
+    bool b = modelContainer()->model()->containsStatement( statement );
+    setError( modelContainer()->model()->lastError() );
+    return b;
+}
+
+
+bool Nepomuk::MainModel::containsAnyStatement( const Statement &statement ) const
+{
+    bool b = modelContainer()->model()->containsAnyStatement( statement );
+    setError( modelContainer()->model()->lastError() );
+    return b;
+}
+
+
+bool Nepomuk::MainModel::isEmpty() const
+{
+    bool b = modelContainer()->model()->isEmpty();
+    setError( modelContainer()->model()->lastError() );
+    return b;
+}
+
+
+int Nepomuk::MainModel::statementCount() const
+{
+    int c = modelContainer()->model()->statementCount();
+    setError( modelContainer()->model()->lastError() );
+    return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::MainModel::addStatement( const Statement& statement )
+{
+    Soprano::Error::ErrorCode c = modelContainer()->model()->addStatement( statement );
+    setError( modelContainer()->model()->lastError() );
+    return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::MainModel::removeStatement( const Statement& statement )
+{
+    Soprano::Error::ErrorCode c = modelContainer()->model()->removeStatement( statement );
+    setError( modelContainer()->model()->lastError() );
+    return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::MainModel::removeAllStatements( const Statement& statement )
+{
+    Soprano::Error::ErrorCode c = modelContainer()->model()->removeAllStatements( statement );
+    setError( modelContainer()->model()->lastError() );
+    return c;
+}
+
+
+Soprano::Node Nepomuk::MainModel::createBlankNode()
+{
+    Soprano::Node n = modelContainer()->model()->createBlankNode();
+    setError( modelContainer()->model()->lastError() );
+    return n;
+}
+
+#include "nepomukmainmodel.moc"
diff -u -r -N nepomuk/core/.svn/text-base/nepomukmainmodel.h.svn-base nepomuk-svn/core/.svn/text-base/nepomukmainmodel.h.svn-base
--- nepomuk/core/.svn/text-base/nepomukmainmodel.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/nepomukmainmodel.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,108 @@
+/* 
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_MAIN_MODEL_H_
+#define _NEPOMUK_MAIN_MODEL_H_
+
+#include <Soprano/Model>
+#include <Soprano/Vocabulary/RDFS>
+
+#include <QtCore/QDateTime>
+
+namespace Nepomuk {
+    /**
+     * \class MainModel nepomukmainmodel.h Nepomuk/MainModel
+     *
+     * \brief The main %Nepomuk data storage model.
+     *
+     * All user data is stored in the %Nepomuk main model.
+     * This is a wrapper model which communicates all commands
+     * to the %Nepomuk server.
+     *
+     * Usage is very simple. Just create an instance and start
+     * using it. Use the isValid method to check the connection 
+     * to the server. All communication details are handled transparently.
+     *
+     * It is perfectly alright to create several instances of MainModel
+     * in one application as internally all is mapped to a single global
+     * instance which is also reused in ResourceManager::mainModel.
+     *
+     * Provides a set of convenience methods
+     * for maintaining resource properties.
+     *
+     * It does automatic NRL named graph handling, i.e. provedance
+     * data is created and deleted automatically.
+     *
+     * \warning This model assumes that no property value is stored twice,
+     * i.e. in two different named graphs.
+     *
+     * \author Sebastian Trueg <trueg@kde.org>
+     *
+     * \since 4.2
+     *
+     * \sa ResourceManager::mainModel()
+     */
+    class MainModel : public Soprano::Model
+    {
+        Q_OBJECT
+
+    public:
+        /**
+         * Create a new main model.
+         */
+        MainModel( QObject* parent = 0 );
+
+        /**
+         * Destructor.
+         */
+        ~MainModel();
+
+        /**
+         * Check the connection to the %Nepomuk server.
+         * \return \p true if the connection is valid and commands can be issued,
+         * \p false otherwise.
+         */
+        bool isValid() const;
+
+        Soprano::StatementIterator listStatements( const Soprano::Statement &partial ) const;
+        Soprano::NodeIterator listContexts() const;
+        Soprano::QueryResultIterator executeQuery( const QString& query, 
+                                                   Soprano::Query::QueryLanguage language, 
+                                                   const QString& userQueryLanguage = QString() ) const;
+        bool containsStatement( const Soprano::Statement &statement ) const;
+        bool containsAnyStatement( const Soprano::Statement &statement ) const;
+        bool isEmpty() const;
+        int statementCount() const;
+        Soprano::Error::ErrorCode addStatement( const Soprano::Statement& statement );
+        Soprano::Error::ErrorCode removeStatement( const Soprano::Statement& statement );
+        Soprano::Error::ErrorCode removeAllStatements( const Soprano::Statement& statement );
+        Soprano::Node createBlankNode();
+
+        using Model::addStatement;
+        using Model::removeStatement;
+        using Model::removeAllStatements;
+
+    private:
+        class Private;
+        Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/nepomukservice.cpp.svn-base nepomuk-svn/core/.svn/text-base/nepomukservice.cpp.svn-base
--- nepomuk/core/.svn/text-base/nepomukservice.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/nepomukservice.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,68 @@
+/* This file is part of the KDE Project
+   Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License version 2 as published by the Free Software Foundation.
+
+   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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#include "nepomukservice.h"
+#include "nepomukmainmodel.h"
+
+#include <QtCore/QTimer>
+
+
+class Nepomuk::Service::Private
+{
+public:
+    MainModel* model;
+};
+
+
+Nepomuk::Service::Service( QObject* parent, bool delayedInitialization )
+    : QObject( parent ),
+      d( new Private() )
+{
+    d->model = 0;
+    if ( !delayedInitialization ) {
+        setServiceInitialized( true );
+    }
+}
+
+
+Nepomuk::Service::~Service()
+{
+    delete d->model;
+    delete d;
+}
+
+
+Soprano::Model* Nepomuk::Service::mainModel()
+{
+    if ( !d->model ) {
+        d->model = new MainModel( this );
+    }
+    return d->model;
+}
+
+
+void Nepomuk::Service::setServiceInitialized( bool success )
+{
+    // the parent will always be a control class in the service stub
+    QMetaObject::invokeMethod( parent(),
+                               "setServiceInitialized",
+                               Qt::QueuedConnection,  // needs to be queued to give the service time to register with DBus
+                               Q_ARG(bool, success) );
+}
+
+#include "nepomukservice.moc"
diff -u -r -N nepomuk/core/.svn/text-base/nepomukservice.h.svn-base nepomuk-svn/core/.svn/text-base/nepomukservice.h.svn-base
--- nepomuk/core/.svn/text-base/nepomukservice.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/nepomukservice.h.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,145 @@
+/* This file is part of the KDE Project
+   Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License version 2 as published by the Free Software Foundation.
+
+   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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_SERVICE_H_
+#define _NEPOMUK_SERVICE_H_
+
+#include <QtCore/QObject>
+#include "nepomuk_export.h"
+
+namespace Soprano {
+    class Model;
+}
+
+namespace Nepomuk {
+    /**
+     * \class Service nepomukservice.h Nepomuk/Service
+     *
+     * \brief Base class for all Nepomuk services.
+     *
+     * A %Nepomuk service is intended to perform some kind of
+     * operation on the %Nepomuk data storage. This can include
+     * data gathering, data enrichment, or enhanced data query.
+     *
+     * %Nepomuk services are started and managed by the %Nepomuk
+     * server. Very much like KDED modules a %Nepomuk service
+     * has autostart and start-on-demand properties. In addition
+     * a %Nepomuk service can define an arbitrary number of
+     * dependencies which are necessary to run the service. These
+     * dependencies name other services.
+     *
+     * To create a new %Nepomuk service one derives a new class from
+     * Nepomuk::Service and exports it as a standard KDE module, i.e.
+     * plugin.
+     *
+     * \code
+     * class MyService : public Nepomuk::Service
+     * {
+     *    // do fancy stuff
+     * };
+     * \endcode
+     *
+     * Export it as a %Nepomuk service plugin:
+     *
+     * \code
+     * NEPOMUK_EXPORT_SERVICE(MyService, "mynepomukservice")
+     * \endcode
+     *
+     * A desktop file describes the service's properties:
+     *
+     * \code
+     * [Desktop Entry]
+     * Type=Service
+     * X-KDE-ServiceTypes=NepomukService
+     * X-KDE-Library=mynepomukservice
+     * X-KDE-Nepomuk-autostart=true
+     * X-KDE-Nepomuk-start-on-demand=false
+     * # Dependencies default to 'nepomukstorage'
+     * X-KDE-Nepomuk-dependencies=nepomukfoobar
+     * Name=My fancy Nepomuk Service
+     * Comment=A Nepomuk service that does fancy things
+     * \endcode
+     *
+     * The %Nepomuk server will automatically export all D-Bus
+     * interfaces defined on the service instance. Thus, the 
+     * simplest way to export methods via D-Bus is by marking
+     * them with Q_SCRIPTABLE.
+     *
+     * \author Sebastian Trueg <trueg@kde.org>
+     *
+     * \since 4.1
+     */
+    class NEPOMUK_EXPORT Service : public QObject
+    {
+        Q_OBJECT
+
+    public:
+        /**
+         * Create a new Service.
+         *
+         * \param parent The parent object
+         * \param delayedInitialization If \p true the service will not
+         * be usable until setServiceInitialized has been called.
+         * This allows to design services that need to perform 
+         * long initialization tasks.
+         */
+        Service( QObject* parent = 0, bool delayedInitialization = false );
+
+        /**
+         * Destructor
+         */
+        virtual ~Service();
+
+    protected:
+        /**
+         * \return A wrapper model which provides
+         * a connection to the %Nepomuk server.
+         */
+        Soprano::Model* mainModel();
+
+        /**
+         * A %Nepomuk service can make use of a warmup phase in which
+         * it is not usable yet. Call this method once your service
+         * is fully initialized.
+         *
+         * Most services do not need to call this method.
+         *
+         * \param success Set to \c true if initialization was
+         * successful, \c false otherwise.
+         *
+         * \sa Service::Service
+         */
+        void setServiceInitialized( bool success );
+
+    private:
+        class Private;
+        Private* const d;
+    };
+}
+
+/**
+ * Export a %Nepomuk service.
+ *
+ * \param classname The name of the Nepomuk::Service subclass to export.
+ * \param libname The name of the library which should export the service.
+ */
+#define NEPOMUK_EXPORT_SERVICE( classname, libname )    \
+K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
+K_EXPORT_PLUGIN(factory(#libname))
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/nie.cpp.svn-base nepomuk-svn/core/.svn/text-base/nie.cpp.svn-base
--- nepomuk/core/.svn/text-base/nie.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/nie.cpp.svn-base	2009-02-27 13:37:46.000000000 +0100
@@ -0,0 +1,311 @@
+/*
+ * This file has been generated by the onto2vocabularyclass tool
+ * copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "nie.h"
+
+class NiePrivate
+{
+public:
+    NiePrivate()
+        : nie_namespace( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#" ),
+          nie_DataObject( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#DataObject" ),
+          nie_DataSource( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#DataSource" ),
+          nie_InformationElement( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#InformationElement" ),
+          nie_byteSize( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#byteSize" ),
+          nie_characterSet( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#characterSet" ),
+          nie_comment( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment" ),
+          nie_contentCreated( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated" ),
+          nie_contentLastModified( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentLastModified" ),
+          nie_contentSize( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize" ),
+          nie_copyright( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright" ),
+          nie_created( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#created" ),
+          nie_dataSource( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#dataSource" ),
+          nie_depends( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#depends" ),
+          nie_description( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description" ),
+          nie_disclaimer( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#disclaimer" ),
+          nie_generator( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator" ),
+          nie_generatorOption( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generatorOption" ),
+          nie_hasLogicalPart( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasLogicalPart" ),
+          nie_hasPart( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasPart" ),
+          nie_identifier( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#identifier" ),
+          nie_informationElementDate( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#informationElementDate" ),
+          nie_interpretedAs( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#interpretedAs" ),
+          nie_isLogicalPartOf( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isLogicalPartOf" ),
+          nie_isPartOf( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf" ),
+          nie_isStoredAs( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isStoredAs" ),
+          nie_keyword( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword" ),
+          nie_language( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#language" ),
+          nie_lastRefreshed( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastRefreshed" ),
+          nie_legal( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#legal" ),
+          nie_license( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#license" ),
+          nie_licenseType( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#licenseType" ),
+          nie_links( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#links" ),
+          nie_mimeType( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType" ),
+          nie_plainTextContent( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#plainTextContent" ),
+          nie_relatedTo( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#relatedTo" ),
+          nie_rootElementOf( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#rootElementOf" ),
+          nie_subject( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject" ),
+          nie_title( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title" ),
+          nie_version( "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#version" ) {
+    }
+
+    QUrl nie_namespace;
+    QUrl nie_DataObject;
+    QUrl nie_DataSource;
+    QUrl nie_InformationElement;
+    QUrl nie_byteSize;
+    QUrl nie_characterSet;
+    QUrl nie_comment;
+    QUrl nie_contentCreated;
+    QUrl nie_contentLastModified;
+    QUrl nie_contentSize;
+    QUrl nie_copyright;
+    QUrl nie_created;
+    QUrl nie_dataSource;
+    QUrl nie_depends;
+    QUrl nie_description;
+    QUrl nie_disclaimer;
+    QUrl nie_generator;
+    QUrl nie_generatorOption;
+    QUrl nie_hasLogicalPart;
+    QUrl nie_hasPart;
+    QUrl nie_identifier;
+    QUrl nie_informationElementDate;
+    QUrl nie_interpretedAs;
+    QUrl nie_isLogicalPartOf;
+    QUrl nie_isPartOf;
+    QUrl nie_isStoredAs;
+    QUrl nie_keyword;
+    QUrl nie_language;
+    QUrl nie_lastRefreshed;
+    QUrl nie_legal;
+    QUrl nie_license;
+    QUrl nie_licenseType;
+    QUrl nie_links;
+    QUrl nie_mimeType;
+    QUrl nie_plainTextContent;
+    QUrl nie_relatedTo;
+    QUrl nie_rootElementOf;
+    QUrl nie_subject;
+    QUrl nie_title;
+    QUrl nie_version;
+};
+
+Q_GLOBAL_STATIC( NiePrivate, s_nie )
+
+QUrl Nepomuk::Vocabulary::NIE::nieNamespace()
+{
+    return s_nie()->nie_namespace;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::DataObject()
+{
+    return s_nie()->nie_DataObject;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::DataSource()
+{
+    return s_nie()->nie_DataSource;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::InformationElement()
+{
+    return s_nie()->nie_InformationElement;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::byteSize()
+{
+    return s_nie()->nie_byteSize;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::characterSet()
+{
+    return s_nie()->nie_characterSet;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::comment()
+{
+    return s_nie()->nie_comment;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::contentCreated()
+{
+    return s_nie()->nie_contentCreated;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::contentLastModified()
+{
+    return s_nie()->nie_contentLastModified;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::contentSize()
+{
+    return s_nie()->nie_contentSize;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::copyright()
+{
+    return s_nie()->nie_copyright;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::created()
+{
+    return s_nie()->nie_created;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::dataSource()
+{
+    return s_nie()->nie_dataSource;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::depends()
+{
+    return s_nie()->nie_depends;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::description()
+{
+    return s_nie()->nie_description;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::disclaimer()
+{
+    return s_nie()->nie_disclaimer;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::generator()
+{
+    return s_nie()->nie_generator;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::generatorOption()
+{
+    return s_nie()->nie_generatorOption;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::hasLogicalPart()
+{
+    return s_nie()->nie_hasLogicalPart;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::hasPart()
+{
+    return s_nie()->nie_hasPart;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::identifier()
+{
+    return s_nie()->nie_identifier;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::informationElementDate()
+{
+    return s_nie()->nie_informationElementDate;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::interpretedAs()
+{
+    return s_nie()->nie_interpretedAs;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::isLogicalPartOf()
+{
+    return s_nie()->nie_isLogicalPartOf;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::isPartOf()
+{
+    return s_nie()->nie_isPartOf;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::isStoredAs()
+{
+    return s_nie()->nie_isStoredAs;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::keyword()
+{
+    return s_nie()->nie_keyword;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::language()
+{
+    return s_nie()->nie_language;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::lastRefreshed()
+{
+    return s_nie()->nie_lastRefreshed;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::legal()
+{
+    return s_nie()->nie_legal;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::license()
+{
+    return s_nie()->nie_license;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::licenseType()
+{
+    return s_nie()->nie_licenseType;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::links()
+{
+    return s_nie()->nie_links;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::mimeType()
+{
+    return s_nie()->nie_mimeType;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::plainTextContent()
+{
+    return s_nie()->nie_plainTextContent;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::relatedTo()
+{
+    return s_nie()->nie_relatedTo;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::rootElementOf()
+{
+    return s_nie()->nie_rootElementOf;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::subject()
+{
+    return s_nie()->nie_subject;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::title()
+{
+    return s_nie()->nie_title;
+}
+
+QUrl Nepomuk::Vocabulary::NIE::version()
+{
+    return s_nie()->nie_version;
+}
diff -u -r -N nepomuk/core/.svn/text-base/nie.h.svn-base nepomuk-svn/core/.svn/text-base/nie.h.svn-base
--- nepomuk/core/.svn/text-base/nie.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/nie.h.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,430 @@
+/*
+ * This file has been generated by the onto2vocabularyclass tool
+ * copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _SOPRANO_NIE_H_
+#define _SOPRANO_NIE_H_
+
+#include <QtCore/QUrl>
+
+namespace Nepomuk {
+    namespace Vocabulary {
+        namespace NIE {
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#
+             */
+            QUrl nieNamespace();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#DataObject 
+             * 
+             * A unit of data that is created, annotated and processed on the 
+             * user desktop. It represents a native structure the user works 
+             * with. The usage of the term 'native' is important. It means that 
+             * a DataObject can be directly mapped to a data structure maintained 
+             * by a native application. This may be a file, a set of files or a 
+             * part of a file. The granularity depends on the user. This class 
+             * is not intended to be instantiated by itself. Use more specific 
+             * subclasses. 
+             */
+            QUrl DataObject();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#DataSource 
+             * 
+             * A superclass for all entities from which DataObjects can be 
+             * extracted. Each entity represents a native application or 
+             * some other system that manages information that may be of interest 
+             * to the user of the Semantic Desktop. Subclasses may include 
+             * FileSystems, Mailboxes, Calendars, websites etc. The exact 
+             * choice of subclasses and their properties is considered application-specific. 
+             * Each data extraction application is supposed to provide it's 
+             * own DataSource ontology. Such an ontology should contain supported 
+             * data source types coupled with properties necessary for the 
+             * application to gain access to the data sources. (paths, urls, 
+             * passwords etc...) 
+             */
+            QUrl DataSource();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#InformationElement 
+             * 
+             * A unit of content the user works with. This is a superclass for 
+             * all interpretations of a DataObject. 
+             */
+            QUrl InformationElement();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#byteSize 
+             * 
+             * The overall size of the data object in bytes. That means the WHOLE 
+             * data object and ONLY the data object, not of the content that 
+             * is of interest to the user. For cases where the content size is 
+             * different (e.g. in compressed files the content is larger, 
+             * in messages the content excludes headings and is smaller) use 
+             * more specific properties, not necessarily subproperties 
+             * of this one. 
+             */
+            QUrl byteSize();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#characterSet 
+             * 
+             * Characterset in which the content of the InformationElement 
+             * was created. Example: ISO-8859-1, UTF-8. One of the registered 
+             * character sets at http://www.iana.org/assignments/character-sets. 
+             * This characterSet is used to interpret any textual parts of 
+             * the content. If more than one characterSet is used within one 
+             * data object, use more specific properties. 
+             */
+            QUrl characterSet();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment 
+             * 
+             * A user comment about an InformationElement. 
+             */
+            QUrl comment();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated 
+             * 
+             * The date of the content creation. This may not necessarily be 
+             * equal to the date when the DataObject (i.e. the physical representation) 
+             * itself was created. Compare with nie:created property. 
+             */
+            QUrl contentCreated();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentLastModified 
+             * 
+             * The date of the last modification of the content. 
+             */
+            QUrl contentLastModified();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize 
+             * 
+             * The size of the content. This property can be used whenever the 
+             * size of the content of an InformationElement differs from the 
+             * size of the DataObject. (e.g. because of compression, encoding, 
+             * encryption or any other representation issues). The contentSize 
+             * in expressed in bytes. 
+             */
+            QUrl contentSize();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#copyright 
+             * 
+             * Content copyright 
+             */
+            QUrl copyright();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#created 
+             * 
+             * Date of creation of the DataObject. Note that this date refers 
+             * to the creation of the DataObject itself (i.e. the physical 
+             * representation). Compare with nie:contentCreated. 
+             */
+            QUrl created();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#dataSource 
+             * 
+             * Marks the provenance of a DataObject, what source does a data 
+             * object come from. 
+             */
+            QUrl dataSource();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#depends 
+             * 
+             * Dependency relation. A piece of content depends on another 
+             * piece of data in order to be properly understood/used/interpreted. 
+             */
+            QUrl depends();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description 
+             * 
+             * A textual description of the resource. This property may be 
+             * used for any metadata fields that provide some meta-information 
+             * or comment about a resource in the form of a passage of text. This 
+             * property is not to be confused with nie:plainTextContent. 
+             * Use more specific subproperties wherever possible. 
+             */
+            QUrl description();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#disclaimer 
+             * 
+             * A disclaimer 
+             */
+            QUrl disclaimer();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator 
+             * 
+             * Software used to "generate" the contents. E.g. a word processor 
+             * name. 
+             */
+            QUrl generator();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generatorOption 
+             * 
+             * A common superproperty for all settings used by the generating 
+             * software. This may include compression settings, algorithms, 
+             * autosave, interlaced/non-interlaced etc. Note that this 
+             * property has no range specified and therefore should not be 
+             * used directly. Always use more specific properties. 
+             */
+            QUrl generatorOption();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasLogicalPart 
+             * 
+             * Generic property used to express 'logical' containment relationships 
+             * between DataObjects. NIE extensions are encouraged to provide 
+             * more specific subproperties of this one. It is advisable for 
+             * actual instances of InformationElement to use those specific 
+             * subproperties. Note the difference between 'physical' containment 
+             * (hasPart) and logical containment (hasLogicalPart) 
+             */
+            QUrl hasLogicalPart();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasPart 
+             * 
+             * Generic property used to express 'physical' containment relationships 
+             * between DataObjects. NIE extensions are encouraged to provide 
+             * more specific subproperties of this one. It is advisable for 
+             * actual instances of DataObjects to use those specific subproperties. 
+             * Note to the developers: Please be aware of the distinction between 
+             * containment relation and provenance. The hasPart relation 
+             * models physical containment, an InformationElement (a nmo:Message) 
+             * can have a 'physical' part (an nfo:Attachment). Also, please 
+             * note the difference between physical containment (hasPart) 
+             * and logical containment (hasLogicalPart) the former has more 
+             * strict meaning. They may occur independently of each other. 
+             */
+            QUrl hasPart();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#identifier 
+             * 
+             * An unambiguous reference to the InformationElement within 
+             * a given context. Recommended best practice is to identify the 
+             * resource by means of a string conforming to a formal identification 
+             * system. 
+             */
+            QUrl identifier();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#informationElementDate 
+             * 
+             * A point or period of time associated with an event in the lifecycle 
+             * of an Information Element. A common superproperty for all date-related 
+             * properties of InformationElements in the NIE Framework. 
+             */
+            QUrl informationElementDate();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#interpretedAs 
+             * 
+             * Links the DataObject with the InformationElement it is interpreted 
+             * as. 
+             */
+            QUrl interpretedAs();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isLogicalPartOf 
+             * 
+             * Generic property used to express 'logical' containment relationships 
+             * between DataObjects. NIE extensions are encouraged to provide 
+             * more specific subproperties of this one. It is advisable for 
+             * actual instances of InformationElement to use those specific 
+             * subproperties. Note the difference between 'physical' containment 
+             * (isPartOf) and logical containment (isLogicalPartOf) 
+             */
+            QUrl isLogicalPartOf();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf 
+             * 
+             * Generic property used to express containment relationships 
+             * between DataObjects. NIE extensions are encouraged to provide 
+             * more specific subproperties of this one. It is advisable for 
+             * actual instances of DataObjects to use those specific subproperties. 
+             * Note to the developers: Please be aware of the distinction between 
+             * containment relation and provenance. The isPartOf relation 
+             * models physical containment, a nie:DataObject (e.g. an nfo:Attachment) 
+             * is a 'physical' part of an nie:InformationElement (a nmo:Message). 
+             * Also, please note the difference between physical containment 
+             * (isPartOf) and logical containment (isLogicalPartOf) the 
+             * former has more strict meaning. They may occur independently 
+             * of each other. 
+             */
+            QUrl isPartOf();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isStoredAs 
+             * 
+             * Links the information element with the DataObject it is stored 
+             * in. 
+             */
+            QUrl isStoredAs();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword 
+             * 
+             * Adapted DublinCore: The topic of the content of the resource, 
+             * as keyword. No sentences here. Recommended best practice is 
+             * to select a value from a controlled vocabulary or formal classification 
+             * scheme. 
+             */
+            QUrl keyword();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#language 
+             * 
+             * Language the InformationElement is expressed in. This property 
+             * applies to the data object in its entirety. If the data object 
+             * is divisible into parts expressed in multiple languages - more 
+             * specific properties should be used. Users are encouraged to 
+             * use the two-letter code specified in the RFC 3066 
+             */
+            QUrl language();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastRefreshed 
+             * 
+             * Date when information about this data object was retrieved 
+             * (for the first time) or last refreshed from the data source. 
+             * This property is important for metadata extraction applications 
+             * that don't receive any notifications of changes in the data 
+             * source and have to poll it regularly. This may lead to information 
+             * becoming out of date. In these cases this property may be used 
+             * to determine the age of data, which is an important element of 
+             * it's dependability. 
+             */
+            QUrl lastRefreshed();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#legal 
+             * 
+             * A common superproperty for all properties that point at legal 
+             * information about an Information Element 
+             */
+            QUrl legal();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#license 
+             * 
+             * Terms and intellectual property rights licensing conditions. 
+             */
+            QUrl license();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#licenseType 
+             * 
+             * The type of the license. Possible values for this field may include 
+             * "GPL", "BSD", "Creative Commons" etc. 
+             */
+            QUrl licenseType();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#links 
+             * 
+             * A linking relation. A piece of content links/mentions a piece 
+             * of data 
+             */
+            QUrl links();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType 
+             * 
+             * The mime type of the resource, if available. Example: "text/plain". 
+             * See http://www.iana.org/assignments/media-types/. This 
+             * property applies to data objects that can be described with 
+             * one mime type. In cases where the object as a whole has one mime 
+             * type, while it's parts have other mime types, or there is no mime 
+             * type that can be applied to the object as a whole, but some parts 
+             * of the content have mime types - use more specific properties. 
+             */
+            QUrl mimeType();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#plainTextContent 
+             * 
+             * Plain-text representation of the content of a InformationElement 
+             * with all markup removed. The main purpose of this property is 
+             * full-text indexing and search. Its exact content is considered 
+             * application-specific. The user can make no assumptions about 
+             * what is and what is not contained within. Applications should 
+             * use more specific properties wherever possible. 
+             */
+            QUrl plainTextContent();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#relatedTo 
+             * 
+             * A common superproperty for all relations between a piece of 
+             * content and other pieces of data (which may be interpreted as 
+             * other pieces of content). 
+             */
+            QUrl relatedTo();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#rootElementOf 
+             * 
+             * DataObjects extracted from a single data source are organized 
+             * into a containment tree. This property links the root of that 
+             * tree with the datasource it has been extracted from 
+             */
+            QUrl rootElementOf();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject 
+             * 
+             * An overall topic of the content of a InformationElement 
+             */
+            QUrl subject();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title 
+             * 
+             * Name given to an InformationElement 
+             */
+            QUrl title();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/01/19/nie#version 
+             * 
+             * The current version of the given data object. Exact semantics 
+             * is unspecified at this level. Use more specific subproperties 
+             * if needed. 
+             */
+            QUrl version();
+        }
+    }
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/pimo.cpp.svn-base nepomuk-svn/core/.svn/text-base/pimo.cpp.svn-base
--- nepomuk/core/.svn/text-base/pimo.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/pimo.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,66 @@
+/*
+ * This file has been generated by the onto2vocabularyclass tool
+ * copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "pimo.h"
+
+class PimoPrivate
+{
+public:
+    PimoPrivate()
+        : pimo_namespace( QUrl::fromEncoded( "http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#", QUrl::StrictMode ) ),
+          pimo_Thing( QUrl::fromEncoded( "http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#Thing", QUrl::StrictMode ) ),
+          pimo_groundingOccurrence( QUrl::fromEncoded( "http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#groundingOccurrence", QUrl::StrictMode ) ),
+          pimo_occurrence( QUrl::fromEncoded( "http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#occurrence", QUrl::StrictMode ) ),
+          pimo_referencingOccurrence( QUrl::fromEncoded( "http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#referencingOccurrence", QUrl::StrictMode ) ) {
+    }
+
+    QUrl pimo_namespace;
+    QUrl pimo_Thing;
+    QUrl pimo_groundingOccurrence;
+    QUrl pimo_occurrence;
+    QUrl pimo_referencingOccurrence;
+};
+
+Q_GLOBAL_STATIC( PimoPrivate, s_pimo )
+
+QUrl Nepomuk::Vocabulary::PIMO::pimoNamespace()
+{
+    return s_pimo()->pimo_namespace;
+}
+
+QUrl Nepomuk::Vocabulary::PIMO::Thing()
+{
+    return s_pimo()->pimo_Thing;
+}
+
+QUrl Nepomuk::Vocabulary::PIMO::groundingOccurrence()
+{
+    return s_pimo()->pimo_groundingOccurrence;
+}
+
+QUrl Nepomuk::Vocabulary::PIMO::occurrence()
+{
+    return s_pimo()->pimo_occurrence;
+}
+
+QUrl Nepomuk::Vocabulary::PIMO::referencingOccurrence()
+{
+    return s_pimo()->pimo_referencingOccurrence;
+}
diff -u -r -N nepomuk/core/.svn/text-base/pimo.h.svn-base nepomuk-svn/core/.svn/text-base/pimo.h.svn-base
--- nepomuk/core/.svn/text-base/pimo.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/pimo.h.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,89 @@
+/*
+ * This file has been generated by the onto2vocabularyclass tool
+ * copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _SOPRANO_PIMO_H_
+#define _SOPRANO_PIMO_H_
+
+#include <QtCore/QUrl>
+
+namespace Nepomuk {
+    namespace Vocabulary {
+        /**
+         * This is an excerpt of the PIMO ontology as used in the Nepomuk core library.
+         *
+         * The complete ontology can be found in kdebase/runtime/nepomuk/ontologies
+         */
+        namespace PIMO {
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#
+             */
+            QUrl pimoNamespace();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#Thing 
+             * 
+             * Entities that are in the direct attention of the user when doing 
+             * knowledge work. 
+             */
+            QUrl Thing();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#groundingOccurrence 
+             * 
+             * The subject Thing represents the entity that is described in 
+             * the object InformationElement. The subject Thing is the canonical, 
+             * unique representation in the personal information model for 
+             * the entity described in the object. Multiple InformationElements 
+             * can be the grounding occurrence of the same Thing, one InformationElement 
+             * can be the groundingOccurrence of only one Thing. 
+             */
+            QUrl groundingOccurrence();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#occurrence 
+             * 
+             * The subject Thing is represented also in the object resource. 
+             * All facts added to the object resource are valid for the subject 
+             * thing. The subject is the canonical represtation of the object. 
+             * In particual, this implies when (?object ?p ?v) -> (?subject 
+             * ?p ?v) and (?s ?p ?object) -> (?s ?p ?subject). The class of the 
+             * object is not defined, but should be compatible with the class 
+             * of the subject. Occurrence relations can be inferred through 
+             * same identifiers or referencingOccurrence relations. 
+             */
+            QUrl occurrence();
+
+            /**
+             * http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#referencingOccurrence 
+             * 
+             * The subject thing is described in the object document. Ideally, 
+             * the document is public and its primary topic is the thing. Although 
+             * this property is not inverse-functional (because the Occurrences 
+             * are not canonical elements of a formal ontology) this property 
+             * allows to use public documents, such as wikipedia pages, as 
+             * indicators identity. The more formal hasOtherRepresentation 
+             * property can be used when an ontology about the subject exists. 
+             */
+            QUrl referencingOccurrence();
+        }
+    }
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/resource.cpp.svn-base nepomuk-svn/core/.svn/text-base/resource.cpp.svn-base
--- nepomuk/core/.svn/text-base/resource.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resource.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,818 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "resource.h"
+#include "resourcedata.h"
+#include "resourcemanager.h"
+#include "resourcemanager_p.h"
+#include "tools.h"
+#include "tag.h"
+#include "pimo.h"
+#include "thing.h"
+
+#include <klocale.h>
+#include <kdebug.h>
+
+#include <Soprano/Vocabulary/NAO>
+#include <Soprano/Vocabulary/Xesam>
+#include <Soprano/Vocabulary/RDFS>
+
+#include <kmimetype.h>
+
+
+Nepomuk::Resource::Resource()
+{
+    m_data = ResourceManager::instance()->d->data( QUrl(), QUrl() );
+    m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( ResourceManager* manager )
+{
+    m_data = manager->d->data( QUrl(), QUrl() );
+    m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const Nepomuk::Resource& res )
+{
+    m_data = res.m_data;
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const QString& uri, const QUrl& type )
+{
+    m_data = ResourceManager::instance()->d->data( uri, type );
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const QString& uri, const QUrl& type, ResourceManager* manager )
+{
+    m_data = manager->d->data( uri, type );
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const QString& uri, const QString& type )
+{
+    m_data = ResourceManager::instance()->d->data( uri, type );
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const QUrl& uri, const QUrl& type )
+{
+    m_data = ResourceManager::instance()->d->data( uri, type );
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const QUrl& uri, const QUrl& type, ResourceManager* manager )
+{
+    m_data = manager->d->data( uri, type );
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( Nepomuk::ResourceData* data )
+{
+    m_data = data;
+    if ( m_data )
+        data->ref();
+}
+
+
+Nepomuk::Resource::~Resource()
+{
+    // FIXME: ResourceData instances having a proxy also need to be deleted, maybe extend deref
+    if( m_data &&
+        m_data->deref() == 0 &&
+        ( !m_data->isValid() || m_data->rm()->dataCacheFull() ) ) {
+        m_data->deleteData();
+    }
+}
+
+
+Nepomuk::Resource& Nepomuk::Resource::operator=( const Resource& res )
+{
+    if( m_data != res.m_data ) {
+        if ( m_data && m_data->deref() == 0 && !m_data->isValid() ) {
+            m_data->deleteData();
+        }
+        m_data = res.m_data;
+        if ( m_data )
+            m_data->ref();
+    }
+
+    return *this;
+}
+
+
+Nepomuk::Resource& Nepomuk::Resource::operator=( const QUrl& res )
+{
+    return operator=( Resource( res ) );
+}
+
+
+Nepomuk::ResourceManager* Nepomuk::Resource::manager() const
+{
+    return m_data->rm()->m_manager;
+}
+
+
+QString Nepomuk::Resource::uri() const
+{
+    return resourceUri().toString();
+}
+
+
+QUrl Nepomuk::Resource::resourceUri() const
+{
+    if ( m_data ) {
+        m_data->determineUri();
+        return m_data->uri();
+    }
+    else {
+        return QUrl();
+    }
+}
+
+
+QString Nepomuk::Resource::type() const
+{
+    return resourceType().toString();
+}
+
+
+QUrl Nepomuk::Resource::resourceType() const
+{
+    if ( m_data ) {
+        return m_data->type();
+    }
+    else {
+        return QUrl();
+    }
+}
+
+
+QList<QUrl> Nepomuk::Resource::types() const
+{
+    if ( m_data ) {
+        return m_data->allTypes();
+    }
+    else {
+        return QList<QUrl>();
+    }
+}
+
+
+void Nepomuk::Resource::setTypes( const QList<QUrl>& types )
+{
+    if ( m_data )
+        m_data->setTypes( types );
+}
+
+
+void Nepomuk::Resource::addType( const QUrl& type )
+{
+    if ( m_data ) {
+        QList<QUrl> tl = types();
+        if( !tl.contains( type ) )
+            setTypes( tl << type );
+    }
+}
+
+
+bool Nepomuk::Resource::hasType( const QUrl& typeUri ) const
+{
+    return m_data ? m_data->hasType( typeUri ) : false;
+}
+
+
+QString Nepomuk::Resource::className() const
+{
+    return resourceType().toString().section( QRegExp( "[#:]" ), -1 );
+}
+
+
+QHash<QUrl, Nepomuk::Variant> Nepomuk::Resource::properties() const
+{
+    if ( m_data ) {
+        return m_data->allProperties();
+    }
+    else {
+        return QHash<QUrl, Nepomuk::Variant>();
+    }
+}
+
+
+QHash<QString, Nepomuk::Variant> Nepomuk::Resource::allProperties() const
+{
+    QHash<QString, Nepomuk::Variant> pl;
+    QHash<QUrl, Nepomuk::Variant> p = properties();
+    QHash<QUrl, Nepomuk::Variant>::const_iterator end = p.constEnd();
+    for ( QHash<QUrl, Nepomuk::Variant>::const_iterator it = p.constBegin();
+          it != end; ++it ) {
+        pl.insert( it.key().toString(), it.value() );
+    }
+    return pl;
+}
+
+
+bool Nepomuk::Resource::hasProperty( const QUrl& uri ) const
+{
+    return m_data ? m_data->hasProperty( uri ) : false;
+}
+
+
+bool Nepomuk::Resource::hasProperty( const QString& uri ) const
+{
+    return hasProperty( QUrl( uri ) );
+}
+
+
+Nepomuk::Variant Nepomuk::Resource::property( const QString& uri ) const
+{
+    return property( QUrl( uri ) );
+}
+
+
+Nepomuk::Variant Nepomuk::Resource::property( const QUrl& uri ) const
+{
+    if ( m_data ) {
+        return m_data->property( uri );
+    }
+    else {
+        return Variant();
+    }
+}
+
+
+void Nepomuk::Resource::setProperty( const QString& uri, const Nepomuk::Variant& value )
+{
+    setProperty( QUrl( uri ), value );
+}
+
+
+void Nepomuk::Resource::addProperty( const QUrl& uri, const Variant& value )
+{
+    Variant v = property( uri );
+    v.append( value );
+    setProperty( uri, v );
+}
+
+
+void Nepomuk::Resource::setProperty( const QUrl& uri, const Nepomuk::Variant& value )
+{
+    if ( m_data ) {
+        m_data->setProperty( uri, value );
+    }
+}
+
+
+void Nepomuk::Resource::removeProperty( const QString& uri )
+{
+    removeProperty( QUrl( uri ) );
+}
+
+
+void Nepomuk::Resource::removeProperty( const QUrl& uri )
+{
+    if ( m_data ) {
+        m_data->removeProperty( uri );
+    }
+}
+
+
+void Nepomuk::Resource::removeProperty( const QUrl& uri, const Variant& value )
+{
+    if ( m_data ) {
+        QList<Variant> vl = property( uri ).toVariantList();
+        foreach( const Variant& v, value.toVariantList() ) {
+            vl.removeAll( v );
+        }
+        setProperty( uri, Variant( vl ) );
+    }
+}
+
+
+void Nepomuk::Resource::remove()
+{
+    if ( m_data ) {
+        m_data->remove();
+    }
+}
+
+
+bool Nepomuk::Resource::exists() const
+{
+    return m_data ? m_data->exists() : false;
+}
+
+
+bool Nepomuk::Resource::isValid() const
+{
+    return m_data ? m_data->isValid() : false;
+}
+
+
+QString Nepomuk::Resource::genericLabel() const
+{
+    QString label = this->label();
+    if ( label.isEmpty() ) {
+        label = property( Soprano::Vocabulary::RDFS::label() ).toString();
+
+        if ( label.isEmpty() ) {
+            label = property( Soprano::Vocabulary::NAO::identifier() ).toString();
+
+            if ( label.isEmpty() ) {
+                label = property( Soprano::Vocabulary::Xesam::name() ).toString();
+
+                if ( label.isEmpty() ) {
+                    label = property( Soprano::Vocabulary::Xesam::url() ).toString().section( '/', -1 );
+
+                    if ( label.isEmpty() ) {
+                        QList<Resource> go = property( Vocabulary::PIMO::groundingOccurrence() ).toResourceList();
+                        if( !go.isEmpty() ) {
+                            label = go.first().genericLabel();
+                            if( label == go.first().resourceUri().toString() ) {
+                                label.clear();
+                            }
+                        }
+
+                        if ( label.isEmpty() ) {
+                            // ugly fallback
+                            label = resourceUri().toString();
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    return label;
+}
+
+
+QString Nepomuk::Resource::genericDescription() const
+{
+    QString s = property( Soprano::Vocabulary::NAO::description() ).toString();
+    if ( !s.isEmpty() ) {
+        return s;
+    }
+
+    s = property( Soprano::Vocabulary::Xesam::summary() ).toString();
+    if ( !s.isEmpty() ) {
+        return s;
+    }
+
+    s = property( Soprano::Vocabulary::Xesam::description() ).toString();
+    if ( !s.isEmpty() ) {
+        return s;
+    }
+
+    s = property( Soprano::Vocabulary::Xesam::asText() ).toString();
+    if ( !s.isEmpty() ) {
+        return s;
+    }
+
+    s = property( Soprano::Vocabulary::RDFS::comment() ).toString();
+
+    return s;
+}
+
+
+QString Nepomuk::Resource::genericIcon() const
+{
+    // FIXME: support resource symbols
+    Variant symbol = property( Soprano::Vocabulary::NAO::hasSymbol() );
+    if ( symbol.isString() ) {
+        return symbol.toString();
+    }
+
+    // strigi mimetypes are sadly not very reliable, I keep the code here for future use
+//     QString mimeType = property( Soprano::Vocabulary::Xesam::mimeType() ).toString();
+//     if ( !mimeType.isEmpty() ) {
+//         if ( KMimeType::Ptr m = KMimeType::mimeType( mimeType ) ) {
+//             return m->iconName();
+//         }
+//     }
+
+    if ( hasType( Soprano::Vocabulary::Xesam::File() ) ||
+         resourceUri().scheme() == "file" ) {
+        return KMimeType::iconNameForUrl( resourceUri() );
+    }
+
+    return QString();
+}
+
+
+Nepomuk::Thing Nepomuk::Resource::pimoThing()
+{
+    if( m_data ) {
+        return m_data->pimoThing();
+    }
+    else {
+        return Thing();
+    }
+}
+
+
+bool Nepomuk::Resource::operator==( const Resource& other ) const
+{
+    if( this == &other )
+        return true;
+
+    if( this->m_data == other.m_data )
+        return true;
+
+    if ( !m_data || !other.m_data ) {
+        return false;
+    }
+
+
+    m_data->determineUri();
+    other.m_data->determineUri();
+    return resourceUri() == other.resourceUri();
+}
+
+
+QString Nepomuk::errorString( ErrorCode code )
+{
+    switch( code ) {
+    case NoError:
+        return i18n("Success");
+    case CommunicationError:
+        return i18n("Communication error");
+    case InvalidType:
+        return i18n("Invalid type in Database");
+    default:
+        return i18n("Unknown error");
+    }
+}
+
+
+QString Nepomuk::Resource::description() const
+{
+    return ( property( Soprano::Vocabulary::NAO::description() ).toStringList() << QString() ).first();
+}
+
+
+void Nepomuk::Resource::setDescription( const QString& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::description(), Variant( value ) );
+}
+
+
+QString Nepomuk::Resource::descriptionUri()
+{
+    return Soprano::Vocabulary::NAO::description().toString();
+}
+
+
+QStringList Nepomuk::Resource::identifiers() const
+{
+    return property( Soprano::Vocabulary::NAO::identifier() ).toStringList();
+}
+
+
+void Nepomuk::Resource::setIdentifiers( const QStringList& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::identifier(), Variant( value ) );
+}
+
+
+void Nepomuk::Resource::addIdentifier( const QString& value )
+{
+    Variant v = property( Soprano::Vocabulary::NAO::identifier() );
+    v.append( value );
+    setProperty( Soprano::Vocabulary::NAO::identifier(), v );
+}
+
+
+QString Nepomuk::Resource::identifierUri()
+{
+    return Soprano::Vocabulary::NAO::identifier().toString();
+}
+
+
+QStringList Nepomuk::Resource::altLabels() const
+{
+    return property( Soprano::Vocabulary::NAO::altLabel() ).toStringList();
+}
+
+
+void Nepomuk::Resource::setAltLabels( const QStringList& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::altLabel(), Variant( value ) );
+}
+
+
+void Nepomuk::Resource::addAltLabel( const QString& value )
+{
+    Variant v = property( Soprano::Vocabulary::NAO::altLabel() );
+    v.append( value );
+    setProperty( Soprano::Vocabulary::NAO::altLabel(), v );
+}
+
+
+QString Nepomuk::Resource::altLabelUri()
+{
+    return Soprano::Vocabulary::NAO::altLabel().toString();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Resource::annotations() const
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    return convertResourceList<Resource>( property( Soprano::Vocabulary::NAO::annotation() ).toResourceList() );
+}
+
+
+void Nepomuk::Resource::setAnnotations( const QList<Nepomuk::Resource>& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::annotation(), Variant( value ) );
+}
+
+
+void Nepomuk::Resource::addAnnotation( const Nepomuk::Resource& value )
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    Variant v = property( Soprano::Vocabulary::NAO::annotation() );
+    v.append( Resource( value ) );
+    setProperty( Soprano::Vocabulary::NAO::annotation(), v );
+}
+
+
+QString Nepomuk::Resource::annotationUri()
+{
+    return Soprano::Vocabulary::NAO::annotation().toString();
+}
+
+
+QList<Nepomuk::Tag> Nepomuk::Resource::tags() const
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    return convertResourceList<Tag>( property( Soprano::Vocabulary::NAO::hasTag() ).toResourceList() );
+}
+
+
+void Nepomuk::Resource::setTags( const QList<Nepomuk::Tag>& value )
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    QList<Resource> l;
+    for( QList<Tag>::const_iterator it = value.constBegin();
+         it != value.constEnd(); ++it ) {
+        l.append( Resource( (*it) ) );
+    }
+    setProperty( Soprano::Vocabulary::NAO::hasTag(), Variant( l ) );
+}
+
+
+void Nepomuk::Resource::addTag( const Nepomuk::Tag& value )
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    Variant v = property( Soprano::Vocabulary::NAO::hasTag() );
+    v.append( Resource( value ) );
+    setProperty( Soprano::Vocabulary::NAO::hasTag(), v );
+}
+
+
+QString Nepomuk::Resource::tagUri()
+{
+    return Soprano::Vocabulary::NAO::hasTag().toString();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Resource::topics() const
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    return convertResourceList<Resource>( property( Soprano::Vocabulary::NAO::hasTopic() ).toResourceList() );
+}
+
+
+void Nepomuk::Resource::setTopics( const QList<Nepomuk::Resource>& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::hasTopic(), Variant( value ) );
+}
+
+
+void Nepomuk::Resource::addTopic( const Nepomuk::Resource& value )
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    Variant v = property( Soprano::Vocabulary::NAO::hasTopic() );
+    v.append( Resource( value ) );
+    setProperty( Soprano::Vocabulary::NAO::hasTopic(), v );
+}
+
+
+QString Nepomuk::Resource::topicUri()
+{
+    return Soprano::Vocabulary::NAO::hasTopic().toString();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Resource::isTopicOfs() const
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    return convertResourceList<Resource>( property( Soprano::Vocabulary::NAO::isTopicOf() ).toResourceList() );
+}
+
+
+void Nepomuk::Resource::setIsTopicOfs( const QList<Nepomuk::Resource>& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::isTopicOf(), Variant( value ) );
+}
+
+
+void Nepomuk::Resource::addIsTopicOf( const Nepomuk::Resource& value )
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    Variant v = property( Soprano::Vocabulary::NAO::isTopicOf() );
+    v.append( Resource( value ) );
+    setProperty( Soprano::Vocabulary::NAO::isTopicOf(), v );
+}
+
+
+QString Nepomuk::Resource::isTopicOfUri()
+{
+    return Soprano::Vocabulary::NAO::isTopicOf().toString();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Resource::isRelateds() const
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    return convertResourceList<Resource>( property( Soprano::Vocabulary::NAO::isRelated() ).toResourceList() );
+}
+
+
+void Nepomuk::Resource::setIsRelateds( const QList<Nepomuk::Resource>& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::isRelated(), Variant( value ) );
+}
+
+
+void Nepomuk::Resource::addIsRelated( const Nepomuk::Resource& value )
+{
+    // We always store all Resource types as plain Resource objects.
+    // It does not introduce any overhead (due to the implicit sharing of
+    // the data and has the advantage that we can mix setProperty calls
+    // with the special Resource subclass methods.
+    // More importantly Resource loads the data as Resource objects anyway.
+    Variant v = property( Soprano::Vocabulary::NAO::isRelated() );
+    v.append( Resource( value ) );
+    setProperty( Soprano::Vocabulary::NAO::isRelated(), v );
+}
+
+
+QString Nepomuk::Resource::isRelatedUri()
+{
+    return Soprano::Vocabulary::NAO::isRelated().toString();
+}
+
+
+QString Nepomuk::Resource::label() const
+{
+    return ( property( Soprano::Vocabulary::NAO::prefLabel() ).toStringList() << QString() ).first();
+}
+
+
+void Nepomuk::Resource::setLabel( const QString& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::prefLabel(), Variant( value ) );
+}
+
+
+QString Nepomuk::Resource::labelUri()
+{
+    return Soprano::Vocabulary::NAO::prefLabel().toString();
+}
+
+
+quint32 Nepomuk::Resource::rating() const
+{
+    return ( property( Soprano::Vocabulary::NAO::numericRating() ).toUnsignedIntList() << 0 ).first();
+}
+
+
+void Nepomuk::Resource::setRating( const quint32& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::numericRating(), Variant( value ) );
+}
+
+
+QString Nepomuk::Resource::ratingUri()
+{
+    return Soprano::Vocabulary::NAO::numericRating().toString();
+}
+
+
+QStringList Nepomuk::Resource::symbols() const
+{
+    return property( Soprano::Vocabulary::NAO::hasSymbol() ).toStringList();
+}
+
+
+void Nepomuk::Resource::setSymbols( const QStringList& value )
+{
+    setProperty( Soprano::Vocabulary::NAO::hasSymbol(), Variant( value ) );
+}
+
+
+void Nepomuk::Resource::addSymbol( const QString& value )
+{
+    Variant v = property( Soprano::Vocabulary::NAO::hasSymbol() );
+    v.append( value );
+    setProperty( Soprano::Vocabulary::NAO::hasSymbol(), v );
+}
+
+
+QString Nepomuk::Resource::symbolUri()
+{
+    return Soprano::Vocabulary::NAO::hasSymbol().toString();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Resource::annotationOf() const
+{
+    return convertResourceList<Resource>( manager()->allResourcesWithProperty( Soprano::Vocabulary::NAO::annotation(), *this ) );
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Resource::isRelatedOf() const
+{
+    return convertResourceList<Resource>( manager()->allResourcesWithProperty( Soprano::Vocabulary::NAO::isRelated(), *this ) );
+}
+
+
+// static
+QList<Nepomuk::Resource> Nepomuk::Resource::allResources()
+{
+    return Nepomuk::convertResourceList<Resource>( ResourceManager::instance()->allResourcesOfType( Soprano::Vocabulary::RDFS::Resource() ) );
+}
diff -u -r -N nepomuk/core/.svn/text-base/resource.h.svn-base nepomuk-svn/core/.svn/text-base/resource.h.svn-base
--- nepomuk/core/.svn/text-base/resource.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resource.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,706 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_H_
+#define _NEPOMUK_RESOURCE_H_
+
+#include <QtCore/QHash>
+#include <QtCore/QStringList>
+#include <QtCore/QUrl>
+
+#include "nepomuk_export.h"
+
+namespace Nepomuk {
+
+    class ResourceManager;
+    class ResourceData;
+    class Variant;
+    class Tag;
+    class Thing;
+
+    enum ErrorCode {
+        NoError = 0,
+        CommunicationError, /**< A communication error, i.e. connection failure */
+        InvalidType,
+        UnknownError
+    };
+
+    /**
+     * \return A human-readble string.
+     */
+    // FIXME: add the uri of the resource as parameter
+    NEPOMUK_EXPORT QString errorString( ErrorCode code );
+
+    /**
+     * \class Resource resource.h Nepomuk/Resource
+     *
+     * \brief Resource is the central object type in Nepomuk. It represents a piece of
+     * information of any kind.
+     *
+     * Resources are identified by their unique URI (which
+     * correlates directly with the URI in the local NEPOMUK RDF storage.
+     *
+     * Resource objects with the same URI share their data.
+     *
+     * All methods in Resource are thread-safe.
+     *
+     * See \ref hacking for details on how to use Resource.
+     *
+     * \see ResourceManager
+     *
+     * \author Sebastian Trueg <trueg@kde.org>
+     */
+    class NEPOMUK_EXPORT Resource
+    {
+    public:
+        /**
+         * Creates an empty invalid Resource.
+         * An invalid resource will become valid (i.e. get a new random URI) once setProperty
+         * is called.
+         */
+        Resource();
+
+        /**
+         * Creates an empty invalid Resource.
+         * An invalid resource will become valid (i.e. get a new random URI) once setProperty
+         * is called.
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Resource( ResourceManager* manager );
+
+        /**
+         * Copy constructor
+         */
+        Resource( const Resource& );
+
+        /**
+         * Creates a new Resource object.
+         *
+         * The actual resource data is loaded on demand. Thus, it is possible to work
+         * with Resources as if they were in memory all the time.
+         *
+         * \param uriOrIdentifier The unique URI or an arbitrary identifier of the resource.
+         *                        If it exists as a resource URI in the RDF store it is used to load the
+         *                        related properties. If not the passed string is treated
+         *                        as an identifier.
+         *                        If a resource exists in the store which has this identifier
+         *                        set this resource's properties are loaded. Otherwise the
+         *                        resource is created in the store
+         *                        with a new random URI which can be accessed through \a uri
+         *                        after the resource has been synced. The resource can later
+         *                        again be found through the same identifier.
+         *                        In Nepomuk there are two ways of identifying a resource
+         *                        uniquely:
+         *                        \li The URI of the resource which is generated randomly
+         *                        by the framework and can only be accessed in a read-only
+         *                        fashion.
+         *                        \li An identifier in combination with the resource type (Be
+         *                        aware that this identification can only be guaranteed if identifiers
+         *                        are never set manually via addIdentifier but only through the
+         *                        constructor.)
+         *
+         * \param type The URI identifying the type of the resource. If it is empty
+         *             Resource falls back to http://www.w3.org/2000/01/rdf-schema\#Resource or
+         *             in case the resource already exists the type will be read from the
+         *             store. (This is a QString instead of a QUrl for historical reasons)
+         *
+         * Example:
+         *
+         * The best way to understand the URI and identifier system is through file resources.
+         * When a Resource object is created with the local path of the file as an identifier:
+         *
+         * \code
+         * Resource myfile( "/tmp/testfile.txt" );
+         * \endcode
+         *
+         * Now the URI of the resource in the store representing metadata for the file /tmp/testfile.txt
+         * is referred to by myfile.uri() which differs from the path of the file. However, the path of
+         * the file is saved as a \a hasIdentifier relation which means that it can be used to easily find
+         * the related resource.
+         */
+        Resource( const QString& uriOrIdentifier, const QUrl& type = QUrl() );
+
+        /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Resource( const QString& uriOrIdentifier, const QUrl& type, ResourceManager* manager );
+
+        /**
+         * \deprecated use Resource( const QString&, const QUrl& )
+         */
+        KDE_DEPRECATED Resource( const QString& uriOrIdentifier, const QString& type );
+
+        /**
+         * Creates a new Resource object.
+         *
+         * \param uri The URI of the resource. If no resource with this URI exists, a new one is
+         * created.
+         * \param type The URI identifying the type of the resource. If it is empty
+         *             Resource falls back to http://www.w3.org/2000/01/rdf-schema\#Resource or
+         *             in case the resource already exists the type will be read from the
+         *             store.
+         */
+        Resource( const QUrl& uri, const QUrl& type = QUrl() );
+
+        /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Resource( const QUrl& uri, const QUrl& type, ResourceManager* manager );
+
+        /**
+         * Constructor used internally.
+         */
+        Resource( ResourceData* );
+
+        /**
+         * Destructor
+         */
+        virtual ~Resource();
+
+        /**
+         * Makes this instance of Resource a copy of other.
+         */
+        Resource& operator=( const Resource& other );
+
+        /**
+         * Same as operator=( Resource( uri ) )
+         */
+        Resource& operator=( const QUrl& uri );
+
+        /**
+         * The Resource manager that manages this resource.
+         *
+         * \since 4.3
+         */
+        ResourceManager* manager() const;
+
+        /**
+         * The URI of the resource, uniquely identifying it. This URI in most
+         * cases is a virtual one which has been created from a generic base
+         * namespace and some identifier.
+         *
+         * The most important thing to remember is that the URI of for example
+         * a file does not necessarily have a relation to its local path.
+         * (Although Nepomuk tries to keep the URI of file resources in sync
+         * with the file URL for convenience.)
+         *
+         * For historical reasons the method does return a URI as QString instead
+         * of QUrl. The value equals resourceUri().toString().
+         *
+         * \sa resourceUri, getIdentifiers
+         *
+         * \deprecated use resourceUri instead
+         */
+        KDE_DEPRECATED QString uri() const;
+
+        /**
+         * The URI of the resource, uniquely identifying it. This URI in most
+         * cases is a virtual one which has been created from a generic base
+         * namespace and some identifier.
+         *
+         * The most important thing to remember is that the URI of for example
+         * a file does not necessarily have a relation to its local path.
+         * (Although Nepomuk tries to keep the URI of file resources in sync
+         * with the file URL for convenience.)
+         *
+         * \sa uri, getIdentifiers
+         */
+        QUrl resourceUri() const;
+
+        /**
+         * The main type of the resource. Nepomuk tries hard to make this
+         * the type furthest down the hierarchy. In case the resource has only
+         * one type, this is no problem. However, if the resource has multiple
+         * types from different type hierarchies, there is no guarantee which
+         * one will be used here.
+         *
+         * For historical reasons the method does return a URI as QString instead
+         * of QUrl. The value equals resourceType().toString().
+         *
+         * \sa name(), hasType(), types()
+         *
+         * \deprecated use resourceType instead
+         */
+        KDE_DEPRECATED QString type() const;
+
+        /**
+         * The main type of the resource. Nepomuk tries hard to make this
+         * the type furthest down the hierarchy. In case the resource has only
+         * one type, this is no problem. However, if the resource has multiple
+         * types from different type hierarchies, there is no guarantee which
+         * one will be used here.
+         *
+         * \sa name(), hasType(), types()
+         */
+        QUrl resourceType() const;
+
+        /**
+         * \return The list of all stored types for this resource. This may
+         * also include types that lie in the same hierachy.
+         *
+         * \sa type(), hasType()
+         */
+        QList<QUrl> types() const;
+
+        /**
+         * Set the types of the resource. Previous types will be overwritten.
+         *
+         * \since 4.2
+         */
+        void setTypes( const QList<QUrl>& types );
+
+        /**
+         * Add a type to the list of types.
+         *
+         * \since 4.2
+         */
+        void addType( const QUrl& type );
+
+        /**
+         * Check if the resource is of a certain type. The type hierarchy
+         * is checked including subclass relations.
+         */
+        bool hasType( const QUrl& typeUri ) const;
+
+        /**
+         * The name of the class this Resource represents an object of.
+         * The classname is derived from the type URI (see Resource::uri).
+         * For a translated user readable name of the resource see
+         * Ontology::typeName.
+         *
+         * \sa type()
+         */
+        QString className() const;
+
+        /**
+         * \deprecated Use properties()
+         */
+        KDE_DEPRECATED QHash<QString, Variant> allProperties() const;
+
+        /**
+         * \return A list of all defined properties
+         */
+        QHash<QUrl, Variant> properties() const;
+
+        /**
+         * Check if property identified by \a uri is defined
+         * for this resource.
+         *
+         * \param uri The URI identifying the property.
+         *
+         * \return true if property \a uri has a value set.
+         */
+        bool hasProperty( const QUrl& uri ) const;
+
+        /**
+         * \deprecated use hasProperty( const QUrl& ) const
+         */
+        KDE_DEPRECATED bool hasProperty( const QString& uri ) const;
+
+        /**
+         * Retrieve the value of property \a uri. If the property is not defined for
+         * this resource an invalid, empty Variant object is returned.
+         *
+         * \param uri The URI identifying the property.
+         */
+        Variant property( const QUrl& uri ) const;
+
+        /**
+         * \deprecated use property( const QUrl& ) const
+         */
+        KDE_DEPRECATED Variant property( const QString& uri ) const;
+
+        /**
+         * Set a property of the resource.
+         *
+         * \param uri The URI identifying the property.
+         * \param value The value of the property (i.e. the object of the RDF triple(s))
+         */
+        void setProperty( const QUrl& uri, const Variant& value );
+
+        /**
+         * Add a property value to the existing values.
+         *
+         * \param uri The URI identifying the property.
+         * \param value The value of the property (i.e. the object of the RDF triple(s))
+         *
+         * \since 4.3
+         */
+        void addProperty( const QUrl& uri, const Variant& value );
+
+        /**
+         * \deprecated use setProperty( const QUrl& )
+         */
+        KDE_DEPRECATED void setProperty( const QString& uri, const Variant& value );
+
+        /**
+         * Remove property \a uri from this resource object.
+         *
+         * \param uri The URI identifying the property.
+         */
+        void removeProperty( const QUrl& uri );
+
+        /**
+         * Remove \a value from property \a uri of this resource object.
+         *
+         * \param uri The URI identifying the property.
+         * \param value The value to remove
+         *
+         * \since 4.3
+         */
+        void removeProperty( const QUrl& uri, const Variant& value );
+
+        /**
+         * \deprecated use removeProperty( const QUrl& )
+         */
+        KDE_DEPRECATED void removeProperty( const QString& uri );
+
+        /**
+         * Remove this resource completely.
+         * CAUTION: After calling this method the resource will have been removed from the store
+         * without any trace.
+         */
+        void remove();
+
+        /**
+         * \return true if this resource (i.e. the uri of this resource) exists in the local
+         * NEPOMUK RDF store.
+         */
+        bool exists() const;
+
+        /**
+         * \return true if this Resource object is valid, i.e. has a proper URI and type and
+         * can be synced with the local NEPOMUK RDF store.
+         *
+         * An invalid resource will become valid (i.e. get a new random URI) once setProperty
+         * is called.
+         */
+        bool isValid() const;
+
+        /**
+         * Tries very hard to find a suitable human-readable label for this resource.
+         * It looks for properties such as nao:prefLabel, rdfs:label, or nao:identifier,
+         * or even the fileName of File resources.
+         *
+         * \return A human readable label or if all fails the URI of the resource.
+         */
+        QString genericLabel() const;
+
+        /**
+         * Tries very hard to find a suitable human-readable description of the resource.
+         * This description is supposed to be longer than genericLabel() and includes such properties
+         * as nao:description, xesam:comment, rdfs:comment
+         *
+         * \return A human readable description of the resource or an empty string if none
+         * could be found.
+         */
+        QString genericDescription() const;
+
+        /**
+         * Tries very hard to find an icon suitable for this resource.
+         *
+         * \return An icon name to be used with KIcon or an empty string if none was found.
+         */
+        QString genericIcon() const;
+
+        /**
+         * Get or create the PIMO thing that relates to this resource. If this resource
+         * itself is a pimo:Thing, a reference to this is returned. If a pimo:Thing exists
+         * with has as occurrence this resource, the thing is returned. Otherwise a new thing
+         * is created.
+         *
+         * \since 4.2
+         */
+        Thing pimoThing();
+
+        /**
+         * Operator to compare two Resource objects. Normally one does not need this. It is
+         * mainly intended for testing and debugging purposes.
+         */
+        bool operator==( const Resource& ) const;
+
+        /**
+         * Get property 'description'. Everything can be annotated with 
+         * a simple string comment. 
+         */
+        QString description() const;
+
+        /**
+         * Set property 'description'. Everything can be annotated with 
+         * a simple string comment. 
+         */
+        void setDescription( const QString& value );
+
+        /**
+         * \return The URI of the property 'description'. 
+         */
+        static QString descriptionUri();
+
+        /**
+         * Get property 'identifier'. 
+         */
+        QStringList identifiers() const;
+
+        /**
+         * Set property 'identifier'. 
+         */
+        void setIdentifiers( const QStringList& value );
+
+        /**
+         * Add a value to property 'identifier'. 
+         */
+        void addIdentifier( const QString& value );
+
+        /**
+         * \return The URI of the property 'identifier'. 
+         */
+        static QString identifierUri();
+
+        /**
+         * Get property 'altLabel'. 
+         */
+        QStringList altLabels() const;
+
+        /**
+         * Set property 'altLabel'. 
+         */
+        void setAltLabels( const QStringList& value );
+
+        /**
+         * Add a value to property 'altLabel'. 
+         */
+        void addAltLabel( const QString& value );
+
+        /**
+         * \return The URI of the property 'altLabel'. 
+         */
+        static QString altLabelUri();
+
+        /**
+         * Get property 'annotation'. 
+         */
+        QList<Resource> annotations() const;
+
+        /**
+         * Set property 'annotation'. 
+         */
+        void setAnnotations( const QList<Resource>& value );
+
+        /**
+         * Add a value to property 'annotation'. 
+         */
+        void addAnnotation( const Resource& value );
+
+        /**
+         * \return The URI of the property 'annotation'. 
+         */
+        static QString annotationUri();
+
+        /**
+         * Get property 'Tag'. Each Resource can be tagged with an arbitrary 
+         * number of Tags. This allows a simple grouping of resources. 
+         */
+        QList<Tag> tags() const;
+
+        /**
+         * Set property 'Tag'. Each Resource can be tagged with an arbitrary 
+         * number of Tags. This allows a simple grouping of resources. 
+         */
+        void setTags( const QList<Tag>& value );
+
+        /**
+         * Add a value to property 'Tag'. Each Resource can be tagged with 
+         * an arbitrary number of Tags. This allows a simple grouping of 
+         * resources. 
+         */
+        void addTag( const Tag& value );
+
+        /**
+         * \return The URI of the property 'Tag'. 
+         */
+        static QString tagUri();
+
+        /**
+         * Get property 'Topic'. 
+         */
+        QList<Resource> topics() const;
+
+        /**
+         * Set property 'Topic'. 
+         */
+        void setTopics( const QList<Resource>& value );
+
+        /**
+         * Add a value to property 'Topic'. 
+         */
+        void addTopic( const Resource& value );
+
+        /**
+         * \return The URI of the property 'Topic'. 
+         */
+        static QString topicUri();
+
+        /**
+         * Get property 'isTopicOf'. 
+         */
+        QList<Resource> isTopicOfs() const;
+
+        /**
+         * Set property 'isTopicOf'. 
+         */
+        void setIsTopicOfs( const QList<Resource>& value );
+
+        /**
+         * Add a value to property 'isTopicOf'. 
+         */
+        void addIsTopicOf( const Resource& value );
+
+        /**
+         * \return The URI of the property 'isTopicOf'. 
+         */
+        static QString isTopicOfUri();
+
+        /**
+         * Get property 'isRelated'. 
+         */
+        QList<Resource> isRelateds() const;
+
+        /**
+         * Set property 'isRelated'. 
+         */
+        void setIsRelateds( const QList<Resource>& value );
+
+        /**
+         * Add a value to property 'isRelated'. 
+         */
+        void addIsRelated( const Resource& value );
+
+        /**
+         * \return The URI of the property 'isRelated'. 
+         */
+        static QString isRelatedUri();
+
+        /**
+         * Get property 'label'. 
+         */
+        QString label() const;
+
+        /**
+         * Set property 'label'. 
+         */
+        void setLabel( const QString& value );
+
+        /**
+         * \return The URI of the property 'label'. 
+         */
+        static QString labelUri();
+
+        /**
+         * Get property 'Rating'. 
+         */
+        quint32 rating() const;
+
+        /**
+         * Set property 'Rating'. 
+         */
+        void setRating( const quint32& value );
+
+        /**
+         * \return The URI of the property 'Rating'. 
+         */
+        static QString ratingUri();
+
+        /**
+         * Get property 'Symbol'. Each resource can have a symbol assigned. 
+         * For now this is a simple string which can either be the patch to 
+         * an actual pixmap file or just the name of an icon as defined by 
+         * the freedesktop.org standard. 
+         */
+        QStringList symbols() const;
+
+        /**
+         * Set property 'Symbol'. Each resource can have a symbol assigned. 
+         * For now this is a simple string which can either be the patch to 
+         * an actual pixmap file or just the name of an icon as defined by 
+         * the freedesktop.org standard. 
+         */
+        void setSymbols( const QStringList& value );
+
+        /**
+         * Add a value to property 'Symbol'. Each resource can have a symbol 
+         * assigned. For now this is a simple string which can either be 
+         * the patch to an actual pixmap file or just the name of an icon as 
+         * defined by the freedesktop.org standard. 
+         */
+        void addSymbol( const QString& value );
+
+        /**
+         * \return The URI of the property 'Symbol'. 
+         */
+        static QString symbolUri();
+
+        /**
+         * Get all resources that have this resource set as property 'annotation'. 
+         * \sa ResourceManager::allResourcesWithProperty 
+         */
+        QList<Resource> annotationOf() const;
+
+        /**
+         * Get all resources that have this resource set as property 'isRelated'. 
+         * \sa ResourceManager::allResourcesWithProperty 
+         */
+        QList<Resource> isRelatedOf() const;
+
+        /**
+         * Retrieve a list of all available Resource resources. This list 
+         * consists of all resource of type Resource that are stored in 
+         * the local Nepomuk meta data storage and any changes made locally. 
+         * Be aware that in some cases this list can get very big. Then it 
+         * might be better to use libKNep directly. 
+         *
+         * \sa ResourceManager::allResources
+         */
+        static QList<Resource> allResources();
+
+    private:
+        ResourceData* m_data;
+
+        class Private;
+        Private* d; // unused
+
+        friend class ResourceData;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/resourcedata.cpp.svn-base nepomuk-svn/core/.svn/text-base/resourcedata.cpp.svn-base
--- nepomuk/core/.svn/text-base/resourcedata.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resourcedata.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,707 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "resourcedata.h"
+#include "resourcemanager.h"
+#include "resourcemanager_p.h"
+#include "resourcefiltermodel.h"
+#include "resource.h"
+#include "tools.h"
+#include "nie.h"
+#include "pimo.h"
+#include "nepomukmainmodel.h"
+
+#include <Soprano/Statement>
+#include <Soprano/StatementIterator>
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Model>
+#include <Soprano/Vocabulary/RDFS>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/Xesam>
+#include <Soprano/Vocabulary/NAO>
+
+#include "ontology/class.h"
+
+#include <QtCore/QFile>
+#include <QtCore/QDateTime>
+
+#include <kdebug.h>
+#include <kurl.h>
+
+using namespace Soprano;
+
+#define MAINMODEL m_rm->resourceFilterModel
+
+
+static Nepomuk::Variant nodeToVariant( const Soprano::Node& node )
+{
+    if ( node.isResource() ) {
+        return Nepomuk::Variant( Nepomuk::Resource( node.uri() ) );
+    }
+    else if ( node.isLiteral() ) {
+        return Nepomuk::Variant( node.literal().variant() );
+    }
+    else {
+        return Nepomuk::Variant();
+    }
+}
+
+
+Nepomuk::ResourceData::ResourceData( const QUrl& uri, const QString& uriOrId, const QUrl& type, ResourceManagerPrivate* rm )
+    : m_kickoffUriOrId( uriOrId ),
+      m_uri( uri ),
+      m_mainType( type ),
+      m_ref(0),
+      m_proxyData(0),
+      m_cacheDirty(true),
+      m_pimoThing(0),
+      m_groundingOccurence(0),
+      m_rm(rm)
+{
+    if( m_mainType.isEmpty() )
+        m_mainType = Soprano::Vocabulary::RDFS::Resource();
+
+    m_types << m_mainType;
+
+    // there is no need to store the trivial type
+    m_initialTypeSaved = ( m_mainType == Soprano::Vocabulary::RDFS::Resource() );
+
+    m_rm->cleanupCache();
+
+    ++m_rm->dataCnt;
+}
+
+
+Nepomuk::ResourceData::~ResourceData()
+{
+    delete m_pimoThing;
+    --m_rm->dataCnt;
+}
+
+
+QString Nepomuk::ResourceData::kickoffUriOrId() const
+{
+    if( m_proxyData )
+        return m_proxyData->kickoffUriOrId();
+    return m_kickoffUriOrId;
+}
+
+
+QUrl Nepomuk::ResourceData::uri() const
+{
+    if( m_proxyData )
+        return m_proxyData->uri();
+    return m_uri;
+}
+
+
+QUrl Nepomuk::ResourceData::type()
+{
+    if( m_proxyData )
+        return m_proxyData->type();
+    load();
+    return m_mainType;
+}
+
+
+QList<QUrl> Nepomuk::ResourceData::allTypes()
+{
+    if( m_proxyData )
+        return m_proxyData->allTypes();
+    load();
+    return m_types;
+}
+
+
+void Nepomuk::ResourceData::setTypes( const QList<QUrl>& types )
+{
+    if( m_proxyData ) {
+        m_proxyData->setTypes( types );
+    }
+    else if ( store() ) {
+        // reset types
+        m_types.clear();
+        m_mainType = Soprano::Vocabulary::RDFS::Resource();
+
+        // load types (and set maintype)
+        QList<Node> nodes;
+        foreach( const QUrl& url, types ) {
+            loadType( url );
+            nodes << Node( url );
+        }
+
+        // update the data store
+        MAINMODEL->updateProperty( m_uri, Soprano::Vocabulary::RDF::type(), nodes );
+    }
+}
+
+
+
+void Nepomuk::ResourceData::deleteData()
+{
+    if( m_proxyData ) {
+        m_proxyData->deref();
+        m_proxyData = 0;
+    }
+    else {
+        if( !m_uri.isEmpty() )
+            m_rm->m_initializedData.remove( m_uri.toString() );
+        if( !m_kickoffUriOrId.isEmpty() )
+            m_rm->m_kickoffData.remove( m_kickoffUriOrId );
+    }
+
+    deleteLater();
+}
+
+
+QHash<QUrl, Nepomuk::Variant> Nepomuk::ResourceData::allProperties()
+{
+    if( m_proxyData )
+        return m_proxyData->allProperties();
+
+    load();
+
+    return m_cache;
+}
+
+
+bool Nepomuk::ResourceData::hasProperty( const QUrl& uri )
+{
+    if( m_proxyData )
+        return m_proxyData->hasProperty( uri );
+
+    if ( determineUri() ) {
+        return MAINMODEL->containsAnyStatement( Soprano::Statement( m_uri, uri, Soprano::Node() ) );
+    }
+    else {
+        return false;
+    }
+}
+
+
+bool Nepomuk::ResourceData::hasType( const QUrl& uri )
+{
+    if( m_proxyData )
+        return m_proxyData->hasType( uri );
+
+    load();
+    return constHasType( uri );
+}
+
+
+bool Nepomuk::ResourceData::constHasType( const QUrl& uri ) const
+{
+    Types::Class requestedType( uri );
+    for ( QList<QUrl>::const_iterator it = m_types.constBegin();
+          it != m_types.constEnd(); ++it ) {
+        Types::Class availType( *it );
+        if ( availType == requestedType ||
+             availType.isSubClassOf( requestedType ) ) {
+            return true;
+        }
+    }
+    return false;
+}
+
+
+Nepomuk::Variant Nepomuk::ResourceData::property( const QUrl& uri )
+{
+    if( m_proxyData )
+        return m_proxyData->property( uri );
+
+    if ( load() ) {
+        QHash<QUrl, Variant>::const_iterator it = m_cache.constFind( uri );
+        if ( it == m_cache.constEnd() ) {
+            return Variant();
+        }
+        else {
+            return *it;
+        }
+    }
+    else {
+        return Variant();
+    }
+
+//     Variant v;
+
+//     if ( determineUri() ) {
+//         Soprano::Model* model = m_rm->m_manager->mainModel();
+//         Soprano::StatementIterator it = model->listStatements( Soprano::Statement( m_uri, QUrl(uri), Soprano::Node() ) );
+
+//         while ( it.next() ) {
+//             Statement statement = *it;
+//             v.append( nodeToVariant( statement.object() ) );
+//         }
+//         it.close();
+//     }
+//     return v;
+}
+
+
+bool Nepomuk::ResourceData::store()
+{
+    if ( !determineUri() ) {
+        // create a random URI and add us to the initialized data, i.e. make us "valid"
+        m_modificationMutex.lock();
+        m_uri = m_rm->m_manager->generateUniqueUri( QString() );
+        m_rm->m_initializedData.insert( m_uri.toString(), this );
+        m_modificationMutex.unlock();
+    }
+
+    QList<Statement> statements;
+
+    // save type (There should be no need to save all the types since there is only one way
+    // that m_types contains more than one element: if we loaded them)
+    // The first type, however, can be set at creation time to any value
+    // FIXME: save all unsaved types here and do not directly save tem above in setTypes
+    if ( !m_initialTypeSaved ) {
+        statements.append( Statement( m_uri, Soprano::Vocabulary::RDF::type(), m_types.first() ) );
+    }
+
+    if ( !exists() ) {
+        // save the creation date
+        statements.append( Statement( m_uri, Soprano::Vocabulary::NAO::created(), Soprano::LiteralValue( QDateTime::currentDateTime() ) ) );
+
+        // save the kickoff identifier (other identifiers are stored via setProperty)
+        if ( !m_kickoffIdentifier.isEmpty() ) {
+            statements.append( Statement( m_uri, QUrl(Resource::identifierUri()), LiteralValue(m_kickoffIdentifier) ) );
+        }
+
+        // HACK: make sure that files have proper fileUrl properties so long as we do not have a File class for
+        // Dolphin and co.
+        if ( ( m_uri.scheme() == "file" ||
+               constHasType( Soprano::Vocabulary::Xesam::File() ) ) &&
+             QFile::exists( m_uri.toLocalFile()) ) {
+            statements.append( Statement( m_uri, Soprano::Vocabulary::Xesam::url(), m_uri ) );
+        }
+
+        // store our grounding occurrence in case we are a thing created by the pimoThing() method
+        if( m_groundingOccurence ) {
+            m_groundingOccurence->store();
+            statements.append( Statement( m_uri, Vocabulary::PIMO::groundingOccurrence(), m_groundingOccurence->uri() ) );
+        }
+    }
+
+    if ( !statements.isEmpty() ) {
+        m_initialTypeSaved = true;
+        return MAINMODEL->addStatements( statements ) == Soprano::Error::ErrorNone;
+    }
+    else {
+        return true;
+    }
+}
+
+
+void Nepomuk::ResourceData::loadType( const QUrl& storedType )
+{
+    if ( !m_types.contains( storedType ) ) {
+        m_types << storedType;
+    }
+    if ( m_mainType == Soprano::Vocabulary::RDFS::Resource() ) {
+        Q_ASSERT( !storedType.isEmpty() );
+        m_mainType = storedType;
+    }
+    else {
+        Types::Class currentTypeClass = m_mainType;
+        Types::Class storedTypeClass = storedType;
+
+        // Keep the type that is further down the hierarchy
+        if ( storedTypeClass.isSubClassOf( currentTypeClass ) ) {
+            m_mainType = storedTypeClass.uri();
+        }
+        else {
+            // This is a little convenience hack since the user is most likely
+            // more interested in the file content than the actual file
+            Types::Class xesamContentClass( Soprano::Vocabulary::Xesam::Content() );
+            if ( m_mainType == Soprano::Vocabulary::Xesam::File() &&
+                 ( storedTypeClass == xesamContentClass ||
+                   storedTypeClass.isSubClassOf( xesamContentClass ) ) ) {
+                m_mainType = storedTypeClass.uri();
+            }
+            else {
+                // the same is true for nie:DataObject vs. nie:InformationElement
+                Types::Class nieInformationElementClass( Vocabulary::NIE::InformationElement() );
+                Types::Class nieDataObjectClass( Vocabulary::NIE::DataObject() );
+                if( ( currentTypeClass == nieDataObjectClass ||
+                      currentTypeClass.isSubClassOf( nieDataObjectClass ) ) &&
+                    ( storedTypeClass == nieInformationElementClass ||
+                      storedTypeClass.isSubClassOf( nieInformationElementClass ) ) ) {
+                    m_mainType = storedTypeClass.uri();
+                }
+            }
+        }
+    }
+}
+
+
+bool Nepomuk::ResourceData::load()
+{
+    if ( m_cacheDirty ) {
+        m_cache.clear();
+
+        if ( determineUri() ) {
+            Soprano::StatementIterator it = MAINMODEL->listStatements( Soprano::Statement( m_uri, Soprano::Node(), Soprano::Node() ) );
+
+            while ( it.next() ) {
+                Statement statement = *it;
+                if ( statement.predicate().uri() == Soprano::Vocabulary::RDF::type() ) {
+                    if ( statement.object().isResource() ) {
+                        QUrl storedType = statement.object().uri();
+                        loadType( storedType );
+                    }
+                }
+                else {
+                    m_cache[statement.predicate().uri()].append( nodeToVariant( statement.object() ) );
+                }
+            }
+
+            m_cacheDirty = false;
+
+            delete m_pimoThing;
+            m_pimoThing = 0;
+            if( hasType( Vocabulary::PIMO::Thing() ) ) {
+                m_pimoThing = new Thing( m_uri );
+            }
+            else {
+                // TODO: somehow handle pimo:referencingOccurrence and pimo:occurrence
+                QueryResultIterator pimoIt = MAINMODEL->executeQuery( QString( "select ?r where { ?r <%1> <%2> . }")
+                                                                      .arg( Vocabulary::PIMO::groundingOccurrence().toString() )
+                                                                      .arg( QString::fromAscii( m_uri.toEncoded() ) ),
+                                                                      Soprano::Query::QueryLanguageSparql );
+                if( pimoIt.next() ) {
+                    m_pimoThing = new Thing( pimoIt.binding("r").uri() );
+                }
+            }
+
+            return true;
+        }
+        else {
+            return false;
+        }
+    }
+    else {
+        return true;
+    }
+}
+
+
+void Nepomuk::ResourceData::setProperty( const QUrl& uri, const Nepomuk::Variant& value )
+{
+    Q_ASSERT( uri.isValid() );
+
+    if( m_proxyData )
+        return m_proxyData->setProperty( uri, value );
+
+    // step 0: make sure this resource is in the store
+    if ( store() ) {
+        QList<Node> valueNodes;
+
+        // make sure resource values are in the store
+        if ( value.simpleType() == qMetaTypeId<Resource>() ) {
+            QList<Resource> l = value.toResourceList();
+            for( QList<Resource>::iterator resIt = l.begin(); resIt != l.end(); ++resIt ) {
+                resIt->m_data->store();
+            }
+        }
+
+        // add the actual property statements
+
+        // one-to-one Resource
+        if( value.isResource() ) {
+            valueNodes.append( value.toResource().resourceUri() );
+        }
+
+        // one-to-many Resource
+        else if( value.isResourceList() ) {
+            const QList<Resource>& l = value.toResourceList();
+            for( QList<Resource>::const_iterator resIt = l.constBegin(); resIt != l.constEnd(); ++resIt ) {
+                valueNodes.append( (*resIt).resourceUri() );
+            }
+        }
+
+        // one-to-many literals
+        else if( value.isList() ) {
+            valueNodes = Nepomuk::valuesToRDFNodes( value );
+        }
+
+        // one-to-one literal
+        else {
+            valueNodes.append( Nepomuk::valueToRDFNode( value ) );
+        }
+
+        // update the cache for now
+        m_cache[uri] = value;
+
+        // update the store
+        MAINMODEL->updateProperty( m_uri, uri, valueNodes );
+    }
+}
+
+
+void Nepomuk::ResourceData::removeProperty( const QUrl& uri )
+{
+    Q_ASSERT( uri.isValid() );
+
+    if( m_proxyData )
+        return m_proxyData->removeProperty( uri );
+
+    if ( determineUri() ) {
+        MAINMODEL->removeProperty( m_uri, uri );
+    }
+}
+
+
+void Nepomuk::ResourceData::remove( bool recursive )
+{
+    if( m_proxyData )
+        return m_proxyData->remove( recursive );
+
+    if ( determineUri() ) {
+        MAINMODEL->removeAllStatements( Statement( m_uri, Node(), Node() ) );
+        if ( recursive ) {
+            MAINMODEL->removeAllStatements( Statement( Node(), Node(), m_uri ) );
+        }
+
+        // the url is invalid now
+        m_rm->m_initializedData.remove( m_uri.toString() );
+        m_uri = QUrl();
+        m_cache.clear();
+        m_cacheDirty = false;
+        m_initialTypeSaved = false;
+        m_types.clear();
+        m_mainType = Soprano::Vocabulary::RDFS::Resource();
+    }
+}
+
+
+bool Nepomuk::ResourceData::exists()
+{
+    if( m_proxyData )
+        return m_proxyData->exists();
+
+    if( determineUri() ) {
+        return MAINMODEL->containsAnyStatement( Statement( m_uri, Node(), Node() ) );
+    }
+    else
+        return false;
+}
+
+
+bool Nepomuk::ResourceData::isValid() const
+{
+    if( m_proxyData )
+        return m_proxyData->isValid();
+
+    // FIXME: check namespaces and stuff
+    return( !m_mainType.isEmpty() && ( !m_uri.isEmpty() || !m_kickoffIdentifier.isEmpty() ) );
+}
+
+
+bool Nepomuk::ResourceData::determineUri()
+{
+    if( m_proxyData )
+        return m_proxyData->determineUri();
+
+    else if( m_uri.isEmpty() && !m_kickoffUriOrId.isEmpty() ) {
+        Q_ASSERT( !m_kickoffUriOrId.isEmpty() );
+
+        m_modificationMutex.lock();
+
+        Soprano::Model* model = MAINMODEL;
+
+        // kickoffUriOrId() cannot be a URI without a slash (ugly hack for a tiny speed gain)
+        if( kickoffUriOrId().contains('/') &&
+            model->containsAnyStatement( Statement( QUrl( kickoffUriOrId() ), Node(), Node() ) ) ) {
+            //
+            // The kickoffUriOrId is actually a URI
+            //
+            m_uri = kickoffUriOrId();
+//            kDebug(300004) << " kickoff identifier " << kickoffUriOrId() << " exists as a URI " << uri();
+        }
+        else {
+            //
+            // Check if the kickoffUriOrId is a resource identifier
+            //
+            StatementIterator it = model->listStatements( Statement( Node(),
+                                                                     Node(QUrl( Resource::identifierUri() )),
+                                                                     LiteralValue( kickoffUriOrId() ) ) );
+
+            //
+            // The kickoffUriOrId is an identifier
+            //
+            // Identifiers are not unique!
+            // Thus, we do the following:
+            // - If we have Ontology support, i.e. we know the classes:
+            //   We reuse a resource if its type is derived from the
+            //   current type of the other way around (example: an ImageFile
+            //   is a File and if we open an ImageFile as File we do want it to
+            //   keep its ImageFile type)
+            // - If we do not have Ontology support:
+            //   Fallback to the default behaviour of always reusing existing
+            //   data.
+            //
+            // TODO: basically it is perfectly valid to store both types in the first case
+            //
+            Q_ASSERT( !m_mainType.isEmpty() );
+            if ( it.next() ) {
+                // At this point we only have one type since without a uri we could not have loaded other types
+                // than the one used on construction
+                Types::Class wantedType( m_mainType );
+
+                if ( m_mainType != Soprano::Vocabulary::RDFS::Resource() && wantedType.isAvailable() ) {
+                    do {
+                        // get the type of the stored resource
+                        StatementIterator resourceSl = model->listStatements( Statement( it.current().subject(),
+                                                                                         Soprano::Vocabulary::RDF::type(),
+                                                                                         Node() ) );
+                        while ( resourceSl.next() ) {
+                            if ( resourceSl.current().object().isResource() ) {
+                                Types::Class storedType = resourceSl.current().object().uri();
+                                if ( storedType == wantedType ||
+                                     wantedType.isSubClassOf( storedType ) ||
+                                     storedType.isSubClassOf( wantedType ) ) {
+                                    // in load() The type will be updated properly
+                                    m_uri = it.current().subject().uri();
+                                    break;
+                                }
+                            }
+                        }
+                    } while ( it.next() && m_uri.isEmpty() );
+                }
+                else {
+                    m_uri = it.current().subject().uri();
+//                    kDebug(300004) << k_funcinfo << " kickoff identifier " << kickoffUriOrId() << " already exists with URI " << uri();
+                }
+            }
+
+            it.close();
+
+            if ( m_uri.isEmpty() ) {
+                //
+                // The resource does not exist, create a new one:
+                // If the kickoffUriOrId is a valid URI we use it as such, otherwise we create a new URI
+                // Special case: files: paths are always converted to URIs (but we only allow absolute paths,
+                // otherwise there can be false positives when for example a tag has the same name as a folder)
+                //
+                QUrl uri( kickoffUriOrId() );
+                if ( uri.isValid() && !uri.scheme().isEmpty() ) {
+                    m_uri = uri;
+                }
+                else if ( kickoffUriOrId()[0] == '/' &&
+                          QFile::exists( kickoffUriOrId() ) ) {
+                    // KURL defaults to schema "file:"
+                    m_uri = KUrl::fromPath( kickoffUriOrId() );
+                }
+                else {
+                    m_kickoffIdentifier = kickoffUriOrId();
+                    m_uri = m_rm->m_manager->generateUniqueUri( m_kickoffIdentifier );
+                }
+
+//                kDebug(300004) << " kickoff identifier " << kickoffUriOrId() << " seems fresh. Generated new URI " << m_uri;
+            }
+        }
+
+        //
+        // Move us to the final data hash now that the URI is known
+        //
+        if( !uri().isEmpty() && uri() != kickoffUriOrId() ) {
+            QString s = uri().toString();
+            if( !m_rm->m_initializedData.contains( s ) ) {
+                m_rm->m_initializedData.insert( s, this );
+            }
+            else {
+                m_proxyData = m_rm->m_initializedData.value( s );
+                m_proxyData->ref();
+            }
+        }
+
+        m_modificationMutex.unlock();
+    }
+
+    return !m_uri.isEmpty();
+}
+
+
+// void Nepomuk::ResourceData::updateType()
+// {
+//     Soprano::Model* model = m_rm->m_manager->mainModel();
+
+//     // get the type of the stored resource
+//     StatementIterator typeStatements = model->listStatements( Statement( m_uri,
+//                                                                          Soprano::Vocabulary::RDF::type(),
+//                                                                          Node() ) );
+//     if ( typeStatements.next() && typeStatements.current().object().isResource() ) {
+//         // FIXME: handle multple types, maybe select the one type that fits best
+//         QUrl storedType = typeStatements.current().object().uri();
+//         if ( m_type == Soprano::Vocabulary::RDFS::Resource() ) {
+//             Q_ASSERT( !storedType.isEmpty() );
+//             m_type = storedType;
+//         }
+//         else {
+//             Types::Class wantedTypeClass = m_type;
+//             Types::Class storedTypeClass = storedType;
+
+//             // Keep the type that is further down the hierarchy
+//             if ( wantedTypeClass.isSubClassOf( storedTypeClass ) ) {
+//                 m_type = wantedTypeClass.uri();
+//             }
+//         }
+//     }
+// }
+
+
+bool Nepomuk::ResourceData::operator==( const ResourceData& other ) const
+{
+    const ResourceData* that = this;
+    if( m_proxyData )
+        that = m_proxyData;
+
+    if( that == &other )
+        return true;
+
+    if( that->m_uri != other.m_uri ||
+        that->m_mainType != other.m_mainType ) {
+        return false;
+    }
+
+    return true;
+}
+
+
+Nepomuk::Thing Nepomuk::ResourceData::pimoThing()
+{
+    load();
+    if( !m_pimoThing ) {
+        if( hasType( Vocabulary::PIMO::Thing() ) ) {
+            kDebug() << "we are already a thing. Creating link to ourself" << m_uri << this;
+            // we are out own thing
+            m_pimoThing = new Thing( this );
+        }
+        else {
+            kDebug() << "creating new thing for" << m_uri << m_types << this;
+            m_pimoThing = new Thing();
+            m_pimoThing->m_data->m_groundingOccurence = this;
+        }
+        kDebug() << "created thing" << m_pimoThing->m_data << "with grounding occurence" << m_pimoThing->m_data->m_groundingOccurence;
+    }
+    return *m_pimoThing;
+}
+
+#include "resourcedata.moc"
diff -u -r -N nepomuk/core/.svn/text-base/resourcedata.h.svn-base nepomuk-svn/core/.svn/text-base/resourcedata.h.svn-base
--- nepomuk/core/.svn/text-base/resourcedata.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resourcedata.h.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,213 @@
+/* 
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_DATA_H_
+#define _NEPOMUK_RESOURCE_DATA_H_
+
+#include <QtCore/QString>
+#include <QtCore/QList>
+#include <QtCore/QHash>
+#include <QtCore/QMutex>
+
+#include "variant.h"
+#include "thing.h"
+
+#include <soprano/statement.h>
+
+
+namespace Nepomuk {
+
+    class ResourceManagerPrivate;
+
+    class ResourceData : public QObject
+    {
+        Q_OBJECT
+
+    public:
+        explicit ResourceData( const QUrl& uri, const QString& kickoffId_, const QUrl& type_, ResourceManagerPrivate* rm );
+        ~ResourceData();
+
+        /**
+         * Used instead of the destructor in Resource. The reason for the existence of
+         * this method is that the destructor does not remove the uri from the global
+         * data map. That behaviour is necessary since in certain situations temporary
+         * ResourceData instances are created.
+         */
+        void deleteData();
+
+        inline int ref() {
+            return ++m_ref;
+        }
+
+        inline int deref() {
+            return --m_ref;
+        }
+
+        inline int cnt() const {
+            return m_ref;
+        }
+
+        /**
+         * Until the resource has not been synced or even loaded the actual URI is not known.
+         * It might even be possible that none exists yet. Thus, the identifier used to create
+         * the resource object is stored in the kickoffUriOrId. During the syncing it will be
+         * determined if it is an actual existing URI or an existing identifier or if a new URI
+         * has to be created.
+         */
+        QString kickoffUriOrId() const;
+
+        /**
+         * The URI of the resource. This might be empty if the resource was not synced yet.
+         * \sa kickoffUriOrId
+         */
+        QUrl uri() const;
+
+        /**
+         * \return The main type of the resource. ResourceData tries hard to make this the
+         * most important type, i.e. that which is furthest down the hierachy.
+         */
+        // FIXME: return Nepomuk::Class here
+        QUrl type();
+
+        QList<QUrl> allTypes();
+
+        void setTypes( const QList<QUrl>& types );
+
+        QHash<QUrl, Variant> allProperties();
+
+        bool hasProperty( const QUrl& uri );
+
+        /**
+         * Does also check for subClass relations.
+         */
+        bool hasType( const QUrl& uri );
+
+        Variant property( const QUrl& uri );
+
+        /**
+         * Set a property. The property will directly be saved to the RDF store.
+         * Calls store to make sure this resource and property resources are properly
+         * stored.
+         */
+        void setProperty( const QUrl& uri, const Variant& value );
+
+        void removeProperty( const QUrl& uri );
+
+        /**
+         * Makes sure the resource is present in the RDF store. This means that if it does
+         * not exist the type and the identifier (if one has been used to create the instance)
+         * are stored.
+         *
+         * \sa exists, setProperty
+         */
+        bool store();
+
+        bool load();
+
+        /**
+         * Remove this resource data from the store completely.
+         * \param recursive If true all statements that contain this
+         * resource as an object will be removed, too.
+         */
+        void remove( bool recursive = true );
+
+        /**
+         * This method only works with a proper URI, i.e. it does
+         * not work on non-initialized resources that only know
+         * their kickoffUriOrId
+         */
+        bool exists();
+
+        bool isValid() const;
+
+        /**
+         * Makes sure the resource has a proper URI. This includes creating a new one
+         * in the store if it does not exist yet.
+         */
+        bool determineUri();
+
+        /**
+         * Sync the local type with the type stored in the RDF store.
+         * If both are compatible, i.e. both lie on one branch in the type
+         * hierarchy, then the more detailed one is used. Otherwise the type is
+         * not changed.
+         */
+//        void updateType();
+
+        void invalidateCache() { m_cacheDirty = true; }
+
+        Thing pimoThing();
+
+        /**
+         * Compares the properties of two ResourceData objects taking into account the Deleted flag
+         */
+        bool operator==( const ResourceData& other ) const;
+
+        ResourceManagerPrivate* rm() const { return m_rm; }
+
+    private:
+        bool constHasType( const QUrl& type ) const;
+        void loadType( const QUrl& type );
+
+        /**
+         * The kickoff URI or ID is used as long as the resource has not been synced yet
+         * to identify it.
+         */
+        QString m_kickoffUriOrId;
+        QUrl m_uri;
+
+        /**
+         * The kickoffIdentifier is the identifier used to construct the resource object.
+         * If the object has been constructed via a URI or determineUri has not been called
+         * yet this value is empty. Otherwise it equals m_kickoffUriOrId
+         */
+        QString m_kickoffIdentifier;
+        QUrl m_mainType;
+        QList<QUrl> m_types;
+
+        int m_ref;
+
+        QMutex m_modificationMutex;
+
+        /**
+         * Used to virtually merge two data objects representing the same
+         * resource. This happens if the resource was once created using its
+         * actual URI and once via its ID. To prevent early loading we allow
+         * this scenario.
+         */
+        ResourceData* m_proxyData;
+
+        QHash<QUrl, Variant> m_cache;
+        bool m_cacheDirty;
+
+        // used to prevent countless model operations in store()
+        bool m_initialTypeSaved;
+
+        // using a pointer to avoid infinite creation loop
+        Thing* m_pimoThing;
+
+        // only used for delayed storage of the pimo thing relation
+        ResourceData* m_groundingOccurence;
+
+        ResourceManagerPrivate* m_rm;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/resourcefiltermodel.cpp.svn-base nepomuk-svn/core/.svn/text-base/resourcefiltermodel.cpp.svn-base
--- nepomuk/core/.svn/text-base/resourcefiltermodel.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resourcefiltermodel.cpp.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,181 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "resourcefiltermodel.h"
+#include "graphwrapper_p.h"
+
+#include <Soprano/Node>
+#include <Soprano/Statement>
+#include <Soprano/StatementIterator>
+#include <Soprano/NodeIterator>
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Client/DBusModel>
+#include <Soprano/Client/DBusClient>
+#include <Soprano/Client/LocalSocketClient>
+#include <Soprano/Query/QueryLanguage>
+#include <Soprano/Util/DummyModel>
+#include <Soprano/Util/MutexModel>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/NAO>
+
+#include <QtCore/QSet>
+
+using namespace Soprano;
+
+
+class Nepomuk::ResourceFilterModel::Private
+{
+public:
+    GraphWrapper graphWrapper;
+};
+
+Nepomuk::ResourceFilterModel::ResourceFilterModel( Soprano::Model* model )
+    : FilterModel( model ),
+      d(new Private())
+{
+    d->graphWrapper.setModel( this );
+}
+
+
+Nepomuk::ResourceFilterModel::~ResourceFilterModel()
+{
+    delete d;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::addStatement( const Statement& statement )
+{
+    Statement s( statement );
+    if( s.context().isEmpty() ) {
+        s.setContext( mainContext() );
+    }
+    return FilterModel::addStatement( s );
+}
+
+
+QUrl Nepomuk::ResourceFilterModel::mainContext()
+{
+    return d->graphWrapper.currentGraph();
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::updateModificationDate( const QUrl& resource, const QDateTime& date )
+{
+    Error::ErrorCode c = removeAllStatements( resource, Soprano::Vocabulary::NAO::lastModified(), Soprano::Node() );
+    if ( c != Error::ErrorNone )
+        return c;
+    else
+        return addStatement( resource, Soprano::Vocabulary::NAO::lastModified(), LiteralValue( date ), mainContext() );
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::updateProperty( const QUrl& resource, const QUrl& property, const Node& value )
+{
+    if( !property.isValid() ) {
+        setError( "Cannot update invalid property", Error::ErrorInvalidArgument );
+        return Error::ErrorInvalidArgument;
+    }
+
+    StatementIterator it = listStatements( Statement( resource, property, Node() ) );
+    if ( it.next() ) {
+        Statement s = it.current();
+        it.close();
+        if ( s.object() == value ) {
+            // nothing to do. Yey!
+            return Error::ErrorNone;
+        }
+        else {
+            removeStatement( s );
+        }
+    }
+
+    // update property
+    Error::ErrorCode c = addStatement( resource, property, value, mainContext() );
+    if ( c != Error::ErrorNone )
+        return updateModificationDate( resource );
+
+    return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::updateProperty( const QUrl& resource, const QUrl& property, const QList<Node>& values )
+{
+    if( !property.isValid() ) {
+        setError( "Cannot update invalid property", Error::ErrorInvalidArgument );
+        return Error::ErrorInvalidArgument;
+    }
+
+    QList<Node> existingValues = listStatements( Statement( resource, property, Node() ) ).iterateObjects().allNodes();
+
+    Error::ErrorCode c = Error::ErrorNone;
+    foreach( const Node &node, existingValues.toSet() - values.toSet() ) {
+        if ( ( c = removeAllStatements( Statement( resource, property, node ) ) ) != Error::ErrorNone ) {
+            return c;
+        }
+    }
+
+    QSet<Node> newNodes = values.toSet() - existingValues.toSet();
+    if ( !newNodes.isEmpty() ) {
+        QUrl context = mainContext();
+        foreach( const Node &node, newNodes ) {
+            if ( ( c = addStatement( Statement( resource, property, node, context ) ) ) != Error::ErrorNone ) {
+                return c;
+            }
+        }
+
+        c = updateModificationDate( resource );
+    }
+
+    return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::removeProperty( const QUrl& resource, const QUrl& property )
+{
+    if( !property.isValid() ) {
+        setError( "Cannot remove invalid property", Error::ErrorInvalidArgument );
+        return Error::ErrorInvalidArgument;
+    }
+
+    Soprano::Error::ErrorCode c = removeAllStatements( Statement( resource, property, Node() ) );
+    if ( c == Soprano::Error::ErrorNone )
+        return updateModificationDate( resource );
+    else
+        return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::ensureResource( const QUrl& resource, const QUrl& type )
+{
+    if ( !containsAnyStatement( Statement( resource, Vocabulary::RDF::type(), type ) ) ) {
+         Soprano::Error::ErrorCode c = addStatement( Statement( resource, Vocabulary::RDF::type(), type, mainContext() ) );
+         if ( c == Soprano::Error::ErrorNone )
+             return updateModificationDate( resource );
+         else
+             return c;
+    }
+    else {
+        clearError();
+        return Error::ErrorNone;
+    }
+}
+
+#include "resourcefiltermodel.moc"
diff -u -r -N nepomuk/core/.svn/text-base/resourcefiltermodel.h.svn-base nepomuk-svn/core/.svn/text-base/resourcefiltermodel.h.svn-base
--- nepomuk/core/.svn/text-base/resourcefiltermodel.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resourcefiltermodel.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,100 @@
+/* 
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_FILTER_MODEL_H_
+#define _NEPOMUK_RESOURCE_FILTER_MODEL_H_
+
+#include <Soprano/FilterModel>
+#include <Soprano/Node>
+#include <Soprano/Vocabulary/RDFS>
+
+#include <QtCore/QList>
+#include <QtCore/QDateTime>
+
+namespace Nepomuk {
+    /**
+     * Filter model that provides a set of convenience methods
+     * for maintaining resource properties.
+     *
+     * It does automatic NRL named graph handling, i.e. provedance
+     * data is created and deleted automatically.
+     *
+     * \warning This model assumes that no property value is stored twice,
+     * i.e. in two different named graphs.
+     */
+    class ResourceFilterModel : public Soprano::FilterModel
+    {
+        Q_OBJECT
+
+    public:
+        ResourceFilterModel( Soprano::Model* model = 0 );
+        ~ResourceFilterModel();
+
+        /**
+         * Adds a statement to the Model. Statements without a valid context will be
+         * added to the mainContext.
+         */
+        Soprano::Error::ErrorCode addStatement( const Soprano::Statement& statement );
+
+        /**
+         * The ResourceFilterModel automatically creates graph metadata and tries to
+         * group batch operations into one graph. This method returns the currently
+         * "open" graph, i.e. that one which is used in all the convinience methods.
+         */
+        QUrl mainContext();
+
+        /**
+         * Updates the modification date of \p resource to \p date.
+         */
+        Soprano::Error::ErrorCode updateModificationDate( const QUrl& resource, const QDateTime& date = QDateTime::currentDateTime() );
+
+        /**
+         * Update a property. This means an existing property is replaced if it differs from
+         * the provided value. Otherwise nothing is done.
+         *
+         * This method assumes that the cardinality or property is 1.
+         */
+        Soprano::Error::ErrorCode updateProperty( const QUrl& resource, const QUrl& property, const Soprano::Node& value );
+
+        /**
+         * Update a property with a cardinality > 1.
+         * This method optmizes the add and remove actions necessary.
+         */
+        Soprano::Error::ErrorCode updateProperty( const QUrl& resource, const QUrl& property, const QList<Soprano::Node>& values );
+
+        /**
+         * Remove a property from a resource and make sure no dangling graphs are left
+         */
+        Soprano::Error::ErrorCode removeProperty( const QUrl& resource, const QUrl& property );
+
+        /**
+         * Ensures that resoruce exists with type.
+         */
+        Soprano::Error::ErrorCode ensureResource( const QUrl& resource, const QUrl& type = Soprano::Vocabulary::RDFS::Resource() );
+
+        using FilterModel::addStatement;
+
+    private:
+        class Private;
+        Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/resourcemanager.cpp.svn-base nepomuk-svn/core/.svn/text-base/resourcemanager.cpp.svn-base
--- nepomuk/core/.svn/text-base/resourcemanager.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resourcemanager.cpp.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,481 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "resourcemanager.h"
+#include "resourcemanager_p.h"
+#include "resourcedata.h"
+#include "tools.h"
+#include "nepomukmainmodel.h"
+#include "resource.h"
+#include "resourcefiltermodel.h"
+
+#include "ontology/class.h"
+
+#include <kglobal.h>
+#include <kdebug.h>
+#include <krandom.h>
+
+#include <Soprano/Node>
+#include <Soprano/Statement>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/StatementIterator>
+#include <Soprano/QueryResultIterator>
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QMutex>
+#include <QtCore/QMutexLocker>
+
+using namespace Soprano;
+
+
+Nepomuk::ResourceManagerPrivate::ResourceManagerPrivate( ResourceManager* manager )
+    : mainModel( 0 ),
+      overrideModel( 0 ),
+      dataCnt( 0 ),
+      m_manager( manager )
+{
+}
+
+
+Nepomuk::ResourceData* Nepomuk::ResourceManagerPrivate::data( const QUrl& uri, const QUrl& type )
+{
+    if ( uri.isEmpty() ) {
+        // return an invalid resource which may be activated by calling setProperty
+        return new ResourceData( uri, QString(), type, this );
+    }
+
+    // default to "file" scheme, i.e. we do not allow an empty scheme
+    if ( uri.scheme().isEmpty() ) {
+        QUrl fileUri( uri );
+        fileUri.setScheme( "file" );
+        return data( fileUri, type );
+    }
+
+    // if scheme is file, try to follow a symlink
+    if ( uri.scheme() == "file" ) {
+        QFileInfo fileInfo( uri.toLocalFile() );
+        if ( fileInfo.isSymLink() ) {
+            QString linkTarget = fileInfo.canonicalFilePath();
+            // linkTarget is empty for dangling symlinks
+            if ( !linkTarget.isEmpty() ) {
+                QUrl targetUri( linkTarget );
+                targetUri.setScheme( "file" );
+                return data( targetUri, type );
+            }
+        }
+    }
+
+    ResourceDataHash::iterator it = m_initializedData.find( uri.toString() );
+
+    //
+    // The uriOrId has no local representation yet -> create one
+    //
+    if( it == m_initializedData.end() ) {
+//        kDebug(300004) << "No existing ResourceData instance found for uri " << uri;
+        //
+        // The actual URI is already known here
+        //
+        ResourceData* d = new ResourceData( uri, QString(), type, this );
+        m_initializedData.insert( uri.toString(), d );
+
+        return d;
+    }
+    else {
+        //
+        // Reuse the already existing ResourceData object
+        //
+        return it.value();
+    }
+}
+
+
+Nepomuk::ResourceData* Nepomuk::ResourceManagerPrivate::data( const QString& uriOrId, const QUrl& type )
+{
+    if ( uriOrId.isEmpty() ) {
+        return new ResourceData( QUrl(), QString(), type, this );
+    }
+
+    // special case: files (only absolute paths for now)
+    if ( uriOrId[0] == '/' ) {
+        // try to follow a symlink
+        QFileInfo fileInfo( uriOrId );
+        if ( fileInfo.isSymLink() ) {
+            QString linkTarget = fileInfo.canonicalFilePath();
+            // linkTarget is empty for dangling symlinks, use given url for those
+            if ( !linkTarget.isEmpty() ) {
+                return data( linkTarget, type );
+            }
+        }
+        ResourceDataHash::iterator it = m_initializedData.find( "file://" + uriOrId );
+        if ( it != m_initializedData.end() ) {
+            return *it;
+        }
+    }
+
+    ResourceDataHash::iterator it = m_initializedData.find( uriOrId );
+
+    bool resFound = ( it != m_initializedData.end() );
+
+    //
+    // The uriOrId is not a known local URI. Might be a kickoff value though
+    //
+    if( it == m_initializedData.end() ) {
+        it = m_kickoffData.find( uriOrId );
+
+        // check if the type matches (see determineUri for details)
+        if ( !type.isEmpty() && type != Soprano::Vocabulary::RDFS::Resource() ) {
+            Types::Class wantedType = type;
+            while ( it != m_kickoffData.end() &&
+                    it.key() == uriOrId ) {
+                if ( it.value()->hasType( type ) ) {
+                    break;
+                }
+                ++it;
+            }
+        }
+
+        resFound = ( it != m_kickoffData.end() && it.key() == uriOrId );
+    }
+
+    //
+    // The uriOrId has no local representation yet -> create one
+    //
+    if( !resFound ) {
+//        kDebug(300004) << "No existing ResourceData instance found for uriOrId " << uriOrId;
+        //
+        // Every new ResourceData object ends up in the kickoffdata since its actual URI is not known yet
+        //
+        ResourceData* d = new ResourceData( QUrl(), uriOrId, type, this );
+        m_kickoffData.insert( uriOrId, d );
+
+        return d;
+    }
+    else {
+        //
+        // Reuse the already existing ResourceData object
+        //
+        return it.value();
+    }
+}
+
+
+QList<Nepomuk::ResourceData*> Nepomuk::ResourceManagerPrivate::allResourceDataOfType( const QUrl& type )
+{
+    QList<ResourceData*> l;
+
+    if( !type.isEmpty() ) {
+        for( ResourceDataHash::iterator rdIt = m_kickoffData.begin();
+             rdIt != m_kickoffData.end(); ++rdIt ) {
+            if( rdIt.value()->type() == type ) {
+                l.append( rdIt.value() );
+            }
+        }
+    }
+
+    return l;
+}
+
+
+QList<Nepomuk::ResourceData*> Nepomuk::ResourceManagerPrivate::allResourceDataWithProperty( const QUrl& uri, const Variant& v )
+{
+    QList<ResourceData*> l;
+
+    for( ResourceDataHash::iterator rdIt = m_kickoffData.begin();
+         rdIt != m_kickoffData.end(); ++rdIt ) {
+
+        if( rdIt.value()->hasProperty( uri ) &&
+            rdIt.value()->property( uri ) == v ) {
+            l.append( rdIt.value() );
+        }
+    }
+
+    return l;
+}
+
+
+QList<Nepomuk::ResourceData*> Nepomuk::ResourceManagerPrivate::allResourceData()
+{
+    QList<ResourceData*> l;
+
+    for( ResourceDataHash::iterator rdIt = m_kickoffData.begin();
+         rdIt != m_kickoffData.end(); ++rdIt ) {
+        l.append( rdIt.value() );
+    }
+    for( ResourceDataHash::iterator rdIt = m_initializedData.begin();
+         rdIt != m_initializedData.end(); ++rdIt ) {
+        l.append( rdIt.value() );
+    }
+
+    return l;
+}
+
+
+bool Nepomuk::ResourceManagerPrivate::dataCacheFull()
+{
+    return dataCnt >= 1000;
+}
+
+
+void Nepomuk::ResourceManagerPrivate::cleanupCache()
+{
+    if ( dataCnt >= 1000 ) {
+        for( ResourceDataHash::iterator rdIt = m_initializedData.begin();
+             rdIt != m_initializedData.end(); ++rdIt ) {
+            ResourceData* data = rdIt.value();
+            if ( !data->cnt() ) {
+                data->deleteData();
+                return;
+            }
+        }
+    }
+}
+
+
+Nepomuk::ResourceManager::ResourceManager()
+    : QObject(),
+      d( new ResourceManagerPrivate( this ) )
+{
+    d->resourceFilterModel = new ResourceFilterModel();
+    connect( d->resourceFilterModel, SIGNAL(statementsAdded()),
+             this, SLOT(slotStoreChanged()) );
+    connect( d->resourceFilterModel, SIGNAL(statementsRemoved()),
+             this, SLOT(slotStoreChanged()) );
+}
+
+
+Nepomuk::ResourceManager::~ResourceManager()
+{
+    delete d->resourceFilterModel;
+    delete d->mainModel;
+    delete d;
+}
+
+
+void Nepomuk::ResourceManager::deleteInstance()
+{
+    delete this;
+}
+
+
+class Nepomuk::ResourceManagerHelper
+{
+    public:
+        Nepomuk::ResourceManager q;
+};
+K_GLOBAL_STATIC(Nepomuk::ResourceManagerHelper, instanceHelper)
+
+Nepomuk::ResourceManager* Nepomuk::ResourceManager::instance()
+{
+    return &instanceHelper->q;
+}
+
+
+int Nepomuk::ResourceManager::init()
+{
+    QMutexLocker lock( &d->mutex );
+
+    if( !d->mainModel ) {
+        d->mainModel = new MainModel( this );
+    }
+
+    d->resourceFilterModel->setParentModel( d->mainModel );
+
+    return d->mainModel->isValid() ? 0 : -1;
+}
+
+
+bool Nepomuk::ResourceManager::initialized() const
+{
+    return d->mainModel && d->mainModel->isValid();
+}
+
+
+Nepomuk::Resource Nepomuk::ResourceManager::createResourceFromUri( const QString& uri )
+{
+    return Resource( uri, QUrl() );
+}
+
+void Nepomuk::ResourceManager::removeResource( const QString& uri )
+{
+    Resource res( uri );
+    res.remove();
+}
+
+void Nepomuk::ResourceManager::notifyError( const QString& uri, int errorCode )
+{
+    kDebug(300004) << "(Nepomuk::ResourceManager) error: " << uri << " " << errorCode;
+    emit error( uri, errorCode );
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::ResourceManager::allResourcesOfType( const QString& type )
+{
+    return allResourcesOfType( QUrl(type) );
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::ResourceManager::allResourcesOfType( const QUrl& type )
+{
+    QList<Resource> l;
+
+    if( !type.isEmpty() ) {
+        // check local data
+        QList<ResourceData*> localData = d->allResourceDataOfType( type );
+        for( QList<ResourceData*>::iterator rdIt = localData.begin();
+             rdIt != localData.end(); ++rdIt ) {
+            l.append( Resource( *rdIt ) );
+        }
+
+//        kDebug(300004) << " added local resources: " << l.count();
+
+        Soprano::Model* model = mainModel();
+        Soprano::StatementIterator it = model->listStatements( Soprano::Statement( Soprano::Node(), Soprano::Vocabulary::RDF::type(), type ) );
+
+        while( it.next() ) {
+            Statement s = *it;
+            Resource res( s.subject().uri() );
+            if( !l.contains( res ) )
+                l.append( res );
+        }
+
+//        kDebug(300004) << " added remote resources: " << l.count();
+    }
+
+    return l;
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::ResourceManager::allResourcesWithProperty( const QString& uri, const Variant& v )
+{
+    return allResourcesWithProperty( QUrl(uri), v );
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::ResourceManager::allResourcesWithProperty( const QUrl& uri, const Variant& v )
+{
+    QList<Resource> l;
+
+    if( v.isList() ) {
+        kDebug(300004) << "(ResourceManager::allResourcesWithProperty) list values not supported.";
+    }
+    else {
+        // check local data
+        QList<ResourceData*> localData = d->allResourceDataWithProperty( uri, v );
+        for( QList<ResourceData*>::iterator rdIt = localData.begin();
+             rdIt != localData.end(); ++rdIt ) {
+            l.append( Resource( *rdIt ) );
+        }
+
+        // check remote data
+        Soprano::Node n;
+        if( v.isResource() ) {
+            n = v.toResource().resourceUri();
+        }
+        else {
+            n = valueToRDFNode(v);
+        }
+
+        Soprano::Model* model = mainModel();
+        Soprano::StatementIterator it = model->listStatements( Soprano::Statement( Soprano::Node(), uri, n ) );
+
+        while( it.next() ) {
+            Statement s = *it;
+            Resource res( s.subject().uri() );
+            if( !l.contains( res ) )
+                l.append( res );
+        }
+    }
+
+    return l;
+}
+
+
+QString Nepomuk::ResourceManager::generateUniqueUri()
+{
+    return generateUniqueUri( QString() ).toString();
+}
+
+
+QUrl Nepomuk::ResourceManager::generateUniqueUri( const QString& name )
+{
+    Soprano::Model* model = mainModel();
+
+    QUrl uri;
+    QString normalizedName( name );
+    normalizedName.remove( QRegExp( "[^\\w\\.\\-_:]" ) );
+    if ( !normalizedName.isEmpty() ) {
+        uri = "nepomuk:/" + normalizedName;
+    }
+    else {
+        uri = "nepomuk:/" + KRandom::randomString( 20 );
+    }
+
+    while( 1 ) {
+        if ( !model->executeQuery( QString("ask where { { <%1> ?p1 ?o1 . } UNION { ?r2 <%1> ?o2 . } UNION { ?r3 ?p3 <%1> . } }")
+                                   .arg( QString::fromAscii( uri.toEncoded() ) ), Soprano::Query::QueryLanguageSparql ).boolValue() ) {
+            return uri;
+        }
+        uri = "nepomuk:/" + normalizedName + '_' +  KRandom::randomString( 20 );
+    }
+}
+
+
+Soprano::Model* Nepomuk::ResourceManager::mainModel()
+{
+    // make sure we are initialized
+    if ( !d->overrideModel && !initialized() ) {
+        init();
+    }
+
+    return d->resourceFilterModel;
+}
+
+
+void Nepomuk::ResourceManager::slotStoreChanged()
+{
+//    kDebug();
+    Q_FOREACH( ResourceData* data, d->allResourceData()) {
+        data->invalidateCache();
+    }
+}
+
+
+void Nepomuk::ResourceManager::setOverrideMainModel( Soprano::Model* model )
+{
+    QMutexLocker lock( &d->mutex );
+
+    d->overrideModel = model;
+    d->resourceFilterModel->setParentModel( model ? model : d->mainModel );
+
+    // clear cache to make sure we do not mix data
+    Q_FOREACH( ResourceData* data, d->allResourceData()) {
+        data->invalidateCache();
+    }
+}
+
+
+Nepomuk::ResourceManager* Nepomuk::ResourceManager::createManagerForModel( Soprano::Model* model )
+{
+    ResourceManager* manager = new ResourceManager();
+    manager->setOverrideMainModel( model );
+    return manager;
+}
+
+#include "resourcemanager.moc"
diff -u -r -N nepomuk/core/.svn/text-base/resourcemanager.h.svn-base nepomuk-svn/core/.svn/text-base/resourcemanager.h.svn-base
--- nepomuk/core/.svn/text-base/resourcemanager.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resourcemanager.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,232 @@
+/* 
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_MANAGER_H_
+#define _NEPOMUK_RESOURCE_MANAGER_H_
+
+#include "nepomuk_export.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QUrl>
+
+
+namespace Soprano {
+    class Model;
+}
+
+namespace Nepomuk {
+    namespace Middleware {
+	class Registry;
+    }
+
+    class Resource;
+    class Variant;
+    class ResourceManagerHelper;
+    class ResourceManagerPrivate;
+
+    /**
+     * \class ResourceManager resourcemanager.h Nepomuk/ResourceManager
+     *
+     * \brief The ResourceManager is the central \a %KMetaData configuration point.
+     *
+     * \author Sebastian Trueg <trueg@kde.org>
+     */
+    class NEPOMUK_EXPORT ResourceManager : public QObject
+    {
+        Q_OBJECT
+
+    public:
+        static ResourceManager* instance();
+
+        /**
+         * In KDE 4.3 support for multiple ResourceManager instances
+         * has been introduced. To keep binary compatibility both the constructor's
+         * and destructor's access visibility could not be changed. Thus, instead of deleting
+         * a custom ResourceManager instance the standard way, one has to call this
+         * method or use QObject::deleteLater.
+         *
+         * \since 4.3
+         */
+        void deleteInstance();
+
+        /**
+         * Initialize the Nepomuk framework. This method will initialize the communication with
+         * the local Nepomuk-KDE services, ie. the data repository.
+         *
+         * When using multiple threads make sure to call this method in the main thread
+         * before doing anything else.
+         *
+         * \return 0 if all necessary components could be found and -1 otherwise.
+         *
+         * FIXME: introduce error codes and human readable translated error messages.
+         */
+        int init();
+
+        /**
+         * \return true if init() has been called successfully, ie. the KMetaData system is connected
+         * to the local RDF repository service and ready to work.
+         */
+        bool initialized() const;
+
+        /**
+         * Retrieve the main data storage model.
+         */
+        Soprano::Model* mainModel();
+
+        /**
+         * Override the main model used for all storage. By default the main model
+         * used is the Nepomuk server main model.
+         *
+         * \param model The model to use instead of the Nepomuk server or 0 to reset.
+         *
+         * \since 4.1
+         */
+        void setOverrideMainModel( Soprano::Model* model );
+
+        /**
+         * \deprecated Use the Resource constructor directly.
+         *
+         * Creates a Resource object representing the data referenced by \a uri.
+         * The result is the same as from using the Resource::Resource( const QString&, const QString& )
+         * constructor with an empty type.
+         *
+         * \return The Resource representing the data at \a uri or an invalid Resource object if the local
+         * NEPOMUK RDF store does not contain an object with URI \a uri.
+         */
+        KDE_DEPRECATED Resource createResourceFromUri( const QString& uri );
+
+        /**
+         * Remove the resource denoted by \a uri completely.
+         *
+         * This method is just a wrapper around Resource::remove. The result
+         * is the same.
+         */
+        void removeResource( const QString& uri );
+
+        /**
+         * Retrieve a list of all resource managed by this manager.
+         *
+         * \since 4.3
+         */
+        QList<Resource> allResources();
+
+        /**
+         * Retrieve a list of all resources of the specified \a type.
+         *
+         * This includes Resources that are not synced yet so it might
+         * not represent exactly the state as in the RDF store.
+         */
+        QList<Resource> allResourcesOfType( const QUrl& type );
+
+        /**
+         * \deprecated Use allResourcesOfType( const QString& type )
+         */
+        KDE_DEPRECATED QList<Resource> allResourcesOfType( const QString& type );
+
+        /**
+         * Retrieve a list of all resources that have property \a uri defined with a value of \a v.
+         *
+         * This includes Resources that are not synced yet so it might
+         * not represent exactly the state as in the RDF store.
+         *
+         * \param uri The URI identifying the property. If this URI does
+         *            not include a namespace the default namespace is
+         *            prepended.
+         * \param v The value all returned resources should have set as properts \a uri.
+         */
+        QList<Resource> allResourcesWithProperty( const QUrl& uri, const Variant& v );
+
+        /**
+         * \deprecated Use allResourcesWithProperty( const QString& type )
+         */
+        KDE_DEPRECATED QList<Resource> allResourcesWithProperty( const QString& uri, const Variant& v );
+
+        /**
+         * \deprecated Use generateUniqueUri(const QString&)
+         *
+         * Generates a unique URI that is not used in the store yet. This method ca be used to 
+         * generate URIs for virtual types such as Tag.
+         */
+        KDE_DEPRECATED QString generateUniqueUri();
+
+        /**
+         * Generates a unique URI that is not used in the store yet. This method ca be used to 
+         * generate URIs for virtual types such as Tag.
+         *
+         * \param label A label that the algorithm should use to try to create a more readable URI.
+         *
+         * \return A new unique URI which can be used to define a new resource.
+         *
+         * \since 4.2
+         */
+        QUrl generateUniqueUri( const QString& label );
+
+        /**
+         * \internal Non-public API. Used by Resource to signalize errors.
+         */
+        void notifyError( const QString& uri, int errorCode );
+
+        /**
+         * Create a new ResourceManager instance which uses model as its
+         * override model. This allows to use multiple instances of ResourceManager
+         * at the same time. Normally one does not need this method as the singleton
+         * accessed via instance() should be enough.
+         *
+         * \param model The model to read and write data from and to.
+         *
+         * \since 4.3
+         */
+        static ResourceManager* createManagerForModel( Soprano::Model* model );
+
+    Q_SIGNALS:
+        /**
+         * This signal gets emitted whenever a Resource changes due to a sync procedure.
+         * Be aware that modifying resources locally via the Resource::setProperty method
+         * does not result in a resourceModified signal being emitted.
+         *
+         * \param uri The URI of the modified resource.
+         *
+         * NOT IMPLEMENTED YET
+         */
+        void resourceModified( const QString& uri );
+
+        /**
+         * Whenever a problem occurs (like for example failed resource syncing) this 
+         * signal is emitted.
+         *
+         * \param uri The resource related to the error.
+         * \param errorCode The type of the error (Resource::ErrorCode)
+         */
+        void error( const QString& uri, int errorCode );
+
+    private Q_SLOTS:
+        void slotStoreChanged();
+
+    private:
+        friend class Nepomuk::ResourceManagerHelper;
+        friend class Nepomuk::Resource;
+        ResourceManager();
+        ~ResourceManager();
+
+        ResourceManagerPrivate* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/resourcemanager_p.h.svn-base nepomuk-svn/core/.svn/text-base/resourcemanager_p.h.svn-base
--- nepomuk/core/.svn/text-base/resourcemanager_p.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/resourcemanager_p.h.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,104 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_MANAGER_P_H_
+#define _NEPOMUK_RESOURCE_MANAGER_P_H_
+
+#include <QtCore/QMutex>
+#include <QtCore/QUrl>
+
+#include "resourcedata.h"
+
+
+namespace Soprano {
+    class Model;
+}
+
+
+namespace Nepomuk {
+
+    class ResourceManager;
+    class MainModel;
+    class ResourceFilterModel;
+
+    typedef QHash<QString, Nepomuk::ResourceData*> ResourceDataHash;
+
+    class ResourceManagerPrivate
+    {
+    public:
+        ResourceManagerPrivate( ResourceManager* manager );
+
+        /**
+         * The Nepomuk lib uses just one context (named graph)
+         * for all statements. This makes things simpler and
+         * we do not use the context for anything else than
+         * the named graph type anyway.
+         */
+        QUrl mainContext();
+
+        Nepomuk::MainModel* mainModel;
+        ResourceFilterModel* resourceFilterModel;
+        Soprano::Model* overrideModel;
+
+        QMutex mutex;
+
+        ResourceDataHash m_initializedData;
+        ResourceDataHash m_kickoffData;
+        int dataCnt;
+
+        ResourceManager* m_manager;
+
+        /**
+         * The Nepomuk lib is based on the fact that for each uri only one ResourceData object is
+         * created at all times. This method searches for an existing data object to reuse or creates
+         * a new one if none exists.
+         *
+         * \param uriOrId The URI or identifier of the resource is question.
+         * \type The type of the resource.
+         *
+         * The Resource constructors use this method in combination with ref()
+         */
+        ResourceData* data( const QString& uriOrId, const QUrl& type );
+
+        /**
+         * The Nepomuk lib is based on the fact that for each uri only one ResourceData object is
+         * created at all times. This method searches for an existing data object to reuse or creates
+         * a new one if none exists.
+         *
+         * \param uri The URI of the resource is question.
+         * \type The type of the resource.
+         *
+         * The Resource constructors use this method in combination with ref()
+         */
+        ResourceData* data( const QUrl& uri, const QUrl& type );
+
+        bool dataCacheFull();
+        void cleanupCache();
+
+        QList<ResourceData*> allResourceData();
+        QList<ResourceData*> allResourceDataOfType( const QUrl& type );
+        QList<ResourceData*> allResourceDataWithProperty( const QUrl& _uri, const Variant& v );
+
+    private:
+        QUrl m_mainContext;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/tag.cpp.svn-base nepomuk-svn/core/.svn/text-base/tag.cpp.svn-base
--- nepomuk/core/.svn/text-base/tag.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/tag.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,131 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "tag.h"
+
+#include "tools.h"
+#include "variant.h"
+#include "resourcemanager.h"
+#include "resource.h"
+
+#include <Soprano/Vocabulary/NAO>
+
+
+Nepomuk::Tag::Tag()
+    : Resource()
+{
+}
+
+
+Nepomuk::Tag::Tag( ResourceManager* manager )
+    : Resource( manager )
+{
+}
+
+
+Nepomuk::Tag::Tag( const Tag& res )
+    : Resource( res )
+{
+}
+
+
+Nepomuk::Tag::Tag( const Nepomuk::Resource& res )
+    : Resource( res )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QString& uri )
+    : Resource( uri, Soprano::Vocabulary::NAO::Tag() )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QString& uri, ResourceManager* manager )
+    : Resource( uri, Soprano::Vocabulary::NAO::Tag(), manager )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QUrl& uri )
+    : Resource( uri, Soprano::Vocabulary::NAO::Tag() )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QUrl& uri, ResourceManager* manager )
+    : Resource( uri, Soprano::Vocabulary::NAO::Tag(), manager )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QString& uri, const QUrl& type )
+    : Resource( uri, type )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QString& uri, const QUrl& type, ResourceManager* manager )
+    : Resource( uri, type, manager )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QUrl& uri, const QUrl& type )
+    : Resource( uri, type )
+{
+}
+
+
+Nepomuk::Tag::Tag( const QUrl& uri, const QUrl& type, ResourceManager* manager )
+    : Resource( uri, type, manager )
+{
+}
+
+
+Nepomuk::Tag::~Tag()
+{
+}
+
+
+Nepomuk::Tag& Nepomuk::Tag::operator=( const Tag& res )
+{
+    Resource::operator=( res );
+    return *this;
+}
+
+
+QString Nepomuk::Tag::resourceTypeUri()
+{
+    return Soprano::Vocabulary::NAO::Tag().toString();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Tag::tagOf() const
+{
+    return convertResourceList<Resource>( manager()->allResourcesWithProperty( Soprano::Vocabulary::NAO::hasTag(), *this ) );
+}
+
+
+// static
+QList<Nepomuk::Tag> Nepomuk::Tag::allTags()
+{
+    return Nepomuk::convertResourceList<Tag>( ResourceManager::instance()->allResourcesOfType( Soprano::Vocabulary::NAO::Tag() ) );
+}
diff -u -r -N nepomuk/core/.svn/text-base/tag.h.svn-base nepomuk-svn/core/.svn/text-base/tag.h.svn-base
--- nepomuk/core/.svn/text-base/tag.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/tag.h.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,145 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _TAG_H_
+#define _TAG_H_
+
+#include "resource.h"
+#include "nepomuk_export.h"
+
+namespace Nepomuk {
+
+    /**
+     * \class Tag tag.h Nepomuk/Tag
+     *
+     * A Tag can be assigned to any Thing. This allows simple grouping 
+     * of resources. Each Tag is identifed by its label which should 
+     * be unique. 
+     *
+     * \author Sebastian Trueg <trueg@kde.org>
+     */
+    class NEPOMUK_EXPORT Tag : public Resource
+    {
+    public:
+        /**
+         * Create a new empty and invalid Tag instance
+         */
+        Tag();
+
+        /**
+         * Create a new empty and invalid Tag instance
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Tag( ResourceManager* manager );
+
+        /**
+         * Default copy constructor
+         */
+        Tag( const Tag& );
+
+        /**
+         * \overload
+         */
+        Tag( const Resource& );
+
+        /**
+         * Create a new Tag instance representing the resource
+         * referenced by \a uriOrIdentifier.
+         */
+        Tag( const QString& uriOrIdentifier );
+
+        /**
+         * Create a new Tag instance representing the resource
+         * referenced by \a uriOrIdentifier.
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Tag( const QString& uriOrIdentifier, ResourceManager* manager );
+
+        /**
+         * Create a new Tag instance representing the resource
+         * referenced by \a uri.
+         */
+        Tag( const QUrl& uri );
+
+        /**
+         * Create a new Tag instance representing the resource
+         * referenced by \a uri.
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Tag( const QUrl& uri, ResourceManager* manager );
+
+        /**
+         * Destructor
+         */
+        ~Tag();
+
+        Tag& operator=( const Tag& );
+
+        /**
+         * Get all resources that have this resource set as property 'Tag'. 
+         * Each Resource can be tagged with an arbitrary number of Tags. 
+         * This allows a simple grouping of resources. \sa ResourceManager::allResourcesWithProperty 
+         */
+        QList<Resource> tagOf() const;
+
+        /**
+         * Retrieve a list of all available Tag resources. This list consists 
+         * of all resource of type Tag that are stored in the local Nepomuk 
+         * meta data storage and any changes made locally. Be aware that 
+         * in some cases this list can get very big. Then it might be better 
+         * to use libKNep directly. 
+         */
+        static QList<Tag> allTags();
+
+
+        /**
+         * \return The URI of the resource type that is used in Tag instances.
+         */
+        static QString resourceTypeUri();
+
+    protected:
+        Tag( const QString& uri, const QUrl& type );
+        Tag( const QUrl& uri, const QUrl& type );
+
+        /**
+         * \since 4.3
+         */
+        Tag( const QString& uri, const QUrl& type, ResourceManager* manager );
+
+        /**
+         * \since 4.3
+         */
+        Tag( const QUrl& uri, const QUrl& type, ResourceManager* manager );
+   };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/thing.cpp.svn-base nepomuk-svn/core/.svn/text-base/thing.cpp.svn-base
--- nepomuk/core/.svn/text-base/thing.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/thing.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,121 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "thing.h"
+#include "pimo.h"
+#include "variant.h"
+
+Nepomuk::Thing::Thing( const QUrl& uri, const QUrl& pimoType )
+    : Resource( uri, pimoType.isEmpty() ? Vocabulary::PIMO::Thing() : pimoType )
+{
+    // FIXME: somehow ensure that pimoType is actually a pimo:Thing. Maybe
+    // use operator= instead of the contructor and check the value beforehand
+}
+
+
+Nepomuk::Thing::Thing( const QUrl& uri, const QUrl& pimoType, ResourceManager* manager )
+    : Resource( uri, pimoType.isEmpty() ? Vocabulary::PIMO::Thing() : pimoType, manager )
+{
+    // FIXME: somehow ensure that pimoType is actually a pimo:Thing. Maybe
+    // use operator= instead of the contructor and check the value beforehand
+}
+
+
+Nepomuk::Thing::Thing( const QString& uriOrName, const QUrl& pimoType )
+    : Resource( uriOrName, pimoType.isEmpty() ? Vocabulary::PIMO::Thing() : pimoType )
+{
+    // FIXME: s.o.
+}
+
+
+Nepomuk::Thing::Thing( const QString& uriOrName, const QUrl& pimoType, ResourceManager* manager )
+    : Resource( uriOrName, pimoType.isEmpty() ? Vocabulary::PIMO::Thing() : pimoType, manager )
+{
+    // FIXME: s.o.
+}
+
+
+Nepomuk::Thing::Thing( const Thing& other )
+    : Resource( other )
+{
+    // FIXME: s.o.
+}
+
+
+Nepomuk::Thing::Thing( const Resource& other )
+    : Resource( other )
+{
+    // FIXME: s.o.
+}
+
+
+Nepomuk::Thing::Thing( Nepomuk::ResourceData* data )
+    : Resource( data )
+{
+}
+
+
+Nepomuk::Thing& Nepomuk::Thing::operator=( const Thing& res )
+{
+    Resource::operator=( res );
+    return *this;
+}
+
+
+Nepomuk::Thing& Nepomuk::Thing::operator=( const Resource& res )
+{
+    Resource::operator=( res );
+    return *this;
+}
+
+
+Nepomuk::Thing& Nepomuk::Thing::operator=( const QUrl& res )
+{
+    Resource::operator=( res );
+    return *this;
+}
+
+
+Nepomuk::Thing::~Thing()
+{
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Thing::groundingOccurrences() const
+{
+    return property( Vocabulary::PIMO::groundingOccurrence() ).toResourceList();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Thing::referencingOccurrences() const
+{
+    return property( Vocabulary::PIMO::referencingOccurrence() ).toResourceList();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Thing::occurrences() const
+{
+    return property( Vocabulary::PIMO::occurrence() ).toResourceList();
+}
+
+
+// void Nepomuk::Thing::merge( Thing other )
+// {
+// }
diff -u -r -N nepomuk/core/.svn/text-base/thing.h.svn-base nepomuk-svn/core/.svn/text-base/thing.h.svn-base
--- nepomuk/core/.svn/text-base/thing.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/thing.h.svn-base	2009-02-27 13:37:48.000000000 +0100
@@ -0,0 +1,175 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_THING_H_
+#define _NEPOMUK_THING_H_
+
+#include "resource.h"
+#include "nepomuk_export.h"
+
+// FIXME: (Would it even make sense to check in Nepomuk::Resource if a resource is a pimo:Thing and if so,
+//         use the PIMO context? Or should we handle that through the Nepomuk::PimoThing class?)
+
+namespace Nepomuk {
+    /**
+     * \class Thing thing.h Nepomuk/Thing
+     *
+     * \brief A Nepomuk PIMO Thing resource.
+     *
+     * A Thing represents a unique abstract concept/idea or real-world
+     * entity which can have multiple representations or occurrences.
+     *
+     * A typical example for a Thing is a unique person resource
+     * which identifies the person itself, not any representation
+     * such as an addressbook entry.
+     *
+     * Things are typically grounded via application resources,
+     * i.e. those resources that are created or handled by applications.
+     * Again the typical example is the addressbook entry.
+     *
+     * In general it is recommended to alway use the Thing instead of the
+     * grounding resource to annotate, i.e. to add tags, or relate to other
+     * resources. The advantage is its uniqueness. While there can be many
+     * occurrences of one concept there is only one Thing, identifying
+     * uniquely.
+     *
+     * \author Sebastian Trueg <trueg@kde.org>
+     *
+     * \since 4.2
+     */
+    class NEPOMUK_EXPORT Thing : public Resource
+    {
+    public:
+        /**
+         * Create a Thing object with URI \p uri. If the Thing does not
+         * exist in the Nepomuk storage yet, it will be created once
+         * a writing method is called (such as Resource::setProperty).
+         *
+         * \param uri The URI of the Thing. If empty, a new random one
+         * will be created.
+         * \param pimoType The type of this Thing. Needs to be a subtype
+         * of pimo:Thing. If empty defaults to pimo:Thing.
+         */
+        Thing( const QUrl& uri = QUrl(), const QUrl& pimoType = QUrl() );
+
+        /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Thing( const QUrl& uri, const QUrl& pimoType, ResourceManager* manager );
+
+        /**
+         * Create a new Thing with label or URI \p uriOrName
+         *
+         * \param uriOrName The URI or the label of the Thing. The constructor
+         * tries hard to find the Thing associated. If it is not found, a new
+         * Thing will be created.
+         * \param pimoType The type of this Thing. Needs to be a subtype
+         * of pimo:Thing. If empty defaults to pimo:Thing.
+         *
+         * Be aware that using the other constructor is always faster in case
+         * the URI of the Thing is known.
+         */
+        Thing( const QString& uriOrName, const QUrl& pimoType = QUrl() );
+
+        /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Thing( const QString& uriOrName, const QUrl& pimoType, ResourceManager* manager );
+
+        /**
+         * Copy constructor.
+         */
+        Thing( const Thing& other );
+
+        /**
+         * Copy constructor.
+         *
+         * \param other the resoruce to construct the Thing from.
+         */
+        Thing( const Resource& other );
+
+        /**
+         * Constructor used internally.
+         */
+        Thing( ResourceData* );
+
+        /**
+         * Desctructor
+         */
+        ~Thing();
+
+        /**
+         * Assignment operator.
+         */
+        Thing& operator=( const Thing& res );
+
+        /**
+         * Assignment operator.
+         */
+        Thing& operator=( const Resource& res );
+
+        /**
+         * Assignment operator.
+         */
+        Thing& operator=( const QUrl& res );
+
+        /**
+         * Get the grounding occurrences for this Thing.
+         * Grounding resources are physical representations
+         * of the Thing.
+         *
+         * An example is an mp3 file which represents an audio track
+         * or a website which represents a company or a person. Or the
+         * addressbook entry for an abstract person thing.
+         *
+         * \sa pimo:groundingResource
+         */
+        QList<Resource> groundingOccurrences() const;
+
+        QList<Resource> referencingOccurrences() const;
+
+        QList<Resource> occurrences() const;
+
+        /**
+         * Merges two Things that represent the same real-world
+         * entity.
+         *
+         * \param other The Thing that should be merged into this
+         * Thing.
+         *
+         * All properties of \p other will be merged into this
+         * Thing and all references to \p other will be replaced
+         * with references to this Thing.
+         */
+//        void merge( Thing other );
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/tools.cpp.svn-base nepomuk-svn/core/.svn/text-base/tools.cpp.svn-base
--- nepomuk/core/.svn/text-base/tools.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/tools.cpp.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,116 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "tools.h"
+#include "resourcemanager.h"
+
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+
+#include <QtCore/QLocale>
+
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/RDFS>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/NAO>
+
+
+
+void Nepomuk::setDefaultRepository( const QString& )
+{
+    // deprecated - do nothing
+}
+
+
+QString Nepomuk::defaultGraph()
+{
+    static QString s = "main";
+    return s;
+}
+
+
+QString Nepomuk::typePredicate()
+{
+    return Soprano::Vocabulary::RDF::type().toString();
+}
+
+
+Soprano::Node Nepomuk::valueToRDFNode( const Nepomuk::Variant& v )
+{
+    if ( v.isUrl() )
+        return Soprano::Node( v.toUrl() );
+    else
+        return Soprano::Node( Soprano::LiteralValue( v.variant() ) );
+}
+
+
+QList<Soprano::Node> Nepomuk::valuesToRDFNodes( const Nepomuk::Variant& v )
+{
+    QList<Soprano::Node> nl;
+
+    if ( v.isUrlList() ) {
+        QList<QUrl> urls = v.toUrlList();
+        for ( QList<QUrl>::const_iterator it = urls.constBegin(); it != urls.constEnd(); ++it ) {
+            nl.append( Soprano::Node( *it ) );
+        }
+    }
+    if( v.isList() ) {
+        QStringList vl = v.toStringList();
+        for( QStringList::const_iterator it = vl.constBegin(); it != vl.constEnd(); ++it ) {
+            nl.append( Soprano::Node( Soprano::LiteralValue::fromString( *it, ( QVariant::Type )v.simpleType() ) ) );
+        }
+    }
+    else {
+        nl.append( valueToRDFNode( v ) );
+    }
+
+    return nl;
+}
+
+
+Nepomuk::Variant Nepomuk::RDFLiteralToValue( const Soprano::Node& node )
+{
+    return Variant( node.literal().variant() );
+}
+
+
+QString Nepomuk::rdfNamepace()
+{
+    return Soprano::Vocabulary::RDF::rdfNamespace().toString();
+}
+
+
+QString Nepomuk::rdfsNamespace()
+{
+    return Soprano::Vocabulary::RDFS::rdfsNamespace().toString();
+}
+
+
+QString Nepomuk::nrlNamespace()
+{
+    return Soprano::Vocabulary::NRL::nrlNamespace().toString();
+}
+
+
+QString Nepomuk::naoNamespace()
+{
+    return Soprano::Vocabulary::NAO::naoNamespace().toString();
+}
diff -u -r -N nepomuk/core/.svn/text-base/tools.h.svn-base nepomuk-svn/core/.svn/text-base/tools.h.svn-base
--- nepomuk/core/.svn/text-base/tools.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/tools.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,108 @@
+/* 
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_TOOLS_H_
+#define _NEPOMUK_TOOLS_H_
+
+#include <QtCore/QString>
+#include <QtCore/QList>
+
+#include "variant.h"
+#include "nepomuk_export.h"
+
+#include <soprano/node.h>
+
+#include <kdemacros.h>
+
+namespace Nepomuk {
+    /**
+     * \deprecated Has no effect anymore.
+     */
+    KDE_DEPRECATED NEPOMUK_EXPORT void setDefaultRepository( const QString& s );
+
+    /**
+     * Used internally by Resource.
+     * \return The URI of the RDF graph meta data is stored in.
+     *
+     * \deprecated Use Nepomuk::ResourceManager::mainModel()
+     */
+    KDE_DEPRECATED NEPOMUK_EXPORT QString defaultGraph();
+
+    /**
+     * Used internally by Resource.
+     * \return The URI of the predicate used to state the type of a resource.
+     *
+     * \deprecated Use Soprano::Vocabulary::RDF::type()
+     */
+    KDE_DEPRECATED NEPOMUK_EXPORT QString typePredicate();
+
+    /**
+     * Used internally by Resource.
+     * Converts a Variant into a literal value to be used in the RDF store.
+     * Uses the language set in the current KDE session.
+     */
+    NEPOMUK_EXPORT QList<Soprano::Node> valuesToRDFNodes( const Variant& );
+    NEPOMUK_EXPORT Soprano::Node valueToRDFNode( const Variant& );
+
+    /**
+     * Used internally by Resource.
+     * Converts a literal value from the RDF store into a Variant.
+     */
+    NEPOMUK_EXPORT Variant RDFLiteralToValue( const Soprano::Node& node );
+
+    template<typename T> QList<T> convertResourceList( const QList<Resource>& l ) {
+        QList<T> rl;
+        for( QList<Resource>::const_iterator it = l.constBegin();
+             it != l.constEnd(); ++it )
+            rl.append( T( *it ) );
+        return rl;
+    }
+
+    template<typename T> QList<Resource> convertResourceList( const QList<T>& l ) {
+        QList<Resource> rl;
+        Q_FOREACH( T r, l )
+/*       for( QList<T>::const_iterator it = l.constBegin(); */
+/* 	   it != l.constEnd(); ++it ) */
+            rl.append( Resource( r/*it*/ ) );
+        return rl;
+    }
+
+    /**
+     * \deprecated Use Soprano::Vocabulary::RDF::rdfNamepace()
+     */
+    KDE_DEPRECATED NEPOMUK_EXPORT QString rdfNamepace();
+
+    /**
+     * \deprecated Use Soprano::Vocabulary::RDFS::rdfsNamepace()
+     */
+    KDE_DEPRECATED NEPOMUK_EXPORT QString rdfsNamespace();
+
+    /**
+     * \deprecated Use Soprano::Vocabulary::NRL::nrlNamepace()
+     */
+    KDE_DEPRECATED NEPOMUK_EXPORT QString nrlNamespace();
+
+    /**
+     * \deprecated Use Soprano::Vocabulary::NAO::naoNamepace()
+     */
+    KDE_DEPRECATED NEPOMUK_EXPORT QString naoNamespace();
+}
+
+#endif
diff -u -r -N nepomuk/core/.svn/text-base/variant.cpp.svn-base nepomuk-svn/core/.svn/text-base/variant.cpp.svn-base
--- nepomuk/core/.svn/text-base/variant.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/variant.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,1304 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "variant.h"
+#include "resource.h"
+
+#include <soprano/literalvalue.h>
+
+#include <kdebug.h>
+
+#include <QtCore/QVariant>
+
+
+namespace {
+    template<typename T1, typename T2> QList<T2> convertList( const QList<T1>& l ) {
+        QList<T2> il;
+        for( int i = 0; i < l.count(); ++i ) {
+            il.append( static_cast<T2>( l[i] ) );
+        }
+        return il;
+    }
+}
+
+
+class Nepomuk::Variant::Private
+{
+public:
+    QVariant value;
+};
+
+
+Nepomuk::Variant::Variant()
+    : d( new Private )
+{
+}
+
+
+Nepomuk::Variant::~Variant()
+{
+    delete d;
+}
+
+
+Nepomuk::Variant::Variant( const Variant& other )
+    : d( new Private )
+{
+    operator=( other );
+}
+
+
+Nepomuk::Variant::Variant( const QVariant& other )
+    : d( new Private )
+{
+    if ( other.userType() == QVariant::Int ||
+         other.userType() == QVariant::LongLong ||
+         other.userType() == QVariant::UInt ||
+         other.userType() == QVariant::ULongLong ||
+         other.userType() == QVariant::Bool ||
+         other.userType() == QVariant::Double ||
+         other.userType() == QVariant::String ||
+         other.userType() == QVariant::Date ||
+         other.userType() == QVariant::Time ||
+         other.userType() == QVariant::DateTime ||
+         other.userType() == QVariant::Url ||
+         other.userType() == qMetaTypeId<Resource>() ||
+         other.userType() == qMetaTypeId<QList<int> >() ||
+         other.userType() == qMetaTypeId<QList<qlonglong> >() ||
+         other.userType() == qMetaTypeId<QList<uint> >() ||
+         other.userType() == qMetaTypeId<QList<qulonglong> >() ||
+         other.userType() == qMetaTypeId<QList<bool> >() ||
+         other.userType() == qMetaTypeId<QList<double> >() ||
+         other.userType() == QVariant::StringList ||
+         other.userType() == qMetaTypeId<QList<QDate> >() ||
+         other.userType() == qMetaTypeId<QList<QTime> >() ||
+         other.userType() == qMetaTypeId<QList<QDateTime> >() ||
+         other.userType() == qMetaTypeId<QList<QUrl> >() ||
+         other.userType() == qMetaTypeId<QList<Resource> >() ) {
+        d->value = other;
+    }
+}
+
+
+Nepomuk::Variant::Variant( int i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( qlonglong i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( uint i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( qulonglong i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( bool b )
+    : d( new Private )
+{
+    d->value.setValue( b );
+}
+
+
+Nepomuk::Variant::Variant( double v )
+    : d( new Private )
+{
+    d->value.setValue( v );
+}
+
+
+Nepomuk::Variant::Variant( const char* string )
+    : d( new Private )
+{
+    d->value.setValue( QString::fromLatin1(string) );
+}
+
+
+Nepomuk::Variant::Variant( const QString& string )
+    : d( new Private )
+{
+    d->value.setValue( string );
+}
+
+
+Nepomuk::Variant::Variant( const QDate& date )
+    : d( new Private )
+{
+    d->value.setValue( date );
+}
+
+
+Nepomuk::Variant::Variant( const QTime& time )
+    : d( new Private )
+{
+    d->value.setValue( time );
+}
+
+
+Nepomuk::Variant::Variant( const QDateTime& datetime )
+    : d( new Private )
+{
+    d->value.setValue( datetime );
+}
+
+
+Nepomuk::Variant::Variant( const QUrl& url )
+    : d( new Private )
+{
+    d->value.setValue( url );
+}
+
+
+Nepomuk::Variant::Variant( const Nepomuk::Resource& r )
+    : d( new Private )
+{
+    d->value.setValue( r );
+}
+
+
+Nepomuk::Variant::Variant( const QList<int>& i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( const QList<qlonglong>& i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( const QList<uint>& i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( const QList<qulonglong>& i )
+    : d( new Private )
+{
+    d->value.setValue( i );
+}
+
+
+Nepomuk::Variant::Variant( const QList<bool>& b )
+    : d( new Private )
+{
+    d->value.setValue( b );
+}
+
+
+Nepomuk::Variant::Variant( const QList<double>& v )
+    : d( new Private )
+{
+    d->value.setValue( v );
+}
+
+
+Nepomuk::Variant::Variant( const QStringList& stringlist )
+    : d( new Private )
+{
+    d->value.setValue( stringlist );
+}
+
+
+Nepomuk::Variant::Variant( const QList<QDate>& date )
+    : d( new Private )
+{
+    d->value.setValue( date );
+}
+
+
+Nepomuk::Variant::Variant( const QList<QTime>& time )
+    : d( new Private )
+{
+    d->value.setValue( time );
+}
+
+
+Nepomuk::Variant::Variant( const QList<QDateTime>& datetime )
+    : d( new Private )
+{
+    d->value.setValue( datetime );
+}
+
+
+Nepomuk::Variant::Variant( const QList<QUrl>& url )
+    : d( new Private )
+{
+    d->value.setValue( url );
+}
+
+
+
+Nepomuk::Variant::Variant( const QList<Resource>& r )
+    : d( new Private )
+{
+    d->value.setValue( r );
+}
+
+
+Nepomuk::Variant::Variant( const QList<Variant>& vl )
+    : d( new Private )
+{
+    foreach( const Variant& v, vl ) {
+        append( v );
+    }
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const Variant& v )
+{
+    d->value = v.d->value;
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( int i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( qlonglong i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( uint i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( qulonglong i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( bool b )
+{
+    d->value.setValue( b );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( double v )
+{
+    d->value.setValue( v );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QString& string )
+{
+    d->value.setValue( string );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QDate& date )
+{
+    d->value.setValue( date );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QTime& time )
+{
+    d->value.setValue( time );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QDateTime& datetime )
+{
+    d->value.setValue( datetime );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QUrl& url )
+{
+    d->value.setValue( url );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const Resource& r )
+{
+    d->value.setValue( r );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<int>& i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<qlonglong>& i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<uint>& i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<qulonglong>& i )
+{
+    d->value.setValue( i );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<bool>& b )
+{
+    d->value.setValue( b );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<double>& v )
+{
+    d->value.setValue( v );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QStringList& stringlist )
+{
+    d->value.setValue( stringlist );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<QDate>& date )
+{
+    d->value.setValue( date );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<QTime>& time )
+{
+    d->value.setValue( time );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<QDateTime>& datetime )
+{
+    d->value.setValue( datetime );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<QUrl>& url )
+{
+    d->value.setValue( url );
+    return *this;
+}
+
+
+Nepomuk::Variant& Nepomuk::Variant::operator=( const QList<Resource>& r )
+{
+    d->value.setValue( r );
+    return *this;
+}
+
+
+void Nepomuk::Variant::append( int i )
+{
+    QList<int> l = toIntList();
+    l.append( i );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( qlonglong i )
+{
+    QList<qlonglong> l = toInt64List();
+    l.append( i );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( uint i )
+{
+    QList<uint> l = toUnsignedIntList();
+    l.append( i );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( qulonglong i )
+{
+    QList<qulonglong> l = toUnsignedInt64List();
+    l.append( i );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( bool b )
+{
+    QList<bool> l = toBoolList();
+    l.append( b );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( double d )
+{
+    QList<double> l = toDoubleList();
+    l.append( d );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( const QString& string )
+{
+    QStringList l = toStringList();
+    l.append( string );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( const QDate& date )
+{
+    QList<QDate> l = toDateList();
+    l.append( date );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( const QTime& time )
+{
+    QList<QTime> l = toTimeList();
+    l.append( time );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( const QDateTime& datetime )
+{
+    QList<QDateTime> l = toDateTimeList();
+    l.append( datetime );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( const QUrl& url )
+{
+    QList<QUrl> l = toUrlList();
+    l.append( url );
+    operator=( l );
+}
+
+
+void Nepomuk::Variant::append( const Resource& r )
+{
+    QList<Resource> l = toResourceList();
+    if ( !l.contains( r ) ) {
+        l.append( r );
+        operator=( l );
+    }
+}
+
+
+void Nepomuk::Variant::append( const Variant& v )
+{
+    if ( !isValid() ) {
+        operator=( v );
+    }
+    else {
+        if( v.simpleType() == QVariant::Int ) {
+            operator=( toIntList() += v.toIntList() );
+        }
+        else if( v.simpleType() == QVariant::UInt ) {
+            operator=( toUnsignedIntList() += v.toUnsignedIntList() );
+        }
+        else if( v.simpleType() == QVariant::LongLong ) {
+            operator=( toInt64List() += v.toInt64List() );
+        }
+        else if( v.simpleType() == QVariant::ULongLong ) {
+            operator=( toUnsignedInt64List() += v.toUnsignedInt64List() );
+        }
+        else if( v.simpleType() == QVariant::Bool ) {
+            operator=( toBoolList() += v.toBoolList() );
+        }
+        else if( v.simpleType() == QVariant::Double ) {
+            operator=( toDoubleList() += v.toDoubleList() );
+        }
+        else if( v.simpleType() == QVariant::String ) {
+            operator=( toStringList() += v.toStringList() );
+        }
+        else if( v.simpleType() == QVariant::Date ) {
+            operator=( toDateList() += v.toDateList() );
+        }
+        else if( v.simpleType() == QVariant::Time ) {
+            operator=( toTimeList() += v.toTimeList() );
+        }
+        else if( v.simpleType() == QVariant::DateTime ) {
+            operator=( toDateTimeList() += v.toDateTimeList() );
+        }
+        else if( v.simpleType() == QVariant::Url ) {
+            operator=( toUrlList() += v.toUrlList() );
+        }
+        else if( v.simpleType() == qMetaTypeId<Resource>() ) {
+            operator=( toResourceList() += v.toResourceList() );
+        }
+        else
+            kDebug(300004) << "(Variant::append) unknown type: " << v.simpleType();
+    }
+}
+
+
+bool Nepomuk::Variant::isInt() const
+{
+    return( type() == QVariant::Int );
+}
+
+
+bool Nepomuk::Variant::isInt64() const
+{
+    return( type() == QVariant::LongLong );
+}
+
+
+bool Nepomuk::Variant::isUnsignedInt() const
+{
+    return( type() == QVariant::UInt );
+}
+
+
+bool Nepomuk::Variant::isUnsignedInt64() const
+{
+    return( type() == QVariant::ULongLong );
+}
+
+
+bool Nepomuk::Variant::isBool() const
+{
+    return( type() == QVariant::Bool );
+}
+
+
+bool Nepomuk::Variant::isDouble() const
+{
+    return( type() == QVariant::Double );
+}
+
+
+bool Nepomuk::Variant::isString() const
+{
+    return( type() == QVariant::String );
+}
+
+
+bool Nepomuk::Variant::isDate() const
+{
+    return( type() == QVariant::Date );
+}
+
+
+bool Nepomuk::Variant::isTime() const
+{
+    return( type() == QVariant::Time );
+}
+
+
+bool Nepomuk::Variant::isDateTime() const
+{
+    return( type() == QVariant::DateTime );
+}
+
+
+bool Nepomuk::Variant::isUrl() const
+{
+    return( type() == QVariant::Url );
+}
+
+
+bool Nepomuk::Variant::isResource() const
+{
+    return( type() == qMetaTypeId<Resource>() );
+}
+
+
+bool Nepomuk::Variant::isIntList() const
+{
+    return( type() == qMetaTypeId<QList<int> >() );
+}
+
+
+bool Nepomuk::Variant::isUnsignedIntList() const
+{
+    return( type() == qMetaTypeId<QList<uint> >() );
+}
+
+
+bool Nepomuk::Variant::isInt64List() const
+{
+    return( type() == qMetaTypeId<QList<qlonglong> >() );
+}
+
+
+bool Nepomuk::Variant::isUnsignedInt64List() const
+{
+    return( type() == qMetaTypeId<QList<qulonglong> >() );
+}
+
+
+bool Nepomuk::Variant::isBoolList() const
+{
+    return( type() == qMetaTypeId<QList<bool> >() );
+}
+
+
+bool Nepomuk::Variant::isDoubleList() const
+{
+    return( type() == qMetaTypeId<QList<double> >() );
+}
+
+
+bool Nepomuk::Variant::isStringList() const
+{
+    return( type() == QVariant::StringList );
+}
+
+
+bool Nepomuk::Variant::isDateList() const
+{
+    return( type() == qMetaTypeId<QList<QDate> >() );
+}
+
+
+bool Nepomuk::Variant::isTimeList() const
+{
+    return( type() == qMetaTypeId<QList<QTime> >() );
+}
+
+
+bool Nepomuk::Variant::isDateTimeList() const
+{
+    return( type() == qMetaTypeId<QList<QDateTime> >() );
+}
+
+
+bool Nepomuk::Variant::isUrlList() const
+{
+    return( type() == qMetaTypeId<QList<QUrl> >() );
+}
+
+
+bool Nepomuk::Variant::isResourceList() const
+{
+    return( type() == qMetaTypeId<QList<Resource> >() );
+}
+
+
+
+int Nepomuk::Variant::toInt() const
+{
+    return d->value.toInt();
+}
+
+
+qlonglong Nepomuk::Variant::toInt64() const
+{
+    return d->value.toLongLong();
+}
+
+
+uint Nepomuk::Variant::toUnsignedInt() const
+{
+    return d->value.toUInt();
+}
+
+
+qulonglong Nepomuk::Variant::toUnsignedInt64() const
+{
+    return d->value.toULongLong();
+}
+
+
+bool Nepomuk::Variant::toBool() const
+{
+    return d->value.toBool();
+}
+
+
+double Nepomuk::Variant::toDouble() const
+{
+    return d->value.toDouble();
+}
+
+
+QString Nepomuk::Variant::toString() const
+{
+//    kDebug(300004) << "(Variant::toString() converting... " << QMetaType::typeName(type());
+    if( isList() )
+        return toStringList().join( "," );
+
+    else if( isInt() )
+        return QString::number( toInt() );
+    else if( isInt64() )
+        return QString::number( toInt64() );
+    else if( isUnsignedInt() )
+        return QString::number( toUnsignedInt() );
+    else if( isUnsignedInt64() )
+        return QString::number( toUnsignedInt64() );
+    else if( isBool() )
+        return ( toBool() ? QString("true") : QString("false" ) );
+    else if( isDouble() )
+        return QString::number( toDouble(), 'e', 10 );
+    else if( isDate() )
+        return Soprano::LiteralValue( toDate() ).toString();
+    else if( isTime() )
+        return Soprano::LiteralValue( toTime() ).toString();
+    else if( isDateTime() )
+        return Soprano::LiteralValue( toDateTime() ).toString();
+    else if( isUrl() )
+        return toUrl().toString();
+    else if( isResource() ) {
+        Resource r = toResource();
+        if( !r.resourceUri().isEmpty() )
+            return r.resourceUri().toString();
+        else if( !r.identifiers().isEmpty() )
+            return r.identifiers().first();
+        else
+            return QString();
+    }
+    else
+        return d->value.value<QString>();
+}
+
+
+QDate Nepomuk::Variant::toDate() const
+{
+    return d->value.toDate();
+}
+
+
+QTime Nepomuk::Variant::toTime() const
+{
+    return d->value.toTime();
+}
+
+
+QDateTime Nepomuk::Variant::toDateTime() const
+{
+    return d->value.toDateTime();
+}
+
+
+QUrl Nepomuk::Variant::toUrl() const
+{
+    return d->value.toUrl();
+}
+
+
+Nepomuk::Resource Nepomuk::Variant::toResource() const
+{
+    return d->value.value<Resource>();
+}
+
+
+
+QList<int> Nepomuk::Variant::toIntList() const
+{
+    if( isUnsignedInt() ||
+        isInt() ||
+        isUnsignedInt64() ||
+        isInt64() ) {
+        QList<int> l;
+        l.append( toInt() );
+        return l;
+    }
+    else if ( isUnsignedIntList() ) {
+        return convertList<uint, int>( d->value.value<QList<uint> >() );
+    }
+    else if ( isUnsignedInt64List() ) {
+        return convertList<qulonglong, int>( d->value.value<QList<qulonglong> >() );
+    }
+    else if ( isInt64List() ) {
+        return convertList<qlonglong, int>( d->value.value<QList<qlonglong> >() );
+    }
+    else {
+        return d->value.value<QList<int> >();
+    }
+}
+
+
+QList<qlonglong> Nepomuk::Variant::toInt64List() const
+{
+    if( isUnsignedInt() ||
+        isInt() ||
+        isUnsignedInt64() ||
+        isInt64() ) {
+        QList<qlonglong> l;
+        l.append( toInt64() );
+        return l;
+    }
+    else if ( isIntList() ) {
+        return convertList<int, qlonglong>( d->value.value<QList<int> >() );
+    }
+    else if ( isUnsignedIntList() ) {
+        return convertList<uint, qlonglong>( d->value.value<QList<uint> >() );
+    }
+    else if ( isUnsignedInt64List() ) {
+        return convertList<qulonglong, qlonglong>( d->value.value<QList<qulonglong> >() );
+    }
+    else {
+        return d->value.value<QList<qlonglong> >();
+    }
+}
+
+
+QList<uint> Nepomuk::Variant::toUnsignedIntList() const
+{
+    if( isUnsignedInt() ||
+        isInt() ||
+        isUnsignedInt64() ||
+        isInt64() ) {
+        QList<uint> l;
+        l.append( toUnsignedInt() );
+        return l;
+    }
+    else if ( isIntList() ) {
+        return convertList<int, uint>( d->value.value<QList<int> >() );
+    }
+    else if ( isUnsignedInt64List() ) {
+        return convertList<qulonglong, uint>( d->value.value<QList<qulonglong> >() );
+    }
+    else if ( isInt64List() ) {
+        return convertList<qlonglong, uint>( d->value.value<QList<qlonglong> >() );
+    }
+    else {
+        return d->value.value<QList<uint> >();
+    }
+}
+
+
+QList<qulonglong> Nepomuk::Variant::toUnsignedInt64List() const
+{
+    if( isUnsignedInt() ||
+        isInt() ||
+        isUnsignedInt64() ||
+        isInt64() ) {
+        QList<qulonglong> l;
+        l.append( toUnsignedInt() );
+        return l;
+    }
+    else if ( isIntList() ) {
+        return convertList<int, qulonglong>( d->value.value<QList<int> >() );
+    }
+    else if ( isUnsignedIntList() ) {
+        return convertList<uint, qulonglong>( d->value.value<QList<uint> >() );
+    }
+    else if ( isInt64List() ) {
+        return convertList<qlonglong, qulonglong>( d->value.value<QList<qlonglong> >() );
+    }
+    else {
+        return d->value.value<QList<qulonglong> >();
+    }
+}
+
+
+QList<bool> Nepomuk::Variant::toBoolList() const
+{
+    if( isBool() ) {
+        QList<bool> l;
+        l.append( toBool() );
+        return l;
+    }
+    else
+        return d->value.value<QList<bool> >();
+}
+
+
+QList<double> Nepomuk::Variant::toDoubleList() const
+{
+    if( isDouble() ) {
+        QList<double> l;
+        l.append( toDouble() );
+        return l;
+    }
+    else
+        return d->value.value<QList<double> >();
+}
+
+
+template<typename T> QStringList convertToStringList( const QList<T>& l )
+{
+    QStringList sl;
+    QListIterator<T> it( l );
+    while( it.hasNext() )
+        sl.append( Nepomuk::Variant( it.next() ).toString() );
+//   for( QList<T>::const_iterator it = l.constBegin(); it != l.constEnd(); ++it )
+//     sl.append( Nepomuk::Variant( *it ).toString() );
+    return sl;
+}
+
+QStringList Nepomuk::Variant::toStringList() const
+{
+    //  kDebug(300004) << "(Variant::toStringList() converting... " << QMetaType::typeName(simpleType());
+    if( !d->value.isValid() )
+        return QStringList();
+
+    if( !isList() )
+        return QStringList( toString() );
+
+    else if( isIntList() )
+        return convertToStringList<int>( toIntList() );
+    else if( isInt64List() )
+        return convertToStringList<qlonglong>( toInt64List() );
+    else if( isUnsignedIntList() )
+        return convertToStringList<uint>( toUnsignedIntList() );
+    else if( isUnsignedInt64List() )
+        return convertToStringList<qulonglong>( toUnsignedInt64List() );
+    else if( isBoolList() )
+        return convertToStringList<bool>( toBoolList() );
+    else if( isDoubleList() )
+        return convertToStringList<double>( toDoubleList() );
+    else if( isDateList() )
+        return convertToStringList<QDate>( toDateList() );
+    else if( isTimeList() )
+        return convertToStringList<QTime>( toTimeList() );
+    else if( isDateTimeList() )
+        return convertToStringList<QDateTime>( toDateTimeList() );
+    else if( isUrlList() )
+        return convertToStringList<QUrl>( toUrlList() );
+    else if( isResourceList() )
+        return convertToStringList<Resource>( toResourceList() );
+    else
+        return d->value.value<QStringList>();
+}
+
+
+QList<QDate> Nepomuk::Variant::toDateList() const
+{
+    if( isDate() ) {
+        QList<QDate> l;
+        l.append( toDate() );
+        return l;
+    }
+    else
+        return d->value.value<QList<QDate> >();
+}
+
+
+QList<QTime> Nepomuk::Variant::toTimeList() const
+{
+    if( isTime() ) {
+        QList<QTime> l;
+        l.append( toTime() );
+        return l;
+    }
+    else
+        return d->value.value<QList<QTime> >();
+}
+
+
+QList<QDateTime> Nepomuk::Variant::toDateTimeList() const
+{
+    if( isDateTime() ) {
+        QList<QDateTime> l;
+        l.append( toDateTime() );
+        return l;
+    }
+    else
+        return d->value.value<QList<QDateTime> >();
+}
+
+
+QList<QUrl> Nepomuk::Variant::toUrlList() const
+{
+    if( isUrl() ) {
+        QList<QUrl> l;
+        l.append( toUrl() );
+        return l;
+    }
+    else
+        return d->value.value<QList<QUrl> >();
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::Variant::toResourceList() const
+{
+    if( isResource() ) {
+        QList<Resource> l;
+        l.append( toResource() );
+        return l;
+    }
+    else
+        return d->value.value<QList<Resource> >();
+}
+
+
+QList<Nepomuk::Variant> Nepomuk::Variant::toVariantList() const
+{
+    QList<Variant> l;
+
+    switch( simpleType() ) {
+    case QVariant::Int:
+        foreach( int i, toIntList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::LongLong:
+        foreach( qlonglong i, toInt64List() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::UInt:
+        foreach( uint i, toUnsignedIntList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::ULongLong:
+        foreach( qulonglong i, toUnsignedInt64List() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Bool:
+        foreach( bool i, toBoolList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Double:
+        foreach( double i, toDoubleList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Date:
+        foreach( const QDate& i, toDateList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Time:
+        foreach( const QTime& i, toTimeList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::DateTime:
+        foreach( const QDateTime& i, toDateTimeList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Url:
+        foreach( const QUrl& i, toUrlList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    default:
+        if( simpleType() == qMetaTypeId<Resource>()) {
+            foreach( const Resource& i, toResourceList() ) {
+                l.append( Variant(i) );
+            }
+        }
+        else {
+            foreach( const QString& i, toStringList() ) {
+                l.append( Variant(i) );
+            }
+            break;
+        }
+    }
+
+    return l;
+}
+
+
+bool Nepomuk::Variant::isList() const
+{
+    return( isIntList() ||
+            isInt64List() ||
+            isUnsignedIntList() ||
+            isUnsignedInt64List() ||
+            isBoolList() ||
+            isDoubleList() ||
+            isStringList() ||
+            isDateList() ||
+            isTimeList() ||
+            isDateTimeList() ||
+            isUrlList() ||
+            isResourceList() );
+}
+
+
+int Nepomuk::Variant::type() const
+{
+    return d->value.userType();
+}
+
+
+int Nepomuk::Variant::simpleType() const
+{
+    if( isIntList() )
+        return QVariant::Int;
+    else if( isInt64List() )
+        return QVariant::LongLong;
+    else if( isUnsignedIntList() )
+        return QVariant::UInt;
+    else if( isUnsignedInt64List() )
+        return QVariant::ULongLong;
+    else if( isBoolList() )
+        return QVariant::Bool;
+    else if( isDoubleList() )
+        return QVariant::Double;
+    else if( isStringList() )
+        return QVariant::String;
+    else if( isDateList() )
+        return QVariant::Date;
+    else if( isTimeList() )
+        return QVariant::Time;
+    else if( isDateTimeList() )
+        return QVariant::DateTime;
+    else if( isUrlList() )
+        return QVariant::Url;
+    else if( isResourceList() )
+        return qMetaTypeId<Resource>();
+    else
+        return d->value.userType();
+}
+
+
+Nepomuk::Variant Nepomuk::Variant::fromString( const QString& value, int type )
+{
+    // first check the types that are not supported by Soprano since they are not literal types
+    if( type == qMetaTypeId<Resource>() ) {
+        return Variant( Resource( value ) );
+    }
+    else if ( type == int( QVariant::Url ) ) {
+        return Variant( QUrl( value ) );
+    }
+
+    // let Soprano do the rest
+    else {
+        return Variant( Soprano::LiteralValue::fromString( value, ( QVariant::Type )type ).variant() );
+    }
+}
+
+
+bool Nepomuk::Variant::operator==( const Variant& other ) const
+{
+    if( other.simpleType() != this->simpleType() )
+        return false;
+
+    if( isInt() || isIntList() )
+        return other.toIntList() == toIntList();
+    else if( isInt64() || isInt64List() )
+        return other.toInt64List() == toInt64List();
+    else if( isUnsignedInt() || isUnsignedIntList() )
+        return other.toUnsignedIntList() == toUnsignedIntList();
+    else if( isUnsignedInt64() || isUnsignedInt64List() )
+        return other.toUnsignedInt64List() == toUnsignedInt64List();
+    else if( isBool() || isBoolList() )
+        return other.toBoolList() == toBoolList();
+    else if( isDouble() || isDoubleList() )
+        return other.toDoubleList() == toDoubleList();
+    else if( isString() || isStringList() )
+        return other.d->value.value<QStringList>() == d->value.value<QStringList>();
+    else if( isDate() || isDateList() )
+        return other.toDateList() == toDateList();
+    else if( isTime() || isTimeList() )
+        return other.toTimeList() == toTimeList();
+    else if( isDateTime() || isDateTimeList() )
+        return other.toDateTimeList() == toDateTimeList();
+    else if( isUrl() || isUrlList() )
+        return other.toUrlList() == toUrlList();
+    else if( isResource() || isResourceList() )
+        return other.toResourceList() == toResourceList();
+    else
+        return ( d->value == other.d->value );
+}
+
+
+bool Nepomuk::Variant::operator!=( const Variant& other ) const
+{
+    return !operator==( other );
+}
+
+
+QVariant Nepomuk::Variant::variant() const
+{
+    return d->value;
+}
+
+
+bool Nepomuk::Variant::isValid() const
+{
+    return d->value.isValid();
+}
+
+
+QDebug operator<<( QDebug dbg, const Nepomuk::Variant& v )
+{
+    if( v.isList() )
+        dbg.nospace() << "Nepomuk::Variant(" << v.toStringList() << "@list)";
+    else if( v.isResource() )
+        dbg.nospace() << "Nepomuk::Variant(Nepomuk::Resource(" << v.toString() << "))";
+    else
+        dbg.nospace() << "Nepomuk::Variant(" << v.variant() << ")";
+    return dbg;
+}
diff -u -r -N nepomuk/core/.svn/text-base/variant.h.svn-base nepomuk-svn/core/.svn/text-base/variant.h.svn-base
--- nepomuk/core/.svn/text-base/variant.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/.svn/text-base/variant.h.svn-base	2009-02-27 13:37:45.000000000 +0100
@@ -0,0 +1,295 @@
+/* 
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_VARIANT_H_
+#define _NEPOMUK_VARIANT_H_
+
+#include "nepomuk_export.h"
+#include "resource.h"
+
+#include <QtCore/QDateTime>
+#include <QtCore/QUrl>
+#include <QtCore/QVariant>
+
+namespace Nepomuk {
+
+    class Resource;
+
+    /**
+     * \class Variant variant.h Nepomuk/Variant
+     *
+     * The %Nepomuk Variant extends over QVariant by introducing
+     * direct support for Resource embedding, automatic list conversion 
+     * and a restricted set of supported types.
+     *
+     * Important differences are:
+     * \li No new types can be added other than the ones that have defined
+     *     constructors and get-methods
+     * \li Variant supports automatic list generation. For example a Variant
+     *     containing an int also can produce an int-list via the toIntList
+     *     method.
+     * \li toString and toStringList always return a valid list and do automatic
+     *     conversion from the actual type used in the Variant. Thus, if one only
+     *     needs to display the value in a Variant toString and toStringList 
+     *     do the job.
+     *
+     * \author Sebastian Trueg <trueg@kde.org>
+     */
+    class NEPOMUK_EXPORT Variant
+    {
+    public:
+        Variant();
+        ~Variant();
+        Variant( const Variant& other );
+
+        /**
+         * Will create an invalid Variant if other has an unsupported type.
+         */
+        explicit Variant( const QVariant& other );
+        Variant( int i );
+        Variant( qlonglong i );
+        Variant( uint i );
+        Variant( qulonglong i );
+        Variant( bool b );
+        Variant( double d );
+        Variant( const char* string );
+        Variant( const QString& string );
+        Variant( const QDate& date );
+        Variant( const QTime& time );
+        Variant( const QDateTime& datetime );
+        Variant( const QUrl& url );
+        Variant( const Resource& r );
+        Variant( const QList<int>& i );
+        Variant( const QList<qlonglong>& i );
+        Variant( const QList<uint>& i );
+        Variant( const QList<qulonglong>& i );
+        Variant( const QList<bool>& b );
+        Variant( const QList<double>& d );
+        Variant( const QStringList& stringlist );
+        Variant( const QList<QDate>& date );
+        Variant( const QList<QTime>& time );
+        Variant( const QList<QDateTime>& datetime );
+        Variant( const QList<QUrl>& url );
+        Variant( const QList<Resource>& r );
+
+        /**
+         * Create a new Variant from a list of Variants.
+         *
+         * \since 4.3
+         */
+        Variant( const QList<Variant>& vl );
+
+        Variant& operator=( const Variant& );
+        Variant& operator=( int i );
+        Variant& operator=( qlonglong i );
+        Variant& operator=( uint i );
+        Variant& operator=( qulonglong i );
+        Variant& operator=( bool b );
+        Variant& operator=( double d );
+        Variant& operator=( const QString& string );
+        Variant& operator=( const QDate& date );
+        Variant& operator=( const QTime& time );
+        Variant& operator=( const QDateTime& datetime );
+        Variant& operator=( const QUrl& url );
+        Variant& operator=( const Resource& r );
+        Variant& operator=( const QList<int>& i );
+        Variant& operator=( const QList<qlonglong>& i );
+        Variant& operator=( const QList<uint>& i );
+        Variant& operator=( const QList<qulonglong>& i );
+        Variant& operator=( const QList<bool>& b );
+        Variant& operator=( const QList<double>& d );
+        Variant& operator=( const QStringList& stringlist );
+        Variant& operator=( const QList<QDate>& date );
+        Variant& operator=( const QList<QTime>& time );
+        Variant& operator=( const QList<QDateTime>& datetime );
+        Variant& operator=( const QList<QUrl>& url );
+        Variant& operator=( const QList<Resource>& r );
+
+        /**
+         * Append \a i to this variant. If the variant already
+         * contains an int it will be converted to a list of int.
+         */
+        void append( int i );
+        void append( qlonglong i );
+        void append( uint i );
+        void append( qulonglong i );
+        void append( bool b );
+        void append( double d );
+        void append( const QString& string );
+        void append( const QDate& date );
+        void append( const QTime& time );
+        void append( const QDateTime& datetime );
+        void append( const QUrl& url );
+        void append( const Resource& r );
+
+        /**
+         * Appends the value stored in \a v to the list in this
+         * Variant. If this Variant contains a value with the same
+         * simple type as \a v they are merged into a list. Otherwise
+         * this Variant will contain one list of simple type v.simpleType()
+         */
+        void append( const Variant& v );
+
+        /**
+         * Does compare two Variant objects. single-valued lists are treated
+         * as the single value itself. For example a QStringList variant with
+         * one element "x" equals a QString variant with value "x".
+         */
+        bool operator==( const Variant& other ) const;
+
+        /**
+         * Inverse of operator==
+         */
+        bool operator!=( const Variant& other ) const;
+
+        bool isValid() const;
+                
+        /**
+         * \return the QT Meta type id of the type
+         */
+        int type() const;
+
+        /**
+         * \return the type of the simple value, i.e. with
+         * the list stripped.
+         */
+        int simpleType() const;
+
+        /**
+         * This methods does not handle all list types.
+         * It checks the following:
+         * \li QList<Resource>
+         * \li QList<int>
+         * \li QList<double>
+         * \li QList<bool>
+         * \li QList<QDate>
+         * \li QList<QTime>
+         * \li QList<QDateTime>
+         * \li QList<QUrl>
+         * \li QList<String> (QStringList)
+         */
+        bool isList() const;
+
+        bool isInt() const;
+        bool isInt64() const;
+        bool isUnsignedInt() const;
+        bool isUnsignedInt64() const;
+        bool isBool() const;
+        bool isDouble() const;
+        bool isString() const;
+        bool isDate() const;
+        bool isTime() const;
+        bool isDateTime() const;
+        bool isUrl() const;
+        bool isResource() const;
+
+        bool isIntList() const;
+        bool isInt64List() const;
+        bool isUnsignedIntList() const;
+        bool isUnsignedInt64List() const;
+        bool isBoolList() const;
+        bool isDoubleList() const;
+        bool isStringList() const;
+        bool isDateList() const;
+        bool isTimeList() const;
+        bool isDateTimeList() const;
+        bool isUrlList() const;
+        bool isResourceList() const;
+
+        QVariant variant() const;
+
+        int toInt() const;
+        qlonglong toInt64() const;
+        uint toUnsignedInt() const;
+        qulonglong toUnsignedInt64() const;
+
+        bool toBool() const;
+        double toDouble() const;
+
+        /**
+         * The toString() method is a little more powerful than other
+         * toXXX methods since it actually converts all values to string.
+         * Thus, toString should work always (even list variants are converted 
+         * to a comma-separated list)
+         *
+         * Resources are converted to a string representation of their URI.
+         */
+        QString toString() const;
+        QDate toDate() const;
+        QTime toTime() const;
+        QDateTime toDateTime() const;
+        QUrl toUrl() const;
+        Resource toResource() const;
+
+        QList<int> toIntList() const;
+        QList<qlonglong> toInt64List() const;
+        QList<uint> toUnsignedIntList() const;
+        QList<qulonglong> toUnsignedInt64List() const;
+        QList<bool> toBoolList() const;
+        QList<double> toDoubleList() const;
+
+        /**
+         * Just like the toString method toStringList is able to convert all
+         * supported types into a list of strings.
+         */
+        QStringList toStringList() const;
+        QList<QDate> toDateList() const;
+        QList<QTime> toTimeList() const;
+        QList<QDateTime> toDateTimeList() const;
+        QList<QUrl> toUrlList() const;
+        QList<Resource> toResourceList() const;
+
+        /**
+         * Convert a Variant to a list of Variants.
+         *
+         * \since 4.3
+         */
+        QList<Variant> toVariantList() const;
+
+        /**
+         * Create a Variant object by parsing string \a value based on \a type.
+         * If \a type is unknown a simple string Variant object is returned
+         * containing the plain string \a value.
+         */
+        static Variant fromString( const QString& value, int type );
+
+    private:
+        class Private;
+        Private* const d;
+    };
+}
+
+
+NEPOMUK_EXPORT QDebug operator<<( QDebug dbg, const Nepomuk::Variant& );
+
+Q_DECLARE_METATYPE(Nepomuk::Resource)
+Q_DECLARE_METATYPE(QList<Nepomuk::Resource>)
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<qlonglong>)
+Q_DECLARE_METATYPE(QList<uint>)
+Q_DECLARE_METATYPE(QList<qulonglong>)
+Q_DECLARE_METATYPE(QList<double>)
+Q_DECLARE_METATYPE(QList<bool>)
+Q_DECLARE_METATYPE(QList<QDate>)
+Q_DECLARE_METATYPE(QList<QTime>)
+Q_DECLARE_METATYPE(QList<QDateTime>)
+Q_DECLARE_METATYPE(QList<QUrl>)
+
+#endif
diff -u -r -N nepomuk/core/CMakeLists.txt nepomuk-svn/core/CMakeLists.txt
--- nepomuk/core/CMakeLists.txt	2009-01-06 18:27:42.000000000 +0100
+++ nepomuk-svn/core/CMakeLists.txt	2009-02-27 13:37:52.000000000 +0100
@@ -19,6 +19,7 @@
   variant.cpp
   resourcedata.cpp
   resourcemanager.cpp
+  resourcefiltermodel.cpp
   nepomukmainmodel.cpp
   tools.cpp
   ui/kratingwidget.cpp
diff -u -r -N nepomuk/core/graphwrapper.cpp nepomuk-svn/core/graphwrapper.cpp
--- nepomuk/core/graphwrapper.cpp	2008-11-04 18:13:09.000000000 +0100
+++ nepomuk-svn/core/graphwrapper.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -19,15 +19,33 @@
  */
 
 #include "graphwrapper_p.h"
-#include "resourcemanager.h"
 
 #include <Soprano/Model>
 #include <Soprano/Node>
+#include <Soprano/QueryResultIterator>
 #include <Soprano/Vocabulary/RDF>
 #include <Soprano/Vocabulary/NRL>
 #include <Soprano/Vocabulary/NAO>
 
 #include <QtCore/QDateTime>
+#include <QtCore/QUuid>
+#include <QtCore/QRegExp>
+
+namespace {
+    QUrl createGraphUri() {
+        return QUrl( "urn:nepomuk:local:" + QUuid::createUuid().toString().remove( QRegExp( "[\\{\\}]" ) ) );
+    }
+
+    QUrl createUniqueGraphUri( Soprano::Model* model ) {
+        while( 1 ) {
+            QUrl uri = createGraphUri();
+            if ( !model->executeQuery( QString("ask where { { <%1> ?p1 ?o1 . } UNION { ?r2 <%1> ?o2 . } UNION { ?r3 ?p3 <%1> . } }")
+                                       .arg( QString::fromAscii( uri.toEncoded() ) ), Soprano::Query::QueryLanguageSparql ).boolValue() ) {
+                return uri;
+            }
+        }
+    }
+}
 
 
 Nepomuk::GraphWrapper::GraphWrapper( QObject* parent )
@@ -45,6 +63,15 @@
 }
 
 
+void Nepomuk::GraphWrapper::setModel( Soprano::Model* model )
+{
+    if( m_model != model ) {
+        m_model = model;
+        m_currentGraph = QUrl();
+    }
+}
+
+
 QUrl Nepomuk::GraphWrapper::lookupCurrentGraph() const
 {
     return m_currentGraph;
@@ -76,32 +103,31 @@
 
 void Nepomuk::GraphWrapper::createNewGraph()
 {
-    m_currentGraph = ResourceManager::instance()->generateUniqueUri( "nepomukgraph" );
+    m_currentGraph = createUniqueGraphUri( m_model );
     m_currentGraphStored = false;
 }
 
 
 void Nepomuk::GraphWrapper::storeGraph( const QUrl& graph )
 {
-    Soprano::Model* model = ResourceManager::instance()->mainModel();
-    QUrl metadataGraph = ResourceManager::instance()->generateUniqueUri( "nepomukgraph-metadata" );
+    QUrl metadataGraph = createUniqueGraphUri( m_model );
 
-    model->addStatement( graph,
-                         Soprano::Vocabulary::RDF::type(),
-                         Soprano::Vocabulary::NRL::InstanceBase(),
-                         metadataGraph );
-    model->addStatement( graph,
-                         Soprano::Vocabulary::NAO::created(),
-                         Soprano::LiteralValue( QDateTime::currentDateTime() ),
-                         metadataGraph );
-    model->addStatement( metadataGraph,
-                         Soprano::Vocabulary::RDF::type(),
-                         Soprano::Vocabulary::NRL::GraphMetadata(),
-                         metadataGraph );
-    model->addStatement( metadataGraph,
-                         Soprano::Vocabulary::NRL::coreGraphMetadataFor(),
-                         graph,
-                         metadataGraph );
+    m_model->addStatement( graph,
+                           Soprano::Vocabulary::RDF::type(),
+                           Soprano::Vocabulary::NRL::InstanceBase(),
+                           metadataGraph );
+    m_model->addStatement( graph,
+                           Soprano::Vocabulary::NAO::created(),
+                           Soprano::LiteralValue( QDateTime::currentDateTime() ),
+                           metadataGraph );
+    m_model->addStatement( metadataGraph,
+                           Soprano::Vocabulary::RDF::type(),
+                           Soprano::Vocabulary::NRL::GraphMetadata(),
+                           metadataGraph );
+    m_model->addStatement( metadataGraph,
+                           Soprano::Vocabulary::NRL::coreGraphMetadataFor(),
+                           graph,
+                           metadataGraph );
 
     //
     // We update the graph every 200 mseconds but only when entering
diff -u -r -N nepomuk/core/graphwrapper_p.h nepomuk-svn/core/graphwrapper_p.h
--- nepomuk/core/graphwrapper_p.h	2008-11-04 18:13:09.000000000 +0100
+++ nepomuk-svn/core/graphwrapper_p.h	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -25,6 +25,10 @@
 #include <QtCore/QTimer>
 #include <QtCore/QUrl>
 
+namespace Soprano {
+    class Model;
+}
+
 namespace Nepomuk {
     /**
      * Creates a new graph whenever the event loop is entered.
@@ -62,6 +66,8 @@
          */
         QUrl currentGraph();
 
+        void setModel( Soprano::Model* model );
+
     private Q_SLOTS:
         void slotTimeout();
 
@@ -72,6 +78,8 @@
         QUrl m_currentGraph;
         bool m_currentGraphStored;
         QTimer m_timer;
+
+        Soprano::Model* m_model;
     };
 }
 
diff -u -r -N nepomuk/core/nepomukmainmodel.cpp nepomuk-svn/core/nepomukmainmodel.cpp
--- nepomuk/core/nepomukmainmodel.cpp	2008-11-04 18:13:09.000000000 +0100
+++ nepomuk-svn/core/nepomukmainmodel.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -20,7 +20,6 @@
 
 #include "nepomukmainmodel.h"
 #include "resourcemanager.h"
-#include "graphwrapper_p.h"
 
 #include <Soprano/Node>
 #include <Soprano/Statement>
@@ -51,12 +50,6 @@
 
 using namespace Soprano;
 
-namespace Soprano {
-uint qHash( const Soprano::Node& node )
-{
-    return qHash( node.toString() );
-}
-}
 
 namespace {
 class GlobalModelContainer
@@ -78,8 +71,6 @@
         delete dummyModel;
     }
 
-    Nepomuk::GraphWrapper graphWrapper;
-
     Soprano::Client::DBusClient dbusClient;
     Soprano::Client::LocalSocketClient localSocketClient;
     Soprano::Client::DBusModel* dbusModel;
@@ -253,11 +244,7 @@
 
 Soprano::Error::ErrorCode Nepomuk::MainModel::addStatement( const Statement& statement )
 {
-    Statement s( statement );
-    if( s.context().isEmpty() ) {
-        s.setContext( mainContext() );
-    }
-    Soprano::Error::ErrorCode c = modelContainer()->model()->addStatement( s );
+    Soprano::Error::ErrorCode c = modelContainer()->model()->addStatement( statement );
     setError( modelContainer()->model()->lastError() );
     return c;
 }
@@ -286,112 +273,4 @@
     return n;
 }
 
-
-QUrl Nepomuk::MainModel::mainContext()
-{
-    return modelContainer()->graphWrapper.currentGraph();
-}
-
-
-Soprano::Error::ErrorCode Nepomuk::MainModel::updateModificationDate( const QUrl& resource, const QDateTime& date )
-{
-    Error::ErrorCode c = removeAllStatements( resource, Soprano::Vocabulary::NAO::lastModified(), Soprano::Node() );
-    if ( c != Error::ErrorNone )
-        return c;
-    else
-        return addStatement( resource, Soprano::Vocabulary::NAO::lastModified(), LiteralValue( date ), mainContext() );
-}
-
-
-Soprano::Error::ErrorCode Nepomuk::MainModel::updateProperty( const QUrl& resource, const QUrl& property, const Node& value )
-{
-    if( !property.isValid() ) {
-        setError( "Cannot update invalid property", Error::ErrorInvalidArgument );
-        return Error::ErrorInvalidArgument;
-    }
-
-    StatementIterator it = listStatements( Statement( resource, property, Node() ) );
-    if ( it.next() ) {
-        Statement s = it.current();
-        it.close();
-        if ( s.object() == value ) {
-            // nothing to do. Yey!
-            return Error::ErrorNone;
-        }
-        else {
-            removeStatement( s );
-        }
-    }
-
-    // update property
-    Error::ErrorCode c = addStatement( resource, property, value, mainContext() );
-    if ( c != Error::ErrorNone )
-        return updateModificationDate( resource );
-
-    return c;
-}
-
-
-Soprano::Error::ErrorCode Nepomuk::MainModel::updateProperty( const QUrl& resource, const QUrl& property, const QList<Node>& values )
-{
-    if( !property.isValid() ) {
-        setError( "Cannot update invalid property", Error::ErrorInvalidArgument );
-        return Error::ErrorInvalidArgument;
-    }
-
-    QList<Node> existingValues = listStatements( Statement( resource, property, Node() ) ).iterateObjects().allNodes();
-
-    Error::ErrorCode c = Error::ErrorNone;
-    foreach( const Node &node, existingValues.toSet() - values.toSet() ) {
-        if ( ( c = removeAllStatements( Statement( resource, property, node ) ) ) != Error::ErrorNone ) {
-            return c;
-        }
-    }
-
-    QSet<Node> newNodes = values.toSet() - existingValues.toSet();
-    if ( !newNodes.isEmpty() ) {
-        QUrl context = mainContext();
-        foreach( const Node &node, newNodes ) {
-            if ( ( c = addStatement( Statement( resource, property, node, context ) ) ) != Error::ErrorNone ) {
-                return c;
-            }
-        }
-
-        c = updateModificationDate( resource );
-    }
-
-    return c;
-}
-
-
-Soprano::Error::ErrorCode Nepomuk::MainModel::removeProperty( const QUrl& resource, const QUrl& property )
-{
-    if( !property.isValid() ) {
-        setError( "Cannot remove invalid property", Error::ErrorInvalidArgument );
-        return Error::ErrorInvalidArgument;
-    }
-
-    Soprano::Error::ErrorCode c = removeAllStatements( Statement( resource, property, Node() ) );
-    if ( c == Soprano::Error::ErrorNone )
-        return updateModificationDate( resource );
-    else
-        return c;
-}
-
-
-Soprano::Error::ErrorCode Nepomuk::MainModel::ensureResource( const QUrl& resource, const QUrl& type )
-{
-    if ( !containsAnyStatement( Statement( resource, Vocabulary::RDF::type(), type ) ) ) {
-         Soprano::Error::ErrorCode c = addStatement( Statement( resource, Vocabulary::RDF::type(), type, mainContext() ) );
-         if ( c == Soprano::Error::ErrorNone )
-             return updateModificationDate( resource );
-         else
-             return c;
-    }
-    else {
-        clearError();
-        return Error::ErrorNone;
-    }
-}
-
 #include "nepomukmainmodel.moc"
diff -u -r -N nepomuk/core/nepomukmainmodel.h nepomuk-svn/core/nepomukmainmodel.h
--- nepomuk/core/nepomukmainmodel.h	2008-09-17 22:55:21.000000000 +0200
+++ nepomuk-svn/core/nepomukmainmodel.h	2009-02-27 13:37:52.000000000 +0100
@@ -90,54 +90,11 @@
         bool containsAnyStatement( const Soprano::Statement &statement ) const;
         bool isEmpty() const;
         int statementCount() const;
-
-        /**
-         * Adds a statement to the Model. Statements without a valid context will be
-         * added to the mainContext.
-         */
         Soprano::Error::ErrorCode addStatement( const Soprano::Statement& statement );
-
         Soprano::Error::ErrorCode removeStatement( const Soprano::Statement& statement );
         Soprano::Error::ErrorCode removeAllStatements( const Soprano::Statement& statement );
         Soprano::Node createBlankNode();
 
-        /**
-         * The Nepomuk lib uses just one context (named graph)
-         * for all statements. This makes things simpler and
-         * we do not use the context for anything else than
-         * the named graph type anyway.
-         */
-        QUrl mainContext();
-
-        /**
-         * Updates the modification date of \p resource to \p date.
-         */
-        Soprano::Error::ErrorCode updateModificationDate( const QUrl& resource, const QDateTime& date = QDateTime::currentDateTime() );
-
-        /**
-         * Update a property. This means an existing property is replaced if it differs from
-         * the provided value. Otherwise nothing is done.
-         *
-         * This method assumes that the cardinality or property is 1.
-         */
-        Soprano::Error::ErrorCode updateProperty( const QUrl& resource, const QUrl& property, const Soprano::Node& value );
-
-        /**
-         * Update a property with a cardinality > 1.
-         * This method optmizes the add and remove actions necessary.
-         */
-        Soprano::Error::ErrorCode updateProperty( const QUrl& resource, const QUrl& property, const QList<Soprano::Node>& values );
-
-        /**
-         * Remove a property from a resource and make sure no dangling graphs are left
-         */
-        Soprano::Error::ErrorCode removeProperty( const QUrl& resource, const QUrl& property );
-
-        /**
-         * Ensures that resoruce exists with type.
-         */
-        Soprano::Error::ErrorCode ensureResource( const QUrl& resource, const QUrl& type = Soprano::Vocabulary::RDFS::Resource() );
-
         using Model::addStatement;
         using Model::removeStatement;
         using Model::removeAllStatements;
diff -u -r -N nepomuk/core/ontology/.svn/all-wcprops nepomuk-svn/core/ontology/.svn/all-wcprops
--- nepomuk/core/ontology/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/all-wcprops	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,191 @@
+K 25
+svn:wc:ra_dav:version-url
+V 65
+/home/kde/!svn/ver/928345/trunk/KDE/kdelibs/nepomuk/core/ontology
+END
+ontology_p.h
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/786517/trunk/KDE/kdelibs/nepomuk/core/ontology/ontology_p.h
+END
+nepomukontologyloader.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 91
+/home/kde/!svn/ver/733256/trunk/KDE/kdelibs/nepomuk/core/ontology/nepomukontologyloader.cpp
+END
+entity_p.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/889174/trunk/KDE/kdelibs/nepomuk/core/ontology/entity_p.h
+END
+global.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/746849/trunk/KDE/kdelibs/nepomuk/core/ontology/global.cpp
+END
+fileontologyloader.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 88
+/home/kde/!svn/ver/716576/trunk/KDE/kdelibs/nepomuk/core/ontology/fileontologyloader.cpp
+END
+ontologymanager.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 85
+/home/kde/!svn/ver/874533/trunk/KDE/kdelibs/nepomuk/core/ontology/ontologymanager.cpp
+END
+ontologyloader.h
+K 25
+svn:wc:ra_dav:version-url
+V 82
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/ontologyloader.h
+END
+entitymanager.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 83
+/home/kde/!svn/ver/889174/trunk/KDE/kdelibs/nepomuk/core/ontology/entitymanager.cpp
+END
+property_p.h
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/786517/trunk/KDE/kdelibs/nepomuk/core/ontology/property_p.h
+END
+class.h
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/home/kde/!svn/ver/792121/trunk/KDE/kdelibs/nepomuk/core/ontology/class.h
+END
+ontology.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/792121/trunk/KDE/kdelibs/nepomuk/core/ontology/ontology.h
+END
+literal_p.h
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/literal_p.h
+END
+entity.h
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/home/kde/!svn/ver/871610/trunk/KDE/kdelibs/nepomuk/core/ontology/entity.h
+END
+property.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/792121/trunk/KDE/kdelibs/nepomuk/core/ontology/property.h
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 80
+/home/kde/!svn/ver/928345/trunk/KDE/kdelibs/nepomuk/core/ontology/CMakeLists.txt
+END
+desktopontologyloader.h
+K 25
+svn:wc:ra_dav:version-url
+V 89
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/desktopontologyloader.h
+END
+literal.h
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/869491/trunk/KDE/kdelibs/nepomuk/core/ontology/literal.h
+END
+ontologyloader.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 84
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/ontology/ontologyloader.cpp
+END
+global.h
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/global.h
+END
+class.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/889174/trunk/KDE/kdelibs/nepomuk/core/ontology/class.cpp
+END
+nepomukontologyloader.h
+K 25
+svn:wc:ra_dav:version-url
+V 89
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/nepomukontologyloader.h
+END
+fileontologyloader.h
+K 25
+svn:wc:ra_dav:version-url
+V 86
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/fileontologyloader.h
+END
+ontology.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/874533/trunk/KDE/kdelibs/nepomuk/core/ontology/ontology.cpp
+END
+ontologymanager.h
+K 25
+svn:wc:ra_dav:version-url
+V 83
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/ontologymanager.h
+END
+entitymanager.h
+K 25
+svn:wc:ra_dav:version-url
+V 81
+/home/kde/!svn/ver/915221/trunk/KDE/kdelibs/nepomuk/core/ontology/entitymanager.h
+END
+entity.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/915222/trunk/KDE/kdelibs/nepomuk/core/ontology/entity.cpp
+END
+README
+K 25
+svn:wc:ra_dav:version-url
+V 72
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/ontology/README
+END
+property.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/889174/trunk/KDE/kdelibs/nepomuk/core/ontology/property.cpp
+END
+class_p.h
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/786517/trunk/KDE/kdelibs/nepomuk/core/ontology/class_p.h
+END
+desktopontologyloader.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 91
+/home/kde/!svn/ver/867603/trunk/KDE/kdelibs/nepomuk/core/ontology/desktopontologyloader.cpp
+END
+literal.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/home/kde/!svn/ver/874533/trunk/KDE/kdelibs/nepomuk/core/ontology/literal.cpp
+END
diff -u -r -N nepomuk/core/ontology/.svn/entries nepomuk-svn/core/ontology/.svn/entries
--- nepomuk/core/ontology/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/entries	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,1085 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/core/ontology
+https://svn.kde.org/home/kde
+
+
+
+2009-02-19T12:46:13.650297Z
+928345
+mlaurent
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+ontology_p.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+aa3582c06491359f4c4c12d395eed043
+2008-03-17T10:01:20.925833Z
+786517
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2085
+
+nepomukontologyloader.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+ba4c995a5289f6b8d798c480ed088e5e
+2007-11-05T23:32:36.344990Z
+733256
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2375
+
+entity_p.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+45eab9eb38c82eea7912d6fc55926675
+2008-11-26T09:05:41.742119Z
+889174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2465
+
+global.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+dc6f424283c6816b05d8caf0144d168b
+2007-12-10T12:38:13.836340Z
+746849
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1319
+
+fileontologyloader.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+4c16ab4d0a772fbe3edd952069f3fb7e
+2007-09-24T22:40:01.080532Z
+716576
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2914
+
+ontologymanager.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+06736fc18719e087a78138fe5716820a
+2008-10-21T19:43:19.863776Z
+874533
+chehrlic
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+12086
+
+ontologyloader.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+25c944b15d4fd15a1ad2829e68dfb941
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1800
+
+entitymanager.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+6c0c6049c7a7de50648e2dee63199121
+2008-11-26T09:05:41.742119Z
+889174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3727
+
+property_p.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+d0cbfe7ff76d86bb0bdfbb9b8a0a50d6
+2008-03-17T10:01:20.925833Z
+786517
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2386
+
+class.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+d342d4bb3ce1a70807ff6ff8411fa64f
+2008-03-31T10:46:22.118588Z
+792121
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9195
+
+ontology.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+44614f17b15a150997d503276440e5cc
+2008-03-31T10:46:22.118588Z
+792121
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7659
+
+literal_p.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+3595506d4a7a6c7728cee44908b0673a
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1435
+
+entity.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+8a3c0a2b3d14458f94abc68de7f93c7b
+2008-10-15T09:45:01.279727Z
+871610
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6488
+
+property.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+f0ee29ea42e85eb7698e295c54a22302
+2008-03-31T10:46:22.118588Z
+792121
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9165
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+9d1458e7c520fb88a2f54860bfedcbde
+2009-02-19T12:46:13.650297Z
+928345
+mlaurent
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+312
+
+test
+dir
+
+desktopontologyloader.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+3dd3b579a94709ec1f59d47c86dc3145
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1906
+
+literal.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+99419d7be78c03939860ea690d93b0bc
+2008-10-09T08:07:23.641486Z
+869491
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3164
+
+ontologyloader.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+0acbb960d48726f0492941b0b9599789
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1097
+
+global.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+4e22190e44bf7d17f614ce01745a7f77
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1130
+
+class.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+d01a4d524d4c44d85a1233963627de74
+2008-11-26T09:05:41.742119Z
+889174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+16806
+
+nepomukontologyloader.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+7dada7fe41c7de5056d8b4249b557e15
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1466
+
+fileontologyloader.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+cc689431d9816757f403cf6e73818bff
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2598
+
+ontology.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+6a9cacbf2c18a9d1e242e921a8c297a3
+2008-10-21T19:43:19.863776Z
+874533
+chehrlic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9641
+
+ontologymanager.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+54d5edeb0cd36513067903bd45cf8767
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3076
+
+entitymanager.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+7376cedb1c1a2069885274e4efe7355a
+2009-01-22T15:29:51.621316Z
+915221
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2220
+
+entity.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+28d502ec2a79d06e0d39dd2bb2fea765
+2009-01-22T15:30:43.215353Z
+915222
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8192
+
+README
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+274e910d9ddd61319390ede0ebc0c14a
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+429
+
+property.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+afb0c46c9913fa30c5a4371d6491ceba
+2008-11-26T09:05:41.742119Z
+889174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+10765
+
+class_p.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+5d7fd5726e27b38cd88420500b87f449
+2008-03-17T10:01:20.925833Z
+786517
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2488
+
+desktopontologyloader.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+7e5e68e3ac09abf37ff881dcede35616
+2008-10-03T22:16:14.836273Z
+867603
+dfaure
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3600
+
+literal.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+60cef6da2cf95952cdb8be533122b5bd
+2008-10-21T19:43:19.863776Z
+874533
+chehrlic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4287
+
diff -u -r -N nepomuk/core/ontology/.svn/format nepomuk-svn/core/ontology/.svn/format
--- nepomuk/core/ontology/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/format	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/CMakeLists.txt.svn-base nepomuk-svn/core/ontology/.svn/prop-base/CMakeLists.txt.svn-base
--- nepomuk/core/ontology/.svn/prop-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/CMakeLists.txt.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mime-type
+V 10
+text/plain
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/desktopontologyloader.cpp.svn-base nepomuk-svn/core/ontology/.svn/prop-base/desktopontologyloader.cpp.svn-base
--- nepomuk/core/ontology/.svn/prop-base/desktopontologyloader.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/desktopontologyloader.cpp.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/desktopontologyloader.h.svn-base nepomuk-svn/core/ontology/.svn/prop-base/desktopontologyloader.h.svn-base
--- nepomuk/core/ontology/.svn/prop-base/desktopontologyloader.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/desktopontologyloader.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/fileontologyloader.cpp.svn-base nepomuk-svn/core/ontology/.svn/prop-base/fileontologyloader.cpp.svn-base
--- nepomuk/core/ontology/.svn/prop-base/fileontologyloader.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/fileontologyloader.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/fileontologyloader.h.svn-base nepomuk-svn/core/ontology/.svn/prop-base/fileontologyloader.h.svn-base
--- nepomuk/core/ontology/.svn/prop-base/fileontologyloader.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/fileontologyloader.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/global.cpp.svn-base nepomuk-svn/core/ontology/.svn/prop-base/global.cpp.svn-base
--- nepomuk/core/ontology/.svn/prop-base/global.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/global.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/global.h.svn-base nepomuk-svn/core/ontology/.svn/prop-base/global.h.svn-base
--- nepomuk/core/ontology/.svn/prop-base/global.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/global.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/nepomukontologyloader.cpp.svn-base nepomuk-svn/core/ontology/.svn/prop-base/nepomukontologyloader.cpp.svn-base
--- nepomuk/core/ontology/.svn/prop-base/nepomukontologyloader.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/nepomukontologyloader.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/nepomukontologyloader.h.svn-base nepomuk-svn/core/ontology/.svn/prop-base/nepomukontologyloader.h.svn-base
--- nepomuk/core/ontology/.svn/prop-base/nepomukontologyloader.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/nepomukontologyloader.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/ontologymanager.cpp.svn-base nepomuk-svn/core/ontology/.svn/prop-base/ontologymanager.cpp.svn-base
--- nepomuk/core/ontology/.svn/prop-base/ontologymanager.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/ontologymanager.cpp.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/prop-base/ontologymanager.h.svn-base nepomuk-svn/core/ontology/.svn/prop-base/ontologymanager.h.svn-base
--- nepomuk/core/ontology/.svn/prop-base/ontologymanager.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/prop-base/ontologymanager.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/core/ontology/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/core/ontology/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,18 @@
+project(nepomukcore_onto)
+
+install(FILES
+  entity.h
+  class.h
+  property.h
+  ontology.h
+  literal.h
+  ontologymanager.h
+  ontologyloader.h
+  nepomukontologyloader.h
+  fileontologyloader.h
+  desktopontologyloader.h
+  global.h
+  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
+)
+
+add_subdirectory(test)
diff -u -r -N nepomuk/core/ontology/.svn/text-base/README.svn-base nepomuk-svn/core/ontology/.svn/text-base/README.svn-base
--- nepomuk/core/ontology/.svn/text-base/README.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/README.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,9 @@
+Konto provides a slightly simplified view on ontologies defined using the NRL 
+ontology description language.
+
+Konto provides three classes: Konto::Ontology, Konto::Class, and Konto::Property
+whiche can be used to explore an ontology including internationalized names and
+comments if available.
+
+The ontologies are read from the Nepomuk RDF data store or the default ontology
+installation folder (see OntologyLoader subclasses).
diff -u -r -N nepomuk/core/ontology/.svn/text-base/class.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/class.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/class.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/class.cpp.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,594 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "class.h"
+#include "class_p.h"
+#include "ontology.h"
+#include "resourcemanager.h"
+#include "property.h"
+#include "entitymanager.h"
+
+#include <QtCore/QList>
+
+#include <kdebug.h>
+
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Model>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/RDFS>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/OWL>
+
+#undef D
+#define D static_cast<Nepomuk::Types::ClassPrivate*>( d.data() )
+
+Nepomuk::Types::ClassPrivate::ClassPrivate( const QUrl& uri )
+    : EntityPrivate( uri ),
+      propertiesAvailable( uri.isValid() ? -1 : 0 )
+{
+}
+
+
+bool Nepomuk::Types::ClassPrivate::load()
+{
+    //
+    // Nearly all here can be done in a very clean way. There is only
+    // one special case: rdfs:Resource, the base class of them all
+    //
+    if ( EntityPrivate::load() ) {
+        // undefined super class means that we are derived from rdfs:Resource directly
+        if ( parents.isEmpty() ) {
+            if ( uri != Soprano::Vocabulary::RDFS::Resource() ) {
+                parents += Soprano::Vocabulary::RDFS::Resource();
+            }
+        }
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+
+bool Nepomuk::Types::ClassPrivate::loadAncestors()
+{
+    //
+    // Nearly all here can be done in a very clean way. There is only
+    // one special case: rdfs:Resource, the base class of them all
+    //
+    if ( uri == Soprano::Vocabulary::RDFS::Resource() ) {
+        //
+        // All classes that do not explicetely state a superclass are
+        // derived from rdfs:Resource. This query selects those classes
+        // (might fail on redland though)
+        //
+        Soprano::QueryResultIterator it
+            = ResourceManager::instance()->mainModel()->executeQuery( QString("select distinct ?s where { "
+                                                                              "{ ?s a <%1> . } UNION { ?s a <%2> . } "
+                                                                              "OPTIONAL { ?s <%3> ?ss . } . "
+                                                                              "FILTER(!BOUND(?ss)) . }")
+                                                                      .arg( Soprano::Vocabulary::RDFS::Class().toString() )
+                                                                      .arg( Soprano::Vocabulary::OWL::Class().toString() )
+                                                                      .arg( Soprano::Vocabulary::RDFS::subClassOf().toString() ),
+                                                                      Soprano::Query::QueryLanguageSparql );
+        bool success = false;
+        while ( it.next() ) {
+            success = true;
+            QUrl resUri = it.binding( "s" ).uri();
+            if ( resUri != Soprano::Vocabulary::RDFS::Resource() ) {
+                children.append( resUri );
+            }
+        }
+    }
+
+    return EntityPrivate::loadAncestors();
+}
+
+
+bool Nepomuk::Types::ClassPrivate::addProperty( const QUrl& property, const Soprano::Node& value )
+{
+    if( property == Soprano::Vocabulary::RDFS::subClassOf() ) {
+        parents.append( Class( value.uri() ) );
+        return true;
+    }
+
+    return false;
+}
+
+
+bool Nepomuk::Types::ClassPrivate::addAncestorProperty( const QUrl& ancestorResource, const QUrl& property )
+{
+    if ( property == Soprano::Vocabulary::RDFS::subClassOf() ) {
+        children.append( Class( ancestorResource ) );
+        return true;
+    }
+
+    return false;
+}
+
+
+void Nepomuk::Types::ClassPrivate::initProperties()
+{
+    QMutexLocker lock( &mutex );
+
+    if ( propertiesAvailable < 0 ) {
+        propertiesAvailable = loadProperties() ? 1 : 0;
+    }
+}
+
+
+bool Nepomuk::Types::ClassPrivate::loadProperties()
+{
+    // load domains with a hack to get at least a subset of properties that inherit their domain from parents
+    Soprano::QueryResultIterator it
+        = ResourceManager::instance()->mainModel()->executeQuery( QString("select ?p where { "
+                                                                          "{ ?p <%1> <%2> . } "
+                                                                          "UNION "
+                                                                          "{ ?p <%3> ?p1 . "
+                                                                          "OPTIONAL { ?p <%1> ?undefdom . } . "
+                                                                          "?p1 <%1> <%2> . "
+                                                                          "FILTER(!bound(?undefdom)) . } "
+                                                                          "UNION "
+                                                                          "{ ?p <%3> ?p1 . "
+                                                                          "OPTIONAL { ?p <%1> ?undefdom1 . } . "
+                                                                          "?p1 <%3> ?p2 . "
+                                                                          "OPTIONAL { ?p1 <%1> ?undefdom2 . } . "
+                                                                          "?p2 <%1> <%2> . "
+                                                                          "FILTER(!bound(?undefdom1) && !bound(?undefdom2)) . } "
+                                                                          "}")
+                                                                  .arg( Soprano::Vocabulary::RDFS::domain().toString() )
+                                                                  .arg( QString::fromAscii( uri.toEncoded() ) )
+                                                                  .arg( Soprano::Vocabulary::RDFS::subPropertyOf().toString() ),
+                                                                  Soprano::Query::QueryLanguageSparql );
+
+    // redland cannot handle UNION queries! So fallback to the "old" query
+    if( it.lastError() ) {
+        it = ResourceManager::instance()->mainModel()->executeQuery( QString("select ?p where { "
+                                                                             "?p <%1> <%2> . }")
+                                                                     .arg( Soprano::Vocabulary::RDFS::domain().toString() )
+                                                                     .arg( QString::fromAscii( uri.toEncoded() ) ),
+                                                                     Soprano::Query::QueryLanguageSparql );
+    }
+
+    bool success = false;
+    while ( it.next() ) {
+        success = true;
+        domainOf.append( Property( it.binding( "p" ).uri() ) );
+    }
+
+
+    // load ranges
+    it = ResourceManager::instance()->mainModel()->executeQuery( QString("select ?p where { "
+                                                                          "?p <%1> <%2> . }")
+                                                                  .arg( Soprano::Vocabulary::RDFS::range().toString() )
+                                                                 .arg( QString::fromAscii( uri.toEncoded() ) ),
+                                                                  Soprano::Query::QueryLanguageSparql );
+    while ( it.next() ) {
+        success = true;
+        rangeOf.append( Property( it.binding( "p" ).uri() ) );
+    }
+
+    return success;
+}
+
+
+void Nepomuk::Types::ClassPrivate::reset( bool recursive )
+{
+    EntityPrivate::reset( recursive );
+
+    QMutexLocker lock( &mutex );
+
+    if ( propertiesAvailable != -1 ) {
+        if ( recursive ) {
+            foreach( Property p, domainOf ) {
+                p.reset( true );
+            }
+            foreach( Property p, rangeOf ) {
+                p.reset( true );
+            }
+        }
+
+        domainOf.clear();
+        rangeOf.clear();
+        propertiesAvailable = -1;
+    }
+
+    if ( available != -1 ) {
+        if ( recursive ) {
+            foreach( Class c, parents ) {
+                c.reset( true );
+            }
+        }
+        parents.clear();
+        available = -1;
+    }
+
+    if ( ancestorsAvailable != -1 ) {
+        if ( recursive ) {
+            foreach( Class c, children ) {
+                c.reset( true );
+            }
+        }
+        children.clear();
+        ancestorsAvailable = -1;
+    }
+}
+
+
+QSet<Nepomuk::Types::Class> Nepomuk::Types::ClassPrivate::findParentClasses( ClassPrivate* requestingClass )
+{
+    QSet<Class> allParents;
+
+    for ( QList<Class>::iterator it = parents.begin(); it != parents.end(); ++it ) {
+        ClassPrivate* p = static_cast<Nepomuk::Types::ClassPrivate*>( it->d.data() );
+        if ( p != requestingClass ) {
+            p->init();
+            allParents += p->findParentClasses( requestingClass );
+            allParents += *it;
+        }
+    }
+
+    return allParents;
+}
+
+
+QSet<Nepomuk::Types::Class> Nepomuk::Types::ClassPrivate::findSubClasses( ClassPrivate* requestingClass )
+{
+    QSet<Class> allChildren;
+
+    for ( QList<Class>::iterator it = children.begin(); it != children.end(); ++it ) {
+        ClassPrivate* p = static_cast<Nepomuk::Types::ClassPrivate*>( it->d.data() );
+        if ( p != requestingClass ) {
+            p->initAncestors();
+            allChildren += p->findSubClasses( requestingClass );
+            allChildren += *it;
+        }
+    }
+
+    return allChildren;
+}
+
+
+
+Nepomuk::Types::Class::Class()
+    : Entity()
+{
+    d = 0;
+}
+
+
+Nepomuk::Types::Class::Class( const QUrl& uri )
+    : Entity()
+{
+    d = EntityManager::self()->getClass( uri );
+}
+
+
+Nepomuk::Types::Class::Class( const Class& other )
+    : Entity( other )
+{
+}
+
+
+Nepomuk::Types::Class::~Class()
+{
+}
+
+
+Nepomuk::Types::Class& Nepomuk::Types::Class::operator=( const Class& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+QList<Nepomuk::Types::Property> Nepomuk::Types::Class::rangeOf()
+{
+    if ( d ) {
+        D->initProperties();
+        return D->rangeOf;
+    }
+    else {
+        return QList<Nepomuk::Types::Property>();
+    }
+}
+
+
+QList<Nepomuk::Types::Property> Nepomuk::Types::Class::domainOf()
+{
+    if ( d ) {
+        D->initProperties();
+        return D->domainOf;
+    }
+    else {
+        return QList<Nepomuk::Types::Property>();
+    }
+}
+
+
+Nepomuk::Types::Property Nepomuk::Types::Class::findPropertyByName( const QString& name )
+{
+    if ( d ) {
+        D->initProperties();
+        for ( QList<Property>::const_iterator it = D->domainOf.constBegin();
+              it != D->domainOf.constEnd(); ++it ) {
+            const Property& p = *it;
+            if ( p.name() == name ) {
+                return p;
+            }
+        }
+    }
+
+    return Property();
+}
+
+
+Nepomuk::Types::Property Nepomuk::Types::Class::findPropertyByLabel( const QString& label, const QString& language )
+{
+    if ( d ) {
+        D->initProperties();
+        for ( QList<Property>::iterator it = D->domainOf.begin();
+              it != D->domainOf.end(); ++it ) {
+            Property& p = *it;
+            if ( p.label( language ) == label ) {
+                return p;
+            }
+        }
+    }
+
+    return Property();
+}
+
+
+QList<Nepomuk::Types::Class> Nepomuk::Types::Class::parentClasses()
+{
+    if ( d ) {
+        D->init();
+        return D->parents;
+    }
+    else {
+        return QList<Nepomuk::Types::Class>();
+    }
+}
+
+
+QList<Nepomuk::Types::Class> Nepomuk::Types::Class::subClasses()
+{
+    if ( d ) {
+        D->initAncestors();
+        return D->children;
+    }
+    else {
+        return QList<Nepomuk::Types::Class>();
+    }
+}
+
+
+QList<Nepomuk::Types::Class> Nepomuk::Types::Class::allParentClasses()
+{
+    if ( d ) {
+        D->init();
+        return D->findParentClasses( D ).toList();
+    }
+    else {
+        return QList<Nepomuk::Types::Class>();
+    }
+}
+
+
+QList<Nepomuk::Types::Class> Nepomuk::Types::Class::allSubClasses()
+{
+    if ( d ) {
+        D->initAncestors();
+        return D->findSubClasses( D ).toList();
+    }
+    else {
+        return QList<Nepomuk::Types::Class>();
+    }
+}
+
+
+bool Nepomuk::Types::Class::isParentOf( const Class& other )
+{
+    if ( d ) {
+        D->initAncestors();
+
+        if ( D->children.contains( other ) ) {
+            return true;
+        }
+        else {
+            for ( QList<Nepomuk::Types::Class>::iterator it = D->children.begin();
+                  it != D->children.end(); ++it ) {
+                if ( ( *it ).isParentOf( other ) ) {
+                    return true;
+                }
+            }
+        }
+    }
+
+    return false;
+}
+
+
+bool Nepomuk::Types::Class::isSubClassOf( const Class& other )
+{
+    if ( d ) {
+        D->init();
+
+        if ( D->parents.contains( other ) ) {
+            return true;
+        }
+        else {
+            for ( QList<Nepomuk::Types::Class>::iterator it = D->parents.begin();
+                  it != D->parents.end(); ++it ) {
+                if ( ( *it ).isSubClassOf( other ) ) {
+                    return true;
+                }
+            }
+        }
+    }
+
+    return false;
+}
+
+
+
+
+// Start of code for deprecated Class
+// ----------------------------------
+
+#include "global.h"
+#include "ontologymanager.h"
+
+Nepomuk::Class::Class()
+    : Entity()
+{
+    d = new Private();
+}
+
+
+Nepomuk::Class::Class( const Class& other )
+    : Entity( other )
+{
+    d = other.d;
+}
+
+
+Nepomuk::Class::~Class()
+{
+}
+
+
+Nepomuk::Class& Nepomuk::Class::operator=( const Class& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+QList<const Nepomuk::Property*> Nepomuk::Class::allProperties() const
+{
+    return d->domainOf.values();
+}
+
+
+const Nepomuk::Property* Nepomuk::Class::findPropertyByName( const QString& name ) const
+{
+    for ( QHash<QUrl, const Property*>::const_iterator it = d->domainOf.constBegin();
+          it != d->domainOf.constEnd(); ++it ) {
+        const Property* p = it.value();
+        if ( p->name() == name ) {
+            return p;
+        }
+    }
+
+    return 0;
+}
+
+
+const Nepomuk::Property* Nepomuk::Class::findPropertyByLabel( const QString& label, const QString& language ) const
+{
+    for ( QHash<QUrl, const Property*>::const_iterator it = d->domainOf.constBegin();
+          it != d->domainOf.constEnd(); ++it ) {
+        const Property* p = it.value();
+        if ( p->label( language ) == label ) {
+            return p;
+        }
+    }
+
+    return 0;
+}
+
+
+const Nepomuk::Property* Nepomuk::Class::findPropertyByUri( const QUrl& uri ) const
+{
+    QHash<QUrl, const Property*>::const_iterator it = d->domainOf.find( uri );
+    if ( it != d->domainOf.constEnd() ) {
+        return it.value();
+    }
+    else {
+        return 0;
+    }
+}
+
+
+QList<const Nepomuk::Class*> Nepomuk::Class::parentClasses() const
+{
+    return d->parents;
+}
+
+
+QList<const Nepomuk::Class*> Nepomuk::Class::subClasses() const
+{
+    return d->children;
+}
+
+
+bool Nepomuk::Class::isParentOf( const Class* other ) const
+{
+    if ( d->children.contains( other ) ) {
+        return true;
+    }
+    else {
+        for ( QList<const Nepomuk::Class*>::const_iterator it = d->children.constBegin();
+              it != d->children.constEnd(); ++it ) {
+            if ( ( *it )->isParentOf( other ) ) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
+
+
+bool Nepomuk::Class::isSubClassOf( const Class* other ) const
+{
+    if ( d->parents.contains( other ) ) {
+        return true;
+    }
+    else {
+        for ( QList<const Nepomuk::Class*>::const_iterator it = d->parents.constBegin();
+              it != d->parents.constEnd(); ++it ) {
+            if ( ( *it )->isSubClassOf( other ) ) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
+
+
+const Nepomuk::Class* Nepomuk::Class::load( const QUrl& uri )
+{
+    Q_ASSERT( !uri.isEmpty() );
+
+    QUrl ns = extractNamespace( uri );
+
+    // load the ontology in the cache
+    const Ontology* ont = OntologyManager::instance()->getOntology( ns );
+
+    // return the requested class or an invalid one if the ontology
+    // was not found
+    if ( ont ) {
+        return ont->findClassByUri( uri );
+    }
+    else {
+        return 0;
+    }
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/class.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/class.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/class.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/class.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,277 @@
+/* This file is part of the Nepomuk-KDE libraries
+   Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_CLASS_H_
+#define _NEPOMUK_CLASS_H_
+
+#include <QtCore/QList>
+#include <QtCore/QUrl>
+#include <QtCore/QString>
+#include <QtCore/QSharedData>
+
+#include "entity.h"
+#include "nepomuk_export.h"
+
+
+namespace Nepomuk {
+    namespace Types {
+        class Property;
+
+        /**
+         * \class Class class.h Nepomuk/Types/Class
+         *
+         * \brief A Class is a resource of type rdf:Class.
+         *
+         * Class instances are explicitly shared. Two instances created
+         * with the same uri reference the same data.
+         *
+         * While Resource objects can be changed Class instances are considered
+         * to be static and never changed during their lifetime.
+         *
+         * \author Sebastian Trueg <trueg@kde.org>
+         */ 
+        class NEPOMUK_EXPORT Class : public Entity
+        {
+            friend class ClassPrivate;
+            
+        public:
+            /**
+             * Default constructor. Creates an empty Class.
+             */
+            Class();
+
+            /**
+             * Create the class referred to by \p uri.
+             * The result is either a valid class which could be loaded from the
+             * Nepomuk store or a simple class which only contains the uri.
+             *
+             * Be aware that the data is only loaded once read.
+             *
+             * Subsequent calls result in a simple hash lookup of cached data.
+             */
+            Class( const QUrl& uri );
+
+            /**
+             * Default copy constructor
+             */
+            Class( const Class& );
+
+            /**
+             * Destructor
+             */
+            ~Class();
+
+            /**
+             * Copy operator.
+             */
+            Class& operator=( const Class& );
+
+            /**
+             * A Property has a certain range which is a Class or a Literal.
+             * \return A list of all properties that have this Class as a range.
+             * \sa Property::range()
+             */
+            QList<Property> rangeOf();
+
+            /**
+             * A Property has a certain domain which is a Class.
+             * \return A list of all properties that have this Class as a domain.
+             * \sa Property::domain()
+             */
+            QList<Property> domainOf();
+
+            /**
+             * Search for a property in the class by its name.
+             * \param name The name of the property.
+             * \return the Property object identified by name or an invalid property if it could not be found.
+             */ 
+            Property findPropertyByName( const QString& name );
+
+            /**
+             * Search for a property in the class by its label.
+             * \param label The label of the property (i.e. rdfs:label)
+             * \param language The language in which the label was specified. If empty the default rdfs:label
+             * is returned.
+             * \return the Property object identified by label or an invalid property if it could not be found.
+             */ 
+            Property findPropertyByLabel( const QString& label, const QString& language = QString() );
+
+            /**
+             * Each class can have multiple parent classes. This method
+             * provides a list of all direct parents.
+             * \return A list of all parent classes of this class.
+             * If the list is emppty it means that the class has no direct
+             * parents, i.e. it is derived from rdf:Resource.
+             * \sa allParentClasses()
+             */
+            QList<Class> parentClasses();
+
+            /**
+             * \return A list of all classes that have this class as a parent.
+             * Be aware that this list can never be final since other ontologies
+             * that have not been loaded yet may contain classes that are derived
+             * from this class.
+             */
+            QList<Class> subClasses();
+
+            /**
+             * Recursively determines all parent classes of this class, not
+             * only the direct ones.
+             * \return A list of parent classes of this class.
+             * \sa parentClasses()
+             */
+            QList<Class> allParentClasses();
+
+            /**
+             * Recursively determines all sub classes of this class, not
+             * only the direct ones.
+             * \return A list of sub classes of this class.
+             * \sa subClasses()
+             */
+            QList<Class> allSubClasses();
+
+            /**
+             * Check if a class inherits this class. This is a recursive method which
+             * does not only check direct child classes.
+             *
+             * \return true if other is derived from this class, false otherwise.
+             */
+            bool isParentOf( const Class& other );
+
+            /**
+             * Check if this class is derived from another class. This is a recursive method which
+             * does not only check direct child classes.
+             *
+             * \return true if this class is derived from other, false otherwise.
+             */
+            bool isSubClassOf( const Class& other );
+        };
+    }
+}
+
+
+namespace Nepomuk {
+
+    class Ontology;
+    class Property;
+
+    /**
+     * A Class is a resource of type rdf:Class.
+     *
+     * \deprecated in favor of Nepomuk::Types::Class
+     */ 
+    class KDE_DEPRECATED NEPOMUK_EXPORT Class : public Entity
+    {
+    public:
+	/**
+	 * Default constructor. Creates an empty Class.
+	 */
+	Class();
+
+	/**
+	 * Default copy constructor
+	 */
+	Class( const Class& );
+
+	/**
+	 * Destructor
+	 */
+	~Class();
+
+	Class& operator=( const Class& );
+
+	// an alternative would be: QList<Property> rangeOf() and QList<Property> domainOf()
+	QList<const Property*> allProperties() const;
+
+	/**
+	 * Search for a property in the class by its name.
+	 * \param name The name of the property.
+	 * \return the Property object identified by name or 0 if the property could not be found.
+	 */ 
+	const Property* findPropertyByName( const QString& name ) const;
+
+	/**
+	 * Search for a property in the class by its label.
+	 * \param label The label of the property (i.e. rdfs:label)
+	 * \param language The language in which the label was specified. If empty the default rdfs:label
+	 * is returned.
+	 * \return the Property object identified by label or 0 if the property could not be found.
+	 */ 
+	const Property* findPropertyByLabel( const QString& label, const QString& language = QString() ) const;
+
+	/**
+	 * Search for a property in the class by its name.
+	 * \param uri the URI of the property
+	 * \return the Property object identified by uri or 0 if the property could not be found.
+	 */ 
+	const Property* findPropertyByUri( const QUrl& uri ) const;
+
+	/**
+	 * Each class can have multiple parent classes.
+	 * \return A list of all parent classes of this class.
+	 * If the list is emppty it means that the class has no direct
+	 * parents, i.e. it is derived from rdf:Resource.
+	 */
+	QList<const Class*> parentClasses() const;
+
+	/**
+	 * \return A list of all classes that have this class as a parent.
+	 * Be aware that this list can never be final since other ontologies
+	 * that have not been loaded yet may contain classes that are derived
+	 * from this class.
+	 */
+	QList<const Class*> subClasses() const;
+
+	/**
+	 * Check if a class inherits this class. This is a recursive method which
+	 * does not only check direct child classes.
+	 *
+	 * \return true if other is derived from this class, false otherwise.
+	 */
+	bool isParentOf( const Class* other ) const;
+
+	/**
+	 * Check if this class is derived from another class. This is a recursive method which
+	 * does not only check direct child classes.
+	 *
+	 * \return true if this class is derived from other, false otherwise.
+	 */
+	bool isSubClassOf( const Class* other ) const;
+
+	/**
+	 * Loads a class actually including the whole ontology
+	 * it is declared in.
+	 *
+	 * Dependancies are resolved automatically if possible.
+	 *
+	 * \return A Class object representing the class identified
+	 * by uri or an invalid Class object if the resource identified
+	 * by uri is either not a class or does not exist.
+	 */
+	static const Class* load( const QUrl& uri );
+
+    private:
+	class Private;
+	QSharedDataPointer<Private> d;
+
+	friend class OntologyManager;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/class_p.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/class_p.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/class_p.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/class_p.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,84 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_CLASS_PRIVATE_H_
+#define _NEPOMUK_CLASS_PRIVATE_H_
+
+#include "entity_p.h"
+#include "class.h"
+#include "property.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QSharedData>
+
+
+namespace Nepomuk {
+    namespace Types {
+        class ClassPrivate : public EntityPrivate
+        {
+        public:
+            ClassPrivate( const QUrl& uri = QUrl() );
+
+            QList<Property> domainOf;
+            QList<Property> rangeOf;
+
+            QList<Class> parents;
+            QList<Class> children;
+
+            // -1 - unknown
+            // 0  - no
+            // 1  - yes
+            int propertiesAvailable;
+
+            bool addProperty( const QUrl& property, const Soprano::Node& value );
+            bool addAncestorProperty( const QUrl& ancestorResource, const QUrl& property );
+
+            void initProperties();
+            bool loadProperties();
+
+            void reset( bool recursive );
+
+            // recursively find all parent or sub classes but stop at requestingClass to avoid endless loops
+            QSet<Class> findParentClasses( ClassPrivate* requestingClass );
+            QSet<Class> findSubClasses( ClassPrivate* requestingClass );
+
+        protected:
+            virtual bool load();
+            virtual bool loadAncestors();
+        };
+    }
+}
+
+
+namespace Nepomuk {
+
+    class Property;
+    
+    class Class::Private : public QSharedData
+    {
+    public:
+        QHash<QUrl, const Property*> domainOf;
+        QHash<QUrl, const Property*> rangeOf;
+
+        QList<const Nepomuk::Class*> parents;
+        QList<const Nepomuk::Class*> children;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/desktopontologyloader.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/desktopontologyloader.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/desktopontologyloader.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/desktopontologyloader.cpp.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,114 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "desktopontologyloader.h"
+#include "fileontologyloader.h"
+
+#include <kstandarddirs.h>
+#include <kdesktopfile.h>
+#include <kconfiggroup.h>
+#include <kdebug.h>
+#include <kglobal.h>
+
+#include <QtCore/QDir>
+
+#include <soprano/statement.h>
+
+struct OntoBuffer
+{
+    QString fileName;
+    Soprano::RdfSerialization serialization;
+};
+
+
+class Nepomuk::DesktopOntologyLoader::Private
+{
+public:
+    Private() {
+    }
+
+    void updateOntologyCache() {
+//        ontoCache.clear();
+
+        QStringList allOntologies = KGlobal::dirs()->findAllResources( "data", "nepomuk/ontologies/*.desktop" );
+        foreach( const QString &ontoDesktopFilePath, allOntologies ) {
+            KDesktopFile ontoDesktopFile( ontoDesktopFilePath );
+
+            if ( ontoDesktopFile.hasLinkType() ) {
+                QUrl uri = ontoDesktopFile.readUrl();
+
+                if ( !ontoCache.contains( uri ) ) {
+                    QString path = ontoDesktopFile.readPath();
+
+                    // make it an absolute path
+                    if ( path[0] != QDir::separator() ) {
+                        path.prepend( ontoDesktopFilePath.section( QDir::separator(),
+                                                                   0, -2,
+                                                                   QString::SectionIncludeLeadingSep|QString::SectionIncludeTrailingSep ) );
+                    }
+
+                    OntoBuffer onto;
+                    onto.fileName = path;
+                    onto.serialization = Soprano::mimeTypeToSerialization( ontoDesktopFile.desktopGroup().readEntry( "MimeType", "application/rdf+xml" ) );
+
+                    kDebug() << "(Nepomuk::DesktopOntologyLoader) found ontology " << uri;
+                    ontoCache.insert( uri, onto );
+                }
+            }
+        }
+    }
+
+    // contains the filename for each cached ontology
+    QHash<QUrl, OntoBuffer> ontoCache;
+};
+
+
+Nepomuk::DesktopOntologyLoader::DesktopOntologyLoader()
+    : OntologyLoader(),
+      d( new Private() )
+{
+}
+
+
+Nepomuk::DesktopOntologyLoader::~DesktopOntologyLoader()
+{
+    delete d;
+}
+
+
+QList<QUrl> Nepomuk::DesktopOntologyLoader::allOntologies()
+{
+    d->updateOntologyCache();
+    return d->ontoCache.keys();
+}
+
+
+QList<Soprano::Statement> Nepomuk::DesktopOntologyLoader::loadOntology( const QUrl& url )
+{
+    d->updateOntologyCache();
+    if ( d->ontoCache.contains( url ) ) {
+        const OntoBuffer& onto = d->ontoCache[url];
+        FileOntologyLoader loader( onto.fileName, onto.serialization );
+        return loader.loadOntology( url );
+    }
+    else {
+        kDebug() << "(Nepomuk::DesktopOntologyLoader) could not find ontology " << url;
+        return QList<Soprano::Statement>();
+    }
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/desktopontologyloader.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/desktopontologyloader.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/desktopontologyloader.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/desktopontologyloader.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,62 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_DESKTOP_ONTOLOGY_LOADER_H_
+#define _NEPOMUK_DESKTOP_ONTOLOGY_LOADER_H_
+
+#include "ontologyloader.h"
+#include "nepomuk_export.h"
+
+#include <QtCore/QUrl>
+#include <QtCore/QList>
+
+namespace Nepomuk {
+    /**
+     * The DesktopOntologyLoader reads ontologies from the installed
+     * ontologies on the desktop using KStandardDirs.
+     * All possible ontology installation folders are searched for
+     * ontology desktop files.
+     *
+     * \deprecated Ontologies should now be handled using the classes
+     * in the Nepomuk::Types namespace.
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT DesktopOntologyLoader : public OntologyLoader
+    {
+    public:
+	DesktopOntologyLoader();
+	~DesktopOntologyLoader();
+
+	/**
+	 * Get a list of all ontology URIs that could be found
+	 * on the system.
+	 */
+	QList<QUrl> allOntologies();
+
+	/**
+	 * reimplemented from OntologyLoader
+	 */
+	QList<Soprano::Statement> loadOntology( const QUrl& url );
+
+    private:
+	class Private;
+	Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/entity.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/entity.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/entity.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/entity.cpp.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,341 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "entity.h"
+#include "entity_p.h"
+#include "resourcemanager.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QMutexLocker>
+
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Model>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/NAO>
+#include <Soprano/Vocabulary/RDFS>
+
+#include <kicon.h>
+
+
+Nepomuk::Types::EntityPrivate::EntityPrivate( const QUrl& uri_ )
+    : uri( uri_ ),
+      available( uri_.isValid() ? -1 : 0 ),
+      ancestorsAvailable( uri_.isValid() ? -1 : 0 )
+{
+}
+
+
+void Nepomuk::Types::EntityPrivate::init()
+{
+    QMutexLocker lock( &mutex );
+
+    if ( available < 0 ) {
+        available = load() ? 1 : 0;
+    }
+}
+
+
+void Nepomuk::Types::EntityPrivate::initAncestors()
+{
+    QMutexLocker lock( &mutex );
+
+    if ( ancestorsAvailable < 0 ) {
+        ancestorsAvailable = loadAncestors() ? 1 : 0;
+    }
+}
+
+
+bool Nepomuk::Types::EntityPrivate::load()
+{
+    Soprano::QueryResultIterator it
+        = ResourceManager::instance()->mainModel()->executeQuery( QString("select ?p ?o where { "
+                                                                          "graph ?g { <%1> ?p ?o . } . "
+                                                                          "{ ?g a <%2> . } UNION { ?g a <%3> . } . }")
+                                                                  .arg( QString::fromAscii( uri.toEncoded() ) )
+                                                                  .arg( Soprano::Vocabulary::NRL::Ontology().toString() )
+                                                                  .arg( Soprano::Vocabulary::NRL::KnowledgeBase().toString() ),
+                                                                  Soprano::Query::QueryLanguageSparql );
+    bool success = false;
+    while ( it.next() ) {
+        success = true;
+        QUrl property = it.binding( "p" ).uri();
+        Soprano::Node value = it.binding( "o" );
+
+        if ( property == Soprano::Vocabulary::RDFS::label() ) {
+            if ( value.language().isEmpty() ) {
+                label = value.toString();
+            }
+            else {
+                l10nLabels[value.language()] = value.toString();
+            }
+        }
+
+        else if ( property == Soprano::Vocabulary::RDFS::comment() ) {
+            if ( value.language().isEmpty() ) {
+                comment = value.toString();
+            }
+            else {
+                l10nComments[value.language()] = value.toString();
+            }
+        }
+
+        else if ( property == Soprano::Vocabulary::NAO::hasSymbol() ) {
+            icon = KIcon( value.toString() );
+        }
+
+        else {
+            addProperty( property, value );
+        }
+    }
+
+    return success;
+}
+
+
+bool Nepomuk::Types::EntityPrivate::loadAncestors()
+{
+    Soprano::QueryResultIterator it
+        = ResourceManager::instance()->mainModel()->executeQuery( QString("select ?s ?p where { "
+                                                                          "graph ?g { ?s ?p <%1> . } . "
+                                                                          "{ ?g a <%2> . } UNION { ?g a <%3> . } . }")
+                                                                  .arg( QString::fromAscii( uri.toEncoded() ) )
+                                                                  .arg( Soprano::Vocabulary::NRL::Ontology().toString() )
+                                                                  .arg( Soprano::Vocabulary::NRL::KnowledgeBase().toString() ),
+                                                                  Soprano::Query::QueryLanguageSparql );
+    bool success = false;
+    while ( it.next() ) {
+        success = true;
+        addAncestorProperty( it.binding( "s" ).uri(), it.binding( "p" ).uri() );
+    }
+
+    return success;
+}
+
+
+
+void Nepomuk::Types::EntityPrivate::reset( bool )
+{
+    QMutexLocker lock( &mutex );
+
+    QString label;
+    QString comment;
+    l10nLabels.clear();
+    l10nComments.clear();;
+
+    icon = QIcon();
+
+    available = -1;
+    ancestorsAvailable = -1;
+}
+
+
+Nepomuk::Types::Entity::Entity()
+{
+}
+
+
+Nepomuk::Types::Entity::Entity( const Entity& other )
+{
+    d = other.d;
+}
+
+
+Nepomuk::Types::Entity::~Entity()
+{
+}
+
+
+Nepomuk::Types::Entity& Nepomuk::Types::Entity::operator=( const Entity& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+QUrl Nepomuk::Types::Entity::uri() const
+{
+    return d ? d->uri : QUrl();
+}
+
+
+QString Nepomuk::Types::Entity::name() const
+{
+    return d ? d->uri.fragment() : QString();
+}
+
+
+QString Nepomuk::Types::Entity::label( const QString& language )
+{
+    if ( d ) {
+        d->init();
+
+        QHash<QString, QString>::const_iterator it = d->l10nLabels.constFind( language );
+        if ( it != d->l10nLabels.constEnd() ) {
+            return it.value();
+        }
+        else if( !d->label.isEmpty() ) {
+            return d->label;
+        }
+        else {
+            return name();
+        }
+    }
+    else {
+        return QString();
+    }
+}
+
+
+QString Nepomuk::Types::Entity::comment( const QString& language )
+{
+    if ( d ) {
+        d->init();
+
+        QHash<QString, QString>::const_iterator it = d->l10nComments.constFind( language );
+        if ( it != d->l10nComments.constEnd() ) {
+            return it.value();
+        }
+        else {
+            return d->comment;
+        }
+    }
+    else {
+        return QString();
+    }
+}
+
+
+QIcon Nepomuk::Types::Entity::icon()
+{
+    if ( d ) {
+        d->init();
+
+        return d->icon;
+    }
+    else {
+        return QIcon();
+    }
+}
+
+
+bool Nepomuk::Types::Entity::isValid() const
+{
+    return d ? d->uri.isValid() : false;
+}
+
+
+bool Nepomuk::Types::Entity::isAvailable()
+{
+    if ( d ) {
+        d->init();
+        return d->available == 1;
+    }
+    else {
+        return false;
+    }
+}
+
+
+void Nepomuk::Types::Entity::reset( bool recursive )
+{
+    d->reset( recursive );
+}
+
+
+bool Nepomuk::Types::Entity::operator==( const Entity& other ) const
+{
+    // since we use one instace cache we can improve comparation operations
+    // intensly by not comparing URLs but pointers.
+    return( d && other.d && d == other.d );
+}
+
+
+bool Nepomuk::Types::Entity::operator!=( const Entity& other ) const
+{
+    return !d || !other.d || d != other.d;
+}
+
+
+
+
+// Code for old deprecated Entity class
+// -------------------------------------------
+Nepomuk::Entity::Entity()
+{
+    d = new Private();
+}
+
+Nepomuk::Entity::Entity( const Entity& other )
+{
+    d = other.d;
+}
+
+
+Nepomuk::Entity::~Entity()
+{
+}
+
+
+Nepomuk::Entity& Nepomuk::Entity::operator=( const Entity& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+const Nepomuk::Ontology* Nepomuk::Entity::definingOntology() const
+{
+    return d->ontology;
+}
+
+
+QUrl Nepomuk::Entity::uri() const
+{
+    return d->uri;
+}
+
+
+QString Nepomuk::Entity::name() const
+{
+    return d->uri.fragment();
+}
+
+
+QString Nepomuk::Entity::label( const QString& language ) const
+{
+    QHash<QString, QString>::const_iterator it = d->l10nLabels.find( language );
+    if ( it != d->l10nLabels.constEnd() ) {
+        return it.value();
+    }
+    else {
+        return d->label;
+    }
+}
+
+
+QString Nepomuk::Entity::comment( const QString& language ) const
+{
+    QHash<QString, QString>::const_iterator it = d->l10nComments.find( language );
+    if ( it != d->l10nComments.constEnd() ) {
+        return it.value();
+    }
+    else {
+        return d->comment;
+    }
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/entity.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/entity.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/entity.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/entity.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,221 @@
+/* This file is part of the Nepomuk-KDE libraries
+   Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_ENTITY_H_
+#define _NEPOMUK_ENTITY_H_
+
+#include <QtCore/QUrl>
+#include <QtCore/QString>
+#include <QtCore/QSharedData>
+#include <QtCore/QHash>
+
+#include <Soprano/Node>
+
+#include <kglobal.h>
+#include <klocale.h>
+
+#include "nepomuk_export.h"
+
+class QIcon;
+
+
+namespace Nepomuk {
+    namespace Types {
+        class EntityPrivate;
+
+        /**
+         * Base class for static ontology entities Class and Property.
+         * It encapsulates the generic labels and comments that both
+         * types have.
+         *
+         * Due to internal optimizations comparing two Entities is much
+         * faster than comparing two QUrl objects.
+         *
+         * \author Sebastian Trueg <trueg@kde.org>
+         */
+        class NEPOMUK_EXPORT Entity
+        {
+        public:
+            /**
+             * Default copy constructor.
+             */
+            Entity( const Entity& );
+
+            /**
+             * Destructor.
+             */
+            virtual ~Entity();
+
+            /**
+             * Copy operator.
+             */
+            Entity& operator=( const Entity& );
+
+            /**
+             * The name of the resource. The name equals the fragment of the
+             * URI.
+             */
+            QString name() const;
+
+            /**
+             * The URI of the resource
+             */
+            QUrl uri() const;
+
+            /**
+             * Retrieve the label of the entity (rdfs:label)
+             *
+             * \param language The code of the language to use. Defaults to the session
+             *                 language configured in KDE.
+             *
+             * \return The label translated into \p language or the default fallback label
+             * if no translation is available or the name() if no label could be found
+             * at all.
+             */
+            QString label( const QString& language = KGlobal::locale()->language() );
+
+            /**
+             * Retrieve the comment of the entity (rdfs:comment)
+             *
+             * \param language The code of the language to use. Defaults to the session
+             *                 language configured in KDE.
+             *
+             * \return The comment translated into \p language or the default fallback comment
+             * if no translation is available or an empty string if no comment could be found
+             * at all.
+             */
+            QString comment( const QString& language = KGlobal::locale()->language() );
+
+            /**
+             * Retrieve the icon stored for the entity (nao:hasSymbol)
+             *
+             * If no symbol is defined for the entity a null icon will be returned.
+             *
+             * \since 4.1
+             */
+            QIcon icon();
+
+            /**
+             * Is this a valid Entity, i.e. has it a valid URI.
+             * A valid Entity does not necessarily have a label and a comment, it
+             * does not even have to exist in the Nepomuk store.
+             *
+             * \sa isAvailable
+             */
+            bool isValid() const;
+
+            /**
+             * Is this Entity available locally, i.e. could its properties
+             * be loaded from the Nepomuk store.
+             */
+            bool isAvailable();
+
+            /**
+             * The Types classes are optimized for performance under the 
+             * aasumption that ontologies never change during the execution
+             * time of an application.
+             *
+             * Since there might be situations where this does not apply
+             * the internal cache can be reset via this method.
+             *
+             * \param recursive If \p true all related entities will be reset
+             * as well.
+             *
+             * \since 4.1
+             */
+            void reset( bool recursive = false );
+
+            /**
+             * An Entity can be used as a QUrl automagically.
+             */
+            operator QUrl() const { return uri(); }
+
+            /**
+             * Compares two Entity instances by simply comparing their URI.
+             */
+            bool operator==( const Entity& other ) const;
+
+            /**
+             * Compares two Entity instances by simply comparing their URI.
+             */
+            bool operator!=( const Entity& other ) const;
+
+        protected:
+            /**
+             * Create an invalid Entity instance.
+             */
+            Entity();
+
+            QExplicitlySharedDataPointer<EntityPrivate> d;
+        };
+
+        inline uint qHash( const Entity& c )
+        {
+            return qHash( c.uri().toString() );
+        }
+    }
+}
+
+
+namespace Nepomuk {
+
+    class Ontology;
+
+    /**
+     * \deprecated in favor of Nepomuk::Types::Entity
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT Entity
+    {
+    public:
+        Entity( const Entity& );
+        ~Entity();
+
+        Entity& operator=( const Entity& );
+
+        /**
+         * The ontology in which the resource is defined.
+         */
+        const Ontology* definingOntology() const;
+
+        /**
+         * The name of the resource. The name equals the fragment of the
+         * URI.
+         */
+        QString name() const;
+
+        /**
+         * The URI of the resource
+         */
+        QUrl uri() const;
+	    
+        QString label( const QString& language = QString() ) const;
+        QString comment( const QString& language = QString() ) const;
+
+    protected:
+        Entity();
+
+    private:
+        class Private;
+        QSharedDataPointer<Private> d;
+
+        friend class OntologyManager;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/entity_p.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/entity_p.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/entity_p.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/entity_p.h.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,91 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_ENTITY_PRIVATE_H_
+#define _NEPOMUK_ENTITY_PRIVATE_H_
+
+#include "entity.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QString>
+#include <QtCore/QUrl>
+#include <QtGui/QIcon>
+#include <QtCore/QSharedData>
+#include <QtCore/QMutex>
+
+namespace Nepomuk {
+    namespace Types {
+        class EntityPrivate : public QSharedData
+        {
+        public:
+            EntityPrivate( const QUrl& uri = QUrl() );
+            virtual ~EntityPrivate() {}
+
+            QMutex mutex;
+            
+            QUrl uri;
+            QString label;
+            QString comment;
+            QHash<QString, QString> l10nLabels;
+            QHash<QString, QString> l10nComments;
+
+            QIcon icon;
+
+            // -1 - unknown
+            // 0  - no
+            // 1  - yes
+            int available;
+            int ancestorsAvailable;
+
+            void init();
+            void initAncestors();
+
+            virtual bool addProperty( const QUrl& property, const Soprano::Node& value ) = 0;
+            virtual bool addAncestorProperty( const QUrl& ancestorResource, const QUrl& property ) = 0;
+
+            virtual void reset( bool recursive );
+
+        protected:
+            virtual bool load();
+            virtual bool loadAncestors();
+        };
+    }
+}
+
+
+
+class Nepomuk::Entity::Private : public QSharedData
+{
+public:
+    Private()
+	: ontology( 0 ) {
+    }
+
+    const Ontology* ontology;
+
+    QUrl uri;
+    QString label;
+    QString comment;
+    QHash<QString, QString> l10nLabels;
+    QHash<QString, QString> l10nComments;
+};
+
+uint qHash( const QUrl& url );
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/entitymanager.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/entitymanager.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/entitymanager.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/entitymanager.cpp.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,131 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "entitymanager.h"
+#include "class_p.h"
+#include "property_p.h"
+#include "ontology_p.h"
+
+#include "../resourcemanager.h"
+
+#include <QtCore/QMutexLocker>
+
+Q_GLOBAL_STATIC( Nepomuk::Types::EntityManager, entityManager )
+
+Nepomuk::Types::EntityManager::EntityManager()
+{
+}
+
+
+Nepomuk::Types::EntityPrivate* Nepomuk::Types::EntityManager::findEntity( const QUrl& uri ) const
+{
+    if ( ClassPrivate* cp = findClass( uri ) ) {
+        return cp;
+    }
+    else if ( PropertyPrivate* pp = findProperty( uri ) ) {
+        return pp;
+    }
+    else if ( OntologyPrivate* op = findOntology( uri ) ) {
+        return op;
+    }
+    else {
+        return 0;
+    }
+}
+
+
+Nepomuk::Types::ClassPrivate* Nepomuk::Types::EntityManager::findClass( const QUrl& uri ) const
+{
+    QHash<QUrl, QExplicitlySharedDataPointer<ClassPrivate> >::const_iterator it = m_classMap.find( uri );
+    if ( it != m_classMap.end() ) {
+        return it.value().data();
+    }
+    return 0;
+}
+
+
+Nepomuk::Types::PropertyPrivate* Nepomuk::Types::EntityManager::findProperty( const QUrl& uri ) const
+{
+    QHash<QUrl, QExplicitlySharedDataPointer<PropertyPrivate> >::const_iterator it = m_propertyMap.find( uri );
+    if ( it != m_propertyMap.end() ) {
+        return it.value().data();
+    }
+    return 0;
+}
+
+
+Nepomuk::Types::OntologyPrivate* Nepomuk::Types::EntityManager::findOntology( const QUrl& uri ) const
+{
+    QHash<QUrl, QExplicitlySharedDataPointer<OntologyPrivate> >::const_iterator it = m_ontologyMap.find( uri );
+    if ( it != m_ontologyMap.end() ) {
+        return it.value().data();
+    }
+    return 0;
+}
+
+
+Nepomuk::Types::ClassPrivate* Nepomuk::Types::EntityManager::getClass( const QUrl& uri )
+{
+    QMutexLocker lock( &m_mutex );
+
+    if ( ClassPrivate* cp = findClass( uri ) ) {
+        return cp;
+    }
+    else {
+        QExplicitlySharedDataPointer<ClassPrivate> scp( new ClassPrivate( uri ) );
+        m_classMap.insert( uri, scp );
+        return scp.data();
+    }
+}
+
+
+Nepomuk::Types::PropertyPrivate* Nepomuk::Types::EntityManager::getProperty( const QUrl& uri )
+{
+    QMutexLocker lock( &m_mutex );
+
+    if ( PropertyPrivate* pp = findProperty( uri ) ) {
+        return pp;
+    }
+    else {
+        QExplicitlySharedDataPointer<PropertyPrivate> cp( new PropertyPrivate( uri ) );
+        m_propertyMap.insert( uri, cp );
+        return cp.data();
+    }
+}
+
+
+Nepomuk::Types::OntologyPrivate* Nepomuk::Types::EntityManager::getOntology( const QUrl& uri )
+{
+    QMutexLocker lock( &m_mutex );
+
+    if ( OntologyPrivate* op = findOntology( uri ) ) {
+        return op;
+    }
+    else {
+        QExplicitlySharedDataPointer<OntologyPrivate> cp( new OntologyPrivate( uri ) );
+        m_ontologyMap.insert( uri, cp );
+        return cp.data();
+    }
+}
+
+
+Nepomuk::Types::EntityManager* Nepomuk::Types::EntityManager::self()
+{
+    return entityManager();
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/entitymanager.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/entitymanager.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/entitymanager.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/entitymanager.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,69 @@
+/* This file is part of the Nepomuk-KDE libraries
+   Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_ENTITY_MANAGER_H_
+#define _NEPOMUK_ENTITY_MANAGER_H_
+
+#include <QtCore/QHash>
+#include <QtCore/QUrl>
+#include <QtCore/QSharedData>
+#include <QtCore/QMutex>
+
+
+namespace Soprano {
+    class Statement;
+}
+
+namespace Nepomuk {
+    namespace Types {
+        class EntityPrivate;
+        class ClassPrivate;
+        class PropertyPrivate;
+        class OntologyPrivate;
+
+        /**
+         * Cache for all loaded entities.
+         */
+        class EntityManager
+        {
+        public:
+            EntityManager();
+
+            ClassPrivate* getClass( const QUrl& uri );
+            PropertyPrivate* getProperty( const QUrl& uri );
+            OntologyPrivate* getOntology( const QUrl& uri );
+
+            static EntityManager* self();
+
+        private:
+            EntityPrivate* findEntity( const QUrl& uri ) const;
+            ClassPrivate* findClass( const QUrl& uri ) const;
+            PropertyPrivate* findProperty( const QUrl& uri ) const;
+            OntologyPrivate* findOntology( const QUrl& uri ) const;
+
+            QHash<QUrl, QExplicitlySharedDataPointer<ClassPrivate> > m_classMap;
+            QHash<QUrl, QExplicitlySharedDataPointer<PropertyPrivate> > m_propertyMap;
+            QHash<QUrl, QExplicitlySharedDataPointer<OntologyPrivate> > m_ontologyMap;
+
+            QMutex m_mutex;
+        };
+    }
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/fileontologyloader.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/fileontologyloader.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/fileontologyloader.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/fileontologyloader.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,108 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "fileontologyloader.h"
+
+#include <soprano/soprano.h>
+
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+
+
+class Nepomuk::FileOntologyLoader::Private
+{
+public:
+    Private()
+        : serialization( Soprano::SerializationUnknown ) {
+    }
+
+    QString filename;
+    Soprano::RdfSerialization serialization;
+};
+
+
+Nepomuk::FileOntologyLoader::FileOntologyLoader()
+    : OntologyLoader(),
+      d( new Private() )
+{
+}
+
+
+Nepomuk::FileOntologyLoader::FileOntologyLoader( const QString& filename, Soprano::RdfSerialization serialization )
+    : OntologyLoader(),
+      d( new Private() )
+{
+    setFileName( filename );
+    setSerialization( serialization );
+}
+
+
+Nepomuk::FileOntologyLoader::~FileOntologyLoader()
+{
+    delete d;
+}
+
+
+void Nepomuk::FileOntologyLoader::setFileName( const QString& filename )
+{
+    d->filename = filename;
+}
+
+
+void Nepomuk::FileOntologyLoader::setSerialization( Soprano::RdfSerialization s )
+{
+    d->serialization = s;
+}
+
+
+QString Nepomuk::FileOntologyLoader::fileName() const
+{
+    return d->filename;
+}
+
+
+QList<Soprano::Statement> Nepomuk::FileOntologyLoader::loadOntology( const QUrl& url )
+{
+    QString filename;
+
+    if ( d->filename.isEmpty() ) {
+        // FIXME: use KIO or is QT sufficient? Actually how about NetAccess and a temp file?
+        qDebug() << "(FileOntologyLoader) remote support not implemented yet.";
+        return QList<Soprano::Statement>();
+    }
+    else {
+        filename = d->filename;
+    }
+
+    QList<Soprano::Statement> sl;
+
+    QFile f( filename );
+    if ( f.open( QIODevice::ReadOnly ) ) {
+        // TODO: how can we check if the requested onto is really defined in this file?
+        const Soprano::Parser* rdfParser = Soprano::PluginManager::instance()->discoverParserForSerialization( d->serialization );
+        if ( rdfParser ) {
+            sl = rdfParser->parseFile( d->filename, url, d->serialization ).allStatements();
+        }
+    }
+    else {
+        qDebug() << "(FileOntologyLoader) failed to open " << filename;
+    }
+
+    return sl;
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/fileontologyloader.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/fileontologyloader.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/fileontologyloader.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/fileontologyloader.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,89 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_FILE_ONTOLOGY_LOADER_H_
+#define _NEPOMUK_FILE_ONTOLOGY_LOADER_H_
+
+#include "ontologyloader.h"
+#include "nepomuk_export.h"
+
+#include <soprano/parser.h>
+#include <soprano/sopranotypes.h>
+
+
+namespace Nepomuk {
+    /**
+     * \deprecated Ontologies should now be handled using the classes
+     * in the Nepomuk::Types namespace.
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT FileOntologyLoader : public OntologyLoader
+    {
+    public:
+	/**
+	 * Default constructor.
+	 * Creates a FileOntologyLoader that will try to load the 
+	 * ontology directly from its URL, i.e. the internet.
+	 */
+	FileOntologyLoader();
+
+	/**
+	 * Creates a FileOntologyLoader that will load the 
+	 * ontology from the specified filename.
+	 */
+	explicit FileOntologyLoader( const QString& filename,
+                                     Soprano::RdfSerialization serialization = Soprano::SerializationUnknown );
+
+	/**
+	 * Destructor
+	 */
+	~FileOntologyLoader();
+
+	/**
+	 * Set the filename to be used for reading the ontologies.
+	 * If no filename has been set FileOntologyLoader will try
+	 * load the ontology file from the internet, i.e. directly
+	 * use the ontology URL - NOT IMPLEMENTED YET.
+	 */
+	void setFileName( const QString& filename );
+
+	/**
+	 * The filename that has been set.
+	 * \sa setFileName
+	 * \return The filename set (can be empty)
+	 */
+	QString fileName() const;
+	
+	/**
+	 * Set the serialization that is used in the file.
+	 * Defaults to Soprano::SerializationUnknown
+	 */
+	void setSerialization( Soprano::RdfSerialization );
+
+	/**
+	 * reimplemented from OntologyLoader
+	 */
+	QList<Soprano::Statement> loadOntology( const QUrl& url );
+
+    private:
+	class Private;
+	Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/global.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/global.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/global.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/global.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,38 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "global.h"
+
+#include <kdebug.h>
+#include <kglobal.h>
+
+
+QUrl Nepomuk::extractNamespace( const QUrl& url )
+{
+    QByteArray s = url.toEncoded();
+    int pos = s.lastIndexOf( '#' );
+    if ( pos == -1 ) {
+        pos = s.lastIndexOf( '/' );
+    }
+    if ( pos == -1 ) {
+        kError() << " Failed to extract namespace from " << url << endl;
+        return QUrl();
+    }
+    return QUrl::fromEncoded( s.left( pos+1 ) );
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/global.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/global.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/global.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/global.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,32 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_GLOBAL_H_
+#define _NEPOMUK_GLOBAL_H_
+
+#include "nepomuk_export.h"
+
+#include <QtCore/QString>
+#include <QtCore/QUrl>
+
+namespace Nepomuk {
+    KDE_DEPRECATED NEPOMUK_EXPORT QUrl extractNamespace( const QUrl& url );
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/literal.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/literal.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/literal.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/literal.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,170 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "literal.h"
+#include "literal_p.h"
+
+#include <QtCore/QHash>
+#include <QtCore/QVariant>
+
+#include <Soprano/Vocabulary/RDFS>
+
+
+namespace {
+QHash<QString, QVariant::Type> s_xmlSchemaTypes;
+
+void initXmlSchemaTypes() {
+    if( s_xmlSchemaTypes.isEmpty() ) {
+        s_xmlSchemaTypes.insert( "int", QVariant::Int );
+        s_xmlSchemaTypes.insert( "integer", QVariant::Int );
+        s_xmlSchemaTypes.insert( "negativeInteger", QVariant::Int );
+        s_xmlSchemaTypes.insert( "decimal", QVariant::Int );
+        s_xmlSchemaTypes.insert( "short", QVariant::Int );
+        s_xmlSchemaTypes.insert( "long", QVariant::LongLong );
+        s_xmlSchemaTypes.insert( "unsignedInt", QVariant::UInt );
+        s_xmlSchemaTypes.insert( "unsignedShort", QVariant::UInt );
+        s_xmlSchemaTypes.insert( "unsignedLong", QVariant::ULongLong );
+        s_xmlSchemaTypes.insert( "boolean", QVariant::Bool );
+        s_xmlSchemaTypes.insert( "double", QVariant::Double );
+        s_xmlSchemaTypes.insert( "float", QVariant::Double );
+        s_xmlSchemaTypes.insert( "string", QVariant::String );
+        s_xmlSchemaTypes.insert( "date", QVariant::Date );
+        s_xmlSchemaTypes.insert( "time", QVariant::Time );
+        s_xmlSchemaTypes.insert( "dateTime", QVariant::DateTime );
+        //    s_xmlSchemaTypes.insert( "", QVariant::Url );
+    }
+}
+}
+
+
+Nepomuk::Types::Literal::Literal()
+{
+    d = new Private();
+}
+
+
+Nepomuk::Types::Literal::Literal( const Literal& other )
+{
+    d = other.d;
+}
+
+
+Nepomuk::Types::Literal::Literal( const QUrl& dataType )
+{
+    d = new Private();
+    d->dataTypeUri = dataType;
+
+    // now determine the QVariant type
+    initXmlSchemaTypes();
+
+    // check if it is a known type, otherwise leave it as QVariant::Invalid
+    if ( dataType == Soprano::Vocabulary::RDFS::Literal() ) {
+        d->dataType = QVariant::String;
+    }
+    else {
+        QHash<QString, QVariant::Type>::const_iterator it = s_xmlSchemaTypes.constFind( dataType.fragment() );
+        if ( it != s_xmlSchemaTypes.constEnd() ) {
+            d->dataType = it.value();
+        }
+    }
+}
+
+
+Nepomuk::Types::Literal::~Literal()
+{
+}
+
+
+Nepomuk::Types::Literal& Nepomuk::Types::Literal::operator=( const Literal& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+QUrl Nepomuk::Types::Literal::dataTypeUri() const
+{
+    return d->dataTypeUri;
+}
+
+
+QVariant::Type Nepomuk::Types::Literal::dataType() const
+{
+    return d->dataType;
+}
+
+
+bool Nepomuk::Types::Literal::isValid() const
+{
+    return d->dataTypeUri.isValid();
+}
+
+
+
+
+Nepomuk::Literal::Literal()
+{
+    d = new Private();
+}
+
+
+Nepomuk::Literal::Literal( const Literal& other )
+{
+    d = other.d;
+}
+
+
+Nepomuk::Literal::Literal( const QUrl& dataType )
+{
+    d = new Private();
+    d->dataTypeUri = dataType;
+
+    // now determine the QVariant type
+    initXmlSchemaTypes();
+
+    // check if it is a known type, otherwise leave it as QVariant::Invalid
+    QHash<QString, QVariant::Type>::const_iterator it = s_xmlSchemaTypes.constFind( dataType.fragment() );
+    if ( it != s_xmlSchemaTypes.constEnd() ) {
+        d->dataType = it.value();
+    }
+}
+
+
+Nepomuk::Literal::~Literal()
+{
+}
+
+
+Nepomuk::Literal& Nepomuk::Literal::operator=( const Literal& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+const QUrl& Nepomuk::Literal::dataTypeUri() const
+{
+    return d->dataTypeUri;
+}
+
+
+QVariant::Type Nepomuk::Literal::dataType() const
+{
+    return d->dataType;
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/literal.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/literal.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/literal.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/literal.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,117 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_LITERAL_H_
+#define _NEPOMUK_LITERAL_H_
+
+#include <QtCore/QUrl>
+#include <QtCore/QVariant>
+#include <QtCore/QSharedData>
+
+#include "nepomuk_export.h"
+
+namespace Nepomuk {
+    namespace Types {
+        /**
+         * \brief Defines a literal type based on XML Schema.
+         *
+         * Each valid Literal represents the literal type
+         * as XML Schema URI and as QVariant type.
+         */
+        class NEPOMUK_EXPORT Literal
+	{
+	public:
+	    /**
+	     * Default constructor.
+	     * Creates an empty Literal
+	     */
+	    Literal();
+	    Literal( const Literal& );
+	    Literal( const QUrl& dataTypeUri );
+	    ~Literal();
+
+	    Literal& operator=( const Literal& );
+
+	    /**
+	     * The XML Schema type URI.
+	     */
+	    QUrl dataTypeUri() const;
+
+	    /**
+	     * The type converted to a QVariant::Type.
+	     * \return The QVariant::Type that corresponds to the XML Schema type or
+	     * QVariant::Invalid if it could not be matched.
+	     */
+	    QVariant::Type dataType() const;
+
+            /**
+             * Is this a valid Literal, i.e. has it a valid URI.
+             */
+            bool isValid() const;
+
+	private:
+	    class Private;
+	    QExplicitlySharedDataPointer<Private> d;
+	};
+    }
+}
+
+
+namespace Nepomuk {
+    /**
+     * \brief Defines a literal type based on XML Schema.
+     *
+     * Each valid Literal represents the literal type
+     * as XML Schema URI and as QVariant type.
+     *
+     * \deprecated in favor of Nepomuk::Types::Literal
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT Literal
+    {
+    public:
+        /**
+         * Default constructor.
+         * Creates an empty Literal
+         */
+        Literal();
+        Literal( const Literal& );
+        Literal( const QUrl& dataTypeUri );
+        ~Literal();
+
+        Literal& operator=( const Literal& );
+
+        /**
+         * The XML Schema type URI.
+         */
+        const QUrl& dataTypeUri() const;
+
+        /**
+         * The type converted to a QVariant::Type.
+         * \return The QVariant::Type that corresponds to the XML Schema type or
+         * QVariant::Invalid if it could not be matched.
+         */
+        QVariant::Type dataType() const;
+
+    private:
+        class Private;
+        QSharedDataPointer<Private> d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/literal_p.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/literal_p.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/literal_p.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/literal_p.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,52 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_LITERAL_PRIVATE_H_
+#define _NEPOMUK_LITERAL_PRIVATE_H_
+
+#include "literal.h"
+
+#include <QtCore/QUrl>
+#include <QtCore/QVariant>
+#include <QtCore/QSharedData>
+
+class Nepomuk::Types::Literal::Private : public QSharedData
+{
+ public:
+    Private()
+	: dataType( QVariant::Invalid ) {
+    }
+
+    QUrl dataTypeUri;
+    QVariant::Type dataType;  
+};
+
+
+class Nepomuk::Literal::Private : public QSharedData
+{
+ public:
+    Private()
+	: dataType( QVariant::Invalid ) {
+    }
+
+    QUrl dataTypeUri;
+    QVariant::Type dataType;  
+};
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/nepomukontologyloader.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/nepomukontologyloader.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/nepomukontologyloader.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/nepomukontologyloader.cpp.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,74 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "nepomukontologyloader.h"
+#include "global.h"
+
+#include <Soprano/Statement>
+#include <Soprano/Model>
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Client/DBusModel>
+#include <Soprano/Client/DBusClient>
+
+#include <QtCore/QDebug>
+
+
+class Nepomuk::NepomukOntologyLoader::Private
+{
+public:
+    Private()
+        : client("org.kde.NepomukServer") {
+    }
+    Soprano::Client::DBusClient client;
+};
+
+
+Nepomuk::NepomukOntologyLoader::NepomukOntologyLoader()
+    : OntologyLoader(),
+      d( new Private() )
+{
+}
+
+
+Nepomuk::NepomukOntologyLoader::~NepomukOntologyLoader()
+{
+    delete d;
+}
+
+
+QList<Soprano::Statement> Nepomuk::NepomukOntologyLoader::loadOntology( const QUrl& uri )
+{
+    QList<Soprano::Statement> sl;
+
+    if ( Soprano::Model* model = d->client.createModel( "main" ) ) {
+        // get the complete named graph describing the ontology
+        Soprano::QueryResultIterator it = model->executeQuery( QString( "construct {?s ?p ?o} "
+                                                                        "where { GRAPH <%1> { ?s ?p ?o } . }" )
+                                                               .arg( uri.toString() ),
+                                                               Soprano::Query::QUERY_LANGUAGE_SPARQL );
+        while ( it.next() ) {
+            sl.append( it.currentStatement() );
+        }
+    }
+    else {
+        qDebug() << "(NepomukOntologyLoader) could not find ontology statements for " << uri;
+    }
+
+    return sl;
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/nepomukontologyloader.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/nepomukontologyloader.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/nepomukontologyloader.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/nepomukontologyloader.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,45 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_NEPOMUK_ONTOLOGY_LOADER_H_
+#define _NEPOMUK_NEPOMUK_ONTOLOGY_LOADER_H_
+
+#include "ontologyloader.h"
+#include "nepomuk_export.h"
+
+namespace Nepomuk {
+    /**
+     * \deprecated Ontologies should now be handled using the classes
+     * in the Nepomuk::Types namespace.
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT NepomukOntologyLoader : public OntologyLoader
+    {
+    public:
+	NepomukOntologyLoader();
+	~NepomukOntologyLoader();
+
+	QList<Soprano::Statement> loadOntology( const QUrl& url );
+
+    private:
+	class Private;
+	Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/ontology.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/ontology.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/ontology.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/ontology.cpp.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,360 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "ontology.h"
+#include "ontology_p.h"
+#include "class.h"
+#include "property.h"
+#include "entitymanager.h"
+#include "resourcemanager.h"
+
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Model>
+#include <Soprano/Vocabulary/NAO>
+#include <Soprano/Vocabulary/RDFS>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/XMLSchema>
+
+#undef D
+#define D static_cast<Nepomuk::Types::OntologyPrivate*>( d.data() )
+
+Nepomuk::Types::OntologyPrivate::OntologyPrivate( const QUrl& uri )
+    : EntityPrivate( uri ),
+      entitiesAvailable( uri.isValid() ? -1 : 0 )
+{
+}
+
+
+void Nepomuk::Types::OntologyPrivate::initEntities()
+{
+    if ( entitiesAvailable < 0 ) {
+        entitiesAvailable = loadEntities() ? 1 : 0;
+    }
+}
+
+
+bool Nepomuk::Types::OntologyPrivate::loadEntities()
+{
+    // load classes
+    Soprano::QueryResultIterator it
+        = ResourceManager::instance()->mainModel()->executeQuery( QString("select ?c where { "
+                                                                          "graph ?g { ?c a <%1> . } . "
+                                                                          "?g <%2> \"%3\"^^<%4> . }" )
+                                                                  .arg( Soprano::Vocabulary::RDFS::Class().toString() )
+                                                                  .arg( Soprano::Vocabulary::NAO::hasDefaultNamespace().toString() )
+                                                                  .arg( QString::fromAscii( uri.toEncoded() ) )
+                                                                  .arg( Soprano::Vocabulary::XMLSchema::string().toString() ),
+                                                                  Soprano::Query::QueryLanguageSparql );
+    bool success = false;
+    while ( it.next() ) {
+        success = true;
+        classes.append( Class( it.binding( "c" ).uri() ) );
+    }
+
+
+    // load properties
+    it = ResourceManager::instance()->mainModel()->executeQuery( QString("select ?p where { "
+                                                                         "graph ?g { ?p a <%1> . } . "
+                                                                         "?g <%2> \"%3\"^^<%4> . }" )
+                                                                 .arg( Soprano::Vocabulary::RDF::Property().toString() )
+                                                                 .arg( Soprano::Vocabulary::NAO::hasDefaultNamespace().toString() )
+                                                                 .arg( QString::fromAscii( uri.toEncoded() ) )
+                                                                 .arg( Soprano::Vocabulary::XMLSchema::string().toString() ),
+                                                                 Soprano::Query::QueryLanguageSparql );
+    while ( it.next() ) {
+        success = true;
+        properties.append( Property( it.binding( "p" ).uri() ) );
+    }
+
+    return success;
+}
+
+
+bool Nepomuk::Types::OntologyPrivate::addProperty( const QUrl&, const Soprano::Node& )
+{
+    return false;
+}
+
+
+bool Nepomuk::Types::OntologyPrivate::addAncestorProperty( const QUrl&, const QUrl& )
+{
+    return false;
+}
+
+
+void Nepomuk::Types::OntologyPrivate::reset( bool recursive )
+{
+    EntityPrivate::reset( recursive );
+
+    if ( entitiesAvailable != -1 ) {
+        if ( recursive ) {
+            foreach( Class c, classes ) {
+                c.reset( true );
+            }
+            foreach( Property p, properties ) {
+                p.reset( true );
+            }
+        }
+        classes.clear();
+        properties.clear();
+
+        entitiesAvailable = -1;
+    }
+}
+
+
+
+Nepomuk::Types::Ontology::Ontology()
+{
+    d = new OntologyPrivate();
+}
+
+
+Nepomuk::Types::Ontology::Ontology( const QUrl& uri )
+{
+    d = EntityManager::self()->getOntology( uri );
+}
+
+
+Nepomuk::Types::Ontology::Ontology( const Ontology& other )
+    : Entity( other )
+{
+}
+
+
+Nepomuk::Types::Ontology::~Ontology()
+{
+}
+
+
+Nepomuk::Types::Ontology& Nepomuk::Types::Ontology::operator=( const Ontology& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+QList<Nepomuk::Types::Class> Nepomuk::Types::Ontology::allClasses()
+{
+    D->initEntities();
+    return D->classes;
+}
+
+
+Nepomuk::Types::Class Nepomuk::Types::Ontology::findClassByName( const QString& name )
+{
+    D->initEntities();
+    for ( QList<Class>::const_iterator it = D->classes.constBegin();
+          it != D->classes.constEnd(); ++it ) {
+        const Class& c = *it;
+        if ( c.name() == name ) {
+            return c;
+        }
+    }
+
+    return Class();
+}
+
+
+Nepomuk::Types::Class Nepomuk::Types::Ontology::findClassByLabel( const QString& label, const QString& language )
+{
+    D->initEntities();
+    for ( QList<Class>::iterator it = D->classes.begin();
+          it != D->classes.end(); ++it ) {
+        Class& c = *it;
+        if ( c.label( language ) == label ) {
+            return c;
+        }
+    }
+
+    return Class();
+}
+
+
+QList<Nepomuk::Types::Property> Nepomuk::Types::Ontology::allProperties()
+{
+    D->initEntities();
+    return D->properties;
+}
+
+
+Nepomuk::Types::Property Nepomuk::Types::Ontology::findPropertyByName( const QString& name )
+{
+    D->initEntities();
+    for ( QList<Property>::const_iterator it = D->properties.constBegin();
+          it != D->properties.constEnd(); ++it ) {
+        const Property& p = *it;
+        if ( p.name() == name ) {
+            return p;
+        }
+    }
+
+    return Property();
+}
+
+
+Nepomuk::Types::Property Nepomuk::Types::Ontology::findPropertyByLabel( const QString& label, const QString& language )
+{
+    D->initEntities();
+    for ( QList<Property>::iterator it = D->properties.begin();
+          it != D->properties.end(); ++it ) {
+        Property& p = *it;
+        if ( p.label( language ) == label ) {
+            return p;
+        }
+    }
+
+    return Property();
+}
+
+
+
+// Start of code for deprecated Ontology
+// -------------------------------------
+#include "global.h"
+#include "ontologymanager.h"
+
+
+Nepomuk::Ontology::Ontology()
+{
+    d = new Private;
+}
+
+
+Nepomuk::Ontology::Ontology( const Ontology& other )
+{
+    d = other.d;
+}
+
+
+Nepomuk::Ontology::~Ontology()
+{
+}
+
+
+Nepomuk::Ontology& Nepomuk::Ontology::operator=( const Ontology& other)
+{
+    d = other.d;
+    return *this;
+}
+
+
+QUrl Nepomuk::Ontology::uri() const
+{
+    return d->uri;
+}
+
+
+QList<const Nepomuk::Class*> Nepomuk::Ontology::allClasses() const
+{
+    return d->classes.values();
+}
+
+
+const Nepomuk::Class* Nepomuk::Ontology::findClassByName( const QString& name ) const
+{
+    for ( QHash<QUrl, const Class*>::const_iterator it = d->classes.constBegin();
+          it != d->classes.constEnd(); ++it ) {
+        const Class* c = it.value();
+        if ( c->name() == name ) {
+            return c;
+        }
+    }
+
+    return 0;
+}
+
+
+const Nepomuk::Class* Nepomuk::Ontology::findClassByLabel( const QString& label, const QString& language ) const
+{
+    for ( QHash<QUrl, const Class*>::const_iterator it = d->classes.constBegin();
+          it != d->classes.constEnd(); ++it ) {
+        const Class* c = it.value();
+        if ( c->label( language ) == label ) {
+            return c;
+        }
+    }
+
+    return 0;
+}
+
+
+const Nepomuk::Class* Nepomuk::Ontology::findClassByUri( const QUrl& uri ) const
+{
+    QHash<QUrl, const Class*>::const_iterator it = d->classes.find( uri );
+    if ( it != d->classes.constEnd() ) {
+        return it.value();
+    }
+    else {
+        return 0;
+    }
+}
+
+
+QList<const Nepomuk::Property*> Nepomuk::Ontology::allProperties() const
+{
+    return d->properties.values();
+}
+
+
+const Nepomuk::Property* Nepomuk::Ontology::findPropertyByName( const QString& name ) const
+{
+    for ( QHash<QUrl, const Property*>::const_iterator it = d->properties.constBegin();
+          it != d->properties.constEnd(); ++it ) {
+        const Property* p = it.value();
+        if ( p->name() == name ) {
+            return p;
+        }
+    }
+
+    return 0;
+}
+
+
+const Nepomuk::Property* Nepomuk::Ontology::findPropertyByLabel( const QString& label, const QString& language ) const
+{
+    for ( QHash<QUrl, const Property*>::const_iterator it = d->properties.constBegin();
+          it != d->properties.constEnd(); ++it ) {
+        const Property* p = it.value();
+        if ( p->label( language ) == label ) {
+            return p;
+        }
+    }
+
+    return 0;
+}
+
+
+const Nepomuk::Property* Nepomuk::Ontology::findPropertyByUri( const QUrl& uri ) const
+{
+    QHash<QUrl, const Property*>::const_iterator it = d->properties.find( uri );
+    if ( it != d->properties.constEnd() ) {
+        return it.value();
+    }
+    else {
+        return 0;
+    }
+}
+
+
+const Nepomuk::Ontology* Nepomuk::Ontology::load( const QUrl& uri )
+{
+    // load the ontology in the cache
+    return OntologyManager::instance()->getOntology( uri );
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/ontology.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/ontology.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/ontology.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/ontology.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,235 @@
+/* This file is part of the Nepomuk-KDE libraries
+   Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_ONTOLOGY_H_
+#define _NEPOMUK_ONTOLOGY_H_
+
+#include <QtCore/QList>
+#include <QtCore/QUrl>
+#include <QtCore/QString>
+#include <QtCore/QSharedData>
+
+#include "entity.h"
+#include "nepomuk_export.h"
+
+
+namespace Nepomuk {
+    namespace Types {
+
+        class Class;
+        class Property;
+
+        /**
+         * \class Ontology ontology.h Nepomuk/Types/Ontology
+         *
+         * \brief Represents one ontology.
+         *
+         * \author Sebastian Trueg <trueg@kde.org>
+         */
+        class NEPOMUK_EXPORT Ontology : public Entity
+        {
+        public:
+            /**
+             * Default constructor. Creates an empty Ontology.
+             */
+            Ontology();
+
+            /**
+             * Create the ontology referred to by \p uri.
+             * The result is either a valid ontology which could be loaded from the
+             * Nepomuk store or a simple class which only contains the uri.
+             *
+             * Be aware that the data is only loaded once read.
+             *
+             * Subsequent calls result in a simple hash lookup of cached data.
+             */
+            Ontology( const QUrl& uri );
+
+            /**
+             * Default copy constructor
+             */
+            Ontology( const Ontology& );
+
+            /**
+             * Destructor
+             */
+            ~Ontology();
+
+            Ontology& operator=( const Ontology& );
+
+            /**
+             * All classes defined in this ontology, i.e. its namespace.
+             */
+            QList<Class> allClasses();
+
+            /**
+             * Search for a class in the ontology by its name.
+             * \param name The name of the class.
+             * \return the Class object identified by name or an invalid one if the class could not be found.
+             */
+            Class findClassByName( const QString& name );
+
+            /**
+             * Search for a class in the ontology by its label.
+             * \param label The label of the class (i.e. rdfs:label)
+             * \param language The language in which the label was specified. If empty the default rdfs:label
+             * is returned.
+             * \return the Class object identified by label or an invalid one if the class could not be found.
+             */ 
+            Class findClassByLabel( const QString& label, const QString& language = QString() );
+
+            /**
+             * A list of all properties defined in this ontology. This does not include properties that use
+             * classes of this ontology but are defined in a different one.
+             */
+            QList<Property> allProperties();
+
+            /**
+             * Search for a property in the ontology by its name.
+             * \param name The name of the property.
+             * \return the Property object identified by name or an invalid one if the property could not be found.
+             */ 
+            Property findPropertyByName( const QString& name );
+
+            /**
+             * Search for a property in the ontology by its label.
+             * \param label The label of the property (i.e. rdfs:label)
+             * \param language The language in which the label was specified. If empty the default rdfs:label
+             * is returned.
+             * \return the Property object identified by label or an invalid one if the property could not be found.
+             */ 
+            Property findPropertyByLabel( const QString& label, const QString& language = QString() );
+        };
+    }
+}
+
+
+
+namespace Nepomuk {
+
+    class Class;
+    class Property;
+
+    /**
+     * Ontology represents one ontology specified using NRL.
+     *
+     * \deprecated in favor of Nepomuk::Types::Ontology
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT Ontology
+    {
+    public:
+	/**
+	 * Default constructor. Creates an empty Ontology.
+	 */
+	Ontology();
+
+	/**
+	 * Default copy constructor
+	 */
+	Ontology( const Ontology& );
+
+	/**
+	 * Destructor
+	 */
+	~Ontology();
+
+	Ontology& operator=( const Ontology& );
+
+	/**
+	 * The URI of the ontology, i.e. its namespace
+	 */
+	QUrl uri() const;
+
+	/**
+	 * All classes defined in this ontology, i.e. its namespace.
+	 */
+	QList<const Class*> allClasses() const;
+
+	/**
+	 * Search for a class in the ontology by its name.
+	 * \param name The name of the class.
+	 * \return the Class object identified by name or 0 if the class could not be found.
+	 */
+	const Class* findClassByName( const QString& name ) const;
+
+	/**
+	 * Search for a class in the ontology by its label.
+	 * \param label The label of the class (i.e. rdfs:label)
+	 * \param language The language in which the label was specified. If empty the default rdfs:label
+	 * is returned.
+	 * \return the Class object identified by label or 0 if the class could not be found.
+	 */ 
+	const Class* findClassByLabel( const QString& label, const QString& language = QString() ) const;
+
+	/**
+	 * Search for a class in the ontology by its name.
+	 * \param uri the URI of the class
+	 * \return the Class object identified by uri or 0 if the class could not be found.
+	 */ 
+	const Class* findClassByUri( const QUrl& uri ) const;
+
+        /**
+	 * A list of all properties defined in this ontology. This does not include properties that use
+	 * classes of this ontology but are defined in a different one.
+	 */
+	QList<const Property*> allProperties() const;
+
+	/**
+	 * Search for a property in the ontology by its name.
+	 * \param name The name of the property.
+	 * \return the Property object identified by name or 0 if the property could not be found.
+	 */ 
+	const Property* findPropertyByName( const QString& name ) const;
+
+	/**
+	 * Search for a property in the ontology by its label.
+	 * \param label The label of the property (i.e. rdfs:label)
+	 * \param language The language in which the label was specified. If empty the default rdfs:label
+	 * is returned.
+	 * \return the Property object identified by label or 0 if the property could not be found.
+	 */ 
+	const Property* findPropertyByLabel( const QString& label, const QString& language = QString() ) const;
+
+	/**
+	 * Search for a property in the ontology by its name.
+	 * \param uri the URI of the property
+	 * \return the Property object identified by uri or 0 if the property could not be found.
+	 */ 
+	const Property* findPropertyByUri( const QUrl& uri ) const;
+
+	/**
+	 * Loads an ontology.
+	 *
+	 * Dependancies are resolved automatically if possible.
+	 *
+	 * \return An Ontology object representing the ontology identified
+	 * by uri or an invalid Ontology object if the resource identified
+	 * by uri is either not an ontology or does not exist.
+	 */
+	static const Ontology* load( const QUrl& uri );
+
+    private:
+	class Private;
+	QSharedDataPointer<Private> d;
+
+	friend class OntologyManager;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/ontology_p.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/ontology_p.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/ontology_p.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/ontology_p.h.svn-base	2009-02-27 13:37:49.000000000 +0100
@@ -0,0 +1,76 @@
+/* This file is part of the Nepomuk-KDE libraries
+   Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_ONTOLOGY_PRIVATE_H_
+#define _NEPOMUK_ONTOLOGY_PRIVATE_H_
+
+#include "entity_p.h"
+#include "class.h"
+#include "property.h"
+
+#include <QtCore/QList>
+#include <QtCore/QUrl>
+#include <QtCore/QSharedData>
+
+namespace Nepomuk {
+    namespace Types {
+        class Class;
+        class Property;
+
+        class OntologyPrivate : public EntityPrivate
+        {
+        public:
+            OntologyPrivate( const QUrl& uri = QUrl() );
+
+            QList<Class> classes;
+            QList<Property> properties;
+
+            // -1 - unknown
+            // 0  - no
+            // 1  - yes
+            int entitiesAvailable;
+
+            bool addProperty( const QUrl& property, const Soprano::Node& value );
+            bool addAncestorProperty( const QUrl& ancestorResource, const QUrl& property );
+
+            void initEntities();
+            bool loadEntities();
+
+            void reset( bool recursive );
+        };
+    }
+}
+
+
+#include "ontology.h"
+namespace Nepomuk {
+
+    class Class;
+    class Property;
+
+    class Ontology::Private : public QSharedData
+    {
+    public:
+        QUrl uri;
+        QHash<QUrl, const Class*> classes;
+        QHash<QUrl, const Property*> properties;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/ontologyloader.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/ontologyloader.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/ontologyloader.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/ontologyloader.cpp.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,35 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "ontologyloader.h"
+
+class Nepomuk::OntologyLoader::Private
+{
+};
+
+Nepomuk::OntologyLoader::OntologyLoader()
+    :d( new Private() )
+{
+}
+
+
+Nepomuk::OntologyLoader::~OntologyLoader()
+{
+    delete d;
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/ontologyloader.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/ontologyloader.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/ontologyloader.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/ontologyloader.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,60 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_ONTOLOGY_LOADER_H_
+#define _NEPOMUK_ONTOLOGY_LOADER_H_
+
+#include <QtCore/QUrl>
+
+#include "nepomuk_export.h"
+
+namespace Soprano {
+    class Statement;
+}
+
+namespace Nepomuk {
+    
+    /**
+     * An OntologyLoader provides the statements that make up an ontology
+     * for the OntologyManager to create the ontology classes and properties.
+     *
+     * Typical implementations read RDF statements from RDF files or from the
+     * Nepomuk-KDE RDF store.
+     *
+     * \deprecated Ontologies should now be handled using the classes
+     * in the Nepomuk::Types namespace.
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT OntologyLoader
+    {
+    public:
+	virtual ~OntologyLoader();
+
+        // FIXME: use StatementIterator
+	virtual QList<Soprano::Statement> loadOntology( const QUrl& url ) = 0;
+
+    protected:
+	OntologyLoader();
+
+    private:
+	class Private;
+	Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/ontologymanager.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/ontologymanager.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/ontologymanager.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/ontologymanager.cpp.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,343 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "ontologymanager.h"
+#include "nepomukontologyloader.h"
+#include "desktopontologyloader.h"
+#include "ontology.h"
+#include "ontology_p.h"
+#include "class_p.h"
+#include "property_p.h"
+#include "entity_p.h"
+#include "global.h"
+
+#include <Soprano/Statement>
+#include <Soprano/Vocabulary/RDFS>
+#include <Soprano/Vocabulary/XMLSchema>
+
+#include <QtCore/QDebug>
+
+
+using namespace Soprano;
+
+class Nepomuk::OntologyManager::Private
+{
+public:
+    Private( OntologyManager* manager )
+        : userOntologyLoader( 0 ),
+          desktopOntologyLoader( 0 ),
+          nepomukOntologyLoader( 0 ),
+          m_manager( manager ) {
+    }
+
+    OntologyLoader* userOntologyLoader;
+    DesktopOntologyLoader* desktopOntologyLoader;
+    NepomukOntologyLoader* nepomukOntologyLoader;
+
+    // cache
+    QHash<QUrl, Ontology> ontoCache;
+    QHash<QUrl, Class> classCache;
+    QHash<QUrl, Property> propertyCache;
+
+    /**
+     * Find a class in the cache.
+     *
+     * \param recurse if true the method will try loading dependancies (i.e.
+     * other ontologies to fulfill the requirement
+     */
+    Class* findClass( const QUrl& uri, bool recurse = false ) {
+        QHash<QUrl, Class>::iterator it = classCache.find( uri );
+        if ( it != classCache.end() ) {
+            return &it.value();
+        }
+        else {
+            if ( recurse ) {
+                // try loading the ontology containing the class
+                QUrl parentNs = extractNamespace( uri );
+                if ( m_manager->getOntology( parentNs ) ) {
+                    return findClass( uri );
+                }
+            }
+            return 0;
+        }
+    }
+
+    /**
+     * Find a property in the cache.
+     *
+     * \param recurse if true the method will try loading dependancies (i.e.
+     * other ontologies to fulfill the requirement
+     */
+    Property* findProperty( const QUrl& uri, bool recurse = false ) {
+        QHash<QUrl, Property>::iterator it = propertyCache.find( uri );
+        if ( it != propertyCache.end() ) {
+            return &it.value();
+        }
+        else {
+            if ( recurse ) {
+                // try loading the ontology containing the property
+                QUrl parentNs = extractNamespace( uri );
+                if ( m_manager->getOntology( parentNs ) ) {
+                    return findProperty( uri );
+                }
+            }
+            return 0;
+        }
+    }
+
+private:
+    OntologyManager* m_manager;
+};
+
+
+Nepomuk::OntologyManager* Nepomuk::OntologyManager::instance()
+{
+    static OntologyManager* s_instance = 0;
+    if ( !s_instance ) {
+        s_instance = new OntologyManager();
+    }
+
+    return s_instance;
+}
+
+
+Nepomuk::OntologyManager::OntologyManager()
+    : d( new Private( this ) )
+{
+}
+
+
+Nepomuk::OntologyManager::~OntologyManager()
+{
+    delete d->userOntologyLoader;
+    delete d->desktopOntologyLoader;
+    delete d->nepomukOntologyLoader;
+    delete d;
+}
+
+
+void Nepomuk::OntologyManager::setOntologyLoader( OntologyLoader* loader )
+{
+    if ( d->userOntologyLoader != loader ) {
+        delete d->userOntologyLoader;
+    }
+    d->userOntologyLoader = loader;
+}
+
+
+const Nepomuk::Ontology* Nepomuk::OntologyManager::getOntology( const QUrl& uri )
+{
+    // if the ontology is already in the cache return it
+    //
+    QHash<QUrl, Ontology>::const_iterator it = d->ontoCache.constFind( uri );
+    if ( it != d->ontoCache.constEnd() ) {
+        return &it.value();
+    }
+
+    // if not in the cache, try loading it
+    //
+    else {
+        QList<Statement> sl;
+        if ( !d->userOntologyLoader ) {
+            if ( !d->desktopOntologyLoader ) {
+                d->desktopOntologyLoader = new DesktopOntologyLoader();
+            }
+            if ( !d->nepomukOntologyLoader ) {
+                d->nepomukOntologyLoader = new NepomukOntologyLoader();
+            }
+
+            // we prefer the NepomukOntologyLoader since it does not parse
+            // anything
+            sl = d->nepomukOntologyLoader->loadOntology( uri );
+            if ( sl.isEmpty() ) {
+                sl = d->desktopOntologyLoader->loadOntology( uri );
+            }
+        }
+        else {
+            sl = d->userOntologyLoader->loadOntology( uri );
+        }
+
+        if ( !sl.isEmpty() ) {
+            qDebug() << "(Nepomuk::OntologyManager) Found ontology " << uri << endl;
+            return constructOntology( uri, sl );
+        }
+        else {
+            // loading failed, i.e. ontology not stored.
+            //
+            qDebug() << "(Nepomuk::OntologyManager) Could not find ontology " << uri << endl;
+            return 0;
+        }
+    }
+}
+
+
+Nepomuk::Ontology* Nepomuk::OntologyManager::constructOntology( const QUrl& ontoUri, const QList<Statement>& sl )
+{
+    Ontology& ont = d->ontoCache[ ontoUri ];
+    ont.d->uri = ontoUri;
+
+    // FIXME: Is it possible to define classes and properties with different namespaces in one file?
+    //        Should we check the namespaces of the resources and if necessary create multiple Ontology
+    //        instances?
+
+    // step 1: collect all classes and properties
+    for ( QList<Statement>::const_iterator it = sl.constBegin(); it != sl.constEnd(); ++it ) {
+        const Statement& s = *it;
+        QUrl subjectUri( s.subject().uri() );
+        if( s.predicate().uri().toString().endsWith( "#type" ) ) {
+            if ( s.object().uri().toString().endsWith( "#Class" ) ) {
+                d->classCache.insert( subjectUri, Class() );
+                Class* c = &d->classCache[ subjectUri ];
+                Entity* entity = static_cast<Entity*>( c );
+                entity->d->uri = subjectUri;
+                entity->d->ontology = &ont;
+                ont.d->classes.insert( subjectUri, c );
+            }
+            else if ( s.object().uri().toString().endsWith( "#Property" ) ) {
+                d->propertyCache.insert( subjectUri, Property() );
+                Property* p = &d->propertyCache[ subjectUri ];
+                Entity* entity = static_cast<Entity*>( p );
+                entity->d->uri = subjectUri;
+                entity->d->ontology = &ont;
+                ont.d->properties.insert( subjectUri, p );
+            }
+            else {
+                qDebug() << "(OntologyManager) unknown type in ontology: " << s.object().uri();
+            }
+        }
+    }
+
+    // step 2: construct the classes and properties
+    for ( QList<Statement>::const_iterator it = sl.constBegin(); it != sl.constEnd(); ++it ) {
+        const Statement& s = *it;
+
+        // build the objects in the cache. If the ontology references another ontology try loading that one
+        // BIG PROBLEM: reverse dependancies of ontologies.
+        // If one ontology depends on another one which in turn depends on the first one. It should work
+        // since the first step already went through and thus, the class and property bodies have been created.
+
+        const QUrl& subjectUri = s.subject().uri();
+        Class* currentClass = d->findClass( subjectUri );
+        Property* currentProperty = ( currentClass ? ( Property* )0 : d->findProperty( subjectUri ) );
+        Entity* currentEntity = currentClass;
+        if ( !currentEntity ) {
+            currentEntity = currentProperty;
+        }
+
+        if ( !currentClass && !currentProperty ) {
+            qDebug() << "(OntologyManager) invalid ontology statement: " << s;
+            d->ontoCache.remove( ontoUri );
+            return 0;
+        }
+
+        if( s.predicate().uri().toString().endsWith( "#subClassOf" ) ) {
+            Class* parent = d->findClass( s.object().uri(), true );
+            if ( !parent ) {
+                qDebug() << "(OntologyManager) unable to load dependancy for: " << s;
+            }
+            else {
+                currentClass->d->parents.append( parent );
+                parent->d->children.append( currentClass );
+            }
+        }
+
+        if( s.predicate().uri().toString().endsWith( "#subPropertyOf" ) ) {
+            Property* parent = d->findProperty( s.object().uri(), true );
+            if ( !parent ) {
+                qDebug() << "(OntologyManager) unable to load dependancy for: " << s;
+            }
+            else {
+                currentProperty->d->parents.append( parent );
+                parent->d->children.append( currentProperty );
+            }
+        }
+
+        else if( s.predicate().toString().endsWith( "#domain" ) ) {
+            Class* domain = d->findClass( s.object().uri(), true );
+            if ( !domain ) {
+                qDebug() << "(OntologyManager) unable to load dependancy for: " << s;
+            }
+            else {
+                currentProperty->d->domain = domain;
+                domain->d->domainOf.insert( subjectUri, currentProperty );
+            }
+        }
+
+        else if( s.predicate().toString().endsWith( "#range" ) ) {
+            if ( s.object().toString().startsWith( Soprano::Vocabulary::XMLSchema::xsdNamespace().toString() ) ) {
+                currentProperty->d->literalRange = Literal( s.object().literal().toString() );
+            }
+            else {
+                Class* range = d->findClass( s.object().uri(), true );
+                if ( range ) {
+                    currentProperty->d->range = range;
+                    range->d->rangeOf.insert( subjectUri, currentProperty );
+                }
+                else {
+                    qDebug() << "(OntologyManager) unable to load dependancy for: " << s;
+                }
+            }
+        }
+
+        else if( s.predicate().toString().endsWith( "#minCardinality" ) ) {
+            currentProperty->d->minCardinality = s.object().literal().toInt();
+        }
+
+        else if( s.predicate().toString().endsWith( "#maxCardinality" ) ) {
+            currentProperty->d->maxCardinality = s.object().literal().toInt();
+        }
+
+        else if ( s.predicate().toString().endsWith( "#cardinality" ) ) {
+            currentProperty->d->cardinality = s.object().literal().toInt();
+        }
+
+        else if ( s.predicate().toString().endsWith( "#inverseProperty" ) ) {
+            Property* inverse = d->findProperty( s.object().toString(), true );
+            if ( !inverse ) {
+                qDebug() << "(OntologyManager) failed to load inverse property: " << s;
+                d->ontoCache.remove( ontoUri );
+                return 0;
+            }
+            currentProperty->d->inverse = inverse;
+            inverse->d->inverse = currentProperty;
+        }
+
+        // load l10n'ed comments
+        else if( s.predicate() == Soprano::Vocabulary::RDFS::comment() ) {
+            if ( s.object().language().isEmpty() ) {
+                currentEntity->d->comment = s.object().toString();
+            }
+            else {
+                currentEntity->d->l10nComments[s.object().language()] = s.object().toString();
+            }
+        }
+
+        // load l10n'ed labels
+        else if( s.predicate() == Soprano::Vocabulary::RDFS::label() ) {
+            if ( s.object().language().isEmpty() ) {
+                currentEntity->d->label = s.object().toString();
+            }
+            else {
+                currentEntity->d->l10nLabels[s.object().language()] = s.object().toString();
+            }
+        }
+    }
+
+    return &ont;
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/ontologymanager.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/ontologymanager.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/ontologymanager.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/ontologymanager.h.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,99 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_ONTOLOGY_MANAGER_H_
+#define _NEPOMUK_ONTOLOGY_MANAGER_H_
+
+#include <QtCore/QUrl>
+
+#include "nepomuk_export.h"
+
+namespace Soprano {
+    class Statement;
+}
+
+namespace Nepomuk {
+
+    class OntologyLoader;
+    class Ontology;
+
+    /**
+     * The OntologyManager is the central ontology cache handler.
+     * It is modeled as a singleton and its instance can be accessed
+     * through OntologyManager::instance.
+     *
+     * \deprecated Ontologies should be handled via the classes in
+     * Nepomuk::Types.
+     */
+    class KDE_DEPRECATED NEPOMUK_EXPORT OntologyManager
+    {
+    public:
+	~OntologyManager();
+
+	static OntologyManager* instance();
+
+	/**
+	 * Set an OntologyLoader to be used to retrieve 
+	 * the RDF statements that make up an ontology.
+	 *
+	 * By default Nepomuk uses a combination of the
+	 * NepomukOntologyLoader and DesktopOntologyLoader
+	 * where the NepomukOntologyLoader is the preferred
+	 * one, i.e. only if it is not able to load the
+	 * ontology DesktopOntologyLoader is used as a fallback.
+	 *
+	 * If an OntologyLoader is set no fallback loader will
+	 * be used. Thus, to force one of the default loaders
+	 * (for example the DesktopOntologyLoader) just do:
+	 *
+	 * \code
+	 * OntologyManager::instance()->setOntologyLoader( new DesktopOntologyLoader() );
+	 * \endcode
+	 *
+	 * OntologyManager will take over ownership of loader.
+	 *
+	 * Overwriting the loader will delete any loader previously
+	 * set via setOntologyLoader.
+	 */
+	void setOntologyLoader( OntologyLoader* loader );
+
+	/**
+	 * Attempt to load the ontology referenced by uri.
+	 * If the manager already has the ontology in the cache
+	 * it is simply returned. Otherwise the manager tries 
+	 * to load the ontology from one of the configured
+	 * OntologyLoader instances.
+	 *
+	 * \return The requested ontology or 0 in case it could
+	 * not be found, i.e. none of the OntologyLoader instances
+	 * could provide the RDF statements making up the ontology.
+	 */
+	const Ontology* getOntology( const QUrl& uri );
+
+    private:
+	OntologyManager();
+
+	Ontology* constructOntology( const QUrl& uri, const QList<Soprano::Statement>& sl );
+
+	class Private;
+	Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/property.cpp.svn-base nepomuk-svn/core/ontology/.svn/text-base/property.cpp.svn-base
--- nepomuk/core/ontology/.svn/text-base/property.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/property.cpp.svn-base	2009-02-27 13:37:51.000000000 +0100
@@ -0,0 +1,492 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "property.h"
+#include "property_p.h"
+#include "class.h"
+#include "ontology.h"
+#include "literal.h"
+#include "entitymanager.h"
+
+#include <Soprano/Vocabulary/RDFS>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/XMLSchema>
+
+#undef D
+#define D static_cast<Nepomuk::Types::PropertyPrivate*>( d.data() )
+
+Nepomuk::Types::PropertyPrivate::PropertyPrivate( const QUrl& uri )
+    : EntityPrivate( uri ),
+      minCardinality( -1 ),
+      maxCardinality( -1 ),
+      cardinality( -1 )
+{
+}
+
+
+bool Nepomuk::Types::PropertyPrivate::addProperty( const QUrl& property, const Soprano::Node& value )
+{
+    if( property == Soprano::Vocabulary::RDFS::subPropertyOf() ) {
+        parents.append( value.uri() );
+        return true;
+    }
+
+    else if( property == Soprano::Vocabulary::RDFS::domain() ) {
+        domain = value.uri();
+        return true;
+    }
+
+    else if( property == Soprano::Vocabulary::RDFS::range() ) {
+        if ( value.toString().startsWith( Soprano::Vocabulary::XMLSchema::xsdNamespace().toString() ) ) {
+            literalRange = Literal( value.uri() );
+        }
+        else if ( value.uri() == Soprano::Vocabulary::RDFS::Literal()) {
+            literalRange = Literal( value.uri() );
+        }
+        else {
+            range = value.uri();
+        }
+        return true;
+    }
+
+    else if( property == Soprano::Vocabulary::NRL::minCardinality() ) {
+        minCardinality = value.literal().toInt();
+        return true;
+    }
+
+    else if( property == Soprano::Vocabulary::NRL::maxCardinality() ) {
+        maxCardinality = value.literal().toInt();
+        return true;
+    }
+
+    else if ( property == Soprano::Vocabulary::NRL::cardinality() ) {
+        cardinality = value.literal().toInt();
+        return true;
+    }
+
+    else if ( property == Soprano::Vocabulary::NRL::inverseProperty() ) {
+        inverse = value.uri();
+        return true;
+    }
+
+    return false;
+}
+
+
+bool Nepomuk::Types::PropertyPrivate::addAncestorProperty( const QUrl& ancestorResource, const QUrl& property )
+{
+    if( property == Soprano::Vocabulary::RDFS::subPropertyOf() ) {
+        children.append( ancestorResource );
+        return true;
+    }
+    else if ( property == Soprano::Vocabulary::NRL::inverseProperty() ) {
+        inverse = ancestorResource;
+        return true;
+    }
+
+    return false;
+}
+
+
+void Nepomuk::Types::PropertyPrivate::reset( bool recursive )
+{
+    EntityPrivate::reset( recursive );
+
+    QMutexLocker lock( &mutex );
+
+    if ( available != -1 ) {
+        if ( recursive ) {
+            range.reset( true );
+            domain.reset( true );
+            inverse.reset( true );
+            foreach( Property p, parents ) {
+                p.reset( true );
+            }
+        }
+
+        parents.clear();
+        available = -1;
+    }
+
+    if ( ancestorsAvailable != -1 ) {
+        if ( recursive ) {
+            foreach( Property p, children ) {
+                p.reset( true );
+            }
+        }
+
+        children.clear();
+        ancestorsAvailable = -1;
+    }
+}
+
+
+
+Nepomuk::Types::Property::Property()
+    : Entity()
+{
+    d = 0;
+}
+
+
+Nepomuk::Types::Property::Property( const QUrl& uri )
+    : Entity()
+{
+    d = EntityManager::self()->getProperty( uri );
+}
+
+
+Nepomuk::Types::Property::Property( const Property& other )
+    : Entity( other )
+{
+}
+
+
+Nepomuk::Types::Property::~Property()
+{
+}
+
+
+Nepomuk::Types::Property& Nepomuk::Types::Property::operator=( const Property& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+QList<Nepomuk::Types::Property> Nepomuk::Types::Property::parentProperties()
+{
+    if ( d ) {
+        D->init();
+        return D->parents;
+    }
+    else {
+        return QList<Nepomuk::Types::Property>();
+    }
+}
+
+
+QList<Nepomuk::Types::Property> Nepomuk::Types::Property::subProperties()
+{
+    if ( d ) {
+        D->initAncestors();
+        return D->children;
+    }
+    else {
+        return QList<Nepomuk::Types::Property>();
+    }
+}
+
+
+Nepomuk::Types::Property Nepomuk::Types::Property::inverseProperty()
+{
+    if ( d ) {
+        D->init();
+        D->initAncestors();
+        return D->inverse;
+    }
+    else {
+        return Property();
+    }
+}
+
+
+Nepomuk::Types::Class Nepomuk::Types::Property::range()
+{
+    if ( d ) {
+        D->init();
+
+        if( D->range.isValid() ) {
+            return D->range;
+        }
+        else if( !literalRangeType().isValid() ) {
+            // try getting a domain from one of the parent properties
+            for( int i = 0; i < D->parents.count(); ++i ) {
+                Class pr = D->parents[i].range();
+                if( pr.isValid() ) {
+                    return pr;
+                }
+            }
+
+            // if we have no literal range type, we fall back to rdfs:Resource
+            return Class( Soprano::Vocabulary::RDFS::Resource() );
+        }
+        else {
+            // other than domain() we do not use a general fallback since the range
+            // might be a literalRangeType()
+            return Class();
+        }
+    }
+    else {
+        return Class();
+    }
+}
+
+
+Nepomuk::Types::Literal Nepomuk::Types::Property::literalRangeType()
+{
+    if ( d ) {
+        D->init();
+
+        if( D->literalRange.isValid() ) {
+            return D->literalRange;
+        }
+        else {
+            // try getting a domain from one of the parent properties
+            // We cannot check the resource range here since that would
+            // result in an endless loop
+            for( int i = 0; i < D->parents.count(); ++i ) {
+                Literal pr = D->parents[i].literalRangeType();
+                if( pr.isValid() ) {
+                    return pr;
+                }
+            }
+
+            // fallback is an invalid range which will then result in
+            // range() returning a valid one
+            return Literal();
+        }
+    }
+    else {
+        return Literal();
+    }
+}
+
+
+Nepomuk::Types::Class Nepomuk::Types::Property::domain()
+{
+    if ( d ) {
+        D->init();
+
+        if( D->domain.isValid() ) {
+            return D->domain;
+        }
+        else {
+            // try getting a domain from one of the parent properties
+            for( int i = 0; i < D->parents.count(); ++i ) {
+                Class pd = D->parents[i].domain();
+                if( pd.isValid() ) {
+                    return pd;
+                }
+            }
+
+            // fallback: rdfs:Resource
+            return Class( Soprano::Vocabulary::RDFS::Resource() );
+        }
+    }
+    else {
+        return Class();
+    }
+}
+
+
+int Nepomuk::Types::Property::cardinality()
+{
+    if ( d ) {
+        D->init();
+        return D->cardinality;
+    }
+    else {
+        return -1;
+    }
+}
+
+
+int Nepomuk::Types::Property::minCardinality()
+{
+    if ( d ) {
+        D->init();
+        if ( D->minCardinality > 0 ) {
+            return D->minCardinality;
+        }
+        else {
+            return D->cardinality;
+        }
+    }
+    else {
+        return -1;
+    }
+}
+
+
+int Nepomuk::Types::Property::maxCardinality()
+{
+    if ( d ) {
+        D->init();
+        if ( D->maxCardinality > 0 ) {
+            return D->maxCardinality;
+        }
+        else {
+            return D->cardinality;
+        }
+    }
+    else {
+        return -1;
+    }
+}
+
+
+bool Nepomuk::Types::Property::isParentOf( const Property& other )
+{
+    if ( d ) {
+        D->initAncestors();
+
+        if ( D->children.contains( other ) ) {
+            return true;
+        }
+        else {
+            for ( QList<Nepomuk::Types::Property>::iterator it = D->children.begin();
+                  it != D->children.end(); ++it ) {
+                if ( ( *it ).isParentOf( other ) ) {
+                    return true;
+                }
+            }
+        }
+    }
+
+    return false;
+}
+
+
+bool Nepomuk::Types::Property::isSubPropertyOf( const Property& other )
+{
+    if ( d ) {
+        D->init();
+
+        if ( D->parents.contains( other ) ) {
+            return true;
+        }
+        else {
+            for ( QList<Nepomuk::Types::Property>::iterator it = D->parents.begin();
+                  it != D->parents.end(); ++it ) {
+                if ( ( *it ).isSubPropertyOf( other ) ) {
+                    return true;
+                }
+            }
+        }
+    }
+
+    return false;
+}
+
+
+
+
+
+// Start of code for deprecated Property
+// -------------------------------------
+#include "global.h"
+#include "ontologymanager.h"
+
+Nepomuk::Property::Property()
+    : Entity()
+{
+    d = new Private();
+}
+
+
+Nepomuk::Property::Property( const Property& other )
+    : Entity( other )
+{
+    d = other.d;
+}
+
+
+Nepomuk::Property::~Property()
+{
+}
+
+
+Nepomuk::Property& Nepomuk::Property::operator=( const Property& other )
+{
+    d = other.d;
+    return *this;
+}
+
+
+QList<const Nepomuk::Property*> Nepomuk::Property::parentProperties() const
+{
+    return d->parents;
+}
+
+
+QList<const Nepomuk::Property*> Nepomuk::Property::parentOf() const
+{
+    return d->children;
+}
+
+
+const Nepomuk::Property* Nepomuk::Property::inverseProperty() const
+{
+    return d->inverse;
+}
+
+
+const Nepomuk::Class* Nepomuk::Property::range() const
+{
+    return d->range;
+}
+
+
+Nepomuk::Literal Nepomuk::Property::literalRangeType() const
+{
+    return d->literalRange;
+}
+
+
+const Nepomuk::Class* Nepomuk::Property::domain() const
+{
+    return d->domain;
+}
+
+
+int Nepomuk::Property::cardinality() const
+{
+    return d->cardinality;
+}
+
+
+int Nepomuk::Property::minCardinality() const
+{
+    return d->minCardinality;
+}
+
+
+int Nepomuk::Property::maxCardinality() const
+{
+    return d->maxCardinality;
+}
+
+
+const Nepomuk::Property* Nepomuk::Property::load( const QUrl& uri )
+{
+    QUrl ns = extractNamespace( uri );
+
+    // load the ontology in the cache
+    const Ontology* ont = OntologyManager::instance()->getOntology( ns );
+
+    // return the requested class or an invalid one if the ontology
+    // was not found
+    if ( ont ) {
+        return ont->findPropertyByUri( uri );
+    }
+    else {
+        return 0;
+    }
+}
diff -u -r -N nepomuk/core/ontology/.svn/text-base/property.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/property.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/property.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/property.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,298 @@
+/* This file is part of the Nepomuk-KDE libraries
+   Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_PROPERTY_H_
+#define _NEPOMUK_PROPERTY_H_
+
+#include <QtCore/QList>
+#include <QtCore/QUrl>
+#include <QtCore/QString>
+#include <QtCore/QVariant>
+#include <QtCore/QSharedData>
+
+#include "entity.h"
+#include "nepomuk_export.h"
+
+namespace Nepomuk {
+    namespace Types {
+
+        class Class;
+        class Literal;
+
+        /**
+         * \class Property property.h Nepomuk/Types/Property
+         *
+         * \brief A property is a resource of type rdf:Property which relates a domain
+         * with a range. The latter one can be a Literal or a Class.
+         *
+         * Property instances are explicitly shared. Two instances created
+         * with the same uri reference the same data.
+         *
+         * While Resource objects can be changed Property instances are considered
+         * to be static and never changed during their lifetime.
+         *
+         * \author Sebastian Trueg <trueg@kde.org>
+         */ 
+        class NEPOMUK_EXPORT Property : public Entity
+        {
+        public:
+            /**
+             * Default constructor. Creates an empty Property.
+             */
+            Property();
+
+            /**
+             * Create the property referred to by \p uri.
+             * The result is either a valid property which could be loaded from the
+             * Nepomuk store or a simple property which only contains the uri.
+             *
+             * Be aware that the data is only loaded once read.
+             *
+             * Subsequent calls result in a simple hash lookup of cached data.
+             */
+            Property( const QUrl& uri );
+
+            /**
+             * Default copy constructor
+             */
+            Property( const Property& );
+
+            /**
+             * Destructor
+             */
+            ~Property();
+
+            /**
+             * Copy operator.
+             */
+            Property& operator=( const Property& );
+
+            /**
+             * Each property can have multiple parent properties.
+             * \return A list of all parent properties of this property.
+             * If the list is emppty it means that the property has no direct
+             * parents, i.e. it is derived from rdf:Resource.
+             */
+            QList<Property> parentProperties();
+
+            /**
+             * \return A list of all properties that have this property as a parent.
+             * Be aware that this list can never be final since other ontologies
+             * that have not been loaded yet may contain properties that are derived
+             * from this property.
+             */
+            QList<Property> subProperties();
+
+            /**
+             * The inverse property (nrl:inverseProperty).
+             * \return A Property instance representing the inverse property of this one
+             * or 0 if none was specified in the ontology.
+             */
+            Property inverseProperty();
+
+            /**
+             * The range of the property.
+             * \return The range of the property or an invalid Class in case
+             * the range of this poperty is a literal.
+             * \sa literalRange
+             */
+            Class range();
+
+            /**
+             * If the rage of this property is a literal (i.e. range returns an invalid Class)
+             * this method provides the literal type.
+             *
+             * \returns the literal type of this property or an empty, invalid Literal
+             * if the range is a Class.
+             *
+             * \sa range
+             */
+            Literal literalRangeType();
+
+            /**
+             * The domain of the property.
+             */
+            Class domain();
+
+            /**
+             * The cardinality of this property as specified by nrl:cardinality.
+             *
+             * \return the cardinality of the property or -1 if none was set.
+             */
+            int cardinality();
+
+            /**
+             * The minimum cardinality of this property as specified by nrl:minCardinality.
+             *
+             * \return the minimum cardinality of the property or -1 if none was set.
+             */
+            int minCardinality();
+
+            /**
+             * The maximum cardinality of this property as specified by nrl:maxCardinality.
+             *
+             * \return the maximum cardinality of the property or -1 if none was set.
+             */
+            int maxCardinality();
+
+            /**
+             * Check if a property inherits this property. This is a recursive method which
+             * does not only check direct child propertyes.
+             *
+             * \return true if other is derived from this property, false otherwise.
+             */
+            bool isParentOf( const Property& other );
+
+            /**
+             * Check if this property is derived from another property. This is a recursive method which
+             * does not only check direct child propertyes.
+             *
+             * \return true if this property is derived from other, false otherwise.
+             */
+            bool isSubPropertyOf( const Property& other );
+        };
+    }
+}
+
+
+
+
+namespace Nepomuk {
+
+    class Ontology;
+    class Class;
+    class Literal;
+
+    /**
+     * A property is a resource of type rdf:Property which relates a domain
+     * with a range. The latter one can be a literal in addition to a Class.
+     *
+     * \deprecated in favor of Nepomuk::Types::Property
+     */ 
+    class KDE_DEPRECATED NEPOMUK_EXPORT Property : public Entity
+    {
+    public:
+	/**
+	 * Default constructor. Creates an empty Property.
+	 */
+	Property();
+
+	/**
+	 * Default copy constructor
+	 */
+	Property( const Property& );
+
+	/**
+	 * Destructor
+	 */
+	~Property();
+
+	Property& operator=( const Property& );
+
+	/**
+	 * Each property can have multiple parent properties.
+	 * \return A list of all parent properties of this property.
+	 * If the list is emppty it means that the property has no direct
+	 * parents, i.e. it is derived from rdf:Resource.
+	 */
+	QList<const Property*> parentProperties() const;
+
+	/**
+	 * \return A list of all properties that have this property as a parent.
+	 * Be aware that this list can never be final since other ontologies
+	 * that have not been loaded yet may contain properties that are derived
+	 * from this property.
+	 */
+	QList<const Property*> parentOf() const;
+
+	/**
+	 * The inverse property (nrl:inverseProperty).
+	 * \return A Property instance representing the inverse property of this one
+	 * or 0 if none was specified in the ontology.
+	 */
+	const Property* inverseProperty() const;
+
+	/**
+	 * The range of the property.
+	 * \return The range of the property or an invalid Class in case
+	 * the range of this poperty is a literal.
+	 * \sa literalRange
+	 */
+	const Class* range() const;
+
+	/**
+	 * If the rage of this property is a literal (i.e. range returns 0)
+	 * this method provides the literal type.
+	 *
+	 * \returns the literal type of this property or an empty, invalid Literal
+	 * if the range is a Class.
+	 *
+	 * \sa range
+	 */
+	Literal literalRangeType() const;
+
+	/**
+	 * The domain of the property.
+	 */
+	const Class* domain() const;
+
+	/**
+	 * The cardinality of this property as specified by nrl:cardinality.
+	 *
+	 * \return the cardinality of the property or -1 if none was set.
+	 */
+	int cardinality() const;
+
+	/**
+	 * The minimum cardinality of this property as specified by nrl:minCardinality.
+	 *
+	 * \return the minimum cardinality of the property or -1 if none was set.
+	 */
+	int minCardinality() const;
+
+	/**
+	 * The maximum cardinality of this property as specified by nrl:maxCardinality.
+	 *
+	 * \return the maximum cardinality of the property or -1 if none was set.
+	 */
+	int maxCardinality() const;
+
+	// QString unit() const;
+
+	/**
+	 * Loads a property actually including the whole ontology
+	 * it is declared in.
+	 *
+	 * Dependancies are resolved automatically if possible.
+	 *
+	 * \return A property object representing the property identified
+	 * by uri or an invalid Property object if the resource identified
+	 * by uri is either not a property or does not exist.
+	 */
+	static const Property* load( const QUrl& uri );
+
+    private:
+	class Private;
+	QSharedDataPointer<Private> d;
+
+	friend class OntologyManager;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/.svn/text-base/property_p.h.svn-base nepomuk-svn/core/ontology/.svn/text-base/property_p.h.svn-base
--- nepomuk/core/ontology/.svn/text-base/property_p.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/.svn/text-base/property_p.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,94 @@
+/* This file is part of the Nepomuk-KDE libraries
+   Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _NEPOMUK_PROPERTY_PRIVATE_H_
+#define _NEPOMUK_PROPERTY_PRIVATE_H_
+
+#include "entity_p.h"
+#include "property.h"
+#include "literal.h"
+#include "class.h"
+
+#include <QtCore/QVariant>
+#include <QtCore/QSharedData>
+
+namespace Nepomuk {
+    namespace Types {
+        class PropertyPrivate : public EntityPrivate
+        {
+        public:
+            PropertyPrivate( const QUrl& uri = QUrl() );
+
+            Class range;
+            Class domain;
+
+            Literal literalRange;
+
+            Property inverse;
+
+            QList<Property> parents;
+            QList<Property> children;
+
+            int minCardinality;
+            int maxCardinality;
+            int cardinality;
+
+            bool addProperty( const QUrl& property, const Soprano::Node& value );
+            bool addAncestorProperty( const QUrl& ancestorResource, const QUrl& property );
+
+            void reset( bool recursive );
+        };
+    }
+}
+
+
+
+namespace Nepomuk {
+
+    class Class;
+
+    class Property::Private : public QSharedData
+    {
+    public:
+        Private()
+            : range( 0 ),
+            domain( 0 ),
+            inverse( 0 ),
+            minCardinality( -1 ),
+            maxCardinality( -1 ),
+            cardinality( -1 ) {
+	    }
+
+	    const Class* range;
+	    const Class* domain;
+
+	    Literal literalRange;
+
+	    const Property* inverse;
+
+	    QList<const Property*> parents;
+	    QList<const Property*> children;
+
+	    int minCardinality;
+	    int maxCardinality;
+	    int cardinality;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ontology/CMakeLists.txt nepomuk-svn/core/ontology/CMakeLists.txt
--- nepomuk/core/ontology/CMakeLists.txt	2008-05-21 13:07:45.000000000 +0200
+++ nepomuk-svn/core/ontology/CMakeLists.txt	2009-02-27 13:37:52.000000000 +0100
@@ -12,7 +12,7 @@
   fileontologyloader.h
   desktopontologyloader.h
   global.h
-  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk
+  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
 )
 
 add_subdirectory(test)
diff -u -r -N nepomuk/core/ontology/entity.cpp nepomuk-svn/core/ontology/entity.cpp
--- nepomuk/core/ontology/entity.cpp	2009-02-26 15:18:34.000000000 +0100
+++ nepomuk-svn/core/ontology/entity.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -32,6 +32,7 @@
 
 #include <kicon.h>
 
+
 Nepomuk::Types::EntityPrivate::EntityPrivate( const QUrl& uri_ )
     : uri( uri_ ),
       available( uri_.isValid() ? -1 : 0 ),
diff -u -r -N nepomuk/core/ontology/entitymanager.h nepomuk-svn/core/ontology/entitymanager.h
--- nepomuk/core/ontology/entitymanager.h	2009-02-26 15:18:34.000000000 +0100
+++ nepomuk-svn/core/ontology/entitymanager.h	2009-02-27 13:37:52.000000000 +0100
@@ -25,6 +25,7 @@
 #include <QtCore/QSharedData>
 #include <QtCore/QMutex>
 
+
 namespace Soprano {
     class Statement;
 }
diff -u -r -N nepomuk/core/ontology/test/.svn/all-wcprops nepomuk-svn/core/ontology/test/.svn/all-wcprops
--- nepomuk/core/ontology/test/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/all-wcprops	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,47 @@
+K 25
+svn:wc:ra_dav:version-url
+V 70
+/home/kde/!svn/ver/852594/trunk/KDE/kdelibs/nepomuk/core/ontology/test
+END
+kontotest.h
+K 25
+svn:wc:ra_dav:version-url
+V 82
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/ontology/test/kontotest.h
+END
+desktopontologyloadertest.h
+K 25
+svn:wc:ra_dav:version-url
+V 98
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/ontology/test/desktopontologyloadertest.h
+END
+entitytest.h
+K 25
+svn:wc:ra_dav:version-url
+V 83
+/home/kde/!svn/ver/762174/trunk/KDE/kdelibs/nepomuk/core/ontology/test/entitytest.h
+END
+kontotest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 84
+/home/kde/!svn/ver/746900/trunk/KDE/kdelibs/nepomuk/core/ontology/test/kontotest.cpp
+END
+desktopontologyloadertest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 100
+/home/kde/!svn/ver/721704/trunk/KDE/kdelibs/nepomuk/core/ontology/test/desktopontologyloadertest.cpp
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 85
+/home/kde/!svn/ver/852594/trunk/KDE/kdelibs/nepomuk/core/ontology/test/CMakeLists.txt
+END
+entitytest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 85
+/home/kde/!svn/ver/829275/trunk/KDE/kdelibs/nepomuk/core/ontology/test/entitytest.cpp
+END
diff -u -r -N nepomuk/core/ontology/test/.svn/entries nepomuk-svn/core/ontology/test/.svn/entries
--- nepomuk/core/ontology/test/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/entries	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,266 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/core/ontology/test
+https://svn.kde.org/home/kde
+
+
+
+2008-08-26T03:38:57.593605Z
+852594
+mattr
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+kontotest.h
+file
+
+
+
+
+2009-02-27T12:37:50.000000Z
+ed1ee3860c19fd38536167b1cff8e369
+2007-04-16T20:48:48.147311Z
+654730
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1138
+
+desktopontologyloadertest.h
+file
+
+
+
+
+2009-02-27T12:37:50.000000Z
+be62a62d673b7c7596a832e074067488
+2007-04-16T20:48:48.147311Z
+654730
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1182
+
+entitytest.h
+file
+
+
+
+
+2009-02-27T12:37:50.000000Z
+1d6c19afc17abc8019863739f19533ad
+2008-01-16T12:37:29.025381Z
+762174
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1091
+
+kontotest.cpp
+file
+
+
+
+
+2009-02-27T12:37:50.000000Z
+11b6b349a7d07335d5e31f668dabeb36
+2007-12-10T15:28:57.603131Z
+746900
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+7253
+
+desktopontologyloadertest.cpp
+file
+
+
+
+
+2009-02-27T12:37:50.000000Z
+2fa48b268c42c9a0e174c2bf30ab6cd3
+2007-10-05T22:21:25.074752Z
+721704
+apaku
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4167
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:50.000000Z
+6f9095b701a4420ce63fe7058cfe8997
+2008-08-26T03:38:57.593605Z
+852594
+mattr
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+520
+
+entitytest.cpp
+file
+
+
+
+
+2009-02-27T12:37:50.000000Z
+e9542039238fed5b0096e0a0a3059354
+2008-07-07T23:46:37.001233Z
+829275
+dfaure
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1885
+
diff -u -r -N nepomuk/core/ontology/test/.svn/format nepomuk-svn/core/ontology/test/.svn/format
--- nepomuk/core/ontology/test/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/format	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/core/ontology/test/.svn/prop-base/CMakeLists.txt.svn-base nepomuk-svn/core/ontology/test/.svn/prop-base/CMakeLists.txt.svn-base
--- nepomuk/core/ontology/test/.svn/prop-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/prop-base/CMakeLists.txt.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mime-type
+V 10
+text/plain
+END
diff -u -r -N nepomuk/core/ontology/test/.svn/prop-base/kontotest.cpp.svn-base nepomuk-svn/core/ontology/test/.svn/prop-base/kontotest.cpp.svn-base
--- nepomuk/core/ontology/test/.svn/prop-base/kontotest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/prop-base/kontotest.cpp.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/test/.svn/prop-base/kontotest.h.svn-base nepomuk-svn/core/ontology/test/.svn/prop-base/kontotest.h.svn-base
--- nepomuk/core/ontology/test/.svn/prop-base/kontotest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/prop-base/kontotest.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ontology/test/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/core/ontology/test/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/core/ontology/test/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,15 @@
+project(konto_test)
+
+include_directories(
+  ${nepomukcore_SOURCE_DIR}/ontology
+)
+
+include_directories( ${KDE4_KIO_INCLUDES} ${CMAKE_SOURCE_DIR}/konto )
+include_directories( ${QT_INCLUDES} ${SOPRANO_INCLUDE_DIR} )
+set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
+
+# tests
+kde4_add_unit_test(entitytest entitytest.cpp)
+target_link_libraries(entitytest nepomuk ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} 
+                                         ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY}
+					 ${SOPRANO_LIBRARIES})
diff -u -r -N nepomuk/core/ontology/test/.svn/text-base/desktopontologyloadertest.cpp.svn-base nepomuk-svn/core/ontology/test/.svn/text-base/desktopontologyloadertest.cpp.svn-base
--- nepomuk/core/ontology/test/.svn/text-base/desktopontologyloadertest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/text-base/desktopontologyloadertest.cpp.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,103 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "desktopontologyloadertest.h"
+#include "desktopontologyloader.h"
+
+#include <QtTest/QTest>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QTextStream>
+#include <QtCore/QList>
+
+#include <kstandarddirs.h>
+#include <kconfiggroup.h>
+#include <kdesktopfile.h>
+#include <kurl.h>
+#include <kio/global.h>
+#include <kio/deletejob.h>
+#include <qtest_kde.h>
+
+#include <Soprano/Statement>
+
+
+void DesktopOntologyLoaderTest::initTestCase()
+{
+    // create our test folder
+    QDir tmpDir( "/tmp" );
+    tmpDir.mkpath( "konto_desktopontologyloader_test/knepomuk/ontologies" );
+    KGlobal::dirs()->addResourceDir( "data", "/tmp/konto_desktopontologyloader_test" );
+
+    // create our little test ontology
+    QFile ontoFile( "/tmp/konto_desktopontologyloader_test/knepomuk/ontologies/test.nrl" );
+    ontoFile.open( QIODevice::WriteOnly );
+    QTextStream ontoStream( &ontoFile );
+
+    // the header
+    ontoStream << "<?xml version='1.0' encoding='UTF-8'?>" << endl
+               << "<!DOCTYPE rdf:RDF [" << endl
+               << "<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>" << endl
+               << "<!ENTITY nrl 'http://semanticdesktop.org/ontologies/2006/11/24/nrl#'>" << endl
+               << "<!ENTITY nao 'http://semanticdesktop.org/ontologies/2007/03/31/nao#'>" << endl
+               << "<!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>" << endl
+               << "<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>" << endl
+               << "<!ENTITY test 'http://test.org/test#'>" << endl
+               << "]>" << endl
+               << "<rdf:RDF xmlns:rdf=\"&rdf;\" xmlns:rdfs=\"&rdfs;\" xmlns:nrl=\"&nrl;\" xmlns:nao=\"&nao;\" xmlns:xsd=\"&xsd;\">" << endl;
+
+    // one class
+    ontoStream << "<rdf:Description rdf:about=\"&test;Test\">" << endl
+               << "<rdfs:label>test</rdfs:label>" << endl
+               << "<rdf:type rdf:resource=\"&rdfs;Class\"/>" << endl
+               << "</rdf:Description>" << endl;
+
+    // the footer
+    ontoStream << "</rdf:RDF>" << endl;
+
+    KDesktopFile desktopFile( "/tmp/konto_desktopontologyloader_test/knepomuk/ontologies/test.desktop" );
+    KConfigGroup desktopGroup( desktopFile.desktopGroup() );
+    desktopGroup.writeEntry( "Type", "Link" );
+    desktopGroup.writeEntry( "Name", "Test Ontology" );
+    desktopGroup.writeEntry( "MimeType", "text/rdf" );
+    desktopGroup.writeEntry( "Path", "test.nrl" );
+    desktopGroup.writeEntry( "URL", "http://test.org/test" );
+}
+
+
+void DesktopOntologyLoaderTest::testLoading()
+{
+    Nepomuk::DesktopOntologyLoader loader;
+    QList<Soprano::Statement> sl = loader.loadOntology( QUrl( "http://test.org/test" ) );
+    QVERIFY( !sl.isEmpty() );
+    QCOMPARE( sl.count(), 2 );
+}
+
+
+void DesktopOntologyLoaderTest::cleanupTestCase()
+{
+    QFile::remove( "/tmp/konto_desktopontologyloader_test/knepomuk/ontologies/test.desktop" );
+    QFile::remove( "/tmp/konto_desktopontologyloader_test/knepomuk/ontologies/test.nrl" );
+    QDir( "/tmp/konto_desktopontologyloader_test/knepomuk/" ).rmdir( "ontologies" );
+    QDir( "/tmp/konto_desktopontologyloader_test" ).rmdir( "knepomuk" );
+    QDir( "/tmp/" ).rmdir( "konto_desktopontologyloader_test" );
+}
+
+QTEST_KDEMAIN( DesktopOntologyLoaderTest, NoGUI )
+
+#include "desktopontologyloadertest.moc"
diff -u -r -N nepomuk/core/ontology/test/.svn/text-base/desktopontologyloadertest.h.svn-base nepomuk-svn/core/ontology/test/.svn/text-base/desktopontologyloadertest.h.svn-base
--- nepomuk/core/ontology/test/.svn/text-base/desktopontologyloadertest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/text-base/desktopontologyloadertest.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,35 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KONTO_DESKTOP_ONTOLOGY_LOADER_TEST_H_
+#define _KONTO_DESKTOP_ONTOLOGY_LOADER_TEST_H_
+
+#include <QtCore/QObject>
+
+class DesktopOntologyLoaderTest : public QObject
+{
+    Q_OBJECT
+
+private Q_SLOTS:
+    void initTestCase();
+    void testLoading();
+    void cleanupTestCase();
+};
+
+#endif
diff -u -r -N nepomuk/core/ontology/test/.svn/text-base/entitytest.cpp.svn-base nepomuk-svn/core/ontology/test/.svn/text-base/entitytest.cpp.svn-base
--- nepomuk/core/ontology/test/.svn/text-base/entitytest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/text-base/entitytest.cpp.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,66 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "entitytest.h"
+#include "../class.h"
+#include "../property.h"
+
+#include <kdebug.h>
+#include <qtest_kde.h>
+#include <QtDBus/QtDBus>
+
+#include <Soprano/Vocabulary/RDFS>
+
+using namespace Nepomuk::Types;
+
+
+void EntityTest::testClass()
+{
+    if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.nepomuk.services.nepomukstorage")) {
+        QSKIP("nepomuk not running", SkipAll);
+    }
+
+    Class c1( Soprano::Vocabulary::RDFS::Resource() );
+    Class c2( Soprano::Vocabulary::RDFS::Resource() );
+
+    QVERIFY( c1.isValid() );
+    QVERIFY( c2.isValid() );
+
+    QVERIFY( c1.isAvailable() );
+    QVERIFY( c2.isAvailable() );
+
+    QCOMPARE( c1.uri(), c2.uri() );
+    QCOMPARE( c1.name(), c2.name() );
+    QCOMPARE( c1.label(), c2.label() );
+    QCOMPARE( c1.comment(), c2.comment() );
+
+    QVERIFY( !c1.label().isEmpty() );
+
+    qDebug() << c1.label() << c1.comment();
+}
+
+
+void EntityTest::testProperty()
+{
+}
+
+
+QTEST_KDEMAIN(EntityTest, NoGUI)
+
+#include "entitytest.moc"
diff -u -r -N nepomuk/core/ontology/test/.svn/text-base/entitytest.h.svn-base nepomuk-svn/core/ontology/test/.svn/text-base/entitytest.h.svn-base
--- nepomuk/core/ontology/test/.svn/text-base/entitytest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/text-base/entitytest.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,34 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _ENTITY_TEST_H_
+#define _ENTITY_TEST_H_
+
+#include <QtCore/QObject>
+
+class EntityTest : public QObject
+{
+    Q_OBJECT
+
+private Q_SLOTS:
+    void testClass();
+    void testProperty();
+};
+
+#endif
diff -u -r -N nepomuk/core/ontology/test/.svn/text-base/kontotest.cpp.svn-base nepomuk-svn/core/ontology/test/.svn/text-base/kontotest.cpp.svn-base
--- nepomuk/core/ontology/test/.svn/text-base/kontotest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/text-base/kontotest.cpp.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,180 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include "kontotest.h"
+#include "../ontologyloader.h"
+#include "../ontologymanager.h"
+#include "../ontology.h"
+#include "../class.h"
+#include "../global.h"
+#include "../property.h"
+
+#include <Soprano/Statement>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/RDFS>
+#include <Soprano/Vocabulary/NRL>
+
+#include <QtTest/QTest>
+#include <QtCore/QCoreApplication>
+
+
+using namespace Nepomuk;
+using namespace Soprano;
+
+class DummyOntologyLoader : public OntologyLoader
+{
+public:
+    QList<Statement> loadOntology( const QUrl& uri )
+    {
+        // create some dummy onto stuff
+        QList<Statement> sl;
+
+        QString ns = uri.toString();
+        if ( !ns.endsWith( "#" ) ) {
+            ns += '#';
+        }
+
+        // one dummy class
+        sl.append( Statement( Node( QUrl( ns + "DummyClass" ) ),
+                              Node( Soprano::Vocabulary::RDF::type() ),
+                              Node( Soprano::Vocabulary::RDFS::Class() ) ) );
+        sl.append( Statement( Node( QUrl( ns + "DummyClass" ) ),
+                              Node( Soprano::Vocabulary::RDFS::label() ),
+                              Node( LiteralValue( "A dummy class" ) ) ) );
+
+        sl.append( Statement( Node( QUrl( ns + "DummySubClass" ) ),
+                              Node( Soprano::Vocabulary::RDF::type() ),
+                              Node( Soprano::Vocabulary::RDFS::Class() ) ) );
+        sl.append( Statement( Node( QUrl( ns + "DummySubClass" ) ),
+                              Node( Soprano::Vocabulary::RDFS::subClassOf() ),
+                              Node( QUrl( ns + "DummyClass" ) ) ) );
+
+        sl.append( Statement( Node( QUrl( ns + "DummySubSubClass" ) ),
+                              Node( Soprano::Vocabulary::RDF::type() ),
+                              Node( Soprano::Vocabulary::RDFS::Class() ) ) );
+        sl.append( Statement( Node( QUrl( ns + "DummySubSubClass" ) ),
+                              Node( Soprano::Vocabulary::RDFS::subClassOf() ),
+                              Node( QUrl( ns + "DummySubClass" ) ) ) );
+
+        // one dummy property
+        sl.append( Statement( Node( QUrl( ns + "hasBrother" ) ),
+                              Node( Soprano::Vocabulary::RDF::type() ),
+                              Node( Soprano::Vocabulary::RDF::Property() ) ) );
+        sl.append( Statement( Node( QUrl( ns + "hasBrother" ) ),
+                              Node( Soprano::Vocabulary::RDFS::domain() ),
+                              Node( QUrl( ns + "DummyClass" ) ) ) );
+        sl.append( Statement( Node( QUrl( ns + "hasBrother" ) ),
+                              Node( Soprano::Vocabulary::RDFS::range() ),
+                              Node( QUrl( ns + "DummyClass" ) ) ) );
+        sl.append( Statement( Node( QUrl( ns + "hasBrother" ) ),
+                              Node( Soprano::Vocabulary::NRL::inverseProperty() ),
+                              Node( QUrl( ns + "isBrotherOf" ) ) ) );
+
+        // and its reverse property
+        sl.append( Statement( Node( QUrl( ns + "isBrotherOf" ) ),
+                              Node( Soprano::Vocabulary::RDF::type() ),
+                              Node( Soprano::Vocabulary::RDF::Property() ) ));
+        sl.append( Statement( Node( QUrl( ns + "isBrotherOf" ) ),
+                              Node( Soprano::Vocabulary::RDFS::domain() ),
+                              Node( QUrl( ns + "DummyClass" ) ) ) );
+        sl.append( Statement( Node( QUrl( ns + "isBrotherOf" ) ),
+                              Node( Soprano::Vocabulary::RDFS::range() ),
+                              Node( QUrl( ns + "DummyClass" ) ) ) );
+        sl.append( Statement( Node( QUrl( ns + "isBrotherOf" ) ),
+                              Node( Soprano::Vocabulary::NRL::inverseProperty() ),
+                              Node( QUrl( ns + "hasBrother" ) ) ) );
+
+        return sl;
+    }
+};
+
+
+void KontoTest::initTestCase()
+{
+    OntologyManager::instance()->setOntologyLoader( new DummyOntologyLoader() );
+}
+
+
+void KontoTest::testOntology()
+{
+    const Ontology* onto = Ontology::load( QUrl( "test" ) );
+    QVERIFY( onto != 0 );
+    QCOMPARE( onto->uri(), QUrl( "test" ) );
+}
+
+
+void KontoTest::testClass()
+{
+    const Ontology* onto = Ontology::load( QUrl( "test" ) );
+
+    QCOMPARE( onto->allClasses().count(), 3 );
+    QVERIFY( onto->findClassByName( "DummyClass" ) != 0 );
+    QVERIFY( onto->findClassByUri( QUrl( "test#DummyClass" ) ) != 0 );
+
+    const Class* dummyClass = Class::load( QUrl( "test#DummyClass" ) );
+    QVERIFY( dummyClass != 0 );
+
+    QCOMPARE( dummyClass->name(), QString( "DummyClass" ) );
+    QCOMPARE( dummyClass->label(), QString( "A dummy class" ) );
+
+    const Class* dummySubClass = onto->findClassByName( "DummySubClass" );
+    const Class* dummySubSubClass = onto->findClassByName( "DummySubSubClass" );
+
+    QVERIFY( dummySubClass != 0 );
+    QVERIFY( dummySubSubClass != 0 );
+    QVERIFY( dummyClass->subClasses().contains( dummySubClass ) );
+    QVERIFY( dummySubClass->subClasses().contains( dummySubSubClass ) );
+    QVERIFY( dummySubClass->parentClasses().contains( dummyClass ) );
+    QVERIFY( dummySubSubClass->parentClasses().contains( dummySubClass ) );
+
+    QVERIFY( dummyClass->isParentOf( dummySubClass ) );
+    QVERIFY( dummyClass->isParentOf( dummySubSubClass ) );
+    QVERIFY( dummySubClass->isParentOf( dummySubSubClass ) );
+    QVERIFY( !dummySubClass->isParentOf( dummyClass ) );
+
+    QVERIFY( dummySubSubClass->isSubClassOf( dummyClass ) );
+    QVERIFY( dummySubSubClass->isSubClassOf( dummySubClass ) );
+    QVERIFY( dummySubClass->isSubClassOf( dummyClass ) );
+    QVERIFY( !dummySubClass->isSubClassOf( dummySubSubClass ) );
+}
+
+
+void KontoTest::testProperty()
+{
+    const Property* hasBrother = Property::load( QUrl( "test#hasBrother" ) );
+    const Property* isBrotherOf = Property::load( QUrl( "test#isBrotherOf" ) );
+
+    QVERIFY( hasBrother != 0 );
+    QVERIFY( isBrotherOf != 0 );
+
+    QCOMPARE( hasBrother->inverseProperty(), isBrotherOf );
+    QCOMPARE( isBrotherOf->inverseProperty(), hasBrother );
+
+    const Class* dummyClass = Class::load( QUrl( "test#DummyClass" ) );
+    QCOMPARE( hasBrother->range(), dummyClass );
+    QCOMPARE( hasBrother->domain(), dummyClass );
+
+    QCOMPARE( isBrotherOf->range(), dummyClass );
+    QCOMPARE( isBrotherOf->domain(), dummyClass );
+}
+
+
+QTEST_MAIN( KontoTest )
+
+#include "kontotest.moc"
diff -u -r -N nepomuk/core/ontology/test/.svn/text-base/kontotest.h.svn-base nepomuk-svn/core/ontology/test/.svn/text-base/kontotest.h.svn-base
--- nepomuk/core/ontology/test/.svn/text-base/kontotest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ontology/test/.svn/text-base/kontotest.h.svn-base	2009-02-27 13:37:50.000000000 +0100
@@ -0,0 +1,36 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef _KONTO_TEST_H_
+#define _KONTO_TEST_H_
+
+#include <QtCore/QObject>
+
+class KontoTest : public QObject
+{
+    Q_OBJECT
+
+private Q_SLOTS:
+    void initTestCase();
+    void testOntology();
+    void testClass();
+    void testProperty();
+};
+
+#endif
diff -u -r -N nepomuk/core/resource.cpp nepomuk-svn/core/resource.cpp
--- nepomuk/core/resource.cpp	2009-02-26 15:18:34.000000000 +0100
+++ nepomuk-svn/core/resource.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -21,6 +21,7 @@
 #include "resource.h"
 #include "resourcedata.h"
 #include "resourcemanager.h"
+#include "resourcemanager_p.h"
 #include "tools.h"
 #include "tag.h"
 #include "pimo.h"
@@ -38,7 +39,14 @@
 
 Nepomuk::Resource::Resource()
 {
-    m_data = ResourceData::data( QUrl(), QUrl() );
+    m_data = ResourceManager::instance()->d->data( QUrl(), QUrl() );
+    m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( ResourceManager* manager )
+{
+    m_data = manager->d->data( QUrl(), QUrl() );
     m_data->ref();
 }
 
@@ -53,7 +61,15 @@
 
 Nepomuk::Resource::Resource( const QString& uri, const QUrl& type )
 {
-    m_data = ResourceData::data( uri, type );
+    m_data = ResourceManager::instance()->d->data( uri, type );
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const QString& uri, const QUrl& type, ResourceManager* manager )
+{
+    m_data = manager->d->data( uri, type );
     if ( m_data )
         m_data->ref();
 }
@@ -61,7 +77,7 @@
 
 Nepomuk::Resource::Resource( const QString& uri, const QString& type )
 {
-    m_data = ResourceData::data( uri, type );
+    m_data = ResourceManager::instance()->d->data( uri, type );
     if ( m_data )
         m_data->ref();
 }
@@ -69,7 +85,15 @@
 
 Nepomuk::Resource::Resource( const QUrl& uri, const QUrl& type )
 {
-    m_data = ResourceData::data( uri, type );
+    m_data = ResourceManager::instance()->d->data( uri, type );
+    if ( m_data )
+        m_data->ref();
+}
+
+
+Nepomuk::Resource::Resource( const QUrl& uri, const QUrl& type, ResourceManager* manager )
+{
+    m_data = manager->d->data( uri, type );
     if ( m_data )
         m_data->ref();
 }
@@ -88,7 +112,7 @@
     // FIXME: ResourceData instances having a proxy also need to be deleted, maybe extend deref
     if( m_data &&
         m_data->deref() == 0 &&
-        ( !m_data->isValid() || ResourceData::dataCacheFull() ) ) {
+        ( !m_data->isValid() || m_data->rm()->dataCacheFull() ) ) {
         m_data->deleteData();
     }
 }
@@ -115,6 +139,12 @@
 }
 
 
+Nepomuk::ResourceManager* Nepomuk::Resource::manager() const
+{
+    return m_data->rm()->m_manager;
+}
+
+
 QString Nepomuk::Resource::uri() const
 {
     return resourceUri().toString();
@@ -249,6 +279,14 @@
 }
 
 
+void Nepomuk::Resource::addProperty( const QUrl& uri, const Variant& value )
+{
+    Variant v = property( uri );
+    v.append( value );
+    setProperty( uri, v );
+}
+
+
 void Nepomuk::Resource::setProperty( const QUrl& uri, const Nepomuk::Variant& value )
 {
     if ( m_data ) {
@@ -271,6 +309,18 @@
 }
 
 
+void Nepomuk::Resource::removeProperty( const QUrl& uri, const Variant& value )
+{
+    if ( m_data ) {
+        QList<Variant> vl = property( uri ).toVariantList();
+        foreach( const Variant& v, value.toVariantList() ) {
+            vl.removeAll( v );
+        }
+        setProperty( uri, Variant( vl ) );
+    }
+}
+
+
 void Nepomuk::Resource::remove()
 {
     if ( m_data ) {
@@ -751,16 +801,17 @@
 
 QList<Nepomuk::Resource> Nepomuk::Resource::annotationOf() const
 {
-    return convertResourceList<Resource>( ResourceManager::instance()->allResourcesWithProperty( Soprano::Vocabulary::NAO::annotation(), *this ) );
+    return convertResourceList<Resource>( manager()->allResourcesWithProperty( Soprano::Vocabulary::NAO::annotation(), *this ) );
 }
 
 
 QList<Nepomuk::Resource> Nepomuk::Resource::isRelatedOf() const
 {
-    return convertResourceList<Resource>( ResourceManager::instance()->allResourcesWithProperty( Soprano::Vocabulary::NAO::isRelated(), *this ) );
+    return convertResourceList<Resource>( manager()->allResourcesWithProperty( Soprano::Vocabulary::NAO::isRelated(), *this ) );
 }
 
 
+// static
 QList<Nepomuk::Resource> Nepomuk::Resource::allResources()
 {
     return Nepomuk::convertResourceList<Resource>( ResourceManager::instance()->allResourcesOfType( Soprano::Vocabulary::RDFS::Resource() ) );
diff -u -r -N nepomuk/core/resource.h nepomuk-svn/core/resource.h
--- nepomuk/core/resource.h	2009-01-06 18:27:42.000000000 +0100
+++ nepomuk-svn/core/resource.h	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -27,9 +27,9 @@
 
 #include "nepomuk_export.h"
 
-
 namespace Nepomuk {
 
+    class ResourceManager;
     class ResourceData;
     class Variant;
     class Tag;
@@ -37,7 +37,7 @@
 
     enum ErrorCode {
         NoError = 0,
-        CommunicationError, /**< A commication error, i.e. connection failure */
+        CommunicationError, /**< A communication error, i.e. connection failure */
         InvalidType,
         UnknownError
     };
@@ -77,6 +77,21 @@
          */
         Resource();
 
+        /**
+         * Creates an empty invalid Resource.
+         * An invalid resource will become valid (i.e. get a new random URI) once setProperty
+         * is called.
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Resource( ResourceManager* manager );
+
+        /**
+         * Copy constructor
+         */
         Resource( const Resource& );
 
         /**
@@ -101,9 +116,9 @@
          *                        by the framework and can only be accessed in a read-only
          *                        fashion.
          *                        \li An identifier in combination with the resource type (Be
-         *                        aware that this identification can only be guranteed if identifiers
+         *                        aware that this identification can only be guaranteed if identifiers
          *                        are never set manually via addIdentifier but only through the
-         *                        constructor.
+         *                        constructor.)
          *
          * \param type The URI identifying the type of the resource. If it is empty
          *             Resource falls back to http://www.w3.org/2000/01/rdf-schema\#Resource or
@@ -127,6 +142,16 @@
         Resource( const QString& uriOrIdentifier, const QUrl& type = QUrl() );
 
         /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Resource( const QString& uriOrIdentifier, const QUrl& type, ResourceManager* manager );
+
+        /**
          * \deprecated use Resource( const QString&, const QUrl& )
          */
         KDE_DEPRECATED Resource( const QString& uriOrIdentifier, const QString& type );
@@ -144,22 +169,48 @@
         Resource( const QUrl& uri, const QUrl& type = QUrl() );
 
         /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Resource( const QUrl& uri, const QUrl& type, ResourceManager* manager );
+
+        /**
          * Constructor used internally.
          */
         Resource( ResourceData* );
 
+        /**
+         * Destructor
+         */
         virtual ~Resource();
 
-        Resource& operator=( const Resource& );
+        /**
+         * Makes this instance of Resource a copy of other.
+         */
+        Resource& operator=( const Resource& other );
+
+        /**
+         * Same as operator=( Resource( uri ) )
+         */
+        Resource& operator=( const QUrl& uri );
 
-        Resource& operator=( const QUrl& );
+        /**
+         * The Resource manager that manages this resource.
+         *
+         * \since 4.3
+         */
+        ResourceManager* manager() const;
 
         /**
          * The URI of the resource, uniquely identifying it. This URI in most
          * cases is a virtual one which has been created from a generic base
          * namespace and some identifier.
          *
-         * the most important thing to remember is that the URI of for example
+         * The most important thing to remember is that the URI of for example
          * a file does not necessarily have a relation to its local path.
          * (Although Nepomuk tries to keep the URI of file resources in sync
          * with the file URL for convenience.)
@@ -178,7 +229,7 @@
          * cases is a virtual one which has been created from a generic base
          * namespace and some identifier.
          *
-         * the most important thing to remember is that the URI of for example
+         * The most important thing to remember is that the URI of for example
          * a file does not necessarily have a relation to its local path.
          * (Although Nepomuk tries to keep the URI of file resources in sync
          * with the file URL for convenience.)
@@ -299,6 +350,16 @@
         void setProperty( const QUrl& uri, const Variant& value );
 
         /**
+         * Add a property value to the existing values.
+         *
+         * \param uri The URI identifying the property.
+         * \param value The value of the property (i.e. the object of the RDF triple(s))
+         *
+         * \since 4.3
+         */
+        void addProperty( const QUrl& uri, const Variant& value );
+
+        /**
          * \deprecated use setProperty( const QUrl& )
          */
         KDE_DEPRECATED void setProperty( const QString& uri, const Variant& value );
@@ -311,6 +372,16 @@
         void removeProperty( const QUrl& uri );
 
         /**
+         * Remove \a value from property \a uri of this resource object.
+         *
+         * \param uri The URI identifying the property.
+         * \param value The value to remove
+         *
+         * \since 4.3
+         */
+        void removeProperty( const QUrl& uri, const Variant& value );
+
+        /**
          * \deprecated use removeProperty( const QUrl& )
          */
         KDE_DEPRECATED void removeProperty( const QString& uri );
@@ -617,10 +688,11 @@
          * the local Nepomuk meta data storage and any changes made locally. 
          * Be aware that in some cases this list can get very big. Then it 
          * might be better to use libKNep directly. 
+         *
+         * \sa ResourceManager::allResources
          */
         static QList<Resource> allResources();
 
-
     private:
         ResourceData* m_data;
 
diff -u -r -N nepomuk/core/resourcedata.cpp nepomuk-svn/core/resourcedata.cpp
--- nepomuk/core/resourcedata.cpp	2009-01-21 11:27:50.000000000 +0100
+++ nepomuk-svn/core/resourcedata.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -20,6 +20,8 @@
 
 #include "resourcedata.h"
 #include "resourcemanager.h"
+#include "resourcemanager_p.h"
+#include "resourcefiltermodel.h"
 #include "resource.h"
 #include "tools.h"
 #include "nie.h"
@@ -36,10 +38,8 @@
 #include <Soprano/Vocabulary/NAO>
 
 #include "ontology/class.h"
-#include "ontology/entity_p.h" // for qHash(QUrl)
 
 #include <QtCore/QFile>
-#include <QtCore/QFileInfo>
 #include <QtCore/QDateTime>
 
 #include <kdebug.h>
@@ -47,15 +47,7 @@
 
 using namespace Soprano;
 
-typedef QHash<QString, Nepomuk::ResourceData*> ResourceDataHash;
-
-// FIXME: make these things thread-safe. Even better: put them into the ResourceManager and make that thread-safe!
-K_GLOBAL_STATIC( ResourceDataHash, s_initializedData )
-K_GLOBAL_STATIC( ResourceDataHash, s_kickoffData )
-
-#define MAINMODEL static_cast<Nepomuk::MainModel*>( ResourceManager::instance()->mainModel() )
-
-static int s_dataCnt = 0;
+#define MAINMODEL m_rm->resourceFilterModel
 
 
 static Nepomuk::Variant nodeToVariant( const Soprano::Node& node )
@@ -72,7 +64,7 @@
 }
 
 
-Nepomuk::ResourceData::ResourceData( const QUrl& uri, const QString& uriOrId, const QUrl& type )
+Nepomuk::ResourceData::ResourceData( const QUrl& uri, const QString& uriOrId, const QUrl& type, ResourceManagerPrivate* rm )
     : m_kickoffUriOrId( uriOrId ),
       m_uri( uri ),
       m_mainType( type ),
@@ -80,7 +72,8 @@
       m_proxyData(0),
       m_cacheDirty(true),
       m_pimoThing(0),
-      m_groundingOccurence(0)
+      m_groundingOccurence(0),
+      m_rm(rm)
 {
     if( m_mainType.isEmpty() )
         m_mainType = Soprano::Vocabulary::RDFS::Resource();
@@ -90,26 +83,16 @@
     // there is no need to store the trivial type
     m_initialTypeSaved = ( m_mainType == Soprano::Vocabulary::RDFS::Resource() );
 
-    // TODO: handle the caching in a decent Cache class and not this ugly.
-    if ( s_dataCnt >= 1000 ) {
-        for( ResourceDataHash::iterator rdIt = s_initializedData->begin();
-             rdIt != s_initializedData->end(); ++rdIt ) {
-            ResourceData* data = rdIt.value();
-            if ( !data->cnt() ) {
-                data->deleteData();
-                break;
-            }
-        }
-    }
+    m_rm->cleanupCache();
 
-    ++s_dataCnt;
+    ++m_rm->dataCnt;
 }
 
 
 Nepomuk::ResourceData::~ResourceData()
 {
     delete m_pimoThing;
-    --s_dataCnt;
+    --m_rm->dataCnt;
 }
 
 
@@ -179,9 +162,9 @@
     }
     else {
         if( !m_uri.isEmpty() )
-            s_initializedData->remove( m_uri.toString() );
+            m_rm->m_initializedData.remove( m_uri.toString() );
         if( !m_kickoffUriOrId.isEmpty() )
-            s_kickoffData->remove( m_kickoffUriOrId );
+            m_rm->m_kickoffData.remove( m_kickoffUriOrId );
     }
 
     deleteLater();
@@ -205,7 +188,7 @@
         return m_proxyData->hasProperty( uri );
 
     if ( determineUri() ) {
-        return ResourceManager::instance()->mainModel()->containsAnyStatement( Soprano::Statement( m_uri, uri, Soprano::Node() ) );
+        return MAINMODEL->containsAnyStatement( Soprano::Statement( m_uri, uri, Soprano::Node() ) );
     }
     else {
         return false;
@@ -259,7 +242,7 @@
 //     Variant v;
 
 //     if ( determineUri() ) {
-//         Soprano::Model* model = ResourceManager::instance()->mainModel();
+//         Soprano::Model* model = m_rm->m_manager->mainModel();
 //         Soprano::StatementIterator it = model->listStatements( Soprano::Statement( m_uri, QUrl(uri), Soprano::Node() ) );
 
 //         while ( it.next() ) {
@@ -277,8 +260,8 @@
     if ( !determineUri() ) {
         // create a random URI and add us to the initialized data, i.e. make us "valid"
         m_modificationMutex.lock();
-        m_uri = ResourceManager::instance()->generateUniqueUri( QString() );
-        s_initializedData->insert( m_uri.toString(), this );
+        m_uri = m_rm->m_manager->generateUniqueUri( QString() );
+        m_rm->m_initializedData.insert( m_uri.toString(), this );
         m_modificationMutex.unlock();
     }
 
@@ -287,6 +270,7 @@
     // save type (There should be no need to save all the types since there is only one way
     // that m_types contains more than one element: if we loaded them)
     // The first type, however, can be set at creation time to any value
+    // FIXME: save all unsaved types here and do not directly save tem above in setTypes
     if ( !m_initialTypeSaved ) {
         statements.append( Statement( m_uri, Soprano::Vocabulary::RDF::type(), m_types.first() ) );
     }
@@ -373,8 +357,7 @@
         m_cache.clear();
 
         if ( determineUri() ) {
-            Soprano::Model* model = ResourceManager::instance()->mainModel();
-            Soprano::StatementIterator it = model->listStatements( Soprano::Statement( m_uri, Soprano::Node(), Soprano::Node() ) );
+            Soprano::StatementIterator it = MAINMODEL->listStatements( Soprano::Statement( m_uri, Soprano::Node(), Soprano::Node() ) );
 
             while ( it.next() ) {
                 Statement statement = *it;
@@ -398,10 +381,10 @@
             }
             else {
                 // TODO: somehow handle pimo:referencingOccurrence and pimo:occurrence
-                QueryResultIterator pimoIt = model->executeQuery( QString( "select ?r where { ?r <%1> <%2> . }")
-                                                                  .arg( Vocabulary::PIMO::groundingOccurrence().toString() )
-                                                                  .arg( QString::fromAscii( m_uri.toEncoded() ) ),
-                                                                  Soprano::Query::QueryLanguageSparql );
+                QueryResultIterator pimoIt = MAINMODEL->executeQuery( QString( "select ?r where { ?r <%1> <%2> . }")
+                                                                      .arg( Vocabulary::PIMO::groundingOccurrence().toString() )
+                                                                      .arg( QString::fromAscii( m_uri.toEncoded() ) ),
+                                                                      Soprano::Query::QueryLanguageSparql );
                 if( pimoIt.next() ) {
                     m_pimoThing = new Thing( pimoIt.binding("r").uri() );
                 }
@@ -497,7 +480,7 @@
         }
 
         // the url is invalid now
-        s_initializedData->remove( m_uri.toString() );
+        m_rm->m_initializedData.remove( m_uri.toString() );
         m_uri = QUrl();
         m_cache.clear();
         m_cacheDirty = false;
@@ -514,7 +497,7 @@
         return m_proxyData->exists();
 
     if( determineUri() ) {
-        return ResourceManager::instance()->mainModel()->containsAnyStatement( Statement( m_uri, Node(), Node() ) );
+        return MAINMODEL->containsAnyStatement( Statement( m_uri, Node(), Node() ) );
     }
     else
         return false;
@@ -541,7 +524,7 @@
 
         m_modificationMutex.lock();
 
-        Soprano::Model* model = ResourceManager::instance()->mainModel();
+        Soprano::Model* model = MAINMODEL;
 
         // kickoffUriOrId() cannot be a URI without a slash (ugly hack for a tiny speed gain)
         if( kickoffUriOrId().contains('/') &&
@@ -628,7 +611,7 @@
                 }
                 else {
                     m_kickoffIdentifier = kickoffUriOrId();
-                    m_uri = ResourceManager::instance()->generateUniqueUri( m_kickoffIdentifier );
+                    m_uri = m_rm->m_manager->generateUniqueUri( m_kickoffIdentifier );
                 }
 
 //                kDebug(300004) << " kickoff identifier " << kickoffUriOrId() << " seems fresh. Generated new URI " << m_uri;
@@ -640,11 +623,11 @@
         //
         if( !uri().isEmpty() && uri() != kickoffUriOrId() ) {
             QString s = uri().toString();
-            if( !s_initializedData->contains( s ) ) {
-                s_initializedData->insert( s, this );
+            if( !m_rm->m_initializedData.contains( s ) ) {
+                m_rm->m_initializedData.insert( s, this );
             }
             else {
-                m_proxyData = s_initializedData->value( s );
+                m_proxyData = m_rm->m_initializedData.value( s );
                 m_proxyData->ref();
             }
         }
@@ -658,7 +641,7 @@
 
 // void Nepomuk::ResourceData::updateType()
 // {
-//     Soprano::Model* model = ResourceManager::instance()->mainModel();
+//     Soprano::Model* model = m_rm->m_manager->mainModel();
 
 //     // get the type of the stored resource
 //     StatementIterator typeStatements = model->listStatements( Statement( m_uri,
@@ -702,185 +685,6 @@
 }
 
 
-Nepomuk::ResourceData* Nepomuk::ResourceData::data( const QUrl& uri, const QUrl& type )
-{
-    if ( uri.isEmpty() ) {
-        // return an invalid resource which may be activated by calling setProperty
-        return new ResourceData( uri, QString(), type );
-    }
-
-    // default to "file" scheme, i.e. we do not allow an empty scheme
-    if ( uri.scheme().isEmpty() ) {
-        QUrl fileUri( uri );
-        fileUri.setScheme( "file" );
-        return data( fileUri, type );
-    }
-
-    // if scheme is file, try to follow a symlink
-    if ( uri.scheme() == "file" ) {
-        QFileInfo fileInfo( uri.toLocalFile() );
-        if ( fileInfo.isSymLink() ) {
-            QString linkTarget = fileInfo.canonicalFilePath();
-            // linkTarget is empty for dangling symlinks
-            if ( !linkTarget.isEmpty() ) {
-                QUrl targetUri( linkTarget );
-                targetUri.setScheme( "file" );
-                return data( targetUri, type );
-            }
-        }
-    }
-
-    ResourceDataHash::iterator it = s_initializedData->find( uri.toString() );
-
-    //
-    // The uriOrId has no local representation yet -> create one
-    //
-    if( it == s_initializedData->end() ) {
-//        kDebug(300004) << "No existing ResourceData instance found for uri " << uri;
-        //
-        // The actual URI is already known here
-        //
-        ResourceData* d = new ResourceData( uri, QString(), type );
-        s_initializedData->insert( uri.toString(), d );
-
-        return d;
-    }
-    else {
-        //
-        // Reuse the already existing ResourceData object
-        //
-        return it.value();
-    }
-}
-
-
-Nepomuk::ResourceData* Nepomuk::ResourceData::data( const QString& uriOrId, const QUrl& type )
-{
-    if ( uriOrId.isEmpty() ) {
-        return new ResourceData( QUrl(), QString(), type );
-    }
-
-    // special case: files (only absolute paths for now)
-    if ( uriOrId[0] == '/' ) {
-        // try to follow a symlink
-        QFileInfo fileInfo( uriOrId );
-        if ( fileInfo.isSymLink() ) {
-            QString linkTarget = fileInfo.canonicalFilePath();
-            // linkTarget is empty for dangling symlinks, use given url for those
-            if ( !linkTarget.isEmpty() ) {
-                return data( linkTarget, type );
-            }
-        }
-        ResourceDataHash::iterator it = s_initializedData->find( "file://" + uriOrId );
-        if ( it != s_initializedData->end() ) {
-            return *it;
-        }
-    }
-
-    ResourceDataHash::iterator it = s_initializedData->find( uriOrId );
-
-    bool resFound = ( it != s_initializedData->end() );
-
-    //
-    // The uriOrId is not a known local URI. Might be a kickoff value though
-    //
-    if( it == s_initializedData->end() ) {
-        it = s_kickoffData->find( uriOrId );
-
-        // check if the type matches (see determineUri for details)
-        if ( !type.isEmpty() && type != Soprano::Vocabulary::RDFS::Resource() ) {
-            Types::Class wantedType = type;
-            while ( it != s_kickoffData->end() &&
-                    it.key() == uriOrId ) {
-                if ( it.value()->hasType( type ) ) {
-                    break;
-                }
-                ++it;
-            }
-        }
-
-        resFound = ( it != s_kickoffData->end() && it.key() == uriOrId );
-    }
-
-    //
-    // The uriOrId has no local representation yet -> create one
-    //
-    if( !resFound ) {
-//        kDebug(300004) << "No existing ResourceData instance found for uriOrId " << uriOrId;
-        //
-        // Every new ResourceData object ends up in the kickoffdata since its actual URI is not known yet
-        //
-        ResourceData* d = new ResourceData( QUrl(), uriOrId, type );
-        s_kickoffData->insert( uriOrId, d );
-
-        return d;
-    }
-    else {
-        //
-        // Reuse the already existing ResourceData object
-        //
-        return it.value();
-    }
-}
-
-
-QList<Nepomuk::ResourceData*> Nepomuk::ResourceData::allResourceDataOfType( const QUrl& type )
-{
-    QList<ResourceData*> l;
-
-    if( !type.isEmpty() ) {
-        for( ResourceDataHash::iterator rdIt = s_kickoffData->begin();
-             rdIt != s_kickoffData->end(); ++rdIt ) {
-            if( rdIt.value()->type() == type ) {
-                l.append( rdIt.value() );
-            }
-        }
-    }
-
-    return l;
-}
-
-
-QList<Nepomuk::ResourceData*> Nepomuk::ResourceData::allResourceDataWithProperty( const QUrl& uri, const Variant& v )
-{
-    QList<ResourceData*> l;
-
-    for( ResourceDataHash::iterator rdIt = s_kickoffData->begin();
-         rdIt != s_kickoffData->end(); ++rdIt ) {
-
-        if( rdIt.value()->hasProperty( uri ) &&
-            rdIt.value()->property( uri ) == v ) {
-            l.append( rdIt.value() );
-        }
-    }
-
-    return l;
-}
-
-
-QList<Nepomuk::ResourceData*> Nepomuk::ResourceData::allResourceData()
-{
-    QList<ResourceData*> l;
-
-    for( ResourceDataHash::iterator rdIt = s_kickoffData->begin();
-         rdIt != s_kickoffData->end(); ++rdIt ) {
-        l.append( rdIt.value() );
-    }
-    for( ResourceDataHash::iterator rdIt = s_initializedData->begin();
-         rdIt != s_initializedData->end(); ++rdIt ) {
-        l.append( rdIt.value() );
-    }
-
-    return l;
-}
-
-
-bool Nepomuk::ResourceData::dataCacheFull()
-{
-    return s_dataCnt >= 1000;
-}
-
-
 Nepomuk::Thing Nepomuk::ResourceData::pimoThing()
 {
     load();
diff -u -r -N nepomuk/core/resourcedata.h nepomuk-svn/core/resourcedata.h
--- nepomuk/core/resourcedata.h	2008-10-09 11:48:43.000000000 +0200
+++ nepomuk-svn/core/resourcedata.h	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /* 
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -33,12 +33,15 @@
 
 
 namespace Nepomuk {
+
+    class ResourceManagerPrivate;
+
     class ResourceData : public QObject
     {
         Q_OBJECT
 
     public:
-        explicit ResourceData( const QUrl& uri = QUrl(), const QString& kickoffId_ = QString(), const QUrl& type_ = QString() );
+        explicit ResourceData( const QUrl& uri, const QString& kickoffId_, const QUrl& type_, ResourceManagerPrivate* rm );
         ~ResourceData();
 
         /**
@@ -157,35 +160,7 @@
          */
         bool operator==( const ResourceData& other ) const;
 
-        /**
-         * The Nepomuk lib is based on the fact that for each uri only one ResourceData object is
-         * created at all times. This method searches for an existing data object to reuse or creates
-         * a new one if none exists.
-         *
-         * \param uriOrId The URI or identifier of the resource is question.
-         * \type The type of the resource.
-         *
-         * The Resource constructors use this method in combination with ref()
-         */
-        static ResourceData* data( const QString& uriOrId, const QUrl& type );
-
-        /**
-         * The Nepomuk lib is based on the fact that for each uri only one ResourceData object is
-         * created at all times. This method searches for an existing data object to reuse or creates
-         * a new one if none exists.
-         *
-         * \param uri The URI of the resource is question.
-         * \type The type of the resource.
-         *
-         * The Resource constructors use this method in combination with ref()
-         */
-        static ResourceData* data( const QUrl& uri, const QUrl& type );
-
-        static bool dataCacheFull();
-
-        static QList<ResourceData*> allResourceData();
-        static QList<ResourceData*> allResourceDataOfType( const QUrl& type );
-        static QList<ResourceData*> allResourceDataWithProperty( const QUrl& _uri, const Variant& v );
+        ResourceManagerPrivate* rm() const { return m_rm; }
 
     private:
         bool constHasType( const QUrl& type ) const;
@@ -198,7 +173,6 @@
         QString m_kickoffUriOrId;
         QUrl m_uri;
 
-
         /**
          * The kickoffIdentifier is the identifier used to construct the resource object.
          * If the object has been constructed via a URI or determineUri has not been called
@@ -232,7 +206,7 @@
         // only used for delayed storage of the pimo thing relation
         ResourceData* m_groundingOccurence;
 
-        friend class ResourceManager;
+        ResourceManagerPrivate* m_rm;
     };
 }
 
diff -u -r -N nepomuk/core/resourcefiltermodel.cpp nepomuk-svn/core/resourcefiltermodel.cpp
--- nepomuk/core/resourcefiltermodel.cpp	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/resourcefiltermodel.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,181 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "resourcefiltermodel.h"
+#include "graphwrapper_p.h"
+
+#include <Soprano/Node>
+#include <Soprano/Statement>
+#include <Soprano/StatementIterator>
+#include <Soprano/NodeIterator>
+#include <Soprano/QueryResultIterator>
+#include <Soprano/Client/DBusModel>
+#include <Soprano/Client/DBusClient>
+#include <Soprano/Client/LocalSocketClient>
+#include <Soprano/Query/QueryLanguage>
+#include <Soprano/Util/DummyModel>
+#include <Soprano/Util/MutexModel>
+#include <Soprano/Vocabulary/RDF>
+#include <Soprano/Vocabulary/NRL>
+#include <Soprano/Vocabulary/NAO>
+
+#include <QtCore/QSet>
+
+using namespace Soprano;
+
+
+class Nepomuk::ResourceFilterModel::Private
+{
+public:
+    GraphWrapper graphWrapper;
+};
+
+Nepomuk::ResourceFilterModel::ResourceFilterModel( Soprano::Model* model )
+    : FilterModel( model ),
+      d(new Private())
+{
+    d->graphWrapper.setModel( this );
+}
+
+
+Nepomuk::ResourceFilterModel::~ResourceFilterModel()
+{
+    delete d;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::addStatement( const Statement& statement )
+{
+    Statement s( statement );
+    if( s.context().isEmpty() ) {
+        s.setContext( mainContext() );
+    }
+    return FilterModel::addStatement( s );
+}
+
+
+QUrl Nepomuk::ResourceFilterModel::mainContext()
+{
+    return d->graphWrapper.currentGraph();
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::updateModificationDate( const QUrl& resource, const QDateTime& date )
+{
+    Error::ErrorCode c = removeAllStatements( resource, Soprano::Vocabulary::NAO::lastModified(), Soprano::Node() );
+    if ( c != Error::ErrorNone )
+        return c;
+    else
+        return addStatement( resource, Soprano::Vocabulary::NAO::lastModified(), LiteralValue( date ), mainContext() );
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::updateProperty( const QUrl& resource, const QUrl& property, const Node& value )
+{
+    if( !property.isValid() ) {
+        setError( "Cannot update invalid property", Error::ErrorInvalidArgument );
+        return Error::ErrorInvalidArgument;
+    }
+
+    StatementIterator it = listStatements( Statement( resource, property, Node() ) );
+    if ( it.next() ) {
+        Statement s = it.current();
+        it.close();
+        if ( s.object() == value ) {
+            // nothing to do. Yey!
+            return Error::ErrorNone;
+        }
+        else {
+            removeStatement( s );
+        }
+    }
+
+    // update property
+    Error::ErrorCode c = addStatement( resource, property, value, mainContext() );
+    if ( c != Error::ErrorNone )
+        return updateModificationDate( resource );
+
+    return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::updateProperty( const QUrl& resource, const QUrl& property, const QList<Node>& values )
+{
+    if( !property.isValid() ) {
+        setError( "Cannot update invalid property", Error::ErrorInvalidArgument );
+        return Error::ErrorInvalidArgument;
+    }
+
+    QList<Node> existingValues = listStatements( Statement( resource, property, Node() ) ).iterateObjects().allNodes();
+
+    Error::ErrorCode c = Error::ErrorNone;
+    foreach( const Node &node, existingValues.toSet() - values.toSet() ) {
+        if ( ( c = removeAllStatements( Statement( resource, property, node ) ) ) != Error::ErrorNone ) {
+            return c;
+        }
+    }
+
+    QSet<Node> newNodes = values.toSet() - existingValues.toSet();
+    if ( !newNodes.isEmpty() ) {
+        QUrl context = mainContext();
+        foreach( const Node &node, newNodes ) {
+            if ( ( c = addStatement( Statement( resource, property, node, context ) ) ) != Error::ErrorNone ) {
+                return c;
+            }
+        }
+
+        c = updateModificationDate( resource );
+    }
+
+    return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::removeProperty( const QUrl& resource, const QUrl& property )
+{
+    if( !property.isValid() ) {
+        setError( "Cannot remove invalid property", Error::ErrorInvalidArgument );
+        return Error::ErrorInvalidArgument;
+    }
+
+    Soprano::Error::ErrorCode c = removeAllStatements( Statement( resource, property, Node() ) );
+    if ( c == Soprano::Error::ErrorNone )
+        return updateModificationDate( resource );
+    else
+        return c;
+}
+
+
+Soprano::Error::ErrorCode Nepomuk::ResourceFilterModel::ensureResource( const QUrl& resource, const QUrl& type )
+{
+    if ( !containsAnyStatement( Statement( resource, Vocabulary::RDF::type(), type ) ) ) {
+         Soprano::Error::ErrorCode c = addStatement( Statement( resource, Vocabulary::RDF::type(), type, mainContext() ) );
+         if ( c == Soprano::Error::ErrorNone )
+             return updateModificationDate( resource );
+         else
+             return c;
+    }
+    else {
+        clearError();
+        return Error::ErrorNone;
+    }
+}
+
+#include "resourcefiltermodel.moc"
diff -u -r -N nepomuk/core/resourcefiltermodel.h nepomuk-svn/core/resourcefiltermodel.h
--- nepomuk/core/resourcefiltermodel.h	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/resourcefiltermodel.h	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,100 @@
+/* 
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_FILTER_MODEL_H_
+#define _NEPOMUK_RESOURCE_FILTER_MODEL_H_
+
+#include <Soprano/FilterModel>
+#include <Soprano/Node>
+#include <Soprano/Vocabulary/RDFS>
+
+#include <QtCore/QList>
+#include <QtCore/QDateTime>
+
+namespace Nepomuk {
+    /**
+     * Filter model that provides a set of convenience methods
+     * for maintaining resource properties.
+     *
+     * It does automatic NRL named graph handling, i.e. provedance
+     * data is created and deleted automatically.
+     *
+     * \warning This model assumes that no property value is stored twice,
+     * i.e. in two different named graphs.
+     */
+    class ResourceFilterModel : public Soprano::FilterModel
+    {
+        Q_OBJECT
+
+    public:
+        ResourceFilterModel( Soprano::Model* model = 0 );
+        ~ResourceFilterModel();
+
+        /**
+         * Adds a statement to the Model. Statements without a valid context will be
+         * added to the mainContext.
+         */
+        Soprano::Error::ErrorCode addStatement( const Soprano::Statement& statement );
+
+        /**
+         * The ResourceFilterModel automatically creates graph metadata and tries to
+         * group batch operations into one graph. This method returns the currently
+         * "open" graph, i.e. that one which is used in all the convinience methods.
+         */
+        QUrl mainContext();
+
+        /**
+         * Updates the modification date of \p resource to \p date.
+         */
+        Soprano::Error::ErrorCode updateModificationDate( const QUrl& resource, const QDateTime& date = QDateTime::currentDateTime() );
+
+        /**
+         * Update a property. This means an existing property is replaced if it differs from
+         * the provided value. Otherwise nothing is done.
+         *
+         * This method assumes that the cardinality or property is 1.
+         */
+        Soprano::Error::ErrorCode updateProperty( const QUrl& resource, const QUrl& property, const Soprano::Node& value );
+
+        /**
+         * Update a property with a cardinality > 1.
+         * This method optmizes the add and remove actions necessary.
+         */
+        Soprano::Error::ErrorCode updateProperty( const QUrl& resource, const QUrl& property, const QList<Soprano::Node>& values );
+
+        /**
+         * Remove a property from a resource and make sure no dangling graphs are left
+         */
+        Soprano::Error::ErrorCode removeProperty( const QUrl& resource, const QUrl& property );
+
+        /**
+         * Ensures that resoruce exists with type.
+         */
+        Soprano::Error::ErrorCode ensureResource( const QUrl& resource, const QUrl& type = Soprano::Vocabulary::RDFS::Resource() );
+
+        using FilterModel::addStatement;
+
+    private:
+        class Private;
+        Private* const d;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/resourcemanager.cpp nepomuk-svn/core/resourcemanager.cpp
--- nepomuk/core/resourcemanager.cpp	2008-12-10 17:12:19.000000000 +0100
+++ nepomuk-svn/core/resourcemanager.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -19,10 +19,14 @@
  */
 
 #include "resourcemanager.h"
+#include "resourcemanager_p.h"
 #include "resourcedata.h"
 #include "tools.h"
 #include "nepomukmainmodel.h"
 #include "resource.h"
+#include "resourcefiltermodel.h"
+
+#include "ontology/class.h"
 
 #include <kglobal.h>
 #include <kdebug.h>
@@ -34,44 +38,242 @@
 #include <Soprano/StatementIterator>
 #include <Soprano/QueryResultIterator>
 
+#include <QtCore/QFileInfo>
 #include <QtCore/QMutex>
 #include <QtCore/QMutexLocker>
 
 using namespace Soprano;
 
 
+Nepomuk::ResourceManagerPrivate::ResourceManagerPrivate( ResourceManager* manager )
+    : mainModel( 0 ),
+      overrideModel( 0 ),
+      dataCnt( 0 ),
+      m_manager( manager )
+{
+}
+
 
-class Nepomuk::ResourceManager::Private
+Nepomuk::ResourceData* Nepomuk::ResourceManagerPrivate::data( const QUrl& uri, const QUrl& type )
 {
-public:
-    Private( ResourceManager* manager )
-        : mainModel( 0 ),
-          overrideModel( 0 ),
-          m_parent(manager) {
+    if ( uri.isEmpty() ) {
+        // return an invalid resource which may be activated by calling setProperty
+        return new ResourceData( uri, QString(), type, this );
+    }
+
+    // default to "file" scheme, i.e. we do not allow an empty scheme
+    if ( uri.scheme().isEmpty() ) {
+        QUrl fileUri( uri );
+        fileUri.setScheme( "file" );
+        return data( fileUri, type );
     }
 
-    Nepomuk::MainModel* mainModel;
-    Soprano::Model* overrideModel;
+    // if scheme is file, try to follow a symlink
+    if ( uri.scheme() == "file" ) {
+        QFileInfo fileInfo( uri.toLocalFile() );
+        if ( fileInfo.isSymLink() ) {
+            QString linkTarget = fileInfo.canonicalFilePath();
+            // linkTarget is empty for dangling symlinks
+            if ( !linkTarget.isEmpty() ) {
+                QUrl targetUri( linkTarget );
+                targetUri.setScheme( "file" );
+                return data( targetUri, type );
+            }
+        }
+    }
 
-    QMutex mutex;
+    ResourceDataHash::iterator it = m_initializedData.find( uri.toString() );
 
-private:
-    ResourceManager* m_parent;
-};
+    //
+    // The uriOrId has no local representation yet -> create one
+    //
+    if( it == m_initializedData.end() ) {
+//        kDebug(300004) << "No existing ResourceData instance found for uri " << uri;
+        //
+        // The actual URI is already known here
+        //
+        ResourceData* d = new ResourceData( uri, QString(), type, this );
+        m_initializedData.insert( uri.toString(), d );
+
+        return d;
+    }
+    else {
+        //
+        // Reuse the already existing ResourceData object
+        //
+        return it.value();
+    }
+}
+
+
+Nepomuk::ResourceData* Nepomuk::ResourceManagerPrivate::data( const QString& uriOrId, const QUrl& type )
+{
+    if ( uriOrId.isEmpty() ) {
+        return new ResourceData( QUrl(), QString(), type, this );
+    }
+
+    // special case: files (only absolute paths for now)
+    if ( uriOrId[0] == '/' ) {
+        // try to follow a symlink
+        QFileInfo fileInfo( uriOrId );
+        if ( fileInfo.isSymLink() ) {
+            QString linkTarget = fileInfo.canonicalFilePath();
+            // linkTarget is empty for dangling symlinks, use given url for those
+            if ( !linkTarget.isEmpty() ) {
+                return data( linkTarget, type );
+            }
+        }
+        ResourceDataHash::iterator it = m_initializedData.find( "file://" + uriOrId );
+        if ( it != m_initializedData.end() ) {
+            return *it;
+        }
+    }
+
+    ResourceDataHash::iterator it = m_initializedData.find( uriOrId );
+
+    bool resFound = ( it != m_initializedData.end() );
+
+    //
+    // The uriOrId is not a known local URI. Might be a kickoff value though
+    //
+    if( it == m_initializedData.end() ) {
+        it = m_kickoffData.find( uriOrId );
+
+        // check if the type matches (see determineUri for details)
+        if ( !type.isEmpty() && type != Soprano::Vocabulary::RDFS::Resource() ) {
+            Types::Class wantedType = type;
+            while ( it != m_kickoffData.end() &&
+                    it.key() == uriOrId ) {
+                if ( it.value()->hasType( type ) ) {
+                    break;
+                }
+                ++it;
+            }
+        }
+
+        resFound = ( it != m_kickoffData.end() && it.key() == uriOrId );
+    }
+
+    //
+    // The uriOrId has no local representation yet -> create one
+    //
+    if( !resFound ) {
+//        kDebug(300004) << "No existing ResourceData instance found for uriOrId " << uriOrId;
+        //
+        // Every new ResourceData object ends up in the kickoffdata since its actual URI is not known yet
+        //
+        ResourceData* d = new ResourceData( QUrl(), uriOrId, type, this );
+        m_kickoffData.insert( uriOrId, d );
+
+        return d;
+    }
+    else {
+        //
+        // Reuse the already existing ResourceData object
+        //
+        return it.value();
+    }
+}
+
+
+QList<Nepomuk::ResourceData*> Nepomuk::ResourceManagerPrivate::allResourceDataOfType( const QUrl& type )
+{
+    QList<ResourceData*> l;
+
+    if( !type.isEmpty() ) {
+        for( ResourceDataHash::iterator rdIt = m_kickoffData.begin();
+             rdIt != m_kickoffData.end(); ++rdIt ) {
+            if( rdIt.value()->type() == type ) {
+                l.append( rdIt.value() );
+            }
+        }
+    }
+
+    return l;
+}
+
+
+QList<Nepomuk::ResourceData*> Nepomuk::ResourceManagerPrivate::allResourceDataWithProperty( const QUrl& uri, const Variant& v )
+{
+    QList<ResourceData*> l;
+
+    for( ResourceDataHash::iterator rdIt = m_kickoffData.begin();
+         rdIt != m_kickoffData.end(); ++rdIt ) {
+
+        if( rdIt.value()->hasProperty( uri ) &&
+            rdIt.value()->property( uri ) == v ) {
+            l.append( rdIt.value() );
+        }
+    }
+
+    return l;
+}
+
+
+QList<Nepomuk::ResourceData*> Nepomuk::ResourceManagerPrivate::allResourceData()
+{
+    QList<ResourceData*> l;
+
+    for( ResourceDataHash::iterator rdIt = m_kickoffData.begin();
+         rdIt != m_kickoffData.end(); ++rdIt ) {
+        l.append( rdIt.value() );
+    }
+    for( ResourceDataHash::iterator rdIt = m_initializedData.begin();
+         rdIt != m_initializedData.end(); ++rdIt ) {
+        l.append( rdIt.value() );
+    }
+
+    return l;
+}
+
+
+bool Nepomuk::ResourceManagerPrivate::dataCacheFull()
+{
+    return dataCnt >= 1000;
+}
+
+
+void Nepomuk::ResourceManagerPrivate::cleanupCache()
+{
+    if ( dataCnt >= 1000 ) {
+        for( ResourceDataHash::iterator rdIt = m_initializedData.begin();
+             rdIt != m_initializedData.end(); ++rdIt ) {
+            ResourceData* data = rdIt.value();
+            if ( !data->cnt() ) {
+                data->deleteData();
+                return;
+            }
+        }
+    }
+}
 
 
 Nepomuk::ResourceManager::ResourceManager()
     : QObject(),
-      d( new Private( this ) )
+      d( new ResourceManagerPrivate( this ) )
 {
+    d->resourceFilterModel = new ResourceFilterModel();
+    connect( d->resourceFilterModel, SIGNAL(statementsAdded()),
+             this, SLOT(slotStoreChanged()) );
+    connect( d->resourceFilterModel, SIGNAL(statementsRemoved()),
+             this, SLOT(slotStoreChanged()) );
 }
 
 
 Nepomuk::ResourceManager::~ResourceManager()
 {
+    delete d->resourceFilterModel;
+    delete d->mainModel;
     delete d;
 }
 
+
+void Nepomuk::ResourceManager::deleteInstance()
+{
+    delete this;
+}
+
+
 class Nepomuk::ResourceManagerHelper
 {
     public:
@@ -91,11 +293,10 @@
 
     if( !d->mainModel ) {
         d->mainModel = new MainModel( this );
-        connect( d->mainModel, SIGNAL(statementsAdded()),
-                 this, SLOT(slotStoreChanged()) );
-        connect( d->mainModel, SIGNAL(statementsRemoved()),
-                 this, SLOT(slotStoreChanged()) );
     }
+
+    d->resourceFilterModel->setParentModel( d->mainModel );
+
     return d->mainModel->isValid() ? 0 : -1;
 }
 
@@ -136,7 +337,7 @@
 
     if( !type.isEmpty() ) {
         // check local data
-        QList<ResourceData*> localData = ResourceData::allResourceDataOfType( type );
+        QList<ResourceData*> localData = d->allResourceDataOfType( type );
         for( QList<ResourceData*>::iterator rdIt = localData.begin();
              rdIt != localData.end(); ++rdIt ) {
             l.append( Resource( *rdIt ) );
@@ -176,7 +377,7 @@
     }
     else {
         // check local data
-        QList<ResourceData*> localData = ResourceData::allResourceDataWithProperty( uri, v );
+        QList<ResourceData*> localData = d->allResourceDataWithProperty( uri, v );
         for( QList<ResourceData*>::iterator rdIt = localData.begin();
              rdIt != localData.end(); ++rdIt ) {
             l.append( Resource( *rdIt ) );
@@ -238,23 +439,19 @@
 
 Soprano::Model* Nepomuk::ResourceManager::mainModel()
 {
-    if ( d->overrideModel ) {
-        return d->overrideModel;
-    }
-
     // make sure we are initialized
-    if ( !initialized() ) {
+    if ( !d->overrideModel && !initialized() ) {
         init();
     }
 
-    return d->mainModel;
+    return d->resourceFilterModel;
 }
 
 
 void Nepomuk::ResourceManager::slotStoreChanged()
 {
 //    kDebug();
-    Q_FOREACH( ResourceData* data, ResourceData::allResourceData()) {
+    Q_FOREACH( ResourceData* data, d->allResourceData()) {
         data->invalidateCache();
     }
 }
@@ -264,27 +461,21 @@
 {
     QMutexLocker lock( &d->mutex );
 
-    if ( d->overrideModel ) {
-        d->overrideModel->disconnect( this );
-    }
-
     d->overrideModel = model;
-
-    if ( model ) {
-        connect( model, SIGNAL(statementsAdded()),
-                 this, SLOT(slotStoreChanged()) );
-        connect( model, SIGNAL(statementsRemoved()),
-                 this, SLOT(slotStoreChanged()) );
-    }
-
-    if ( d->mainModel ) {
-        d->mainModel->blockSignals( model != 0 );
-    }
+    d->resourceFilterModel->setParentModel( model ? model : d->mainModel );
 
     // clear cache to make sure we do not mix data
-    Q_FOREACH( ResourceData* data, ResourceData::allResourceData()) {
+    Q_FOREACH( ResourceData* data, d->allResourceData()) {
         data->invalidateCache();
     }
 }
 
+
+Nepomuk::ResourceManager* Nepomuk::ResourceManager::createManagerForModel( Soprano::Model* model )
+{
+    ResourceManager* manager = new ResourceManager();
+    manager->setOverrideMainModel( model );
+    return manager;
+}
+
 #include "resourcemanager.moc"
diff -u -r -N nepomuk/core/resourcemanager.h nepomuk-svn/core/resourcemanager.h
--- nepomuk/core/resourcemanager.h	2009-01-06 18:27:42.000000000 +0100
+++ nepomuk-svn/core/resourcemanager.h	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /* 
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2006-2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -39,6 +39,7 @@
     class Resource;
     class Variant;
     class ResourceManagerHelper;
+    class ResourceManagerPrivate;
 
     /**
      * \class ResourceManager resourcemanager.h Nepomuk/ResourceManager
@@ -55,6 +56,17 @@
         static ResourceManager* instance();
 
         /**
+         * In KDE 4.3 support for multiple ResourceManager instances
+         * has been introduced. To keep binary compatibility both the constructor's
+         * and destructor's access visibility could not be changed. Thus, instead of deleting
+         * a custom ResourceManager instance the standard way, one has to call this
+         * method or use QObject::deleteLater.
+         *
+         * \since 4.3
+         */
+        void deleteInstance();
+
+        /**
          * Initialize the Nepomuk framework. This method will initialize the communication with
          * the local Nepomuk-KDE services, ie. the data repository.
          *
@@ -109,6 +121,13 @@
         void removeResource( const QString& uri );
 
         /**
+         * Retrieve a list of all resource managed by this manager.
+         *
+         * \since 4.3
+         */
+        QList<Resource> allResources();
+
+        /**
          * Retrieve a list of all resources of the specified \a type.
          *
          * This includes Resources that are not synced yet so it might
@@ -164,6 +183,18 @@
          */
         void notifyError( const QString& uri, int errorCode );
 
+        /**
+         * Create a new ResourceManager instance which uses model as its
+         * override model. This allows to use multiple instances of ResourceManager
+         * at the same time. Normally one does not need this method as the singleton
+         * accessed via instance() should be enough.
+         *
+         * \param model The model to read and write data from and to.
+         *
+         * \since 4.3
+         */
+        static ResourceManager* createManagerForModel( Soprano::Model* model );
+
     Q_SIGNALS:
         /**
          * This signal gets emitted whenever a Resource changes due to a sync procedure.
@@ -190,11 +221,11 @@
 
     private:
         friend class Nepomuk::ResourceManagerHelper;
+        friend class Nepomuk::Resource;
         ResourceManager();
         ~ResourceManager();
 
-        class Private;
-        Private* const d;
+        ResourceManagerPrivate* const d;
     };
 }
 
diff -u -r -N nepomuk/core/resourcemanager_p.h nepomuk-svn/core/resourcemanager_p.h
--- nepomuk/core/resourcemanager_p.h	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/resourcemanager_p.h	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,104 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_MANAGER_P_H_
+#define _NEPOMUK_RESOURCE_MANAGER_P_H_
+
+#include <QtCore/QMutex>
+#include <QtCore/QUrl>
+
+#include "resourcedata.h"
+
+
+namespace Soprano {
+    class Model;
+}
+
+
+namespace Nepomuk {
+
+    class ResourceManager;
+    class MainModel;
+    class ResourceFilterModel;
+
+    typedef QHash<QString, Nepomuk::ResourceData*> ResourceDataHash;
+
+    class ResourceManagerPrivate
+    {
+    public:
+        ResourceManagerPrivate( ResourceManager* manager );
+
+        /**
+         * The Nepomuk lib uses just one context (named graph)
+         * for all statements. This makes things simpler and
+         * we do not use the context for anything else than
+         * the named graph type anyway.
+         */
+        QUrl mainContext();
+
+        Nepomuk::MainModel* mainModel;
+        ResourceFilterModel* resourceFilterModel;
+        Soprano::Model* overrideModel;
+
+        QMutex mutex;
+
+        ResourceDataHash m_initializedData;
+        ResourceDataHash m_kickoffData;
+        int dataCnt;
+
+        ResourceManager* m_manager;
+
+        /**
+         * The Nepomuk lib is based on the fact that for each uri only one ResourceData object is
+         * created at all times. This method searches for an existing data object to reuse or creates
+         * a new one if none exists.
+         *
+         * \param uriOrId The URI or identifier of the resource is question.
+         * \type The type of the resource.
+         *
+         * The Resource constructors use this method in combination with ref()
+         */
+        ResourceData* data( const QString& uriOrId, const QUrl& type );
+
+        /**
+         * The Nepomuk lib is based on the fact that for each uri only one ResourceData object is
+         * created at all times. This method searches for an existing data object to reuse or creates
+         * a new one if none exists.
+         *
+         * \param uri The URI of the resource is question.
+         * \type The type of the resource.
+         *
+         * The Resource constructors use this method in combination with ref()
+         */
+        ResourceData* data( const QUrl& uri, const QUrl& type );
+
+        bool dataCacheFull();
+        void cleanupCache();
+
+        QList<ResourceData*> allResourceData();
+        QList<ResourceData*> allResourceDataOfType( const QUrl& type );
+        QList<ResourceData*> allResourceDataWithProperty( const QUrl& _uri, const Variant& v );
+
+    private:
+        QUrl m_mainContext;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/tag.cpp nepomuk-svn/core/tag.cpp
--- nepomuk/core/tag.cpp	2008-07-08 11:54:17.000000000 +0200
+++ nepomuk-svn/core/tag.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -34,6 +34,12 @@
 }
 
 
+Nepomuk::Tag::Tag( ResourceManager* manager )
+    : Resource( manager )
+{
+}
+
+
 Nepomuk::Tag::Tag( const Tag& res )
     : Resource( res )
 {
@@ -51,21 +57,49 @@
 {
 }
 
+
+Nepomuk::Tag::Tag( const QString& uri, ResourceManager* manager )
+    : Resource( uri, Soprano::Vocabulary::NAO::Tag(), manager )
+{
+}
+
+
 Nepomuk::Tag::Tag( const QUrl& uri )
     : Resource( uri, Soprano::Vocabulary::NAO::Tag() )
 {
 }
 
+
+Nepomuk::Tag::Tag( const QUrl& uri, ResourceManager* manager )
+    : Resource( uri, Soprano::Vocabulary::NAO::Tag(), manager )
+{
+}
+
+
 Nepomuk::Tag::Tag( const QString& uri, const QUrl& type )
     : Resource( uri, type )
 {
 }
 
+
+Nepomuk::Tag::Tag( const QString& uri, const QUrl& type, ResourceManager* manager )
+    : Resource( uri, type, manager )
+{
+}
+
+
 Nepomuk::Tag::Tag( const QUrl& uri, const QUrl& type )
     : Resource( uri, type )
 {
 }
 
+
+Nepomuk::Tag::Tag( const QUrl& uri, const QUrl& type, ResourceManager* manager )
+    : Resource( uri, type, manager )
+{
+}
+
+
 Nepomuk::Tag::~Tag()
 {
 }
@@ -83,11 +117,14 @@
     return Soprano::Vocabulary::NAO::Tag().toString();
 }
 
+
 QList<Nepomuk::Resource> Nepomuk::Tag::tagOf() const
 {
-    return convertResourceList<Resource>( ResourceManager::instance()->allResourcesWithProperty( Soprano::Vocabulary::NAO::hasTag(), *this ) );
+    return convertResourceList<Resource>( manager()->allResourcesWithProperty( Soprano::Vocabulary::NAO::hasTag(), *this ) );
 }
 
+
+// static
 QList<Nepomuk::Tag> Nepomuk::Tag::allTags()
 {
     return Nepomuk::convertResourceList<Tag>( ResourceManager::instance()->allResourcesOfType( Soprano::Vocabulary::NAO::Tag() ) );
diff -u -r -N nepomuk/core/tag.h nepomuk-svn/core/tag.h
--- nepomuk/core/tag.h	2008-05-21 13:07:45.000000000 +0200
+++ nepomuk-svn/core/tag.h	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -21,12 +21,8 @@
 #ifndef _TAG_H_
 #define _TAG_H_
 
-namespace Nepomuk {
-        class Resource;
-}
-
 #include "resource.h"
-#include <nepomuk/nepomuk_export.h>
+#include "nepomuk_export.h"
 
 namespace Nepomuk {
 
@@ -46,40 +42,83 @@
          * Create a new empty and invalid Tag instance
          */
         Tag();
+
+        /**
+         * Create a new empty and invalid Tag instance
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Tag( ResourceManager* manager );
+
         /**
          * Default copy constructor
          */
         Tag( const Tag& );
+
+        /**
+         * \overload
+         */
         Tag( const Resource& );
+
         /**
          * Create a new Tag instance representing the resource
          * referenced by \a uriOrIdentifier.
          */
         Tag( const QString& uriOrIdentifier );
+
+        /**
+         * Create a new Tag instance representing the resource
+         * referenced by \a uriOrIdentifier.
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Tag( const QString& uriOrIdentifier, ResourceManager* manager );
+
         /**
          * Create a new Tag instance representing the resource
          * referenced by \a uri.
          */
         Tag( const QUrl& uri );
+
+        /**
+         * Create a new Tag instance representing the resource
+         * referenced by \a uri.
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Tag( const QUrl& uri, ResourceManager* manager );
+
+        /**
+         * Destructor
+         */
         ~Tag();
 
         Tag& operator=( const Tag& );
 
-            /**
-             * Get all resources that have this resource set as property 'Tag'. 
-             * Each Resource can be tagged with an arbitrary number of Tags. 
-             * This allows a simple grouping of resources. \sa ResourceManager::allResourcesWithProperty 
-             */
-            QList<Resource> tagOf() const;
-
-            /**
-             * Retrieve a list of all available Tag resources. This list consists 
-             * of all resource of type Tag that are stored in the local Nepomuk 
-             * meta data storage and any changes made locally. Be aware that 
-             * in some cases this list can get very big. Then it might be better 
-             * to use libKNep directly. 
-             */
-            static QList<Tag> allTags();
+        /**
+         * Get all resources that have this resource set as property 'Tag'. 
+         * Each Resource can be tagged with an arbitrary number of Tags. 
+         * This allows a simple grouping of resources. \sa ResourceManager::allResourcesWithProperty 
+         */
+        QList<Resource> tagOf() const;
+
+        /**
+         * Retrieve a list of all available Tag resources. This list consists 
+         * of all resource of type Tag that are stored in the local Nepomuk 
+         * meta data storage and any changes made locally. Be aware that 
+         * in some cases this list can get very big. Then it might be better 
+         * to use libKNep directly. 
+         */
+        static QList<Tag> allTags();
 
 
         /**
@@ -88,8 +127,18 @@
         static QString resourceTypeUri();
 
     protected:
-       Tag( const QString& uri, const QUrl& type );
-       Tag( const QUrl& uri, const QUrl& type );
+        Tag( const QString& uri, const QUrl& type );
+        Tag( const QUrl& uri, const QUrl& type );
+
+        /**
+         * \since 4.3
+         */
+        Tag( const QString& uri, const QUrl& type, ResourceManager* manager );
+
+        /**
+         * \since 4.3
+         */
+        Tag( const QUrl& uri, const QUrl& type, ResourceManager* manager );
    };
 }
 
diff -u -r -N nepomuk/core/test/.svn/all-wcprops nepomuk-svn/core/test/.svn/all-wcprops
--- nepomuk/core/test/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/all-wcprops	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,89 @@
+K 25
+svn:wc:ra_dav:version-url
+V 61
+/home/kde/!svn/ver/886480/trunk/KDE/kdelibs/nepomuk/core/test
+END
+testbase.h
+K 25
+svn:wc:ra_dav:version-url
+V 72
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/testbase.h
+END
+speedtest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/829275/trunk/KDE/kdelibs/nepomuk/core/test/speedtest.cpp
+END
+datetimetest.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/datetimetest.h
+END
+resourcedatatest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 82
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/resourcedatatest.cpp
+END
+tagcloudtest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/748030/trunk/KDE/kdelibs/nepomuk/core/test/tagcloudtest.cpp
+END
+varianttest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/varianttest.cpp
+END
+speedtest.h
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/home/kde/!svn/ver/733956/trunk/KDE/kdelibs/nepomuk/core/test/speedtest.h
+END
+resourcedatatest.h
+K 25
+svn:wc:ra_dav:version-url
+V 80
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/resourcedatatest.h
+END
+resourcetest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/886480/trunk/KDE/kdelibs/nepomuk/core/test/resourcetest.cpp
+END
+varianttest.h
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/varianttest.h
+END
+testbase.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/home/kde/!svn/ver/804580/trunk/KDE/kdelibs/nepomuk/core/test/testbase.cpp
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/861478/trunk/KDE/kdelibs/nepomuk/core/test/CMakeLists.txt
+END
+datetimetest.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/datetimetest.cpp
+END
+resourcetest.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/674110/trunk/KDE/kdelibs/nepomuk/core/test/resourcetest.h
+END
diff -u -r -N nepomuk/core/test/.svn/entries nepomuk-svn/core/test/.svn/entries
--- nepomuk/core/test/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/entries	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,504 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/core/test
+https://svn.kde.org/home/kde
+
+
+
+2008-11-19T11:33:19.009228Z
+886480
+trueg
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+testbase.h
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+733377bb47ad3f76c0d425ad3a5e70d7
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+730
+
+speedtest.cpp
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+9cb442b7f2a7f79cc0401fff343b11b3
+2008-07-07T23:46:37.001233Z
+829275
+dfaure
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4566
+
+datetimetest.h
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+a4b561a2c0142a9d18f50beb700487eb
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+725
+
+resourcedatatest.cpp
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+45025249a1852e5afd673b6f13a921e1
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+8190
+
+tagcloudtest.cpp
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+9563d5fa6737b9cb88aaa702c8096701
+2007-12-13T12:42:30.147413Z
+748030
+alexmerry
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1674
+
+varianttest.cpp
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+e5a4a627894397481afb6bd34bf2a3f8
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2410
+
+speedtest.h
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+6b529a4a2e338c4d293e28cd0475b42c
+2007-11-07T17:32:05.244147Z
+733956
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+756
+
+resourcedatatest.h
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+c636c1a14c9dccb8a4209987b4707c18
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+795
+
+resourcetest.cpp
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+279fe43ceb9da77d74dc2f8c26c28e99
+2008-11-19T11:33:19.009228Z
+886480
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9982
+
+varianttest.h
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+3768ceba7d6cac74492a2894260aed48
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+772
+
+testbase.cpp
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+affe207dea8e9176415bafdc5a1d8032
+2008-05-06T13:54:01.102993Z
+804580
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+932
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+af9ba95e2ce843a7e967ae1612d09b3a
+2008-09-16T09:10:25.560325Z
+861478
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1778
+
+datetimetest.cpp
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+0fe598e4d27a2c4dea8f7a25297397bd
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4338
+
+resourcetest.h
+file
+
+
+
+
+2009-02-27T12:37:47.000000Z
+2f43b0e23b8b08e2177f813858ffeb3e
+2007-06-11T19:22:30.936419Z
+674110
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+819
+
diff -u -r -N nepomuk/core/test/.svn/format nepomuk-svn/core/test/.svn/format
--- nepomuk/core/test/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/format	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/core/test/.svn/prop-base/CMakeLists.txt.svn-base nepomuk-svn/core/test/.svn/prop-base/CMakeLists.txt.svn-base
--- nepomuk/core/test/.svn/prop-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/prop-base/CMakeLists.txt.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mime-type
+V 10
+text/plain
+END
diff -u -r -N nepomuk/core/test/.svn/prop-base/tagcloudtest.cpp.svn-base nepomuk-svn/core/test/.svn/prop-base/tagcloudtest.cpp.svn-base
--- nepomuk/core/test/.svn/prop-base/tagcloudtest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/prop-base/tagcloudtest.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/test/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/core/test/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/core/test/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,64 @@
+set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
+project(kmetadata_tests)
+
+include_directories(
+  ${kmetadata_SOURCE_DIR}
+  ${libkmetadata_SOURCE_DIR}
+  ${libkmetadata_SOURCE_DIR}/generated
+  ${kmetadata_ui_SOURCE_DIR}
+)
+
+include_directories( ${KDE4_KDEUI_INCLUDES} )
+include_directories( ${QT_INCLUDES} ${SOPRANO_INCLUDE_DIR} )
+
+# The basis of all the tests handling statements
+kde4_add_library(nepomuk_testbase STATIC testbase.cpp)
+target_link_libraries(nepomuk_testbase nepomuk ${QT_QTCORE_LIBRARY} ${QT_QTTEST_LIBRARY})
+
+# tests
+kde4_add_unit_test(resourcetest resourcetest.cpp)
+target_link_libraries(resourcetest
+  nepomuk_testbase
+  ${QT_QTCORE_LIBRARY}
+  ${QT_QTDBUS_LIBRARY}
+  ${QT_QTTEST_LIBRARY}
+  ${QT_QTGUI_LIBRARY}
+  ${SOPRANO_LIBRARIES}
+  ${KDE4_KDECORE_LIBS})
+
+#kde4_add_unit_test(varianttest varianttest.cpp)
+#target_link_libraries(varianttest kmetadata ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTTEST_LIBRARY})
+
+kde4_add_unit_test(speedtest speedtest.cpp)
+target_link_libraries(speedtest
+  nepomuk
+  ${QT_QTCORE_LIBRARY}
+  ${QT_QTDBUS_LIBRARY}
+  ${QT_QTTEST_LIBRARY}
+  ${QT_QTGUI_LIBRARY}
+  ${SOPRANO_LIBRARIES}
+  ${KDE4_KDECORE_LIBS})
+
+#set(datatest_SRC 
+#  resourcedatatest.cpp
+#  ../kmetadata/resourcedata.cpp
+#)
+#kde4_add_unit_test(resourcedatatest ${datatest_SRC})
+#target_link_libraries(resourcedatatest
+#  kmetadata_testbase
+#  kmetadata
+#  knepomuk
+#  konto
+#  ${QT_QTCORE_LIBRARY}
+#  ${QT_QTDBUS_LIBRARY}
+#  ${QT_QTTEST_LIBRARY}
+#  ${QT_QTGUI_LIBRARY}
+#  ${KDE4_KDECORE_LIBRARY})
+
+# Not a real test, just a simple app for testing a widget manually
+kde4_add_executable(tagcloudtest TEST tagcloudtest.cpp)
+target_link_libraries(tagcloudtest nepomuk
+  ${QT_QTCORE_LIBRARY}
+  ${QT_QTGUI_LIBRARY}
+  ${KDE4_KDECORE_LIBS}
+  ${KDE4_KDEUI_LIBS})
diff -u -r -N nepomuk/core/test/.svn/text-base/datetimetest.cpp.svn-base nepomuk-svn/core/test/.svn/text-base/datetimetest.cpp.svn-base
--- nepomuk/core/test/.svn/text-base/datetimetest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/datetimetest.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,85 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "datetimetest.h"
+#include <kmetadata/datetime.h>
+
+#include <kdatetime.h>
+#include <qtest_kde.h>
+
+using namespace Nepomuk::KMetaData;
+
+void DateTimeTest::testDateTime()
+{
+    QDate date1( QDate::currentDate() );
+    QDate date2( -10, 3, 23 );
+
+    QTime time1( QTime::currentTime() );
+    QTime time2( 13, 2, 10, 99 );
+    QTime time3( 13, 2, 10 );
+
+    QDateTime dateTime1( QDateTime::currentDateTime() );
+    QDateTime dateTime2( date2, time2, Qt::UTC );
+    QDateTime dateTime3( date2, time2, Qt::LocalTime );
+
+    // check if the strings are actually correct
+    QCOMPARE( DateTime::toString( date2 ), QString("-0010-03-23") );
+    QCOMPARE( DateTime::toString( time3 ), QString("13:02:10Z") );
+    QCOMPARE( DateTime::toString( time2 ), QString("13:02:10.099Z") );
+    QCOMPARE( DateTime::toString( dateTime2 ), QString("-0010-03-23T13:02:10.099Z") );
+
+//     QCOMPARE( KDateTime( date2 ).toString( KDateTime::ISODate ), QString("-0010-03-23") );
+//     QCOMPARE( KDateTime( time3, KDateTime::UTC ).toString( KDateTime::ISODate ), QString("13:02:10Z") );
+//     QCOMPARE( KDateTime( time2, KDateTime::UTC ).toUtc().toString( KDateTime::ISODate ), QString("13:02:10.099Z") );
+//     QCOMPARE( KDateTime( dateTime2 ).toUtc().toString( KDateTime::ISODate ), QString("-0010-03-23T13:02:10.099Z") );
+
+    // check timezone conversion
+//     QCOMPARE( DateTime::fromTimeString( "13:02:10.099Z" ),
+//               KDateTime::fromString( "13:02:10.099Z", KDateTime::ISODate ).toUtc().time() );
+//     QCOMPARE( DateTime::fromTimeString( "15:02:10.099+02:00" ),
+//               KDateTime::fromString( "15:02:10.099+02:00", KDateTime::ISODate ).toUtc().time() );
+//     QCOMPARE( DateTime::fromTimeString( "11:02:10.099-02:00" ),
+//               KDateTime::fromString( "11:02:10.099-02:00", KDateTime::ISODate ).toUtc().time() );
+
+    // check conversion in general
+    QVERIFY( !DateTime::toString( date1 ).isEmpty() );
+    QVERIFY( !DateTime::toString( date2 ).isEmpty() );
+    QVERIFY( !DateTime::toString( time1 ).isEmpty() );
+    QVERIFY( !DateTime::toString( time2 ).isEmpty() );
+    QVERIFY( !DateTime::toString( time3 ).isEmpty() );
+    QVERIFY( !DateTime::toString( dateTime2 ).isEmpty() );
+    QCOMPARE( DateTime::fromDateString( DateTime::toString( date1 ) ), date1 );
+    QCOMPARE( DateTime::fromDateString( DateTime::toString( date2 ) ), date2 );
+    QCOMPARE( DateTime::fromTimeString( DateTime::toString( time1 ) ), time1 );
+    QCOMPARE( DateTime::fromTimeString( DateTime::toString( time2 ) ), time2 );
+    QCOMPARE( DateTime::fromTimeString( DateTime::toString( time3 ) ), time3 );
+
+    // for some weird reason QDateTime does not properly convert to UTC when comparing objects
+    QCOMPARE( DateTime::fromDateTimeString( DateTime::toString( dateTime1 ) ), dateTime1.toUTC() );
+    QCOMPARE( DateTime::fromDateTimeString( DateTime::toString( dateTime2 ) ), dateTime2.toUTC() );
+    QCOMPARE( DateTime::fromDateTimeString( DateTime::toString( dateTime3 ) ), dateTime3.toUTC() );
+
+    // check if KDateTime provides the same
+//     QCOMPARE( DateTime::toString( dateTime1 ), KDateTime( dateTime1 ).toUtc().toString( KDateTime::ISODate ) );
+//     QCOMPARE( DateTime::toString( dateTime2 ), KDateTime( dateTime2 ).toUtc().toString( KDateTime::ISODate ) );
+//     QCOMPARE( DateTime::toString( dateTime3 ), KDateTime( dateTime3 ).toUtc().toString( KDateTime::ISODate ) );
+
+//     QCOMPARE( DateTime::fromDateTimeString( KDateTime( dateTime1 ).toString( KDateTime::ISODate ) ), dateTime1.toUTC() );
+//     QCOMPARE( DateTime::fromDateTimeString( KDateTime( dateTime2 ).toString( KDateTime::ISODate ) ), dateTime2.toUTC() );
+//     QCOMPARE( DateTime::fromDateTimeString( KDateTime( dateTime3 ).toString( KDateTime::ISODate ) ), dateTime3.toUTC() );
+}
+
+QTEST_KDEMAIN(DateTimeTest,  NoGUI)
+
+#include "datetimetest.moc"
diff -u -r -N nepomuk/core/test/.svn/text-base/datetimetest.h.svn-base nepomuk-svn/core/test/.svn/text-base/datetimetest.h.svn-base
--- nepomuk/core/test/.svn/text-base/datetimetest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/datetimetest.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,30 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _DATETIME_TEST_H_
+#define _DATETIME_TEST_H_
+
+#include <QtTest/QtTest>
+
+#include <kmetadata/datetime.h>
+
+class DateTimeTest : public QObject
+{
+    Q_OBJECT
+    
+ private Q_SLOTS:
+    void testDateTime();
+};
+
+#endif
diff -u -r -N nepomuk/core/test/.svn/text-base/resourcedatatest.cpp.svn-base nepomuk-svn/core/test/.svn/text-base/resourcedatatest.cpp.svn-base
--- nepomuk/core/test/.svn/text-base/resourcedatatest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/resourcedatatest.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,230 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "resourcedatatest.h"
+
+#include "../kmetadata/kmetadata.h"
+
+#include <knepomuk/knepomuk.h>
+#include <knepomuk/services/rdfrepository.h>
+
+#include <konto/ontologyloader.h>
+#include <konto/ontologymanager.h>
+#include <konto/global.h>
+
+#include <kdebug.h>
+#include <qtest_kde.h>
+
+using namespace Nepomuk::KMetaData;
+using namespace Nepomuk::RDF;
+using namespace Nepomuk::Services;
+using namespace Soprano;
+
+
+void ResourceDataTest::testResourceData()
+{
+    QString uri;
+    QString id = "id002";
+
+    {
+        ResourceData* rd1 = new ResourceData( id );
+        QVERIFY( rd1->uri().isEmpty() );
+        QCOMPARE( rd1->kickoffUriOrId(), id );
+        QVERIFY( rd1->determineUri() );
+        uri = rd1->uri();
+        QVERIFY( !rd1->uri().isEmpty() );
+
+        QVERIFY( !rd1->exists() );
+        QVERIFY( rd1->store() );
+        QVERIFY( rd1->exists() );
+        rd1->deleteData();
+    }
+
+    {
+        ResourceData* rd = new ResourceData( id );
+        QVERIFY( rd->determineUri() );
+        QCOMPARE( rd->uri(), uri );
+        QVERIFY( rd->exists() );
+        rd->deleteData();
+    }
+
+    {
+        ResourceData* rd = new ResourceData( uri );
+        QVERIFY( rd->determineUri() );
+        QCOMPARE( rd->uri(), uri );
+        QVERIFY( rd->exists() );
+        rd->deleteData();
+    }
+}
+
+
+void ResourceDataTest::testPropertyTypes()
+{
+    Variant vInt( (int)17 );
+    Variant vUInt( (unsigned int)12 );
+    Variant vLong( (long long)123498670808943LL );
+    Variant vULong( (unsigned long long)2709487120951223ULL );
+    Variant vDouble( 78879.2324 );
+    Variant vDate( QDate( 1977, 8, 9 ) );
+    Variant vTime( QTime::currentTime() );
+    Variant vDateTime( QDateTime( vDate.toDate(), vTime.toTime() ) );
+
+    {
+        ResourceData* r1 = new ResourceData( "something12" );
+
+        r1->setProperty( "hasInt", vInt );
+        r1->setProperty( "hasUInt", vUInt );
+        r1->setProperty( "hasLong", vLong );
+        r1->setProperty( "hasULong", vULong );
+        r1->setProperty( "hasDouble", vDouble );
+        r1->setProperty( "hasDate", vDate );
+        r1->setProperty( "hasTime", vTime );
+        r1->setProperty( "hasDateTime", vDateTime );
+
+        r1->deleteData();
+    }
+
+    {
+        ResourceData* r1 = new ResourceData( "something12" );
+
+        QVERIFY( r1->hasProperty( "hasInt" ) );
+        QVERIFY( r1->hasProperty( "hasUInt" ) );
+        QVERIFY( r1->hasProperty( "hasLong" ) );
+        QVERIFY( r1->hasProperty( "hasULong" ) );
+        QVERIFY( r1->hasProperty( "hasDouble" ) );
+        QVERIFY( r1->hasProperty( "hasDate" ) );
+        QVERIFY( r1->hasProperty( "hasTime" ) );
+        QVERIFY( r1->hasProperty( "hasDateTime" ) );
+
+        QCOMPARE( r1->property( "hasInt" ).toInt(), vInt.toInt() );
+        QCOMPARE( r1->property( "hasUInt" ).toUnsignedInt(), vUInt.toUnsignedInt() );
+        QCOMPARE( r1->property( "hasLong" ).toInt64(), vLong.toInt64() );
+        QCOMPARE( r1->property( "hasULong" ).toUnsignedInt64(), vULong.toUnsignedInt64() );
+        QCOMPARE( r1->property( "hasDouble" ).toDouble(), vDouble.toDouble() );
+        QCOMPARE( r1->property( "hasDate" ).toDate(), vDate.toDate() );
+        QCOMPARE( r1->property( "hasTime" ).toTime(), vTime.toTime() );
+        QCOMPARE( r1->property( "hasDateTime" ).toDateTime(), vDateTime.toDateTime().toUTC() );
+
+        r1->deleteData();
+    }
+}
+
+
+class DummyOntologyLoader : public Konto::OntologyLoader
+{
+public:
+    QList<Soprano::Statement> loadOntology( const QUrl& uri ) {
+        // create some dummy onto stuff
+        QList<Statement> sl;
+
+        QString ns = uri.toString();
+        if ( !ns.endsWith( "#" ) ) {
+            ns += '#';
+        }
+
+        // one dummy class
+        sl.append( Statement( QUrl( ns + "DummyClass" ),
+                              QUrl( Konto::rdfNamespace() + "type" ),
+                              QUrl( Konto::rdfsNamespace() + "Class" ) ) );
+        sl.append( Statement( QUrl( ns + "DummyClass" ),
+                              QUrl( Konto::rdfsNamespace() + "label" ),
+                              LiteralValue( "A dummy class" ) ) );
+
+        sl.append( Statement( QUrl( ns + "DummySubClass" ),
+                              QUrl( Konto::rdfNamespace() + "type" ),
+                              QUrl( Konto::rdfsNamespace() + "Class" ) ) );
+        sl.append( Statement( QUrl( ns + "DummySubClass" ),
+                              QUrl( Konto::rdfsNamespace() + "subClassOf" ),
+                              QUrl( ns + "DummyClass" ) ) );
+
+        sl.append( Statement( QUrl( ns + "DummySubSubClass" ),
+                              QUrl( Konto::rdfNamespace() + "type" ),
+                              QUrl( Konto::rdfsNamespace() + "Class" ) ) );
+        sl.append( Statement( QUrl( ns + "DummySubSubClass" ),
+                              QUrl( Konto::rdfsNamespace() + "subClassOf" ),
+                              QUrl( ns + "DummySubClass" ) ) );
+
+        sl.append( Statement( QUrl( ns + "SomeOtherDummyClass" ),
+                              QUrl( Konto::rdfNamespace() + "type" ),
+                              QUrl( Konto::rdfsNamespace() + "Class" ) ) );
+
+        return sl;
+    }
+};
+
+
+void ResourceDataTest::testTypeHandling()
+{
+    Konto::OntologyManager::instance()->setOntologyLoader( new DummyOntologyLoader() );
+
+    ResourceData* r1 = ResourceData::data( "test", "test#DummyClass" );
+    ResourceData* r2 = ResourceData::data( "test", "test#DummySubClass" );
+    ResourceData* r3 = ResourceData::data( "test", "test#DummySubSubClass" );
+    ResourceData* r4 = ResourceData::data( "test", "test#SomeOtherDummyClass" );
+    ResourceData* r5 = ResourceData::data( "test", "http://www.w3.org/2000/01/rdf-schema#Resource" );
+
+    // let's create one that can be loaded from the store
+    Nepomuk::Services::RDFRepository rr( ResourceManager::instance()->serviceRegistry()->discoverRDFRepository() );
+    QString uri = ResourceManager::instance()->generateUniqueUri();
+    QList<Statement> sl;
+    sl.append( Statement( QUrl( uri ),
+                          QUrl( typePredicate() ),
+                          QUrl( "test#SomeOtherDummyClass" ) ) );
+    sl.append( Statement( QUrl( uri ),
+                          QUrl( Resource::identifierUri() ),
+                          LiteralValue( "test2" ) ) );
+    rr.addStatements( defaultGraph(), sl );
+
+    ResourceData* r6 = ResourceData::data( "test2", "http://www.w3.org/2000/01/rdf-schema#Resource" );
+
+    QCOMPARE( r1, r2 );
+    QCOMPARE( r1, r3 );
+    QVERIFY( r1 != r4 );
+    QVERIFY( r1 == r5 ||
+             r4 == r5 );
+    QVERIFY( r1 != r6 );
+    QVERIFY( r5 != r6 );
+
+    QVERIFY( r1->determineUri() );
+    QVERIFY( r2->determineUri() );
+    QVERIFY( r3->determineUri() );
+    QVERIFY( r4->determineUri() );
+    QVERIFY( r5->determineUri() );
+    QVERIFY( r6->determineUri() );
+    QVERIFY( r6->determineUri() );
+
+    // the first three resourcedatas should have the same URI since their type and identifier match
+    // the fourth has a completely different type, thus the URI should differ
+    QCOMPARE( r1->uri(), r2->uri() );
+    QCOMPARE( r1->uri(), r3->uri() );
+    QVERIFY( r1->uri() != r4->uri() );
+    QVERIFY( r1->uri() == r5->uri() ||
+             r4->uri() == r5->uri() );
+    QVERIFY( r1->uri() != r6->uri() );
+    QVERIFY( r5->uri() != r6->uri() );
+
+    // the type should be set to the most detailed one
+    QCOMPARE( r1->type(), QString( "test#DummySubSubClass" ) );
+    QCOMPARE( r4->type(), QString( "test#SomeOtherDummyClass" ) );
+    QCOMPARE( r6->type(), QString( "test#SomeOtherDummyClass" ) );
+
+    r1->deleteData(); // r1 == r2 == r3
+    r4->deleteData(); // r4 == r5
+    r6->deleteData();
+}
+
+
+QTEST_KDEMAIN(ResourceDataTest, NoGUI)
+
+#include "resourcedatatest.moc"
diff -u -r -N nepomuk/core/test/.svn/text-base/resourcedatatest.h.svn-base nepomuk-svn/core/test/.svn/text-base/resourcedatatest.h.svn-base
--- nepomuk/core/test/.svn/text-base/resourcedatatest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/resourcedatatest.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,32 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _RESOURCE_DATA_TEST_H_
+#define _RESOURCE_DATA_TEST_H_
+
+#include "testbase.h"
+
+#include <kmetadata/resourcedata.h>
+
+class ResourceDataTest : public TestBase
+{
+    Q_OBJECT
+
+ private Q_SLOTS:
+    void testResourceData();
+    void testPropertyTypes();
+    void testTypeHandling();
+};
+
+#endif
diff -u -r -N nepomuk/core/test/.svn/text-base/resourcetest.cpp.svn-base nepomuk-svn/core/test/.svn/text-base/resourcetest.cpp.svn-base
--- nepomuk/core/test/.svn/text-base/resourcetest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/resourcetest.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,265 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "resourcetest.h"
+
+#include "../resource.h"
+#include "../variant.h"
+#include "../resourcemanager.h"
+
+#include <kdebug.h>
+#include <qtest_kde.h>
+
+#include <Soprano/Soprano>
+
+#include <QtCore/QTextStream>
+
+using namespace Soprano;
+using namespace Nepomuk;
+
+
+void ResourceTest::testResourceStates()
+{
+    QUrl someUri = ResourceManager::instance()->generateUniqueUri( QString() );
+
+    Resource r1( someUri );
+    Resource r2( someUri );
+
+    QCOMPARE( r1, r2 );
+
+    QVERIFY( r1.isValid() );
+    QVERIFY( !r1.exists() );
+
+    r1.setProperty( QUrl("http://test/something"), 12 );
+
+    QCOMPARE( r1, r2 );
+    QVERIFY( r1.exists() );
+}
+
+
+void ResourceTest::testResourceRemoval()
+{
+    Resource res( "testi" );
+    res.setProperty( QUrl("http://nepomuk.test.org/foo/bar"),  "foobar" );
+
+    QVERIFY( !res.resourceUri().isEmpty() );
+
+    QVERIFY( ResourceManager::instance()->mainModel()->containsAnyStatement( Statement( res.resourceUri(), Node(), Node() ) ) );
+
+    res.remove();
+
+    QVERIFY( !res.exists() );
+
+    QVERIFY( !ResourceManager::instance()->mainModel()->containsAnyStatement( Statement( res.resourceUri(), Node(), Node() ) ) );
+
+    //
+    // test recursive removal
+    //
+    Resource res2( "testi2" );
+
+    res.setProperty( QUrl("http://nepomuk.test.org/foo/bar2"), res2 );
+
+    QVERIFY( res.exists() );
+    QVERIFY( res2.exists() );
+
+    QVERIFY( ResourceManager::instance()->mainModel()->containsAnyStatement( Statement( res.resourceUri(), QUrl("http://nepomuk.test.org/foo/bar2"), Node(res2.resourceUri()) ) ) );
+
+    res2.remove();
+
+    QVERIFY( res.exists() );
+    QVERIFY( !res2.exists() );
+
+    QVERIFY( !ResourceManager::instance()->mainModel()->containsAnyStatement( Statement( res.resourceUri(), QUrl("http://nepomuk.test.org/foo/bar2"), Node(res2.resourceUri()) ) ) );
+}
+
+
+void ResourceTest::testProperties()
+{
+    QUrl r1Uri, r2Uri;
+
+    {
+        Resource r1( "testi" );
+        Resource r2( "testi2" );
+
+        r1.setProperty( QUrl("http://nepomuk.test.org/int"), 17 );
+        r1.setProperty( QUrl("http://nepomuk.test.org/bool1"), true );
+        r1.setProperty( QUrl("http://nepomuk.test.org/bool2"), false );
+        r1.setProperty( QUrl("http://nepomuk.test.org/double"), 2.2 );
+        r1.setProperty( QUrl("http://nepomuk.test.org/string"), "test" );
+        r1.setProperty( QUrl("http://nepomuk.test.org/date"), QDate::currentDate() );
+        r1.setProperty( QUrl("http://nepomuk.test.org/Resource"), r2 );
+
+        r1Uri = r1.resourceUri();
+        r2Uri = r2.resourceUri();
+    }
+
+    QTextStream s(stdout);
+    foreach( const Statement& st,     ResourceManager::instance()->mainModel()->listStatements().allStatements() ) {
+        s << st << endl;
+    }
+
+    {
+        Resource r1( r1Uri );
+        Resource r2( r2Uri );
+
+        QVERIFY( r1.hasProperty( QUrl("http://nepomuk.test.org/int" ) ) );
+        QVERIFY( r1.hasProperty( QUrl("http://nepomuk.test.org/bool1" ) ) );
+        QVERIFY( r1.hasProperty( QUrl("http://nepomuk.test.org/bool2" ) ) );
+        QVERIFY( r1.hasProperty( QUrl("http://nepomuk.test.org/double" ) ) );
+        QVERIFY( r1.hasProperty( QUrl("http://nepomuk.test.org/string" ) ) );
+        QVERIFY( r1.hasProperty( QUrl("http://nepomuk.test.org/date" ) ) );
+        QVERIFY( r1.hasProperty( QUrl("http://nepomuk.test.org/Resource" ) ) );
+
+        QCOMPARE( r1.property( QUrl("http://nepomuk.test.org/int" ) ).toInt(), 17 );
+        QCOMPARE( r1.property( QUrl("http://nepomuk.test.org/bool1" ) ).toBool(), true );
+        QCOMPARE( r1.property( QUrl("http://nepomuk.test.org/bool2" ) ).toBool(), false );
+        QCOMPARE( r1.property( QUrl("http://nepomuk.test.org/double" ) ).toDouble(), 2.2 );
+        QCOMPARE( r1.property( QUrl("http://nepomuk.test.org/string" ) ).toString(), QString("test") );
+        QCOMPARE( r1.property( QUrl("http://nepomuk.test.org/date" ) ).toDate(), QDate::currentDate() );
+        QCOMPARE( r1.property( QUrl("http://nepomuk.test.org/Resource" ) ).toResource(), r2 );
+
+        QHash<QString, Variant> allProps = r1.allProperties();
+        QCOMPARE( allProps.count(), 10 ); // properties + type + identifier + modification date
+        QVERIFY( allProps.keys().contains( "http://nepomuk.test.org/int" ) );
+        QVERIFY( allProps.keys().contains( "http://nepomuk.test.org/bool1" ) );
+        QVERIFY( allProps.keys().contains( "http://nepomuk.test.org/bool2" ) );
+        QVERIFY( allProps.keys().contains( "http://nepomuk.test.org/double" ) );
+        QVERIFY( allProps.keys().contains( "http://nepomuk.test.org/string" ) );
+        QVERIFY( allProps.keys().contains( "http://nepomuk.test.org/date" ) );
+        QVERIFY( allProps.keys().contains( "http://nepomuk.test.org/Resource" ) );
+    }
+}
+
+
+void ResourceTest::testResourceIdentifiers()
+{
+    QUrl theUri;
+    {
+        Resource r1( "wurst" );
+        Resource r2( "wurst" );
+
+        QVERIFY( r1 == r2 );
+
+        theUri = r1.resourceUri();
+
+        Resource r3( r1.resourceUri() );
+
+        QVERIFY( r1 == r3 );
+
+        QVERIFY( r1.resourceUri() != QUrl("wurst") );
+
+        r1.setProperty( QUrl("http://nepomuk.test.org/foo/bar"), "foobar" );
+
+        QList<Statement> sl
+            = ResourceManager::instance()->mainModel()->listStatements( Statement( r1.resourceUri(), Node(), Node() ) ).allStatements();
+
+        foreach( const Statement& s, sl )
+            qDebug() << s << endl;
+
+        QCOMPARE( sl.count(), 4 );
+
+        QVERIFY( ResourceManager::instance()->mainModel()->containsAnyStatement( Statement( r1.resourceUri(),
+                                                                                            QUrl( Resource::identifierUri() ),
+                                                                                            LiteralValue( "wurst" ) ) ) );
+    }
+
+    {
+        Resource r1( theUri );
+        Resource r2( "wurst" );
+
+        QCOMPARE( r1, r2 );
+    }
+}
+
+
+void ResourceTest::testResourceManager()
+{
+    {
+        Resource r1( "res1", QUrl("http://test/mytype" ) );
+        Resource r2( "res2", QUrl("http://test/mytype" ) );
+        Resource r3( "res3", QUrl("http://test/myothertype" ) );
+        Resource r4( "res4", QUrl("http://test/myothertype" ) );
+        Resource r5( "res5", QUrl("http://test/myothertype" ) );
+        Resource r6( "res6", QUrl("http://test/mythirdtype" ) );
+
+        QList<Resource> rl = ResourceManager::instance()->allResourcesOfType( QUrl("http://test/mytype") );
+        QCOMPARE( rl.count(), 2 );
+        QVERIFY( rl.contains( r1 ) && rl.contains( r2 ) );
+
+        rl = ResourceManager::instance()->allResourcesOfType( r6.resourceType() );
+        QCOMPARE( rl.count(), 1 );
+        QCOMPARE( rl.first(), r6 );
+
+        r1.setProperty( QUrl("http://test/prop1"), 42 );
+        r3.setProperty( QUrl("http://test/prop1"), 42 );
+        r4.setProperty( QUrl("http://test/prop1"), 41 );
+
+        r3.setProperty( QUrl("http://test/prop2"), r6 );
+        r4.setProperty( QUrl("http://test/prop2"), r6 );
+        r5.setProperty( QUrl("http://test/prop2"), r6 );
+        r6.setProperty( QUrl("http://test/prop2"), r1 );
+
+        rl = ResourceManager::instance()->allResourcesWithProperty( QUrl("http://test/prop1"), 42 );
+        QCOMPARE( rl.count(), 2 );
+        QVERIFY( rl.contains( r1 ) && rl.contains( r3 ) );
+
+        rl = ResourceManager::instance()->allResourcesWithProperty( QUrl("http://test/prop2"), r6 );
+        QCOMPARE( rl.count(), 3 );
+        QVERIFY( rl.contains( r3 ) && rl.contains( r4 ) && rl.contains( r5 ) );
+    }
+
+    {
+        Resource r1( "res1", QUrl("http://test/mytype" ) );
+        Resource r2( "res2", QUrl("http://test/mytype" ) );
+        Resource r3( "res3", QUrl("http://test/myothertype" ) );
+        Resource r4( "res4", QUrl("http://test/myothertype" ) );
+        Resource r5( "res5", QUrl("http://test/myothertype" ) );
+        Resource r6( "res6", QUrl("http://test/mythirdtype" ) );
+
+        QList<Resource> rl = ResourceManager::instance()->allResourcesOfType( QUrl("http://test/mytype" ));
+        QCOMPARE( rl.count(), 2 );
+        QVERIFY( rl.contains( r1 ) && rl.contains( r2 ) );
+
+        rl = ResourceManager::instance()->allResourcesOfType( r6.resourceType() );
+        QCOMPARE( rl.count(), 1 );
+        QCOMPARE( rl.first(), r6 );
+
+        rl = ResourceManager::instance()->allResourcesWithProperty( QUrl("http://test/prop1"), 42 );
+        QCOMPARE( rl.count(), 2 );
+        QVERIFY( rl.contains( r1 ) && rl.contains( r3 ) );
+
+        rl = ResourceManager::instance()->allResourcesWithProperty( QUrl("http://test/prop2"), r6 );
+        QCOMPARE( rl.count(), 3 );
+        QVERIFY( rl.contains( r3 ) && rl.contains( r4 ) && rl.contains( r5 ) );
+
+        QVERIFY( r1.hasProperty( QUrl("http://test/prop1" ) ) );
+        QVERIFY( r3.hasProperty( QUrl("http://test/prop1" ) ) );
+        QVERIFY( r4.hasProperty( QUrl("http://test/prop1" ) ) );
+
+        QVERIFY( r3.hasProperty( QUrl("http://test/prop2" ) ) );
+        QVERIFY( r4.hasProperty( QUrl("http://test/prop2" ) ) );
+        QVERIFY( r5.hasProperty( QUrl("http://test/prop2" ) ) );
+        QVERIFY( r6.hasProperty( QUrl("http://test/prop2" ) ) );
+
+        QCOMPARE( r3.property( QUrl("http://test/prop2" )).toResource(), r6 );
+        QCOMPARE( r4.property( QUrl("http://test/prop2" )).toResource(), r6 );
+        QCOMPARE( r5.property( QUrl("http://test/prop2" )).toResource(), r6 );
+        QCOMPARE( r6.property( QUrl("http://test/prop2" )).toResource(), r1 );
+    }
+}
+
+
+QTEST_KDEMAIN(ResourceTest, NoGUI)
+
+#include "resourcetest.moc"
diff -u -r -N nepomuk/core/test/.svn/text-base/resourcetest.h.svn-base nepomuk-svn/core/test/.svn/text-base/resourcetest.h.svn-base
--- nepomuk/core/test/.svn/text-base/resourcetest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/resourcetest.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,32 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _RESOURCE_TEST_H_
+#define _RESOURCE_TEST_H_
+
+#include "testbase.h"
+
+class ResourceTest : public TestBase
+{
+    Q_OBJECT
+
+ private Q_SLOTS:
+    void testResourceStates();
+    void testProperties();
+    void testResourceRemoval();
+    void testResourceIdentifiers();
+    void testResourceManager();
+};
+
+#endif
diff -u -r -N nepomuk/core/test/.svn/text-base/speedtest.cpp.svn-base nepomuk-svn/core/test/.svn/text-base/speedtest.cpp.svn-base
--- nepomuk/core/test/.svn/text-base/speedtest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/speedtest.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,147 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "speedtest.h"
+#include "../resourcemanager.h"
+#include "../resource.h"
+#include "../variant.h"
+
+#include <Soprano/Model>
+#include <Soprano/Statement>
+#include <Soprano/StatementIterator>
+#include <Soprano/Node>
+#include <Soprano/LiteralValue>
+#include <Soprano/QueryResultIterator>
+
+#include <QtDBus/QtDBus>
+
+#include <qtest_kde.h>
+
+using namespace Soprano;
+using namespace Nepomuk;
+
+
+void SpeedTest::testKMetaData()
+{
+    return;
+    const int TESTCNT = 10;
+
+    Soprano::Model* rr = ResourceManager::instance()->mainModel();
+
+    QTime t;
+    t.start();
+
+    QList<Resource> rl;
+    QString ns = "http://nepomuk-kde.semanticdesktop.org/testdata#";
+    for( int i = 0; i < TESTCNT; ++i ) {
+        Resource r( ns + QString("test") + QString::number(i) );
+        r.setProperty( ns + QString("wurstprop"), 10 );
+        rl.append( r );
+    }
+
+    qDebug( "Added %d resources in %d ms", TESTCNT, t.elapsed() );
+
+    // check that everything has been saved properly
+    foreach( const Resource &r, rl ) {
+        QVERIFY( rr->containsAnyStatement( Statement( r.resourceUri(), Node(), Node() ) ) );
+    }
+
+    t.start();
+
+    for( int i = 0; i < TESTCNT; ++i ) {
+        Resource( ns + QString("test") + QString::number(i) ).remove();
+    }
+
+    qDebug( "Removed %d resources in %d ms", TESTCNT, t.elapsed() );
+
+    // check that there actually is nothing left
+    foreach( const Resource &r, rl ) {
+        QVERIFY( !rr->containsAnyStatement( Statement( r.resourceUri(), Node(), Node() ) ) );
+    }
+}
+
+
+void SpeedTest::compareToPlain_data()
+{
+    QTest::addColumn<QUrl>( "uri" );
+    QTest::addColumn<QString>( "identifier" );
+
+    QTest::newRow( "simple" ) << QUrl( "http://test.kde.org/A" ) << "testA";
+    QTest::newRow( "file" ) << QUrl( "file:///tmp" ) << "/tmp";
+}
+
+void SpeedTest::compareToPlain()
+{
+    QFETCH( QUrl, uri );
+    QFETCH( QString,  identifier );
+
+    if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.nepomuk.services.nepomukstorage")) {
+        QSKIP("nepomuk not running", SkipAll);
+    }
+
+    // first we add some data
+    Soprano::Model* rr = ResourceManager::instance()->mainModel();
+
+    QVERIFY( rr->addStatement( Statement( uri, QUrl(Resource::identifierUri()), LiteralValue(identifier) ) ) == Soprano::Error::ErrorNone );
+    QVERIFY( rr->addStatement( Statement( uri, QUrl("http://test.kde.org/hasSomething"), LiteralValue(17) ) ) == Soprano::Error::ErrorNone );
+
+    QTime t;
+    t.start();
+
+    // now read the thing with Nepomuk
+    {
+        Resource res( identifier );
+        Variant val = res.property( "http://test.kde.org/hasSomething" );
+
+        qDebug( "Read property with nepomuk and identifier in %d ms", t.elapsed() );
+
+        QCOMPARE( val.toInt(), 17 );
+    }
+
+    t.start();
+
+    {
+        Resource res2( uri.toString() );
+        Variant val2 = res2.property( "http://test.kde.org/hasSomething" );
+
+        qDebug( "Read property with nepomuk and URI in %d ms", t.elapsed() );
+
+        QCOMPARE( val2.toInt(), 17 );
+    }
+
+    // now read it with plain Soprano
+    t.start();
+
+    StatementIterator it = rr->listStatements( Statement( uri, QUrl("http://test.kde.org/hasSomething"), Node() ) );
+    qDebug( "Read property with Soprano and URI in %d ms", t.elapsed() );
+
+    QVERIFY( it.next() );
+    QCOMPARE( it.current().object().literal().toInt(), 17 );
+
+
+    t.start();
+    QueryResultIterator qr = rr->executeQuery( QString( "select ?x where { ?r <%1> \"%2\"^^<http://www.w3.org/2001/XMLSchema#string> . "
+                                                        "?r <http://test.kde.org/hasSomething> ?x . }" )
+                                               .arg( Resource::identifierUri() )
+                                               .arg( identifier ),
+                                               Soprano::Query::QUERY_LANGUAGE_SPARQL );
+    qDebug( "Read property with Soprano and identifier in %d ms", t.elapsed() );
+    QVERIFY( qr.next() );
+    QCOMPARE( qr.binding( "x" ).literal().toInt(),  17 );
+}
+
+
+QTEST_KDEMAIN(SpeedTest, NoGUI)
+
+#include "speedtest.moc"
diff -u -r -N nepomuk/core/test/.svn/text-base/speedtest.h.svn-base nepomuk-svn/core/test/.svn/text-base/speedtest.h.svn-base
--- nepomuk/core/test/.svn/text-base/speedtest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/speedtest.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,30 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _NEPOMUK_SPEED_TEST_H_
+#define _NEPOMUK_SPEED_TEST_H_
+
+#include <QtCore/QObject>
+
+class SpeedTest : public QObject
+{
+    Q_OBJECT
+
+ private Q_SLOTS:
+    void testKMetaData();
+    void compareToPlain_data();
+    void compareToPlain();
+};
+
+#endif
diff -u -r -N nepomuk/core/test/.svn/text-base/tagcloudtest.cpp.svn-base nepomuk-svn/core/test/.svn/text-base/tagcloudtest.cpp.svn-base
--- nepomuk/core/test/.svn/text-base/tagcloudtest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/tagcloudtest.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,44 @@
+/* This file is part of the Nepomuk-KDE libraries
+    Copyright (c) 2007 Sebastian Trueg <trueg@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#include <resourcemanager.h>
+#include "../ui/kmetadatatagcloud.h"
+
+#include <krandom.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+
+int main( int argc, char** argv )
+{
+    KAboutData about("tagcloudtest", 0, ki18n("tagcloudtest"), "1.0");
+    KCmdLineArgs::init( argc, argv, &about );
+    KApplication app;
+    Nepomuk::ResourceManager::instance()->init();
+    Nepomuk::TagCloud tcw;
+    //  KTagCloudWidget tcw;
+//   for( int i = 1; i <= 12; ++i )
+//     tcw.addTag( QLocale::system().monthName(i), (int)(20.0*(double)KRandom::random()/(double)RAND_MAX) + 1 );
+//   for( int i = 1; i <= 7; ++i )
+//     tcw.addTag( QLocale::system().dayName(i), (int)(20.0*(double)KRandom::random()/(double)RAND_MAX) + 1 );
+
+    tcw.show();
+
+    return app.exec();
+}
diff -u -r -N nepomuk/core/test/.svn/text-base/testbase.cpp.svn-base nepomuk-svn/core/test/.svn/text-base/testbase.cpp.svn-base
--- nepomuk/core/test/.svn/text-base/testbase.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/testbase.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,39 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "testbase.h"
+
+#include "../resource.h"
+#include "../resourcemanager.h"
+
+#include <Soprano/Soprano>
+
+
+void TestBase::initTestCase()
+{
+    Soprano::Model* model = Soprano::createModel();
+    Nepomuk::ResourceManager::instance()->setOverrideMainModel( model );
+}
+
+void TestBase::init()
+{
+    Nepomuk::ResourceManager::instance()->mainModel()->removeAllStatements();
+}
+
+
+void TestBase::cleanup()
+{
+}
+
+#include "testbase.moc"
diff -u -r -N nepomuk/core/test/.svn/text-base/testbase.h.svn-base nepomuk-svn/core/test/.svn/text-base/testbase.h.svn-base
--- nepomuk/core/test/.svn/text-base/testbase.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/testbase.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,31 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _TEST_BASE_H_
+#define _TEST_BASE_H_
+
+#include <QtTest/QtTest>
+
+
+class TestBase : public QObject
+{
+    Q_OBJECT
+
+ private Q_SLOTS:
+    void initTestCase();
+    virtual void init();
+    virtual void cleanup();
+};
+
+#endif
diff -u -r -N nepomuk/core/test/.svn/text-base/varianttest.cpp.svn-base nepomuk-svn/core/test/.svn/text-base/varianttest.cpp.svn-base
--- nepomuk/core/test/.svn/text-base/varianttest.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/varianttest.cpp.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,73 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "varianttest.h"
+#include "../kmetadata/kmetadata.h"
+
+#include <qtest_kde.h>
+
+using namespace Nepomuk::KMetaData;
+
+Q_DECLARE_METATYPE(Nepomuk::KMetaData::Variant)
+
+void VariantTest::initTestCase()
+{
+    QVERIFY( ResourceManager::instance()->init() == 0 );
+}
+
+
+void VariantTest::testToString_data()
+{
+    // test comparison
+    QTest::addColumn<Variant>( "a" );
+    QTest::addColumn<Variant>( "b" );
+
+    QTest::newRow("string-string") << Variant( "test" ) << Variant( "test" );
+    QTest::newRow("string-int") << Variant( "42" ) << Variant( 42 );
+    QTest::newRow("string-false") << Variant( "false" ) << Variant( false );
+    QTest::newRow("string-true") << Variant( "true" ) << Variant( true );
+    QTest::newRow("string-double") << Variant( "42.2" ) << Variant( 42.2 );
+//  QTest::newRow("string-resource") << Variant( Resource("test") ) << Variant( "test" );
+
+    QList<int> intL;
+    QList<bool> boolL;
+    QList<double> doubleL;
+    QList<Resource> resL;
+
+    intL << 42 << 2 << -18 << 100000;
+    boolL << true << true << false << true;
+    doubleL << 42.5 << 2.5 << -18.5 << 1000.5;
+    resL << Resource( "/home/test/wurst" ) << Resource( "hello" ) << Resource( "/tmp" );
+    QStringList uriL;
+    uriL << "/home/test/wurst" << "hello" << "/tmp";
+
+    QTest::newRow("int-list") << Variant( intL ) << Variant( QString("42,2,-18,100000").split(",") );
+    QTest::newRow("bool-list") << Variant( boolL ) << Variant( QString("true,true,false,true").split(",") );
+    QTest::newRow("double-list") << Variant( doubleL ) << Variant( QString("42.5,2.5,-18.5,1000.5").split(",") );
+//  QTest::newRow("res-list") << Variant( resL ) << Variant( uriL );
+}
+
+
+void VariantTest::testToString()
+{
+    QFETCH(Variant, a);
+    QFETCH(Variant, b);
+    QCOMPARE( a.toString(), b.toString() );
+    QCOMPARE( a.toStringList(), b.toStringList() );
+}
+
+
+QTEST_KDEMAIN(VariantTest, NoGUI)
+
+#include "varianttest.moc"
diff -u -r -N nepomuk/core/test/.svn/text-base/varianttest.h.svn-base nepomuk-svn/core/test/.svn/text-base/varianttest.h.svn-base
--- nepomuk/core/test/.svn/text-base/varianttest.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/test/.svn/text-base/varianttest.h.svn-base	2009-02-27 13:37:47.000000000 +0100
@@ -0,0 +1,32 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 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 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _VARIANT_TEST_H_
+#define _VARIANT_TEST_H_
+
+#include <QtTest/QtTest>
+
+#include <kmetadata/variant.h>
+
+class VariantTest : public QObject
+{
+    Q_OBJECT
+
+ private Q_SLOTS:
+    void initTestCase();
+    void testToString_data();
+    void testToString();
+};
+
+#endif
diff -u -r -N nepomuk/core/thing.cpp nepomuk-svn/core/thing.cpp
--- nepomuk/core/thing.cpp	2008-11-19 15:44:39.000000000 +0100
+++ nepomuk-svn/core/thing.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -30,6 +30,14 @@
 }
 
 
+Nepomuk::Thing::Thing( const QUrl& uri, const QUrl& pimoType, ResourceManager* manager )
+    : Resource( uri, pimoType.isEmpty() ? Vocabulary::PIMO::Thing() : pimoType, manager )
+{
+    // FIXME: somehow ensure that pimoType is actually a pimo:Thing. Maybe
+    // use operator= instead of the contructor and check the value beforehand
+}
+
+
 Nepomuk::Thing::Thing( const QString& uriOrName, const QUrl& pimoType )
     : Resource( uriOrName, pimoType.isEmpty() ? Vocabulary::PIMO::Thing() : pimoType )
 {
@@ -37,6 +45,13 @@
 }
 
 
+Nepomuk::Thing::Thing( const QString& uriOrName, const QUrl& pimoType, ResourceManager* manager )
+    : Resource( uriOrName, pimoType.isEmpty() ? Vocabulary::PIMO::Thing() : pimoType, manager )
+{
+    // FIXME: s.o.
+}
+
+
 Nepomuk::Thing::Thing( const Thing& other )
     : Resource( other )
 {
diff -u -r -N nepomuk/core/thing.h nepomuk-svn/core/thing.h
--- nepomuk/core/thing.h	2008-11-19 15:44:39.000000000 +0100
+++ nepomuk-svn/core/thing.h	2009-02-27 13:37:52.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * This file is part of the Nepomuk KDE project.
- * Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
+ * Copyright (C) 2008-2009 Sebastian Trueg <trueg@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -70,6 +70,16 @@
         Thing( const QUrl& uri = QUrl(), const QUrl& pimoType = QUrl() );
 
         /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Thing( const QUrl& uri, const QUrl& pimoType, ResourceManager* manager );
+
+        /**
          * Create a new Thing with label or URI \p uriOrName
          *
          * \param uriOrName The URI or the label of the Thing. The constructor
@@ -84,6 +94,16 @@
         Thing( const QString& uriOrName, const QUrl& pimoType = QUrl() );
 
         /**
+         * \overload
+         *
+         * \param manager The resource manager to use. This allows to mix resources from different
+         * managers and, thus, different models.
+         *
+         * \since 4.3
+         */
+        Thing( const QString& uriOrName, const QUrl& pimoType, ResourceManager* manager );
+
+        /**
          * Copy constructor.
          */
         Thing( const Thing& other );
diff -u -r -N nepomuk/core/ui/.svn/all-wcprops nepomuk-svn/core/ui/.svn/all-wcprops
--- nepomuk/core/ui/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/all-wcprops	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,119 @@
+K 25
+svn:wc:ra_dav:version-url
+V 59
+/home/kde/!svn/ver/928345/trunk/KDE/kdelibs/nepomuk/core/ui
+END
+nepomukmassupdatejob.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 84
+/home/kde/!svn/ver/800771/trunk/KDE/kdelibs/nepomuk/core/ui/nepomukmassupdatejob.cpp
+END
+kautoscrollarea.h
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/home/kde/!svn/ver/747587/trunk/KDE/kdelibs/nepomuk/core/ui/kautoscrollarea.h
+END
+kmetadatatagwidget.h
+K 25
+svn:wc:ra_dav:version-url
+V 80
+/home/kde/!svn/ver/851378/trunk/KDE/kdelibs/nepomuk/core/ui/kmetadatatagwidget.h
+END
+kblocklayout.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/772931/trunk/KDE/kdelibs/nepomuk/core/ui/kblocklayout.cpp
+END
+kratingwidget.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/home/kde/!svn/ver/786656/trunk/KDE/kdelibs/nepomuk/core/ui/kratingwidget.cpp
+END
+nepomukmassupdatejob.h
+K 25
+svn:wc:ra_dav:version-url
+V 82
+/home/kde/!svn/ver/788523/trunk/KDE/kdelibs/nepomuk/core/ui/nepomukmassupdatejob.h
+END
+kblocklayout.h
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/home/kde/!svn/ver/747587/trunk/KDE/kdelibs/nepomuk/core/ui/kblocklayout.h
+END
+kratingwidget.h
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/781611/trunk/KDE/kdelibs/nepomuk/core/ui/kratingwidget.h
+END
+kmetadatatagcloud.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 81
+/home/kde/!svn/ver/792139/trunk/KDE/kdelibs/nepomuk/core/ui/kmetadatatagcloud.cpp
+END
+ktagdisplaywidget.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 81
+/home/kde/!svn/ver/772931/trunk/KDE/kdelibs/nepomuk/core/ui/ktagdisplaywidget.cpp
+END
+ktagcloudwidget.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 79
+/home/kde/!svn/ver/772931/trunk/KDE/kdelibs/nepomuk/core/ui/ktagcloudwidget.cpp
+END
+kratingpainter.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 78
+/home/kde/!svn/ver/786656/trunk/KDE/kdelibs/nepomuk/core/ui/kratingpainter.cpp
+END
+kmetadatatagcloud.h
+K 25
+svn:wc:ra_dav:version-url
+V 79
+/home/kde/!svn/ver/747587/trunk/KDE/kdelibs/nepomuk/core/ui/kmetadatatagcloud.h
+END
+ktagdisplaywidget.h
+K 25
+svn:wc:ra_dav:version-url
+V 79
+/home/kde/!svn/ver/747587/trunk/KDE/kdelibs/nepomuk/core/ui/ktagdisplaywidget.h
+END
+ktagcloudwidget.h
+K 25
+svn:wc:ra_dav:version-url
+V 77
+/home/kde/!svn/ver/747587/trunk/KDE/kdelibs/nepomuk/core/ui/ktagcloudwidget.h
+END
+kratingpainter.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/786656/trunk/KDE/kdelibs/nepomuk/core/ui/kratingpainter.h
+END
+kmetadatatagwidget.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 82
+/home/kde/!svn/ver/874533/trunk/KDE/kdelibs/nepomuk/core/ui/kmetadatatagwidget.cpp
+END
+kautoscrollarea.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 79
+/home/kde/!svn/ver/747587/trunk/KDE/kdelibs/nepomuk/core/ui/kautoscrollarea.cpp
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/home/kde/!svn/ver/928345/trunk/KDE/kdelibs/nepomuk/core/ui/CMakeLists.txt
+END
diff -u -r -N nepomuk/core/ui/.svn/entries nepomuk-svn/core/ui/.svn/entries
--- nepomuk/core/ui/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/entries	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,680 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/core/ui
+https://svn.kde.org/home/kde
+
+
+
+2009-02-19T12:46:13.650297Z
+928345
+mlaurent
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+test
+dir
+
+nepomukmassupdatejob.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+abb5a27c5a0cf69ba493e8e872660ad9
+2008-04-24T20:21:39.094130Z
+800771
+aacid
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4553
+
+kautoscrollarea.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+d65ee2bdd315e1afa9b7a6652f3d8818
+2007-12-12T13:28:24.330469Z
+747587
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2245
+
+kmetadatatagwidget.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+a8c2fa909911d07734d5c9d2cda44a9b
+2008-08-23T15:42:45.772078Z
+851378
+toma
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3089
+
+kblocklayout.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+1f05bd800998a9465d02a4188d97e58d
+2008-02-09T19:31:57.142669Z
+772931
+aacid
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4993
+
+kratingwidget.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+092514e36b3c42f3d5ebe7ab7108e740
+2008-03-17T15:44:25.198600Z
+786656
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5266
+
+nepomukmassupdatejob.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+816f24a52cb924f809c607b7dea0cb14
+2008-03-21T18:06:25.975997Z
+788523
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2921
+
+kblocklayout.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+7b7e72bf32db64f87827a4b1cfd9c186
+2007-12-12T13:28:24.330469Z
+747587
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2262
+
+kratingwidget.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+7b9ecefea3cac326069ae13e8256413e
+2008-03-03T10:54:51.104062Z
+781611
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5044
+
+pics
+dir
+
+kmetadatatagcloud.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+2d9576bff74fbcc02b9eb2e48f547a17
+2008-03-31T11:39:23.471440Z
+792139
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2846
+
+ktagdisplaywidget.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+8f9c7a4e28332ec5318c1c9c7b066ed1
+2008-02-09T19:31:57.142669Z
+772931
+aacid
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+3075
+
+ktagcloudwidget.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+80d0cdced4036399241336707080caff
+2008-02-09T19:31:57.142669Z
+772931
+aacid
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4548
+
+kratingpainter.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+0a21fa8e5268676874269cea7b3357f3
+2008-03-17T15:44:25.198600Z
+786656
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9628
+
+kmetadatatagcloud.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+653d8e7303a5c3aad87dc1d0a8fb65d9
+2007-12-12T13:28:24.330469Z
+747587
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2517
+
+ktagdisplaywidget.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+eec0e31e5bff928ed7970c1709d0f433
+2007-12-12T13:28:24.330469Z
+747587
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1870
+
+ktagcloudwidget.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+3fb86356f96b68878547b1e7cf01a2cb
+2007-12-12T13:28:24.330469Z
+747587
+trueg
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2193
+
+kratingpainter.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+23f7b048ab52b189ddf089870ccb011a
+2008-03-17T15:44:25.198600Z
+786656
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6011
+
+kmetadatatagwidget.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+c0ccf80c08266750b2d0f45bf2e11a0e
+2008-10-21T19:43:19.863776Z
+874533
+chehrlic
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6804
+
+kautoscrollarea.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+a03e61a9d56e773e49923b078c336403
+2007-12-12T13:28:24.330469Z
+747587
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9883
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+5474ebbff587130feed978e57ea35ede
+2009-02-19T12:46:13.650297Z
+928345
+mlaurent
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+493
+
diff -u -r -N nepomuk/core/ui/.svn/format nepomuk-svn/core/ui/.svn/format
--- nepomuk/core/ui/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/format	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/core/ui/.svn/prop-base/CMakeLists.txt.svn-base nepomuk-svn/core/ui/.svn/prop-base/CMakeLists.txt.svn-base
--- nepomuk/core/ui/.svn/prop-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/CMakeLists.txt.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mime-type
+V 10
+text/plain
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/kblocklayout.cpp.svn-base nepomuk-svn/core/ui/.svn/prop-base/kblocklayout.cpp.svn-base
--- nepomuk/core/ui/.svn/prop-base/kblocklayout.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/kblocklayout.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/kblocklayout.h.svn-base nepomuk-svn/core/ui/.svn/prop-base/kblocklayout.h.svn-base
--- nepomuk/core/ui/.svn/prop-base/kblocklayout.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/kblocklayout.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/kmetadatatagcloud.cpp.svn-base nepomuk-svn/core/ui/.svn/prop-base/kmetadatatagcloud.cpp.svn-base
--- nepomuk/core/ui/.svn/prop-base/kmetadatatagcloud.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/kmetadatatagcloud.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/kmetadatatagcloud.h.svn-base nepomuk-svn/core/ui/.svn/prop-base/kmetadatatagcloud.h.svn-base
--- nepomuk/core/ui/.svn/prop-base/kmetadatatagcloud.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/kmetadatatagcloud.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/kratingwidget.cpp.svn-base nepomuk-svn/core/ui/.svn/prop-base/kratingwidget.cpp.svn-base
--- nepomuk/core/ui/.svn/prop-base/kratingwidget.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/kratingwidget.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/kratingwidget.h.svn-base nepomuk-svn/core/ui/.svn/prop-base/kratingwidget.h.svn-base
--- nepomuk/core/ui/.svn/prop-base/kratingwidget.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/kratingwidget.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/ktagcloudwidget.cpp.svn-base nepomuk-svn/core/ui/.svn/prop-base/ktagcloudwidget.cpp.svn-base
--- nepomuk/core/ui/.svn/prop-base/ktagcloudwidget.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/ktagcloudwidget.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/prop-base/ktagcloudwidget.h.svn-base nepomuk-svn/core/ui/.svn/prop-base/ktagcloudwidget.h.svn-base
--- nepomuk/core/ui/.svn/prop-base/ktagcloudwidget.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/prop-base/ktagcloudwidget.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:eol-style
+V 6
+native
+END
diff -u -r -N nepomuk/core/ui/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/core/ui/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/core/ui/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,26 @@
+project(nepomukcoreui)
+
+include_directories(
+  ${nepomuk_BINARY_DIR}
+  ${nepomuk_SOURCE_DIR}
+  ${nepomukcore_SOURCE_DIR}
+  ${KDE4_INCLUDES} 
+  ${QT_INCLUDES}
+  ${SOPRANO_INCLUDE_DIR} )
+
+install(FILES
+  kratingwidget.h
+  ktagcloudwidget.h
+  kmetadatatagcloud.h
+  kmetadatatagwidget.h
+  ktagdisplaywidget.h
+  kratingpainter.h
+  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
+)
+
+install(FILES
+  pics/rating.png
+  DESTINATION ${DATA_INSTALL_DIR}/nepomuk/pics
+)
+
+add_subdirectory(test)
diff -u -r -N nepomuk/core/ui/.svn/text-base/kautoscrollarea.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/kautoscrollarea.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/kautoscrollarea.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kautoscrollarea.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,321 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kautoscrollarea.h"
+
+#include <kdebug.h>
+
+#include <QtCore/QTimer>
+#include <QtGui/QSizePolicy>
+#include <QtCore/QSize>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QScrollBar>
+#include <QtGui/QPainter>
+
+#include <math.h>
+
+
+class KAutoScrollArea::Private
+{
+public:
+    Private( KAutoScrollArea* _parent )
+        : widget( 0 ),
+          orientation( Qt::Horizontal ),
+          fadeSize( 20 ),
+          scrollSpeed( 0 ),
+          parent( _parent ) {
+    }
+
+    void setWidget( QWidget* w ) {
+        if ( w != widget ) {
+            delete widget;
+            widget = w;
+            widget->setParent( parent );
+            widget->installEventFilter( parent );
+
+            // now grab all the paint events from all the children
+            grabChildren( widget );
+        }
+    }
+
+    void grabChildren( QObject* o ) {
+        const QObjectList& children = o->children();
+        for( QObjectList::const_iterator it = children.constBegin(); it != children.constEnd(); ++it ) {
+            QObject* child = *it;
+            if ( child->isWidgetType() ) {
+                child->installEventFilter( parent );
+                qobject_cast<QWidget*>( child )->setMouseTracking( true );
+                grabChildren( child );
+            }
+        }
+    }
+
+    void setupWidget() {
+        // update the size policy to fit the child widget
+        // and the orientation
+        QSizePolicy sp( widget->sizePolicy() );
+        if ( orientation == Qt::Horizontal )
+            sp.setHorizontalPolicy( QSizePolicy::Expanding );
+        else
+            sp.setVerticalPolicy( QSizePolicy::Expanding );
+        parent->setSizePolicy( sp );
+
+        // resize the child according to our policy
+        // ie. fill at least the complete viewport
+        QSize s( widget->sizeHint() );
+        if ( orientation == Qt::Horizontal ) {
+            s.setHeight( parent->height() );
+            s.setWidth( qMax( s.width(), parent->width() ) );
+        }
+        else {
+            s.setWidth( parent->width() );
+            s.setHeight( qMax( s.height(), parent->height() ) );
+        }
+        widget->setGeometry( QRect( QPoint( 0, 0 ), s ) );
+
+        // mainly for QLabel which disables mouse tracking itself
+        widget->setMouseTracking( true );
+    }
+
+    void startAutoScroll() {
+        if ( scrollSpeed != 0 ) {
+            if ( !scrollTimer->isActive() )
+                scrollTimer->start();
+        }
+        else
+            stopAutoScroll();
+    }
+
+    void stopAutoScroll() {
+        scrollTimer->stop();
+    }
+
+    QWidget* widget;
+    Qt::Orientation orientation;
+    int fadeSize;
+    int scrollSpeed;
+    QTimer* scrollTimer;
+
+private:
+    KAutoScrollArea* parent;
+};
+
+
+KAutoScrollArea::KAutoScrollArea( QWidget* parent )
+    : QWidget( parent )
+{
+    d = new Private( this );
+    d->scrollTimer = new QTimer( this );
+    d->scrollTimer->setSingleShot( true );
+    connect( d->scrollTimer,  SIGNAL( timeout() ), this, SLOT( slotScroll() ) );
+    installEventFilter( this );
+    setMouseTracking( true );
+}
+
+
+KAutoScrollArea::~KAutoScrollArea()
+{
+    delete d;
+}
+
+
+QSize KAutoScrollArea::minimumSizeHint() const
+{
+    if ( d->widget ) {
+        if ( d->orientation == Qt::Horizontal )
+            return QSize( d->fadeSize > 0 ? d->fadeSize*2 : 20, d->widget->minimumSizeHint().height() );
+        else
+            return QSize( d->widget->minimumSizeHint().width(), d->fadeSize > 0 ? d->fadeSize*2 : 20 );
+    }
+    else
+        return QSize();
+}
+
+
+QSize KAutoScrollArea::sizeHint() const
+{
+    if ( d->widget )
+        return d->widget->sizeHint();
+    else
+        return QSize();
+}
+
+
+void KAutoScrollArea::setWidget( QWidget* w )
+{
+    d->setWidget( w );
+    d->setupWidget();
+}
+
+
+void KAutoScrollArea::setFadeWidth( int w )
+{
+    d->fadeSize = w;
+}
+
+
+void KAutoScrollArea::setOrientation( Qt::Orientation o )
+{
+    d->orientation = o;
+    d->setupWidget();
+}
+
+
+bool KAutoScrollArea::eventFilter( QObject* o, QEvent* e )
+{
+    if ( e->type() == QEvent::MouseMove ) {
+        QMouseEvent* me = static_cast<QMouseEvent*>( e );
+        QWidget* w = qobject_cast<QWidget*>( o );
+
+        QPoint pos = me->pos();
+        if ( o != this )
+            pos = w->mapTo( this, me->pos() );
+
+        if ( me->buttons() ) {
+            // TODO: scroll manually
+
+        }
+        else {
+            // we define the max speed to be 1 step every 2ms
+            // and the min to be 1 step every 100ms
+            if ( d->orientation == Qt::Horizontal ) {
+                if ( pos.x() < width()/2 )
+                    d->scrollSpeed = -2 - 100*pos.x()/( width()/2 );
+                else if ( pos.x() > width()/2 )
+                    d->scrollSpeed = 2 + ( 100 - 100*( pos.x()-width()/2 )/( width()/2 ) );
+            }
+            else {
+                if ( pos.y() < height()/2 )
+                    d->scrollSpeed = -2 - 100*pos.y()/( height()/2 );
+                else if ( pos.y() > height()/2 )
+                    d->scrollSpeed = 2 + ( 100 - 100*( pos.y()-height()/2 )/( height()/2 ) );
+            }
+
+            d->startAutoScroll();
+        }
+    }
+
+    else if ( e->type() == QEvent::MouseButtonPress ||
+              e->type() == QEvent::Leave ) {
+        d->stopAutoScroll();
+    }
+
+    else if ( e->type() == QEvent::MouseButtonRelease ) {
+        d->startAutoScroll();
+    }
+
+    else if ( e->type() == QEvent::LayoutRequest ) {
+        // the child widget changed and maybe also its children
+        d->grabChildren( d->widget );
+        d->setupWidget();
+    }
+
+    // Brute force: we just paint the fading effect over each and every child widget
+    // This is the only solution I found since child widgets are painted over their parents
+    else if ( e->type() == QEvent::Paint &&
+              o != this ) {
+        // paint the child widgets
+        o->event( e );
+
+        if ( d->fadeSize <= 0 )
+            return true;
+
+        // and now do some fancy fading out effect
+        QColor bg( d->widget->palette().color( QPalette::Background ) );
+        QColor ac( bg );
+        ac.setAlpha( 0 );
+
+        QWidget* w = qobject_cast<QWidget*>( o );
+
+        QPainter p( w );
+
+        if ( d->orientation == Qt::Horizontal ) {
+            if ( d->widget->geometry().right() > rect().right() ) {
+                QRect r( w->mapFrom( this, QPoint( width()-d->fadeSize, 0 ) ), QSize( d->fadeSize, height() ) );
+                QLinearGradient g( QPoint( r.left(), height()/2 ), QPoint( r.right(), height()/2 ) );
+                g.setColorAt( 0.0, ac );
+                g.setColorAt( 1.0, bg );
+                p.fillRect( r, g );
+            }
+            if ( d->widget->geometry().left() < rect().left() ) {
+                QRect r( w->mapFrom( this, QPoint( 0, 0 ) ), QSize( d->fadeSize, height() ) );
+                QLinearGradient g( QPoint( r.left(), height()/2 ), QPoint( r.right(), height()/2 ) );
+                g.setColorAt( 0.0, bg );
+                g.setColorAt( 1.0, ac );
+                p.fillRect( r, g );
+            }
+        }
+        else {
+            if ( d->widget->geometry().bottom() > rect().bottom() ) {
+                QRect r( w->mapFrom( this, QPoint( 0, height()-d->fadeSize ) ), QSize( width(), d->fadeSize ) );
+                QLinearGradient g( QPoint( this->width()/2, r.top() ), QPoint( this->width()/2, r.bottom() ) );
+                g.setColorAt( 0.0, ac );
+                g.setColorAt( 1.0, bg );
+                p.fillRect( r, g );
+            }
+            if ( d->widget->geometry().top() < rect().top() ) {
+                QRect r( w->mapFrom( this, QPoint( 0, 0 ) ), QSize( width(), d->fadeSize ) );
+                QLinearGradient g( QPoint( this->width()/2, r.top() ), QPoint( this->width()/2, r.bottom() ) );
+                g.setColorAt( 0.0, bg );
+                g.setColorAt( 1.0, ac );
+                p.fillRect( r, g );
+            }
+        }
+
+        return true;
+    }
+
+    return QWidget::eventFilter( o, e );
+}
+
+
+void KAutoScrollArea::resizeEvent( QResizeEvent* e )
+{
+    QWidget::resizeEvent( e );
+    if ( d->widget )
+        d->setupWidget();
+}
+
+
+void KAutoScrollArea::slotScroll()
+{
+    static const int step = 1;
+    if ( d->orientation == Qt::Horizontal ) {
+        if ( d->scrollSpeed > 0 &&
+             d->widget->geometry().right() > rect().right() )
+            d->widget->move( d->widget->geometry().left() - step, 0 );
+        else if ( d->scrollSpeed < 0 &&
+                  d->widget->geometry().left() < rect().left() )
+            d->widget->move( d->widget->geometry().left() + step, 0 );
+    }
+    else {
+        if ( d->scrollSpeed > 0 &&
+             d->widget->geometry().bottom() > rect().bottom() )
+            d->widget->move( 0, d->widget->geometry().top() - step );
+        else if ( d->scrollSpeed < 0 &&
+                  d->widget->geometry().top() < rect().top() )
+            d->widget->move( 0, d->widget->geometry().top() + step );
+    }
+
+    d->scrollTimer->setInterval( abs( d->scrollSpeed ) );
+    d->scrollTimer->start();
+}
+
+#include "kautoscrollarea.moc"
diff -u -r -N nepomuk/core/ui/.svn/text-base/kautoscrollarea.h.svn-base nepomuk-svn/core/ui/.svn/text-base/kautoscrollarea.h.svn-base
--- nepomuk/core/ui/.svn/text-base/kautoscrollarea.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kautoscrollarea.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _KAUTOSCROLL_AREA_H_
+#define _KAUTOSCROLL_AREA_H_
+
+#include <QtGui/QWidget>
+
+class QEvent;
+
+/**
+ * KAutoScrollArea provides a scroll area for an arbitrary widget.
+ * However, instead of scroll bars the widget is scrolled based on
+ * the mouse pointer position.
+ */
+class KAutoScrollArea : public QWidget
+{
+    Q_OBJECT
+
+ public:
+    KAutoScrollArea( QWidget* parent = 0 );
+    ~KAutoScrollArea();
+
+    QSize minimumSizeHint() const;
+    QSize sizeHint() const;
+
+    /**
+     * Set w to be the child widget which will be auto scrolled.
+     * KAutoScrollArea will take ownership of the widget.
+     */
+    void setWidget( QWidget* w );
+
+    /**
+     * Auto scrolling can take place in two directions but only
+     * one at a time. The other direction will not be scrollable
+     * at all and KAutoScrollArea will adjust the child's size
+     * to it's own.
+     */
+    void setOrientation( Qt::Orientation );
+
+ public Q_SLOTS:
+    /**
+     * Set the fade width to be used when the child widget is scrolled.
+     * It can also be set to 0 to disable fading alltogether.
+     * The default value is 20.
+     */
+    void setFadeWidth( int w );
+
+ protected:
+    bool eventFilter( QObject* obj, QEvent* event );
+    void resizeEvent( QResizeEvent* e );
+
+ private Q_SLOTS:
+    void slotScroll();
+
+ private:
+    class Private;
+    Private* d;
+};
+
+#endif
diff -u -r -N nepomuk/core/ui/.svn/text-base/kblocklayout.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/kblocklayout.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/kblocklayout.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kblocklayout.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,207 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+  KBlockLayout is based on the FlowLayout example from QT4.
+  Copyright (C) 2004-2006 Trolltech ASA. All rights reserved.
+*/
+
+#include "kblocklayout.h"
+
+#include <QtCore/QList>
+
+
+class KBlockLayout::Private
+{
+public:
+    Private()
+        : alignment(Qt::AlignLeft|Qt::AlignTop) {
+    }
+
+    QList<QLayoutItem*> itemList;
+
+    Qt::Alignment alignment;
+};
+
+
+KBlockLayout::KBlockLayout( QWidget* parent, int margin, int spacing )
+    : QLayout(parent),
+      d( new Private() )
+{
+    setMargin(margin);
+    setSpacing(spacing);
+}
+
+KBlockLayout::KBlockLayout( int spacing )
+    : d( new Private() )
+{
+    setSpacing(spacing);
+}
+
+KBlockLayout::~KBlockLayout()
+{
+    QLayoutItem* item;
+    while ((item = takeAt(0)))
+        delete item;
+    delete d;
+}
+
+void KBlockLayout::setAlignment( Qt::Alignment a )
+{
+    d->alignment = a;
+}
+
+Qt::Alignment KBlockLayout::alignment() const
+{
+    return d->alignment;
+}
+
+void KBlockLayout::addItem( QLayoutItem* item )
+{
+    d->itemList.append(item);
+}
+
+int KBlockLayout::count() const
+{
+    return d->itemList.size();
+}
+
+QLayoutItem *KBlockLayout::itemAt( int index ) const
+{
+    return d->itemList.value(index);
+}
+
+QLayoutItem *KBlockLayout::takeAt( int index )
+{
+    if (index >= 0 && index < d->itemList.size())
+        return d->itemList.takeAt(index);
+    else
+        return 0;
+}
+
+Qt::Orientations KBlockLayout::expandingDirections() const
+{
+    return 0;
+}
+
+bool KBlockLayout::hasHeightForWidth() const
+{
+    return true;
+}
+
+int KBlockLayout::heightForWidth( int width ) const
+{
+    int height = doLayout(QRect(0, 0, width, 0), true);
+    return height;
+}
+
+void KBlockLayout::setGeometry( const QRect& rect )
+{
+    QLayout::setGeometry(rect);
+    doLayout(rect, false);
+}
+
+QSize KBlockLayout::sizeHint() const
+{
+    return minimumSize();
+}
+
+QSize KBlockLayout::minimumSize() const
+{
+    QSize size;
+    QLayoutItem *item;
+    foreach (item, d->itemList)
+        size = size.expandedTo(item->minimumSize());
+
+    size += QSize(2*margin(), 2*margin());
+    return size;
+}
+
+struct Row {
+    Row( const QList<QLayoutItem*>& i, int h, int w )
+        : items(i), height(h), width(w) {
+    }
+
+    QList<QLayoutItem*> items;
+    int height;
+    int width;
+};
+
+int KBlockLayout::doLayout( const QRect& rect, bool testOnly ) const
+{
+    int x = rect.x();
+    int y = rect.y();
+    int lineHeight = 0;
+
+    // 1. calculate lines
+    QList<Row> rows;
+    QList<QLayoutItem*> rowItems;
+    foreach( QLayoutItem* item, d->itemList ) {
+        int nextX = x + item->sizeHint().width() + spacing();
+        if (nextX - spacing() > rect.right() && lineHeight > 0) {
+            rows.append( Row( rowItems, lineHeight, x - spacing() ) );
+            rowItems.clear();
+
+            x = rect.x();
+            y = y + lineHeight + spacing();
+            nextX = x + item->sizeHint().width() + spacing();
+            lineHeight = 0;
+        }
+
+        rowItems.append( item );
+
+        x = nextX;
+        lineHeight = qMax(lineHeight, item->sizeHint().height());
+    }
+    // append the last row
+    rows.append( Row( rowItems, lineHeight, x ) );
+
+    int finalHeight = y + lineHeight - rect.y();
+    if( testOnly )
+        return finalHeight;
+
+    // 2. place the items
+    y = rect.y();
+    foreach( const Row &row, rows ) {
+        x = rect.x();
+        if( alignment() & Qt::AlignRight )
+            x += (rect.width() - row.width);
+        else if( alignment() & Qt::AlignHCenter )
+            x += (rect.width() - row.width)/2;
+
+        foreach( QLayoutItem* item, row.items ) {
+            int yy = y;
+            if( alignment() & Qt::AlignBottom )
+                yy += (row.height - item->sizeHint().height());
+            else if( alignment() & Qt::AlignVCenter )
+                yy += (row.height - item->sizeHint().height())/2;
+            item->setGeometry(QRect(QPoint(x, yy), item->sizeHint()));
+
+            x += item->sizeHint().width() + spacing();
+
+            if( alignment() & Qt::AlignJustify )
+                x += (rect.width() - row.width)/qMax(row.items.count()-1,1);
+        }
+
+        y = y + row.height + spacing();
+    }
+
+    return finalHeight;
+}
diff -u -r -N nepomuk/core/ui/.svn/text-base/kblocklayout.h.svn-base nepomuk-svn/core/ui/.svn/text-base/kblocklayout.h.svn-base
--- nepomuk/core/ui/.svn/text-base/kblocklayout.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kblocklayout.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,71 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+  KBlockLayout is based on the FlowLayout example from QT4.
+  Copyright (C) 2004-2006 Trolltech ASA. All rights reserved.
+*/
+
+#ifndef KBLOCKLAYOUT_H
+#define KBLOCKLAYOUT_H
+
+#include <QtGui/QLayout>
+#include <QtGui/QLayoutItem>
+
+/**
+ * The KBlockLayout arranges widget in rows and columns like a text
+ * editor does.
+ */
+class KBlockLayout : public QLayout
+{
+ public:
+    explicit KBlockLayout( QWidget *parent, int margin = 0, int spacing = -1 );
+    KBlockLayout( int spacing = -1 );
+    ~KBlockLayout();
+
+    /**
+     * Set the alignment to use. It can be a combination of a horizontal and
+     * a vertical alignment flag. The vertical flag is used to arrange widgets
+     * that do not fill the complete height of a row.
+     *
+     * The default alignment is Qt::AlignLeft|Qt::AlignTop
+     */
+    void setAlignment( Qt::Alignment );
+    Qt::Alignment alignment() const;
+
+    void addItem( QLayoutItem* item );
+    Qt::Orientations expandingDirections() const;
+    bool hasHeightForWidth() const;
+    int heightForWidth(int) const;
+    int count() const;
+    QLayoutItem* itemAt( int index ) const;
+    QSize minimumSize() const;
+    void setGeometry( const QRect& rect );
+    QSize sizeHint() const;
+    QLayoutItem* takeAt( int index );
+
+ private:
+    int doLayout( const QRect& rect, bool testOnly ) const;
+
+    class Private;
+    Private* const d;
+};
+
+#endif
diff -u -r -N nepomuk/core/ui/.svn/text-base/kmetadatatagcloud.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/kmetadatatagcloud.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/kmetadatatagcloud.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kmetadatatagcloud.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,109 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kmetadatatagcloud.h"
+#include "resourcemanager.h"
+
+#include "../tag.h"
+
+#include <QtCore/QTimer>
+
+#include <Soprano/Model>
+
+
+class Nepomuk::TagCloud::Private
+{
+public:
+    Private()
+        : autoUpdate(false) {
+    }
+    QTimer* updateTimer;
+    bool autoUpdate;
+};
+
+
+Nepomuk::TagCloud::TagCloud( QWidget* parent )
+    : KTagCloudWidget( parent ),
+      d( new Private() )
+{
+    updateTags();
+    setAutoUpdate( true );
+}
+
+
+Nepomuk::TagCloud::~TagCloud()
+{
+    delete d;
+}
+
+
+bool Nepomuk::TagCloud::autoUpdate() const
+{
+    return d->autoUpdate;
+}
+
+
+void Nepomuk::TagCloud::updateTags()
+{
+    // clear the tag cloud
+    clear();
+
+    // retrieve the list of all tags
+    QList<Tag> tags = Tag::allTags();
+
+    // count the number of usages of the tags and add them to the cloud
+    for( QList<Tag>::iterator it = tags.begin();
+         it != tags.end(); ++it ) {
+        Tag& tag = *it;
+        if ( tag.label().isEmpty() ) {
+            tag.setLabel( tag.genericLabel() );
+        }
+        addTag( tag.label(), tag.tagOf().count() );
+    }
+}
+
+
+void Nepomuk::TagCloud::setAutoUpdate( bool enable )
+{
+    if ( enable != d->autoUpdate ) {
+        if( !enable ) {
+            disconnect( ResourceManager::instance()->mainModel(), SIGNAL(statementsAdded()),
+                        this, SLOT(updateTags()) );
+            disconnect( ResourceManager::instance()->mainModel(), SIGNAL(statementsRemoved()),
+                        this, SLOT(updateTags()) );
+        }
+        else {
+            connect( ResourceManager::instance()->mainModel(), SIGNAL(statementsAdded()),
+                     this, SLOT(updateTags()) );
+            connect( ResourceManager::instance()->mainModel(), SIGNAL(statementsRemoved()),
+                     this, SLOT(updateTags()) );
+        }
+
+        d->autoUpdate = enable;
+    }
+}
+
+
+void Nepomuk::TagCloud::slotTagClicked( const QString& tag )
+{
+    emit tagClicked( Tag(tag) );
+}
+
+#include "kmetadatatagcloud.moc"
diff -u -r -N nepomuk/core/ui/.svn/text-base/kmetadatatagcloud.h.svn-base nepomuk-svn/core/ui/.svn/text-base/kmetadatatagcloud.h.svn-base
--- nepomuk/core/ui/.svn/text-base/kmetadatatagcloud.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kmetadatatagcloud.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KMETADATATAGCLOUD_H
+#define KMETADATATAGCLOUD_H
+
+#include <nepomuk/nepomuk_export.h>
+
+#include "ktagcloudwidget.h"
+
+namespace Nepomuk {
+    class Tag;
+
+    /**
+     * Tag cloud widget that displays all tags stored in the
+     * local Nepomuk store.
+     */
+    class NEPOMUK_EXPORT TagCloud : public KTagCloudWidget
+    {
+        Q_OBJECT
+
+    public:
+        /**
+         * Create a new TagCloud widget.
+         * The widget will be populated immediately.
+         */
+        TagCloud( QWidget* parent = 0 );
+        ~TagCloud();
+
+        /**
+         * \return true if auto updating is enabled (the default).
+         *
+         * \sa setAutoUpdate
+         */
+        bool autoUpdate() const;
+
+    public Q_SLOTS:
+        /**
+         * Update the tag cloud, ie. reload all tags from the store
+         * and recalculate their importance.
+         *
+         * There is no need to call this unless auto updating is
+         * disabled.
+         *
+         * \sa setAutoUpdate
+         */
+        void updateTags();
+
+        /**
+         * If auto updating is enabled the tag cloud is updated
+         * regularly to keep in sync with the local Nepomuk store.
+         *
+         * \sa updateTags
+         */
+        void setAutoUpdate( bool enable );
+
+    Q_SIGNALS:
+        /**
+         * This signal is emitted whenever a tag is clicked.
+         *
+         * \sa KTagCloudWidget::tagClicked
+         */
+        void tagClicked( Tag );
+
+    private Q_SLOTS:
+        void slotTagClicked( const QString& tag );
+
+    private:
+        class Private;
+        Private* const d;
+    };
+}
+
+#endif // KMETADATATAGCLOUD_H
diff -u -r -N nepomuk/core/ui/.svn/text-base/kmetadatatagwidget.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/kmetadatatagwidget.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/kmetadatatagwidget.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kmetadatatagwidget.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,251 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kmetadatatagwidget.h"
+#include "kautoscrollarea.h"
+#include "ktagdisplaywidget.h"
+#include "nepomukmassupdatejob.h"
+
+#include "../tools.h"
+#include "../tag.h"
+
+#include <karrowbutton.h>
+#include <kinputdialog.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kdebug.h>
+
+#include <QtGui/QPushButton>
+#include <QtGui/QBoxLayout>
+#include <QtGui/QMenu>
+#include <QtGui/QAction>
+#include <QtCore/QSet>
+
+
+uint qHash( const Nepomuk::Tag& res )
+{
+    return qHash( res.resourceUri().toString() );
+}
+
+
+
+class Nepomuk::TagWidget::Private
+{
+public:
+    Private( TagWidget* _parent )
+        : parent( _parent ) {
+        QHBoxLayout* lay = new QHBoxLayout( parent );
+        lay->setMargin( 0 );
+        KAutoScrollArea* sa = new KAutoScrollArea( parent );
+        label = new KTagDisplayWidget;
+        sa->setWidget( label );
+        button = new KArrowButton( parent, Qt::DownArrow );
+
+        tagMenu = new QMenu( parent );
+        button->setMenu( tagMenu );
+
+        lay->addWidget( sa, 1 );
+        lay->addWidget( button );
+
+        connect( label, SIGNAL( tagClicked( const QString& ) ),
+                 parent, SLOT( slotTagClicked( const QString& ) ) );
+        connect( tagMenu, SIGNAL( aboutToShow() ), parent, SLOT( fillTagMenu() ) );
+    }
+
+    QStringList extractTagNames( QList<Tag> tags ) {
+        QStringList tagStrings;
+        // convert the tag list to keywords
+        for( QList<Tag>::const_iterator it = tags.constBegin();
+             it != tags.constEnd(); ++it ) {
+            tagStrings += ( *it ).genericLabel();
+        }
+        return tagStrings;
+    }
+
+    QList<Tag> intersectTags() {
+        if ( res.count() == 1 ) {
+            return res.first().tags();
+        }
+        else if ( !res.isEmpty() ) {
+            // determine the tags used for all resources
+            QSet<Tag> tags = QSet<Tag>::fromList( res.first().tags() );
+            QList<Resource>::const_iterator it = res.constBegin();
+            for ( ++it; it != res.constEnd(); ++it ) {
+                tags.intersect( QSet<Tag>::fromList( (*it).tags() ) );
+            }
+            return tags.values();
+        }
+        else {
+            return QList<Tag>();
+        }
+    }
+
+    QList<Resource> res;
+    KTagDisplayWidget* label;
+    KArrowButton* button;
+    TagWidget* parent;
+    QMenu* tagMenu;
+    QMap<QAction*, Tag> tagFromAction;
+};
+
+
+Nepomuk::TagWidget::TagWidget( const Resource& resource, QWidget* parent )
+    : QWidget( parent ),
+      d( new Private( this ) )
+{
+    setTaggedResource( resource );
+}
+
+
+Nepomuk::TagWidget::TagWidget( QWidget* parent )
+    : QWidget( parent ),
+      d( new Private( this ) )
+{
+}
+
+
+Nepomuk::TagWidget::~TagWidget()
+{
+    delete d;
+}
+
+
+QList<Nepomuk::Resource> Nepomuk::TagWidget::taggedResources() const
+{
+    return d->res;
+}
+
+
+QList<Nepomuk::Tag> Nepomuk::TagWidget::assignedTags() const
+{
+    return d->intersectTags();
+}
+
+
+void Nepomuk::TagWidget::setTaggedResource( const Resource& resource )
+{
+    QList<Resource> l;
+    l.append( resource );
+    setTaggedResources( l );
+}
+
+
+void Nepomuk::TagWidget::setTaggedResources( const QList<Resource>& resources )
+{
+    d->res = resources;
+    if ( !resources.isEmpty() ) {
+        d->label->setTags( d->extractTagNames( d->intersectTags() ) );
+    }
+    else {
+        d->label->setTags( QStringList() );
+    }
+}
+
+
+void Nepomuk::TagWidget::setAssignedTags( const QList<Tag>& tags )
+{
+    if ( !d->res.isEmpty() ) {
+        d->label->setTags( d->extractTagNames( tags ) );
+        Nepomuk::MassUpdateJob* job = Nepomuk::MassUpdateJob::tagResources( d->res, tags );
+        connect( job, SIGNAL( result( KJob* ) ),
+                 this, SLOT( slotTagUpdateDone() ) );
+        setEnabled( false ); // no updates during execution
+        job->start();
+    }
+}
+
+
+void Nepomuk::TagWidget::slotTagUpdateDone()
+{
+    setEnabled( true );
+}
+
+void Nepomuk::TagWidget::slotTagClicked( const QString& text) 
+{
+    Nepomuk::Tag tag( text );
+    emit tagClicked( tag );
+}
+
+static bool tagLabelLessThan( const Nepomuk::Tag& t1, const Nepomuk::Tag& t2 )
+{
+    return t1.label() < t2.label();
+}
+
+
+void Nepomuk::TagWidget::fillTagMenu()
+{
+    QList<Tag> allTags = Tag::allTags();
+    // Prepare allTags list
+    foreach( Tag tag, allTags ) {
+        if ( tag.label().isEmpty() ) {
+            tag.setLabel( tag.genericLabel() );
+        }
+    }
+    qSort( allTags.begin(), allTags.end(), tagLabelLessThan );
+
+    QList<Tag> assignedTags = d->intersectTags();
+
+    d->tagMenu->clear();
+    d->tagFromAction.clear();
+    foreach( const Tag &tag,  allTags ) {
+        QAction* a = d->tagMenu->addAction( tag.label(), this, SLOT( updateAssignedTagsFromMenu() ) );
+        d->tagFromAction.insert( a, tag );
+        a->setCheckable( true );
+        a->setChecked( assignedTags.contains( tag ) );
+    }
+
+    d->tagMenu->addAction( i18n( "Create New Tag..."), this, SLOT(createTag()) );
+}
+
+
+void Nepomuk::TagWidget::createTag()
+{
+    QString s = KInputDialog::getText( i18n("New Tag"), i18n("Please insert the name of the new tag:"), QString(), 0, this );
+    if( !s.isEmpty() ) {
+        // see if the tag exists
+        QList<Tag> l = Tag::allTags();
+        QListIterator<Tag> tagIt( l );
+        while( tagIt.hasNext() ) {
+            const Nepomuk::Tag& tag = tagIt.next();
+            if( tag.label() == s ||
+                tag.identifiers().contains( s ) ) {
+                KMessageBox::sorry( this, i18n("The tag %1 already exists", s), i18n("Tag Exists") );
+                return;
+            }
+        }
+
+        Nepomuk::Tag( s ).setLabel( s );
+    }
+}
+
+
+void Nepomuk::TagWidget::updateAssignedTagsFromMenu()
+{
+    QList<Tag> tags;
+    for ( QMap<QAction*, Tag>::const_iterator it = d->tagFromAction.constBegin();
+          it != d->tagFromAction.constEnd(); ++it )
+        if ( it.key()->isChecked() )
+            tags.append( it.value() );
+
+    setAssignedTags( tags );
+}
+
+
+#include "kmetadatatagwidget.moc"
diff -u -r -N nepomuk/core/ui/.svn/text-base/kmetadatatagwidget.h.svn-base nepomuk-svn/core/ui/.svn/text-base/kmetadatatagwidget.h.svn-base
--- nepomuk/core/ui/.svn/text-base/kmetadatatagwidget.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kmetadatatagwidget.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,102 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _KMETADATA_TAG_WIDGET_H_
+#define _KMETADATA_TAG_WIDGET_H_
+
+#include "nepomuk_export.h"
+
+#include <QtGui/QWidget>
+
+namespace Nepomuk {
+    class Resource;
+    class Tag;
+
+    /**
+     * TagWidget provides a simple GUI interface to assign tags.
+     * It consists of a single text line displaying the assigned 
+     * tags and a menu to change the tags.
+     */
+    class NEPOMUK_EXPORT TagWidget : public QWidget
+    {
+        Q_OBJECT
+		
+    public:
+        /**
+         * Creates a new TagWidget for resource. The assigned tags are loaded
+         * instantly.
+         */
+        explicit TagWidget( const Resource& resource, QWidget* parent = 0 );
+        TagWidget( QWidget* parent = 0 );
+        ~TagWidget();
+
+        /**
+         * \return The resources that are supposed to be tagged or an empty
+         * list if none have been set.
+         */
+        QList<Resource> taggedResources() const;
+
+        /**
+         * \return The list of all tags that are assigned to the currently set 
+         * resource or an empty list if no resource has been set.
+         *
+         * \sa setTaggedResource, taggedResource, Resource::getTags
+         */
+        QList<Tag> assignedTags() const;
+
+    Q_SIGNALS:
+        /**
+         * This signal is emitted whenever a tag is clicked.
+         */
+        void tagClicked( Tag );
+
+    public Q_SLOTS:
+        /**
+         * Set the Resource to be tagged. The assigned tags will be loaded
+         * instantly.
+         */
+        void setTaggedResource( const Resource& resource );
+
+        void setTaggedResources( const QList<Resource>& resources );
+
+        /**
+         * Set the list of tags to be assigned to the configured resource.
+         * If no resource has been set this method does nothing.
+         *
+         * \sa setTaggedResource
+         */
+        void setAssignedTags( const QList<Tag>& tags );
+
+    private Q_SLOTS:
+        void fillTagMenu();
+        void createTag();
+        void updateAssignedTagsFromMenu();
+        void slotTagUpdateDone();
+        void slotTagClicked( const QString& text );
+
+    private:
+        class Private;
+        Private* const d;
+    };
+}
+
+uint qHash( const Nepomuk::Tag& res );
+
+#endif
diff -u -r -N nepomuk/core/ui/.svn/text-base/kratingpainter.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/kratingpainter.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/kratingpainter.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kratingpainter.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,356 @@
+/*
+   This file is part of the Nepomuk KDE project.
+   Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+ */
+
+#include "kratingpainter.h"
+
+#include <QtGui/QPainter>
+#include <QtGui/QPixmap>
+#include <QtGui/QIcon>
+#include <QtCore/QRect>
+#include <QtCore/QPoint>
+
+#include <kicon.h>
+#include <kiconeffect.h>
+#include <kdebug.h>
+
+
+class KRatingPainter::Private
+{
+public:
+    Private()
+        : maxRating(10),
+          isEnabled( true ),
+          bHalfSteps(true),
+          alignment(Qt::AlignCenter),
+          direction(Qt::LeftToRight),
+          spacing(0) {
+    }
+
+    QPixmap getPixmap( int size );
+
+    int maxRating;
+    QIcon icon;
+    bool isEnabled;
+    bool bHalfSteps;
+    Qt::Alignment alignment;
+    Qt::LayoutDirection direction;
+    QPixmap customPixmap;
+    int spacing;
+};
+
+
+QPixmap KRatingPainter::Private::getPixmap( int size )
+{
+    if ( !customPixmap.isNull() ) {
+        return customPixmap.scaled( QSize( size, size ) );
+    }
+    else {
+        QIcon _icon( icon );
+        if ( _icon.isNull() ) {
+            _icon = KIcon( "rating" );
+        }
+        return _icon.pixmap( size );
+    }
+}
+
+
+KRatingPainter::KRatingPainter()
+    : d(new Private())
+{
+}
+
+
+KRatingPainter::~KRatingPainter()
+{
+    delete d;
+}
+
+
+int KRatingPainter::maxRating() const
+{
+    return d->maxRating;
+}
+
+
+bool KRatingPainter::halfStepsEnabled() const
+{
+    return d->bHalfSteps;
+}
+
+
+Qt::Alignment KRatingPainter::alignment() const
+{
+    return d->alignment;
+}
+
+
+Qt::LayoutDirection KRatingPainter::layoutDirection() const
+{
+    return d->direction;
+}
+
+
+QIcon KRatingPainter::icon() const
+{
+    return d->icon;
+}
+
+
+bool KRatingPainter::isEnabled() const
+{
+    return d->isEnabled;
+}
+
+
+QPixmap KRatingPainter::customPixmap() const
+{
+    return d->customPixmap;
+}
+
+
+int KRatingPainter::spacing() const
+{
+    return d->spacing;
+}
+
+
+void KRatingPainter::setMaxRating( int max )
+{
+    d->maxRating = max;
+}
+
+
+void KRatingPainter::setHalfStepsEnabled( bool enabled )
+{
+    d->bHalfSteps = enabled;
+}
+
+
+void KRatingPainter::setAlignment( Qt::Alignment align )
+{
+    d->alignment = align;
+}
+
+
+void KRatingPainter::setLayoutDirection( Qt::LayoutDirection direction )
+{
+    d->direction = direction;
+}
+
+
+void KRatingPainter::setIcon( const QIcon& icon )
+{
+    d->icon = icon;
+}
+
+
+void KRatingPainter::setEnabled( bool enabled )
+{
+    d->isEnabled = enabled;
+}
+
+
+void KRatingPainter::setCustomPixmap( const QPixmap& pixmap )
+{
+    d->customPixmap = pixmap;
+}
+
+
+void KRatingPainter::setSpacing( int s )
+{
+    d->spacing = qMax( 0, s );
+}
+
+
+void KRatingPainter::paint( QPainter* painter, const QRect& rect, int rating, int hoverRating ) const
+{
+    rating = qMin( rating, d->maxRating );
+    hoverRating = qMin( hoverRating, d->maxRating );
+
+    int numUsedStars = d->bHalfSteps ? d->maxRating/2 : d->maxRating;
+
+    if ( hoverRating > 0 && hoverRating < rating ) {
+        int tmp = hoverRating;
+        hoverRating = rating;
+        rating = tmp;
+    }
+
+    int usedSpacing = d->spacing;
+
+    // get the rating pixmaps
+    int maxHSizeOnePix = ( rect.width() - (numUsedStars-1)*usedSpacing ) / numUsedStars;
+    QPixmap ratingPix = d->getPixmap( qMin( rect.height(), maxHSizeOnePix ) );
+
+    QPixmap disabledRatingPix = KIconEffect().apply( ratingPix, KIconEffect::ToGray, 1.0, QColor(), false );
+    QPixmap hoverPix;
+
+    // if we are disabled we become gray and more transparent
+    if ( !d->isEnabled ) {
+        ratingPix = disabledRatingPix;
+        KIconEffect::semiTransparent( disabledRatingPix );
+    }
+
+    bool half = d->bHalfSteps && rating%2;
+    int numRatingStars = d->bHalfSteps ? rating/2 : rating;
+
+    int numHoverStars = 0;
+    bool halfHover = false;
+    if ( hoverRating > 0 && rating != hoverRating && d->isEnabled ) {
+        numHoverStars = d->bHalfSteps ? hoverRating/2 : hoverRating;
+        halfHover = d->bHalfSteps && hoverRating%2;
+        hoverPix = KIconEffect().apply( ratingPix, KIconEffect::ToGray, 0.5, QColor(), false );
+    }
+
+    if ( d->alignment & Qt::AlignJustify ) {
+        int w = rect.width();
+        w -= numUsedStars * ratingPix.width();
+        usedSpacing = w / ( numUsedStars-1 );
+    }
+
+    int ratingAreaWidth = ratingPix.width()*numUsedStars + usedSpacing*(numUsedStars-1);
+
+    int i = 0;
+    int x = rect.x();
+    if ( d->alignment & Qt::AlignRight ) {
+        x += ( rect.width() - ratingAreaWidth );
+    }
+    else if ( d->alignment & Qt::AlignHCenter ) {
+        x += ( rect.width() - ratingAreaWidth )/2;
+    }
+
+    int xInc = ratingPix.width() + usedSpacing;
+    if ( d->direction == Qt::RightToLeft ) {
+        x = rect.width() - ratingPix.width() - x;
+        xInc = -xInc;
+    }
+
+    int y = rect.y();
+    if( d->alignment & Qt::AlignVCenter ) {
+        y += ( rect.height() / 2 - ratingPix.height() / 2 );
+    }
+    else if ( d->alignment & Qt::AlignBottom ) {
+        y += ( rect.height() - ratingPix.height() );
+    }
+    for(; i < numRatingStars; ++i ) {
+        painter->drawPixmap( x, y, ratingPix );
+        x += xInc;
+    }
+    if( half ) {
+        painter->drawPixmap( x, y, ratingPix.width()/2, ratingPix.height(),
+                             d->direction == Qt::LeftToRight ? ratingPix : ( numHoverStars > 0 ? hoverPix : disabledRatingPix ),
+                             0, 0, ratingPix.width()/2, ratingPix.height() );
+        painter->drawPixmap( x + ratingPix.width()/2, y, ratingPix.width()/2, ratingPix.height(),
+                             d->direction == Qt::LeftToRight ? ( numHoverStars > 0 ? hoverPix : disabledRatingPix ) : ratingPix,
+                             ratingPix.width()/2, 0, ratingPix.width()/2, ratingPix.height() );
+        x += xInc;
+        ++i;
+    }
+    for(; i < numHoverStars; ++i ) {
+        painter->drawPixmap( x, y, hoverPix );
+        x += xInc;
+    }
+    if( halfHover ) {
+        painter->drawPixmap( x, y, ratingPix.width()/2, ratingPix.height(),
+                             d->direction == Qt::LeftToRight ? hoverPix : disabledRatingPix,
+                             0, 0, ratingPix.width()/2, ratingPix.height() );
+        painter->drawPixmap( x + ratingPix.width()/2, y, ratingPix.width()/2, ratingPix.height(),
+                             d->direction == Qt::LeftToRight ? disabledRatingPix : hoverPix,
+                             ratingPix.width()/2, 0, ratingPix.width()/2, ratingPix.height() );
+        x += xInc;
+        ++i;
+    }
+    for(; i < numUsedStars; ++i ) {
+        painter->drawPixmap( x, y, disabledRatingPix );
+        x += xInc;
+    }
+}
+
+
+int KRatingPainter::ratingFromPosition( const QRect& rect, const QPoint& pos ) const
+{
+    int usedSpacing = d->spacing;
+    int numUsedStars = d->bHalfSteps ? d->maxRating/2 : d->maxRating;
+    int maxHSizeOnePix = ( rect.width() - (numUsedStars-1)*usedSpacing ) / numUsedStars;
+    QPixmap ratingPix = d->getPixmap( qMin( rect.height(), maxHSizeOnePix ) );
+
+    int ratingAreaWidth = ratingPix.width()*numUsedStars + usedSpacing*(numUsedStars-1);
+
+    QRect usedRect( rect );
+    if ( d->alignment & Qt::AlignRight ) {
+        usedRect.setLeft( rect.right() - ratingAreaWidth );
+    }
+    else if ( d->alignment & Qt::AlignHCenter ) {
+        int x = ( rect.width() - ratingAreaWidth )/2;
+        usedRect.setLeft( rect.left() + x );
+        usedRect.setRight( rect.right() - x );
+    }
+    else { // d->alignment & Qt::AlignLeft
+        usedRect.setRight( rect.left() + ratingAreaWidth - 1 );
+    }
+
+    if ( d->alignment & Qt::AlignBottom ) {
+        usedRect.setTop( rect.bottom() - ratingPix.height() + 1 );
+    }
+    else if ( d->alignment & Qt::AlignVCenter ) {
+        int x = ( rect.height() - ratingPix.height() )/2;
+        usedRect.setTop( rect.top() + x );
+        usedRect.setBottom( rect.bottom() - x );
+    }
+    else { // d->alignment & Qt::AlignTop
+        usedRect.setBottom( rect.top() + ratingPix.height() - 1 );
+    }
+
+    if ( usedRect.contains( pos ) ) {
+        int x = 0;
+        if ( d->direction == Qt::RightToLeft ) {
+            x = usedRect.right() - pos.x();
+        }
+        else {
+            x = pos.x() - usedRect.left();
+        }
+
+        double one = ( double )usedRect.width() / ( double )d->maxRating;
+
+//        kDebug() << "rating:" << ( int )( ( double )x/one + 0.5 );
+
+        return ( int )( ( double )x/one + 0.5 );
+    }
+    else {
+        return -1;
+    }
+}
+
+
+void KRatingPainter::paintRating( QPainter* painter, const QRect& rect, Qt::Alignment align, int rating, int hoverRating )
+{
+    KRatingPainter rp;
+    rp.setAlignment( align );
+    rp.setLayoutDirection( painter->layoutDirection() );
+    rp.paint( painter, rect, rating, hoverRating );
+}
+
+
+int KRatingPainter::getRatingFromPosition( const QRect& rect, Qt::Alignment align, Qt::LayoutDirection direction, const QPoint& pos )
+{
+    KRatingPainter rp;
+    rp.setAlignment( align );
+    rp.setLayoutDirection( direction );
+    return rp.ratingFromPosition( rect, pos );
+}
diff -u -r -N nepomuk/core/ui/.svn/text-base/kratingpainter.h.svn-base nepomuk-svn/core/ui/.svn/text-base/kratingpainter.h.svn-base
--- nepomuk/core/ui/.svn/text-base/kratingpainter.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kratingpainter.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,217 @@
+/*
+   This file is part of the Nepomuk KDE project.
+   Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _NEPOMUK_RATING_PAINTER_H_
+#define _NEPOMUK_RATING_PAINTER_H_
+
+#include "nepomuk_export.h"
+
+#include <QtCore/Qt>
+
+class QIcon;
+class QPixmap;
+class QPainter;
+class QPoint;
+class QRect;
+
+
+/**
+ * \brief Utility class that draws a row of stars for a rating value.
+ *
+ * The KRatingPainter also allows to determine a rating value from
+ * a position in the draw area. it supports all different alignments
+ * and custom icons.
+ *
+ * For showing a rating in a widget see KRatingWidget.
+ *
+ * \author Sebastian Trueg <trueg@kde.org>
+ *
+ * \since 4.1
+ */
+class NEPOMUK_EXPORT KRatingPainter
+{
+public:
+    /**
+     * Create a new KRatingPainter.
+     * For most cases the static methods paintRating and getRatingFromPosition
+     * should be sufficient.
+     */
+    KRatingPainter();
+        
+    /**
+     * Destructor
+     */
+    ~KRatingPainter();
+
+    /**
+     * The maximum rating, i.e. how many stars are drawn
+     * in total.
+     *
+     * \sa setMaxRating
+     */
+    int maxRating() const;
+
+    /**
+     * If half steps are enabled one star equals to 2 rating
+     * points and uneven rating values result in half-stars being
+     * drawn.
+     *
+     * \sa setHalfStepsEnabled
+     */
+    bool halfStepsEnabled() const;
+
+    /**
+     * The alignment of the stars.
+     *
+     * \sa setAlignment
+     */
+    Qt::Alignment alignment() const;
+
+    /**
+     * The layout direction. If RTL the stars
+     * representing the rating value will be drawn from the 
+     * right.
+     *
+     * \sa setLayoutDirection
+     */
+    Qt::LayoutDirection layoutDirection() const;
+
+    /**
+     * The icon used to draw a star. In case a custom pixmap has been set
+     * this value is ignored.
+     *
+     * \sa setIcon, setCustomPixmap
+     */
+    QIcon icon() const;
+
+    /**
+     * The rating can be painted in a disabled state where no color
+     * is used and hover ratings are ignored.
+     *
+     * \sa setEnabled
+     */
+    bool isEnabled() const;
+
+    /**
+     * The custom pixmap set to draw a star. If no custom
+     * pixmap has been set, an invalid pixmap is returned.
+     *
+     * \sa setCustomPixmap
+     */
+    QPixmap customPixmap() const;
+
+    /**
+     * The spacing between rating pixmaps.
+     *
+     * \sa setSpacing
+     */
+    int spacing() const;
+
+    /**
+     * The maximum rating. Defaults to 10.
+     */
+    void setMaxRating( int max );
+
+    /**
+     * If half steps are enabled (the default) then
+     * one rating step corresponds to half a star.
+     */
+    void setHalfStepsEnabled( bool enabled );
+        
+    /**
+     * The alignment of the stars in the drawing rect.
+     * All alignment flags are supported.
+     */
+    void setAlignment( Qt::Alignment align );
+
+    /**
+     * LTR or RTL
+     */
+    void setLayoutDirection( Qt::LayoutDirection direction );
+
+    /**
+     * Set a custom icon. Defaults to "rating".
+     */
+    void setIcon( const QIcon& icon );
+
+    /**
+     * Enable or disable the rating. Default is enabled.
+     */
+    void setEnabled( bool enabled );
+
+    /**
+     * Set a custom pixmap.
+     */
+    void setCustomPixmap( const QPixmap& pixmap );
+
+    /**
+     * Set the spacing between rating pixmaps. Be aware that
+     * for justified horizontal alignment this values may be
+     * ignored.
+     */
+    void setSpacing( int spacing );
+
+    /**
+     * Draw the rating.
+     *
+     * \param painter The painter to draw the rating to.
+     * \param rect The geometry of the rating. The alignment of the rating is used relative
+     *             to this value.
+     * \param rating The actual rating value to draw.
+     * \param hoverRating The hover rating indicates the position the user hovers the mouse
+     *                    pointer at. This will provide visual feedback about the new rating
+     *                    if the user would actually click as well as the difference to the
+     *                    current rating.
+     */
+    void paint( QPainter* painter, const QRect& rect, int rating, int hoverRating = -1 ) const;
+
+    /**
+     * Calculate the rating value from mouse position pos.
+     *
+     * \return The rating corresponding to pos or -1 if pos is
+     * outside of the configured rect.
+     */
+    int ratingFromPosition( const QRect& rect, const QPoint& pos ) const;
+
+    /**
+     * Convenience method that paints a rating into the given rect.
+     *
+     * LayoutDirection is read from QPainter.
+     *
+     * \param align can be aligned vertically and horizontally. Using Qt::AlignJustify will insert spacing
+     * between the stars.
+     */
+    static void paintRating( QPainter* p, const QRect& rect, Qt::Alignment align, int rating, int hoverRating = -1 );
+
+    /**
+     * Get the rating that would be selected if the user clicked position pos
+     * within rect if the rating has been drawn with paintRating() using the same
+     * rect and align values.
+     *
+     * \return The new rating or -1 if pos is outside of the rating area.
+     */
+    static int getRatingFromPosition( const QRect& rect, Qt::Alignment align, Qt::LayoutDirection direction, const QPoint& pos );
+
+private:
+    class Private;
+    Private* const d;
+};
+
+#endif
diff -u -r -N nepomuk/core/ui/.svn/text-base/kratingwidget.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/kratingwidget.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/kratingwidget.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kratingwidget.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,258 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kratingwidget.h"
+#include "kratingpainter.h"
+
+#include <QtGui/QPainter>
+#include <QtGui/QPixmap>
+#include <QtGui/QKeyEvent>
+#include <QtGui/QImage>
+#include <QtGui/QIcon>
+
+#include <kiconeffect.h>
+#include <kiconloader.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+
+class KRatingWidget::Private
+{
+public:
+    Private()
+        : rating(0),
+          hoverRating(-1),
+          pixSize( 16 ) {
+    }
+
+    int rating;
+    int hoverRating;
+    int pixSize;
+
+    KRatingPainter ratingPainter;
+};
+
+
+
+KRatingWidget::KRatingWidget( QWidget* parent )
+    : QFrame( parent ),
+      d( new Private() )
+{
+    setMouseTracking( true );
+}
+
+
+KRatingWidget::~KRatingWidget()
+{
+    delete d;
+}
+
+
+void KRatingWidget::setPixmap( const QPixmap& pix )
+{
+    setCustomPixmap( pix );
+}
+
+
+void KRatingWidget::setCustomPixmap( const QPixmap& pix )
+{
+    d->ratingPainter.setCustomPixmap( pix );
+    update();
+}
+
+
+void KRatingWidget::setIcon( const QIcon& icon )
+{
+    d->ratingPainter.setIcon( icon );
+    update();
+}
+
+
+void KRatingWidget::setPixmapSize( int size )
+{
+    d->pixSize = size;
+    updateGeometry();
+}
+
+
+int KRatingWidget::spacing() const
+{
+    return d->ratingPainter.spacing();
+}
+
+
+QIcon KRatingWidget::icon() const
+{
+    return d->ratingPainter.icon();
+}
+
+
+void KRatingWidget::setSpacing( int s )
+{
+    d->ratingPainter.setSpacing( s );
+    update();
+}
+
+
+Qt::Alignment KRatingWidget::alignment() const
+{
+    return d->ratingPainter.alignment();
+}
+
+
+void KRatingWidget::setAlignment( Qt::Alignment align )
+{
+    d->ratingPainter.setAlignment( align );
+    update();
+}
+
+
+Qt::LayoutDirection KRatingWidget::layoutDirection() const
+{
+    return d->ratingPainter.layoutDirection();
+}
+
+
+void KRatingWidget::setLayoutDirection( Qt::LayoutDirection direction )
+{
+    d->ratingPainter.setLayoutDirection( direction );
+    update();
+}
+
+
+unsigned int KRatingWidget::rating() const
+{
+    return d->rating;
+}
+
+
+int KRatingWidget::maxRating() const
+{
+    return d->ratingPainter.maxRating();
+}
+
+
+bool KRatingWidget::halfStepsEnabled() const
+{
+    return d->ratingPainter.halfStepsEnabled();
+}
+
+
+void KRatingWidget::setRating( unsigned int rating )
+{
+    setRating( (int)rating );
+}
+
+
+void KRatingWidget::setRating( int rating )
+{
+    d->rating = rating;
+    d->hoverRating = rating;
+    update();
+}
+
+
+void KRatingWidget::setMaxRating( unsigned int max )
+{
+    setMaxRating( (int)max );
+}
+
+
+void KRatingWidget::setMaxRating( int max )
+{
+    d->ratingPainter.setMaxRating( max );
+    update();
+}
+
+
+void KRatingWidget::setHalfStepsEnabled( bool enabled )
+{
+    d->ratingPainter.setHalfStepsEnabled( enabled );
+    update();
+}
+
+
+void KRatingWidget::setOnlyPaintFullSteps( bool fs )
+{
+    setHalfStepsEnabled( !fs );
+}
+
+
+void KRatingWidget::mousePressEvent( QMouseEvent* e )
+{
+    if ( e->button() == Qt::LeftButton ) {
+        d->hoverRating = d->rating = d->ratingPainter.ratingFromPosition( contentsRect(), e->pos() );
+        update();
+        emit ratingChanged( d->rating );
+        emit ratingChanged( (unsigned int)d->rating );
+    }
+}
+
+
+void KRatingWidget::mouseMoveEvent( QMouseEvent* e )
+{
+    // when moving the mouse we show the user what the result of clicking will be
+    d->hoverRating = d->ratingPainter.ratingFromPosition( contentsRect(), e->pos() );
+    if ( d->hoverRating >= 0 && e->buttons() & Qt::LeftButton ) {
+        d->rating = d->hoverRating;
+        emit ratingChanged( d->rating );
+        emit ratingChanged( (unsigned int)d->rating );
+    }
+    update();
+}
+
+
+void KRatingWidget::leaveEvent( QEvent* )
+{
+    d->hoverRating = -1;
+    update();
+}
+
+
+void KRatingWidget::paintEvent( QPaintEvent* e )
+{
+    QFrame::paintEvent( e );
+    QPainter p( this );
+    d->ratingPainter.setEnabled( isEnabled() );
+    d->ratingPainter.paint( &p, contentsRect(), d->rating, d->hoverRating );
+}
+
+
+QSize KRatingWidget::sizeHint() const
+{
+    int numPix = d->ratingPainter.maxRating();
+    if( d->ratingPainter.halfStepsEnabled() )
+        numPix /= 2;
+
+    QSize pixSize( d->pixSize, d->pixSize );
+    if ( !d->ratingPainter.customPixmap().isNull() ) {
+        pixSize = d->ratingPainter.customPixmap().size();
+    }
+
+    return QSize( pixSize.width()*numPix + spacing()*(numPix-1) + frameWidth()*2,
+                  pixSize.height() + frameWidth()*2 );
+}
+
+
+void KRatingWidget::resizeEvent( QResizeEvent* e )
+{
+    QFrame::resizeEvent( e );
+}
+
+#include "kratingwidget.moc"
diff -u -r -N nepomuk/core/ui/.svn/text-base/kratingwidget.h.svn-base nepomuk-svn/core/ui/.svn/text-base/kratingwidget.h.svn-base
--- nepomuk/core/ui/.svn/text-base/kratingwidget.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/kratingwidget.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,201 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KRATINGWIDGET_H
+#define KRATINGWIDGET_H
+
+#include <QtGui/QFrame>
+
+#include "nepomuk_export.h"
+
+/**
+ * \brief Displays a rating value as a row of pixmaps.
+ *
+ * The KRatingWidget displays a range of stars or other arbitrary
+ * pixmaps and allows the user to select a certain number by mouse.
+ *
+ * \sa KRatingPainter
+ *
+ * \author Sebastian Trueg <trueg@kde.org>
+ */
+class NEPOMUK_EXPORT KRatingWidget : public QFrame
+{
+    Q_OBJECT
+
+ public:
+    /**
+     * Creates a new rating widget.
+     */
+    KRatingWidget( QWidget* parent = 0 );
+
+    /**
+     * Destructor
+     */
+    ~KRatingWidget();
+
+    /**
+     * \return The current rating.
+     */
+    unsigned int rating() const;
+
+    /**
+     * \return the maximum possible rating.
+     */
+    int maxRating() const;
+
+    /**
+     * The alignment of the stars.
+     *
+     * \sa setAlignment
+     */
+    Qt::Alignment alignment() const;
+
+    /**
+     * The layout direction. If RTL the stars
+     * representing the rating value will be drawn from the 
+     * right.
+     *
+     * \sa setLayoutDirection
+     */
+    Qt::LayoutDirection layoutDirection() const;
+
+    /**
+     * The spacing between the rating stars.
+     *
+     * \sa setSpacing
+     */
+    int spacing() const;
+
+    QSize sizeHint() const;
+
+    /**
+     * If half steps are enabled one star equals to 2 rating
+     * points and uneven rating values result in half-stars being
+     * drawn.
+     *
+     * \sa setHalfStepsEnabled
+     */
+    bool halfStepsEnabled() const;
+
+    /**
+     * The icon used to draw a star. In case a custom pixmap has been set
+     * this value is ignored.
+     *
+     * \sa setIcon, setCustomPixmap
+     */
+    QIcon icon() const;
+
+ Q_SIGNALS:
+    /**
+     * Emitted if the rating is changed by user interaction (ie. mouse click).
+     * A call to setRating does not trigger this signal.
+     */
+    void ratingChanged( unsigned int rating );
+    void ratingChanged( int rating );
+
+ public Q_SLOTS:
+    /**
+     * Set the current rating. Calling this method will NOT trigger the
+     * ratingChanged signal.
+     */
+    void setRating( int rating );
+
+    /**
+     * \deprecated use setRating( int max )
+     */
+    KDE_DEPRECATED void setRating( unsigned int rating );
+
+    /**
+     * Set the maximum allowed rating value. The default is 10 which means
+     * that a rating from 1 to 10 is selectable. If \a max is uneven steps
+     * are automatically only allowed full.
+     */
+    void setMaxRating( int max );
+
+    /**
+     * \deprecated use setMaxRating( int max )
+     */
+    KDE_DEPRECATED void setMaxRating( unsigned int max );
+
+    /**
+     * If half steps are enabled (the default) then
+     * one rating step corresponds to half a star.
+     */
+    void setHalfStepsEnabled( bool enabled );
+
+    /**
+     * \deprecated Use setHalfStepsEnabled
+     */
+    KDE_DEPRECATED void setOnlyPaintFullSteps( bool );
+
+    /**
+     * Set the spacing between the pixmaps. The default is 0.
+     */
+    void setSpacing( int );
+
+    /**
+     * The alignment of the stars in the drawing rect.
+     * All alignment flags are supported.
+     */
+    void setAlignment( Qt::Alignment align );
+
+    /**
+     * LTR or RTL
+     */
+    void setLayoutDirection( Qt::LayoutDirection direction );
+
+    /**
+     * Set a custom icon. Defaults to "rating".
+     */
+    void setIcon( const QIcon& icon );
+
+    /**
+     * Set a custom pixmap.
+     */
+    void setCustomPixmap( const QPixmap& pixmap );
+
+    /**
+     * Set the pixap to be used to display a rating step.
+     * By default the "rating" pixmap is loaded.
+     *
+     * \deprecated use setCustomPixmap
+     */
+    KDE_DEPRECATED void setPixmap( const QPixmap& );
+
+    /**
+     * Set the recommended size of the pixmaps. This is
+     * only used for the sizeHint. The actual size is always
+     * dependant on the size of the widget itself.
+     */
+    void setPixmapSize( int size );
+
+ protected:
+    void mousePressEvent( QMouseEvent* e );
+    void mouseMoveEvent( QMouseEvent* e );
+    void leaveEvent( QEvent* e );
+    void paintEvent( QPaintEvent* e );
+    void resizeEvent( QResizeEvent* e );
+
+ private:
+    class Private;
+    Private* const d;
+};
+
+#endif
diff -u -r -N nepomuk/core/ui/.svn/text-base/ktagcloudwidget.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/ktagcloudwidget.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/ktagcloudwidget.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/ktagcloudwidget.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,179 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ktagcloudwidget.h"
+#include "kblocklayout.h"
+
+#include <kurllabel.h>
+
+#include <QtGui/QBoxLayout>
+
+
+class KTagCloudWidget::Private
+{
+public:
+    Private()
+        : minFontSize(8),
+          maxFontSize(22) {
+    }
+
+    QMap<QString,int> tagMap;
+    QMap<QString,KUrlLabel*> labelMap;
+    QMap<QString,double> weightMap;
+
+    KBlockLayout* mainLay;
+
+    int minFontSize;
+    int maxFontSize;
+
+    void buildWeightMap() {
+        weightMap.clear();
+
+        int max = 0;
+        int min = 0;
+
+        // determine max
+        for( QMap<QString,int>::const_iterator it = tagMap.constBegin();
+             it != tagMap.constEnd(); ++it ) {
+            max = qMax( max, it.value() );
+            min = qMin( min, it.value() );
+        }
+
+        // normalize weights
+        for( QMap<QString,int>::const_iterator it = tagMap.constBegin();
+             it != tagMap.constEnd(); ++it ) {
+            weightMap[it.key()] = (double)(it.value() - min) / (double)qMax(max - min, 1);
+        }
+    }
+
+    KUrlLabel* createLabel( QWidget* parent, const QString& tag ) {
+        KUrlLabel* label = new KUrlLabel( tag, tag, parent );
+        QFont font( label->font() );
+        font.setPointSize( minFontSize + (int)((double)(maxFontSize-minFontSize)*weightMap[tag]) );
+        if( weightMap[tag] > 0.8 )
+            font.setBold( true );
+        label->setFont( font );
+        label->setUnderline(false);
+        return label;
+    }
+};
+
+
+KTagCloudWidget::KTagCloudWidget( QWidget* parent )
+    : QWidget( parent ),
+      d( new Private() )
+{
+    d->mainLay = new KBlockLayout( this );
+    d->mainLay->setAlignment( Qt::AlignJustify|Qt::AlignVCenter );
+}
+
+
+KTagCloudWidget::~KTagCloudWidget()
+{
+    delete d;
+}
+
+
+void KTagCloudWidget::setMaxFontSize( int pointSize )
+{
+    d->maxFontSize = pointSize;
+    buildTagCloud();
+}
+
+
+void KTagCloudWidget::setMinFontSize( int pointSize )
+{
+    d->minFontSize = pointSize;
+    buildTagCloud();
+}
+
+
+int KTagCloudWidget::tagWeight( const QString& tag ) const
+{
+    return d->tagMap[tag];
+}
+
+
+void KTagCloudWidget::addTag( const QString& tag, int weight )
+{
+    d->tagMap[tag] = weight;
+    buildTagCloud();
+}
+
+
+void KTagCloudWidget::addTags( const QMap<QString,int>& tags )
+{
+    for( QMap<QString,int>::const_iterator it = tags.constBegin();
+         it != tags.constEnd(); ++it )
+        d->tagMap[it.key()] = it.value();
+    buildTagCloud();
+}
+
+
+void KTagCloudWidget::clear()
+{
+    d->tagMap.clear();
+    buildTagCloud();
+}
+
+
+void KTagCloudWidget::resizeEvent( QResizeEvent* e )
+{
+    QWidget::resizeEvent( e );
+}
+
+
+void KTagCloudWidget::buildTagCloud()
+{
+    // Brute force: delete all existing labels
+    for( QMap<QString,KUrlLabel*>::iterator it = d->labelMap.begin();
+         it != d->labelMap.end(); ++it )
+        delete it.value();
+
+    d->labelMap.clear();
+
+    d->buildWeightMap();
+
+    // now rebuild the cloud
+    QStringList tags;
+    for( QMap<QString,int>::const_iterator it = d->tagMap.constBegin();
+         it != d->tagMap.constEnd(); ++it ) {
+        tags.append( it.key() );
+        d->labelMap[it.key()] = d->createLabel( this, it.key() );
+        connect( d->labelMap[it.key()], SIGNAL(leftClickedUrl(const QString&)),
+                 this, SIGNAL(tagClicked(const QString&)) );
+    }
+
+    // for now we display the tags sorted alphabetically
+    qSort( tags.begin(), tags.end() );
+
+    int x = 0;
+    foreach( const QString &tag, tags ) {
+        KUrlLabel* label = d->labelMap[tag];
+        if( x + label->width() > width() ) {
+            // new line
+            x = 0;
+        }
+        d->mainLay->addWidget( label );
+        x += label->width();
+    }
+}
+
+#include "ktagcloudwidget.moc"
diff -u -r -N nepomuk/core/ui/.svn/text-base/ktagcloudwidget.h.svn-base nepomuk-svn/core/ui/.svn/text-base/ktagcloudwidget.h.svn-base
--- nepomuk/core/ui/.svn/text-base/ktagcloudwidget.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/ktagcloudwidget.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KTAGCLOUDWIDGET_H
+#define KTAGCLOUDWIDGET_H
+
+#include <QtGui/QWidget>
+#include <QtCore/QMap>
+
+#include <nepomuk/nepomuk_export.h>
+
+class NEPOMUK_EXPORT KTagCloudWidget : public QWidget
+{
+    Q_OBJECT
+
+ public:
+    KTagCloudWidget( QWidget* parent = 0 );
+    ~KTagCloudWidget();
+
+    /**
+     * Retrieve the weight for a certain tag
+     */
+    int tagWeight( const QString& tag ) const;
+
+ public Q_SLOTS:
+    /**
+     * Add \a tag to the cloud using the weight factor \a weight. 
+     * Existing tags with the same name will be overwritten.
+     */
+    void addTag( const QString& tag, int weight );
+
+    /**
+     * Add a set of tags with weight factors
+     */
+    void addTags( const QMap<QString,int>& tags );
+
+    /**
+     * Remove all tags from the cloud.
+     */
+    void clear();
+
+    /**
+     * Set the maximum font size to be used for the most popular tags.
+     * Default is 22.
+     */
+    void setMaxFontSize( int pointSize );
+
+    /**
+     * Set the minimum font size to be used for the most unpopular tags.
+     * Default is 8.
+     */
+    void setMinFontSize( int pointSize );
+  
+ Q_SIGNALS:
+    void tagClicked( const QString& tag );
+
+ protected:
+    void resizeEvent( QResizeEvent* e );
+
+ private:
+    void buildTagCloud();
+
+    class Private;
+    Private* const d;
+};
+
+#endif
diff -u -r -N nepomuk/core/ui/.svn/text-base/ktagdisplaywidget.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/ktagdisplaywidget.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/ktagdisplaywidget.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/ktagdisplaywidget.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,119 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ktagdisplaywidget.h"
+
+#include <kurllabel.h>
+
+#include <QtGui/QBoxLayout>
+
+
+class KTagDisplayWidget::Private
+{
+public:
+    Private( KTagDisplayWidget* _parent )
+        : parent( _parent ) {
+        layout = new QHBoxLayout( parent );
+        layout->setMargin( 0 );
+    }
+
+    void buildDisplay() {
+        // delete all the children
+        foreach( QWidget* w, wl )
+            delete w;
+        wl.clear();
+
+        // remove the stretch we added in the last call
+        if ( QLayoutItem* item = layout->takeAt( 0 ) )
+            delete item;
+
+        // create new labels
+        for( QStringList::const_iterator it = tags.constBegin();
+             it != tags.constEnd(); ++it ) {
+            if (  it != tags.constBegin() ) {
+                QLabel* label = new QLabel( "-", parent );
+                wl.append( label );
+                layout->addWidget( label ); // FIXME: display some nicer symbol like a big dot
+            }
+            KUrlLabel* label = new KUrlLabel( *it, *it, parent );
+            wl.append( label );
+            label->setUnderline( false );
+            layout->addWidget( label );
+
+            connect( label, SIGNAL(leftClickedUrl(const QString&)),
+                     parent, SIGNAL(tagClicked(const QString&)) );
+        }
+
+        layout->addStretch( 1 );
+    }
+
+    QStringList tags;
+    QList<QWidget*> wl;
+    QHBoxLayout* layout;
+
+private:
+    KTagDisplayWidget* parent;
+};
+
+
+KTagDisplayWidget::KTagDisplayWidget( QWidget* parent )
+    : QWidget( parent ),
+      d( new Private( this ) )
+{
+}
+
+
+KTagDisplayWidget::~KTagDisplayWidget()
+{
+    delete d;
+}
+
+
+void KTagDisplayWidget::setTags( const QStringList& tags )
+{
+    d->tags = tags;
+    d->buildDisplay();
+}
+
+
+void KTagDisplayWidget::addTag( const QString& tag )
+{
+    if ( !d->tags.contains( tag ) )
+        d->tags.append( tag );
+    d->buildDisplay();
+}
+
+
+void KTagDisplayWidget::addTags( const QStringList& tags )
+{
+    foreach( const QString &tag, tags )
+        if ( !d->tags.contains( tag ) )
+            d->tags.append( tag );
+    d->buildDisplay();
+}
+
+
+void KTagDisplayWidget::clear()
+{
+    d->tags.clear();
+    d->buildDisplay();
+}
+
+#include "ktagdisplaywidget.moc"
diff -u -r -N nepomuk/core/ui/.svn/text-base/ktagdisplaywidget.h.svn-base nepomuk-svn/core/ui/.svn/text-base/ktagdisplaywidget.h.svn-base
--- nepomuk/core/ui/.svn/text-base/ktagdisplaywidget.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/ktagdisplaywidget.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _KTAG_DISPLAY_WIDGET_H_
+#define _KTAG_DISPLAY_WIDGET_H_
+
+#include <QtGui/QWidget>
+
+#include <nepomuk/nepomuk_export.h>
+
+/**
+ * The KTagDisplayWidget shows a list of tags and allows clicking each of them.
+ */
+class NEPOMUK_EXPORT KTagDisplayWidget : public QWidget
+{
+    Q_OBJECT
+
+ public:
+    KTagDisplayWidget( QWidget* parent = 0 );
+    ~KTagDisplayWidget();
+
+ public Q_SLOTS:
+    /**
+     * Set \a tags to be displayed.
+     */
+    void setTags( const QStringList& tags );
+
+    /**
+     * Add \a tag to be displayed.
+     * Existing tags with the same name will be overwritten.
+     */
+    void addTag( const QString& tag );
+
+    /**
+     * Add a set of tags to be displayed.
+     * Existing tags with the same name will be overwritten.
+     */
+    void addTags( const QStringList& tags );
+
+    /**
+     * Remove all tags.
+     */
+    void clear();
+
+ Q_SIGNALS:
+    void tagClicked( const QString& tag );
+
+ private:
+    class Private;
+    Private* const d;
+};
+
+#endif
diff -u -r -N nepomuk/core/ui/.svn/text-base/nepomukmassupdatejob.cpp.svn-base nepomuk-svn/core/ui/.svn/text-base/nepomukmassupdatejob.cpp.svn-base
--- nepomuk/core/ui/.svn/text-base/nepomukmassupdatejob.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/nepomukmassupdatejob.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,154 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Sebastian Trueg <trueg@kde.org>                 *
+ *                                                                         *
+ *   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 "nepomukmassupdatejob.h"
+
+#include "klocale.h"
+#include "kdebug.h"
+
+#include "tag.h"
+#include "tools.h"
+
+
+Nepomuk::MassUpdateJob::MassUpdateJob( QObject* parent )
+    : KJob( parent ),
+      m_index( -1 )
+{
+    kDebug();
+    setCapabilities( Killable|Suspendable );
+    connect( &m_processTimer, SIGNAL( timeout() ),
+             this, SLOT( slotNext() ) );
+}
+
+
+Nepomuk::MassUpdateJob::~MassUpdateJob()
+{
+    kDebug();
+}
+
+
+void Nepomuk::MassUpdateJob::setFiles( const KUrl::List& urls )
+{
+    m_resources.clear();
+    foreach( const KUrl &url, urls ) {
+        m_resources.append( Resource( url ) );
+    }
+    setTotalAmount( KJob::Files, m_resources.count() );
+}
+
+
+void Nepomuk::MassUpdateJob::setResources( const QList<Nepomuk::Resource>& rl )
+{
+    m_resources = rl;
+    setTotalAmount( KJob::Files, m_resources.count() );
+}
+
+
+void Nepomuk::MassUpdateJob::setProperties( const QList<QPair<QUrl,Nepomuk::Variant> >& props )
+{
+    m_properties = props;
+}
+
+
+void Nepomuk::MassUpdateJob::start()
+{
+    if ( m_index < 0 ) {
+        kDebug();
+        emit description( this,
+                          i18n("Changing annotations") );
+        m_index = 0;
+        m_processTimer.start();
+    }
+    else {
+        kDebug() << "Job has already been started";
+    }
+}
+
+
+bool Nepomuk::MassUpdateJob::doKill()
+{
+    if ( m_index > 0 ) {
+        m_processTimer.stop();
+        m_index = -1;
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+
+bool Nepomuk::MassUpdateJob::doSuspend()
+{
+    m_processTimer.stop();
+    return true;
+}
+
+
+bool Nepomuk::MassUpdateJob::doResume()
+{
+    if ( m_index > 0 ) {
+        m_processTimer.start();
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+
+void Nepomuk::MassUpdateJob::slotNext()
+{
+    if ( !isSuspended() ) {
+        if ( m_index < m_resources.count() ) {
+            Nepomuk::Resource& res = m_resources[m_index];
+            for ( int i = 0; i < m_properties.count(); ++i ) {
+                res.setProperty( m_properties[i].first, m_properties[i].second );
+            }
+            ++m_index;
+            setProcessedAmount( KJob::Files, m_index );
+        }
+        else if ( m_index >= m_resources.count() ) {
+            kDebug() << "done";
+            m_index = -1;
+            m_processTimer.stop();
+            emitResult();
+        }
+    }
+}
+
+
+Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::tagResources( const QList<Nepomuk::Resource>& rl, const QList<Nepomuk::Tag>& tags )
+{
+    Nepomuk::MassUpdateJob* job = new Nepomuk::MassUpdateJob();
+    job->setResources( rl );
+    job->setProperties( QList<QPair<QUrl,Nepomuk::Variant> >() << qMakePair( QUrl( Nepomuk::Resource::tagUri() ), Nepomuk::Variant( convertResourceList<Tag>( tags ) ) ) );
+    return job;
+}
+
+
+Nepomuk::MassUpdateJob* Nepomuk::MassUpdateJob::rateResources( const QList<Nepomuk::Resource>& rl, int rating )
+{
+    Nepomuk::MassUpdateJob* job = new Nepomuk::MassUpdateJob();
+    job->setResources( rl );
+    job->setProperties( QList<QPair<QUrl,Nepomuk::Variant> >() << qMakePair( QUrl( Nepomuk::Resource::ratingUri() ), Nepomuk::Variant( rating ) ) );
+    return job;
+}
+
+#include "nepomukmassupdatejob.moc"
diff -u -r -N nepomuk/core/ui/.svn/text-base/nepomukmassupdatejob.h.svn-base nepomuk-svn/core/ui/.svn/text-base/nepomukmassupdatejob.h.svn-base
--- nepomuk/core/ui/.svn/text-base/nepomukmassupdatejob.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/.svn/text-base/nepomukmassupdatejob.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,84 @@
+/***************************************************************************
+ *   Copyright (C) 2008 by Sebastian Trueg <trueg@kde.org>                 *
+ *                                                                         *
+ *   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 _NEPOMUK_MASS_UPDATE_JOB_H_
+#define _NEPOMUK_MASS_UPDATE_JOB_H_
+
+#include "kjob.h"
+#include "kurl.h"
+
+#include <QtCore/QList>
+#include <QtCore/QPair>
+#include <QtCore/QTimer>
+
+#include "resource.h"
+#include "variant.h"
+
+
+namespace Nepomuk {
+    class MassUpdateJob : public KJob
+    {
+        Q_OBJECT
+
+    public:
+        MassUpdateJob( QObject* parent = 0 );
+        ~MassUpdateJob();
+
+        /**
+         * Set a list of files to change
+         * This has the same effect as using setResources
+         * with a list of manually created resources.
+         */
+        void setFiles( const KUrl::List& urls );
+
+        /**
+         * Set a list of resources to change.
+         */
+        void setResources( const QList<Nepomuk::Resource>& );
+
+        /**
+         * Set the properties to change in the mass update.
+         */
+        void setProperties( const QList<QPair<QUrl,Nepomuk::Variant> >& props );
+
+        /**
+         * Actually start the job.
+         */
+        void start();
+
+        static MassUpdateJob* tagResources( const QList<Nepomuk::Resource>&, const QList<Nepomuk::Tag>& tags );
+        static MassUpdateJob* rateResources( const QList<Nepomuk::Resource>&, int rating );
+
+    protected:
+        bool doKill();
+        bool doSuspend();
+        bool doResume();
+
+    private Q_SLOTS:
+        void slotNext();
+
+    private:
+        QList<Nepomuk::Resource> m_resources;
+        QList<QPair<QUrl,Nepomuk::Variant> > m_properties;
+        int m_index;
+        QTimer m_processTimer;
+    };
+}
+
+#endif
diff -u -r -N nepomuk/core/ui/CMakeLists.txt nepomuk-svn/core/ui/CMakeLists.txt
--- nepomuk/core/ui/CMakeLists.txt	2008-05-21 13:07:45.000000000 +0200
+++ nepomuk-svn/core/ui/CMakeLists.txt	2009-02-27 13:37:52.000000000 +0100
@@ -15,7 +15,7 @@
   kmetadatatagwidget.h
   ktagdisplaywidget.h
   kratingpainter.h
-  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk
+  DESTINATION ${INCLUDE_INSTALL_DIR}/nepomuk COMPONENT Devel
 )
 
 install(FILES
diff -u -r -N nepomuk/core/ui/pics/.svn/all-wcprops nepomuk-svn/core/ui/pics/.svn/all-wcprops
--- nepomuk/core/ui/pics/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/pics/.svn/all-wcprops	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,11 @@
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/home/kde/!svn/ver/755647/trunk/KDE/kdelibs/nepomuk/core/ui/pics
+END
+rating.png
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/755647/trunk/KDE/kdelibs/nepomuk/core/ui/pics/rating.png
+END
diff -u -r -N nepomuk/core/ui/pics/.svn/entries nepomuk-svn/core/ui/pics/.svn/entries
--- nepomuk/core/ui/pics/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/pics/.svn/entries	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,62 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/core/ui/pics
+https://svn.kde.org/home/kde
+
+
+
+2008-01-02T00:10:07.267883Z
+755647
+uwolfer
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+rating.png
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+dabf2266e4079556724f27bdee0de9b9
+2008-01-02T00:10:07.267883Z
+755647
+uwolfer
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1172
+
diff -u -r -N nepomuk/core/ui/pics/.svn/format nepomuk-svn/core/ui/pics/.svn/format
--- nepomuk/core/ui/pics/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/pics/.svn/format	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/core/ui/pics/.svn/prop-base/rating.png.svn-base nepomuk-svn/core/ui/pics/.svn/prop-base/rating.png.svn-base
--- nepomuk/core/ui/pics/.svn/prop-base/rating.png.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/pics/.svn/prop-base/rating.png.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 9
+image/png
+END
Files nepomuk/core/ui/pics/.svn/text-base/rating.png.svn-base and nepomuk-svn/core/ui/pics/.svn/text-base/rating.png.svn-base differ
diff -u -r -N nepomuk/core/ui/test/.svn/all-wcprops nepomuk-svn/core/ui/test/.svn/all-wcprops
--- nepomuk/core/ui/test/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/test/.svn/all-wcprops	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,29 @@
+K 25
+svn:wc:ra_dav:version-url
+V 64
+/home/kde/!svn/ver/829273/trunk/KDE/kdelibs/nepomuk/core/ui/test
+END
+ratingpaintertestwidget.h
+K 25
+svn:wc:ra_dav:version-url
+V 90
+/home/kde/!svn/ver/786656/trunk/KDE/kdelibs/nepomuk/core/ui/test/ratingpaintertestwidget.h
+END
+ratingpaintertestapp.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 89
+/home/kde/!svn/ver/781611/trunk/KDE/kdelibs/nepomuk/core/ui/test/ratingpaintertestapp.cpp
+END
+ratingpaintertestwidget.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 92
+/home/kde/!svn/ver/786656/trunk/KDE/kdelibs/nepomuk/core/ui/test/ratingpaintertestwidget.cpp
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 79
+/home/kde/!svn/ver/829273/trunk/KDE/kdelibs/nepomuk/core/ui/test/CMakeLists.txt
+END
diff -u -r -N nepomuk/core/ui/test/.svn/entries nepomuk-svn/core/ui/test/.svn/entries
--- nepomuk/core/ui/test/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/test/.svn/entries	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,164 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/core/ui/test
+https://svn.kde.org/home/kde
+
+
+
+2008-07-07T23:31:01.596778Z
+829273
+dfaure
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+ratingpaintertestwidget.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+81259c01cc884fca955c383512997645
+2008-03-17T15:44:25.198600Z
+786656
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+718
+
+ratingpaintertestapp.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+bf5bcb6725194f7cfa0c4e8adb67efe2
+2008-03-03T10:54:51.104062Z
+781611
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+301
+
+ratingpaintertestwidget.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+bacf4ed8a8c96ecca7fcee4c08db59bb
+2008-03-17T15:44:25.198600Z
+786656
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+4685
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+04980a128f802b5c435c204da471abe7
+2008-07-07T23:31:01.596778Z
+829273
+dfaure
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+408
+
diff -u -r -N nepomuk/core/ui/test/.svn/format nepomuk-svn/core/ui/test/.svn/format
--- nepomuk/core/ui/test/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/test/.svn/format	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/core/ui/test/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/core/ui/test/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/core/ui/test/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/test/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,17 @@
+set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
+
+include_directories(
+  ${QT_INCLUDES}
+  ${KDE4_INCLUDES}
+  ${CMAKE_SOURCE_DIR}
+  )
+
+kde4_add_executable(ratingpaintertestapp TEST ratingpaintertestapp.cpp ratingpaintertestwidget.cpp)
+target_link_libraries(ratingpaintertestapp
+  ${QT_QTCORE_LIBRARY}
+  ${QT_QTGUI_LIBRARY}
+  ${KDE4_KDECORE_LIBS}
+  ${KDE4_KDEUI_LIBS}
+  ${KDE4_KIO_LIBS}
+  nepomuk
+  )
diff -u -r -N nepomuk/core/ui/test/.svn/text-base/ratingpaintertestapp.cpp.svn-base nepomuk-svn/core/ui/test/.svn/text-base/ratingpaintertestapp.cpp.svn-base
--- nepomuk/core/ui/test/.svn/text-base/ratingpaintertestapp.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/test/.svn/text-base/ratingpaintertestapp.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,14 @@
+#include "ratingpaintertestwidget.h"
+
+#include <QApplication>
+#include <kcomponentdata.h>
+
+
+int main( int argc, char** argv )
+{
+    QApplication app( argc, argv );
+    KComponentData data( "NepomukRatingPainterTest" );
+    RatingPainterTestWidget ratingW;
+    ratingW.show();
+    return app.exec();
+}
diff -u -r -N nepomuk/core/ui/test/.svn/text-base/ratingpaintertestwidget.cpp.svn-base nepomuk-svn/core/ui/test/.svn/text-base/ratingpaintertestwidget.cpp.svn-base
--- nepomuk/core/ui/test/.svn/text-base/ratingpaintertestwidget.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/test/.svn/text-base/ratingpaintertestwidget.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,138 @@
+#include "ratingpaintertestwidget.h"
+#include "../kratingwidget.h"
+
+#include <QtGui/QGridLayout>
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QComboBox>
+#include <QtGui/QCheckBox>
+#include <QtGui/QLabel>
+#include <QtGui/QSpinBox>
+#include <QtGui/QPushButton>
+
+#include <kicon.h>
+#include <kicondialog.h>
+
+
+RatingPainterTestWidget::RatingPainterTestWidget()
+    : QWidget( 0 )
+{
+    QVBoxLayout* layout = new QVBoxLayout( this );
+    m_ratingWidget = new KRatingWidget( this );
+    m_ratingWidget->setFrameStyle( QFrame::StyledPanel|QFrame::Sunken );
+    m_checkHalfSteps = new QCheckBox( "Enable half steps", this );
+    m_checkEnalbed = new QCheckBox( "Rating disabled", this );
+    m_spinMaxRating = new QSpinBox( this );
+    m_spinRating = new QSpinBox( this );
+    m_spinSpacing = new QSpinBox( this );
+
+    m_comboAlignmentH = new QComboBox( this );
+    m_comboAlignmentV = new QComboBox( this );
+
+    m_buttonIcon = new QPushButton( "Change Icon...", this );
+
+    m_comboAlignmentH->addItem( "Left" );
+    m_comboAlignmentH->addItem( "Right" );
+    m_comboAlignmentH->addItem( "Center" );
+    m_comboAlignmentH->addItem( "Justify" );
+
+    m_comboAlignmentV->addItem( "Top" );
+    m_comboAlignmentV->addItem( "Bottom" );
+    m_comboAlignmentV->addItem( "Center" );
+
+    layout->addWidget( m_ratingWidget, 1 );
+    layout->addWidget( new QLabel( "Alignment:" ) );
+    layout->addWidget( m_comboAlignmentH );
+    layout->addWidget( m_comboAlignmentV );
+    layout->addWidget( m_checkHalfSteps );
+    layout->addWidget( m_checkEnalbed );
+
+    QHBoxLayout* ratingLayout = new QHBoxLayout;
+    ratingLayout->addWidget( new QLabel( "Rating:", this ) );
+    ratingLayout->addWidget( m_spinRating );
+    layout->addLayout( ratingLayout );
+
+    QHBoxLayout* maxRatingLayout = new QHBoxLayout;
+    maxRatingLayout->addWidget( new QLabel( "Max Rating:", this ) );
+    maxRatingLayout->addWidget( m_spinMaxRating );
+    layout->addLayout( maxRatingLayout );
+
+    QHBoxLayout* spacingLayout = new QHBoxLayout;
+    spacingLayout->addWidget( new QLabel( "Spacing:", this ) );
+    spacingLayout->addWidget( m_spinSpacing );
+    layout->addLayout( spacingLayout );
+
+    layout->addWidget( m_buttonIcon );
+
+    connect( m_comboAlignmentH, SIGNAL( activated( int ) ),
+             this, SLOT( slotAlignmentChanged() ) );
+    connect( m_comboAlignmentV, SIGNAL( activated( int ) ),
+             this, SLOT( slotAlignmentChanged() ) );
+    connect( m_spinMaxRating, SIGNAL(valueChanged(int)),
+             m_ratingWidget, SLOT(setMaxRating(int)) );
+    connect( m_spinRating, SIGNAL(valueChanged(int)),
+             m_ratingWidget, SLOT(setRating(int)) );
+    connect( m_spinSpacing, SIGNAL(valueChanged(int)),
+             m_ratingWidget, SLOT(setSpacing(int)) );
+    connect( m_checkHalfSteps, SIGNAL(toggled(bool)),
+             m_ratingWidget, SLOT(setHalfStepsEnabled(bool)) );
+    connect( m_checkEnalbed, SIGNAL(toggled(bool)),
+             m_ratingWidget, SLOT(setDisabled(bool)) );
+    connect( m_ratingWidget, SIGNAL(ratingChanged(int)),
+             m_spinRating, SLOT(setValue(int)) );
+    connect( m_buttonIcon, SIGNAL(clicked()),
+             this, SLOT(slotChangeIcon()) );
+
+    m_comboAlignmentH->setCurrentIndex( 2 );
+    m_comboAlignmentV->setCurrentIndex( 2 );
+    m_spinMaxRating->setValue( m_ratingWidget->maxRating() );
+    m_spinRating->setValue( m_ratingWidget->rating() );
+    m_spinSpacing->setValue( m_ratingWidget->spacing() );
+    m_checkHalfSteps->setChecked( m_ratingWidget->halfStepsEnabled() );
+}
+
+
+RatingPainterTestWidget::~RatingPainterTestWidget()
+{
+}
+
+
+void RatingPainterTestWidget::slotAlignmentChanged()
+{
+    Qt::Alignment align = Qt::AlignLeft;
+    if ( m_comboAlignmentH->currentText() == "Left" ) {
+        align = Qt::AlignLeft;
+    }
+    else if ( m_comboAlignmentH->currentText() == "Right" ) {
+        align = Qt::AlignRight;
+    }
+    else if ( m_comboAlignmentH->currentText() == "Center" ) {
+        align = Qt::AlignHCenter;
+    }
+    else if ( m_comboAlignmentH->currentText() == "Justify" ) {
+        align = Qt::AlignJustify;
+    }
+
+    if ( m_comboAlignmentV->currentText() == "Top" ) {
+        align |= Qt::AlignTop;
+    }
+    else if ( m_comboAlignmentV->currentText() == "Bottom" ) {
+        align |= Qt::AlignBottom;
+    }
+    else if ( m_comboAlignmentV->currentText() == "Center" ) {
+        align |= Qt::AlignVCenter;
+    }
+
+    m_ratingWidget->setAlignment( align );
+}
+
+
+void RatingPainterTestWidget::slotChangeIcon()
+{
+    QString icon = KIconDialog::getIcon();
+    if ( !icon.isEmpty() ) {
+        m_ratingWidget->setIcon( KIcon( icon ) );
+        m_buttonIcon->setIcon( KIcon( icon ) );
+    }
+}
+
+#include "ratingpaintertestwidget.moc"
diff -u -r -N nepomuk/core/ui/test/.svn/text-base/ratingpaintertestwidget.h.svn-base nepomuk-svn/core/ui/test/.svn/text-base/ratingpaintertestwidget.h.svn-base
--- nepomuk/core/ui/test/.svn/text-base/ratingpaintertestwidget.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/core/ui/test/.svn/text-base/ratingpaintertestwidget.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,39 @@
+#ifndef _RATING_PAINTER_TEST_WIDGET_H_
+#define _RATING_PAINTER_TEST_WIDGET_H_
+
+#include <QtGui/QWidget>
+
+class QComboBox;
+class QCheckBox;
+class KRatingWidget;
+class QSpinBox;
+class QPushButton;
+
+class RatingPainterTestWidget : public QWidget
+{
+    Q_OBJECT
+
+public:
+    RatingPainterTestWidget();
+    ~RatingPainterTestWidget();
+
+private Q_SLOTS:
+    void slotChangeIcon();
+    void slotAlignmentChanged();
+
+private:
+    QSpinBox* m_spinMaxRating;
+    QSpinBox* m_spinRating;
+    QSpinBox* m_spinSpacing;
+
+    QComboBox* m_comboAlignmentH;
+    QComboBox* m_comboAlignmentV;
+    QCheckBox* m_checkHalfSteps;
+    QCheckBox* m_checkEnalbed;
+
+    QPushButton* m_buttonIcon;
+
+    KRatingWidget* m_ratingWidget;
+};
+
+#endif
diff -u -r -N nepomuk/core/variant.cpp nepomuk-svn/core/variant.cpp
--- nepomuk/core/variant.cpp	2008-05-21 13:07:45.000000000 +0200
+++ nepomuk-svn/core/variant.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -273,6 +273,15 @@
 }
 
 
+Nepomuk::Variant::Variant( const QList<Variant>& vl )
+    : d( new Private )
+{
+    foreach( const Variant& v, vl ) {
+        append( v );
+    }
+}
+
+
 Nepomuk::Variant& Nepomuk::Variant::operator=( const Variant& v )
 {
     d->value = v.d->value;
@@ -805,8 +814,10 @@
         Resource r = toResource();
         if( !r.resourceUri().isEmpty() )
             return r.resourceUri().toString();
-        else
+        else if( !r.identifiers().isEmpty() )
             return r.identifiers().first();
+        else
+            return QString();
     }
     else
         return d->value.value<QString>();
@@ -1075,6 +1086,89 @@
 }
 
 
+QList<Nepomuk::Variant> Nepomuk::Variant::toVariantList() const
+{
+    QList<Variant> l;
+
+    switch( simpleType() ) {
+    case QVariant::Int:
+        foreach( int i, toIntList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::LongLong:
+        foreach( qlonglong i, toInt64List() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::UInt:
+        foreach( uint i, toUnsignedIntList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::ULongLong:
+        foreach( qulonglong i, toUnsignedInt64List() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Bool:
+        foreach( bool i, toBoolList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Double:
+        foreach( double i, toDoubleList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Date:
+        foreach( const QDate& i, toDateList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Time:
+        foreach( const QTime& i, toTimeList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::DateTime:
+        foreach( const QDateTime& i, toDateTimeList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    case QVariant::Url:
+        foreach( const QUrl& i, toUrlList() ) {
+            l.append( Variant(i) );
+        }
+        break;
+
+    default:
+        if( simpleType() == qMetaTypeId<Resource>()) {
+            foreach( const Resource& i, toResourceList() ) {
+                l.append( Variant(i) );
+            }
+        }
+        else {
+            foreach( const QString& i, toStringList() ) {
+                l.append( Variant(i) );
+            }
+            break;
+        }
+    }
+
+    return l;
+}
+
+
 bool Nepomuk::Variant::isList() const
 {
     return( isIntList() ||
@@ -1201,8 +1295,10 @@
 QDebug operator<<( QDebug dbg, const Nepomuk::Variant& v )
 {
     if( v.isList() )
-        dbg << v.toStringList();
+        dbg.nospace() << "Nepomuk::Variant(" << v.toStringList() << "@list)";
+    else if( v.isResource() )
+        dbg.nospace() << "Nepomuk::Variant(Nepomuk::Resource(" << v.toString() << "))";
     else
-        dbg << v.toString();
+        dbg.nospace() << "Nepomuk::Variant(" << v.variant() << ")";
     return dbg;
 }
diff -u -r -N nepomuk/core/variant.h nepomuk-svn/core/variant.h
--- nepomuk/core/variant.h	2008-05-21 13:07:45.000000000 +0200
+++ nepomuk-svn/core/variant.h	2009-02-27 13:37:52.000000000 +0100
@@ -89,6 +89,13 @@
         Variant( const QList<QUrl>& url );
         Variant( const QList<Resource>& r );
 
+        /**
+         * Create a new Variant from a list of Variants.
+         *
+         * \since 4.3
+         */
+        Variant( const QList<Variant>& vl );
+
         Variant& operator=( const Variant& );
         Variant& operator=( int i );
         Variant& operator=( qlonglong i );
@@ -250,6 +257,13 @@
         QList<Resource> toResourceList() const;
 
         /**
+         * Convert a Variant to a list of Variants.
+         *
+         * \since 4.3
+         */
+        QList<Variant> toVariantList() const;
+
+        /**
          * Create a Variant object by parsing string \a value based on \a type.
          * If \a type is unknown a simple string Variant object is returned
          * containing the plain string \a value.
diff -u -r -N nepomuk/rcgen/.svn/all-wcprops nepomuk-svn/rcgen/.svn/all-wcprops
--- nepomuk/rcgen/.svn/all-wcprops	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/all-wcprops	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,47 @@
+K 25
+svn:wc:ra_dav:version-url
+V 57
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/rcgen
+END
+rcgen.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 67
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/rcgen/rcgen.cpp
+END
+resourceclass.h
+K 25
+svn:wc:ra_dav:version-url
+V 73
+/home/kde/!svn/ver/877017/trunk/KDE/kdelibs/nepomuk/rcgen/resourceclass.h
+END
+ontologyparser.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/rcgen/ontologyparser.cpp
+END
+resourcetemplate.h
+K 25
+svn:wc:ra_dav:version-url
+V 76
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/rcgen/resourcetemplate.h
+END
+CMakeLists.txt
+K 25
+svn:wc:ra_dav:version-url
+V 72
+/home/kde/!svn/ver/877568/trunk/KDE/kdelibs/nepomuk/rcgen/CMakeLists.txt
+END
+ontologyparser.h
+K 25
+svn:wc:ra_dav:version-url
+V 74
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/rcgen/ontologyparser.h
+END
+resourceclass.cpp
+K 25
+svn:wc:ra_dav:version-url
+V 75
+/home/kde/!svn/ver/913635/trunk/KDE/kdelibs/nepomuk/rcgen/resourceclass.cpp
+END
diff -u -r -N nepomuk/rcgen/.svn/entries nepomuk-svn/rcgen/.svn/entries
--- nepomuk/rcgen/.svn/entries	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/entries	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,266 @@
+9
+
+dir
+932765
+https://svn.kde.org/home/kde/trunk/KDE/kdelibs/nepomuk/rcgen
+https://svn.kde.org/home/kde
+
+
+
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+svn:special svn:externals svn:needs-lock
+
+
+
+
+
+
+
+
+
+
+
+283d02a7-25f6-0310-bc7c-ecb5cbfe19da
+
+rcgen.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+62871b286b98f7d7b0d04defaa8cd0c9
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+5601
+
+resourceclass.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+a58971a2f1854c562117b54ac6161a33
+2008-10-28T14:19:17.098991Z
+877017
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+2967
+
+ontologyparser.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+d7dc35c68dc959794ff6094bb68db28a
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+9667
+
+resourcetemplate.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+30b7588404591f089dcc9933ca1c10e4
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+6275
+
+CMakeLists.txt
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+3cb937bbf1570b972f2dbe7bf096c2bc
+2008-10-29T20:49:54.493758Z
+877568
+mlaurent
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+454
+
+ontologyparser.h
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+8aa86b1b4909cdf9800e5b2932ae551f
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+947
+
+resourceclass.cpp
+file
+
+
+
+
+2009-02-27T12:37:52.000000Z
+4893e39beca9fe55db0e42f058f11ec0
+2009-01-19T16:33:20.663565Z
+913635
+trueg
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+22076
+
diff -u -r -N nepomuk/rcgen/.svn/format nepomuk-svn/rcgen/.svn/format
--- nepomuk/rcgen/.svn/format	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/format	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1 @@
+9
diff -u -r -N nepomuk/rcgen/.svn/prop-base/CMakeLists.txt.svn-base nepomuk-svn/rcgen/.svn/prop-base/CMakeLists.txt.svn-base
--- nepomuk/rcgen/.svn/prop-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/prop-base/CMakeLists.txt.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,9 @@
+K 13
+svn:eol-style
+V 6
+native
+K 13
+svn:mime-type
+V 10
+text/plain
+END
diff -u -r -N nepomuk/rcgen/.svn/text-base/CMakeLists.txt.svn-base nepomuk-svn/rcgen/.svn/text-base/CMakeLists.txt.svn-base
--- nepomuk/rcgen/.svn/text-base/CMakeLists.txt.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/text-base/CMakeLists.txt.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,21 @@
+project(nepomuk_rcgen)
+
+include_directories(
+  ${nepomuk_rcgen_SOURCE_DIR}
+  ${KDE4_KDECORE_INCLUDES}
+  ${QT_INCLUDES}
+  ${SOPRANO_INCLUDE_DIR} )
+
+set(nepomuk_rcgen_SRCS
+  rcgen.cpp
+  resourceclass.cpp
+  ontologyparser.cpp)
+
+kde4_add_executable(nepomuk-rcgen ${nepomuk_rcgen_SRCS})
+target_link_libraries(nepomuk-rcgen
+  ${SOPRANO_LIBRARIES}
+  ${QT_QTCORE_LIBRARY}
+  ${QT_QTDBUS_LIBRARY}
+)
+
+install(TARGETS nepomuk-rcgen ${INSTALL_TARGETS_DEFAULT_ARGS} )
diff -u -r -N nepomuk/rcgen/.svn/text-base/ontologyparser.cpp.svn-base nepomuk-svn/rcgen/.svn/text-base/ontologyparser.cpp.svn-base
--- nepomuk/rcgen/.svn/text-base/ontologyparser.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/text-base/ontologyparser.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,272 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library 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.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "ontologyparser.h"
+#include "resourceclass.h"
+#include "resourcetemplate.h"
+
+#include <soprano/soprano.h>
+
+#include <QtCore/QMap>
+#include <QtCore/QStringList>
+#include <QtCore/QFile>
+#include <QtCore/QHash>
+#include <QtCore/QDebug>
+#include <QtCore/QDir>
+
+
+extern bool quiet;
+
+
+class OntologyParser::Private
+{
+public:
+    Private() {
+        // default parent class
+        resources.insert( "http://www.w3.org/2000/01/rdf-schema#Resource",
+                          ResourceClass( "http://www.w3.org/2000/01/rdf-schema#Resource" ) );
+    }
+
+    QMap<QString, ResourceClass> resources;
+    QMap<QString, Property> properties;
+    QMap<QString, QString> comments;
+    const Soprano::Parser* rdfParser;
+
+    QHash<QString, QString> namespaceAbbr;
+
+    QString ensureNS( const QString& uri ) {
+        // check if we have a NS abbrev
+        QString ns = uri.left( uri.indexOf( ":" ) );
+        if( namespaceAbbr.contains( ns ) )
+            return namespaceAbbr[ns] + uri.mid( ns.length()+1 );
+        else
+            return uri;
+    }
+
+    ResourceClass& getResource( const QString& uri ) {
+        ResourceClass& r = resources[ensureNS(uri)];
+        r.uri = ensureNS(uri);
+        if ( !r.parent ) {
+            r.parent = &resources["http://www.w3.org/2000/01/rdf-schema#Resource"];
+        }
+        return r;
+    }
+
+    Property& getProperty( const QString& uri ) {
+        Property& p = properties[ensureNS(uri)];
+        p.uri = ensureNS(uri);
+        return p;
+    }
+};
+
+
+OntologyParser::OntologyParser()
+{
+    d = new Private;
+    d->rdfParser = 0;
+}
+
+
+OntologyParser::~OntologyParser()
+{
+    delete d;
+}
+
+
+bool OntologyParser::assignTemplates( const QStringList& templates )
+{
+    // FIXME: do an actual class name mapping by parsing the class
+    foreach( const QString &tf, templates ) {
+        QString filename = QFileInfo( tf ).fileName();
+        for( QMap<QString, ResourceClass>::iterator it = d->resources.begin();
+             it != d->resources.end(); ++it ) {
+            // we use startsWith() for a hackish handling of such suffixes as ".in"
+            if( filename.startsWith( it.value().headerName() ) ) {
+                if ( !quiet )
+                    qDebug() << "Using header template file " << tf << " for class " << it.value().name();
+                it.value().headerTemplateFilePath = tf;
+            }
+            else if( filename.startsWith( it.value().sourceName() ) ) {
+                if ( !quiet )
+                    qDebug() << "Using source template file " << tf << " for class " << it.value().name();
+                it.value().sourceTemplateFilePath = tf;
+            }
+        }
+    }
+
+    return true;
+}
+
+
+bool OntologyParser::parse( const QString& filename )
+{
+    Soprano::RdfSerialization serialization;
+    if ( filename.endsWith( "trig" ) ) {
+        serialization = Soprano::SerializationTrig;
+    }
+    else {
+        serialization = Soprano::SerializationRdfXml;
+    }
+
+    if ( !( d->rdfParser = Soprano::PluginManager::instance()->discoverParserForSerialization( serialization ) ) ) {
+        return false;
+    }
+
+    if ( !quiet )
+        qDebug() << "(OntologyParser) Parsing " << filename << endl;
+
+    // get the namespaces the hacky way
+    QFile f( filename );
+    if( f.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
+        QString s = QTextStream( &f ).readAll();
+        QRegExp nsr( "xmlns:(\\S*)=\"(\\S*\\#)\"" );
+        int pos = 0;
+        while( ( pos = s.indexOf( nsr, pos+1 ) ) > 0 ) {
+            if ( !quiet )
+                qDebug() << "Found namespace abbreviation: " << nsr.cap(1) << "->" << nsr.cap(2) << endl;
+            d->namespaceAbbr.insert( nsr.cap(1), nsr.cap(2) );
+        }
+    }
+
+    // FIXME: the serialization should be somehow specified
+    Soprano::StatementIterator it = d->rdfParser->parseFile( filename,
+                                                             QUrl("http://org.kde.nepomuk/dummybaseuri"),
+                                                             serialization );
+    bool success = true;
+
+    while( it.next() ) {
+        const Soprano::Statement& s = *it;
+
+        if( s.predicate().uri().toString().endsWith( "#subClassOf" ) ) {
+            ResourceClass& rc = d->getResource( s.subject().uri().toString() );
+            rc.parent = &d->getResource( s.object().uri().toString() );
+            rc.allParents.append( &d->getResource( s.object().uri().toString() ) );
+            rc.generate = true;
+        }
+        else if( s.predicate().uri().toString().endsWith( "#type" ) ) {
+            if( s.object().uri().toString().endsWith( "#Class" ) )
+                d->getResource( s.subject().uri().toString() ).generate = true;
+        }
+        else if( s.predicate().uri().toString().endsWith( "#domain" ) ) {
+            ResourceClass& rc = d->getResource( s.object().uri().toString() );
+            Property& p = d->getProperty( s.subject().uri().toString() );
+            p.domain = &rc;
+            if ( !rc.properties.contains( &p ) )
+                rc.properties.append( &p );
+            rc.generate = true;
+        }
+        else if( s.predicate().uri().toString().endsWith( "#range" ) ) {
+            d->getProperty(s.subject().uri().toString()).type = d->ensureNS(s.object().uri().toString());
+        }
+        else if( s.predicate().uri().toString().endsWith( "#maxCardinality" ) ||
+                 s.predicate().uri().toString().endsWith( "#cardinality" ) ) {
+            d->getProperty(s.subject().uri().toString()).list = ( s.object().literal().toInt() > 1 );
+        }
+        else if( s.predicate().uri().toString().endsWith( "#comment" ) ) {
+            d->comments[d->ensureNS(s.subject().uri().toString())] = s.object().literal().toString();
+        }
+        else if ( s.predicate().uri().toString().endsWith("inverseProperty") ) {
+            d->getProperty(s.subject().uri().toString()).inverse = &d->getProperty(s.object().uri().toString());
+            d->getProperty(s.object().uri().toString()).inverse = &d->getProperty(s.subject().uri().toString());
+        }
+    }
+
+    // determine the reverse properties
+    for( QMap<QString, Property>::iterator propIt = d->properties.begin();
+         propIt != d->properties.end(); ++propIt ) {
+        Property& p = propIt.value();
+        if( d->resources.contains( p.type ) ) {
+            if ( !quiet )
+                qDebug() << "Setting reverse property " << p.uri << " on type " << p.type << endl;
+            if ( !d->resources[p.type].reverseProperties.contains( &p ) )
+                d->resources[p.type].reverseProperties.append( &p );
+        }
+        if ( !p.domain ) {
+            p.domain = &d->resources["http://www.w3.org/2000/01/rdf-schema#Resource"];
+        }
+
+        Q_ASSERT( d->properties.count( propIt.key() ) == 1 );
+    }
+
+    // now assign the comments to resources and properties
+    QMapIterator<QString, QString> commentsIt( d->comments );
+    while( commentsIt.hasNext() ) {
+        commentsIt.next();
+        if( d->resources.contains( commentsIt.key() ) )
+            d->resources[commentsIt.key()].comment = commentsIt.value();
+        else if( d->properties.contains( commentsIt.key() ) )
+            d->properties[commentsIt.key()].comment = commentsIt.value();
+    }
+
+    // testing stuff
+    for( QMap<QString, ResourceClass>::iterator it = d->resources.begin();
+         it != d->resources.end(); ++it ) {
+        if( !it->parent ) {
+            it->parent = &d->resources["http://www.w3.org/2000/01/rdf-schema#Resource"];
+        }
+        if ( !quiet )
+            qDebug() << "Resource: " << (*it).name()
+                     << "[" << (*it).uri << "]"
+                     << " (->" << (*it).parent->name() << ")"
+                     << ( (*it).generateClass() ? " (will be generated)" : " (will not be generated)" )
+                     << endl;
+
+        Q_ASSERT( d->resources.count( it.key() ) == 1 );
+
+        QListIterator<const Property*> propIt( (*it).properties );
+        while( propIt.hasNext() ) {
+            const Property* p = propIt.next();
+            if ( !quiet )
+                qDebug() << "          " << p->uri << " (->" << p->type << ")" << ( p->list ? QString("+") : QString("1") ) << endl;
+        }
+    }
+
+    return success;
+}
+
+
+bool OntologyParser::writeSources( const QString& dir, bool externalRefs )
+{
+    bool success = true;
+
+    for( QMap<QString, ResourceClass>::const_iterator it = d->resources.constBegin();
+         it != d->resources.constEnd(); ++it ) {
+        if( (*it).generateClass() )
+            success &= (*it).write( dir + QDir::separator() );
+    }
+
+    return success;
+}
+
+
+QStringList OntologyParser::listHeader()
+{
+    QStringList l;
+    for( QMap<QString, ResourceClass>::const_iterator it = d->resources.constBegin();
+         it != d->resources.constEnd(); ++it )
+        if( (*it).generateClass() )
+            l.append( (*it).headerName() );
+    return l;
+}
+
+
+QStringList OntologyParser::listSources()
+{
+    QStringList l;
+    for( QMap<QString, ResourceClass>::const_iterator it = d->resources.constBegin();
+         it != d->resources.constEnd(); ++it )
+        if( (*it).generateClass() )
+            l.append( (*it).sourceName() );
+    return l;
+}
diff -u -r -N nepomuk/rcgen/.svn/text-base/ontologyparser.h.svn-base nepomuk-svn/rcgen/.svn/text-base/ontologyparser.h.svn-base
--- nepomuk/rcgen/.svn/text-base/ontologyparser.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/text-base/ontologyparser.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,39 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library 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.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _ONTOLOGY_PARSER_H_
+#define _ONTOLOGY_PARSER_H_
+
+#include <QtCore/QStringList>
+
+
+class OntologyParser
+{
+ public:
+    OntologyParser();
+    ~OntologyParser();
+
+    bool parse( const QString& filename );
+    bool assignTemplates( const QStringList& templates );
+    bool writeSources( const QString& dir, bool externalRefs );
+
+    QStringList listHeader();
+    QStringList listSources();
+
+ private:
+    class Private;
+    Private* d;
+};
+
+#endif
diff -u -r -N nepomuk/rcgen/.svn/text-base/rcgen.cpp.svn-base nepomuk-svn/rcgen/.svn/text-base/rcgen.cpp.svn-base
--- nepomuk/rcgen/.svn/text-base/rcgen.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/text-base/rcgen.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,172 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library 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.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include <QtCore/QTextStream>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QFile>
+#include <QtCore/QDebug>
+
+#include "resourceclass.h"
+#include "ontologyparser.h"
+
+
+bool quiet = true;
+
+static int usage()
+{
+    QTextStream( stderr, QIODevice::WriteOnly )
+        << "Usage:" << endl
+        << "   " << QCoreApplication::instance()->arguments()[0] << " --writeall [--templates <tmpl1> [<tmpl2> [<tmpl3> ...]]] [--no-external-refs] --target <sourcefolder> --ontologies <ontologyfile(s)>" << endl
+        << "   " << QCoreApplication::instance()->arguments()[0] << " --listincludes --ontologies <ontologyfile(s)>" << endl
+        << "   " << QCoreApplication::instance()->arguments()[0] << " --listheaders [--prefix <listprefix>] --ontologies <ontologyfile(s)>" << endl
+        << "   " << QCoreApplication::instance()->arguments()[0] << " --listsources [--prefix <listprefix>] --ontologies <ontologyfile(s)>" << endl;
+    return 1;
+}
+
+
+int main( int argc, char** argv )
+{
+    // we probably need a QCoreApplication instance for some
+    // stuff. If not, who cares, we don't do anything time relevant here
+    QCoreApplication app( argc, argv );
+
+    bool writeAll = false, listHeader = false, listSource = false, listIncludes = false,  externalRefs = true;
+    QStringList ontoFiles;
+    QString targetDir, prefix;
+    QStringList templates;
+
+    QStringList args = app.arguments();
+    if( args.count() < 2 )
+        return usage();
+
+    QStringList::const_iterator argIt = args.constBegin();
+    ++argIt; // skip the app name
+    while (argIt != args.constEnd()) {
+        const QString& arg = *argIt;
+
+        // new parameter
+        if ( arg.startsWith("--") ) {
+            // gather parameter arg
+            QStringList paramArgs;
+            ++argIt;
+            while ( argIt != args.constEnd() &&
+                    !(*argIt).startsWith("--") ) {
+                paramArgs += *argIt;
+                ++argIt;
+            }
+
+            // now lets see what we have
+            if ( arg == "--writeall" ) {
+                writeAll = true;
+            }
+            else if ( arg == "--listincludes" ) {
+                listIncludes = true;
+            }
+            else if ( arg == "--listheaders" ) {
+                listHeader = true;
+            }
+            else if ( arg == "--listsources" ) {
+                listSource = true;
+            }
+            else if ( arg == "--no-external-refs" ) {
+                externalRefs = false;
+            }
+            else if ( arg == "--templates" ) {
+                templates = paramArgs;
+            }
+            else if ( arg == "--ontologies" ) {
+                if ( paramArgs.isEmpty() ) {
+                    return usage();
+                }
+                ontoFiles = paramArgs;
+            }
+            else if ( arg == "--prefix" ) {
+                if ( paramArgs.count() != 1 ) {
+                    return usage();
+                }
+                prefix = paramArgs.first();
+            }
+            else if ( arg == "--target" ) {
+                if ( paramArgs.count() != 1 ) {
+                    return usage();
+                }
+                targetDir = paramArgs.first();
+            }
+            else if ( arg == "--verbose" ) {
+                quiet = false;
+            }
+            else {
+                return usage();
+            }
+        }
+        else
+            return usage();
+    }
+
+    foreach( const QString &ontoFile, ontoFiles ) {
+        if( !QFile::exists( ontoFile ) ) {
+            qDebug() << "Ontology file " << ontoFile << " does not exist." << endl;
+            return -1;
+        }
+    }
+
+    if( writeAll ) {
+        if( !QFile::exists( targetDir ) ) {
+            qDebug() << "Folder " << targetDir << " does not exist." << endl;
+            return -1;
+        }
+    }
+
+    OntologyParser prsr;
+    foreach( const QString &ontoFile, ontoFiles ) {
+        if( !prsr.parse( ontoFile ) ) {
+            qDebug() << "Parsing ontology file " << ontoFile << " failed." << endl;
+            return -1;
+        }
+    }
+
+    if( writeAll ) {
+        if( !prsr.assignTemplates( templates ) ) {
+            return -1;
+        }
+
+        if( !prsr.writeSources( targetDir, externalRefs ) ) {
+            qDebug() << "Writing sources to " << targetDir << " failed." << endl;
+            return -1;
+        }
+    }
+    else if( listSource ) {
+        QStringList l = prsr.listSources();
+        QTextStream s( stdout, QIODevice::WriteOnly );
+        QStringListIterator it( l );
+        while( it.hasNext() )
+            s << prefix << it.next() << ";";
+    }
+    else if( listHeader ) {
+        QStringList l = prsr.listHeader();
+        QTextStream s( stdout, QIODevice::WriteOnly );
+        QStringListIterator it( l );
+        while( it.hasNext() )
+            s << prefix << it.next() << ";";
+    }
+    else if( listIncludes ) {
+        QStringList l = prsr.listHeader();
+        QTextStream s( stdout, QIODevice::WriteOnly );
+        QStringListIterator it( l );
+        while( it.hasNext() )
+            s << "#include <kmetadata/" << it.next() << ">" << endl;
+    }
+
+    return 0;
+}
diff -u -r -N nepomuk/rcgen/.svn/text-base/resourceclass.cpp.svn-base nepomuk-svn/rcgen/.svn/text-base/resourceclass.cpp.svn-base
--- nepomuk/rcgen/.svn/text-base/resourceclass.cpp.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/text-base/resourceclass.cpp.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,697 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library 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.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#include "resourceclass.h"
+#include "resourcetemplate.h"
+
+#include <QtCore/QFile>
+#include <QtCore/QTextStream>
+#include <QtCore/QRegExp>
+#include <QtCore/QDebug>
+#include <QtCore/QUrl>
+#include <QtCore/QStringList>
+
+
+extern bool quiet;
+
+
+static const QString s_typeComment =
+"    // We always store all Resource types as plain Resource objects.\n"
+"    // It does not introduce any overhead (due to the implicit sharing of\n"
+"    // the data and has the advantage that we can mix setProperty calls\n"
+"    // with the special Resource subclass methods.\n"
+"    // More importantly Resource loads the data as Resource objects anyway.\n";
+
+
+static QString writeComment( const QString& comment, int indent )
+{
+    static const int maxLine = 50;
+
+    QString s;
+
+    if( !comment.isEmpty() ) {
+        s += QString().fill( ' ', indent );
+        s += "/**\n"
+             + QString().fill( ' ', indent+1 )
+             + "* ";
+
+        QStringList words = comment.split( QRegExp("\\s"), QString::SkipEmptyParts );
+        int cnt = 0;
+        for( int i = 0; i < words.count(); ++i ) {
+            if( cnt >= maxLine ) {
+                s += '\n'
+                     + QString().fill( ' ', indent+1 )
+                     + "* ";
+                cnt = 0;
+            }
+
+            s += words[i] + ' ';
+            cnt += words[i].length();
+        }
+
+        if( cnt > 0 )
+            s += '\n';
+        s += QString().fill( ' ', indent+1 )
+             + "*/";
+    }
+
+    return s;
+}
+
+
+
+Property::Property()
+    : list(true),
+      domain(0),
+      inverse(0)
+{
+}
+
+
+Property::Property( const QString& uri_,
+		    const QString& type_ )
+    : uri(uri_),
+      type(type_),
+      list(true),
+      domain(0),
+      inverse(0)
+{
+}
+
+
+QString Property::name() const
+{
+    //
+    // many predicates are named "hasSomething"
+    // we remove the "has" becasue setHasSomething sounds weird
+    //
+    QString n = uri.section( QRegExp( "[#/:]" ), -1 );
+    if( n.toLower().startsWith( "has" ) )
+        return n.mid( 3 );
+    else
+        return n;
+}
+
+
+QString Property::typeString( bool simple, bool withNamespace ) const
+{
+    QString t;
+    if( type.contains( "XMLSchema" ) ) {
+        // XML Schema types
+        // FIXME: move this map somewhere else
+        QHash<QString, QString> xmlSchemaTypes;
+        xmlSchemaTypes.insert( "integer", "qint64" );
+        xmlSchemaTypes.insert( "nonNegativeInteger", "quint64" );
+        xmlSchemaTypes.insert( "nonPositiveInteger", "qint64" );
+        xmlSchemaTypes.insert( "negativeInteger", "qint64" );
+        xmlSchemaTypes.insert( "positiveInteger", "quint64" );
+        xmlSchemaTypes.insert( "long", "qint64" );
+        xmlSchemaTypes.insert( "unsignedLong", "quint64" );
+        xmlSchemaTypes.insert( "int", "qint32" );
+        xmlSchemaTypes.insert( "unsignedInt", "quint32" );
+        xmlSchemaTypes.insert( "short", "qint16" );
+        xmlSchemaTypes.insert( "unsignedShort", "quint16" );
+        xmlSchemaTypes.insert( "byte", "char" );
+        xmlSchemaTypes.insert( "unsignedByte", "unsigned char" );
+        xmlSchemaTypes.insert( "float", "double" );
+        xmlSchemaTypes.insert( "double", "double" );
+        xmlSchemaTypes.insert( "boolean", "bool" );
+        xmlSchemaTypes.insert( "date", "QDate" );
+        xmlSchemaTypes.insert( "time", "QTime" );
+        xmlSchemaTypes.insert( "dateTime", "QDateTime" );
+        xmlSchemaTypes.insert( "duration", "QDateTime" ); // FIXME
+        xmlSchemaTypes.insert( "string", "QString" );
+        t = xmlSchemaTypes[type.mid(type.lastIndexOf( "#" ) + 1 )];
+    }
+    else if( type.endsWith( "#Literal" ) ) {
+        t = "QString";
+    }
+    else {
+        t = type.section( QRegExp( "[#/:]" ), -1 );
+        if( withNamespace )
+            t.prepend( "Nepomuk::" );
+    }
+
+    if( !simple && list ) {
+        if( t == "QString" )
+            return "QStringList";
+        else
+            return "QList<" + t + '>';
+    }
+
+    Q_ASSERT( !t.isEmpty() );
+
+    return t;
+}
+
+
+bool Property::hasSimpleType() const
+{
+    return ( type.contains( "XMLSchema" ) || type.endsWith( "#Literal" ) );
+}
+
+
+QString Property::setterDeclaration( const ResourceClass* rc, bool withNamespace ) const
+{
+    return QString( "void %1set%2%3%4( const %5& value )" )
+        .arg( withNamespace ? QString("Nepomuk::%1::").arg(rc->name()) : QString() )
+        .arg( name()[0].toUpper() )
+        .arg( name().mid(1) )
+        .arg( list ? (name().endsWith('s') ? QLatin1String("es") : QLatin1String("s") ) : QString() )
+        .arg( typeString( false, withNamespace ) );
+}
+
+
+QString Property::getterDeclaration( const ResourceClass* rc, bool withNamespace ) const
+{
+    return QString( "%1 %2%3%4%5() const" )
+        .arg( typeString( false, withNamespace ) )
+        .arg( withNamespace ? QString("Nepomuk::%1::").arg(rc->name()) : QString() )
+        .arg( name()[0].toLower() )
+        .arg( name().mid(1) )
+        .arg( list ? (name().endsWith('s') ? QLatin1String("es") : QLatin1String("s") ) : QString() );
+}
+
+
+QString Property::adderDeclaration( const ResourceClass* rc, bool withNamespace ) const
+{
+    return QString( "void %1add%2%3( const %4& value )" )
+        .arg( withNamespace ? QString("Nepomuk::%1::").arg(rc->name()) : QString() )
+        .arg( name()[0].toUpper() )
+        .arg( name().mid(1) )
+        .arg( typeString( true, withNamespace ) );
+}
+
+
+QString Property::reversePropertyGetterDeclaration( const ResourceClass* rc, bool withNamespace ) const
+{
+    Q_ASSERT( rc );
+    Q_ASSERT( domain );
+    return QString( "%1 %2%3%4Of() const" )
+        .arg( QString("QList<") + domain->name( withNamespace ) + QString(">") )
+        .arg( withNamespace ? QString("Nepomuk::%1::").arg(rc->name()) : QString() )
+        .arg( name()[0].toLower() )
+        .arg( name().mid(1) );
+}
+
+
+QString Property::setterDefinition( const ResourceClass* rc ) const
+{
+    QString s = setterDeclaration( rc, true ) + '\n';
+
+    if( hasSimpleType() || typeString( true ) == "Resource" || !list ) {
+        s += QString("{\n"
+                     "    setProperty( QUrl(\"%1\"), Variant( value ) );\n"
+                     "}\n" )
+             .arg( uri );
+    }
+    else if( list ) {
+        s += QString("{\n"
+                     "%1"
+                     "    QList<Resource> l;\n"
+                     "    for( %2::const_iterator it = value.constBegin();\n"
+                     "         it != value.constEnd(); ++it ) {\n"
+                     "        l.append( Resource( (*it) ) );\n"
+                     "    }\n"
+                     "    setProperty( QUrl(\"%3\"), Variant( l ) );\n"
+                     "}\n" )
+             .arg( s_typeComment )
+             .arg( typeString() )
+             .arg( uri );
+    }
+    else {
+        s += QString("{\n"
+                     "%1"
+                     "    setProperty( QUrl(\"%2\"), Variant( Resource( value ) ) );\n"
+                     "}\n" )
+             .arg( s_typeComment )
+             .arg( uri );
+    }
+
+    return s;
+}
+
+
+QString Property::typeConversionMethod() const
+{
+    // for properties with cardinality == 1 we use a little hack since there will always be duplication of
+    // data.
+    if ( typeString(false) == "QStringList" ) {
+        return QLatin1String("toStringList())");
+    }
+    else if ( typeString(true) == "QString" ) {
+        return QLatin1String("toStringList() << QString() ).first()");
+    }
+    else if ( typeString(true) == "qint32" ) {
+        return list ? QLatin1String("toIntList())") : QLatin1String("toIntList() << 0 ).first()");
+    }
+    else if ( typeString(true) == "quint32" ) {
+        return list ? QLatin1String("toUnsignedIntList())") : QLatin1String("toUnsignedIntList() << 0 ).first()");
+    }
+    else if ( typeString(true) == "qint64" ) {
+        return list ? QLatin1String("toInt64List())") : QLatin1String("toInt64List() << 0 ).first()");
+    }
+    else if ( typeString(true) == "quint64" ) {
+        return list ? QLatin1String("toUnsignedInt64List())") : QLatin1String("toUnsignedInt64List() << 0 ).first()");
+    }
+    else if ( typeString(true) == "bool" ) {
+        return list ? QLatin1String("toBoolList())") : QLatin1String("toBoolList() << false ).first()");
+    }
+    else if ( typeString(true) == "double" ) {
+        return list ? QLatin1String("toDoubleList())") : QLatin1String("toDoubleList() << 0.0 ).first()");
+    }
+    else if ( typeString(true) == "QDateTime" ) {
+        return list ? QLatin1String("toDateTimeList())") : QLatin1String("toDateTimeList() << QDateTime() ).first()");
+    }
+    else if ( typeString(true) == "QDate" ) {
+        return list ? QLatin1String("toDateList())") : QLatin1String("toDateList() << QDate() ).first()");
+    }
+    else if ( typeString(true) == "QTime" ) {
+        return list ? QLatin1String("toTimeList())") : QLatin1String("toTimeList() << QTime() ).first()");
+    }
+
+    if ( !quiet )
+        qDebug() << "Unknown type:" << typeString(true);
+
+    return QString();
+}
+
+
+QString Property::getterDefinition( const ResourceClass* rc ) const
+{
+    QString s = getterDeclaration( rc, true ) + '\n';
+
+    if( hasSimpleType() ) {
+        s += QString( "{\n"
+                      "    return ( property( QUrl(\"%1\") ).%2;\n"
+                      "}\n" )
+             .arg( uri )
+             .arg( typeConversionMethod() );
+    }
+    else if( list ) {
+        s += QString("{\n"
+                     "%1"
+                     "    return convertResourceList<%3>( property( QUrl(\"%2\") ).toResourceList() );\n"
+                     "}\n" )
+             .arg( s_typeComment )
+             .arg( uri )
+             .arg( typeString( true ) );
+    }
+    else {
+        s += QString("{\n"
+                     "%1"
+                     "    return %2( property( QUrl(\"%3\") ).toResource().uri() );\n"
+                     "}\n" )
+             .arg( s_typeComment )
+             .arg( typeString( true ) )
+             .arg( uri );
+    }
+
+    return s;
+}
+
+
+QString Property::adderDefinition( const ResourceClass* rc ) const
+{
+    QString s = adderDeclaration( rc, true ) + '\n';
+
+    if( hasSimpleType() ) {
+        s += QString( "{\n"
+                      "    Variant v = property( QUrl(\"%1\") );\n"
+                      "    v.append( value );\n"
+                      "    setProperty( QUrl(\"%1\"), v );\n"
+                      "}\n" )
+             .arg( uri );
+    }
+    else {
+        s += QString( "{\n"
+                      "%1"
+                      "    Variant v = property( QUrl(\"%2\") );\n"
+                      "    v.append( Resource( value ) );\n"
+                      "    setProperty( QUrl(\"%2\"), v );\n"
+                      "}\n" )
+             .arg( s_typeComment )
+             .arg( uri );
+    }
+
+    return s;
+}
+
+
+QString Property::reversePropertyGetterDefinition( const ResourceClass* rc ) const
+{
+    QString s = reversePropertyGetterDeclaration( rc, true ) + '\n';
+
+    s += QString( "{\n"
+                  "    return convertResourceList<%2>( manager()->allResourcesWithProperty( QUrl(\"%1\"), *this ) );\n"
+                  "}\n" )
+         .arg( uri )
+         .arg( domain->name() );
+
+    return s;
+}
+
+
+
+ResourceClass::ResourceClass()
+    : parent( 0 ),
+      generate( false )
+{
+}
+
+
+ResourceClass::ResourceClass( const QString& uri_ )
+    : parent( 0 ),
+      generate( false ),
+      uri( uri_ )
+{
+}
+
+
+ResourceClass::~ResourceClass()
+{
+}
+
+
+QString ResourceClass::name( bool withNamespace ) const
+{
+    QString s = uri.section( QRegExp( "[#/:]" ), -1 );
+    if( withNamespace )
+        s.prepend( "Nepomuk::" );
+    return s;
+}
+
+
+QString ResourceClass::headerName() const
+{
+    return name().toLower() + ".h";
+}
+
+
+QString ResourceClass::sourceName() const
+{
+    return name().toLower() + ".cpp";
+}
+
+
+QString ResourceClass::allResourcesDeclaration( bool withNamespace ) const
+{
+    return QString( "QList<%1%2> %3all%2s()" )
+        .arg( withNamespace ? QString("Nepomuk::") : QString() )
+        .arg( name() )
+        .arg( withNamespace ? QString("Nepomuk::%1::").arg( name() ) : QString() );
+}
+
+
+QString ResourceClass::allResourcesDefinition() const
+{
+    return QString( "%1\n"
+                    "{\n"
+                    "    return Nepomuk::convertResourceList<%3>( ResourceManager::instance()->allResourcesOfType( QUrl(\"%2\") ) );\n"
+                    "}\n" )
+        .arg( allResourcesDeclaration( true ) )
+        .arg( uri )
+        .arg( name() );
+}
+
+
+QString ResourceClass::pseudoInheritanceDeclaration( ResourceClass* rc, bool withNamespace ) const
+{
+    return QString( "%1 %2to%3() const" )
+        .arg( rc->name( withNamespace ) )
+        .arg( withNamespace ? name( true ) + "::" : QString() )
+        .arg( rc->name( false ) );
+}
+
+
+QString ResourceClass::pseudoInheritanceDefinition( ResourceClass* rc ) const
+{
+    return QString( "%1\n"
+                    "{\n"
+                    "    return %2( *this );\n"
+                    "}\n" )
+        .arg( pseudoInheritanceDeclaration( rc, true ) )
+        .arg( rc->name( true ) );
+}
+
+
+bool ResourceClass::writeHeader( QTextStream& stream ) const
+{
+    QString s = headerTemplate;
+    if( QFile::exists( headerTemplateFilePath ) ) {
+        QFile f( headerTemplateFilePath );
+        if( !f.open( QIODevice::ReadOnly ) ) {
+            qDebug() << "Failed to open " << headerTemplateFilePath;
+            return false;
+        }
+        s = QTextStream( &f ).readAll();
+    }
+    s.replace( "NEPOMUK_RESOURCECOMMENT", writeComment( comment, 0 ) );
+    s.replace( "NEPOMUK_RESOURCENAMEUPPER", name().toUpper() );
+    s.replace( "NEPOMUK_RESOURCENAME", name() );
+    s.replace( "NEPOMUK_PARENTRESOURCE", parent->name() );
+
+    // A resource that is not part of the currently generated stuff is supposed
+    // to be installed in include/nepomuk
+    if ( parent->generateClass() ) {
+        s.replace( "NEPOMUK_PARENT_INCLUDE", QString("\"%1.h\"").arg( parent->name().toLower() ) );
+    }
+    else {
+        s.replace( "NEPOMUK_PARENT_INCLUDE", QString("<nepomuk/%1.h>").arg( parent->name().toLower() ) );
+    }
+
+    QString methods;
+    QTextStream ms( &methods );
+    QSet<QString> includes;
+
+    QListIterator<const Property*> it( properties );
+    while( it.hasNext() ) {
+        const Property* p = it.next();
+
+        if( p->type.isEmpty() ) {
+            if ( !quiet )
+                qDebug() << "(ResourceClass::writeSource) type not defined for property: " << p->name() << endl;
+            continue;
+        }
+
+        ms << writeComment( QString("Get property '%1'. ").arg(p->name()) + p->comment, 3*4 ) << endl;
+        ms << "            " << p->getterDeclaration( this ) << ";" << endl;
+        ms << endl;
+
+        ms << writeComment( QString("Set property '%1'. ").arg(p->name()) + p->comment, 3*4 ) << endl;
+        ms << "            " << p->setterDeclaration( this ) << ";" << endl;
+        ms << endl;
+
+        if( p->list ) {
+            ms << writeComment( QString("Add a value to property '%1'. ").arg(p->name()) + p->comment, 3*4 ) << endl;
+            ms << "            " << p->adderDeclaration( this ) << ";" << endl;
+            ms << endl;
+        }
+
+        ms << writeComment( QString( "\\return The URI of the property '%1'." ).arg( p->name() ), 3*4 ) << endl;
+        ms << "            " << "static QUrl " << p->name()[0].toLower() << p->name().mid(1) << "Uri();" << endl;
+        ms << endl;
+
+        if( !p->hasSimpleType() )
+            includes.insert( p->typeString( true ) );
+    }
+
+
+    it = reverseProperties;
+    while( it.hasNext() ) {
+        const Property* p = it.next();
+
+        if( p->type.isEmpty() ) {
+            if ( !quiet )
+                qDebug() << "(ResourceClass::writeSource) type not defined for property: " << p->name() << endl;
+            continue;
+        }
+
+        if ( p->inverse ) {
+            // we already define a reverse property. So leave the generated one out
+            continue;
+        }
+
+        ms << writeComment( QString("Get all resources that have this resource set as property '%1'. ")
+                            .arg(p->name()) + p->comment + QString(" \\sa ResourceManager::allResourcesWithProperty"), 3*4 ) << endl;
+        ms << "            " << p->reversePropertyGetterDeclaration( this ) << ";" << endl;
+        ms << endl;
+
+        if( !p->hasSimpleType() )
+            includes.insert( p->domain->name() );
+    }
+
+
+    //
+    // Nepomuk does not support multiple inheritance
+    // So we have to use a workaround instead
+    //
+    if( allParents.count() > 1 ) {
+        foreach( ResourceClass* rc, allParents ) {
+            // ignore the one we derived from
+            if( rc != parent ) {
+                ms << writeComment( QString("Nepomuk does not support multiple inheritance. Thus, to access "
+                                            "properties from all parent classes helper methods like this are "
+                                            "introduced. The object returned represents the exact same resource."), 3*4 ) << endl
+                   << "            " << pseudoInheritanceDeclaration( rc, false ) << ";" << endl << endl;
+
+                includes.insert( rc->name() );
+            }
+        }
+    }
+
+    ms << writeComment( QString("Retrieve a list of all available %1 resources. "
+                                "This list consists of all resource of type %1 that are stored "
+                                "in the local Nepomuk meta data storage and any changes made locally. "
+                                "Be aware that in some cases this list can get very big. Then it might "
+                                "be better to use libKNep directly.").arg( name() ), 3*4 ) << endl;
+    ms << "            static " << allResourcesDeclaration( false ) << ";" << endl;
+
+    QString includeString;
+    QSetIterator<QString> includeIt( includes );
+    while( includeIt.hasNext() ) {
+        includeString += "        class " + includeIt.next() + ";\n";
+    }
+
+    s.replace( "NEPOMUK_OTHERCLASSES", includeString );
+    s.replace( "NEPOMUK_METHODS", methods );
+
+    stream << s;
+
+    return true;
+}
+
+
+bool ResourceClass::writeSource( QTextStream& stream ) const
+{
+    QString s = sourceTemplate;
+    if( QFile::exists( sourceTemplateFilePath ) ) {
+        QFile f( sourceTemplateFilePath );
+        if( !f.open( QIODevice::ReadOnly ) ) {
+            qDebug() << "Failed to open " << sourceTemplateFilePath;
+            return false;
+        }
+        s = QTextStream( &f ).readAll();
+    }
+    s.replace( "NEPOMUK_RESOURCENAMELOWER", name().toLower() );
+    s.replace( "NEPOMUK_RESOURCENAME", name() );
+    s.replace( "NEPOMUK_RESOURCETYPEURI", uri );
+    s.replace( "NEPOMUK_PARENTRESOURCE", parent->name() );
+
+    QString methods;
+    QStringList includes;
+    QTextStream ms( &methods );
+
+    QListIterator<const Property*> it( properties );
+    while( it.hasNext() ) {
+        const Property* p = it.next();
+
+        if( p->type.isEmpty() ) {
+            if ( !quiet )
+                qDebug() << "(ResourceClass::writeSource) type not defined for property: " << p->name() << endl;
+            continue;
+        }
+
+        if ( !p->hasSimpleType() ) {
+            includes.append( QString( "#include \"%1.h\"" ).arg( p->typeString( true, false ).toLower() ) );
+        }
+
+        ms << p->getterDefinition( this ) << endl
+           << p->setterDefinition( this ) << endl;
+        if( p->list )
+            ms << p->adderDefinition( this ) << endl;
+
+        // write the static method that returns the property's Uri
+        ms << "QUrl " << name( true ) << "::" << p->name()[0].toLower() << p->name().mid(1) << "Uri()" << endl
+           << "{" << endl
+           << "    return QUrl(\"" << p->uri << "\");" << endl
+           << "}" << endl << endl;
+    }
+
+    it = reverseProperties;
+    while( it.hasNext() ) {
+        const Property* p = it.next();
+
+        if( p->type.isEmpty() ) {
+            if ( !quiet )
+                qDebug() << "(ResourceClass::writeSource) type not defined for property: " << p->name() << endl;
+            continue;
+        }
+
+        if ( p->inverse ) {
+            // we already define a reverse property. So leave the generated one out
+            continue;
+        }
+
+        ms << p->reversePropertyGetterDefinition( this ) << endl;
+
+        includes.append( QString( "#include \"%1\"" ).arg( p->domain->headerName() ) );
+    }
+
+    //
+    // Nepomuk does not support multiple inheritance
+    // So we have to use a workaround instead
+    //
+    if( allParents.count() > 1 ) {
+        foreach( ResourceClass* rc, allParents ) {
+            // ignore the one we derived from
+            if( rc != parent ) {
+                ms << pseudoInheritanceDefinition( rc ) << endl;
+                includes.append( QString("#include \"%1.h\"").arg( rc->name().toLower() ) );
+            }
+        }
+    }
+
+    ms << allResourcesDefinition() << endl;
+
+    // HACK: remove duplicates and resource include
+    includes = includes.toSet().toList();
+    includes.removeAll( "#include \"resource.h\"" );
+
+    s.replace( "NEPOMUK_METHODS", methods );
+    s.replace( "NEPOMUK_INCLUDES", includes.join( "\n" ) );
+
+    stream << s;
+
+    return true;
+}
+
+
+bool ResourceClass::write( const QString& folder ) const
+{
+    QFile f( folder + headerName() );
+    if( !f.open( QIODevice::WriteOnly ) )
+        return false;
+
+    QTextStream s( &f );
+    if( !writeHeader( s ) )
+        return false;
+
+    f.close();
+
+    f.setFileName( folder + sourceName() );
+    if( !f.open( QIODevice::WriteOnly ) )
+        return false;
+
+    if( !writeSource( s ) )
+        return false;
+
+    return true;
+}
+
+
+bool ResourceClass::generateClass() const
+{
+    return generate;
+}
diff -u -r -N nepomuk/rcgen/.svn/text-base/resourceclass.h.svn-base nepomuk-svn/rcgen/.svn/text-base/resourceclass.h.svn-base
--- nepomuk/rcgen/.svn/text-base/resourceclass.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/text-base/resourceclass.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,111 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library 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.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _NEPOMUK_RESOURCE_CLASS_H_
+#define _NEPOMUK_RESOURCE_CLASS_H_
+
+#include <QtCore/QString>
+#include <QtCore/QList>
+#include <QtCore/QTextStream>
+
+class ResourceClass;
+
+class Property
+{
+ public:
+    Property();
+    Property( const QString& uri,
+	      const QString& type );
+
+    /**
+     * The uri of the property
+     */
+    QString uri;
+
+    /**
+     * The scope of the property
+     */
+    QString type;
+
+    QString comment;
+
+    bool list;
+
+    ResourceClass* domain;
+
+    Property* inverse;
+
+    QString name() const;
+    QString typeConversionMethod() const;
+    QString typeString( bool simple = false, bool withNamespace = false ) const;
+    QString setterDeclaration( const ResourceClass* rc, bool withNamespace = false ) const;
+    QString getterDeclaration( const ResourceClass* rc, bool withNamespace = false ) const;
+    QString adderDeclaration( const ResourceClass* rc, bool withNamespace = false ) const;
+    QString reversePropertyGetterDeclaration( const ResourceClass* rc, bool withNamespace = false ) const;
+
+    QString setterDefinition( const ResourceClass* rc ) const;
+    QString getterDefinition( const ResourceClass* rc ) const;
+    QString adderDefinition( const ResourceClass* rc ) const;
+    QString reversePropertyGetterDefinition( const ResourceClass* rc ) const;
+
+    bool hasSimpleType() const;
+};
+
+
+class ResourceClass
+{
+ public:
+    ResourceClass();
+    ResourceClass( const QString& uri );
+    ~ResourceClass();
+
+    ResourceClass* parent;
+
+    QList<ResourceClass*> allParents;
+
+    bool generate;
+
+    /**
+     * \return true if this class should be generated.
+     * normally this always returns true except for the base class
+     * Resource.
+     */
+    bool generateClass() const;
+
+    QString name( bool withNamespace = false ) const;
+    QString uri;
+    QString comment;
+
+    QList<const Property*> properties;
+    QList<const Property*> reverseProperties;
+
+    QString headerName() const;
+    QString sourceName() const;
+
+    bool writeHeader( QTextStream& ) const;
+    bool writeSource( QTextStream& ) const;
+
+    QString allResourcesDeclaration( bool withNamespace = false ) const;
+    QString allResourcesDefinition() const;
+
+    QString pseudoInheritanceDeclaration( ResourceClass* rc, bool withNamespace ) const;
+    QString pseudoInheritanceDefinition( ResourceClass* rc ) const;
+
+    bool write( const QString& folder ) const;
+
+    QString headerTemplateFilePath;
+    QString sourceTemplateFilePath;
+};
+
+#endif
diff -u -r -N nepomuk/rcgen/.svn/text-base/resourcetemplate.h.svn-base nepomuk-svn/rcgen/.svn/text-base/resourcetemplate.h.svn-base
--- nepomuk/rcgen/.svn/text-base/resourcetemplate.h.svn-base	1970-01-01 01:00:00.000000000 +0100
+++ nepomuk-svn/rcgen/.svn/text-base/resourcetemplate.h.svn-base	2009-02-27 13:37:52.000000000 +0100
@@ -0,0 +1,199 @@
+/* 
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ *
+ * This file is part of the Nepomuk KDE project.
+ * Copyright (C) 2006-2007 Sebastian Trueg <trueg@kde.org>
+ *
+ * This library 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.
+ * See the file "COPYING.LIB" for the exact licensing terms.
+ */
+
+#ifndef _RESOURCE_TEMPLATE_H_
+#define _RESOURCE_TEMPLATE_H_
+
+
+static const QString gplTemplate = 
+"/*\n"
+" * This file is part of the Nepomuk KDE project.\n"
+" *\n"
+" * This library is free software; you can redistribute it and/or modify\n"
+" * it under the terms of the GNU General Public License as published by\n"
+" * the Free Software Foundation; either version 2 of the License, or\n"
+" * (at your option) any later version.\n"
+" * See the file \"COPYING\" for the exact licensing terms.\n"
+" */\n"
+"\n"
+"/*\n"
+" * This file has been generated by the Nepomuk Resource class generator.\n"
+" * DO NOT EDIT THIS FILE.\n"
+" * ANY CHANGES WILL BE LOST.\n"
+" */\n";
+
+static const QString headerTemplate = gplTemplate +
+"\n"
+"#ifndef _NEPOMUK_RESOURCENAMEUPPER_H_\n"
+"#define _NEPOMUK_RESOURCENAMEUPPER_H_\n"
+"\n"
+"class QDateTime;\n"
+"class QDate;\n"
+"class QTime;\n"
+"\n"
+"namespace Nepomuk {\n"
+"NEPOMUK_OTHERCLASSES"
+"}\n"
+"\n"
+"#include NEPOMUK_PARENT_INCLUDE\n"
+"#include <nepomuk/nepomuk_export.h>\n"
+"\n"
+"namespace Nepomuk {\n"
+"\n"
+"NEPOMUK_RESOURCECOMMENT\n"
+"    class NEPOMUK_EXPORT NEPOMUK_RESOURCENAME : public NEPOMUK_PARENTRESOURCE\n"
+"    {\n"
+"    public:\n"
+"        /**\n"
+"         * Create a new empty and invalid NEPOMUK_RESOURCENAME instance\n"
+"         */\n"
+"        NEPOMUK_RESOURCENAME();\n"
+"        NEPOMUK_RESOURCENAME( ResourceManager* );\n"
+"        /**\n"
+"         * Default copy constructor\n"
+"         */\n"
+"        NEPOMUK_RESOURCENAME( const NEPOMUK_RESOURCENAME& );\n"
+"        NEPOMUK_RESOURCENAME( const Resource& );\n"
+"        /**\n"
+"         * Create a new NEPOMUK_RESOURCENAME instance representing the resource\n"
+"         * referenced by \\a uriOrIdentifier.\n"
+"         */\n"
+"        NEPOMUK_RESOURCENAME( const QString& uriOrIdentifier );\n"
+"        NEPOMUK_RESOURCENAME( const QString& uriOrIdentifier, ResourceManager* );\n"
+"        /**\n"
+"         * Create a new NEPOMUK_RESOURCENAME instance representing the resource\n"
+"         * referenced by \\a uri.\n"
+"         */\n"
+"        NEPOMUK_RESOURCENAME( const QUrl& uri );\n"
+"        NEPOMUK_RESOURCENAME( const QUrl& uri, ResourceManager* );\n"
+"        ~NEPOMUK_RESOURCENAME();\n"
+"\n"
+"        NEPOMUK_RESOURCENAME& operator=( const NEPOMUK_RESOURCENAME& );\n"
+"\n"
+"NEPOMUK_METHODS\n"
+"\n"
+"        /**\n"
+"         * \\return The URI of the resource type that is used in NEPOMUK_RESOURCENAME instances.\n"
+"         */\n"
+"        static QString resourceTypeUri();\n"
+"\n"
+"    protected:\n"
+"       NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type );\n"
+"       NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type );\n"
+"       NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type, ResourceManager* );\n"
+"       NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type, ResourceManager* );\n"
+"   };\n"
+"}\n"
+"\n"
+"#endif\n";
+
+
+static const QString sourceTemplate = gplTemplate +
+"\n"
+"#include <nepomuk/tools.h>\n"
+"#include <nepomuk/variant.h>\n"
+"#include <nepomuk/resourcemanager.h>\n"
+"#include \"NEPOMUK_RESOURCENAMELOWER.h\"\n"
+"\n"
+"NEPOMUK_INCLUDES"
+"\n"
+"#include <QtCore/QDateTime>\n"
+"#include <QtCore/QDate>\n"
+"#include <QtCore/QTime>\n"
+"\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME()\n"
+"  : NEPOMUK_PARENTRESOURCE( QUrl(), QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\") )\n"
+"{\n"
+"}\n"
+"\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( QUrl(), QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\"), manager )\n"
+"{\n"
+"}\n"
+"\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const NEPOMUK_RESOURCENAME& res )\n"
+"  : NEPOMUK_PARENTRESOURCE( res )\n"
+"{\n"
+"}\n"
+"\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const Nepomuk::Resource& res )\n"
+"  : NEPOMUK_PARENTRESOURCE( res )\n"
+"{\n"
+"}\n"
+"\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QString& uri )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\") )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QString& uri, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\"), manager )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\") )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\"), manager )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, type )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, type, manager )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, type )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, type, manager )\n"
+"{\n"
+"}\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::~NEPOMUK_RESOURCENAME()\n"
+"{\n"
+"}\n"
+"\n"
+"\n"
+"Nepomuk::NEPOMUK_RESOURCENAME& Nepomuk::NEPOMUK_RESOURCENAME::operator=( const NEPOMUK_RESOURCENAME& res )\n"
+"{\n"
+"    Resource::operator=( res );\n"
+"    return *this;\n"
+"}\n"
+"\n"
+"\n"
+"QString Nepomuk::NEPOMUK_RESOURCENAME::resourceTypeUri()\n"
+"{\n"
+"    return \"NEPOMUK_RESOURCETYPEURI\";\n"
+"}\n"
+"\n"
+"NEPOMUK_METHODS\n";
+
+#endif
diff -u -r -N nepomuk/rcgen/ontologyparser.cpp nepomuk-svn/rcgen/ontologyparser.cpp
--- nepomuk/rcgen/ontologyparser.cpp	2008-10-30 15:19:02.000000000 +0100
+++ nepomuk-svn/rcgen/ontologyparser.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -236,7 +236,7 @@
 }
 
 
-bool OntologyParser::writeSources( const QString& dir )
+bool OntologyParser::writeSources( const QString& dir, bool externalRefs )
 {
     bool success = true;
 
diff -u -r -N nepomuk/rcgen/ontologyparser.h nepomuk-svn/rcgen/ontologyparser.h
--- nepomuk/rcgen/ontologyparser.h	2008-10-30 15:19:02.000000000 +0100
+++ nepomuk-svn/rcgen/ontologyparser.h	2009-02-27 13:37:52.000000000 +0100
@@ -26,7 +26,7 @@
 
     bool parse( const QString& filename );
     bool assignTemplates( const QStringList& templates );
-    bool writeSources( const QString& dir );
+    bool writeSources( const QString& dir, bool externalRefs );
 
     QStringList listHeader();
     QStringList listSources();
diff -u -r -N nepomuk/rcgen/rcgen.cpp nepomuk-svn/rcgen/rcgen.cpp
--- nepomuk/rcgen/rcgen.cpp	2008-10-30 15:19:02.000000000 +0100
+++ nepomuk-svn/rcgen/rcgen.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -27,7 +27,7 @@
 {
     QTextStream( stderr, QIODevice::WriteOnly )
         << "Usage:" << endl
-        << "   " << QCoreApplication::instance()->arguments()[0] << " --writeall [--templates <tmpl1> [<tmpl2> [<tmpl3> ...]]] --target <sourcefolder> --ontologies <ontologyfile(s)>" << endl
+        << "   " << QCoreApplication::instance()->arguments()[0] << " --writeall [--templates <tmpl1> [<tmpl2> [<tmpl3> ...]]] [--no-external-refs] --target <sourcefolder> --ontologies <ontologyfile(s)>" << endl
         << "   " << QCoreApplication::instance()->arguments()[0] << " --listincludes --ontologies <ontologyfile(s)>" << endl
         << "   " << QCoreApplication::instance()->arguments()[0] << " --listheaders [--prefix <listprefix>] --ontologies <ontologyfile(s)>" << endl
         << "   " << QCoreApplication::instance()->arguments()[0] << " --listsources [--prefix <listprefix>] --ontologies <ontologyfile(s)>" << endl;
@@ -41,7 +41,7 @@
     // stuff. If not, who cares, we don't do anything time relevant here
     QCoreApplication app( argc, argv );
 
-    bool writeAll = false, listHeader = false, listSource = false, listIncludes = false;
+    bool writeAll = false, listHeader = false, listSource = false, listIncludes = false,  externalRefs = true;
     QStringList ontoFiles;
     QString targetDir, prefix;
     QStringList templates;
@@ -79,6 +79,9 @@
             else if ( arg == "--listsources" ) {
                 listSource = true;
             }
+            else if ( arg == "--no-external-refs" ) {
+                externalRefs = false;
+            }
             else if ( arg == "--templates" ) {
                 templates = paramArgs;
             }
@@ -138,7 +141,7 @@
             return -1;
         }
 
-        if( !prsr.writeSources( targetDir ) ) {
+        if( !prsr.writeSources( targetDir, externalRefs ) ) {
             qDebug() << "Writing sources to " << targetDir << " failed." << endl;
             return -1;
         }
diff -u -r -N nepomuk/rcgen/resourceclass.cpp nepomuk-svn/rcgen/resourceclass.cpp
--- nepomuk/rcgen/resourceclass.cpp	2008-10-30 15:19:02.000000000 +0100
+++ nepomuk-svn/rcgen/resourceclass.cpp	2009-02-27 13:37:52.000000000 +0100
@@ -354,7 +354,7 @@
     QString s = reversePropertyGetterDeclaration( rc, true ) + '\n';
 
     s += QString( "{\n"
-                  "    return convertResourceList<%2>( ResourceManager::instance()->allResourcesWithProperty( QUrl(\"%1\"), *this ) );\n"
+                  "    return convertResourceList<%2>( manager()->allResourcesWithProperty( QUrl(\"%1\"), *this ) );\n"
                   "}\n" )
          .arg( uri )
          .arg( domain->name() );
diff -u -r -N nepomuk/rcgen/resourcetemplate.h nepomuk-svn/rcgen/resourcetemplate.h
--- nepomuk/rcgen/resourcetemplate.h	2008-10-30 15:19:02.000000000 +0100
+++ nepomuk-svn/rcgen/resourcetemplate.h	2009-02-27 13:37:52.000000000 +0100
@@ -59,6 +59,7 @@
 "         * Create a new empty and invalid NEPOMUK_RESOURCENAME instance\n"
 "         */\n"
 "        NEPOMUK_RESOURCENAME();\n"
+"        NEPOMUK_RESOURCENAME( ResourceManager* );\n"
 "        /**\n"
 "         * Default copy constructor\n"
 "         */\n"
@@ -69,11 +70,13 @@
 "         * referenced by \\a uriOrIdentifier.\n"
 "         */\n"
 "        NEPOMUK_RESOURCENAME( const QString& uriOrIdentifier );\n"
+"        NEPOMUK_RESOURCENAME( const QString& uriOrIdentifier, ResourceManager* );\n"
 "        /**\n"
 "         * Create a new NEPOMUK_RESOURCENAME instance representing the resource\n"
 "         * referenced by \\a uri.\n"
 "         */\n"
 "        NEPOMUK_RESOURCENAME( const QUrl& uri );\n"
+"        NEPOMUK_RESOURCENAME( const QUrl& uri, ResourceManager* );\n"
 "        ~NEPOMUK_RESOURCENAME();\n"
 "\n"
 "        NEPOMUK_RESOURCENAME& operator=( const NEPOMUK_RESOURCENAME& );\n"
@@ -88,6 +91,8 @@
 "    protected:\n"
 "       NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type );\n"
 "       NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type );\n"
+"       NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type, ResourceManager* );\n"
+"       NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type, ResourceManager* );\n"
 "   };\n"
 "}\n"
 "\n"
@@ -114,6 +119,12 @@
 "}\n"
 "\n"
 "\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( QUrl(), QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\"), manager )\n"
+"{\n"
+"}\n"
+"\n"
+"\n"
 "Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const NEPOMUK_RESOURCENAME& res )\n"
 "  : NEPOMUK_PARENTRESOURCE( res )\n"
 "{\n"
@@ -131,21 +142,41 @@
 "{\n"
 "}\n"
 "\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QString& uri, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\"), manager )\n"
+"{\n"
+"}\n"
+"\n"
 "Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri )\n"
 "  : NEPOMUK_PARENTRESOURCE( uri, QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\") )\n"
 "{\n"
 "}\n"
 "\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, QUrl::fromEncoded(\"NEPOMUK_RESOURCETYPEURI\"), manager )\n"
+"{\n"
+"}\n"
+"\n"
 "Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type )\n"
 "  : NEPOMUK_PARENTRESOURCE( uri, type )\n"
 "{\n"
 "}\n"
 "\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QString& uri, const QUrl& type, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, type, manager )\n"
+"{\n"
+"}\n"
+"\n"
 "Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type )\n"
 "  : NEPOMUK_PARENTRESOURCE( uri, type )\n"
 "{\n"
 "}\n"
 "\n"
+"Nepomuk::NEPOMUK_RESOURCENAME::NEPOMUK_RESOURCENAME( const QUrl& uri, const QUrl& type, ResourceManager* manager )\n"
+"  : NEPOMUK_PARENTRESOURCE( uri, type, manager )\n"
+"{\n"
+"}\n"
+"\n"
 "Nepomuk::NEPOMUK_RESOURCENAME::~NEPOMUK_RESOURCENAME()\n"
 "{\n"
 "}\n"