Diffstat (limited to 'libopie2/opiepim/core/opimnotify.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimnotify.cpp | 219 |
1 files changed, 170 insertions, 49 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 | |||
@@ -27,13 +27,17 @@ | |||
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 | ||
33 | namespace Opie { | 32 | /* QT */ |
33 | #include <qshared.h> | ||
34 | 34 | ||
35 | struct OPimNotify::Data : public QShared { | 35 | namespace Opie |
36 | Data() : QShared(),dur(-1),parent(0) { | 36 | { |
37 | 37 | ||
38 | struct OPimNotify::Data : public QShared | ||
39 | { | ||
40 | Data() : QShared(), dur( -1 ), parent( 0 ) | ||
41 | { | ||
38 | } | 42 | } |
39 | QDateTime start; | 43 | QDateTime start; |
@@ -43,5 +47,6 @@ struct OPimNotify::Data : public QShared { | |||
43 | }; | 47 | }; |
44 | 48 | ||
45 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { | 49 | OPimNotify::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; |
@@ -49,4 +54,6 @@ OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { | |||
49 | data->parent = parent; | 54 | data->parent = parent; |
50 | } | 55 | } |
56 | |||
57 | |||
51 | OPimNotify::OPimNotify( const OPimNotify& noti) | 58 | OPimNotify::OPimNotify( const OPimNotify& noti) |
52 | : data( noti.data ) | 59 | : data( noti.data ) |
@@ -54,6 +61,10 @@ OPimNotify::OPimNotify( const OPimNotify& noti) | |||
54 | data->ref(); | 61 | data->ref(); |
55 | } | 62 | } |
56 | OPimNotify::~OPimNotify() { | 63 | |
57 | if ( data->deref() ) { | 64 | |
65 | OPimNotify::~OPimNotify() | ||
66 | { | ||
67 | if ( data->deref() ) | ||
68 | { | ||
58 | delete data; | 69 | delete data; |
59 | data = 0l; | 70 | data = 0l; |
@@ -61,5 +72,7 @@ OPimNotify::~OPimNotify() { | |||
61 | } | 72 | } |
62 | 73 | ||
63 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { | 74 | |
75 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti ) | ||
76 | { | ||
64 | noti.data->ref(); | 77 | noti.data->ref(); |
65 | deref(); | 78 | deref(); |
@@ -68,5 +81,8 @@ OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { | |||
68 | return *this; | 81 | return *this; |
69 | } | 82 | } |
70 | bool OPimNotify::operator==( const OPimNotify& noti ) { | 83 | |
84 | |||
85 | bool 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; |
@@ -77,37 +93,68 @@ bool OPimNotify::operator==( const OPimNotify& noti ) { | |||
77 | return true; | 93 | return true; |
78 | } | 94 | } |
79 | QDateTime OPimNotify::dateTime()const { | 95 | |
96 | |||
97 | QDateTime OPimNotify::dateTime() const | ||
98 | { | ||
80 | return data->start; | 99 | return data->start; |
81 | } | 100 | } |
82 | QString OPimNotify::service()const { | 101 | |
102 | |||
103 | QString OPimNotify::service() const | ||
104 | { | ||
83 | return data->application; | 105 | return data->application; |
84 | } | 106 | } |
85 | int OPimNotify::parent()const { | 107 | |
108 | |||
109 | int OPimNotify::parent() const | ||
110 | { | ||
86 | return data->parent; | 111 | return data->parent; |
87 | } | 112 | } |
88 | int OPimNotify::duration()const { | 113 | |
114 | |||
115 | int OPimNotify::duration() const | ||
116 | { | ||
89 | return data->dur; | 117 | return data->dur; |
90 | } | 118 | } |
91 | QDateTime OPimNotify::endTime()const { | 119 | |
120 | |||
121 | QDateTime OPimNotify::endTime() const | ||
122 | { | ||
92 | return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) ); | 123 | return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) ); |
93 | } | 124 | } |
94 | void OPimNotify::setDateTime( const QDateTime& time ) { | 125 | |
126 | |||
127 | void OPimNotify::setDateTime( const QDateTime& time ) | ||
128 | { | ||
95 | copyIntern(); | 129 | copyIntern(); |
96 | data->start = time; | 130 | data->start = time; |
97 | } | 131 | } |
98 | void OPimNotify::setDuration( int dur ) { | 132 | |
133 | |||
134 | void OPimNotify::setDuration( int dur ) | ||
135 | { | ||
99 | copyIntern(); | 136 | copyIntern(); |
100 | data->dur = dur; | 137 | data->dur = dur; |
101 | } | 138 | } |
102 | void OPimNotify::setParent( int uid ) { | 139 | |
140 | |||
141 | void OPimNotify::setParent( int uid ) | ||
142 | { | ||
103 | copyIntern(); | 143 | copyIntern(); |
104 | data->parent = uid; | 144 | data->parent = uid; |
105 | } | 145 | } |
106 | void OPimNotify::setService( const QString& str ) { | 146 | |
147 | |||
148 | void OPimNotify::setService( const QString& str ) | ||
149 | { | ||
107 | copyIntern(); | 150 | copyIntern(); |
108 | data->application = str; | 151 | data->application = str; |
109 | } | 152 | } |
110 | void OPimNotify::copyIntern() { | 153 | |
111 | if ( data->count != 1 ) { | 154 | |
155 | void 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; |
@@ -119,6 +166,10 @@ void OPimNotify::copyIntern() { | |||
119 | } | 166 | } |
120 | } | 167 | } |
121 | void OPimNotify::deref() { | 168 | |
122 | if ( data->deref() ) { | 169 | |
170 | void OPimNotify::deref() | ||
171 | { | ||
172 | if ( data->deref() ) | ||
173 | { | ||
123 | delete data; | 174 | delete data; |
124 | data = 0; | 175 | data = 0; |
@@ -126,7 +177,10 @@ void OPimNotify::deref() { | |||
126 | } | 177 | } |
127 | 178 | ||
179 | |||
128 | /***********************************************************/ | 180 | /***********************************************************/ |
129 | struct OPimAlarm::Data : public QShared { | 181 | struct OPimAlarm::Data : public QShared |
130 | Data() : QShared() { | 182 | { |
183 | Data() : QShared() | ||
184 | { | ||
131 | sound = 1; | 185 | sound = 1; |
132 | } | 186 | } |
@@ -134,4 +188,6 @@ struct OPimAlarm::Data : public QShared { | |||
134 | QString file; | 188 | QString file; |
135 | }; | 189 | }; |
190 | |||
191 | |||
136 | OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) | 192 | OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int parent ) |
137 | : OPimNotify( start, duration, parent ) | 193 | : OPimNotify( start, duration, parent ) |
@@ -140,4 +196,6 @@ OPimAlarm::OPimAlarm( int sound, const QDateTime& start, int duration, int paren | |||
140 | data->sound = sound; | 196 | data->sound = sound; |
141 | } | 197 | } |
198 | |||
199 | |||
142 | OPimAlarm::OPimAlarm( const OPimAlarm& al) | 200 | OPimAlarm::OPimAlarm( const OPimAlarm& al) |
143 | : OPimNotify(al), data( al.data ) | 201 | : OPimNotify(al), data( al.data ) |
@@ -145,10 +203,16 @@ OPimAlarm::OPimAlarm( const OPimAlarm& al) | |||
145 | data->ref(); | 203 | data->ref(); |
146 | } | 204 | } |
147 | OPimAlarm::~OPimAlarm() { | 205 | |
148 | if ( data->deref() ) { | 206 | |
207 | OPimAlarm::~OPimAlarm() | ||
208 | { | ||
209 | if ( data->deref() ) | ||
210 | { | ||
149 | delete data; | 211 | delete data; |
150 | data = 0l; | 212 | data = 0l; |
151 | } | 213 | } |
152 | } | 214 | } |
215 | |||
216 | |||
153 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) | 217 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) |
154 | { | 218 | { |
@@ -162,5 +226,8 @@ OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) | |||
162 | return *this; | 226 | return *this; |
163 | } | 227 | } |
164 | bool OPimAlarm::operator==( const OPimAlarm& al) { | 228 | |
229 | |||
230 | bool 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 ) |
@@ -169,29 +236,52 @@ bool OPimAlarm::operator==( const OPimAlarm& al) { | |||
169 | return OPimNotify::operator==( al ); | 236 | return OPimNotify::operator==( al ); |
170 | } | 237 | } |
171 | QString OPimAlarm::type()const { | 238 | |
239 | |||
240 | QString OPimAlarm::type() const | ||
241 | { | ||
172 | return QString::fromLatin1("OPimAlarm"); | 242 | return QString::fromLatin1("OPimAlarm"); |
173 | } | 243 | } |
174 | int OPimAlarm::sound()const { | 244 | |
245 | |||
246 | int OPimAlarm::sound() const | ||
247 | { | ||
175 | return data->sound; | 248 | return data->sound; |
176 | } | 249 | } |
177 | QString OPimAlarm::file()const { | 250 | |
251 | |||
252 | QString OPimAlarm::file() const | ||
253 | { | ||
178 | return data->file; | 254 | return data->file; |
179 | } | 255 | } |
180 | void OPimAlarm::setSound( int snd) { | 256 | |
257 | |||
258 | void OPimAlarm::setSound( int snd ) | ||
259 | { | ||
181 | copyIntern(); | 260 | copyIntern(); |
182 | data->sound = snd; | 261 | data->sound = snd; |
183 | } | 262 | } |
184 | void OPimAlarm::setFile( const QString& sound ) { | 263 | |
264 | |||
265 | void OPimAlarm::setFile( const QString& sound ) | ||
266 | { | ||
185 | copyIntern(); | 267 | copyIntern(); |
186 | data->file = sound; | 268 | data->file = sound; |
187 | } | 269 | } |
188 | void OPimAlarm::deref() { | 270 | |
189 | if ( data->deref() ) { | 271 | |
272 | void OPimAlarm::deref() | ||
273 | { | ||
274 | if ( data->deref() ) | ||
275 | { | ||
190 | delete data; | 276 | delete data; |
191 | data = 0l; | 277 | data = 0l; |
192 | } | 278 | } |
193 | } | 279 | } |
194 | void OPimAlarm::copyIntern() { | 280 | |
195 | if ( data->count != 1 ) { | 281 | |
282 | void 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; |
@@ -201,11 +291,16 @@ void OPimAlarm::copyIntern() { | |||
201 | } | 291 | } |
202 | } | 292 | } |
293 | |||
294 | |||
203 | /************************/ | 295 | /************************/ |
204 | struct OPimReminder::Data : public QShared { | 296 | struct 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 | }; |
303 | |||
304 | |||
210 | OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) | 305 | OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) |
211 | : OPimNotify( start, dur, parent ) | 306 | : OPimNotify( start, dur, parent ) |
@@ -214,4 +309,6 @@ OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int paren | |||
214 | data->record = uid; | 309 | data->record = uid; |
215 | } | 310 | } |
311 | |||
312 | |||
216 | OPimReminder::OPimReminder( const OPimReminder& rem ) | 313 | OPimReminder::OPimReminder( const OPimReminder& rem ) |
217 | : OPimNotify( rem ), data( rem.data ) | 314 | : OPimNotify( rem ), data( rem.data ) |
@@ -219,5 +316,8 @@ OPimReminder::OPimReminder( const OPimReminder& rem ) | |||
219 | data->ref(); | 316 | data->ref(); |
220 | } | 317 | } |
221 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { | 318 | |
319 | |||
320 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem ) | ||
321 | { | ||
222 | OPimNotify::operator=(rem ); | 322 | OPimNotify::operator=(rem ); |
223 | 323 | ||
@@ -228,27 +328,47 @@ OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { | |||
228 | return *this; | 328 | return *this; |
229 | } | 329 | } |
230 | bool OPimReminder::operator==( const OPimReminder& rem) { | 330 | |
331 | |||
332 | bool 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 | } |
235 | QString OPimReminder::type()const { | 338 | |
339 | |||
340 | QString OPimReminder::type() const | ||
341 | { | ||
236 | return QString::fromLatin1("OPimReminder"); | 342 | return QString::fromLatin1("OPimReminder"); |
237 | } | 343 | } |
238 | int OPimReminder::recordUid()const { | 344 | |
345 | |||
346 | int OPimReminder::recordUid() const | ||
347 | { | ||
239 | return data->record; | 348 | return data->record; |
240 | } | 349 | } |
241 | void OPimReminder::setRecordUid( int uid ) { | 350 | |
351 | |||
352 | void OPimReminder::setRecordUid( int uid ) | ||
353 | { | ||
242 | copyIntern(); | 354 | copyIntern(); |
243 | data->record = uid; | 355 | data->record = uid; |
244 | } | 356 | } |
245 | void OPimReminder::deref() { | 357 | |
246 | if ( data->deref() ) { | 358 | |
359 | void OPimReminder::deref() | ||
360 | { | ||
361 | if ( data->deref() ) | ||
362 | { | ||
247 | delete data; | 363 | delete data; |
248 | data = 0l; | 364 | data = 0l; |
249 | } | 365 | } |
250 | } | 366 | } |
251 | void OPimReminder::copyIntern() { | 367 | |
252 | if ( data->count != 1 ) { | 368 | |
369 | void OPimReminder::copyIntern() | ||
370 | { | ||
371 | if ( data->count != 1 ) | ||
372 | { | ||
253 | Data* da = new Data; | 373 | Data* da = new Data; |
254 | da->record = data->record; | 374 | da->record = data->record; |
@@ -256,3 +376,4 @@ void OPimReminder::copyIntern() { | |||
256 | } | 376 | } |
257 | } | 377 | } |
378 | |||
258 | } | 379 | } |