summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimrecord.cpp3
-rw-r--r--libopie/pim/orecordlist.h2
-rw-r--r--libopie/pim/otodo.cpp4
-rw-r--r--libopie/pim/otodoaccess.cpp4
-rw-r--r--libopie/pim/otodoaccessxml.cpp20
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp20
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp3
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp4
-rw-r--r--libopie2/opiepim/orecordlist.h2
-rw-r--r--libopie2/opiepim/otodo.cpp4
10 files changed, 40 insertions, 26 deletions
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index 60cdbf3..62dc353 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -1,133 +1,134 @@
1#include <qpe/categories.h> 1#include <qpe/categories.h>
2#include <qpe/categoryselect.h> 2#include <qpe/categoryselect.h>
3 3
4#include "opimrecord.h" 4#include "opimrecord.h"
5 5
6Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 6Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
7 7
8 8
9OPimRecord::OPimRecord( int uid ) 9OPimRecord::OPimRecord( int uid )
10 : Qtopia::Record() { 10 : Qtopia::Record() {
11 11
12 setUid( uid ); 12 setUid( uid );
13} 13}
14OPimRecord::~OPimRecord() { 14OPimRecord::~OPimRecord() {
15} 15}
16OPimRecord::OPimRecord( const OPimRecord& rec ) 16OPimRecord::OPimRecord( const OPimRecord& rec )
17 : Qtopia::Record( rec ) 17 : Qtopia::Record( rec )
18{ 18{
19 (*this) = rec; 19 (*this) = rec;
20} 20}
21 21
22OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 22OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
23 Qtopia::Record::operator=( rec ); 23 Qtopia::Record::operator=( rec );
24 m_relations = rec.m_relations; 24 m_relations = rec.m_relations;
25 25
26 return *this; 26 return *this;
27} 27}
28/* 28/*
29 * category names 29 * category names
30 */ 30 */
31QStringList OPimRecord::categoryNames()const { 31QStringList OPimRecord::categoryNames()const {
32 QStringList list; 32 QStringList list;
33 QArray<int> cats = categories(); 33 QArray<int> cats = categories();
34 Categories catDB; 34 Categories catDB;
35 catDB.load( categoryFileName() ); 35 catDB.load( categoryFileName() );
36 36
37 for (uint i = 0; i < cats.count(); i++ ) { 37 for (uint i = 0; i < cats.count(); i++ ) {
38 list << catDB.label("Todo List", cats[i] ); 38 list << catDB.label("Todo List", cats[i] );
39 } 39 }
40 40
41 return list; 41 return list;
42} 42}
43void OPimRecord::setCategoryNames( const QStringList& ) { 43void OPimRecord::setCategoryNames( const QStringList& ) {
44 44
45} 45}
46void OPimRecord::addCategoryName( const QString& ) { 46void OPimRecord::addCategoryName( const QString& ) {
47 Categories catDB; 47 Categories catDB;
48 catDB.load( categoryFileName() ); 48 catDB.load( categoryFileName() );
49 49
50 50
51} 51}
52bool OPimRecord::isEmpty()const { 52bool OPimRecord::isEmpty()const {
53 return ( uid() == 0 ); 53 return ( uid() == 0 );
54} 54}
55QStringList OPimRecord::relatedApps()const{ 55QStringList OPimRecord::relatedApps()const{
56 QStringList list; 56 QStringList list;
57 QMap<QString, QArray<int> >::ConstIterator it; 57 QMap<QString, QArray<int> >::ConstIterator it;
58 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { 58 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) {
59 list << it.key(); 59 list << it.key();
60 } 60 }
61 return list; 61 return list;
62} 62}
63QArray<int> OPimRecord::relations(const QString& app )const { 63QArray<int> OPimRecord::relations(const QString& app )const {
64 QArray<int> tmp; 64 QArray<int> tmp;
65 QMap<QString, QArray<int> >::ConstIterator it; 65 QMap<QString, QArray<int> >::ConstIterator it;
66 it = m_relations.find( app); 66 it = m_relations.find( app);
67 if ( it != m_relations.end() ) 67 if ( it != m_relations.end() )
68 tmp = it.data(); 68 tmp = it.data();
69 return tmp; 69 return tmp;
70} 70}
71void OPimRecord::clearRelation( const QString& app ) { 71void OPimRecord::clearRelation( const QString& app ) {
72 m_relations.remove( app ); 72 m_relations.remove( app );
73} 73}
74void OPimRecord::addRelation( const QString& app, int id ) { 74void OPimRecord::addRelation( const QString& app, int id ) {
75 75
76 QMap<QString, QArray<int> >::Iterator it; 76 QMap<QString, QArray<int> >::Iterator it;
77 QArray<int> tmp; 77 QArray<int> tmp;
78 78
79 it = m_relations.find( app ); 79 it = m_relations.find( app );
80 if ( it == m_relations.end() ) { 80 if ( it == m_relations.end() ) {
81 tmp.resize(1 ); 81 tmp.resize(1 );
82 tmp[0] = id; 82 tmp[0] = id;
83 }else{ 83 }else{
84 tmp = it.data(); 84 tmp = it.data();
85 tmp.resize( tmp.size() + 1 ); 85 tmp.resize( tmp.size() + 1 );
86 tmp[tmp.size() - 1] = id; 86 tmp[tmp.size() - 1] = id;
87 } 87 }
88 m_relations.replace( app, tmp ); 88 m_relations.replace( app, tmp );
89} 89}
90void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { 90void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
91 91
92 QMap<QString, QArray<int> >::Iterator it; 92 QMap<QString, QArray<int> >::Iterator it;
93 QArray<int> tmp; 93 QArray<int> tmp;
94 94
95 it = m_relations.find( app); 95 it = m_relations.find( app);
96 if ( it == m_relations.end() ) { 96 if ( it == m_relations.end() ) {
97 tmp = ids; 97 tmp = ids;
98 }else{ 98 }else{
99 tmp = it.data(); 99 tmp = it.data();
100 int offset = tmp.size()-1; 100 int offset = tmp.size()-1;
101 tmp.resize( tmp.size() + ids.size() ); 101 tmp.resize( tmp.size() + ids.size() );
102 for (uint i = 0; i < ids.size(); i++ ) { 102 for (uint i = 0; i < ids.size(); i++ ) {
103 tmp[offset+i] = ids[i]; 103 tmp[offset+i] = ids[i];
104 } 104 }
105 105
106 } 106 }
107 m_relations.replace( app, tmp ); 107 m_relations.replace( app, tmp );
108} 108}
109QString OPimRecord::crossToString()const { 109QString OPimRecord::crossToString()const {
110 QString str; 110 QString str;
111 QMap<QString, QArray<int> >::ConstIterator it; 111 QMap<QString, QArray<int> >::ConstIterator it;
112 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 112 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
113 QArray<int> id = it.data(); 113 QArray<int> id = it.data();
114 for ( uint i = 0; i < id.size(); ++i ) { 114 for ( uint i = 0; i < id.size(); ++i ) {
115 str += it.key() + "," + QString::number( i ) + ";"; 115 str += it.key() + "," + QString::number( i ) + ";";
116 } 116 }
117 } 117 }
118 str = str.remove( str.length()-1, 1); // strip the ; 118 str = str.remove( str.length()-1, 1); // strip the ;
119 //qWarning("IDS " + str ); 119 //qWarning("IDS " + str );
120 120
121 return str; 121 return str;
122} 122}
123/* if uid = 1 assign a new one */ 123/* if uid = 1 assign a new one */
124void OPimRecord::setUid( int uid ) { 124void OPimRecord::setUid( int uid ) {
125 125// qWarning("setting uid" );
126 if ( uid == 1) 126 if ( uid == 1)
127 uid = uidGen().generate(); 127 uid = uidGen().generate();
128 128
129// qWarning(" uid %d", uid);
129 Qtopia::Record::setUid( uid ); 130 Qtopia::Record::setUid( uid );
130}; 131};
131Qtopia::UidGen &OPimRecord::uidGen() { 132Qtopia::UidGen &OPimRecord::uidGen() {
132 return m_uidGen; 133 return m_uidGen;
133} 134}
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 36728b8..1795938 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -1,208 +1,210 @@
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 <qarray.h> 5#include <qarray.h>
6 6
7#include "otemplatebase.h" 7#include "otemplatebase.h"
8#include "opimrecord.h" 8#include "opimrecord.h"
9 9
10/** 10/**
11 * Our List Iterator 11 * Our List Iterator
12 * it behaves like STL or Qt 12 * it behaves like STL or Qt
13 * 13 *
14 * for(it = list.begin(); it != list.end(); ++it ) 14 * for(it = list.begin(); it != list.end(); ++it )
15 * doSomeCoolStuff( (*it) ); 15 * doSomeCoolStuff( (*it) );
16 */ 16 */
17template <class T> class ORecordList; 17template <class T> class ORecordList;
18template <class T = OPimRecord> 18template <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:
68 typedef OTemplateBase<T> Base; 68 typedef OTemplateBase<T> Base;
69 typedef ORecordListIterator<T> Iterator; 69 typedef ORecordListIterator<T> Iterator;
70 70
71 /** 71 /**
72 * c'tor 72 * c'tor
73 */ 73 */
74 ORecordList () {
75 }
74 ORecordList( const QArray<int>& ids, 76 ORecordList( const QArray<int>& ids,
75 const Base* ); 77 const Base* );
76 ~ORecordList(); 78 ~ORecordList();
77 79
78 /** 80 /**
79 * the first iterator 81 * the first iterator
80 */ 82 */
81 Iterator begin(); 83 Iterator begin();
82 84
83 /** 85 /**
84 * the end 86 * the end
85 */ 87 */
86 Iterator end(); 88 Iterator end();
87 /* 89 /*
88 ConstIterator begin()const; 90 ConstIterator begin()const;
89 ConstIterator end()const; 91 ConstIterator end()const;
90 */ 92 */
91private: 93private:
92 QArray<int> m_ids; 94 QArray<int> m_ids;
93 const Base* m_acc; 95 const Base* m_acc;
94}; 96};
95 97
96/* ok now implement it */ 98/* ok now implement it */
97template <class T> 99template <class T>
98ORecordListIterator<T>::ORecordListIterator() { 100ORecordListIterator<T>::ORecordListIterator() {
99 m_current = 0; 101 m_current = 0;
100 m_temp = 0l; 102 m_temp = 0l;
101 m_end = true; 103 m_end = true;
102 m_record = T(); 104 m_record = T();
103} 105}
104template <class T> 106template <class T>
105ORecordListIterator<T>::~ORecordListIterator() { 107ORecordListIterator<T>::~ORecordListIterator() {
106/* nothing to delete */ 108/* nothing to delete */
107} 109}
108 110
109template <class T> 111template <class T>
110ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 112ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
111// qWarning("ORecordListIterator copy c'tor"); 113// qWarning("ORecordListIterator copy c'tor");
112 m_uids = it.m_uids; 114 m_uids = it.m_uids;
113 m_current = it.m_current; 115 m_current = it.m_current;
114 m_temp = it.m_temp; 116 m_temp = it.m_temp;
115 m_end = it.m_end; 117 m_end = it.m_end;
116 m_record = it.m_record; 118 m_record = it.m_record;
117} 119}
118 120
119template <class T> 121template <class T>
120ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 122ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
121 m_uids = it.m_uids; 123 m_uids = it.m_uids;
122 m_current = it.m_current; 124 m_current = it.m_current;
123 m_temp = it.m_temp; 125 m_temp = it.m_temp;
124 m_end = it.m_end; 126 m_end = it.m_end;
125// m_record = it.m_record; 127// m_record = it.m_record;
126 128
127 return *this; 129 return *this;
128} 130}
129 131
130template <class T> 132template <class T>
131T ORecordListIterator<T>::operator*() { 133T ORecordListIterator<T>::operator*() {
132// qWarning("operator* %d %d", m_current, m_uids[m_current] ); 134// qWarning("operator* %d %d", m_current, m_uids[m_current] );
133 if (!m_end ) 135 if (!m_end )
134 m_record = m_temp->find( m_uids[m_current] ); 136 m_record = m_temp->find( m_uids[m_current] );
135 else 137 else
136 m_record = T(); 138 m_record = T();
137 139
138 return m_record; 140 return m_record;
139} 141}
140 142
141template <class T> 143template <class T>
142ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 144ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
143 if (m_current < (int)m_uids.count() ) { 145 if (m_current < (int)m_uids.count() ) {
144 m_end = false; 146 m_end = false;
145 ++m_current; 147 ++m_current;
146 }else 148 }else
147 m_end = true; 149 m_end = true;
148 150
149 return *this; 151 return *this;
150} 152}
151template <class T> 153template <class T>
152ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 154ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
153 if ( m_current > 0 ) { 155 if ( m_current > 0 ) {
154 --m_current; 156 --m_current;
155 m_end = false; 157 m_end = false;
156 } else 158 } else
157 m_end = true; 159 m_end = true;
158 160
159 return *this; 161 return *this;
160} 162}
161 163
162template <class T> 164template <class T>
163bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 165bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
164 166
165 /* if both are at we're the same.... */ 167 /* if both are at we're the same.... */
166 if ( m_end == it.m_end ) return true; 168 if ( m_end == it.m_end ) return true;
167 169
168 if ( m_uids != it.m_uids ) return false; 170 if ( m_uids != it.m_uids ) return false;
169 if ( m_current != it.m_current ) return false; 171 if ( m_current != it.m_current ) return false;
170 if ( m_temp != it.m_temp ) return false; 172 if ( m_temp != it.m_temp ) return false;
171 173
172 return true; 174 return true;
173} 175}
174template <class T> 176template <class T>
175bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 177bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
176 return !(*this == it ); 178 return !(*this == it );
177} 179}
178template <class T> 180template <class T>
179ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 181ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
180 const Base* t ) 182 const Base* t )
181 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 183 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
182{ 184{
183} 185}
184 186
185template <class T> 187template <class T>
186ORecordList<T>::ORecordList( const QArray<int>& ids, 188ORecordList<T>::ORecordList( const QArray<int>& ids,
187 const Base* acc ) 189 const Base* acc )
188 : m_ids( ids ), m_acc( acc ) 190 : m_ids( ids ), m_acc( acc )
189{ 191{
190} 192}
191template <class T> 193template <class T>
192ORecordList<T>::~ORecordList() { 194ORecordList<T>::~ORecordList() {
193/* nothing to do here */ 195/* nothing to do here */
194} 196}
195template <class T> 197template <class T>
196ORecordList<T>::Iterator ORecordList<T>::begin() { 198ORecordList<T>::Iterator ORecordList<T>::begin() {
197 Iterator it( m_ids, m_acc ); 199 Iterator it( m_ids, m_acc );
198 return it; 200 return it;
199} 201}
200template <class T> 202template <class T>
201ORecordList<T>::Iterator ORecordList<T>::end() { 203ORecordList<T>::Iterator ORecordList<T>::end() {
202 Iterator it( m_ids, m_acc ); 204 Iterator it( m_ids, m_acc );
203 it.m_end = true; 205 it.m_end = true;
204 it.m_current = m_ids.count(); 206 it.m_current = m_ids.count();
205 207
206 return it; 208 return it;
207} 209}
208#endif 210#endif
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index cc46b21..6dd4c0e 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -1,386 +1,386 @@
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 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 42
43// qWarning("~OTodo " ); 43// qWarning("~OTodo " );
44 if ( data->deref() ) { 44 if ( data->deref() ) {
45// qWarning("OTodo::dereffing"); 45// qWarning("OTodo::dereffing");
46 delete data; 46 delete data;
47 data = 0l; 47 data = 0l;
48 } 48 }
49} 49}
50OTodo::OTodo(bool completed, int priority, 50OTodo::OTodo(bool completed, int priority,
51 const QArray<int> &category, 51 const QArray<int> &category,
52 const QString& summary, 52 const QString& summary,
53 const QString &description, 53 const QString &description,
54 ushort progress, 54 ushort progress,
55 bool hasDate, QDate date, int uid ) 55 bool hasDate, QDate date, int uid )
56 : OPimRecord( uid ) 56 : OPimRecord( uid )
57{ 57{
58// qWarning("OTodoData " + summary); 58// qWarning("OTodoData " + summary);
59 setCategories( category ); 59 setCategories( category );
60 60
61 data = new OTodoData; 61 data = new OTodoData;
62 62
63 data->date = date; 63 data->date = date;
64 data->isCompleted = completed; 64 data->isCompleted = completed;
65 data->hasDate = hasDate; 65 data->hasDate = hasDate;
66 data->priority = priority; 66 data->priority = priority;
67 data->sum = summary; 67 data->sum = summary;
68 data->prog = progress; 68 data->prog = progress;
69 data->desc = Qtopia::simplifyMultiLineSpace(description ); 69 data->desc = Qtopia::simplifyMultiLineSpace(description );
70 data->hasAlarmDateTime = false; 70 data->hasAlarmDateTime = false;
71 71
72} 72}
73OTodo::OTodo(bool completed, int priority, 73OTodo::OTodo(bool completed, int priority,
74 const QStringList &category, 74 const QStringList &category,
75 const QString& summary, 75 const QString& summary,
76 const QString &description, 76 const QString &description,
77 ushort progress, 77 ushort progress,
78 bool hasDate, QDate date, int uid ) 78 bool hasDate, QDate date, int uid )
79 : OPimRecord( uid ) 79 : OPimRecord( uid )
80{ 80{
81// qWarning("OTodoData" + summary); 81// qWarning("OTodoData" + summary);
82 setCategories( idsFromString( category.join(";") ) ); 82 setCategories( idsFromString( category.join(";") ) );
83 83
84 data = new OTodoData; 84 data = new OTodoData;
85 85
86 data->date = date; 86 data->date = date;
87 data->isCompleted = completed; 87 data->isCompleted = completed;
88 data->hasDate = hasDate; 88 data->hasDate = hasDate;
89 data->priority = priority; 89 data->priority = priority;
90 data->sum = summary; 90 data->sum = summary;
91 data->prog = progress; 91 data->prog = progress;
92 data->desc = Qtopia::simplifyMultiLineSpace(description ); 92 data->desc = Qtopia::simplifyMultiLineSpace(description );
93 data->hasAlarmDateTime = false; 93 data->hasAlarmDateTime = false;
94 94
95} 95}
96bool OTodo::match( const QRegExp &regExp )const 96bool OTodo::match( const QRegExp &regExp )const
97{ 97{
98 if( QString::number( data->priority ).find( regExp ) != -1 ){ 98 if( QString::number( data->priority ).find( regExp ) != -1 ){
99 return true; 99 return true;
100 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 100 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
101 return true; 101 return true;
102 }else if(data->desc.find( regExp ) != -1 ){ 102 }else if(data->desc.find( regExp ) != -1 ){
103 return true; 103 return true;
104 }else if(data->sum.find( regExp ) != -1 ) { 104 }else if(data->sum.find( regExp ) != -1 ) {
105 return true; 105 return true;
106 } 106 }
107 return false; 107 return false;
108} 108}
109bool OTodo::isCompleted() const 109bool OTodo::isCompleted() const
110{ 110{
111 return data->isCompleted; 111 return data->isCompleted;
112} 112}
113bool OTodo::hasDueDate() const 113bool OTodo::hasDueDate() const
114{ 114{
115 return data->hasDate; 115 return data->hasDate;
116} 116}
117bool OTodo::hasAlarmDateTime() const 117bool OTodo::hasAlarmDateTime() const
118{ 118{
119 return data->hasAlarmDateTime; 119 return data->hasAlarmDateTime;
120} 120}
121int OTodo::priority()const 121int OTodo::priority()const
122{ 122{
123 return data->priority; 123 return data->priority;
124} 124}
125QString OTodo::summary() const 125QString OTodo::summary() const
126{ 126{
127 return data->sum; 127 return data->sum;
128} 128}
129ushort OTodo::progress() const 129ushort OTodo::progress() const
130{ 130{
131 return data->prog; 131 return data->prog;
132} 132}
133QDate OTodo::dueDate()const 133QDate OTodo::dueDate()const
134{ 134{
135 return data->date; 135 return data->date;
136} 136}
137 137
138QDateTime OTodo::alarmDateTime() const 138QDateTime OTodo::alarmDateTime() const
139{ 139{
140 return data->alarmDateTime; 140 return data->alarmDateTime;
141} 141}
142 142
143QString OTodo::description()const 143QString OTodo::description()const
144{ 144{
145 return data->desc; 145 return data->desc;
146} 146}
147void OTodo::setCompleted( bool completed ) 147void OTodo::setCompleted( bool completed )
148{ 148{
149 changeOrModify(); 149 changeOrModify();
150 data->isCompleted = completed; 150 data->isCompleted = completed;
151} 151}
152void OTodo::setHasDueDate( bool hasDate ) 152void OTodo::setHasDueDate( bool hasDate )
153{ 153{
154 changeOrModify(); 154 changeOrModify();
155 data->hasDate = hasDate; 155 data->hasDate = hasDate;
156} 156}
157void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) 157void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
158{ 158{
159 changeOrModify(); 159 changeOrModify();
160 data->hasAlarmDateTime = hasAlarmDateTime; 160 data->hasAlarmDateTime = hasAlarmDateTime;
161} 161}
162void OTodo::setDescription(const QString &desc ) 162void OTodo::setDescription(const QString &desc )
163{ 163{
164 qWarning( "desc " + desc ); 164// qWarning( "desc " + desc );
165 changeOrModify(); 165 changeOrModify();
166 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 166 data->desc = Qtopia::simplifyMultiLineSpace(desc );
167} 167}
168void OTodo::setSummary( const QString& sum ) 168void OTodo::setSummary( const QString& sum )
169{ 169{
170 changeOrModify(); 170 changeOrModify();
171 data->sum = sum; 171 data->sum = sum;
172} 172}
173void OTodo::setPriority(int prio ) 173void OTodo::setPriority(int prio )
174{ 174{
175 changeOrModify(); 175 changeOrModify();
176 data->priority = prio; 176 data->priority = prio;
177} 177}
178void OTodo::setDueDate( QDate date ) 178void OTodo::setDueDate( QDate date )
179{ 179{
180 changeOrModify(); 180 changeOrModify();
181 data->date = date; 181 data->date = date;
182} 182}
183void OTodo::setAlarmDateTime( const QDateTime& alarm ) 183void OTodo::setAlarmDateTime( const QDateTime& alarm )
184{ 184{
185 changeOrModify(); 185 changeOrModify();
186 data->alarmDateTime = alarm; 186 data->alarmDateTime = alarm;
187} 187}
188bool OTodo::isOverdue( ) 188bool OTodo::isOverdue( )
189{ 189{
190 if( data->hasDate ) 190 if( data->hasDate )
191 return QDate::currentDate() > data->date; 191 return QDate::currentDate() > data->date;
192 return false; 192 return false;
193} 193}
194void OTodo::setProgress(ushort progress ) 194void OTodo::setProgress(ushort progress )
195{ 195{
196 changeOrModify(); 196 changeOrModify();
197 data->prog = progress; 197 data->prog = progress;
198} 198}
199QString OTodo::toShortText() const { 199QString OTodo::toShortText() const {
200 return summary(); 200 return summary();
201} 201}
202/*! 202/*!
203 Returns a richt text string 203 Returns a richt text string
204*/ 204*/
205QString OTodo::toRichText() const 205QString OTodo::toRichText() const
206{ 206{
207 QString text; 207 QString text;
208 QStringList catlist; 208 QStringList catlist;
209 209
210 // Description of the todo 210 // Description of the todo
211 if ( !summary().isEmpty() ) { 211 if ( !summary().isEmpty() ) {
212 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 212 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
213 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 213 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
214 } 214 }
215 if( !description().isEmpty() ){ 215 if( !description().isEmpty() ){
216 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 216 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
217 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 217 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
218 } 218 }
219 text += "<br><br><br>"; 219 text += "<br><br><br>";
220 220
221 text += "<b>" + QObject::tr( "Priority:") +" </b>" 221 text += "<b>" + QObject::tr( "Priority:") +" </b>"
222 + QString::number( priority() ) + " <br>"; 222 + QString::number( priority() ) + " <br>";
223 text += "<b>" + QObject::tr( "Progress:") + " </b>" 223 text += "<b>" + QObject::tr( "Progress:") + " </b>"
224 + QString::number( progress() ) + " %<br>"; 224 + QString::number( progress() ) + " %<br>";
225 if (hasDueDate() ){ 225 if (hasDueDate() ){
226 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 226 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
227 text += dueDate().toString(); 227 text += dueDate().toString();
228 text += "<br>"; 228 text += "<br>";
229 } 229 }
230 if (hasAlarmDateTime() ){ 230 if (hasAlarmDateTime() ){
231 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; 231 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
232 text += alarmDateTime().toString(); 232 text += alarmDateTime().toString();
233 text += "<br>"; 233 text += "<br>";
234 } 234 }
235 235
236 text += "<b>" + QObject::tr( "Category:") + "</b> "; 236 text += "<b>" + QObject::tr( "Category:") + "</b> ";
237 text += categoryNames().join(", "); 237 text += categoryNames().join(", ");
238 text += "<br>"; 238 text += "<br>";
239 239
240 return text; 240 return text;
241} 241}
242 242
243bool OTodo::operator<( const OTodo &toDoEvent )const{ 243bool OTodo::operator<( const OTodo &toDoEvent )const{
244 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 244 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
245 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 245 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
246 if( hasDueDate() && toDoEvent.hasDueDate() ){ 246 if( hasDueDate() && toDoEvent.hasDueDate() ){
247 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 247 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
248 return priority() < toDoEvent.priority(); 248 return priority() < toDoEvent.priority();
249 }else{ 249 }else{
250 return dueDate() < toDoEvent.dueDate(); 250 return dueDate() < toDoEvent.dueDate();
251 } 251 }
252 } 252 }
253 return false; 253 return false;
254} 254}
255bool OTodo::operator<=(const OTodo &toDoEvent )const 255bool OTodo::operator<=(const OTodo &toDoEvent )const
256{ 256{
257 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 257 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
258 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 258 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
259 if( hasDueDate() && toDoEvent.hasDueDate() ){ 259 if( hasDueDate() && toDoEvent.hasDueDate() ){
260 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 260 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
261 return priority() <= toDoEvent.priority(); 261 return priority() <= toDoEvent.priority();
262 }else{ 262 }else{
263 return dueDate() <= toDoEvent.dueDate(); 263 return dueDate() <= toDoEvent.dueDate();
264 } 264 }
265 } 265 }
266 return true; 266 return true;
267} 267}
268bool OTodo::operator>(const OTodo &toDoEvent )const 268bool OTodo::operator>(const OTodo &toDoEvent )const
269{ 269{
270 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 270 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
271 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 271 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
272 if( hasDueDate() && toDoEvent.hasDueDate() ){ 272 if( hasDueDate() && toDoEvent.hasDueDate() ){
273 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 273 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
274 return priority() > toDoEvent.priority(); 274 return priority() > toDoEvent.priority();
275 }else{ 275 }else{
276 return dueDate() > toDoEvent.dueDate(); 276 return dueDate() > toDoEvent.dueDate();
277 } 277 }
278 } 278 }
279 return false; 279 return false;
280} 280}
281bool OTodo::operator>=(const OTodo &toDoEvent )const 281bool OTodo::operator>=(const OTodo &toDoEvent )const
282{ 282{
283 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 283 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
284 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 284 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
285 if( hasDueDate() && toDoEvent.hasDueDate() ){ 285 if( hasDueDate() && toDoEvent.hasDueDate() ){
286 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 286 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
287 return priority() > toDoEvent.priority(); 287 return priority() > toDoEvent.priority();
288 }else{ 288 }else{
289 return dueDate() > toDoEvent.dueDate(); 289 return dueDate() > toDoEvent.dueDate();
290 } 290 }
291 } 291 }
292 return true; 292 return true;
293} 293}
294bool OTodo::operator==(const OTodo &toDoEvent )const 294bool OTodo::operator==(const OTodo &toDoEvent )const
295{ 295{
296 if ( data->priority != toDoEvent.data->priority ) return false; 296 if ( data->priority != toDoEvent.data->priority ) return false;
297 if ( data->priority != toDoEvent.data->prog ) return false; 297 if ( data->priority != toDoEvent.data->prog ) return false;
298 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 298 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
299 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 299 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
300 if ( data->date != toDoEvent.data->date ) return false; 300 if ( data->date != toDoEvent.data->date ) return false;
301 if ( data->sum != toDoEvent.data->sum ) return false; 301 if ( data->sum != toDoEvent.data->sum ) return false;
302 if ( data->desc != toDoEvent.data->desc ) return false; 302 if ( data->desc != toDoEvent.data->desc ) return false;
303 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) 303 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
304 return false; 304 return false;
305 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) 305 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
306 return false; 306 return false;
307 307
308 return OPimRecord::operator==( toDoEvent ); 308 return OPimRecord::operator==( toDoEvent );
309} 309}
310void OTodo::deref() { 310void OTodo::deref() {
311 311
312// qWarning("deref in ToDoEvent"); 312// qWarning("deref in ToDoEvent");
313 if ( data->deref() ) { 313 if ( data->deref() ) {
314// qWarning("deleting"); 314// qWarning("deleting");
315 delete data; 315 delete data;
316 data= 0; 316 data= 0;
317 } 317 }
318} 318}
319OTodo &OTodo::operator=(const OTodo &item ) 319OTodo &OTodo::operator=(const OTodo &item )
320{ 320{
321// OPimRecord::operator=( item ); 321 OPimRecord::operator=( item );
322 //qWarning("operator= ref "); 322 //qWarning("operator= ref ");
323 item.data->ref(); 323 item.data->ref();
324 deref(); 324 deref();
325 data = item.data; 325 data = item.data;
326 326
327 return *this; 327 return *this;
328} 328}
329 329
330QMap<int, QString> OTodo::toMap() const { 330QMap<int, QString> OTodo::toMap() const {
331 QMap<int, QString> map; 331 QMap<int, QString> map;
332 332
333 map.insert( Uid, QString::number( uid() ) ); 333 map.insert( Uid, QString::number( uid() ) );
334 map.insert( Category, idsToString( categories() ) ); 334 map.insert( Category, idsToString( categories() ) );
335 map.insert( HasDate, QString::number( data->hasDate ) ); 335 map.insert( HasDate, QString::number( data->hasDate ) );
336 map.insert( Completed, QString::number( data->isCompleted ) ); 336 map.insert( Completed, QString::number( data->isCompleted ) );
337 map.insert( Description, data->desc ); 337 map.insert( Description, data->desc );
338 map.insert( Summary, data->sum ); 338 map.insert( Summary, data->sum );
339 map.insert( Priority, QString::number( data->priority ) ); 339 map.insert( Priority, QString::number( data->priority ) );
340 map.insert( DateDay, QString::number( data->date.day() ) ); 340 map.insert( DateDay, QString::number( data->date.day() ) );
341 map.insert( DateMonth, QString::number( data->date.month() ) ); 341 map.insert( DateMonth, QString::number( data->date.month() ) );
342 map.insert( DateYear, QString::number( data->date.year() ) ); 342 map.insert( DateYear, QString::number( data->date.year() ) );
343 map.insert( Progress, QString::number( data->prog ) ); 343 map.insert( Progress, QString::number( data->prog ) );
344 map.insert( CrossReference, crossToString() ); 344 map.insert( CrossReference, crossToString() );
345 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 345 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
346 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 346 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
347 347
348 return map; 348 return map;
349} 349}
350 350
351QMap<QString, QString> OTodo::toExtraMap()const { 351QMap<QString, QString> OTodo::toExtraMap()const {
352 return data->extra; 352 return data->extra;
353} 353}
354/** 354/**
355 * change or modify looks at the ref count and either 355 * change or modify looks at the ref count and either
356 * creates a new QShared Object or it can modify it 356 * creates a new QShared Object or it can modify it
357 * right in place 357 * right in place
358 */ 358 */
359void OTodo::changeOrModify() { 359void OTodo::changeOrModify() {
360 if ( data->count != 1 ) { 360 if ( data->count != 1 ) {
361// qWarning("changeOrModify"); 361// qWarning("changeOrModify");
362 data->deref(); 362 data->deref();
363 OTodoData* d2 = new OTodoData(); 363 OTodoData* d2 = new OTodoData();
364 copy(data, d2 ); 364 copy(data, d2 );
365 data = d2; 365 data = d2;
366 } 366 }
367} 367}
368void OTodo::copy( OTodoData* src, OTodoData* dest ) { 368void OTodo::copy( OTodoData* src, OTodoData* dest ) {
369 dest->date = src->date; 369 dest->date = src->date;
370 dest->isCompleted = src->isCompleted; 370 dest->isCompleted = src->isCompleted;
371 dest->hasDate = src->hasDate; 371 dest->hasDate = src->hasDate;
372 dest->priority = src->priority; 372 dest->priority = src->priority;
373 dest->desc = src->desc; 373 dest->desc = src->desc;
374 dest->sum = src->sum; 374 dest->sum = src->sum;
375 dest->extra = src->extra; 375 dest->extra = src->extra;
376 dest->prog = src->prog; 376 dest->prog = src->prog;
377 dest->hasAlarmDateTime = src->hasAlarmDateTime; 377 dest->hasAlarmDateTime = src->hasAlarmDateTime;
378 dest->alarmDateTime = src->alarmDateTime; 378 dest->alarmDateTime = src->alarmDateTime;
379} 379}
380QString OTodo::type() const { 380QString OTodo::type() const {
381 return QString::fromLatin1("OTodo"); 381 return QString::fromLatin1("OTodo");
382} 382}
383QString OTodo::recordField(int id )const { 383QString OTodo::recordField(int id )const {
384 return QString::null; 384 return QString::null;
385} 385}
386 386
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp
index a65cf5c..8ec09bc 100644
--- a/libopie/pim/otodoaccess.cpp
+++ b/libopie/pim/otodoaccess.cpp
@@ -1,71 +1,71 @@
1#include <qdatetime.h> 1#include <qdatetime.h>
2 2
3#include <qpe/alarmserver.h> 3#include <qpe/alarmserver.h>
4 4
5#include "otodoaccessxml.h" 5#include "otodoaccessxml.h"
6#include "otodoaccess.h" 6#include "otodoaccess.h"
7 7
8 8
9OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) 9OTodoAccess::OTodoAccess( OTodoAccessBackend* end )
10 : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) 10 : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end )
11{ 11{
12 if (end == 0l ) 12 if (end == 0l )
13 m_todoBackEnd = new OTodoAccessXML( "Todolist" ); 13 m_todoBackEnd = new OTodoAccessXML( "Todolist" );
14 14
15 setBackEnd( m_todoBackEnd ); 15 setBackEnd( m_todoBackEnd );
16} 16}
17OTodoAccess::~OTodoAccess() { 17OTodoAccess::~OTodoAccess() {
18 qWarning("~OTodoAccess"); 18// qWarning("~OTodoAccess");
19} 19}
20void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { 20void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) {
21 QValueList<OTodo>::ConstIterator it; 21 QValueList<OTodo>::ConstIterator it;
22 for ( it = list.begin(); it != list.end(); ++it ) { 22 for ( it = list.begin(); it != list.end(); ++it ) {
23 replace( (*it) ); 23 replace( (*it) );
24 } 24 }
25} 25}
26OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 26OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
27 const QDate& end, 27 const QDate& end,
28 bool includeNoDates ) { 28 bool includeNoDates ) {
29 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); 29 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
30 30
31 List lis( ints, this ); 31 List lis( ints, this );
32 return lis; 32 return lis;
33} 33}
34OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 34OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
35 bool includeNoDates ) { 35 bool includeNoDates ) {
36 return effectiveToDos( start, QDate::currentDate(), 36 return effectiveToDos( start, QDate::currentDate(),
37 includeNoDates ); 37 includeNoDates );
38} 38}
39OTodoAccess::List OTodoAccess::overDue() { 39OTodoAccess::List OTodoAccess::overDue() {
40 List lis( m_todoBackEnd->overDue(), this ); 40 List lis( m_todoBackEnd->overDue(), this );
41 return lis; 41 return lis;
42} 42}
43void OTodoAccess::addAlarm( const OTodo& event) { 43void OTodoAccess::addAlarm( const OTodo& event) {
44 if (!event.hasAlarmDateTime() ) 44 if (!event.hasAlarmDateTime() )
45 return; 45 return;
46 46
47 QDateTime now = QDateTime::currentDateTime(); 47 QDateTime now = QDateTime::currentDateTime();
48 QDateTime schedule = event.alarmDateTime(); 48 QDateTime schedule = event.alarmDateTime();
49 49
50 if ( schedule > now ){ 50 if ( schedule > now ){
51 AlarmServer::addAlarm( schedule, 51 AlarmServer::addAlarm( schedule,
52 "QPE/Application/todolist", 52 "QPE/Application/todolist",
53 "alarm(QDateTime,int)", event.uid() ); 53 "alarm(QDateTime,int)", event.uid() );
54 54
55 } 55 }
56} 56}
57void OTodoAccess::delAlarm( int uid) { 57void OTodoAccess::delAlarm( int uid) {
58 58
59 QDateTime schedule; // Create null DateTime 59 QDateTime schedule; // Create null DateTime
60 60
61 // I hope this will remove all scheduled alarms 61 // I hope this will remove all scheduled alarms
62 // with the given uid !? 62 // with the given uid !?
63 // If not: I have to rethink how to remove already 63 // If not: I have to rethink how to remove already
64 // scheduled events... (se) 64 // scheduled events... (se)
65 // it should be fine -zecke 65 // it should be fine -zecke
66 qWarning("Removing alarm for event with uid %d", uid ); 66// qWarning("Removing alarm for event with uid %d", uid );
67 AlarmServer::deleteAlarm( schedule , 67 AlarmServer::deleteAlarm( schedule ,
68 "QPE/Application/todolist", 68 "QPE/Application/todolist",
69 "alarm(QDateTime,int)", uid ); 69 "alarm(QDateTime,int)", uid );
70} 70}
71 71
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 3a72881..5fe733c 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -1,362 +1,366 @@
1#include <qfile.h> 1#include <qfile.h>
2 2
3#include <qpe/global.h> 3#include <qpe/global.h>
4#include <qpe/stringutil.h> 4#include <qpe/stringutil.h>
5#include <qpe/timeconversion.h> 5#include <qpe/timeconversion.h>
6 6
7#include <opie/xmltree.h> 7#include <opie/xmltree.h>
8 8
9#include "otodoaccessxml.h" 9#include "otodoaccessxml.h"
10 10
11OTodoAccessXML::OTodoAccessXML( const QString& appName, 11OTodoAccessXML::OTodoAccessXML( const QString& appName,
12 const QString& fileName ) 12 const QString& fileName )
13 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) 13 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
14{ 14{
15 if (!fileName.isEmpty() ) 15 if (!fileName.isEmpty() )
16 m_file = fileName; 16 m_file = fileName;
17 else 17 else
18 m_file = Global::applicationFileName( "todolist", "todolist.xml" ); 18 m_file = Global::applicationFileName( "todolist", "todolist.xml" );
19} 19}
20OTodoAccessXML::~OTodoAccessXML() { 20OTodoAccessXML::~OTodoAccessXML() {
21 21
22} 22}
23bool OTodoAccessXML::load() { 23bool OTodoAccessXML::load() {
24 m_opened = false; 24 m_opened = true;
25 m_changed = false; 25 m_changed = false;
26 /* initialize dict */ 26 /* initialize dict */
27 /* 27 /*
28 * UPDATE dict if you change anything!!! 28 * UPDATE dict if you change anything!!!
29 */ 29 */
30 QAsciiDict<int> dict(15); 30 QAsciiDict<int> dict(15);
31 dict.setAutoDelete( TRUE ); 31 dict.setAutoDelete( TRUE );
32 dict.insert("Categories" , new int(OTodo::Category) ); 32 dict.insert("Categories" , new int(OTodo::Category) );
33 dict.insert("Uid" , new int(OTodo::Uid) ); 33 dict.insert("Uid" , new int(OTodo::Uid) );
34 dict.insert("HasDate" , new int(OTodo::HasDate) ); 34 dict.insert("HasDate" , new int(OTodo::HasDate) );
35 dict.insert("Completed" , new int(OTodo::Completed) ); 35 dict.insert("Completed" , new int(OTodo::Completed) );
36 dict.insert("Description" , new int(OTodo::Description) ); 36 dict.insert("Description" , new int(OTodo::Description) );
37 dict.insert("Summary" , new int(OTodo::Summary) ); 37 dict.insert("Summary" , new int(OTodo::Summary) );
38 dict.insert("Priority" , new int(OTodo::Priority) ); 38 dict.insert("Priority" , new int(OTodo::Priority) );
39 dict.insert("DateDay" , new int(OTodo::DateDay) ); 39 dict.insert("DateDay" , new int(OTodo::DateDay) );
40 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 40 dict.insert("DateMonth" , new int(OTodo::DateMonth) );
41 dict.insert("DateYear" , new int(OTodo::DateYear) ); 41 dict.insert("DateYear" , new int(OTodo::DateYear) );
42 dict.insert("Progress" , new int(OTodo::Progress) ); 42 dict.insert("Progress" , new int(OTodo::Progress) );
43 dict.insert("Completed", new int(OTodo::Completed) ); 43 dict.insert("Completed", new int(OTodo::Completed) );
44 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 44 dict.insert("CrossReference", new int(OTodo::CrossReference) );
45 dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); 45 dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) );
46 dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); 46 dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) );
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 }else { 71 }else {
72 qWarning("could not parse"); 72// qWarning("could not parse");
73 return false;; 73 return false;;
74 } 74 }
75 delete root; 75 delete root;
76 76
77 m_opened = true; 77// qWarning("Access %d" + m_events.count() );
78 qWarning("Access %d" + m_events.count() );
79 return true; 78 return true;
80} 79}
81bool OTodoAccessXML::reload() { 80bool OTodoAccessXML::reload() {
82 return load(); 81 return load();
83} 82}
84bool OTodoAccessXML::save() { 83bool OTodoAccessXML::save() {
85 if (!m_opened || !m_changed ) 84// qWarning("saving");
85 if (!m_opened || !m_changed ) {
86// qWarning("not saving");
86 return true; 87 return true;
88 }
87 QString strNewFile = m_file + ".new"; 89 QString strNewFile = m_file + ".new";
88 QFile f( strNewFile ); 90 QFile f( strNewFile );
89 if (!f.open( IO_WriteOnly|IO_Raw ) ) 91 if (!f.open( IO_WriteOnly|IO_Raw ) )
90 return false; 92 return false;
91 93
92 int written; 94 int written;
93 QString out; 95 QString out;
94 out = "<!DOCTYPE Tasks>\n<Tasks>\n"; 96 out = "<!DOCTYPE Tasks>\n<Tasks>\n";
95 97
96 // for all todos 98 // for all todos
97 QMap<int, OTodo>::Iterator it; 99 QMap<int, OTodo>::Iterator it;
98 for (it = m_events.begin(); it != m_events.end(); ++it ) { 100 for (it = m_events.begin(); it != m_events.end(); ++it ) {
99 out+= "<Task " + toString( (*it) ) + " />\n"; 101 out+= "<Task " + toString( (*it) ) + " />\n";
100 QCString cstr = out.utf8(); 102 QCString cstr = out.utf8();
101 written = f.writeBlock( cstr.data(), cstr.length() ); 103 written = f.writeBlock( cstr.data(), cstr.length() );
102 104
103 /* less written then we wanted */ 105 /* less written then we wanted */
104 if ( written != (int)cstr.length() ) { 106 if ( written != (int)cstr.length() ) {
105 f.close(); 107 f.close();
106 QFile::remove( strNewFile ); 108 QFile::remove( strNewFile );
107 return false; 109 return false;
108 } 110 }
109 out = QString::null; 111 out = QString::null;
110 } 112 }
111 113
112 out += "</Tasks>"; 114 out += "</Tasks>";
113 QCString cstr = out.utf8(); 115 QCString cstr = out.utf8();
114 written = f.writeBlock( cstr.data(), cstr.length() ); 116 written = f.writeBlock( cstr.data(), cstr.length() );
115 117
116 if ( written != (int)cstr.length() ) { 118 if ( written != (int)cstr.length() ) {
117 f.close(); 119 f.close();
118 QFile::remove( strNewFile ); 120 QFile::remove( strNewFile );
119 return false; 121 return false;
120 } 122 }
121 /* flush before renaming */ 123 /* flush before renaming */
122 f.close(); 124 f.close();
123 125
124 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 126 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
125 qWarning("error renaming"); 127// qWarning("error renaming");
126 QFile::remove( strNewFile ); 128 QFile::remove( strNewFile );
127 } 129 }
128 130
129 m_changed = false; 131 m_changed = false;
130 return true; 132 return true;
131} 133}
132QArray<int> OTodoAccessXML::allRecords()const { 134QArray<int> OTodoAccessXML::allRecords()const {
133 QArray<int> ids( m_events.count() ); 135 QArray<int> ids( m_events.count() );
134 QMap<int, OTodo>::ConstIterator it; 136 QMap<int, OTodo>::ConstIterator it;
135 int i = 0; 137 int i = 0;
136 138
137 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 139 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
138 ids[i] = it.key(); 140 ids[i] = it.key();
139 i++; 141 i++;
140 } 142 }
141 return ids; 143 return ids;
142} 144}
143QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) { 145QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) {
144 QArray<int> ids(0); 146 QArray<int> ids(0);
145 return ids; 147 return ids;
146} 148}
147OTodo OTodoAccessXML::find( int uid )const { 149OTodo OTodoAccessXML::find( int uid )const {
148 OTodo todo; 150 OTodo todo;
149 todo.setUid( 0 ); // isEmpty() 151 todo.setUid( 0 ); // isEmpty()
150 QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); 152 QMap<int, OTodo>::ConstIterator it = m_events.find( uid );
151 if ( it != m_events.end() ) 153 if ( it != m_events.end() )
152 todo = it.data(); 154 todo = it.data();
153 155
154 return todo; 156 return todo;
155} 157}
156void OTodoAccessXML::clear() { 158void OTodoAccessXML::clear() {
157 if (m_opened ) 159 if (m_opened )
158 m_changed = true; 160 m_changed = true;
159 161
160 m_events.clear(); 162 m_events.clear();
161} 163}
162bool OTodoAccessXML::add( const OTodo& todo ) { 164bool OTodoAccessXML::add( const OTodo& todo ) {
165// qWarning("add");
163 m_changed = true; 166 m_changed = true;
164 m_events.insert( todo.uid(), todo ); 167 m_events.insert( todo.uid(), todo );
165 168
166 return true; 169 return true;
167} 170}
168bool OTodoAccessXML::remove( int uid ) { 171bool OTodoAccessXML::remove( int uid ) {
169 m_changed = true; 172 m_changed = true;
170 m_events.remove( uid ); 173 m_events.remove( uid );
171 174
172 return true; 175 return true;
173} 176}
174bool OTodoAccessXML::replace( const OTodo& todo) { 177bool OTodoAccessXML::replace( const OTodo& todo) {
175 m_changed = true; 178 m_changed = true;
176 m_events.replace( todo.uid(), todo ); 179 m_events.replace( todo.uid(), todo );
177 180
178 return true; 181 return true;
179} 182}
180QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, 183QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start,
181 const QDate& end, 184 const QDate& end,
182 bool includeNoDates ) { 185 bool includeNoDates ) {
183 QArray<int> ids( m_events.count() ); 186 QArray<int> ids( m_events.count() );
184 QMap<int, OTodo>::Iterator it; 187 QMap<int, OTodo>::Iterator it;
185 188
186 int i = 0; 189 int i = 0;
187 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 190 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
188 if ( !it.data().hasDueDate() ) { 191 if ( !it.data().hasDueDate() ) {
189 if ( includeNoDates ) { 192 if ( includeNoDates ) {
190 ids[i] = it.key(); 193 ids[i] = it.key();
191 i++; 194 i++;
192 } 195 }
193 }else if ( it.data().dueDate() >= start && 196 }else if ( it.data().dueDate() >= start &&
194 it.data().dueDate() <= end ) { 197 it.data().dueDate() <= end ) {
195 ids[i] = it.key(); 198 ids[i] = it.key();
196 i++; 199 i++;
197 } 200 }
198 } 201 }
199 ids.resize( i ); 202 ids.resize( i );
200 return ids; 203 return ids;
201} 204}
202QArray<int> OTodoAccessXML::overDue() { 205QArray<int> OTodoAccessXML::overDue() {
203 QArray<int> ids( m_events.count() ); 206 QArray<int> ids( m_events.count() );
204 int i = 0; 207 int i = 0;
205 208
206 QMap<int, OTodo>::Iterator it; 209 QMap<int, OTodo>::Iterator it;
207 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 210 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
208 if ( it.data().isOverdue() ) { 211 if ( it.data().isOverdue() ) {
209 ids[i] = it.key(); 212 ids[i] = it.key();
210 i++; 213 i++;
211 } 214 }
212 } 215 }
213 ids.resize( i ); 216 ids.resize( i );
214 return ids; 217 return ids;
215} 218}
216 219
217 220
218/* private */ 221/* private */
219OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const { 222OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const {
220 qWarning("parse to do from XMLElement" ); 223// qWarning("parse to do from XMLElement" );
221 OTodo ev; 224 OTodo ev;
222 QMap<QString, QString> attributes = element->attributes(); 225 QMap<QString, QString> attributes = element->attributes();
223 QMap<QString, QString>::Iterator it; 226 QMap<QString, QString>::Iterator it;
224 227
225 int *find=0; 228 int *find=0;
226 int day, month, year; 229 int day, month, year;
227 day = month = year = -1; 230 day = month = year = -1;
228 for ( it = attributes.begin(); it != attributes.end(); ++it ) { 231 for ( it = attributes.begin(); it != attributes.end(); ++it ) {
229 find = (*dict)[ it.key() ]; 232 find = (*dict)[ it.key() ];
230 if (!find ) { 233 if (!find ) {
231 qWarning("Unknown option" + it.key() ); 234// qWarning("Unknown option" + it.key() );
232 ev.setCustomField( it.key(), it.data() ); 235 ev.setCustomField( it.key(), it.data() );
233 continue; 236 continue;
234 } 237 }
235 238
236 switch( *find ) { 239 switch( *find ) {
237 case OTodo::Uid: 240 case OTodo::Uid:
238 ev.setUid( it.data().toInt() ); 241 ev.setUid( it.data().toInt() );
239 break; 242 break;
240 case OTodo::Category: 243 case OTodo::Category:
241 ev.setCategories( ev.idsFromString( it.data() ) ); 244 ev.setCategories( ev.idsFromString( it.data() ) );
242 break; 245 break;
243 case OTodo::HasDate: 246 case OTodo::HasDate:
244 ev.setHasDueDate( it.data().toInt() ); 247 ev.setHasDueDate( it.data().toInt() );
245 break; 248 break;
246 case OTodo::Completed: 249 case OTodo::Completed:
247 ev.setCompleted( it.data().toInt() ); 250 ev.setCompleted( it.data().toInt() );
248 break; 251 break;
249 case OTodo::Description: 252 case OTodo::Description:
250 ev.setDescription( it.data() ); 253 ev.setDescription( it.data() );
251 break; 254 break;
252 case OTodo::Summary: 255 case OTodo::Summary:
253 ev.setSummary( it.data() ); 256 ev.setSummary( it.data() );
254 break; 257 break;
255 case OTodo::Priority: 258 case OTodo::Priority:
256 ev.setPriority( it.data().toInt() ); 259 ev.setPriority( it.data().toInt() );
257 break; 260 break;
258 case OTodo::DateDay: 261 case OTodo::DateDay:
259 day = it.data().toInt(); 262 day = it.data().toInt();
260 break; 263 break;
261 case OTodo::DateMonth: 264 case OTodo::DateMonth:
262 month = it.data().toInt(); 265 month = it.data().toInt();
263 break; 266 break;
264 case OTodo::DateYear: 267 case OTodo::DateYear:
265 year = it.data().toInt(); 268 year = it.data().toInt();
266 break; 269 break;
267 case OTodo::Progress: 270 case OTodo::Progress:
268 ev.setProgress( it.data().toInt() ); 271 ev.setProgress( it.data().toInt() );
269 break; 272 break;
270 case OTodo::CrossReference: 273 case OTodo::CrossReference:
271 { 274 {
272 /* 275 /*
273 * A cross refernce looks like 276 * A cross refernce looks like
274 * appname,id;appname,id 277 * appname,id;appname,id
275 * we need to split it up 278 * we need to split it up
276 */ 279 */
277 QStringList refs = QStringList::split(';', it.data() ); 280 QStringList refs = QStringList::split(';', it.data() );
278 QStringList::Iterator strIt; 281 QStringList::Iterator strIt;
279 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { 282 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
280 int pos = (*strIt).find(','); 283 int pos = (*strIt).find(',');
281 if ( pos > -1 ) 284 if ( pos > -1 )
282 ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); 285 ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
283 286
284 } 287 }
285 break; 288 break;
286 } 289 }
287 case OTodo::HasAlarmDateTime: 290 case OTodo::HasAlarmDateTime:
288 ev.setHasAlarmDateTime( it.data().toInt() ); 291 ev.setHasAlarmDateTime( it.data().toInt() );
289 break; 292 break;
290 case OTodo::AlarmDateTime: { 293 case OTodo::AlarmDateTime: {
291 /* this sounds better ;) zecke */ 294 /* this sounds better ;) zecke */
292 ev.setAlarmDateTime( TimeConversion::fromISO8601( it.data().local8Bit() ) ); 295 ev.setAlarmDateTime( TimeConversion::fromISO8601( it.data().local8Bit() ) );
293 break; 296 break;
294 } 297 }
295 default: 298 default:
296 break; 299 break;
297 } 300 }
298 } 301 }
299 if ( ev.hasDueDate() ) { 302 if ( ev.hasDueDate() ) {
300 QDate date( year, month, day ); 303 QDate date( year, month, day );
301 ev.setDueDate( date ); 304 ev.setDueDate( date );
302 } 305 }
303 306
304 return ev; 307 return ev;
305} 308}
306QString OTodoAccessXML::toString( const OTodo& ev )const { 309QString OTodoAccessXML::toString( const OTodo& ev )const {
307 QString str; 310 QString str;
308 311
309 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 312 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
310 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; 313 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
311 str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; 314 str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
312 str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; 315 str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
313 316
314 str += "Categories=\"" + toString( ev.categories() ) + "\" "; 317 str += "Categories=\"" + toString( ev.categories() ) + "\" ";
315 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; 318 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
316 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; 319 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
317 320
318 if ( ev.hasDueDate() ) { 321 if ( ev.hasDueDate() ) {
319 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; 322 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
320 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 323 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
321 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 324 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
322 } 325 }
326// qWarning( "Uid %d", ev.uid() );
323 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 327 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
324 328
325// append the extra options 329// append the extra options
326 /* FIXME Qtopia::Record this is currently not 330 /* FIXME Qtopia::Record this is currently not
327 * possible you can set custom fields 331 * possible you can set custom fields
328 * but don' iterate over the list 332 * but don' iterate over the list
329 * I may do #define private protected 333 * I may do #define private protected
330 * for this case - cough --zecke 334 * for this case - cough --zecke
331 */ 335 */
332 /* 336 /*
333 QMap<QString, QString> extras = ev.extras(); 337 QMap<QString, QString> extras = ev.extras();
334 QMap<QString, QString>::Iterator extIt; 338 QMap<QString, QString>::Iterator extIt;
335 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 339 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
336 str += extIt.key() + "=\"" + extIt.data() + "\" "; 340 str += extIt.key() + "=\"" + extIt.data() + "\" ";
337 */ 341 */
338 // cross refernce 342 // cross refernce
339 QStringList list = ev.relatedApps(); 343 QStringList list = ev.relatedApps();
340 QStringList::Iterator listIt; 344 QStringList::Iterator listIt;
341 QString refs; 345 QString refs;
342 str += "CrossReference=\""; 346 str += "CrossReference=\"";
343 bool added = false; 347 bool added = false;
344 for ( listIt = list.begin(); listIt != list.end(); ++listIt ) { 348 for ( listIt = list.begin(); listIt != list.end(); ++listIt ) {
345 added = true; 349 added = true;
346 QArray<int> ints = ev.relations( (*listIt) ); 350 QArray<int> ints = ev.relations( (*listIt) );
347 for ( uint i = 0; i< ints.count(); i++ ) { 351 for ( uint i = 0; i< ints.count(); i++ ) {
348 str += (*listIt) + "," + QString::number( i ) + ";"; 352 str += (*listIt) + "," + QString::number( i ) + ";";
349 } 353 }
350 } 354 }
351 if ( added ) 355 if ( added )
352 str = str.remove( str.length()-1, 1 ); 356 str = str.remove( str.length()-1, 1 );
353 357
354 str += "\" "; 358 str += "\" ";
355 359
356 str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" "; 360 str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" ";
357 361
358 return str; 362 return str;
359} 363}
360QString OTodoAccessXML::toString( const QArray<int>& ints ) const { 364QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
361 return Qtopia::Record::idsToString( ints ); 365 return Qtopia::Record::idsToString( ints );
362} 366}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 3a72881..5fe733c 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -1,362 +1,366 @@
1#include <qfile.h> 1#include <qfile.h>
2 2
3#include <qpe/global.h> 3#include <qpe/global.h>
4#include <qpe/stringutil.h> 4#include <qpe/stringutil.h>
5#include <qpe/timeconversion.h> 5#include <qpe/timeconversion.h>
6 6
7#include <opie/xmltree.h> 7#include <opie/xmltree.h>
8 8
9#include "otodoaccessxml.h" 9#include "otodoaccessxml.h"
10 10
11OTodoAccessXML::OTodoAccessXML( const QString& appName, 11OTodoAccessXML::OTodoAccessXML( const QString& appName,
12 const QString& fileName ) 12 const QString& fileName )
13 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) 13 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
14{ 14{
15 if (!fileName.isEmpty() ) 15 if (!fileName.isEmpty() )
16 m_file = fileName; 16 m_file = fileName;
17 else 17 else
18 m_file = Global::applicationFileName( "todolist", "todolist.xml" ); 18 m_file = Global::applicationFileName( "todolist", "todolist.xml" );
19} 19}
20OTodoAccessXML::~OTodoAccessXML() { 20OTodoAccessXML::~OTodoAccessXML() {
21 21
22} 22}
23bool OTodoAccessXML::load() { 23bool OTodoAccessXML::load() {
24 m_opened = false; 24 m_opened = true;
25 m_changed = false; 25 m_changed = false;
26 /* initialize dict */ 26 /* initialize dict */
27 /* 27 /*
28 * UPDATE dict if you change anything!!! 28 * UPDATE dict if you change anything!!!
29 */ 29 */
30 QAsciiDict<int> dict(15); 30 QAsciiDict<int> dict(15);
31 dict.setAutoDelete( TRUE ); 31 dict.setAutoDelete( TRUE );
32 dict.insert("Categories" , new int(OTodo::Category) ); 32 dict.insert("Categories" , new int(OTodo::Category) );
33 dict.insert("Uid" , new int(OTodo::Uid) ); 33 dict.insert("Uid" , new int(OTodo::Uid) );
34 dict.insert("HasDate" , new int(OTodo::HasDate) ); 34 dict.insert("HasDate" , new int(OTodo::HasDate) );
35 dict.insert("Completed" , new int(OTodo::Completed) ); 35 dict.insert("Completed" , new int(OTodo::Completed) );
36 dict.insert("Description" , new int(OTodo::Description) ); 36 dict.insert("Description" , new int(OTodo::Description) );
37 dict.insert("Summary" , new int(OTodo::Summary) ); 37 dict.insert("Summary" , new int(OTodo::Summary) );
38 dict.insert("Priority" , new int(OTodo::Priority) ); 38 dict.insert("Priority" , new int(OTodo::Priority) );
39 dict.insert("DateDay" , new int(OTodo::DateDay) ); 39 dict.insert("DateDay" , new int(OTodo::DateDay) );
40 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 40 dict.insert("DateMonth" , new int(OTodo::DateMonth) );
41 dict.insert("DateYear" , new int(OTodo::DateYear) ); 41 dict.insert("DateYear" , new int(OTodo::DateYear) );
42 dict.insert("Progress" , new int(OTodo::Progress) ); 42 dict.insert("Progress" , new int(OTodo::Progress) );
43 dict.insert("Completed", new int(OTodo::Completed) ); 43 dict.insert("Completed", new int(OTodo::Completed) );
44 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 44 dict.insert("CrossReference", new int(OTodo::CrossReference) );
45 dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); 45 dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) );
46 dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); 46 dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) );
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 }else { 71 }else {
72 qWarning("could not parse"); 72// qWarning("could not parse");
73 return false;; 73 return false;;
74 } 74 }
75 delete root; 75 delete root;
76 76
77 m_opened = true; 77// qWarning("Access %d" + m_events.count() );
78 qWarning("Access %d" + m_events.count() );
79 return true; 78 return true;
80} 79}
81bool OTodoAccessXML::reload() { 80bool OTodoAccessXML::reload() {
82 return load(); 81 return load();
83} 82}
84bool OTodoAccessXML::save() { 83bool OTodoAccessXML::save() {
85 if (!m_opened || !m_changed ) 84// qWarning("saving");
85 if (!m_opened || !m_changed ) {
86// qWarning("not saving");
86 return true; 87 return true;
88 }
87 QString strNewFile = m_file + ".new"; 89 QString strNewFile = m_file + ".new";
88 QFile f( strNewFile ); 90 QFile f( strNewFile );
89 if (!f.open( IO_WriteOnly|IO_Raw ) ) 91 if (!f.open( IO_WriteOnly|IO_Raw ) )
90 return false; 92 return false;
91 93
92 int written; 94 int written;
93 QString out; 95 QString out;
94 out = "<!DOCTYPE Tasks>\n<Tasks>\n"; 96 out = "<!DOCTYPE Tasks>\n<Tasks>\n";
95 97
96 // for all todos 98 // for all todos
97 QMap<int, OTodo>::Iterator it; 99 QMap<int, OTodo>::Iterator it;
98 for (it = m_events.begin(); it != m_events.end(); ++it ) { 100 for (it = m_events.begin(); it != m_events.end(); ++it ) {
99 out+= "<Task " + toString( (*it) ) + " />\n"; 101 out+= "<Task " + toString( (*it) ) + " />\n";
100 QCString cstr = out.utf8(); 102 QCString cstr = out.utf8();
101 written = f.writeBlock( cstr.data(), cstr.length() ); 103 written = f.writeBlock( cstr.data(), cstr.length() );
102 104
103 /* less written then we wanted */ 105 /* less written then we wanted */
104 if ( written != (int)cstr.length() ) { 106 if ( written != (int)cstr.length() ) {
105 f.close(); 107 f.close();
106 QFile::remove( strNewFile ); 108 QFile::remove( strNewFile );
107 return false; 109 return false;
108 } 110 }
109 out = QString::null; 111 out = QString::null;
110 } 112 }
111 113
112 out += "</Tasks>"; 114 out += "</Tasks>";
113 QCString cstr = out.utf8(); 115 QCString cstr = out.utf8();
114 written = f.writeBlock( cstr.data(), cstr.length() ); 116 written = f.writeBlock( cstr.data(), cstr.length() );
115 117
116 if ( written != (int)cstr.length() ) { 118 if ( written != (int)cstr.length() ) {
117 f.close(); 119 f.close();
118 QFile::remove( strNewFile ); 120 QFile::remove( strNewFile );
119 return false; 121 return false;
120 } 122 }
121 /* flush before renaming */ 123 /* flush before renaming */
122 f.close(); 124 f.close();
123 125
124 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 126 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
125 qWarning("error renaming"); 127// qWarning("error renaming");
126 QFile::remove( strNewFile ); 128 QFile::remove( strNewFile );
127 } 129 }
128 130
129 m_changed = false; 131 m_changed = false;
130 return true; 132 return true;
131} 133}
132QArray<int> OTodoAccessXML::allRecords()const { 134QArray<int> OTodoAccessXML::allRecords()const {
133 QArray<int> ids( m_events.count() ); 135 QArray<int> ids( m_events.count() );
134 QMap<int, OTodo>::ConstIterator it; 136 QMap<int, OTodo>::ConstIterator it;
135 int i = 0; 137 int i = 0;
136 138
137 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 139 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
138 ids[i] = it.key(); 140 ids[i] = it.key();
139 i++; 141 i++;
140 } 142 }
141 return ids; 143 return ids;
142} 144}
143QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) { 145QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int sort ) {
144 QArray<int> ids(0); 146 QArray<int> ids(0);
145 return ids; 147 return ids;
146} 148}
147OTodo OTodoAccessXML::find( int uid )const { 149OTodo OTodoAccessXML::find( int uid )const {
148 OTodo todo; 150 OTodo todo;
149 todo.setUid( 0 ); // isEmpty() 151 todo.setUid( 0 ); // isEmpty()
150 QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); 152 QMap<int, OTodo>::ConstIterator it = m_events.find( uid );
151 if ( it != m_events.end() ) 153 if ( it != m_events.end() )
152 todo = it.data(); 154 todo = it.data();
153 155
154 return todo; 156 return todo;
155} 157}
156void OTodoAccessXML::clear() { 158void OTodoAccessXML::clear() {
157 if (m_opened ) 159 if (m_opened )
158 m_changed = true; 160 m_changed = true;
159 161
160 m_events.clear(); 162 m_events.clear();
161} 163}
162bool OTodoAccessXML::add( const OTodo& todo ) { 164bool OTodoAccessXML::add( const OTodo& todo ) {
165// qWarning("add");
163 m_changed = true; 166 m_changed = true;
164 m_events.insert( todo.uid(), todo ); 167 m_events.insert( todo.uid(), todo );
165 168
166 return true; 169 return true;
167} 170}
168bool OTodoAccessXML::remove( int uid ) { 171bool OTodoAccessXML::remove( int uid ) {
169 m_changed = true; 172 m_changed = true;
170 m_events.remove( uid ); 173 m_events.remove( uid );
171 174
172 return true; 175 return true;
173} 176}
174bool OTodoAccessXML::replace( const OTodo& todo) { 177bool OTodoAccessXML::replace( const OTodo& todo) {
175 m_changed = true; 178 m_changed = true;
176 m_events.replace( todo.uid(), todo ); 179 m_events.replace( todo.uid(), todo );
177 180
178 return true; 181 return true;
179} 182}
180QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, 183QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start,
181 const QDate& end, 184 const QDate& end,
182 bool includeNoDates ) { 185 bool includeNoDates ) {
183 QArray<int> ids( m_events.count() ); 186 QArray<int> ids( m_events.count() );
184 QMap<int, OTodo>::Iterator it; 187 QMap<int, OTodo>::Iterator it;
185 188
186 int i = 0; 189 int i = 0;
187 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 190 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
188 if ( !it.data().hasDueDate() ) { 191 if ( !it.data().hasDueDate() ) {
189 if ( includeNoDates ) { 192 if ( includeNoDates ) {
190 ids[i] = it.key(); 193 ids[i] = it.key();
191 i++; 194 i++;
192 } 195 }
193 }else if ( it.data().dueDate() >= start && 196 }else if ( it.data().dueDate() >= start &&
194 it.data().dueDate() <= end ) { 197 it.data().dueDate() <= end ) {
195 ids[i] = it.key(); 198 ids[i] = it.key();
196 i++; 199 i++;
197 } 200 }
198 } 201 }
199 ids.resize( i ); 202 ids.resize( i );
200 return ids; 203 return ids;
201} 204}
202QArray<int> OTodoAccessXML::overDue() { 205QArray<int> OTodoAccessXML::overDue() {
203 QArray<int> ids( m_events.count() ); 206 QArray<int> ids( m_events.count() );
204 int i = 0; 207 int i = 0;
205 208
206 QMap<int, OTodo>::Iterator it; 209 QMap<int, OTodo>::Iterator it;
207 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 210 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
208 if ( it.data().isOverdue() ) { 211 if ( it.data().isOverdue() ) {
209 ids[i] = it.key(); 212 ids[i] = it.key();
210 i++; 213 i++;
211 } 214 }
212 } 215 }
213 ids.resize( i ); 216 ids.resize( i );
214 return ids; 217 return ids;
215} 218}
216 219
217 220
218/* private */ 221/* private */
219OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const { 222OTodo OTodoAccessXML::todo( QAsciiDict<int>* dict, Opie::XMLElement* element)const {
220 qWarning("parse to do from XMLElement" ); 223// qWarning("parse to do from XMLElement" );
221 OTodo ev; 224 OTodo ev;
222 QMap<QString, QString> attributes = element->attributes(); 225 QMap<QString, QString> attributes = element->attributes();
223 QMap<QString, QString>::Iterator it; 226 QMap<QString, QString>::Iterator it;
224 227
225 int *find=0; 228 int *find=0;
226 int day, month, year; 229 int day, month, year;
227 day = month = year = -1; 230 day = month = year = -1;
228 for ( it = attributes.begin(); it != attributes.end(); ++it ) { 231 for ( it = attributes.begin(); it != attributes.end(); ++it ) {
229 find = (*dict)[ it.key() ]; 232 find = (*dict)[ it.key() ];
230 if (!find ) { 233 if (!find ) {
231 qWarning("Unknown option" + it.key() ); 234// qWarning("Unknown option" + it.key() );
232 ev.setCustomField( it.key(), it.data() ); 235 ev.setCustomField( it.key(), it.data() );
233 continue; 236 continue;
234 } 237 }
235 238
236 switch( *find ) { 239 switch( *find ) {
237 case OTodo::Uid: 240 case OTodo::Uid:
238 ev.setUid( it.data().toInt() ); 241 ev.setUid( it.data().toInt() );
239 break; 242 break;
240 case OTodo::Category: 243 case OTodo::Category:
241 ev.setCategories( ev.idsFromString( it.data() ) ); 244 ev.setCategories( ev.idsFromString( it.data() ) );
242 break; 245 break;
243 case OTodo::HasDate: 246 case OTodo::HasDate:
244 ev.setHasDueDate( it.data().toInt() ); 247 ev.setHasDueDate( it.data().toInt() );
245 break; 248 break;
246 case OTodo::Completed: 249 case OTodo::Completed:
247 ev.setCompleted( it.data().toInt() ); 250 ev.setCompleted( it.data().toInt() );
248 break; 251 break;
249 case OTodo::Description: 252 case OTodo::Description:
250 ev.setDescription( it.data() ); 253 ev.setDescription( it.data() );
251 break; 254 break;
252 case OTodo::Summary: 255 case OTodo::Summary:
253 ev.setSummary( it.data() ); 256 ev.setSummary( it.data() );
254 break; 257 break;
255 case OTodo::Priority: 258 case OTodo::Priority:
256 ev.setPriority( it.data().toInt() ); 259 ev.setPriority( it.data().toInt() );
257 break; 260 break;
258 case OTodo::DateDay: 261 case OTodo::DateDay:
259 day = it.data().toInt(); 262 day = it.data().toInt();
260 break; 263 break;
261 case OTodo::DateMonth: 264 case OTodo::DateMonth:
262 month = it.data().toInt(); 265 month = it.data().toInt();
263 break; 266 break;
264 case OTodo::DateYear: 267 case OTodo::DateYear:
265 year = it.data().toInt(); 268 year = it.data().toInt();
266 break; 269 break;
267 case OTodo::Progress: 270 case OTodo::Progress:
268 ev.setProgress( it.data().toInt() ); 271 ev.setProgress( it.data().toInt() );
269 break; 272 break;
270 case OTodo::CrossReference: 273 case OTodo::CrossReference:
271 { 274 {
272 /* 275 /*
273 * A cross refernce looks like 276 * A cross refernce looks like
274 * appname,id;appname,id 277 * appname,id;appname,id
275 * we need to split it up 278 * we need to split it up
276 */ 279 */
277 QStringList refs = QStringList::split(';', it.data() ); 280 QStringList refs = QStringList::split(';', it.data() );
278 QStringList::Iterator strIt; 281 QStringList::Iterator strIt;
279 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { 282 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
280 int pos = (*strIt).find(','); 283 int pos = (*strIt).find(',');
281 if ( pos > -1 ) 284 if ( pos > -1 )
282 ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); 285 ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
283 286
284 } 287 }
285 break; 288 break;
286 } 289 }
287 case OTodo::HasAlarmDateTime: 290 case OTodo::HasAlarmDateTime:
288 ev.setHasAlarmDateTime( it.data().toInt() ); 291 ev.setHasAlarmDateTime( it.data().toInt() );
289 break; 292 break;
290 case OTodo::AlarmDateTime: { 293 case OTodo::AlarmDateTime: {
291 /* this sounds better ;) zecke */ 294 /* this sounds better ;) zecke */
292 ev.setAlarmDateTime( TimeConversion::fromISO8601( it.data().local8Bit() ) ); 295 ev.setAlarmDateTime( TimeConversion::fromISO8601( it.data().local8Bit() ) );
293 break; 296 break;
294 } 297 }
295 default: 298 default:
296 break; 299 break;
297 } 300 }
298 } 301 }
299 if ( ev.hasDueDate() ) { 302 if ( ev.hasDueDate() ) {
300 QDate date( year, month, day ); 303 QDate date( year, month, day );
301 ev.setDueDate( date ); 304 ev.setDueDate( date );
302 } 305 }
303 306
304 return ev; 307 return ev;
305} 308}
306QString OTodoAccessXML::toString( const OTodo& ev )const { 309QString OTodoAccessXML::toString( const OTodo& ev )const {
307 QString str; 310 QString str;
308 311
309 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 312 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
310 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; 313 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
311 str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; 314 str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
312 str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; 315 str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
313 316
314 str += "Categories=\"" + toString( ev.categories() ) + "\" "; 317 str += "Categories=\"" + toString( ev.categories() ) + "\" ";
315 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; 318 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
316 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; 319 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
317 320
318 if ( ev.hasDueDate() ) { 321 if ( ev.hasDueDate() ) {
319 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; 322 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
320 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 323 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
321 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 324 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
322 } 325 }
326// qWarning( "Uid %d", ev.uid() );
323 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 327 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
324 328
325// append the extra options 329// append the extra options
326 /* FIXME Qtopia::Record this is currently not 330 /* FIXME Qtopia::Record this is currently not
327 * possible you can set custom fields 331 * possible you can set custom fields
328 * but don' iterate over the list 332 * but don' iterate over the list
329 * I may do #define private protected 333 * I may do #define private protected
330 * for this case - cough --zecke 334 * for this case - cough --zecke
331 */ 335 */
332 /* 336 /*
333 QMap<QString, QString> extras = ev.extras(); 337 QMap<QString, QString> extras = ev.extras();
334 QMap<QString, QString>::Iterator extIt; 338 QMap<QString, QString>::Iterator extIt;
335 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 339 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
336 str += extIt.key() + "=\"" + extIt.data() + "\" "; 340 str += extIt.key() + "=\"" + extIt.data() + "\" ";
337 */ 341 */
338 // cross refernce 342 // cross refernce
339 QStringList list = ev.relatedApps(); 343 QStringList list = ev.relatedApps();
340 QStringList::Iterator listIt; 344 QStringList::Iterator listIt;
341 QString refs; 345 QString refs;
342 str += "CrossReference=\""; 346 str += "CrossReference=\"";
343 bool added = false; 347 bool added = false;
344 for ( listIt = list.begin(); listIt != list.end(); ++listIt ) { 348 for ( listIt = list.begin(); listIt != list.end(); ++listIt ) {
345 added = true; 349 added = true;
346 QArray<int> ints = ev.relations( (*listIt) ); 350 QArray<int> ints = ev.relations( (*listIt) );
347 for ( uint i = 0; i< ints.count(); i++ ) { 351 for ( uint i = 0; i< ints.count(); i++ ) {
348 str += (*listIt) + "," + QString::number( i ) + ";"; 352 str += (*listIt) + "," + QString::number( i ) + ";";
349 } 353 }
350 } 354 }
351 if ( added ) 355 if ( added )
352 str = str.remove( str.length()-1, 1 ); 356 str = str.remove( str.length()-1, 1 );
353 357
354 str += "\" "; 358 str += "\" ";
355 359
356 str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" "; 360 str += "AlarmDateTime=\"" + TimeConversion::toISO8601( ev.alarmDateTime() ) + "\" ";
357 361
358 return str; 362 return str;
359} 363}
360QString OTodoAccessXML::toString( const QArray<int>& ints ) const { 364QString OTodoAccessXML::toString( const QArray<int>& ints ) const {
361 return Qtopia::Record::idsToString( ints ); 365 return Qtopia::Record::idsToString( ints );
362} 366}
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 60cdbf3..62dc353 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -1,133 +1,134 @@
1#include <qpe/categories.h> 1#include <qpe/categories.h>
2#include <qpe/categoryselect.h> 2#include <qpe/categoryselect.h>
3 3
4#include "opimrecord.h" 4#include "opimrecord.h"
5 5
6Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 6Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
7 7
8 8
9OPimRecord::OPimRecord( int uid ) 9OPimRecord::OPimRecord( int uid )
10 : Qtopia::Record() { 10 : Qtopia::Record() {
11 11
12 setUid( uid ); 12 setUid( uid );
13} 13}
14OPimRecord::~OPimRecord() { 14OPimRecord::~OPimRecord() {
15} 15}
16OPimRecord::OPimRecord( const OPimRecord& rec ) 16OPimRecord::OPimRecord( const OPimRecord& rec )
17 : Qtopia::Record( rec ) 17 : Qtopia::Record( rec )
18{ 18{
19 (*this) = rec; 19 (*this) = rec;
20} 20}
21 21
22OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 22OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
23 Qtopia::Record::operator=( rec ); 23 Qtopia::Record::operator=( rec );
24 m_relations = rec.m_relations; 24 m_relations = rec.m_relations;
25 25
26 return *this; 26 return *this;
27} 27}
28/* 28/*
29 * category names 29 * category names
30 */ 30 */
31QStringList OPimRecord::categoryNames()const { 31QStringList OPimRecord::categoryNames()const {
32 QStringList list; 32 QStringList list;
33 QArray<int> cats = categories(); 33 QArray<int> cats = categories();
34 Categories catDB; 34 Categories catDB;
35 catDB.load( categoryFileName() ); 35 catDB.load( categoryFileName() );
36 36
37 for (uint i = 0; i < cats.count(); i++ ) { 37 for (uint i = 0; i < cats.count(); i++ ) {
38 list << catDB.label("Todo List", cats[i] ); 38 list << catDB.label("Todo List", cats[i] );
39 } 39 }
40 40
41 return list; 41 return list;
42} 42}
43void OPimRecord::setCategoryNames( const QStringList& ) { 43void OPimRecord::setCategoryNames( const QStringList& ) {
44 44
45} 45}
46void OPimRecord::addCategoryName( const QString& ) { 46void OPimRecord::addCategoryName( const QString& ) {
47 Categories catDB; 47 Categories catDB;
48 catDB.load( categoryFileName() ); 48 catDB.load( categoryFileName() );
49 49
50 50
51} 51}
52bool OPimRecord::isEmpty()const { 52bool OPimRecord::isEmpty()const {
53 return ( uid() == 0 ); 53 return ( uid() == 0 );
54} 54}
55QStringList OPimRecord::relatedApps()const{ 55QStringList OPimRecord::relatedApps()const{
56 QStringList list; 56 QStringList list;
57 QMap<QString, QArray<int> >::ConstIterator it; 57 QMap<QString, QArray<int> >::ConstIterator it;
58 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { 58 for ( it = m_relations.begin(); it != m_relations.end(); ++it ) {
59 list << it.key(); 59 list << it.key();
60 } 60 }
61 return list; 61 return list;
62} 62}
63QArray<int> OPimRecord::relations(const QString& app )const { 63QArray<int> OPimRecord::relations(const QString& app )const {
64 QArray<int> tmp; 64 QArray<int> tmp;
65 QMap<QString, QArray<int> >::ConstIterator it; 65 QMap<QString, QArray<int> >::ConstIterator it;
66 it = m_relations.find( app); 66 it = m_relations.find( app);
67 if ( it != m_relations.end() ) 67 if ( it != m_relations.end() )
68 tmp = it.data(); 68 tmp = it.data();
69 return tmp; 69 return tmp;
70} 70}
71void OPimRecord::clearRelation( const QString& app ) { 71void OPimRecord::clearRelation( const QString& app ) {
72 m_relations.remove( app ); 72 m_relations.remove( app );
73} 73}
74void OPimRecord::addRelation( const QString& app, int id ) { 74void OPimRecord::addRelation( const QString& app, int id ) {
75 75
76 QMap<QString, QArray<int> >::Iterator it; 76 QMap<QString, QArray<int> >::Iterator it;
77 QArray<int> tmp; 77 QArray<int> tmp;
78 78
79 it = m_relations.find( app ); 79 it = m_relations.find( app );
80 if ( it == m_relations.end() ) { 80 if ( it == m_relations.end() ) {
81 tmp.resize(1 ); 81 tmp.resize(1 );
82 tmp[0] = id; 82 tmp[0] = id;
83 }else{ 83 }else{
84 tmp = it.data(); 84 tmp = it.data();
85 tmp.resize( tmp.size() + 1 ); 85 tmp.resize( tmp.size() + 1 );
86 tmp[tmp.size() - 1] = id; 86 tmp[tmp.size() - 1] = id;
87 } 87 }
88 m_relations.replace( app, tmp ); 88 m_relations.replace( app, tmp );
89} 89}
90void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { 90void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
91 91
92 QMap<QString, QArray<int> >::Iterator it; 92 QMap<QString, QArray<int> >::Iterator it;
93 QArray<int> tmp; 93 QArray<int> tmp;
94 94
95 it = m_relations.find( app); 95 it = m_relations.find( app);
96 if ( it == m_relations.end() ) { 96 if ( it == m_relations.end() ) {
97 tmp = ids; 97 tmp = ids;
98 }else{ 98 }else{
99 tmp = it.data(); 99 tmp = it.data();
100 int offset = tmp.size()-1; 100 int offset = tmp.size()-1;
101 tmp.resize( tmp.size() + ids.size() ); 101 tmp.resize( tmp.size() + ids.size() );
102 for (uint i = 0; i < ids.size(); i++ ) { 102 for (uint i = 0; i < ids.size(); i++ ) {
103 tmp[offset+i] = ids[i]; 103 tmp[offset+i] = ids[i];
104 } 104 }
105 105
106 } 106 }
107 m_relations.replace( app, tmp ); 107 m_relations.replace( app, tmp );
108} 108}
109QString OPimRecord::crossToString()const { 109QString OPimRecord::crossToString()const {
110 QString str; 110 QString str;
111 QMap<QString, QArray<int> >::ConstIterator it; 111 QMap<QString, QArray<int> >::ConstIterator it;
112 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 112 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
113 QArray<int> id = it.data(); 113 QArray<int> id = it.data();
114 for ( uint i = 0; i < id.size(); ++i ) { 114 for ( uint i = 0; i < id.size(); ++i ) {
115 str += it.key() + "," + QString::number( i ) + ";"; 115 str += it.key() + "," + QString::number( i ) + ";";
116 } 116 }
117 } 117 }
118 str = str.remove( str.length()-1, 1); // strip the ; 118 str = str.remove( str.length()-1, 1); // strip the ;
119 //qWarning("IDS " + str ); 119 //qWarning("IDS " + str );
120 120
121 return str; 121 return str;
122} 122}
123/* if uid = 1 assign a new one */ 123/* if uid = 1 assign a new one */
124void OPimRecord::setUid( int uid ) { 124void OPimRecord::setUid( int uid ) {
125 125// qWarning("setting uid" );
126 if ( uid == 1) 126 if ( uid == 1)
127 uid = uidGen().generate(); 127 uid = uidGen().generate();
128 128
129// qWarning(" uid %d", uid);
129 Qtopia::Record::setUid( uid ); 130 Qtopia::Record::setUid( uid );
130}; 131};
131Qtopia::UidGen &OPimRecord::uidGen() { 132Qtopia::UidGen &OPimRecord::uidGen() {
132 return m_uidGen; 133 return m_uidGen;
133} 134}
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index a65cf5c..8ec09bc 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -1,71 +1,71 @@
1#include <qdatetime.h> 1#include <qdatetime.h>
2 2
3#include <qpe/alarmserver.h> 3#include <qpe/alarmserver.h>
4 4
5#include "otodoaccessxml.h" 5#include "otodoaccessxml.h"
6#include "otodoaccess.h" 6#include "otodoaccess.h"
7 7
8 8
9OTodoAccess::OTodoAccess( OTodoAccessBackend* end ) 9OTodoAccess::OTodoAccess( OTodoAccessBackend* end )
10 : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) 10 : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end )
11{ 11{
12 if (end == 0l ) 12 if (end == 0l )
13 m_todoBackEnd = new OTodoAccessXML( "Todolist" ); 13 m_todoBackEnd = new OTodoAccessXML( "Todolist" );
14 14
15 setBackEnd( m_todoBackEnd ); 15 setBackEnd( m_todoBackEnd );
16} 16}
17OTodoAccess::~OTodoAccess() { 17OTodoAccess::~OTodoAccess() {
18 qWarning("~OTodoAccess"); 18// qWarning("~OTodoAccess");
19} 19}
20void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { 20void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) {
21 QValueList<OTodo>::ConstIterator it; 21 QValueList<OTodo>::ConstIterator it;
22 for ( it = list.begin(); it != list.end(); ++it ) { 22 for ( it = list.begin(); it != list.end(); ++it ) {
23 replace( (*it) ); 23 replace( (*it) );
24 } 24 }
25} 25}
26OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 26OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
27 const QDate& end, 27 const QDate& end,
28 bool includeNoDates ) { 28 bool includeNoDates ) {
29 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); 29 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
30 30
31 List lis( ints, this ); 31 List lis( ints, this );
32 return lis; 32 return lis;
33} 33}
34OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 34OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
35 bool includeNoDates ) { 35 bool includeNoDates ) {
36 return effectiveToDos( start, QDate::currentDate(), 36 return effectiveToDos( start, QDate::currentDate(),
37 includeNoDates ); 37 includeNoDates );
38} 38}
39OTodoAccess::List OTodoAccess::overDue() { 39OTodoAccess::List OTodoAccess::overDue() {
40 List lis( m_todoBackEnd->overDue(), this ); 40 List lis( m_todoBackEnd->overDue(), this );
41 return lis; 41 return lis;
42} 42}
43void OTodoAccess::addAlarm( const OTodo& event) { 43void OTodoAccess::addAlarm( const OTodo& event) {
44 if (!event.hasAlarmDateTime() ) 44 if (!event.hasAlarmDateTime() )
45 return; 45 return;
46 46
47 QDateTime now = QDateTime::currentDateTime(); 47 QDateTime now = QDateTime::currentDateTime();
48 QDateTime schedule = event.alarmDateTime(); 48 QDateTime schedule = event.alarmDateTime();
49 49
50 if ( schedule > now ){ 50 if ( schedule > now ){
51 AlarmServer::addAlarm( schedule, 51 AlarmServer::addAlarm( schedule,
52 "QPE/Application/todolist", 52 "QPE/Application/todolist",
53 "alarm(QDateTime,int)", event.uid() ); 53 "alarm(QDateTime,int)", event.uid() );
54 54
55 } 55 }
56} 56}
57void OTodoAccess::delAlarm( int uid) { 57void OTodoAccess::delAlarm( int uid) {
58 58
59 QDateTime schedule; // Create null DateTime 59 QDateTime schedule; // Create null DateTime
60 60
61 // I hope this will remove all scheduled alarms 61 // I hope this will remove all scheduled alarms
62 // with the given uid !? 62 // with the given uid !?
63 // If not: I have to rethink how to remove already 63 // If not: I have to rethink how to remove already
64 // scheduled events... (se) 64 // scheduled events... (se)
65 // it should be fine -zecke 65 // it should be fine -zecke
66 qWarning("Removing alarm for event with uid %d", uid ); 66// qWarning("Removing alarm for event with uid %d", uid );
67 AlarmServer::deleteAlarm( schedule , 67 AlarmServer::deleteAlarm( schedule ,
68 "QPE/Application/todolist", 68 "QPE/Application/todolist",
69 "alarm(QDateTime,int)", uid ); 69 "alarm(QDateTime,int)", uid );
70} 70}
71 71
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h
index 36728b8..1795938 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/orecordlist.h
@@ -1,208 +1,210 @@
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 <qarray.h> 5#include <qarray.h>
6 6
7#include "otemplatebase.h" 7#include "otemplatebase.h"
8#include "opimrecord.h" 8#include "opimrecord.h"
9 9
10/** 10/**
11 * Our List Iterator 11 * Our List Iterator
12 * it behaves like STL or Qt 12 * it behaves like STL or Qt
13 * 13 *
14 * for(it = list.begin(); it != list.end(); ++it ) 14 * for(it = list.begin(); it != list.end(); ++it )
15 * doSomeCoolStuff( (*it) ); 15 * doSomeCoolStuff( (*it) );
16 */ 16 */
17template <class T> class ORecordList; 17template <class T> class ORecordList;
18template <class T = OPimRecord> 18template <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:
68 typedef OTemplateBase<T> Base; 68 typedef OTemplateBase<T> Base;
69 typedef ORecordListIterator<T> Iterator; 69 typedef ORecordListIterator<T> Iterator;
70 70
71 /** 71 /**
72 * c'tor 72 * c'tor
73 */ 73 */
74 ORecordList () {
75 }
74 ORecordList( const QArray<int>& ids, 76 ORecordList( const QArray<int>& ids,
75 const Base* ); 77 const Base* );
76 ~ORecordList(); 78 ~ORecordList();
77 79
78 /** 80 /**
79 * the first iterator 81 * the first iterator
80 */ 82 */
81 Iterator begin(); 83 Iterator begin();
82 84
83 /** 85 /**
84 * the end 86 * the end
85 */ 87 */
86 Iterator end(); 88 Iterator end();
87 /* 89 /*
88 ConstIterator begin()const; 90 ConstIterator begin()const;
89 ConstIterator end()const; 91 ConstIterator end()const;
90 */ 92 */
91private: 93private:
92 QArray<int> m_ids; 94 QArray<int> m_ids;
93 const Base* m_acc; 95 const Base* m_acc;
94}; 96};
95 97
96/* ok now implement it */ 98/* ok now implement it */
97template <class T> 99template <class T>
98ORecordListIterator<T>::ORecordListIterator() { 100ORecordListIterator<T>::ORecordListIterator() {
99 m_current = 0; 101 m_current = 0;
100 m_temp = 0l; 102 m_temp = 0l;
101 m_end = true; 103 m_end = true;
102 m_record = T(); 104 m_record = T();
103} 105}
104template <class T> 106template <class T>
105ORecordListIterator<T>::~ORecordListIterator() { 107ORecordListIterator<T>::~ORecordListIterator() {
106/* nothing to delete */ 108/* nothing to delete */
107} 109}
108 110
109template <class T> 111template <class T>
110ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { 112ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) {
111// qWarning("ORecordListIterator copy c'tor"); 113// qWarning("ORecordListIterator copy c'tor");
112 m_uids = it.m_uids; 114 m_uids = it.m_uids;
113 m_current = it.m_current; 115 m_current = it.m_current;
114 m_temp = it.m_temp; 116 m_temp = it.m_temp;
115 m_end = it.m_end; 117 m_end = it.m_end;
116 m_record = it.m_record; 118 m_record = it.m_record;
117} 119}
118 120
119template <class T> 121template <class T>
120ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { 122ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) {
121 m_uids = it.m_uids; 123 m_uids = it.m_uids;
122 m_current = it.m_current; 124 m_current = it.m_current;
123 m_temp = it.m_temp; 125 m_temp = it.m_temp;
124 m_end = it.m_end; 126 m_end = it.m_end;
125// m_record = it.m_record; 127// m_record = it.m_record;
126 128
127 return *this; 129 return *this;
128} 130}
129 131
130template <class T> 132template <class T>
131T ORecordListIterator<T>::operator*() { 133T ORecordListIterator<T>::operator*() {
132// qWarning("operator* %d %d", m_current, m_uids[m_current] ); 134// qWarning("operator* %d %d", m_current, m_uids[m_current] );
133 if (!m_end ) 135 if (!m_end )
134 m_record = m_temp->find( m_uids[m_current] ); 136 m_record = m_temp->find( m_uids[m_current] );
135 else 137 else
136 m_record = T(); 138 m_record = T();
137 139
138 return m_record; 140 return m_record;
139} 141}
140 142
141template <class T> 143template <class T>
142ORecordListIterator<T> &ORecordListIterator<T>::operator++() { 144ORecordListIterator<T> &ORecordListIterator<T>::operator++() {
143 if (m_current < (int)m_uids.count() ) { 145 if (m_current < (int)m_uids.count() ) {
144 m_end = false; 146 m_end = false;
145 ++m_current; 147 ++m_current;
146 }else 148 }else
147 m_end = true; 149 m_end = true;
148 150
149 return *this; 151 return *this;
150} 152}
151template <class T> 153template <class T>
152ORecordListIterator<T> &ORecordListIterator<T>::operator--() { 154ORecordListIterator<T> &ORecordListIterator<T>::operator--() {
153 if ( m_current > 0 ) { 155 if ( m_current > 0 ) {
154 --m_current; 156 --m_current;
155 m_end = false; 157 m_end = false;
156 } else 158 } else
157 m_end = true; 159 m_end = true;
158 160
159 return *this; 161 return *this;
160} 162}
161 163
162template <class T> 164template <class T>
163bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { 165bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) {
164 166
165 /* if both are at we're the same.... */ 167 /* if both are at we're the same.... */
166 if ( m_end == it.m_end ) return true; 168 if ( m_end == it.m_end ) return true;
167 169
168 if ( m_uids != it.m_uids ) return false; 170 if ( m_uids != it.m_uids ) return false;
169 if ( m_current != it.m_current ) return false; 171 if ( m_current != it.m_current ) return false;
170 if ( m_temp != it.m_temp ) return false; 172 if ( m_temp != it.m_temp ) return false;
171 173
172 return true; 174 return true;
173} 175}
174template <class T> 176template <class T>
175bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { 177bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) {
176 return !(*this == it ); 178 return !(*this == it );
177} 179}
178template <class T> 180template <class T>
179ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 181ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids,
180 const Base* t ) 182 const Base* t )
181 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ) 183 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
182{ 184{
183} 185}
184 186
185template <class T> 187template <class T>
186ORecordList<T>::ORecordList( const QArray<int>& ids, 188ORecordList<T>::ORecordList( const QArray<int>& ids,
187 const Base* acc ) 189 const Base* acc )
188 : m_ids( ids ), m_acc( acc ) 190 : m_ids( ids ), m_acc( acc )
189{ 191{
190} 192}
191template <class T> 193template <class T>
192ORecordList<T>::~ORecordList() { 194ORecordList<T>::~ORecordList() {
193/* nothing to do here */ 195/* nothing to do here */
194} 196}
195template <class T> 197template <class T>
196ORecordList<T>::Iterator ORecordList<T>::begin() { 198ORecordList<T>::Iterator ORecordList<T>::begin() {
197 Iterator it( m_ids, m_acc ); 199 Iterator it( m_ids, m_acc );
198 return it; 200 return it;
199} 201}
200template <class T> 202template <class T>
201ORecordList<T>::Iterator ORecordList<T>::end() { 203ORecordList<T>::Iterator ORecordList<T>::end() {
202 Iterator it( m_ids, m_acc ); 204 Iterator it( m_ids, m_acc );
203 it.m_end = true; 205 it.m_end = true;
204 it.m_current = m_ids.count(); 206 it.m_current = m_ids.count();
205 207
206 return it; 208 return it;
207} 209}
208#endif 210#endif
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index cc46b21..6dd4c0e 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -1,386 +1,386 @@
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 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 42
43// qWarning("~OTodo " ); 43// qWarning("~OTodo " );
44 if ( data->deref() ) { 44 if ( data->deref() ) {
45// qWarning("OTodo::dereffing"); 45// qWarning("OTodo::dereffing");
46 delete data; 46 delete data;
47 data = 0l; 47 data = 0l;
48 } 48 }
49} 49}
50OTodo::OTodo(bool completed, int priority, 50OTodo::OTodo(bool completed, int priority,
51 const QArray<int> &category, 51 const QArray<int> &category,
52 const QString& summary, 52 const QString& summary,
53 const QString &description, 53 const QString &description,
54 ushort progress, 54 ushort progress,
55 bool hasDate, QDate date, int uid ) 55 bool hasDate, QDate date, int uid )
56 : OPimRecord( uid ) 56 : OPimRecord( uid )
57{ 57{
58// qWarning("OTodoData " + summary); 58// qWarning("OTodoData " + summary);
59 setCategories( category ); 59 setCategories( category );
60 60
61 data = new OTodoData; 61 data = new OTodoData;
62 62
63 data->date = date; 63 data->date = date;
64 data->isCompleted = completed; 64 data->isCompleted = completed;
65 data->hasDate = hasDate; 65 data->hasDate = hasDate;
66 data->priority = priority; 66 data->priority = priority;
67 data->sum = summary; 67 data->sum = summary;
68 data->prog = progress; 68 data->prog = progress;
69 data->desc = Qtopia::simplifyMultiLineSpace(description ); 69 data->desc = Qtopia::simplifyMultiLineSpace(description );
70 data->hasAlarmDateTime = false; 70 data->hasAlarmDateTime = false;
71 71
72} 72}
73OTodo::OTodo(bool completed, int priority, 73OTodo::OTodo(bool completed, int priority,
74 const QStringList &category, 74 const QStringList &category,
75 const QString& summary, 75 const QString& summary,
76 const QString &description, 76 const QString &description,
77 ushort progress, 77 ushort progress,
78 bool hasDate, QDate date, int uid ) 78 bool hasDate, QDate date, int uid )
79 : OPimRecord( uid ) 79 : OPimRecord( uid )
80{ 80{
81// qWarning("OTodoData" + summary); 81// qWarning("OTodoData" + summary);
82 setCategories( idsFromString( category.join(";") ) ); 82 setCategories( idsFromString( category.join(";") ) );
83 83
84 data = new OTodoData; 84 data = new OTodoData;
85 85
86 data->date = date; 86 data->date = date;
87 data->isCompleted = completed; 87 data->isCompleted = completed;
88 data->hasDate = hasDate; 88 data->hasDate = hasDate;
89 data->priority = priority; 89 data->priority = priority;
90 data->sum = summary; 90 data->sum = summary;
91 data->prog = progress; 91 data->prog = progress;
92 data->desc = Qtopia::simplifyMultiLineSpace(description ); 92 data->desc = Qtopia::simplifyMultiLineSpace(description );
93 data->hasAlarmDateTime = false; 93 data->hasAlarmDateTime = false;
94 94
95} 95}
96bool OTodo::match( const QRegExp &regExp )const 96bool OTodo::match( const QRegExp &regExp )const
97{ 97{
98 if( QString::number( data->priority ).find( regExp ) != -1 ){ 98 if( QString::number( data->priority ).find( regExp ) != -1 ){
99 return true; 99 return true;
100 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ 100 }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){
101 return true; 101 return true;
102 }else if(data->desc.find( regExp ) != -1 ){ 102 }else if(data->desc.find( regExp ) != -1 ){
103 return true; 103 return true;
104 }else if(data->sum.find( regExp ) != -1 ) { 104 }else if(data->sum.find( regExp ) != -1 ) {
105 return true; 105 return true;
106 } 106 }
107 return false; 107 return false;
108} 108}
109bool OTodo::isCompleted() const 109bool OTodo::isCompleted() const
110{ 110{
111 return data->isCompleted; 111 return data->isCompleted;
112} 112}
113bool OTodo::hasDueDate() const 113bool OTodo::hasDueDate() const
114{ 114{
115 return data->hasDate; 115 return data->hasDate;
116} 116}
117bool OTodo::hasAlarmDateTime() const 117bool OTodo::hasAlarmDateTime() const
118{ 118{
119 return data->hasAlarmDateTime; 119 return data->hasAlarmDateTime;
120} 120}
121int OTodo::priority()const 121int OTodo::priority()const
122{ 122{
123 return data->priority; 123 return data->priority;
124} 124}
125QString OTodo::summary() const 125QString OTodo::summary() const
126{ 126{
127 return data->sum; 127 return data->sum;
128} 128}
129ushort OTodo::progress() const 129ushort OTodo::progress() const
130{ 130{
131 return data->prog; 131 return data->prog;
132} 132}
133QDate OTodo::dueDate()const 133QDate OTodo::dueDate()const
134{ 134{
135 return data->date; 135 return data->date;
136} 136}
137 137
138QDateTime OTodo::alarmDateTime() const 138QDateTime OTodo::alarmDateTime() const
139{ 139{
140 return data->alarmDateTime; 140 return data->alarmDateTime;
141} 141}
142 142
143QString OTodo::description()const 143QString OTodo::description()const
144{ 144{
145 return data->desc; 145 return data->desc;
146} 146}
147void OTodo::setCompleted( bool completed ) 147void OTodo::setCompleted( bool completed )
148{ 148{
149 changeOrModify(); 149 changeOrModify();
150 data->isCompleted = completed; 150 data->isCompleted = completed;
151} 151}
152void OTodo::setHasDueDate( bool hasDate ) 152void OTodo::setHasDueDate( bool hasDate )
153{ 153{
154 changeOrModify(); 154 changeOrModify();
155 data->hasDate = hasDate; 155 data->hasDate = hasDate;
156} 156}
157void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) 157void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
158{ 158{
159 changeOrModify(); 159 changeOrModify();
160 data->hasAlarmDateTime = hasAlarmDateTime; 160 data->hasAlarmDateTime = hasAlarmDateTime;
161} 161}
162void OTodo::setDescription(const QString &desc ) 162void OTodo::setDescription(const QString &desc )
163{ 163{
164 qWarning( "desc " + desc ); 164// qWarning( "desc " + desc );
165 changeOrModify(); 165 changeOrModify();
166 data->desc = Qtopia::simplifyMultiLineSpace(desc ); 166 data->desc = Qtopia::simplifyMultiLineSpace(desc );
167} 167}
168void OTodo::setSummary( const QString& sum ) 168void OTodo::setSummary( const QString& sum )
169{ 169{
170 changeOrModify(); 170 changeOrModify();
171 data->sum = sum; 171 data->sum = sum;
172} 172}
173void OTodo::setPriority(int prio ) 173void OTodo::setPriority(int prio )
174{ 174{
175 changeOrModify(); 175 changeOrModify();
176 data->priority = prio; 176 data->priority = prio;
177} 177}
178void OTodo::setDueDate( QDate date ) 178void OTodo::setDueDate( QDate date )
179{ 179{
180 changeOrModify(); 180 changeOrModify();
181 data->date = date; 181 data->date = date;
182} 182}
183void OTodo::setAlarmDateTime( const QDateTime& alarm ) 183void OTodo::setAlarmDateTime( const QDateTime& alarm )
184{ 184{
185 changeOrModify(); 185 changeOrModify();
186 data->alarmDateTime = alarm; 186 data->alarmDateTime = alarm;
187} 187}
188bool OTodo::isOverdue( ) 188bool OTodo::isOverdue( )
189{ 189{
190 if( data->hasDate ) 190 if( data->hasDate )
191 return QDate::currentDate() > data->date; 191 return QDate::currentDate() > data->date;
192 return false; 192 return false;
193} 193}
194void OTodo::setProgress(ushort progress ) 194void OTodo::setProgress(ushort progress )
195{ 195{
196 changeOrModify(); 196 changeOrModify();
197 data->prog = progress; 197 data->prog = progress;
198} 198}
199QString OTodo::toShortText() const { 199QString OTodo::toShortText() const {
200 return summary(); 200 return summary();
201} 201}
202/*! 202/*!
203 Returns a richt text string 203 Returns a richt text string
204*/ 204*/
205QString OTodo::toRichText() const 205QString OTodo::toRichText() const
206{ 206{
207 QString text; 207 QString text;
208 QStringList catlist; 208 QStringList catlist;
209 209
210 // Description of the todo 210 // Description of the todo
211 if ( !summary().isEmpty() ) { 211 if ( !summary().isEmpty() ) {
212 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 212 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
213 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 213 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
214 } 214 }
215 if( !description().isEmpty() ){ 215 if( !description().isEmpty() ){
216 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 216 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
217 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; 217 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ;
218 } 218 }
219 text += "<br><br><br>"; 219 text += "<br><br><br>";
220 220
221 text += "<b>" + QObject::tr( "Priority:") +" </b>" 221 text += "<b>" + QObject::tr( "Priority:") +" </b>"
222 + QString::number( priority() ) + " <br>"; 222 + QString::number( priority() ) + " <br>";
223 text += "<b>" + QObject::tr( "Progress:") + " </b>" 223 text += "<b>" + QObject::tr( "Progress:") + " </b>"
224 + QString::number( progress() ) + " %<br>"; 224 + QString::number( progress() ) + " %<br>";
225 if (hasDueDate() ){ 225 if (hasDueDate() ){
226 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 226 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
227 text += dueDate().toString(); 227 text += dueDate().toString();
228 text += "<br>"; 228 text += "<br>";
229 } 229 }
230 if (hasAlarmDateTime() ){ 230 if (hasAlarmDateTime() ){
231 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; 231 text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>";
232 text += alarmDateTime().toString(); 232 text += alarmDateTime().toString();
233 text += "<br>"; 233 text += "<br>";
234 } 234 }
235 235
236 text += "<b>" + QObject::tr( "Category:") + "</b> "; 236 text += "<b>" + QObject::tr( "Category:") + "</b> ";
237 text += categoryNames().join(", "); 237 text += categoryNames().join(", ");
238 text += "<br>"; 238 text += "<br>";
239 239
240 return text; 240 return text;
241} 241}
242 242
243bool OTodo::operator<( const OTodo &toDoEvent )const{ 243bool OTodo::operator<( const OTodo &toDoEvent )const{
244 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 244 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
245 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 245 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
246 if( hasDueDate() && toDoEvent.hasDueDate() ){ 246 if( hasDueDate() && toDoEvent.hasDueDate() ){
247 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 247 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
248 return priority() < toDoEvent.priority(); 248 return priority() < toDoEvent.priority();
249 }else{ 249 }else{
250 return dueDate() < toDoEvent.dueDate(); 250 return dueDate() < toDoEvent.dueDate();
251 } 251 }
252 } 252 }
253 return false; 253 return false;
254} 254}
255bool OTodo::operator<=(const OTodo &toDoEvent )const 255bool OTodo::operator<=(const OTodo &toDoEvent )const
256{ 256{
257 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 257 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
258 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 258 if( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
259 if( hasDueDate() && toDoEvent.hasDueDate() ){ 259 if( hasDueDate() && toDoEvent.hasDueDate() ){
260 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 260 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
261 return priority() <= toDoEvent.priority(); 261 return priority() <= toDoEvent.priority();
262 }else{ 262 }else{
263 return dueDate() <= toDoEvent.dueDate(); 263 return dueDate() <= toDoEvent.dueDate();
264 } 264 }
265 } 265 }
266 return true; 266 return true;
267} 267}
268bool OTodo::operator>(const OTodo &toDoEvent )const 268bool OTodo::operator>(const OTodo &toDoEvent )const
269{ 269{
270 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 270 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
271 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 271 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
272 if( hasDueDate() && toDoEvent.hasDueDate() ){ 272 if( hasDueDate() && toDoEvent.hasDueDate() ){
273 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 273 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
274 return priority() > toDoEvent.priority(); 274 return priority() > toDoEvent.priority();
275 }else{ 275 }else{
276 return dueDate() > toDoEvent.dueDate(); 276 return dueDate() > toDoEvent.dueDate();
277 } 277 }
278 } 278 }
279 return false; 279 return false;
280} 280}
281bool OTodo::operator>=(const OTodo &toDoEvent )const 281bool OTodo::operator>=(const OTodo &toDoEvent )const
282{ 282{
283 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 283 if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
284 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 284 if( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
285 if( hasDueDate() && toDoEvent.hasDueDate() ){ 285 if( hasDueDate() && toDoEvent.hasDueDate() ){
286 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide 286 if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide
287 return priority() > toDoEvent.priority(); 287 return priority() > toDoEvent.priority();
288 }else{ 288 }else{
289 return dueDate() > toDoEvent.dueDate(); 289 return dueDate() > toDoEvent.dueDate();
290 } 290 }
291 } 291 }
292 return true; 292 return true;
293} 293}
294bool OTodo::operator==(const OTodo &toDoEvent )const 294bool OTodo::operator==(const OTodo &toDoEvent )const
295{ 295{
296 if ( data->priority != toDoEvent.data->priority ) return false; 296 if ( data->priority != toDoEvent.data->priority ) return false;
297 if ( data->priority != toDoEvent.data->prog ) return false; 297 if ( data->priority != toDoEvent.data->prog ) return false;
298 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 298 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
299 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 299 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
300 if ( data->date != toDoEvent.data->date ) return false; 300 if ( data->date != toDoEvent.data->date ) return false;
301 if ( data->sum != toDoEvent.data->sum ) return false; 301 if ( data->sum != toDoEvent.data->sum ) return false;
302 if ( data->desc != toDoEvent.data->desc ) return false; 302 if ( data->desc != toDoEvent.data->desc ) return false;
303 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime ) 303 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
304 return false; 304 return false;
305 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime ) 305 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
306 return false; 306 return false;
307 307
308 return OPimRecord::operator==( toDoEvent ); 308 return OPimRecord::operator==( toDoEvent );
309} 309}
310void OTodo::deref() { 310void OTodo::deref() {
311 311
312// qWarning("deref in ToDoEvent"); 312// qWarning("deref in ToDoEvent");
313 if ( data->deref() ) { 313 if ( data->deref() ) {
314// qWarning("deleting"); 314// qWarning("deleting");
315 delete data; 315 delete data;
316 data= 0; 316 data= 0;
317 } 317 }
318} 318}
319OTodo &OTodo::operator=(const OTodo &item ) 319OTodo &OTodo::operator=(const OTodo &item )
320{ 320{
321// OPimRecord::operator=( item ); 321 OPimRecord::operator=( item );
322 //qWarning("operator= ref "); 322 //qWarning("operator= ref ");
323 item.data->ref(); 323 item.data->ref();
324 deref(); 324 deref();
325 data = item.data; 325 data = item.data;
326 326
327 return *this; 327 return *this;
328} 328}
329 329
330QMap<int, QString> OTodo::toMap() const { 330QMap<int, QString> OTodo::toMap() const {
331 QMap<int, QString> map; 331 QMap<int, QString> map;
332 332
333 map.insert( Uid, QString::number( uid() ) ); 333 map.insert( Uid, QString::number( uid() ) );
334 map.insert( Category, idsToString( categories() ) ); 334 map.insert( Category, idsToString( categories() ) );
335 map.insert( HasDate, QString::number( data->hasDate ) ); 335 map.insert( HasDate, QString::number( data->hasDate ) );
336 map.insert( Completed, QString::number( data->isCompleted ) ); 336 map.insert( Completed, QString::number( data->isCompleted ) );
337 map.insert( Description, data->desc ); 337 map.insert( Description, data->desc );
338 map.insert( Summary, data->sum ); 338 map.insert( Summary, data->sum );
339 map.insert( Priority, QString::number( data->priority ) ); 339 map.insert( Priority, QString::number( data->priority ) );
340 map.insert( DateDay, QString::number( data->date.day() ) ); 340 map.insert( DateDay, QString::number( data->date.day() ) );
341 map.insert( DateMonth, QString::number( data->date.month() ) ); 341 map.insert( DateMonth, QString::number( data->date.month() ) );
342 map.insert( DateYear, QString::number( data->date.year() ) ); 342 map.insert( DateYear, QString::number( data->date.year() ) );
343 map.insert( Progress, QString::number( data->prog ) ); 343 map.insert( Progress, QString::number( data->prog ) );
344 map.insert( CrossReference, crossToString() ); 344 map.insert( CrossReference, crossToString() );
345 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); 345 map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) );
346 map.insert( AlarmDateTime, data->alarmDateTime.toString() ); 346 map.insert( AlarmDateTime, data->alarmDateTime.toString() );
347 347
348 return map; 348 return map;
349} 349}
350 350
351QMap<QString, QString> OTodo::toExtraMap()const { 351QMap<QString, QString> OTodo::toExtraMap()const {
352 return data->extra; 352 return data->extra;
353} 353}
354/** 354/**
355 * change or modify looks at the ref count and either 355 * change or modify looks at the ref count and either
356 * creates a new QShared Object or it can modify it 356 * creates a new QShared Object or it can modify it
357 * right in place 357 * right in place
358 */ 358 */
359void OTodo::changeOrModify() { 359void OTodo::changeOrModify() {
360 if ( data->count != 1 ) { 360 if ( data->count != 1 ) {
361// qWarning("changeOrModify"); 361// qWarning("changeOrModify");
362 data->deref(); 362 data->deref();
363 OTodoData* d2 = new OTodoData(); 363 OTodoData* d2 = new OTodoData();
364 copy(data, d2 ); 364 copy(data, d2 );
365 data = d2; 365 data = d2;
366 } 366 }
367} 367}
368void OTodo::copy( OTodoData* src, OTodoData* dest ) { 368void OTodo::copy( OTodoData* src, OTodoData* dest ) {
369 dest->date = src->date; 369 dest->date = src->date;
370 dest->isCompleted = src->isCompleted; 370 dest->isCompleted = src->isCompleted;
371 dest->hasDate = src->hasDate; 371 dest->hasDate = src->hasDate;
372 dest->priority = src->priority; 372 dest->priority = src->priority;
373 dest->desc = src->desc; 373 dest->desc = src->desc;
374 dest->sum = src->sum; 374 dest->sum = src->sum;
375 dest->extra = src->extra; 375 dest->extra = src->extra;
376 dest->prog = src->prog; 376 dest->prog = src->prog;
377 dest->hasAlarmDateTime = src->hasAlarmDateTime; 377 dest->hasAlarmDateTime = src->hasAlarmDateTime;
378 dest->alarmDateTime = src->alarmDateTime; 378 dest->alarmDateTime = src->alarmDateTime;
379} 379}
380QString OTodo::type() const { 380QString OTodo::type() const {
381 return QString::fromLatin1("OTodo"); 381 return QString::fromLatin1("OTodo");
382} 382}
383QString OTodo::recordField(int id )const { 383QString OTodo::recordField(int id )const {
384 return QString::null; 384 return QString::null;
385} 385}
386 386