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.cpp15
1 files changed, 2 insertions, 13 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index 105c106..41b714e 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -164,14 +164,12 @@ bool ODateBookAccessBackend_SQL::load()
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 owarn << "command: " << qu << "" << oendl;
171
172 OSQLRawQuery raw( qu ); 170 OSQLRawQuery raw( qu );
173 OSQLResult res = m_driver->query( &raw ); 171 OSQLResult res = m_driver->query( &raw );
174 if ( res.state() != OSQLResult::Success ) 172 if ( res.state() != OSQLResult::Success )
175 return false; 173 return false;
176 174
177 update(); 175 update();
@@ -285,13 +283,12 @@ bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
285 + "'," 283 + "',"
286 + "0" // Priority for future enhancements 284 + "0" // Priority for future enhancements
287 + ",'" 285 + ",'"
288 + it.data() //.latin1() 286 + it.data() //.latin1()
289 + "');"; 287 + "');";
290 } 288 }
291 owarn << "add " << qu << "" << oendl;
292 289
293 OSQLRawQuery raw( qu ); 290 OSQLRawQuery raw( qu );
294 OSQLResult res = m_driver->query( &raw ); 291 OSQLResult res = m_driver->query( &raw );
295 if ( res.state() != OSQLResult::Success ){ 292 if ( res.state() != OSQLResult::Success ){
296 return false; 293 return false;
297 } 294 }
@@ -325,16 +322,12 @@ bool ODateBookAccessBackend_SQL::remove( int uid )
325bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev ) 322bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev )
326{ 323{
327 remove( ev.uid() ); 324 remove( ev.uid() );
328 return add( ev ); 325 return add( ev );
329} 326}
330 327
331QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
332{
333 return allRecords();
334}
335 328
336QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const 329QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const
337{ 330{
338 QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\""; 331 QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\"";
339 OSQLRawQuery raw( qu ); 332 OSQLRawQuery raw( qu );
340 OSQLResult res = m_driver->query( &raw ); 333 OSQLResult res = m_driver->query( &raw );
@@ -356,25 +349,25 @@ QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const
356 return nix; 349 return nix;
357 } 350 }
358 351
359 return extractUids( res ); 352 return extractUids( res );
360} 353}
361 354
362OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() 355OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()const
363{ 356{
364 QArray<int> nonRepUids = nonRepeats(); 357 QArray<int> nonRepUids = nonRepeats();
365 OPimEvent::ValueList list; 358 OPimEvent::ValueList list;
366 359
367 for (uint i = 0; i < nonRepUids.count(); ++i ){ 360 for (uint i = 0; i < nonRepUids.count(); ++i ){
368 list.append( find( nonRepUids[i] ) ); 361 list.append( find( nonRepUids[i] ) );
369 } 362 }
370 363
371 return list; 364 return list;
372 365
373} 366}
374OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() 367OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()const
375{ 368{
376 QArray<int> rawRepUids = rawRepeats(); 369 QArray<int> rawRepUids = rawRepeats();
377 OPimEvent::ValueList list; 370 OPimEvent::ValueList list;
378 371
379 for (uint i = 0; i < rawRepUids.count(); ++i ){ 372 for (uint i = 0; i < rawRepUids.count(); ++i ){
380 list.append( find( rawRepUids[i] ) ); 373 list.append( find( rawRepUids[i] ) );
@@ -407,26 +400,23 @@ QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
407} 400}
408 401
409/* ===== Private Functions ========================================== */ 402/* ===== Private Functions ========================================== */
410 403
411QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const 404QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
412{ 405{
413 owarn << "extractUids" << oendl;
414 QTime t; 406 QTime t;
415 t.start(); 407 t.start();
416 OSQLResultItem::ValueList list = res.results(); 408 OSQLResultItem::ValueList list = res.results();
417 OSQLResultItem::ValueList::Iterator it; 409 OSQLResultItem::ValueList::Iterator it;
418 QArray<int> ints(list.count() ); 410 QArray<int> ints(list.count() );
419 owarn << " count = " << list.count() << "" << oendl;
420 411
421 int i = 0; 412 int i = 0;
422 for (it = list.begin(); it != list.end(); ++it ) { 413 for (it = list.begin(); it != list.end(); ++it ) {
423 ints[i] = (*it).data("uid").toInt(); 414 ints[i] = (*it).data("uid").toInt();
424 i++; 415 i++;
425 } 416 }
426 owarn << "extractUids ready: count2 = " << i << " needs " << t.elapsed() << " ms" << oendl;
427 417
428 return ints; 418 return ints;
429 419
430} 420}
431 421
432QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) const 422QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) const
@@ -437,13 +427,12 @@ QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) cons
437 QMap<QString, QString> customMap; 427 QMap<QString, QString> customMap;
438 428
439 FindCustomQuery query( uid ); 429 FindCustomQuery query( uid );
440 OSQLResult res_custom = m_driver->query( &query ); 430 OSQLResult res_custom = m_driver->query( &query );
441 431
442 if ( res_custom.state() == OSQLResult::Failure ) { 432 if ( res_custom.state() == OSQLResult::Failure ) {
443 owarn << "OSQLResult::Failure in find query !!" << oendl;
444 QMap<QString, QString> empty; 433 QMap<QString, QString> empty;
445 return empty; 434 return empty;
446 } 435 }
447 436
448 OSQLResultItem::ValueList list = res_custom.results(); 437 OSQLResultItem::ValueList list = res_custom.results();
449 OSQLResultItem::ValueList::Iterator it = list.begin(); 438 OSQLResultItem::ValueList::Iterator it = list.begin();