summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccesssql.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp129
1 files changed, 32 insertions, 97 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 4e3e47b..2bcab29 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -457,3 +457,2 @@ OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
457 return parseResultAndCache( uid, m_driver->query(&query) ); 457 return parseResultAndCache( uid, m_driver->query(&query) );
458
459} 458}
@@ -467,3 +466,2 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
467 uint size =0; 466 uint size =0;
468 OPimTodo to;
469 467
@@ -474,3 +472,2 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
474 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { 472 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
475 odebug << "size " << size << " " << ints[i] << "" << oendl;
476 search[size] = ints[i]; 473 search[size] = ints[i];
@@ -492,3 +489,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
492 if ( res.state() != OSQLResult::Success ) 489 if ( res.state() != OSQLResult::Success )
493 return to; 490 return OPimTodo();
494 491
@@ -509,2 +506,3 @@ bool OPimTodoAccessBackendSQL::add( const OPimTodo& t) {
509 return false; 506 return false;
507
510 int c = m_uids.count(); 508 int c = m_uids.count();
@@ -536,3 +534,3 @@ bool OPimTodoAccessBackendSQL::replace( const OPimTodo& t) {
536} 534}
537QArray<int> OPimTodoAccessBackendSQL::overDue() { 535QArray<int> OPimTodoAccessBackendSQL::overDue()const {
538 OverDueQuery qu; 536 OverDueQuery qu;
@@ -542,3 +540,3 @@ QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s,
542 const QDate& t, 540 const QDate& t,
543 bool u) { 541 bool u)const {
544 EffQuery ef(s, t, u ); 542 EffQuery ef(s, t, u );
@@ -546,2 +544,4 @@ QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s,
546} 544}
545
546#if 0
547/* 547/*
@@ -562,3 +562,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
562 /* Category */ 562 /* Category */
563 if ( sortFilter & 1 ) { 563 if ( sortFilter & OPimTodoAccess::FilterCategory ) {
564 QString str; 564 QString str;
@@ -568,3 +568,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
568 /* Show only overdue */ 568 /* Show only overdue */
569 if ( sortFilter & 2 ) { 569 if ( sortFilter & OPimTodoAccess::OnlyOverDue ) {
570 QDate date = QDate::currentDate(); 570 QDate date = QDate::currentDate();
@@ -579,3 +579,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
579 /* not show completed */ 579 /* not show completed */
580 if ( sortFilter & 4 ) { 580 if ( sortFilter & OPimTodoAccess::DoNotShowCompleted ) {
581 query += " completed = 0 AND"; 581 query += " completed = 0 AND";
@@ -595,12 +595,12 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
595 /* completed */ 595 /* completed */
596 case 0: 596 case OPimTodoAccess::Completed:
597 query += "completed"; 597 query += "completed";
598 break; 598 break;
599 case 1: 599 case OPimTodoAccess::Priority:
600 query += "priority"; 600 query += "priority";
601 break; 601 break;
602 case 2: 602 case OPimTodoAccess::SortSummary:
603 query += "summary"; 603 query += "summary";
604 break; 604 break;
605 case 3: 605 case OPimTodoAccess::Deadline:
606 query += "DueDate"; 606 query += "DueDate";
@@ -609,6 +609,5 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
609 609
610 if ( !asc ) { 610 if ( !asc )
611 odebug << "not ascending!" << oendl;
612 query += " DESC"; 611 query += " DESC";
613 } 612
614 613
@@ -618,2 +617,5 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
618} 617}
618#endif
619
620
619bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ 621bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
@@ -631,2 +633,4 @@ bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
631} 633}
634
635
632OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{ 636OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResult& res ) const{
@@ -641,10 +645,6 @@ OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResul
641 OSQLResultItem::ValueList::Iterator it = list.begin(); 645 OSQLResultItem::ValueList::Iterator it = list.begin();
642 odebug << "todo1" << oendl; 646 OPimTodo to, tmp;
643 OPimTodo to = todo( (*it) );
644 cache( to );
645 ++it;
646 647
647 for ( ; it != list.end(); ++it ) { 648 for ( ; it != list.end(); ++it ) {
648 odebug << "caching" << oendl; 649 OPimTodo newTodo = parse( (*it) );
649 OPimTodo newTodo = todo( (*it) );
650 cache( newTodo ); 650 cache( newTodo );
@@ -655,4 +655,3 @@ OPimTodo OPimTodoAccessBackendSQL::parseResultAndCache( int uid, const OSQLResul
655} 655}
656OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { 656OPimTodo OPimTodoAccessBackendSQL::parse( OSQLResultItem& item )const {
657 odebug << "todo(ResultItem)" << oendl;
658 657
@@ -664,4 +663,2 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
664 663
665 odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl;
666
667 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), 664 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(),
@@ -719,32 +716,4 @@ OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const {
719} 716}
720/*
721 * update the dict
722 */
723void OPimTodoAccessBackendSQL::fillDict() {
724 717
725#if 0
726 /* initialize dict */
727 /*
728 * UPDATE dict if you change anything!!!
729 * FIXME: Isn't this dict obsolete ? (eilers)
730 */
731 m_dict.setAutoDelete( TRUE );
732 m_dict.insert("Categories" , new int(OPimTodo::Category) );
733 m_dict.insert("Uid" , new int(OPimTodo::Uid) );
734 m_dict.insert("HasDate" , new int(OPimTodo::HasDate) );
735 m_dict.insert("Completed" , new int(OPimTodo::Completed) );
736 m_dict.insert("Description" , new int(OPimTodo::Description) );
737 m_dict.insert("Summary" , new int(OPimTodo::Summary) );
738 m_dict.insert("Priority" , new int(OPimTodo::Priority) );
739 m_dict.insert("DateDay" , new int(OPimTodo::DateDay) );
740 m_dict.insert("DateMonth" , new int(OPimTodo::DateMonth) );
741 m_dict.insert("DateYear" , new int(OPimTodo::DateYear) );
742 m_dict.insert("Progress" , new int(OPimTodo::Progress) );
743 m_dict.insert("Completed", new int(OPimTodo::Completed) ); // Why twice ? (eilers)
744 m_dict.insert("CrossReference", new int(OPimTodo::CrossReference) );
745// m_dict.insert("HasAlarmDateTime",new int(OPimTodo::HasAlarmDateTime) ); // old stuff (eilers)
746// m_dict.insert("AlarmDateTime", new int(OPimTodo::AlarmDateTime) ); // old stuff (eilers)
747 718
748#endif
749}
750/* 719/*
@@ -767,3 +736,2 @@ QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
767 QArray<int> ints(list.count() ); 736 QArray<int> ints(list.count() );
768 odebug << " count = " << list.count() << "" << oendl;
769 737
@@ -779,11 +747,5 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
779{ 747{
780
781#if 0
782 QArray<int> empty;
783 return empty;
784
785#else
786 QString qu = "SELECT uid FROM todolist WHERE ("; 748 QString qu = "SELECT uid FROM todolist WHERE (";
787 749
788 // Do it make sense to search other fields, too ? 750 // Does it make sense to search other fields, too ?
789 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; 751 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
@@ -793,4 +755,2 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
793 755
794 odebug << "query: " << qu << "" << oendl;
795
796 OSQLRawQuery raw( qu ); 756 OSQLRawQuery raw( qu );
@@ -799,23 +759,2 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
799 return uids( res ); 759 return uids( res );
800
801
802#endif
803
804}
805QBitArray OPimTodoAccessBackendSQL::supports()const {
806
807 return sup();
808}
809
810QBitArray OPimTodoAccessBackendSQL::sup() const{
811
812 QBitArray ar( OPimTodo::CompletedDate + 1 );
813 ar.fill( true );
814 ar[OPimTodo::CrossReference] = false;
815 ar[OPimTodo::State ] = false;
816 ar[OPimTodo::Reminders] = false;
817 ar[OPimTodo::Notifiers] = false;
818 ar[OPimTodo::Maintainer] = false;
819
820 return ar;
821} 760}
@@ -833,4 +772,2 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
833 772
834 odebug << "Number of completed: " << completed_uids.size() << "" << oendl;
835
836 if ( completed_uids.size() == 0 ) 773 if ( completed_uids.size() == 0 )
@@ -841,3 +778,3 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
841 778
842 for ( int i = 0; i < completed_uids.size(); i++ ){ 779 for ( uint i = 0; i < completed_uids.size(); i++ ){
843 if ( !query.isEmpty() ) 780 if ( !query.isEmpty() )
@@ -852,3 +789,3 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
852 789
853 for ( int i = 0; i < completed_uids.size(); i++ ){ 790 for ( uint i = 0; i < completed_uids.size(); i++ ){
854 if ( !query.isEmpty() ) 791 if ( !query.isEmpty() )
@@ -859,9 +796,8 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
859 796
860 odebug << "query: " << qu << "" << oendl;
861
862 OSQLRawQuery raw2( qu ); 797 OSQLRawQuery raw2( qu );
863 res = m_driver->query( &raw2 ); 798 res = m_driver->query( &raw2 );
864 if ( res.state() == OSQLResult::Failure ) { 799
800 if ( res.state() == OSQLResult::Failure )
865 owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl; 801 owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl;
866 } 802
867} 803}
@@ -878,4 +814,3 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
878 owarn << "OSQLResult::Failure in find query !!" << oendl; 814 owarn << "OSQLResult::Failure in find query !!" << oendl;
879 QMap<QString, QString> empty; 815 return QMap<QString, QString>();
880 return empty;
881 } 816 }
@@ -884,5 +819,5 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
884 OSQLResultItem::ValueList::Iterator it = list.begin(); 819 OSQLResultItem::ValueList::Iterator it = list.begin();
885 for ( ; it != list.end(); ++it ) { 820 for ( ; it != list.end(); ++it )
886 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 821 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
887 } 822
888 823