summaryrefslogtreecommitdiff
path: root/libopie/pim
Unidiff
Diffstat (limited to 'libopie/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimmaintainer.cpp37
-rw-r--r--libopie/pim/opimmaintainer.h36
-rw-r--r--libopie/pim/opimxrefmanager.cpp2
-rw-r--r--libopie/pim/otodo.cpp20
-rw-r--r--libopie/pim/otodo.h12
5 files changed, 106 insertions, 1 deletions
diff --git a/libopie/pim/opimmaintainer.cpp b/libopie/pim/opimmaintainer.cpp
new file mode 100644
index 0000000..e34f035
--- a/dev/null
+++ b/libopie/pim/opimmaintainer.cpp
@@ -0,0 +1,37 @@
1#include "opimmaintainer.h"
2
3OPimMaintainer::OPimMaintainer( enum Mode mode, int uid )
4 : m_mode(mode), m_uid(uid )
5{}
6OPimMaintainer::~OPimMaintainer() {
7}
8OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) {
9 *this = main;
10}
11OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) {
12 m_mode = main.m_mode;
13 m_uid = main.m_uid;
14
15 return *this;
16}
17bool OPimMaintainer::operator==( const OPimMaintainer& main ) {
18 if (m_mode != main.m_mode ) return false;
19 if (m_uid != main.m_uid ) return false;
20
21 return true;
22}
23bool OPimMaintainer::operator!=( const OPimMaintainer& main ) {
24 return !(*this == main );
25}
26OPimMaintainer::Mode OPimMaintainer::mode()const {
27 return m_mode;
28}
29int OPimMaintainer::uid()const {
30 return m_uid;
31}
32void OPimMaintainer::setMode( enum Mode mo) {
33 m_mode = mo;
34}
35void OPimMaintainer::setUid( int uid ) {
36 m_uid = uid;
37}
diff --git a/libopie/pim/opimmaintainer.h b/libopie/pim/opimmaintainer.h
new file mode 100644
index 0000000..310e15a
--- a/dev/null
+++ b/libopie/pim/opimmaintainer.h
@@ -0,0 +1,36 @@
1#ifndef OPIE_PIM_MAINTAINER_H
2#define OPIE_PIM_MAINTAINER_H
3
4#include <qstring.h>
5
6/**
7 * Who maintains what?
8 */
9class OPimMaintainer {
10public:
11 enum Mode { Undefined = -1,
12 Responsible = 0,
13 DoneBy,
14 Coordinating };
15 OPimMaintainer( enum Mode mode = Undefined, int uid = 0);
16 OPimMaintainer( const OPimMaintainer& );
17 ~OPimMaintainer();
18
19 OPimMaintainer &operator=( const OPimMaintainer& );
20 bool operator==( const OPimMaintainer& );
21 bool operator!=( const OPimMaintainer& );
22
23
24 Mode mode()const;
25 int uid()const;
26
27 void setMode( enum Mode );
28 void setUid( int uid );
29
30private:
31 Mode m_mode;
32 int m_uid;
33
34};
35
36#endif
diff --git a/libopie/pim/opimxrefmanager.cpp b/libopie/pim/opimxrefmanager.cpp
index d49f5f5..965f542 100644
--- a/libopie/pim/opimxrefmanager.cpp
+++ b/libopie/pim/opimxrefmanager.cpp
@@ -1,24 +1,26 @@
1#include "opimxrefmanager.h" 1#include "opimxrefmanager.h"
2 2
3 3
4OPimXRefManager::OPimXRefManager() { 4OPimXRefManager::OPimXRefManager() {
5} 5}
6OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { 6OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) {
7 m_list = ref.m_list; 7 m_list = ref.m_list;
8} 8}
9OPimXRefManager::~OPimXRefManager() {
10}
9OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { 11OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) {
10 m_list = ref.m_list; 12 m_list = ref.m_list;
11 return *this; 13 return *this;
12} 14}
13bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { 15bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) {
14 // if ( m_list == ref.m_list ) return true; 16 // if ( m_list == ref.m_list ) return true;
15 17
16 return false; 18 return false;
17} 19}
18void OPimXRefManager::add( const OPimXRef& ref) { 20void OPimXRefManager::add( const OPimXRef& ref) {
19 m_list.append( ref ); 21 m_list.append( ref );
20} 22}
21void OPimXRefManager::remove( const OPimXRef& ref) { 23void OPimXRefManager::remove( const OPimXRef& ref) {
22 m_list.remove( ref ); 24 m_list.remove( ref );
23} 25}
24void OPimXRefManager::replace( const OPimXRef& ref) { 26void OPimXRefManager::replace( const OPimXRef& ref) {
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 4d5cb79..6fcf9f6 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,51 +1,54 @@
1 1
2#include <qobject.h> 2#include <qobject.h>
3#include <qshared.h> 3#include <qshared.h>
4 4
5 5
6 6
7#include <qpe/palmtopuidgen.h> 7#include <qpe/palmtopuidgen.h>
8#include <qpe/stringutil.h> 8#include <qpe/stringutil.h>
9#include <qpe/palmtoprecord.h> 9#include <qpe/palmtoprecord.h>
10#include <qpe/stringutil.h> 10#include <qpe/stringutil.h>
11#include <qpe/categories.h> 11#include <qpe/categories.h>
12#include <qpe/categoryselect.h> 12#include <qpe/categoryselect.h>
13 13
14 14
15#include "opimstate.h" 15#include "opimstate.h"
16#include "orecur.h" 16#include "orecur.h"
17#include "opimmaintainer.h"
18
17#include "otodo.h" 19#include "otodo.h"
18 20
19 21
20struct OTodo::OTodoData : public QShared { 22struct OTodo::OTodoData : public QShared {
21 OTodoData() : QShared() { 23 OTodoData() : QShared() {
22 }; 24 };
23 25
24 QDate date; 26 QDate date;
25 bool isCompleted:1; 27 bool isCompleted:1;
26 bool hasDate:1; 28 bool hasDate:1;
27 int priority; 29 int priority;
28 QString desc; 30 QString desc;
29 QString sum; 31 QString sum;
30 QMap<QString, QString> extra; 32 QMap<QString, QString> extra;
31 ushort prog; 33 ushort prog;
32 bool hasAlarmDateTime :1; 34 bool hasAlarmDateTime :1;
33 QDateTime alarmDateTime; 35 QDateTime alarmDateTime;
34 OPimState state; 36 OPimState state;
35 ORecur recur; 37 ORecur recur;
38 OPimMaintainer maintainer;
36}; 39};
37 40
38OTodo::OTodo(const OTodo &event ) 41OTodo::OTodo(const OTodo &event )
39 : OPimRecord( event ), data( event.data ) 42 : OPimRecord( event ), data( event.data )
40{ 43{
41 data->ref(); 44 data->ref();
42// qWarning("ref up"); 45// qWarning("ref up");
43} 46}
44OTodo::~OTodo() { 47OTodo::~OTodo() {
45 48
46// qWarning("~OTodo " ); 49// qWarning("~OTodo " );
47 if ( data->deref() ) { 50 if ( data->deref() ) {
48// qWarning("OTodo::dereffing"); 51// qWarning("OTodo::dereffing");
49 delete data; 52 delete data;
50 data = 0l; 53 data = 0l;
51 } 54 }
@@ -140,32 +143,35 @@ QDate OTodo::dueDate()const
140 143
141QDateTime OTodo::alarmDateTime() const 144QDateTime OTodo::alarmDateTime() const
142{ 145{
143 return data->alarmDateTime; 146 return data->alarmDateTime;
144} 147}
145 148
146QString OTodo::description()const 149QString OTodo::description()const
147{ 150{
148 return data->desc; 151 return data->desc;
149} 152}
150OPimState OTodo::state()const { 153OPimState OTodo::state()const {
151 return data->state; 154 return data->state;
152} 155}
153ORecur OTodo::recurrence()const { 156ORecur OTodo::recurrence()const {
154 return data->recur; 157 return data->recur;
155} 158}
159OPimMaintainer OTodo::maintainer()const {
160 return data->maintainer;
161}
156void OTodo::setCompleted( bool completed ) 162void OTodo::setCompleted( bool completed )
157{ 163{
158 changeOrModify(); 164 changeOrModify();
159 data->isCompleted = completed; 165 data->isCompleted = completed;
160} 166}
161void OTodo::setHasDueDate( bool hasDate ) 167void OTodo::setHasDueDate( bool hasDate )
162{ 168{
163 changeOrModify(); 169 changeOrModify();
164 data->hasDate = hasDate; 170 data->hasDate = hasDate;
165} 171}
166void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) 172void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
167{ 173{
168 changeOrModify(); 174 changeOrModify();
169 data->hasAlarmDateTime = hasAlarmDateTime; 175 data->hasAlarmDateTime = hasAlarmDateTime;
170} 176}
171void OTodo::setDescription(const QString &desc ) 177void OTodo::setDescription(const QString &desc )
@@ -189,32 +195,36 @@ void OTodo::setDueDate( QDate date )
189 changeOrModify(); 195 changeOrModify();
190 data->date = date; 196 data->date = date;
191} 197}
192void OTodo::setAlarmDateTime( const QDateTime& alarm ) 198void OTodo::setAlarmDateTime( const QDateTime& alarm )
193{ 199{
194 changeOrModify(); 200 changeOrModify();
195 data->alarmDateTime = alarm; 201 data->alarmDateTime = alarm;
196} 202}
197void OTodo::setState( const OPimState& state ) { 203void OTodo::setState( const OPimState& state ) {
198 changeOrModify(); 204 changeOrModify();
199 data->state = state; 205 data->state = state;
200} 206}
201void OTodo::setRecurrence( const ORecur& rec) { 207void OTodo::setRecurrence( const ORecur& rec) {
202 changeOrModify(); 208 changeOrModify();
203 data->recur = rec; 209 data->recur = rec;
204} 210}
211void OTodo::setMaintainer( const OPimMaintainer& pim ) {
212 changeOrModify();
213 data->maintainer = pim;
214}
205bool OTodo::isOverdue( ) 215bool OTodo::isOverdue( )
206{ 216{
207 if( data->hasDate && !data->isCompleted) 217 if( data->hasDate && !data->isCompleted)
208 return QDate::currentDate() > data->date; 218 return QDate::currentDate() > data->date;
209 return false; 219 return false;
210} 220}
211void OTodo::setProgress(ushort progress ) 221void OTodo::setProgress(ushort progress )
212{ 222{
213 changeOrModify(); 223 changeOrModify();
214 data->prog = progress; 224 data->prog = progress;
215} 225}
216QString OTodo::toShortText() const { 226QString OTodo::toShortText() const {
217 return summary(); 227 return summary();
218} 228}
219/*! 229/*!
220 Returns a richt text string 230 Returns a richt text string
@@ -308,32 +318,34 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
308 } 318 }
309 return true; 319 return true;
310} 320}
311bool OTodo::operator==(const OTodo &toDoEvent )const 321bool OTodo::operator==(const OTodo &toDoEvent )const
312{ 322{
313 if ( data->priority != toDoEvent.data->priority ) return false; 323 if ( data->priority != toDoEvent.data->priority ) return false;
314 if ( data->priority != toDoEvent.data->prog ) return false; 324 if ( data->priority != toDoEvent.data->prog ) return false;
315 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 325 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
316 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 326 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
317 if ( data->date != toDoEvent.data->date ) return false; 327 if ( data->date != toDoEvent.data->date ) return false;
318 if ( data->sum != toDoEvent.data->sum ) return false; 328 if ( data->sum != toDoEvent.data->sum ) return false;
319 if ( data->desc != toDoEvent.data->desc ) return false; 329 if ( data->desc != toDoEvent.data->desc ) return false;
320 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) 330 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
321 return false; 331 return false;
322 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) 332 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
323 return false; 333 return false;
334 if ( data->maintainer != toDoEvent.data->maintainer )
335 return false;
324 336
325 return OPimRecord::operator==( toDoEvent ); 337 return OPimRecord::operator==( toDoEvent );
326} 338}
327void OTodo::deref() { 339void OTodo::deref() {
328 340
329// qWarning("deref in ToDoEvent"); 341// qWarning("deref in ToDoEvent");
330 if ( data->deref() ) { 342 if ( data->deref() ) {
331// qWarning("deleting"); 343// qWarning("deleting");
332 delete data; 344 delete data;
333 data= 0; 345 data= 0;
334 } 346 }
335} 347}
336OTodo &OTodo::operator=(const OTodo &item ) 348OTodo &OTodo::operator=(const OTodo &item )
337{ 349{
338 OPimRecord::operator=( item ); 350 OPimRecord::operator=( item );
339 //qWarning("operator= ref "); 351 //qWarning("operator= ref ");
@@ -345,61 +357,67 @@ OTodo &OTodo::operator=(const OTodo &item )
345} 357}
346 358
347QMap<int, QString> OTodo::toMap() const { 359QMap<int, QString> OTodo::toMap() const {
348 QMap<int, QString> map; 360 QMap<int, QString> map;
349 361
350 map.insert( Uid, QString::number( uid() ) ); 362 map.insert( Uid, QString::number( uid() ) );
351 map.insert( Category, idsToString( categories() ) ); 363 map.insert( Category, idsToString( categories() ) );
352 map.insert( HasDate, QString::number( data->hasDate ) ); 364 map.insert( HasDate, QString::number( data->hasDate ) );
353 map.insert( Completed, QString::number( data->isCompleted ) ); 365 map.insert( Completed, QString::number( data->isCompleted ) );
354 map.insert( Description, data->desc ); 366 map.insert( Description, data->desc );
355 map.insert( Summary, data->sum ); 367 map.insert( Summary, data->sum );
356 map.insert( Priority, QString::number( data->priority ) ); 368 map.insert( Priority, QString::number( data->priority ) );
357 map.insert( DateDay, QString::number( data->date.day() ) ); 369 map.insert( DateDay, QString::number( data->date.day() ) );
358 map.insert( DateMonth, QString::number( data->date.month() ) ); 370 map.insert( DateMonth, QString::number( data->date.month() ) );
359 map.insert( DateYear, QString::number( data->date.year() ) ); 371 map.insert( DateYear, QString::number( data->date.year() ) );
360 map.insert( Progress, QString::number( data->prog ) ); 372 map.insert( Progress, QString::number( data->prog ) );
361 map.insert( CrossReference, crossToString() ); 373// map.insert( CrossReference, crossToString() );
362 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 374 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
363 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 375 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
364 376
365 return map; 377 return map;
366} 378}
367 379
368QMap<QString, QString> OTodo::toExtraMap()const { 380QMap<QString, QString> OTodo::toExtraMap()const {
369 return data->extra; 381 return data->extra;
370} 382}
371/** 383/**
372 * change or modify looks at the ref count and either 384 * change or modify looks at the ref count and either
373 * creates a new QShared Object or it can modify it 385 * creates a new QShared Object or it can modify it
374 * right in place 386 * right in place
375 */ 387 */
376void OTodo::changeOrModify() { 388void OTodo::changeOrModify() {
377 if ( data->count != 1 ) { 389 if ( data->count != 1 ) {
378 qWarning("changeOrModify"); 390 qWarning("changeOrModify");
379 data->deref(); 391 data->deref();
380 OTodoData* d2 = new OTodoData(); 392 OTodoData* d2 = new OTodoData();
381 copy(data, d2 ); 393 copy(data, d2 );
382 data = d2; 394 data = d2;
383 } 395 }
384} 396}
397// WATCHOUT
398/*
399 * if you add something to the Data struct
400 * be sure to copy it here
401 */
385void OTodo::copy( OTodoData* src, OTodoData* dest ) { 402void OTodo::copy( OTodoData* src, OTodoData* dest ) {
386 dest->date = src->date; 403 dest->date = src->date;
387 dest->isCompleted = src->isCompleted; 404 dest->isCompleted = src->isCompleted;
388 dest->hasDate = src->hasDate; 405 dest->hasDate = src->hasDate;
389 dest->priority = src->priority; 406 dest->priority = src->priority;
390 dest->desc = src->desc; 407 dest->desc = src->desc;
391 dest->sum = src->sum; 408 dest->sum = src->sum;
392 dest->extra = src->extra; 409 dest->extra = src->extra;
393 dest->prog = src->prog; 410 dest->prog = src->prog;
394 dest->hasAlarmDateTime = src->hasAlarmDateTime; 411 dest->hasAlarmDateTime = src->hasAlarmDateTime;
395 dest->alarmDateTime = src->alarmDateTime; 412 dest->alarmDateTime = src->alarmDateTime;
396 dest->state = src->state; 413 dest->state = src->state;
397 dest->recur = src->recur; 414 dest->recur = src->recur;
415 dest->maintainer = src->maintainer;
398} 416}
399QString OTodo::type() const { 417QString OTodo::type() const {
400 return QString::fromLatin1("OTodo"); 418 return QString::fromLatin1("OTodo");
401} 419}
402QString OTodo::recordField(int /*id*/ )const { 420QString OTodo::recordField(int /*id*/ )const {
403 return QString::null; 421 return QString::null;
404} 422}
405 423
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index 2cdc587..70b0253 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -5,32 +5,33 @@
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
19class OPimState; 19class OPimState;
20class ORecur; 20class ORecur;
21class OPimMaintainer;
21class OTodo : public OPimRecord { 22class OTodo : public OPimRecord {
22public: 23public:
23 typedef QValueList<OTodo> ValueList; 24 typedef QValueList<OTodo> ValueList;
24 enum RecordFields { 25 enum RecordFields {
25 Uid = Qtopia::UID_ID, 26 Uid = Qtopia::UID_ID,
26 Category = Qtopia::CATEGORY_ID, 27 Category = Qtopia::CATEGORY_ID,
27 HasDate, 28 HasDate,
28 Completed, 29 Completed,
29 Description, 30 Description,
30 Summary, 31 Summary,
31 Priority, 32 Priority,
32 DateDay, 33 DateDay,
33 DateMonth, 34 DateMonth,
34 DateYear, 35 DateYear,
35 Progress, 36 Progress,
36 CrossReference, 37 CrossReference,
@@ -115,32 +116,37 @@ public:
115 /** 116 /**
116 * Alarm Date and Time 117 * Alarm Date and Time
117 */ 118 */
118 QDateTime alarmDateTime()const; 119 QDateTime alarmDateTime()const;
119 120
120 /** 121 /**
121 * What is the state of this OTodo? 122 * What is the state of this OTodo?
122 */ 123 */
123 OPimState state()const; 124 OPimState state()const;
124 125
125 /** 126 /**
126 * the recurrance of this 127 * the recurrance of this
127 */ 128 */
128 ORecur recurrence()const; 129 ORecur recurrence()const;
129 130
130 /** 131 /**
132 * the Maintainer of this OTodo
133 */
134 OPimMaintainer maintainer()const;
135
136 /**
131 * The description of the todo 137 * The description of the todo
132 */ 138 */
133 QString description()const; 139 QString description()const;
134 140
135 /** 141 /**
136 * A small summary of the todo 142 * A small summary of the todo
137 */ 143 */
138 QString summary() const; 144 QString summary() const;
139 145
140 /** 146 /**
141 * @reimplemented 147 * @reimplemented
142 * Return this todoevent in a RichText formatted QString 148 * Return this todoevent in a RichText formatted QString
143 */ 149 */
144 QString toRichText() const; 150 QString toRichText() const;
145 151
146 /** 152 /**
@@ -189,32 +195,38 @@ public:
189 195
190 196
191 void setRecurrence( const ORecur& ); 197 void setRecurrence( const ORecur& );
192 /** 198 /**
193 * set the alarm time 199 * set the alarm time
194 */ 200 */
195 void setAlarmDateTime ( const QDateTime& alarm ); 201 void setAlarmDateTime ( const QDateTime& alarm );
196 202
197 void setDescription(const QString& ); 203 void setDescription(const QString& );
198 void setSummary(const QString& ); 204 void setSummary(const QString& );
199 205
200 /** 206 /**
201 * set the state of a Todo 207 * set the state of a Todo
202 * @param state State what the todo should take 208 * @param state State what the todo should take
203 */ 209 */
204 void setState( const OPimState& state); 210 void setState( const OPimState& state);
211
212 /**
213 * set the Maintainer Mode
214 */
215 void setMaintainer( const OPimMaintainer& );
216
205 bool isOverdue(); 217 bool isOverdue();
206 218
207 219
208 bool match( const QRegExp &r )const; 220 bool match( const QRegExp &r )const;
209 221
210 bool operator<(const OTodo &toDoEvent )const; 222 bool operator<(const OTodo &toDoEvent )const;
211 bool operator<=(const OTodo &toDoEvent )const; 223 bool operator<=(const OTodo &toDoEvent )const;
212 bool operator!=(const OTodo &toDoEvent )const; 224 bool operator!=(const OTodo &toDoEvent )const;
213 bool operator>(const OTodo &toDoEvent )const; 225 bool operator>(const OTodo &toDoEvent )const;
214 bool operator>=(const OTodo &toDoEvent)const; 226 bool operator>=(const OTodo &toDoEvent)const;
215 bool operator==(const OTodo &toDoEvent )const; 227 bool operator==(const OTodo &toDoEvent )const;
216 OTodo &operator=(const OTodo &toDoEvent ); 228 OTodo &operator=(const OTodo &toDoEvent );
217 229
218 private: 230 private:
219 class OTodoPrivate; 231 class OTodoPrivate;
220 struct OTodoData; 232 struct OTodoData;