author | zecke <zecke> | 2003-05-12 13:12:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-12 13:12:45 (UTC) |
commit | 52b74f396416cc1b87d76a0541617512da22157a (patch) (unidiff) | |
tree | dbec31fb8b79cdb6fbe50f588aac280a8fdc2bfa | |
parent | 64f9f964ef690806378d639118f79539a8934d40 (diff) | |
download | opie-52b74f396416cc1b87d76a0541617512da22157a.zip opie-52b74f396416cc1b87d76a0541617512da22157a.tar.gz opie-52b74f396416cc1b87d76a0541617512da22157a.tar.bz2 |
fix up OTodo::hasNotifiers
add a const notifiers() function
and fix OPimNotifyManager::isEmpty
-rw-r--r-- | libopie/pim/opimnotifymanager.cpp | 4 | ||||
-rw-r--r-- | libopie/pim/otodo.cpp | 8 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 8 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 8 |
6 files changed, 34 insertions, 6 deletions
diff --git a/libopie/pim/opimnotifymanager.cpp b/libopie/pim/opimnotifymanager.cpp index 49af757..06b5987 100644 --- a/libopie/pim/opimnotifymanager.cpp +++ b/libopie/pim/opimnotifymanager.cpp | |||
@@ -1,72 +1,74 @@ | |||
1 | #include "opimnotifymanager.h" | 1 | #include "opimnotifymanager.h" |
2 | 2 | ||
3 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | 3 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) |
4 | : m_rem( rem ), m_al( al ) | 4 | : m_rem( rem ), m_al( al ) |
5 | {} | 5 | {} |
6 | OPimNotifyManager::~OPimNotifyManager() { | 6 | OPimNotifyManager::~OPimNotifyManager() { |
7 | } | 7 | } |
8 | /* use static_cast and type instead of dynamic... */ | 8 | /* use static_cast and type instead of dynamic... */ |
9 | void OPimNotifyManager::add( const OPimNotify& noti) { | 9 | void OPimNotifyManager::add( const OPimNotify& noti) { |
10 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 10 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
11 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 11 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
12 | m_rem.append( rem ); | 12 | m_rem.append( rem ); |
13 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 13 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
14 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 14 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
15 | m_al.append( al ); | 15 | m_al.append( al ); |
16 | } | 16 | } |
17 | } | 17 | } |
18 | void OPimNotifyManager::remove( const OPimNotify& noti) { | 18 | void OPimNotifyManager::remove( const OPimNotify& noti) { |
19 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 19 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
20 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 20 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
21 | m_rem.remove( rem ); | 21 | m_rem.remove( rem ); |
22 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 22 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
23 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 23 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
24 | m_al.remove( al ); | 24 | m_al.remove( al ); |
25 | } | 25 | } |
26 | } | 26 | } |
27 | void OPimNotifyManager::replace( const OPimNotify& noti) { | 27 | void OPimNotifyManager::replace( const OPimNotify& noti) { |
28 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 28 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
29 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 29 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
30 | m_rem.remove( rem ); | 30 | m_rem.remove( rem ); |
31 | m_rem.append( rem ); | 31 | m_rem.append( rem ); |
32 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 32 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
33 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 33 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
34 | m_al.remove( al ); | 34 | m_al.remove( al ); |
35 | m_al.append( al ); | 35 | m_al.append( al ); |
36 | } | 36 | } |
37 | } | 37 | } |
38 | OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { | 38 | OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { |
39 | return m_rem; | 39 | return m_rem; |
40 | } | 40 | } |
41 | OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { | 41 | OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { |
42 | return m_al; | 42 | return m_al; |
43 | } | 43 | } |
44 | void OPimNotifyManager::setAlarms( const Alarms& al) { | 44 | void OPimNotifyManager::setAlarms( const Alarms& al) { |
45 | m_al = al; | 45 | m_al = al; |
46 | } | 46 | } |
47 | void OPimNotifyManager::setReminders( const Reminders& rem) { | 47 | void OPimNotifyManager::setReminders( const Reminders& rem) { |
48 | m_rem = rem; | 48 | m_rem = rem; |
49 | } | 49 | } |
50 | /* FIXME!!! */ | 50 | /* FIXME!!! */ |
51 | /** | 51 | /** |
52 | * The idea is to check if the provider for our service | 52 | * The idea is to check if the provider for our service |
53 | * is online | 53 | * is online |
54 | * if it is we will use QCOP | 54 | * if it is we will use QCOP |
55 | * if not the Factory to get the backend... | 55 | * if not the Factory to get the backend... |
56 | * Qtopia1.6 services would be kewl to have here.... | 56 | * Qtopia1.6 services would be kewl to have here.... |
57 | */ | 57 | */ |
58 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { | 58 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { |
59 | 59 | ||
60 | } | 60 | } |
61 | /* FIXME!!! */ | 61 | /* FIXME!!! */ |
62 | /** | 62 | /** |
63 | * same as above... | 63 | * same as above... |
64 | * Also implement Url model | 64 | * Also implement Url model |
65 | * have a MainWindow.... | 65 | * have a MainWindow.... |
66 | */ | 66 | */ |
67 | void OPimNotifyManager::deregister( const OPimNotify& ) { | 67 | void OPimNotifyManager::deregister( const OPimNotify& ) { |
68 | 68 | ||
69 | } | 69 | } |
70 | bool OPimNotifyManager::isEmpty()const { | 70 | bool OPimNotifyManager::isEmpty()const { |
71 | return ( m_rem.isEmpty() && m_al.isEmpty() ); | 71 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); |
72 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; | ||
73 | else return false; | ||
72 | } | 74 | } |
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index f3df119..a29d88e 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -45,431 +45,437 @@ struct OTodo::OTodoData : public QShared { | |||
45 | OPimNotifyManager *notifiers; | 45 | OPimNotifyManager *notifiers; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | OTodo::OTodo(const OTodo &event ) | 48 | OTodo::OTodo(const OTodo &event ) |
49 | : OPimRecord( event ), data( event.data ) | 49 | : OPimRecord( event ), data( event.data ) |
50 | { | 50 | { |
51 | data->ref(); | 51 | data->ref(); |
52 | // qWarning("ref up"); | 52 | // qWarning("ref up"); |
53 | } | 53 | } |
54 | OTodo::~OTodo() { | 54 | OTodo::~OTodo() { |
55 | 55 | ||
56 | // qWarning("~OTodo " ); | 56 | // qWarning("~OTodo " ); |
57 | if ( data->deref() ) { | 57 | if ( data->deref() ) { |
58 | // qWarning("OTodo::dereffing"); | 58 | // qWarning("OTodo::dereffing"); |
59 | delete data; | 59 | delete data; |
60 | data = 0l; | 60 | data = 0l; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | OTodo::OTodo(bool completed, int priority, | 63 | OTodo::OTodo(bool completed, int priority, |
64 | const QArray<int> &category, | 64 | const QArray<int> &category, |
65 | const QString& summary, | 65 | const QString& summary, |
66 | const QString &description, | 66 | const QString &description, |
67 | ushort progress, | 67 | ushort progress, |
68 | bool hasDate, QDate date, int uid ) | 68 | bool hasDate, QDate date, int uid ) |
69 | : OPimRecord( uid ) | 69 | : OPimRecord( uid ) |
70 | { | 70 | { |
71 | // qWarning("OTodoData " + summary); | 71 | // qWarning("OTodoData " + summary); |
72 | setCategories( category ); | 72 | setCategories( category ); |
73 | 73 | ||
74 | data = new OTodoData; | 74 | data = new OTodoData; |
75 | 75 | ||
76 | data->date = date; | 76 | data->date = date; |
77 | data->isCompleted = completed; | 77 | data->isCompleted = completed; |
78 | data->hasDate = hasDate; | 78 | data->hasDate = hasDate; |
79 | data->priority = priority; | 79 | data->priority = priority; |
80 | data->sum = summary; | 80 | data->sum = summary; |
81 | data->prog = progress; | 81 | data->prog = progress; |
82 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 82 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
83 | } | 83 | } |
84 | OTodo::OTodo(bool completed, int priority, | 84 | OTodo::OTodo(bool completed, int priority, |
85 | const QStringList &category, | 85 | const QStringList &category, |
86 | const QString& summary, | 86 | const QString& summary, |
87 | const QString &description, | 87 | const QString &description, |
88 | ushort progress, | 88 | ushort progress, |
89 | bool hasDate, QDate date, int uid ) | 89 | bool hasDate, QDate date, int uid ) |
90 | : OPimRecord( uid ) | 90 | : OPimRecord( uid ) |
91 | { | 91 | { |
92 | // qWarning("OTodoData" + summary); | 92 | // qWarning("OTodoData" + summary); |
93 | setCategories( idsFromString( category.join(";") ) ); | 93 | setCategories( idsFromString( category.join(";") ) ); |
94 | 94 | ||
95 | data = new OTodoData; | 95 | data = new OTodoData; |
96 | 96 | ||
97 | data->date = date; | 97 | data->date = date; |
98 | data->isCompleted = completed; | 98 | data->isCompleted = completed; |
99 | data->hasDate = hasDate; | 99 | data->hasDate = hasDate; |
100 | data->priority = priority; | 100 | data->priority = priority; |
101 | data->sum = summary; | 101 | data->sum = summary; |
102 | data->prog = progress; | 102 | data->prog = progress; |
103 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 103 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
104 | } | 104 | } |
105 | bool OTodo::match( const QRegExp ®Exp )const | 105 | bool OTodo::match( const QRegExp ®Exp )const |
106 | { | 106 | { |
107 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 107 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
108 | return true; | 108 | return true; |
109 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 109 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
110 | return true; | 110 | return true; |
111 | }else if(data->desc.find( regExp ) != -1 ){ | 111 | }else if(data->desc.find( regExp ) != -1 ){ |
112 | return true; | 112 | return true; |
113 | }else if(data->sum.find( regExp ) != -1 ) { | 113 | }else if(data->sum.find( regExp ) != -1 ) { |
114 | return true; | 114 | return true; |
115 | } | 115 | } |
116 | return false; | 116 | return false; |
117 | } | 117 | } |
118 | bool OTodo::isCompleted() const | 118 | bool OTodo::isCompleted() const |
119 | { | 119 | { |
120 | return data->isCompleted; | 120 | return data->isCompleted; |
121 | } | 121 | } |
122 | bool OTodo::hasDueDate() const | 122 | bool OTodo::hasDueDate() const |
123 | { | 123 | { |
124 | return data->hasDate; | 124 | return data->hasDate; |
125 | } | 125 | } |
126 | bool OTodo::hasStartDate()const { | 126 | bool OTodo::hasStartDate()const { |
127 | return data->start.isValid(); | 127 | return data->start.isValid(); |
128 | } | 128 | } |
129 | bool OTodo::hasCompletedDate()const { | 129 | bool OTodo::hasCompletedDate()const { |
130 | return data->completed.isValid(); | 130 | return data->completed.isValid(); |
131 | } | 131 | } |
132 | int OTodo::priority()const | 132 | int OTodo::priority()const |
133 | { | 133 | { |
134 | return data->priority; | 134 | return data->priority; |
135 | } | 135 | } |
136 | QString OTodo::summary() const | 136 | QString OTodo::summary() const |
137 | { | 137 | { |
138 | return data->sum; | 138 | return data->sum; |
139 | } | 139 | } |
140 | ushort OTodo::progress() const | 140 | ushort OTodo::progress() const |
141 | { | 141 | { |
142 | return data->prog; | 142 | return data->prog; |
143 | } | 143 | } |
144 | QDate OTodo::dueDate()const | 144 | QDate OTodo::dueDate()const |
145 | { | 145 | { |
146 | return data->date; | 146 | return data->date; |
147 | } | 147 | } |
148 | QDate OTodo::startDate()const { | 148 | QDate OTodo::startDate()const { |
149 | return data->start; | 149 | return data->start; |
150 | } | 150 | } |
151 | QDate OTodo::completedDate()const { | 151 | QDate OTodo::completedDate()const { |
152 | return data->completed; | 152 | return data->completed; |
153 | } | 153 | } |
154 | QString OTodo::description()const | 154 | QString OTodo::description()const |
155 | { | 155 | { |
156 | return data->desc; | 156 | return data->desc; |
157 | } | 157 | } |
158 | bool OTodo::hasState() const{ | 158 | bool OTodo::hasState() const{ |
159 | if (!data->state ) return false; | 159 | if (!data->state ) return false; |
160 | return ( data->state->state() != OPimState::Undefined ); | 160 | return ( data->state->state() != OPimState::Undefined ); |
161 | } | 161 | } |
162 | OPimState OTodo::state()const { | 162 | OPimState OTodo::state()const { |
163 | if (!data->state ) { | 163 | if (!data->state ) { |
164 | OPimState state; | 164 | OPimState state; |
165 | return state; | 165 | return state; |
166 | } | 166 | } |
167 | 167 | ||
168 | return (*data->state); | 168 | return (*data->state); |
169 | } | 169 | } |
170 | bool OTodo::hasRecurrence()const { | 170 | bool OTodo::hasRecurrence()const { |
171 | if (!data->recur) return false; | 171 | if (!data->recur) return false; |
172 | return data->recur->doesRecur(); | 172 | return data->recur->doesRecur(); |
173 | } | 173 | } |
174 | ORecur OTodo::recurrence()const { | 174 | ORecur OTodo::recurrence()const { |
175 | if (!data->recur) return ORecur(); | 175 | if (!data->recur) return ORecur(); |
176 | 176 | ||
177 | return (*data->recur); | 177 | return (*data->recur); |
178 | } | 178 | } |
179 | bool OTodo::hasMaintainer()const { | 179 | bool OTodo::hasMaintainer()const { |
180 | if (!data->maintainer) return false; | 180 | if (!data->maintainer) return false; |
181 | 181 | ||
182 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | 182 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); |
183 | } | 183 | } |
184 | OPimMaintainer OTodo::maintainer()const { | 184 | OPimMaintainer OTodo::maintainer()const { |
185 | if (!data->maintainer) return OPimMaintainer(); | 185 | if (!data->maintainer) return OPimMaintainer(); |
186 | 186 | ||
187 | return (*data->maintainer); | 187 | return (*data->maintainer); |
188 | } | 188 | } |
189 | void OTodo::setCompleted( bool completed ) | 189 | void OTodo::setCompleted( bool completed ) |
190 | { | 190 | { |
191 | changeOrModify(); | 191 | changeOrModify(); |
192 | data->isCompleted = completed; | 192 | data->isCompleted = completed; |
193 | } | 193 | } |
194 | void OTodo::setHasDueDate( bool hasDate ) | 194 | void OTodo::setHasDueDate( bool hasDate ) |
195 | { | 195 | { |
196 | changeOrModify(); | 196 | changeOrModify(); |
197 | data->hasDate = hasDate; | 197 | data->hasDate = hasDate; |
198 | } | 198 | } |
199 | void OTodo::setDescription(const QString &desc ) | 199 | void OTodo::setDescription(const QString &desc ) |
200 | { | 200 | { |
201 | // qWarning( "desc " + desc ); | 201 | // qWarning( "desc " + desc ); |
202 | changeOrModify(); | 202 | changeOrModify(); |
203 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 203 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
204 | } | 204 | } |
205 | void OTodo::setSummary( const QString& sum ) | 205 | void OTodo::setSummary( const QString& sum ) |
206 | { | 206 | { |
207 | changeOrModify(); | 207 | changeOrModify(); |
208 | data->sum = sum; | 208 | data->sum = sum; |
209 | } | 209 | } |
210 | void OTodo::setPriority(int prio ) | 210 | void OTodo::setPriority(int prio ) |
211 | { | 211 | { |
212 | changeOrModify(); | 212 | changeOrModify(); |
213 | data->priority = prio; | 213 | data->priority = prio; |
214 | } | 214 | } |
215 | void OTodo::setDueDate( const QDate& date ) | 215 | void OTodo::setDueDate( const QDate& date ) |
216 | { | 216 | { |
217 | changeOrModify(); | 217 | changeOrModify(); |
218 | data->date = date; | 218 | data->date = date; |
219 | } | 219 | } |
220 | void OTodo::setStartDate( const QDate& date ) { | 220 | void OTodo::setStartDate( const QDate& date ) { |
221 | changeOrModify(); | 221 | changeOrModify(); |
222 | data->start = date; | 222 | data->start = date; |
223 | } | 223 | } |
224 | void OTodo::setCompletedDate( const QDate& date ) { | 224 | void OTodo::setCompletedDate( const QDate& date ) { |
225 | changeOrModify(); | 225 | changeOrModify(); |
226 | data->completed = date; | 226 | data->completed = date; |
227 | } | 227 | } |
228 | void OTodo::setState( const OPimState& state ) { | 228 | void OTodo::setState( const OPimState& state ) { |
229 | changeOrModify(); | 229 | changeOrModify(); |
230 | if (data->state ) | 230 | if (data->state ) |
231 | (*data->state) = state; | 231 | (*data->state) = state; |
232 | else | 232 | else |
233 | data->state = new OPimState( state ); | 233 | data->state = new OPimState( state ); |
234 | } | 234 | } |
235 | void OTodo::setRecurrence( const ORecur& rec) { | 235 | void OTodo::setRecurrence( const ORecur& rec) { |
236 | changeOrModify(); | 236 | changeOrModify(); |
237 | if (data->recur ) | 237 | if (data->recur ) |
238 | (*data->recur) = rec; | 238 | (*data->recur) = rec; |
239 | else | 239 | else |
240 | data->recur = new ORecur( rec ); | 240 | data->recur = new ORecur( rec ); |
241 | } | 241 | } |
242 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 242 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { |
243 | changeOrModify(); | 243 | changeOrModify(); |
244 | 244 | ||
245 | if (data->maintainer ) | 245 | if (data->maintainer ) |
246 | (*data->maintainer) = pim; | 246 | (*data->maintainer) = pim; |
247 | else | 247 | else |
248 | data->maintainer = new OPimMaintainer( pim ); | 248 | data->maintainer = new OPimMaintainer( pim ); |
249 | } | 249 | } |
250 | bool OTodo::isOverdue( ) | 250 | bool OTodo::isOverdue( ) |
251 | { | 251 | { |
252 | if( data->hasDate && !data->isCompleted) | 252 | if( data->hasDate && !data->isCompleted) |
253 | return QDate::currentDate() > data->date; | 253 | return QDate::currentDate() > data->date; |
254 | return false; | 254 | return false; |
255 | } | 255 | } |
256 | void OTodo::setProgress(ushort progress ) | 256 | void OTodo::setProgress(ushort progress ) |
257 | { | 257 | { |
258 | changeOrModify(); | 258 | changeOrModify(); |
259 | data->prog = progress; | 259 | data->prog = progress; |
260 | } | 260 | } |
261 | QString OTodo::toShortText() const { | 261 | QString OTodo::toShortText() const { |
262 | return summary(); | 262 | return summary(); |
263 | } | 263 | } |
264 | /*! | 264 | /*! |
265 | Returns a richt text string | 265 | Returns a richt text string |
266 | */ | 266 | */ |
267 | QString OTodo::toRichText() const | 267 | QString OTodo::toRichText() const |
268 | { | 268 | { |
269 | QString text; | 269 | QString text; |
270 | QStringList catlist; | 270 | QStringList catlist; |
271 | 271 | ||
272 | // Description of the todo | 272 | // Description of the todo |
273 | if ( !summary().isEmpty() ) { | 273 | if ( !summary().isEmpty() ) { |
274 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 274 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; |
275 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 275 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
276 | } | 276 | } |
277 | if( !description().isEmpty() ){ | 277 | if( !description().isEmpty() ){ |
278 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 278 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
279 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 279 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
280 | } | 280 | } |
281 | text += "<br><br><br>"; | 281 | text += "<br><br><br>"; |
282 | 282 | ||
283 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 283 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
284 | + QString::number( priority() ) + " <br>"; | 284 | + QString::number( priority() ) + " <br>"; |
285 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 285 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
286 | + QString::number( progress() ) + " %<br>"; | 286 | + QString::number( progress() ) + " %<br>"; |
287 | if (hasDueDate() ){ | 287 | if (hasDueDate() ){ |
288 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 288 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
289 | text += dueDate().toString(); | 289 | text += dueDate().toString(); |
290 | text += "<br>"; | 290 | text += "<br>"; |
291 | } | 291 | } |
292 | 292 | ||
293 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 293 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
294 | text += categoryNames( "Todo List" ).join(", "); | 294 | text += categoryNames( "Todo List" ).join(", "); |
295 | text += "<br>"; | 295 | text += "<br>"; |
296 | 296 | ||
297 | return text; | 297 | return text; |
298 | } | 298 | } |
299 | bool OTodo::hasNotifiers()const { | 299 | bool OTodo::hasNotifiers()const { |
300 | if (!data->notifiers) return false; | 300 | if (!data->notifiers) return false; |
301 | return data->notifiers->isEmpty(); | 301 | return !data->notifiers->isEmpty(); |
302 | } | 302 | } |
303 | OPimNotifyManager& OTodo::notifiers() { | 303 | OPimNotifyManager& OTodo::notifiers() { |
304 | if (!data->notifiers ) | 304 | if (!data->notifiers ) |
305 | data->notifiers = new OPimNotifyManager; | 305 | data->notifiers = new OPimNotifyManager; |
306 | return (*data->notifiers); | 306 | return (*data->notifiers); |
307 | } | 307 | } |
308 | const OPimNotifyManager& OTodo::notifiers()const{ | ||
309 | if (!data->notifiers ) | ||
310 | data->notifiers = new OPimNotifyManager; | ||
311 | |||
312 | return (*data->notifiers); | ||
313 | } | ||
308 | 314 | ||
309 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 315 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
310 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 316 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
311 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 317 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
312 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 318 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
313 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 319 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
314 | return priority() < toDoEvent.priority(); | 320 | return priority() < toDoEvent.priority(); |
315 | }else{ | 321 | }else{ |
316 | return dueDate() < toDoEvent.dueDate(); | 322 | return dueDate() < toDoEvent.dueDate(); |
317 | } | 323 | } |
318 | } | 324 | } |
319 | return false; | 325 | return false; |
320 | } | 326 | } |
321 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 327 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
322 | { | 328 | { |
323 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 329 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
324 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 330 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
325 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 331 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
326 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 332 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
327 | return priority() <= toDoEvent.priority(); | 333 | return priority() <= toDoEvent.priority(); |
328 | }else{ | 334 | }else{ |
329 | return dueDate() <= toDoEvent.dueDate(); | 335 | return dueDate() <= toDoEvent.dueDate(); |
330 | } | 336 | } |
331 | } | 337 | } |
332 | return true; | 338 | return true; |
333 | } | 339 | } |
334 | bool OTodo::operator>(const OTodo &toDoEvent )const | 340 | bool OTodo::operator>(const OTodo &toDoEvent )const |
335 | { | 341 | { |
336 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 342 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
337 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 343 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
338 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 344 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
339 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 345 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
340 | return priority() > toDoEvent.priority(); | 346 | return priority() > toDoEvent.priority(); |
341 | }else{ | 347 | }else{ |
342 | return dueDate() > toDoEvent.dueDate(); | 348 | return dueDate() > toDoEvent.dueDate(); |
343 | } | 349 | } |
344 | } | 350 | } |
345 | return false; | 351 | return false; |
346 | } | 352 | } |
347 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 353 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
348 | { | 354 | { |
349 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 355 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
350 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 356 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
351 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 357 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
352 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 358 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
353 | return priority() > toDoEvent.priority(); | 359 | return priority() > toDoEvent.priority(); |
354 | }else{ | 360 | }else{ |
355 | return dueDate() > toDoEvent.dueDate(); | 361 | return dueDate() > toDoEvent.dueDate(); |
356 | } | 362 | } |
357 | } | 363 | } |
358 | return true; | 364 | return true; |
359 | } | 365 | } |
360 | bool OTodo::operator==(const OTodo &toDoEvent )const | 366 | bool OTodo::operator==(const OTodo &toDoEvent )const |
361 | { | 367 | { |
362 | if ( data->priority != toDoEvent.data->priority ) return false; | 368 | if ( data->priority != toDoEvent.data->priority ) return false; |
363 | if ( data->priority != toDoEvent.data->prog ) return false; | 369 | if ( data->priority != toDoEvent.data->prog ) return false; |
364 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | 370 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
365 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | 371 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
366 | if ( data->date != toDoEvent.data->date ) return false; | 372 | if ( data->date != toDoEvent.data->date ) return false; |
367 | if ( data->sum != toDoEvent.data->sum ) return false; | 373 | if ( data->sum != toDoEvent.data->sum ) return false; |
368 | if ( data->desc != toDoEvent.data->desc ) return false; | 374 | if ( data->desc != toDoEvent.data->desc ) return false; |
369 | if ( data->maintainer != toDoEvent.data->maintainer ) | 375 | if ( data->maintainer != toDoEvent.data->maintainer ) |
370 | return false; | 376 | return false; |
371 | 377 | ||
372 | return OPimRecord::operator==( toDoEvent ); | 378 | return OPimRecord::operator==( toDoEvent ); |
373 | } | 379 | } |
374 | void OTodo::deref() { | 380 | void OTodo::deref() { |
375 | 381 | ||
376 | // qWarning("deref in ToDoEvent"); | 382 | // qWarning("deref in ToDoEvent"); |
377 | if ( data->deref() ) { | 383 | if ( data->deref() ) { |
378 | // qWarning("deleting"); | 384 | // qWarning("deleting"); |
379 | delete data; | 385 | delete data; |
380 | data= 0; | 386 | data= 0; |
381 | } | 387 | } |
382 | } | 388 | } |
383 | OTodo &OTodo::operator=(const OTodo &item ) | 389 | OTodo &OTodo::operator=(const OTodo &item ) |
384 | { | 390 | { |
385 | if ( this == &item ) return *this; | 391 | if ( this == &item ) return *this; |
386 | 392 | ||
387 | OPimRecord::operator=( item ); | 393 | OPimRecord::operator=( item ); |
388 | //qWarning("operator= ref "); | 394 | //qWarning("operator= ref "); |
389 | item.data->ref(); | 395 | item.data->ref(); |
390 | deref(); | 396 | deref(); |
391 | data = item.data; | 397 | data = item.data; |
392 | 398 | ||
393 | return *this; | 399 | return *this; |
394 | } | 400 | } |
395 | 401 | ||
396 | QMap<int, QString> OTodo::toMap() const { | 402 | QMap<int, QString> OTodo::toMap() const { |
397 | QMap<int, QString> map; | 403 | QMap<int, QString> map; |
398 | 404 | ||
399 | map.insert( Uid, QString::number( uid() ) ); | 405 | map.insert( Uid, QString::number( uid() ) ); |
400 | map.insert( Category, idsToString( categories() ) ); | 406 | map.insert( Category, idsToString( categories() ) ); |
401 | map.insert( HasDate, QString::number( data->hasDate ) ); | 407 | map.insert( HasDate, QString::number( data->hasDate ) ); |
402 | map.insert( Completed, QString::number( data->isCompleted ) ); | 408 | map.insert( Completed, QString::number( data->isCompleted ) ); |
403 | map.insert( Description, data->desc ); | 409 | map.insert( Description, data->desc ); |
404 | map.insert( Summary, data->sum ); | 410 | map.insert( Summary, data->sum ); |
405 | map.insert( Priority, QString::number( data->priority ) ); | 411 | map.insert( Priority, QString::number( data->priority ) ); |
406 | map.insert( DateDay, QString::number( data->date.day() ) ); | 412 | map.insert( DateDay, QString::number( data->date.day() ) ); |
407 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 413 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
408 | map.insert( DateYear, QString::number( data->date.year() ) ); | 414 | map.insert( DateYear, QString::number( data->date.year() ) ); |
409 | map.insert( Progress, QString::number( data->prog ) ); | 415 | map.insert( Progress, QString::number( data->prog ) ); |
410 | // map.insert( CrossReference, crossToString() ); | 416 | // map.insert( CrossReference, crossToString() ); |
411 | /* FIXME!!! map.insert( State, ); | 417 | /* FIXME!!! map.insert( State, ); |
412 | map.insert( Recurrence, ); | 418 | map.insert( Recurrence, ); |
413 | map.insert( Reminders, ); | 419 | map.insert( Reminders, ); |
414 | map. | 420 | map. |
415 | */ | 421 | */ |
416 | return map; | 422 | return map; |
417 | } | 423 | } |
418 | 424 | ||
419 | QMap<QString, QString> OTodo::toExtraMap()const { | 425 | QMap<QString, QString> OTodo::toExtraMap()const { |
420 | return data->extra; | 426 | return data->extra; |
421 | } | 427 | } |
422 | /** | 428 | /** |
423 | * change or modify looks at the ref count and either | 429 | * change or modify looks at the ref count and either |
424 | * creates a new QShared Object or it can modify it | 430 | * creates a new QShared Object or it can modify it |
425 | * right in place | 431 | * right in place |
426 | */ | 432 | */ |
427 | void OTodo::changeOrModify() { | 433 | void OTodo::changeOrModify() { |
428 | if ( data->count != 1 ) { | 434 | if ( data->count != 1 ) { |
429 | qWarning("changeOrModify"); | 435 | qWarning("changeOrModify"); |
430 | data->deref(); | 436 | data->deref(); |
431 | OTodoData* d2 = new OTodoData(); | 437 | OTodoData* d2 = new OTodoData(); |
432 | copy(data, d2 ); | 438 | copy(data, d2 ); |
433 | data = d2; | 439 | data = d2; |
434 | } | 440 | } |
435 | } | 441 | } |
436 | // WATCHOUT | 442 | // WATCHOUT |
437 | /* | 443 | /* |
438 | * if you add something to the Data struct | 444 | * if you add something to the Data struct |
439 | * be sure to copy it here | 445 | * be sure to copy it here |
440 | */ | 446 | */ |
441 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 447 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
442 | dest->date = src->date; | 448 | dest->date = src->date; |
443 | dest->isCompleted = src->isCompleted; | 449 | dest->isCompleted = src->isCompleted; |
444 | dest->hasDate = src->hasDate; | 450 | dest->hasDate = src->hasDate; |
445 | dest->priority = src->priority; | 451 | dest->priority = src->priority; |
446 | dest->desc = src->desc; | 452 | dest->desc = src->desc; |
447 | dest->sum = src->sum; | 453 | dest->sum = src->sum; |
448 | dest->extra = src->extra; | 454 | dest->extra = src->extra; |
449 | dest->prog = src->prog; | 455 | dest->prog = src->prog; |
450 | 456 | ||
451 | if (src->state ) | 457 | if (src->state ) |
452 | dest->state = new OPimState( *src->state ); | 458 | dest->state = new OPimState( *src->state ); |
453 | 459 | ||
454 | if (src->recur ) | 460 | if (src->recur ) |
455 | dest->recur = new ORecur( *src->recur ); | 461 | dest->recur = new ORecur( *src->recur ); |
456 | 462 | ||
457 | if (src->maintainer ) | 463 | if (src->maintainer ) |
458 | dest->maintainer = new OPimMaintainer( *src->maintainer ) | 464 | dest->maintainer = new OPimMaintainer( *src->maintainer ) |
459 | ; | 465 | ; |
460 | dest->start = src->start; | 466 | dest->start = src->start; |
461 | dest->completed = src->completed; | 467 | dest->completed = src->completed; |
462 | 468 | ||
463 | if (src->notifiers ) | 469 | if (src->notifiers ) |
464 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); | 470 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); |
465 | } | 471 | } |
466 | QString OTodo::type() const { | 472 | QString OTodo::type() const { |
467 | return QString::fromLatin1("OTodo"); | 473 | return QString::fromLatin1("OTodo"); |
468 | } | 474 | } |
469 | QString OTodo::recordField(int /*id*/ )const { | 475 | QString OTodo::recordField(int /*id*/ )const { |
470 | return QString::null; | 476 | return QString::null; |
471 | } | 477 | } |
472 | 478 | ||
473 | int OTodo::rtti(){ | 479 | int OTodo::rtti(){ |
474 | return OPimResolver::TodoList; | 480 | return OPimResolver::TodoList; |
475 | } | 481 | } |
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h index 0e7c73f..4d5ee36 100644 --- a/libopie/pim/otodo.h +++ b/libopie/pim/otodo.h | |||
@@ -1,289 +1,295 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_TODO_EVENT_H | 2 | #ifndef OPIE_TODO_EVENT_H |
3 | #define OPIE_TODO_EVENT_H | 3 | #define OPIE_TODO_EVENT_H |
4 | 4 | ||
5 | 5 | ||
6 | #include <qarray.h> | 6 | #include <qarray.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 11 | #include <qvaluelist.h> |
12 | 12 | ||
13 | #include <qpe/recordfields.h> | 13 | #include <qpe/recordfields.h> |
14 | #include <qpe/palmtopuidgen.h> | 14 | #include <qpe/palmtopuidgen.h> |
15 | 15 | ||
16 | #include <opie/opimrecord.h> | 16 | #include <opie/opimrecord.h> |
17 | 17 | ||
18 | 18 | ||
19 | class OPimState; | 19 | class OPimState; |
20 | class ORecur; | 20 | class ORecur; |
21 | class OPimMaintainer; | 21 | class OPimMaintainer; |
22 | class OPimNotifyManager; | 22 | class OPimNotifyManager; |
23 | class OTodo : public OPimRecord { | 23 | class OTodo : public OPimRecord { |
24 | public: | 24 | public: |
25 | typedef QValueList<OTodo> ValueList; | 25 | typedef QValueList<OTodo> ValueList; |
26 | enum RecordFields { | 26 | enum RecordFields { |
27 | Uid = Qtopia::UID_ID, | 27 | Uid = Qtopia::UID_ID, |
28 | Category = Qtopia::CATEGORY_ID, | 28 | Category = Qtopia::CATEGORY_ID, |
29 | HasDate, | 29 | HasDate, |
30 | Completed, | 30 | Completed, |
31 | Description, | 31 | Description, |
32 | Summary, | 32 | Summary, |
33 | Priority, | 33 | Priority, |
34 | DateDay, | 34 | DateDay, |
35 | DateMonth, | 35 | DateMonth, |
36 | DateYear, | 36 | DateYear, |
37 | Progress, | 37 | Progress, |
38 | CrossReference, | 38 | CrossReference, |
39 | State, | 39 | State, |
40 | Recurrence, | 40 | Recurrence, |
41 | Alarms, | 41 | Alarms, |
42 | Reminders, | 42 | Reminders, |
43 | Notifiers, | 43 | Notifiers, |
44 | Maintainer, | 44 | Maintainer, |
45 | StartDate, | 45 | StartDate, |
46 | CompletedDate | 46 | CompletedDate |
47 | }; | 47 | }; |
48 | public: | 48 | public: |
49 | // priorities from Very low to very high | 49 | // priorities from Very low to very high |
50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; |
51 | 51 | ||
52 | /* Constructs a new ToDoEvent | 52 | /* Constructs a new ToDoEvent |
53 | @param completed Is the TodoEvent completed | 53 | @param completed Is the TodoEvent completed |
54 | @param priority What is the priority of this ToDoEvent | 54 | @param priority What is the priority of this ToDoEvent |
55 | @param category Which category does it belong( uid ) | 55 | @param category Which category does it belong( uid ) |
56 | @param summary A small summary of the todo | 56 | @param summary A small summary of the todo |
57 | @param description What is this ToDoEvent about | 57 | @param description What is this ToDoEvent about |
58 | @param hasDate Does this Event got a deadline | 58 | @param hasDate Does this Event got a deadline |
59 | @param date what is the deadline? | 59 | @param date what is the deadline? |
60 | @param uid what is the UUID of this Event | 60 | @param uid what is the UUID of this Event |
61 | **/ | 61 | **/ |
62 | OTodo( bool completed = false, int priority = Normal, | 62 | OTodo( bool completed = false, int priority = Normal, |
63 | const QStringList &category = QStringList(), | 63 | const QStringList &category = QStringList(), |
64 | const QString &summary = QString::null , | 64 | const QString &summary = QString::null , |
65 | const QString &description = QString::null, | 65 | const QString &description = QString::null, |
66 | ushort progress = 0, | 66 | ushort progress = 0, |
67 | bool hasDate = false, QDate date = QDate::currentDate(), | 67 | bool hasDate = false, QDate date = QDate::currentDate(), |
68 | int uid = 0 /*empty*/ ); | 68 | int uid = 0 /*empty*/ ); |
69 | 69 | ||
70 | OTodo( bool completed, int priority, | 70 | OTodo( bool completed, int priority, |
71 | const QArray<int>& category, | 71 | const QArray<int>& category, |
72 | const QString& summary = QString::null, | 72 | const QString& summary = QString::null, |
73 | const QString& description = QString::null, | 73 | const QString& description = QString::null, |
74 | ushort progress = 0, | 74 | ushort progress = 0, |
75 | bool hasDate = false, QDate date = QDate::currentDate(), | 75 | bool hasDate = false, QDate date = QDate::currentDate(), |
76 | int uid = 0 /* empty */ ); | 76 | int uid = 0 /* empty */ ); |
77 | 77 | ||
78 | /** Copy c'tor | 78 | /** Copy c'tor |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | OTodo(const OTodo & ); | 81 | OTodo(const OTodo & ); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | *destructor | 84 | *destructor |
85 | */ | 85 | */ |
86 | ~OTodo(); | 86 | ~OTodo(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Is this event completed? | 89 | * Is this event completed? |
90 | */ | 90 | */ |
91 | bool isCompleted() const; | 91 | bool isCompleted() const; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Does this Event have a deadline | 94 | * Does this Event have a deadline |
95 | */ | 95 | */ |
96 | bool hasDueDate() const; | 96 | bool hasDueDate() const; |
97 | bool hasStartDate()const; | 97 | bool hasStartDate()const; |
98 | bool hasCompletedDate()const; | 98 | bool hasCompletedDate()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Does this Event has an alarm time ? | 101 | * Does this Event has an alarm time ? |
102 | */ | 102 | */ |
103 | bool hasAlarmDateTime() const; | 103 | bool hasAlarmDateTime() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * What is the priority? | 106 | * What is the priority? |
107 | */ | 107 | */ |
108 | int priority()const ; | 108 | int priority()const ; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 111 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
112 | */ | 112 | */ |
113 | ushort progress() const; | 113 | ushort progress() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * The due Date | 116 | * The due Date |
117 | */ | 117 | */ |
118 | QDate dueDate()const; | 118 | QDate dueDate()const; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * When did it start? | 121 | * When did it start? |
122 | */ | 122 | */ |
123 | QDate startDate()const; | 123 | QDate startDate()const; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * When was it completed? | 126 | * When was it completed? |
127 | */ | 127 | */ |
128 | QDate completedDate()const; | 128 | QDate completedDate()const; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * does it have a state? | 131 | * does it have a state? |
132 | */ | 132 | */ |
133 | bool hasState()const; | 133 | bool hasState()const; |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * What is the state of this OTodo? | 136 | * What is the state of this OTodo? |
137 | */ | 137 | */ |
138 | OPimState state()const; | 138 | OPimState state()const; |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * has recurrence? | 141 | * has recurrence? |
142 | */ | 142 | */ |
143 | bool hasRecurrence()const; | 143 | bool hasRecurrence()const; |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * the recurrance of this | 146 | * the recurrance of this |
147 | */ | 147 | */ |
148 | ORecur recurrence()const; | 148 | ORecur recurrence()const; |
149 | 149 | ||
150 | /** | 150 | /** |
151 | * does this OTodo have a maintainer? | 151 | * does this OTodo have a maintainer? |
152 | */ | 152 | */ |
153 | bool hasMaintainer()const; | 153 | bool hasMaintainer()const; |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * the Maintainer of this OTodo | 156 | * the Maintainer of this OTodo |
157 | */ | 157 | */ |
158 | OPimMaintainer maintainer()const; | 158 | OPimMaintainer maintainer()const; |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * The description of the todo | 161 | * The description of the todo |
162 | */ | 162 | */ |
163 | QString description()const; | 163 | QString description()const; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * A small summary of the todo | 166 | * A small summary of the todo |
167 | */ | 167 | */ |
168 | QString summary() const; | 168 | QString summary() const; |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * @reimplemented | 171 | * @reimplemented |
172 | * Return this todoevent in a RichText formatted QString | 172 | * Return this todoevent in a RichText formatted QString |
173 | */ | 173 | */ |
174 | QString toRichText() const; | 174 | QString toRichText() const; |
175 | 175 | ||
176 | bool hasNotifiers()const; | 176 | bool hasNotifiers()const; |
177 | /* | 177 | /* |
178 | * check if the sharing is still fine!! -zecke | 178 | * FIXME check if the sharing is still fine!! -zecke |
179 | * ### CHECK If API is fine | ||
179 | */ | 180 | */ |
180 | /** | 181 | /** |
181 | * return a reference to our notifiers... | 182 | * return a reference to our notifiers... |
182 | */ | 183 | */ |
183 | OPimNotifyManager ¬ifiers(); | 184 | OPimNotifyManager ¬ifiers(); |
184 | 185 | ||
185 | /** | 186 | /** |
187 | * | ||
188 | */ | ||
189 | const OPimNotifyManager ¬ifiers()const; | ||
190 | |||
191 | /** | ||
186 | * reimplementations | 192 | * reimplementations |
187 | */ | 193 | */ |
188 | QString type()const; | 194 | QString type()const; |
189 | QString toShortText()const; | 195 | QString toShortText()const; |
190 | QMap<QString, QString> toExtraMap()const; | 196 | QMap<QString, QString> toExtraMap()const; |
191 | QString recordField(int id )const; | 197 | QString recordField(int id )const; |
192 | 198 | ||
193 | /** | 199 | /** |
194 | * toMap puts all data into the map. int relates | 200 | * toMap puts all data into the map. int relates |
195 | * to ToDoEvent RecordFields enum | 201 | * to ToDoEvent RecordFields enum |
196 | */ | 202 | */ |
197 | QMap<int, QString> toMap()const; | 203 | QMap<int, QString> toMap()const; |
198 | 204 | ||
199 | /** | 205 | /** |
200 | * Set if this Todo is completed | 206 | * Set if this Todo is completed |
201 | */ | 207 | */ |
202 | void setCompleted(bool completed ); | 208 | void setCompleted(bool completed ); |
203 | 209 | ||
204 | /** | 210 | /** |
205 | * set if this todo got an end data | 211 | * set if this todo got an end data |
206 | */ | 212 | */ |
207 | void setHasDueDate( bool hasDate ); | 213 | void setHasDueDate( bool hasDate ); |
208 | // FIXME we do not have these for start, completed | 214 | // FIXME we do not have these for start, completed |
209 | // cause we'll use the isNull() of QDate for figuring | 215 | // cause we'll use the isNull() of QDate for figuring |
210 | // out if it's has a date... | 216 | // out if it's has a date... |
211 | // decide what to do here? -zecke | 217 | // decide what to do here? -zecke |
212 | 218 | ||
213 | /** | 219 | /** |
214 | * Set the priority of the Todo | 220 | * Set the priority of the Todo |
215 | */ | 221 | */ |
216 | void setPriority(int priority ); | 222 | void setPriority(int priority ); |
217 | 223 | ||
218 | /** | 224 | /** |
219 | * Set the progress. | 225 | * Set the progress. |
220 | */ | 226 | */ |
221 | void setProgress( ushort progress ); | 227 | void setProgress( ushort progress ); |
222 | 228 | ||
223 | /** | 229 | /** |
224 | * set the end date | 230 | * set the end date |
225 | */ | 231 | */ |
226 | void setDueDate( const QDate& date ); | 232 | void setDueDate( const QDate& date ); |
227 | 233 | ||
228 | /** | 234 | /** |
229 | * set the start date | 235 | * set the start date |
230 | */ | 236 | */ |
231 | void setStartDate( const QDate& date ); | 237 | void setStartDate( const QDate& date ); |
232 | 238 | ||
233 | /** | 239 | /** |
234 | * set the completed date | 240 | * set the completed date |
235 | */ | 241 | */ |
236 | void setCompletedDate( const QDate& date ); | 242 | void setCompletedDate( const QDate& date ); |
237 | 243 | ||
238 | void setRecurrence( const ORecur& ); | 244 | void setRecurrence( const ORecur& ); |
239 | /** | 245 | /** |
240 | * set the alarm time | 246 | * set the alarm time |
241 | */ | 247 | */ |
242 | void setAlarmDateTime ( const QDateTime& alarm ); | 248 | void setAlarmDateTime ( const QDateTime& alarm ); |
243 | 249 | ||
244 | void setDescription(const QString& ); | 250 | void setDescription(const QString& ); |
245 | void setSummary(const QString& ); | 251 | void setSummary(const QString& ); |
246 | 252 | ||
247 | /** | 253 | /** |
248 | * set the state of a Todo | 254 | * set the state of a Todo |
249 | * @param state State what the todo should take | 255 | * @param state State what the todo should take |
250 | */ | 256 | */ |
251 | void setState( const OPimState& state); | 257 | void setState( const OPimState& state); |
252 | 258 | ||
253 | /** | 259 | /** |
254 | * set the Maintainer Mode | 260 | * set the Maintainer Mode |
255 | */ | 261 | */ |
256 | void setMaintainer( const OPimMaintainer& ); | 262 | void setMaintainer( const OPimMaintainer& ); |
257 | 263 | ||
258 | bool isOverdue(); | 264 | bool isOverdue(); |
259 | 265 | ||
260 | 266 | ||
261 | virtual bool match( const QRegExp &r )const; | 267 | virtual bool match( const QRegExp &r )const; |
262 | 268 | ||
263 | bool operator<(const OTodo &toDoEvent )const; | 269 | bool operator<(const OTodo &toDoEvent )const; |
264 | bool operator<=(const OTodo &toDoEvent )const; | 270 | bool operator<=(const OTodo &toDoEvent )const; |
265 | bool operator!=(const OTodo &toDoEvent )const; | 271 | bool operator!=(const OTodo &toDoEvent )const; |
266 | bool operator>(const OTodo &toDoEvent )const; | 272 | bool operator>(const OTodo &toDoEvent )const; |
267 | bool operator>=(const OTodo &toDoEvent)const; | 273 | bool operator>=(const OTodo &toDoEvent)const; |
268 | bool operator==(const OTodo &toDoEvent )const; | 274 | bool operator==(const OTodo &toDoEvent )const; |
269 | OTodo &operator=(const OTodo &toDoEvent ); | 275 | OTodo &operator=(const OTodo &toDoEvent ); |
270 | 276 | ||
271 | static int rtti(); | 277 | static int rtti(); |
272 | 278 | ||
273 | private: | 279 | private: |
274 | class OTodoPrivate; | 280 | class OTodoPrivate; |
275 | struct OTodoData; | 281 | struct OTodoData; |
276 | 282 | ||
277 | void deref(); | 283 | void deref(); |
278 | inline void changeOrModify(); | 284 | inline void changeOrModify(); |
279 | void copy( OTodoData* src, OTodoData* dest ); | 285 | void copy( OTodoData* src, OTodoData* dest ); |
280 | OTodoPrivate *d; | 286 | OTodoPrivate *d; |
281 | OTodoData *data; | 287 | OTodoData *data; |
282 | 288 | ||
283 | }; | 289 | }; |
284 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | 290 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { |
285 | return !(*this == toDoEvent); | 291 | return !(*this == toDoEvent); |
286 | } | 292 | } |
287 | 293 | ||
288 | 294 | ||
289 | #endif | 295 | #endif |
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 49af757..06b5987 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -1,72 +1,74 @@ | |||
1 | #include "opimnotifymanager.h" | 1 | #include "opimnotifymanager.h" |
2 | 2 | ||
3 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | 3 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) |
4 | : m_rem( rem ), m_al( al ) | 4 | : m_rem( rem ), m_al( al ) |
5 | {} | 5 | {} |
6 | OPimNotifyManager::~OPimNotifyManager() { | 6 | OPimNotifyManager::~OPimNotifyManager() { |
7 | } | 7 | } |
8 | /* use static_cast and type instead of dynamic... */ | 8 | /* use static_cast and type instead of dynamic... */ |
9 | void OPimNotifyManager::add( const OPimNotify& noti) { | 9 | void OPimNotifyManager::add( const OPimNotify& noti) { |
10 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 10 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
11 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 11 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
12 | m_rem.append( rem ); | 12 | m_rem.append( rem ); |
13 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 13 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
14 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 14 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
15 | m_al.append( al ); | 15 | m_al.append( al ); |
16 | } | 16 | } |
17 | } | 17 | } |
18 | void OPimNotifyManager::remove( const OPimNotify& noti) { | 18 | void OPimNotifyManager::remove( const OPimNotify& noti) { |
19 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 19 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
20 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 20 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
21 | m_rem.remove( rem ); | 21 | m_rem.remove( rem ); |
22 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 22 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
23 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 23 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
24 | m_al.remove( al ); | 24 | m_al.remove( al ); |
25 | } | 25 | } |
26 | } | 26 | } |
27 | void OPimNotifyManager::replace( const OPimNotify& noti) { | 27 | void OPimNotifyManager::replace( const OPimNotify& noti) { |
28 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 28 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
29 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 29 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
30 | m_rem.remove( rem ); | 30 | m_rem.remove( rem ); |
31 | m_rem.append( rem ); | 31 | m_rem.append( rem ); |
32 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 32 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
33 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 33 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
34 | m_al.remove( al ); | 34 | m_al.remove( al ); |
35 | m_al.append( al ); | 35 | m_al.append( al ); |
36 | } | 36 | } |
37 | } | 37 | } |
38 | OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { | 38 | OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { |
39 | return m_rem; | 39 | return m_rem; |
40 | } | 40 | } |
41 | OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { | 41 | OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { |
42 | return m_al; | 42 | return m_al; |
43 | } | 43 | } |
44 | void OPimNotifyManager::setAlarms( const Alarms& al) { | 44 | void OPimNotifyManager::setAlarms( const Alarms& al) { |
45 | m_al = al; | 45 | m_al = al; |
46 | } | 46 | } |
47 | void OPimNotifyManager::setReminders( const Reminders& rem) { | 47 | void OPimNotifyManager::setReminders( const Reminders& rem) { |
48 | m_rem = rem; | 48 | m_rem = rem; |
49 | } | 49 | } |
50 | /* FIXME!!! */ | 50 | /* FIXME!!! */ |
51 | /** | 51 | /** |
52 | * The idea is to check if the provider for our service | 52 | * The idea is to check if the provider for our service |
53 | * is online | 53 | * is online |
54 | * if it is we will use QCOP | 54 | * if it is we will use QCOP |
55 | * if not the Factory to get the backend... | 55 | * if not the Factory to get the backend... |
56 | * Qtopia1.6 services would be kewl to have here.... | 56 | * Qtopia1.6 services would be kewl to have here.... |
57 | */ | 57 | */ |
58 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { | 58 | void OPimNotifyManager::registerNotify( const OPimNotify& ) { |
59 | 59 | ||
60 | } | 60 | } |
61 | /* FIXME!!! */ | 61 | /* FIXME!!! */ |
62 | /** | 62 | /** |
63 | * same as above... | 63 | * same as above... |
64 | * Also implement Url model | 64 | * Also implement Url model |
65 | * have a MainWindow.... | 65 | * have a MainWindow.... |
66 | */ | 66 | */ |
67 | void OPimNotifyManager::deregister( const OPimNotify& ) { | 67 | void OPimNotifyManager::deregister( const OPimNotify& ) { |
68 | 68 | ||
69 | } | 69 | } |
70 | bool OPimNotifyManager::isEmpty()const { | 70 | bool OPimNotifyManager::isEmpty()const { |
71 | return ( m_rem.isEmpty() && m_al.isEmpty() ); | 71 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); |
72 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; | ||
73 | else return false; | ||
72 | } | 74 | } |
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index f3df119..a29d88e 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -45,431 +45,437 @@ struct OTodo::OTodoData : public QShared { | |||
45 | OPimNotifyManager *notifiers; | 45 | OPimNotifyManager *notifiers; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | OTodo::OTodo(const OTodo &event ) | 48 | OTodo::OTodo(const OTodo &event ) |
49 | : OPimRecord( event ), data( event.data ) | 49 | : OPimRecord( event ), data( event.data ) |
50 | { | 50 | { |
51 | data->ref(); | 51 | data->ref(); |
52 | // qWarning("ref up"); | 52 | // qWarning("ref up"); |
53 | } | 53 | } |
54 | OTodo::~OTodo() { | 54 | OTodo::~OTodo() { |
55 | 55 | ||
56 | // qWarning("~OTodo " ); | 56 | // qWarning("~OTodo " ); |
57 | if ( data->deref() ) { | 57 | if ( data->deref() ) { |
58 | // qWarning("OTodo::dereffing"); | 58 | // qWarning("OTodo::dereffing"); |
59 | delete data; | 59 | delete data; |
60 | data = 0l; | 60 | data = 0l; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | OTodo::OTodo(bool completed, int priority, | 63 | OTodo::OTodo(bool completed, int priority, |
64 | const QArray<int> &category, | 64 | const QArray<int> &category, |
65 | const QString& summary, | 65 | const QString& summary, |
66 | const QString &description, | 66 | const QString &description, |
67 | ushort progress, | 67 | ushort progress, |
68 | bool hasDate, QDate date, int uid ) | 68 | bool hasDate, QDate date, int uid ) |
69 | : OPimRecord( uid ) | 69 | : OPimRecord( uid ) |
70 | { | 70 | { |
71 | // qWarning("OTodoData " + summary); | 71 | // qWarning("OTodoData " + summary); |
72 | setCategories( category ); | 72 | setCategories( category ); |
73 | 73 | ||
74 | data = new OTodoData; | 74 | data = new OTodoData; |
75 | 75 | ||
76 | data->date = date; | 76 | data->date = date; |
77 | data->isCompleted = completed; | 77 | data->isCompleted = completed; |
78 | data->hasDate = hasDate; | 78 | data->hasDate = hasDate; |
79 | data->priority = priority; | 79 | data->priority = priority; |
80 | data->sum = summary; | 80 | data->sum = summary; |
81 | data->prog = progress; | 81 | data->prog = progress; |
82 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 82 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
83 | } | 83 | } |
84 | OTodo::OTodo(bool completed, int priority, | 84 | OTodo::OTodo(bool completed, int priority, |
85 | const QStringList &category, | 85 | const QStringList &category, |
86 | const QString& summary, | 86 | const QString& summary, |
87 | const QString &description, | 87 | const QString &description, |
88 | ushort progress, | 88 | ushort progress, |
89 | bool hasDate, QDate date, int uid ) | 89 | bool hasDate, QDate date, int uid ) |
90 | : OPimRecord( uid ) | 90 | : OPimRecord( uid ) |
91 | { | 91 | { |
92 | // qWarning("OTodoData" + summary); | 92 | // qWarning("OTodoData" + summary); |
93 | setCategories( idsFromString( category.join(";") ) ); | 93 | setCategories( idsFromString( category.join(";") ) ); |
94 | 94 | ||
95 | data = new OTodoData; | 95 | data = new OTodoData; |
96 | 96 | ||
97 | data->date = date; | 97 | data->date = date; |
98 | data->isCompleted = completed; | 98 | data->isCompleted = completed; |
99 | data->hasDate = hasDate; | 99 | data->hasDate = hasDate; |
100 | data->priority = priority; | 100 | data->priority = priority; |
101 | data->sum = summary; | 101 | data->sum = summary; |
102 | data->prog = progress; | 102 | data->prog = progress; |
103 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 103 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
104 | } | 104 | } |
105 | bool OTodo::match( const QRegExp ®Exp )const | 105 | bool OTodo::match( const QRegExp ®Exp )const |
106 | { | 106 | { |
107 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 107 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
108 | return true; | 108 | return true; |
109 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 109 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
110 | return true; | 110 | return true; |
111 | }else if(data->desc.find( regExp ) != -1 ){ | 111 | }else if(data->desc.find( regExp ) != -1 ){ |
112 | return true; | 112 | return true; |
113 | }else if(data->sum.find( regExp ) != -1 ) { | 113 | }else if(data->sum.find( regExp ) != -1 ) { |
114 | return true; | 114 | return true; |
115 | } | 115 | } |
116 | return false; | 116 | return false; |
117 | } | 117 | } |
118 | bool OTodo::isCompleted() const | 118 | bool OTodo::isCompleted() const |
119 | { | 119 | { |
120 | return data->isCompleted; | 120 | return data->isCompleted; |
121 | } | 121 | } |
122 | bool OTodo::hasDueDate() const | 122 | bool OTodo::hasDueDate() const |
123 | { | 123 | { |
124 | return data->hasDate; | 124 | return data->hasDate; |
125 | } | 125 | } |
126 | bool OTodo::hasStartDate()const { | 126 | bool OTodo::hasStartDate()const { |
127 | return data->start.isValid(); | 127 | return data->start.isValid(); |
128 | } | 128 | } |
129 | bool OTodo::hasCompletedDate()const { | 129 | bool OTodo::hasCompletedDate()const { |
130 | return data->completed.isValid(); | 130 | return data->completed.isValid(); |
131 | } | 131 | } |
132 | int OTodo::priority()const | 132 | int OTodo::priority()const |
133 | { | 133 | { |
134 | return data->priority; | 134 | return data->priority; |
135 | } | 135 | } |
136 | QString OTodo::summary() const | 136 | QString OTodo::summary() const |
137 | { | 137 | { |
138 | return data->sum; | 138 | return data->sum; |
139 | } | 139 | } |
140 | ushort OTodo::progress() const | 140 | ushort OTodo::progress() const |
141 | { | 141 | { |
142 | return data->prog; | 142 | return data->prog; |
143 | } | 143 | } |
144 | QDate OTodo::dueDate()const | 144 | QDate OTodo::dueDate()const |
145 | { | 145 | { |
146 | return data->date; | 146 | return data->date; |
147 | } | 147 | } |
148 | QDate OTodo::startDate()const { | 148 | QDate OTodo::startDate()const { |
149 | return data->start; | 149 | return data->start; |
150 | } | 150 | } |
151 | QDate OTodo::completedDate()const { | 151 | QDate OTodo::completedDate()const { |
152 | return data->completed; | 152 | return data->completed; |
153 | } | 153 | } |
154 | QString OTodo::description()const | 154 | QString OTodo::description()const |
155 | { | 155 | { |
156 | return data->desc; | 156 | return data->desc; |
157 | } | 157 | } |
158 | bool OTodo::hasState() const{ | 158 | bool OTodo::hasState() const{ |
159 | if (!data->state ) return false; | 159 | if (!data->state ) return false; |
160 | return ( data->state->state() != OPimState::Undefined ); | 160 | return ( data->state->state() != OPimState::Undefined ); |
161 | } | 161 | } |
162 | OPimState OTodo::state()const { | 162 | OPimState OTodo::state()const { |
163 | if (!data->state ) { | 163 | if (!data->state ) { |
164 | OPimState state; | 164 | OPimState state; |
165 | return state; | 165 | return state; |
166 | } | 166 | } |
167 | 167 | ||
168 | return (*data->state); | 168 | return (*data->state); |
169 | } | 169 | } |
170 | bool OTodo::hasRecurrence()const { | 170 | bool OTodo::hasRecurrence()const { |
171 | if (!data->recur) return false; | 171 | if (!data->recur) return false; |
172 | return data->recur->doesRecur(); | 172 | return data->recur->doesRecur(); |
173 | } | 173 | } |
174 | ORecur OTodo::recurrence()const { | 174 | ORecur OTodo::recurrence()const { |
175 | if (!data->recur) return ORecur(); | 175 | if (!data->recur) return ORecur(); |
176 | 176 | ||
177 | return (*data->recur); | 177 | return (*data->recur); |
178 | } | 178 | } |
179 | bool OTodo::hasMaintainer()const { | 179 | bool OTodo::hasMaintainer()const { |
180 | if (!data->maintainer) return false; | 180 | if (!data->maintainer) return false; |
181 | 181 | ||
182 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | 182 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); |
183 | } | 183 | } |
184 | OPimMaintainer OTodo::maintainer()const { | 184 | OPimMaintainer OTodo::maintainer()const { |
185 | if (!data->maintainer) return OPimMaintainer(); | 185 | if (!data->maintainer) return OPimMaintainer(); |
186 | 186 | ||
187 | return (*data->maintainer); | 187 | return (*data->maintainer); |
188 | } | 188 | } |
189 | void OTodo::setCompleted( bool completed ) | 189 | void OTodo::setCompleted( bool completed ) |
190 | { | 190 | { |
191 | changeOrModify(); | 191 | changeOrModify(); |
192 | data->isCompleted = completed; | 192 | data->isCompleted = completed; |
193 | } | 193 | } |
194 | void OTodo::setHasDueDate( bool hasDate ) | 194 | void OTodo::setHasDueDate( bool hasDate ) |
195 | { | 195 | { |
196 | changeOrModify(); | 196 | changeOrModify(); |
197 | data->hasDate = hasDate; | 197 | data->hasDate = hasDate; |
198 | } | 198 | } |
199 | void OTodo::setDescription(const QString &desc ) | 199 | void OTodo::setDescription(const QString &desc ) |
200 | { | 200 | { |
201 | // qWarning( "desc " + desc ); | 201 | // qWarning( "desc " + desc ); |
202 | changeOrModify(); | 202 | changeOrModify(); |
203 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 203 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
204 | } | 204 | } |
205 | void OTodo::setSummary( const QString& sum ) | 205 | void OTodo::setSummary( const QString& sum ) |
206 | { | 206 | { |
207 | changeOrModify(); | 207 | changeOrModify(); |
208 | data->sum = sum; | 208 | data->sum = sum; |
209 | } | 209 | } |
210 | void OTodo::setPriority(int prio ) | 210 | void OTodo::setPriority(int prio ) |
211 | { | 211 | { |
212 | changeOrModify(); | 212 | changeOrModify(); |
213 | data->priority = prio; | 213 | data->priority = prio; |
214 | } | 214 | } |
215 | void OTodo::setDueDate( const QDate& date ) | 215 | void OTodo::setDueDate( const QDate& date ) |
216 | { | 216 | { |
217 | changeOrModify(); | 217 | changeOrModify(); |
218 | data->date = date; | 218 | data->date = date; |
219 | } | 219 | } |
220 | void OTodo::setStartDate( const QDate& date ) { | 220 | void OTodo::setStartDate( const QDate& date ) { |
221 | changeOrModify(); | 221 | changeOrModify(); |
222 | data->start = date; | 222 | data->start = date; |
223 | } | 223 | } |
224 | void OTodo::setCompletedDate( const QDate& date ) { | 224 | void OTodo::setCompletedDate( const QDate& date ) { |
225 | changeOrModify(); | 225 | changeOrModify(); |
226 | data->completed = date; | 226 | data->completed = date; |
227 | } | 227 | } |
228 | void OTodo::setState( const OPimState& state ) { | 228 | void OTodo::setState( const OPimState& state ) { |
229 | changeOrModify(); | 229 | changeOrModify(); |
230 | if (data->state ) | 230 | if (data->state ) |
231 | (*data->state) = state; | 231 | (*data->state) = state; |
232 | else | 232 | else |
233 | data->state = new OPimState( state ); | 233 | data->state = new OPimState( state ); |
234 | } | 234 | } |
235 | void OTodo::setRecurrence( const ORecur& rec) { | 235 | void OTodo::setRecurrence( const ORecur& rec) { |
236 | changeOrModify(); | 236 | changeOrModify(); |
237 | if (data->recur ) | 237 | if (data->recur ) |
238 | (*data->recur) = rec; | 238 | (*data->recur) = rec; |
239 | else | 239 | else |
240 | data->recur = new ORecur( rec ); | 240 | data->recur = new ORecur( rec ); |
241 | } | 241 | } |
242 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 242 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { |
243 | changeOrModify(); | 243 | changeOrModify(); |
244 | 244 | ||
245 | if (data->maintainer ) | 245 | if (data->maintainer ) |
246 | (*data->maintainer) = pim; | 246 | (*data->maintainer) = pim; |
247 | else | 247 | else |
248 | data->maintainer = new OPimMaintainer( pim ); | 248 | data->maintainer = new OPimMaintainer( pim ); |
249 | } | 249 | } |
250 | bool OTodo::isOverdue( ) | 250 | bool OTodo::isOverdue( ) |
251 | { | 251 | { |
252 | if( data->hasDate && !data->isCompleted) | 252 | if( data->hasDate && !data->isCompleted) |
253 | return QDate::currentDate() > data->date; | 253 | return QDate::currentDate() > data->date; |
254 | return false; | 254 | return false; |
255 | } | 255 | } |
256 | void OTodo::setProgress(ushort progress ) | 256 | void OTodo::setProgress(ushort progress ) |
257 | { | 257 | { |
258 | changeOrModify(); | 258 | changeOrModify(); |
259 | data->prog = progress; | 259 | data->prog = progress; |
260 | } | 260 | } |
261 | QString OTodo::toShortText() const { | 261 | QString OTodo::toShortText() const { |
262 | return summary(); | 262 | return summary(); |
263 | } | 263 | } |
264 | /*! | 264 | /*! |
265 | Returns a richt text string | 265 | Returns a richt text string |
266 | */ | 266 | */ |
267 | QString OTodo::toRichText() const | 267 | QString OTodo::toRichText() const |
268 | { | 268 | { |
269 | QString text; | 269 | QString text; |
270 | QStringList catlist; | 270 | QStringList catlist; |
271 | 271 | ||
272 | // Description of the todo | 272 | // Description of the todo |
273 | if ( !summary().isEmpty() ) { | 273 | if ( !summary().isEmpty() ) { |
274 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 274 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; |
275 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 275 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
276 | } | 276 | } |
277 | if( !description().isEmpty() ){ | 277 | if( !description().isEmpty() ){ |
278 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 278 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
279 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 279 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
280 | } | 280 | } |
281 | text += "<br><br><br>"; | 281 | text += "<br><br><br>"; |
282 | 282 | ||
283 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 283 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
284 | + QString::number( priority() ) + " <br>"; | 284 | + QString::number( priority() ) + " <br>"; |
285 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 285 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
286 | + QString::number( progress() ) + " %<br>"; | 286 | + QString::number( progress() ) + " %<br>"; |
287 | if (hasDueDate() ){ | 287 | if (hasDueDate() ){ |
288 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 288 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
289 | text += dueDate().toString(); | 289 | text += dueDate().toString(); |
290 | text += "<br>"; | 290 | text += "<br>"; |
291 | } | 291 | } |
292 | 292 | ||
293 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 293 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
294 | text += categoryNames( "Todo List" ).join(", "); | 294 | text += categoryNames( "Todo List" ).join(", "); |
295 | text += "<br>"; | 295 | text += "<br>"; |
296 | 296 | ||
297 | return text; | 297 | return text; |
298 | } | 298 | } |
299 | bool OTodo::hasNotifiers()const { | 299 | bool OTodo::hasNotifiers()const { |
300 | if (!data->notifiers) return false; | 300 | if (!data->notifiers) return false; |
301 | return data->notifiers->isEmpty(); | 301 | return !data->notifiers->isEmpty(); |
302 | } | 302 | } |
303 | OPimNotifyManager& OTodo::notifiers() { | 303 | OPimNotifyManager& OTodo::notifiers() { |
304 | if (!data->notifiers ) | 304 | if (!data->notifiers ) |
305 | data->notifiers = new OPimNotifyManager; | 305 | data->notifiers = new OPimNotifyManager; |
306 | return (*data->notifiers); | 306 | return (*data->notifiers); |
307 | } | 307 | } |
308 | const OPimNotifyManager& OTodo::notifiers()const{ | ||
309 | if (!data->notifiers ) | ||
310 | data->notifiers = new OPimNotifyManager; | ||
311 | |||
312 | return (*data->notifiers); | ||
313 | } | ||
308 | 314 | ||
309 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 315 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
310 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 316 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
311 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 317 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
312 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 318 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
313 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 319 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
314 | return priority() < toDoEvent.priority(); | 320 | return priority() < toDoEvent.priority(); |
315 | }else{ | 321 | }else{ |
316 | return dueDate() < toDoEvent.dueDate(); | 322 | return dueDate() < toDoEvent.dueDate(); |
317 | } | 323 | } |
318 | } | 324 | } |
319 | return false; | 325 | return false; |
320 | } | 326 | } |
321 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 327 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
322 | { | 328 | { |
323 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 329 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
324 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 330 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
325 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 331 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
326 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 332 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
327 | return priority() <= toDoEvent.priority(); | 333 | return priority() <= toDoEvent.priority(); |
328 | }else{ | 334 | }else{ |
329 | return dueDate() <= toDoEvent.dueDate(); | 335 | return dueDate() <= toDoEvent.dueDate(); |
330 | } | 336 | } |
331 | } | 337 | } |
332 | return true; | 338 | return true; |
333 | } | 339 | } |
334 | bool OTodo::operator>(const OTodo &toDoEvent )const | 340 | bool OTodo::operator>(const OTodo &toDoEvent )const |
335 | { | 341 | { |
336 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 342 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
337 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 343 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
338 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 344 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
339 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 345 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
340 | return priority() > toDoEvent.priority(); | 346 | return priority() > toDoEvent.priority(); |
341 | }else{ | 347 | }else{ |
342 | return dueDate() > toDoEvent.dueDate(); | 348 | return dueDate() > toDoEvent.dueDate(); |
343 | } | 349 | } |
344 | } | 350 | } |
345 | return false; | 351 | return false; |
346 | } | 352 | } |
347 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 353 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
348 | { | 354 | { |
349 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 355 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
350 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 356 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
351 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 357 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
352 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 358 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
353 | return priority() > toDoEvent.priority(); | 359 | return priority() > toDoEvent.priority(); |
354 | }else{ | 360 | }else{ |
355 | return dueDate() > toDoEvent.dueDate(); | 361 | return dueDate() > toDoEvent.dueDate(); |
356 | } | 362 | } |
357 | } | 363 | } |
358 | return true; | 364 | return true; |
359 | } | 365 | } |
360 | bool OTodo::operator==(const OTodo &toDoEvent )const | 366 | bool OTodo::operator==(const OTodo &toDoEvent )const |
361 | { | 367 | { |
362 | if ( data->priority != toDoEvent.data->priority ) return false; | 368 | if ( data->priority != toDoEvent.data->priority ) return false; |
363 | if ( data->priority != toDoEvent.data->prog ) return false; | 369 | if ( data->priority != toDoEvent.data->prog ) return false; |
364 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | 370 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
365 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | 371 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
366 | if ( data->date != toDoEvent.data->date ) return false; | 372 | if ( data->date != toDoEvent.data->date ) return false; |
367 | if ( data->sum != toDoEvent.data->sum ) return false; | 373 | if ( data->sum != toDoEvent.data->sum ) return false; |
368 | if ( data->desc != toDoEvent.data->desc ) return false; | 374 | if ( data->desc != toDoEvent.data->desc ) return false; |
369 | if ( data->maintainer != toDoEvent.data->maintainer ) | 375 | if ( data->maintainer != toDoEvent.data->maintainer ) |
370 | return false; | 376 | return false; |
371 | 377 | ||
372 | return OPimRecord::operator==( toDoEvent ); | 378 | return OPimRecord::operator==( toDoEvent ); |
373 | } | 379 | } |
374 | void OTodo::deref() { | 380 | void OTodo::deref() { |
375 | 381 | ||
376 | // qWarning("deref in ToDoEvent"); | 382 | // qWarning("deref in ToDoEvent"); |
377 | if ( data->deref() ) { | 383 | if ( data->deref() ) { |
378 | // qWarning("deleting"); | 384 | // qWarning("deleting"); |
379 | delete data; | 385 | delete data; |
380 | data= 0; | 386 | data= 0; |
381 | } | 387 | } |
382 | } | 388 | } |
383 | OTodo &OTodo::operator=(const OTodo &item ) | 389 | OTodo &OTodo::operator=(const OTodo &item ) |
384 | { | 390 | { |
385 | if ( this == &item ) return *this; | 391 | if ( this == &item ) return *this; |
386 | 392 | ||
387 | OPimRecord::operator=( item ); | 393 | OPimRecord::operator=( item ); |
388 | //qWarning("operator= ref "); | 394 | //qWarning("operator= ref "); |
389 | item.data->ref(); | 395 | item.data->ref(); |
390 | deref(); | 396 | deref(); |
391 | data = item.data; | 397 | data = item.data; |
392 | 398 | ||
393 | return *this; | 399 | return *this; |
394 | } | 400 | } |
395 | 401 | ||
396 | QMap<int, QString> OTodo::toMap() const { | 402 | QMap<int, QString> OTodo::toMap() const { |
397 | QMap<int, QString> map; | 403 | QMap<int, QString> map; |
398 | 404 | ||
399 | map.insert( Uid, QString::number( uid() ) ); | 405 | map.insert( Uid, QString::number( uid() ) ); |
400 | map.insert( Category, idsToString( categories() ) ); | 406 | map.insert( Category, idsToString( categories() ) ); |
401 | map.insert( HasDate, QString::number( data->hasDate ) ); | 407 | map.insert( HasDate, QString::number( data->hasDate ) ); |
402 | map.insert( Completed, QString::number( data->isCompleted ) ); | 408 | map.insert( Completed, QString::number( data->isCompleted ) ); |
403 | map.insert( Description, data->desc ); | 409 | map.insert( Description, data->desc ); |
404 | map.insert( Summary, data->sum ); | 410 | map.insert( Summary, data->sum ); |
405 | map.insert( Priority, QString::number( data->priority ) ); | 411 | map.insert( Priority, QString::number( data->priority ) ); |
406 | map.insert( DateDay, QString::number( data->date.day() ) ); | 412 | map.insert( DateDay, QString::number( data->date.day() ) ); |
407 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 413 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
408 | map.insert( DateYear, QString::number( data->date.year() ) ); | 414 | map.insert( DateYear, QString::number( data->date.year() ) ); |
409 | map.insert( Progress, QString::number( data->prog ) ); | 415 | map.insert( Progress, QString::number( data->prog ) ); |
410 | // map.insert( CrossReference, crossToString() ); | 416 | // map.insert( CrossReference, crossToString() ); |
411 | /* FIXME!!! map.insert( State, ); | 417 | /* FIXME!!! map.insert( State, ); |
412 | map.insert( Recurrence, ); | 418 | map.insert( Recurrence, ); |
413 | map.insert( Reminders, ); | 419 | map.insert( Reminders, ); |
414 | map. | 420 | map. |
415 | */ | 421 | */ |
416 | return map; | 422 | return map; |
417 | } | 423 | } |
418 | 424 | ||
419 | QMap<QString, QString> OTodo::toExtraMap()const { | 425 | QMap<QString, QString> OTodo::toExtraMap()const { |
420 | return data->extra; | 426 | return data->extra; |
421 | } | 427 | } |
422 | /** | 428 | /** |
423 | * change or modify looks at the ref count and either | 429 | * change or modify looks at the ref count and either |
424 | * creates a new QShared Object or it can modify it | 430 | * creates a new QShared Object or it can modify it |
425 | * right in place | 431 | * right in place |
426 | */ | 432 | */ |
427 | void OTodo::changeOrModify() { | 433 | void OTodo::changeOrModify() { |
428 | if ( data->count != 1 ) { | 434 | if ( data->count != 1 ) { |
429 | qWarning("changeOrModify"); | 435 | qWarning("changeOrModify"); |
430 | data->deref(); | 436 | data->deref(); |
431 | OTodoData* d2 = new OTodoData(); | 437 | OTodoData* d2 = new OTodoData(); |
432 | copy(data, d2 ); | 438 | copy(data, d2 ); |
433 | data = d2; | 439 | data = d2; |
434 | } | 440 | } |
435 | } | 441 | } |
436 | // WATCHOUT | 442 | // WATCHOUT |
437 | /* | 443 | /* |
438 | * if you add something to the Data struct | 444 | * if you add something to the Data struct |
439 | * be sure to copy it here | 445 | * be sure to copy it here |
440 | */ | 446 | */ |
441 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 447 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
442 | dest->date = src->date; | 448 | dest->date = src->date; |
443 | dest->isCompleted = src->isCompleted; | 449 | dest->isCompleted = src->isCompleted; |
444 | dest->hasDate = src->hasDate; | 450 | dest->hasDate = src->hasDate; |
445 | dest->priority = src->priority; | 451 | dest->priority = src->priority; |
446 | dest->desc = src->desc; | 452 | dest->desc = src->desc; |
447 | dest->sum = src->sum; | 453 | dest->sum = src->sum; |
448 | dest->extra = src->extra; | 454 | dest->extra = src->extra; |
449 | dest->prog = src->prog; | 455 | dest->prog = src->prog; |
450 | 456 | ||
451 | if (src->state ) | 457 | if (src->state ) |
452 | dest->state = new OPimState( *src->state ); | 458 | dest->state = new OPimState( *src->state ); |
453 | 459 | ||
454 | if (src->recur ) | 460 | if (src->recur ) |
455 | dest->recur = new ORecur( *src->recur ); | 461 | dest->recur = new ORecur( *src->recur ); |
456 | 462 | ||
457 | if (src->maintainer ) | 463 | if (src->maintainer ) |
458 | dest->maintainer = new OPimMaintainer( *src->maintainer ) | 464 | dest->maintainer = new OPimMaintainer( *src->maintainer ) |
459 | ; | 465 | ; |
460 | dest->start = src->start; | 466 | dest->start = src->start; |
461 | dest->completed = src->completed; | 467 | dest->completed = src->completed; |
462 | 468 | ||
463 | if (src->notifiers ) | 469 | if (src->notifiers ) |
464 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); | 470 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); |
465 | } | 471 | } |
466 | QString OTodo::type() const { | 472 | QString OTodo::type() const { |
467 | return QString::fromLatin1("OTodo"); | 473 | return QString::fromLatin1("OTodo"); |
468 | } | 474 | } |
469 | QString OTodo::recordField(int /*id*/ )const { | 475 | QString OTodo::recordField(int /*id*/ )const { |
470 | return QString::null; | 476 | return QString::null; |
471 | } | 477 | } |
472 | 478 | ||
473 | int OTodo::rtti(){ | 479 | int OTodo::rtti(){ |
474 | return OPimResolver::TodoList; | 480 | return OPimResolver::TodoList; |
475 | } | 481 | } |
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index 0e7c73f..4d5ee36 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h | |||
@@ -1,289 +1,295 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_TODO_EVENT_H | 2 | #ifndef OPIE_TODO_EVENT_H |
3 | #define OPIE_TODO_EVENT_H | 3 | #define OPIE_TODO_EVENT_H |
4 | 4 | ||
5 | 5 | ||
6 | #include <qarray.h> | 6 | #include <qarray.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 11 | #include <qvaluelist.h> |
12 | 12 | ||
13 | #include <qpe/recordfields.h> | 13 | #include <qpe/recordfields.h> |
14 | #include <qpe/palmtopuidgen.h> | 14 | #include <qpe/palmtopuidgen.h> |
15 | 15 | ||
16 | #include <opie/opimrecord.h> | 16 | #include <opie/opimrecord.h> |
17 | 17 | ||
18 | 18 | ||
19 | class OPimState; | 19 | class OPimState; |
20 | class ORecur; | 20 | class ORecur; |
21 | class OPimMaintainer; | 21 | class OPimMaintainer; |
22 | class OPimNotifyManager; | 22 | class OPimNotifyManager; |
23 | class OTodo : public OPimRecord { | 23 | class OTodo : public OPimRecord { |
24 | public: | 24 | public: |
25 | typedef QValueList<OTodo> ValueList; | 25 | typedef QValueList<OTodo> ValueList; |
26 | enum RecordFields { | 26 | enum RecordFields { |
27 | Uid = Qtopia::UID_ID, | 27 | Uid = Qtopia::UID_ID, |
28 | Category = Qtopia::CATEGORY_ID, | 28 | Category = Qtopia::CATEGORY_ID, |
29 | HasDate, | 29 | HasDate, |
30 | Completed, | 30 | Completed, |
31 | Description, | 31 | Description, |
32 | Summary, | 32 | Summary, |
33 | Priority, | 33 | Priority, |
34 | DateDay, | 34 | DateDay, |
35 | DateMonth, | 35 | DateMonth, |
36 | DateYear, | 36 | DateYear, |
37 | Progress, | 37 | Progress, |
38 | CrossReference, | 38 | CrossReference, |
39 | State, | 39 | State, |
40 | Recurrence, | 40 | Recurrence, |
41 | Alarms, | 41 | Alarms, |
42 | Reminders, | 42 | Reminders, |
43 | Notifiers, | 43 | Notifiers, |
44 | Maintainer, | 44 | Maintainer, |
45 | StartDate, | 45 | StartDate, |
46 | CompletedDate | 46 | CompletedDate |
47 | }; | 47 | }; |
48 | public: | 48 | public: |
49 | // priorities from Very low to very high | 49 | // priorities from Very low to very high |
50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; |
51 | 51 | ||
52 | /* Constructs a new ToDoEvent | 52 | /* Constructs a new ToDoEvent |
53 | @param completed Is the TodoEvent completed | 53 | @param completed Is the TodoEvent completed |
54 | @param priority What is the priority of this ToDoEvent | 54 | @param priority What is the priority of this ToDoEvent |
55 | @param category Which category does it belong( uid ) | 55 | @param category Which category does it belong( uid ) |
56 | @param summary A small summary of the todo | 56 | @param summary A small summary of the todo |
57 | @param description What is this ToDoEvent about | 57 | @param description What is this ToDoEvent about |
58 | @param hasDate Does this Event got a deadline | 58 | @param hasDate Does this Event got a deadline |
59 | @param date what is the deadline? | 59 | @param date what is the deadline? |
60 | @param uid what is the UUID of this Event | 60 | @param uid what is the UUID of this Event |
61 | **/ | 61 | **/ |
62 | OTodo( bool completed = false, int priority = Normal, | 62 | OTodo( bool completed = false, int priority = Normal, |
63 | const QStringList &category = QStringList(), | 63 | const QStringList &category = QStringList(), |
64 | const QString &summary = QString::null , | 64 | const QString &summary = QString::null , |
65 | const QString &description = QString::null, | 65 | const QString &description = QString::null, |
66 | ushort progress = 0, | 66 | ushort progress = 0, |
67 | bool hasDate = false, QDate date = QDate::currentDate(), | 67 | bool hasDate = false, QDate date = QDate::currentDate(), |
68 | int uid = 0 /*empty*/ ); | 68 | int uid = 0 /*empty*/ ); |
69 | 69 | ||
70 | OTodo( bool completed, int priority, | 70 | OTodo( bool completed, int priority, |
71 | const QArray<int>& category, | 71 | const QArray<int>& category, |
72 | const QString& summary = QString::null, | 72 | const QString& summary = QString::null, |
73 | const QString& description = QString::null, | 73 | const QString& description = QString::null, |
74 | ushort progress = 0, | 74 | ushort progress = 0, |
75 | bool hasDate = false, QDate date = QDate::currentDate(), | 75 | bool hasDate = false, QDate date = QDate::currentDate(), |
76 | int uid = 0 /* empty */ ); | 76 | int uid = 0 /* empty */ ); |
77 | 77 | ||
78 | /** Copy c'tor | 78 | /** Copy c'tor |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | OTodo(const OTodo & ); | 81 | OTodo(const OTodo & ); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | *destructor | 84 | *destructor |
85 | */ | 85 | */ |
86 | ~OTodo(); | 86 | ~OTodo(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Is this event completed? | 89 | * Is this event completed? |
90 | */ | 90 | */ |
91 | bool isCompleted() const; | 91 | bool isCompleted() const; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Does this Event have a deadline | 94 | * Does this Event have a deadline |
95 | */ | 95 | */ |
96 | bool hasDueDate() const; | 96 | bool hasDueDate() const; |
97 | bool hasStartDate()const; | 97 | bool hasStartDate()const; |
98 | bool hasCompletedDate()const; | 98 | bool hasCompletedDate()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Does this Event has an alarm time ? | 101 | * Does this Event has an alarm time ? |
102 | */ | 102 | */ |
103 | bool hasAlarmDateTime() const; | 103 | bool hasAlarmDateTime() const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * What is the priority? | 106 | * What is the priority? |
107 | */ | 107 | */ |
108 | int priority()const ; | 108 | int priority()const ; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 111 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
112 | */ | 112 | */ |
113 | ushort progress() const; | 113 | ushort progress() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * The due Date | 116 | * The due Date |
117 | */ | 117 | */ |
118 | QDate dueDate()const; | 118 | QDate dueDate()const; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * When did it start? | 121 | * When did it start? |
122 | */ | 122 | */ |
123 | QDate startDate()const; | 123 | QDate startDate()const; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * When was it completed? | 126 | * When was it completed? |
127 | */ | 127 | */ |
128 | QDate completedDate()const; | 128 | QDate completedDate()const; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * does it have a state? | 131 | * does it have a state? |
132 | */ | 132 | */ |
133 | bool hasState()const; | 133 | bool hasState()const; |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * What is the state of this OTodo? | 136 | * What is the state of this OTodo? |
137 | */ | 137 | */ |
138 | OPimState state()const; | 138 | OPimState state()const; |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * has recurrence? | 141 | * has recurrence? |
142 | */ | 142 | */ |
143 | bool hasRecurrence()const; | 143 | bool hasRecurrence()const; |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * the recurrance of this | 146 | * the recurrance of this |
147 | */ | 147 | */ |
148 | ORecur recurrence()const; | 148 | ORecur recurrence()const; |
149 | 149 | ||
150 | /** | 150 | /** |
151 | * does this OTodo have a maintainer? | 151 | * does this OTodo have a maintainer? |
152 | */ | 152 | */ |
153 | bool hasMaintainer()const; | 153 | bool hasMaintainer()const; |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * the Maintainer of this OTodo | 156 | * the Maintainer of this OTodo |
157 | */ | 157 | */ |
158 | OPimMaintainer maintainer()const; | 158 | OPimMaintainer maintainer()const; |
159 | 159 | ||
160 | /** | 160 | /** |
161 | * The description of the todo | 161 | * The description of the todo |
162 | */ | 162 | */ |
163 | QString description()const; | 163 | QString description()const; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * A small summary of the todo | 166 | * A small summary of the todo |
167 | */ | 167 | */ |
168 | QString summary() const; | 168 | QString summary() const; |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * @reimplemented | 171 | * @reimplemented |
172 | * Return this todoevent in a RichText formatted QString | 172 | * Return this todoevent in a RichText formatted QString |
173 | */ | 173 | */ |
174 | QString toRichText() const; | 174 | QString toRichText() const; |
175 | 175 | ||
176 | bool hasNotifiers()const; | 176 | bool hasNotifiers()const; |
177 | /* | 177 | /* |
178 | * check if the sharing is still fine!! -zecke | 178 | * FIXME check if the sharing is still fine!! -zecke |
179 | * ### CHECK If API is fine | ||
179 | */ | 180 | */ |
180 | /** | 181 | /** |
181 | * return a reference to our notifiers... | 182 | * return a reference to our notifiers... |
182 | */ | 183 | */ |
183 | OPimNotifyManager ¬ifiers(); | 184 | OPimNotifyManager ¬ifiers(); |
184 | 185 | ||
185 | /** | 186 | /** |
187 | * | ||
188 | */ | ||
189 | const OPimNotifyManager ¬ifiers()const; | ||
190 | |||
191 | /** | ||
186 | * reimplementations | 192 | * reimplementations |
187 | */ | 193 | */ |
188 | QString type()const; | 194 | QString type()const; |
189 | QString toShortText()const; | 195 | QString toShortText()const; |
190 | QMap<QString, QString> toExtraMap()const; | 196 | QMap<QString, QString> toExtraMap()const; |
191 | QString recordField(int id )const; | 197 | QString recordField(int id )const; |
192 | 198 | ||
193 | /** | 199 | /** |
194 | * toMap puts all data into the map. int relates | 200 | * toMap puts all data into the map. int relates |
195 | * to ToDoEvent RecordFields enum | 201 | * to ToDoEvent RecordFields enum |
196 | */ | 202 | */ |
197 | QMap<int, QString> toMap()const; | 203 | QMap<int, QString> toMap()const; |
198 | 204 | ||
199 | /** | 205 | /** |
200 | * Set if this Todo is completed | 206 | * Set if this Todo is completed |
201 | */ | 207 | */ |
202 | void setCompleted(bool completed ); | 208 | void setCompleted(bool completed ); |
203 | 209 | ||
204 | /** | 210 | /** |
205 | * set if this todo got an end data | 211 | * set if this todo got an end data |
206 | */ | 212 | */ |
207 | void setHasDueDate( bool hasDate ); | 213 | void setHasDueDate( bool hasDate ); |
208 | // FIXME we do not have these for start, completed | 214 | // FIXME we do not have these for start, completed |
209 | // cause we'll use the isNull() of QDate for figuring | 215 | // cause we'll use the isNull() of QDate for figuring |
210 | // out if it's has a date... | 216 | // out if it's has a date... |
211 | // decide what to do here? -zecke | 217 | // decide what to do here? -zecke |
212 | 218 | ||
213 | /** | 219 | /** |
214 | * Set the priority of the Todo | 220 | * Set the priority of the Todo |
215 | */ | 221 | */ |
216 | void setPriority(int priority ); | 222 | void setPriority(int priority ); |
217 | 223 | ||
218 | /** | 224 | /** |
219 | * Set the progress. | 225 | * Set the progress. |
220 | */ | 226 | */ |
221 | void setProgress( ushort progress ); | 227 | void setProgress( ushort progress ); |
222 | 228 | ||
223 | /** | 229 | /** |
224 | * set the end date | 230 | * set the end date |
225 | */ | 231 | */ |
226 | void setDueDate( const QDate& date ); | 232 | void setDueDate( const QDate& date ); |
227 | 233 | ||
228 | /** | 234 | /** |
229 | * set the start date | 235 | * set the start date |
230 | */ | 236 | */ |
231 | void setStartDate( const QDate& date ); | 237 | void setStartDate( const QDate& date ); |
232 | 238 | ||
233 | /** | 239 | /** |
234 | * set the completed date | 240 | * set the completed date |
235 | */ | 241 | */ |
236 | void setCompletedDate( const QDate& date ); | 242 | void setCompletedDate( const QDate& date ); |
237 | 243 | ||
238 | void setRecurrence( const ORecur& ); | 244 | void setRecurrence( const ORecur& ); |
239 | /** | 245 | /** |
240 | * set the alarm time | 246 | * set the alarm time |
241 | */ | 247 | */ |
242 | void setAlarmDateTime ( const QDateTime& alarm ); | 248 | void setAlarmDateTime ( const QDateTime& alarm ); |
243 | 249 | ||
244 | void setDescription(const QString& ); | 250 | void setDescription(const QString& ); |
245 | void setSummary(const QString& ); | 251 | void setSummary(const QString& ); |
246 | 252 | ||
247 | /** | 253 | /** |
248 | * set the state of a Todo | 254 | * set the state of a Todo |
249 | * @param state State what the todo should take | 255 | * @param state State what the todo should take |
250 | */ | 256 | */ |
251 | void setState( const OPimState& state); | 257 | void setState( const OPimState& state); |
252 | 258 | ||
253 | /** | 259 | /** |
254 | * set the Maintainer Mode | 260 | * set the Maintainer Mode |
255 | */ | 261 | */ |
256 | void setMaintainer( const OPimMaintainer& ); | 262 | void setMaintainer( const OPimMaintainer& ); |
257 | 263 | ||
258 | bool isOverdue(); | 264 | bool isOverdue(); |
259 | 265 | ||
260 | 266 | ||
261 | virtual bool match( const QRegExp &r )const; | 267 | virtual bool match( const QRegExp &r )const; |
262 | 268 | ||
263 | bool operator<(const OTodo &toDoEvent )const; | 269 | bool operator<(const OTodo &toDoEvent )const; |
264 | bool operator<=(const OTodo &toDoEvent )const; | 270 | bool operator<=(const OTodo &toDoEvent )const; |
265 | bool operator!=(const OTodo &toDoEvent )const; | 271 | bool operator!=(const OTodo &toDoEvent )const; |
266 | bool operator>(const OTodo &toDoEvent )const; | 272 | bool operator>(const OTodo &toDoEvent )const; |
267 | bool operator>=(const OTodo &toDoEvent)const; | 273 | bool operator>=(const OTodo &toDoEvent)const; |
268 | bool operator==(const OTodo &toDoEvent )const; | 274 | bool operator==(const OTodo &toDoEvent )const; |
269 | OTodo &operator=(const OTodo &toDoEvent ); | 275 | OTodo &operator=(const OTodo &toDoEvent ); |
270 | 276 | ||
271 | static int rtti(); | 277 | static int rtti(); |
272 | 278 | ||
273 | private: | 279 | private: |
274 | class OTodoPrivate; | 280 | class OTodoPrivate; |
275 | struct OTodoData; | 281 | struct OTodoData; |
276 | 282 | ||
277 | void deref(); | 283 | void deref(); |
278 | inline void changeOrModify(); | 284 | inline void changeOrModify(); |
279 | void copy( OTodoData* src, OTodoData* dest ); | 285 | void copy( OTodoData* src, OTodoData* dest ); |
280 | OTodoPrivate *d; | 286 | OTodoPrivate *d; |
281 | OTodoData *data; | 287 | OTodoData *data; |
282 | 288 | ||
283 | }; | 289 | }; |
284 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | 290 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { |
285 | return !(*this == toDoEvent); | 291 | return !(*this == toDoEvent); |
286 | } | 292 | } |
287 | 293 | ||
288 | 294 | ||
289 | #endif | 295 | #endif |