~ubuntu-branches/ubuntu/natty/kdebase-runtime/natty-proposed

« back to all changes in this revision

Viewing changes to nepomuk/kioslaves/common/timelinetools.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-24 11:07:10 UTC
  • mto: (0.8.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: james.westby@ubuntu.com-20101124110710-6dbsyw0yh21qvn82
Tags: upstream-4.5.80
ImportĀ upstreamĀ versionĀ 4.5.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   Copyright (C) 2010 Sebastian Trueg <trueg@kde.org>
4
4
 
5
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 version 2 as published by the Free Software Foundation.
 
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.
8
12
 
9
13
   This library is distributed in the hope that it will be useful,
10
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
   Library General Public License for more details.
 
16
   Lesser General Public License for more details.
13
17
 
14
 
   You should have received a copy of the GNU Library General Public License
15
 
   along with this library; see the file COPYING.LIB.  If not, write to
16
 
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
 
   Boston, MA 02110-1301, USA.
 
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/>.
18
20
 */
19
21
 
20
22
#include "timelinetools.h"
22
24
#include <Soprano/Node>
23
25
#include <Soprano/Vocabulary/XMLSchema>
24
26
 
25
 
#include "nie.h"
26
 
#include "nfo.h"
27
 
#include "nie.h"
28
 
#include "nuao.h"
 
27
#include <Nepomuk/Vocabulary/NFO>
 
28
#include <Nepomuk/Vocabulary/NIE>
 
29
#include <Nepomuk/Vocabulary/NUAO>
 
30
 
 
31
#include <Nepomuk/Query/FileQuery>
 
32
#include <Nepomuk/Query/AndTerm>
 
33
#include <Nepomuk/Query/OrTerm>
 
34
#include <Nepomuk/Query/ComparisonTerm>
 
35
#include <Nepomuk/Query/LiteralTerm>
 
36
#include <Nepomuk/Query/StandardQuery>
29
37
 
30
38
#include <KUrl>
31
39
#include <KCalendarSystem>
141
149
}
142
150
 
143
151
 
144
 
KUrl Nepomuk::buildTimelineQueryUrl( const QDate& date )
 
152
Nepomuk::Query::Query Nepomuk::buildTimelineQuery( const QDate& date )
145
153
{
146
 
    static const char* DATEFORMATSTART("yyyy-MM-ddT00:00:00.000Z");
147
 
    static const char* DATEFORMATEND("yyyy-MM-ddT23:59:59.999Z");
148
 
 
149
 
    QString dateFrom = date.toString(DATEFORMATSTART);
150
 
    QString dateTo = date.toString(DATEFORMATEND);
151
 
 
152
 
    QString query = QString("select distinct ?r where { "
153
 
                            "?r a %1 . "
154
 
                            "{ ?r %2 ?date . } "
155
 
                            "UNION "
156
 
                            "{ ?r %3 ?date . } "
157
 
                            "UNION "
158
 
                            "{ ?r %4 ?date . } "
159
 
                            "FILTER(?date > '%5'^^%7 && ?date < '%6'^^%7) . "
160
 
                            "OPTIONAL { ?r2 a %8 . FILTER(?r=?r2) . } . FILTER(!BOUND(?r2)) . "
161
 
                            "}")
162
 
                    .arg( Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NFO::FileDataObject()),
163
 
                          Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NIE::lastModified()),
164
 
                          Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NUAO::lastUsage()),
165
 
                          Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NIE::contentCreated()),
166
 
                          dateFrom,
167
 
                          dateTo,
168
 
                          Soprano::Node::resourceToN3(Soprano::Vocabulary::XMLSchema::dateTime()),
169
 
                          Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NFO::Folder()) );
170
 
    KUrl url("nepomuksearch:/");
171
 
    url.addQueryItem( "sparql", query );
172
 
    return url;
 
154
    Nepomuk::Query::FileQuery query = Nepomuk::Query::dateRangeQuery( date, date );
 
155
    query.setFileMode( Query::FileQuery::QueryFiles );
 
156
    return query;
173
157
}