summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-07 17:44:24 (UTC)
committer eilers <eilers>2002-10-07 17:44:24 (UTC)
commitd25a925e70982b86539b98362ab2cd75c7883110 (patch) (unidiff)
treeeaa1d292fdfc9a87e538130b8c635df63086ec9c
parent0981af024243b314b45ddaf3ebee08bc184f06e2 (diff)
downloadopie-d25a925e70982b86539b98362ab2cd75c7883110.zip
opie-d25a925e70982b86539b98362ab2cd75c7883110.tar.gz
opie-d25a925e70982b86539b98362ab2cd75c7883110.tar.bz2
added OBackendFactory for advanced backend access
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otodoaccess.cpp5
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp
index 5990841..4468812 100644
--- a/libopie/pim/otodoaccess.cpp
+++ b/libopie/pim/otodoaccess.cpp
@@ -1,77 +1,80 @@
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 7#include "obackendfactory.h"
8 8
9OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) 9OTodoAccess::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 )
16 // m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null);
17
15 setBackEnd( m_todoBackEnd ); 18 setBackEnd( m_todoBackEnd );
16} 19}
17OTodoAccess::~OTodoAccess() { 20OTodoAccess::~OTodoAccess() {
18// qWarning("~OTodoAccess"); 21// qWarning("~OTodoAccess");
19} 22}
20void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { 23void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) {
21 QValueList<OTodo>::ConstIterator it; 24 QValueList<OTodo>::ConstIterator it;
22 for ( it = list.begin(); it != list.end(); ++it ) { 25 for ( it = list.begin(); it != list.end(); ++it ) {
23 replace( (*it) ); 26 replace( (*it) );
24 } 27 }
25} 28}
26OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 29OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
27 const QDate& end, 30 const QDate& end,
28 bool includeNoDates ) { 31 bool includeNoDates ) {
29 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); 32 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
30 33
31 List lis( ints, this ); 34 List lis( ints, this );
32 return lis; 35 return lis;
33} 36}
34OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 37OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
35 bool includeNoDates ) { 38 bool includeNoDates ) {
36 return effectiveToDos( start, QDate::currentDate(), 39 return effectiveToDos( start, QDate::currentDate(),
37 includeNoDates ); 40 includeNoDates );
38} 41}
39OTodoAccess::List OTodoAccess::overDue() { 42OTodoAccess::List OTodoAccess::overDue() {
40 List lis( m_todoBackEnd->overDue(), this ); 43 List lis( m_todoBackEnd->overDue(), this );
41 return lis; 44 return lis;
42} 45}
43void OTodoAccess::addAlarm( const OTodo& event) { 46void OTodoAccess::addAlarm( const OTodo& event) {
44 if (!event.hasAlarmDateTime() ) 47 if (!event.hasAlarmDateTime() )
45 return; 48 return;
46 49
47 QDateTime now = QDateTime::currentDateTime(); 50 QDateTime now = QDateTime::currentDateTime();
48 QDateTime schedule = event.alarmDateTime(); 51 QDateTime schedule = event.alarmDateTime();
49 52
50 if ( schedule > now ){ 53 if ( schedule > now ){
51 AlarmServer::addAlarm( schedule, 54 AlarmServer::addAlarm( schedule,
52 "QPE/Application/todolist", 55 "QPE/Application/todolist",
53 "alarm(QDateTime,int)", event.uid() ); 56 "alarm(QDateTime,int)", event.uid() );
54 57
55 } 58 }
56} 59}
57void OTodoAccess::delAlarm( int uid) { 60void OTodoAccess::delAlarm( int uid) {
58 61
59 QDateTime schedule; // Create null DateTime 62 QDateTime schedule; // Create null DateTime
60 63
61 // I hope this will remove all scheduled alarms 64 // I hope this will remove all scheduled alarms
62 // with the given uid !? 65 // with the given uid !?
63 // If not: I have to rethink how to remove already 66 // If not: I have to rethink how to remove already
64 // scheduled events... (se) 67 // scheduled events... (se)
65 // it should be fine -zecke 68 // it should be fine -zecke
66// qWarning("Removing alarm for event with uid %d", uid ); 69// qWarning("Removing alarm for event with uid %d", uid );
67 AlarmServer::deleteAlarm( schedule , 70 AlarmServer::deleteAlarm( schedule ,
68 "QPE/Application/todolist", 71 "QPE/Application/todolist",
69 "alarm(QDateTime,int)", uid ); 72 "alarm(QDateTime,int)", uid );
70} 73}
71/* sort order */ 74/* sort order */
72OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { 75OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
73 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, 76 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
74 filter, cat ); 77 filter, cat );
75 OTodoAccess::List list( ints, this ); 78 OTodoAccess::List list( ints, this );
76 return list; 79 return list;
77} 80}
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index 5990841..4468812 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -1,77 +1,80 @@
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 7#include "obackendfactory.h"
8 8
9OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) 9OTodoAccess::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 )
16 // m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null);
17
15 setBackEnd( m_todoBackEnd ); 18 setBackEnd( m_todoBackEnd );
16} 19}
17OTodoAccess::~OTodoAccess() { 20OTodoAccess::~OTodoAccess() {
18// qWarning("~OTodoAccess"); 21// qWarning("~OTodoAccess");
19} 22}
20void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { 23void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) {
21 QValueList<OTodo>::ConstIterator it; 24 QValueList<OTodo>::ConstIterator it;
22 for ( it = list.begin(); it != list.end(); ++it ) { 25 for ( it = list.begin(); it != list.end(); ++it ) {
23 replace( (*it) ); 26 replace( (*it) );
24 } 27 }
25} 28}
26OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 29OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
27 const QDate& end, 30 const QDate& end,
28 bool includeNoDates ) { 31 bool includeNoDates ) {
29 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); 32 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
30 33
31 List lis( ints, this ); 34 List lis( ints, this );
32 return lis; 35 return lis;
33} 36}
34OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 37OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
35 bool includeNoDates ) { 38 bool includeNoDates ) {
36 return effectiveToDos( start, QDate::currentDate(), 39 return effectiveToDos( start, QDate::currentDate(),
37 includeNoDates ); 40 includeNoDates );
38} 41}
39OTodoAccess::List OTodoAccess::overDue() { 42OTodoAccess::List OTodoAccess::overDue() {
40 List lis( m_todoBackEnd->overDue(), this ); 43 List lis( m_todoBackEnd->overDue(), this );
41 return lis; 44 return lis;
42} 45}
43void OTodoAccess::addAlarm( const OTodo& event) { 46void OTodoAccess::addAlarm( const OTodo& event) {
44 if (!event.hasAlarmDateTime() ) 47 if (!event.hasAlarmDateTime() )
45 return; 48 return;
46 49
47 QDateTime now = QDateTime::currentDateTime(); 50 QDateTime now = QDateTime::currentDateTime();
48 QDateTime schedule = event.alarmDateTime(); 51 QDateTime schedule = event.alarmDateTime();
49 52
50 if ( schedule > now ){ 53 if ( schedule > now ){
51 AlarmServer::addAlarm( schedule, 54 AlarmServer::addAlarm( schedule,
52 "QPE/Application/todolist", 55 "QPE/Application/todolist",
53 "alarm(QDateTime,int)", event.uid() ); 56 "alarm(QDateTime,int)", event.uid() );
54 57
55 } 58 }
56} 59}
57void OTodoAccess::delAlarm( int uid) { 60void OTodoAccess::delAlarm( int uid) {
58 61
59 QDateTime schedule; // Create null DateTime 62 QDateTime schedule; // Create null DateTime
60 63
61 // I hope this will remove all scheduled alarms 64 // I hope this will remove all scheduled alarms
62 // with the given uid !? 65 // with the given uid !?
63 // If not: I have to rethink how to remove already 66 // If not: I have to rethink how to remove already
64 // scheduled events... (se) 67 // scheduled events... (se)
65 // it should be fine -zecke 68 // it should be fine -zecke
66// qWarning("Removing alarm for event with uid %d", uid ); 69// qWarning("Removing alarm for event with uid %d", uid );
67 AlarmServer::deleteAlarm( schedule , 70 AlarmServer::deleteAlarm( schedule ,
68 "QPE/Application/todolist", 71 "QPE/Application/todolist",
69 "alarm(QDateTime,int)", uid ); 72 "alarm(QDateTime,int)", uid );
70} 73}
71/* sort order */ 74/* sort order */
72OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { 75OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
73 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, 76 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
74 filter, cat ); 77 filter, cat );
75 OTodoAccess::List list( ints, this ); 78 OTodoAccess::List list( ints, this );
76 return list; 79 return list;
77} 80}