• 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
variant.cpp
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 #include "variant.h"
22 #include "resource.h"
23 #include "tools.h"
24 
25 #include <soprano/literalvalue.h>
26 #include <soprano/node.h>
27 
28 #include <kdebug.h>
29 
30 #include <QtCore/QVariant>
31 
32 
33 namespace {
34  template<typename T1, typename T2> QList<T2> convertList( const QList<T1>& l ) {
35  QList<T2> il;
36  for( int i = 0; i < l.count(); ++i ) {
37  il.append( static_cast<T2>( l[i] ) );
38  }
39  return il;
40  }
41 }
42 
43 
44 class Nepomuk2::Variant::Private
45 {
46 public:
47  QVariant value;
48 };
49 
50 
51 Nepomuk2::Variant::Variant()
52  : d( new Private )
53 {
54 }
55 
56 
57 Nepomuk2::Variant::~Variant()
58 {
59  delete d;
60 }
61 
62 
63 Nepomuk2::Variant::Variant( const Variant& other )
64  : d( new Private )
65 {
66  operator=( other );
67 }
68 
69 
70 Nepomuk2::Variant::Variant( const QVariant& other )
71  : d( new Private )
72 {
73  if ( other.userType() == QVariant::Int ||
74  other.userType() == QVariant::LongLong ||
75  other.userType() == QVariant::UInt ||
76  other.userType() == QVariant::ULongLong ||
77  other.userType() == QVariant::Bool ||
78  other.userType() == QVariant::Double ||
79  other.userType() == QVariant::String ||
80  other.userType() == QVariant::Date ||
81  other.userType() == QVariant::Time ||
82  other.userType() == QVariant::DateTime ||
83  other.userType() == QVariant::Url ||
84  other.userType() == qMetaTypeId<Resource>() ||
85  other.userType() == qMetaTypeId<QList<int> >() ||
86  other.userType() == qMetaTypeId<QList<qlonglong> >() ||
87  other.userType() == qMetaTypeId<QList<uint> >() ||
88  other.userType() == qMetaTypeId<QList<qulonglong> >() ||
89  other.userType() == qMetaTypeId<QList<bool> >() ||
90  other.userType() == qMetaTypeId<QList<double> >() ||
91  other.userType() == QVariant::StringList ||
92  other.userType() == qMetaTypeId<QList<QDate> >() ||
93  other.userType() == qMetaTypeId<QList<QTime> >() ||
94  other.userType() == qMetaTypeId<QList<QDateTime> >() ||
95  other.userType() == qMetaTypeId<QList<QUrl> >() ||
96  other.userType() == qMetaTypeId<QList<Resource> >() ) {
97  d->value = other;
98  }
99 }
100 
101 
102 Nepomuk2::Variant::Variant( int i )
103  : d( new Private )
104 {
105  d->value.setValue( i );
106 }
107 
108 
109 Nepomuk2::Variant::Variant( qlonglong i )
110  : d( new Private )
111 {
112  d->value.setValue( i );
113 }
114 
115 
116 Nepomuk2::Variant::Variant( uint i )
117  : d( new Private )
118 {
119  d->value.setValue( i );
120 }
121 
122 
123 Nepomuk2::Variant::Variant( qulonglong i )
124  : d( new Private )
125 {
126  d->value.setValue( i );
127 }
128 
129 
130 Nepomuk2::Variant::Variant( bool b )
131  : d( new Private )
132 {
133  d->value.setValue( b );
134 }
135 
136 
137 Nepomuk2::Variant::Variant( double v )
138  : d( new Private )
139 {
140  d->value.setValue( v );
141 }
142 
143 
144 Nepomuk2::Variant::Variant( const char* string )
145  : d( new Private )
146 {
147  d->value.setValue( QString::fromLatin1(string) );
148 }
149 
150 
151 Nepomuk2::Variant::Variant( const QString& string )
152  : d( new Private )
153 {
154  d->value.setValue( string );
155 }
156 
157 
158 Nepomuk2::Variant::Variant( const QDate& date )
159  : d( new Private )
160 {
161  d->value.setValue( date );
162 }
163 
164 
165 Nepomuk2::Variant::Variant( const QTime& time )
166  : d( new Private )
167 {
168  d->value.setValue( time );
169 }
170 
171 
172 Nepomuk2::Variant::Variant( const QDateTime& datetime )
173  : d( new Private )
174 {
175  d->value.setValue( datetime );
176 }
177 
178 
179 Nepomuk2::Variant::Variant( const QUrl& url )
180  : d( new Private )
181 {
182  d->value.setValue( url );
183 }
184 
185 
186 Nepomuk2::Variant::Variant( const Nepomuk2::Resource& r )
187  : d( new Private )
188 {
189  d->value.setValue( r );
190 }
191 
192 
193 Nepomuk2::Variant::Variant( const QList<int>& i )
194  : d( new Private )
195 {
196  d->value.setValue( i );
197 }
198 
199 
200 Nepomuk2::Variant::Variant( const QList<qlonglong>& i )
201  : d( new Private )
202 {
203  d->value.setValue( i );
204 }
205 
206 
207 Nepomuk2::Variant::Variant( const QList<uint>& i )
208  : d( new Private )
209 {
210  d->value.setValue( i );
211 }
212 
213 
214 Nepomuk2::Variant::Variant( const QList<qulonglong>& i )
215  : d( new Private )
216 {
217  d->value.setValue( i );
218 }
219 
220 
221 Nepomuk2::Variant::Variant( const QList<bool>& b )
222  : d( new Private )
223 {
224  d->value.setValue( b );
225 }
226 
227 
228 Nepomuk2::Variant::Variant( const QList<double>& v )
229  : d( new Private )
230 {
231  d->value.setValue( v );
232 }
233 
234 
235 Nepomuk2::Variant::Variant( const QStringList& stringlist )
236  : d( new Private )
237 {
238  d->value.setValue( stringlist );
239 }
240 
241 
242 Nepomuk2::Variant::Variant( const QList<QDate>& date )
243  : d( new Private )
244 {
245  d->value.setValue( date );
246 }
247 
248 
249 Nepomuk2::Variant::Variant( const QList<QTime>& time )
250  : d( new Private )
251 {
252  d->value.setValue( time );
253 }
254 
255 
256 Nepomuk2::Variant::Variant( const QList<QDateTime>& datetime )
257  : d( new Private )
258 {
259  d->value.setValue( datetime );
260 }
261 
262 
263 Nepomuk2::Variant::Variant( const QList<QUrl>& url )
264  : d( new Private )
265 {
266  d->value.setValue( url );
267 }
268 
269 
270 
271 Nepomuk2::Variant::Variant( const QList<Resource>& r )
272  : d( new Private )
273 {
274  d->value.setValue( r );
275 }
276 
277 
278 Nepomuk2::Variant::Variant( const QList<Variant>& vl )
279  : d( new Private )
280 {
281  foreach( const Variant& v, vl ) {
282  append( v );
283  }
284 }
285 
286 
287 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const Variant& v )
288 {
289  d->value = v.d->value;
290  return *this;
291 }
292 
293 
294 Nepomuk2::Variant& Nepomuk2::Variant::operator=( int i )
295 {
296  d->value.setValue( i );
297  return *this;
298 }
299 
300 
301 Nepomuk2::Variant& Nepomuk2::Variant::operator=( qlonglong i )
302 {
303  d->value.setValue( i );
304  return *this;
305 }
306 
307 
308 Nepomuk2::Variant& Nepomuk2::Variant::operator=( uint i )
309 {
310  d->value.setValue( i );
311  return *this;
312 }
313 
314 
315 Nepomuk2::Variant& Nepomuk2::Variant::operator=( qulonglong i )
316 {
317  d->value.setValue( i );
318  return *this;
319 }
320 
321 
322 Nepomuk2::Variant& Nepomuk2::Variant::operator=( bool b )
323 {
324  d->value.setValue( b );
325  return *this;
326 }
327 
328 
329 Nepomuk2::Variant& Nepomuk2::Variant::operator=( double v )
330 {
331  d->value.setValue( v );
332  return *this;
333 }
334 
335 
336 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QString& string )
337 {
338  d->value.setValue( string );
339  return *this;
340 }
341 
342 
343 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QDate& date )
344 {
345  d->value.setValue( date );
346  return *this;
347 }
348 
349 
350 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QTime& time )
351 {
352  d->value.setValue( time );
353  return *this;
354 }
355 
356 
357 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QDateTime& datetime )
358 {
359  d->value.setValue( datetime );
360  return *this;
361 }
362 
363 
364 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QUrl& url )
365 {
366  d->value.setValue( url );
367  return *this;
368 }
369 
370 
371 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const Resource& r )
372 {
373  d->value.setValue( r );
374  return *this;
375 }
376 
377 
378 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<int>& i )
379 {
380  d->value.setValue( i );
381  return *this;
382 }
383 
384 
385 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<qlonglong>& i )
386 {
387  d->value.setValue( i );
388  return *this;
389 }
390 
391 
392 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<uint>& i )
393 {
394  d->value.setValue( i );
395  return *this;
396 }
397 
398 
399 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<qulonglong>& i )
400 {
401  d->value.setValue( i );
402  return *this;
403 }
404 
405 
406 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<bool>& b )
407 {
408  d->value.setValue( b );
409  return *this;
410 }
411 
412 
413 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<double>& v )
414 {
415  d->value.setValue( v );
416  return *this;
417 }
418 
419 
420 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QStringList& stringlist )
421 {
422  d->value.setValue( stringlist );
423  return *this;
424 }
425 
426 
427 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<QDate>& date )
428 {
429  d->value.setValue( date );
430  return *this;
431 }
432 
433 
434 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<QTime>& time )
435 {
436  d->value.setValue( time );
437  return *this;
438 }
439 
440 
441 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<QDateTime>& datetime )
442 {
443  d->value.setValue( datetime );
444  return *this;
445 }
446 
447 
448 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<QUrl>& url )
449 {
450  d->value.setValue( url );
451  return *this;
452 }
453 
454 
455 Nepomuk2::Variant& Nepomuk2::Variant::operator=( const QList<Resource>& r )
456 {
457  d->value.setValue( r );
458  return *this;
459 }
460 
461 
462 void Nepomuk2::Variant::append( int i )
463 {
464  QList<int> l = toIntList();
465  l.append( i );
466  operator=( l );
467 }
468 
469 
470 void Nepomuk2::Variant::append( qlonglong i )
471 {
472  QList<qlonglong> l = toInt64List();
473  l.append( i );
474  operator=( l );
475 }
476 
477 
478 void Nepomuk2::Variant::append( uint i )
479 {
480  QList<uint> l = toUnsignedIntList();
481  l.append( i );
482  operator=( l );
483 }
484 
485 
486 void Nepomuk2::Variant::append( qulonglong i )
487 {
488  QList<qulonglong> l = toUnsignedInt64List();
489  l.append( i );
490  operator=( l );
491 }
492 
493 
494 void Nepomuk2::Variant::append( bool b )
495 {
496  QList<bool> l = toBoolList();
497  l.append( b );
498  operator=( l );
499 }
500 
501 
502 void Nepomuk2::Variant::append( double d )
503 {
504  QList<double> l = toDoubleList();
505  l.append( d );
506  operator=( l );
507 }
508 
509 
510 void Nepomuk2::Variant::append( const QString& string )
511 {
512  QStringList l = toStringList();
513  l.append( string );
514  operator=( l );
515 }
516 
517 
518 void Nepomuk2::Variant::append( const QDate& date )
519 {
520  QList<QDate> l = toDateList();
521  l.append( date );
522  operator=( l );
523 }
524 
525 
526 void Nepomuk2::Variant::append( const QTime& time )
527 {
528  QList<QTime> l = toTimeList();
529  l.append( time );
530  operator=( l );
531 }
532 
533 
534 void Nepomuk2::Variant::append( const QDateTime& datetime )
535 {
536  QList<QDateTime> l = toDateTimeList();
537  l.append( datetime );
538  operator=( l );
539 }
540 
541 
542 void Nepomuk2::Variant::append( const QUrl& url )
543 {
544  QList<QUrl> l = toUrlList();
545  l.append( url );
546  operator=( l );
547 }
548 
549 
550 void Nepomuk2::Variant::append( const Resource& r )
551 {
552  QList<Resource> l = toResourceList();
553  if ( !l.contains( r ) ) {
554  l.append( r );
555  operator=( l );
556  }
557 }
558 
559 
560 void Nepomuk2::Variant::append( const Variant& v )
561 {
562  if ( !isValid() ) {
563  operator=( v );
564  }
565  else {
566  if( v.simpleType() == QVariant::Int ) {
567  operator=( toIntList() += v.toIntList() );
568  }
569  else if( v.simpleType() == QVariant::UInt ) {
570  operator=( toUnsignedIntList() += v.toUnsignedIntList() );
571  }
572  else if( v.simpleType() == QVariant::LongLong ) {
573  operator=( toInt64List() += v.toInt64List() );
574  }
575  else if( v.simpleType() == QVariant::ULongLong ) {
576  operator=( toUnsignedInt64List() += v.toUnsignedInt64List() );
577  }
578  else if( v.simpleType() == QVariant::Bool ) {
579  operator=( toBoolList() += v.toBoolList() );
580  }
581  else if( v.simpleType() == QVariant::Double ) {
582  operator=( toDoubleList() += v.toDoubleList() );
583  }
584  else if( v.simpleType() == QVariant::String ) {
585  operator=( toStringList() += v.toStringList() );
586  }
587  else if( v.simpleType() == QVariant::Date ) {
588  operator=( toDateList() += v.toDateList() );
589  }
590  else if( v.simpleType() == QVariant::Time ) {
591  operator=( toTimeList() += v.toTimeList() );
592  }
593  else if( v.simpleType() == QVariant::DateTime ) {
594  operator=( toDateTimeList() += v.toDateTimeList() );
595  }
596  else if( v.simpleType() == QVariant::Url ) {
597  operator=( toUrlList() += v.toUrlList() );
598  }
599  else if( v.simpleType() == qMetaTypeId<Resource>() ) {
600  operator=( toResourceList() += v.toResourceList() );
601  }
602  else
603  kDebug() << "(Variant::append) unknown type: " << v.simpleType();
604  }
605 }
606 
607 
608 bool Nepomuk2::Variant::isInt() const
609 {
610  return( type() == QVariant::Int );
611 }
612 
613 
614 bool Nepomuk2::Variant::isInt64() const
615 {
616  return( type() == QVariant::LongLong );
617 }
618 
619 
620 bool Nepomuk2::Variant::isUnsignedInt() const
621 {
622  return( type() == QVariant::UInt );
623 }
624 
625 
626 bool Nepomuk2::Variant::isUnsignedInt64() const
627 {
628  return( type() == QVariant::ULongLong );
629 }
630 
631 
632 bool Nepomuk2::Variant::isBool() const
633 {
634  return( type() == QVariant::Bool );
635 }
636 
637 
638 bool Nepomuk2::Variant::isDouble() const
639 {
640  return( type() == QVariant::Double );
641 }
642 
643 
644 bool Nepomuk2::Variant::isString() const
645 {
646  return( type() == QVariant::String );
647 }
648 
649 
650 bool Nepomuk2::Variant::isDate() const
651 {
652  return( type() == QVariant::Date );
653 }
654 
655 
656 bool Nepomuk2::Variant::isTime() const
657 {
658  return( type() == QVariant::Time );
659 }
660 
661 
662 bool Nepomuk2::Variant::isDateTime() const
663 {
664  return( type() == QVariant::DateTime );
665 }
666 
667 
668 bool Nepomuk2::Variant::isUrl() const
669 {
670  return( type() == QVariant::Url );
671 }
672 
673 
674 bool Nepomuk2::Variant::isResource() const
675 {
676  return( type() == qMetaTypeId<Resource>() ||
677  isUrl() );
678 }
679 
680 
681 bool Nepomuk2::Variant::isIntList() const
682 {
683  return( type() == qMetaTypeId<QList<int> >() );
684 }
685 
686 
687 bool Nepomuk2::Variant::isUnsignedIntList() const
688 {
689  return( type() == qMetaTypeId<QList<uint> >() );
690 }
691 
692 
693 bool Nepomuk2::Variant::isInt64List() const
694 {
695  return( type() == qMetaTypeId<QList<qlonglong> >() );
696 }
697 
698 
699 bool Nepomuk2::Variant::isUnsignedInt64List() const
700 {
701  return( type() == qMetaTypeId<QList<qulonglong> >() );
702 }
703 
704 
705 bool Nepomuk2::Variant::isBoolList() const
706 {
707  return( type() == qMetaTypeId<QList<bool> >() );
708 }
709 
710 
711 bool Nepomuk2::Variant::isDoubleList() const
712 {
713  return( type() == qMetaTypeId<QList<double> >() );
714 }
715 
716 
717 bool Nepomuk2::Variant::isStringList() const
718 {
719  return( type() == QVariant::StringList );
720 }
721 
722 
723 bool Nepomuk2::Variant::isDateList() const
724 {
725  return( type() == qMetaTypeId<QList<QDate> >() );
726 }
727 
728 
729 bool Nepomuk2::Variant::isTimeList() const
730 {
731  return( type() == qMetaTypeId<QList<QTime> >() );
732 }
733 
734 
735 bool Nepomuk2::Variant::isDateTimeList() const
736 {
737  return( type() == qMetaTypeId<QList<QDateTime> >() );
738 }
739 
740 
741 bool Nepomuk2::Variant::isUrlList() const
742 {
743  return( type() == qMetaTypeId<QList<QUrl> >() );
744 }
745 
746 
747 bool Nepomuk2::Variant::isResourceList() const
748 {
749  return( type() == qMetaTypeId<QList<Resource> >() ||
750  isUrlList() );
751 }
752 
753 
754 
755 int Nepomuk2::Variant::toInt() const
756 {
757  if(isList()) {
758  QList<int> l = toIntList();
759  if(!l.isEmpty())
760  return l.first();
761  }
762 
763  return d->value.toInt();
764 }
765 
766 
767 qlonglong Nepomuk2::Variant::toInt64() const
768 {
769  if(isList()) {
770  QList<qlonglong> l = toInt64List();
771  if(!l.isEmpty())
772  return l.first();
773  }
774 
775  return d->value.toLongLong();
776 }
777 
778 
779 uint Nepomuk2::Variant::toUnsignedInt() const
780 {
781  if(isList()) {
782  QList<uint> l = toUnsignedIntList();
783  if(!l.isEmpty())
784  return l.first();
785  }
786 
787  return d->value.toUInt();
788 }
789 
790 
791 qulonglong Nepomuk2::Variant::toUnsignedInt64() const
792 {
793  if(isList()) {
794  QList<qulonglong> l = toUnsignedInt64List();
795  if(!l.isEmpty())
796  return l.first();
797  }
798 
799  return d->value.toULongLong();
800 }
801 
802 
803 bool Nepomuk2::Variant::toBool() const
804 {
805  if(isList()) {
806  QList<bool> l = toBoolList();
807  if(!l.isEmpty())
808  return l.first();
809  }
810 
811  return d->value.toBool();
812 }
813 
814 
815 double Nepomuk2::Variant::toDouble() const
816 {
817  if(isList()) {
818  QList<double> l = toDoubleList();
819  if(!l.isEmpty())
820  return l.first();
821  }
822 
823  return d->value.toDouble();
824 }
825 
826 
827 QString Nepomuk2::Variant::toString() const
828 {
829 // kDebug() << "(Variant::toString() converting... " << QMetaType::typeName(type());
830  if( isList() )
831  return toStringList().join( "," );
832 
833  else if( isInt() )
834  return QString::number( toInt() );
835  else if( isInt64() )
836  return QString::number( toInt64() );
837  else if( isUnsignedInt() )
838  return QString::number( toUnsignedInt() );
839  else if( isUnsignedInt64() )
840  return QString::number( toUnsignedInt64() );
841  else if( isBool() )
842  return ( toBool() ? QString("true") : QString("false" ) );
843  else if( isDouble() )
844  return QString::number( toDouble(), 'e', 10 );
845  else if( isDate() )
846  return Soprano::LiteralValue( toDate() ).toString();
847  else if( isTime() )
848  return Soprano::LiteralValue( toTime() ).toString();
849  else if( isDateTime() )
850  return Soprano::LiteralValue( toDateTime() ).toString();
851  else if( isUrl() )
852  return KUrl(toUrl()).pathOrUrl();
853  else if( isResource() )
854  return toResource().genericLabel();
855  else
856  return d->value.toString();
857 }
858 
859 
860 QDate Nepomuk2::Variant::toDate() const
861 {
862  if(isList()) {
863  QList<QDate> l = toDateList();
864  if(!l.isEmpty())
865  return l.first();
866  }
867  return d->value.toDate();
868 }
869 
870 
871 QTime Nepomuk2::Variant::toTime() const
872 {
873  if(isList()) {
874  QList<QTime> l = toTimeList();
875  if(!l.isEmpty())
876  return l.first();
877  }
878  return d->value.toTime();
879 }
880 
881 
882 QDateTime Nepomuk2::Variant::toDateTime() const
883 {
884  if(isList()) {
885  QList<QDateTime> l = toDateTimeList();
886  if(!l.isEmpty())
887  return l.first();
888  }
889  return d->value.toDateTime();
890 }
891 
892 
893 QUrl Nepomuk2::Variant::toUrl() const
894 {
895  if(isList()) {
896  QList<QUrl> l = toUrlList();
897  if(!l.isEmpty())
898  return l.first();
899  }
900  else if(type() == qMetaTypeId<Resource>()) {
901  return toResource().uri();
902  }
903 
904  return d->value.toUrl();
905 }
906 
907 
908 Nepomuk2::Resource Nepomuk2::Variant::toResource() const
909 {
910  if(isResourceList() || isUrlList()) {
911  QList<Resource> l = toResourceList();
912  if(!l.isEmpty())
913  return l.first();
914  }
915  else if(type() == QVariant::Url) {
916  return Resource(toUrl());
917  }
918 
919  return d->value.value<Resource>();
920 }
921 
922 
923 
924 QList<int> Nepomuk2::Variant::toIntList() const
925 {
926  if( isUnsignedInt() ||
927  isInt() ||
928  isUnsignedInt64() ||
929  isInt64() ) {
930  QList<int> l;
931  l.append( toInt() );
932  return l;
933  }
934  else if ( isUnsignedIntList() ) {
935  return convertList<uint, int>( d->value.value<QList<uint> >() );
936  }
937  else if ( isUnsignedInt64List() ) {
938  return convertList<qulonglong, int>( d->value.value<QList<qulonglong> >() );
939  }
940  else if ( isInt64List() ) {
941  return convertList<qlonglong, int>( d->value.value<QList<qlonglong> >() );
942  }
943  else {
944  return d->value.value<QList<int> >();
945  }
946 }
947 
948 
949 QList<qlonglong> Nepomuk2::Variant::toInt64List() const
950 {
951  if( isUnsignedInt() ||
952  isInt() ||
953  isUnsignedInt64() ||
954  isInt64() ) {
955  QList<qlonglong> l;
956  l.append( toInt64() );
957  return l;
958  }
959  else if ( isIntList() ) {
960  return convertList<int, qlonglong>( d->value.value<QList<int> >() );
961  }
962  else if ( isUnsignedIntList() ) {
963  return convertList<uint, qlonglong>( d->value.value<QList<uint> >() );
964  }
965  else if ( isUnsignedInt64List() ) {
966  return convertList<qulonglong, qlonglong>( d->value.value<QList<qulonglong> >() );
967  }
968  else {
969  return d->value.value<QList<qlonglong> >();
970  }
971 }
972 
973 
974 QList<uint> Nepomuk2::Variant::toUnsignedIntList() const
975 {
976  if( isUnsignedInt() ||
977  isInt() ||
978  isUnsignedInt64() ||
979  isInt64() ) {
980  QList<uint> l;
981  l.append( toUnsignedInt() );
982  return l;
983  }
984  else if ( isIntList() ) {
985  return convertList<int, uint>( d->value.value<QList<int> >() );
986  }
987  else if ( isUnsignedInt64List() ) {
988  return convertList<qulonglong, uint>( d->value.value<QList<qulonglong> >() );
989  }
990  else if ( isInt64List() ) {
991  return convertList<qlonglong, uint>( d->value.value<QList<qlonglong> >() );
992  }
993  else {
994  return d->value.value<QList<uint> >();
995  }
996 }
997 
998 
999 QList<qulonglong> Nepomuk2::Variant::toUnsignedInt64List() const
1000 {
1001  if( isUnsignedInt() ||
1002  isInt() ||
1003  isUnsignedInt64() ||
1004  isInt64() ) {
1005  QList<qulonglong> l;
1006  l.append( toUnsignedInt() );
1007  return l;
1008  }
1009  else if ( isIntList() ) {
1010  return convertList<int, qulonglong>( d->value.value<QList<int> >() );
1011  }
1012  else if ( isUnsignedIntList() ) {
1013  return convertList<uint, qulonglong>( d->value.value<QList<uint> >() );
1014  }
1015  else if ( isInt64List() ) {
1016  return convertList<qlonglong, qulonglong>( d->value.value<QList<qlonglong> >() );
1017  }
1018  else {
1019  return d->value.value<QList<qulonglong> >();
1020  }
1021 }
1022 
1023 
1024 QList<bool> Nepomuk2::Variant::toBoolList() const
1025 {
1026  if( isBool() ) {
1027  QList<bool> l;
1028  l.append( toBool() );
1029  return l;
1030  }
1031  else
1032  return d->value.value<QList<bool> >();
1033 }
1034 
1035 
1036 QList<double> Nepomuk2::Variant::toDoubleList() const
1037 {
1038  if( isDouble() ) {
1039  QList<double> l;
1040  l.append( toDouble() );
1041  return l;
1042  }
1043  else
1044  return d->value.value<QList<double> >();
1045 }
1046 
1047 
1048 template<typename T> QStringList convertToStringList( const QList<T>& l )
1049 {
1050  QStringList sl;
1051  QListIterator<T> it( l );
1052  while( it.hasNext() )
1053  sl.append( Nepomuk2::Variant( it.next() ).toString() );
1054 // for( QList<T>::const_iterator it = l.constBegin(); it != l.constEnd(); ++it )
1055 // sl.append( Nepomuk2::Variant( *it ).toString() );
1056  return sl;
1057 }
1058 
1059 QStringList Nepomuk2::Variant::toStringList() const
1060 {
1061  // kDebug() << "(Variant::toStringList() converting... " << QMetaType::typeName(simpleType());
1062  if( !d->value.isValid() )
1063  return QStringList();
1064 
1065  if( !isList() )
1066  return QStringList( toString() );
1067 
1068  else if( isIntList() )
1069  return convertToStringList<int>( toIntList() );
1070  else if( isInt64List() )
1071  return convertToStringList<qlonglong>( toInt64List() );
1072  else if( isUnsignedIntList() )
1073  return convertToStringList<uint>( toUnsignedIntList() );
1074  else if( isUnsignedInt64List() )
1075  return convertToStringList<qulonglong>( toUnsignedInt64List() );
1076  else if( isBoolList() )
1077  return convertToStringList<bool>( toBoolList() );
1078  else if( isDoubleList() )
1079  return convertToStringList<double>( toDoubleList() );
1080  else if( isDateList() )
1081  return convertToStringList<QDate>( toDateList() );
1082  else if( isTimeList() )
1083  return convertToStringList<QTime>( toTimeList() );
1084  else if( isDateTimeList() )
1085  return convertToStringList<QDateTime>( toDateTimeList() );
1086  else if( isUrlList() )
1087  return convertToStringList<QUrl>( toUrlList() );
1088  else if( isResourceList() )
1089  return convertToStringList<Resource>( toResourceList() );
1090  else
1091  return d->value.value<QStringList>();
1092 }
1093 
1094 
1095 QList<QDate> Nepomuk2::Variant::toDateList() const
1096 {
1097  if( isDate() ) {
1098  QList<QDate> l;
1099  l.append( toDate() );
1100  return l;
1101  }
1102  else
1103  return d->value.value<QList<QDate> >();
1104 }
1105 
1106 
1107 QList<QTime> Nepomuk2::Variant::toTimeList() const
1108 {
1109  if( isTime() ) {
1110  QList<QTime> l;
1111  l.append( toTime() );
1112  return l;
1113  }
1114  else
1115  return d->value.value<QList<QTime> >();
1116 }
1117 
1118 
1119 QList<QDateTime> Nepomuk2::Variant::toDateTimeList() const
1120 {
1121  if( isDateTime() ) {
1122  QList<QDateTime> l;
1123  l.append( toDateTime() );
1124  return l;
1125  }
1126  else
1127  return d->value.value<QList<QDateTime> >();
1128 }
1129 
1130 
1131 QList<QUrl> Nepomuk2::Variant::toUrlList() const
1132 {
1133  if( type() == qMetaTypeId<Resource>() ||
1134  type() == QVariant::Url ) {
1135  QList<QUrl> l;
1136  l.append( toUrl() );
1137  return l;
1138  }
1139  else if( type() == qMetaTypeId<QList<Resource> >() ) {
1140  QList<QUrl> l;
1141  QList<Resource> rl = toResourceList();
1142  foreach(const Resource& r, rl)
1143  l << r.uri();
1144  return l;
1145  }
1146  else {
1147  return d->value.value<QList<QUrl> >();
1148  }
1149 }
1150 
1151 
1152 QList<Nepomuk2::Resource> Nepomuk2::Variant::toResourceList() const
1153 {
1154  if( type() == qMetaTypeId<Resource>() ||
1155  type() == QVariant::Url ) {
1156  QList<Resource> l;
1157  l.append( toResource() );
1158  return l;
1159  }
1160  else if( type() == qMetaTypeId<QList<QUrl> >() ) {
1161  QList<QUrl> urls = toUrlList();
1162  QList<Resource> l;
1163  foreach(const QUrl& url, urls)
1164  l << Resource(url);
1165  return l;
1166  }
1167  else {
1168  return d->value.value<QList<Resource> >();
1169  }
1170 }
1171 
1172 
1173 QList<Nepomuk2::Variant> Nepomuk2::Variant::toVariantList() const
1174 {
1175  QList<Variant> l;
1176 
1177  switch( simpleType() ) {
1178  case QVariant::Int:
1179  foreach( int i, toIntList() ) {
1180  l.append( Variant(i) );
1181  }
1182  break;
1183 
1184  case QVariant::LongLong:
1185  foreach( qlonglong i, toInt64List() ) {
1186  l.append( Variant(i) );
1187  }
1188  break;
1189 
1190  case QVariant::UInt:
1191  foreach( uint i, toUnsignedIntList() ) {
1192  l.append( Variant(i) );
1193  }
1194  break;
1195 
1196  case QVariant::ULongLong:
1197  foreach( qulonglong i, toUnsignedInt64List() ) {
1198  l.append( Variant(i) );
1199  }
1200  break;
1201 
1202  case QVariant::Bool:
1203  foreach( bool i, toBoolList() ) {
1204  l.append( Variant(i) );
1205  }
1206  break;
1207 
1208  case QVariant::Double:
1209  foreach( double i, toDoubleList() ) {
1210  l.append( Variant(i) );
1211  }
1212  break;
1213 
1214  case QVariant::Date:
1215  foreach( const QDate& i, toDateList() ) {
1216  l.append( Variant(i) );
1217  }
1218  break;
1219 
1220  case QVariant::Time:
1221  foreach( const QTime& i, toTimeList() ) {
1222  l.append( Variant(i) );
1223  }
1224  break;
1225 
1226  case QVariant::DateTime:
1227  foreach( const QDateTime& i, toDateTimeList() ) {
1228  l.append( Variant(i) );
1229  }
1230  break;
1231 
1232  case QVariant::Url:
1233  foreach( const QUrl& i, toUrlList() ) {
1234  l.append( Variant(i) );
1235  }
1236  break;
1237 
1238  default:
1239  if( simpleType() == qMetaTypeId<Resource>()) {
1240  foreach( const Resource& i, toResourceList() ) {
1241  l.append( Variant(i) );
1242  }
1243  }
1244  else {
1245  foreach( const QString& i, toStringList() ) {
1246  l.append( Variant(i) );
1247  }
1248  break;
1249  }
1250  }
1251 
1252  return l;
1253 }
1254 
1255 
1256 Soprano::Node Nepomuk2::Variant::toNode() const
1257 {
1258  if( !isValid() || isList() )
1259  return Soprano::Node();
1260  else if( isResource() )
1261  return Soprano::Node( toUrl() );
1262  else
1263  return Soprano::Node( Soprano::LiteralValue( variant() ) );
1264 }
1265 
1266 
1267 QList<Soprano::Node> Nepomuk2::Variant::toNodeList() const
1268 {
1269  QList<Soprano::Node> nl;
1270 
1271  if ( isResourceList() ) {
1272  QList<QUrl> urls = toUrlList();
1273  for ( QList<QUrl>::const_iterator it = urls.constBegin(); it != urls.constEnd(); ++it ) {
1274  nl.append( Soprano::Node( *it ) );
1275  }
1276  }
1277  else if( isList() ) {
1278  QStringList vl = toStringList();
1279  for( QStringList::const_iterator it = vl.constBegin(); it != vl.constEnd(); ++it ) {
1280  nl.append( Soprano::Node( Soprano::LiteralValue::fromString( *it, ( QVariant::Type )simpleType() ) ) );
1281  }
1282  }
1283  else if( isValid() ) {
1284  nl.append( toNode() );
1285  }
1286 
1287  return nl;
1288 }
1289 
1290 
1291 bool Nepomuk2::Variant::isList() const
1292 {
1293  return( isIntList() ||
1294  isInt64List() ||
1295  isUnsignedIntList() ||
1296  isUnsignedInt64List() ||
1297  isBoolList() ||
1298  isDoubleList() ||
1299  isStringList() ||
1300  isDateList() ||
1301  isTimeList() ||
1302  isDateTimeList() ||
1303  isUrlList() ||
1304  isResourceList() );
1305 }
1306 
1307 
1308 int Nepomuk2::Variant::type() const
1309 {
1310  return d->value.userType();
1311 }
1312 
1313 
1314 int Nepomuk2::Variant::simpleType() const
1315 {
1316  if( isIntList() )
1317  return QVariant::Int;
1318  else if( isInt64List() )
1319  return QVariant::LongLong;
1320  else if( isUnsignedIntList() )
1321  return QVariant::UInt;
1322  else if( isUnsignedInt64List() )
1323  return QVariant::ULongLong;
1324  else if( isBoolList() )
1325  return QVariant::Bool;
1326  else if( isDoubleList() )
1327  return QVariant::Double;
1328  else if( isStringList() )
1329  return QVariant::String;
1330  else if( isDateList() )
1331  return QVariant::Date;
1332  else if( isTimeList() )
1333  return QVariant::Time;
1334  else if( isDateTimeList() )
1335  return QVariant::DateTime;
1336  else if( isUrlList() )
1337  return QVariant::Url;
1338  else if( isResourceList() )
1339  return qMetaTypeId<Resource>();
1340  else
1341  return d->value.userType();
1342 }
1343 
1344 
1345 // static
1346 Nepomuk2::Variant Nepomuk2::Variant::fromString( const QString& value, int type )
1347 {
1348  // first check the types that are not supported by Soprano since they are not literal types
1349  if( type == qMetaTypeId<Resource>() ) {
1350  return Variant( Resource( value ) );
1351  }
1352  else if ( type == int( QVariant::Url ) ) {
1353  return Variant( QUrl( value ) );
1354  }
1355 
1356  // let Soprano do the rest
1357  else {
1358  return Variant( Soprano::LiteralValue::fromString( value, ( QVariant::Type )type ).variant() );
1359  }
1360 }
1361 
1362 
1363 // static
1364 Nepomuk2::Variant Nepomuk2::Variant::fromNode( const Soprano::Node& node )
1365 {
1366  //
1367  // We cannot put in Resource objects here since then nie:url file:/ URLs would
1368  // get converted back to the actual resource URIs which would be useless.
1369  // That is why Variant treats QUrl and Resource pretty much as similar.
1370  //
1371  if ( node.isResource() ) {
1372  return Nepomuk2::Variant( node.uri() );
1373  }
1374  else if ( node.isLiteral() ) {
1375  return Nepomuk2::Variant( node.literal().variant() );
1376  }
1377  else {
1378  return Nepomuk2::Variant();
1379  }
1380 }
1381 
1382 
1383 // static
1384 Nepomuk2::Variant Nepomuk2::Variant::fromNodeList( const QList<Soprano::Node>& valueNodes )
1385 {
1386  if( valueNodes.size() == 1 ) {
1387  return Nepomuk2::Variant::fromNode( valueNodes.first() );
1388  }
1389  else {
1390  if( valueNodes.first().isResource() ) {
1391  QList<Nepomuk2::Resource> resList;
1392  Q_FOREACH( const Soprano::Node & n, valueNodes ) {
1393  if( n.isResource() )
1394  resList << Nepomuk2::Resource( n.uri() );
1395  }
1396  return Nepomuk2::Variant( resList );
1397  }
1398  else if( valueNodes.first().isLiteral() ) {
1399  QList<Variant> varList;
1400  Q_FOREACH( const Soprano::Node & n, valueNodes ) {
1401  if( n.isLiteral() )
1402  varList << Nepomuk2::Variant( n.literal().variant() );
1403  }
1404  return Nepomuk2::Variant( varList );
1405  }
1406  return Nepomuk2::Variant();
1407  }
1408 }
1409 
1410 
1411 bool Nepomuk2::Variant::operator==( const Variant& other ) const
1412 {
1413  // we handle the special case of Urls and Resources before
1414  // comparing the simple type
1415  if( isUrl() || isUrlList() )
1416  return other.toUrlList() == toUrlList();
1417  else if( isResource() || isResourceList() )
1418  return other.toResourceList() == toResourceList();
1419 
1420  if( other.simpleType() != this->simpleType() )
1421  return false;
1422 
1423  if( isInt() || isIntList() )
1424  return other.toIntList() == toIntList();
1425  else if( isInt64() || isInt64List() )
1426  return other.toInt64List() == toInt64List();
1427  else if( isUnsignedInt() || isUnsignedIntList() )
1428  return other.toUnsignedIntList() == toUnsignedIntList();
1429  else if( isUnsignedInt64() || isUnsignedInt64List() )
1430  return other.toUnsignedInt64List() == toUnsignedInt64List();
1431  else if( isBool() || isBoolList() )
1432  return other.toBoolList() == toBoolList();
1433  else if( isDouble() || isDoubleList() )
1434  return other.toDoubleList() == toDoubleList();
1435  else if( isString() || isStringList() )
1436  return other.d->value.value<QStringList>() == d->value.value<QStringList>();
1437  else if( isDate() || isDateList() )
1438  return other.toDateList() == toDateList();
1439  else if( isTime() || isTimeList() )
1440  return other.toTimeList() == toTimeList();
1441  else if( isDateTime() || isDateTimeList() )
1442  return other.toDateTimeList() == toDateTimeList();
1443  else
1444  return ( d->value == other.d->value );
1445 }
1446 
1447 
1448 bool Nepomuk2::Variant::operator!=( const Variant& other ) const
1449 {
1450  return !operator==( other );
1451 }
1452 
1453 
1454 QVariant Nepomuk2::Variant::variant() const
1455 {
1456  return d->value;
1457 }
1458 
1459 
1460 bool Nepomuk2::Variant::isValid() const
1461 {
1462  return d->value.isValid();
1463 }
1464 
1465 
1466 QDebug operator<<( QDebug dbg, const Nepomuk2::Variant& v )
1467 {
1468  if( v.isList() )
1469  dbg.nospace() << "Nepomuk2::Variant(" << v.toStringList() << "@list)";
1470  else if( v.isResource() )
1471  dbg.nospace() << "Nepomuk2::Variant(Nepomuk2::Resource(" << v.toString() << "))";
1472  else
1473  dbg.nospace() << "Nepomuk2::Variant(" << v.variant() << ")";
1474  return dbg;
1475 }
Nepomuk2::Variant::isResourceList
bool isResourceList() const
Definition: variant.cpp:747
Nepomuk2::Variant::isBool
bool isBool() const
Definition: variant.cpp:632
Nepomuk2::Variant::isIntList
bool isIntList() const
Definition: variant.cpp:681
Nepomuk2::Variant::toUrl
QUrl toUrl() const
Convert into a QUrl value.
Definition: variant.cpp:893
Nepomuk2::Variant::toIntList
QList< int > toIntList() const
Definition: variant.cpp:924
Nepomuk2::Variant::isTime
bool isTime() const
Definition: variant.cpp:656
Nepomuk2::Variant::type
int type() const
Definition: variant.cpp:1308
Nepomuk2::Variant::isDoubleList
bool isDoubleList() const
Definition: variant.cpp:711
Nepomuk2::Variant::isInt64List
bool isInt64List() const
Definition: variant.cpp:693
Nepomuk2::Variant::isDateTimeList
bool isDateTimeList() const
Definition: variant.cpp:735
Nepomuk2::Variant::isDate
bool isDate() const
Definition: variant.cpp:650
Nepomuk2::Variant::operator==
bool operator==(const Variant &other) const
Does compare two Variant objects.
Definition: variant.cpp:1411
Nepomuk2::Variant::toUnsignedInt
uint toUnsignedInt() const
Convert into a uint value.
Definition: variant.cpp:779
Nepomuk2::operator<<
QDataStream & operator<<(QDataStream &, const Nepomuk2::SimpleResource &)
Definition: simpleresource.cpp:307
Nepomuk2::Variant::isUnsignedInt64
bool isUnsignedInt64() const
Definition: variant.cpp:626
Nepomuk2::Variant::isStringList
bool isStringList() const
Definition: variant.cpp:717
Nepomuk2::Variant::toDate
QDate toDate() const
Convert into a QDate value.
Definition: variant.cpp:860
Nepomuk2::Variant::isInt
bool isInt() const
Definition: variant.cpp:608
Nepomuk2::Variant::isDateList
bool isDateList() const
Definition: variant.cpp:723
Nepomuk2::Variant::variant
QVariant variant() const
Definition: variant.cpp:1454
Nepomuk2::Variant::~Variant
~Variant()
Definition: variant.cpp:57
Nepomuk2::Variant::isList
bool isList() const
This methods does not handle all list types.
Definition: variant.cpp:1291
Nepomuk2::Variant::toDouble
double toDouble() const
Convert into a double value.
Definition: variant.cpp:815
Nepomuk2::Variant::toUnsignedInt64
qulonglong toUnsignedInt64() const
Convert into a qulonglong value.
Definition: variant.cpp:791
Nepomuk2::Variant::isUnsignedIntList
bool isUnsignedIntList() const
Definition: variant.cpp:687
Nepomuk2::Variant::toVariantList
QList< Variant > toVariantList() const
Convert a Variant to a list of Variants.
Definition: variant.cpp:1173
Nepomuk2::Variant
The Nepomuk Variant extends over QVariant by introducing direct support for Resource embedding...
Definition: variant.h:65
variant.h
Nepomuk2::Variant::toResource
Resource toResource() const
Convert into a Resource value.
Definition: variant.cpp:908
Nepomuk2::Variant::fromNode
static Variant fromNode(const Soprano::Node &node)
Create a Variant object from a Soprano::Node.
Definition: variant.cpp:1364
Nepomuk2::Variant::toInt64List
QList< qlonglong > toInt64List() const
Definition: variant.cpp:949
Nepomuk2::Variant::toDoubleList
QList< double > toDoubleList() const
Definition: variant.cpp:1036
Nepomuk2::Variant::toTimeList
QList< QTime > toTimeList() const
Definition: variant.cpp:1107
Nepomuk2::Variant::toStringList
QStringList toStringList() const
Just like the toString method toStringList is able to convert all supported types into a list of stri...
Definition: variant.cpp:1059
Nepomuk2::Variant::toBoolList
QList< bool > toBoolList() const
Definition: variant.cpp:1024
Nepomuk2::Variant::toInt
int toInt() const
Convert into an int value.
Definition: variant.cpp:755
Nepomuk2::Variant::operator=
Variant & operator=(const Variant &)
Definition: variant.cpp:287
resource.h
Nepomuk2::Variant::toResourceList
QList< Resource > toResourceList() const
Definition: variant.cpp:1152
Nepomuk2::Variant::fromNodeList
static Variant fromNodeList(const QList< Soprano::Node > &node)
Create a Variant object from a list of Soprano::Node.
Definition: variant.cpp:1384
Nepomuk2::Variant::toInt64
qlonglong toInt64() const
Convert into a qlonglong value.
Definition: variant.cpp:767
Nepomuk2::Variant::Variant
Variant()
Definition: variant.cpp:51
Nepomuk2::Variant::isBoolList
bool isBoolList() const
Definition: variant.cpp:705
Nepomuk2::Variant::toUnsignedIntList
QList< uint > toUnsignedIntList() const
Definition: variant.cpp:974
Nepomuk2::Variant::operator!=
bool operator!=(const Variant &other) const
Inverse of operator==.
Definition: variant.cpp:1448
Nepomuk2::Variant::toDateList
QList< QDate > toDateList() const
Definition: variant.cpp:1095
Nepomuk2::Variant::simpleType
int simpleType() const
Definition: variant.cpp:1314
Nepomuk2::Variant::toDateTime
QDateTime toDateTime() const
Convert into a QDateTime value.
Definition: variant.cpp:882
Nepomuk2::Variant::isUnsignedInt64List
bool isUnsignedInt64List() const
Definition: variant.cpp:699
Nepomuk2::Variant::toUnsignedInt64List
QList< qulonglong > toUnsignedInt64List() const
Definition: variant.cpp:999
Nepomuk2::Variant::isUrl
bool isUrl() const
Definition: variant.cpp:668
Nepomuk2::Variant::toUrlList
QList< QUrl > toUrlList() const
Definition: variant.cpp:1131
Nepomuk2::Variant::isUnsignedInt
bool isUnsignedInt() const
Definition: variant.cpp:620
Nepomuk2::Variant::fromString
static Variant fromString(const QString &value, int type)
Create a Variant object by parsing string value based on type.
Definition: variant.cpp:1346
Nepomuk2::Variant::toTime
QTime toTime() const
Convert into a QTime value.
Definition: variant.cpp:871
Nepomuk2::Variant::isDouble
bool isDouble() const
Definition: variant.cpp:638
Nepomuk2::Variant::isTimeList
bool isTimeList() const
Definition: variant.cpp:729
Nepomuk2::Variant::isDateTime
bool isDateTime() const
Definition: variant.cpp:662
Nepomuk2::Variant::isString
bool isString() const
Definition: variant.cpp:644
tools.h
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::Variant::isUrlList
bool isUrlList() const
Definition: variant.cpp:741
Nepomuk2::Resource
Resource is the central object type in Nepomuk.
Definition: resource.h:93
Nepomuk2::Variant::append
void append(int i)
Append i to this variant.
Definition: variant.cpp:462
Nepomuk2::Variant::isResource
bool isResource() const
Definition: variant.cpp:674
convertToStringList
QStringList convertToStringList(const QList< T > &l)
Definition: variant.cpp:1048
Nepomuk2::Resource::uri
QUrl uri() const
The URI of the resource, uniquely identifying it.
Definition: resource.cpp:166
Nepomuk2::Variant::isValid
bool isValid() const
Definition: variant.cpp:1460
Nepomuk2::Variant::toNode
Soprano::Node toNode() const
Convert a Variant to a Node.
Definition: variant.cpp:1256
Nepomuk2::Variant::toDateTimeList
QList< QDateTime > toDateTimeList() const
Definition: variant.cpp:1119
Nepomuk2::Variant::isInt64
bool isInt64() const
Definition: variant.cpp:614
Nepomuk2::Variant::toBool
bool toBool() const
Convert into a bool value.
Definition: variant.cpp:803
Nepomuk2::Variant::toNodeList
QList< Soprano::Node > toNodeList() const
Convert a Variant to a a list of Nodes.
Definition: variant.cpp:1267
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 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