author | zecke <zecke> | 2002-09-21 15:02:50 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-21 15:02:50 (UTC) |
commit | e6c53c4d7317e766235449535b22d0d2fe709214 (patch) (unidiff) | |
tree | c210c639611acd5aa3c1863451fb4e31ac3af29a /libopie | |
parent | fe0806def8ec79815832193fe402c75361108622 (diff) | |
download | opie-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
-rw-r--r-- | libopie/pim/opimrecord.cpp | 11 | ||||
-rw-r--r-- | libopie/pim/opimrecord.h | 1 | ||||
-rw-r--r-- | libopie/pim/orecordlist.h | 139 | ||||
-rw-r--r-- | libopie/pim/otodo.cpp | 52 | ||||
-rw-r--r-- | libopie/pim/otodo.h | 10 |
5 files changed, 183 insertions, 30 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,33 +1,30 @@ | |||
1 | #include "opimrecord.h" | 1 | #include "opimrecord.h" |
2 | 2 | ||
3 | OPimRecord::OPimRecord( int uid ) | 3 | OPimRecord::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 | } |
11 | OPimRecord::~OPimRecord() { | 8 | OPimRecord::~OPimRecord() { |
12 | } | 9 | } |
13 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 10 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
14 | : Qtopia::Record( rec ) | 11 | : Qtopia::Record( rec ) |
15 | { | 12 | { |
16 | (*this) = rec; | 13 | (*this) = rec; |
17 | } | 14 | } |
18 | 15 | ||
19 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 16 | OPimRecord &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 | } |
25 | QStringList OPimRecord::categoryNames()const { | 22 | QStringList OPimRecord::categoryNames()const { |
26 | QStringList list; | 23 | QStringList list; |
27 | 24 | ||
28 | return list; | 25 | return list; |
29 | } | 26 | } |
30 | void OPimRecord::setCategoryNames( const QStringList& ) { | 27 | void OPimRecord::setCategoryNames( const QStringList& ) { |
31 | 28 | ||
32 | } | 29 | } |
33 | void OPimRecord::addCategoryName( const QString& ) { | 30 | void OPimRecord::addCategoryName( const QString& ) { |
@@ -83,24 +80,32 @@ void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { | |||
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 | } |
93 | QString OPimRecord::crossToString()const { | 90 | QString 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 */ | ||
105 | void 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 | |||
@@ -80,38 +80,39 @@ public: | |||
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 | ||
105 | protected: | 106 | protected: |
106 | QString crossToString()const; | 107 | QString crossToString()const; |
107 | 108 | ||
108 | private: | 109 | private: |
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 | ||
8 | template <class T = OPimRecord > | 8 | template <class T = OPimRecord > |
9 | class ORecordList { | 9 | class ORecordList { |
10 | public: | 10 | public: |
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 | */ |
39 | private: | 48 | private: |
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 */ | ||
54 | template <class T= OPimRecord> | ||
55 | ORecordList<T>::Iterator::Iterator() { | ||
56 | m_current = 0; | ||
57 | m_temp = 0l; | ||
58 | m_end = true; | ||
59 | } | ||
60 | template <class T= OPimRecord> | ||
61 | ORecordList<T>::Iterator::~Iterator() { | ||
62 | /* nothing to delete */ | ||
63 | } | ||
64 | |||
65 | template <class T = OPimRecord> | ||
66 | ORecordList<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 | |||
74 | template <class T = OPimRecord> | ||
75 | ORecordList<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 | |||
85 | template <class T = OPimRecord> | ||
86 | T &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 | |||
95 | template <class T = OPimRecord> | ||
96 | ORecordList<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 | } | ||
105 | template <class T = OPimRecord> | ||
106 | ORecordList<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 | |||
116 | template <class T = OPimRecord> | ||
117 | bool 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 | } | ||
128 | template <class T = ORecordList> | ||
129 | bool ORecordList<T>::Iterator::operator!=( const ORecordList<T>::Iterator it ) { | ||
130 | return !(*this == it ); | ||
131 | } | ||
132 | template <class T = ORecordList> | ||
133 | ORecordList<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 | } | ||
138 | template <class T = ORecordList> | ||
139 | ORecordList<T>::ORecordList( const QArray<int>& ids, | ||
140 | OPimAccessTemplate<T>* acc ) | ||
141 | : m_ids( ids ), m_acc( acc ) | ||
142 | { | ||
143 | } | ||
144 | template <class T = ORecordList> | ||
145 | ORecordList<T>::~ORecordList() { | ||
146 | /* nothing to do here */ | ||
147 | } | ||
148 | template <class T = ORecordList> | ||
149 | ORecordList<T>::Iterator ORecordList<T>::begin() { | ||
150 | Iterator it( m_ids, m_acc ); | ||
151 | return it; | ||
152 | } | ||
153 | template <class T = ORecordList> | ||
154 | ORecordList<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 | |||
@@ -3,71 +3,90 @@ | |||
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 | ||
19 | struct OTodo::OTodoData : public QShared { | 19 | struct 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 | ||
36 | OTodo::OTodo(const OTodo &event ) | 35 | OTodo::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 | } |
42 | OTodo::~OTodo() { | 41 | OTodo::~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 | } |
48 | OTodo::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 | } | ||
50 | OTodo::OTodo(bool completed, int priority, | 69 | OTodo::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 | } |
71 | bool OTodo::match( const QRegExp ®Exp )const | 90 | bool OTodo::match( const QRegExp ®Exp )const |
72 | { | 91 | { |
73 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 92 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
@@ -246,61 +265,61 @@ bool OTodo::operator>(const OTodo &toDoEvent )const | |||
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 | } |
255 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 274 | bool 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 | } |
268 | bool OTodo::operator==(const OTodo &toDoEvent )const | 287 | bool 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 | } |
284 | void OTodo::deref() { | 303 | void 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 | } |
293 | OTodo &OTodo::operator=(const OTodo &item ) | 312 | OTodo &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 | ||
303 | QMap<int, QString> OTodo::toMap() const { | 322 | QMap<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() ) ); |
@@ -329,26 +348,31 @@ QMap<QString, QString> OTodo::toExtraMap()const { | |||
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 | */ |
332 | void OTodo::changeOrModify() { | 351 | void 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 | } |
341 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 360 | void 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 | 372 | QString OTodo::type() const { | |
373 | return QString::fromLatin1("OTodo"); | ||
374 | } | ||
375 | QString 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 | |||
@@ -34,49 +34,57 @@ public: | |||
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 | */ |