Diffstat (limited to 'libopie2/opiepim/backend/otodoaccesssql.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index 3764c7e..944f82a 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp | |||
@@ -1,39 +1,68 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | 29 | ||
2 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
3 | 31 | ||
4 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
5 | 33 | ||
6 | #include <opie2/osqldriver.h> | 34 | #include <opie2/osqldriver.h> |
7 | #include <opie2/osqlresult.h> | 35 | #include <opie2/osqlresult.h> |
8 | #include <opie2/osqlmanager.h> | 36 | #include <opie2/osqlmanager.h> |
9 | #include <opie2/osqlquery.h> | 37 | #include <opie2/osqlquery.h> |
10 | 38 | ||
11 | #include "otodoaccesssql.h" | 39 | #include <opie2/otodoaccesssql.h> |
12 | #include "opimstate.h" | 40 | #include <opie2/opimstate.h> |
13 | #include "opimnotifymanager.h" | 41 | #include <opie2/opimnotifymanager.h> |
14 | #include "orecur.h" | 42 | #include <opie2/orecur.h> |
15 | 43 | ||
44 | using namespace Opie; | ||
16 | /* | 45 | /* |
17 | * first some query | 46 | * first some query |
18 | * CREATE query | 47 | * CREATE query |
19 | * LOAD query | 48 | * LOAD query |
20 | * INSERT | 49 | * INSERT |
21 | * REMOVE | 50 | * REMOVE |
22 | * CLEAR | 51 | * CLEAR |
23 | */ | 52 | */ |
24 | namespace { | 53 | namespace { |
25 | /** | 54 | /** |
26 | * CreateQuery for the Todolist Table | 55 | * CreateQuery for the Todolist Table |
27 | */ | 56 | */ |
28 | class CreateQuery : public OSQLQuery { | 57 | class CreateQuery : public OSQLQuery { |
29 | public: | 58 | public: |
30 | CreateQuery(); | 59 | CreateQuery(); |
31 | ~CreateQuery(); | 60 | ~CreateQuery(); |
32 | QString query()const; | 61 | QString query()const; |
33 | }; | 62 | }; |
34 | 63 | ||
35 | /** | 64 | /** |
36 | * LoadQuery | 65 | * LoadQuery |
37 | * this one queries for all uids | 66 | * this one queries for all uids |
38 | */ | 67 | */ |
39 | class LoadQuery : public OSQLQuery { | 68 | class LoadQuery : public OSQLQuery { |
@@ -277,48 +306,50 @@ namespace { | |||
277 | 306 | ||
278 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) | 307 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) |
279 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} | 308 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} |
280 | EffQuery::~EffQuery() {} | 309 | EffQuery::~EffQuery() {} |
281 | QString EffQuery::query()const { | 310 | QString EffQuery::query()const { |
282 | return m_inc ? with() : out(); | 311 | return m_inc ? with() : out(); |
283 | } | 312 | } |
284 | QString EffQuery::with()const { | 313 | QString EffQuery::with()const { |
285 | QString str; | 314 | QString str; |
286 | str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") | 315 | str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") |
287 | .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() ) | 316 | .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() ) |
288 | .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() ); | 317 | .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() ); |
289 | return str; | 318 | return str; |
290 | } | 319 | } |
291 | QString EffQuery::out()const { | 320 | QString EffQuery::out()const { |
292 | QString str; | 321 | QString str; |
293 | str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") | 322 | str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") |
294 | .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() ) | 323 | .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() ) |
295 | .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() ); | 324 | .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() ); |
296 | 325 | ||
297 | return str; | 326 | return str; |
298 | } | 327 | } |
299 | }; | 328 | }; |
300 | 329 | ||
330 | |||
331 | namespace Opie { | ||
301 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) | 332 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) |
302 | : OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) | 333 | : OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) |
303 | { | 334 | { |
304 | QString fi = file; | 335 | QString fi = file; |
305 | if ( fi.isEmpty() ) | 336 | if ( fi.isEmpty() ) |
306 | fi = Global::applicationFileName( "todolist", "todolist.db" ); | 337 | fi = Global::applicationFileName( "todolist", "todolist.db" ); |
307 | OSQLManager man; | 338 | OSQLManager man; |
308 | m_driver = man.standard(); | 339 | m_driver = man.standard(); |
309 | m_driver->setUrl(fi); | 340 | m_driver->setUrl(fi); |
310 | // fillDict(); | 341 | // fillDict(); |
311 | } | 342 | } |
312 | 343 | ||
313 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ | 344 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ |
314 | if( m_driver ) | 345 | if( m_driver ) |
315 | delete m_driver; | 346 | delete m_driver; |
316 | } | 347 | } |
317 | 348 | ||
318 | bool OTodoAccessBackendSQL::load(){ | 349 | bool OTodoAccessBackendSQL::load(){ |
319 | if (!m_driver->open() ) | 350 | if (!m_driver->open() ) |
320 | return false; | 351 | return false; |
321 | 352 | ||
322 | CreateQuery creat; | 353 | CreateQuery creat; |
323 | OSQLResult res = m_driver->query(&creat ); | 354 | OSQLResult res = m_driver->query(&creat ); |
324 | 355 | ||
@@ -670,24 +701,26 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const | |||
670 | return empty; | 701 | return empty; |
671 | } | 702 | } |
672 | QBitArray OTodoAccessBackendSQL::supports()const { | 703 | QBitArray OTodoAccessBackendSQL::supports()const { |
673 | 704 | ||
674 | return sup(); | 705 | return sup(); |
675 | } | 706 | } |
676 | 707 | ||
677 | QBitArray OTodoAccessBackendSQL::sup() const{ | 708 | QBitArray OTodoAccessBackendSQL::sup() const{ |
678 | 709 | ||
679 | QBitArray ar( OTodo::CompletedDate + 1 ); | 710 | QBitArray ar( OTodo::CompletedDate + 1 ); |
680 | ar.fill( true ); | 711 | ar.fill( true ); |
681 | ar[OTodo::CrossReference] = false; | 712 | ar[OTodo::CrossReference] = false; |
682 | ar[OTodo::State ] = false; | 713 | ar[OTodo::State ] = false; |
683 | ar[OTodo::Reminders] = false; | 714 | ar[OTodo::Reminders] = false; |
684 | ar[OTodo::Notifiers] = false; | 715 | ar[OTodo::Notifiers] = false; |
685 | ar[OTodo::Maintainer] = false; | 716 | ar[OTodo::Maintainer] = false; |
686 | 717 | ||
687 | return ar; | 718 | return ar; |
688 | } | 719 | } |
689 | 720 | ||
690 | void OTodoAccessBackendSQL::removeAllCompleted(){ | 721 | void OTodoAccessBackendSQL::removeAllCompleted(){ |
691 | #warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !! | 722 | #warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !! |
692 | 723 | ||
693 | } | 724 | } |
725 | |||
726 | } | ||