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

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • libnepomukcore
  • resource
resource.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Nepomuk KDE project.
3  * Copyright (C) 2006-2010 Sebastian Trueg <trueg@kde.org>
4  * Copyright (C) 2012 Vishesh Handa <me@vhanda.in>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #include "resource.h"
23 #include "resourcedata.h"
24 #include "resourcemanager.h"
25 #include "resourcemanager_p.h"
26 #include "tools.h"
27 #include "tag.h"
28 #include "pimo.h"
29 #include "file.h"
30 #include "property.h"
31 #include "nfo.h"
32 #include "nie.h"
33 #include "nco.h"
34 #include "nuao.h"
35 
36 #include "klocale.h"
37 #include "kdebug.h"
38 #include "kurl.h"
39 #include "kmimetype.h"
40 
41 #include <Soprano/Vocabulary/NAO>
42 #include <Soprano/Vocabulary/RDFS>
43 #include <Soprano/Vocabulary/RDF>
44 #include <Soprano/Model>
45 #include <Soprano/QueryResultIterator>
46 #include <Soprano/StatementIterator>
47 #include <Soprano/NodeIterator>
48 
49 using namespace Nepomuk2::Vocabulary;
50 using namespace Soprano::Vocabulary;
51 
52 Nepomuk2::Resource::Resource()
53 {
54  ResourceManager* rm = ResourceManager::instance();
55  if( rm ) {
56  QMutexLocker lock( &rm->d->mutex );
57  m_data = rm->d->data( QUrl(), QUrl() );
58  if ( m_data )
59  m_data->ref( this );
60  }
61  else {
62  kError() << "QCoreApplication does not exist. Resource cannot be initalialized";
63  }
64 }
65 
66 
67 Nepomuk2::Resource::Resource( const Nepomuk2::Resource& res )
68 {
69  ResourceManager* rm = ResourceManager::instance();
70  if( rm ) {
71  QMutexLocker lock( &rm->d->mutex );
72  m_data = res.m_data;
73  if ( m_data )
74  m_data->ref( this );
75  }
76  else {
77  kError() << "QCoreApplication does not exist. Resource cannot be initalialized";
78  }
79 }
80 
81 
82 Nepomuk2::Resource::Resource( const QString& uri, const QUrl& type )
83 {
84  ResourceManager* rm = ResourceManager::instance();
85  if( rm ) {
86  QMutexLocker lock( &rm->d->mutex );
87  m_data = rm->d->data( uri, type );
88  if ( m_data )
89  m_data->ref( this );
90  }
91  else {
92  kError() << "QCoreApplication does not exist. Resource cannot be initalialized";
93  }
94 }
95 
96 
97 Nepomuk2::Resource::Resource( const QUrl& uri, const QUrl& type )
98 {
99  ResourceManager* rm = ResourceManager::instance();
100  if( rm ) {
101  QMutexLocker lock( &rm->d->mutex );
102  m_data = rm->d->data( uri, type );
103  if ( m_data )
104  m_data->ref( this );
105  }
106  else {
107  kError() << "QCoreApplication does not exist. Resource cannot be initalialized";
108  }
109 }
110 
111 
112 
113 Nepomuk2::Resource::Resource( Nepomuk2::ResourceData* data )
114 {
115  ResourceManager* rm = ResourceManager::instance();
116  if( rm ) {
117  QMutexLocker lock( &rm->d->mutex );
118  m_data = data;
119  if ( m_data )
120  m_data->ref( this );
121  }
122 }
123 
124 
125 Nepomuk2::Resource::~Resource()
126 {
127  if ( m_data ) {
128  ResourceManager* rm = ResourceManager::instance();
129  if ( rm ) {
130  // It is possible that this resource is hanging around
131  // after the ResourceManager has been deleted
132  QMutexLocker lock( &rm->d->mutex );
133  m_data->deref( this );
134  if ( m_data->rm()->shouldBeDeleted( m_data ) )
135  delete m_data;
136  }
137  }
138 }
139 
140 
141 Nepomuk2::Resource& Nepomuk2::Resource::operator=( const Resource& res )
142 {
143  if( m_data != res.m_data ) {
144  ResourceManager* rm = ResourceManager::instance();
145  if ( rm ) {
146  QMutexLocker lock( &rm->d->mutex );
147  if ( m_data && !m_data->deref( this ) && m_data->rm()->shouldBeDeleted( m_data ) ) {
148  delete m_data;
149  }
150  m_data = res.m_data;
151  if ( m_data )
152  m_data->ref( this );
153  }
154  }
155 
156  return *this;
157 }
158 
159 
160 Nepomuk2::Resource& Nepomuk2::Resource::operator=( const QUrl& res )
161 {
162  return operator=( Resource( res ) );
163 }
164 
165 
166 QUrl Nepomuk2::Resource::uri() const
167 {
168  if ( m_data ) {
169  determineFinalResourceData();
170  return m_data->uri();
171  }
172  else {
173  return QUrl();
174  }
175 }
176 
177 
178 QUrl Nepomuk2::Resource::type() const
179 {
180  determineFinalResourceData();
181  if ( m_data ) {
182  return m_data->type();
183  }
184  else {
185  return QUrl();
186  }
187 }
188 
189 
190 QList<QUrl> Nepomuk2::Resource::types() const
191 {
192  determineFinalResourceData();
193  if ( m_data ) {
194  return m_data->property( RDF::type() ).toUrlList();
195  }
196  return QList<QUrl>();
197 }
198 
199 
200 void Nepomuk2::Resource::setTypes( const QList<QUrl>& types )
201 {
202  determineFinalResourceData();
203  if ( m_data ) {
204  m_data->setProperty( RDF::type(), types );
205  }
206 }
207 
208 
209 void Nepomuk2::Resource::addType( const QUrl& type )
210 {
211  determineFinalResourceData();
212  if ( m_data ) {
213  m_data->addProperty( RDF::type(), type );
214  }
215 }
216 
217 
218 bool Nepomuk2::Resource::hasType( const QUrl& typeUri ) const
219 {
220  determineFinalResourceData();
221  if ( m_data ) {
222  return m_data->hasProperty( RDF::type(), typeUri );
223  }
224  else {
225  return false;
226  }
227 }
228 
229 
230 QHash<QUrl, Nepomuk2::Variant> Nepomuk2::Resource::properties() const
231 {
232  determineFinalResourceData();
233  if ( m_data ) {
234  return m_data->allProperties();
235  }
236  return QHash<QUrl, Nepomuk2::Variant> ();
237 }
238 
239 
240 bool Nepomuk2::Resource::hasProperty( const QUrl& uri ) const
241 {
242  determineFinalResourceData();
243  if ( m_data ) {
244  return m_data->hasProperty( uri );
245  }
246  else {
247  return false;
248  }
249 }
250 
251 
252 bool Nepomuk2::Resource::hasProperty( const Types::Property& p, const Variant& v ) const
253 {
254  determineFinalResourceData();
255  if ( m_data ) {
256  return m_data->hasProperty( p.uri(), v );
257  }
258  else {
259  return false;
260  }
261 }
262 
263 
264 Nepomuk2::Variant Nepomuk2::Resource::property( const QUrl& uri ) const
265 {
266  determineFinalResourceData();
267  if ( m_data ) {
268  return m_data->property( uri );
269  }
270  else {
271  return Nepomuk2::Variant();
272  }
273 }
274 
275 
276 void Nepomuk2::Resource::addProperty( const QUrl& uri, const Variant& value )
277 {
278  determineFinalResourceData();
279  if ( m_data ) {
280  m_data->addProperty( uri, value );
281  }
282 }
283 
284 
285 void Nepomuk2::Resource::setProperty( const QUrl& uri, const Nepomuk2::Variant& value )
286 {
287  determineFinalResourceData();
288  if ( m_data ) {
289  m_data->setProperty( uri, value );
290  }
291 }
292 
293 
294 void Nepomuk2::Resource::removeProperty( const QUrl& uri )
295 {
296  determineFinalResourceData();
297  if ( m_data ) {
298  m_data->removeProperty( uri );
299  }
300 }
301 
302 
303 void Nepomuk2::Resource::removeProperty( const QUrl& uri, const Variant& value )
304 {
305  QList<Variant> vl = property( uri ).toVariantList();
306  foreach( const Variant& v, value.toVariantList() ) {
307  vl.removeAll( v );
308  }
309  setProperty( uri, Variant( vl ) );
310 }
311 
312 
313 void Nepomuk2::Resource::remove()
314 {
315  determineFinalResourceData();
316  if ( m_data ) {
317  m_data->remove();
318  }
319 }
320 
321 
322 bool Nepomuk2::Resource::exists() const
323 {
324  determineFinalResourceData();
325  if ( m_data ) {
326  return m_data->exists();
327  }
328  else {
329  return false;
330  }
331 }
332 
333 
334 bool Nepomuk2::Resource::isValid() const
335 {
336  return m_data ? m_data->isValid() : false;
337 }
338 
339 
340 // TODO: cache this one in ResourceData
341 QString Nepomuk2::Resource::genericLabel() const
342 {
343  QString label = this->label();
344  if(!label.isEmpty())
345  return label;
346 
347  label = property( Soprano::Vocabulary::RDFS::label() ).toString();
348  if(!label.isEmpty())
349  return label;
350 
351  label = property( Nepomuk2::Vocabulary::NIE::title() ).toString();
352  if(!label.isEmpty())
353  return label;
354 
355  label = property( Nepomuk2::Vocabulary::NCO::fullname() ).toString();
356  if(!label.isEmpty())
357  return label;
358 
359  label = property( Soprano::Vocabulary::NAO::identifier() ).toString();
360  if(!label.isEmpty())
361  return label;
362 
363  //label = m_data->pimoThing().label();
364  //if(!label.isEmpty())
365  // return label;
366 
367  label = property( Nepomuk2::Vocabulary::NFO::fileName() ).toString();
368  if(!label.isEmpty())
369  return label;
370 
371  const KUrl nieUrl = property( Nepomuk2::Vocabulary::NIE::url() ).toUrl();
372  if(!nieUrl.isEmpty()) {
373  if(nieUrl.isLocalFile())
374  return nieUrl.fileName();
375  else
376  return nieUrl.prettyUrl();
377  }
378 
379  QList<Resource> go = property( Vocabulary::PIMO::groundingOccurrence() ).toResourceList();
380  if( !go.isEmpty() ) {
381  label = go.first().genericLabel();
382  if( label != KUrl(go.first().uri()).pathOrUrl() ) {
383  return label;
384  }
385  }
386 
387  QString hashValue = property( Vocabulary::NFO::hashValue() ).toString();
388  if( !hashValue.isEmpty() )
389  return hashValue;
390 
391  // ugly fallback
392  return KUrl(uri()).pathOrUrl();
393 }
394 
395 
396 QString Nepomuk2::Resource::genericDescription() const
397 {
398  QString s = property( Soprano::Vocabulary::NAO::description() ).toString();
399  if ( !s.isEmpty() ) {
400  return s;
401  }
402 
403  s = property( Soprano::Vocabulary::RDFS::comment() ).toString();
404 
405  return s;
406 }
407 
408 
409 QString Nepomuk2::Resource::genericIcon() const
410 {
411  if( hasType(NAO::FreeDesktopIcon()) ) {
412  QString label = property(NAO::iconName()).toString();
413  if( !label.isEmpty() )
414  return label;
415 
416  label = property(NAO::prefLabel()).toString();
417  if( !label.isEmpty() )
418  return label;
419  }
420 
421  // Symbol Resources
422  Variant symbol = property( NAO::hasSymbol() );
423  if( symbol.isResource() ) {
424  QString icon = symbol.toResource().genericIcon();
425  if(!icon.isEmpty())
426  return icon;
427  }
428  else if( symbol.isString() ) {
429  // Backward compatibiltiy
430  QString icon = symbol.toString();
431  if( !icon.isEmpty() )
432  return icon;
433  }
434 
435  // FIXME: NAO::prefSymbol is a sub-property of nao:hasSymbol, it should be auto detected
436  symbol = property( NAO::prefSymbol() );
437  if( symbol.isResource() ) {
438  QString icon = symbol.toResource().genericIcon();
439  if(!icon.isEmpty())
440  return icon;
441  }
442  else if( symbol.isString() ) {
443  // Backward compatibiltiy
444  QString icon = symbol.toString();
445  if( !icon.isEmpty() )
446  return icon;
447  }
448 
449  QString mimeType = property( NIE::mimeType() ).toString();
450  if( !mimeType.isEmpty() ) {
451  if( KMimeType::Ptr m = KMimeType::mimeType( mimeType ) )
452  return m->iconName();
453  }
454 
455  return QString();
456 }
457 
458 
459 bool Nepomuk2::Resource::operator==( const Resource& other ) const
460 {
461  if( this == &other )
462  return true;
463 
464  if( this->m_data == other.m_data )
465  return true;
466 
467  if ( !m_data || !other.m_data ) {
468  return false;
469  }
470 
471  // get the resource URIs since two different ResourceData instances
472  // can still represent the same Resource
473  determineFinalResourceData();
474  other.determineFinalResourceData();
475 
476  if( m_data->uri().isEmpty() )
477  return *m_data == *other.m_data;
478  else
479  return uri() == other.uri();
480 }
481 
482 
483 bool Nepomuk2::Resource::operator!=( const Resource& other ) const
484 {
485  return !operator==( other );
486 }
487 
488 
489 QString Nepomuk2::errorString( ErrorCode code )
490 {
491  switch( code ) {
492  case NoError:
493  return i18n("Success");
494  case CommunicationError:
495  return i18n("Communication error");
496  case InvalidType:
497  return i18n("Invalid type in Database");
498  default:
499  return i18n("Unknown error");
500  }
501 }
502 
503 
504 QString Nepomuk2::Resource::description() const
505 {
506  return ( property( Soprano::Vocabulary::NAO::description() ).toStringList() << QString() ).first();
507 }
508 
509 
510 void Nepomuk2::Resource::setDescription( const QString& value )
511 {
512  setProperty( Soprano::Vocabulary::NAO::description(), Variant( value ) );
513 }
514 
515 
516 QStringList Nepomuk2::Resource::identifiers() const
517 {
518  return property( Soprano::Vocabulary::NAO::identifier() ).toStringList();
519 }
520 
521 
522 void Nepomuk2::Resource::setIdentifiers( const QStringList& value )
523 {
524  setProperty( Soprano::Vocabulary::NAO::identifier(), Variant( value ) );
525 }
526 
527 
528 void Nepomuk2::Resource::addIdentifier( const QString& value )
529 {
530  addProperty( Soprano::Vocabulary::NAO::identifier(), Variant( value ) );
531 }
532 
533 
534 QList<Nepomuk2::Tag> Nepomuk2::Resource::tags() const
535 {
536  // We always store all Resource types as plain Resource objects.
537  // It does not introduce any overhead (due to the implicit sharing of
538  // the data and has the advantage that we can mix setProperty calls
539  // with the special Resource subclass methods.
540  // More importantly Resource loads the data as Resource objects anyway.
541  return convertResourceList<Tag>( property( Soprano::Vocabulary::NAO::hasTag() ).toResourceList() );
542 }
543 
544 
545 void Nepomuk2::Resource::setTags( const QList<Nepomuk2::Tag>& value )
546 {
547  // We always store all Resource types as plain Resource objects.
548  // It does not introduce any overhead (due to the implicit sharing of
549  // the data and has the advantage that we can mix setProperty calls
550  // with the special Resource subclass methods.
551  // More importantly Resource loads the data as Resource objects anyway.
552  QList<Resource> l;
553  for( QList<Tag>::const_iterator it = value.constBegin();
554  it != value.constEnd(); ++it ) {
555  l.append( Resource( (*it) ) );
556  }
557  setProperty( Soprano::Vocabulary::NAO::hasTag(), Variant( l ) );
558 }
559 
560 
561 void Nepomuk2::Resource::addTag( const Nepomuk2::Tag& value )
562 {
563  // We always store all Resource types as plain Resource objects.
564  // It does not introduce any overhead (due to the implicit sharing of
565  // the data and has the advantage that we can mix setProperty calls
566  // with the special Resource subclass methods.
567  // More importantly Resource loads the data as Resource objects anyway.
568  addProperty( Soprano::Vocabulary::NAO::hasTag(), Resource(value) );
569 }
570 
571 
572 QList<Nepomuk2::Resource> Nepomuk2::Resource::isRelateds() const
573 {
574  // We always store all Resource types as plain Resource objects.
575  // It does not introduce any overhead (due to the implicit sharing of
576  // the data and has the advantage that we can mix setProperty calls
577  // with the special Resource subclass methods.
578  // More importantly Resource loads the data as Resource objects anyway.
579  return property( Soprano::Vocabulary::NAO::isRelated() ).toResourceList();
580 }
581 
582 
583 void Nepomuk2::Resource::setIsRelateds( const QList<Nepomuk2::Resource>& value )
584 {
585  setProperty( Soprano::Vocabulary::NAO::isRelated(), Variant( value ) );
586 }
587 
588 
589 void Nepomuk2::Resource::addIsRelated( const Nepomuk2::Resource& value )
590 {
591  // We always store all Resource types as plain Resource objects.
592  // It does not introduce any overhead (due to the implicit sharing of
593  // the data and has the advantage that we can mix setProperty calls
594  // with the special Resource subclass methods.
595  // More importantly Resource loads the data as Resource objects anyway.
596  addProperty( Soprano::Vocabulary::NAO::isRelated(), Resource(value) );
597 }
598 
599 
600 QString Nepomuk2::Resource::label() const
601 {
602  return ( property( Soprano::Vocabulary::NAO::prefLabel() ).toStringList() << QString() ).first();
603 }
604 
605 
606 void Nepomuk2::Resource::setLabel( const QString& value )
607 {
608  setProperty( Soprano::Vocabulary::NAO::prefLabel(), Variant( value ) );
609 }
610 
611 
612 quint32 Nepomuk2::Resource::rating() const
613 {
614  return ( property( Soprano::Vocabulary::NAO::numericRating() ).toUnsignedIntList() << 0 ).first();
615 }
616 
617 
618 void Nepomuk2::Resource::setRating( const quint32& value )
619 {
620  setProperty( Soprano::Vocabulary::NAO::numericRating(), Variant( value ) );
621 }
622 
623 QStringList Nepomuk2::Resource::symbols() const
624 {
625  QList<Resource> symbolResources = property( Soprano::Vocabulary::NAO::hasSymbol() ).toResourceList();
626 
627  QStringList symbolStrings;
628  foreach(const Resource& symbolRes, symbolResources ) {
629  symbolStrings << symbolRes.label();
630  }
631 
632  return symbolStrings;
633 }
634 
635 namespace {
636  QUrl uriForSymbolName(const QString& symbolName) {
637  // Check if it exists
638  // We aren't using Soprano::Node::literalToN3 cause prefLabel has a range of a literal not
639  // of a string
640  QString query = QString::fromLatin1("select ?r where { ?r a %1 . ?r %2 \"%3\" . } LIMIT 1")
641  .arg( Soprano::Node::resourceToN3(Soprano::Vocabulary::NAO::FreeDesktopIcon()),
642  Soprano::Node::resourceToN3(Soprano::Vocabulary::NAO::iconName()),
643  symbolName );
644 
645  Soprano::Model* model = Nepomuk2::ResourceManager::instance()->mainModel();
646  Soprano::QueryResultIterator it = model->executeQuery( query, Soprano::Query::QueryLanguageSparql );
647  if( it.next() ) {
648  return it["r"].uri();
649  }
650  else {
651  Nepomuk2::Resource res(QUrl(), Soprano::Vocabulary::NAO::FreeDesktopIcon());
652  res.setProperty( NAO::iconName(), symbolName );
653 
654  return res.uri();
655  }
656  }
657 }
658 
659 void Nepomuk2::Resource::setSymbols( const QStringList& value )
660 {
661  QList<QUrl> symbolList;
662  foreach( const QString& symbolName, value ) {
663  symbolList << uriForSymbolName(symbolName);
664  }
665 
666  setProperty( Soprano::Vocabulary::NAO::hasSymbol(), Variant(symbolList) );
667 }
668 
669 
670 void Nepomuk2::Resource::addSymbol( const QString& value )
671 {
672  addProperty( Soprano::Vocabulary::NAO::hasSymbol(), uriForSymbolName(value) );
673 }
674 
675 
676 QList<Nepomuk2::Resource> Nepomuk2::Resource::isRelatedOf() const
677 {
678  Soprano::Model* model = ResourceManager::instance()->mainModel();
679  QList<Soprano::Node> list = model->listStatements( Soprano::Node(), NAO::isRelated(), uri() ).iterateSubjects().allNodes();
680  QList<Nepomuk2::Resource> resources;
681  foreach(const Soprano::Node& node, list)
682  resources << node.uri();
683  return resources;
684 }
685 
686 
687 int Nepomuk2::Resource::usageCount() const
688 {
689  return property( Vocabulary::NUAO::usageCount() ).toInt();
690 }
691 
692 
693 void Nepomuk2::Resource::increaseUsageCount()
694 {
695  int cnt = 0;
696  const QDateTime now = QDateTime::currentDateTime();
697  if( hasProperty( Vocabulary::NUAO::usageCount() ) )
698  cnt = property( Vocabulary::NUAO::usageCount() ).toInt();
699  else
700  setProperty( Vocabulary::NUAO::firstUsage(), now );
701  ++cnt;
702  setProperty( Vocabulary::NUAO::usageCount(), cnt );
703  setProperty( Vocabulary::NUAO::lastUsage(), now );
704 }
705 
706 
707 bool Nepomuk2::Resource::isFile() const
708 {
709  if( m_data ) {
710  determineFinalResourceData();
711  m_data->load();
712  return m_data->isFile();
713  }
714  else {
715  return false;
716  }
717 }
718 
719 
720 Nepomuk2::File Nepomuk2::Resource::toFile() const
721 {
722  return File( *this );
723 }
724 
725 void Nepomuk2::Resource::setWatchEnabled(bool status)
726 {
727  determineFinalResourceData();
728  if( m_data )
729  return m_data->setWatchEnabled( status );
730 }
731 
732 bool Nepomuk2::Resource::watchEnabled()
733 {
734  determineFinalResourceData();
735  if( m_data )
736  return m_data->watchEnabled();
737 
738  return false;
739 }
740 
741 
742 // static
743 Nepomuk2::Resource Nepomuk2::Resource::fromResourceUri( const KUrl& uri, const Nepomuk2::Types::Class& type )
744 {
745  ResourceManager* manager = ResourceManager::instance();
746  QMutexLocker lock( &manager->d->mutex );
747  return Resource( manager->d->dataForResourceUri( uri, type.uri() ) );
748 }
749 
750 
751 void Nepomuk2::Resource::determineFinalResourceData() const
752 {
753  if (!m_data || !m_data->uri().isEmpty()) {
754  return;
755  }
756 
757  // Get an initialized ResourceData instance
758  ResourceData* oldData = m_data;
759 
760  m_data->determineUri(); // note that this can change the value of m_data
761 
762  if ( !oldData->cnt() )
763  delete oldData;
764 }
765 
766 
767 uint Nepomuk2::qHash( const Resource& res )
768 {
769  return qHash(res.uri());
770 }
Nepomuk2::Resource::remove
void remove()
Remove this resource completely.
Definition: resource.cpp:313
tag.h
Nepomuk2::ErrorCode
ErrorCode
Definition: resource.h:44
Nepomuk2::Resource::label
QString label() const
Get property 'label'.
Definition: resource.cpp:600
Nepomuk2::Resource::addType
void addType(const QUrl &type)
Add a type to the list of types.
Definition: resource.cpp:209
Nepomuk2::Resource::types
QList< QUrl > types() const
Definition: resource.cpp:190
Nepomuk2::Resource::setProperty
void setProperty(const QUrl &uri, const Variant &value)
Set a property of the resource.
Definition: resource.cpp:285
Nepomuk2::Resource::hasType
bool hasType(const QUrl &typeUri) const
Check if the resource is of a certain type.
Definition: resource.cpp:218
Nepomuk2::Resource::operator=
Resource & operator=(const Resource &other)
Makes this instance of Resource a copy of other.
Definition: resource.cpp:141
Nepomuk2::addProperty
KJob * addProperty(const QList< QUrl > &resources, const QUrl &property, const QVariantList &values, const KComponentData &component=KGlobal::mainComponent())
Add one or more property values to one or more resources.
Definition: datamanagement.cpp:36
Nepomuk2::Types::Entity::uri
QUrl uri() const
The URI of the resource.
Definition: entity.cpp:175
Nepomuk2::Resource::setLabel
void setLabel(const QString &value)
Set property 'label'.
Definition: resource.cpp:606
Nepomuk2::Resource::addIdentifier
void addIdentifier(const QString &value)
Add a value to property 'identifier'.
Definition: resource.cpp:528
Nepomuk2::Resource::addSymbol
void addSymbol(const QString &value)
Add a value to property 'Symbol'.
Definition: resource.cpp:670
Nepomuk2::Resource::exists
bool exists() const
Definition: resource.cpp:322
Nepomuk2::Resource::genericDescription
QString genericDescription() const
Tries very hard to find a suitable human-readable description of the resource.
Definition: resource.cpp:396
Nepomuk2::Resource::type
QUrl type() const
The main type of the resource.
Definition: resource.cpp:178
Nepomuk2::Resource::isRelateds
QList< Resource > isRelateds() const
Get property 'isRelated'.
Definition: resource.cpp:572
Nepomuk2::Resource::hasProperty
bool hasProperty(const QUrl &uri) const
Check if property identified by uri is defined for this resource.
Definition: resource.cpp:240
QHash
file.h
Nepomuk2::NoError
Definition: resource.h:45
Nepomuk2::Resource::identifiers
QStringList identifiers() const
Get property 'identifier'.
Definition: resource.cpp:516
Nepomuk2::Resource::isValid
bool isValid() const
Definition: resource.cpp:334
Nepomuk2::Tag
A Tag can be assigned to any Thing.
Definition: tag.h:38
Nepomuk2::Resource::setTags
void setTags(const QList< Tag > &value)
Set property 'Tag'.
Definition: resource.cpp:545
Nepomuk2::InvalidType
Definition: resource.h:47
Nepomuk2::errorString
QString errorString(ErrorCode code)
Definition: resource.cpp:489
Nepomuk2::Resource::genericIcon
QString genericIcon() const
Tries very hard to find an icon suitable for this resource.
Definition: resource.cpp:409
Nepomuk2::Variant::toVariantList
QList< Variant > toVariantList() const
Convert a Variant to a list of Variants.
Definition: variant.cpp:1173
Nepomuk2::Resource::increaseUsageCount
void increaseUsageCount()
Increase the usage count of this resource and also update the last used date to the current date and ...
Definition: resource.cpp:693
Nepomuk2::Resource::addTag
void addTag(const Tag &value)
Add a value to property 'Tag'.
Definition: resource.cpp:561
Nepomuk2::Variant
The Nepomuk Variant extends over QVariant by introducing direct support for Resource embedding...
Definition: variant.h:65
Nepomuk2::Resource::setIsRelateds
void setIsRelateds(const QList< Resource > &value)
Set property 'isRelated'.
Definition: resource.cpp:583
Nepomuk2::Variant::toResource
Resource toResource() const
Convert into a Resource value.
Definition: variant.cpp:908
Nepomuk2::Resource::properties
QHash< QUrl, Variant > properties() const
Definition: resource.cpp:230
Nepomuk2::Resource::property
Variant property(const QUrl &uri) const
Retrieve the value of property uri.
Definition: resource.cpp:264
Nepomuk2::Resource::setWatchEnabled
void setWatchEnabled(bool status)
Enables automatic updates of the internal cache using a ResourceWatcher.
Definition: resource.cpp:725
Nepomuk2::Resource::toFile
File toFile() const
Convert this resource into a File resource to have access to the convinience methods provided by the ...
Definition: resource.cpp:720
Nepomuk2::Types::Class
A Class is a resource of type rdf:Class.
Definition: class.h:49
resource.h
Nepomuk2::Resource::rating
quint32 rating() const
Get property 'Rating'.
Definition: resource.cpp:612
Nepomuk2::Resource::~Resource
virtual ~Resource()
Destructor.
Definition: resource.cpp:125
Nepomuk2::Types::Property
A property is a resource of type rdf:Property which relates a domain with a range.
Definition: libnepomukcore/types/property.h:52
Nepomuk2::ResourceManager::instance
static ResourceManager * instance()
Definition: resourcemanager.cpp:270
Nepomuk2::Resource::fromResourceUri
static Resource fromResourceUri(const KUrl &uri, const Nepomuk2::Types::Class &type=Nepomuk2::Types::Class())
Allows to quickly load a resource from its resource URI without any additional checks.
Definition: resource.cpp:743
resourcemanager.h
Nepomuk2::Resource::genericLabel
QString genericLabel() const
Tries very hard to find a suitable human-readable label for this resource.
Definition: resource.cpp:341
Nepomuk2::Resource::setRating
void setRating(const quint32 &value)
Set property 'Rating'.
Definition: resource.cpp:618
Nepomuk2::CommunicationError
A communication error, i.e.
Definition: resource.h:46
resourcedata.h
Nepomuk2::Resource::tags
QList< Tag > tags() const
Get property 'Tag'.
Definition: resource.cpp:534
Nepomuk2::Resource::operator==
bool operator==(const Resource &) const
Operator to compare two Resource objects.
Definition: resource.cpp:459
Nepomuk2::Resource::isFile
bool isFile() const
Definition: resource.cpp:707
Nepomuk2::Resource::addIsRelated
void addIsRelated(const Resource &value)
Add a value to property 'isRelated'.
Definition: resource.cpp:589
Nepomuk2::Resource::setDescription
void setDescription(const QString &value)
Set property 'description'.
Definition: resource.cpp:510
Nepomuk2::ResourceManager
The ResourceManager is the central Nepomuk configuration point.
Definition: resourcemanager.h:55
Nepomuk2::Resource::removeProperty
void removeProperty(const QUrl &uri)
Remove property uri from this resource object.
Definition: resource.cpp:294
Nepomuk2::Resource::operator!=
bool operator!=(const Resource &) const
Operator to compare two Resource objects.
Definition: resource.cpp:483
Nepomuk2::Resource::symbols
QStringList symbols() const
Get property 'Symbol'.
Definition: resource.cpp:623
Nepomuk2::qHash
uint qHash(const SimpleResource &res)
Definition: simpleresource.cpp:297
Nepomuk2::File
A Nepomuk resource representing a file.
Definition: file.h:41
Nepomuk2::Resource::Resource
Resource()
Creates an empty invalid Resource.
Definition: resource.cpp:52
Nepomuk2::Variant::isString
bool isString() const
Definition: variant.cpp:644
tools.h
Nepomuk2::setProperty
KJob * setProperty(const QList< QUrl > &resources, const QUrl &property, const QVariantList &values, const KComponentData &component=KGlobal::mainComponent())
Set the values of a property for one or more resources.
Definition: datamanagement.cpp:48
Nepomuk2::Resource::setIdentifiers
void setIdentifiers(const QStringList &value)
Set property 'identifier'.
Definition: resource.cpp:522
Nepomuk2::Variant::toString
QString toString() const
The toString() method is a little more powerful than other toXXX methods since it actually converts a...
Definition: variant.cpp:827
Nepomuk2::Resource
Resource is the central object type in Nepomuk.
Definition: resource.h:93
Nepomuk2::Variant::isResource
bool isResource() const
Definition: variant.cpp:674
Nepomuk2::Resource::usageCount
int usageCount() const
Definition: resource.cpp:687
Nepomuk2::Resource::uri
QUrl uri() const
The URI of the resource, uniquely identifying it.
Definition: resource.cpp:166
Nepomuk2::Resource::setSymbols
void setSymbols(const QStringList &value)
Set property 'Symbol'.
Definition: resource.cpp:659
Nepomuk2::Resource::setTypes
void setTypes(const QList< QUrl > &types)
Set the types of the resource.
Definition: resource.cpp:200
Nepomuk2::ResourceManager::mainModel
Soprano::Model * mainModel()
Retrieve the main data storage model.
Definition: resourcemanager.cpp:363
Nepomuk2::ResourceData::ref
bool ref(Nepomuk2::Resource *res)
Definition: resourcedata.h:48
Nepomuk2::Resource::watchEnabled
bool watchEnabled()
Definition: resource.cpp:732
Nepomuk2::Resource::isRelatedOf
QList< Resource > isRelatedOf() const
Get all resources that have this resource set as property 'isRelated'.
Definition: resource.cpp:676
Nepomuk2::Resource::addProperty
void addProperty(const QUrl &uri, const Variant &value)
Add a property value to the existing values.
Definition: resource.cpp:276
Nepomuk2::ResourceData
Definition: resourcedata.h:42
Nepomuk2::Resource::description
QString description() const
Get property 'description'.
Definition: resource.cpp:504
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

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

kdelibs API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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