2
This file is part of the Nepomuk KDE project.
3
Copyright (C) 2010 Vishesh Handa <handa.vish@gmail.com>
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.
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.
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/>.
26
#include <QtCore/QUrl>
27
#include <QtCore/QTextStream>
36
class ChangeLogRecord;
39
* \class ChangeLog changelog.h
41
* Consists of a set of ChangeLogRecords.
43
* In order to use the Sync API, a list of changes or a ChangeLog has
44
* to be provided. It is advisable to keep the internal records sorted on
45
* the basis of their time stamp, but that IS NOT enforced.
49
* \author Vishesh Handa <handa.vish@gmail.com>
55
ChangeLog( const ChangeLog & rhs );
59
* Converts \p st into a list of ChangeLogRecords. The dateTime is set
60
* to the current time, and all statements are marked as added.
62
static ChangeLog fromList( const QList<Soprano::Statement> & st );
64
static ChangeLog fromList( const QList<ChangeLogRecord> & records );
67
* Load all statements from graph \p graphUri in the \p model into a list of
68
* ChangeLogRecord. The dateTime is set to the current time, and all
69
* statements are marked as added.
71
* By default the main model is used.
73
static ChangeLog fromGraphUri( const QUrl& graphUri, Soprano::Model * model = 0 );
76
* Load all statements from all contexts in \p graphUrlList into a list of
77
* ChangeLogRecord. The dateTime is set to the current time, and all
78
* statements are marked as added.
80
static ChangeLog fromGraphUriList( const QList< QUrl >& graphUriList, Soprano::Model* model = 0 );
83
static ChangeLog fromUrl( const QUrl & url );
84
static ChangeLog fromUrl( const QUrl & url, const QDateTime & min );
87
* Saves all the internal records in url. The records are saved in plain text form
89
bool save( const QUrl & url ) const;
95
virtual void add( const ChangeLogRecord & record );
99
QList<ChangeLogRecord> toList() const;
102
* Changes all the added statements to removed and vice versa
107
* Removes all the records whose subject is not present in \p nepomukUris
109
void filter( const QSet<QUrl> & nepomukUris );
112
* Concatenates the records held by the two ChangeLogs
114
ChangeLog & operator +=( const ChangeLog & log );
115
ChangeLog& operator +=( const ChangeLogRecord & record );
117
ChangeLog& operator=( const ChangeLog & rhs );
119
void removeRecordsAfter( const QDateTime& dt );
120
void removeRecordsBefore( const QDateTime & dt );
123
* Return uri of all objects and subjects in changelog
125
QSet<QUrl> resources() const;
127
* Return uri of all subjects in changelog
129
QSet<QUrl> subjects() const;
131
// trueg: do we really only have resource objects here? No literals at all?
133
* Return uri of all objects in changelog
135
QSet<QUrl> objects() const;
137
static QString dateTimeFormat();
144
QTextStream& operator<<( QTextStream & ts, const ChangeLog & log );
145
QDebug operator<<( QDebug debug, const ChangeLog & log );
148
#endif // CHANGELOG_H