summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp2
1 files changed, 1 insertions, 1 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
@@ -162,97 +162,97 @@ bool ODateBookAccessBackend_SQL::load()
162 QMap<int, QString>::Iterator it; 162 QMap<int, QString>::Iterator it;
163 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 163 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
164 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); 164 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
165 } 165 }
166 qu += " );"; 166 qu += " );";
167 167
168 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; 168 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
169 169
170 OSQLRawQuery raw( qu ); 170 OSQLRawQuery raw( qu );
171 OSQLResult res = m_driver->query( &raw ); 171 OSQLResult res = m_driver->query( &raw );
172 if ( res.state() != OSQLResult::Success ) 172 if ( res.state() != OSQLResult::Success )
173 return false; 173 return false;
174 174
175 update(); 175 update();
176 176
177 return true; 177 return true;
178} 178}
179 179
180void ODateBookAccessBackend_SQL::update() 180void 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
195bool ODateBookAccessBackend_SQL::reload() 195bool ODateBookAccessBackend_SQL::reload()
196{ 196{
197 return load(); 197 return load();
198} 198}
199 199
200bool ODateBookAccessBackend_SQL::save() 200bool 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
205QArray<int> ODateBookAccessBackend_SQL::allRecords()const 205QArray<int> ODateBookAccessBackend_SQL::allRecords()const
206{ 206{
207 return m_uids; 207 return m_uids;
208} 208}
209 209
210QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) { 210QArray<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
215void ODateBookAccessBackend_SQL::clear() 215void 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
227OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ 227OPimEvent 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 ) );
243 243
244 // Now insert the data out of the columns into the map. 244 // Now insert the data out of the columns into the map.
245 QMapConstIterator<int, QString> it; 245 QMapConstIterator<int, QString> it;
246 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 246 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
247 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); 247 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
248 } 248 }
249 249
250 // Last step: Put map into date event, add custom map and return it 250 // Last step: Put map into date event, add custom map and return it
251 OPimEvent retDate( dateEventMap ); 251 OPimEvent retDate( dateEventMap );
252 retDate.setExtraMap( requestCustom( uid ) ); 252 retDate.setExtraMap( requestCustom( uid ) );
253 253
254 odebug << "ODateBookAccessBackend_SQL::find( " << uid << " ) end" << oendl; 254 odebug << "ODateBookAccessBackend_SQL::find( " << uid << " ) end" << oendl;
255 return retDate; 255 return retDate;
256} 256}
257 257
258// FIXME: Speed up update of uid's.. 258// FIXME: Speed up update of uid's..