Diffstat (limited to 'libopie/pim/otodoaccesssql.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie/pim/otodoaccesssql.cpp | 90 |
1 files changed, 74 insertions, 16 deletions
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp index 23e0c3e..d255c66 100644 --- a/libopie/pim/otodoaccesssql.cpp +++ b/libopie/pim/otodoaccesssql.cpp | |||
@@ -120,4 +120,5 @@ namespace { | |||
120 | QString qu; | 120 | QString qu; |
121 | qu += "create table todolist( uid, categories, completed, progress, "; | 121 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; |
122 | qu += "summary, DueDate, priority, description )"; | 122 | qu += "description, summary, priority, DueDate, progress , state, "; |
123 | qu += "Recurrence, notifiers, maintainer, startdate, completeddate)"; | ||
123 | return qu; | 124 | return qu; |
@@ -129,3 +130,5 @@ namespace { | |||
129 | QString qu; | 130 | QString qu; |
130 | qu += "select distinct uid from todolist"; | 131 | // We do not need "distinct" here. The primary key is always unique.. |
132 | //qu += "select distinct uid from todolist"; | ||
133 | qu += "select uid from todolist"; | ||
131 | 134 | ||
@@ -153,7 +156,41 @@ namespace { | |||
153 | } | 156 | } |
157 | int sYear = 0, sMonth = 0, sDay = 0; | ||
158 | if( m_todo.hasStartDate() ){ | ||
159 | QDate sDate = m_todo.startDate(); | ||
160 | sYear = sDate.year(); | ||
161 | sMonth= sDate.month(); | ||
162 | sDay = sDate.day(); | ||
163 | } | ||
164 | |||
165 | int eYear = 0, eMonth = 0, eDay = 0; | ||
166 | if( m_todo.hasCompletedDate() ){ | ||
167 | QDate eDate = m_todo.completedDate(); | ||
168 | eYear = eDate.year(); | ||
169 | eMonth= eDate.month(); | ||
170 | eDay = eDate.day(); | ||
171 | } | ||
154 | QString qu; | 172 | QString qu; |
155 | qu = "insert into todolist VALUES(" + QString::number( m_todo.uid() ) + ",'" + m_todo.idsToString( m_todo.categories() ) + "',"; | 173 | qu = "insert into todolist VALUES(" |
156 | qu += QString::number( m_todo.isCompleted() ) + "," + QString::number( m_todo.progress() ) + ","; | 174 | + QString::number( m_todo.uid() ) + "," |
157 | qu += "'"+m_todo.summary()+"','"+QString::number(year)+"-"+QString::number(month)+"-"+QString::number(day)+"',"; | 175 | + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," |
158 | qu += QString::number(m_todo.priority() ) +",'" + m_todo.description() + "')"; | 176 | + QString::number( m_todo.isCompleted() ) + "," |
177 | + "'" + m_todo.description() + "'" + "," | ||
178 | + "'" + m_todo.summary() + "'" + "," | ||
179 | + QString::number(m_todo.priority() ) + "," | ||
180 | + "'" + QString::number(year) + "-" | ||
181 | + QString::number(month) | ||
182 | + "-" + QString::number( day ) + "'" + "," | ||
183 | + QString::number( m_todo.progress() ) + "," | ||
184 | + "''" + "," // state (conversion needed) | ||
185 | // + QString::number( m_todo.state() ) + "," | ||
186 | + "''" + "," // Recurrence (conversion needed) | ||
187 | + "''" + "," // Notifiers (conversion needed) | ||
188 | + "''" + "," // Maintainers (conversion needed) | ||
189 | + "'" + QString::number(sYear) + "-" | ||
190 | + QString::number(sMonth) | ||
191 | + "-" + QString::number(sDay) + "'" + "," | ||
192 | + "'" + QString::number(eYear) + "-" | ||
193 | + QString::number(eMonth) | ||
194 | + "-"+QString::number(eDay) + "'" | ||
195 | + ")"; | ||
159 | 196 | ||
@@ -194,4 +231,3 @@ namespace { | |||
194 | QString FindQuery::single()const{ | 231 | QString FindQuery::single()const{ |
195 | QString qu = "select uid, categories, completed, progress, summary, "; | 232 | QString qu = "select * from todolist where uid = " + QString::number(m_uid); |
196 | qu += "DueDate, priority, description from todolist where uid = " + QString::number(m_uid); | ||
197 | return qu; | 233 | return qu; |
@@ -199,4 +235,3 @@ namespace { | |||
199 | QString FindQuery::multi()const { | 235 | QString FindQuery::multi()const { |
200 | QString qu = "select uid, categories, completed, progress, summary, "; | 236 | QString qu = "select * from todolist where "; |
201 | qu += "DueDate, priority, description from todolist where "; | ||
202 | for (uint i = 0; i < m_uids.count(); i++ ) { | 237 | for (uint i = 0; i < m_uids.count(); i++ ) { |
@@ -290,3 +325,3 @@ OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, | |||
290 | uint cur, Frontend::CacheDirection dir ) const{ | 325 | uint cur, Frontend::CacheDirection dir ) const{ |
291 | int CACHE = readAhead(); | 326 | uint CACHE = readAhead(); |
292 | qWarning("searching for %d", uid ); | 327 | qWarning("searching for %d", uid ); |
@@ -474,4 +509,4 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | |||
474 | qWarning("todo"); | 509 | qWarning("todo"); |
475 | bool has = false; QDate da = QDate::currentDate(); | 510 | bool hasDueDate = false; QDate dueDate = QDate::currentDate(); |
476 | has = date( da, item.data("DueDate") ); | 511 | hasDueDate = date( dueDate, item.data("DueDate") ); |
477 | QStringList cats = QStringList::split(";", item.data("categories") ); | 512 | QStringList cats = QStringList::split(";", item.data("categories") ); |
@@ -480,4 +515,20 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | |||
480 | cats, item.data("summary"), item.data("description"), | 515 | cats, item.data("summary"), item.data("description"), |
481 | item.data("progress").toUShort(), has, da, | 516 | item.data("progress").toUShort(), hasDueDate, dueDate, |
482 | item.data("uid").toInt() ); | 517 | item.data("uid").toInt() ); |
518 | |||
519 | bool isOk; | ||
520 | int prioInt = QString( item.data("priority") ).toInt( &isOk ); | ||
521 | if ( isOk ) | ||
522 | to.setPriority( prioInt ); | ||
523 | |||
524 | bool hasStartDate = false; QDate startDate = QDate::currentDate(); | ||
525 | hasStartDate = date( startDate, item.data("startdate") ); | ||
526 | bool hasCompletedDate = false; QDate completedDate = QDate::currentDate(); | ||
527 | hasCompletedDate = date( completedDate, item.data("completeddate") ); | ||
528 | |||
529 | if ( hasStartDate ) | ||
530 | to.setStartDate( startDate ); | ||
531 | if ( hasCompletedDate ) | ||
532 | to.setCompletedDate( completedDate ); | ||
533 | |||
483 | return to; | 534 | return to; |
@@ -572,3 +623,10 @@ QBitArray OTodoAccessBackendSQL::supports()const { | |||
572 | 623 | ||
573 | static QBitArray ar = sup(); | 624 | QBitArray ar( OTodo::CompletedDate + 1 ); |
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 | |||
574 | return ar; | 632 | return ar; |