-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_sql.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp index 629e4da..78c3bf7 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | |||
@@ -178,65 +178,65 @@ bool ODateBookAccessBackend_SQL::load() | |||
178 | } | 178 | } |
179 | 179 | ||
180 | void ODateBookAccessBackend_SQL::update() | 180 | void ODateBookAccessBackend_SQL::update() |
181 | { | 181 | { |
182 | 182 | ||
183 | QString qu = "select uid from datebook"; | 183 | QString qu = "select uid from datebook"; |
184 | OSQLRawQuery raw( qu ); | 184 | OSQLRawQuery raw( qu ); |
185 | OSQLResult res = m_driver->query( &raw ); | 185 | OSQLResult res = m_driver->query( &raw ); |
186 | if ( res.state() != OSQLResult::Success ){ | 186 | if ( res.state() != OSQLResult::Success ){ |
187 | // m_uids.clear(); | 187 | // m_uids.clear(); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | 190 | ||
191 | m_uids = extractUids( res ); | 191 | m_uids = extractUids( res ); |
192 | 192 | ||
193 | } | 193 | } |
194 | 194 | ||
195 | bool ODateBookAccessBackend_SQL::reload() | 195 | bool ODateBookAccessBackend_SQL::reload() |
196 | { | 196 | { |
197 | return load(); | 197 | return load(); |
198 | } | 198 | } |
199 | 199 | ||
200 | bool ODateBookAccessBackend_SQL::save() | 200 | bool ODateBookAccessBackend_SQL::save() |
201 | { | 201 | { |
202 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) | 202 | return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) |
203 | } | 203 | } |
204 | 204 | ||
205 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const | 205 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const |
206 | { | 206 | { |
207 | return m_uids; | 207 | return m_uids; |
208 | } | 208 | } |
209 | 209 | ||
210 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) { | 210 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const int& unUsed, int settings, const QDateTime& ) { |
211 | qDebug( "Accessing ODateBookAccessBackend_SQL::queryByExample() which is not implemented!" ); | 211 | qDebug( "Accessing ODateBookAccessBackend_SQL::queryByExample() which is not implemented!" ); |
212 | return QArray<int>(); | 212 | return QArray<int>(); |
213 | } | 213 | } |
214 | 214 | ||
215 | void ODateBookAccessBackend_SQL::clear() | 215 | void ODateBookAccessBackend_SQL::clear() |
216 | { | 216 | { |
217 | QString qu = "drop table datebook;"; | 217 | QString qu = "drop table datebook;"; |
218 | qu += "drop table custom_data;"; | 218 | qu += "drop table custom_data;"; |
219 | 219 | ||
220 | OSQLRawQuery raw( qu ); | 220 | OSQLRawQuery raw( qu ); |
221 | OSQLResult res = m_driver->query( &raw ); | 221 | OSQLResult res = m_driver->query( &raw ); |
222 | 222 | ||
223 | reload(); | 223 | reload(); |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ | 227 | OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ |
228 | odebug << "ODateBookAccessBackend_SQL::find( " << uid << " )" << oendl; | 228 | odebug << "ODateBookAccessBackend_SQL::find( " << uid << " )" << oendl; |
229 | 229 | ||
230 | QString qu = "select *"; | 230 | QString qu = "select *"; |
231 | qu += "from datebook where uid = " + QString::number(uid); | 231 | qu += "from datebook where uid = " + QString::number(uid); |
232 | 232 | ||
233 | odebug << "Query: " << qu << "" << oendl; | 233 | odebug << "Query: " << qu << "" << oendl; |
234 | 234 | ||
235 | OSQLRawQuery raw( qu ); | 235 | OSQLRawQuery raw( qu ); |
236 | OSQLResult res = m_driver->query( &raw ); | 236 | OSQLResult res = m_driver->query( &raw ); |
237 | 237 | ||
238 | OSQLResultItem resItem = res.first(); | 238 | OSQLResultItem resItem = res.first(); |
239 | 239 | ||
240 | // Create Map for date event and insert UID | 240 | // Create Map for date event and insert UID |
241 | QMap<int,QString> dateEventMap; | 241 | QMap<int,QString> dateEventMap; |
242 | dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) ); | 242 | dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) ); |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h index a649d25..2de2dca 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h | |||
@@ -30,65 +30,65 @@ | |||
30 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H | 30 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H |
31 | 31 | ||
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #include <opie2/osqlresult.h> | 33 | #include <opie2/osqlresult.h> |
34 | 34 | ||
35 | #include <opie2/odatebookaccessbackend.h> | 35 | #include <opie2/odatebookaccessbackend.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | namespace DB { | 38 | namespace DB { |
39 | class OSQLDriver; | 39 | class OSQLDriver; |
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | namespace Opie { | 43 | namespace Opie { |
44 | /** | 44 | /** |
45 | * This is the default SQL implementation for DateBoook SQL storage | 45 | * This is the default SQL implementation for DateBoook SQL storage |
46 | * It fully implements the interface | 46 | * It fully implements the interface |
47 | * @see ODateBookAccessBackend | 47 | * @see ODateBookAccessBackend |
48 | * @see OPimAccessBackend | 48 | * @see OPimAccessBackend |
49 | */ | 49 | */ |
50 | class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { | 50 | class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { |
51 | public: | 51 | public: |
52 | ODateBookAccessBackend_SQL( const QString& appName, | 52 | ODateBookAccessBackend_SQL( const QString& appName, |
53 | const QString& fileName = QString::null); | 53 | const QString& fileName = QString::null); |
54 | ~ODateBookAccessBackend_SQL(); | 54 | ~ODateBookAccessBackend_SQL(); |
55 | 55 | ||
56 | bool load(); | 56 | bool load(); |
57 | bool reload(); | 57 | bool reload(); |
58 | bool save(); | 58 | bool save(); |
59 | 59 | ||
60 | QArray<int> allRecords()const; | 60 | QArray<int> allRecords()const; |
61 | QArray<int> matchRegexp(const QRegExp &r) const; | 61 | QArray<int> matchRegexp(const QRegExp &r) const; |
62 | QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() ); | 62 | QArray<int> queryByExample( const int& unUsed, int settings, const QDateTime& d = QDateTime() ); |
63 | OPimEvent find( int uid )const; | 63 | OPimEvent find( int uid )const; |
64 | void clear(); | 64 | void clear(); |
65 | bool add( const OPimEvent& ev ); | 65 | bool add( const OPimEvent& ev ); |
66 | bool remove( int uid ); | 66 | bool remove( int uid ); |
67 | bool replace( const OPimEvent& ev ); | 67 | bool replace( const OPimEvent& ev ); |
68 | 68 | ||
69 | QArray<UID> rawRepeats()const; | 69 | QArray<UID> rawRepeats()const; |
70 | QArray<UID> nonRepeats()const; | 70 | QArray<UID> nonRepeats()const; |
71 | 71 | ||
72 | OPimEvent::ValueList directNonRepeats()const; | 72 | OPimEvent::ValueList directNonRepeats()const; |
73 | OPimEvent::ValueList directRawRepeats()const; | 73 | OPimEvent::ValueList directRawRepeats()const; |
74 | 74 | ||
75 | private: | 75 | private: |
76 | bool loadFile(); | 76 | bool loadFile(); |
77 | QString m_fileName; | 77 | QString m_fileName; |
78 | QArray<int> m_uids; | 78 | QArray<int> m_uids; |
79 | 79 | ||
80 | QMap<int, QString> m_fieldMap; | 80 | QMap<int, QString> m_fieldMap; |
81 | QMap<QString, int> m_reverseFieldMap; | 81 | QMap<QString, int> m_reverseFieldMap; |
82 | 82 | ||
83 | Opie::DB::OSQLDriver* m_driver; | 83 | Opie::DB::OSQLDriver* m_driver; |
84 | 84 | ||
85 | class Private; | 85 | class Private; |
86 | Private *d; | 86 | Private *d; |
87 | 87 | ||
88 | void initFields(); | 88 | void initFields(); |
89 | void update(); | 89 | void update(); |
90 | 90 | ||
91 | QArray<int> extractUids( Opie::DB::OSQLResult& res ) const; | 91 | QArray<int> extractUids( Opie::DB::OSQLResult& res ) const; |
92 | QMap<QString, QString> requestCustom( int uid ) const; | 92 | QMap<QString, QString> requestCustom( int uid ) const; |
93 | 93 | ||
94 | }; | 94 | }; |