Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp index e79696c..2ee76cc 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | |||
@@ -40,13 +40,13 @@ | |||
40 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
41 | 41 | ||
42 | #include <opie2/osqldriver.h> | 42 | #include <opie2/osqldriver.h> |
43 | #include <opie2/osqlmanager.h> | 43 | #include <opie2/osqlmanager.h> |
44 | #include <opie2/osqlquery.h> | 44 | #include <opie2/osqlquery.h> |
45 | 45 | ||
46 | #include <opie2/orecur.h> | 46 | #include <opie2/opimrecurrence.h> |
47 | #include <opie2/odatebookaccessbackend_sql.h> | 47 | #include <opie2/odatebookaccessbackend_sql.h> |
48 | 48 | ||
49 | namespace Opie { | 49 | namespace Opie { |
50 | 50 | ||
51 | 51 | ||
52 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , | 52 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , |
@@ -72,33 +72,33 @@ ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { | |||
72 | 72 | ||
73 | void ODateBookAccessBackend_SQL::initFields() | 73 | void ODateBookAccessBackend_SQL::initFields() |
74 | { | 74 | { |
75 | 75 | ||
76 | // This map contains the translation of the fieldtype id's to | 76 | // This map contains the translation of the fieldtype id's to |
77 | // the names of the table columns | 77 | // the names of the table columns |
78 | m_fieldMap.insert( OEvent::FUid, "uid" ); | 78 | m_fieldMap.insert( OPimEvent::FUid, "uid" ); |
79 | m_fieldMap.insert( OEvent::FCategories, "Categories" ); | 79 | m_fieldMap.insert( OPimEvent::FCategories, "Categories" ); |
80 | m_fieldMap.insert( OEvent::FDescription, "Description" ); | 80 | m_fieldMap.insert( OPimEvent::FDescription, "Description" ); |
81 | m_fieldMap.insert( OEvent::FLocation, "Location" ); | 81 | m_fieldMap.insert( OPimEvent::FLocation, "Location" ); |
82 | m_fieldMap.insert( OEvent::FType, "Type" ); | 82 | m_fieldMap.insert( OPimEvent::FType, "Type" ); |
83 | m_fieldMap.insert( OEvent::FAlarm, "Alarm" ); | 83 | m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" ); |
84 | m_fieldMap.insert( OEvent::FSound, "Sound" ); | 84 | m_fieldMap.insert( OPimEvent::FSound, "Sound" ); |
85 | m_fieldMap.insert( OEvent::FRType, "RType" ); | 85 | m_fieldMap.insert( OPimEvent::FRType, "RType" ); |
86 | m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" ); | 86 | m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" ); |
87 | m_fieldMap.insert( OEvent::FRPosition, "RPosition" ); | 87 | m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" ); |
88 | m_fieldMap.insert( OEvent::FRFreq, "RFreq" ); | 88 | m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" ); |
89 | m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" ); | 89 | m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" ); |
90 | m_fieldMap.insert( OEvent::FREndDate, "REndDate" ); | 90 | m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" ); |
91 | m_fieldMap.insert( OEvent::FRCreated, "RCreated" ); | 91 | m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" ); |
92 | m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" ); | 92 | m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" ); |
93 | m_fieldMap.insert( OEvent::FStart, "Start" ); | 93 | m_fieldMap.insert( OPimEvent::FStart, "Start" ); |
94 | m_fieldMap.insert( OEvent::FEnd, "End" ); | 94 | m_fieldMap.insert( OPimEvent::FEnd, "End" ); |
95 | m_fieldMap.insert( OEvent::FNote, "Note" ); | 95 | m_fieldMap.insert( OPimEvent::FNote, "Note" ); |
96 | m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" ); | 96 | m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" ); |
97 | m_fieldMap.insert( OEvent::FRecParent, "RecParent" ); | 97 | m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" ); |
98 | m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" ); | 98 | m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" ); |
99 | 99 | ||
100 | // Create a map that maps the column name to the id | 100 | // Create a map that maps the column name to the id |
101 | QMapConstIterator<int, QString> it; | 101 | QMapConstIterator<int, QString> it; |
102 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 102 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
103 | m_reverseFieldMap.insert( it.data(), it.key() ); | 103 | m_reverseFieldMap.insert( it.data(), it.key() ); |
104 | } | 104 | } |
@@ -162,13 +162,13 @@ bool ODateBookAccessBackend_SQL::save() | |||
162 | 162 | ||
163 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const | 163 | QArray<int> ODateBookAccessBackend_SQL::allRecords()const |
164 | { | 164 | { |
165 | return m_uids; | 165 | return m_uids; |
166 | } | 166 | } |
167 | 167 | ||
168 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) { | 168 | QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) { |
169 | return QArray<int>(); | 169 | return QArray<int>(); |
170 | } | 170 | } |
171 | 171 | ||
172 | void ODateBookAccessBackend_SQL::clear() | 172 | void ODateBookAccessBackend_SQL::clear() |
173 | { | 173 | { |
174 | QString qu = "drop table datebook;"; | 174 | QString qu = "drop table datebook;"; |
@@ -178,39 +178,39 @@ void ODateBookAccessBackend_SQL::clear() | |||
178 | OSQLResult res = m_driver->query( &raw ); | 178 | OSQLResult res = m_driver->query( &raw ); |
179 | 179 | ||
180 | reload(); | 180 | reload(); |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | OEvent ODateBookAccessBackend_SQL::find( int uid ) const{ | 184 | OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ |
185 | QString qu = "select *"; | 185 | QString qu = "select *"; |
186 | qu += "from datebook where uid = " + QString::number(uid); | 186 | qu += "from datebook where uid = " + QString::number(uid); |
187 | 187 | ||
188 | OSQLRawQuery raw( qu ); | 188 | OSQLRawQuery raw( qu ); |
189 | OSQLResult res = m_driver->query( &raw ); | 189 | OSQLResult res = m_driver->query( &raw ); |
190 | 190 | ||
191 | OSQLResultItem resItem = res.first(); | 191 | OSQLResultItem resItem = res.first(); |
192 | 192 | ||
193 | // Create Map for date event and insert UID | 193 | // Create Map for date event and insert UID |
194 | QMap<int,QString> dateEventMap; | 194 | QMap<int,QString> dateEventMap; |
195 | dateEventMap.insert( OEvent::FUid, QString::number( uid ) ); | 195 | dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) ); |
196 | 196 | ||
197 | // Now insert the data out of the columns into the map. | 197 | // Now insert the data out of the columns into the map. |
198 | QMapConstIterator<int, QString> it; | 198 | QMapConstIterator<int, QString> it; |
199 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 199 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
200 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); | 200 | dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); |
201 | } | 201 | } |
202 | 202 | ||
203 | // Last step: Put map into date event and return it | 203 | // Last step: Put map into date event and return it |
204 | OEvent retDate( dateEventMap ); | 204 | OPimEvent retDate( dateEventMap ); |
205 | 205 | ||
206 | return retDate; | 206 | return retDate; |
207 | } | 207 | } |
208 | 208 | ||
209 | // FIXME: Speed up update of uid's.. | 209 | // FIXME: Speed up update of uid's.. |
210 | bool ODateBookAccessBackend_SQL::add( const OEvent& ev ) | 210 | bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev ) |
211 | { | 211 | { |
212 | QMap<int,QString> eventMap = ev.toMap(); | 212 | QMap<int,QString> eventMap = ev.toMap(); |
213 | 213 | ||
214 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); | 214 | QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); |
215 | QMap<int, QString>::Iterator it; | 215 | QMap<int, QString>::Iterator it; |
216 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ | 216 | for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ |
@@ -269,13 +269,13 @@ bool ODateBookAccessBackend_SQL::remove( int uid ) | |||
269 | // Update list of uid's | 269 | // Update list of uid's |
270 | update(); | 270 | update(); |
271 | 271 | ||
272 | return true; | 272 | return true; |
273 | } | 273 | } |
274 | 274 | ||
275 | bool ODateBookAccessBackend_SQL::replace( const OEvent& ev ) | 275 | bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev ) |
276 | { | 276 | { |
277 | remove( ev.uid() ); | 277 | remove( ev.uid() ); |
278 | return add( ev ); | 278 | return add( ev ); |
279 | } | 279 | } |
280 | 280 | ||
281 | QArray<int> ODateBookAccessBackend_SQL::rawEvents()const | 281 | QArray<int> ODateBookAccessBackend_SQL::rawEvents()const |
@@ -306,28 +306,28 @@ QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const | |||
306 | return nix; | 306 | return nix; |
307 | } | 307 | } |
308 | 308 | ||
309 | return extractUids( res ); | 309 | return extractUids( res ); |
310 | } | 310 | } |
311 | 311 | ||
312 | OEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() | 312 | OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() |
313 | { | 313 | { |
314 | QArray<int> nonRepUids = nonRepeats(); | 314 | QArray<int> nonRepUids = nonRepeats(); |
315 | OEvent::ValueList list; | 315 | OPimEvent::ValueList list; |
316 | 316 | ||
317 | for (uint i = 0; i < nonRepUids.count(); ++i ){ | 317 | for (uint i = 0; i < nonRepUids.count(); ++i ){ |
318 | list.append( find( nonRepUids[i] ) ); | 318 | list.append( find( nonRepUids[i] ) ); |
319 | } | 319 | } |
320 | 320 | ||
321 | return list; | 321 | return list; |
322 | 322 | ||
323 | } | 323 | } |
324 | OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() | 324 | OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() |
325 | { | 325 | { |
326 | QArray<int> rawRepUids = rawRepeats(); | 326 | QArray<int> rawRepUids = rawRepeats(); |
327 | OEvent::ValueList list; | 327 | OPimEvent::ValueList list; |
328 | 328 | ||
329 | for (uint i = 0; i < rawRepUids.count(); ++i ){ | 329 | for (uint i = 0; i < rawRepUids.count(); ++i ){ |
330 | list.append( find( rawRepUids[i] ) ); | 330 | list.append( find( rawRepUids[i] ) ); |
331 | } | 331 | } |
332 | 332 | ||
333 | return list; | 333 | return list; |