author | zecke <zecke> | 2002-03-20 21:55:54 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-20 21:55:54 (UTC) |
commit | c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344 (patch) (unidiff) | |
tree | f68d6a7c899e1ffe297af30002a3dc8b4f3762c6 | |
parent | 0d759d6e9c84a8597b6594bb7c5ad5d17621b966 (diff) | |
download | opie-c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344.zip opie-c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344.tar.gz opie-c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344.tar.bz2 |
tododb vCal support
-rw-r--r-- | libopie/tododb.h | 4 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 6 | ||||
-rw-r--r-- | libopie/todoevent.h | 1 | ||||
-rw-r--r-- | libopie/todovcalresource.h | 42 |
4 files changed, 51 insertions, 2 deletions
diff --git a/libopie/tododb.h b/libopie/tododb.h index 945f343..e77a0f4 100644 --- a/libopie/tododb.h +++ b/libopie/tododb.h | |||
@@ -7,38 +7,38 @@ | |||
7 | #include <opie/todoevent.h> | 7 | #include <opie/todoevent.h> |
8 | 8 | ||
9 | class ToDoResource; | 9 | class ToDoResource; |
10 | class ToDoDB | 10 | class ToDoDB |
11 | { | 11 | { |
12 | public: | 12 | public: |
13 | // if no argument is supplied pick the default book | 13 | // if no argument is supplied pick the default book |
14 | ToDoDB(const QString &fileName = QString::null, ToDoResource* resource= 0 ); | 14 | ToDoDB(const QString &fileName = QString::null, ToDoResource* resource= 0 ); |
15 | ~ToDoDB(); | 15 | ~ToDoDB(); |
16 | QValueList<ToDoEvent> effectiveToDos(const QDate &from, | 16 | QValueList<ToDoEvent> effectiveToDos(const QDate &from, |
17 | const QDate &to, | 17 | const QDate &to, |
18 | bool includeNoDates = true); | 18 | bool includeNoDates = true); |
19 | QValueList<ToDoEvent> effectiveToDos(const QDate &start, bool includeNoDates = true ); | 19 | QValueList<ToDoEvent> effectiveToDos(const QDate &start, bool includeNoDates = true ); |
20 | QValueList<ToDoEvent> rawToDos(); // all events | 20 | QValueList<ToDoEvent> rawToDos(); // all events |
21 | QValueList<ToDoEvent> overDue(); | 21 | QValueList<ToDoEvent> overDue(); |
22 | 22 | ||
23 | void addEvent(const ToDoEvent &event ); | 23 | void addEvent(const ToDoEvent &event ); |
24 | void editEvent(const ToDoEvent &editEvent ); | 24 | void editEvent(const ToDoEvent &editEvent ); |
25 | void removeEvent(const ToDoEvent &event); | 25 | void removeEvent(const ToDoEvent &event); |
26 | 26 | ||
27 | void reload(); | 27 | void reload(); |
28 | void setFileName(const QString & ); | 28 | void setFileName(const QString & ); |
29 | QString fileName()const; | 29 | QString fileName()const; |
30 | bool save(); | 30 | bool save(); |
31 | ToDoResource *resource(); | 31 | ToDoResource *resource(); |
32 | void setResource(ToDoResource* res); | 32 | void setResource(ToDoResource* res); |
33 | 33 | ||
34 | private: | 34 | private: |
35 | class ToDoDBPrivate; | 35 | class ToDoDBPrivate; |
36 | ToDoDBPrivate *d; | 36 | ToDoDBPrivate *d; |
37 | QString m_fileName; | 37 | QString m_fileName; |
38 | ToDoResource *m_res; | 38 | ToDoResource *m_res; |
39 | QValueList<ToDoEvent> m_todos; | 39 | QValueList<ToDoEvent> m_todos; |
40 | void load(); | 40 | void load(); |
41 | }; | 41 | }; |
42 | 42 | ||
43 | 43 | ||
44 | #endif | 44 | #endif |
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 5fa4472..daa25f4 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -1,30 +1,35 @@ | |||
1 | 1 | ||
2 | #include <opie/todoevent.h> | 2 | #include <opie/todoevent.h> |
3 | #include <qpe/palmtopuidgen.h> | 3 | #include <qpe/palmtopuidgen.h> |
4 | #include <qpe/stringutil.h> | 4 | #include <qpe/stringutil.h> |
5 | //#include <qpe/palmtoprecord.h> | 5 | //#include <qpe/palmtoprecord.h> |
6 | 6 | ||
7 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | ||
8 | { | ||
9 | *this = event; | ||
10 | } | ||
11 | |||
7 | ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, | 12 | ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, |
8 | const QString &description, bool hasDate, QDate date, int uid ) | 13 | const QString &description, bool hasDate, QDate date, int uid ) |
9 | { | 14 | { |
10 | qWarning("todoEvent c'tor" ); | 15 | qWarning("todoEvent c'tor" ); |
11 | m_date = date; | 16 | m_date = date; |
12 | m_isCompleted = completed; | 17 | m_isCompleted = completed; |
13 | m_hasDate = hasDate; | 18 | m_hasDate = hasDate; |
14 | m_priority = priority; | 19 | m_priority = priority; |
15 | m_category = category; | 20 | m_category = category; |
16 | m_desc = Qtopia::simplifyMultiLineSpace(description ); | 21 | m_desc = Qtopia::simplifyMultiLineSpace(description ); |
17 | if (uid == -1 ) { | 22 | if (uid == -1 ) { |
18 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 23 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
19 | uid = uidgen->generate(); | 24 | uid = uidgen->generate(); |
20 | delete uidgen; | 25 | delete uidgen; |
21 | }// generate the ids | 26 | }// generate the ids |
22 | m_uid = uid; | 27 | m_uid = uid; |
23 | } | 28 | } |
24 | bool ToDoEvent::isCompleted() const | 29 | bool ToDoEvent::isCompleted() const |
25 | { | 30 | { |
26 | return m_isCompleted; | 31 | return m_isCompleted; |
27 | } | 32 | } |
28 | bool ToDoEvent::hasDate() const | 33 | bool ToDoEvent::hasDate() const |
29 | { | 34 | { |
30 | return m_hasDate; | 35 | return m_hasDate; |
@@ -119,34 +124,35 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | |||
119 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 124 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
120 | if( hasDate() && toDoEvent.hasDate() ){ | 125 | if( hasDate() && toDoEvent.hasDate() ){ |
121 | if( date() == toDoEvent.date() ){ // let's the priority decide | 126 | if( date() == toDoEvent.date() ){ // let's the priority decide |
122 | return priority() > toDoEvent.priority(); | 127 | return priority() > toDoEvent.priority(); |
123 | }else{ | 128 | }else{ |
124 | return date() > toDoEvent.date(); | 129 | return date() > toDoEvent.date(); |
125 | } | 130 | } |
126 | } | 131 | } |
127 | return true; | 132 | return true; |
128 | } | 133 | } |
129 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 134 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const |
130 | { | 135 | { |
131 | if( m_date == toDoEvent.m_date && m_isCompleted == toDoEvent.m_isCompleted && m_hasDate == toDoEvent.m_hasDate && m_priority == toDoEvent.m_priority && m_category == toDoEvent.m_category && m_desc == toDoEvent.m_category ) | 136 | if( m_date == toDoEvent.m_date && m_isCompleted == toDoEvent.m_isCompleted && m_hasDate == toDoEvent.m_hasDate && m_priority == toDoEvent.m_priority && m_category == toDoEvent.m_category && m_desc == toDoEvent.m_category ) |
132 | return true; | 137 | return true; |
133 | return false; | 138 | return false; |
134 | } | 139 | } |
135 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 140 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) |
136 | { | 141 | { |
137 | m_date = item.m_date; | 142 | m_date = item.m_date; |
138 | m_isCompleted = item.m_isCompleted; | 143 | m_isCompleted = item.m_isCompleted; |
139 | m_hasDate = item.m_hasDate; | 144 | m_hasDate = item.m_hasDate; |
140 | m_priority = item.m_priority; | 145 | m_priority = item.m_priority; |
141 | m_category = item.m_category; | 146 | m_category = item.m_category; |
142 | m_desc = item.m_desc; | 147 | m_desc = item.m_desc; |
148 | m_uid = item.m_uid; | ||
143 | return *this; | 149 | return *this; |
144 | } | 150 | } |
145 | 151 | ||
146 | 152 | ||
147 | 153 | ||
148 | 154 | ||
149 | 155 | ||
150 | 156 | ||
151 | 157 | ||
152 | 158 | ||
diff --git a/libopie/todoevent.h b/libopie/todoevent.h index 79522b2..bca7f6e 100644 --- a/libopie/todoevent.h +++ b/libopie/todoevent.h | |||
@@ -1,38 +1,39 @@ | |||
1 | 1 | ||
2 | #ifndef todoevent_h | 2 | #ifndef todoevent_h |
3 | #define todoevent_h | 3 | #define todoevent_h |
4 | 4 | ||
5 | #include <qdatetime.h> | 5 | #include <qdatetime.h> |
6 | 6 | ||
7 | class ToDoEvent { | 7 | class ToDoEvent { |
8 | friend class ToDoDB; | 8 | friend class ToDoDB; |
9 | public: | 9 | public: |
10 | enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; | 10 | enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; |
11 | ToDoEvent( bool completed = false, int priority = NORMAL, | 11 | ToDoEvent( bool completed = false, int priority = NORMAL, |
12 | const QString &category = QString::null, | 12 | const QString &category = QString::null, |
13 | const QString &description = QString::null , | 13 | const QString &description = QString::null , |
14 | bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); | 14 | bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); |
15 | ToDoEvent(const ToDoEvent & ); | ||
15 | bool isCompleted() const; | 16 | bool isCompleted() const; |
16 | bool hasDate() const; | 17 | bool hasDate() const; |
17 | int priority()const ; | 18 | int priority()const ; |
18 | QString category()const; | 19 | QString category()const; |
19 | QDate date()const; | 20 | QDate date()const; |
20 | QString description()const; | 21 | QString description()const; |
21 | 22 | ||
22 | int uid()const { return m_uid;}; | 23 | int uid()const { return m_uid;}; |
23 | void setCompleted(bool completed ); | 24 | void setCompleted(bool completed ); |
24 | void setHasDate( bool hasDate ); | 25 | void setHasDate( bool hasDate ); |
25 | // if the category doesn't exist we will create it | 26 | // if the category doesn't exist we will create it |
26 | void setCategory( const QString &category ); | 27 | void setCategory( const QString &category ); |
27 | void setPriority(int priority ); | 28 | void setPriority(int priority ); |
28 | void setDate( QDate date ); | 29 | void setDate( QDate date ); |
29 | void setDescription(const QString& ); | 30 | void setDescription(const QString& ); |
30 | bool isOverdue(); | 31 | bool isOverdue(); |
31 | 32 | ||
32 | void setUid(int id) {m_uid = id; }; | 33 | void setUid(int id) {m_uid = id; }; |
33 | bool operator<(const ToDoEvent &toDoEvent )const; | 34 | bool operator<(const ToDoEvent &toDoEvent )const; |
34 | bool operator<=(const ToDoEvent &toDoEvent )const; | 35 | bool operator<=(const ToDoEvent &toDoEvent )const; |
35 | bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; | 36 | bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; |
36 | bool operator>(const ToDoEvent &toDoEvent )const; | 37 | bool operator>(const ToDoEvent &toDoEvent )const; |
37 | bool operator>=(const ToDoEvent &toDoEvent)const; | 38 | bool operator>=(const ToDoEvent &toDoEvent)const; |
38 | bool operator==(const ToDoEvent &toDoEvent )const; | 39 | bool operator==(const ToDoEvent &toDoEvent )const; |
diff --git a/libopie/todovcalresource.h b/libopie/todovcalresource.h new file mode 100644 index 0000000..0663bc2 --- a/dev/null +++ b/libopie/todovcalresource.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #ifndef opievcaltodoresource_h | ||
30 | #define opievcaltodoresource_h | ||
31 | |||
32 | #include <opie/todoresource.h> | ||
33 | |||
34 | class ToDoVCalResource : public ToDoResource { | ||
35 | public: | ||
36 | ToDoVCalResource() { }; | ||
37 | QValueList<ToDoEvent> load(const QString &file ); | ||
38 | bool save( const QString &filename, const QValueList<ToDoEvent> & ); | ||
39 | |||
40 | }; | ||
41 | |||
42 | #endif | ||