summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/orecordlist.h12
-rw-r--r--libopie/pim/otodo.cpp21
-rw-r--r--libopie/pim/otodoaccessxml.cpp2
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp2
-rw-r--r--libopie2/opiepim/orecordlist.h12
-rw-r--r--libopie2/opiepim/otodo.cpp21
6 files changed, 38 insertions, 32 deletions
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 75bb33c..36728b8 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -19,49 +19,49 @@ template <class T = OPimRecord>
19class ORecordListIterator { 19class ORecordListIterator {
20 friend class ORecordList<T>; 20 friend class ORecordList<T>;
21public: 21public:
22 typedef OTemplateBase<T> Base; 22 typedef OTemplateBase<T> Base;
23 23
24 /** 24 /**
25 * The c'tor used internally from 25 * The c'tor used internally from
26 * ORecordList 26 * ORecordList
27 */ 27 */
28 ORecordListIterator( const QArray<int>, const Base* ); 28 ORecordListIterator( const QArray<int>, const Base* );
29 29
30 /** 30 /**
31 * The standard c'tor 31 * The standard c'tor
32 */ 32 */
33 ORecordListIterator(); 33 ORecordListIterator();
34 ~ORecordListIterator(); 34 ~ORecordListIterator();
35 35
36 ORecordListIterator( const ORecordListIterator& ); 36 ORecordListIterator( const ORecordListIterator& );
37 ORecordListIterator &operator=(const ORecordListIterator& ); 37 ORecordListIterator &operator=(const ORecordListIterator& );
38 38
39 /** 39 /**
40 * a * operator ;) 40 * a * operator ;)
41 * use it like this T = (*it); 41 * use it like this T = (*it);
42 */ 42 */
43 T &operator*(); 43 T operator*();
44 ORecordListIterator &operator++(); 44 ORecordListIterator &operator++();
45 ORecordListIterator &operator--(); 45 ORecordListIterator &operator--();
46 46
47 bool operator==( const ORecordListIterator& it ); 47 bool operator==( const ORecordListIterator& it );
48 bool operator!=( const ORecordListIterator& it ); 48 bool operator!=( const ORecordListIterator& it );
49 49
50private: 50private:
51 QArray<int> m_uids; 51 QArray<int> m_uids;
52 int m_current; 52 int m_current;
53 const Base* m_temp; 53 const Base* m_temp;
54 bool m_end : 1; 54 bool m_end : 1;
55 T m_record; 55 T m_record;
56 56
57 /* d pointer for future versions */ 57 /* d pointer for future versions */
58 class IteratorPrivate; 58 class IteratorPrivate;
59 IteratorPrivate *d; 59 IteratorPrivate *d;
60}; 60};
61/** 61/**
62 * The recordlist used as a return type 62 * The recordlist used as a return type
63 * from OPimAccessTemplate 63 * from OPimAccessTemplate
64 */ 64 */
65template <class T = OPimRecord > 65template <class T = OPimRecord >
66class ORecordList { 66class ORecordList {
67public: 67public:
@@ -78,78 +78,79 @@ public:
78 /** 78 /**
79 * the first iterator 79 * the first iterator
80 */ 80 */
81 Iterator begin(); 81 Iterator begin();
82 82
83 /** 83 /**
84 * the end 84 * the end
85 */ 85 */
86 Iterator end(); 86 Iterator end();
87 /* 87 /*
88 ConstIterator begin()const; 88 ConstIterator begin()const;
89 ConstIterator end()const; 89 ConstIterator end()const;
90 */ 90 */
91private: 91private:
92 QArray<int> m_ids; 92 QArray<int> m_ids;
93 const Base* m_acc; 93 const Base* m_acc;
94}; 94};
95 95
96/* ok now implement it */ 96/* ok now implement it */
97template <class T> 97template <class T>
98ORecordListIterator<T>::ORecordListIterator() { 98ORecordListIterator<T>::ORecordListIterator() {
99 m_current = 0; 99 m_current = 0;
100 m_temp = 0l; 100 m_temp = 0l;
101 m_end = true; 101 m_end = true;
102 m_record = T();
102} 103}
103template <class T> 104template <class T>
104ORecordListIterator<T>::~ORecordListIterator() { 105ORecordListIterator<T>::~ORecordListIterator() {
105/* nothing to delete */ 106/* nothing to delete */
106} 107}
107 108
108template <class T> 109template <class T>
109ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 110ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
110 qWarning("ORecordListIterator"); 111// qWarning("ORecordListIterator copy c'tor");
111 m_uids = it.m_uids; 112 m_uids = it.m_uids;
112 m_current = it.m_current; 113 m_current = it.m_current;
113 m_temp = it.m_temp; 114 m_temp = it.m_temp;
114 m_end = it.m_end; 115 m_end = it.m_end;
115 m_record = it.m_record; 116 m_record = it.m_record;
116} 117}
117 118
118template <class T> 119template <class T>
119ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 120ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
120 m_uids = it.m_uids; 121 m_uids = it.m_uids;
121 m_current = it.m_current; 122 m_current = it.m_current;
122 m_temp = it.m_temp; 123 m_temp = it.m_temp;
123 m_end = it.m_end; 124 m_end = it.m_end;
124 m_record = it.m_record; 125// m_record = it.m_record;
125 126
126 return *this; 127 return *this;
127} 128}
128 129
129template <class T> 130template <class T>
130T &ORecordListIterator<T>::operator*() { 131T ORecordListIterator<T>::operator*() {
131 qWarning("operator* %d %d", m_current, m_uids[m_current] ); 132// qWarning("operator* %d %d", m_current, m_uids[m_current] );
132 if (!m_end ) 133 if (!m_end )
133 m_record = m_temp->find( m_uids[m_current] ); 134 m_record = m_temp->find( m_uids[m_current] );
134 else 135 else
135 m_record = T(); 136 m_record = T();
136 137
137 return m_record; 138 return m_record;
138} 139}
139 140
140template <class T> 141template <class T>
141ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 142ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
142 if (m_current < (int)m_uids.count() ) { 143 if (m_current < (int)m_uids.count() ) {
143 m_end = false; 144 m_end = false;
144 ++m_current; 145 ++m_current;
145 }else 146 }else
146 m_end = true; 147 m_end = true;
147 148
148 return *this; 149 return *this;
149} 150}
150template <class T> 151template <class T>
151ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 152ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
152 if ( m_current > 0 ) { 153 if ( m_current > 0 ) {
153 --m_current; 154 --m_current;
154 m_end = false; 155 m_end = false;
155 } else 156 } else
@@ -172,37 +173,36 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
172} 173}
173template <class T> 174template <class T>
174bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 175bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
175 return !(*this == it ); 176 return !(*this == it );
176} 177}
177template <class T> 178template <class T>
178ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 179ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
179 const Base* t ) 180 const Base* t )
180 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 181 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
181{ 182{
182} 183}
183 184
184template <class T> 185template <class T>
185ORecordList<T>::ORecordList( const QArray<int>& ids, 186ORecordList<T>::ORecordList( const QArray<int>& ids,
186 const Base* acc ) 187 const Base* acc )
187 : m_ids( ids ), m_acc( acc ) 188 : m_ids( ids ), m_acc( acc )
188{ 189{
189} 190}
190template <class T> 191template <class T>
191ORecordList<T>::~ORecordList() { 192ORecordList<T>::~ORecordList() {
192/* nothing to do here */ 193/* nothing to do here */
193} 194}
194template <class T> 195template <class T>
195ORecordList<T>::Iterator ORecordList<T>::begin() { 196ORecordList<T>::Iterator ORecordList<T>::begin() {
196 qWarning("ORecordList::begin");
197 Iterator it( m_ids, m_acc ); 197 Iterator it( m_ids, m_acc );
198 return it; 198 return it;
199} 199}
200template <class T> 200template <class T>
201ORecordList<T>::Iterator ORecordList<T>::end() { 201ORecordList<T>::Iterator ORecordList<T>::end() {
202 Iterator it( m_ids, m_acc ); 202 Iterator it( m_ids, m_acc );
203 it.m_end = true; 203 it.m_end = true;
204 it.m_current = m_ids.count(); 204 it.m_current = m_ids.count();
205 205
206 return it; 206 return it;
207} 207}
208#endif 208#endif
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index b3c14e6..cc46b21 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -15,95 +15,96 @@
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 QString desc; 27 QString desc;
28 QString sum; 28 QString sum;
29 QMap<QString, QString> extra; 29 QMap<QString, QString> extra;
30 ushort prog; 30 ushort prog;
31 bool hasAlarmDateTime :1; 31 bool hasAlarmDateTime :1;
32 QDateTime alarmDateTime; 32 QDateTime alarmDateTime;
33}; 33};
34 34
35OTodo::OTodo(const OTodo &event ) 35OTodo::OTodo(const OTodo &event )
36 : OPimRecord( event ), data( event.data ) 36 : OPimRecord( event ), data( event.data )
37{ 37{
38 data->ref(); 38 data->ref();
39 qWarning("ref up"); 39// qWarning("ref up");
40} 40}
41OTodo::~OTodo() { 41OTodo::~OTodo() {
42 qWarning("~OTodo " + data->sum ); 42
43// qWarning("~OTodo " );
43 if ( data->deref() ) { 44 if ( data->deref() ) {
44 qWarning("OTodo::dereffing"); 45// qWarning("OTodo::dereffing");
45 delete data; 46 delete data;
46 data = 0l; 47 data = 0l;
47 } 48 }
48} 49}
49OTodo::OTodo(bool completed, int priority, 50OTodo::OTodo(bool completed, int priority,
50 const QArray<int> &category, 51 const QArray<int> &category,
51 const QString& summary, 52 const QString& summary,
52 const QString &description, 53 const QString &description,
53 ushort progress, 54 ushort progress,
54 bool hasDate, QDate date, int uid ) 55 bool hasDate, QDate date, int uid )
55 : OPimRecord( uid ) 56 : OPimRecord( uid )
56{ 57{
57 qWarning("OTodoData " + summary); 58// qWarning("OTodoData " + summary);
58 setCategories( category ); 59 setCategories( category );
59 60
60 data = new OTodoData; 61 data = new OTodoData;
61 62
62 data->date = date; 63 data->date = date;
63 data->isCompleted = completed; 64 data->isCompleted = completed;
64 data->hasDate = hasDate; 65 data->hasDate = hasDate;
65 data->priority = priority; 66 data->priority = priority;
66 data->sum = summary; 67 data->sum = summary;
67 data->prog = progress; 68 data->prog = progress;
68 data->desc = Qtopia::simplifyMultiLineSpace(description ); 69 data->desc = Qtopia::simplifyMultiLineSpace(description );
69 data->hasAlarmDateTime = false; 70 data->hasAlarmDateTime = false;
70 71
71} 72}
72OTodo::OTodo(bool completed, int priority, 73OTodo::OTodo(bool completed, int priority,
73 const QStringList &category, 74 const QStringList &category,
74 const QString& summary, 75 const QString& summary,
75 const QString &description, 76 const QString &description,
76 ushort progress, 77 ushort progress,
77 bool hasDate, QDate date, int uid ) 78 bool hasDate, QDate date, int uid )
78 : OPimRecord( uid ) 79 : OPimRecord( uid )
79{ 80{
80 qWarning("OTodoData" + summary); 81// qWarning("OTodoData" + summary);
81 setCategories( idsFromString( category.join(";") ) ); 82 setCategories( idsFromString( category.join(";") ) );
82 83
83 data = new OTodoData; 84 data = new OTodoData;
84 data->date = date;
85 85
86 data->date = date;
86 data->isCompleted = completed; 87 data->isCompleted = completed;
87 data->hasDate = hasDate; 88 data->hasDate = hasDate;
88 data->priority = priority; 89 data->priority = priority;
89 data->sum = summary; 90 data->sum = summary;
90 data->prog = progress; 91 data->prog = progress;
91 data->desc = Qtopia::simplifyMultiLineSpace(description ); 92 data->desc = Qtopia::simplifyMultiLineSpace(description );
92 data->hasAlarmDateTime = false; 93 data->hasAlarmDateTime = false;
93 94
94} 95}
95bool OTodo::match( const QRegExp &regExp )const 96bool OTodo::match( const QRegExp &regExp )const
96{ 97{
97 if( QString::number( data->priority ).find( regExp ) != -1 ){ 98 if( QString::number( data->priority ).find( regExp ) != -1 ){
98 return true; 99 return true;
99 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 100 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
100 return true; 101 return true;
101 }else if(data->desc.find( regExp ) != -1 ){ 102 }else if(data->desc.find( regExp ) != -1 ){
102 return true; 103 return true;
103 }else if(data->sum.find( regExp ) != -1 ) { 104 }else if(data->sum.find( regExp ) != -1 ) {
104 return true; 105 return true;
105 } 106 }
106 return false; 107 return false;
107} 108}
108bool OTodo::isCompleted() const 109bool OTodo::isCompleted() const
109{ 110{
@@ -139,48 +140,49 @@ QDateTime OTodo::alarmDateTime() const
139 return data->alarmDateTime; 140 return data->alarmDateTime;
140} 141}
141 142
142QString OTodo::description()const 143QString OTodo::description()const
143{ 144{
144 return data->desc; 145 return data->desc;
145} 146}
146void OTodo::setCompleted( bool completed ) 147void OTodo::setCompleted( bool completed )
147{ 148{
148 changeOrModify(); 149 changeOrModify();
149 data->isCompleted = completed; 150 data->isCompleted = completed;
150} 151}
151void OTodo::setHasDueDate( bool hasDate ) 152void OTodo::setHasDueDate( bool hasDate )
152{ 153{
153 changeOrModify(); 154 changeOrModify();
154 data->hasDate = hasDate; 155 data->hasDate = hasDate;
155} 156}
156void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) 157void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
157{ 158{
158 changeOrModify(); 159 changeOrModify();
159 data->hasAlarmDateTime = hasAlarmDateTime; 160 data->hasAlarmDateTime = hasAlarmDateTime;
160} 161}
161void OTodo::setDescription(const QString &desc ) 162void OTodo::setDescription(const QString &desc )
162{ 163{
164 qWarning( "desc " + desc );
163 changeOrModify(); 165 changeOrModify();
164 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 166 data->desc = Qtopia::simplifyMultiLineSpace(desc );
165} 167}
166void OTodo::setSummary( const QString& sum ) 168void OTodo::setSummary( const QString& sum )
167{ 169{
168 changeOrModify(); 170 changeOrModify();
169 data->sum = sum; 171 data->sum = sum;
170} 172}
171void OTodo::setPriority(int prio ) 173void OTodo::setPriority(int prio )
172{ 174{
173 changeOrModify(); 175 changeOrModify();
174 data->priority = prio; 176 data->priority = prio;
175} 177}
176void OTodo::setDueDate( QDate date ) 178void OTodo::setDueDate( QDate date )
177{ 179{
178 changeOrModify(); 180 changeOrModify();
179 data->date = date; 181 data->date = date;
180} 182}
181void OTodo::setAlarmDateTime( const QDateTime& alarm ) 183void OTodo::setAlarmDateTime( const QDateTime& alarm )
182{ 184{
183 changeOrModify(); 185 changeOrModify();
184 data->alarmDateTime = alarm; 186 data->alarmDateTime = alarm;
185} 187}
186bool OTodo::isOverdue( ) 188bool OTodo::isOverdue( )
@@ -290,93 +292,94 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
290 return true; 292 return true;
291} 293}
292bool OTodo::operator==(const OTodo &toDoEvent )const 294bool OTodo::operator==(const OTodo &toDoEvent )const
293{ 295{
294 if ( data->priority != toDoEvent.data->priority ) return false; 296 if ( data->priority != toDoEvent.data->priority ) return false;
295 if ( data->priority != toDoEvent.data->prog ) return false; 297 if ( data->priority != toDoEvent.data->prog ) return false;
296 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 298 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
297 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 299 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
298 if ( data->date != toDoEvent.data->date ) return false; 300 if ( data->date != toDoEvent.data->date ) return false;
299 if ( data->sum != toDoEvent.data->sum ) return false; 301 if ( data->sum != toDoEvent.data->sum ) return false;
300 if ( data->desc != toDoEvent.data->desc ) return false; 302 if ( data->desc != toDoEvent.data->desc ) return false;
301 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) 303 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
302 return false; 304 return false;
303 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) 305 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
304 return false; 306 return false;
305 307
306 return OPimRecord::operator==( toDoEvent ); 308 return OPimRecord::operator==( toDoEvent );
307} 309}
308void OTodo::deref() { 310void OTodo::deref() {
309 311
310 //qWarning("deref in ToDoEvent"); 312 //qWarning("deref in ToDoEvent");
311 if ( data->deref() ) { 313 if ( data->deref() ) {
312 //qWarning("deleting"); 314 //qWarning("deleting");
313 delete data; 315 delete data;
314 d= 0; 316 data= 0;
315 } 317 }
316} 318}
317OTodo &OTodo::operator=(const OTodo &item ) 319OTodo &OTodo::operator=(const OTodo &item )
318{ 320{
319 OPimRecord::operator=( item ); 321// OPimRecord::operator=( item );
320 //qWarning("operator= ref "); 322 //qWarning("operator= ref ");
321 item.data->ref(); 323 item.data->ref();
322 deref(); 324 deref();
325 data = item.data;
323 326
324 return *this; 327 return *this;
325} 328}
326 329
327QMap<int, QString> OTodo::toMap() const { 330QMap<int, QString> OTodo::toMap() const {
328 QMap<int, QString> map; 331 QMap<int, QString> map;
329 332
330 map.insert( Uid, QString::number( uid() ) ); 333 map.insert( Uid, QString::number( uid() ) );
331 map.insert( Category, idsToString( categories() ) ); 334 map.insert( Category, idsToString( categories() ) );
332 map.insert( HasDate, QString::number( data->hasDate ) ); 335 map.insert( HasDate, QString::number( data->hasDate ) );
333 map.insert( Completed, QString::number( data->isCompleted ) ); 336 map.insert( Completed, QString::number( data->isCompleted ) );
334 map.insert( Description, data->desc ); 337 map.insert( Description, data->desc );
335 map.insert( Summary, data->sum ); 338 map.insert( Summary, data->sum );
336 map.insert( Priority, QString::number( data->priority ) ); 339 map.insert( Priority, QString::number( data->priority ) );
337 map.insert( DateDay, QString::number( data->date.day() ) ); 340 map.insert( DateDay, QString::number( data->date.day() ) );
338 map.insert( DateMonth, QString::number( data->date.month() ) ); 341 map.insert( DateMonth, QString::number( data->date.month() ) );
339 map.insert( DateYear, QString::number( data->date.year() ) ); 342 map.insert( DateYear, QString::number( data->date.year() ) );
340 map.insert( Progress, QString::number( data->prog ) ); 343 map.insert( Progress, QString::number( data->prog ) );
341 map.insert( CrossReference, crossToString() ); 344 map.insert( CrossReference, crossToString() );
342 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 345 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
343 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 346 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
344 347
345 return map; 348 return map;
346} 349}
347 350
348QMap<QString, QString> OTodo::toExtraMap()const { 351QMap<QString, QString> OTodo::toExtraMap()const {
349 return data->extra; 352 return data->extra;
350} 353}
351/** 354/**
352 * change or modify looks at the ref count and either 355 * change or modify looks at the ref count and either
353 * creates a new QShared Object or it can modify it 356 * creates a new QShared Object or it can modify it
354 * right in place 357 * right in place
355 */ 358 */
356void OTodo::changeOrModify() { 359void OTodo::changeOrModify() {
357 if ( data->count != 1 ) { 360 if ( data->count != 1 ) {
358 qWarning("changeOrModify"); 361// qWarning("changeOrModify");
359 data->deref(); 362 data->deref();
360 OTodoData* d2 = new OTodoData(); 363 OTodoData* d2 = new OTodoData();
361 copy(data, d2 ); 364 copy(data, d2 );
362 data = d2; 365 data = d2;
363 } 366 }
364} 367}
365void OTodo::copy( OTodoData* src, OTodoData* dest ) { 368void OTodo::copy( OTodoData* src, OTodoData* dest ) {
366 dest->date = src->date; 369 dest->date = src->date;
367 dest->isCompleted = src->isCompleted; 370 dest->isCompleted = src->isCompleted;
368 dest->hasDate = src->hasDate; 371 dest->hasDate = src->hasDate;
369 dest->priority = src->priority; 372 dest->priority = src->priority;
370 dest->desc = src->desc; 373 dest->desc = src->desc;
371 dest->sum = src->sum; 374 dest->sum = src->sum;
372 dest->extra = src->extra; 375 dest->extra = src->extra;
373 dest->prog = src->prog; 376 dest->prog = src->prog;
374 dest->hasAlarmDateTime = src->hasAlarmDateTime; 377 dest->hasAlarmDateTime = src->hasAlarmDateTime;
375 dest->alarmDateTime = src->alarmDateTime; 378 dest->alarmDateTime = src->alarmDateTime;
376} 379}
377QString OTodo::type() const { 380QString OTodo::type() const {
378 return QString::fromLatin1("OTodo"); 381 return QString::fromLatin1("OTodo");
379} 382}
380QString OTodo::recordField(int id )const { 383QString OTodo::recordField(int id )const {
381 return QString::null; 384 return QString::null;
382} 385}
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 21756c9..3a72881 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -47,56 +47,56 @@ bool OTodoAccessXML::load() {
47 47
48 Opie::XMLElement *root = Opie::XMLElement::load( m_file ); 48 Opie::XMLElement *root = Opie::XMLElement::load( m_file );
49 int day, year, month; 49 int day, year, month;
50 day = year = month = -1; 50 day = year = month = -1;
51 51
52 /* if opened */ 52 /* if opened */
53 if ( root != 0l ) { 53 if ( root != 0l ) {
54 Opie::XMLElement *element = root->firstChild(); 54 Opie::XMLElement *element = root->firstChild();
55 if ( element == 0l ) 55 if ( element == 0l )
56 return false; 56 return false;
57 57
58 element = element->firstChild(); 58 element = element->firstChild();
59 59
60 while ( element ) { 60 while ( element ) {
61 if ( element->tagName() != QString::fromLatin1("Task") ) { 61 if ( element->tagName() != QString::fromLatin1("Task") ) {
62 element = element->nextChild(); 62 element = element->nextChild();
63 continue; 63 continue;
64 } 64 }
65 /* here is the right element for a task */ 65 /* here is the right element for a task */
66 OTodo ev = todo( &dict, element ); 66 OTodo ev = todo( &dict, element );
67 m_events.insert( ev.uid(), ev ); 67 m_events.insert( ev.uid(), ev );
68 68
69 element = element->nextChild(); 69 element = element->nextChild();
70 } 70 }
71 return true;
72 }else { 71 }else {
73 qWarning("could not parse"); 72 qWarning("could not parse");
74 return false;; 73 return false;;
75 } 74 }
76 delete root; 75 delete root;
77 76
78 m_opened = true; 77 m_opened = true;
78 qWarning("Access %d" + m_events.count() );
79 return true; 79 return true;
80} 80}
81bool OTodoAccessXML::reload() { 81bool OTodoAccessXML::reload() {
82 return load(); 82 return load();
83} 83}
84bool OTodoAccessXML::save() { 84bool OTodoAccessXML::save() {
85 if (!m_opened || !m_changed ) 85 if (!m_opened || !m_changed )
86 return true; 86 return true;
87 QString strNewFile = m_file + ".new"; 87 QString strNewFile = m_file + ".new";
88 QFile f( strNewFile ); 88 QFile f( strNewFile );
89 if (!f.open( IO_WriteOnly|IO_Raw ) ) 89 if (!f.open( IO_WriteOnly|IO_Raw ) )
90 return false; 90 return false;
91 91
92 int written; 92 int written;
93 QString out; 93 QString out;
94 out = "<!DOCTYPE Tasks>\n<Tasks>\n"; 94 out = "<!DOCTYPE Tasks>\n<Tasks>\n";
95 95
96 // for all todos 96 // for all todos
97 QMap<int, OTodo>::Iterator it; 97 QMap<int, OTodo>::Iterator it;
98 for (it = m_events.begin(); it != m_events.end(); ++it ) { 98 for (it = m_events.begin(); it != m_events.end(); ++it ) {
99 out+= "<Task " + toString( (*it) ) + " />\n"; 99 out+= "<Task " + toString( (*it) ) + " />\n";
100 QCString cstr = out.utf8(); 100 QCString cstr = out.utf8();
101 written = f.writeBlock( cstr.data(), cstr.length() ); 101 written = f.writeBlock( cstr.data(), cstr.length() );
102 102
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 21756c9..3a72881 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -47,56 +47,56 @@ bool OTodoAccessXML::load() {
47 47
48 Opie::XMLElement *root = Opie::XMLElement::load( m_file ); 48 Opie::XMLElement *root = Opie::XMLElement::load( m_file );
49 int day, year, month; 49 int day, year, month;
50 day = year = month = -1; 50 day = year = month = -1;
51 51
52 /* if opened */ 52 /* if opened */
53 if ( root != 0l ) { 53 if ( root != 0l ) {
54 Opie::XMLElement *element = root->firstChild(); 54 Opie::XMLElement *element = root->firstChild();
55 if ( element == 0l ) 55 if ( element == 0l )
56 return false; 56 return false;
57 57
58 element = element->firstChild(); 58 element = element->firstChild();
59 59
60 while ( element ) { 60 while ( element ) {
61 if ( element->tagName() != QString::fromLatin1("Task") ) { 61 if ( element->tagName() != QString::fromLatin1("Task") ) {
62 element = element->nextChild(); 62 element = element->nextChild();
63 continue; 63 continue;
64 } 64 }
65 /* here is the right element for a task */ 65 /* here is the right element for a task */
66 OTodo ev = todo( &dict, element ); 66 OTodo ev = todo( &dict, element );
67 m_events.insert( ev.uid(), ev ); 67 m_events.insert( ev.uid(), ev );
68 68
69 element = element->nextChild(); 69 element = element->nextChild();
70 } 70 }
71 return true;
72 }else { 71 }else {
73 qWarning("could not parse"); 72 qWarning("could not parse");
74 return false;; 73 return false;;
75 } 74 }
76 delete root; 75 delete root;
77 76
78 m_opened = true; 77 m_opened = true;
78 qWarning("Access %d" + m_events.count() );
79 return true; 79 return true;
80} 80}
81bool OTodoAccessXML::reload() { 81bool OTodoAccessXML::reload() {
82 return load(); 82 return load();
83} 83}
84bool OTodoAccessXML::save() { 84bool OTodoAccessXML::save() {
85 if (!m_opened || !m_changed ) 85 if (!m_opened || !m_changed )
86 return true; 86 return true;
87 QString strNewFile = m_file + ".new"; 87 QString strNewFile = m_file + ".new";
88 QFile f( strNewFile ); 88 QFile f( strNewFile );
89 if (!f.open( IO_WriteOnly|IO_Raw ) ) 89 if (!f.open( IO_WriteOnly|IO_Raw ) )
90 return false; 90 return false;
91 91
92 int written; 92 int written;
93 QString out; 93 QString out;
94 out = "<!DOCTYPE Tasks>\n<Tasks>\n"; 94 out = "<!DOCTYPE Tasks>\n<Tasks>\n";
95 95
96 // for all todos 96 // for all todos
97 QMap<int, OTodo>::Iterator it; 97 QMap<int, OTodo>::Iterator it;
98 for (it = m_events.begin(); it != m_events.end(); ++it ) { 98 for (it = m_events.begin(); it != m_events.end(); ++it ) {
99 out+= "<Task " + toString( (*it) ) + " />\n"; 99 out+= "<Task " + toString( (*it) ) + " />\n";
100 QCString cstr = out.utf8(); 100 QCString cstr = out.utf8();
101 written = f.writeBlock( cstr.data(), cstr.length() ); 101 written = f.writeBlock( cstr.data(), cstr.length() );
102 102
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 75bb33c..36728b8 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -19,49 +19,49 @@ template <class T = OPimRecord>
19class ORecordListIterator { 19class ORecordListIterator {
20 friend class ORecordList<T>; 20 friend class ORecordList<T>;
21public: 21public:
22 typedef OTemplateBase<T> Base; 22 typedef OTemplateBase<T> Base;
23 23
24 /** 24 /**
25 * The c'tor used internally from 25 * The c'tor used internally from
26 * ORecordList 26 * ORecordList
27 */ 27 */
28 ORecordListIterator( const QArray<int>, const Base* ); 28 ORecordListIterator( const QArray<int>, const Base* );
29 29
30 /** 30 /**
31 * The standard c'tor 31 * The standard c'tor
32 */ 32 */
33 ORecordListIterator(); 33 ORecordListIterator();
34 ~ORecordListIterator(); 34 ~ORecordListIterator();
35 35
36 ORecordListIterator( const ORecordListIterator& ); 36 ORecordListIterator( const ORecordListIterator& );
37 ORecordListIterator &operator=(const ORecordListIterator& ); 37 ORecordListIterator &operator=(const ORecordListIterator& );
38 38
39 /** 39 /**
40 * a * operator ;) 40 * a * operator ;)
41 * use it like this T = (*it); 41 * use it like this T = (*it);
42 */ 42 */
43 T &operator*(); 43 T operator*();
44 ORecordListIterator &operator++(); 44 ORecordListIterator &operator++();
45 ORecordListIterator &operator--(); 45 ORecordListIterator &operator--();
46 46
47 bool operator==( const ORecordListIterator& it ); 47 bool operator==( const ORecordListIterator& it );
48 bool operator!=( const ORecordListIterator& it ); 48 bool operator!=( const ORecordListIterator& it );
49 49
50private: 50private:
51 QArray<int> m_uids; 51 QArray<int> m_uids;
52 int m_current; 52 int m_current;
53 const Base* m_temp; 53 const Base* m_temp;
54 bool m_end : 1; 54 bool m_end : 1;
55 T m_record; 55 T m_record;
56 56
57 /* d pointer for future versions */ 57 /* d pointer for future versions */
58 class IteratorPrivate; 58 class IteratorPrivate;
59 IteratorPrivate *d; 59 IteratorPrivate *d;
60}; 60};
61/** 61/**
62 * The recordlist used as a return type 62 * The recordlist used as a return type
63 * from OPimAccessTemplate 63 * from OPimAccessTemplate
64 */ 64 */
65template <class T = OPimRecord > 65template <class T = OPimRecord >
66class ORecordList { 66class ORecordList {
67public: 67public:
@@ -78,78 +78,79 @@ public:
78 /** 78 /**
79 * the first iterator 79 * the first iterator
80 */ 80 */
81 Iterator begin(); 81 Iterator begin();
82 82
83 /** 83 /**
84 * the end 84 * the end
85 */ 85 */
86 Iterator end(); 86 Iterator end();
87 /* 87 /*
88 ConstIterator begin()const; 88 ConstIterator begin()const;
89 ConstIterator end()const; 89 ConstIterator end()const;
90 */ 90 */
91private: 91private:
92 QArray<int> m_ids; 92 QArray<int> m_ids;
93 const Base* m_acc; 93 const Base* m_acc;
94}; 94};
95 95
96/* ok now implement it */ 96/* ok now implement it */
97template <class T> 97template <class T>
98ORecordListIterator<T>::ORecordListIterator() { 98ORecordListIterator<T>::ORecordListIterator() {
99 m_current = 0; 99 m_current = 0;
100 m_temp = 0l; 100 m_temp = 0l;
101 m_end = true; 101 m_end = true;
102 m_record = T();
102} 103}
103template <class T> 104template <class T>
104ORecordListIterator<T>::~ORecordListIterator() { 105ORecordListIterator<T>::~ORecordListIterator() {
105/* nothing to delete */ 106/* nothing to delete */
106} 107}
107 108
108template <class T> 109template <class T>
109ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 110ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
110 qWarning("ORecordListIterator"); 111// qWarning("ORecordListIterator copy c'tor");
111 m_uids = it.m_uids; 112 m_uids = it.m_uids;
112 m_current = it.m_current; 113 m_current = it.m_current;
113 m_temp = it.m_temp; 114 m_temp = it.m_temp;
114 m_end = it.m_end; 115 m_end = it.m_end;
115 m_record = it.m_record; 116 m_record = it.m_record;
116} 117}
117 118
118template <class T> 119template <class T>
119ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 120ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
120 m_uids = it.m_uids; 121 m_uids = it.m_uids;
121 m_current = it.m_current; 122 m_current = it.m_current;
122 m_temp = it.m_temp; 123 m_temp = it.m_temp;
123 m_end = it.m_end; 124 m_end = it.m_end;
124 m_record = it.m_record; 125// m_record = it.m_record;
125 126
126 return *this; 127 return *this;
127} 128}
128 129
129template <class T> 130template <class T>
130T &ORecordListIterator<T>::operator*() { 131T ORecordListIterator<T>::operator*() {
131 qWarning("operator* %d %d", m_current, m_uids[m_current] ); 132// qWarning("operator* %d %d", m_current, m_uids[m_current] );
132 if (!m_end ) 133 if (!m_end )
133 m_record = m_temp->find( m_uids[m_current] ); 134 m_record = m_temp->find( m_uids[m_current] );
134 else 135 else
135 m_record = T(); 136 m_record = T();
136 137
137 return m_record; 138 return m_record;
138} 139}
139 140
140template <class T> 141template <class T>
141ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 142ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
142 if (m_current < (int)m_uids.count() ) { 143 if (m_current < (int)m_uids.count() ) {
143 m_end = false; 144 m_end = false;
144 ++m_current; 145 ++m_current;
145 }else 146 }else
146 m_end = true; 147 m_end = true;
147 148
148 return *this; 149 return *this;
149} 150}
150template <class T> 151template <class T>
151ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 152ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
152 if ( m_current > 0 ) { 153 if ( m_current > 0 ) {
153 --m_current; 154 --m_current;
154 m_end = false; 155 m_end = false;
155 } else 156 } else
@@ -172,37 +173,36 @@ bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
172} 173}
173template <class T> 174template <class T>
174bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 175bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
175 return !(*this == it ); 176 return !(*this == it );
176} 177}
177template <class T> 178template <class T>
178ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 179ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
179 const Base* t ) 180 const Base* t )
180 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 181 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
181{ 182{
182} 183}
183 184
184template <class T> 185template <class T>
185ORecordList<T>::ORecordList( const QArray<int>& ids, 186ORecordList<T>::ORecordList( const QArray<int>& ids,
186 const Base* acc ) 187 const Base* acc )
187 : m_ids( ids ), m_acc( acc ) 188 : m_ids( ids ), m_acc( acc )
188{ 189{
189} 190}
190template <class T> 191template <class T>
191ORecordList<T>::~ORecordList() { 192ORecordList<T>::~ORecordList() {
192/* nothing to do here */ 193/* nothing to do here */
193} 194}
194template <class T> 195template <class T>
195ORecordList<T>::Iterator ORecordList<T>::begin() { 196ORecordList<T>::Iterator ORecordList<T>::begin() {
196 qWarning("ORecordList::begin");
197 Iterator it( m_ids, m_acc ); 197 Iterator it( m_ids, m_acc );
198 return it; 198 return it;
199} 199}
200template <class T> 200template <class T>
201ORecordList<T>::Iterator ORecordList<T>::end() { 201ORecordList<T>::Iterator ORecordList<T>::end() {
202 Iterator it( m_ids, m_acc ); 202 Iterator it( m_ids, m_acc );
203 it.m_end = true; 203 it.m_end = true;
204 it.m_current = m_ids.count(); 204 it.m_current = m_ids.count();
205 205
206 return it; 206 return it;
207} 207}
208#endif 208#endif
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index b3c14e6..cc46b21 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -15,95 +15,96 @@
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 QString desc; 27 QString desc;
28 QString sum; 28 QString sum;
29 QMap<QString, QString> extra; 29 QMap<QString, QString> extra;
30 ushort prog; 30 ushort prog;
31 bool hasAlarmDateTime :1; 31 bool hasAlarmDateTime :1;
32 QDateTime alarmDateTime; 32 QDateTime alarmDateTime;
33}; 33};
34 34
35OTodo::OTodo(const OTodo &event ) 35OTodo::OTodo(const OTodo &event )
36 : OPimRecord( event ), data( event.data ) 36 : OPimRecord( event ), data( event.data )
37{ 37{
38 data->ref(); 38 data->ref();
39 qWarning("ref up"); 39// qWarning("ref up");
40} 40}
41OTodo::~OTodo() { 41OTodo::~OTodo() {
42 qWarning("~OTodo " + data->sum ); 42
43// qWarning("~OTodo " );
43 if ( data->deref() ) { 44 if ( data->deref() ) {
44 qWarning("OTodo::dereffing"); 45// qWarning("OTodo::dereffing");
45 delete data; 46 delete data;
46 data = 0l; 47 data = 0l;
47 } 48 }
48} 49}
49OTodo::OTodo(bool completed, int priority, 50OTodo::OTodo(bool completed, int priority,
50 const QArray<int> &category, 51 const QArray<int> &category,
51 const QString& summary, 52 const QString& summary,
52 const QString &description, 53 const QString &description,
53 ushort progress, 54 ushort progress,
54 bool hasDate, QDate date, int uid ) 55 bool hasDate, QDate date, int uid )
55 : OPimRecord( uid ) 56 : OPimRecord( uid )
56{ 57{
57 qWarning("OTodoData " + summary); 58// qWarning("OTodoData " + summary);
58 setCategories( category ); 59 setCategories( category );
59 60
60 data = new OTodoData; 61 data = new OTodoData;
61 62
62 data->date = date; 63 data->date = date;
63 data->isCompleted = completed; 64 data->isCompleted = completed;
64 data->hasDate = hasDate; 65 data->hasDate = hasDate;
65 data->priority = priority; 66 data->priority = priority;
66 data->sum = summary; 67 data->sum = summary;
67 data->prog = progress; 68 data->prog = progress;
68 data->desc = Qtopia::simplifyMultiLineSpace(description ); 69 data->desc = Qtopia::simplifyMultiLineSpace(description );
69 data->hasAlarmDateTime = false; 70 data->hasAlarmDateTime = false;
70 71
71} 72}
72OTodo::OTodo(bool completed, int priority, 73OTodo::OTodo(bool completed, int priority,
73 const QStringList &category, 74 const QStringList &category,
74 const QString& summary, 75 const QString& summary,
75 const QString &description, 76 const QString &description,
76 ushort progress, 77 ushort progress,
77 bool hasDate, QDate date, int uid ) 78 bool hasDate, QDate date, int uid )
78 : OPimRecord( uid ) 79 : OPimRecord( uid )
79{ 80{
80 qWarning("OTodoData" + summary); 81// qWarning("OTodoData" + summary);
81 setCategories( idsFromString( category.join(";") ) ); 82 setCategories( idsFromString( category.join(";") ) );
82 83
83 data = new OTodoData; 84 data = new OTodoData;
84 data->date = date;
85 85
86 data->date = date;
86 data->isCompleted = completed; 87 data->isCompleted = completed;
87 data->hasDate = hasDate; 88 data->hasDate = hasDate;
88 data->priority = priority; 89 data->priority = priority;
89 data->sum = summary; 90 data->sum = summary;
90 data->prog = progress; 91 data->prog = progress;
91 data->desc = Qtopia::simplifyMultiLineSpace(description ); 92 data->desc = Qtopia::simplifyMultiLineSpace(description );
92 data->hasAlarmDateTime = false; 93 data->hasAlarmDateTime = false;
93 94
94} 95}
95bool OTodo::match( const QRegExp &regExp )const 96bool OTodo::match( const QRegExp &regExp )const
96{ 97{
97 if( QString::number( data->priority ).find( regExp ) != -1 ){ 98 if( QString::number( data->priority ).find( regExp ) != -1 ){
98 return true; 99 return true;
99 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 100 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
100 return true; 101 return true;
101 }else if(data->desc.find( regExp ) != -1 ){ 102 }else if(data->desc.find( regExp ) != -1 ){
102 return true; 103 return true;
103 }else if(data->sum.find( regExp ) != -1 ) { 104 }else if(data->sum.find( regExp ) != -1 ) {
104 return true; 105 return true;
105 } 106 }
106 return false; 107 return false;
107} 108}
108bool OTodo::isCompleted() const 109bool OTodo::isCompleted() const
109{ 110{
@@ -139,48 +140,49 @@ QDateTime OTodo::alarmDateTime() const
139 return data->alarmDateTime; 140 return data->alarmDateTime;
140} 141}
141 142
142QString OTodo::description()const 143QString OTodo::description()const
143{ 144{
144 return data->desc; 145 return data->desc;
145} 146}
146void OTodo::setCompleted( bool completed ) 147void OTodo::setCompleted( bool completed )
147{ 148{
148 changeOrModify(); 149 changeOrModify();
149 data->isCompleted = completed; 150 data->isCompleted = completed;
150} 151}
151void OTodo::setHasDueDate( bool hasDate ) 152void OTodo::setHasDueDate( bool hasDate )
152{ 153{
153 changeOrModify(); 154 changeOrModify();
154 data->hasDate = hasDate; 155 data->hasDate = hasDate;
155} 156}
156void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) 157void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
157{ 158{
158 changeOrModify(); 159 changeOrModify();
159 data->hasAlarmDateTime = hasAlarmDateTime; 160 data->hasAlarmDateTime = hasAlarmDateTime;
160} 161}
161void OTodo::setDescription(const QString &desc ) 162void OTodo::setDescription(const QString &desc )
162{ 163{
164 qWarning( "desc " + desc );
163 changeOrModify(); 165 changeOrModify();
164 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 166 data->desc = Qtopia::simplifyMultiLineSpace(desc );
165} 167}
166void OTodo::setSummary( const QString& sum ) 168void OTodo::setSummary( const QString& sum )
167{ 169{
168 changeOrModify(); 170 changeOrModify();
169 data->sum = sum; 171 data->sum = sum;
170} 172}
171void OTodo::setPriority(int prio ) 173void OTodo::setPriority(int prio )
172{ 174{
173 changeOrModify(); 175 changeOrModify();
174 data->priority = prio; 176 data->priority = prio;
175} 177}
176void OTodo::setDueDate( QDate date ) 178void OTodo::setDueDate( QDate date )
177{ 179{
178 changeOrModify(); 180 changeOrModify();
179 data->date = date; 181 data->date = date;
180} 182}
181void OTodo::setAlarmDateTime( const QDateTime& alarm ) 183void OTodo::setAlarmDateTime( const QDateTime& alarm )
182{ 184{
183 changeOrModify(); 185 changeOrModify();
184 data->alarmDateTime = alarm; 186 data->alarmDateTime = alarm;
185} 187}
186bool OTodo::isOverdue( ) 188bool OTodo::isOverdue( )
@@ -290,93 +292,94 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
290 return true; 292 return true;
291} 293}
292bool OTodo::operator==(const OTodo &toDoEvent )const 294bool OTodo::operator==(const OTodo &toDoEvent )const
293{ 295{
294 if ( data->priority != toDoEvent.data->priority ) return false; 296 if ( data->priority != toDoEvent.data->priority ) return false;
295 if ( data->priority != toDoEvent.data->prog ) return false; 297 if ( data->priority != toDoEvent.data->prog ) return false;
296 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 298 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
297 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 299 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
298 if ( data->date != toDoEvent.data->date ) return false; 300 if ( data->date != toDoEvent.data->date ) return false;
299 if ( data->sum != toDoEvent.data->sum ) return false; 301 if ( data->sum != toDoEvent.data->sum ) return false;
300 if ( data->desc != toDoEvent.data->desc ) return false; 302 if ( data->desc != toDoEvent.data->desc ) return false;
301 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) 303 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
302 return false; 304 return false;
303 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) 305 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
304 return false; 306 return false;
305 307
306 return OPimRecord::operator==( toDoEvent ); 308 return OPimRecord::operator==( toDoEvent );
307} 309}
308void OTodo::deref() { 310void OTodo::deref() {
309 311
310 //qWarning("deref in ToDoEvent"); 312 //qWarning("deref in ToDoEvent");
311 if ( data->deref() ) { 313 if ( data->deref() ) {
312 //qWarning("deleting"); 314 //qWarning("deleting");
313 delete data; 315 delete data;
314 d= 0; 316 data= 0;
315 } 317 }
316} 318}
317OTodo &OTodo::operator=(const OTodo &item ) 319OTodo &OTodo::operator=(const OTodo &item )
318{ 320{
319 OPimRecord::operator=( item ); 321// OPimRecord::operator=( item );
320 //qWarning("operator= ref "); 322 //qWarning("operator= ref ");
321 item.data->ref(); 323 item.data->ref();
322 deref(); 324 deref();
325 data = item.data;
323 326
324 return *this; 327 return *this;
325} 328}
326 329
327QMap<int, QString> OTodo::toMap() const { 330QMap<int, QString> OTodo::toMap() const {
328 QMap<int, QString> map; 331 QMap<int, QString> map;
329 332
330 map.insert( Uid, QString::number( uid() ) ); 333 map.insert( Uid, QString::number( uid() ) );
331 map.insert( Category, idsToString( categories() ) ); 334 map.insert( Category, idsToString( categories() ) );
332 map.insert( HasDate, QString::number( data->hasDate ) ); 335 map.insert( HasDate, QString::number( data->hasDate ) );
333 map.insert( Completed, QString::number( data->isCompleted ) ); 336 map.insert( Completed, QString::number( data->isCompleted ) );
334 map.insert( Description, data->desc ); 337 map.insert( Description, data->desc );
335 map.insert( Summary, data->sum ); 338 map.insert( Summary, data->sum );
336 map.insert( Priority, QString::number( data->priority ) ); 339 map.insert( Priority, QString::number( data->priority ) );
337 map.insert( DateDay, QString::number( data->date.day() ) ); 340 map.insert( DateDay, QString::number( data->date.day() ) );
338 map.insert( DateMonth, QString::number( data->date.month() ) ); 341 map.insert( DateMonth, QString::number( data->date.month() ) );
339 map.insert( DateYear, QString::number( data->date.year() ) ); 342 map.insert( DateYear, QString::number( data->date.year() ) );
340 map.insert( Progress, QString::number( data->prog ) ); 343 map.insert( Progress, QString::number( data->prog ) );
341 map.insert( CrossReference, crossToString() ); 344 map.insert( CrossReference, crossToString() );
342 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 345 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
343 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 346 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
344 347
345 return map; 348 return map;
346} 349}
347 350
348QMap<QString, QString> OTodo::toExtraMap()const { 351QMap<QString, QString> OTodo::toExtraMap()const {
349 return data->extra; 352 return data->extra;
350} 353}
351/** 354/**
352 * change or modify looks at the ref count and either 355 * change or modify looks at the ref count and either
353 * creates a new QShared Object or it can modify it 356 * creates a new QShared Object or it can modify it
354 * right in place 357 * right in place
355 */ 358 */
356void OTodo::changeOrModify() { 359void OTodo::changeOrModify() {
357 if ( data->count != 1 ) { 360 if ( data->count != 1 ) {
358 qWarning("changeOrModify"); 361// qWarning("changeOrModify");
359 data->deref(); 362 data->deref();
360 OTodoData* d2 = new OTodoData(); 363 OTodoData* d2 = new OTodoData();
361 copy(data, d2 ); 364 copy(data, d2 );
362 data = d2; 365 data = d2;
363 } 366 }
364} 367}
365void OTodo::copy( OTodoData* src, OTodoData* dest ) { 368void OTodo::copy( OTodoData* src, OTodoData* dest ) {
366 dest->date = src->date; 369 dest->date = src->date;
367 dest->isCompleted = src->isCompleted; 370 dest->isCompleted = src->isCompleted;
368 dest->hasDate = src->hasDate; 371 dest->hasDate = src->hasDate;
369 dest->priority = src->priority; 372 dest->priority = src->priority;
370 dest->desc = src->desc; 373 dest->desc = src->desc;
371 dest->sum = src->sum; 374 dest->sum = src->sum;
372 dest->extra = src->extra; 375 dest->extra = src->extra;
373 dest->prog = src->prog; 376 dest->prog = src->prog;
374 dest->hasAlarmDateTime = src->hasAlarmDateTime; 377 dest->hasAlarmDateTime = src->hasAlarmDateTime;
375 dest->alarmDateTime = src->alarmDateTime; 378 dest->alarmDateTime = src->alarmDateTime;
376} 379}
377QString OTodo::type() const { 380QString OTodo::type() const {
378 return QString::fromLatin1("OTodo"); 381 return QString::fromLatin1("OTodo");
379} 382}
380QString OTodo::recordField(int id )const { 383QString OTodo::recordField(int id )const {
381 return QString::null; 384 return QString::null;
382} 385}