• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Nepomuk

  • nepomuk
  • core
resource.h
Go to the documentation of this file.
1/*
2 * This file is part of the Nepomuk KDE project.
3 * Copyright (C) 2006-2009 Sebastian Trueg <trueg@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#ifndef _NEPOMUK_RESOURCE_H_
22#define _NEPOMUK_RESOURCE_H_
23
24#include <QtCore/QHash>
25#include <QtCore/QStringList>
26
27#include <kurl.h>
28
29#include "class.h"
30
31#include "nepomuk_export.h"
32
33namespace Nepomuk {
34
35 class ResourceManager;
36 class ResourceData;
37 class Variant;
38 class Tag;
39 class Thing;
40 class File;
41 namespace Types {
42 class Property;
43 }
44
45 enum ErrorCode {
46 NoError = 0,
47 CommunicationError,
48 InvalidType,
49 UnknownError
50 };
51
55 // FIXME: add the uri of the resource as parameter
56 NEPOMUK_EXPORT QString errorString( ErrorCode code );
57
94 class NEPOMUK_EXPORT Resource
95 {
96 public:
102 Resource();
103
114 Resource( ResourceManager* manager );
115
119 Resource( const Resource& );
120
154 Resource( const QString& pathOrIdentifier, const QUrl& type = QUrl() );
155
164 Resource( const QString& pathOrIdentifier, const QUrl& type, ResourceManager* manager );
165
169#ifndef KDE_NO_DEPRECATED
170 KDE_DEPRECATED Resource( const QString& pathOrIdentifier, const QString& type );
171#endif
172
187 Resource( const QUrl& uri, const QUrl& type = QUrl() );
188
197 Resource( const QUrl& uri, const QUrl& type, ResourceManager* manager );
198
202 Resource( ResourceData* );
203
207 virtual ~Resource();
208
212 Resource& operator=( const Resource& other );
213
217 Resource& operator=( const QUrl& uri );
218
224 ResourceManager* manager() const;
225
243#ifndef KDE_NO_DEPRECATED
244 KDE_DEPRECATED QString uri() const;
245#endif
246
260 QUrl resourceUri() const;
261
276#ifndef KDE_NO_DEPRECATED
277 KDE_DEPRECATED QString type() const;
278#endif
279
289 QUrl resourceType() const;
290
297 QList<QUrl> types() const;
298
304 void setTypes( const QList<QUrl>& types );
305
311 void addType( const QUrl& type );
312
317 bool hasType( const QUrl& typeUri ) const;
318
327 QString className() const;
328
332#ifndef KDE_NO_DEPRECATED
333 KDE_DEPRECATED QHash<QString, Variant> allProperties() const;
334#endif
335
339 QHash<QUrl, Variant> properties() const;
340
349 bool hasProperty( const QUrl& uri ) const;
350
356 bool hasProperty( const Types::Property& p, const Variant& v ) const;
357
361#ifndef KDE_NO_DEPRECATED
362 KDE_DEPRECATED bool hasProperty( const QString& uri ) const;
363#endif
364
371 Variant property( const QUrl& uri ) const;
372
376#ifndef KDE_NO_DEPRECATED
377 KDE_DEPRECATED Variant property( const QString& uri ) const;
378#endif
379
386 void setProperty( const QUrl& uri, const Variant& value );
387
396 void addProperty( const QUrl& uri, const Variant& value );
397
401#ifndef KDE_NO_DEPRECATED
402 KDE_DEPRECATED void setProperty( const QString& uri, const Variant& value );
403#endif
404
410 void removeProperty( const QUrl& uri );
411
420 void removeProperty( const QUrl& uri, const Variant& value );
421
425#ifndef KDE_NO_DEPRECATED
426 KDE_DEPRECATED void removeProperty( const QString& uri );
427#endif
428
434 void remove();
435
440 bool exists() const;
441
449 bool isValid() const;
450
458 QString genericLabel() const;
459
468 QString genericDescription() const;
469
475 QString genericIcon() const;
476
485 Thing pimoThing();
486
490 bool operator==( const Resource& ) const;
491
497 bool operator!=( const Resource& ) const;
498
503 QString description() const;
504
509 void setDescription( const QString& value );
510
514 static QString descriptionUri();
515
519 QStringList identifiers() const;
520
524 void setIdentifiers( const QStringList& value );
525
529 void addIdentifier( const QString& value );
530
534 static QString identifierUri();
535
539 QStringList altLabels() const;
540
544 void setAltLabels( const QStringList& value );
545
549 void addAltLabel( const QString& value );
550
554 static QString altLabelUri();
555
559 QList<Resource> annotations() const;
560
564 void setAnnotations( const QList<Resource>& value );
565
569 void addAnnotation( const Resource& value );
570
574 static QString annotationUri();
575
580 QList<Tag> tags() const;
581
586 void setTags( const QList<Tag>& value );
587
593 void addTag( const Tag& value );
594
598 static QString tagUri();
599
603 QList<Resource> topics() const;
604
608 void setTopics( const QList<Resource>& value );
609
613 void addTopic( const Resource& value );
614
618 static QString topicUri();
619
623 QList<Resource> isTopicOfs() const;
624
628 void setIsTopicOfs( const QList<Resource>& value );
629
633 void addIsTopicOf( const Resource& value );
634
638 static QString isTopicOfUri();
639
643 QList<Resource> isRelateds() const;
644
648 void setIsRelateds( const QList<Resource>& value );
649
653 void addIsRelated( const Resource& value );
654
658 static QString isRelatedUri();
659
663 QString label() const;
664
668 void setLabel( const QString& value );
669
673 static QString labelUri();
674
678 quint32 rating() const;
679
683 void setRating( const quint32& value );
684
688 static QString ratingUri();
689
696 QStringList symbols() const;
697
704 void setSymbols( const QStringList& value );
705
712 void addSymbol( const QString& value );
713
717 static QString symbolUri();
718
723 QList<Resource> annotationOf() const;
724
729 QList<Resource> isRelatedOf() const;
730
744 static QList<Resource> allResources();
745
753 int usageCount() const;
754
761 void increaseUsageCount();
762
770 bool isFile() const;
771
778 File toFile() const;
779
788 static Resource fromResourceUri( const KUrl& uri, const Nepomuk::Types::Class& type = Nepomuk::Types::Class(), ResourceManager* manager = 0 );
789
790 private:
797 void determineFinalResourceData() const;
798
799 ResourceData* m_data;
800
801 class Private;
802 Private* d; // unused
803
804 friend class ResourceData;
805 };
806
807 NEPOMUK_EXPORT uint qHash( const Resource& res );
808}
809
810#endif
Nepomuk::File
A Nepomuk resource representing a file.
Definition: file.h:42
Nepomuk::ResourceManager
The ResourceManager is the central Nepomuk configuration point.
Definition: resourcemanager.h:56
Nepomuk::Resource
Resource is the central object type in Nepomuk.
Definition: resource.h:95
Nepomuk::Resource::allProperties
QHash< QString, Variant > allProperties() const
Nepomuk::Resource::property
Variant property(const QString &uri) const
Nepomuk::Resource::Resource
Resource(const Resource &)
Copy constructor.
Nepomuk::Resource::description
QString description() const
Get property 'description'.
Nepomuk::Resource::uri
QString uri() const
The URI of the resource, uniquely identifying it.
Nepomuk::Resource::rating
quint32 rating() const
Get property 'Rating'.
Nepomuk::Resource::isRelateds
QList< Resource > isRelateds() const
Get property 'isRelated'.
Nepomuk::Resource::type
QString type() const
The main type of the resource.
Nepomuk::Resource::toFile
File toFile() const
Convert this resource into a File resource to have access to the convinience methods provided by the ...
Nepomuk::Resource::tags
QList< Tag > tags() const
Get property 'Tag'.
Nepomuk::Resource::setTypes
void setTypes(const QList< QUrl > &types)
Set the types of the resource.
Nepomuk::Resource::genericDescription
QString genericDescription() const
Tries very hard to find a suitable human-readable description of the resource.
Nepomuk::Resource::~Resource
virtual ~Resource()
Destructor.
Nepomuk::Resource::addTag
void addTag(const Tag &value)
Add a value to property 'Tag'.
Nepomuk::Resource::isRelatedOf
QList< Resource > isRelatedOf() const
Get all resources that have this resource set as property 'isRelated'.
Nepomuk::Resource::ratingUri
static QString ratingUri()
Nepomuk::Resource::addType
void addType(const QUrl &type)
Add a type to the list of types.
Nepomuk::Resource::addAnnotation
void addAnnotation(const Resource &value)
Add a value to property 'annotation'.
Nepomuk::Resource::Resource
Resource(const QString &pathOrIdentifier, const QString &type)
Nepomuk::Resource::label
QString label() const
Get property 'label'.
Nepomuk::Resource::allResources
static QList< Resource > allResources()
Retrieve a list of all available Resource resources.
Nepomuk::Resource::annotationOf
QList< Resource > annotationOf() const
Get all resources that have this resource set as property 'annotation'.
Nepomuk::Resource::identifiers
QStringList identifiers() const
Get property 'identifier'.
Nepomuk::Resource::hasProperty
bool hasProperty(const QUrl &uri) const
Check if property identified by uri is defined for this resource.
Nepomuk::Resource::usageCount
int usageCount() const
Nepomuk::Resource::Resource
Resource(const QString &pathOrIdentifier, const QUrl &type, ResourceManager *manager)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Nepomuk::Resource::Resource
Resource(ResourceManager *manager)
Creates an empty invalid Resource.
Nepomuk::Resource::setRating
void setRating(const quint32 &value)
Set property 'Rating'.
Nepomuk::Resource::altLabelUri
static QString altLabelUri()
Nepomuk::Resource::isFile
bool isFile() const
Nepomuk::Resource::remove
void remove()
Remove this resource completely.
Nepomuk::Resource::setTopics
void setTopics(const QList< Resource > &value)
Set property 'Topic'.
Nepomuk::Resource::addIsRelated
void addIsRelated(const Resource &value)
Add a value to property 'isRelated'.
Nepomuk::Resource::manager
ResourceManager * manager() const
The Resource manager that manages this resource.
Nepomuk::Resource::genericLabel
QString genericLabel() const
Tries very hard to find a suitable human-readable label for this resource.
Nepomuk::Resource::pimoThing
Thing pimoThing()
Get or create the PIMO thing that relates to this resource.
Nepomuk::Resource::setIdentifiers
void setIdentifiers(const QStringList &value)
Set property 'identifier'.
Nepomuk::Resource::setTags
void setTags(const QList< Tag > &value)
Set property 'Tag'.
Nepomuk::Resource::isRelatedUri
static QString isRelatedUri()
Nepomuk::Resource::setProperty
void setProperty(const QString &uri, const Variant &value)
Nepomuk::Resource::resourceType
QUrl resourceType() const
The main type of the resource.
Nepomuk::Resource::Resource
Resource()
Creates an empty invalid Resource.
Nepomuk::Resource::annotationUri
static QString annotationUri()
Nepomuk::Resource::labelUri
static QString labelUri()
Nepomuk::Resource::setAnnotations
void setAnnotations(const QList< Resource > &value)
Set property 'annotation'.
Nepomuk::Resource::altLabels
QStringList altLabels() const
Get property 'altLabel'.
Nepomuk::Resource::operator=
Resource & operator=(const Resource &other)
Makes this instance of Resource a copy of other.
Nepomuk::Resource::fromResourceUri
static Resource fromResourceUri(const KUrl &uri, const Nepomuk::Types::Class &type=Nepomuk::Types::Class(), ResourceManager *manager=0)
Allows to quickly load a resource from its resource URI without any additional checks.
Nepomuk::Resource::operator!=
bool operator!=(const Resource &) const
Operator to compare two Resource objects.
Nepomuk::Resource::isTopicOfUri
static QString isTopicOfUri()
Nepomuk::Resource::isValid
bool isValid() const
Nepomuk::Resource::Resource
Resource(const QUrl &uri, const QUrl &type, ResourceManager *manager)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Nepomuk::Resource::setDescription
void setDescription(const QString &value)
Set property 'description'.
Nepomuk::Resource::addIsTopicOf
void addIsTopicOf(const Resource &value)
Add a value to property 'isTopicOf'.
Nepomuk::Resource::identifierUri
static QString identifierUri()
Nepomuk::Resource::setProperty
void setProperty(const QUrl &uri, const Variant &value)
Set a property of the resource.
Nepomuk::Resource::hasProperty
bool hasProperty(const QString &uri) const
Nepomuk::Resource::removeProperty
void removeProperty(const QUrl &uri, const Variant &value)
Remove value from property uri of this resource object.
Nepomuk::Resource::addProperty
void addProperty(const QUrl &uri, const Variant &value)
Add a property value to the existing values.
Nepomuk::Resource::addSymbol
void addSymbol(const QString &value)
Add a value to property 'Symbol'.
Nepomuk::Resource::addAltLabel
void addAltLabel(const QString &value)
Add a value to property 'altLabel'.
Nepomuk::Resource::descriptionUri
static QString descriptionUri()
Nepomuk::Resource::Resource
Resource(const QString &pathOrIdentifier, const QUrl &type=QUrl())
Creates a new Resource object.
Nepomuk::Resource::types
QList< QUrl > types() const
Nepomuk::Resource::isTopicOfs
QList< Resource > isTopicOfs() const
Get property 'isTopicOf'.
Nepomuk::Resource::property
Variant property(const QUrl &uri) const
Retrieve the value of property uri.
Nepomuk::Resource::increaseUsageCount
void increaseUsageCount()
Increase the usage count of this resource and also update the last used date to the current date and ...
Nepomuk::Resource::addTopic
void addTopic(const Resource &value)
Add a value to property 'Topic'.
Nepomuk::Resource::setIsRelateds
void setIsRelateds(const QList< Resource > &value)
Set property 'isRelated'.
Nepomuk::Resource::hasType
bool hasType(const QUrl &typeUri) const
Check if the resource is of a certain type.
Nepomuk::Resource::setAltLabels
void setAltLabels(const QStringList &value)
Set property 'altLabel'.
Nepomuk::Resource::setIsTopicOfs
void setIsTopicOfs(const QList< Resource > &value)
Set property 'isTopicOf'.
Nepomuk::Resource::genericIcon
QString genericIcon() const
Tries very hard to find an icon suitable for this resource.
Nepomuk::Resource::topicUri
static QString topicUri()
Nepomuk::Resource::operator==
bool operator==(const Resource &) const
Operator to compare two Resource objects.
Nepomuk::Resource::exists
bool exists() const
Nepomuk::Resource::setSymbols
void setSymbols(const QStringList &value)
Set property 'Symbol'.
Nepomuk::Resource::addIdentifier
void addIdentifier(const QString &value)
Add a value to property 'identifier'.
Nepomuk::Resource::tagUri
static QString tagUri()
Nepomuk::Resource::properties
QHash< QUrl, Variant > properties() const
Nepomuk::Resource::topics
QList< Resource > topics() const
Get property 'Topic'.
Nepomuk::Resource::annotations
QList< Resource > annotations() const
Get property 'annotation'.
Nepomuk::Resource::hasProperty
bool hasProperty(const Types::Property &p, const Variant &v) const
Check if the resource has a property p with value v.
Nepomuk::Resource::symbols
QStringList symbols() const
Get property 'Symbol'.
Nepomuk::Resource::Resource
Resource(const QUrl &uri, const QUrl &type=QUrl())
Creates a new Resource object.
Nepomuk::Resource::className
QString className() const
The name of the class this Resource represents an object of.
Nepomuk::Resource::resourceUri
QUrl resourceUri() const
The URI of the resource, uniquely identifying it.
Nepomuk::Resource::removeProperty
void removeProperty(const QUrl &uri)
Remove property uri from this resource object.
Nepomuk::Resource::Resource
Resource(ResourceData *)
Constructor used internally.
Nepomuk::Resource::symbolUri
static QString symbolUri()
Nepomuk::Resource::setLabel
void setLabel(const QString &value)
Set property 'label'.
Nepomuk::Resource::removeProperty
void removeProperty(const QString &uri)
Nepomuk::Resource::operator=
Resource & operator=(const QUrl &uri)
Same as operator=( Resource( uri ) )
Nepomuk::Tag
A Tag can be assigned to any Thing.
Definition: tag.h:39
Nepomuk::Thing
A Nepomuk PIMO Thing resource.
Definition: thing.h:58
Nepomuk::Types::Class
A Class is a resource of type rdf:Class.
Definition: class.h:50
Nepomuk::Types::Property
A property is a resource of type rdf:Property which relates a domain with a range.
Definition: property.h:53
Nepomuk::Variant
The Nepomuk Variant extends over QVariant by introducing direct support for Resource embedding,...
Definition: variant.h:66
class.h
Nepomuk
Nepomuk::ErrorCode
ErrorCode
Definition: resource.h:45
Nepomuk::CommunicationError
@ CommunicationError
A communication error, i.e.
Definition: resource.h:47
Nepomuk::UnknownError
@ UnknownError
Definition: resource.h:49
Nepomuk::InvalidType
@ InvalidType
Definition: resource.h:48
Nepomuk::NoError
@ NoError
Definition: resource.h:46
Nepomuk::qHash
uint qHash(const Resource &res)
Nepomuk::errorString
QString errorString(ErrorCode code)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk

Skip menu "Nepomuk"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal