summaryrefslogtreecommitdiff
authorzecke <zecke>2002-09-21 15:02:50 (UTC)
committer zecke <zecke>2002-09-21 15:02:50 (UTC)
commite6c53c4d7317e766235449535b22d0d2fe709214 (patch) (unidiff)
treec210c639611acd5aa3c1863451fb4e31ac3af29a
parentfe0806def8ec79815832193fe402c75361108622 (diff)
downloadopie-e6c53c4d7317e766235449535b22d0d2fe709214.zip
opie-e6c53c4d7317e766235449535b22d0d2fe709214.tar.gz
opie-e6c53c4d7317e766235449535b22d0d2fe709214.tar.bz2
Some more implementation
in OPimRecord::setUid ORecordList implemented never compiled it though OTodo a new c'tor and some more changes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimrecord.cpp11
-rw-r--r--libopie/pim/opimrecord.h1
-rw-r--r--libopie/pim/orecordlist.h139
-rw-r--r--libopie/pim/otodo.cpp52
-rw-r--r--libopie/pim/otodo.h10
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp11
-rw-r--r--libopie2/opiepim/core/opimrecord.h1
-rw-r--r--libopie2/opiepim/orecordlist.h139
-rw-r--r--libopie2/opiepim/otodo.cpp52
-rw-r--r--libopie2/opiepim/otodo.h10
10 files changed, 366 insertions, 60 deletions
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index d8f73c7..e510f4e 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -1,106 +1,111 @@
1#include "opimrecord.h" 1#include "opimrecord.h"
2 2
3OPimRecord::OPimRecord( int uid ) 3OPimRecord::OPimRecord( int uid )
4 : Qtopia::Record() { 4 : Qtopia::Record() {
5 5
6 setUid( uid ); 6 setUid( uid );
7 /* assign a new UID */
8 if ( uid == 1 )
9 assignUid();
10} 7}
11OPimRecord::~OPimRecord() { 8OPimRecord::~OPimRecord() {
12} 9}
13OPimRecord::OPimRecord( const OPimRecord& rec ) 10OPimRecord::OPimRecord( const OPimRecord& rec )
14 : Qtopia::Record( rec ) 11 : Qtopia::Record( rec )
15{ 12{
16 (*this) = rec; 13 (*this) = rec;
17} 14}
18 15
19OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 16OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
20 Qtopia::Record::operator=( rec ); 17 Qtopia::Record::operator=( rec );
21 m_relations = rec.m_relations; 18 m_relations = rec.m_relations;
22 19
23 return *this; 20 return *this;
24} 21}
25QStringList OPimRecord::categoryNames()const { 22QStringList OPimRecord::categoryNames()const {
26 QStringList list; 23 QStringList list;
27 24
28 return list; 25 return list;
29} 26}
30void OPimRecord::setCategoryNames( const QStringList& ) { 27void OPimRecord::setCategoryNames( const QStringList& ) {
31 28
32} 29}
33void OPimRecord::addCategoryName( const QString& ) { 30void OPimRecord::addCategoryName( const QString& ) {
34 31
35} 32}
36bool OPimRecord::isEmpty()const { 33bool OPimRecord::isEmpty()const {
37 return ( uid() == 0 ); 34 return ( uid() == 0 );
38} 35}
39QStringList OPimRecord::relatedApps()const{ 36QStringList OPimRecord::relatedApps()const{
40 QStringList list; 37 QStringList list;
41 QMap<QString, QArray<int> >::ConstIterator it; 38 QMap<QString, QArray<int> >::ConstIterator it;
42 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { 39 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) {
43 list << it.key(); 40 list << it.key();
44 } 41 }
45 return list; 42 return list;
46} 43}
47QArray<int> OPimRecord::relations(const QString& app )const { 44QArray<int> OPimRecord::relations(const QString& app )const {
48 QArray<int> tmp; 45 QArray<int> tmp;
49 QMap<QString, QArray<int> >::ConstIterator it; 46 QMap<QString, QArray<int> >::ConstIterator it;
50 it = m_relations.find( app); 47 it = m_relations.find( app);
51 if ( it != m_relations.end() ) 48 if ( it != m_relations.end() )
52 tmp = it.data(); 49 tmp = it.data();
53 return tmp; 50 return tmp;
54} 51}
55void OPimRecord::clearRelation( const QString& app ) { 52void OPimRecord::clearRelation( const QString& app ) {
56 m_relations.remove( app ); 53 m_relations.remove( app );
57} 54}
58void OPimRecord::addRelation( const QString& app, int id ) { 55void OPimRecord::addRelation( const QString& app, int id ) {
59 56
60 QMap<QString, QArray<int> >::Iterator it; 57 QMap<QString, QArray<int> >::Iterator it;
61 QArray<int> tmp; 58 QArray<int> tmp;
62 59
63 it = m_relations.find( app ); 60 it = m_relations.find( app );
64 if ( it == m_relations.end() ) { 61 if ( it == m_relations.end() ) {
65 tmp.resize(1 ); 62 tmp.resize(1 );
66 tmp[0] = id; 63 tmp[0] = id;
67 }else{ 64 }else{
68 tmp = it.data(); 65 tmp = it.data();
69 tmp.resize( tmp.size() + 1 ); 66 tmp.resize( tmp.size() + 1 );
70 tmp[tmp.size() - 1] = id; 67 tmp[tmp.size() - 1] = id;
71 } 68 }
72 m_relations.replace( app, tmp ); 69 m_relations.replace( app, tmp );
73} 70}
74void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { 71void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
75 72
76 QMap<QString, QArray<int> >::Iterator it; 73 QMap<QString, QArray<int> >::Iterator it;
77 QArray<int> tmp; 74 QArray<int> tmp;
78 75
79 it = m_relations.find( app); 76 it = m_relations.find( app);
80 if ( it == m_relations.end() ) { 77 if ( it == m_relations.end() ) {
81 tmp = ids; 78 tmp = ids;
82 }else{ 79 }else{
83 tmp = it.data(); 80 tmp = it.data();
84 int offset = tmp.size()-1; 81 int offset = tmp.size()-1;
85 tmp.resize( tmp.size() + ids.size() ); 82 tmp.resize( tmp.size() + ids.size() );
86 for (uint i = 0; i < ids.size(); i++ ) { 83 for (uint i = 0; i < ids.size(); i++ ) {
87 tmp[offset+i] = ids[i]; 84 tmp[offset+i] = ids[i];
88 } 85 }
89 86
90 } 87 }
91 m_relations.replace( app, tmp ); 88 m_relations.replace( app, tmp );
92} 89}
93QString OPimRecord::crossToString()const { 90QString OPimRecord::crossToString()const {
94 QString str; 91 QString str;
95 QMap<QString, QArray<int> >::ConstIterator it; 92 QMap<QString, QArray<int> >::ConstIterator it;
96 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 93 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
97 QArray<int> id = it.data(); 94 QArray<int> id = it.data();
98 for ( uint i = 0; i < id.size(); ++i ) { 95 for ( uint i = 0; i < id.size(); ++i ) {
99 str += it.key() + "," + QString::number( i ) + ";"; 96 str += it.key() + "," + QString::number( i ) + ";";
100 } 97 }
101 } 98 }
102 str = str.remove( str.length()-1, 1); // strip the ; 99 str = str.remove( str.length()-1, 1); // strip the ;
103 //qWarning("IDS " + str ); 100 //qWarning("IDS " + str );
104 101
105 return str; 102 return str;
106} 103}
104/* if uid = 1 assign a new one */
105void OPimRecord::setUid( int uid ) {
106
107 if ( uid == 1)
108 uid = uidGen().generate();
109
110 Qtopia::Record::setUid( uid );
111};
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index 18112d4..297ff12 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -1,117 +1,118 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qmap.h> 4#include <qmap.h>
5#include <qstring.h> 5#include <qstring.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8#include <qpe/palmtoprecord.h> 8#include <qpe/palmtoprecord.h>
9 9
10class OPimRecord : public Qtopia::Record { 10class OPimRecord : public Qtopia::Record {
11public: 11public:
12 /** 12 /**
13 * uid of 0 isEmpty 13 * uid of 0 isEmpty
14 * uid of 1 will be assigned a new one 14 * uid of 1 will be assigned a new one
15 */ 15 */
16 OPimRecord(int uid = 0); 16 OPimRecord(int uid = 0);
17 ~OPimRecord(); 17 ~OPimRecord();
18 18
19 /** 19 /**
20 * copy c'tor 20 * copy c'tor
21 */ 21 */
22 OPimRecord( const OPimRecord& rec ); 22 OPimRecord( const OPimRecord& rec );
23 23
24 /** 24 /**
25 * copy operator 25 * copy operator
26 */ 26 */
27 OPimRecord &operator=( const OPimRecord& ); 27 OPimRecord &operator=( const OPimRecord& );
28 28
29 /** 29 /**
30 * category names resolved 30 * category names resolved
31 */ 31 */
32 QStringList categoryNames()const; 32 QStringList categoryNames()const;
33 33
34 /** 34 /**
35 * set category names they will be resolved 35 * set category names they will be resolved
36 */ 36 */
37 void setCategoryNames( const QStringList& ); 37 void setCategoryNames( const QStringList& );
38 38
39 /** 39 /**
40 * addCategoryName adds a name 40 * addCategoryName adds a name
41 * to the internal category list 41 * to the internal category list
42 */ 42 */
43 void addCategoryName( const QString& ); 43 void addCategoryName( const QString& );
44 44
45 /** 45 /**
46 * if a Record isEmpty 46 * if a Record isEmpty
47 */ 47 */
48 virtual bool isEmpty()const; 48 virtual bool isEmpty()const;
49 49
50 /** 50 /**
51 * toRichText summary 51 * toRichText summary
52 */ 52 */
53 virtual QString toRichText()const = 0; 53 virtual QString toRichText()const = 0;
54 54
55 /** 55 /**
56 * a small one line summary 56 * a small one line summary
57 */ 57 */
58 virtual QString toShortText()const = 0; 58 virtual QString toShortText()const = 0;
59 59
60 /** 60 /**
61 * the name of the Record 61 * the name of the Record
62 */ 62 */
63 virtual QString type()const = 0; 63 virtual QString type()const = 0;
64 64
65 /** 65 /**
66 * converts the internal structure to a map 66 * converts the internal structure to a map
67 */ 67 */
68 virtual QMap<int, QString> toMap()const = 0; 68 virtual QMap<int, QString> toMap()const = 0;
69 69
70 /** 70 /**
71 * key value representation of extra items 71 * key value representation of extra items
72 */ 72 */
73 virtual QMap<QString, QString> toExtraMap()const = 0; 73 virtual QMap<QString, QString> toExtraMap()const = 0;
74 74
75 /** 75 /**
76 * the name for a recordField 76 * the name for a recordField
77 */ 77 */
78 virtual QString recordField(int)const = 0; 78 virtual QString recordField(int)const = 0;
79 79
80 /** 80 /**
81 * the related apps names 81 * the related apps names
82 */ 82 */
83 QStringList relatedApps()const; 83 QStringList relatedApps()const;
84 84
85 /** 85 /**
86 * the realtions between an app 86 * the realtions between an app
87 */ 87 */
88 QArray<int> relations( const QString& app )const; 88 QArray<int> relations( const QString& app )const;
89 89
90 /** 90 /**
91 * 91 *
92 */ 92 */
93 void clearRelation( const QString& app ); 93 void clearRelation( const QString& app );
94 94
95 /** 95 /**
96 * 96 *
97 */ 97 */
98 void addRelation( const QString& app, int id ); 98 void addRelation( const QString& app, int id );
99 99
100 /** 100 /**
101 * 101 *
102 */ 102 */
103 void setRelations( const QString&, QArray<int> ids ); 103 void setRelations( const QString&, QArray<int> ids );
104 virtual void setUid( int uid );
104 105
105protected: 106protected:
106 QString crossToString()const; 107 QString crossToString()const;
107 108
108private: 109private:
109 class OPimRecordPrivate; 110 class OPimRecordPrivate;
110 OPimRecordPrivate *d; 111 OPimRecordPrivate *d;
111 QMap<QString, QArray<int> > m_relations; 112 QMap<QString, QArray<int> > m_relations;
112 113
113}; 114};
114 115
115 116
116 117
117#endif 118#endif
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index c17186f..65c2169 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -1,44 +1,159 @@
1 1
2#ifndef OPIE_RECORD_LIST_H 2#ifndef OPIE_RECORD_LIST_H
3#define OPIE_RECORD_LIST_H 3#define OPIE_RECORD_LIST_H
4 4
5#include <opie/opimaccesstemplate.h> 5#include <opie/opimaccesstemplate.h>
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7 7
8template <class T = OPimRecord > 8template <class T = OPimRecord >
9class ORecordList { 9class ORecordList {
10public: 10public:
11 class Iterator { 11 class Iterator {
12 friend class ORecordList; 12 friend class ORecordList;
13 public: 13 public:
14 Iterator() {} 14 Iterator();
15 ~Iterator() {} 15 ~Iterator();
16 Iterator(const Iterator& ) {} 16 Iterator(const Iterator& );
17 Iterator &operator=(const Iterator& ); 17 Iterator &operator=(const Iterator& );
18 T &operator*() {} 18 T &operator*();
19 Iterator &operator++(); 19 Iterator &operator++();
20 Iterator &operator--();
20 21
21 bool operator==( const Iterator& it ); 22 bool operator==( const Iterator& it );
22 bool operator!=( const Iterator& it ); 23 bool operator!=( const Iterator& it );
23 24
24 } 25 private:
25 ORecordList( const QArray<int>& ids, 26 Iterator( const QArray<int>,
26 OPimAccessTemplate<T>* acc ) 27 OPimAccessTemplate<T>* );
27 : m_ids(ids ), m_acc( acc ) {
28 28
29 } 29 QArray<int> m_uids;
30 ~ORecordList() { 30 int m_current;
31 OPimAccessTemplate* m_temp;
32 bool m_end : 1;
33 T m_record;
31 34
32 } 35 /* d pointer for future versions */
36 class IteratorPrivate;
37 IteratorPrivate *d;
38 };
39 ORecordList( const QArray<int>& ids,
40 OPimAccessTemplate<T>* acc );
41 ~ORecordList();
33 Iterator begin(); 42 Iterator begin();
34 Iterator end(); 43 Iterator end();
35 /* 44 /*
36 ConstIterator begin()const; 45 ConstIterator begin()const;
37 ConstIterator end()const; 46 ConstIterator end()const;
38 */ 47 */
39private: 48private:
40 QArray<int> ids; 49 QArray<int> m_ids;
41 OPimAccessTemplate<T>* m_acc; 50 OPimAccessTemplate<T>* m_acc;
42}; 51};
43 52
53/* ok now implement it */
54template <class T= OPimRecord>
55ORecordList<T>::Iterator::Iterator() {
56 m_current = 0;
57 m_temp = 0l;
58 m_end = true;
59}
60template <class T= OPimRecord>
61ORecordList<T>::Iterator::~Iterator() {
62/* nothing to delete */
63}
64
65template <class T = OPimRecord>
66ORecordList<T>::Iterator::Iterator( const ORecordList<T>::Iterator& it) {
67 m_uids = it.m_uids;
68 m_current = it.m_current;
69 m_temp = it.m_temp;
70 m_end = it.m_end;
71 m_record = it.m_record;
72}
73
74template <class T = OPimRecord>
75ORecordList<T>::Iterator &ORecordList::Iterator::operator=( const ORecordList<T>::Iterator& it) {
76 m_uids = it.m_uids;
77 m_current = it.m_current;
78 m_temp = it.m_temp;
79 m_end = it.m_end;
80 m_record = it.m_record;
81
82 return *this;
83}
84
85template <class T = OPimRecord>
86T &ORecordList<T>::Iterator::operator*() {
87 if (!m_end )
88 m_record = m_temp->find( m_uids[m_current] );
89 else
90 m_record = T;
91
92 return m_record;
93}
94
95template <class T = OPimRecord>
96ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator++() {
97 if (m_current < m_uids.count() ) {
98 m_end = false;
99 ++m_current;
100 }else
101 m_end = true;
102
103 return *this;
104}
105template <class T = OPimRecord>
106ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator--() {
107 if ( m_current > 0 ) {
108 --m_current;
109 m_end = false;
110 } else
111 m_end = true;
112
113 return *this;
114}
115
116template <class T = OPimRecord>
117bool ORecordList<T>::Iterator::operator==( const ORecordList<T>::Iterator& it ) {
118
119 /* if both are at we're the same.... */
120 if ( m_end == it.m_end ) return true;
121
122 if ( m_uids != it.m_uids ) return false;
123 if ( m_current != it.m_current ) return false;
124 if ( m_temp != it.m_temp ) return false;
125
126 return true;
127}
128template <class T = ORecordList>
129bool ORecordList<T>::Iterator::operator!=( const ORecordList<T>::Iterator it ) {
130 return !(*this == it );
131}
132template <class T = ORecordList>
133ORecordList<T>::Iterator::Iterator( const QArray<int> uids,
134 OPimAccessTemplate<T>* t )
135 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
136{
137}
138template <class T = ORecordList>
139ORecordList<T>::ORecordList( const QArray<int>& ids,
140 OPimAccessTemplate<T>* acc )
141 : m_ids( ids ), m_acc( acc )
142{
143}
144template <class T = ORecordList>
145ORecordList<T>::~ORecordList() {
146/* nothing to do here */
147}
148template <class T = ORecordList>
149ORecordList<T>::Iterator ORecordList<T>::begin() {
150 Iterator it( m_ids, m_acc );
151 return it;
152}
153template <class T = ORecordList>
154ORecordList<T>::Iterator ORecordList<T>::end() {
155 Iterator it( m_ids, m_acc );
156 it.m_end = true;
157 it.m_current = m_ids.count();
158}
44#endif 159#endif
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 3c93838..8239ba6 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,354 +1,378 @@
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 15
16#include "otodo.h" 16#include "otodo.h"
17 17
18 18
19struct OTodo::OTodoData : public QShared { 19struct OTodo::OTodoData : public QShared {
20 OTodoData() : QShared() { 20 OTodoData() : QShared() {
21 }; 21 };
22 22
23 QDate date; 23 QDate date;
24 bool isCompleted:1; 24 bool isCompleted:1;
25 bool hasDate:1; 25 bool hasDate:1;
26 int priority; 26 int priority;
27 QStringList category;
28 QString desc; 27 QString desc;
29 QString sum; 28 QString sum;
30 QMap<QString, QString> extra; 29 QMap<QString, QString> extra;
31 ushort prog; 30 ushort prog;
32 bool hasAlarmDateTime :1; 31 bool hasAlarmDateTime :1;
33 QDateTime alarmDateTime; 32 QDateTime alarmDateTime;
34}; 33};
35 34
36OTodo::OTodo(const OTodo &event ) 35OTodo::OTodo(const OTodo &event )
37 : OPimRecord( event ), data( event.data ) 36 : OPimRecord( event ), data( event.data )
38{ 37{
39 data->ref(); 38 data->ref();
40 //qWarning("ref up"); 39 //qWarning("ref up");
41} 40}
42OTodo::~OTodo() { 41OTodo::~OTodo() {
43 if ( data->deref() ) { 42 if ( data->deref() ) {
44 //qWarning("OTodo::dereffing"); 43 //qWarning("OTodo::dereffing");
45 delete data; 44 delete data;
46 data = 0l; 45 data = 0l;
47 } 46 }
48} 47}
48OTodo::OTodo(bool completed, int priority,
49 const QArray<int> &category,
50 const QString& summary,
51 const QString &description,
52 ushort progress,
53 bool hasDate, QDate date, int uid )
54 : OPimRecord( uid )
55{
56 //qWarning("OTodoData");
57 setCategories( category );
58 data = new OTodoData;
59 data->date = date;
60 data->isCompleted = completed;
61 data->hasDate = hasDate;
62 data->priority = priority;
63 data->sum = summary;
64 data->prog = progress;
65 data->desc = Qtopia::simplifyMultiLineSpace(description );
66 data->hasAlarmDateTime = false;
49 67
68}
50OTodo::OTodo(bool completed, int priority, 69OTodo::OTodo(bool completed, int priority,
51 const QStringList &category, 70 const QStringList &category,
52 const QString& summary, 71 const QString& summary,
53 const QString &description, 72 const QString &description,
54 ushort progress, 73 ushort progress,
55 bool hasDate, QDate date, int uid ) 74 bool hasDate, QDate date, int uid )
56 : OPimRecord( uid ) 75 : OPimRecord( uid )
57{ 76{
58 //qWarning("OTodoData"); 77 //qWarning("OTodoData");
59 setCategories( idsFromString( category.join(";") ) ); 78 setCategories( idsFromString( category.join(";") ) );
60 data = new OTodoData; 79 data = new OTodoData;
61 data->date = date; 80 data->date = date;
62 data->isCompleted = completed; 81 data->isCompleted = completed;
63 data->hasDate = hasDate; 82 data->hasDate = hasDate;
64 data->priority = priority; 83 data->priority = priority;
65 data->sum = summary; 84 data->sum = summary;
66 data->prog = progress; 85 data->prog = progress;
67 data->desc = Qtopia::simplifyMultiLineSpace(description ); 86 data->desc = Qtopia::simplifyMultiLineSpace(description );
68 data->hasAlarmDateTime = false; 87 data->hasAlarmDateTime = false;
69 88
70} 89}
71bool OTodo::match( const QRegExp &regExp )const 90bool OTodo::match( const QRegExp &regExp )const
72{ 91{
73 if( QString::number( data->priority ).find( regExp ) != -1 ){ 92 if( QString::number( data->priority ).find( regExp ) != -1 ){
74 return true; 93 return true;
75 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 94 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
76 return true; 95 return true;
77 }else if(data->desc.find( regExp ) != -1 ){ 96 }else if(data->desc.find( regExp ) != -1 ){
78 return true; 97 return true;
79 }else if(data->sum.find( regExp ) != -1 ) { 98 }else if(data->sum.find( regExp ) != -1 ) {
80 return true; 99 return true;
81 } 100 }
82 return false; 101 return false;
83} 102}
84bool OTodo::isCompleted() const 103bool OTodo::isCompleted() const
85{ 104{
86 return data->isCompleted; 105 return data->isCompleted;
87} 106}
88bool OTodo::hasDueDate() const 107bool OTodo::hasDueDate() const
89{ 108{
90 return data->hasDate; 109 return data->hasDate;
91} 110}
92bool OTodo::hasAlarmDateTime() const 111bool OTodo::hasAlarmDateTime() const
93{ 112{
94 return data->hasAlarmDateTime; 113 return data->hasAlarmDateTime;
95} 114}
96int OTodo::priority()const 115int OTodo::priority()const
97{ 116{
98 return data->priority; 117 return data->priority;
99} 118}
100QString OTodo::summary() const 119QString OTodo::summary() const
101{ 120{
102 return data->sum; 121 return data->sum;
103} 122}
104ushort OTodo::progress() const 123ushort OTodo::progress() const
105{ 124{
106 return data->prog; 125 return data->prog;
107} 126}
108QDate OTodo::dueDate()const 127QDate OTodo::dueDate()const
109{ 128{
110 return data->date; 129 return data->date;
111} 130}
112 131
113QDateTime OTodo::alarmDateTime() const 132QDateTime OTodo::alarmDateTime() const
114{ 133{
115 return data->alarmDateTime; 134 return data->alarmDateTime;
116} 135}
117 136
118QString OTodo::description()const 137QString OTodo::description()const
119{ 138{
120 return data->desc; 139 return data->desc;
121} 140}
122void OTodo::setCompleted( bool completed ) 141void OTodo::setCompleted( bool completed )
123{ 142{
124 changeOrModify(); 143 changeOrModify();
125 data->isCompleted = completed; 144 data->isCompleted = completed;
126} 145}
127void OTodo::setHasDueDate( bool hasDate ) 146void OTodo::setHasDueDate( bool hasDate )
128{ 147{
129 changeOrModify(); 148 changeOrModify();
130 data->hasDate = hasDate; 149 data->hasDate = hasDate;
131} 150}
132void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) 151void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
133{ 152{
134 changeOrModify(); 153 changeOrModify();
135 data->hasAlarmDateTime = hasAlarmDateTime; 154 data->hasAlarmDateTime = hasAlarmDateTime;
136} 155}
137void OTodo::setDescription(const QString &desc ) 156void OTodo::setDescription(const QString &desc )
138{ 157{
139 changeOrModify(); 158 changeOrModify();
140 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 159 data->desc = Qtopia::simplifyMultiLineSpace(desc );
141} 160}
142void OTodo::setSummary( const QString& sum ) 161void OTodo::setSummary( const QString& sum )
143{ 162{
144 changeOrModify(); 163 changeOrModify();
145 data->sum = sum; 164 data->sum = sum;
146} 165}
147void OTodo::setPriority(int prio ) 166void OTodo::setPriority(int prio )
148{ 167{
149 changeOrModify(); 168 changeOrModify();
150 data->priority = prio; 169 data->priority = prio;
151} 170}
152void OTodo::setDueDate( QDate date ) 171void OTodo::setDueDate( QDate date )
153{ 172{
154 changeOrModify(); 173 changeOrModify();
155 data->date = date; 174 data->date = date;
156} 175}
157void OTodo::setAlarmDateTime( const QDateTime& alarm ) 176void OTodo::setAlarmDateTime( const QDateTime& alarm )
158{ 177{
159 changeOrModify(); 178 changeOrModify();
160 data->alarmDateTime = alarm; 179 data->alarmDateTime = alarm;
161} 180}
162bool OTodo::isOverdue( ) 181bool OTodo::isOverdue( )
163{ 182{
164 if( data->hasDate ) 183 if( data->hasDate )
165 return QDate::currentDate() > data->date; 184 return QDate::currentDate() > data->date;
166 return false; 185 return false;
167} 186}
168void OTodo::setProgress(ushort progress ) 187void OTodo::setProgress(ushort progress )
169{ 188{
170 changeOrModify(); 189 changeOrModify();
171 data->prog = progress; 190 data->prog = progress;
172} 191}
173QString OTodo::toShortText() const { 192QString OTodo::toShortText() const {
174 return summary(); 193 return summary();
175} 194}
176/*! 195/*!
177 Returns a richt text string 196 Returns a richt text string
178*/ 197*/
179QString OTodo::toRichText() const 198QString OTodo::toRichText() const
180{ 199{
181 QString text; 200 QString text;
182 QStringList catlist; 201 QStringList catlist;
183 202
184 // Description of the todo 203 // Description of the todo
185 if ( !summary().isEmpty() ) { 204 if ( !summary().isEmpty() ) {
186 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 205 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
187 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 206 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
188 } 207 }
189 if( !description().isEmpty() ){ 208 if( !description().isEmpty() ){
190 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 209 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
191 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 210 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
192 } 211 }
193 text += "<br><br><br>"; 212 text += "<br><br><br>";
194 213
195 text += "<b>" + QObject::tr( "Priority:") +" </b>" 214 text += "<b>" + QObject::tr( "Priority:") +" </b>"
196 + QString::number( priority() ) + " <br>"; 215 + QString::number( priority() ) + " <br>";
197 text += "<b>" + QObject::tr( "Progress:") + " </b>" 216 text += "<b>" + QObject::tr( "Progress:") + " </b>"
198 + QString::number( progress() ) + " %<br>"; 217 + QString::number( progress() ) + " %<br>";
199 if (hasDueDate() ){ 218 if (hasDueDate() ){
200 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 219 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
201 text += dueDate().toString(); 220 text += dueDate().toString();
202 text += "<br>"; 221 text += "<br>";
203 } 222 }
204 if (hasAlarmDateTime() ){ 223 if (hasAlarmDateTime() ){
205 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; 224 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
206 text += alarmDateTime().toString(); 225 text += alarmDateTime().toString();
207 text += "<br>"; 226 text += "<br>";
208 } 227 }
209 228
210 text += "<b>" + QObject::tr( "Category:") + "</b> "; 229 text += "<b>" + QObject::tr( "Category:") + "</b> ";
211 text += categoryNames().join(", "); 230 text += categoryNames().join(", ");
212 text += "<br>"; 231 text += "<br>";
213 232
214 return text; 233 return text;
215} 234}
216 235
217bool OTodo::operator<( const OTodo &toDoEvent )const{ 236bool OTodo::operator<( const OTodo &toDoEvent )const{
218 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 237 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
219 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 238 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
220 if( hasDueDate() && toDoEvent.hasDueDate() ){ 239 if( hasDueDate() && toDoEvent.hasDueDate() ){
221 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 240 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
222 return priority() < toDoEvent.priority(); 241 return priority() < toDoEvent.priority();
223 }else{ 242 }else{
224 return dueDate() < toDoEvent.dueDate(); 243 return dueDate() < toDoEvent.dueDate();
225 } 244 }
226 } 245 }
227 return false; 246 return false;
228} 247}
229bool OTodo::operator<=(const OTodo &toDoEvent )const 248bool OTodo::operator<=(const OTodo &toDoEvent )const
230{ 249{
231 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 250 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
232 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 251 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
233 if( hasDueDate() && toDoEvent.hasDueDate() ){ 252 if( hasDueDate() && toDoEvent.hasDueDate() ){
234 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 253 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
235 return priority() <= toDoEvent.priority(); 254 return priority() <= toDoEvent.priority();
236 }else{ 255 }else{
237 return dueDate() <= toDoEvent.dueDate(); 256 return dueDate() <= toDoEvent.dueDate();
238 } 257 }
239 } 258 }
240 return true; 259 return true;
241} 260}
242bool OTodo::operator>(const OTodo &toDoEvent )const 261bool OTodo::operator>(const OTodo &toDoEvent )const
243{ 262{
244 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 263 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
245 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 264 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
246 if( hasDueDate() && toDoEvent.hasDueDate() ){ 265 if( hasDueDate() && toDoEvent.hasDueDate() ){
247 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 266 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
248 return priority() > toDoEvent.priority(); 267 return priority() > toDoEvent.priority();
249 }else{ 268 }else{
250 return dueDate() > toDoEvent.dueDate(); 269 return dueDate() > toDoEvent.dueDate();
251 } 270 }
252 } 271 }
253 return false; 272 return false;
254} 273}
255bool OTodo::operator>=(const OTodo &toDoEvent )const 274bool OTodo::operator>=(const OTodo &toDoEvent )const
256{ 275{
257 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 276 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
258 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 277 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
259 if( hasDueDate() && toDoEvent.hasDueDate() ){ 278 if( hasDueDate() && toDoEvent.hasDueDate() ){
260 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 279 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
261 return priority() > toDoEvent.priority(); 280 return priority() > toDoEvent.priority();
262 }else{ 281 }else{
263 return dueDate() > toDoEvent.dueDate(); 282 return dueDate() > toDoEvent.dueDate();
264 } 283 }
265 } 284 }
266 return true; 285 return true;
267} 286}
268bool OTodo::operator==(const OTodo &toDoEvent )const 287bool OTodo::operator==(const OTodo &toDoEvent )const
269{ 288{
270 if( data->priority == toDoEvent.data->priority && 289 if ( data->priority != toDoEvent.data->priority ) return false;
271 data->priority == toDoEvent.data->prog && 290 if ( data->priority != toDoEvent.data->prog ) return false;
272 data->isCompleted == toDoEvent.data->isCompleted && 291 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
273 data->hasDate == toDoEvent.data->hasDate && 292 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
274 data->date == toDoEvent.data->date && 293 if ( data->date != toDoEvent.data->date ) return false;
275 data->category == toDoEvent.data->category && 294 if ( data->sum != toDoEvent.data->sum ) return false;
276 data->sum == toDoEvent.data->sum && 295 if ( data->desc != toDoEvent.data->desc ) return false;
277 data->desc == toDoEvent.data->desc && 296 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
278 data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && 297 return false;
279 data->alarmDateTime == toDoEvent.data->alarmDateTime ) 298 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
280 return true; 299 return false;
281 300
282 return false; 301 return OPimRecord::operator==( toDoEvent );
283} 302}
284void OTodo::deref() { 303void OTodo::deref() {
285 304
286 //qWarning("deref in ToDoEvent"); 305 //qWarning("deref in ToDoEvent");
287 if ( data->deref() ) { 306 if ( data->deref() ) {
288 //qWarning("deleting"); 307 //qWarning("deleting");
289 delete data; 308 delete data;
290 d= 0; 309 d= 0;
291 } 310 }
292} 311}
293OTodo &OTodo::operator=(const OTodo &item ) 312OTodo &OTodo::operator=(const OTodo &item )
294{ 313{
295 OPimRecord::operator=( item ); 314 OPimRecord::operator=( item );
296 //qWarning("operator= ref "); 315 //qWarning("operator= ref ");
297 item.data->ref(); 316 item.data->ref();
298 deref(); 317 deref();
299 318
300 return *this; 319 return *this;
301} 320}
302 321
303QMap<int, QString> OTodo::toMap() const { 322QMap<int, QString> OTodo::toMap() const {
304 QMap<int, QString> map; 323 QMap<int, QString> map;
305 324
306 map.insert( Uid, QString::number( uid() ) ); 325 map.insert( Uid, QString::number( uid() ) );
307 map.insert( Category, idsToString( categories() ) ); 326 map.insert( Category, idsToString( categories() ) );
308 map.insert( HasDate, QString::number( data->hasDate ) ); 327 map.insert( HasDate, QString::number( data->hasDate ) );
309 map.insert( Completed, QString::number( data->isCompleted ) ); 328 map.insert( Completed, QString::number( data->isCompleted ) );
310 map.insert( Description, data->desc ); 329 map.insert( Description, data->desc );
311 map.insert( Summary, data->sum ); 330 map.insert( Summary, data->sum );
312 map.insert( Priority, QString::number( data->priority ) ); 331 map.insert( Priority, QString::number( data->priority ) );
313 map.insert( DateDay, QString::number( data->date.day() ) ); 332 map.insert( DateDay, QString::number( data->date.day() ) );
314 map.insert( DateMonth, QString::number( data->date.month() ) ); 333 map.insert( DateMonth, QString::number( data->date.month() ) );
315 map.insert( DateYear, QString::number( data->date.year() ) ); 334 map.insert( DateYear, QString::number( data->date.year() ) );
316 map.insert( Progress, QString::number( data->prog ) ); 335 map.insert( Progress, QString::number( data->prog ) );
317 map.insert( CrossReference, crossToString() ); 336 map.insert( CrossReference, crossToString() );
318 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 337 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
319 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 338 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
320 339
321 return map; 340 return map;
322} 341}
323 342
324QMap<QString, QString> OTodo::toExtraMap()const { 343QMap<QString, QString> OTodo::toExtraMap()const {
325 return data->extra; 344 return data->extra;
326} 345}
327/** 346/**
328 * change or modify looks at the ref count and either 347 * change or modify looks at the ref count and either
329 * creates a new QShared Object or it can modify it 348 * creates a new QShared Object or it can modify it
330 * right in place 349 * right in place
331 */ 350 */
332void OTodo::changeOrModify() { 351void OTodo::changeOrModify() {
333 if ( data->count != 1 ) { 352 if ( data->count != 1 ) {
334 //qWarning("changeOrModify"); 353 //qWarning("changeOrModify");
335 data->deref(); 354 data->deref();
336 OTodoData* d2 = new OTodoData(); 355 OTodoData* d2 = new OTodoData();
337 copy(data, d2 ); 356 copy(data, d2 );
338 data = d2; 357 data = d2;
339 } 358 }
340} 359}
341void OTodo::copy( OTodoData* src, OTodoData* dest ) { 360void OTodo::copy( OTodoData* src, OTodoData* dest ) {
342 dest->date = src->date; 361 dest->date = src->date;
343 dest->isCompleted = src->isCompleted; 362 dest->isCompleted = src->isCompleted;
344 dest->hasDate = src->hasDate; 363 dest->hasDate = src->hasDate;
345 dest->priority = src->priority; 364 dest->priority = src->priority;
346 dest->desc = src->desc; 365 dest->desc = src->desc;
347 dest->sum = src->sum; 366 dest->sum = src->sum;
348 dest->extra = src->extra; 367 dest->extra = src->extra;
349 dest->prog = src->prog; 368 dest->prog = src->prog;
350 dest->hasAlarmDateTime = src->hasAlarmDateTime; 369 dest->hasAlarmDateTime = src->hasAlarmDateTime;
351 dest->alarmDateTime = src->alarmDateTime; 370 dest->alarmDateTime = src->alarmDateTime;
352} 371}
353 372QString OTodo::type() const {
373 return QString::fromLatin1("OTodo");
374}
375QString OTodo::recordField(int id )const {
376 return QString::null;
377}
354 378
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index e1729db..75af44c 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -1,211 +1,219 @@
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
19class OTodo : public OPimRecord { 19class OTodo : public OPimRecord {
20public: 20public:
21 typedef QValueList<OTodo> ValueList; 21 typedef QValueList<OTodo> ValueList;
22 enum RecordFields { 22 enum RecordFields {
23 Uid = Qtopia::UID_ID, 23 Uid = Qtopia::UID_ID,
24 Category = Qtopia::CATEGORY_ID, 24 Category = Qtopia::CATEGORY_ID,
25 HasDate, 25 HasDate,
26 Completed, 26 Completed,
27 Description, 27 Description,
28 Summary, 28 Summary,
29 Priority, 29 Priority,
30 DateDay, 30 DateDay,
31 DateMonth, 31 DateMonth,
32 DateYear, 32 DateYear,
33 Progress, 33 Progress,
34 CrossReference, 34 CrossReference,
35 HasAlarmDateTime, 35 HasAlarmDateTime,
36 AlarmDateTime 36 AlarmDateTime
37 }; 37 };
38 public: 38 public:
39 // priorities from Very low to very high 39 // priorities from Very low to very high
40 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; 40 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
41 41
42 /* Constructs a new ToDoEvent 42 /* Constructs a new ToDoEvent
43 @param completed Is the TodoEvent completed 43 @param completed Is the TodoEvent completed
44 @param priority What is the priority of this ToDoEvent 44 @param priority What is the priority of this ToDoEvent
45 @param category Which category does it belong( uid ) 45 @param category Which category does it belong( uid )
46 @param summary A small summary of the todo 46 @param summary A small summary of the todo
47 @param description What is this ToDoEvent about 47 @param description What is this ToDoEvent about
48 @param hasDate Does this Event got a deadline 48 @param hasDate Does this Event got a deadline
49 @param date what is the deadline? 49 @param date what is the deadline?
50 @param uid what is the UUID of this Event 50 @param uid what is the UUID of this Event
51 **/ 51 **/
52 OTodo( bool completed = false, int priority = Normal, 52 OTodo( bool completed = false, int priority = Normal,
53 const QStringList &category = QStringList(), 53 const QStringList &category = QStringList(),
54 const QString &summary = QString::null , 54 const QString &summary = QString::null ,
55 const QString &description = QString::null, 55 const QString &description = QString::null,
56 ushort progress = 0, 56 ushort progress = 0,
57 bool hasDate = false, QDate date = QDate::currentDate(), 57 bool hasDate = false, QDate date = QDate::currentDate(),
58 int uid = -1 ); 58 int uid = 0 /*empty*/ );
59
60 OTodo( bool completed, int priority,
61 const QArray<int>& category,
62 const QString& summary = QString::null,
63 const QString& description = QString::null,
64 ushort progress = 0,
65 bool hasDate = false, QDate date = QDate::currentDate(),
66 int uid = 0 /* empty */ );
59 67
60 /* Copy c'tor 68 /* Copy c'tor
61 69
62 **/ 70 **/
63 OTodo(const OTodo & ); 71 OTodo(const OTodo & );
64 72
65 /** 73 /**
66 *destructor 74 *destructor
67 */ 75 */
68 ~OTodo(); 76 ~OTodo();
69 77
70 /** 78 /**
71 * Is this event completed? 79 * Is this event completed?
72 */ 80 */
73 bool isCompleted() const; 81 bool isCompleted() const;
74 82
75 /** 83 /**
76 * Does this Event have a deadline 84 * Does this Event have a deadline
77 */ 85 */
78 bool hasDueDate() const; 86 bool hasDueDate() const;
79 87
80 /** 88 /**
81 * Does this Event has an alarm time ? 89 * Does this Event has an alarm time ?
82 */ 90 */
83 bool hasAlarmDateTime() const; 91 bool hasAlarmDateTime() const;
84 92
85 /** 93 /**
86 * What is the priority? 94 * What is the priority?
87 */ 95 */
88 int priority()const ; 96 int priority()const ;
89 97
90 /** 98 /**
91 * progress as ushort 0, 20, 40, 60, 80 or 100% 99 * progress as ushort 0, 20, 40, 60, 80 or 100%
92 */ 100 */
93 ushort progress() const; 101 ushort progress() const;
94 102
95 /** 103 /**
96 * The due Date 104 * The due Date
97 */ 105 */
98 QDate dueDate()const; 106 QDate dueDate()const;
99 107
100 /** 108 /**
101 * Alarm Date and Time 109 * Alarm Date and Time
102 */ 110 */
103 QDateTime alarmDateTime()const; 111 QDateTime alarmDateTime()const;
104 112
105 /** 113 /**
106 * The description of the todo 114 * The description of the todo
107 */ 115 */
108 QString description()const; 116 QString description()const;
109 117
110 /** 118 /**
111 * A small summary of the todo 119 * A small summary of the todo
112 */ 120 */
113 QString summary() const; 121 QString summary() const;
114 122
115 /** 123 /**
116 * @reimplemented 124 * @reimplemented
117 * Return this todoevent in a RichText formatted QString 125 * Return this todoevent in a RichText formatted QString
118 */ 126 */
119 QString toRichText() const; 127 QString toRichText() const;
120 128
121 /** 129 /**
122 * reimplementation 130 * reimplementation
123 */ 131 */
124 QString type()const; 132 QString type()const;
125 QString toShortText()const; 133 QString toShortText()const;
126 QMap<QString, QString> toExtraMap()const; 134 QMap<QString, QString> toExtraMap()const;
127 QString recordField(int id )const; 135 QString recordField(int id )const;
128 136
129 /** 137 /**
130 * returns a list of apps which have related items 138 * returns a list of apps which have related items
131 */ 139 */
132 QStringList relatedApps()const; 140 QStringList relatedApps()const;
133 141
134 /** 142 /**
135 * returns all relations for one app 143 * returns all relations for one app
136 */ 144 */
137 QArray<int> relations( const QString& app )const; 145 QArray<int> relations( const QString& app )const;
138 146
139 /** 147 /**
140 * toMap puts all data into the map. int relates 148 * toMap puts all data into the map. int relates
141 * to ToDoEvent RecordFields enum 149 * to ToDoEvent RecordFields enum
142 */ 150 */
143 QMap<int, QString> toMap()const; 151 QMap<int, QString> toMap()const;
144 152
145 /** 153 /**
146 * Set if this Todo is completed 154 * Set if this Todo is completed
147 */ 155 */
148 void setCompleted(bool completed ); 156 void setCompleted(bool completed );
149 157
150 /** 158 /**
151 * set if this todo got an end data 159 * set if this todo got an end data
152 */ 160 */
153 void setHasDueDate( bool hasDate ); 161 void setHasDueDate( bool hasDate );
154 162
155 /** 163 /**
156 * set if this todo has an alarm time and date 164 * set if this todo has an alarm time and date
157 */ 165 */
158 void setHasAlarmDateTime ( bool hasAlarm ); 166 void setHasAlarmDateTime ( bool hasAlarm );
159 167
160 /** 168 /**
161 * Set the priority of the Todo 169 * Set the priority of the Todo
162 */ 170 */
163 void setPriority(int priority ); 171 void setPriority(int priority );
164 172
165 /** 173 /**
166 * Set the progress. 174 * Set the progress.
167 */ 175 */
168 void setProgress( ushort progress ); 176 void setProgress( ushort progress );
169 177
170 /** 178 /**
171 * set the end date 179 * set the end date
172 */ 180 */
173 void setDueDate( QDate date ); 181 void setDueDate( QDate date );
174 182
175 /** 183 /**
176 * set the alarm time 184 * set the alarm time
177 */ 185 */
178 void setAlarmDateTime ( const QDateTime& alarm ); 186 void setAlarmDateTime ( const QDateTime& alarm );
179 187
180 void setDescription(const QString& ); 188 void setDescription(const QString& );
181 void setSummary(const QString& ); 189 void setSummary(const QString& );
182 bool isOverdue(); 190 bool isOverdue();
183 191
184 192
185 bool match( const QRegExp &r )const; 193 bool match( const QRegExp &r )const;
186 194
187 bool operator<(const OTodo &toDoEvent )const; 195 bool operator<(const OTodo &toDoEvent )const;
188 bool operator<=(const OTodo &toDoEvent )const; 196 bool operator<=(const OTodo &toDoEvent )const;
189 bool operator!=(const OTodo &toDoEvent )const; 197 bool operator!=(const OTodo &toDoEvent )const;
190 bool operator>(const OTodo &toDoEvent )const; 198 bool operator>(const OTodo &toDoEvent )const;
191 bool operator>=(const OTodo &toDoEvent)const; 199 bool operator>=(const OTodo &toDoEvent)const;
192 bool operator==(const OTodo &toDoEvent )const; 200 bool operator==(const OTodo &toDoEvent )const;
193 OTodo &operator=(const OTodo &toDoEvent ); 201 OTodo &operator=(const OTodo &toDoEvent );
194 202
195 private: 203 private:
196 class OTodoPrivate; 204 class OTodoPrivate;
197 struct OTodoData; 205 struct OTodoData;
198 206
199 void deref(); 207 void deref();
200 void changeOrModify(); 208 void changeOrModify();
201 void copy( OTodoData* src, OTodoData* dest ); 209 void copy( OTodoData* src, OTodoData* dest );
202 OTodoPrivate *d; 210 OTodoPrivate *d;
203 OTodoData *data; 211 OTodoData *data;
204 212
205}; 213};
206inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 214inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
207 return !(*this == toDoEvent); 215 return !(*this == toDoEvent);
208} 216}
209 217
210 218
211#endif 219#endif
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index d8f73c7..e510f4e 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -1,106 +1,111 @@
1#include "opimrecord.h" 1#include "opimrecord.h"
2 2
3OPimRecord::OPimRecord( int uid ) 3OPimRecord::OPimRecord( int uid )
4 : Qtopia::Record() { 4 : Qtopia::Record() {
5 5
6 setUid( uid ); 6 setUid( uid );
7 /* assign a new UID */
8 if ( uid == 1 )
9 assignUid();
10} 7}
11OPimRecord::~OPimRecord() { 8OPimRecord::~OPimRecord() {
12} 9}
13OPimRecord::OPimRecord( const OPimRecord& rec ) 10OPimRecord::OPimRecord( const OPimRecord& rec )
14 : Qtopia::Record( rec ) 11 : Qtopia::Record( rec )
15{ 12{
16 (*this) = rec; 13 (*this) = rec;
17} 14}
18 15
19OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 16OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
20 Qtopia::Record::operator=( rec ); 17 Qtopia::Record::operator=( rec );
21 m_relations = rec.m_relations; 18 m_relations = rec.m_relations;
22 19
23 return *this; 20 return *this;
24} 21}
25QStringList OPimRecord::categoryNames()const { 22QStringList OPimRecord::categoryNames()const {
26 QStringList list; 23 QStringList list;
27 24
28 return list; 25 return list;
29} 26}
30void OPimRecord::setCategoryNames( const QStringList& ) { 27void OPimRecord::setCategoryNames( const QStringList& ) {
31 28
32} 29}
33void OPimRecord::addCategoryName( const QString& ) { 30void OPimRecord::addCategoryName( const QString& ) {
34 31
35} 32}
36bool OPimRecord::isEmpty()const { 33bool OPimRecord::isEmpty()const {
37 return ( uid() == 0 ); 34 return ( uid() == 0 );
38} 35}
39QStringList OPimRecord::relatedApps()const{ 36QStringList OPimRecord::relatedApps()const{
40 QStringList list; 37 QStringList list;
41 QMap<QString, QArray<int> >::ConstIterator it; 38 QMap<QString, QArray<int> >::ConstIterator it;
42 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { 39 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) {
43 list << it.key(); 40 list << it.key();
44 } 41 }
45 return list; 42 return list;
46} 43}
47QArray<int> OPimRecord::relations(const QString& app )const { 44QArray<int> OPimRecord::relations(const QString& app )const {
48 QArray<int> tmp; 45 QArray<int> tmp;
49 QMap<QString, QArray<int> >::ConstIterator it; 46 QMap<QString, QArray<int> >::ConstIterator it;
50 it = m_relations.find( app); 47 it = m_relations.find( app);
51 if ( it != m_relations.end() ) 48 if ( it != m_relations.end() )
52 tmp = it.data(); 49 tmp = it.data();
53 return tmp; 50 return tmp;
54} 51}
55void OPimRecord::clearRelation( const QString& app ) { 52void OPimRecord::clearRelation( const QString& app ) {
56 m_relations.remove( app ); 53 m_relations.remove( app );
57} 54}
58void OPimRecord::addRelation( const QString& app, int id ) { 55void OPimRecord::addRelation( const QString& app, int id ) {
59 56
60 QMap<QString, QArray<int> >::Iterator it; 57 QMap<QString, QArray<int> >::Iterator it;
61 QArray<int> tmp; 58 QArray<int> tmp;
62 59
63 it = m_relations.find( app ); 60 it = m_relations.find( app );
64 if ( it == m_relations.end() ) { 61 if ( it == m_relations.end() ) {
65 tmp.resize(1 ); 62 tmp.resize(1 );
66 tmp[0] = id; 63 tmp[0] = id;
67 }else{ 64 }else{
68 tmp = it.data(); 65 tmp = it.data();
69 tmp.resize( tmp.size() + 1 ); 66 tmp.resize( tmp.size() + 1 );
70 tmp[tmp.size() - 1] = id; 67 tmp[tmp.size() - 1] = id;
71 } 68 }
72 m_relations.replace( app, tmp ); 69 m_relations.replace( app, tmp );
73} 70}
74void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { 71void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
75 72
76 QMap<QString, QArray<int> >::Iterator it; 73 QMap<QString, QArray<int> >::Iterator it;
77 QArray<int> tmp; 74 QArray<int> tmp;
78 75
79 it = m_relations.find( app); 76 it = m_relations.find( app);
80 if ( it == m_relations.end() ) { 77 if ( it == m_relations.end() ) {
81 tmp = ids; 78 tmp = ids;
82 }else{ 79 }else{
83 tmp = it.data(); 80 tmp = it.data();
84 int offset = tmp.size()-1; 81 int offset = tmp.size()-1;
85 tmp.resize( tmp.size() + ids.size() ); 82 tmp.resize( tmp.size() + ids.size() );
86 for (uint i = 0; i < ids.size(); i++ ) { 83 for (uint i = 0; i < ids.size(); i++ ) {
87 tmp[offset+i] = ids[i]; 84 tmp[offset+i] = ids[i];
88 } 85 }
89 86
90 } 87 }
91 m_relations.replace( app, tmp ); 88 m_relations.replace( app, tmp );
92} 89}
93QString OPimRecord::crossToString()const { 90QString OPimRecord::crossToString()const {
94 QString str; 91 QString str;
95 QMap<QString, QArray<int> >::ConstIterator it; 92 QMap<QString, QArray<int> >::ConstIterator it;
96 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 93 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
97 QArray<int> id = it.data(); 94 QArray<int> id = it.data();
98 for ( uint i = 0; i < id.size(); ++i ) { 95 for ( uint i = 0; i < id.size(); ++i ) {
99 str += it.key() + "," + QString::number( i ) + ";"; 96 str += it.key() + "," + QString::number( i ) + ";";
100 } 97 }
101 } 98 }
102 str = str.remove( str.length()-1, 1); // strip the ; 99 str = str.remove( str.length()-1, 1); // strip the ;
103 //qWarning("IDS " + str ); 100 //qWarning("IDS " + str );
104 101
105 return str; 102 return str;
106} 103}
104/* if uid = 1 assign a new one */
105void OPimRecord::setUid( int uid ) {
106
107 if ( uid == 1)
108 uid = uidGen().generate();
109
110 Qtopia::Record::setUid( uid );
111};
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index 18112d4..297ff12 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -1,117 +1,118 @@
1#ifndef OPIE_PIM_RECORD_H 1#ifndef OPIE_PIM_RECORD_H
2#define OPIE_PIM_RECORD_H 2#define OPIE_PIM_RECORD_H
3 3
4#include <qmap.h> 4#include <qmap.h>
5#include <qstring.h> 5#include <qstring.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8#include <qpe/palmtoprecord.h> 8#include <qpe/palmtoprecord.h>
9 9
10class OPimRecord : public Qtopia::Record { 10class OPimRecord : public Qtopia::Record {
11public: 11public:
12 /** 12 /**
13 * uid of 0 isEmpty 13 * uid of 0 isEmpty
14 * uid of 1 will be assigned a new one 14 * uid of 1 will be assigned a new one
15 */ 15 */
16 OPimRecord(int uid = 0); 16 OPimRecord(int uid = 0);
17 ~OPimRecord(); 17 ~OPimRecord();
18 18
19 /** 19 /**
20 * copy c'tor 20 * copy c'tor
21 */ 21 */
22 OPimRecord( const OPimRecord& rec ); 22 OPimRecord( const OPimRecord& rec );
23 23
24 /** 24 /**
25 * copy operator 25 * copy operator
26 */ 26 */
27 OPimRecord &operator=( const OPimRecord& ); 27 OPimRecord &operator=( const OPimRecord& );
28 28
29 /** 29 /**
30 * category names resolved 30 * category names resolved
31 */ 31 */
32 QStringList categoryNames()const; 32 QStringList categoryNames()const;
33 33
34 /** 34 /**
35 * set category names they will be resolved 35 * set category names they will be resolved
36 */ 36 */
37 void setCategoryNames( const QStringList& ); 37 void setCategoryNames( const QStringList& );
38 38
39 /** 39 /**
40 * addCategoryName adds a name 40 * addCategoryName adds a name
41 * to the internal category list 41 * to the internal category list
42 */ 42 */
43 void addCategoryName( const QString& ); 43 void addCategoryName( const QString& );
44 44
45 /** 45 /**
46 * if a Record isEmpty 46 * if a Record isEmpty
47 */ 47 */
48 virtual bool isEmpty()const; 48 virtual bool isEmpty()const;
49 49
50 /** 50 /**
51 * toRichText summary 51 * toRichText summary
52 */ 52 */
53 virtual QString toRichText()const = 0; 53 virtual QString toRichText()const = 0;
54 54
55 /** 55 /**
56 * a small one line summary 56 * a small one line summary
57 */ 57 */
58 virtual QString toShortText()const = 0; 58 virtual QString toShortText()const = 0;
59 59
60 /** 60 /**
61 * the name of the Record 61 * the name of the Record
62 */ 62 */
63 virtual QString type()const = 0; 63 virtual QString type()const = 0;
64 64
65 /** 65 /**
66 * converts the internal structure to a map 66 * converts the internal structure to a map
67 */ 67 */
68 virtual QMap<int, QString> toMap()const = 0; 68 virtual QMap<int, QString> toMap()const = 0;
69 69
70 /** 70 /**
71 * key value representation of extra items 71 * key value representation of extra items
72 */ 72 */
73 virtual QMap<QString, QString> toExtraMap()const = 0; 73 virtual QMap<QString, QString> toExtraMap()const = 0;
74 74
75 /** 75 /**
76 * the name for a recordField 76 * the name for a recordField
77 */ 77 */
78 virtual QString recordField(int)const = 0; 78 virtual QString recordField(int)const = 0;
79 79
80 /** 80 /**
81 * the related apps names 81 * the related apps names
82 */ 82 */
83 QStringList relatedApps()const; 83 QStringList relatedApps()const;
84 84
85 /** 85 /**
86 * the realtions between an app 86 * the realtions between an app
87 */ 87 */
88 QArray<int> relations( const QString& app )const; 88 QArray<int> relations( const QString& app )const;
89 89
90 /** 90 /**
91 * 91 *
92 */ 92 */
93 void clearRelation( const QString& app ); 93 void clearRelation( const QString& app );
94 94
95 /** 95 /**
96 * 96 *
97 */ 97 */
98 void addRelation( const QString& app, int id ); 98 void addRelation( const QString& app, int id );
99 99
100 /** 100 /**
101 * 101 *
102 */ 102 */
103 void setRelations( const QString&, QArray<int> ids ); 103 void setRelations( const QString&, QArray<int> ids );
104 virtual void setUid( int uid );
104 105
105protected: 106protected:
106 QString crossToString()const; 107 QString crossToString()const;
107 108
108private: 109private:
109 class OPimRecordPrivate; 110 class OPimRecordPrivate;
110 OPimRecordPrivate *d; 111 OPimRecordPrivate *d;
111 QMap<QString, QArray<int> > m_relations; 112 QMap<QString, QArray<int> > m_relations;
112 113
113}; 114};
114 115
115 116
116 117
117#endif 118#endif
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index c17186f..65c2169 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -1,44 +1,159 @@
1 1
2#ifndef OPIE_RECORD_LIST_H 2#ifndef OPIE_RECORD_LIST_H
3#define OPIE_RECORD_LIST_H 3#define OPIE_RECORD_LIST_H
4 4
5#include <opie/opimaccesstemplate.h> 5#include <opie/opimaccesstemplate.h>
6#include <opie/opimrecord.h> 6#include <opie/opimrecord.h>
7 7
8template <class T = OPimRecord > 8template <class T = OPimRecord >
9class ORecordList { 9class ORecordList {
10public: 10public:
11 class Iterator { 11 class Iterator {
12 friend class ORecordList; 12 friend class ORecordList;
13 public: 13 public:
14 Iterator() {} 14 Iterator();
15 ~Iterator() {} 15 ~Iterator();
16 Iterator(const Iterator& ) {} 16 Iterator(const Iterator& );
17 Iterator &operator=(const Iterator& ); 17 Iterator &operator=(const Iterator& );
18 T &operator*() {} 18 T &operator*();
19 Iterator &operator++(); 19 Iterator &operator++();
20 Iterator &operator--();
20 21
21 bool operator==( const Iterator& it ); 22 bool operator==( const Iterator& it );
22 bool operator!=( const Iterator& it ); 23 bool operator!=( const Iterator& it );
23 24
24 } 25 private:
25 ORecordList( const QArray<int>& ids, 26 Iterator( const QArray<int>,
26 OPimAccessTemplate<T>* acc ) 27 OPimAccessTemplate<T>* );
27 : m_ids(ids ), m_acc( acc ) {
28 28
29 } 29 QArray<int> m_uids;
30 ~ORecordList() { 30 int m_current;
31 OPimAccessTemplate* m_temp;
32 bool m_end : 1;
33 T m_record;
31 34
32 } 35 /* d pointer for future versions */
36 class IteratorPrivate;
37 IteratorPrivate *d;
38 };
39 ORecordList( const QArray<int>& ids,
40 OPimAccessTemplate<T>* acc );
41 ~ORecordList();
33 Iterator begin(); 42 Iterator begin();
34 Iterator end(); 43 Iterator end();
35 /* 44 /*
36 ConstIterator begin()const; 45 ConstIterator begin()const;
37 ConstIterator end()const; 46 ConstIterator end()const;
38 */ 47 */
39private: 48private:
40 QArray<int> ids; 49 QArray<int> m_ids;
41 OPimAccessTemplate<T>* m_acc; 50 OPimAccessTemplate<T>* m_acc;
42}; 51};
43 52
53/* ok now implement it */
54template <class T= OPimRecord>
55ORecordList<T>::Iterator::Iterator() {
56 m_current = 0;
57 m_temp = 0l;
58 m_end = true;
59}
60template <class T= OPimRecord>
61ORecordList<T>::Iterator::~Iterator() {
62/* nothing to delete */
63}
64
65template <class T = OPimRecord>
66ORecordList<T>::Iterator::Iterator( const ORecordList<T>::Iterator& it) {
67 m_uids = it.m_uids;
68 m_current = it.m_current;
69 m_temp = it.m_temp;
70 m_end = it.m_end;
71 m_record = it.m_record;
72}
73
74template <class T = OPimRecord>
75ORecordList<T>::Iterator &ORecordList::Iterator::operator=( const ORecordList<T>::Iterator& it) {
76 m_uids = it.m_uids;
77 m_current = it.m_current;
78 m_temp = it.m_temp;
79 m_end = it.m_end;
80 m_record = it.m_record;
81
82 return *this;
83}
84
85template <class T = OPimRecord>
86T &ORecordList<T>::Iterator::operator*() {
87 if (!m_end )
88 m_record = m_temp->find( m_uids[m_current] );
89 else
90 m_record = T;
91
92 return m_record;
93}
94
95template <class T = OPimRecord>
96ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator++() {
97 if (m_current < m_uids.count() ) {
98 m_end = false;
99 ++m_current;
100 }else
101 m_end = true;
102
103 return *this;
104}
105template <class T = OPimRecord>
106ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator--() {
107 if ( m_current > 0 ) {
108 --m_current;
109 m_end = false;
110 } else
111 m_end = true;
112
113 return *this;
114}
115
116template <class T = OPimRecord>
117bool ORecordList<T>::Iterator::operator==( const ORecordList<T>::Iterator& it ) {
118
119 /* if both are at we're the same.... */
120 if ( m_end == it.m_end ) return true;
121
122 if ( m_uids != it.m_uids ) return false;
123 if ( m_current != it.m_current ) return false;
124 if ( m_temp != it.m_temp ) return false;
125
126 return true;
127}
128template <class T = ORecordList>
129bool ORecordList<T>::Iterator::operator!=( const ORecordList<T>::Iterator it ) {
130 return !(*this == it );
131}
132template <class T = ORecordList>
133ORecordList<T>::Iterator::Iterator( const QArray<int> uids,
134 OPimAccessTemplate<T>* t )
135 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
136{
137}
138template <class T = ORecordList>
139ORecordList<T>::ORecordList( const QArray<int>& ids,
140 OPimAccessTemplate<T>* acc )
141 : m_ids( ids ), m_acc( acc )
142{
143}
144template <class T = ORecordList>
145ORecordList<T>::~ORecordList() {
146/* nothing to do here */
147}
148template <class T = ORecordList>
149ORecordList<T>::Iterator ORecordList<T>::begin() {
150 Iterator it( m_ids, m_acc );
151 return it;
152}
153template <class T = ORecordList>
154ORecordList<T>::Iterator ORecordList<T>::end() {
155 Iterator it( m_ids, m_acc );
156 it.m_end = true;
157 it.m_current = m_ids.count();
158}
44#endif 159#endif
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index 3c93838..8239ba6 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -1,354 +1,378 @@
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 15
16#include "otodo.h" 16#include "otodo.h"
17 17
18 18
19struct OTodo::OTodoData : public QShared { 19struct OTodo::OTodoData : public QShared {
20 OTodoData() : QShared() { 20 OTodoData() : QShared() {
21 }; 21 };
22 22
23 QDate date; 23 QDate date;
24 bool isCompleted:1; 24 bool isCompleted:1;
25 bool hasDate:1; 25 bool hasDate:1;
26 int priority; 26 int priority;
27 QStringList category;
28 QString desc; 27 QString desc;
29 QString sum; 28 QString sum;
30 QMap<QString, QString> extra; 29 QMap<QString, QString> extra;
31 ushort prog; 30 ushort prog;
32 bool hasAlarmDateTime :1; 31 bool hasAlarmDateTime :1;
33 QDateTime alarmDateTime; 32 QDateTime alarmDateTime;
34}; 33};
35 34
36OTodo::OTodo(const OTodo &event ) 35OTodo::OTodo(const OTodo &event )
37 : OPimRecord( event ), data( event.data ) 36 : OPimRecord( event ), data( event.data )
38{ 37{
39 data->ref(); 38 data->ref();
40 //qWarning("ref up"); 39 //qWarning("ref up");
41} 40}
42OTodo::~OTodo() { 41OTodo::~OTodo() {
43 if ( data->deref() ) { 42 if ( data->deref() ) {
44 //qWarning("OTodo::dereffing"); 43 //qWarning("OTodo::dereffing");
45 delete data; 44 delete data;
46 data = 0l; 45 data = 0l;
47 } 46 }
48} 47}
48OTodo::OTodo(bool completed, int priority,
49 const QArray<int> &category,
50 const QString& summary,
51 const QString &description,
52 ushort progress,
53 bool hasDate, QDate date, int uid )
54 : OPimRecord( uid )
55{
56 //qWarning("OTodoData");
57 setCategories( category );
58 data = new OTodoData;
59 data->date = date;
60 data->isCompleted = completed;
61 data->hasDate = hasDate;
62 data->priority = priority;
63 data->sum = summary;
64 data->prog = progress;
65 data->desc = Qtopia::simplifyMultiLineSpace(description );
66 data->hasAlarmDateTime = false;
49 67
68}
50OTodo::OTodo(bool completed, int priority, 69OTodo::OTodo(bool completed, int priority,
51 const QStringList &category, 70 const QStringList &category,
52 const QString& summary, 71 const QString& summary,
53 const QString &description, 72 const QString &description,
54 ushort progress, 73 ushort progress,
55 bool hasDate, QDate date, int uid ) 74 bool hasDate, QDate date, int uid )
56 : OPimRecord( uid ) 75 : OPimRecord( uid )
57{ 76{
58 //qWarning("OTodoData"); 77 //qWarning("OTodoData");
59 setCategories( idsFromString( category.join(";") ) ); 78 setCategories( idsFromString( category.join(";") ) );
60 data = new OTodoData; 79 data = new OTodoData;
61 data->date = date; 80 data->date = date;
62 data->isCompleted = completed; 81 data->isCompleted = completed;
63 data->hasDate = hasDate; 82 data->hasDate = hasDate;
64 data->priority = priority; 83 data->priority = priority;
65 data->sum = summary; 84 data->sum = summary;
66 data->prog = progress; 85 data->prog = progress;
67 data->desc = Qtopia::simplifyMultiLineSpace(description ); 86 data->desc = Qtopia::simplifyMultiLineSpace(description );
68 data->hasAlarmDateTime = false; 87 data->hasAlarmDateTime = false;
69 88
70} 89}
71bool OTodo::match( const QRegExp &regExp )const 90bool OTodo::match( const QRegExp &regExp )const
72{ 91{
73 if( QString::number( data->priority ).find( regExp ) != -1 ){ 92 if( QString::number( data->priority ).find( regExp ) != -1 ){
74 return true; 93 return true;
75 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 94 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
76 return true; 95 return true;
77 }else if(data->desc.find( regExp ) != -1 ){ 96 }else if(data->desc.find( regExp ) != -1 ){
78 return true; 97 return true;
79 }else if(data->sum.find( regExp ) != -1 ) { 98 }else if(data->sum.find( regExp ) != -1 ) {
80 return true; 99 return true;
81 } 100 }
82 return false; 101 return false;
83} 102}
84bool OTodo::isCompleted() const 103bool OTodo::isCompleted() const
85{ 104{
86 return data->isCompleted; 105 return data->isCompleted;
87} 106}
88bool OTodo::hasDueDate() const 107bool OTodo::hasDueDate() const
89{ 108{
90 return data->hasDate; 109 return data->hasDate;
91} 110}
92bool OTodo::hasAlarmDateTime() const 111bool OTodo::hasAlarmDateTime() const
93{ 112{
94 return data->hasAlarmDateTime; 113 return data->hasAlarmDateTime;
95} 114}
96int OTodo::priority()const 115int OTodo::priority()const
97{ 116{
98 return data->priority; 117 return data->priority;
99} 118}
100QString OTodo::summary() const 119QString OTodo::summary() const
101{ 120{
102 return data->sum; 121 return data->sum;
103} 122}
104ushort OTodo::progress() const 123ushort OTodo::progress() const
105{ 124{
106 return data->prog; 125 return data->prog;
107} 126}
108QDate OTodo::dueDate()const 127QDate OTodo::dueDate()const
109{ 128{
110 return data->date; 129 return data->date;
111} 130}
112 131
113QDateTime OTodo::alarmDateTime() const 132QDateTime OTodo::alarmDateTime() const
114{ 133{
115 return data->alarmDateTime; 134 return data->alarmDateTime;
116} 135}
117 136
118QString OTodo::description()const 137QString OTodo::description()const
119{ 138{
120 return data->desc; 139 return data->desc;
121} 140}
122void OTodo::setCompleted( bool completed ) 141void OTodo::setCompleted( bool completed )
123{ 142{
124 changeOrModify(); 143 changeOrModify();
125 data->isCompleted = completed; 144 data->isCompleted = completed;
126} 145}
127void OTodo::setHasDueDate( bool hasDate ) 146void OTodo::setHasDueDate( bool hasDate )
128{ 147{
129 changeOrModify(); 148 changeOrModify();
130 data->hasDate = hasDate; 149 data->hasDate = hasDate;
131} 150}
132void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) 151void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
133{ 152{
134 changeOrModify(); 153 changeOrModify();
135 data->hasAlarmDateTime = hasAlarmDateTime; 154 data->hasAlarmDateTime = hasAlarmDateTime;
136} 155}
137void OTodo::setDescription(const QString &desc ) 156void OTodo::setDescription(const QString &desc )
138{ 157{
139 changeOrModify(); 158 changeOrModify();
140 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 159 data->desc = Qtopia::simplifyMultiLineSpace(desc );
141} 160}
142void OTodo::setSummary( const QString& sum ) 161void OTodo::setSummary( const QString& sum )
143{ 162{
144 changeOrModify(); 163 changeOrModify();
145 data->sum = sum; 164 data->sum = sum;
146} 165}
147void OTodo::setPriority(int prio ) 166void OTodo::setPriority(int prio )
148{ 167{
149 changeOrModify(); 168 changeOrModify();
150 data->priority = prio; 169 data->priority = prio;
151} 170}
152void OTodo::setDueDate( QDate date ) 171void OTodo::setDueDate( QDate date )
153{ 172{
154 changeOrModify(); 173 changeOrModify();
155 data->date = date; 174 data->date = date;
156} 175}
157void OTodo::setAlarmDateTime( const QDateTime& alarm ) 176void OTodo::setAlarmDateTime( const QDateTime& alarm )
158{ 177{
159 changeOrModify(); 178 changeOrModify();
160 data->alarmDateTime = alarm; 179 data->alarmDateTime = alarm;
161} 180}
162bool OTodo::isOverdue( ) 181bool OTodo::isOverdue( )
163{ 182{
164 if( data->hasDate ) 183 if( data->hasDate )
165 return QDate::currentDate() > data->date; 184 return QDate::currentDate() > data->date;
166 return false; 185 return false;
167} 186}
168void OTodo::setProgress(ushort progress ) 187void OTodo::setProgress(ushort progress )
169{ 188{
170 changeOrModify(); 189 changeOrModify();
171 data->prog = progress; 190 data->prog = progress;
172} 191}
173QString OTodo::toShortText() const { 192QString OTodo::toShortText() const {
174 return summary(); 193 return summary();
175} 194}
176/*! 195/*!
177 Returns a richt text string 196 Returns a richt text string
178*/ 197*/
179QString OTodo::toRichText() const 198QString OTodo::toRichText() const
180{ 199{
181 QString text; 200 QString text;
182 QStringList catlist; 201 QStringList catlist;
183 202
184 // Description of the todo 203 // Description of the todo
185 if ( !summary().isEmpty() ) { 204 if ( !summary().isEmpty() ) {
186 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 205 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
187 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 206 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
188 } 207 }
189 if( !description().isEmpty() ){ 208 if( !description().isEmpty() ){
190 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 209 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
191 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 210 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
192 } 211 }
193 text += "<br><br><br>"; 212 text += "<br><br><br>";
194 213
195 text += "<b>" + QObject::tr( "Priority:") +" </b>" 214 text += "<b>" + QObject::tr( "Priority:") +" </b>"
196 + QString::number( priority() ) + " <br>"; 215 + QString::number( priority() ) + " <br>";
197 text += "<b>" + QObject::tr( "Progress:") + " </b>" 216 text += "<b>" + QObject::tr( "Progress:") + " </b>"
198 + QString::number( progress() ) + " %<br>"; 217 + QString::number( progress() ) + " %<br>";
199 if (hasDueDate() ){ 218 if (hasDueDate() ){
200 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 219 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
201 text += dueDate().toString(); 220 text += dueDate().toString();
202 text += "<br>"; 221 text += "<br>";
203 } 222 }
204 if (hasAlarmDateTime() ){ 223 if (hasAlarmDateTime() ){
205 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; 224 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
206 text += alarmDateTime().toString(); 225 text += alarmDateTime().toString();
207 text += "<br>"; 226 text += "<br>";
208 } 227 }
209 228
210 text += "<b>" + QObject::tr( "Category:") + "</b> "; 229 text += "<b>" + QObject::tr( "Category:") + "</b> ";
211 text += categoryNames().join(", "); 230 text += categoryNames().join(", ");
212 text += "<br>"; 231 text += "<br>";
213 232
214 return text; 233 return text;
215} 234}
216 235
217bool OTodo::operator<( const OTodo &toDoEvent )const{ 236bool OTodo::operator<( const OTodo &toDoEvent )const{
218 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 237 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
219 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 238 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
220 if( hasDueDate() && toDoEvent.hasDueDate() ){ 239 if( hasDueDate() && toDoEvent.hasDueDate() ){
221 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 240 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
222 return priority() < toDoEvent.priority(); 241 return priority() < toDoEvent.priority();
223 }else{ 242 }else{
224 return dueDate() < toDoEvent.dueDate(); 243 return dueDate() < toDoEvent.dueDate();
225 } 244 }
226 } 245 }
227 return false; 246 return false;
228} 247}
229bool OTodo::operator<=(const OTodo &toDoEvent )const 248bool OTodo::operator<=(const OTodo &toDoEvent )const
230{ 249{
231 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 250 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
232 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 251 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
233 if( hasDueDate() && toDoEvent.hasDueDate() ){ 252 if( hasDueDate() && toDoEvent.hasDueDate() ){
234 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 253 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
235 return priority() <= toDoEvent.priority(); 254 return priority() <= toDoEvent.priority();
236 }else{ 255 }else{
237 return dueDate() <= toDoEvent.dueDate(); 256 return dueDate() <= toDoEvent.dueDate();
238 } 257 }
239 } 258 }
240 return true; 259 return true;
241} 260}
242bool OTodo::operator>(const OTodo &toDoEvent )const 261bool OTodo::operator>(const OTodo &toDoEvent )const
243{ 262{
244 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 263 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
245 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 264 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
246 if( hasDueDate() && toDoEvent.hasDueDate() ){ 265 if( hasDueDate() && toDoEvent.hasDueDate() ){
247 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 266 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
248 return priority() > toDoEvent.priority(); 267 return priority() > toDoEvent.priority();
249 }else{ 268 }else{
250 return dueDate() > toDoEvent.dueDate(); 269 return dueDate() > toDoEvent.dueDate();
251 } 270 }
252 } 271 }
253 return false; 272 return false;
254} 273}
255bool OTodo::operator>=(const OTodo &toDoEvent )const 274bool OTodo::operator>=(const OTodo &toDoEvent )const
256{ 275{
257 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 276 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
258 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 277 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
259 if( hasDueDate() && toDoEvent.hasDueDate() ){ 278 if( hasDueDate() && toDoEvent.hasDueDate() ){
260 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 279 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
261 return priority() > toDoEvent.priority(); 280 return priority() > toDoEvent.priority();
262 }else{ 281 }else{
263 return dueDate() > toDoEvent.dueDate(); 282 return dueDate() > toDoEvent.dueDate();
264 } 283 }
265 } 284 }
266 return true; 285 return true;
267} 286}
268bool OTodo::operator==(const OTodo &toDoEvent )const 287bool OTodo::operator==(const OTodo &toDoEvent )const
269{ 288{
270 if( data->priority == toDoEvent.data->priority && 289 if ( data->priority != toDoEvent.data->priority ) return false;
271 data->priority == toDoEvent.data->prog && 290 if ( data->priority != toDoEvent.data->prog ) return false;
272 data->isCompleted == toDoEvent.data->isCompleted && 291 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
273 data->hasDate == toDoEvent.data->hasDate && 292 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
274 data->date == toDoEvent.data->date && 293 if ( data->date != toDoEvent.data->date ) return false;
275 data->category == toDoEvent.data->category && 294 if ( data->sum != toDoEvent.data->sum ) return false;
276 data->sum == toDoEvent.data->sum && 295 if ( data->desc != toDoEvent.data->desc ) return false;
277 data->desc == toDoEvent.data->desc && 296 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
278 data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && 297 return false;
279 data->alarmDateTime == toDoEvent.data->alarmDateTime ) 298 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
280 return true; 299 return false;
281 300
282 return false; 301 return OPimRecord::operator==( toDoEvent );
283} 302}
284void OTodo::deref() { 303void OTodo::deref() {
285 304
286 //qWarning("deref in ToDoEvent"); 305 //qWarning("deref in ToDoEvent");
287 if ( data->deref() ) { 306 if ( data->deref() ) {
288 //qWarning("deleting"); 307 //qWarning("deleting");
289 delete data; 308 delete data;
290 d= 0; 309 d= 0;
291 } 310 }
292} 311}
293OTodo &OTodo::operator=(const OTodo &item ) 312OTodo &OTodo::operator=(const OTodo &item )
294{ 313{
295 OPimRecord::operator=( item ); 314 OPimRecord::operator=( item );
296 //qWarning("operator= ref "); 315 //qWarning("operator= ref ");
297 item.data->ref(); 316 item.data->ref();
298 deref(); 317 deref();
299 318
300 return *this; 319 return *this;
301} 320}
302 321
303QMap<int, QString> OTodo::toMap() const { 322QMap<int, QString> OTodo::toMap() const {
304 QMap<int, QString> map; 323 QMap<int, QString> map;
305 324
306 map.insert( Uid, QString::number( uid() ) ); 325 map.insert( Uid, QString::number( uid() ) );
307 map.insert( Category, idsToString( categories() ) ); 326 map.insert( Category, idsToString( categories() ) );
308 map.insert( HasDate, QString::number( data->hasDate ) ); 327 map.insert( HasDate, QString::number( data->hasDate ) );
309 map.insert( Completed, QString::number( data->isCompleted ) ); 328 map.insert( Completed, QString::number( data->isCompleted ) );
310 map.insert( Description, data->desc ); 329 map.insert( Description, data->desc );
311 map.insert( Summary, data->sum ); 330 map.insert( Summary, data->sum );
312 map.insert( Priority, QString::number( data->priority ) ); 331 map.insert( Priority, QString::number( data->priority ) );
313 map.insert( DateDay, QString::number( data->date.day() ) ); 332 map.insert( DateDay, QString::number( data->date.day() ) );
314 map.insert( DateMonth, QString::number( data->date.month() ) ); 333 map.insert( DateMonth, QString::number( data->date.month() ) );
315 map.insert( DateYear, QString::number( data->date.year() ) ); 334 map.insert( DateYear, QString::number( data->date.year() ) );
316 map.insert( Progress, QString::number( data->prog ) ); 335 map.insert( Progress, QString::number( data->prog ) );
317 map.insert( CrossReference, crossToString() ); 336 map.insert( CrossReference, crossToString() );
318 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 337 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
319 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 338 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
320 339
321 return map; 340 return map;
322} 341}
323 342
324QMap<QString, QString> OTodo::toExtraMap()const { 343QMap<QString, QString> OTodo::toExtraMap()const {
325 return data->extra; 344 return data->extra;
326} 345}
327/** 346/**
328 * change or modify looks at the ref count and either 347 * change or modify looks at the ref count and either
329 * creates a new QShared Object or it can modify it 348 * creates a new QShared Object or it can modify it
330 * right in place 349 * right in place
331 */ 350 */
332void OTodo::changeOrModify() { 351void OTodo::changeOrModify() {
333 if ( data->count != 1 ) { 352 if ( data->count != 1 ) {
334 //qWarning("changeOrModify"); 353 //qWarning("changeOrModify");
335 data->deref(); 354 data->deref();
336 OTodoData* d2 = new OTodoData(); 355 OTodoData* d2 = new OTodoData();
337 copy(data, d2 ); 356 copy(data, d2 );
338 data = d2; 357 data = d2;
339 } 358 }
340} 359}
341void OTodo::copy( OTodoData* src, OTodoData* dest ) { 360void OTodo::copy( OTodoData* src, OTodoData* dest ) {
342 dest->date = src->date; 361 dest->date = src->date;
343 dest->isCompleted = src->isCompleted; 362 dest->isCompleted = src->isCompleted;
344 dest->hasDate = src->hasDate; 363 dest->hasDate = src->hasDate;
345 dest->priority = src->priority; 364 dest->priority = src->priority;
346 dest->desc = src->desc; 365 dest->desc = src->desc;
347 dest->sum = src->sum; 366 dest->sum = src->sum;
348 dest->extra = src->extra; 367 dest->extra = src->extra;
349 dest->prog = src->prog; 368 dest->prog = src->prog;
350 dest->hasAlarmDateTime = src->hasAlarmDateTime; 369 dest->hasAlarmDateTime = src->hasAlarmDateTime;
351 dest->alarmDateTime = src->alarmDateTime; 370 dest->alarmDateTime = src->alarmDateTime;
352} 371}
353 372QString OTodo::type() const {
373 return QString::fromLatin1("OTodo");
374}
375QString OTodo::recordField(int id )const {
376 return QString::null;
377}
354 378
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index e1729db..75af44c 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -1,211 +1,219 @@
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
19class OTodo : public OPimRecord { 19class OTodo : public OPimRecord {
20public: 20public:
21 typedef QValueList<OTodo> ValueList; 21 typedef QValueList<OTodo> ValueList;
22 enum RecordFields { 22 enum RecordFields {
23 Uid = Qtopia::UID_ID, 23 Uid = Qtopia::UID_ID,
24 Category = Qtopia::CATEGORY_ID, 24 Category = Qtopia::CATEGORY_ID,
25 HasDate, 25 HasDate,
26 Completed, 26 Completed,
27 Description, 27 Description,
28 Summary, 28 Summary,
29 Priority, 29 Priority,
30 DateDay, 30 DateDay,
31 DateMonth, 31 DateMonth,
32 DateYear, 32 DateYear,
33 Progress, 33 Progress,
34 CrossReference, 34 CrossReference,
35 HasAlarmDateTime, 35 HasAlarmDateTime,
36 AlarmDateTime 36 AlarmDateTime
37 }; 37 };
38 public: 38 public:
39 // priorities from Very low to very high 39 // priorities from Very low to very high
40 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; 40 enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow };
41 41
42 /* Constructs a new ToDoEvent 42 /* Constructs a new ToDoEvent
43 @param completed Is the TodoEvent completed 43 @param completed Is the TodoEvent completed
44 @param priority What is the priority of this ToDoEvent 44 @param priority What is the priority of this ToDoEvent
45 @param category Which category does it belong( uid ) 45 @param category Which category does it belong( uid )
46 @param summary A small summary of the todo 46 @param summary A small summary of the todo
47 @param description What is this ToDoEvent about 47 @param description What is this ToDoEvent about
48 @param hasDate Does this Event got a deadline 48 @param hasDate Does this Event got a deadline
49 @param date what is the deadline? 49 @param date what is the deadline?
50 @param uid what is the UUID of this Event 50 @param uid what is the UUID of this Event
51 **/ 51 **/
52 OTodo( bool completed = false, int priority = Normal, 52 OTodo( bool completed = false, int priority = Normal,
53 const QStringList &category = QStringList(), 53 const QStringList &category = QStringList(),
54 const QString &summary = QString::null , 54 const QString &summary = QString::null ,
55 const QString &description = QString::null, 55 const QString &description = QString::null,
56 ushort progress = 0, 56 ushort progress = 0,
57 bool hasDate = false, QDate date = QDate::currentDate(), 57 bool hasDate = false, QDate date = QDate::currentDate(),
58 int uid = -1 ); 58 int uid = 0 /*empty*/ );
59
60 OTodo( bool completed, int priority,
61 const QArray<int>& category,
62 const QString& summary = QString::null,
63 const QString& description = QString::null,
64 ushort progress = 0,
65 bool hasDate = false, QDate date = QDate::currentDate(),
66 int uid = 0 /* empty */ );
59 67
60 /* Copy c'tor 68 /* Copy c'tor
61 69
62 **/ 70 **/
63 OTodo(const OTodo & ); 71 OTodo(const OTodo & );
64 72
65 /** 73 /**
66 *destructor 74 *destructor
67 */ 75 */
68 ~OTodo(); 76 ~OTodo();
69 77
70 /** 78 /**
71 * Is this event completed? 79 * Is this event completed?
72 */ 80 */
73 bool isCompleted() const; 81 bool isCompleted() const;
74 82
75 /** 83 /**
76 * Does this Event have a deadline 84 * Does this Event have a deadline
77 */ 85 */
78 bool hasDueDate() const; 86 bool hasDueDate() const;
79 87
80 /** 88 /**
81 * Does this Event has an alarm time ? 89 * Does this Event has an alarm time ?
82 */ 90 */
83 bool hasAlarmDateTime() const; 91 bool hasAlarmDateTime() const;
84 92
85 /** 93 /**
86 * What is the priority? 94 * What is the priority?
87 */ 95 */
88 int priority()const ; 96 int priority()const ;
89 97
90 /** 98 /**
91 * progress as ushort 0, 20, 40, 60, 80 or 100% 99 * progress as ushort 0, 20, 40, 60, 80 or 100%
92 */ 100 */
93 ushort progress() const; 101 ushort progress() const;
94 102
95 /** 103 /**
96 * The due Date 104 * The due Date
97 */ 105 */
98 QDate dueDate()const; 106 QDate dueDate()const;
99 107
100 /** 108 /**
101 * Alarm Date and Time 109 * Alarm Date and Time
102 */ 110 */
103 QDateTime alarmDateTime()const; 111 QDateTime alarmDateTime()const;
104 112
105 /** 113 /**
106 * The description of the todo 114 * The description of the todo
107 */ 115 */
108 QString description()const; 116 QString description()const;
109 117
110 /** 118 /**
111 * A small summary of the todo 119 * A small summary of the todo
112 */ 120 */
113 QString summary() const; 121 QString summary() const;
114 122
115 /** 123 /**
116 * @reimplemented 124 * @reimplemented
117 * Return this todoevent in a RichText formatted QString 125 * Return this todoevent in a RichText formatted QString
118 */ 126 */
119 QString toRichText() const; 127 QString toRichText() const;
120 128
121 /** 129 /**
122 * reimplementation 130 * reimplementation
123 */ 131 */
124 QString type()const; 132 QString type()const;
125 QString toShortText()const; 133 QString toShortText()const;
126 QMap<QString, QString> toExtraMap()const; 134 QMap<QString, QString> toExtraMap()const;
127 QString recordField(int id )const; 135 QString recordField(int id )const;
128 136
129 /** 137 /**
130 * returns a list of apps which have related items 138 * returns a list of apps which have related items
131 */ 139 */
132 QStringList relatedApps()const; 140 QStringList relatedApps()const;
133 141
134 /** 142 /**
135 * returns all relations for one app 143 * returns all relations for one app
136 */ 144 */
137 QArray<int> relations( const QString& app )const; 145 QArray<int> relations( const QString& app )const;
138 146
139 /** 147 /**
140 * toMap puts all data into the map. int relates 148 * toMap puts all data into the map. int relates
141 * to ToDoEvent RecordFields enum 149 * to ToDoEvent RecordFields enum
142 */ 150 */
143 QMap<int, QString> toMap()const; 151 QMap<int, QString> toMap()const;
144 152
145 /** 153 /**
146 * Set if this Todo is completed 154 * Set if this Todo is completed
147 */ 155 */
148 void setCompleted(bool completed ); 156 void setCompleted(bool completed );
149 157
150 /** 158 /**
151 * set if this todo got an end data 159 * set if this todo got an end data
152 */ 160 */
153 void setHasDueDate( bool hasDate ); 161 void setHasDueDate( bool hasDate );
154 162
155 /** 163 /**
156 * set if this todo has an alarm time and date 164 * set if this todo has an alarm time and date
157 */ 165 */
158 void setHasAlarmDateTime ( bool hasAlarm ); 166 void setHasAlarmDateTime ( bool hasAlarm );
159 167
160 /** 168 /**
161 * Set the priority of the Todo 169 * Set the priority of the Todo
162 */ 170 */
163 void setPriority(int priority ); 171 void setPriority(int priority );
164 172
165 /** 173 /**
166 * Set the progress. 174 * Set the progress.
167 */ 175 */
168 void setProgress( ushort progress ); 176 void setProgress( ushort progress );
169 177
170 /** 178 /**
171 * set the end date 179 * set the end date
172 */ 180 */
173 void setDueDate( QDate date ); 181 void setDueDate( QDate date );
174 182
175 /** 183 /**
176 * set the alarm time 184 * set the alarm time
177 */ 185 */
178 void setAlarmDateTime ( const QDateTime& alarm ); 186 void setAlarmDateTime ( const QDateTime& alarm );
179 187
180 void setDescription(const QString& ); 188 void setDescription(const QString& );
181 void setSummary(const QString& ); 189 void setSummary(const QString& );
182 bool isOverdue(); 190 bool isOverdue();
183 191
184 192
185 bool match( const QRegExp &r )const; 193 bool match( const QRegExp &r )const;
186 194
187 bool operator<(const OTodo &toDoEvent )const; 195 bool operator<(const OTodo &toDoEvent )const;
188 bool operator<=(const OTodo &toDoEvent )const; 196 bool operator<=(const OTodo &toDoEvent )const;
189 bool operator!=(const OTodo &toDoEvent )const; 197 bool operator!=(const OTodo &toDoEvent )const;
190 bool operator>(const OTodo &toDoEvent )const; 198 bool operator>(const OTodo &toDoEvent )const;
191 bool operator>=(const OTodo &toDoEvent)const; 199 bool operator>=(const OTodo &toDoEvent)const;
192 bool operator==(const OTodo &toDoEvent )const; 200 bool operator==(const OTodo &toDoEvent )const;
193 OTodo &operator=(const OTodo &toDoEvent ); 201 OTodo &operator=(const OTodo &toDoEvent );
194 202
195 private: 203 private:
196 class OTodoPrivate; 204 class OTodoPrivate;
197 struct OTodoData; 205 struct OTodoData;
198 206
199 void deref(); 207 void deref();
200 void changeOrModify(); 208 void changeOrModify();
201 void copy( OTodoData* src, OTodoData* dest ); 209 void copy( OTodoData* src, OTodoData* dest );
202 OTodoPrivate *d; 210 OTodoPrivate *d;
203 OTodoData *data; 211 OTodoData *data;
204 212
205}; 213};
206inline bool OTodo::operator!=(const OTodo &toDoEvent )const { 214inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
207 return !(*this == toDoEvent); 215 return !(*this == toDoEvent);
208} 216}
209 217
210 218
211#endif 219#endif