forked from sialan-labs/kaqaz
-
Notifications
You must be signed in to change notification settings - Fork 12
/
database.h
208 lines (156 loc) · 6.16 KB
/
database.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
Copyright (C) 2014 Aseman
http://aseman.co
Papyrus is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Papyrus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATABASE_H
#define DATABASE_H
#define GROUPS_SYNC_KEY "Groups"
#define NO_GROUP_UUID "{47e4f990-c3db-4077-bb22-81172160986b}"
#include "databasedatatypes.h"
#include <QObject>
#include <QDate>
#include <QRectF>
#include <QList>
#include <QHash>
#include <QVariant>
class QSqlQuery;
class DatabasePrivate;
class Database : public QObject
{
Q_OBJECT
Q_ENUMS(PasswordType)
friend class PaperCoreObject;
public:
enum PasswordType {
Numeric = 0,
Characters = 1
};
Database(QObject *parent = 0);
~Database();
public slots:
void connect();
void disconnect();
void setPath( const QString & path );
QString path() const;
void setCurrentActivity( int activity );
int currentActivity() const;
QList<int> dates();
QList<int> lastThreeDays();
int papersCountOf( const QDate & date );
QList<int> papersOf( const QDate & date );
QList<int> papersOf( int group_id );
QList<int> papers();
QList<int> search(const QString & keyword );
QList<int> advanceSearch(const QString & keyword, const QDate & startDate, const QDate & endDate, const QTime & startTime, const QTime & endTime, int group, int domain, const QRectF &geo = QRectF(), const QString & weather = QString() );
int createPaper(const QString &uuid = QString());
void deletePaper( int id );
void setPaper(int id, const QString & title, const QString & text, int group );
void setPaper(const QString & uuid, const QString & title, const QString & text, const QString & group, const QString & date, const QGeoCoordinate & location , int type, const QString & weather, int temperature);
QString paperTitle( int id );
void setPaperTitle( int id, const QString & title );
QString paperText( int id );
void setPaperText( int id, const QString & text );
int paperType( int id );
void setPaperType( int id, int type );
int paperTemperature( int id );
void setPaperTemperature( int id, int tmp );
QString paperWeather( int id );
void setPaperWeather( int id, const QString & weather );
QGeoCoordinate paperLocation( int id );
void setPaperLocation( int id, const QGeoCoordinate & coo );
void setPaperLocation(int id, const QPointF & point );
int paperGroup( int id );
void setPaperGroup( int id, int group );
QDateTime paperCreatedDate( int id );
void setPaperCreatedDate( int id, const QDateTime & dt );
QDateTime paperModifiedDate( int id );
QString paperUuid( int id );
int paperActivity( int id );
int paperUuidId( const QString & uuid );
QStringList paperFiles( int id );
bool hasFiles( int id );
void addFileToPaper( int id, const QString & file );
void addCustomFileToPaper( int id, const QString & file, qint64 date );
void removeFileFromPaper( int id, const QString & file );
bool fileContaintOnDatabase( const QString & file );
qint64 fileTime( int id, const QString & file );
QList<int> groups();
bool groupIsDeleted( int id );
int createGroup(const QString &uuid = QString());
void deleteGroup( int id );
void setGroup( const QString & uuid, const QString & name, const QString & color );
QString groupName( int id );
void setGroupName( int id, const QString & name );
QColor groupColor( int id );
void setGroupColor(int id , const QColor &color);
QString groupUuid( int id );
int groupUuidId( const QString & uuid );
int groupPapersCount( int id );
QList<int> activities();
int passwordType();
QString password();
void setPassword(const QString & pass, int type = Numeric );
QString syncPassword();
void setSyncPassword( const QString & pass );
QString value( const QString & property );
void setValue( const QString & property, const QString & value );
int statePapersCount();
int stateDatesCount();
int stateGroupsCount();
void setRevision( const QString & id, int revisionOf );
int revisionOf( const QString & id ) const;
SyncItemHash revisions() const;
void setSignalBlocker(bool stt );
void begin();
void commit();
signals:
void currentActivityChanged();
void groupsListChanged();
void datesListChanged();
void activityListChanged();
void revisionsChanged();
void revisionChanged( const QString &iid, int revision );
void filesListChanged();
void fileDeleted( const QString & file );
void groupNameChanged(int id);
void groupColorChanged(int id);
void groupPapersCountChanged(int id);
void paperChanged( int id );
void paperCreated(int id);
void paperDeleted(int id);
void paperUuidChanged(int id);
void paperTitleChanged(int id);
void paperTextChanged(int id);
void paperCreateChanged(int id);
void paperModifiedChanged(int id);
void paperLocationChanged(int id);
void paperGroupChanged(int id);
void paperActivityChanged(int id);
void paperWeatherChanged(int id);
void paperTemperatureChanged(int id);
void paperFilesChanged(int id);
void paperTypeChanged(int id);
private:
void reinit_buffer();
void update_database();
void savePaper(PaperClass paper);
void saveGroup(GroupClass group);
void saveActivity(ActivityClass activity);
PaperClass getPaper( int id );
QList<int> searchQuery(const QString &query , const QString &keyword, const QHash<QString, QVariant> &boundValues = QHash<QString, QVariant>());
protected:
void timerEvent(QTimerEvent *e);
private:
DatabasePrivate *p;
};
#endif // DATABASE_H