summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimrecord.cpp11
-rw-r--r--libopie/pim/opimrecord.h1
-rw-r--r--libopie/pim/orecordlist.h139
-rw-r--r--libopie/pim/otodo.cpp52
-rw-r--r--libopie/pim/otodo.h10
5 files changed, 183 insertions, 30 deletions
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp
index d8f73c7..e510f4e 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/libopie/pim/opimrecord.cpp
@@ -4,9 +4,6 @@ OPimRecord::OPimRecord( int uid )
4 : Qtopia::Record() { 4 : Qtopia::Record() {
5 5
6 setUid( uid ); 6 setUid( uid );
7 /* assign a new UID */
8 if ( uid == 1 )
9 assignUid();
10} 7}
11OPimRecord::~OPimRecord() { 8OPimRecord::~OPimRecord() {
12} 9}
@@ -104,3 +101,11 @@ QString OPimRecord::crossToString()const {
104 101
105 return str; 102 return str;
106} 103}
104/* if uid = 1 assign a new one */
105void OPimRecord::setUid( int uid ) {
106
107 if ( uid == 1)
108 uid = uidGen().generate();
109
110 Qtopia::Record::setUid( uid );
111};
diff --git a/libopie/pim/opimrecord.h b/libopie/pim/opimrecord.h
index 18112d4..297ff12 100644
--- a/libopie/pim/opimrecord.h
+++ b/libopie/pim/opimrecord.h
@@ -101,6 +101,7 @@ public:
101 * 101 *
102 */ 102 */
103 void setRelations( const QString&, QArray<int> ids ); 103 void setRelations( const QString&, QArray<int> ids );
104 virtual void setUid( int uid );
104 105
105protected: 106protected:
106 QString crossToString()const; 107 QString crossToString()const;
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index c17186f..65c2169 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -11,25 +11,34 @@ public:
11 class Iterator { 11 class Iterator {
12 friend class ORecordList; 12 friend class ORecordList;
13 public: 13 public:
14 Iterator() {} 14 Iterator();
15 ~Iterator() {} 15 ~Iterator();
16 Iterator(const Iterator& ) {} 16 Iterator(const Iterator& );
17 Iterator &operator=(const Iterator& ); 17 Iterator &operator=(const Iterator& );
18 T &operator*() {} 18 T &operator*();
19 Iterator &operator++(); 19 Iterator &operator++();
20 Iterator &operator--();
20 21
21 bool operator==( const Iterator& it ); 22 bool operator==( const Iterator& it );
22 bool operator!=( const Iterator& it ); 23 bool operator!=( const Iterator& it );
23 24
24 } 25 private:
25 ORecordList( const QArray<int>& ids, 26 Iterator( const QArray<int>,
26 OPimAccessTemplate<T>* acc ) 27 OPimAccessTemplate<T>* );
27 : m_ids(ids ), m_acc( acc ) {
28 28
29 } 29 QArray<int> m_uids;
30 ~ORecordList() { 30 int m_current;
31 OPimAccessTemplate* m_temp;
32 bool m_end : 1;
33 T m_record;
31 34
32 } 35 /* d pointer for future versions */
36 class IteratorPrivate;
37 IteratorPrivate *d;
38 };
39 ORecordList( const QArray<int>& ids,
40 OPimAccessTemplate<T>* acc );
41 ~ORecordList();
33 Iterator begin(); 42 Iterator begin();
34 Iterator end(); 43 Iterator end();
35 /* 44 /*
@@ -37,8 +46,114 @@ public:
37 ConstIterator end()const; 46 ConstIterator end()const;
38 */ 47 */
39private: 48private:
40 QArray<int> ids; 49 QArray<int> m_ids;
41 OPimAccessTemplate<T>* m_acc; 50 OPimAccessTemplate<T>* m_acc;
42}; 51};
43 52
53/* ok now implement it */
54template <class T= OPimRecord>
55ORecordList<T>::Iterator::Iterator() {
56 m_current = 0;
57 m_temp = 0l;
58 m_end = true;
59}
60template <class T= OPimRecord>
61ORecordList<T>::Iterator::~Iterator() {
62/* nothing to delete */
63}
64
65template <class T = OPimRecord>
66ORecordList<T>::Iterator::Iterator( const ORecordList<T>::Iterator& it) {
67 m_uids = it.m_uids;
68 m_current = it.m_current;
69 m_temp = it.m_temp;
70 m_end = it.m_end;
71 m_record = it.m_record;
72}
73
74template <class T = OPimRecord>
75ORecordList<T>::Iterator &ORecordList::Iterator::operator=( const ORecordList<T>::Iterator& it) {
76 m_uids = it.m_uids;
77 m_current = it.m_current;
78 m_temp = it.m_temp;
79 m_end = it.m_end;
80 m_record = it.m_record;
81
82 return *this;
83}
84
85template <class T = OPimRecord>
86T &ORecordList<T>::Iterator::operator*() {
87 if (!m_end )
88 m_record = m_temp->find( m_uids[m_current] );
89 else
90 m_record = T;
91
92 return m_record;
93}
94
95template <class T = OPimRecord>
96ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator++() {
97 if (m_current < m_uids.count() ) {
98 m_end = false;
99 ++m_current;
100 }else
101 m_end = true;
102
103 return *this;
104}
105template <class T = OPimRecord>
106ORecordList<T>::Iterator &ORecordList<T>::Iterator::operator--() {
107 if ( m_current > 0 ) {
108 --m_current;
109 m_end = false;
110 } else
111 m_end = true;
112
113 return *this;
114}
115
116template <class T = OPimRecord>
117bool ORecordList<T>::Iterator::operator==( const ORecordList<T>::Iterator& it ) {
118
119 /* if both are at we're the same.... */
120 if ( m_end == it.m_end ) return true;
121
122 if ( m_uids != it.m_uids ) return false;
123 if ( m_current != it.m_current ) return false;
124 if ( m_temp != it.m_temp ) return false;
125
126 return true;
127}
128template <class T = ORecordList>
129bool ORecordList<T>::Iterator::operator!=( const ORecordList<T>::Iterator it ) {
130 return !(*this == it );
131}
132template <class T = ORecordList>
133ORecordList<T>::Iterator::Iterator( const QArray<int> uids,
134 OPimAccessTemplate<T>* t )
135 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false )
136{
137}
138template <class T = ORecordList>
139ORecordList<T>::ORecordList( const QArray<int>& ids,
140 OPimAccessTemplate<T>* acc )
141 : m_ids( ids ), m_acc( acc )
142{
143}
144template <class T = ORecordList>
145ORecordList<T>::~ORecordList() {
146/* nothing to do here */
147}
148template <class T = ORecordList>
149ORecordList<T>::Iterator ORecordList<T>::begin() {
150 Iterator it( m_ids, m_acc );
151 return it;
152}
153template <class T = ORecordList>
154ORecordList<T>::Iterator ORecordList<T>::end() {
155 Iterator it( m_ids, m_acc );
156 it.m_end = true;
157 it.m_current = m_ids.count();
158}
44#endif 159#endif
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp
index 3c93838..8239ba6 100644
--- a/libopie/pim/otodo.cpp
+++ b/libopie/pim/otodo.cpp
@@ -24,7 +24,6 @@ struct OTodo::OTodoData : public QShared {
24 bool isCompleted:1; 24 bool isCompleted:1;
25 bool hasDate:1; 25 bool hasDate:1;
26 int priority; 26 int priority;
27 QStringList category;
28 QString desc; 27 QString desc;
29 QString sum; 28 QString sum;
30 QMap<QString, QString> extra; 29 QMap<QString, QString> extra;
@@ -46,7 +45,27 @@ OTodo::~OTodo() {
46 data = 0l; 45 data = 0l;
47 } 46 }
48} 47}
48OTodo::OTodo(bool completed, int priority,
49 const QArray<int> &category,
50 const QString& summary,
51 const QString &description,
52 ushort progress,
53 bool hasDate, QDate date, int uid )
54 : OPimRecord( uid )
55{
56 //qWarning("OTodoData");
57 setCategories( category );
58 data = new OTodoData;
59 data->date = date;
60 data->isCompleted = completed;
61 data->hasDate = hasDate;
62 data->priority = priority;
63 data->sum = summary;
64 data->prog = progress;
65 data->desc = Qtopia::simplifyMultiLineSpace(description );
66 data->hasAlarmDateTime = false;
49 67
68}
50OTodo::OTodo(bool completed, int priority, 69OTodo::OTodo(bool completed, int priority,
51 const QStringList &category, 70 const QStringList &category,
52 const QString& summary, 71 const QString& summary,
@@ -267,19 +286,19 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const
267} 286}
268bool OTodo::operator==(const OTodo &toDoEvent )const 287bool OTodo::operator==(const OTodo &toDoEvent )const
269{ 288{
270 if( data->priority == toDoEvent.data->priority && 289 if ( data->priority != toDoEvent.data->priority ) return false;
271 data->priority == toDoEvent.data->prog && 290 if ( data->priority != toDoEvent.data->prog ) return false;
272 data->isCompleted == toDoEvent.data->isCompleted && 291 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
273 data->hasDate == toDoEvent.data->hasDate && 292 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
274 data->date == toDoEvent.data->date && 293 if ( data->date != toDoEvent.data->date ) return false;
275 data->category == toDoEvent.data->category && 294 if ( data->sum != toDoEvent.data->sum ) return false;
276 data->sum == toDoEvent.data->sum && 295 if ( data->desc != toDoEvent.data->desc ) return false;
277 data->desc == toDoEvent.data->desc && 296 if ( data->hasAlarmDateTime != toDoEvent.data->hasAlarmDateTime )
278 data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && 297 return false;
279 data->alarmDateTime == toDoEvent.data->alarmDateTime ) 298 if ( data->alarmDateTime != toDoEvent.data->alarmDateTime )
280 return true; 299 return false;
281 300
282 return false; 301 return OPimRecord::operator==( toDoEvent );
283} 302}
284void OTodo::deref() { 303void OTodo::deref() {
285 304
@@ -350,5 +369,10 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) {
350 dest->hasAlarmDateTime = src->hasAlarmDateTime; 369 dest->hasAlarmDateTime = src->hasAlarmDateTime;
351 dest->alarmDateTime = src->alarmDateTime; 370 dest->alarmDateTime = src->alarmDateTime;
352} 371}
353 372QString OTodo::type() const {
373 return QString::fromLatin1("OTodo");
374}
375QString OTodo::recordField(int id )const {
376 return QString::null;
377}
354 378
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h
index e1729db..75af44c 100644
--- a/libopie/pim/otodo.h
+++ b/libopie/pim/otodo.h
@@ -55,7 +55,15 @@ public:
55 const QString &description = QString::null, 55 const QString &description = QString::null,
56 ushort progress = 0, 56 ushort progress = 0,
57 bool hasDate = false, QDate date = QDate::currentDate(), 57 bool hasDate = false, QDate date = QDate::currentDate(),
58 int uid = -1 ); 58 int uid = 0 /*empty*/ );
59
60 OTodo( bool completed, int priority,
61 const QArray<int>& category,
62 const QString& summary = QString::null,
63 const QString& description = QString::null,
64 ushort progress = 0,
65 bool hasDate = false, QDate date = QDate::currentDate(),
66 int uid = 0 /* empty */ );
59 67
60 /* Copy c'tor 68 /* Copy c'tor
61 69