Diffstat (limited to 'libopie2/opiepim/core/opimnotify.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimnotify.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp index af5514b..c61f9da 100644 --- a/libopie2/opiepim/core/opimnotify.cpp +++ b/libopie2/opiepim/core/opimnotify.cpp | |||
@@ -1,51 +1,81 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #include <qshared.h> | 29 | #include <qshared.h> |
2 | 30 | ||
3 | #include "opimnotify.h" | 31 | #include <opie2/opimnotify.h> |
32 | |||
33 | namespace Opie { | ||
4 | 34 | ||
5 | struct OPimNotify::Data : public QShared { | 35 | struct OPimNotify::Data : public QShared { |
6 | Data() : QShared(),dur(-1),parent(0) { | 36 | Data() : QShared(),dur(-1),parent(0) { |
7 | 37 | ||
8 | } | 38 | } |
9 | QDateTime start; | 39 | QDateTime start; |
10 | int dur; | 40 | int dur; |
11 | QString application; | 41 | QString application; |
12 | int parent; | 42 | int parent; |
13 | }; | 43 | }; |
14 | 44 | ||
15 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { | 45 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { |
16 | data = new Data; | 46 | data = new Data; |
17 | data->start = start; | 47 | data->start = start; |
18 | data->dur = duration; | 48 | data->dur = duration; |
19 | data->parent = parent; | 49 | data->parent = parent; |
20 | } | 50 | } |
21 | OPimNotify::OPimNotify( const OPimNotify& noti) | 51 | OPimNotify::OPimNotify( const OPimNotify& noti) |
22 | : data( noti.data ) | 52 | : data( noti.data ) |
23 | { | 53 | { |
24 | data->ref(); | 54 | data->ref(); |
25 | } | 55 | } |
26 | OPimNotify::~OPimNotify() { | 56 | OPimNotify::~OPimNotify() { |
27 | if ( data->deref() ) { | 57 | if ( data->deref() ) { |
28 | delete data; | 58 | delete data; |
29 | data = 0l; | 59 | data = 0l; |
30 | } | 60 | } |
31 | } | 61 | } |
32 | 62 | ||
33 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { | 63 | OPimNotify &OPimNotify::operator=( const OPimNotify& noti) { |
34 | noti.data->ref(); | 64 | noti.data->ref(); |
35 | deref(); | 65 | deref(); |
36 | data = noti.data; | 66 | data = noti.data; |
37 | 67 | ||
38 | return *this; | 68 | return *this; |
39 | } | 69 | } |
40 | bool OPimNotify::operator==( const OPimNotify& noti ) { | 70 | bool OPimNotify::operator==( const OPimNotify& noti ) { |
41 | if ( data == noti.data ) return true; | 71 | if ( data == noti.data ) return true; |
42 | if ( data->dur != noti.data->dur ) return false; | 72 | if ( data->dur != noti.data->dur ) return false; |
43 | if ( data->parent != noti.data->parent ) return false; | 73 | if ( data->parent != noti.data->parent ) return false; |
44 | if ( data->application != noti.data->application ) return false; | 74 | if ( data->application != noti.data->application ) return false; |
45 | if ( data->start != noti.data->start ) return false; | 75 | if ( data->start != noti.data->start ) return false; |
46 | 76 | ||
47 | return true; | 77 | return true; |
48 | } | 78 | } |
49 | QDateTime OPimNotify::dateTime()const { | 79 | QDateTime OPimNotify::dateTime()const { |
50 | return data->start; | 80 | return data->start; |
51 | } | 81 | } |
@@ -180,48 +210,49 @@ struct OPimReminder::Data : public QShared { | |||
180 | OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) | 210 | OPimReminder::OPimReminder( int uid, const QDateTime& start, int dur, int parent ) |
181 | : OPimNotify( start, dur, parent ) | 211 | : OPimNotify( start, dur, parent ) |
182 | { | 212 | { |
183 | data = new Data; | 213 | data = new Data; |
184 | data->record = uid; | 214 | data->record = uid; |
185 | } | 215 | } |
186 | OPimReminder::OPimReminder( const OPimReminder& rem ) | 216 | OPimReminder::OPimReminder( const OPimReminder& rem ) |
187 | : OPimNotify( rem ), data( rem.data ) | 217 | : OPimNotify( rem ), data( rem.data ) |
188 | { | 218 | { |
189 | data->ref(); | 219 | data->ref(); |
190 | } | 220 | } |
191 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { | 221 | OPimReminder& OPimReminder::operator=( const OPimReminder& rem) { |
192 | OPimNotify::operator=(rem ); | 222 | OPimNotify::operator=(rem ); |
193 | 223 | ||
194 | deref(); | 224 | deref(); |
195 | rem.data->ref(); | 225 | rem.data->ref(); |
196 | data = rem.data; | 226 | data = rem.data; |
197 | 227 | ||
198 | return *this; | 228 | return *this; |
199 | } | 229 | } |
200 | bool OPimReminder::operator==( const OPimReminder& rem) { | 230 | bool OPimReminder::operator==( const OPimReminder& rem) { |
201 | if ( data->record != rem.data->record ) return false; | 231 | if ( data->record != rem.data->record ) return false; |
202 | 232 | ||
203 | return OPimNotify::operator==( rem ); | 233 | return OPimNotify::operator==( rem ); |
204 | } | 234 | } |
205 | QString OPimReminder::type()const { | 235 | QString OPimReminder::type()const { |
206 | return QString::fromLatin1("OPimReminder"); | 236 | return QString::fromLatin1("OPimReminder"); |
207 | } | 237 | } |
208 | int OPimReminder::recordUid()const { | 238 | int OPimReminder::recordUid()const { |
209 | return data->record; | 239 | return data->record; |
210 | } | 240 | } |
211 | void OPimReminder::setRecordUid( int uid ) { | 241 | void OPimReminder::setRecordUid( int uid ) { |
212 | copyIntern(); | 242 | copyIntern(); |
213 | data->record = uid; | 243 | data->record = uid; |
214 | } | 244 | } |
215 | void OPimReminder::deref() { | 245 | void OPimReminder::deref() { |
216 | if ( data->deref() ) { | 246 | if ( data->deref() ) { |
217 | delete data; | 247 | delete data; |
218 | data = 0l; | 248 | data = 0l; |
219 | } | 249 | } |
220 | } | 250 | } |
221 | void OPimReminder::copyIntern() { | 251 | void OPimReminder::copyIntern() { |
222 | if ( data->count != 1 ) { | 252 | if ( data->count != 1 ) { |
223 | Data* da = new Data; | 253 | Data* da = new Data; |
224 | da->record = data->record; | 254 | da->record = data->record; |
225 | data = da; | 255 | data = da; |
226 | } | 256 | } |
227 | } | 257 | } |
258 | } | ||