summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core
Unidiff
Diffstat (limited to 'libopie2/opiepim/core') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimnotify.cpp251
-rw-r--r--libopie2/opiepim/core/opimnotify.h67
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp240
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.h40
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp141
-rw-r--r--libopie2/opiepim/core/opimrecord.h66
6 files changed, 528 insertions, 277 deletions
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp
index c61f9da..43858f0 100644
--- a/libopie2/opiepim/core/opimnotify.cpp
+++ b/libopie2/opiepim/core/opimnotify.cpp
@@ -23,236 +23,357 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qshared.h>
30 29
31#include <opie2/opimnotify.h> 30#include "opimnotify.h"
32 31
33namespace Opie { 32/* QT */
33#include <qshared.h>
34 34
35struct OPimNotify::Data : public QShared { 35namespace Opie
36 Data() : QShared(),dur(-1),parent(0) { 36{
37 37
38struct OPimNotify::Data : public QShared
39{
40 Data() : QShared(), dur( -1 ), parent( 0 )
41 {
38 } 42 }
39 QDateTime start; 43 QDateTime start;
40 int dur; 44 int dur;
41 QString application; 45 QString application;
42 int parent; 46 int parent;
43}; 47};
44 48
45OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { 49OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent )
50{
46 data = new Data; 51 data = new Data;
47 data->start = start; 52 data->start = start;
48 data->dur = duration; 53 data->dur = duration;
49 data->parent = parent; 54 data->parent = parent;
50} 55}
51OPimNotify::OPimNotify( const OPimNotify& noti) 56
52 : data( noti.data ) 57
58OPimNotify::OPimNotify( const OPimNotify& noti )
59 : data( noti.data )
53{ 60{
54 data->ref(); 61 data->ref();
55} 62}
56OPimNotify::~OPimNotify() { 63
57 if ( data->deref() ) { 64
65OPimNotify::~OPimNotify()
66{
67 if ( data->deref() )
68 {
58 delete data; 69 delete data;
59 data = 0l; 70 data = 0l;
60 } 71 }
61} 72}
62 73
63OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { 74
75OPimNotify &OPimNotify::operator=( const OPimNotify& noti )
76{
64 noti.data->ref(); 77 noti.data->ref();
65 deref(); 78 deref();
66 data = noti.data; 79 data = noti.data;
67 80
68 return *this; 81 return *this;
69} 82}
70bool OPimNotify::operator==( const OPimNotify& noti ) { 83
84
85bool OPimNotify::operator==( const OPimNotify& noti )
86{
71 if ( data == noti.data ) return true; 87 if ( data == noti.data ) return true;
72 if ( data->dur != noti.data->dur ) return false; 88 if ( data->dur != noti.data->dur ) return false;
73 if ( data->parent != noti.data->parent ) return false; 89 if ( data->parent != noti.data->parent ) return false;
74 if ( data->application != noti.data->application ) return false; 90 if ( data->application != noti.data->application ) return false;
75 if ( data->start != noti.data->start ) return false; 91 if ( data->start != noti.data->start ) return false;
76 92
77 return true; 93 return true;
78} 94}
79QDateTime OPimNotify::dateTime()const { 95
96
97QDateTime OPimNotify::dateTime() const
98{
80 return data->start; 99 return data->start;
81} 100}
82QString OPimNotify::service()const { 101
102
103QString OPimNotify::service() const
104{
83 return data->application; 105 return data->application;
84} 106}
85int OPimNotify::parent()const { 107
108
109int OPimNotify::parent() const
110{
86 return data->parent; 111 return data->parent;
87} 112}
88int OPimNotify::duration()const { 113
114
115int OPimNotify::duration() const
116{
89 return data->dur; 117 return data->dur;
90} 118}
91QDateTime OPimNotify::endTime()const { 119
92 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) ); 120
121QDateTime OPimNotify::endTime() const
122{
123 return QDateTime( data->start.date(), data->start.time().addSecs( data->dur ) );
93} 124}
94void OPimNotify::setDateTime( const QDateTime& time ) { 125
126
127void OPimNotify::setDateTime( const QDateTime& time )
128{
95 copyIntern(); 129 copyIntern();
96 data->start = time; 130 data->start = time;
97} 131}
98void OPimNotify::setDuration( int dur ) { 132
133
134void OPimNotify::setDuration( int dur )
135{
99 copyIntern(); 136 copyIntern();
100 data->dur = dur; 137 data->dur = dur;
101} 138}
102void OPimNotify::setParent( int uid ) { 139
140
141void OPimNotify::setParent( int uid )
142{
103 copyIntern(); 143 copyIntern();
104 data->parent = uid; 144 data->parent = uid;
105} 145}
106void OPimNotify::setService( const QString& str ) { 146
147
148void OPimNotify::setService( const QString& str )
149{
107 copyIntern(); 150 copyIntern();
108 data->application = str; 151 data->application = str;
109} 152}
110void OPimNotify::copyIntern() { 153
111 if ( data->count != 1 ) { 154
155void OPimNotify::copyIntern()
156{
157 if ( data->count != 1 )
158 {
112 data->deref(); 159 data->deref();
113 Data* dat = new Data; 160 Data* dat = new Data;
114 dat->start = data->start; 161 dat->start = data->start;
115 dat->dur = data->dur; 162 dat->dur = data->dur;
116 dat->application = data->application; 163 dat->application = data->application;
117 dat->parent = data->parent; 164 dat->parent = data->parent;
118 data = dat; 165 data = dat;
119 } 166 }
120} 167}
121void OPimNotify::deref() { 168
122 if ( data->deref() ) { 169
170void OPimNotify::deref()
171{
172 if ( data->deref() )
173 {
123 delete data; 174 delete data;
124 data = 0; 175 data = 0;
125 } 176 }
126} 177}
127 178
179
128/***********************************************************/ 180/***********************************************************/
129struct OPimAlarm::Data : public QShared { 181struct OPimAlarm::Data : public QShared
130 Data() : QShared() { 182{
183 Data() : QShared()
184 {
131 sound = 1; 185 sound = 1;
132 } 186 }
133 int sound; 187 int sound;
134 QString file; 188 QString file;
135}; 189};
190
191
136OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) 192OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent )
137 : OPimNotify( start, duration, parent ) 193 : OPimNotify( start, duration, parent )
138{ 194{
139 data = new Data; 195 data = new Data;
140 data->sound = sound; 196 data->sound = sound;
141} 197}
142OPimAlarm::OPimAlarm( const OPimAlarm& al) 198
143 : OPimNotify(al), data( al.data ) 199
200OPimAlarm::OPimAlarm( const OPimAlarm& al )
201 : OPimNotify( al ), data( al.data )
144{ 202{
145 data->ref(); 203 data->ref();
146} 204}
147OPimAlarm::~OPimAlarm() { 205
148 if ( data->deref() ) { 206
207OPimAlarm::~OPimAlarm()
208{
209 if ( data->deref() )
210 {
149 delete data; 211 delete data;
150 data = 0l; 212 data = 0l;
151 } 213 }
152} 214}
153OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) 215
216
217OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al )
154{ 218{
155 OPimNotify::operator=( al ); 219 OPimNotify::operator=( al );
156 deref(); 220 deref();
157 al.data->ref(); 221 al.data->ref();
158 222
159 data = al.data; 223 data = al.data;
160 224
161 225
162 return *this; 226 return *this;
163} 227}
164bool OPimAlarm::operator==( const OPimAlarm& al) { 228
229
230bool OPimAlarm::operator==( const OPimAlarm& al )
231{
165 if ( data->sound != al.data->sound ) return false; 232 if ( data->sound != al.data->sound ) return false;
166 else if ( data->sound == Custom && data->file != al.data->file ) 233 else if ( data->sound == Custom && data->file != al.data->file )
167 return false; 234 return false;
168 235
169 return OPimNotify::operator==( al ); 236 return OPimNotify::operator==( al );
170} 237}
171QString OPimAlarm::type()const { 238
172 return QString::fromLatin1("OPimAlarm"); 239
240QString OPimAlarm::type() const
241{
242 return QString::fromLatin1( "OPimAlarm" );
173} 243}
174int OPimAlarm::sound()const { 244
245
246int OPimAlarm::sound() const
247{
175 return data->sound; 248 return data->sound;
176} 249}
177QString OPimAlarm::file()const { 250
251
252QString OPimAlarm::file() const
253{
178 return data->file; 254 return data->file;
179} 255}
180void OPimAlarm::setSound( int snd) { 256
257
258void OPimAlarm::setSound( int snd )
259{
181 copyIntern(); 260 copyIntern();
182 data->sound = snd; 261 data->sound = snd;
183} 262}
184void OPimAlarm::setFile( const QString& sound ) { 263
264
265void OPimAlarm::setFile( const QString& sound )
266{
185 copyIntern(); 267 copyIntern();
186 data->file = sound; 268 data->file = sound;
187} 269}
188void OPimAlarm::deref() { 270
189 if ( data->deref() ) { 271
272void OPimAlarm::deref()
273{
274 if ( data->deref() )
275 {
190 delete data; 276 delete data;
191 data = 0l; 277 data = 0l;
192 } 278 }
193} 279}
194void OPimAlarm::copyIntern() { 280
195 if ( data->count != 1 ) { 281
282void OPimAlarm::copyIntern()
283{
284 if ( data->count != 1 )
285 {
196 data->deref(); 286 data->deref();
197 Data *newDat = new Data; 287 Data *newDat = new Data;
198 newDat->sound = data->sound; 288 newDat->sound = data->sound;
199 newDat->file = data->file; 289 newDat->file = data->file;
200 data = newDat; 290 data = newDat;
201 } 291 }
202} 292}
293
294
203/************************/ 295/************************/
204struct OPimReminder::Data : public QShared { 296struct OPimReminder::Data : public QShared
205 Data() : QShared(), record( 0) { 297{
206 } 298 Data() : QShared(), record( 0 )
299 {}
207 int record; 300 int record;
208 301
209}; 302};
210OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) 303
211 : OPimNotify( start, dur, parent ) 304
305OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent )
306 : OPimNotify( start, dur, parent )
212{ 307{
213 data = new Data; 308 data = new Data;
214 data->record = uid; 309 data->record = uid;
215} 310}
311
312
216OPimReminder::OPimReminder( const OPimReminder& rem ) 313OPimReminder::OPimReminder( const OPimReminder& rem )
217 : OPimNotify( rem ), data( rem.data ) 314 : OPimNotify( rem ), data( rem.data )
218{ 315{
219 data->ref(); 316 data->ref();
220} 317}
221OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { 318
222 OPimNotify::operator=(rem ); 319
320OPimReminder& OPimReminder::operator=( const OPimReminder& rem )
321{
322 OPimNotify::operator=( rem );
223 323
224 deref(); 324 deref();
225 rem.data->ref(); 325 rem.data->ref();
226 data = rem.data; 326 data = rem.data;
227 327
228 return *this; 328 return *this;
229} 329}
230bool OPimReminder::operator==( const OPimReminder& rem) { 330
331
332bool OPimReminder::operator==( const OPimReminder& rem )
333{
231 if ( data->record != rem.data->record ) return false; 334 if ( data->record != rem.data->record ) return false;
232 335
233 return OPimNotify::operator==( rem ); 336 return OPimNotify::operator==( rem );
234} 337}
235QString OPimReminder::type()const { 338
236 return QString::fromLatin1("OPimReminder"); 339
340QString OPimReminder::type() const
341{
342 return QString::fromLatin1( "OPimReminder" );
237} 343}
238int OPimReminder::recordUid()const { 344
345
346int OPimReminder::recordUid() const
347{
239 return data->record; 348 return data->record;
240} 349}
241void OPimReminder::setRecordUid( int uid ) { 350
351
352void OPimReminder::setRecordUid( int uid )
353{
242 copyIntern(); 354 copyIntern();
243 data->record = uid; 355 data->record = uid;
244} 356}
245void OPimReminder::deref() { 357
246 if ( data->deref() ) { 358
359void OPimReminder::deref()
360{
361 if ( data->deref() )
362 {
247 delete data; 363 delete data;
248 data = 0l; 364 data = 0l;
249 } 365 }
250} 366}
251void OPimReminder::copyIntern() { 367
252 if ( data->count != 1 ) { 368
253 Data* da = new Data; 369void OPimReminder::copyIntern()
370{
371 if ( data->count != 1 )
372 {
373 Data * da = new Data;
254 da->record = data->record; 374 da->record = data->record;
255 data = da; 375 data = da;
256 } 376 }
257} 377}
378
258} 379}
diff --git a/libopie2/opiepim/core/opimnotify.h b/libopie2/opiepim/core/opimnotify.h
index fed3970..d0e40ca 100644
--- a/libopie2/opiepim/core/opimnotify.h
+++ b/libopie2/opiepim/core/opimnotify.h
@@ -23,20 +23,22 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_PIM_NOTIFY_H
30#define OPIE_PIM_NOTIFY_H
31 29
30#ifndef OPIMNOTIFY_H
31#define OPIMNOTIFY_H
32
33/* QT */
32#include <qdatetime.h> 34#include <qdatetime.h>
33#include <qvaluelist.h> 35#include <qvaluelist.h>
34 36
35 37namespace Opie
36namespace Opie { 38{
37/** 39/**
38 * This is the base class of Notifiers. Possible 40 * This is the base class of Notifiers. Possible
39 * notifiers would be Alarms, Reminders 41 * notifiers would be Alarms, Reminders
40 * What they share is that they have 42 * What they share is that they have
41 * A DateTime, Type, Duration 43 * A DateTime, Type, Duration
42 * This is what this base class takes care of 44 * This is what this base class takes care of
@@ -44,50 +46,52 @@ namespace Opie {
44 */ 46 */
45/* 47/*
46 * TALK to eilers: have a class OPimDuration which sets the Duration 48 * TALK to eilers: have a class OPimDuration which sets the Duration
47 * given on the Due/Start Date? -zecke 49 * given on the Due/Start Date? -zecke
48 * discuss: do we need a uid for the notify? -zecke 50 * discuss: do we need a uid for the notify? -zecke
49 */ 51 */
50class OPimNotify { 52class OPimNotify
51public: 53{
54
55 public:
52 typedef QValueList<OPimNotify> ValueList; 56 typedef QValueList<OPimNotify> ValueList;
53 OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); 57 OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
54 OPimNotify( const OPimNotify& ); 58 OPimNotify( const OPimNotify& );
55 virtual ~OPimNotify(); 59 virtual ~OPimNotify();
56 60
57 OPimNotify &operator=(const OPimNotify& ); 61 OPimNotify &operator=( const OPimNotify& );
58 bool operator==( const OPimNotify& ); 62 bool operator==( const OPimNotify& );
59 63
60 virtual QString type()const = 0; 64 virtual QString type() const = 0;
61 65
62 /** start date */ 66 /** start date */
63 QDateTime dateTime()const; 67 QDateTime dateTime() const;
64 QString service()const; 68 QString service() const;
65 69
66 /** 70 /**
67 * RETURN the parent uid 71 * RETURN the parent uid
68 */ 72 */
69 int parent()const; 73 int parent() const;
70 74
71 /** 75 /**
72 * in Seconds 76 * in Seconds
73 */ 77 */
74 int duration()const; 78 int duration() const;
75 79
76 /** 80 /**
77 * Start Time + Duration 81 * Start Time + Duration
78 */ 82 */
79 QDateTime endTime()const; 83 QDateTime endTime() const;
80 84
81 void setDateTime( const QDateTime& ); 85 void setDateTime( const QDateTime& );
82 void setDuration( int dur ); 86 void setDuration( int dur );
83 void setParent(int uid ); 87 void setParent( int uid );
84 void setService( const QString& ); 88 void setService( const QString& );
85 89
86 90
87private: 91 private:
88 inline void copyIntern(); 92 inline void copyIntern();
89 void deref(); 93 void deref();
90 struct Data; 94 struct Data;
91 Data* data; 95 Data* data;
92 96
93 /* d-pointer */ 97 /* d-pointer */
@@ -97,31 +101,32 @@ private:
97}; 101};
98/** 102/**
99 * An alarm is a sound/mail/buzzer played/send 103 * An alarm is a sound/mail/buzzer played/send
100 * at a given time to inform about 104 * at a given time to inform about
101 * an Event 105 * an Event
102 */ 106 */
103class OPimAlarm : public OPimNotify { 107class OPimAlarm : public OPimNotify
104public: 108{
105 enum Sound{Loud=1, Silent=0, Custom=2 }; 109 public:
110 enum Sound{Loud = 1, Silent = 0, Custom = 2 };
106 OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); 111 OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
107 OPimAlarm( const OPimAlarm& ); 112 OPimAlarm( const OPimAlarm& );
108 ~OPimAlarm(); 113 ~OPimAlarm();
109 114
110 OPimAlarm &operator=( const OPimAlarm& ); 115 OPimAlarm &operator=( const OPimAlarm& );
111 bool operator==( const OPimAlarm& ); 116 bool operator==( const OPimAlarm& );
112 QString type()const; 117 QString type() const;
113 118
114 int sound()const; 119 int sound() const;
115 QString file()const; 120 QString file() const;
116 121
117 void setSound( int ); 122 void setSound( int );
118 /* only when sound is custom... */ 123 /* only when sound is custom... */
119 void setFile( const QString& sound ); 124 void setFile( const QString& sound );
120 125
121private: 126 private:
122 void deref(); 127 void deref();
123 void copyIntern(); 128 void copyIntern();
124 struct Data; 129 struct Data;
125 Data * data; 130 Data * data;
126 131
127 class Private; 132 class Private;
@@ -132,39 +137,39 @@ private:
132/** 137/**
133 * A Reminder will be put into the 138 * A Reminder will be put into the
134 * datebook 139 * datebook
135 * Note that the returned dateTime() may be not valid. 140 * Note that the returned dateTime() may be not valid.
136 * In these cases one must resolve the uid and get the OEvent 141 * In these cases one must resolve the uid and get the OEvent
137 */ 142 */
138class OPimReminder : public OPimNotify { 143class OPimReminder : public OPimNotify
139public: 144{
140 145 public:
141 /** 146 /**
142 * c'tor of a reminder 147 * c'tor of a reminder
143 * @param uid The uid of the Record inside the Datebook 148 * @param uid The uid of the Record inside the Datebook
144 * @param start the StartDate invalid for all day... 149 * @param start the StartDate invalid for all day...
145 * @param duration The duration of the event ( -1 for all day ) 150 * @param duration The duration of the event ( -1 for all day )
146 * @param parent The 'parent' record of this reminder 151 * @param parent The 'parent' record of this reminder
147 */ 152 */
148 OPimReminder( int uid = 0, const QDateTime& start = QDateTime(), 153 OPimReminder( int uid = 0, const QDateTime& start = QDateTime(),
149 int duration = 0, int parent = 0 ); 154 int duration = 0, int parent = 0 );
150 OPimReminder( const OPimReminder& ); 155 OPimReminder( const OPimReminder& );
151 OPimReminder &operator=(const OPimReminder& ); 156 OPimReminder &operator=( const OPimReminder& );
152 157
153 QString type()const; 158 QString type() const;
154 159
155 bool operator==( const OPimReminder& ); 160 bool operator==( const OPimReminder& );
156 161
157 /** 162 /**
158 * the uid of the alarm 163 * the uid of the alarm
159 * inside the 'datebook' application 164 * inside the 'datebook' application
160 */ 165 */
161 int recordUid()const; 166 int recordUid() const;
162 void setRecordUid( int uid ); 167 void setRecordUid( int uid );
163 168
164private: 169 private:
165 void deref(); 170 void deref();
166 void copyIntern(); 171 void copyIntern();
167 172
168 struct Data; 173 struct Data;
169 Data* data; 174 Data* data;
170 class Private; 175 class Private;
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
index 1771fad..a54d597 100644
--- a/libopie2/opiepim/core/opimnotifymanager.cpp
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -23,171 +23,227 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <opie2/opimnotifymanager.h>
30 29
30#include "opimnotifymanager.h"
31
32/* OPIE */
31#include <opie2/oconversion.h> 33#include <opie2/oconversion.h>
32 34
35/* QT */
33#include <qstringlist.h> 36#include <qstringlist.h>
34 37
35namespace Opie { 38namespace Opie
39{
36 40
37OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) 41OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al )
38 : m_rem( rem ), m_al( al ) 42 : m_rem( rem ), m_al( al )
39{} 43{}
40OPimNotifyManager::~OPimNotifyManager() { 44
41} 45
46OPimNotifyManager::~OPimNotifyManager()
47{}
48
49
42/* use static_cast and type instead of dynamic... */ 50/* use static_cast and type instead of dynamic... */
43void OPimNotifyManager::add( const OPimNotify& noti) { 51void OPimNotifyManager::add( const OPimNotify& noti )
44 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 52{
45 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 53 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
54 {
55 const OPimReminder & rem = static_cast<const OPimReminder&>( noti );
46 m_rem.append( rem ); 56 m_rem.append( rem );
47 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 57 }
48 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 58 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
59 {
60 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti );
49 m_al.append( al ); 61 m_al.append( al );
50 } 62 }
51} 63}
52void OPimNotifyManager::remove( const OPimNotify& noti) { 64
53 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 65
54 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 66void OPimNotifyManager::remove( const OPimNotify& noti )
67{
68 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
69 {
70 const OPimReminder & rem = static_cast<const OPimReminder&>( noti );
55 m_rem.remove( rem ); 71 m_rem.remove( rem );
56 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 72 }
57 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 73 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
74 {
75 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti );
58 m_al.remove( al ); 76 m_al.remove( al );
59 } 77 }
60} 78}
61void OPimNotifyManager::replace( const OPimNotify& noti) { 79
62 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 80
63 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 81void OPimNotifyManager::replace( const OPimNotify& noti )
82{
83 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
84 {
85 const OPimReminder & rem = static_cast<const OPimReminder&>( noti );
64 m_rem.remove( rem ); 86 m_rem.remove( rem );
65 m_rem.append( rem ); 87 m_rem.append( rem );
66 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 88 }
67 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 89 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
90 {
91 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti );
68 m_al.remove( al ); 92 m_al.remove( al );
69 m_al.append( al ); 93 m_al.append( al );
70 } 94 }
71} 95}
72OPimNotifyManager::Reminders OPimNotifyManager::reminders()const { 96
97
98OPimNotifyManager::Reminders OPimNotifyManager::reminders() const
99{
73 return m_rem; 100 return m_rem;
74} 101}
75OPimNotifyManager::Alarms OPimNotifyManager::alarms()const { 102
103
104OPimNotifyManager::Alarms OPimNotifyManager::alarms() const
105{
76 return m_al; 106 return m_al;
77} 107}
78OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const {
79 Alarms::ConstIterator it;
80 found = true;
81 108
82 for ( it = m_al.begin(); it != m_al.end(); ++it ){
83 if ( (*it).dateTime() == when )
84 return (*it);
85 }
86 109
87 // Fall through if nothing could be found 110OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const
88 found = false; 111{
89 OPimAlarm empty; 112 Alarms::ConstIterator it;
90 return empty; 113 found = true;
114
115 for ( it = m_al.begin(); it != m_al.end(); ++it )
116 {
117 if ( ( *it ).dateTime() == when )
118 return ( *it );
119 }
120
121 // Fall through if nothing could be found
122 found = false;
123 OPimAlarm empty;
124 return empty;
91} 125}
92 126
93 127
94void OPimNotifyManager::setAlarms( const Alarms& al) { 128void OPimNotifyManager::setAlarms( const Alarms& al )
129{
95 m_al = al; 130 m_al = al;
96} 131}
97void OPimNotifyManager::setReminders( const Reminders& rem) { 132
133
134void OPimNotifyManager::setReminders( const Reminders& rem )
135{
98 m_rem = rem; 136 m_rem = rem;
99} 137}
138
139
100/* FIXME!!! */ 140/* FIXME!!! */
101/** 141/**
102 * The idea is to check if the provider for our service 142 * The idea is to check if the provider for our service
103 * is online 143 * is online
104 * if it is we will use QCOP 144 * if it is we will use QCOP
105 * if not the Factory to get the backend... 145 * if not the Factory to get the backend...
106 * Qtopia1.6 services would be kewl to have here.... 146 * Qtopia1.6 services would be kewl to have here....
107 */ 147 */
108void OPimNotifyManager::registerNotify( const OPimNotify& ) { 148void OPimNotifyManager::registerNotify( const OPimNotify& )
109 149{
110} 150}
151
152
111/* FIXME!!! */ 153/* FIXME!!! */
112/** 154/**
113 * same as above... 155 * same as above...
114 * Also implement Url model 156 * Also implement Url model
115 * have a MainWindow.... 157 * have a MainWindow....
116 */ 158 */
117void OPimNotifyManager::deregister( const OPimNotify& ) { 159void OPimNotifyManager::deregister( const OPimNotify& )
118 160{
119} 161}
120 162
121bool OPimNotifyManager::isEmpty()const { 163
122 qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); 164bool OPimNotifyManager::isEmpty() const
165{
166 qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
123 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; 167 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
124 else return false; 168 else return false;
125} 169}
126 170
127// Taken from otodoaccessxml.. 171
172// Taken from otodoaccessxml.. code duplication bad. any alternative?
128QString OPimNotifyManager::alarmsToString() const 173QString OPimNotifyManager::alarmsToString() const
129{ 174{
130 QString str; 175 QString str;
131 176
132 OPimNotifyManager::Alarms alarms = m_al; 177 OPimNotifyManager::Alarms alarms = m_al;
133 if ( !alarms.isEmpty() ) { 178 if ( !alarms.isEmpty() )
134 QStringList als; 179 {
135 OPimNotifyManager::Alarms::Iterator it = alarms.begin(); 180 QStringList als;
136 for ( ; it != alarms.end(); ++it ) { 181 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
137 /* only if time is valid */ 182 for ( ; it != alarms.end(); ++it )
138 if ( (*it).dateTime().isValid() ) { 183 {
139 als << OConversion::dateTimeToString( (*it).dateTime() ) 184 /* only if time is valid */
140 + ":" + QString::number( (*it).duration() ) 185 if ( ( *it ).dateTime().isValid() )
141 + ":" + QString::number( (*it).sound() ) 186 {
142 + ":"; 187 als << OConversion::dateTimeToString( ( *it ).dateTime() )
143 } 188 + ":" + QString::number( ( *it ).duration() )
144 } 189 + ":" + QString::number( ( *it ).sound() )
145 // now write the list 190 + ":";
146 qWarning("als: %s", als.join("____________").latin1() ); 191 }
147 str = als.join(";"); 192 }
148 } 193 // now write the list
149 194 qWarning( "als: %s", als.join( "____________" ).latin1() );
150 return str; 195 str = als.join( ";" );
196 }
197
198 return str;
151} 199}
200
201
152QString OPimNotifyManager::remindersToString() const 202QString OPimNotifyManager::remindersToString() const
153{ 203{
154 QString str; 204 QString str;
155 205
156 OPimNotifyManager::Reminders reminders = m_rem; 206 OPimNotifyManager::Reminders reminders = m_rem;
157 if (!reminders.isEmpty() ) { 207 if ( !reminders.isEmpty() )
158 OPimNotifyManager::Reminders::Iterator it = reminders.begin(); 208 {
159 QStringList records; 209 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
160 for ( ; it != reminders.end(); ++it ) { 210 QStringList records;
161 records << QString::number( (*it).recordUid() ); 211 for ( ; it != reminders.end(); ++it )
162 } 212 {
163 str = records.join(";"); 213 records << QString::number( ( *it ).recordUid() );
164 } 214 }
215 str = records.join( ";" );
216 }
165 217
166 return str; 218 return str;
167} 219}
168 220
221
169void OPimNotifyManager::alarmsFromString( const QString& str ) 222void OPimNotifyManager::alarmsFromString( const QString& str )
170{ 223{
171 QStringList als = QStringList::split(";", str ); 224 QStringList als = QStringList::split( ";", str );
172 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { 225 for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it )
173 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty 226 {
174 qWarning("alarm: %s", alarm.join("___").latin1() ); 227 QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty
175 qWarning("alarm[0]: %s %s", alarm[0].latin1(), 228 qWarning( "alarm: %s", alarm.join( "___" ).latin1() );
176 OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); 229 qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(),
177 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), 230 OConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() );
178 alarm[1].toInt() ); 231 OPimAlarm al( alarm[ 2 ].toInt(), OConversion::dateTimeFromString( alarm[ 0 ] ),
179 add( al ); 232 alarm[ 1 ].toInt() );
180 } 233 add( al );
234 }
181} 235}
182 236
237
183void OPimNotifyManager::remindersFromString( const QString& str ) 238void OPimNotifyManager::remindersFromString( const QString& str )
184{ 239{
185 240
186 QStringList rems = QStringList::split(";", str ); 241 QStringList rems = QStringList::split( ";", str );
187 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { 242 for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it )
188 OPimReminder rem( (*it).toInt() ); 243 {
189 add( rem ); 244 OPimReminder rem( ( *it ).toInt() );
190 } 245 add( rem );
191 246 }
247
192} 248}
193} 249}
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h
index 0272e5d..9241ea2 100644
--- a/libopie2/opiepim/core/opimnotifymanager.h
+++ b/libopie2/opiepim/core/opimnotifymanager.h
@@ -23,50 +23,54 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_PIM_NOTIFY_MANAGER_H 29#ifndef OPIMNOTIFYMANAGER_H
30#define OPIE_PIM_NOTIFY_MANAGER_H 30#define OPIMNOTIFYMANAGER_H
31
32#include <qvaluelist.h>
33 31
32/* OPIE */
34#include <opie2/opimnotify.h> 33#include <opie2/opimnotify.h>
35 34
36namespace Opie { 35/* QT */
36#include <qvaluelist.h>
37
38namespace Opie
39{
37/** 40/**
38 * The notify manager keeps track of the Notifiers.... 41 * The notify manager keeps track of the Notifiers....
39 */ 42 */
40class OPimNotifyManager { 43class OPimNotifyManager
41public: 44{
45 public:
42 typedef QValueList<OPimReminder> Reminders; 46 typedef QValueList<OPimReminder> Reminders;
43 typedef QValueList<OPimAlarm> Alarms; 47 typedef QValueList<OPimAlarm> Alarms;
44 OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() ); 48 OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() );
45 ~OPimNotifyManager(); 49 ~OPimNotifyManager();
46 50
47 /* we will cast it for you ;) */ 51 /* we will cast it for you ;) */
48 void add( const OPimNotify& ); 52 void add( const OPimNotify& );
49 void remove( const OPimNotify& ); 53 void remove( const OPimNotify& );
50 /* replaces all with this one! */ 54 /* replaces all with this one! */
51 void replace( const OPimNotify& ); 55 void replace( const OPimNotify& );
52 56
53 Reminders reminders()const; 57 Reminders reminders() const;
54 58
55 /** 59 /**
56 * Return 60 * Return
57 */ 61 */
58 Alarms alarms()const; 62 Alarms alarms() const;
59 63
60 /** 64 /**
61 * Return alarm at DateTime "when". If more than one is registered at this 65 * Return alarm at DateTime "when". If more than one is registered at this
62 * DateTime, the first one is returned. 66 * DateTime, the first one is returned.
63 * If none was found, an empty Alarm is returned. 67 * If none was found, an empty Alarm is returned.
64 * @param when The date and time of the returned alarm 68 * @param when The date and time of the returned alarm
65 * @param found Returns true if anything was found. 69 * @param found Returns true if anything was found.
66 * @return Returns the found alarm at given DateTime. It is empty if found is false 70 * @return Returns the found alarm at given DateTime. It is empty if found is false
67 * (nothing could be found at given date and time) 71 * (nothing could be found at given date and time)
68 */ 72 */
69 OPimAlarm alarmAtDateTime( const QDateTime& when, bool& found ) const; 73 OPimAlarm alarmAtDateTime( const QDateTime& when, bool& found ) const;
70 74
71 void setAlarms( const Alarms& ); 75 void setAlarms( const Alarms& );
72 void setReminders( const Reminders& ); 76 void setReminders( const Reminders& );
@@ -80,38 +84,36 @@ public:
80 84
81 /** 85 /**
82 * this will do the opposite.. 86 * this will do the opposite..
83 */ 87 */
84 void deregister( const OPimNotify& ); 88 void deregister( const OPimNotify& );
85 89
86 bool isEmpty()const; 90 bool isEmpty() const;
87 91
88 /** 92 /**
89 * Return all alarms as string 93 * Return all alarms as string
90 */ 94 */
91 QString alarmsToString() const; 95 QString alarmsToString() const;
92 /** 96 /**
93 * Return all notifiers as string 97 * Return all notifiers as string
94 */ 98 */
95 QString remindersToString() const; 99 QString remindersToString() const;
96 100
97 /** 101 /**
98 * Convert string to alarms 102 * Convert string to alarms
99 * @param str String created by alarmsToString() 103 * @param str String created by alarmsToString()
100 */ 104 */
101 void alarmsFromString( const QString& str ); 105 void alarmsFromString( const QString& str );
102 106
103 /** 107 /**
104 * Convert string to reminders 108 * Convert string to reminders
105 * @param str String created by remindersToString() 109 * @param str String created by remindersToString()
106 */ 110 */
107 void remindersFromString( const QString& str ); 111 void remindersFromString( const QString& str );
108 112
109 113 private:
110
111private:
112 Reminders m_rem; 114 Reminders m_rem;
113 Alarms m_al; 115 Alarms m_al;
114 116
115 class Private; 117 class Private;
116 Private *d; 118 Private *d;
117 119
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 72bb372..c603f44 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -23,73 +23,98 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qarray.h>
30 29
30#include "opimrecord.h"
31
32/* OPIE */
31#include <qpe/categories.h> 33#include <qpe/categories.h>
32#include <qpe/categoryselect.h> 34#include <qpe/categoryselect.h>
33 35
34#include <opie2/opimrecord.h> 36/* QT */
37#include <qarray.h>
35 38
36namespace Opie { 39namespace Opie
40{
37Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 41Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
38 42
39 43
40OPimRecord::OPimRecord( int uid ) 44OPimRecord::OPimRecord( int uid )
41 : Qtopia::Record() { 45 : Qtopia::Record()
46{
42 47
43 m_lastHit = -1; 48 m_lastHit = -1;
44 setUid( uid ); 49 setUid( uid );
45} 50}
46OPimRecord::~OPimRecord() { 51
47} 52
53OPimRecord::~OPimRecord()
54{}
55
56
48OPimRecord::OPimRecord( const OPimRecord& rec ) 57OPimRecord::OPimRecord( const OPimRecord& rec )
49 : Qtopia::Record( rec ) 58 : Qtopia::Record( rec )
50{ 59{
51 (*this) = rec; 60 ( *this ) = rec;
52} 61}
53 62
54OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { 63
55 if ( this == &rec ) return *this; 64OPimRecord &OPimRecord::operator=( const OPimRecord& rec )
65{
66 if ( this == &rec ) return * this;
56 67
57 Qtopia::Record::operator=( rec ); 68 Qtopia::Record::operator=( rec );
58 m_xrefman = rec.m_xrefman; 69 m_xrefman = rec.m_xrefman;
59 m_lastHit = rec.m_lastHit; 70 m_lastHit = rec.m_lastHit;
60 71
61 return *this; 72 return *this;
62} 73}
74
75
63/* 76/*
64 * category names 77 * category names
65 */ 78 */
66QStringList OPimRecord::categoryNames( const QString& appname ) const { 79QStringList OPimRecord::categoryNames( const QString& appname ) const
80{
67 QStringList list; 81 QStringList list;
68 QArray<int> cats = categories(); 82 QArray<int> cats = categories();
69 Categories catDB; 83 Categories catDB;
70 catDB.load( categoryFileName() ); 84 catDB.load( categoryFileName() );
71 85
72 for (uint i = 0; i < cats.count(); i++ ) { 86 for ( uint i = 0; i < cats.count(); i++ )
73 list << catDB.label( appname, cats[i] ); 87 {
88 list << catDB.label( appname, cats[ i ] );
74 } 89 }
75 90
76 return list; 91 return list;
77} 92}
78void OPimRecord::setCategoryNames( const QStringList& ) {
79 93
94
95void OPimRecord::setCategoryNames( const QStringList& )
96{
80} 97}
81void OPimRecord::addCategoryName( const QString& ) { 98
99
100void OPimRecord::addCategoryName( const QString& )
101{
82 Categories catDB; 102 Categories catDB;
83 catDB.load( categoryFileName() ); 103 catDB.load( categoryFileName() );
84 104
85 105
86} 106}
87bool OPimRecord::isEmpty()const { 107
108
109bool OPimRecord::isEmpty() const
110{
88 return ( uid() == 0 ); 111 return ( uid() == 0 );
89} 112}
113
114
90/*QString OPimRecord::crossToString()const { 115/*QString OPimRecord::crossToString()const {
91 QString str; 116 QString str;
92 QMap<QString, QArray<int> >::ConstIterator it; 117 QMap<QString, QArray<int> >::ConstIterator it;
93 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 118 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
94 QArray<int> id = it.data(); 119 QArray<int> id = it.data();
95 for ( uint i = 0; i < id.size(); ++i ) { 120 for ( uint i = 0; i < id.size(); ++i ) {
@@ -99,92 +124,116 @@ bool OPimRecord::isEmpty()const {
99 str = str.remove( str.length()-1, 1); // strip the ; 124 str = str.remove( str.length()-1, 1); // strip the ;
100 //qWarning("IDS " + str ); 125 //qWarning("IDS " + str );
101 126
102 return str; 127 return str;
103 }*/ 128 }*/
104/* if uid = 1 assign a new one */ 129/* if uid = 1 assign a new one */
105void OPimRecord::setUid( int uid ) { 130void OPimRecord::setUid( int uid )
106 if ( uid == 1) 131{
132 if ( uid == 1 )
107 uid = uidGen().generate(); 133 uid = uidGen().generate();
108 134
109 Qtopia::Record::setUid( uid ); 135 Qtopia::Record::setUid( uid );
110}; 136};
111Qtopia::UidGen &OPimRecord::uidGen() { 137
138
139Qtopia::UidGen &OPimRecord::uidGen()
140{
112 return m_uidGen; 141 return m_uidGen;
113} 142}
114OPimXRefManager &OPimRecord::xrefmanager() { 143
144
145OPimXRefManager &OPimRecord::xrefmanager()
146{
115 return m_xrefman; 147 return m_xrefman;
116} 148}
117int OPimRecord::rtti(){ 149
150
151int OPimRecord::rtti()
152{
118 return 0; 153 return 0;
119} 154}
120 155
121/** 156/**
122 * now let's put our data into the stream 157 * now let's put our data into the stream
123 */ 158 */
124/* 159/*
125 * First read UID 160 * First read UID
126 * Categories 161 * Categories
127 * XRef 162 * XRef
128 */ 163 */
129bool OPimRecord::loadFromStream( QDataStream& stream ) { 164bool OPimRecord::loadFromStream( QDataStream& stream )
165{
130 int Int; 166 int Int;
131 uint UInt; 167 uint UInt;
132 stream >> Int; 168 stream >> Int;
133 setUid(Int); 169 setUid( Int );
134 170
135 /** Categories */ 171 /** Categories */
136 stream >> UInt; 172 stream >> UInt;
137 QArray<int> array(UInt); 173 QArray<int> array( UInt );
138 for (uint i = 0; i < UInt; i++ ) { 174 for ( uint i = 0; i < UInt; i++ )
139 stream >> array[i]; 175 {
176 stream >> array[ i ];
140 } 177 }
141 setCategories( array ); 178 setCategories( array );
142 179
143 /* 180 /*
144 * now we do the X-Ref stuff 181 * now we do the X-Ref stuff
145 */ 182 */
146 OPimXRef xref; 183 OPimXRef xref;
147 stream >> UInt; 184 stream >> UInt;
148 for ( uint i = 0; i < UInt; i++ ) { 185 for ( uint i = 0; i < UInt; i++ )
186 {
149 xref.setPartner( OPimXRef::One, partner( stream ) ); 187 xref.setPartner( OPimXRef::One, partner( stream ) );
150 xref.setPartner( OPimXRef::Two, partner( stream ) ); 188 xref.setPartner( OPimXRef::Two, partner( stream ) );
151 m_xrefman.add( xref ); 189 m_xrefman.add( xref );
152 } 190 }
153 191
154 return true; 192 return true;
155} 193}
156bool OPimRecord::saveToStream( QDataStream& stream )const { 194
195
196bool OPimRecord::saveToStream( QDataStream& stream ) const
197{
157 /** UIDs */ 198 /** UIDs */
158 199
159 stream << uid(); 200 stream << uid();
160 201
161 /** Categories */ 202 /** Categories */
162 stream << categories().count(); 203 stream << categories().count();
163 for ( uint i = 0; i < categories().count(); i++ ) { 204 for ( uint i = 0; i < categories().count(); i++ )
164 stream << categories()[i]; 205 {
206 stream << categories() [ i ];
165 } 207 }
166 208
167 /* 209 /*
168 * first the XRef count 210 * first the XRef count
169 * then the xrefs 211 * then the xrefs
170 */ 212 */
171 stream << m_xrefman.list().count(); 213 stream << m_xrefman.list().count();
172 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 214 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
173 it != m_xrefman.list().end(); ++it ) { 215 it != m_xrefman.list().end(); ++it )
174 flush( (*it).partner( OPimXRef::One), stream ); 216 {
175 flush( (*it).partner( OPimXRef::Two), stream ); 217 flush( ( *it ).partner( OPimXRef::One ), stream );
218 flush( ( *it ).partner( OPimXRef::Two ), stream );
176 } 219 }
177 return true; 220 return true;
178} 221}
179void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const{ 222
223
224void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const
225{
180 str << par.service(); 226 str << par.service();
181 str << par.uid(); 227 str << par.uid();
182 str << par.field(); 228 str << par.field();
183} 229}
184OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { 230
231
232OPimXRefPartner OPimRecord::partner( QDataStream& stream )
233{
185 OPimXRefPartner par; 234 OPimXRefPartner par;
186 QString str; 235 QString str;
187 int i; 236 int i;
188 237
189 stream >> str; 238 stream >> str;
190 par.setService( str ); 239 par.setService( str );
@@ -194,20 +243,32 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) {
194 243
195 stream >> i ; 244 stream >> i ;
196 par.setField( i ); 245 par.setField( i );
197 246
198 return par; 247 return par;
199} 248}
200void OPimRecord::setLastHitField( int lastHit )const { 249
250
251void OPimRecord::setLastHitField( int lastHit ) const
252{
201 m_lastHit = lastHit; 253 m_lastHit = lastHit;
202} 254}
203int OPimRecord::lastHitField()const{ 255
256
257int OPimRecord::lastHitField() const
258{
204 return m_lastHit; 259 return m_lastHit;
205} 260}
206QMap<QString, QString> OPimRecord::toExtraMap()const { 261
262
263QMap<QString, QString> OPimRecord::toExtraMap() const
264{
207 return customMap; 265 return customMap;
208} 266}
209void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { 267
268
269void OPimRecord::setExtraMap( const QMap<QString, QString>& map )
270{
210 customMap = map; 271 customMap = map;
211} 272}
212 273
213} 274}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index 63a3a98..4981a41 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -23,43 +23,47 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_PIM_RECORD_H
30#define OPIE_PIM_RECORD_H
31 29
32#include <qdatastream.h> 30#ifndef OPIMRECORD_H
33#include <qmap.h> 31#define OPIMRECORD_H
34#include <qstring.h>
35#include <qstringlist.h>
36 32
33/* OPIE */
34#include <opie2/opimxrefmanager.h>
37/* 35/*
38 * we need to get customMap which is private... 36 * we need to get customMap which is private...
39 */ 37 */
40#define private protected 38#define private protected
41#include <qpe/palmtoprecord.h> 39#include <qpe/palmtoprecord.h>
42#undef private 40#undef private
43 41
44#include <opie2/opimxrefmanager.h> 42/* QT */
43#include <qdatastream.h>
44#include <qmap.h>
45#include <qstring.h>
46#include <qstringlist.h>
45 47
46namespace Opie { 48namespace Opie
49{
47/** 50/**
48 * This is the base class for 51 * This is the base class for
49 * all PIM Records 52 * all PIM Records
50 * 53 *
51 */ 54 */
52class OPimRecord : public Qtopia::Record { 55class OPimRecord : public Qtopia::Record
53public: 56{
57 public:
54 /** 58 /**
55 * c'tor 59 * c'tor
56 * uid of 0 isEmpty 60 * uid of 0 isEmpty
57 * uid of 1 will be assigned a new one 61 * uid of 1 will be assigned a new one
58 */ 62 */
59 OPimRecord(int uid = 0); 63 OPimRecord( int uid = 0 );
60 ~OPimRecord(); 64 ~OPimRecord();
61 65
62 /** 66 /**
63 * copy c'tor 67 * copy c'tor
64 */ 68 */
65 OPimRecord( const OPimRecord& rec ); 69 OPimRecord( const OPimRecord& rec );
@@ -69,13 +73,13 @@ public:
69 */ 73 */
70 OPimRecord &operator=( const OPimRecord& ); 74 OPimRecord &operator=( const OPimRecord& );
71 75
72 /** 76 /**
73 * category names resolved 77 * category names resolved
74 */ 78 */
75 QStringList categoryNames( const QString& appname )const; 79 QStringList categoryNames( const QString& appname ) const;
76 80
77 /** 81 /**
78 * set category names they will be resolved 82 * set category names they will be resolved
79 */ 83 */
80 void setCategoryNames( const QStringList& ); 84 void setCategoryNames( const QStringList& );
81 85
@@ -86,59 +90,61 @@ public:
86 void addCategoryName( const QString& ); 90 void addCategoryName( const QString& );
87 91
88 /** 92 /**
89 * if a Record isEmpty 93 * if a Record isEmpty
90 * it's empty if it's 0 94 * it's empty if it's 0
91 */ 95 */
92 virtual bool isEmpty()const; 96 virtual bool isEmpty() const;
93 97
94 /** 98 /**
95 * toRichText summary 99 * toRichText summary
96 */ 100 */
97 virtual QString toRichText()const = 0; 101 virtual QString toRichText() const = 0;
98 102
99 /** 103 /**
100 * a small one line summary 104 * a small one line summary
101 */ 105 */
102 virtual QString toShortText()const = 0; 106 virtual QString toShortText() const = 0;
103 107
104 /** 108 /**
105 * the name of the Record 109 * the name of the Record
106 */ 110 */
107 virtual QString type()const = 0; 111 virtual QString type() const = 0;
108 112
109 /** 113 /**
110 * matches the Records the regular expression? 114 * matches the Records the regular expression?
111 */ 115 */
112 virtual bool match( const QString &regexp ) const 116 virtual bool match( const QString &regexp ) const
113 {setLastHitField( -1 ); 117 {
114 return Qtopia::Record::match(QRegExp(regexp));}; 118 setLastHitField( -1 );
119 return Qtopia::Record::match( QRegExp( regexp ) );
120 };
115 121
116 /** 122 /**
117 * if implemented this function returns which item has been 123 * if implemented this function returns which item has been
118 * last hit by the match() function. 124 * last hit by the match() function.
119 * or -1 if not implemented or no hit has occured 125 * or -1 if not implemented or no hit has occured
120 */ 126 */
121 int lastHitField()const; 127 int lastHitField() const;
122 128
123 /** 129 /**
124 * converts the internal structure to a map 130 * converts the internal structure to a map
125 */ 131 */
126 virtual QMap<int, QString> toMap()const = 0; 132 virtual QMap<int, QString> toMap() const = 0;
127 // virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers) 133 // virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers)
128 134
129 /** 135 /**
130 * key value representation of extra items 136 * key value representation of extra items
131 */ 137 */
132 QMap<QString, QString> toExtraMap()const; 138 QMap<QString, QString> toExtraMap() const;
133 void setExtraMap( const QMap<QString, QString>& ); 139 void setExtraMap( const QMap<QString, QString>& );
134 140
135 /** 141 /**
136 * the name for a recordField 142 * the name for a recordField
137 */ 143 */
138 virtual QString recordField(int)const = 0; 144 virtual QString recordField( int ) const = 0;
139 145
140 /** 146 /**
141 * returns a reference of the 147 * returns a reference of the
142 * Cross Reference Manager 148 * Cross Reference Manager
143 * Partner 'One' is THIS PIM RECORD! 149 * Partner 'One' is THIS PIM RECORD!
144 * 'Two' is the Partner where we link to 150 * 'Two' is the Partner where we link to
@@ -158,30 +164,30 @@ public:
158 164
159 /** 165 /**
160 * some marshalling and de marshalling code 166 * some marshalling and de marshalling code
161 * saves the OPimRecord 167 * saves the OPimRecord
162 * to and from a DataStream 168 * to and from a DataStream
163 */ 169 */
164 virtual bool loadFromStream(QDataStream& ); 170 virtual bool loadFromStream( QDataStream& );
165 virtual bool saveToStream( QDataStream& stream )const; 171 virtual bool saveToStream( QDataStream& stream ) const;
166 172
167protected: 173 protected:
168 // need to be const cause it is called from const methods 174 // need to be const cause it is called from const methods
169 mutable int m_lastHit; 175 mutable int m_lastHit;
170 void setLastHitField( int lastHit )const; 176 void setLastHitField( int lastHit ) const;
171 Qtopia::UidGen &uidGen(); 177 Qtopia::UidGen &uidGen();
172// QString crossToString()const; 178 // QString crossToString()const;
173 179
174private: 180 private:
175 class OPimRecordPrivate; 181 class OPimRecordPrivate;
176 OPimRecordPrivate *d; 182 OPimRecordPrivate *d;
177 OPimXRefManager m_xrefman; 183 OPimXRefManager m_xrefman;
178 static Qtopia::UidGen m_uidGen; 184 static Qtopia::UidGen m_uidGen;
179 185
180private: 186 private:
181 void flush( const OPimXRefPartner&, QDataStream& stream )const; 187 void flush( const OPimXRefPartner&, QDataStream& stream ) const;
182 OPimXRefPartner partner( QDataStream& ); 188 OPimXRefPartner partner( QDataStream& );
183}; 189};
184 190
185} 191}
186 192
187#endif 193#endif