summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Unidiff
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/TODO5
-rw-r--r--libopie2/opiepim/core/opimcontact.cpp2
-rw-r--r--libopie2/opiepim/core/opimcontact.h2
-rw-r--r--libopie2/opiepim/core/opimevent.cpp2
-rw-r--r--libopie2/opiepim/core/opimevent.h2
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp2
-rw-r--r--libopie2/opiepim/core/opimrecord.h2
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp2
-rw-r--r--libopie2/opiepim/core/opimtodo.h2
9 files changed, 12 insertions, 9 deletions
diff --git a/libopie2/opiepim/TODO b/libopie2/opiepim/TODO
index cdde11c..c3420cf 100644
--- a/libopie2/opiepim/TODO
+++ b/libopie2/opiepim/TODO
@@ -1,60 +1,63 @@
1As to popular request.... 1As to popular request....
2 2
31.) fix up the core/backend mess. 31.) fix up the core/backend mess.
4 The actual Backend Implementation + Interface should be there 4 The actual Backend Implementation + Interface should be there
5 The API frontend used by the developer should not be used 5 The API frontend used by the developer should not be used
6 6
7 Rename ODateBookAccess* to OPimDateBookAccess*
8 Fix filenames to OPim* ...
9
72.) Move sorting, Query By Example, Exposing of Attributes of a Record 102.) Move sorting, Query By Example, Exposing of Attributes of a Record
8 available to the Ptr base class and have sane implementation 11 available to the Ptr base class and have sane implementation
9 on the template level 12 on the template level
10 13
113.) Have something like QProperty to expose attributes from OPimRecord. 143.) Have something like QProperty to expose attributes from OPimRecord.
12 This would include exporting,importing of data, and translated names. 15 This would include exporting,importing of data, and translated names.
13 This can be used for Cross Reference, Selector Widget, Generic Table 16 This can be used for Cross Reference, Selector Widget, Generic Table
14 Shower 17 Shower
15 18
164.) Marshall/Demarshall all PIM Records correctly 194.) Marshall/Demarshall all PIM Records correctly
17 20
185.) Add the Private Backend to the OPimRecord ( private ) make the base 215.) Add the Private Backend to the OPimRecord ( private ) make the base
19 access class friend and allow retrieving the backend. Make it virtual 22 access class friend and allow retrieving the backend. Make it virtual
20 so the template gets the right pointer. So it can only be accessed from 23 so the template gets the right pointer. So it can only be accessed from
21 the inside 24 the inside
22 25
236.) Add signals for updating/adding/removing records to the access template 266.) Add signals for updating/adding/removing records to the access template
24 Internal connect method 27 Internal connect method
25 28
267.) internal QCOP communication between the interfaces 297.) internal QCOP communication between the interfaces
27 30
288.) GUI:Better and Improved Recurrence Widget 318.) GUI:Better and Improved Recurrence Widget
29 32
309.) GUI:Improved Alarm Widget and handling classes 339.) GUI:Improved Alarm Widget and handling classes
31 34
3210.) GUI:Undo/Redo template look at KDE 3510.) GUI:Undo/Redo template look at KDE
33 36
3411.) GUI: Generic X-Ref Selector using the factory and pointer interface 3711.) GUI: Generic X-Ref Selector using the factory and pointer interface
35 38
3612.) GUI: Factory and also registration of foreign services. generate a records of type 3912.) GUI: Factory and also registration of foreign services. generate a records of type
37 40
3813.) Multiple Backends for an Access Template 4113.) Multiple Backends for an Access Template
39 42
4014.) ReadOnly Access 4314.) ReadOnly Access
41 44
4215.) GUI: Generic Table Widget maybe even baed on Selector with 4515.) GUI: Generic Table Widget maybe even baed on Selector with
43 configuration of shown Attribute 46 configuration of shown Attribute
44 47
4516.) Multiple Categories with Sub Categories including popup selector 4816.) Multiple Categories with Sub Categories including popup selector
46 Widget. Fix Bug with changing visible. Both helper class + gui. 49 Widget. Fix Bug with changing visible. Both helper class + gui.
47 Also group PopupNames Like in Function Menu of XEmacs 50 Also group PopupNames Like in Function Menu of XEmacs
48 51
4917.) ListView for TodolIst At least introduce parents and child 5217.) ListView for TodolIst At least introduce parents and child
50 And query for them 53 And query for them
51 54
5218.) Add querieng to Ptr Level for dates and date ranges. 5518.) Add querieng to Ptr Level for dates and date ranges.
53 Return OEffectiveEvents or such which is also only loaded 56 Return OEffectiveEvents or such which is also only loaded
54 if required. 57 if required.
55 58
5619.) Clean Up 5919.) Clean Up
57 60
5820.) Datebook Classes 6120.) Datebook Classes
59 62
6022.) Better helper for AlarmServer \ No newline at end of file 6322.) Better helper for AlarmServer \ No newline at end of file
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp
index 4a774e8..c1e06c8 100644
--- a/libopie2/opiepim/core/opimcontact.cpp
+++ b/libopie2/opiepim/core/opimcontact.cpp
@@ -1,1289 +1,1289 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de> 3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
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 29
30#define QTOPIA_INTERNAL_CONTACT_MRE 30#define QTOPIA_INTERNAL_CONTACT_MRE
31 31
32#include "opimcontact.h" 32#include "opimcontact.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/opimresolver.h> 35#include <opie2/opimresolver.h>
36#include <opie2/opimdateconversion.h> 36#include <opie2/opimdateconversion.h>
37#include <qpe/stringutil.h> 37#include <qpe/stringutil.h>
38#include <qpe/timestring.h> 38#include <qpe/timestring.h>
39#include <qpe/config.h> 39#include <qpe/config.h>
40 40
41/* QT */ 41/* QT */
42#include <qstylesheet.h> 42#include <qstylesheet.h>
43 43
44/* STD */ 44/* STD */
45#include <stdio.h> 45#include <stdio.h>
46 46
47/*! 47/*!
48 \class Contact contact.h 48 \class Contact contact.h
49 \brief The Contact class holds the data of an address book entry. 49 \brief The Contact class holds the data of an address book entry.
50 50
51 This data includes information the name of the person, contact 51 This data includes information the name of the person, contact
52 information, and business information such as deparment and job title. 52 information, and business information such as deparment and job title.
53 53
54 \ingroup qtopiaemb 54 \ingroup qtopiaemb
55 \ingroup qtopiadesktop 55 \ingroup qtopiadesktop
56*/ 56*/
57 57
58 58
59namespace Opie 59namespace Opie
60{ 60{
61/*! 61/*!
62 Creates a new, empty contact. 62 Creates a new, empty contact.
63*/ 63*/
64OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) 64OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 )
65{} 65{}
66 66
67/*! 67/*!
68 \internal 68 \internal
69 Creates a new contact. The properties of the contact are 69 Creates a new contact. The properties of the contact are
70 set from \a fromMap. 70 set from \a fromMap.
71*/ 71*/
72OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) 72OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
73{ 73{
74 QString cats = mMap[ Qtopia::AddressCategory ]; 74 QString cats = mMap[ Qtopia::AddressCategory ];
75 if ( !cats.isEmpty() ) 75 if ( !cats.isEmpty() )
76 setCategories( idsFromString( cats ) ); 76 setCategories( idsFromString( cats ) );
77 77
78 QString uidStr = find( Qtopia::AddressUid ); 78 QString uidStr = find( Qtopia::AddressUid );
79 79
80 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) 80 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
81 { 81 {
82 qWarning( "Invalid UID found. Generate new one.." ); 82 qWarning( "Invalid UID found. Generate new one.." );
83 setUid( uidGen().generate() ); 83 setUid( uidGen().generate() );
84 } 84 }
85 else 85 else
86 setUid( uidStr.toInt() ); 86 setUid( uidStr.toInt() );
87 87
88 // if ( !uidStr.isEmpty() ) 88 // if ( !uidStr.isEmpty() )
89 // setUid( uidStr.toInt() ); 89 // setUid( uidStr.toInt() );
90} 90}
91 91
92/*! 92/*!
93 Destroys a contact. 93 Destroys a contact.
94*/ 94*/
95OPimContact::~OPimContact() 95OPimContact::~OPimContact()
96{} 96{}
97 97
98/*! \fn void OPimContact::setTitle( const QString &str ) 98/*! \fn void OPimContact::setTitle( const QString &str )
99 Sets the title of the contact to \a str. 99 Sets the title of the contact to \a str.
100*/ 100*/
101 101
102/*! \fn void OPimContact::setFirstName( const QString &str ) 102/*! \fn void OPimContact::setFirstName( const QString &str )
103 Sets the first name of the contact to \a str. 103 Sets the first name of the contact to \a str.
104*/ 104*/
105 105
106/*! \fn void OPimContact::setMiddleName( const QString &str ) 106/*! \fn void OPimContact::setMiddleName( const QString &str )
107 Sets the middle name of the contact to \a str. 107 Sets the middle name of the contact to \a str.
108*/ 108*/
109 109
110/*! \fn void OPimContact::setLastName( const QString &str ) 110/*! \fn void OPimContact::setLastName( const QString &str )
111 Sets the last name of the contact to \a str. 111 Sets the last name of the contact to \a str.
112*/ 112*/
113 113
114/*! \fn void OPimContact::setSuffix( const QString &str ) 114/*! \fn void OPimContact::setSuffix( const QString &str )
115 Sets the suffix of the contact to \a str. 115 Sets the suffix of the contact to \a str.
116*/ 116*/
117 117
118/*! \fn void OPimContact::setFileAs( const QString &str ) 118/*! \fn void OPimContact::setFileAs( const QString &str )
119 Sets the contact to filed as \a str. 119 Sets the contact to filed as \a str.
120*/ 120*/
121 121
122/*! \fn void OPimContact::setDefaultEmail( const QString &str ) 122/*! \fn void OPimContact::setDefaultEmail( const QString &str )
123 Sets the default email of the contact to \a str. 123 Sets the default email of the contact to \a str.
124*/ 124*/
125 125
126/*! \fn void OPimContact::setHomeStreet( const QString &str ) 126/*! \fn void OPimContact::setHomeStreet( const QString &str )
127 Sets the home street address of the contact to \a str. 127 Sets the home street address of the contact to \a str.
128*/ 128*/
129 129
130/*! \fn void OPimContact::setHomeCity( const QString &str ) 130/*! \fn void OPimContact::setHomeCity( const QString &str )
131 Sets the home city of the contact to \a str. 131 Sets the home city of the contact to \a str.
132*/ 132*/
133 133
134/*! \fn void OPimContact::setHomeState( const QString &str ) 134/*! \fn void OPimContact::setHomeState( const QString &str )
135 Sets the home state of the contact to \a str. 135 Sets the home state of the contact to \a str.
136*/ 136*/
137 137
138/*! \fn void OPimContact::setHomeZip( const QString &str ) 138/*! \fn void OPimContact::setHomeZip( const QString &str )
139 Sets the home zip code of the contact to \a str. 139 Sets the home zip code of the contact to \a str.
140*/ 140*/
141 141
142/*! \fn void OPimContact::setHomeCountry( const QString &str ) 142/*! \fn void OPimContact::setHomeCountry( const QString &str )
143 Sets the home country of the contact to \a str. 143 Sets the home country of the contact to \a str.
144*/ 144*/
145 145
146/*! \fn void OPimContact::setHomePhone( const QString &str ) 146/*! \fn void OPimContact::setHomePhone( const QString &str )
147 Sets the home phone number of the contact to \a str. 147 Sets the home phone number of the contact to \a str.
148*/ 148*/
149 149
150/*! \fn void OPimContact::setHomeFax( const QString &str ) 150/*! \fn void OPimContact::setHomeFax( const QString &str )
151 Sets the home fax number of the contact to \a str. 151 Sets the home fax number of the contact to \a str.
152*/ 152*/
153 153
154/*! \fn void OPimContact::setHomeMobile( const QString &str ) 154/*! \fn void OPimContact::setHomeMobile( const QString &str )
155 Sets the home mobile phone number of the contact to \a str. 155 Sets the home mobile phone number of the contact to \a str.
156*/ 156*/
157 157
158/*! \fn void OPimContact::setHomeWebpage( const QString &str ) 158/*! \fn void OPimContact::setHomeWebpage( const QString &str )
159 Sets the home webpage of the contact to \a str. 159 Sets the home webpage of the contact to \a str.
160*/ 160*/
161 161
162/*! \fn void OPimContact::setCompany( const QString &str ) 162/*! \fn void OPimContact::setCompany( const QString &str )
163 Sets the company for contact to \a str. 163 Sets the company for contact to \a str.
164*/ 164*/
165 165
166/*! \fn void OPimContact::setJobTitle( const QString &str ) 166/*! \fn void OPimContact::setJobTitle( const QString &str )
167 Sets the job title of the contact to \a str. 167 Sets the job title of the contact to \a str.
168*/ 168*/
169 169
170/*! \fn void OPimContact::setDepartment( const QString &str ) 170/*! \fn void OPimContact::setDepartment( const QString &str )
171 Sets the department for contact to \a str. 171 Sets the department for contact to \a str.
172*/ 172*/
173 173
174/*! \fn void OPimContact::setOffice( const QString &str ) 174/*! \fn void OPimContact::setOffice( const QString &str )
175 Sets the office for contact to \a str. 175 Sets the office for contact to \a str.
176*/ 176*/
177 177
178/*! \fn void OPimContact::setBusinessStreet( const QString &str ) 178/*! \fn void OPimContact::setBusinessStreet( const QString &str )
179 Sets the business street address of the contact to \a str. 179 Sets the business street address of the contact to \a str.
180*/ 180*/
181 181
182/*! \fn void OPimContact::setBusinessCity( const QString &str ) 182/*! \fn void OPimContact::setBusinessCity( const QString &str )
183 Sets the business city of the contact to \a str. 183 Sets the business city of the contact to \a str.
184*/ 184*/
185 185
186/*! \fn void OPimContact::setBusinessState( const QString &str ) 186/*! \fn void OPimContact::setBusinessState( const QString &str )
187 Sets the business state of the contact to \a str. 187 Sets the business state of the contact to \a str.
188*/ 188*/
189 189
190/*! \fn void OPimContact::setBusinessZip( const QString &str ) 190/*! \fn void OPimContact::setBusinessZip( const QString &str )
191 Sets the business zip code of the contact to \a str. 191 Sets the business zip code of the contact to \a str.
192*/ 192*/
193 193
194/*! \fn void OPimContact::setBusinessCountry( const QString &str ) 194/*! \fn void OPimContact::setBusinessCountry( const QString &str )
195 Sets the business country of the contact to \a str. 195 Sets the business country of the contact to \a str.
196*/ 196*/
197 197
198/*! \fn void OPimContact::setBusinessPhone( const QString &str ) 198/*! \fn void OPimContact::setBusinessPhone( const QString &str )
199 Sets the business phone number of the contact to \a str. 199 Sets the business phone number of the contact to \a str.
200*/ 200*/
201 201
202/*! \fn void OPimContact::setBusinessFax( const QString &str ) 202/*! \fn void OPimContact::setBusinessFax( const QString &str )
203 Sets the business fax number of the contact to \a str. 203 Sets the business fax number of the contact to \a str.
204*/ 204*/
205 205
206/*! \fn void OPimContact::setBusinessMobile( const QString &str ) 206/*! \fn void OPimContact::setBusinessMobile( const QString &str )
207 Sets the business mobile phone number of the contact to \a str. 207 Sets the business mobile phone number of the contact to \a str.
208*/ 208*/
209 209
210/*! \fn void OPimContact::setBusinessPager( const QString &str ) 210/*! \fn void OPimContact::setBusinessPager( const QString &str )
211 Sets the business pager number of the contact to \a str. 211 Sets the business pager number of the contact to \a str.
212*/ 212*/
213 213
214/*! \fn void OPimContact::setBusinessWebpage( const QString &str ) 214/*! \fn void OPimContact::setBusinessWebpage( const QString &str )
215 Sets the business webpage of the contact to \a str. 215 Sets the business webpage of the contact to \a str.
216*/ 216*/
217 217
218/*! \fn void OPimContact::setProfession( const QString &str ) 218/*! \fn void OPimContact::setProfession( const QString &str )
219 Sets the profession of the contact to \a str. 219 Sets the profession of the contact to \a str.
220*/ 220*/
221 221
222/*! \fn void OPimContact::setAssistant( const QString &str ) 222/*! \fn void OPimContact::setAssistant( const QString &str )
223 Sets the assistant of the contact to \a str. 223 Sets the assistant of the contact to \a str.
224*/ 224*/
225 225
226/*! \fn void OPimContact::setManager( const QString &str ) 226/*! \fn void OPimContact::setManager( const QString &str )
227 Sets the manager of the contact to \a str. 227 Sets the manager of the contact to \a str.
228*/ 228*/
229 229
230/*! \fn void OPimContact::setSpouse( const QString &str ) 230/*! \fn void OPimContact::setSpouse( const QString &str )
231 Sets the spouse of the contact to \a str. 231 Sets the spouse of the contact to \a str.
232*/ 232*/
233 233
234/*! \fn void OPimContact::setGender( const QString &str ) 234/*! \fn void OPimContact::setGender( const QString &str )
235 Sets the gender of the contact to \a str. 235 Sets the gender of the contact to \a str.
236*/ 236*/
237 237
238/*! \fn void OPimContact::setNickname( const QString &str ) 238/*! \fn void OPimContact::setNickname( const QString &str )
239 Sets the nickname of the contact to \a str. 239 Sets the nickname of the contact to \a str.
240*/ 240*/
241 241
242/*! \fn void OPimContact::setNotes( const QString &str ) 242/*! \fn void OPimContact::setNotes( const QString &str )
243 Sets the notes about the contact to \a str. 243 Sets the notes about the contact to \a str.
244*/ 244*/
245 245
246/*! \fn QString OPimContact::title() const 246/*! \fn QString OPimContact::title() const
247 Returns the title of the contact. 247 Returns the title of the contact.
248*/ 248*/
249 249
250/*! \fn QString OPimContact::firstName() const 250/*! \fn QString OPimContact::firstName() const
251 Returns the first name of the contact. 251 Returns the first name of the contact.
252*/ 252*/
253 253
254/*! \fn QString OPimContact::middleName() const 254/*! \fn QString OPimContact::middleName() const
255 Returns the middle name of the contact. 255 Returns the middle name of the contact.
256*/ 256*/
257 257
258/*! \fn QString OPimContact::lastName() const 258/*! \fn QString OPimContact::lastName() const
259 Returns the last name of the contact. 259 Returns the last name of the contact.
260*/ 260*/
261 261
262/*! \fn QString OPimContact::suffix() const 262/*! \fn QString OPimContact::suffix() const
263 Returns the suffix of the contact. 263 Returns the suffix of the contact.
264*/ 264*/
265 265
266/*! \fn QString OPimContact::fileAs() const 266/*! \fn QString OPimContact::fileAs() const
267 Returns the string the contact is filed as. 267 Returns the string the contact is filed as.
268*/ 268*/
269 269
270/*! \fn QString OPimContact::defaultEmail() const 270/*! \fn QString OPimContact::defaultEmail() const
271 Returns the default email address of the contact. 271 Returns the default email address of the contact.
272*/ 272*/
273 273
274/*! \fn QString OPimContact::emails() const 274/*! \fn QString OPimContact::emails() const
275 Returns the list of email address for a contact separated by ';'s in a single 275 Returns the list of email address for a contact separated by ';'s in a single
276 string. 276 string.
277*/ 277*/
278 278
279/*! \fn QString OPimContact::homeStreet() const 279/*! \fn QString OPimContact::homeStreet() const
280 Returns the home street address of the contact. 280 Returns the home street address of the contact.
281*/ 281*/
282 282
283/*! \fn QString OPimContact::homeCity() const 283/*! \fn QString OPimContact::homeCity() const
284 Returns the home city of the contact. 284 Returns the home city of the contact.
285*/ 285*/
286 286
287/*! \fn QString OPimContact::homeState() const 287/*! \fn QString OPimContact::homeState() const
288 Returns the home state of the contact. 288 Returns the home state of the contact.
289*/ 289*/
290 290
291/*! \fn QString OPimContact::homeZip() const 291/*! \fn QString OPimContact::homeZip() const
292 Returns the home zip of the contact. 292 Returns the home zip of the contact.
293*/ 293*/
294 294
295/*! \fn QString OPimContact::homeCountry() const 295/*! \fn QString OPimContact::homeCountry() const
296 Returns the home country of the contact. 296 Returns the home country of the contact.
297*/ 297*/
298 298
299/*! \fn QString OPimContact::homePhone() const 299/*! \fn QString OPimContact::homePhone() const
300 Returns the home phone number of the contact. 300 Returns the home phone number of the contact.
301*/ 301*/
302 302
303/*! \fn QString OPimContact::homeFax() const 303/*! \fn QString OPimContact::homeFax() const
304 Returns the home fax number of the contact. 304 Returns the home fax number of the contact.
305*/ 305*/
306 306
307/*! \fn QString OPimContact::homeMobile() const 307/*! \fn QString OPimContact::homeMobile() const
308 Returns the home mobile number of the contact. 308 Returns the home mobile number of the contact.
309*/ 309*/
310 310
311/*! \fn QString OPimContact::homeWebpage() const 311/*! \fn QString OPimContact::homeWebpage() const
312 Returns the home webpage of the contact. 312 Returns the home webpage of the contact.
313*/ 313*/
314 314
315/*! \fn QString OPimContact::company() const 315/*! \fn QString OPimContact::company() const
316 Returns the company for the contact. 316 Returns the company for the contact.
317*/ 317*/
318 318
319/*! \fn QString OPimContact::department() const 319/*! \fn QString OPimContact::department() const
320 Returns the department for the contact. 320 Returns the department for the contact.
321*/ 321*/
322 322
323/*! \fn QString OPimContact::office() const 323/*! \fn QString OPimContact::office() const
324 Returns the office for the contact. 324 Returns the office for the contact.
325*/ 325*/
326 326
327/*! \fn QString OPimContact::jobTitle() const 327/*! \fn QString OPimContact::jobTitle() const
328 Returns the job title of the contact. 328 Returns the job title of the contact.
329*/ 329*/
330 330
331/*! \fn QString OPimContact::profession() const 331/*! \fn QString OPimContact::profession() const
332 Returns the profession of the contact. 332 Returns the profession of the contact.
333*/ 333*/
334 334
335/*! \fn QString OPimContact::assistant() const 335/*! \fn QString OPimContact::assistant() const
336 Returns the assistant of the contact. 336 Returns the assistant of the contact.
337*/ 337*/
338 338
339/*! \fn QString OPimContact::manager() const 339/*! \fn QString OPimContact::manager() const
340 Returns the manager of the contact. 340 Returns the manager of the contact.
341*/ 341*/
342 342
343/*! \fn QString OPimContact::businessStreet() const 343/*! \fn QString OPimContact::businessStreet() const
344 Returns the business street address of the contact. 344 Returns the business street address of the contact.
345*/ 345*/
346 346
347/*! \fn QString OPimContact::businessCity() const 347/*! \fn QString OPimContact::businessCity() const
348 Returns the business city of the contact. 348 Returns the business city of the contact.
349*/ 349*/
350 350
351/*! \fn QString OPimContact::businessState() const 351/*! \fn QString OPimContact::businessState() const
352 Returns the business state of the contact. 352 Returns the business state of the contact.
353*/ 353*/
354 354
355/*! \fn QString OPimContact::businessZip() const 355/*! \fn QString OPimContact::businessZip() const
356 Returns the business zip of the contact. 356 Returns the business zip of the contact.
357*/ 357*/
358 358
359/*! \fn QString OPimContact::businessCountry() const 359/*! \fn QString OPimContact::businessCountry() const
360 Returns the business country of the contact. 360 Returns the business country of the contact.
361*/ 361*/
362 362
363/*! \fn QString OPimContact::businessPhone() const 363/*! \fn QString OPimContact::businessPhone() const
364 Returns the business phone number of the contact. 364 Returns the business phone number of the contact.
365*/ 365*/
366 366
367/*! \fn QString OPimContact::businessFax() const 367/*! \fn QString OPimContact::businessFax() const
368 Returns the business fax number of the contact. 368 Returns the business fax number of the contact.
369*/ 369*/
370 370
371/*! \fn QString OPimContact::businessMobile() const 371/*! \fn QString OPimContact::businessMobile() const
372 Returns the business mobile number of the contact. 372 Returns the business mobile number of the contact.
373*/ 373*/
374 374
375/*! \fn QString OPimContact::businessPager() const 375/*! \fn QString OPimContact::businessPager() const
376 Returns the business pager number of the contact. 376 Returns the business pager number of the contact.
377*/ 377*/
378 378
379/*! \fn QString OPimContact::businessWebpage() const 379/*! \fn QString OPimContact::businessWebpage() const
380 Returns the business webpage of the contact. 380 Returns the business webpage of the contact.
381*/ 381*/
382 382
383/*! \fn QString OPimContact::spouse() const 383/*! \fn QString OPimContact::spouse() const
384 Returns the spouse of the contact. 384 Returns the spouse of the contact.
385*/ 385*/
386 386
387/*! \fn QString OPimContact::gender() const 387/*! \fn QString OPimContact::gender() const
388 Returns the gender of the contact. 388 Returns the gender of the contact.
389*/ 389*/
390 390
391/*! \fn QString OPimContact::nickname() const 391/*! \fn QString OPimContact::nickname() const
392 Returns the nickname of the contact. 392 Returns the nickname of the contact.
393*/ 393*/
394 394
395/*! \fn QString OPimContact::children() const 395/*! \fn QString OPimContact::children() const
396 Returns the children of the contact. 396 Returns the children of the contact.
397*/ 397*/
398 398
399/*! \fn QString OPimContact::notes() const 399/*! \fn QString OPimContact::notes() const
400 Returns the notes relating to the the contact. 400 Returns the notes relating to the the contact.
401*/ 401*/
402 402
403/*! \fn QString OPimContact::groups() const 403/*! \fn QString OPimContact::groups() const
404 \internal 404 \internal
405 Returns the groups for the contact. 405 Returns the groups for the contact.
406*/ 406*/
407 407
408/*! \fn QStringList OPimContact::groupList() const 408/*! \fn QStringList OPimContact::groupList() const
409 \internal 409 \internal
410*/ 410*/
411 411
412/*! \fn QString OPimContact::field(int) const 412/*! \fn QString OPimContact::field(int) const
413 \internal 413 \internal
414*/ 414*/
415 415
416/*! \fn void OPimContact::saveJournal( journal_action, const QString & = QString::null ) 416/*! \fn void OPimContact::saveJournal( journal_action, const QString & = QString::null )
417 \internal 417 \internal
418*/ 418*/
419 419
420/*! \fn void OPimContact::setUid( int id ) 420/*! \fn void OPimContact::setUid( int id )
421 \internal 421 \internal
422 Sets the uid for this record to \a id. 422 Sets the uid for this record to \a id.
423*/ 423*/
424 424
425/*! \enum OPimContact::journal_action 425/*! \enum OPimContact::journal_action
426 \internal 426 \internal
427*/ 427*/
428 428
429/*! 429/*!
430 \internal 430 \internal
431*/ 431*/
432QMap<int, QString> OPimContact::toMap() const 432QMap<int, QString> OPimContact::toMap() const
433{ 433{
434 QMap<int, QString> map = mMap; 434 QMap<int, QString> map = mMap;
435 QString cats = idsToString( categories() ); 435 QString cats = idsToString( categories() );
436 if ( !cats.isEmpty() ) 436 if ( !cats.isEmpty() )
437 map.insert( Qtopia::AddressCategory, cats ); 437 map.insert( Qtopia::AddressCategory, cats );
438 return map; 438 return map;
439} 439}
440 440
441/*! 441/*!
442 Returns a rich text formatted QString representing the contents the contact. 442 Returns a rich text formatted QString representing the contents the contact.
443*/ 443*/
444QString OPimContact::toRichText() const 444QString OPimContact::toRichText() const
445{ 445{
446 QString text; 446 QString text;
447 QString value, comp, state; 447 QString value, comp, state;
448 QString str; 448 QString str;
449 bool marker = false; 449 bool marker = false;
450 450
451 Config cfg( "qpe" ); 451 Config cfg( "qpe" );
452 cfg.setGroup( "Appearance" ); 452 cfg.setGroup( "Appearance" );
453 int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State ); 453 int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );
454 454
455 // name, jobtitle and company 455 // name, jobtitle and company
456 if ( !( value = fullName() ).isEmpty() ) 456 if ( !( value = fullName() ).isEmpty() )
457 text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>"; 457 text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>";
458 458
459 if ( !( value = jobTitle() ).isEmpty() ) 459 if ( !( value = jobTitle() ).isEmpty() )
460 text += Qtopia::escapeString( value ) + " "; 460 text += Qtopia::escapeString( value ) + " ";
461 461
462 comp = company(); 462 comp = company();
463 if ( !( value = department() ).isEmpty() ) 463 if ( !( value = department() ).isEmpty() )
464 { 464 {
465 text += Qtopia::escapeString( value ); 465 text += Qtopia::escapeString( value );
466 if ( comp ) 466 if ( comp )
467 text += ", " + Qtopia::escapeString( comp ); 467 text += ", " + Qtopia::escapeString( comp );
468 } 468 }
469 else if ( comp ) 469 else if ( comp )
470 text += "<br>" + Qtopia::escapeString( comp ); 470 text += "<br>" + Qtopia::escapeString( comp );
471 text += "<br><hr>"; 471 text += "<br><hr>";
472 472
473 // defailt email 473 // defailt email
474 QString defEmail = defaultEmail(); 474 QString defEmail = defaultEmail();
475 if ( !defEmail.isEmpty() ) 475 if ( !defEmail.isEmpty() )
476 { 476 {
477 text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>" 477 text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>"
478 + Qtopia::escapeString( defEmail ); 478 + Qtopia::escapeString( defEmail );
479 marker = true; 479 marker = true;
480 } 480 }
481 481
482 // business address 482 // business address
483 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 483 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
484 !businessZip().isEmpty() || !businessCountry().isEmpty() ) 484 !businessZip().isEmpty() || !businessCountry().isEmpty() )
485 { 485 {
486 text += QObject::tr( "<br><b>Work Address:</b>" ); 486 text += QObject::tr( "<br><b>Work Address:</b>" );
487 marker = true; 487 marker = true;
488 } 488 }
489 489
490 if ( !( value = businessStreet() ).isEmpty() ) 490 if ( !( value = businessStreet() ).isEmpty() )
491 { 491 {
492 text += "<br>" + Qtopia::escapeString( value ); 492 text += "<br>" + Qtopia::escapeString( value );
493 marker = true; 493 marker = true;
494 } 494 }
495 495
496 switch ( addressformat ) 496 switch ( addressformat )
497 { 497 {
498 case Zip_City_State: 498 case Zip_City_State:
499 { // Zip_Code City, State 499 { // Zip_Code City, State
500 state = businessState(); 500 state = businessState();
501 if ( !( value = businessZip() ).isEmpty() ) 501 if ( !( value = businessZip() ).isEmpty() )
502 { 502 {
503 text += "<br>" + Qtopia::escapeString( value ) + " "; 503 text += "<br>" + Qtopia::escapeString( value ) + " ";
504 marker = true; 504 marker = true;
505 505
506 } 506 }
507 if ( !( value = businessCity() ).isEmpty() ) 507 if ( !( value = businessCity() ).isEmpty() )
508 { 508 {
509 marker = true; 509 marker = true;
510 if ( businessZip().isEmpty() && !businessStreet().isEmpty() ) 510 if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
511 text += "<br>"; 511 text += "<br>";
512 text += Qtopia::escapeString( value ); 512 text += Qtopia::escapeString( value );
513 if ( state ) 513 if ( state )
514 text += ", " + Qtopia::escapeString( state ); 514 text += ", " + Qtopia::escapeString( state );
515 } 515 }
516 else if ( !state.isEmpty() ) 516 else if ( !state.isEmpty() )
517 { 517 {
518 text += "<br>" + Qtopia::escapeString( state ); 518 text += "<br>" + Qtopia::escapeString( state );
519 marker = true; 519 marker = true;
520 } 520 }
521 break; 521 break;
522 } 522 }
523 case City_State_Zip: 523 case City_State_Zip:
524 { // City, State Zip_Code 524 { // City, State Zip_Code
525 state = businessState(); 525 state = businessState();
526 if ( !( value = businessCity() ).isEmpty() ) 526 if ( !( value = businessCity() ).isEmpty() )
527 { 527 {
528 marker = true; 528 marker = true;
529 text += "<br>" + Qtopia::escapeString( value ); 529 text += "<br>" + Qtopia::escapeString( value );
530 if ( state ) 530 if ( state )
531 text += ", " + Qtopia::escapeString( state ); 531 text += ", " + Qtopia::escapeString( state );
532 } 532 }
533 else if ( !state.isEmpty() ) 533 else if ( !state.isEmpty() )
534 { 534 {
535 text += "<br>" + Qtopia::escapeString( state ); 535 text += "<br>" + Qtopia::escapeString( state );
536 marker = true; 536 marker = true;
537 } 537 }
538 if ( !( value = businessZip() ).isEmpty() ) 538 if ( !( value = businessZip() ).isEmpty() )
539 { 539 {
540 text += " " + Qtopia::escapeString( value ); 540 text += " " + Qtopia::escapeString( value );
541 marker = true; 541 marker = true;
542 } 542 }
543 break; 543 break;
544 } 544 }
545 } 545 }
546 546
547 if ( !( value = businessCountry() ).isEmpty() ) 547 if ( !( value = businessCountry() ).isEmpty() )
548 { 548 {
549 text += "<br>" + Qtopia::escapeString( value ); 549 text += "<br>" + Qtopia::escapeString( value );
550 marker = true; 550 marker = true;
551 } 551 }
552 552
553 // rest of Business data 553 // rest of Business data
554 str = office(); 554 str = office();
555 if ( !str.isEmpty() ) 555 if ( !str.isEmpty() )
556 { 556 {
557 text += "<br><b>" + QObject::tr( "Office: " ) + "</b>" 557 text += "<br><b>" + QObject::tr( "Office: " ) + "</b>"
558 + Qtopia::escapeString( str ); 558 + Qtopia::escapeString( str );
559 marker = true; 559 marker = true;
560 } 560 }
561 str = businessWebpage(); 561 str = businessWebpage();
562 if ( !str.isEmpty() ) 562 if ( !str.isEmpty() )
563 { 563 {
564 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>" 564 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>"
565 + Qtopia::escapeString( str ); 565 + Qtopia::escapeString( str );
566 marker = true; 566 marker = true;
567 } 567 }
568 str = businessPhone(); 568 str = businessPhone();
569 if ( !str.isEmpty() ) 569 if ( !str.isEmpty() )
570 { 570 {
571 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>" 571 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>"
572 + Qtopia::escapeString( str ); 572 + Qtopia::escapeString( str );
573 marker = true; 573 marker = true;
574 } 574 }
575 str = businessFax(); 575 str = businessFax();
576 if ( !str.isEmpty() ) 576 if ( !str.isEmpty() )
577 { 577 {
578 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>" 578 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>"
579 + Qtopia::escapeString( str ); 579 + Qtopia::escapeString( str );
580 marker = true; 580 marker = true;
581 } 581 }
582 str = businessMobile(); 582 str = businessMobile();
583 if ( !str.isEmpty() ) 583 if ( !str.isEmpty() )
584 { 584 {
585 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>" 585 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>"
586 + Qtopia::escapeString( str ); 586 + Qtopia::escapeString( str );
587 marker = true; 587 marker = true;
588 } 588 }
589 str = businessPager(); 589 str = businessPager();
590 if ( !str.isEmpty() ) 590 if ( !str.isEmpty() )
591 { 591 {
592 text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>" 592 text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>"
593 + Qtopia::escapeString( str ); 593 + Qtopia::escapeString( str );
594 marker = true; 594 marker = true;
595 } 595 }
596 596
597 // text += "<br>"; 597 // text += "<br>";
598 598
599 // home address 599 // home address
600 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 600 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
601 !homeZip().isEmpty() || !homeCountry().isEmpty() ) 601 !homeZip().isEmpty() || !homeCountry().isEmpty() )
602 { 602 {
603 text += QObject::tr( "<br><b>Home Address:</b>" ); 603 text += QObject::tr( "<br><b>Home Address:</b>" );
604 marker = true; 604 marker = true;
605 } 605 }
606 606
607 if ( !( value = homeStreet() ).isEmpty() ) 607 if ( !( value = homeStreet() ).isEmpty() )
608 { 608 {
609 text += "<br>" + Qtopia::escapeString( value ); 609 text += "<br>" + Qtopia::escapeString( value );
610 marker = true; 610 marker = true;
611 } 611 }
612 612
613 switch ( addressformat ) 613 switch ( addressformat )
614 { 614 {
615 case Zip_City_State: 615 case Zip_City_State:
616 { // Zip_Code City, State 616 { // Zip_Code City, State
617 state = homeState(); 617 state = homeState();
618 if ( !( value = homeZip() ).isEmpty() ) 618 if ( !( value = homeZip() ).isEmpty() )
619 { 619 {
620 text += "<br>" + Qtopia::escapeString( value ) + " "; 620 text += "<br>" + Qtopia::escapeString( value ) + " ";
621 marker = true; 621 marker = true;
622 } 622 }
623 if ( !( value = homeCity() ).isEmpty() ) 623 if ( !( value = homeCity() ).isEmpty() )
624 { 624 {
625 marker = true; 625 marker = true;
626 if ( homeZip().isEmpty() && !homeStreet().isEmpty() ) 626 if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
627 text += "<br>"; 627 text += "<br>";
628 text += Qtopia::escapeString( value ); 628 text += Qtopia::escapeString( value );
629 if ( !state.isEmpty() ) 629 if ( !state.isEmpty() )
630 text += ", " + Qtopia::escapeString( state ); 630 text += ", " + Qtopia::escapeString( state );
631 } 631 }
632 else if ( !state.isEmpty() ) 632 else if ( !state.isEmpty() )
633 { 633 {
634 text += "<br>" + Qtopia::escapeString( state ); 634 text += "<br>" + Qtopia::escapeString( state );
635 marker = true; 635 marker = true;
636 } 636 }
637 break; 637 break;
638 } 638 }
639 case City_State_Zip: 639 case City_State_Zip:
640 { // City, State Zip_Code 640 { // City, State Zip_Code
641 state = homeState(); 641 state = homeState();
642 if ( !( value = homeCity() ).isEmpty() ) 642 if ( !( value = homeCity() ).isEmpty() )
643 { 643 {
644 marker = true; 644 marker = true;
645 text += "<br>" + Qtopia::escapeString( value ); 645 text += "<br>" + Qtopia::escapeString( value );
646 if ( state ) 646 if ( state )
647 text += ", " + Qtopia::escapeString( state ); 647 text += ", " + Qtopia::escapeString( state );
648 } 648 }
649 else if ( !state.isEmpty() ) 649 else if ( !state.isEmpty() )
650 { 650 {
651 text += "<br>" + Qtopia::escapeString( state ); 651 text += "<br>" + Qtopia::escapeString( state );
652 marker = true; 652 marker = true;
653 } 653 }
654 if ( !( value = homeZip() ).isEmpty() ) 654 if ( !( value = homeZip() ).isEmpty() )
655 { 655 {
656 text += " " + Qtopia::escapeString( value ); 656 text += " " + Qtopia::escapeString( value );
657 marker = true; 657 marker = true;
658 } 658 }
659 break; 659 break;
660 } 660 }
661 } 661 }
662 662
663 if ( !( value = homeCountry() ).isEmpty() ) 663 if ( !( value = homeCountry() ).isEmpty() )
664 { 664 {
665 text += "<br>" + Qtopia::escapeString( value ); 665 text += "<br>" + Qtopia::escapeString( value );
666 marker = true; 666 marker = true;
667 } 667 }
668 668
669 // rest of Home data 669 // rest of Home data
670 str = homeWebpage(); 670 str = homeWebpage();
671 if ( !str.isEmpty() ) 671 if ( !str.isEmpty() )
672 { 672 {
673 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>" 673 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>"
674 + Qtopia::escapeString( str ); 674 + Qtopia::escapeString( str );
675 marker = true; 675 marker = true;
676 } 676 }
677 str = homePhone(); 677 str = homePhone();
678 if ( !str.isEmpty() ) 678 if ( !str.isEmpty() )
679 { 679 {
680 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>" 680 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>"
681 + Qtopia::escapeString( str ); 681 + Qtopia::escapeString( str );
682 marker = true; 682 marker = true;
683 } 683 }
684 str = homeFax(); 684 str = homeFax();
685 if ( !str.isEmpty() ) 685 if ( !str.isEmpty() )
686 { 686 {
687 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>" 687 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>"
688 + Qtopia::escapeString( str ); 688 + Qtopia::escapeString( str );
689 marker = true; 689 marker = true;
690 } 690 }
691 str = homeMobile(); 691 str = homeMobile();
692 if ( !str.isEmpty() ) 692 if ( !str.isEmpty() )
693 { 693 {
694 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>" 694 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>"
695 + Qtopia::escapeString( str ); 695 + Qtopia::escapeString( str );
696 marker = true; 696 marker = true;
697 } 697 }
698 698
699 if ( marker ) 699 if ( marker )
700 text += "<br><hr>"; 700 text += "<br><hr>";
701 701
702 // the rest... 702 // the rest...
703 str = emails(); 703 str = emails();
704 if ( !str.isEmpty() && ( str != defEmail ) ) 704 if ( !str.isEmpty() && ( str != defEmail ) )
705 text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>" 705 text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>"
706 + Qtopia::escapeString( str ); 706 + Qtopia::escapeString( str );
707 str = profession(); 707 str = profession();
708 if ( !str.isEmpty() ) 708 if ( !str.isEmpty() )
709 text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>" 709 text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>"
710 + Qtopia::escapeString( str ); 710 + Qtopia::escapeString( str );
711 str = assistant(); 711 str = assistant();
712 if ( !str.isEmpty() ) 712 if ( !str.isEmpty() )
713 text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>" 713 text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>"
714 + Qtopia::escapeString( str ); 714 + Qtopia::escapeString( str );
715 str = manager(); 715 str = manager();
716 if ( !str.isEmpty() ) 716 if ( !str.isEmpty() )
717 text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>" 717 text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>"
718 + Qtopia::escapeString( str ); 718 + Qtopia::escapeString( str );
719 str = gender(); 719 str = gender();
720 if ( !str.isEmpty() && str.toInt() != 0 ) 720 if ( !str.isEmpty() && str.toInt() != 0 )
721 { 721 {
722 text += "<br>"; 722 text += "<br>";
723 if ( str.toInt() == 1 ) 723 if ( str.toInt() == 1 )
724 str = QObject::tr( "Male" ); 724 str = QObject::tr( "Male" );
725 else if ( str.toInt() == 2 ) 725 else if ( str.toInt() == 2 )
726 str = QObject::tr( "Female" ); 726 str = QObject::tr( "Female" );
727 text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str; 727 text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str;
728 } 728 }
729 str = spouse(); 729 str = spouse();
730 if ( !str.isEmpty() ) 730 if ( !str.isEmpty() )
731 text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>" 731 text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>"
732 + Qtopia::escapeString( str ); 732 + Qtopia::escapeString( str );
733 if ( birthday().isValid() ) 733 if ( birthday().isValid() )
734 { 734 {
735 str = TimeString::numberDateString( birthday() ); 735 str = TimeString::numberDateString( birthday() );
736 text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>" 736 text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>"
737 + Qtopia::escapeString( str ); 737 + Qtopia::escapeString( str );
738 } 738 }
739 if ( anniversary().isValid() ) 739 if ( anniversary().isValid() )
740 { 740 {
741 str = TimeString::numberDateString( anniversary() ); 741 str = TimeString::numberDateString( anniversary() );
742 text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>" 742 text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>"
743 + Qtopia::escapeString( str ); 743 + Qtopia::escapeString( str );
744 } 744 }
745 str = children(); 745 str = children();
746 if ( !str.isEmpty() ) 746 if ( !str.isEmpty() )
747 text += "<br><b>" + QObject::tr( "Children: " ) + "</b>" 747 text += "<br><b>" + QObject::tr( "Children: " ) + "</b>"
748 + Qtopia::escapeString( str ); 748 + Qtopia::escapeString( str );
749 749
750 str = nickname(); 750 str = nickname();
751 if ( !str.isEmpty() ) 751 if ( !str.isEmpty() )
752 text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>" 752 text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>"
753 + Qtopia::escapeString( str ); 753 + Qtopia::escapeString( str );
754 754
755 // categories 755 // categories
756 if ( categoryNames( "Contacts" ).count() ) 756 if ( categoryNames( "Contacts" ).count() )
757 { 757 {
758 text += "<br><b>" + QObject::tr( "Category:" ) + "</b> "; 758 text += "<br><b>" + QObject::tr( "Category:" ) + "</b> ";
759 text += categoryNames( "Contacts" ).join( ", " ); 759 text += categoryNames( "Contacts" ).join( ", " );
760 } 760 }
761 761
762 // notes last 762 // notes last
763 if ( !( value = notes() ).isEmpty() ) 763 if ( !( value = notes() ).isEmpty() )
764 { 764 {
765 text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> "; 765 text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> ";
766 QRegExp reg( "\n" ); 766 QRegExp reg( "\n" );
767 767
768 //QString tmp = Qtopia::escapeString(value); 768 //QString tmp = Qtopia::escapeString(value);
769 QString tmp = QStyleSheet::convertFromPlainText( value ); 769 QString tmp = QStyleSheet::convertFromPlainText( value );
770 //tmp.replace( reg, "<br>" ); 770 //tmp.replace( reg, "<br>" );
771 text += "<br>" + tmp + "<br>"; 771 text += "<br>" + tmp + "<br>";
772 } 772 }
773 return text; 773 return text;
774} 774}
775 775
776/*! 776/*!
777 \internal 777 \internal
778*/ 778*/
779void OPimContact::insert( int key, const QString &v ) 779void OPimContact::insert( int key, const QString &v )
780{ 780{
781 QString value = v.stripWhiteSpace(); 781 QString value = v.stripWhiteSpace();
782 if ( value.isEmpty() ) 782 if ( value.isEmpty() )
783 mMap.remove( key ); 783 mMap.remove( key );
784 else 784 else
785 mMap.insert( key, value ); 785 mMap.insert( key, value );
786} 786}
787 787
788/*! 788/*!
789 \internal 789 \internal
790*/ 790*/
791void OPimContact::replace( int key, const QString & v ) 791void OPimContact::replace( int key, const QString & v )
792{ 792{
793 QString value = v.stripWhiteSpace(); 793 QString value = v.stripWhiteSpace();
794 if ( value.isEmpty() ) 794 if ( value.isEmpty() )
795 mMap.remove( key ); 795 mMap.remove( key );
796 else 796 else
797 mMap.replace( key, value ); 797 mMap.replace( key, value );
798} 798}
799 799
800/*! 800/*!
801 \internal 801 \internal
802*/ 802*/
803QString OPimContact::find( int key ) const 803QString OPimContact::find( int key ) const
804{ 804{
805 return mMap[ key ]; 805 return mMap[ key ];
806} 806}
807 807
808/*! 808/*!
809 \internal 809 \internal
810*/ 810*/
811QString OPimContact::displayAddress( const QString &street, 811QString OPimContact::displayAddress( const QString &street,
812 const QString &city, 812 const QString &city,
813 const QString &state, 813 const QString &state,
814 const QString &zip, 814 const QString &zip,
815 const QString &country ) const 815 const QString &country ) const
816{ 816{
817 QString s = street; 817 QString s = street;
818 if ( !street.isEmpty() ) 818 if ( !street.isEmpty() )
819 s += "\n"; 819 s += "\n";
820 s += city; 820 s += city;
821 if ( !city.isEmpty() && !state.isEmpty() ) 821 if ( !city.isEmpty() && !state.isEmpty() )
822 s += ", "; 822 s += ", ";
823 s += state; 823 s += state;
824 if ( !state.isEmpty() && !zip.isEmpty() ) 824 if ( !state.isEmpty() && !zip.isEmpty() )
825 s += " "; 825 s += " ";
826 s += zip; 826 s += zip;
827 if ( !country.isEmpty() && !s.isEmpty() ) 827 if ( !country.isEmpty() && !s.isEmpty() )
828 s += "\n"; 828 s += "\n";
829 s += country; 829 s += country;
830 return s; 830 return s;
831} 831}
832 832
833/*! 833/*!
834 \internal 834 \internal
835*/ 835*/
836QString OPimContact::displayBusinessAddress() const 836QString OPimContact::displayBusinessAddress() const
837{ 837{
838 return displayAddress( businessStreet(), businessCity(), 838 return displayAddress( businessStreet(), businessCity(),
839 businessState(), businessZip(), 839 businessState(), businessZip(),
840 businessCountry() ); 840 businessCountry() );
841} 841}
842 842
843/*! 843/*!
844 \internal 844 \internal
845*/ 845*/
846QString OPimContact::displayHomeAddress() const 846QString OPimContact::displayHomeAddress() const
847{ 847{
848 return displayAddress( homeStreet(), homeCity(), 848 return displayAddress( homeStreet(), homeCity(),
849 homeState(), homeZip(), 849 homeState(), homeZip(),
850 homeCountry() ); 850 homeCountry() );
851} 851}
852 852
853/*! 853/*!
854 Returns the full name of the contact 854 Returns the full name of the contact
855*/ 855*/
856QString OPimContact::fullName() const 856QString OPimContact::fullName() const
857{ 857{
858 QString title = find( Qtopia::Title ); 858 QString title = find( Qtopia::Title );
859 QString firstName = find( Qtopia::FirstName ); 859 QString firstName = find( Qtopia::FirstName );
860 QString middleName = find( Qtopia::MiddleName ); 860 QString middleName = find( Qtopia::MiddleName );
861 QString lastName = find( Qtopia::LastName ); 861 QString lastName = find( Qtopia::LastName );
862 QString suffix = find( Qtopia::Suffix ); 862 QString suffix = find( Qtopia::Suffix );
863 863
864 QString name = title; 864 QString name = title;
865 if ( !firstName.isEmpty() ) 865 if ( !firstName.isEmpty() )
866 { 866 {
867 if ( !name.isEmpty() ) 867 if ( !name.isEmpty() )
868 name += " "; 868 name += " ";
869 name += firstName; 869 name += firstName;
870 } 870 }
871 if ( !middleName.isEmpty() ) 871 if ( !middleName.isEmpty() )
872 { 872 {
873 if ( !name.isEmpty() ) 873 if ( !name.isEmpty() )
874 name += " "; 874 name += " ";
875 name += middleName; 875 name += middleName;
876 } 876 }
877 if ( !lastName.isEmpty() ) 877 if ( !lastName.isEmpty() )
878 { 878 {
879 if ( !name.isEmpty() ) 879 if ( !name.isEmpty() )
880 name += " "; 880 name += " ";
881 name += lastName; 881 name += lastName;
882 } 882 }
883 if ( !suffix.isEmpty() ) 883 if ( !suffix.isEmpty() )
884 { 884 {
885 if ( !name.isEmpty() ) 885 if ( !name.isEmpty() )
886 name += " "; 886 name += " ";
887 name += suffix; 887 name += suffix;
888 } 888 }
889 return name.simplifyWhiteSpace(); 889 return name.simplifyWhiteSpace();
890} 890}
891 891
892/*! 892/*!
893 Returns a list of the names of the children of the contact. 893 Returns a list of the names of the children of the contact.
894*/ 894*/
895QStringList OPimContact::childrenList() const 895QStringList OPimContact::childrenList() const
896{ 896{
897 return QStringList::split( " ", find( Qtopia::Children ) ); 897 return QStringList::split( " ", find( Qtopia::Children ) );
898} 898}
899 899
900/*! \fn void OPimContact::insertEmail( const QString &email ) 900/*! \fn void OPimContact::insertEmail( const QString &email )
901 901
902 Insert \a email into the email list. Ensures \a email can only be added 902 Insert \a email into the email list. Ensures \a email can only be added
903 once. If there is no default email address set, it sets it to the \a email. 903 once. If there is no default email address set, it sets it to the \a email.
904*/ 904*/
905 905
906/*! \fn void OPimContact::removeEmail( const QString &email ) 906/*! \fn void OPimContact::removeEmail( const QString &email )
907 907
908 Removes the \a email from the email list. If the default email was \a email, 908 Removes the \a email from the email list. If the default email was \a email,
909 then the default email address is assigned to the first email in the 909 then the default email address is assigned to the first email in the
910 email list 910 email list
911*/ 911*/
912 912
913/*! \fn void OPimContact::clearEmails() 913/*! \fn void OPimContact::clearEmails()
914 914
915 Clears the email list. 915 Clears the email list.
916 */ 916 */
917 917
918/*! \fn void OPimContact::insertEmails( const QStringList &emailList ) 918/*! \fn void OPimContact::insertEmails( const QStringList &emailList )
919 919
920 Appends the \a emailList to the exiting email list 920 Appends the \a emailList to the exiting email list
921 */ 921 */
922 922
923/*! 923/*!
924 Returns a list of email addresses belonging to the contact, including 924 Returns a list of email addresses belonging to the contact, including
925 the default email address. 925 the default email address.
926*/ 926*/
927QStringList OPimContact::emailList() const 927QStringList OPimContact::emailList() const
928{ 928{
929 QString emailStr = emails(); 929 QString emailStr = emails();
930 930
931 QStringList r; 931 QStringList r;
932 if ( !emailStr.isEmpty() ) 932 if ( !emailStr.isEmpty() )
933 { 933 {
934 qDebug( " emailstr " ); 934 qDebug( " emailstr " );
935 QStringList l = QStringList::split( emailSeparator(), emailStr ); 935 QStringList l = QStringList::split( emailSeparator(), emailStr );
936 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 936 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
937 r += ( *it ).simplifyWhiteSpace(); 937 r += ( *it ).simplifyWhiteSpace();
938 } 938 }
939 939
940 return r; 940 return r;
941} 941}
942 942
943/*! 943/*!
944 \overload 944 \overload
945 945
946 Generates the string for the contact to be filed as from the first, 946 Generates the string for the contact to be filed as from the first,
947 middle and last name of the contact. 947 middle and last name of the contact.
948*/ 948*/
949void OPimContact::setFileAs() 949void OPimContact::setFileAs()
950{ 950{
951 QString lastName, firstName, middleName, fileas; 951 QString lastName, firstName, middleName, fileas;
952 952
953 lastName = find( Qtopia::LastName ); 953 lastName = find( Qtopia::LastName );
954 firstName = find( Qtopia::FirstName ); 954 firstName = find( Qtopia::FirstName );
955 middleName = find( Qtopia::MiddleName ); 955 middleName = find( Qtopia::MiddleName );
956 if ( !lastName.isEmpty() && !firstName.isEmpty() 956 if ( !lastName.isEmpty() && !firstName.isEmpty()
957 && !middleName.isEmpty() ) 957 && !middleName.isEmpty() )
958 fileas = lastName + ", " + firstName + " " + middleName; 958 fileas = lastName + ", " + firstName + " " + middleName;
959 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 959 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
960 fileas = lastName + ", " + firstName; 960 fileas = lastName + ", " + firstName;
961 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 961 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
962 !middleName.isEmpty() ) 962 !middleName.isEmpty() )
963 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 963 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
964 + middleName + ( middleName.isEmpty() ? "" : " " ) 964 + middleName + ( middleName.isEmpty() ? "" : " " )
965 + lastName; 965 + lastName;
966 966
967 replace( Qtopia::FileAs, fileas ); 967 replace( Qtopia::FileAs, fileas );
968} 968}
969 969
970/*! 970/*!
971 \internal 971 \internal
972 Appends the contact information to \a buf. 972 Appends the contact information to \a buf.
973*/ 973*/
974void OPimContact::save( QString &buf ) const 974void OPimContact::save( QString &buf ) const
975{ 975{
976 static const QStringList SLFIELDS = fields(); 976 static const QStringList SLFIELDS = fields();
977 // I'm expecting "<Contact " in front of this... 977 // I'm expecting "<Contact " in front of this...
978 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 978 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
979 it != mMap.end(); ++it ) 979 it != mMap.end(); ++it )
980 { 980 {
981 const QString &value = it.data(); 981 const QString &value = it.data();
982 int key = it.key(); 982 int key = it.key();
983 if ( !value.isEmpty() ) 983 if ( !value.isEmpty() )
984 { 984 {
985 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid ) 985 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid )
986 continue; 986 continue;
987 987
988 key -= Qtopia::AddressCategory + 1; 988 key -= Qtopia::AddressCategory + 1;
989 buf += SLFIELDS[ key ]; 989 buf += SLFIELDS[ key ];
990 buf += "=\"" + Qtopia::escapeString( value ) + "\" "; 990 buf += "=\"" + Qtopia::escapeString( value ) + "\" ";
991 } 991 }
992 } 992 }
993 buf += customToXml(); 993 buf += customToXml();
994 if ( categories().count() > 0 ) 994 if ( categories().count() > 0 )
995 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 995 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
996 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 996 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
997 // You need to close this yourself 997 // You need to close this yourself
998} 998}
999 999
1000 1000
1001/*! 1001/*!
1002 \internal 1002 \internal
1003 Returns the list of fields belonging to a contact 1003 Returns the list of fields belonging to a contact
1004 Never change order of this list ! It has to be regarding 1004 Never change order of this list ! It has to be regarding
1005 enum AddressBookFields !! 1005 enum AddressBookFields !!
1006*/ 1006*/
1007QStringList OPimContact::fields() 1007QStringList OPimContact::fields()
1008{ 1008{
1009 QStringList list; 1009 QStringList list;
1010 1010
1011 list.append( "Title" ); // Not Used! 1011 list.append( "Title" ); // Not Used!
1012 list.append( "FirstName" ); 1012 list.append( "FirstName" );
1013 list.append( "MiddleName" ); 1013 list.append( "MiddleName" );
1014 list.append( "LastName" ); 1014 list.append( "LastName" );
1015 list.append( "Suffix" ); 1015 list.append( "Suffix" );
1016 list.append( "FileAs" ); 1016 list.append( "FileAs" );
1017 1017
1018 list.append( "JobTitle" ); 1018 list.append( "JobTitle" );
1019 list.append( "Department" ); 1019 list.append( "Department" );
1020 list.append( "Company" ); 1020 list.append( "Company" );
1021 list.append( "BusinessPhone" ); 1021 list.append( "BusinessPhone" );
1022 list.append( "BusinessFax" ); 1022 list.append( "BusinessFax" );
1023 list.append( "BusinessMobile" ); 1023 list.append( "BusinessMobile" );
1024 1024
1025 list.append( "DefaultEmail" ); 1025 list.append( "DefaultEmail" );
1026 list.append( "Emails" ); 1026 list.append( "Emails" );
1027 1027
1028 list.append( "HomePhone" ); 1028 list.append( "HomePhone" );
1029 list.append( "HomeFax" ); 1029 list.append( "HomeFax" );
1030 list.append( "HomeMobile" ); 1030 list.append( "HomeMobile" );
1031 1031
1032 list.append( "BusinessStreet" ); 1032 list.append( "BusinessStreet" );
1033 list.append( "BusinessCity" ); 1033 list.append( "BusinessCity" );
1034 list.append( "BusinessState" ); 1034 list.append( "BusinessState" );
1035 list.append( "BusinessZip" ); 1035 list.append( "BusinessZip" );
1036 list.append( "BusinessCountry" ); 1036 list.append( "BusinessCountry" );
1037 list.append( "BusinessPager" ); 1037 list.append( "BusinessPager" );
1038 list.append( "BusinessWebPage" ); 1038 list.append( "BusinessWebPage" );
1039 1039
1040 list.append( "Office" ); 1040 list.append( "Office" );
1041 list.append( "Profession" ); 1041 list.append( "Profession" );
1042 list.append( "Assistant" ); 1042 list.append( "Assistant" );
1043 list.append( "Manager" ); 1043 list.append( "Manager" );
1044 1044
1045 list.append( "HomeStreet" ); 1045 list.append( "HomeStreet" );
1046 list.append( "HomeCity" ); 1046 list.append( "HomeCity" );
1047 list.append( "HomeState" ); 1047 list.append( "HomeState" );
1048 list.append( "HomeZip" ); 1048 list.append( "HomeZip" );
1049 list.append( "HomeCountry" ); 1049 list.append( "HomeCountry" );
1050 list.append( "HomeWebPage" ); 1050 list.append( "HomeWebPage" );
1051 1051
1052 list.append( "Spouse" ); 1052 list.append( "Spouse" );
1053 list.append( "Gender" ); 1053 list.append( "Gender" );
1054 list.append( "Birthday" ); 1054 list.append( "Birthday" );
1055 list.append( "Anniversary" ); 1055 list.append( "Anniversary" );
1056 list.append( "Nickname" ); 1056 list.append( "Nickname" );
1057 list.append( "Children" ); 1057 list.append( "Children" );
1058 1058
1059 list.append( "Notes" ); 1059 list.append( "Notes" );
1060 list.append( "Groups" ); 1060 list.append( "Groups" );
1061 1061
1062 return list; 1062 return list;
1063} 1063}
1064 1064
1065 1065
1066/*! 1066/*!
1067 Sets the list of email address for contact to those contained in \a str. 1067 Sets the list of email address for contact to those contained in \a str.
1068 Email address should be separated by ';'s. 1068 Email address should be separated by ';'s.
1069*/ 1069*/
1070void OPimContact::setEmails( const QString &str ) 1070void OPimContact::setEmails( const QString &str )
1071{ 1071{
1072 replace( Qtopia::Emails, str ); 1072 replace( Qtopia::Emails, str );
1073 if ( str.isEmpty() ) 1073 if ( str.isEmpty() )
1074 setDefaultEmail( QString::null ); 1074 setDefaultEmail( QString::null );
1075} 1075}
1076 1076
1077/*! 1077/*!
1078 Sets the list of children for the contact to those contained in \a str. 1078 Sets the list of children for the contact to those contained in \a str.
1079*/ 1079*/
1080void OPimContact::setChildren( const QString &str ) 1080void OPimContact::setChildren( const QString &str )
1081{ 1081{
1082 replace( Qtopia::Children, str ); 1082 replace( Qtopia::Children, str );
1083} 1083}
1084 1084
1085/*! 1085/*!
1086 \overload 1086 \overload
1087 Returns TRUE if the contact matches the regular expression \a regexp. 1087 Returns TRUE if the contact matches the regular expression \a regexp.
1088 Otherwise returns FALSE. 1088 Otherwise returns FALSE.
1089*/ 1089*/
1090bool OPimContact::match( const QRegExp &r ) const 1090bool OPimContact::match( const QRegExp &r ) const
1091{ 1091{
1092 setLastHitField( -1 ); 1092 setLastHitField( -1 );
1093 bool match; 1093 bool match;
1094 match = false; 1094 match = false;
1095 QMap<int, QString>::ConstIterator it; 1095 QMap<int, QString>::ConstIterator it;
1096 for ( it = mMap.begin(); it != mMap.end(); ++it ) 1096 for ( it = mMap.begin(); it != mMap.end(); ++it )
1097 { 1097 {
1098 if ( ( *it ).find( r ) > -1 ) 1098 if ( ( *it ).find( r ) > -1 )
1099 { 1099 {
1100 setLastHitField( it.key() ); 1100 setLastHitField( it.key() );
1101 match = true; 1101 match = true;
1102 break; 1102 break;
1103 } 1103 }
1104 } 1104 }
1105 return match; 1105 return match;
1106} 1106}
1107 1107
1108 1108
1109QString OPimContact::toShortText() const 1109QString OPimContact::toShortText() const
1110{ 1110{
1111 return ( fullName() ); 1111 return ( fullName() );
1112} 1112}
1113 1113
1114 1114
1115QString OPimContact::type() const 1115QString OPimContact::type() const
1116{ 1116{
1117 return QString::fromLatin1( "OPimContact" ); 1117 return QString::fromLatin1( "OPimContact" );
1118} 1118}
1119 1119
1120 1120
1121class QString OPimContact::recordField( int pos ) const 1121class QString OPimContact::recordField( int pos ) const
1122{ 1122{
1123 QStringList SLFIELDS = fields(); // ?? why this ? (se) 1123 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1124 return SLFIELDS[ pos ]; 1124 return SLFIELDS[ pos ];
1125} 1125}
1126 1126
1127// In future releases, we should store birthday and anniversary 1127// In future releases, we should store birthday and anniversary
1128// internally as QDate instead of QString ! 1128// internally as QDate instead of QString !
1129// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1129// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1130 1130
1131/*! \fn void OPimContact::setBirthday( const QDate& date ) 1131/*! \fn void OPimContact::setBirthday( const QDate& date )
1132 Sets the birthday for the contact to \a date. If date is null 1132 Sets the birthday for the contact to \a date. If date is null
1133 the current stored date will be removed. 1133 the current stored date will be removed.
1134*/ 1134*/
1135void OPimContact::setBirthday( const QDate &v ) 1135void OPimContact::setBirthday( const QDate &v )
1136{ 1136{
1137 if ( v.isNull() ) 1137 if ( v.isNull() )
1138 { 1138 {
1139 qWarning( "Remove Birthday" ); 1139 qWarning( "Remove Birthday" );
1140 replace( Qtopia::Birthday, QString::null ); 1140 replace( Qtopia::Birthday, QString::null );
1141 return ; 1141 return ;
1142 } 1142 }
1143 1143
1144 if ( v.isValid() ) 1144 if ( v.isValid() )
1145 replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); 1145 replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) );
1146 1146
1147} 1147}
1148 1148
1149 1149
1150/*! \fn void OPimContact::setAnniversary( const QDate &date ) 1150/*! \fn void OPimContact::setAnniversary( const QDate &date )
1151 Sets the anniversary of the contact to \a date. If date is 1151 Sets the anniversary of the contact to \a date. If date is
1152 null, the current stored date will be removed. 1152 null, the current stored date will be removed.
1153*/ 1153*/
1154void OPimContact::setAnniversary( const QDate &v ) 1154void OPimContact::setAnniversary( const QDate &v )
1155{ 1155{
1156 if ( v.isNull() ) 1156 if ( v.isNull() )
1157 { 1157 {
1158 qWarning( "Remove Anniversary" ); 1158 qWarning( "Remove Anniversary" );
1159 replace( Qtopia::Anniversary, QString::null ); 1159 replace( Qtopia::Anniversary, QString::null );
1160 return ; 1160 return ;
1161 } 1161 }
1162 1162
1163 if ( v.isValid() ) 1163 if ( v.isValid() )
1164 replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); 1164 replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) );
1165} 1165}
1166 1166
1167 1167
1168/*! \fn QDate OPimContact::birthday() const 1168/*! \fn QDate OPimContact::birthday() const
1169 Returns the birthday of the contact. 1169 Returns the birthday of the contact.
1170*/ 1170*/
1171QDate OPimContact::birthday() const 1171QDate OPimContact::birthday() const
1172{ 1172{
1173 QString str = find( Qtopia::Birthday ); 1173 QString str = find( Qtopia::Birthday );
1174 // qWarning ("Birthday %s", str.latin1() ); 1174 // qWarning ("Birthday %s", str.latin1() );
1175 if ( !str.isEmpty() ) 1175 if ( !str.isEmpty() )
1176 return OPimDateConversion::dateFromString ( str ); 1176 return OPimDateConversion::dateFromString ( str );
1177 else 1177 else
1178 return QDate(); 1178 return QDate();
1179} 1179}
1180 1180
1181 1181
1182/*! \fn QDate OPimContact::anniversary() const 1182/*! \fn QDate OPimContact::anniversary() const
1183 Returns the anniversary of the contact. 1183 Returns the anniversary of the contact.
1184*/ 1184*/
1185QDate OPimContact::anniversary() const 1185QDate OPimContact::anniversary() const
1186{ 1186{
1187 QDate empty; 1187 QDate empty;
1188 QString str = find( Qtopia::Anniversary ); 1188 QString str = find( Qtopia::Anniversary );
1189 // qWarning ("Anniversary %s", str.latin1() ); 1189 // qWarning ("Anniversary %s", str.latin1() );
1190 if ( !str.isEmpty() ) 1190 if ( !str.isEmpty() )
1191 return OPimDateConversion::dateFromString ( str ); 1191 return OPimDateConversion::dateFromString ( str );
1192 else 1192 else
1193 return empty; 1193 return empty;
1194} 1194}
1195 1195
1196 1196
1197void OPimContact::insertEmail( const QString &v ) 1197void OPimContact::insertEmail( const QString &v )
1198{ 1198{
1199 //qDebug("insertEmail %s", v.latin1()); 1199 //qDebug("insertEmail %s", v.latin1());
1200 QString e = v.simplifyWhiteSpace(); 1200 QString e = v.simplifyWhiteSpace();
1201 QString def = defaultEmail(); 1201 QString def = defaultEmail();
1202 1202
1203 // if no default, set it as the default email and don't insert 1203 // if no default, set it as the default email and don't insert
1204 if ( def.isEmpty() ) 1204 if ( def.isEmpty() )
1205 { 1205 {
1206 setDefaultEmail( e ); // will insert into the list for us 1206 setDefaultEmail( e ); // will insert into the list for us
1207 return ; 1207 return ;
1208 } 1208 }
1209 1209
1210 // otherwise, insert assuming doesn't already exist 1210 // otherwise, insert assuming doesn't already exist
1211 QString emailsStr = find( Qtopia::Emails ); 1211 QString emailsStr = find( Qtopia::Emails );
1212 if ( emailsStr.contains( e ) ) 1212 if ( emailsStr.contains( e ) )
1213 return ; 1213 return ;
1214 if ( !emailsStr.isEmpty() ) 1214 if ( !emailsStr.isEmpty() )
1215 emailsStr += emailSeparator(); 1215 emailsStr += emailSeparator();
1216 emailsStr += e; 1216 emailsStr += e;
1217 replace( Qtopia::Emails, emailsStr ); 1217 replace( Qtopia::Emails, emailsStr );
1218} 1218}
1219 1219
1220 1220
1221 void OPimContact::removeEmail( const QString &v ) 1221 void OPimContact::removeEmail( const QString &v )
1222{ 1222{
1223 QString e = v.simplifyWhiteSpace(); 1223 QString e = v.simplifyWhiteSpace();
1224 QString def = defaultEmail(); 1224 QString def = defaultEmail();
1225 QString emailsStr = find( Qtopia::Emails ); 1225 QString emailsStr = find( Qtopia::Emails );
1226 QStringList emails = emailList(); 1226 QStringList emails = emailList();
1227 1227
1228 // otherwise, must first contain it 1228 // otherwise, must first contain it
1229 if ( !emailsStr.contains( e ) ) 1229 if ( !emailsStr.contains( e ) )
1230 return ; 1230 return ;
1231 1231
1232 // remove it 1232 // remove it
1233 //qDebug(" removing email from list %s", e.latin1()); 1233 //qDebug(" removing email from list %s", e.latin1());
1234 emails.remove( e ); 1234 emails.remove( e );
1235 // reset the string 1235 // reset the string
1236 emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator 1236 emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator
1237 replace( Qtopia::Emails, emailsStr ); 1237 replace( Qtopia::Emails, emailsStr );
1238 1238
1239 // if default, then replace the default email with the first one 1239 // if default, then replace the default email with the first one
1240 if ( def == e ) 1240 if ( def == e )
1241 { 1241 {
1242 //qDebug("removeEmail is default; setting new default"); 1242 //qDebug("removeEmail is default; setting new default");
1243 if ( !emails.count() ) 1243 if ( !emails.count() )
1244 clearEmails(); 1244 clearEmails();
1245 else // setDefaultEmail will remove e from the list 1245 else // setDefaultEmail will remove e from the list
1246 setDefaultEmail( emails.first() ); 1246 setDefaultEmail( emails.first() );
1247 } 1247 }
1248} 1248}
1249 1249
1250 1250
1251void OPimContact::clearEmails() 1251void OPimContact::clearEmails()
1252{ 1252{
1253 mMap.remove( Qtopia::DefaultEmail ); 1253 mMap.remove( Qtopia::DefaultEmail );
1254 mMap.remove( Qtopia::Emails ); 1254 mMap.remove( Qtopia::Emails );
1255} 1255}
1256 1256
1257 1257
1258void OPimContact::setDefaultEmail( const QString &v ) 1258void OPimContact::setDefaultEmail( const QString &v )
1259{ 1259{
1260 QString e = v.simplifyWhiteSpace(); 1260 QString e = v.simplifyWhiteSpace();
1261 1261
1262 //qDebug("OPimContact::setDefaultEmail %s", e.latin1()); 1262 //qDebug("OPimContact::setDefaultEmail %s", e.latin1());
1263 replace( Qtopia::DefaultEmail, e ); 1263 replace( Qtopia::DefaultEmail, e );
1264 1264
1265 if ( !e.isEmpty() ) 1265 if ( !e.isEmpty() )
1266 insertEmail( e ); 1266 insertEmail( e );
1267 1267
1268} 1268}
1269 1269
1270 1270
1271void OPimContact::insertEmails( const QStringList &v ) 1271void OPimContact::insertEmails( const QStringList &v )
1272{ 1272{
1273 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1273 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1274 insertEmail( *it ); 1274 insertEmail( *it );
1275} 1275}
1276 1276
1277 1277
1278int OPimContact::rtti() 1278int OPimContact::rtti() const
1279{ 1279{
1280 return OPimResolver::AddressBook; 1280 return OPimResolver::AddressBook;
1281} 1281}
1282 1282
1283 1283
1284void OPimContact::setUid( int i ) 1284void OPimContact::setUid( int i )
1285{ 1285{
1286 OPimRecord::setUid( i ); 1286 OPimRecord::setUid( i );
1287 replace( Qtopia::AddressUid , QString::number( i ) ); 1287 replace( Qtopia::AddressUid , QString::number( i ) );
1288} 1288}
1289} 1289}
diff --git a/libopie2/opiepim/core/opimcontact.h b/libopie2/opiepim/core/opimcontact.h
index 9d3cacc..6891dd6 100644
--- a/libopie2/opiepim/core/opimcontact.h
+++ b/libopie2/opiepim/core/opimcontact.h
@@ -1,256 +1,256 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@handhelds.org> 3 Copyright (C) Stefan Eilers <eilers.stefan@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
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 29
30#ifndef OCONTACT_H 30#ifndef OCONTACT_H
31#define OCONTACT_H 31#define OCONTACT_H
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/opimrecord.h> 34#include <opie2/opimrecord.h>
35#include <qpe/recordfields.h> 35#include <qpe/recordfields.h>
36 36
37/* QT */ 37/* QT */
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qstringlist.h> 39#include <qstringlist.h>
40 40
41#if defined(QPC_TEMPLATEDLL) 41#if defined(QPC_TEMPLATEDLL)
42// MOC_SKIP_BEGIN 42// MOC_SKIP_BEGIN
43QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 43QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
44// MOC_SKIP_END 44// MOC_SKIP_END
45#endif 45#endif
46 46
47namespace Opie 47namespace Opie
48{ 48{
49class OPimContactPrivate; 49class OPimContactPrivate;
50 50
51/** 51/**
52 * OPimContact class represents a specialised PIM Record for contacts. 52 * OPimContact class represents a specialised PIM Record for contacts.
53 * It does store all kind of persopn related information. 53 * It does store all kind of persopn related information.
54 * 54 *
55 * @short Contact Container 55 * @short Contact Container
56 * @author TT, Stefan Eiler, Holger Freyther 56 * @author TT, Stefan Eiler, Holger Freyther
57 */ 57 */
58class QPC_EXPORT OPimContact : public OPimRecord 58class QPC_EXPORT OPimContact : public OPimRecord
59{ 59{
60 friend class DataSet; 60 friend class DataSet;
61 61
62 public: 62 public:
63 OPimContact(); 63 OPimContact();
64 OPimContact( const QMap<int, QString> &fromMap ); 64 OPimContact( const QMap<int, QString> &fromMap );
65 virtual ~OPimContact(); 65 virtual ~OPimContact();
66 66
67 enum DateFormat{ 67 enum DateFormat{
68 Zip_City_State = 0, 68 Zip_City_State = 0,
69 City_State_Zip 69 City_State_Zip
70 }; 70 };
71 71
72 /* 72 /*
73 * do we need to inline them 73 * do we need to inline them
74 * if yes do we need to inline them this way? 74 * if yes do we need to inline them this way?
75 * -zecke 75 * -zecke
76 */ 76 */
77 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 77 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
78 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 78 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
79 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 79 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
80 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 80 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
81 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 81 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
82 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 82 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
83 void setFileAs(); 83 void setFileAs();
84 84
85 // default email address 85 // default email address
86 void setDefaultEmail( const QString &v ); 86 void setDefaultEmail( const QString &v );
87 // inserts email to list and ensure's doesn't already exist 87 // inserts email to list and ensure's doesn't already exist
88 void insertEmail( const QString &v ); 88 void insertEmail( const QString &v );
89 void removeEmail( const QString &v ); 89 void removeEmail( const QString &v );
90 void clearEmails(); 90 void clearEmails();
91 void insertEmails( const QStringList &v ); 91 void insertEmails( const QStringList &v );
92 92
93 // home 93 // home
94 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 94 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
95 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 95 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
96 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 96 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
97 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 97 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
98 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 98 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
99 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 99 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
100 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 100 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
101 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 101 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
102 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 102 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
103 103
104 // business 104 // business
105 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 105 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
106 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 106 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
107 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 107 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
108 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 108 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
109 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 109 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
110 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 110 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
111 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 111 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
112 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 112 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
113 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 113 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
114 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 114 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
115 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 115 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
116 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 116 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
117 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 117 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
118 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 118 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
119 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 119 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
120 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 120 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
121 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 121 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
122 122
123 // personal 123 // personal
124 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 124 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
125 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 125 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
126 void setBirthday( const QDate &v ); 126 void setBirthday( const QDate &v );
127 void setAnniversary( const QDate &v ); 127 void setAnniversary( const QDate &v );
128 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 128 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
129 void setChildren( const QString &v ); 129 void setChildren( const QString &v );
130 130
131 // other 131 // other
132 void setNotes( const QString &v ) { replace( Qtopia::Notes, v ); } 132 void setNotes( const QString &v ) { replace( Qtopia::Notes, v ); }
133 133
134 virtual bool match( const QRegExp &regexp ) const; 134 virtual bool match( const QRegExp &regexp ) const;
135 135
136 // // custom 136 // // custom
137 // void setCustomField( const QString &key, const QString &v ) 137 // void setCustomField( const QString &key, const QString &v )
138 // { replace(Custom- + key, v ); } 138 // { replace(Custom- + key, v ); }
139 139
140 // name 140 // name
141 QString fullName() const; 141 QString fullName() const;
142 QString title() const { return find( Qtopia::Title ); } 142 QString title() const { return find( Qtopia::Title ); }
143 QString firstName() const { return find( Qtopia::FirstName ); } 143 QString firstName() const { return find( Qtopia::FirstName ); }
144 QString middleName() const { return find( Qtopia::MiddleName ); } 144 QString middleName() const { return find( Qtopia::MiddleName ); }
145 QString lastName() const { return find( Qtopia::LastName ); } 145 QString lastName() const { return find( Qtopia::LastName ); }
146 QString suffix() const { return find( Qtopia::Suffix ); } 146 QString suffix() const { return find( Qtopia::Suffix ); }
147 QString fileAs() const { return find( Qtopia::FileAs ); } 147 QString fileAs() const { return find( Qtopia::FileAs ); }
148 148
149 // email 149 // email
150 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 150 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
151 QStringList emailList() const; 151 QStringList emailList() const;
152 152
153 // home 153 // home
154 /* 154 /*
155 * OPimAddress address(enum Location)const; 155 * OPimAddress address(enum Location)const;
156 * would be some how nicer... 156 * would be some how nicer...
157 * -zecke 157 * -zecke
158 */ 158 */
159 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 159 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
160 QString homeCity() const { return find( Qtopia::HomeCity ); } 160 QString homeCity() const { return find( Qtopia::HomeCity ); }
161 QString homeState() const { return find( Qtopia::HomeState ); } 161 QString homeState() const { return find( Qtopia::HomeState ); }
162 QString homeZip() const { return find( Qtopia::HomeZip ); } 162 QString homeZip() const { return find( Qtopia::HomeZip ); }
163 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 163 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
164 QString homePhone() const { return find( Qtopia::HomePhone ); } 164 QString homePhone() const { return find( Qtopia::HomePhone ); }
165 QString homeFax() const { return find( Qtopia::HomeFax ); } 165 QString homeFax() const { return find( Qtopia::HomeFax ); }
166 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 166 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
167 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 167 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
168 /** Multi line string containing all non-empty address info in the form 168 /** Multi line string containing all non-empty address info in the form
169 * Street 169 * Street
170 * City, State Zip 170 * City, State Zip
171 * Country 171 * Country
172 */ 172 */
173 QString displayHomeAddress() const; 173 QString displayHomeAddress() const;
174 174
175 // business 175 // business
176 QString company() const { return find( Qtopia::Company ); } 176 QString company() const { return find( Qtopia::Company ); }
177 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 177 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
178 QString businessCity() const { return find( Qtopia::BusinessCity ); } 178 QString businessCity() const { return find( Qtopia::BusinessCity ); }
179 QString businessState() const { return find( Qtopia::BusinessState ); } 179 QString businessState() const { return find( Qtopia::BusinessState ); }
180 QString businessZip() const { return find( Qtopia::BusinessZip ); } 180 QString businessZip() const { return find( Qtopia::BusinessZip ); }
181 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 181 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
182 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 182 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
183 QString jobTitle() const { return find( Qtopia::JobTitle ); } 183 QString jobTitle() const { return find( Qtopia::JobTitle ); }
184 QString department() const { return find( Qtopia::Department ); } 184 QString department() const { return find( Qtopia::Department ); }
185 QString office() const { return find( Qtopia::Office ); } 185 QString office() const { return find( Qtopia::Office ); }
186 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 186 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
187 QString businessFax() const { return find( Qtopia::BusinessFax ); } 187 QString businessFax() const { return find( Qtopia::BusinessFax ); }
188 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 188 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
189 QString businessPager() const { return find( Qtopia::BusinessPager ); } 189 QString businessPager() const { return find( Qtopia::BusinessPager ); }
190 QString profession() const { return find( Qtopia::Profession ); } 190 QString profession() const { return find( Qtopia::Profession ); }
191 QString assistant() const { return find( Qtopia::Assistant ); } 191 QString assistant() const { return find( Qtopia::Assistant ); }
192 QString manager() const { return find( Qtopia::Manager ); } 192 QString manager() const { return find( Qtopia::Manager ); }
193 /** Multi line string containing all non-empty address info in the form 193 /** Multi line string containing all non-empty address info in the form
194 * Street 194 * Street
195 * City, State Zip 195 * City, State Zip
196 * Country 196 * Country
197 */ 197 */
198 QString displayBusinessAddress() const; 198 QString displayBusinessAddress() const;
199 199
200 //personal 200 //personal
201 QString spouse() const { return find( Qtopia::Spouse ); } 201 QString spouse() const { return find( Qtopia::Spouse ); }
202 QString gender() const { return find( Qtopia::Gender ); } 202 QString gender() const { return find( Qtopia::Gender ); }
203 QDate birthday() const; 203 QDate birthday() const;
204 QDate anniversary() const; 204 QDate anniversary() const;
205 QString nickname() const { return find( Qtopia::Nickname ); } 205 QString nickname() const { return find( Qtopia::Nickname ); }
206 QString children() const { return find( Qtopia::Children ); } 206 QString children() const { return find( Qtopia::Children ); }
207 QStringList childrenList() const; 207 QStringList childrenList() const;
208 208
209 // other 209 // other
210 QString notes() const { return find( Qtopia::Notes ); } 210 QString notes() const { return find( Qtopia::Notes ); }
211 QString groups() const { return find( Qtopia::Groups ); } 211 QString groups() const { return find( Qtopia::Groups ); }
212 QStringList groupList() const; 212 QStringList groupList() const;
213 213
214 QString toRichText() const; 214 QString toRichText() const;
215 QMap<int, QString> toMap() const; 215 QMap<int, QString> toMap() const;
216 QString field( int key ) const { return find( key ); } 216 QString field( int key ) const { return find( key ); }
217 217
218 218
219 void setUid( int i ); 219 void setUid( int i );
220 220
221 QString toShortText() const; 221 QString toShortText() const;
222 QString type() const; 222 QString type() const;
223 class QString recordField( int ) const; 223 class QString recordField( int ) const;
224 224
225 // Why private ? (eilers,se) 225 // Why private ? (eilers,se)
226 QString emailSeparator() const { return " "; } 226 QString emailSeparator() const { return " "; }
227 227
228 // the emails should be seperated by a comma 228 // the emails should be seperated by a comma
229 void setEmails( const QString &v ); 229 void setEmails( const QString &v );
230 QString emails() const { return find( Qtopia::Emails ); } 230 QString emails() const { return find( Qtopia::Emails ); }
231 static int rtti(); 231 int rtti() const;
232 232
233 private: 233 private:
234 // The XML Backend needs some access to the private functions 234 // The XML Backend needs some access to the private functions
235 friend class OPimContactAccessBackend_XML; 235 friend class OPimContactAccessBackend_XML;
236 236
237 void insert( int key, const QString &value ); 237 void insert( int key, const QString &value );
238 void replace( int key, const QString &value ); 238 void replace( int key, const QString &value );
239 QString find( int key ) const; 239 QString find( int key ) const;
240 static QStringList fields(); 240 static QStringList fields();
241 241
242 void save( QString &buf ) const; 242 void save( QString &buf ) const;
243 243
244 QString displayAddress( const QString &street, 244 QString displayAddress( const QString &street,
245 const QString &city, 245 const QString &city,
246 const QString &state, 246 const QString &state,
247 const QString &zip, 247 const QString &zip,
248 const QString &country ) const; 248 const QString &country ) const;
249 249
250 QMap<int, QString> mMap; 250 QMap<int, QString> mMap;
251 OPimContactPrivate *d; 251 OPimContactPrivate *d;
252}; 252};
253 253
254} 254}
255 255
256#endif 256#endif
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp
index 77730e9..8bf8b25 100644
--- a/libopie2/opiepim/core/opimevent.cpp
+++ b/libopie2/opiepim/core/opimevent.cpp
@@ -1,1022 +1,1022 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> 3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
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 29
30#include "opimevent.h" 30#include "opimevent.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimrecurrence.h> 33#include <opie2/opimrecurrence.h>
34#include <opie2/opimresolver.h> 34#include <opie2/opimresolver.h>
35#include <opie2/opimnotifymanager.h> 35#include <opie2/opimnotifymanager.h>
36#include <qpe/categories.h> 36#include <qpe/categories.h>
37#include <qpe/stringutil.h> 37#include <qpe/stringutil.h>
38 38
39/* QT */ 39/* QT */
40 40
41namespace Opie 41namespace Opie
42{ 42{
43 43
44int OCalendarHelper::week( const QDate& date ) 44int OCalendarHelper::week( const QDate& date )
45{ 45{
46 // Calculates the week this date is in within that 46 // Calculates the week this date is in within that
47 // month. Equals the "row" is is in in the month view 47 // month. Equals the "row" is is in in the month view
48 int week = 1; 48 int week = 1;
49 QDate tmp( date.year(), date.month(), 1 ); 49 QDate tmp( date.year(), date.month(), 1 );
50 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 50 if ( date.dayOfWeek() < tmp.dayOfWeek() )
51 ++week; 51 ++week;
52 52
53 week += ( date.day() - 1 ) / 7; 53 week += ( date.day() - 1 ) / 7;
54 54
55 return week; 55 return week;
56} 56}
57 57
58 58
59int OCalendarHelper::ocurrence( const QDate& date ) 59int OCalendarHelper::ocurrence( const QDate& date )
60{ 60{
61 // calculates the number of occurrances of this day of the 61 // calculates the number of occurrances of this day of the
62 // week till the given date (e.g 3rd Wednesday of the month) 62 // week till the given date (e.g 3rd Wednesday of the month)
63 return ( date.day() - 1 ) / 7 + 1; 63 return ( date.day() - 1 ) / 7 + 1;
64} 64}
65 65
66 66
67int OCalendarHelper::dayOfWeek( char day ) 67int OCalendarHelper::dayOfWeek( char day )
68{ 68{
69 int dayOfWeek = 1; 69 int dayOfWeek = 1;
70 char i = OPimRecurrence::MON; 70 char i = OPimRecurrence::MON;
71 while ( !( i & day ) && i <= OPimRecurrence::SUN ) 71 while ( !( i & day ) && i <= OPimRecurrence::SUN )
72 { 72 {
73 i <<= 1; 73 i <<= 1;
74 ++dayOfWeek; 74 ++dayOfWeek;
75 } 75 }
76 return dayOfWeek; 76 return dayOfWeek;
77} 77}
78 78
79 79
80int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) 80int OCalendarHelper::monthDiff( const QDate& first, const QDate& second )
81{ 81{
82 return ( second.year() - first.year() ) * 12 + 82 return ( second.year() - first.year() ) * 12 +
83 second.month() - first.month(); 83 second.month() - first.month();
84} 84}
85 85
86 86
87struct OPimEvent::Data : public QShared 87struct OPimEvent::Data : public QShared
88{ 88{
89 Data() : QShared() 89 Data() : QShared()
90 { 90 {
91 child = 0; 91 child = 0;
92 recur = 0; 92 recur = 0;
93 manager = 0; 93 manager = 0;
94 isAllDay = false; 94 isAllDay = false;
95 parent = 0; 95 parent = 0;
96 } 96 }
97 ~Data() 97 ~Data()
98 { 98 {
99 delete manager; 99 delete manager;
100 delete recur; 100 delete recur;
101 } 101 }
102 QString description; 102 QString description;
103 QString location; 103 QString location;
104 OPimNotifyManager* manager; 104 OPimNotifyManager* manager;
105 OPimRecurrence* recur; 105 OPimRecurrence* recur;
106 QString note; 106 QString note;
107 QDateTime created; 107 QDateTime created;
108 QDateTime start; 108 QDateTime start;
109 QDateTime end; 109 QDateTime end;
110bool isAllDay : 1; 110bool isAllDay : 1;
111 QString timezone; 111 QString timezone;
112 QArray<int>* child; 112 QArray<int>* child;
113 int parent; 113 int parent;
114}; 114};
115 115
116 116
117OPimEvent::OPimEvent( int uid ) 117OPimEvent::OPimEvent( int uid )
118 : OPimRecord( uid ) 118 : OPimRecord( uid )
119{ 119{
120 data = new Data; 120 data = new Data;
121} 121}
122 122
123 123
124OPimEvent::OPimEvent( const OPimEvent& ev ) 124OPimEvent::OPimEvent( const OPimEvent& ev )
125 : OPimRecord( ev ), data( ev.data ) 125 : OPimRecord( ev ), data( ev.data )
126{ 126{
127 data->ref(); 127 data->ref();
128} 128}
129 129
130 130
131OPimEvent::OPimEvent( const QMap<int, QString> map ) 131OPimEvent::OPimEvent( const QMap<int, QString> map )
132 : OPimRecord( 0 ) 132 : OPimRecord( 0 )
133{ 133{
134 data = new Data; 134 data = new Data;
135 135
136 fromMap( map ); 136 fromMap( map );
137} 137}
138 138
139 139
140OPimEvent::~OPimEvent() 140OPimEvent::~OPimEvent()
141{ 141{
142 if ( data->deref() ) 142 if ( data->deref() )
143 { 143 {
144 delete data; 144 delete data;
145 data = 0; 145 data = 0;
146 } 146 }
147} 147}
148 148
149 149
150OPimEvent& OPimEvent::operator=( const OPimEvent& ev ) 150OPimEvent& OPimEvent::operator=( const OPimEvent& ev )
151{ 151{
152 if ( this == &ev ) return * this; 152 if ( this == &ev ) return * this;
153 153
154 OPimRecord::operator=( ev ); 154 OPimRecord::operator=( ev );
155 ev.data->ref(); 155 ev.data->ref();
156 deref(); 156 deref();
157 data = ev.data; 157 data = ev.data;
158 158
159 159
160 return *this; 160 return *this;
161} 161}
162 162
163 163
164QString OPimEvent::description() const 164QString OPimEvent::description() const
165{ 165{
166 return data->description; 166 return data->description;
167} 167}
168 168
169 169
170void OPimEvent::setDescription( const QString& description ) 170void OPimEvent::setDescription( const QString& description )
171{ 171{
172 changeOrModify(); 172 changeOrModify();
173 data->description = description; 173 data->description = description;
174} 174}
175 175
176 176
177void OPimEvent::setLocation( const QString& loc ) 177void OPimEvent::setLocation( const QString& loc )
178{ 178{
179 changeOrModify(); 179 changeOrModify();
180 data->location = loc; 180 data->location = loc;
181} 181}
182 182
183 183
184QString OPimEvent::location() const 184QString OPimEvent::location() const
185{ 185{
186 return data->location; 186 return data->location;
187} 187}
188 188
189 189
190OPimNotifyManager &OPimEvent::notifiers() const 190OPimNotifyManager &OPimEvent::notifiers() const
191{ 191{
192 // I hope we can skip the changeOrModify here 192 // I hope we can skip the changeOrModify here
193 // the notifier should take care of it 193 // the notifier should take care of it
194 // and OPimNotify is shared too 194 // and OPimNotify is shared too
195 if ( !data->manager ) 195 if ( !data->manager )
196 data->manager = new OPimNotifyManager; 196 data->manager = new OPimNotifyManager;
197 197
198 return *data->manager; 198 return *data->manager;
199} 199}
200 200
201 201
202bool OPimEvent::hasNotifiers() const 202bool OPimEvent::hasNotifiers() const
203{ 203{
204 if ( !data->manager ) 204 if ( !data->manager )
205 return false; 205 return false;
206 if ( data->manager->reminders().isEmpty() && 206 if ( data->manager->reminders().isEmpty() &&
207 data->manager->alarms().isEmpty() ) 207 data->manager->alarms().isEmpty() )
208 return false; 208 return false;
209 209
210 return true; 210 return true;
211} 211}
212 212
213 213
214OPimRecurrence OPimEvent::recurrence() const 214OPimRecurrence OPimEvent::recurrence() const
215{ 215{
216 if ( !data->recur ) 216 if ( !data->recur )
217 data->recur = new OPimRecurrence; 217 data->recur = new OPimRecurrence;
218 218
219 return *data->recur; 219 return *data->recur;
220} 220}
221 221
222 222
223void OPimEvent::setRecurrence( const OPimRecurrence& rec ) 223void OPimEvent::setRecurrence( const OPimRecurrence& rec )
224{ 224{
225 changeOrModify(); 225 changeOrModify();
226 if ( data->recur ) 226 if ( data->recur )
227 ( *data->recur ) = rec; 227 ( *data->recur ) = rec;
228 else 228 else
229 data->recur = new OPimRecurrence( rec ); 229 data->recur = new OPimRecurrence( rec );
230} 230}
231 231
232 232
233bool OPimEvent::hasRecurrence() const 233bool OPimEvent::hasRecurrence() const
234{ 234{
235 if ( !data->recur ) return false; 235 if ( !data->recur ) return false;
236 return data->recur->doesRecur(); 236 return data->recur->doesRecur();
237} 237}
238 238
239 239
240QString OPimEvent::note() const 240QString OPimEvent::note() const
241{ 241{
242 return data->note; 242 return data->note;
243} 243}
244 244
245 245
246void OPimEvent::setNote( const QString& note ) 246void OPimEvent::setNote( const QString& note )
247{ 247{
248 changeOrModify(); 248 changeOrModify();
249 data->note = note; 249 data->note = note;
250} 250}
251 251
252 252
253QDateTime OPimEvent::createdDateTime() const 253QDateTime OPimEvent::createdDateTime() const
254{ 254{
255 return data->created; 255 return data->created;
256} 256}
257 257
258 258
259void OPimEvent::setCreatedDateTime( const QDateTime& time ) 259void OPimEvent::setCreatedDateTime( const QDateTime& time )
260{ 260{
261 changeOrModify(); 261 changeOrModify();
262 data->created = time; 262 data->created = time;
263} 263}
264 264
265 265
266QDateTime OPimEvent::startDateTime() const 266QDateTime OPimEvent::startDateTime() const
267{ 267{
268 if ( data->isAllDay ) 268 if ( data->isAllDay )
269 return QDateTime( data->start.date(), QTime( 0, 0, 0 ) ); 269 return QDateTime( data->start.date(), QTime( 0, 0, 0 ) );
270 return data->start; 270 return data->start;
271} 271}
272 272
273 273
274QDateTime OPimEvent::startDateTimeInZone() const 274QDateTime OPimEvent::startDateTimeInZone() const
275{ 275{
276 /* if no timezone, or all day event or if the current and this timeZone match... */ 276 /* if no timezone, or all day event or if the current and this timeZone match... */
277 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return startDateTime(); 277 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return startDateTime();
278 278
279 OPimTimeZone zone( data->timezone ); 279 OPimTimeZone zone( data->timezone );
280 return zone.toDateTime( data->start, OPimTimeZone::current() ); 280 return zone.toDateTime( data->start, OPimTimeZone::current() );
281} 281}
282 282
283 283
284void OPimEvent::setStartDateTime( const QDateTime& dt ) 284void OPimEvent::setStartDateTime( const QDateTime& dt )
285{ 285{
286 changeOrModify(); 286 changeOrModify();
287 data->start = dt; 287 data->start = dt;
288} 288}
289 289
290 290
291QDateTime OPimEvent::endDateTime() const 291QDateTime OPimEvent::endDateTime() const
292{ 292{
293 /* 293 /*
294 * if all Day event the end time needs 294 * if all Day event the end time needs
295 * to be on the same day as the start 295 * to be on the same day as the start
296 */ 296 */
297 if ( data->isAllDay ) 297 if ( data->isAllDay )
298 return QDateTime( data->start.date(), QTime( 23, 59, 59 ) ); 298 return QDateTime( data->start.date(), QTime( 23, 59, 59 ) );
299 return data->end; 299 return data->end;
300} 300}
301 301
302 302
303QDateTime OPimEvent::endDateTimeInZone() const 303QDateTime OPimEvent::endDateTimeInZone() const
304{ 304{
305 /* if no timezone, or all day event or if the current and this timeZone match... */ 305 /* if no timezone, or all day event or if the current and this timeZone match... */
306 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime(); 306 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime();
307 307
308 OPimTimeZone zone( data->timezone ); 308 OPimTimeZone zone( data->timezone );
309 return zone.toDateTime( data->end, OPimTimeZone::current() ); 309 return zone.toDateTime( data->end, OPimTimeZone::current() );
310} 310}
311 311
312 312
313void OPimEvent::setEndDateTime( const QDateTime& dt ) 313void OPimEvent::setEndDateTime( const QDateTime& dt )
314{ 314{
315 changeOrModify(); 315 changeOrModify();
316 data->end = dt; 316 data->end = dt;
317} 317}
318 318
319 319
320bool OPimEvent::isMultipleDay() const 320bool OPimEvent::isMultipleDay() const
321{ 321{
322 return data->end.date().day() - data->start.date().day(); 322 return data->end.date().day() - data->start.date().day();
323} 323}
324 324
325 325
326bool OPimEvent::isAllDay() const 326bool OPimEvent::isAllDay() const
327{ 327{
328 return data->isAllDay; 328 return data->isAllDay;
329} 329}
330 330
331 331
332void OPimEvent::setAllDay( bool allDay ) 332void OPimEvent::setAllDay( bool allDay )
333{ 333{
334 changeOrModify(); 334 changeOrModify();
335 data->isAllDay = allDay; 335 data->isAllDay = allDay;
336 if ( allDay ) data->timezone = "UTC"; 336 if ( allDay ) data->timezone = "UTC";
337} 337}
338 338
339 339
340void OPimEvent::setTimeZone( const QString& tz ) 340void OPimEvent::setTimeZone( const QString& tz )
341{ 341{
342 changeOrModify(); 342 changeOrModify();
343 data->timezone = tz; 343 data->timezone = tz;
344} 344}
345 345
346 346
347QString OPimEvent::timeZone() const 347QString OPimEvent::timeZone() const
348{ 348{
349 if ( data->isAllDay ) return QString::fromLatin1( "UTC" ); 349 if ( data->isAllDay ) return QString::fromLatin1( "UTC" );
350 return data->timezone; 350 return data->timezone;
351} 351}
352 352
353 353
354bool OPimEvent::match( const QRegExp& re ) const 354bool OPimEvent::match( const QRegExp& re ) const
355{ 355{
356 if ( re.match( data->description ) != -1 ) 356 if ( re.match( data->description ) != -1 )
357 { 357 {
358 setLastHitField( Qtopia::DatebookDescription ); 358 setLastHitField( Qtopia::DatebookDescription );
359 return true; 359 return true;
360 } 360 }
361 if ( re.match( data->note ) != -1 ) 361 if ( re.match( data->note ) != -1 )
362 { 362 {
363 setLastHitField( Qtopia::Note ); 363 setLastHitField( Qtopia::Note );
364 return true; 364 return true;
365 } 365 }
366 if ( re.match( data->location ) != -1 ) 366 if ( re.match( data->location ) != -1 )
367 { 367 {
368 setLastHitField( Qtopia::Location ); 368 setLastHitField( Qtopia::Location );
369 return true; 369 return true;
370 } 370 }
371 if ( re.match( data->start.toString() ) != -1 ) 371 if ( re.match( data->start.toString() ) != -1 )
372 { 372 {
373 setLastHitField( Qtopia::StartDateTime ); 373 setLastHitField( Qtopia::StartDateTime );
374 return true; 374 return true;
375 } 375 }
376 if ( re.match( data->end.toString() ) != -1 ) 376 if ( re.match( data->end.toString() ) != -1 )
377 { 377 {
378 setLastHitField( Qtopia::EndDateTime ); 378 setLastHitField( Qtopia::EndDateTime );
379 return true; 379 return true;
380 } 380 }
381 return false; 381 return false;
382} 382}
383 383
384 384
385QString OPimEvent::toRichText() const 385QString OPimEvent::toRichText() const
386{ 386{
387 QString text, value; 387 QString text, value;
388 388
389 // description 389 // description
390 text += "<b><h3><img src=\"datebook/DateBook\">"; 390 text += "<b><h3><img src=\"datebook/DateBook\">";
391 if ( !description().isEmpty() ) 391 if ( !description().isEmpty() )
392 { 392 {
393 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" ); 393 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" );
394 } 394 }
395 text += "</h3></b><br><hr><br>"; 395 text += "</h3></b><br><hr><br>";
396 396
397 // location 397 // location
398 if ( !( value = location() ).isEmpty() ) 398 if ( !( value = location() ).isEmpty() )
399 { 399 {
400 text += "<b>" + QObject::tr( "Location:" ) + "</b> "; 400 text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
401 text += Qtopia::escapeString( value ) + "<br>"; 401 text += Qtopia::escapeString( value ) + "<br>";
402 } 402 }
403 403
404 // all day event 404 // all day event
405 if ( isAllDay() ) 405 if ( isAllDay() )
406 { 406 {
407 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; 407 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>";
408 } 408 }
409 // multiple day event 409 // multiple day event
410 else if ( isMultipleDay () ) 410 else if ( isMultipleDay () )
411 { 411 {
412 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; 412 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>";
413 } 413 }
414 // start & end times 414 // start & end times
415 else 415 else
416 { 416 {
417 // start time 417 // start time
418 if ( startDateTime().isValid() ) 418 if ( startDateTime().isValid() )
419 { 419 {
420 text += "<b>" + QObject::tr( "Start:" ) + "</b> "; 420 text += "<b>" + QObject::tr( "Start:" ) + "</b> ";
421 text += Qtopia::escapeString( startDateTime().toString() ). 421 text += Qtopia::escapeString( startDateTime().toString() ).
422 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 422 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
423 } 423 }
424 424
425 // end time 425 // end time
426 if ( endDateTime().isValid() ) 426 if ( endDateTime().isValid() )
427 { 427 {
428 text += "<b>" + QObject::tr( "End:" ) + "</b> "; 428 text += "<b>" + QObject::tr( "End:" ) + "</b> ";
429 text += Qtopia::escapeString( endDateTime().toString() ). 429 text += Qtopia::escapeString( endDateTime().toString() ).
430 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 430 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
431 } 431 }
432 } 432 }
433 433
434 // categories 434 // categories
435 if ( categoryNames( "Calendar" ).count() ) 435 if ( categoryNames( "Calendar" ).count() )
436 { 436 {
437 text += "<b>" + QObject::tr( "Category:" ) + "</b> "; 437 text += "<b>" + QObject::tr( "Category:" ) + "</b> ";
438 text += categoryNames( "Calendar" ).join( ", " ); 438 text += categoryNames( "Calendar" ).join( ", " );
439 text += "<br>"; 439 text += "<br>";
440 } 440 }
441 441
442 //notes 442 //notes
443 if ( !note().isEmpty() ) 443 if ( !note().isEmpty() )
444 { 444 {
445 text += "<b>" + QObject::tr( "Note:" ) + "</b><br>"; 445 text += "<b>" + QObject::tr( "Note:" ) + "</b><br>";
446 text += note(); 446 text += note();
447 // text += Qtopia::escapeString(note() ). 447 // text += Qtopia::escapeString(note() ).
448 // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 448 // replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
449 } 449 }
450 return text; 450 return text;
451} 451}
452 452
453 453
454QString OPimEvent::toShortText() const 454QString OPimEvent::toShortText() const
455{ 455{
456 QString text; 456 QString text;
457 text += QString::number( startDateTime().date().day() ); 457 text += QString::number( startDateTime().date().day() );
458 text += "."; 458 text += ".";
459 text += QString::number( startDateTime().date().month() ); 459 text += QString::number( startDateTime().date().month() );
460 text += "."; 460 text += ".";
461 text += QString::number( startDateTime().date().year() ); 461 text += QString::number( startDateTime().date().year() );
462 text += " "; 462 text += " ";
463 text += QString::number( startDateTime().time().hour() ); 463 text += QString::number( startDateTime().time().hour() );
464 text += ":"; 464 text += ":";
465 text += QString::number( startDateTime().time().minute() ); 465 text += QString::number( startDateTime().time().minute() );
466 text += " - "; 466 text += " - ";
467 text += description(); 467 text += description();
468 return text; 468 return text;
469} 469}
470 470
471 471
472QString OPimEvent::type() const 472QString OPimEvent::type() const
473{ 473{
474 return QString::fromLatin1( "OPimEvent" ); 474 return QString::fromLatin1( "OPimEvent" );
475} 475}
476 476
477 477
478QString OPimEvent::recordField( int /*id */ ) const 478QString OPimEvent::recordField( int /*id */ ) const
479{ 479{
480 return QString::null; 480 return QString::null;
481} 481}
482 482
483 483
484int OPimEvent::rtti() 484int OPimEvent::rtti() const
485{ 485{
486 return OPimResolver::DateBook; 486 return OPimResolver::DateBook;
487} 487}
488 488
489 489
490bool OPimEvent::loadFromStream( QDataStream& ) 490bool OPimEvent::loadFromStream( QDataStream& )
491{ 491{
492 return true; 492 return true;
493} 493}
494 494
495 495
496bool OPimEvent::saveToStream( QDataStream& ) const 496bool OPimEvent::saveToStream( QDataStream& ) const
497{ 497{
498 return true; 498 return true;
499} 499}
500 500
501 501
502void OPimEvent::changeOrModify() 502void OPimEvent::changeOrModify()
503{ 503{
504 if ( data->count != 1 ) 504 if ( data->count != 1 )
505 { 505 {
506 data->deref(); 506 data->deref();
507 Data* d2 = new Data; 507 Data* d2 = new Data;
508 d2->description = data->description; 508 d2->description = data->description;
509 d2->location = data->location; 509 d2->location = data->location;
510 510
511 if ( data->manager ) 511 if ( data->manager )
512 d2->manager = new OPimNotifyManager( *data->manager ); 512 d2->manager = new OPimNotifyManager( *data->manager );
513 513
514 if ( data->recur ) 514 if ( data->recur )
515 d2->recur = new OPimRecurrence( *data->recur ); 515 d2->recur = new OPimRecurrence( *data->recur );
516 516
517 d2->note = data->note; 517 d2->note = data->note;
518 d2->created = data->created; 518 d2->created = data->created;
519 d2->start = data->start; 519 d2->start = data->start;
520 d2->end = data->end; 520 d2->end = data->end;
521 d2->isAllDay = data->isAllDay; 521 d2->isAllDay = data->isAllDay;
522 d2->timezone = data->timezone; 522 d2->timezone = data->timezone;
523 d2->parent = data->parent; 523 d2->parent = data->parent;
524 524
525 if ( data->child ) 525 if ( data->child )
526 { 526 {
527 d2->child = new QArray<int>( *data->child ); 527 d2->child = new QArray<int>( *data->child );
528 d2->child->detach(); 528 d2->child->detach();
529 } 529 }
530 530
531 data = d2; 531 data = d2;
532 } 532 }
533} 533}
534 534
535 535
536void OPimEvent::deref() 536void OPimEvent::deref()
537{ 537{
538 if ( data->deref() ) 538 if ( data->deref() )
539 { 539 {
540 delete data; 540 delete data;
541 data = 0; 541 data = 0;
542 } 542 }
543} 543}
544// Exporting Event data to map. Using the same 544// Exporting Event data to map. Using the same
545// encoding as ODateBookAccessBackend_xml does.. 545// encoding as ODateBookAccessBackend_xml does..
546// Thus, we could remove the stuff there and use this 546// Thus, we could remove the stuff there and use this
547// for it and for all other places.. 547// for it and for all other places..
548// Encoding should happen at one place, only ! (eilers) 548// Encoding should happen at one place, only ! (eilers)
549QMap<int, QString> OPimEvent::toMap() const 549QMap<int, QString> OPimEvent::toMap() const
550{ 550{
551 QMap<int, QString> retMap; 551 QMap<int, QString> retMap;
552 552
553 retMap.insert( OPimEvent::FUid, QString::number( uid() ) ); 553 retMap.insert( OPimEvent::FUid, QString::number( uid() ) );
554 retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); 554 retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) );
555 retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) ); 555 retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) );
556 retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) ); 556 retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) );
557 retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" ); 557 retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" );
558 OPimAlarm alarm = notifiers().alarms() [ 0 ]; 558 OPimAlarm alarm = notifiers().alarms() [ 0 ];
559 retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); 559 retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
560 retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); 560 retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" );
561 561
562 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); 562 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() );
563 retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) ); 563 retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) );
564 retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) ); 564 retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) );
565 retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) ); 565 retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) );
566 retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); 566 retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
567 if ( parent() ) 567 if ( parent() )
568 retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) ); 568 retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) );
569 if ( children().count() ) 569 if ( children().count() )
570 { 570 {
571 QArray<int> childr = children(); 571 QArray<int> childr = children();
572 QString buf; 572 QString buf;
573 for ( uint i = 0; i < childr.count(); i++ ) 573 for ( uint i = 0; i < childr.count(); i++ )
574 { 574 {
575 if ( i != 0 ) buf += " "; 575 if ( i != 0 ) buf += " ";
576 buf += QString::number( childr[ i ] ); 576 buf += QString::number( childr[ i ] );
577 } 577 }
578 retMap.insert( OPimEvent::FRecChildren, buf ); 578 retMap.insert( OPimEvent::FRecChildren, buf );
579 } 579 }
580 580
581 // Add recurrence stuff 581 // Add recurrence stuff
582 if ( hasRecurrence() ) 582 if ( hasRecurrence() )
583 { 583 {
584 OPimRecurrence recur = recurrence(); 584 OPimRecurrence recur = recurrence();
585 QMap<int, QString> recFields = recur.toMap(); 585 QMap<int, QString> recFields = recur.toMap();
586 retMap.insert( OPimEvent::FRType, recFields[ OPimRecurrence::RType ] ); 586 retMap.insert( OPimEvent::FRType, recFields[ OPimRecurrence::RType ] );
587 retMap.insert( OPimEvent::FRWeekdays, recFields[ OPimRecurrence::RWeekdays ] ); 587 retMap.insert( OPimEvent::FRWeekdays, recFields[ OPimRecurrence::RWeekdays ] );
588 retMap.insert( OPimEvent::FRPosition, recFields[ OPimRecurrence::RPosition ] ); 588 retMap.insert( OPimEvent::FRPosition, recFields[ OPimRecurrence::RPosition ] );
589 retMap.insert( OPimEvent::FRFreq, recFields[ OPimRecurrence::RFreq ] ); 589 retMap.insert( OPimEvent::FRFreq, recFields[ OPimRecurrence::RFreq ] );
590 retMap.insert( OPimEvent::FRHasEndDate, recFields[ OPimRecurrence::RHasEndDate ] ); 590 retMap.insert( OPimEvent::FRHasEndDate, recFields[ OPimRecurrence::RHasEndDate ] );
591 retMap.insert( OPimEvent::FREndDate, recFields[ OPimRecurrence::EndDate ] ); 591 retMap.insert( OPimEvent::FREndDate, recFields[ OPimRecurrence::EndDate ] );
592 retMap.insert( OPimEvent::FRCreated, recFields[ OPimRecurrence::Created ] ); 592 retMap.insert( OPimEvent::FRCreated, recFields[ OPimRecurrence::Created ] );
593 retMap.insert( OPimEvent::FRExceptions, recFields[ OPimRecurrence::Exceptions ] ); 593 retMap.insert( OPimEvent::FRExceptions, recFields[ OPimRecurrence::Exceptions ] );
594 } 594 }
595 else 595 else
596 { 596 {
597 OPimRecurrence recur = recurrence(); 597 OPimRecurrence recur = recurrence();
598 QMap<int, QString> recFields = recur.toMap(); 598 QMap<int, QString> recFields = recur.toMap();
599 retMap.insert( OPimEvent::FRType, recFields[ OPimRecurrence::RType ] ); 599 retMap.insert( OPimEvent::FRType, recFields[ OPimRecurrence::RType ] );
600 } 600 }
601 601
602 return retMap; 602 return retMap;
603} 603}
604 604
605 605
606void OPimEvent::fromMap( const QMap<int, QString>& map ) 606void OPimEvent::fromMap( const QMap<int, QString>& map )
607{ 607{
608 608
609 // We just want to set the UID if it is really stored. 609 // We just want to set the UID if it is really stored.
610 if ( !map[ OPimEvent::FUid ].isEmpty() ) 610 if ( !map[ OPimEvent::FUid ].isEmpty() )
611 setUid( map[ OPimEvent::FUid ].toInt() ); 611 setUid( map[ OPimEvent::FUid ].toInt() );
612 612
613 setCategories( idsFromString( map[ OPimEvent::FCategories ] ) ); 613 setCategories( idsFromString( map[ OPimEvent::FCategories ] ) );
614 setDescription( map[ OPimEvent::FDescription ] ); 614 setDescription( map[ OPimEvent::FDescription ] );
615 setLocation( map[ OPimEvent::FLocation ] ); 615 setLocation( map[ OPimEvent::FLocation ] );
616 616
617 if ( map[ OPimEvent::FType ] == "AllDay" ) 617 if ( map[ OPimEvent::FType ] == "AllDay" )
618 setAllDay( true ); 618 setAllDay( true );
619 else 619 else
620 setAllDay( false ); 620 setAllDay( false );
621 621
622 int alarmTime = -1; 622 int alarmTime = -1;
623 if ( !map[ OPimEvent::FAlarm ].isEmpty() ) 623 if ( !map[ OPimEvent::FAlarm ].isEmpty() )
624 alarmTime = map[ OPimEvent::FAlarm ].toInt(); 624 alarmTime = map[ OPimEvent::FAlarm ].toInt();
625 625
626 int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); 626 int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
627 if ( ( alarmTime != -1 ) ) 627 if ( ( alarmTime != -1 ) )
628 { 628 {
629 QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); 629 QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 );
630 OPimAlarm al( sound , dt ); 630 OPimAlarm al( sound , dt );
631 notifiers().add( al ); 631 notifiers().add( al );
632 } 632 }
633 if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) ) 633 if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) )
634 { 634 {
635 setTimeZone( map[ OPimEvent::FTimeZone ] ); 635 setTimeZone( map[ OPimEvent::FTimeZone ] );
636 } 636 }
637 637
638 time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong(); 638 time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong();
639 time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong(); 639 time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong();
640 640
641 /* AllDay is always in UTC */ 641 /* AllDay is always in UTC */
642 if ( isAllDay() ) 642 if ( isAllDay() )
643 { 643 {
644 OPimTimeZone utc = OPimTimeZone::utc(); 644 OPimTimeZone utc = OPimTimeZone::utc();
645 setStartDateTime( utc.fromUTCDateTime( start ) ); 645 setStartDateTime( utc.fromUTCDateTime( start ) );
646 setEndDateTime ( utc.fromUTCDateTime( end ) ); 646 setEndDateTime ( utc.fromUTCDateTime( end ) );
647 setTimeZone( "UTC" ); // make sure it is really utc 647 setTimeZone( "UTC" ); // make sure it is really utc
648 } 648 }
649 else 649 else
650 { 650 {
651 /* to current date time */ 651 /* to current date time */
652 // qWarning(" Start is %d", start ); 652 // qWarning(" Start is %d", start );
653 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); 653 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() );
654 QDateTime date = zone.toDateTime( start ); 654 QDateTime date = zone.toDateTime( start );
655 qWarning( " Start is %s", date.toString().latin1() ); 655 qWarning( " Start is %s", date.toString().latin1() );
656 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); 656 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
657 657
658 date = zone.toDateTime( end ); 658 date = zone.toDateTime( end );
659 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); 659 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) );
660 } 660 }
661 661
662 if ( !map[ OPimEvent::FRecParent ].isEmpty() ) 662 if ( !map[ OPimEvent::FRecParent ].isEmpty() )
663 setParent( map[ OPimEvent::FRecParent ].toInt() ); 663 setParent( map[ OPimEvent::FRecParent ].toInt() );
664 664
665 if ( !map[ OPimEvent::FRecChildren ].isEmpty() ) 665 if ( !map[ OPimEvent::FRecChildren ].isEmpty() )
666 { 666 {
667 QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] ); 667 QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] );
668 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 668 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
669 { 669 {
670 addChild( ( *it ).toInt() ); 670 addChild( ( *it ).toInt() );
671 } 671 }
672 } 672 }
673 673
674 // Fill recurrence stuff and put it directly into the OPimRecurrence-Object using fromMap.. 674 // Fill recurrence stuff and put it directly into the OPimRecurrence-Object using fromMap..
675 if ( !map[ OPimEvent::FRType ].isEmpty() ) 675 if ( !map[ OPimEvent::FRType ].isEmpty() )
676 { 676 {
677 QMap<int, QString> recFields; 677 QMap<int, QString> recFields;
678 recFields.insert( OPimRecurrence::RType, map[ OPimEvent::FRType ] ); 678 recFields.insert( OPimRecurrence::RType, map[ OPimEvent::FRType ] );
679 recFields.insert( OPimRecurrence::RWeekdays, map[ OPimEvent::FRWeekdays ] ); 679 recFields.insert( OPimRecurrence::RWeekdays, map[ OPimEvent::FRWeekdays ] );
680 recFields.insert( OPimRecurrence::RPosition, map[ OPimEvent::FRPosition ] ); 680 recFields.insert( OPimRecurrence::RPosition, map[ OPimEvent::FRPosition ] );
681 recFields.insert( OPimRecurrence::RFreq, map[ OPimEvent::FRFreq ] ); 681 recFields.insert( OPimRecurrence::RFreq, map[ OPimEvent::FRFreq ] );
682 recFields.insert( OPimRecurrence::RHasEndDate, map[ OPimEvent::FRHasEndDate ] ); 682 recFields.insert( OPimRecurrence::RHasEndDate, map[ OPimEvent::FRHasEndDate ] );
683 recFields.insert( OPimRecurrence::EndDate, map[ OPimEvent::FREndDate ] ); 683 recFields.insert( OPimRecurrence::EndDate, map[ OPimEvent::FREndDate ] );
684 recFields.insert( OPimRecurrence::Created, map[ OPimEvent::FRCreated ] ); 684 recFields.insert( OPimRecurrence::Created, map[ OPimEvent::FRCreated ] );
685 recFields.insert( OPimRecurrence::Exceptions, map[ OPimEvent::FRExceptions ] ); 685 recFields.insert( OPimRecurrence::Exceptions, map[ OPimEvent::FRExceptions ] );
686 OPimRecurrence recur( recFields ); 686 OPimRecurrence recur( recFields );
687 setRecurrence( recur ); 687 setRecurrence( recur );
688 } 688 }
689 689
690} 690}
691 691
692 692
693int OPimEvent::parent() const 693int OPimEvent::parent() const
694{ 694{
695 return data->parent; 695 return data->parent;
696} 696}
697 697
698 698
699void OPimEvent::setParent( int uid ) 699void OPimEvent::setParent( int uid )
700{ 700{
701 changeOrModify(); 701 changeOrModify();
702 data->parent = uid; 702 data->parent = uid;
703} 703}
704 704
705 705
706QArray<int> OPimEvent::children() const 706QArray<int> OPimEvent::children() const
707{ 707{
708 if ( !data->child ) return QArray<int>(); 708 if ( !data->child ) return QArray<int>();
709 else 709 else
710 return data->child->copy(); 710 return data->child->copy();
711} 711}
712 712
713 713
714void OPimEvent::setChildren( const QArray<int>& arr ) 714void OPimEvent::setChildren( const QArray<int>& arr )
715{ 715{
716 changeOrModify(); 716 changeOrModify();
717 if ( data->child ) delete data->child; 717 if ( data->child ) delete data->child;
718 718
719 data->child = new QArray<int>( arr ); 719 data->child = new QArray<int>( arr );
720 data->child->detach(); 720 data->child->detach();
721} 721}
722 722
723 723
724void OPimEvent::addChild( int uid ) 724void OPimEvent::addChild( int uid )
725{ 725{
726 changeOrModify(); 726 changeOrModify();
727 if ( !data->child ) 727 if ( !data->child )
728 { 728 {
729 data->child = new QArray<int>( 1 ); 729 data->child = new QArray<int>( 1 );
730 ( *data->child ) [ 0 ] = uid; 730 ( *data->child ) [ 0 ] = uid;
731 } 731 }
732 else 732 else
733 { 733 {
734 int count = data->child->count(); 734 int count = data->child->count();
735 data->child->resize( count + 1 ); 735 data->child->resize( count + 1 );
736 ( *data->child ) [ count ] = uid; 736 ( *data->child ) [ count ] = uid;
737 } 737 }
738} 738}
739 739
740 740
741void OPimEvent::removeChild( int uid ) 741void OPimEvent::removeChild( int uid )
742{ 742{
743 if ( !data->child || !data->child->contains( uid ) ) return ; 743 if ( !data->child || !data->child->contains( uid ) ) return ;
744 changeOrModify(); 744 changeOrModify();
745 QArray<int> newAr( data->child->count() - 1 ); 745 QArray<int> newAr( data->child->count() - 1 );
746 int j = 0; 746 int j = 0;
747 uint count = data->child->count(); 747 uint count = data->child->count();
748 for ( uint i = 0; i < count; i++ ) 748 for ( uint i = 0; i < count; i++ )
749 { 749 {
750 if ( ( *data->child ) [ i ] != uid ) 750 if ( ( *data->child ) [ i ] != uid )
751 { 751 {
752 newAr[ j ] = ( *data->child ) [ i ]; 752 newAr[ j ] = ( *data->child ) [ i ];
753 j++; 753 j++;
754 } 754 }
755 } 755 }
756 ( *data->child ) = newAr; 756 ( *data->child ) = newAr;
757} 757}
758 758
759 759
760struct OEffectiveEvent::Data : public QShared 760struct OEffectiveEvent::Data : public QShared
761{ 761{
762 Data() : QShared() 762 Data() : QShared()
763 {} 763 {}
764 OPimEvent event; 764 OPimEvent event;
765 QDate date; 765 QDate date;
766 QTime start, end; 766 QTime start, end;
767 QDate startDate, endDate; 767 QDate startDate, endDate;
768bool dates : 1; 768bool dates : 1;
769}; 769};
770 770
771 771
772OEffectiveEvent::OEffectiveEvent() 772OEffectiveEvent::OEffectiveEvent()
773{ 773{
774 data = new Data; 774 data = new Data;
775 data->date = QDate::currentDate(); 775 data->date = QDate::currentDate();
776 data->start = data->end = QTime::currentTime(); 776 data->start = data->end = QTime::currentTime();
777 data->dates = false; 777 data->dates = false;
778} 778}
779 779
780 780
781OEffectiveEvent::OEffectiveEvent( const OPimEvent& ev, const QDate& startDate, 781OEffectiveEvent::OEffectiveEvent( const OPimEvent& ev, const QDate& startDate,
782 Position pos ) 782 Position pos )
783{ 783{
784 data = new Data; 784 data = new Data;
785 data->event = ev; 785 data->event = ev;
786 data->date = startDate; 786 data->date = startDate;
787 if ( pos & Start ) 787 if ( pos & Start )
788 data->start = ev.startDateTime().time(); 788 data->start = ev.startDateTime().time();
789 else 789 else
790 data->start = QTime( 0, 0, 0 ); 790 data->start = QTime( 0, 0, 0 );
791 791
792 if ( pos & End ) 792 if ( pos & End )
793 data->end = ev.endDateTime().time(); 793 data->end = ev.endDateTime().time();
794 else 794 else
795 data->end = QTime( 23, 59, 59 ); 795 data->end = QTime( 23, 59, 59 );
796 796
797 data->dates = false; 797 data->dates = false;
798} 798}
799 799
800 800
801OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev ) 801OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev )
802{ 802{
803 data = ev.data; 803 data = ev.data;
804 data->ref(); 804 data->ref();
805} 805}
806 806
807 807
808OEffectiveEvent::~OEffectiveEvent() 808OEffectiveEvent::~OEffectiveEvent()
809{ 809{
810 if ( data->deref() ) 810 if ( data->deref() )
811 { 811 {
812 delete data; 812 delete data;
813 data = 0; 813 data = 0;
814 } 814 }
815} 815}
816 816
817 817
818OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) 818OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev )
819{ 819{
820 if ( *this == ev ) return * this; 820 if ( *this == ev ) return * this;
821 821
822 ev.data->ref(); 822 ev.data->ref();
823 deref(); 823 deref();
824 data = ev.data; 824 data = ev.data;
825 825
826 return *this; 826 return *this;
827} 827}
828 828
829 829
830void OEffectiveEvent::setStartTime( const QTime& ti ) 830void OEffectiveEvent::setStartTime( const QTime& ti )
831{ 831{
832 changeOrModify(); 832 changeOrModify();
833 data->start = ti; 833 data->start = ti;
834} 834}
835 835
836 836
837void OEffectiveEvent::setEndTime( const QTime& en ) 837void OEffectiveEvent::setEndTime( const QTime& en )
838{ 838{
839 changeOrModify(); 839 changeOrModify();
840 data->end = en; 840 data->end = en;
841} 841}
842 842
843 843
844void OEffectiveEvent::setEvent( const OPimEvent& ev ) 844void OEffectiveEvent::setEvent( const OPimEvent& ev )
845{ 845{
846 changeOrModify(); 846 changeOrModify();
847 data->event = ev; 847 data->event = ev;
848} 848}
849 849
850 850
851void OEffectiveEvent::setDate( const QDate& da ) 851void OEffectiveEvent::setDate( const QDate& da )
852{ 852{
853 changeOrModify(); 853 changeOrModify();
854 data->date = da; 854 data->date = da;
855} 855}
856 856
857 857
858void OEffectiveEvent::setEffectiveDates( const QDate& from, 858void OEffectiveEvent::setEffectiveDates( const QDate& from,
859 const QDate& to ) 859 const QDate& to )
860{ 860{
861 if ( !from.isValid() ) 861 if ( !from.isValid() )
862 { 862 {
863 data->dates = false; 863 data->dates = false;
864 return ; 864 return ;
865 } 865 }
866 866
867 data->startDate = from; 867 data->startDate = from;
868 data->endDate = to; 868 data->endDate = to;
869} 869}
870 870
871 871
872QString OEffectiveEvent::description() const 872QString OEffectiveEvent::description() const
873{ 873{
874 return data->event.description(); 874 return data->event.description();
875} 875}
876 876
877 877
878QString OEffectiveEvent::location() const 878QString OEffectiveEvent::location() const
879{ 879{
880 return data->event.location(); 880 return data->event.location();
881} 881}
882 882
883 883
884QString OEffectiveEvent::note() const 884QString OEffectiveEvent::note() const
885{ 885{
886 return data->event.note(); 886 return data->event.note();
887} 887}
888 888
889 889
890OPimEvent OEffectiveEvent::event() const 890OPimEvent OEffectiveEvent::event() const
891{ 891{
892 return data->event; 892 return data->event;
893} 893}
894 894
895 895
896QTime OEffectiveEvent::startTime() const 896QTime OEffectiveEvent::startTime() const
897{ 897{
898 return data->start; 898 return data->start;
899} 899}
900 900
901 901
902QTime OEffectiveEvent::endTime() const 902QTime OEffectiveEvent::endTime() const
903{ 903{
904 return data->end; 904 return data->end;
905} 905}
906 906
907 907
908QDate OEffectiveEvent::date() const 908QDate OEffectiveEvent::date() const
909{ 909{
910 return data->date; 910 return data->date;
911} 911}
912 912
913 913
914int OEffectiveEvent::length() const 914int OEffectiveEvent::length() const
915{ 915{
916 return ( data->end.hour() * 60 - data->start.hour() * 60 ) 916 return ( data->end.hour() * 60 - data->start.hour() * 60 )
917 + QABS( data->start.minute() - data->end.minute() ); 917 + QABS( data->start.minute() - data->end.minute() );
918} 918}
919 919
920 920
921int OEffectiveEvent::size() const 921int OEffectiveEvent::size() const
922{ 922{
923 return ( data->end.hour() - data->start.hour() ) * 3600 923 return ( data->end.hour() - data->start.hour() ) * 3600
924 + ( data->end.minute() - data->start.minute() * 60 924 + ( data->end.minute() - data->start.minute() * 60
925 + data->end.second() - data->start.second() ); 925 + data->end.second() - data->start.second() );
926} 926}
927 927
928 928
929QDate OEffectiveEvent::startDate() const 929QDate OEffectiveEvent::startDate() const
930{ 930{
931 if ( data->dates ) 931 if ( data->dates )
932 return data->startDate; 932 return data->startDate;
933 else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer 933 else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer
934 return data->date; 934 return data->date;
935 else 935 else
936 return data->event.startDateTime().date(); 936 return data->event.startDateTime().date();
937} 937}
938 938
939 939
940QDate OEffectiveEvent::endDate() const 940QDate OEffectiveEvent::endDate() const
941{ 941{
942 if ( data->dates ) 942 if ( data->dates )
943 return data->endDate; 943 return data->endDate;
944 else if ( data->event.hasRecurrence() ) 944 else if ( data->event.hasRecurrence() )
945 return data->date; 945 return data->date;
946 else 946 else
947 return data->event.endDateTime().date(); 947 return data->event.endDateTime().date();
948} 948}
949 949
950 950
951void OEffectiveEvent::deref() 951void OEffectiveEvent::deref()
952{ 952{
953 if ( data->deref() ) 953 if ( data->deref() )
954 { 954 {
955 delete data; 955 delete data;
956 data = 0; 956 data = 0;
957 } 957 }
958} 958}
959 959
960 960
961void OEffectiveEvent::changeOrModify() 961void OEffectiveEvent::changeOrModify()
962{ 962{
963 if ( data->count != 1 ) 963 if ( data->count != 1 )
964 { 964 {
965 data->deref(); 965 data->deref();
966 Data* d2 = new Data; 966 Data* d2 = new Data;
967 d2->event = data->event; 967 d2->event = data->event;
968 d2->date = data->date; 968 d2->date = data->date;
969 d2->start = data->start; 969 d2->start = data->start;
970 d2->end = data->end; 970 d2->end = data->end;
971 d2->startDate = data->startDate; 971 d2->startDate = data->startDate;
972 d2->endDate = data->endDate; 972 d2->endDate = data->endDate;
973 d2->dates = data->dates; 973 d2->dates = data->dates;
974 data = d2; 974 data = d2;
975 } 975 }
976} 976}
977 977
978 978
979bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const 979bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const
980{ 980{
981 if ( data->date < e.date() ) 981 if ( data->date < e.date() )
982 return TRUE; 982 return TRUE;
983 if ( data->date == e.date() ) 983 if ( data->date == e.date() )
984 return ( startTime() < e.startTime() ); 984 return ( startTime() < e.startTime() );
985 else 985 else
986 return FALSE; 986 return FALSE;
987} 987}
988 988
989 989
990bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const 990bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const
991{ 991{
992 return ( data->date <= e.date() ); 992 return ( data->date <= e.date() );
993} 993}
994 994
995 995
996bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const 996bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const
997{ 997{
998 return ( date() == e.date() 998 return ( date() == e.date()
999 && startTime() == e.startTime() 999 && startTime() == e.startTime()
1000 && endTime() == e.endTime() 1000 && endTime() == e.endTime()
1001 && event() == e.event() ); 1001 && event() == e.event() );
1002} 1002}
1003 1003
1004 1004
1005bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const 1005bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const
1006{ 1006{
1007 return !( *this == e ); 1007 return !( *this == e );
1008} 1008}
1009 1009
1010 1010
1011bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const 1011bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const
1012{ 1012{
1013 return !( *this <= e ); 1013 return !( *this <= e );
1014} 1014}
1015 1015
1016 1016
1017bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const 1017bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const
1018{ 1018{
1019 return !( *this < e ); 1019 return !( *this < e );
1020} 1020}
1021 1021
1022} 1022}
diff --git a/libopie2/opiepim/core/opimevent.h b/libopie2/opiepim/core/opimevent.h
index 949f263..56fe917 100644
--- a/libopie2/opiepim/core/opimevent.h
+++ b/libopie2/opiepim/core/opimevent.h
@@ -1,275 +1,275 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> 3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
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// CONTAINS GPLed code of TT 29// CONTAINS GPLed code of TT
30 30
31#ifndef OEVENT_H 31#ifndef OEVENT_H
32#define OEVENT_H 32#define OEVENT_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/opimtimezone.h> 35#include <opie2/opimtimezone.h>
36#include <opie2/opimrecord.h> 36#include <opie2/opimrecord.h>
37#include <qpe/recordfields.h> 37#include <qpe/recordfields.h>
38#include <qpe/palmtopuidgen.h> 38#include <qpe/palmtopuidgen.h>
39 39
40/* QT */ 40/* QT */
41#include <qstring.h> 41#include <qstring.h>
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qvaluelist.h> 43#include <qvaluelist.h>
44 44
45namespace Opie 45namespace Opie
46{ 46{
47struct OCalendarHelper 47struct OCalendarHelper
48{ 48{
49 /** calculate the week number of the date */ 49 /** calculate the week number of the date */
50 static int week( const QDate& ); 50 static int week( const QDate& );
51 /** calculate the occurence of week days since the start of the month */ 51 /** calculate the occurence of week days since the start of the month */
52 static int ocurrence( const QDate& ); 52 static int ocurrence( const QDate& );
53 53
54 // returns the dayOfWeek for the *first* day it finds (ignores 54 // returns the dayOfWeek for the *first* day it finds (ignores
55 // any further days!). Returns 1 (Monday) if there isn't any day found 55 // any further days!). Returns 1 (Monday) if there isn't any day found
56 static int dayOfWeek( char day ); 56 static int dayOfWeek( char day );
57 57
58 /** returns the diff of month */ 58 /** returns the diff of month */
59 static int monthDiff( const QDate& first, const QDate& second ); 59 static int monthDiff( const QDate& first, const QDate& second );
60 60
61}; 61};
62 62
63class OPimNotifyManager; 63class OPimNotifyManager;
64class OPimRecurrence; 64class OPimRecurrence;
65 65
66/** 66/**
67 * This is the container for all Events. It encapsules all 67 * This is the container for all Events. It encapsules all
68 * available information for a single Event 68 * available information for a single Event
69 * @short container for events. 69 * @short container for events.
70 */ 70 */
71class OPimEvent : public OPimRecord 71class OPimEvent : public OPimRecord
72{ 72{
73 public: 73 public:
74 typedef QValueList<OPimEvent> ValueList; 74 typedef QValueList<OPimEvent> ValueList;
75 /** 75 /**
76 * RecordFields contain possible attributes 76 * RecordFields contain possible attributes
77 * used in the Results of toMap().. 77 * used in the Results of toMap()..
78 */ 78 */
79 enum RecordFields { 79 enum RecordFields {
80 FUid = Qtopia::UID_ID, 80 FUid = Qtopia::UID_ID,
81 FCategories = Qtopia::CATEGORY_ID, 81 FCategories = Qtopia::CATEGORY_ID,
82 FDescription = 0, 82 FDescription = 0,
83 FLocation, 83 FLocation,
84 FType, 84 FType,
85 FAlarm, 85 FAlarm,
86 FSound, 86 FSound,
87 FRType, 87 FRType,
88 FRWeekdays, 88 FRWeekdays,
89 FRPosition, 89 FRPosition,
90 FRFreq, 90 FRFreq,
91 FRHasEndDate, 91 FRHasEndDate,
92 FREndDate, 92 FREndDate,
93 FRCreated, 93 FRCreated,
94 FRExceptions, 94 FRExceptions,
95 FStart, 95 FStart,
96 FEnd, 96 FEnd,
97 FNote, 97 FNote,
98 FTimeZone, 98 FTimeZone,
99 FRecParent, 99 FRecParent,
100 FRecChildren, 100 FRecChildren,
101 }; 101 };
102 102
103 /** 103 /**
104 * Start with an Empty OPimEvent. UID == 0 means that it is empty 104 * Start with an Empty OPimEvent. UID == 0 means that it is empty
105 */ 105 */
106 OPimEvent( int uid = 0 ); 106 OPimEvent( int uid = 0 );
107 107
108 /** 108 /**
109 * copy c'tor 109 * copy c'tor
110 */ 110 */
111 OPimEvent( const OPimEvent& ); 111 OPimEvent( const OPimEvent& );
112 112
113 /** 113 /**
114 * Create OPimEvent, initialized by map 114 * Create OPimEvent, initialized by map
115 * @see enum RecordFields 115 * @see enum RecordFields
116 */ 116 */
117 OPimEvent( const QMap<int, QString> map ); 117 OPimEvent( const QMap<int, QString> map );
118 ~OPimEvent(); 118 ~OPimEvent();
119 OPimEvent &operator=( const OPimEvent& ); 119 OPimEvent &operator=( const OPimEvent& );
120 120
121 QString description() const; 121 QString description() const;
122 void setDescription( const QString& description ); 122 void setDescription( const QString& description );
123 123
124 QString location() const; 124 QString location() const;
125 void setLocation( const QString& loc ); 125 void setLocation( const QString& loc );
126 126
127 bool hasNotifiers() const; 127 bool hasNotifiers() const;
128 OPimNotifyManager &notifiers() const; 128 OPimNotifyManager &notifiers() const;
129 129
130 OPimRecurrence recurrence() const; 130 OPimRecurrence recurrence() const;
131 void setRecurrence( const OPimRecurrence& ); 131 void setRecurrence( const OPimRecurrence& );
132 bool hasRecurrence() const; 132 bool hasRecurrence() const;
133 133
134 QString note() const; 134 QString note() const;
135 void setNote( const QString& note ); 135 void setNote( const QString& note );
136 136
137 137
138 QDateTime createdDateTime() const; 138 QDateTime createdDateTime() const;
139 void setCreatedDateTime( const QDateTime& dt ); 139 void setCreatedDateTime( const QDateTime& dt );
140 140
141 /** set the date to dt. dt is the QDateTime in localtime */ 141 /** set the date to dt. dt is the QDateTime in localtime */
142 void setStartDateTime( const QDateTime& ); 142 void setStartDateTime( const QDateTime& );
143 /** returns the datetime in the local timeZone */ 143 /** returns the datetime in the local timeZone */
144 QDateTime startDateTime() const; 144 QDateTime startDateTime() const;
145 145
146 /** returns the start datetime in the current zone */ 146 /** returns the start datetime in the current zone */
147 QDateTime startDateTimeInZone() const; 147 QDateTime startDateTimeInZone() const;
148 148
149 /** in current timezone */ 149 /** in current timezone */
150 void setEndDateTime( const QDateTime& ); 150 void setEndDateTime( const QDateTime& );
151 /** in current timezone */ 151 /** in current timezone */
152 QDateTime endDateTime() const; 152 QDateTime endDateTime() const;
153 QDateTime endDateTimeInZone() const; 153 QDateTime endDateTimeInZone() const;
154 154
155 bool isMultipleDay() const; 155 bool isMultipleDay() const;
156 bool isAllDay() const; 156 bool isAllDay() const;
157 void setAllDay( bool isAllDay ); 157 void setAllDay( bool isAllDay );
158 158
159 /* pin this event to a timezone! FIXME */ 159 /* pin this event to a timezone! FIXME */
160 void setTimeZone( const QString& timeZone ); 160 void setTimeZone( const QString& timeZone );
161 QString timeZone() const; 161 QString timeZone() const;
162 162
163 163
164 virtual bool match( const QRegExp& ) const; 164 virtual bool match( const QRegExp& ) const;
165 165
166 /** For exception to recurrence here is a list of children... */ 166 /** For exception to recurrence here is a list of children... */
167 QArray<int> children() const; 167 QArray<int> children() const;
168 void setChildren( const QArray<int>& ); 168 void setChildren( const QArray<int>& );
169 void addChild( int uid ); 169 void addChild( int uid );
170 void removeChild( int uid ); 170 void removeChild( int uid );
171 171
172 /** return the parent OPimEvent */ 172 /** return the parent OPimEvent */
173 int parent() const; 173 int parent() const;
174 void setParent( int uid ); 174 void setParent( int uid );
175 175
176 176
177 /* needed reimp */ 177 /* needed reimp */
178 QString toRichText() const; 178 QString toRichText() const;
179 QString toShortText() const; 179 QString toShortText() const;
180 QString type() const; 180 QString type() const;
181 181
182 QMap<int, QString> toMap() const; 182 QMap<int, QString> toMap() const;
183 void fromMap( const QMap<int, QString>& map ); 183 void fromMap( const QMap<int, QString>& map );
184 QString recordField( int ) const; 184 QString recordField( int ) const;
185 185
186 static int rtti(); 186 int rtti() const;
187 187
188 bool loadFromStream( QDataStream& ); 188 bool loadFromStream( QDataStream& );
189 bool saveToStream( QDataStream& ) const; 189 bool saveToStream( QDataStream& ) const;
190 190
191 /* bool operator==( const OPimEvent& ); 191 /* bool operator==( const OPimEvent& );
192 bool operator!=( const OPimEvent& ); 192 bool operator!=( const OPimEvent& );
193 bool operator<( const OPimEvent& ); 193 bool operator<( const OPimEvent& );
194 bool operator<=( const OPimEvent& ); 194 bool operator<=( const OPimEvent& );
195 bool operator>( const OPimEvent& ); 195 bool operator>( const OPimEvent& );
196 bool operator>=(const OPimEvent& ); 196 bool operator>=(const OPimEvent& );
197 */ 197 */
198 198
199 private: 199 private:
200 inline void changeOrModify(); 200 inline void changeOrModify();
201 void deref(); 201 void deref();
202 struct Data; 202 struct Data;
203 Data* data; 203 Data* data;
204 class Private; 204 class Private;
205 Private* priv; 205 Private* priv;
206 206
207}; 207};
208 208
209/** 209/**
210 * AN Event can span through multiple days. We split up a multiday eve 210 * AN Event can span through multiple days. We split up a multiday eve
211 */ 211 */
212class OEffectiveEvent 212class OEffectiveEvent
213{ 213{
214 214
215 public: 215 public:
216 typedef QValueList<OEffectiveEvent> ValueList; 216 typedef QValueList<OEffectiveEvent> ValueList;
217 enum Position { MidWay, Start, End, StartEnd }; 217 enum Position { MidWay, Start, End, StartEnd };
218 // If we calculate the effective event of a multi-day event 218 // If we calculate the effective event of a multi-day event
219 // we have to figure out whether we are at the first day, 219 // we have to figure out whether we are at the first day,
220 // at the end, or anywhere else ("middle"). This is important 220 // at the end, or anywhere else ("middle"). This is important
221 // for the start/end times (00:00/23:59) 221 // for the start/end times (00:00/23:59)
222 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- 222 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
223 // day event 223 // day event
224 // Start: start time -> 23:59 224 // Start: start time -> 23:59
225 // End: 00:00 -> end time 225 // End: 00:00 -> end time
226 // Start | End == StartEnd: for single-day events (default) 226 // Start | End == StartEnd: for single-day events (default)
227 // here we draw start time -> end time 227 // here we draw start time -> end time
228 OEffectiveEvent(); 228 OEffectiveEvent();
229 OEffectiveEvent( const OPimEvent& event, const QDate& startDate, Position pos = StartEnd ); 229 OEffectiveEvent( const OPimEvent& event, const QDate& startDate, Position pos = StartEnd );
230 OEffectiveEvent( const OEffectiveEvent& ); 230 OEffectiveEvent( const OEffectiveEvent& );
231 OEffectiveEvent &operator=( const OEffectiveEvent& ); 231 OEffectiveEvent &operator=( const OEffectiveEvent& );
232 ~OEffectiveEvent(); 232 ~OEffectiveEvent();
233 233
234 void setStartTime( const QTime& ); 234 void setStartTime( const QTime& );
235 void setEndTime( const QTime& ); 235 void setEndTime( const QTime& );
236 void setEvent( const OPimEvent& ); 236 void setEvent( const OPimEvent& );
237 void setDate( const QDate& ); 237 void setDate( const QDate& );
238 238
239 void setEffectiveDates( const QDate& from, const QDate& to ); 239 void setEffectiveDates( const QDate& from, const QDate& to );
240 240
241 QString description() const; 241 QString description() const;
242 QString location() const; 242 QString location() const;
243 QString note() const; 243 QString note() const;
244 OPimEvent event() const; 244 OPimEvent event() const;
245 QTime startTime() const; 245 QTime startTime() const;
246 QTime endTime() const; 246 QTime endTime() const;
247 QDate date() const; 247 QDate date() const;
248 248
249 /* return the length in hours */ 249 /* return the length in hours */
250 int length() const; 250 int length() const;
251 int size() const; 251 int size() const;
252 252
253 QDate startDate() const; 253 QDate startDate() const;
254 QDate endDate() const; 254 QDate endDate() const;
255 255
256 bool operator<( const OEffectiveEvent &e ) const; 256 bool operator<( const OEffectiveEvent &e ) const;
257 bool operator<=( const OEffectiveEvent &e ) const; 257 bool operator<=( const OEffectiveEvent &e ) const;
258 bool operator==( const OEffectiveEvent &e ) const; 258 bool operator==( const OEffectiveEvent &e ) const;
259 bool operator!=( const OEffectiveEvent &e ) const; 259 bool operator!=( const OEffectiveEvent &e ) const;
260 bool operator>( const OEffectiveEvent &e ) const; 260 bool operator>( const OEffectiveEvent &e ) const;
261 bool operator>= ( const OEffectiveEvent &e ) const; 261 bool operator>= ( const OEffectiveEvent &e ) const;
262 262
263 private: 263 private:
264 void deref(); 264 void deref();
265 inline void changeOrModify(); 265 inline void changeOrModify();
266 class Private; 266 class Private;
267 Private* priv; 267 Private* priv;
268 struct Data; 268 struct Data;
269 Data* data; 269 Data* data;
270 270
271}; 271};
272 272
273} 273}
274 274
275#endif 275#endif
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 67eed41..c783092 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -1,273 +1,273 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
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 29
30#include "opimrecord.h" 30#include "opimrecord.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <qpe/categories.h> 33#include <qpe/categories.h>
34#include <qpe/categoryselect.h> 34#include <qpe/categoryselect.h>
35 35
36/* QT */ 36/* QT */
37 37
38namespace Opie 38namespace Opie
39{ 39{
40Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); 40Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia );
41 41
42 42
43OPimRecord::OPimRecord( int uid ) 43OPimRecord::OPimRecord( int uid )
44 : Qtopia::Record() 44 : Qtopia::Record()
45{ 45{
46 46
47 m_lastHit = -1; 47 m_lastHit = -1;
48 setUid( uid ); 48 setUid( uid );
49} 49}
50 50
51 51
52OPimRecord::~OPimRecord() 52OPimRecord::~OPimRecord()
53{} 53{}
54 54
55 55
56OPimRecord::OPimRecord( const OPimRecord& rec ) 56OPimRecord::OPimRecord( const OPimRecord& rec )
57 : Qtopia::Record( rec ) 57 : Qtopia::Record( rec )
58{ 58{
59 ( *this ) = rec; 59 ( *this ) = rec;
60} 60}
61 61
62 62
63OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) 63OPimRecord &OPimRecord::operator=( const OPimRecord& rec )
64{ 64{
65 if ( this == &rec ) return * this; 65 if ( this == &rec ) return * this;
66 66
67 Qtopia::Record::operator=( rec ); 67 Qtopia::Record::operator=( rec );
68 m_xrefman = rec.m_xrefman; 68 m_xrefman = rec.m_xrefman;
69 m_lastHit = rec.m_lastHit; 69 m_lastHit = rec.m_lastHit;
70 70
71 return *this; 71 return *this;
72} 72}
73 73
74 74
75/* 75/*
76 * category names 76 * category names
77 */ 77 */
78QStringList OPimRecord::categoryNames( const QString& appname ) const 78QStringList OPimRecord::categoryNames( const QString& appname ) const
79{ 79{
80 QStringList list; 80 QStringList list;
81 QArray<int> cats = categories(); 81 QArray<int> cats = categories();
82 Categories catDB; 82 Categories catDB;
83 catDB.load( categoryFileName() ); 83 catDB.load( categoryFileName() );
84 84
85 for ( uint i = 0; i < cats.count(); i++ ) 85 for ( uint i = 0; i < cats.count(); i++ )
86 { 86 {
87 list << catDB.label( appname, cats[ i ] ); 87 list << catDB.label( appname, cats[ i ] );
88 } 88 }
89 89
90 return list; 90 return list;
91} 91}
92 92
93 93
94void OPimRecord::setCategoryNames( const QStringList& ) 94void OPimRecord::setCategoryNames( const QStringList& )
95{ 95{
96} 96}
97 97
98 98
99void OPimRecord::addCategoryName( const QString& ) 99void OPimRecord::addCategoryName( const QString& )
100{ 100{
101 Categories catDB; 101 Categories catDB;
102 catDB.load( categoryFileName() ); 102 catDB.load( categoryFileName() );
103 103
104 104
105} 105}
106 106
107 107
108bool OPimRecord::isEmpty() const 108bool OPimRecord::isEmpty() const
109{ 109{
110 return ( uid() == 0 ); 110 return ( uid() == 0 );
111} 111}
112 112
113 113
114/*QString OPimRecord::crossToString()const { 114/*QString OPimRecord::crossToString()const {
115 QString str; 115 QString str;
116 QMap<QString, QArray<int> >::ConstIterator it; 116 QMap<QString, QArray<int> >::ConstIterator it;
117 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 117 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
118 QArray<int> id = it.data(); 118 QArray<int> id = it.data();
119 for ( uint i = 0; i < id.size(); ++i ) { 119 for ( uint i = 0; i < id.size(); ++i ) {
120 str += it.key() + "," + QString::number( i ) + ";"; 120 str += it.key() + "," + QString::number( i ) + ";";
121 } 121 }
122 } 122 }
123 str = str.remove( str.length()-1, 1); // strip the ; 123 str = str.remove( str.length()-1, 1); // strip the ;
124 //qWarning("IDS " + str ); 124 //qWarning("IDS " + str );
125 125
126 return str; 126 return str;
127 }*/ 127 }*/
128/* if uid = 1 assign a new one */ 128/* if uid = 1 assign a new one */
129void OPimRecord::setUid( int uid ) 129void OPimRecord::setUid( int uid )
130{ 130{
131 if ( uid == 1 ) 131 if ( uid == 1 )
132 uid = uidGen().generate(); 132 uid = uidGen().generate();
133 133
134 Qtopia::Record::setUid( uid ); 134 Qtopia::Record::setUid( uid );
135}; 135};
136 136
137 137
138Qtopia::UidGen &OPimRecord::uidGen() 138Qtopia::UidGen &OPimRecord::uidGen()
139{ 139{
140 return m_uidGen; 140 return m_uidGen;
141} 141}
142 142
143 143
144OPimXRefManager &OPimRecord::xrefmanager() 144OPimXRefManager &OPimRecord::xrefmanager()
145{ 145{
146 return m_xrefman; 146 return m_xrefman;
147} 147}
148 148
149 149
150int OPimRecord::rtti() 150int OPimRecord::rtti() const
151{ 151{
152 return 0; 152 return 0;
153} 153}
154 154
155/** 155/**
156 * now let's put our data into the stream 156 * now let's put our data into the stream
157 */ 157 */
158/* 158/*
159 * First read UID 159 * First read UID
160 * Categories 160 * Categories
161 * XRef 161 * XRef
162 */ 162 */
163bool OPimRecord::loadFromStream( QDataStream& stream ) 163bool OPimRecord::loadFromStream( QDataStream& stream )
164{ 164{
165 int Int; 165 int Int;
166 uint UInt; 166 uint UInt;
167 stream >> Int; 167 stream >> Int;
168 setUid( Int ); 168 setUid( Int );
169 169
170 /** Categories */ 170 /** Categories */
171 stream >> UInt; 171 stream >> UInt;
172 QArray<int> array( UInt ); 172 QArray<int> array( UInt );
173 for ( uint i = 0; i < UInt; i++ ) 173 for ( uint i = 0; i < UInt; i++ )
174 { 174 {
175 stream >> array[ i ]; 175 stream >> array[ i ];
176 } 176 }
177 setCategories( array ); 177 setCategories( array );
178 178
179 /* 179 /*
180 * now we do the X-Ref stuff 180 * now we do the X-Ref stuff
181 */ 181 */
182 OPimXRef xref; 182 OPimXRef xref;
183 stream >> UInt; 183 stream >> UInt;
184 for ( uint i = 0; i < UInt; i++ ) 184 for ( uint i = 0; i < UInt; i++ )
185 { 185 {
186 xref.setPartner( OPimXRef::One, partner( stream ) ); 186 xref.setPartner( OPimXRef::One, partner( stream ) );
187 xref.setPartner( OPimXRef::Two, partner( stream ) ); 187 xref.setPartner( OPimXRef::Two, partner( stream ) );
188 m_xrefman.add( xref ); 188 m_xrefman.add( xref );
189 } 189 }
190 190
191 return true; 191 return true;
192} 192}
193 193
194 194
195bool OPimRecord::saveToStream( QDataStream& stream ) const 195bool OPimRecord::saveToStream( QDataStream& stream ) const
196{ 196{
197 /** UIDs */ 197 /** UIDs */
198 198
199 stream << uid(); 199 stream << uid();
200 200
201 /** Categories */ 201 /** Categories */
202 stream << categories().count(); 202 stream << categories().count();
203 for ( uint i = 0; i < categories().count(); i++ ) 203 for ( uint i = 0; i < categories().count(); i++ )
204 { 204 {
205 stream << categories() [ i ]; 205 stream << categories() [ i ];
206 } 206 }
207 207
208 /* 208 /*
209 * first the XRef count 209 * first the XRef count
210 * then the xrefs 210 * then the xrefs
211 */ 211 */
212 stream << m_xrefman.list().count(); 212 stream << m_xrefman.list().count();
213 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin(); 213 for ( OPimXRef::ValueList::ConstIterator it = m_xrefman.list().begin();
214 it != m_xrefman.list().end(); ++it ) 214 it != m_xrefman.list().end(); ++it )
215 { 215 {
216 flush( ( *it ).partner( OPimXRef::One ), stream ); 216 flush( ( *it ).partner( OPimXRef::One ), stream );
217 flush( ( *it ).partner( OPimXRef::Two ), stream ); 217 flush( ( *it ).partner( OPimXRef::Two ), stream );
218 } 218 }
219 return true; 219 return true;
220} 220}
221 221
222 222
223void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const 223void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const
224{ 224{
225 str << par.service(); 225 str << par.service();
226 str << par.uid(); 226 str << par.uid();
227 str << par.field(); 227 str << par.field();
228} 228}
229 229
230 230
231OPimXRefPartner OPimRecord::partner( QDataStream& stream ) 231OPimXRefPartner OPimRecord::partner( QDataStream& stream )
232{ 232{
233 OPimXRefPartner par; 233 OPimXRefPartner par;
234 QString str; 234 QString str;
235 int i; 235 int i;
236 236
237 stream >> str; 237 stream >> str;
238 par.setService( str ); 238 par.setService( str );
239 239
240 stream >> i; 240 stream >> i;
241 par.setUid( i ); 241 par.setUid( i );
242 242
243 stream >> i ; 243 stream >> i ;
244 par.setField( i ); 244 par.setField( i );
245 245
246 return par; 246 return par;
247} 247}
248 248
249 249
250void OPimRecord::setLastHitField( int lastHit ) const 250void OPimRecord::setLastHitField( int lastHit ) const
251{ 251{
252 m_lastHit = lastHit; 252 m_lastHit = lastHit;
253} 253}
254 254
255 255
256int OPimRecord::lastHitField() const 256int OPimRecord::lastHitField() const
257{ 257{
258 return m_lastHit; 258 return m_lastHit;
259} 259}
260 260
261 261
262QMap<QString, QString> OPimRecord::toExtraMap() const 262QMap<QString, QString> OPimRecord::toExtraMap() const
263{ 263{
264 return customMap; 264 return customMap;
265} 265}
266 266
267 267
268void OPimRecord::setExtraMap( const QMap<QString, QString>& map ) 268void OPimRecord::setExtraMap( const QMap<QString, QString>& map )
269{ 269{
270 customMap = map; 270 customMap = map;
271} 271}
272 272
273} 273}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index 4981a41..127439a 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -1,193 +1,193 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
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 29
30#ifndef OPIMRECORD_H 30#ifndef OPIMRECORD_H
31#define OPIMRECORD_H 31#define OPIMRECORD_H
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/opimxrefmanager.h> 34#include <opie2/opimxrefmanager.h>
35/* 35/*
36 * we need to get customMap which is private... 36 * we need to get customMap which is private...
37 */ 37 */
38#define private protected 38#define private protected
39#include <qpe/palmtoprecord.h> 39#include <qpe/palmtoprecord.h>
40#undef private 40#undef private
41 41
42/* QT */ 42/* QT */
43#include <qdatastream.h> 43#include <qdatastream.h>
44#include <qmap.h> 44#include <qmap.h>
45#include <qstring.h> 45#include <qstring.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47 47
48namespace Opie 48namespace Opie
49{ 49{
50/** 50/**
51 * This is the base class for 51 * This is the base class for
52 * all PIM Records 52 * all PIM Records
53 * 53 *
54 */ 54 */
55class OPimRecord : public Qtopia::Record 55class OPimRecord : public Qtopia::Record
56{ 56{
57 public: 57 public:
58 /** 58 /**
59 * c'tor 59 * c'tor
60 * uid of 0 isEmpty 60 * uid of 0 isEmpty
61 * uid of 1 will be assigned a new one 61 * uid of 1 will be assigned a new one
62 */ 62 */
63 OPimRecord( int uid = 0 ); 63 OPimRecord( int uid = 0 );
64 ~OPimRecord(); 64 ~OPimRecord();
65 65
66 /** 66 /**
67 * copy c'tor 67 * copy c'tor
68 */ 68 */
69 OPimRecord( const OPimRecord& rec ); 69 OPimRecord( const OPimRecord& rec );
70 70
71 /** 71 /**
72 * copy operator 72 * copy operator
73 */ 73 */
74 OPimRecord &operator=( const OPimRecord& ); 74 OPimRecord &operator=( const OPimRecord& );
75 75
76 /** 76 /**
77 * category names resolved 77 * category names resolved
78 */ 78 */
79 QStringList categoryNames( const QString& appname ) const; 79 QStringList categoryNames( const QString& appname ) const;
80 80
81 /** 81 /**
82 * set category names they will be resolved 82 * set category names they will be resolved
83 */ 83 */
84 void setCategoryNames( const QStringList& ); 84 void setCategoryNames( const QStringList& );
85 85
86 /** 86 /**
87 * addCategoryName adds a name 87 * addCategoryName adds a name
88 * to the internal category list 88 * to the internal category list
89 */ 89 */
90 void addCategoryName( const QString& ); 90 void addCategoryName( const QString& );
91 91
92 /** 92 /**
93 * if a Record isEmpty 93 * if a Record isEmpty
94 * it's empty if it's 0 94 * it's empty if it's 0
95 */ 95 */
96 virtual bool isEmpty() const; 96 virtual bool isEmpty() const;
97 97
98 /** 98 /**
99 * toRichText summary 99 * toRichText summary
100 */ 100 */
101 virtual QString toRichText() const = 0; 101 virtual QString toRichText() const = 0;
102 102
103 /** 103 /**
104 * a small one line summary 104 * a small one line summary
105 */ 105 */
106 virtual QString toShortText() const = 0; 106 virtual QString toShortText() const = 0;
107 107
108 /** 108 /**
109 * the name of the Record 109 * the name of the Record
110 */ 110 */
111 virtual QString type() const = 0; 111 virtual QString type() const = 0;
112 112
113 /** 113 /**
114 * matches the Records the regular expression? 114 * matches the Records the regular expression?
115 */ 115 */
116 virtual bool match( const QString &regexp ) const 116 virtual bool match( const QString &regexp ) const
117 { 117 {
118 setLastHitField( -1 ); 118 setLastHitField( -1 );
119 return Qtopia::Record::match( QRegExp( regexp ) ); 119 return Qtopia::Record::match( QRegExp( regexp ) );
120 }; 120 };
121 121
122 /** 122 /**
123 * if implemented this function returns which item has been 123 * if implemented this function returns which item has been
124 * last hit by the match() function. 124 * last hit by the match() function.
125 * or -1 if not implemented or no hit has occured 125 * or -1 if not implemented or no hit has occured
126 */ 126 */
127 int lastHitField() const; 127 int lastHitField() const;
128 128
129 /** 129 /**
130 * converts the internal structure to a map 130 * converts the internal structure to a map
131 */ 131 */
132 virtual QMap<int, QString> toMap() const = 0; 132 virtual QMap<int, QString> toMap() const = 0;
133 // 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)
134 134
135 /** 135 /**
136 * key value representation of extra items 136 * key value representation of extra items
137 */ 137 */
138 QMap<QString, QString> toExtraMap() const; 138 QMap<QString, QString> toExtraMap() const;
139 void setExtraMap( const QMap<QString, QString>& ); 139 void setExtraMap( const QMap<QString, QString>& );
140 140
141 /** 141 /**
142 * the name for a recordField 142 * the name for a recordField
143 */ 143 */
144 virtual QString recordField( int ) const = 0; 144 virtual QString recordField( int ) const = 0;
145 145
146 /** 146 /**
147 * returns a reference of the 147 * returns a reference of the
148 * Cross Reference Manager 148 * Cross Reference Manager
149 * Partner 'One' is THIS PIM RECORD! 149 * Partner 'One' is THIS PIM RECORD!
150 * 'Two' is the Partner where we link to 150 * 'Two' is the Partner where we link to
151 */ 151 */
152 OPimXRefManager& xrefmanager(); 152 OPimXRefManager& xrefmanager();
153 153
154 /** 154 /**
155 * set the uid 155 * set the uid
156 */ 156 */
157 virtual void setUid( int uid ); 157 virtual void setUid( int uid );
158 158
159 /* 159 /*
160 * used inside the Templates for casting 160 * used inside the Templates for casting
161 * REIMPLEMENT in your .... 161 * REIMPLEMENT in your ....
162 */ 162 */
163 static int rtti(); 163 virtual int rtti() const;
164 164
165 /** 165 /**
166 * some marshalling and de marshalling code 166 * some marshalling and de marshalling code
167 * saves the OPimRecord 167 * saves the OPimRecord
168 * to and from a DataStream 168 * to and from a DataStream
169 */ 169 */
170 virtual bool loadFromStream( QDataStream& ); 170 virtual bool loadFromStream( QDataStream& );
171 virtual bool saveToStream( QDataStream& stream ) const; 171 virtual bool saveToStream( QDataStream& stream ) const;
172 172
173 protected: 173 protected:
174 // need to be const cause it is called from const methods 174 // need to be const cause it is called from const methods
175 mutable int m_lastHit; 175 mutable int m_lastHit;
176 void setLastHitField( int lastHit ) const; 176 void setLastHitField( int lastHit ) const;
177 Qtopia::UidGen &uidGen(); 177 Qtopia::UidGen &uidGen();
178 // QString crossToString()const; 178 // QString crossToString()const;
179 179
180 private: 180 private:
181 class OPimRecordPrivate; 181 class OPimRecordPrivate;
182 OPimRecordPrivate *d; 182 OPimRecordPrivate *d;
183 OPimXRefManager m_xrefman; 183 OPimXRefManager m_xrefman;
184 static Qtopia::UidGen m_uidGen; 184 static Qtopia::UidGen m_uidGen;
185 185
186 private: 186 private:
187 void flush( const OPimXRefPartner&, QDataStream& stream ) const; 187 void flush( const OPimXRefPartner&, QDataStream& stream ) const;
188 OPimXRefPartner partner( QDataStream& ); 188 OPimXRefPartner partner( QDataStream& );
189}; 189};
190 190
191} 191}
192 192
193#endif 193#endif
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index f246bfd..47433e0 100644
--- a/libopie2/opiepim/core/opimtodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -1,711 +1,711 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
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 29
30#include "opimtodo.h" 30#include "opimtodo.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimstate.h> 33#include <opie2/opimstate.h>
34#include <opie2/opimrecurrence.h> 34#include <opie2/opimrecurrence.h>
35#include <opie2/opimmaintainer.h> 35#include <opie2/opimmaintainer.h>
36#include <opie2/opimnotifymanager.h> 36#include <opie2/opimnotifymanager.h>
37#include <opie2/opimresolver.h> 37#include <opie2/opimresolver.h>
38#include <qpe/palmtopuidgen.h> 38#include <qpe/palmtopuidgen.h>
39#include <qpe/palmtoprecord.h> 39#include <qpe/palmtoprecord.h>
40#include <qpe/categories.h> 40#include <qpe/categories.h>
41#include <qpe/categoryselect.h> 41#include <qpe/categoryselect.h>
42#include <qpe/stringutil.h> 42#include <qpe/stringutil.h>
43 43
44/* QT */ 44/* QT */
45#include <qobject.h> 45#include <qobject.h>
46#include <qshared.h> 46#include <qshared.h>
47 47
48namespace Opie 48namespace Opie
49{ 49{
50 50
51struct OPimTodo::OPimTodoData : public QShared 51struct OPimTodo::OPimTodoData : public QShared
52{ 52{
53 OPimTodoData() : QShared() 53 OPimTodoData() : QShared()
54 { 54 {
55 recur = 0; 55 recur = 0;
56 state = 0; 56 state = 0;
57 maintainer = 0; 57 maintainer = 0;
58 notifiers = 0; 58 notifiers = 0;
59 }; 59 };
60 ~OPimTodoData() 60 ~OPimTodoData()
61 { 61 {
62 delete recur; 62 delete recur;
63 delete maintainer; 63 delete maintainer;
64 delete notifiers; 64 delete notifiers;
65 } 65 }
66 66
67 QDate date; 67 QDate date;
68 bool isCompleted: 1; 68 bool isCompleted: 1;
69 bool hasDate: 1; 69 bool hasDate: 1;
70 int priority; 70 int priority;
71 QString desc; 71 QString desc;
72 QString sum; 72 QString sum;
73 QMap<QString, QString> extra; 73 QMap<QString, QString> extra;
74 ushort prog; 74 ushort prog;
75 OPimState *state; 75 OPimState *state;
76 OPimRecurrence *recur; 76 OPimRecurrence *recur;
77 OPimMaintainer *maintainer; 77 OPimMaintainer *maintainer;
78 QDate start; 78 QDate start;
79 QDate completed; 79 QDate completed;
80 OPimNotifyManager *notifiers; 80 OPimNotifyManager *notifiers;
81}; 81};
82 82
83 83
84OPimTodo::OPimTodo( const OPimTodo &event ) 84OPimTodo::OPimTodo( const OPimTodo &event )
85 : OPimRecord( event ), data( event.data ) 85 : OPimRecord( event ), data( event.data )
86{ 86{
87 data->ref(); 87 data->ref();
88 // qWarning("ref up"); 88 // qWarning("ref up");
89} 89}
90 90
91 91
92OPimTodo::~OPimTodo() 92OPimTodo::~OPimTodo()
93{ 93{
94 94
95 // qWarning("~OPimTodo " ); 95 // qWarning("~OPimTodo " );
96 if ( data->deref() ) 96 if ( data->deref() )
97 { 97 {
98 // qWarning("OPimTodo::dereffing"); 98 // qWarning("OPimTodo::dereffing");
99 delete data; 99 delete data;
100 data = 0l; 100 data = 0l;
101 } 101 }
102} 102}
103 103
104 104
105OPimTodo::OPimTodo( bool completed, int priority, 105OPimTodo::OPimTodo( bool completed, int priority,
106 const QArray<int> &category, 106 const QArray<int> &category,
107 const QString& summary, 107 const QString& summary,
108 const QString &description, 108 const QString &description,
109 ushort progress, 109 ushort progress,
110 bool hasDate, QDate date, int uid ) 110 bool hasDate, QDate date, int uid )
111 : OPimRecord( uid ) 111 : OPimRecord( uid )
112{ 112{
113 // qWarning("OPimTodoData " + summary); 113 // qWarning("OPimTodoData " + summary);
114 setCategories( category ); 114 setCategories( category );
115 115
116 data = new OPimTodoData; 116 data = new OPimTodoData;
117 117
118 data->date = date; 118 data->date = date;
119 data->isCompleted = completed; 119 data->isCompleted = completed;
120 data->hasDate = hasDate; 120 data->hasDate = hasDate;
121 data->priority = priority; 121 data->priority = priority;
122 data->sum = summary; 122 data->sum = summary;
123 data->prog = progress; 123 data->prog = progress;
124 data->desc = Qtopia::simplifyMultiLineSpace( description ); 124 data->desc = Qtopia::simplifyMultiLineSpace( description );
125} 125}
126 126
127 127
128OPimTodo::OPimTodo( bool completed, int priority, 128OPimTodo::OPimTodo( bool completed, int priority,
129 const QStringList &category, 129 const QStringList &category,
130 const QString& summary, 130 const QString& summary,
131 const QString &description, 131 const QString &description,
132 ushort progress, 132 ushort progress,
133 bool hasDate, QDate date, int uid ) 133 bool hasDate, QDate date, int uid )
134 : OPimRecord( uid ) 134 : OPimRecord( uid )
135{ 135{
136 // qWarning("OPimTodoData" + summary); 136 // qWarning("OPimTodoData" + summary);
137 setCategories( idsFromString( category.join( ";" ) ) ); 137 setCategories( idsFromString( category.join( ";" ) ) );
138 138
139 data = new OPimTodoData; 139 data = new OPimTodoData;
140 140
141 data->date = date; 141 data->date = date;
142 data->isCompleted = completed; 142 data->isCompleted = completed;
143 data->hasDate = hasDate; 143 data->hasDate = hasDate;
144 data->priority = priority; 144 data->priority = priority;
145 data->sum = summary; 145 data->sum = summary;
146 data->prog = progress; 146 data->prog = progress;
147 data->desc = Qtopia::simplifyMultiLineSpace( description ); 147 data->desc = Qtopia::simplifyMultiLineSpace( description );
148} 148}
149 149
150 150
151bool OPimTodo::match( const QRegExp &regExp ) const 151bool OPimTodo::match( const QRegExp &regExp ) const
152{ 152{
153 if ( QString::number( data->priority ).find( regExp ) != -1 ) 153 if ( QString::number( data->priority ).find( regExp ) != -1 )
154 { 154 {
155 setLastHitField( Priority ); 155 setLastHitField( Priority );
156 return true; 156 return true;
157 } 157 }
158 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) 158 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
159 { 159 {
160 setLastHitField( HasDate ); 160 setLastHitField( HasDate );
161 return true; 161 return true;
162 } 162 }
163 else if ( data->desc.find( regExp ) != -1 ) 163 else if ( data->desc.find( regExp ) != -1 )
164 { 164 {
165 setLastHitField( Description ); 165 setLastHitField( Description );
166 return true; 166 return true;
167 } 167 }
168 else if ( data->sum.find( regExp ) != -1 ) 168 else if ( data->sum.find( regExp ) != -1 )
169 { 169 {
170 setLastHitField( Summary ); 170 setLastHitField( Summary );
171 return true; 171 return true;
172 } 172 }
173 return false; 173 return false;
174} 174}
175 175
176 176
177bool OPimTodo::isCompleted() const 177bool OPimTodo::isCompleted() const
178{ 178{
179 return data->isCompleted; 179 return data->isCompleted;
180} 180}
181 181
182 182
183bool OPimTodo::hasDueDate() const 183bool OPimTodo::hasDueDate() const
184{ 184{
185 return data->hasDate; 185 return data->hasDate;
186} 186}
187 187
188 188
189bool OPimTodo::hasStartDate() const 189bool OPimTodo::hasStartDate() const
190{ 190{
191 return data->start.isValid(); 191 return data->start.isValid();
192} 192}
193 193
194 194
195bool OPimTodo::hasCompletedDate() const 195bool OPimTodo::hasCompletedDate() const
196{ 196{
197 return data->completed.isValid(); 197 return data->completed.isValid();
198} 198}
199 199
200 200
201int OPimTodo::priority() const 201int OPimTodo::priority() const
202{ 202{
203 return data->priority; 203 return data->priority;
204} 204}
205 205
206 206
207QString OPimTodo::summary() const 207QString OPimTodo::summary() const
208{ 208{
209 return data->sum; 209 return data->sum;
210} 210}
211 211
212 212
213ushort OPimTodo::progress() const 213ushort OPimTodo::progress() const
214{ 214{
215 return data->prog; 215 return data->prog;
216} 216}
217 217
218 218
219QDate OPimTodo::dueDate() const 219QDate OPimTodo::dueDate() const
220{ 220{
221 return data->date; 221 return data->date;
222} 222}
223 223
224 224
225QDate OPimTodo::startDate() const 225QDate OPimTodo::startDate() const
226{ 226{
227 return data->start; 227 return data->start;
228} 228}
229 229
230 230
231QDate OPimTodo::completedDate() const 231QDate OPimTodo::completedDate() const
232{ 232{
233 return data->completed; 233 return data->completed;
234} 234}
235 235
236 236
237QString OPimTodo::description() const 237QString OPimTodo::description() const
238{ 238{
239 return data->desc; 239 return data->desc;
240} 240}
241 241
242 242
243bool OPimTodo::hasState() const 243bool OPimTodo::hasState() const
244{ 244{
245 if ( !data->state ) return false; 245 if ( !data->state ) return false;
246 return ( data->state->state() != OPimState::Undefined ); 246 return ( data->state->state() != OPimState::Undefined );
247} 247}
248 248
249 249
250OPimState OPimTodo::state() const 250OPimState OPimTodo::state() const
251{ 251{
252 if ( !data->state ) 252 if ( !data->state )
253 { 253 {
254 OPimState state; 254 OPimState state;
255 return state; 255 return state;
256 } 256 }
257 257
258 return ( *data->state ); 258 return ( *data->state );
259} 259}
260 260
261 261
262bool OPimTodo::hasRecurrence() const 262bool OPimTodo::hasRecurrence() const
263{ 263{
264 if ( !data->recur ) return false; 264 if ( !data->recur ) return false;
265 return data->recur->doesRecur(); 265 return data->recur->doesRecur();
266} 266}
267 267
268 268
269OPimRecurrence OPimTodo::recurrence() const 269OPimRecurrence OPimTodo::recurrence() const
270{ 270{
271 if ( !data->recur ) return OPimRecurrence(); 271 if ( !data->recur ) return OPimRecurrence();
272 272
273 return ( *data->recur ); 273 return ( *data->recur );
274} 274}
275 275
276 276
277bool OPimTodo::hasMaintainer() const 277bool OPimTodo::hasMaintainer() const
278{ 278{
279 if ( !data->maintainer ) return false; 279 if ( !data->maintainer ) return false;
280 280
281 return ( data->maintainer->mode() != OPimMaintainer::Undefined ); 281 return ( data->maintainer->mode() != OPimMaintainer::Undefined );
282} 282}
283 283
284 284
285OPimMaintainer OPimTodo::maintainer() const 285OPimMaintainer OPimTodo::maintainer() const
286{ 286{
287 if ( !data->maintainer ) return OPimMaintainer(); 287 if ( !data->maintainer ) return OPimMaintainer();
288 288
289 return ( *data->maintainer ); 289 return ( *data->maintainer );
290} 290}
291 291
292 292
293void OPimTodo::setCompleted( bool completed ) 293void OPimTodo::setCompleted( bool completed )
294{ 294{
295 changeOrModify(); 295 changeOrModify();
296 data->isCompleted = completed; 296 data->isCompleted = completed;
297} 297}
298 298
299 299
300void OPimTodo::setHasDueDate( bool hasDate ) 300void OPimTodo::setHasDueDate( bool hasDate )
301{ 301{
302 changeOrModify(); 302 changeOrModify();
303 data->hasDate = hasDate; 303 data->hasDate = hasDate;
304} 304}
305 305
306 306
307void OPimTodo::setDescription( const QString &desc ) 307void OPimTodo::setDescription( const QString &desc )
308{ 308{
309 // qWarning( "desc " + desc ); 309 // qWarning( "desc " + desc );
310 changeOrModify(); 310 changeOrModify();
311 data->desc = Qtopia::simplifyMultiLineSpace( desc ); 311 data->desc = Qtopia::simplifyMultiLineSpace( desc );
312} 312}
313 313
314 314
315void OPimTodo::setSummary( const QString& sum ) 315void OPimTodo::setSummary( const QString& sum )
316{ 316{
317 changeOrModify(); 317 changeOrModify();
318 data->sum = sum; 318 data->sum = sum;
319} 319}
320 320
321 321
322void OPimTodo::setPriority( int prio ) 322void OPimTodo::setPriority( int prio )
323{ 323{
324 changeOrModify(); 324 changeOrModify();
325 data->priority = prio; 325 data->priority = prio;
326} 326}
327 327
328 328
329void OPimTodo::setDueDate( const QDate& date ) 329void OPimTodo::setDueDate( const QDate& date )
330{ 330{
331 changeOrModify(); 331 changeOrModify();
332 data->date = date; 332 data->date = date;
333} 333}
334 334
335 335
336void OPimTodo::setStartDate( const QDate& date ) 336void OPimTodo::setStartDate( const QDate& date )
337{ 337{
338 changeOrModify(); 338 changeOrModify();
339 data->start = date; 339 data->start = date;
340} 340}
341 341
342 342
343void OPimTodo::setCompletedDate( const QDate& date ) 343void OPimTodo::setCompletedDate( const QDate& date )
344{ 344{
345 changeOrModify(); 345 changeOrModify();
346 data->completed = date; 346 data->completed = date;
347} 347}
348 348
349 349
350void OPimTodo::setState( const OPimState& state ) 350void OPimTodo::setState( const OPimState& state )
351{ 351{
352 changeOrModify(); 352 changeOrModify();
353 if ( data->state ) 353 if ( data->state )
354 ( *data->state ) = state; 354 ( *data->state ) = state;
355 else 355 else
356 data->state = new OPimState( state ); 356 data->state = new OPimState( state );
357} 357}
358 358
359 359
360void OPimTodo::setRecurrence( const OPimRecurrence& rec ) 360void OPimTodo::setRecurrence( const OPimRecurrence& rec )
361{ 361{
362 changeOrModify(); 362 changeOrModify();
363 if ( data->recur ) 363 if ( data->recur )
364 ( *data->recur ) = rec; 364 ( *data->recur ) = rec;
365 else 365 else
366 data->recur = new OPimRecurrence( rec ); 366 data->recur = new OPimRecurrence( rec );
367} 367}
368 368
369 369
370void OPimTodo::setMaintainer( const OPimMaintainer& pim ) 370void OPimTodo::setMaintainer( const OPimMaintainer& pim )
371{ 371{
372 changeOrModify(); 372 changeOrModify();
373 373
374 if ( data->maintainer ) 374 if ( data->maintainer )
375 ( *data->maintainer ) = pim; 375 ( *data->maintainer ) = pim;
376 else 376 else
377 data->maintainer = new OPimMaintainer( pim ); 377 data->maintainer = new OPimMaintainer( pim );
378} 378}
379 379
380 380
381bool OPimTodo::isOverdue( ) 381bool OPimTodo::isOverdue( )
382{ 382{
383 if ( data->hasDate && !data->isCompleted ) 383 if ( data->hasDate && !data->isCompleted )
384 return QDate::currentDate() > data->date; 384 return QDate::currentDate() > data->date;
385 return false; 385 return false;
386} 386}
387 387
388 388
389void OPimTodo::setProgress( ushort progress ) 389void OPimTodo::setProgress( ushort progress )
390{ 390{
391 changeOrModify(); 391 changeOrModify();
392 data->prog = progress; 392 data->prog = progress;
393} 393}
394 394
395 395
396QString OPimTodo::toShortText() const 396QString OPimTodo::toShortText() const
397{ 397{
398 return summary(); 398 return summary();
399} 399}
400 400
401 401
402/*! 402/*!
403 Returns a richt text string 403 Returns a richt text string
404*/ 404*/
405QString OPimTodo::toRichText() const 405QString OPimTodo::toRichText() const
406{ 406{
407 QString text; 407 QString text;
408 QStringList catlist; 408 QStringList catlist;
409 409
410 // summary 410 // summary
411 text += "<b><h3><img src=\"todo/TodoList\"> "; 411 text += "<b><h3><img src=\"todo/TodoList\"> ";
412 if ( !summary().isEmpty() ) 412 if ( !summary().isEmpty() )
413 { 413 {
414 text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); 414 text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" );
415 } 415 }
416 text += "</h3></b><br><hr><br>"; 416 text += "</h3></b><br><hr><br>";
417 417
418 // description 418 // description
419 if ( !description().isEmpty() ) 419 if ( !description().isEmpty() )
420 { 420 {
421 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 421 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
422 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 422 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
423 } 423 }
424 424
425 // priority 425 // priority
426 int priorityval = priority(); 426 int priorityval = priority();
427 text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" + 427 text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" +
428 QString::number( priorityval ) + "\"> "; 428 QString::number( priorityval ) + "\"> ";
429 429
430 switch ( priorityval ) 430 switch ( priorityval )
431 { 431 {
432 case 1 : text += QObject::tr( "Very high" ); 432 case 1 : text += QObject::tr( "Very high" );
433 break; 433 break;
434 case 2 : text += QObject::tr( "High" ); 434 case 2 : text += QObject::tr( "High" );
435 break; 435 break;
436 case 3 : text += QObject::tr( "Normal" ); 436 case 3 : text += QObject::tr( "Normal" );
437 break; 437 break;
438 case 4 : text += QObject::tr( "Low" ); 438 case 4 : text += QObject::tr( "Low" );
439 break; 439 break;
440 case 5 : text += QObject::tr( "Very low" ); 440 case 5 : text += QObject::tr( "Very low" );
441 break; 441 break;
442 }; 442 };
443 text += "<br>"; 443 text += "<br>";
444 444
445 // progress 445 // progress
446 text += "<b>" + QObject::tr( "Progress:" ) + " </b>" 446 text += "<b>" + QObject::tr( "Progress:" ) + " </b>"
447 + QString::number( progress() ) + " %<br>"; 447 + QString::number( progress() ) + " %<br>";
448 448
449 // due date 449 // due date
450 if ( hasDueDate() ) 450 if ( hasDueDate() )
451 { 451 {
452 QDate dd = dueDate(); 452 QDate dd = dueDate();
453 int off = QDate::currentDate().daysTo( dd ); 453 int off = QDate::currentDate().daysTo( dd );
454 454
455 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; 455 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
456 if ( off < 0 ) 456 if ( off < 0 )
457 text += "#FF0000"; 457 text += "#FF0000";
458 else if ( off == 0 ) 458 else if ( off == 0 )
459 text += "#FFFF00"; 459 text += "#FFFF00";
460 else if ( off > 0 ) 460 else if ( off > 0 )
461 text += "#00FF00"; 461 text += "#00FF00";
462 462
463 text += "\">" + dd.toString() + "</font><br>"; 463 text += "\">" + dd.toString() + "</font><br>";
464 } 464 }
465 465
466 // categories 466 // categories
467 text += "<b>" + QObject::tr( "Category:" ) + "</b> "; 467 text += "<b>" + QObject::tr( "Category:" ) + "</b> ";
468 text += categoryNames( "Todo List" ).join( ", " ); 468 text += categoryNames( "Todo List" ).join( ", " );
469 text += "<br>"; 469 text += "<br>";
470 470
471 return text; 471 return text;
472} 472}
473 473
474 474
475bool OPimTodo::hasNotifiers() const 475bool OPimTodo::hasNotifiers() const
476{ 476{
477 if ( !data->notifiers ) return false; 477 if ( !data->notifiers ) return false;
478 return !data->notifiers->isEmpty(); 478 return !data->notifiers->isEmpty();
479} 479}
480 480
481 481
482OPimNotifyManager& OPimTodo::notifiers() 482OPimNotifyManager& OPimTodo::notifiers()
483{ 483{
484 if ( !data->notifiers ) 484 if ( !data->notifiers )
485 data->notifiers = new OPimNotifyManager; 485 data->notifiers = new OPimNotifyManager;
486 return ( *data->notifiers ); 486 return ( *data->notifiers );
487} 487}
488 488
489 489
490const OPimNotifyManager& OPimTodo::notifiers() const 490const OPimNotifyManager& OPimTodo::notifiers() const
491{ 491{
492 if ( !data->notifiers ) 492 if ( !data->notifiers )
493 data->notifiers = new OPimNotifyManager; 493 data->notifiers = new OPimNotifyManager;
494 494
495 return ( *data->notifiers ); 495 return ( *data->notifiers );
496} 496}
497 497
498 498
499bool OPimTodo::operator<( const OPimTodo &toDoEvent ) const 499bool OPimTodo::operator<( const OPimTodo &toDoEvent ) const
500{ 500{
501 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 501 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
502 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 502 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
503 if ( hasDueDate() && toDoEvent.hasDueDate() ) 503 if ( hasDueDate() && toDoEvent.hasDueDate() )
504 { 504 {
505 if ( dueDate() == toDoEvent.dueDate() ) 505 if ( dueDate() == toDoEvent.dueDate() )
506 { // let's the priority decide 506 { // let's the priority decide
507 return priority() < toDoEvent.priority(); 507 return priority() < toDoEvent.priority();
508 } 508 }
509 else 509 else
510 { 510 {
511 return dueDate() < toDoEvent.dueDate(); 511 return dueDate() < toDoEvent.dueDate();
512 } 512 }
513 } 513 }
514 return false; 514 return false;
515} 515}
516 516
517 517
518bool OPimTodo::operator<=( const OPimTodo &toDoEvent ) const 518bool OPimTodo::operator<=( const OPimTodo &toDoEvent ) const
519{ 519{
520 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 520 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
521 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 521 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
522 if ( hasDueDate() && toDoEvent.hasDueDate() ) 522 if ( hasDueDate() && toDoEvent.hasDueDate() )
523 { 523 {
524 if ( dueDate() == toDoEvent.dueDate() ) 524 if ( dueDate() == toDoEvent.dueDate() )
525 { // let's the priority decide 525 { // let's the priority decide
526 return priority() <= toDoEvent.priority(); 526 return priority() <= toDoEvent.priority();
527 } 527 }
528 else 528 else
529 { 529 {
530 return dueDate() <= toDoEvent.dueDate(); 530 return dueDate() <= toDoEvent.dueDate();
531 } 531 }
532 } 532 }
533 return true; 533 return true;
534} 534}
535 535
536 536
537bool OPimTodo::operator>( const OPimTodo &toDoEvent ) const 537bool OPimTodo::operator>( const OPimTodo &toDoEvent ) const
538{ 538{
539 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 539 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
540 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 540 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
541 if ( hasDueDate() && toDoEvent.hasDueDate() ) 541 if ( hasDueDate() && toDoEvent.hasDueDate() )
542 { 542 {
543 if ( dueDate() == toDoEvent.dueDate() ) 543 if ( dueDate() == toDoEvent.dueDate() )
544 { // let's the priority decide 544 { // let's the priority decide
545 return priority() > toDoEvent.priority(); 545 return priority() > toDoEvent.priority();
546 } 546 }
547 else 547 else
548 { 548 {
549 return dueDate() > toDoEvent.dueDate(); 549 return dueDate() > toDoEvent.dueDate();
550 } 550 }
551 } 551 }
552 return false; 552 return false;
553} 553}
554 554
555 555
556bool OPimTodo::operator>=( const OPimTodo &toDoEvent ) const 556bool OPimTodo::operator>=( const OPimTodo &toDoEvent ) const
557{ 557{
558 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 558 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
559 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 559 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
560 if ( hasDueDate() && toDoEvent.hasDueDate() ) 560 if ( hasDueDate() && toDoEvent.hasDueDate() )
561 { 561 {
562 if ( dueDate() == toDoEvent.dueDate() ) 562 if ( dueDate() == toDoEvent.dueDate() )
563 { // let's the priority decide 563 { // let's the priority decide
564 return priority() > toDoEvent.priority(); 564 return priority() > toDoEvent.priority();
565 } 565 }
566 else 566 else
567 { 567 {
568 return dueDate() > toDoEvent.dueDate(); 568 return dueDate() > toDoEvent.dueDate();
569 } 569 }
570 } 570 }
571 return true; 571 return true;
572} 572}
573 573
574 574
575bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const 575bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const
576{ 576{
577 if ( data->priority != toDoEvent.data->priority ) return false; 577 if ( data->priority != toDoEvent.data->priority ) return false;
578 if ( data->priority != toDoEvent.data->prog ) return false; 578 if ( data->priority != toDoEvent.data->prog ) return false;
579 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 579 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
580 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 580 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
581 if ( data->date != toDoEvent.data->date ) return false; 581 if ( data->date != toDoEvent.data->date ) return false;
582 if ( data->sum != toDoEvent.data->sum ) return false; 582 if ( data->sum != toDoEvent.data->sum ) return false;
583 if ( data->desc != toDoEvent.data->desc ) return false; 583 if ( data->desc != toDoEvent.data->desc ) return false;
584 if ( data->maintainer != toDoEvent.data->maintainer ) 584 if ( data->maintainer != toDoEvent.data->maintainer )
585 return false; 585 return false;
586 586
587 return OPimRecord::operator==( toDoEvent ); 587 return OPimRecord::operator==( toDoEvent );
588} 588}
589 589
590 590
591void OPimTodo::deref() 591void OPimTodo::deref()
592{ 592{
593 593
594 // qWarning("deref in ToDoEvent"); 594 // qWarning("deref in ToDoEvent");
595 if ( data->deref() ) 595 if ( data->deref() )
596 { 596 {
597 // qWarning("deleting"); 597 // qWarning("deleting");
598 delete data; 598 delete data;
599 data = 0; 599 data = 0;
600 } 600 }
601} 601}
602 602
603 603
604OPimTodo &OPimTodo::operator=( const OPimTodo &item ) 604OPimTodo &OPimTodo::operator=( const OPimTodo &item )
605{ 605{
606 if ( this == &item ) return * this; 606 if ( this == &item ) return * this;
607 607
608 OPimRecord::operator=( item ); 608 OPimRecord::operator=( item );
609 //qWarning("operator= ref "); 609 //qWarning("operator= ref ");
610 item.data->ref(); 610 item.data->ref();
611 deref(); 611 deref();
612 data = item.data; 612 data = item.data;
613 613
614 return *this; 614 return *this;
615} 615}
616 616
617 617
618QMap<int, QString> OPimTodo::toMap() const 618QMap<int, QString> OPimTodo::toMap() const
619{ 619{
620 QMap<int, QString> map; 620 QMap<int, QString> map;
621 621
622 map.insert( Uid, QString::number( uid() ) ); 622 map.insert( Uid, QString::number( uid() ) );
623 map.insert( Category, idsToString( categories() ) ); 623 map.insert( Category, idsToString( categories() ) );
624 map.insert( HasDate, QString::number( data->hasDate ) ); 624 map.insert( HasDate, QString::number( data->hasDate ) );
625 map.insert( Completed, QString::number( data->isCompleted ) ); 625 map.insert( Completed, QString::number( data->isCompleted ) );
626 map.insert( Description, data->desc ); 626 map.insert( Description, data->desc );
627 map.insert( Summary, data->sum ); 627 map.insert( Summary, data->sum );
628 map.insert( Priority, QString::number( data->priority ) ); 628 map.insert( Priority, QString::number( data->priority ) );
629 map.insert( DateDay, QString::number( data->date.day() ) ); 629 map.insert( DateDay, QString::number( data->date.day() ) );
630 map.insert( DateMonth, QString::number( data->date.month() ) ); 630 map.insert( DateMonth, QString::number( data->date.month() ) );
631 map.insert( DateYear, QString::number( data->date.year() ) ); 631 map.insert( DateYear, QString::number( data->date.year() ) );
632 map.insert( Progress, QString::number( data->prog ) ); 632 map.insert( Progress, QString::number( data->prog ) );
633 // map.insert( CrossReference, crossToString() ); 633 // map.insert( CrossReference, crossToString() );
634 /* FIXME!!! map.insert( State, ); 634 /* FIXME!!! map.insert( State, );
635 map.insert( Recurrence, ); 635 map.insert( Recurrence, );
636 map.insert( Reminders, ); 636 map.insert( Reminders, );
637 map. 637 map.
638 */ 638 */
639 return map; 639 return map;
640} 640}
641 641
642 642
643/** 643/**
644 * change or modify looks at the ref count and either 644 * change or modify looks at the ref count and either
645 * creates a new QShared Object or it can modify it 645 * creates a new QShared Object or it can modify it
646 * right in place 646 * right in place
647 */ 647 */
648void OPimTodo::changeOrModify() 648void OPimTodo::changeOrModify()
649{ 649{
650 if ( data->count != 1 ) 650 if ( data->count != 1 )
651 { 651 {
652 qWarning( "changeOrModify" ); 652 qWarning( "changeOrModify" );
653 data->deref(); 653 data->deref();
654 OPimTodoData* d2 = new OPimTodoData(); 654 OPimTodoData* d2 = new OPimTodoData();
655 copy( data, d2 ); 655 copy( data, d2 );
656 data = d2; 656 data = d2;
657 } 657 }
658} 658}
659 659
660 660
661// WATCHOUT 661// WATCHOUT
662/* 662/*
663 * if you add something to the Data struct 663 * if you add something to the Data struct
664 * be sure to copy it here 664 * be sure to copy it here
665 */ 665 */
666void OPimTodo::copy( OPimTodoData* src, OPimTodoData* dest ) 666void OPimTodo::copy( OPimTodoData* src, OPimTodoData* dest )
667{ 667{
668 dest->date = src->date; 668 dest->date = src->date;
669 dest->isCompleted = src->isCompleted; 669 dest->isCompleted = src->isCompleted;
670 dest->hasDate = src->hasDate; 670 dest->hasDate = src->hasDate;
671 dest->priority = src->priority; 671 dest->priority = src->priority;
672 dest->desc = src->desc; 672 dest->desc = src->desc;
673 dest->sum = src->sum; 673 dest->sum = src->sum;
674 dest->extra = src->extra; 674 dest->extra = src->extra;
675 dest->prog = src->prog; 675 dest->prog = src->prog;
676 676
677 if ( src->state ) 677 if ( src->state )
678 dest->state = new OPimState( *src->state ); 678 dest->state = new OPimState( *src->state );
679 679
680 if ( src->recur ) 680 if ( src->recur )
681 dest->recur = new OPimRecurrence( *src->recur ); 681 dest->recur = new OPimRecurrence( *src->recur );
682 682
683 if ( src->maintainer ) 683 if ( src->maintainer )
684 dest->maintainer = new OPimMaintainer( *src->maintainer ) 684 dest->maintainer = new OPimMaintainer( *src->maintainer )
685 ; 685 ;
686 dest->start = src->start; 686 dest->start = src->start;
687 dest->completed = src->completed; 687 dest->completed = src->completed;
688 688
689 if ( src->notifiers ) 689 if ( src->notifiers )
690 dest->notifiers = new OPimNotifyManager( *src->notifiers ); 690 dest->notifiers = new OPimNotifyManager( *src->notifiers );
691} 691}
692 692
693 693
694QString OPimTodo::type() const 694QString OPimTodo::type() const
695{ 695{
696 return QString::fromLatin1( "OPimTodo" ); 696 return QString::fromLatin1( "OPimTodo" );
697} 697}
698 698
699 699
700QString OPimTodo::recordField( int /*id*/ ) const 700QString OPimTodo::recordField( int /*id*/ ) const
701{ 701{
702 return QString::null; 702 return QString::null;
703} 703}
704 704
705 705
706int OPimTodo::rtti() 706int OPimTodo::rtti() const
707{ 707{
708 return OPimResolver::TodoList; 708 return OPimResolver::TodoList;
709} 709}
710 710
711} 711}
diff --git a/libopie2/opiepim/core/opimtodo.h b/libopie2/opiepim/core/opimtodo.h
index 5304180..e17fe6a 100644
--- a/libopie2/opiepim/core/opimtodo.h
+++ b/libopie2/opiepim/core/opimtodo.h
@@ -1,320 +1,320 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
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 29
30#ifndef OTODOEVENT_H 30#ifndef OTODOEVENT_H
31#define OTODOEVENT_H 31#define OTODOEVENT_H
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/opimrecord.h> 34#include <opie2/opimrecord.h>
35#include <qpe/recordfields.h> 35#include <qpe/recordfields.h>
36#include <qpe/palmtopuidgen.h> 36#include <qpe/palmtopuidgen.h>
37 37
38/* QT */ 38/* QT */
39#include <qarray.h> 39#include <qarray.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qregexp.h> 41#include <qregexp.h>
42#include <qstringlist.h> 42#include <qstringlist.h>
43#include <qdatetime.h> 43#include <qdatetime.h>
44#include <qvaluelist.h> 44#include <qvaluelist.h>
45 45
46namespace Opie 46namespace Opie
47{ 47{
48 48
49class OPimState; 49class OPimState;
50class OPimRecurrence; 50class OPimRecurrence;
51class OPimMaintainer; 51class OPimMaintainer;
52class OPimNotifyManager; 52class OPimNotifyManager;
53class OPimTodo : public OPimRecord 53class OPimTodo : public OPimRecord
54{ 54{
55 public: 55 public:
56 typedef QValueList<OPimTodo> ValueList; 56 typedef QValueList<OPimTodo> ValueList;
57 enum RecordFields { 57 enum RecordFields {
58 Uid = Qtopia::UID_ID, 58 Uid = Qtopia::UID_ID,
59 Category = Qtopia::CATEGORY_ID, 59 Category = Qtopia::CATEGORY_ID,
60 HasDate, 60 HasDate,
61 Completed, 61 Completed,
62 Description, 62 Description,
63 Summary, 63 Summary,
64 Priority, 64 Priority,
65 DateDay, 65 DateDay,
66 DateMonth, 66 DateMonth,
67 DateYear, 67 DateYear,
68 Progress, 68 Progress,
69 CrossReference, 69 CrossReference,
70 State, 70 State,
71 Recurrence, 71 Recurrence,
72 Alarms, 72 Alarms,
73 Reminders, 73 Reminders,
74 Notifiers, 74 Notifiers,
75 Maintainer, 75 Maintainer,
76 StartDate, 76 StartDate,
77 CompletedDate 77 CompletedDate
78 }; 78 };
79 public: 79 public:
80 // priorities from Very low to very high 80 // priorities from Very low to very high
81 enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow }; 81 enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow };
82 82
83 /* Constructs a new ToDoEvent 83 /* Constructs a new ToDoEvent
84 @param completed Is the TodoEvent completed 84 @param completed Is the TodoEvent completed
85 @param priority What is the priority of this ToDoEvent 85 @param priority What is the priority of this ToDoEvent
86 @param category Which category does it belong( uid ) 86 @param category Which category does it belong( uid )
87 @param summary A small summary of the todo 87 @param summary A small summary of the todo
88 @param description What is this ToDoEvent about 88 @param description What is this ToDoEvent about
89 @param hasDate Does this Event got a deadline 89 @param hasDate Does this Event got a deadline
90 @param date what is the deadline? 90 @param date what is the deadline?
91 @param uid what is the UUID of this Event 91 @param uid what is the UUID of this Event
92 **/ 92 **/
93 OPimTodo( bool completed = false, int priority = Normal, 93 OPimTodo( bool completed = false, int priority = Normal,
94 const QStringList &category = QStringList(), 94 const QStringList &category = QStringList(),
95 const QString &summary = QString::null , 95 const QString &summary = QString::null ,
96 const QString &description = QString::null, 96 const QString &description = QString::null,
97 ushort progress = 0, 97 ushort progress = 0,
98 bool hasDate = false, QDate date = QDate::currentDate(), 98 bool hasDate = false, QDate date = QDate::currentDate(),
99 int uid = 0 /*empty*/ ); 99 int uid = 0 /*empty*/ );
100 100
101 OPimTodo( bool completed, int priority, 101 OPimTodo( bool completed, int priority,
102 const QArray<int>& category, 102 const QArray<int>& category,
103 const QString& summary = QString::null, 103 const QString& summary = QString::null,
104 const QString& description = QString::null, 104 const QString& description = QString::null,
105 ushort progress = 0, 105 ushort progress = 0,
106 bool hasDate = false, QDate date = QDate::currentDate(), 106 bool hasDate = false, QDate date = QDate::currentDate(),
107 int uid = 0 /* empty */ ); 107 int uid = 0 /* empty */ );
108 108
109 /** Copy c'tor 109 /** Copy c'tor
110 * 110 *
111 */ 111 */
112 OPimTodo( const OPimTodo & ); 112 OPimTodo( const OPimTodo & );
113 113
114 /** 114 /**
115 *destructor 115 *destructor
116 */ 116 */
117 ~OPimTodo(); 117 ~OPimTodo();
118 118
119 /** 119 /**
120 * Is this event completed? 120 * Is this event completed?
121 */ 121 */
122 bool isCompleted() const; 122 bool isCompleted() const;
123 123
124 /** 124 /**
125 * Does this Event have a deadline 125 * Does this Event have a deadline
126 */ 126 */
127 bool hasDueDate() const; 127 bool hasDueDate() const;
128 bool hasStartDate() const; 128 bool hasStartDate() const;
129 bool hasCompletedDate() const; 129 bool hasCompletedDate() const;
130 130
131 /** 131 /**
132 * What is the priority? 132 * What is the priority?
133 */ 133 */
134 int priority() const ; 134 int priority() const ;
135 135
136 /** 136 /**
137 * progress as ushort 0, 20, 40, 60, 80 or 100% 137 * progress as ushort 0, 20, 40, 60, 80 or 100%
138 */ 138 */
139 ushort progress() const; 139 ushort progress() const;
140 140
141 /** 141 /**
142 * The due Date 142 * The due Date
143 */ 143 */
144 QDate dueDate() const; 144 QDate dueDate() const;
145 145
146 /** 146 /**
147 * When did it start? 147 * When did it start?
148 */ 148 */
149 QDate startDate() const; 149 QDate startDate() const;
150 150
151 /** 151 /**
152 * When was it completed? 152 * When was it completed?
153 */ 153 */
154 QDate completedDate() const; 154 QDate completedDate() const;
155 155
156 /** 156 /**
157 * does it have a state? 157 * does it have a state?
158 */ 158 */
159 bool hasState() const; 159 bool hasState() const;
160 160
161 /** 161 /**
162 * What is the state of this OPimTodo? 162 * What is the state of this OPimTodo?
163 */ 163 */
164 OPimState state() const; 164 OPimState state() const;
165 165
166 /** 166 /**
167 * has recurrence? 167 * has recurrence?
168 */ 168 */
169 bool hasRecurrence() const; 169 bool hasRecurrence() const;
170 170
171 /** 171 /**
172 * the recurrance of this 172 * the recurrance of this
173 */ 173 */
174 OPimRecurrence recurrence() const; 174 OPimRecurrence recurrence() const;
175 175
176 /** 176 /**
177 * does this OPimTodo have a maintainer? 177 * does this OPimTodo have a maintainer?
178 */ 178 */
179 bool hasMaintainer() const; 179 bool hasMaintainer() const;
180 180
181 /** 181 /**
182 * the Maintainer of this OPimTodo 182 * the Maintainer of this OPimTodo
183 */ 183 */
184 OPimMaintainer maintainer() const; 184 OPimMaintainer maintainer() const;
185 185
186 /** 186 /**
187 * The description of the todo 187 * The description of the todo
188 */ 188 */
189 QString description() const; 189 QString description() const;
190 190
191 /** 191 /**
192 * A small summary of the todo 192 * A small summary of the todo
193 */ 193 */
194 QString summary() const; 194 QString summary() const;
195 195
196 /** 196 /**
197 * @reimplemented 197 * @reimplemented
198 * Return this todoevent in a RichText formatted QString 198 * Return this todoevent in a RichText formatted QString
199 */ 199 */
200 QString toRichText() const; 200 QString toRichText() const;
201 201
202 bool hasNotifiers() const; 202 bool hasNotifiers() const;
203 /* 203 /*
204 * FIXME check if the sharing is still fine!! -zecke 204 * FIXME check if the sharing is still fine!! -zecke
205 * ### CHECK If API is fine 205 * ### CHECK If API is fine
206 */ 206 */
207 /** 207 /**
208 * return a reference to our notifiers... 208 * return a reference to our notifiers...
209 */ 209 */
210 OPimNotifyManager &notifiers(); 210 OPimNotifyManager &notifiers();
211 211
212 /** 212 /**
213 * 213 *
214 */ 214 */
215 const OPimNotifyManager &notifiers() const; 215 const OPimNotifyManager &notifiers() const;
216 216
217 /** 217 /**
218 * reimplementations 218 * reimplementations
219 */ 219 */
220 QString type() const; 220 QString type() const;
221 QString toShortText() const; 221 QString toShortText() const;
222 QString recordField( int id ) const; 222 QString recordField( int id ) const;
223 223
224 /** 224 /**
225 * toMap puts all data into the map. int relates 225 * toMap puts all data into the map. int relates
226 * to ToDoEvent RecordFields enum 226 * to ToDoEvent RecordFields enum
227 */ 227 */
228 QMap<int, QString> toMap() const; 228 QMap<int, QString> toMap() const;
229 229
230 /** 230 /**
231 * Set if this Todo is completed 231 * Set if this Todo is completed
232 */ 232 */
233 void setCompleted( bool completed ); 233 void setCompleted( bool completed );
234 234
235 /** 235 /**
236 * set if this todo got an end data 236 * set if this todo got an end data
237 */ 237 */
238 void setHasDueDate( bool hasDate ); 238 void setHasDueDate( bool hasDate );
239 // FIXME we do not have these for start, completed 239 // FIXME we do not have these for start, completed
240 // cause we'll use the isNull() of QDate for figuring 240 // cause we'll use the isNull() of QDate for figuring
241 // out if it's has a date... 241 // out if it's has a date...
242 // decide what to do here? -zecke 242 // decide what to do here? -zecke
243 243
244 /** 244 /**
245 * Set the priority of the Todo 245 * Set the priority of the Todo
246 */ 246 */
247 void setPriority( int priority ); 247 void setPriority( int priority );
248 248
249 /** 249 /**
250 * Set the progress. 250 * Set the progress.
251 */ 251 */
252 void setProgress( ushort progress ); 252 void setProgress( ushort progress );
253 253
254 /** 254 /**
255 * set the end date 255 * set the end date
256 */ 256 */
257 void setDueDate( const QDate& date ); 257 void setDueDate( const QDate& date );
258 258
259 /** 259 /**
260 * set the start date 260 * set the start date
261 */ 261 */
262 void setStartDate( const QDate& date ); 262 void setStartDate( const QDate& date );
263 263
264 /** 264 /**
265 * set the completed date 265 * set the completed date
266 */ 266 */
267 void setCompletedDate( const QDate& date ); 267 void setCompletedDate( const QDate& date );
268 268
269 void setRecurrence( const OPimRecurrence& ); 269 void setRecurrence( const OPimRecurrence& );
270 270
271 void setDescription( const QString& ); 271 void setDescription( const QString& );
272 void setSummary( const QString& ); 272 void setSummary( const QString& );
273 273
274 /** 274 /**
275 * set the state of a Todo 275 * set the state of a Todo
276 * @param state State what the todo should take 276 * @param state State what the todo should take
277 */ 277 */
278 void setState( const OPimState& state ); 278 void setState( const OPimState& state );
279 279
280 /** 280 /**
281 * set the Maintainer Mode 281 * set the Maintainer Mode
282 */ 282 */
283 void setMaintainer( const OPimMaintainer& ); 283 void setMaintainer( const OPimMaintainer& );
284 284
285 bool isOverdue(); 285 bool isOverdue();
286 286
287 287
288 virtual bool match( const QRegExp &r ) const; 288 virtual bool match( const QRegExp &r ) const;
289 289
290 bool operator<( const OPimTodo &toDoEvent ) const; 290 bool operator<( const OPimTodo &toDoEvent ) const;
291 bool operator<=( const OPimTodo &toDoEvent ) const; 291 bool operator<=( const OPimTodo &toDoEvent ) const;
292 bool operator!=( const OPimTodo &toDoEvent ) const; 292 bool operator!=( const OPimTodo &toDoEvent ) const;
293 bool operator>( const OPimTodo &toDoEvent ) const; 293 bool operator>( const OPimTodo &toDoEvent ) const;
294 bool operator>=( const OPimTodo &toDoEvent ) const; 294 bool operator>=( const OPimTodo &toDoEvent ) const;
295 bool operator==( const OPimTodo &toDoEvent ) const; 295 bool operator==( const OPimTodo &toDoEvent ) const;
296 OPimTodo &operator=( const OPimTodo &toDoEvent ); 296 OPimTodo &operator=( const OPimTodo &toDoEvent );
297 297
298 static int rtti(); 298 int rtti() const;
299 299
300 private: 300 private:
301 class OPimTodoPrivate; 301 class OPimTodoPrivate;
302 struct OPimTodoData; 302 struct OPimTodoData;
303 303
304 void deref(); 304 void deref();
305 inline void changeOrModify(); 305 inline void changeOrModify();
306 void copy( OPimTodoData* src, OPimTodoData* dest ); 306 void copy( OPimTodoData* src, OPimTodoData* dest );
307 OPimTodoPrivate *d; 307 OPimTodoPrivate *d;
308 OPimTodoData *data; 308 OPimTodoData *data;
309 309
310}; 310};
311 311
312 312
313inline bool OPimTodo::operator!=( const OPimTodo &toDoEvent ) const 313inline bool OPimTodo::operator!=( const OPimTodo &toDoEvent ) const
314{ 314{
315 return !( *this == toDoEvent ); 315 return !( *this == toDoEvent );
316} 316}
317 317
318} 318}
319 319
320#endif 320#endif