-rw-r--r-- | libopie/pim/otodoaccess.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp new file mode 100644 index 0000000..a65cf5c --- a/dev/null +++ b/libopie/pim/otodoaccess.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | #include <qdatetime.h> | ||
2 | |||
3 | #include <qpe/alarmserver.h> | ||
4 | |||
5 | #include "otodoaccessxml.h" | ||
6 | #include "otodoaccess.h" | ||
7 | |||
8 | |||
9 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) | ||
10 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) | ||
11 | { | ||
12 | if (end == 0l ) | ||
13 | m_todoBackEnd = new OTodoAccessXML( "Todolist" ); | ||
14 | |||
15 | setBackEnd( m_todoBackEnd ); | ||
16 | } | ||
17 | OTodoAccess::~OTodoAccess() { | ||
18 | qWarning("~OTodoAccess"); | ||
19 | } | ||
20 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { | ||
21 | QValueList<OTodo>::ConstIterator it; | ||
22 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
23 | replace( (*it) ); | ||
24 | } | ||
25 | } | ||
26 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | ||
27 | const QDate& end, | ||
28 | bool includeNoDates ) { | ||
29 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); | ||
30 | |||
31 | List lis( ints, this ); | ||
32 | return lis; | ||
33 | } | ||
34 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | ||
35 | bool includeNoDates ) { | ||
36 | return effectiveToDos( start, QDate::currentDate(), | ||
37 | includeNoDates ); | ||
38 | } | ||
39 | OTodoAccess::List OTodoAccess::overDue() { | ||
40 | List lis( m_todoBackEnd->overDue(), this ); | ||
41 | return lis; | ||
42 | } | ||
43 | void OTodoAccess::addAlarm( const OTodo& event) { | ||
44 | if (!event.hasAlarmDateTime() ) | ||
45 | return; | ||
46 | |||
47 | QDateTime now = QDateTime::currentDateTime(); | ||
48 | QDateTime schedule = event.alarmDateTime(); | ||
49 | |||
50 | if ( schedule > now ){ | ||
51 | AlarmServer::addAlarm( schedule, | ||
52 | "QPE/Application/todolist", | ||
53 | "alarm(QDateTime,int)", event.uid() ); | ||
54 | |||
55 | } | ||
56 | } | ||
57 | void OTodoAccess::delAlarm( int uid) { | ||
58 | |||
59 | QDateTime schedule; // Create null DateTime | ||
60 | |||
61 | // I hope this will remove all scheduled alarms | ||
62 | // with the given uid !? | ||
63 | // If not: I have to rethink how to remove already | ||
64 | // scheduled events... (se) | ||
65 | // it should be fine -zecke | ||
66 | qWarning("Removing alarm for event with uid %d", uid ); | ||
67 | AlarmServer::deleteAlarm( schedule , | ||
68 | "QPE/Application/todolist", | ||
69 | "alarm(QDateTime,int)", uid ); | ||
70 | } | ||
71 | |||