-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 52 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 2 |
3 files changed, 36 insertions, 20 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index d255c66..ebd03bb 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp | |||
@@ -1,23 +1,26 @@ | |||
1 | 1 | ||
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | 3 | ||
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | 5 | ||
6 | #include <opie2/osqldriver.h> | 6 | #include <opie2/osqldriver.h> |
7 | #include <opie2/osqlresult.h> | 7 | #include <opie2/osqlresult.h> |
8 | #include <opie2/osqlmanager.h> | 8 | #include <opie2/osqlmanager.h> |
9 | #include <opie2/osqlquery.h> | 9 | #include <opie2/osqlquery.h> |
10 | 10 | ||
11 | #include "otodoaccesssql.h" | 11 | #include "otodoaccesssql.h" |
12 | #include "opimstate.h" | ||
13 | #include "opimnotifymanager.h" | ||
14 | #include "orecur.h" | ||
12 | 15 | ||
13 | /* | 16 | /* |
14 | * first some query | 17 | * first some query |
15 | * CREATE query | 18 | * CREATE query |
16 | * LOAD query | 19 | * LOAD query |
17 | * INSERT | 20 | * INSERT |
18 | * REMOVE | 21 | * REMOVE |
19 | * CLEAR | 22 | * CLEAR |
20 | */ | 23 | */ |
21 | namespace { | 24 | namespace { |
22 | /** | 25 | /** |
23 | * CreateQuery for the Todolist Table | 26 | * CreateQuery for the Todolist Table |
@@ -111,25 +114,26 @@ namespace { | |||
111 | QDate m_start; | 114 | QDate m_start; |
112 | QDate m_end; | 115 | QDate m_end; |
113 | bool m_inc :1; | 116 | bool m_inc :1; |
114 | }; | 117 | }; |
115 | 118 | ||
116 | 119 | ||
117 | CreateQuery::CreateQuery() : OSQLQuery() {} | 120 | CreateQuery::CreateQuery() : OSQLQuery() {} |
118 | CreateQuery::~CreateQuery() {} | 121 | CreateQuery::~CreateQuery() {} |
119 | QString CreateQuery::query()const { | 122 | QString CreateQuery::query()const { |
120 | QString qu; | 123 | QString qu; |
121 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; | 124 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; |
122 | qu += "description, summary, priority, DueDate, progress , state, "; | 125 | qu += "description, summary, priority, DueDate, progress , state, "; |
123 | qu += "Recurrence, notifiers, maintainer, startdate, completeddate)"; | 126 | qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);"; |
127 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; | ||
124 | return qu; | 128 | return qu; |
125 | } | 129 | } |
126 | 130 | ||
127 | LoadQuery::LoadQuery() : OSQLQuery() {} | 131 | LoadQuery::LoadQuery() : OSQLQuery() {} |
128 | LoadQuery::~LoadQuery() {} | 132 | LoadQuery::~LoadQuery() {} |
129 | QString LoadQuery::query()const { | 133 | QString LoadQuery::query()const { |
130 | QString qu; | 134 | QString qu; |
131 | // We do not need "distinct" here. The primary key is always unique.. | 135 | // We do not need "distinct" here. The primary key is always unique.. |
132 | //qu += "select distinct uid from todolist"; | 136 | //qu += "select distinct uid from todolist"; |
133 | qu += "select uid from todolist"; | 137 | qu += "select uid from todolist"; |
134 | 138 | ||
135 | return qu; | 139 | return qu; |
@@ -172,32 +176,41 @@ namespace { | |||
172 | QString qu; | 176 | QString qu; |
173 | qu = "insert into todolist VALUES(" | 177 | qu = "insert into todolist VALUES(" |
174 | + QString::number( m_todo.uid() ) + "," | 178 | + QString::number( m_todo.uid() ) + "," |
175 | + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," | 179 | + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," |
176 | + QString::number( m_todo.isCompleted() ) + "," | 180 | + QString::number( m_todo.isCompleted() ) + "," |
177 | + "'" + m_todo.description() + "'" + "," | 181 | + "'" + m_todo.description() + "'" + "," |
178 | + "'" + m_todo.summary() + "'" + "," | 182 | + "'" + m_todo.summary() + "'" + "," |
179 | + QString::number(m_todo.priority() ) + "," | 183 | + QString::number(m_todo.priority() ) + "," |
180 | + "'" + QString::number(year) + "-" | 184 | + "'" + QString::number(year) + "-" |
181 | + QString::number(month) | 185 | + QString::number(month) |
182 | + "-" + QString::number( day ) + "'" + "," | 186 | + "-" + QString::number( day ) + "'" + "," |
183 | + QString::number( m_todo.progress() ) + "," | 187 | + QString::number( m_todo.progress() ) + "," |
184 | + "''" + "," // state (conversion needed) | 188 | + QString::number( m_todo.state().state() ) + "," |
185 | // + QString::number( m_todo.state() ) + "," | 189 | + "'" + m_todo.recurrence().toString() + "'"+ ","; |
186 | + "''" + "," // Recurrence (conversion needed) | 190 | |
187 | + "''" + "," // Notifiers (conversion needed) | 191 | if ( m_todo.hasNotifiers() ) { |
188 | + "''" + "," // Maintainers (conversion needed) | 192 | OPimNotifyManager manager = m_todo.notifiers(); |
193 | qu += "'" + manager.remindersToString() + "'" + "," | ||
194 | + "'" + manager.alarmsToString() + "'" + ","; | ||
195 | } | ||
196 | else{ | ||
197 | qu += QString( "''" ) + "," | ||
198 | + "''" + ","; | ||
199 | } | ||
200 | |||
201 | qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) | ||
189 | + "'" + QString::number(sYear) + "-" | 202 | + "'" + QString::number(sYear) + "-" |
190 | + QString::number(sMonth) | 203 | + QString::number(sMonth) |
191 | + "-" + QString::number(sDay) + "'" + "," | 204 | + "-" + QString::number(sDay) + "'" + "," |
192 | + "'" + QString::number(eYear) + "-" | 205 | + "'" + QString::number(eYear) + "-" |
193 | + QString::number(eMonth) | 206 | + QString::number(eMonth) |
194 | + "-"+QString::number(eDay) + "'" | 207 | + "-"+QString::number(eDay) + "'" |
195 | + ")"; | 208 | + ")"; |
196 | 209 | ||
197 | qWarning("add %s", qu.latin1() ); | 210 | qWarning("add %s", qu.latin1() ); |
198 | return qu; | 211 | return qu; |
199 | } | 212 | } |
200 | 213 | ||
201 | RemoveQuery::RemoveQuery(int uid ) | 214 | RemoveQuery::RemoveQuery(int uid ) |
202 | : OSQLQuery(), m_uid( uid ) {} | 215 | : OSQLQuery(), m_uid( uid ) {} |
203 | RemoveQuery::~RemoveQuery() {} | 216 | RemoveQuery::~RemoveQuery() {} |
@@ -521,24 +534,35 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | |||
521 | if ( isOk ) | 534 | if ( isOk ) |
522 | to.setPriority( prioInt ); | 535 | to.setPriority( prioInt ); |
523 | 536 | ||
524 | bool hasStartDate = false; QDate startDate = QDate::currentDate(); | 537 | bool hasStartDate = false; QDate startDate = QDate::currentDate(); |
525 | hasStartDate = date( startDate, item.data("startdate") ); | 538 | hasStartDate = date( startDate, item.data("startdate") ); |
526 | bool hasCompletedDate = false; QDate completedDate = QDate::currentDate(); | 539 | bool hasCompletedDate = false; QDate completedDate = QDate::currentDate(); |
527 | hasCompletedDate = date( completedDate, item.data("completeddate") ); | 540 | hasCompletedDate = date( completedDate, item.data("completeddate") ); |
528 | 541 | ||
529 | if ( hasStartDate ) | 542 | if ( hasStartDate ) |
530 | to.setStartDate( startDate ); | 543 | to.setStartDate( startDate ); |
531 | if ( hasCompletedDate ) | 544 | if ( hasCompletedDate ) |
532 | to.setCompletedDate( completedDate ); | 545 | to.setCompletedDate( completedDate ); |
546 | |||
547 | OPimNotifyManager& manager = to.notifiers(); | ||
548 | manager.alarmsFromString( item.data("alarms") ); | ||
549 | manager.remindersFromString( item.data("reminders") ); | ||
550 | |||
551 | OPimState pimState; | ||
552 | pimState.setState( QString( item.data("state") ).toInt() ); | ||
553 | to.setState( pimState ); | ||
554 | |||
555 | // Recurrence not supported yet | ||
556 | // to.setRecurrence( | ||
533 | 557 | ||
534 | return to; | 558 | return to; |
535 | } | 559 | } |
536 | OTodo OTodoAccessBackendSQL::todo( int uid )const { | 560 | OTodo OTodoAccessBackendSQL::todo( int uid )const { |
537 | FindQuery find( uid ); | 561 | FindQuery find( uid ); |
538 | return todo( m_driver->query(&find) ); | 562 | return todo( m_driver->query(&find) ); |
539 | } | 563 | } |
540 | /* | 564 | /* |
541 | * update the dict | 565 | * update the dict |
542 | */ | 566 | */ |
543 | void OTodoAccessBackendSQL::fillDict() { | 567 | void OTodoAccessBackendSQL::fillDict() { |
544 | /* initialize dict */ | 568 | /* initialize dict */ |
@@ -612,36 +636,28 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const | |||
612 | 636 | ||
613 | } | 637 | } |
614 | // Shrink to fit.. | 638 | // Shrink to fit.. |
615 | m_currentQuery.resize(arraycounter); | 639 | m_currentQuery.resize(arraycounter); |
616 | 640 | ||
617 | return m_currentQuery; | 641 | return m_currentQuery; |
618 | #endif | 642 | #endif |
619 | QArray<int> empty; | 643 | QArray<int> empty; |
620 | return empty; | 644 | return empty; |
621 | } | 645 | } |
622 | QBitArray OTodoAccessBackendSQL::supports()const { | 646 | QBitArray OTodoAccessBackendSQL::supports()const { |
623 | 647 | ||
624 | QBitArray ar( OTodo::CompletedDate + 1 ); | 648 | return sup(); |
625 | ar.fill( true ); | ||
626 | ar[OTodo::CrossReference] = false; | ||
627 | ar[OTodo::State ] = false; | ||
628 | ar[OTodo::Reminders] = false; | ||
629 | ar[OTodo::Notifiers] = false; | ||
630 | ar[OTodo::Maintainer] = false; | ||
631 | |||
632 | return ar; | ||
633 | } | 649 | } |
634 | 650 | ||
635 | QBitArray OTodoAccessBackendSQL::sup() { | 651 | QBitArray OTodoAccessBackendSQL::sup() const{ |
636 | 652 | ||
637 | QBitArray ar( OTodo::CompletedDate + 1 ); | 653 | QBitArray ar( OTodo::CompletedDate + 1 ); |
638 | ar.fill( true ); | 654 | ar.fill( true ); |
639 | ar[OTodo::CrossReference] = false; | 655 | ar[OTodo::CrossReference] = false; |
640 | ar[OTodo::State ] = false; | 656 | ar[OTodo::State ] = false; |
641 | ar[OTodo::Reminders] = false; | 657 | ar[OTodo::Reminders] = false; |
642 | ar[OTodo::Notifiers] = false; | 658 | ar[OTodo::Notifiers] = false; |
643 | ar[OTodo::Maintainer] = false; | 659 | ar[OTodo::Maintainer] = false; |
644 | 660 | ||
645 | return ar; | 661 | return ar; |
646 | } | 662 | } |
647 | 663 | ||
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h index 77d8b77..1c55567 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.h +++ b/libopie2/opiepim/backend/otodoaccesssql.h | |||
@@ -35,22 +35,22 @@ public: | |||
35 | QArray<int> matchRegexp( const QRegExp &r ) const; | 35 | QArray<int> matchRegexp( const QRegExp &r ) const; |
36 | void removeAllCompleted(); | 36 | void removeAllCompleted(); |
37 | 37 | ||
38 | 38 | ||
39 | private: | 39 | private: |
40 | void update()const; | 40 | void update()const; |
41 | void fillDict(); | 41 | void fillDict(); |
42 | inline bool date( QDate& date, const QString& )const; | 42 | inline bool date( QDate& date, const QString& )const; |
43 | inline OTodo todo( const OSQLResult& )const; | 43 | inline OTodo todo( const OSQLResult& )const; |
44 | inline OTodo todo( OSQLResultItem& )const; | 44 | inline OTodo todo( OSQLResultItem& )const; |
45 | inline QArray<int> uids( const OSQLResult& )const; | 45 | inline QArray<int> uids( const OSQLResult& )const; |
46 | OTodo todo( int uid )const; | 46 | OTodo todo( int uid )const; |
47 | QBitArray sup(); | 47 | QBitArray sup() const; |
48 | 48 | ||
49 | QAsciiDict<int> m_dict; | 49 | QAsciiDict<int> m_dict; |
50 | OSQLDriver* m_driver; | 50 | OSQLDriver* m_driver; |
51 | QArray<int> m_uids; | 51 | QArray<int> m_uids; |
52 | bool m_dirty : 1; | 52 | bool m_dirty : 1; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
56 | #endif | 56 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index f688735..4a5cb33 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -559,25 +559,25 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
559 | if ( ev.hasRecurrence() ) { | 559 | if ( ev.hasRecurrence() ) { |
560 | str += ev.recurrence().toString(); | 560 | str += ev.recurrence().toString(); |
561 | } | 561 | } |
562 | if ( ev.hasStartDate() ) | 562 | if ( ev.hasStartDate() ) |
563 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; | 563 | str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; |
564 | if ( ev.hasCompletedDate() ) | 564 | if ( ev.hasCompletedDate() ) |
565 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; | 565 | str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; |
566 | if ( ev.hasState() ) | 566 | if ( ev.hasState() ) |
567 | str += "State=\""+QString::number( ev.state().state() )+"\" "; | 567 | str += "State=\""+QString::number( ev.state().state() )+"\" "; |
568 | 568 | ||
569 | /* | 569 | /* |
570 | * save reminders and notifiers! | 570 | * save reminders and notifiers! |
571 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... | 571 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... |
572 | */ | 572 | */ |
573 | if ( ev.hasNotifiers() ) { | 573 | if ( ev.hasNotifiers() ) { |
574 | OPimNotifyManager manager = ev.notifiers(); | 574 | OPimNotifyManager manager = ev.notifiers(); |
575 | OPimNotifyManager::Alarms alarms = manager.alarms(); | 575 | OPimNotifyManager::Alarms alarms = manager.alarms(); |
576 | if (!alarms.isEmpty() ) { | 576 | if (!alarms.isEmpty() ) { |
577 | QStringList als; | 577 | QStringList als; |
578 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 578 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
579 | for ( ; it != alarms.end(); ++it ) { | 579 | for ( ; it != alarms.end(); ++it ) { |
580 | /* only if time is valid */ | 580 | /* only if time is valid */ |
581 | if ( (*it).dateTime().isValid() ) { | 581 | if ( (*it).dateTime().isValid() ) { |
582 | als << OConversion::dateTimeToString( (*it).dateTime() ) | 582 | als << OConversion::dateTimeToString( (*it).dateTime() ) |
583 | + ":" + QString::number( (*it).duration() ) | 583 | + ":" + QString::number( (*it).duration() ) |