author | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-23 13:15:42 (UTC) |
commit | f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf (patch) (unidiff) | |
tree | 4044006e676c78370fdeccf960ea4214f13eabd2 /libopie2/opiepim/core/opimnotify.cpp | |
parent | 2d37d653310da0a9d6e2e2e6c9f5bf092e54cbbb (diff) | |
download | opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.zip opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.gz opie-f9f0c26d9ac94586ffc36efa1b582ece3dbc43cf.tar.bz2 |
cosmetics
Diffstat (limited to 'libopie2/opiepim/core/opimnotify.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimnotify.cpp | 251 |
1 files changed, 186 insertions, 65 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 | |||
@@ -26,15 +26,19 @@ | |||
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 | ||
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; |
40 | int dur; | 44 | int dur; |
@@ -42,32 +46,44 @@ struct OPimNotify::Data : public QShared { | |||
42 | int parent; | 46 | int parent; |
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; |
48 | data->dur = duration; | 53 | data->dur = duration; |
49 | data->parent = parent; | 54 | data->parent = parent; |
50 | } | 55 | } |
51 | OPimNotify::OPimNotify( const OPimNotify& noti) | 56 | |
52 | : data( noti.data ) | 57 | |
58 | OPimNotify::OPimNotify( const OPimNotify& noti ) | ||
59 | : data( noti.data ) | ||
53 | { | 60 | { |
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; |
60 | } | 71 | } |
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(); |
66 | data = noti.data; | 79 | data = noti.data; |
67 | 80 | ||
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; |
73 | if ( data->parent != noti.data->parent ) return false; | 89 | if ( data->parent != noti.data->parent ) return false; |
@@ -76,81 +92,129 @@ bool OPimNotify::operator==( const OPimNotify& noti ) { | |||
76 | 92 | ||
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 | |
92 | return QDateTime( data->start.date(), data->start.time().addSecs( data->dur) ); | 120 | |
121 | QDateTime OPimNotify::endTime() const | ||
122 | { | ||
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; |
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 | } |
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; |
125 | } | 176 | } |
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 | } |
133 | int sound; | 187 | int sound; |
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 ) |
138 | { | 194 | { |
139 | data = new Data; | 195 | data = new Data; |
140 | data->sound = sound; | 196 | data->sound = sound; |
141 | } | 197 | } |
142 | OPimAlarm::OPimAlarm( const OPimAlarm& al) | 198 | |
143 | : OPimNotify(al), data( al.data ) | 199 | |
200 | OPimAlarm::OPimAlarm( const OPimAlarm& al ) | ||
201 | : OPimNotify( al ), data( al.data ) | ||
144 | { | 202 | { |
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 | } |
153 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) | 215 | |
216 | |||
217 | OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al ) | ||
154 | { | 218 | { |
155 | OPimNotify::operator=( al ); | 219 | OPimNotify::operator=( al ); |
156 | deref(); | 220 | deref(); |
@@ -161,65 +225,101 @@ OPimAlarm &OPimAlarm::operator=( const OPimAlarm& al) | |||
161 | 225 | ||
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 ) |
167 | return false; | 234 | return false; |
168 | 235 | ||
169 | return OPimNotify::operator==( al ); | 236 | return OPimNotify::operator==( al ); |
170 | } | 237 | } |
171 | QString OPimAlarm::type()const { | 238 | |
172 | return QString::fromLatin1("OPimAlarm"); | 239 | |
240 | QString OPimAlarm::type() const | ||
241 | { | ||
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; |
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 | /************************/ |
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 | }; |
210 | OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) | 303 | |
211 | : OPimNotify( start, dur, parent ) | 304 | |
305 | OPimReminder::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 | |||
216 | OPimReminder::OPimReminder( const OPimReminder& rem ) | 313 | OPimReminder::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 | } |
221 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { | 318 | |
222 | OPimNotify::operator=(rem ); | 319 | |
320 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem ) | ||
321 | { | ||
322 | OPimNotify::operator=( rem ); | ||
223 | 323 | ||
224 | deref(); | 324 | deref(); |
225 | rem.data->ref(); | 325 | rem.data->ref(); |
@@ -227,32 +327,53 @@ OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { | |||
227 | 327 | ||
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 | |
236 | return QString::fromLatin1("OPimReminder"); | 339 | |
340 | QString OPimReminder::type() const | ||
341 | { | ||
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 | |
253 | Data* da = new Data; | 369 | void 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 | } |