-rw-r--r-- | libopie/libopie.pro | 42 | ||||
-rw-r--r-- | libopie/pim/obackendfactory.h | 17 | ||||
-rw-r--r-- | libopie/pim/otodoaccess.cpp | 9 | ||||
-rw-r--r-- | libopie2/opiepim/backend/obackendfactory.h | 17 | ||||
-rw-r--r-- | libopie2/opiepim/core/otodoaccess.cpp | 9 |
5 files changed, 74 insertions, 20 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 6a1f1b3..c99db9b 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,42 +1,68 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h ofileselector.h \ | 3 | HEADERS = ofontmenu.h \ |
4 | ofiledialog.h tododb.h \ | 4 | ofiledialog.h ofileselector.h tododb.h \ |
5 | todoevent.h todoresource.h \ | 5 | ocheckitem.h todoevent.h todoresource.h \ |
6 | todovcalresource.h xmltree.h \ | 6 | todovcalresource.h xmltree.h \ |
7 | colordialog.h colorpopupmenu.h \ | 7 | colordialog.h colorpopupmenu.h \ |
8 | oclickablelabel.h oprocctrl.h \ | 8 | oclickablelabel.h oprocctrl.h \ |
9 | oprocess.h odevice.h \ | 9 | oprocess.h odevice.h \ |
10 | otimepicker.h otabwidget.h \ | 10 | otimepicker.h otabwidget.h \ |
11 | otabbar.h otabinfo.h \ | 11 | otabbar.h otabinfo.h \ |
12 | ofontselector.h ocolorbutton.h | 12 | ofontselector.h \ |
13 | SOURCES = ofontmenu.cc ofileselector.cc \ | 13 | pim/opimrecord.h \ |
14 | ofiledialog.cc xmltree.cc \ | 14 | pim/otodo.h \ |
15 | tododb.cpp todoevent.cpp \ | 15 | pim/orecordlist.h \ |
16 | pim/opimaccesstemplate.h \ | ||
17 | pim/opimaccessbackend.h \ | ||
18 | pim/otodoaccess.h \ | ||
19 | pim/otodacessbackend.h \ | ||
20 | pim/ocontact.h \ | ||
21 | pim/ocontactaccess.h \ | ||
22 | pim/ocontactaccessbackend.h \ | ||
23 | pim/ocontactaccessbackend_xml.h \ | ||
24 | pim/obackendfactory.h | ||
25 | # pim/otodoaccesssql.h \ | ||
26 | |||
27 | SOURCES = ofontmenu.cc \ | ||
28 | xmltree.cc \ | ||
29 | ofiledialog.cc ofileselector.cc \ | ||
30 | ocheckitem.cpp tododb.cpp todoevent.cpp \ | ||
16 | todovcalresource.cpp colordialog.cpp \ | 31 | todovcalresource.cpp colordialog.cpp \ |
17 | colorpopupmenu.cpp oclickablelabel.cpp \ | 32 | colorpopupmenu.cpp oclickablelabel.cpp \ |
18 | oprocctrl.cpp oprocess.cpp \ | 33 | oprocctrl.cpp oprocess.cpp \ |
19 | odevice.cpp otimepicker.cpp \ | 34 | odevice.cpp otimepicker.cpp \ |
20 | otabwidget.cpp otabbar.cpp \ | 35 | otabwidget.cpp otabbar.cpp \ |
21 | ofontselector.cpp ocolorbutton.cpp | 36 | ofontselector.cpp \ |
37 | pim/otodo.cpp \ | ||
38 | pim/opimrecord.cpp \ | ||
39 | pim/otodoaccess.cpp \ | ||
40 | pim/otodoaccessbackend.cpp \ | ||
41 | pim/otodoaccessxml.cpp \ | ||
42 | pim/ocontact.cpp \ | ||
43 | pim/ocontactaccess.cpp | ||
44 | # pim/otodoaccesssql.cpp \ | ||
45 | |||
22 | TARGET = opie | 46 | TARGET = opie |
23 | INCLUDEPATH += $(OPIEDIR)/include | 47 | INCLUDEPATH += $(OPIEDIR)/include |
24 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 48 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
25 | #VERSION = 1.0.0 | 49 | #VERSION = 1.0.0 |
26 | 50 | ||
51 | # LIBS += -lopiesql | ||
52 | |||
27 | INTERFACES = otimepickerbase.ui | 53 | INTERFACES = otimepickerbase.ui |
28 | 54 | ||
29 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 55 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
30 | ../i18n/en/libopie.ts \ | 56 | ../i18n/en/libopie.ts \ |
31 | ../i18n/es/libopie.ts \ | 57 | ../i18n/es/libopie.ts \ |
32 | ../i18n/fr/libopie.ts \ | 58 | ../i18n/fr/libopie.ts \ |
33 | ../i18n/hu/libopie.ts \ | 59 | ../i18n/hu/libopie.ts \ |
34 | ../i18n/ja/libopie.ts \ | 60 | ../i18n/ja/libopie.ts \ |
35 | ../i18n/ko/libopie.ts \ | 61 | ../i18n/ko/libopie.ts \ |
36 | ../i18n/no/libopie.ts \ | 62 | ../i18n/no/libopie.ts \ |
37 | ../i18n/pl/libopie.ts \ | 63 | ../i18n/pl/libopie.ts \ |
38 | ../i18n/pt/libopie.ts \ | 64 | ../i18n/pt/libopie.ts \ |
39 | ../i18n/pt_BR/libopie.ts \ | 65 | ../i18n/pt_BR/libopie.ts \ |
40 | ../i18n/sl/libopie.ts \ | 66 | ../i18n/sl/libopie.ts \ |
41 | ../i18n/zh_CN/libopie.ts \ | 67 | ../i18n/zh_CN/libopie.ts \ |
42 | ../i18n/zh_TW/libopie.ts | 68 | ../i18n/zh_TW/libopie.ts |
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h index 599fbf2..f11f029 100644 --- a/libopie/pim/obackendfactory.h +++ b/libopie/pim/obackendfactory.h | |||
@@ -1,88 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage Backends. | 2 | * Class to manage Backends. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; | 9 | * License as published by the Free Software Foundation; |
10 | * either version 2 of the License, or (at your option) any later | 10 | * either version 2 of the License, or (at your option) any later |
11 | * version. | 11 | * version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: Use plugins | 13 | * ToDo: Use plugins |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * Version: $Id$ | 15 | * Version: $Id$ |
16 | * ===================================================================== | 16 | * ===================================================================== |
17 | * History: | 17 | * History: |
18 | * $Log$ | 18 | * $Log$ |
19 | * Revision 1.2 2002/10/08 09:27:36 eilers | ||
20 | * Fixed libopie.pro to include the new pim-API. | ||
21 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | ||
22 | * compile itself would need to install libsqlite, libopiesql... | ||
23 | * Therefore, the backend currently uses XML only.. | ||
24 | * | ||
19 | * Revision 1.1 2002/10/07 17:35:01 eilers | 25 | * Revision 1.1 2002/10/07 17:35:01 eilers |
20 | * added OBackendFactory for advanced backend access | 26 | * added OBackendFactory for advanced backend access |
21 | * | 27 | * |
22 | * | 28 | * |
23 | * ===================================================================== | 29 | * ===================================================================== |
24 | */ | 30 | */ |
25 | #ifndef __OPIE_BACKENDFACTORY_H_ | 31 | #ifndef __OPIE_BACKENDFACTORY_H_ |
26 | #define __OPIE_BACKENDFACTORY_H_ | 32 | #define __OPIE_BACKENDFACTORY_H_ |
27 | 33 | ||
28 | #include <qstring.h> | 34 | #include <qstring.h> |
29 | #include <qasciidict.h> | 35 | #include <qasciidict.h> |
30 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
31 | 37 | ||
32 | #include "otodoaccessxml.h" | 38 | #include "otodoaccessxml.h" |
33 | #include "ocontactaccessbackend_xml.h" | 39 | #include "ocontactaccessbackend_xml.h" |
34 | #include "otodoaccesssql.h" | ||
35 | 40 | ||
41 | #ifdef __USE_SQL | ||
42 | #include "otodoaccesssql.h" | ||
43 | #endif | ||
36 | 44 | ||
37 | template<class T> | 45 | template<class T> |
38 | class OBackendFactory | 46 | class OBackendFactory |
39 | { | 47 | { |
40 | public: | 48 | public: |
41 | OBackendFactory() {}; | 49 | OBackendFactory() {}; |
42 | 50 | ||
43 | enum BACKENDS { | 51 | enum BACKENDS { |
44 | TODO, | 52 | TODO, |
45 | CONTACT, | 53 | CONTACT, |
46 | DATE | 54 | DATE |
47 | }; | 55 | }; |
48 | 56 | ||
49 | static T* Default( const QString backendName, const QString& appName ){ | 57 | static T* Default( const QString backendName, const QString& appName ){ |
50 | 58 | ||
51 | 59 | ||
52 | Config config( "pimaccess" ); | 60 | Config config( "pimaccess" ); |
53 | config.setGroup ( backendName ); | 61 | config.setGroup ( backendName ); |
54 | QString backend = config.readEntry( "usebackend" ); | 62 | QString backend = config.readEntry( "usebackend" ); |
55 | 63 | ||
56 | QAsciiDict<int> dict ( 3 ); | 64 | QAsciiDict<int> dict ( 3 ); |
57 | dict.setAutoDelete ( TRUE ); | 65 | dict.setAutoDelete ( TRUE ); |
58 | 66 | ||
59 | dict.insert( "todo", new int (TODO) ); | 67 | dict.insert( "todo", new int (TODO) ); |
60 | dict.insert( "contact", new int (CONTACT) ); | 68 | dict.insert( "contact", new int (CONTACT) ); |
61 | 69 | ||
62 | qWarning ("TODO is: %d", TODO); | 70 | qWarning ("TODO is: %d", TODO); |
63 | qWarning ("CONTACT is: %d", CONTACT); | 71 | qWarning ("CONTACT is: %d", CONTACT); |
64 | 72 | ||
65 | switch ( *dict.take( backendName ) ){ | 73 | switch ( *dict.take( backendName ) ){ |
66 | case TODO: | 74 | case TODO: |
75 | #ifdef __USE_SQL | ||
67 | if ( backend == "sql" ) | 76 | if ( backend == "sql" ) |
68 | return (T*) new OTodoAccessBackendSQL(""); | 77 | return (T*) new OTodoAccessBackendSQL(""); |
69 | 78 | #else | |
79 | if ( backend == "sql" ) | ||
80 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | ||
81 | #endif | ||
82 | |||
70 | return (T*) new OTodoAccessXML( appName ); | 83 | return (T*) new OTodoAccessXML( appName ); |
71 | case CONTACT: | 84 | case CONTACT: |
72 | if ( backend == "sql" ) | 85 | if ( backend == "sql" ) |
73 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 86 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
74 | 87 | ||
75 | return (T*) new OContactAccessBackend_XML( appName ); | 88 | return (T*) new OContactAccessBackend_XML( appName ); |
76 | case DATE: | 89 | case DATE: |
77 | qWarning ("OBackendFactory:: DATE-Backend not implemented!"); | 90 | qWarning ("OBackendFactory:: DATE-Backend not implemented!"); |
78 | return NULL; | 91 | return NULL; |
79 | default: | 92 | default: |
80 | return NULL; | 93 | return NULL; |
81 | } | 94 | } |
82 | 95 | ||
83 | 96 | ||
84 | } | 97 | } |
85 | }; | 98 | }; |
86 | 99 | ||
87 | 100 | ||
88 | #endif | 101 | #endif |
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp index 4468812..80424d9 100644 --- a/libopie/pim/otodoaccess.cpp +++ b/libopie/pim/otodoaccess.cpp | |||
@@ -1,80 +1,81 @@ | |||
1 | #include <qdatetime.h> | 1 | #include <qdatetime.h> |
2 | 2 | ||
3 | #include <qpe/alarmserver.h> | 3 | #include <qpe/alarmserver.h> |
4 | 4 | ||
5 | #include "otodoaccesssql.h" | 5 | #include "otodoaccesssql.h" |
6 | #include "otodoaccess.h" | 6 | #include "otodoaccess.h" |
7 | #include "obackendfactory.h" | 7 | #include "obackendfactory.h" |
8 | 8 | ||
9 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) | 9 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) |
10 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) | 10 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) |
11 | { | 11 | { |
12 | if (end == 0l ) | 12 | // if (end == 0l ) |
13 | m_todoBackEnd = new OTodoAccessBackendSQL( QString::null); | 13 | // m_todoBackEnd = new OTodoAccessBackendSQL( QString::null); |
14 | 14 | ||
15 | // if (end == 0l ) | 15 | // Zecke: Du musst hier noch für das XML-Backend einen Appnamen übergeben ! |
16 | // m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null); | 16 | if (end == 0l ) |
17 | m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null); | ||
17 | 18 | ||
18 | setBackEnd( m_todoBackEnd ); | 19 | setBackEnd( m_todoBackEnd ); |
19 | } | 20 | } |
20 | OTodoAccess::~OTodoAccess() { | 21 | OTodoAccess::~OTodoAccess() { |
21 | // qWarning("~OTodoAccess"); | 22 | // qWarning("~OTodoAccess"); |
22 | } | 23 | } |
23 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { | 24 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { |
24 | QValueList<OTodo>::ConstIterator it; | 25 | QValueList<OTodo>::ConstIterator it; |
25 | for ( it = list.begin(); it != list.end(); ++it ) { | 26 | for ( it = list.begin(); it != list.end(); ++it ) { |
26 | replace( (*it) ); | 27 | replace( (*it) ); |
27 | } | 28 | } |
28 | } | 29 | } |
29 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | 30 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, |
30 | const QDate& end, | 31 | const QDate& end, |
31 | bool includeNoDates ) { | 32 | bool includeNoDates ) { |
32 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); | 33 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); |
33 | 34 | ||
34 | List lis( ints, this ); | 35 | List lis( ints, this ); |
35 | return lis; | 36 | return lis; |
36 | } | 37 | } |
37 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | 38 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, |
38 | bool includeNoDates ) { | 39 | bool includeNoDates ) { |
39 | return effectiveToDos( start, QDate::currentDate(), | 40 | return effectiveToDos( start, QDate::currentDate(), |
40 | includeNoDates ); | 41 | includeNoDates ); |
41 | } | 42 | } |
42 | OTodoAccess::List OTodoAccess::overDue() { | 43 | OTodoAccess::List OTodoAccess::overDue() { |
43 | List lis( m_todoBackEnd->overDue(), this ); | 44 | List lis( m_todoBackEnd->overDue(), this ); |
44 | return lis; | 45 | return lis; |
45 | } | 46 | } |
46 | void OTodoAccess::addAlarm( const OTodo& event) { | 47 | void OTodoAccess::addAlarm( const OTodo& event) { |
47 | if (!event.hasAlarmDateTime() ) | 48 | if (!event.hasAlarmDateTime() ) |
48 | return; | 49 | return; |
49 | 50 | ||
50 | QDateTime now = QDateTime::currentDateTime(); | 51 | QDateTime now = QDateTime::currentDateTime(); |
51 | QDateTime schedule = event.alarmDateTime(); | 52 | QDateTime schedule = event.alarmDateTime(); |
52 | 53 | ||
53 | if ( schedule > now ){ | 54 | if ( schedule > now ){ |
54 | AlarmServer::addAlarm( schedule, | 55 | AlarmServer::addAlarm( schedule, |
55 | "QPE/Application/todolist", | 56 | "QPE/Application/todolist", |
56 | "alarm(QDateTime,int)", event.uid() ); | 57 | "alarm(QDateTime,int)", event.uid() ); |
57 | 58 | ||
58 | } | 59 | } |
59 | } | 60 | } |
60 | void OTodoAccess::delAlarm( int uid) { | 61 | void OTodoAccess::delAlarm( int uid) { |
61 | 62 | ||
62 | QDateTime schedule; // Create null DateTime | 63 | QDateTime schedule; // Create null DateTime |
63 | 64 | ||
64 | // I hope this will remove all scheduled alarms | 65 | // I hope this will remove all scheduled alarms |
65 | // with the given uid !? | 66 | // with the given uid !? |
66 | // If not: I have to rethink how to remove already | 67 | // If not: I have to rethink how to remove already |
67 | // scheduled events... (se) | 68 | // scheduled events... (se) |
68 | // it should be fine -zecke | 69 | // it should be fine -zecke |
69 | // qWarning("Removing alarm for event with uid %d", uid ); | 70 | // qWarning("Removing alarm for event with uid %d", uid ); |
70 | AlarmServer::deleteAlarm( schedule , | 71 | AlarmServer::deleteAlarm( schedule , |
71 | "QPE/Application/todolist", | 72 | "QPE/Application/todolist", |
72 | "alarm(QDateTime,int)", uid ); | 73 | "alarm(QDateTime,int)", uid ); |
73 | } | 74 | } |
74 | /* sort order */ | 75 | /* sort order */ |
75 | OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { | 76 | OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { |
76 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, | 77 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, |
77 | filter, cat ); | 78 | filter, cat ); |
78 | OTodoAccess::List list( ints, this ); | 79 | OTodoAccess::List list( ints, this ); |
79 | return list; | 80 | return list; |
80 | } | 81 | } |
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index 599fbf2..f11f029 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -1,88 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage Backends. | 2 | * Class to manage Backends. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; | 9 | * License as published by the Free Software Foundation; |
10 | * either version 2 of the License, or (at your option) any later | 10 | * either version 2 of the License, or (at your option) any later |
11 | * version. | 11 | * version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: Use plugins | 13 | * ToDo: Use plugins |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * Version: $Id$ | 15 | * Version: $Id$ |
16 | * ===================================================================== | 16 | * ===================================================================== |
17 | * History: | 17 | * History: |
18 | * $Log$ | 18 | * $Log$ |
19 | * Revision 1.2 2002/10/08 09:27:36 eilers | ||
20 | * Fixed libopie.pro to include the new pim-API. | ||
21 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | ||
22 | * compile itself would need to install libsqlite, libopiesql... | ||
23 | * Therefore, the backend currently uses XML only.. | ||
24 | * | ||
19 | * Revision 1.1 2002/10/07 17:35:01 eilers | 25 | * Revision 1.1 2002/10/07 17:35:01 eilers |
20 | * added OBackendFactory for advanced backend access | 26 | * added OBackendFactory for advanced backend access |
21 | * | 27 | * |
22 | * | 28 | * |
23 | * ===================================================================== | 29 | * ===================================================================== |
24 | */ | 30 | */ |
25 | #ifndef __OPIE_BACKENDFACTORY_H_ | 31 | #ifndef __OPIE_BACKENDFACTORY_H_ |
26 | #define __OPIE_BACKENDFACTORY_H_ | 32 | #define __OPIE_BACKENDFACTORY_H_ |
27 | 33 | ||
28 | #include <qstring.h> | 34 | #include <qstring.h> |
29 | #include <qasciidict.h> | 35 | #include <qasciidict.h> |
30 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
31 | 37 | ||
32 | #include "otodoaccessxml.h" | 38 | #include "otodoaccessxml.h" |
33 | #include "ocontactaccessbackend_xml.h" | 39 | #include "ocontactaccessbackend_xml.h" |
34 | #include "otodoaccesssql.h" | ||
35 | 40 | ||
41 | #ifdef __USE_SQL | ||
42 | #include "otodoaccesssql.h" | ||
43 | #endif | ||
36 | 44 | ||
37 | template<class T> | 45 | template<class T> |
38 | class OBackendFactory | 46 | class OBackendFactory |
39 | { | 47 | { |
40 | public: | 48 | public: |
41 | OBackendFactory() {}; | 49 | OBackendFactory() {}; |
42 | 50 | ||
43 | enum BACKENDS { | 51 | enum BACKENDS { |
44 | TODO, | 52 | TODO, |
45 | CONTACT, | 53 | CONTACT, |
46 | DATE | 54 | DATE |
47 | }; | 55 | }; |
48 | 56 | ||
49 | static T* Default( const QString backendName, const QString& appName ){ | 57 | static T* Default( const QString backendName, const QString& appName ){ |
50 | 58 | ||
51 | 59 | ||
52 | Config config( "pimaccess" ); | 60 | Config config( "pimaccess" ); |
53 | config.setGroup ( backendName ); | 61 | config.setGroup ( backendName ); |
54 | QString backend = config.readEntry( "usebackend" ); | 62 | QString backend = config.readEntry( "usebackend" ); |
55 | 63 | ||
56 | QAsciiDict<int> dict ( 3 ); | 64 | QAsciiDict<int> dict ( 3 ); |
57 | dict.setAutoDelete ( TRUE ); | 65 | dict.setAutoDelete ( TRUE ); |
58 | 66 | ||
59 | dict.insert( "todo", new int (TODO) ); | 67 | dict.insert( "todo", new int (TODO) ); |
60 | dict.insert( "contact", new int (CONTACT) ); | 68 | dict.insert( "contact", new int (CONTACT) ); |
61 | 69 | ||
62 | qWarning ("TODO is: %d", TODO); | 70 | qWarning ("TODO is: %d", TODO); |
63 | qWarning ("CONTACT is: %d", CONTACT); | 71 | qWarning ("CONTACT is: %d", CONTACT); |
64 | 72 | ||
65 | switch ( *dict.take( backendName ) ){ | 73 | switch ( *dict.take( backendName ) ){ |
66 | case TODO: | 74 | case TODO: |
75 | #ifdef __USE_SQL | ||
67 | if ( backend == "sql" ) | 76 | if ( backend == "sql" ) |
68 | return (T*) new OTodoAccessBackendSQL(""); | 77 | return (T*) new OTodoAccessBackendSQL(""); |
69 | 78 | #else | |
79 | if ( backend == "sql" ) | ||
80 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | ||
81 | #endif | ||
82 | |||
70 | return (T*) new OTodoAccessXML( appName ); | 83 | return (T*) new OTodoAccessXML( appName ); |
71 | case CONTACT: | 84 | case CONTACT: |
72 | if ( backend == "sql" ) | 85 | if ( backend == "sql" ) |
73 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 86 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
74 | 87 | ||
75 | return (T*) new OContactAccessBackend_XML( appName ); | 88 | return (T*) new OContactAccessBackend_XML( appName ); |
76 | case DATE: | 89 | case DATE: |
77 | qWarning ("OBackendFactory:: DATE-Backend not implemented!"); | 90 | qWarning ("OBackendFactory:: DATE-Backend not implemented!"); |
78 | return NULL; | 91 | return NULL; |
79 | default: | 92 | default: |
80 | return NULL; | 93 | return NULL; |
81 | } | 94 | } |
82 | 95 | ||
83 | 96 | ||
84 | } | 97 | } |
85 | }; | 98 | }; |
86 | 99 | ||
87 | 100 | ||
88 | #endif | 101 | #endif |
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp index 4468812..80424d9 100644 --- a/libopie2/opiepim/core/otodoaccess.cpp +++ b/libopie2/opiepim/core/otodoaccess.cpp | |||
@@ -1,80 +1,81 @@ | |||
1 | #include <qdatetime.h> | 1 | #include <qdatetime.h> |
2 | 2 | ||
3 | #include <qpe/alarmserver.h> | 3 | #include <qpe/alarmserver.h> |
4 | 4 | ||
5 | #include "otodoaccesssql.h" | 5 | #include "otodoaccesssql.h" |
6 | #include "otodoaccess.h" | 6 | #include "otodoaccess.h" |
7 | #include "obackendfactory.h" | 7 | #include "obackendfactory.h" |
8 | 8 | ||
9 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) | 9 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) |
10 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) | 10 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) |
11 | { | 11 | { |
12 | if (end == 0l ) | 12 | // if (end == 0l ) |
13 | m_todoBackEnd = new OTodoAccessBackendSQL( QString::null); | 13 | // m_todoBackEnd = new OTodoAccessBackendSQL( QString::null); |
14 | 14 | ||
15 | // if (end == 0l ) | 15 | // Zecke: Du musst hier noch für das XML-Backend einen Appnamen übergeben ! |
16 | // m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null); | 16 | if (end == 0l ) |
17 | m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null); | ||
17 | 18 | ||
18 | setBackEnd( m_todoBackEnd ); | 19 | setBackEnd( m_todoBackEnd ); |
19 | } | 20 | } |
20 | OTodoAccess::~OTodoAccess() { | 21 | OTodoAccess::~OTodoAccess() { |
21 | // qWarning("~OTodoAccess"); | 22 | // qWarning("~OTodoAccess"); |
22 | } | 23 | } |
23 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { | 24 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { |
24 | QValueList<OTodo>::ConstIterator it; | 25 | QValueList<OTodo>::ConstIterator it; |
25 | for ( it = list.begin(); it != list.end(); ++it ) { | 26 | for ( it = list.begin(); it != list.end(); ++it ) { |
26 | replace( (*it) ); | 27 | replace( (*it) ); |
27 | } | 28 | } |
28 | } | 29 | } |
29 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | 30 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, |
30 | const QDate& end, | 31 | const QDate& end, |
31 | bool includeNoDates ) { | 32 | bool includeNoDates ) { |
32 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); | 33 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); |
33 | 34 | ||
34 | List lis( ints, this ); | 35 | List lis( ints, this ); |
35 | return lis; | 36 | return lis; |
36 | } | 37 | } |
37 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | 38 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, |
38 | bool includeNoDates ) { | 39 | bool includeNoDates ) { |
39 | return effectiveToDos( start, QDate::currentDate(), | 40 | return effectiveToDos( start, QDate::currentDate(), |
40 | includeNoDates ); | 41 | includeNoDates ); |
41 | } | 42 | } |
42 | OTodoAccess::List OTodoAccess::overDue() { | 43 | OTodoAccess::List OTodoAccess::overDue() { |
43 | List lis( m_todoBackEnd->overDue(), this ); | 44 | List lis( m_todoBackEnd->overDue(), this ); |
44 | return lis; | 45 | return lis; |
45 | } | 46 | } |
46 | void OTodoAccess::addAlarm( const OTodo& event) { | 47 | void OTodoAccess::addAlarm( const OTodo& event) { |
47 | if (!event.hasAlarmDateTime() ) | 48 | if (!event.hasAlarmDateTime() ) |
48 | return; | 49 | return; |
49 | 50 | ||
50 | QDateTime now = QDateTime::currentDateTime(); | 51 | QDateTime now = QDateTime::currentDateTime(); |
51 | QDateTime schedule = event.alarmDateTime(); | 52 | QDateTime schedule = event.alarmDateTime(); |
52 | 53 | ||
53 | if ( schedule > now ){ | 54 | if ( schedule > now ){ |
54 | AlarmServer::addAlarm( schedule, | 55 | AlarmServer::addAlarm( schedule, |
55 | "QPE/Application/todolist", | 56 | "QPE/Application/todolist", |
56 | "alarm(QDateTime,int)", event.uid() ); | 57 | "alarm(QDateTime,int)", event.uid() ); |
57 | 58 | ||
58 | } | 59 | } |
59 | } | 60 | } |
60 | void OTodoAccess::delAlarm( int uid) { | 61 | void OTodoAccess::delAlarm( int uid) { |
61 | 62 | ||
62 | QDateTime schedule; // Create null DateTime | 63 | QDateTime schedule; // Create null DateTime |
63 | 64 | ||
64 | // I hope this will remove all scheduled alarms | 65 | // I hope this will remove all scheduled alarms |
65 | // with the given uid !? | 66 | // with the given uid !? |
66 | // If not: I have to rethink how to remove already | 67 | // If not: I have to rethink how to remove already |
67 | // scheduled events... (se) | 68 | // scheduled events... (se) |
68 | // it should be fine -zecke | 69 | // it should be fine -zecke |
69 | // qWarning("Removing alarm for event with uid %d", uid ); | 70 | // qWarning("Removing alarm for event with uid %d", uid ); |
70 | AlarmServer::deleteAlarm( schedule , | 71 | AlarmServer::deleteAlarm( schedule , |
71 | "QPE/Application/todolist", | 72 | "QPE/Application/todolist", |
72 | "alarm(QDateTime,int)", uid ); | 73 | "alarm(QDateTime,int)", uid ); |
73 | } | 74 | } |
74 | /* sort order */ | 75 | /* sort order */ |
75 | OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { | 76 | OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { |
76 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, | 77 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, |
77 | filter, cat ); | 78 | filter, cat ); |
78 | OTodoAccess::List list( ints, this ); | 79 | OTodoAccess::List list( ints, this ); |
79 | return list; | 80 | return list; |
80 | } | 81 | } |