• 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
  • query
andterm.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Nepomuk KDE project.
3  Copyright (C) 2009-2010 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 Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) version 3, or any
9  later version accepted by the membership of KDE e.V. (or its
10  successor approved by the membership of KDE e.V.), which shall
11  act as a proxy defined in Section 6 of version 3 of the license.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "andterm.h"
23 #include "andterm_p.h"
24 #include "querybuilderdata_p.h"
25 
26 #include <QtCore/QStringList>
27 
28 QString Nepomuk2::Query::AndTermPrivate::toSparqlGraphPattern( const QString& resourceVarName, const TermPrivate* parentTerm, const QString &additionalFilters, QueryBuilderData *qbd ) const
29 {
30  Q_UNUSED(parentTerm);
31 
32  QStringList pattern;
33 
34  const bool haveRealPattern = hasRealPattern();
35 
36  qbd->pushGroupTerm(this);
37  foreach( const Nepomuk2::Query::Term &t, m_subTerms ) {
38  pattern += t.d_ptr->toSparqlGraphPattern( resourceVarName, this, haveRealPattern ? QString() : additionalFilters, qbd );
39  }
40  qbd->popGroupTerm();
41 
42  if(haveRealPattern && !additionalFilters.isEmpty()) {
43  pattern += additionalFilters;
44  }
45 
46  return QLatin1String( "{ " ) + pattern.join(QString()) + QLatin1String( "} . " );
47 }
48 
49 
50 bool Nepomuk2::Query::AndTermPrivate::hasRealPattern() const
51 {
52  Q_FOREACH( const Nepomuk2::Query::Term& term, m_subTerms ) {
53  if( term.isComparisonTerm() ||
54  term.isResourceTypeTerm() ) {
55  return true;
56  }
57  }
58  return false;
59 }
60 
61 
62 Nepomuk2::Query::AndTerm::AndTerm()
63  : GroupTerm( new AndTermPrivate() )
64 {
65 }
66 
67 
68 Nepomuk2::Query::AndTerm::AndTerm( const AndTerm& term )
69  : GroupTerm( term )
70 {
71 }
72 
73 
74 Nepomuk2::Query::AndTerm::AndTerm( const Term& term1,
75  const Term& term2,
76  const Term& term3,
77  const Term& term4,
78  const Term& term5,
79  const Term& term6 )
80  : GroupTerm( new AndTermPrivate(),
81  term1,
82  term2,
83  term3,
84  term4,
85  term5,
86  term6 )
87 {
88 }
89 
90 
91 Nepomuk2::Query::AndTerm::AndTerm( const QList<Term>& terms )
92  : GroupTerm( new AndTermPrivate() )
93 {
94  setSubTerms( terms );
95 }
96 
97 
98 Nepomuk2::Query::AndTerm::~AndTerm()
99 {
100 }
101 
102 
103 Nepomuk2::Query::AndTerm& Nepomuk2::Query::AndTerm::operator=( const AndTerm& term )
104 {
105  d_ptr = term.d_ptr;
106  return *this;
107 }
andterm.h
Nepomuk2::Query::AndTerm
Match resource that match all sub terms.
Definition: andterm.h:43
Nepomuk2::Query::Term::isComparisonTerm
bool isComparisonTerm() const
Definition: term.cpp:199
Nepomuk2::Query::Term
The base class for all term types.
Definition: term.h:64
Nepomuk2::Query::AndTerm::~AndTerm
~AndTerm()
Destructor.
Definition: andterm.cpp:98
Nepomuk2::Query::GroupTerm
Abstract base class for AndTerm and OrTerm which maintains a list of sub-terms.
Definition: groupterm.h:41
Nepomuk2::Query::AndTerm::operator=
AndTerm & operator=(const AndTerm &term)
Assignment operator.
Definition: andterm.cpp:103
Nepomuk2::Query::GroupTerm::setSubTerms
void setSubTerms(const QList< Term > &terms)
Set the sub terms that are combined in this group.
Definition: groupterm.cpp:101
Nepomuk2::Query::Term::isResourceTypeTerm
bool isResourceTypeTerm() const
Definition: term.cpp:205
Nepomuk2::Query::AndTerm::AndTerm
AndTerm()
Default constructor: creates an invalid and-term.
Definition: andterm.cpp:62
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