summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactfields.cpp233
-rw-r--r--libopie/pim/ocontactfields.h7
-rw-r--r--libopie/pim/opimnotifymanager.cpp72
-rw-r--r--libopie/pim/opimnotifymanager.h24
-rw-r--r--libopie/pim/otodoaccesssql.cpp52
-rw-r--r--libopie/pim/otodoaccesssql.h2
-rw-r--r--libopie/pim/otodoaccessxml.cpp2
7 files changed, 260 insertions, 132 deletions
diff --git a/libopie/pim/ocontactfields.cpp b/libopie/pim/ocontactfields.cpp
index 7206f0d..0f08a5a 100644
--- a/libopie/pim/ocontactfields.cpp
+++ b/libopie/pim/ocontactfields.cpp
@@ -1,236 +1,245 @@
1 1
2#include "ocontactfields.h" 2#include "ocontactfields.h"
3 3
4#include <qstringlist.h> 4#include <qstringlist.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7// We should use our own enum in the future .. 7// We should use our own enum in the future ..
8#include <qpe/recordfields.h> 8#include <qpe/recordfields.h>
9#include <qpe/config.h> 9#include <qpe/config.h>
10#include <opie/ocontact.h> 10#include <opie/ocontact.h>
11 11
12/*! 12/*!
13 \internal 13 \internal
14 Returns a list of details field names for a contact. 14 Returns a list of personal field names for a contact.
15*/ 15*/
16QStringList OContactFields::untrdetailsfields( bool sorted ) 16QStringList OContactFields::personalfields( bool sorted, bool translated )
17{ 17{
18 QStringList list; 18 QStringList list;
19 QMap<int, QString> mapIdToStr = idToUntrFields(); 19 QMap<int, QString> mapIdToStr;
20 if ( translated )
21 mapIdToStr = idToTrFields();
22 else
23 mapIdToStr = idToUntrFields();
20 24
21 list.append( mapIdToStr[ Qtopia::Office ] ); 25 list.append( mapIdToStr[ Qtopia::AddressUid ] );
22 list.append( mapIdToStr[ Qtopia::Profession ] ); 26 list.append( mapIdToStr[ Qtopia::AddressCategory ] );
23 list.append( mapIdToStr[ Qtopia::Assistant ] );
24 list.append( mapIdToStr[ Qtopia::Manager ] );
25 27
26 list.append( mapIdToStr[ Qtopia::Spouse ] ); 28 list.append( mapIdToStr[ Qtopia::Title ] );
27 list.append( mapIdToStr[ Qtopia::Gender ] ); 29 list.append( mapIdToStr[ Qtopia::FirstName ] );
28 list.append( mapIdToStr[ Qtopia::Birthday ] ); 30 list.append( mapIdToStr[ Qtopia::MiddleName ] );
29 list.append( mapIdToStr[ Qtopia::Anniversary ] ); 31 list.append( mapIdToStr[ Qtopia::LastName ] );
30 list.append( mapIdToStr[ Qtopia::Nickname ] ); 32 list.append( mapIdToStr[ Qtopia::Suffix ] );
31 list.append( mapIdToStr[ Qtopia::Children ] ); 33 list.append( mapIdToStr[ Qtopia::FileAs ] );
34
35 list.append( mapIdToStr[ Qtopia::JobTitle ] );
36 list.append( mapIdToStr[ Qtopia::Department ] );
37 list.append( mapIdToStr[ Qtopia::Company ] );
38
39 list.append( mapIdToStr[ Qtopia::Notes ] );
40 list.append( mapIdToStr[ Qtopia::Groups ] );
32 41
33 if (sorted) list.sort(); 42 if (sorted) list.sort();
34 return list; 43 return list;
35} 44}
36 45
37/*! 46/*!
38 \internal 47 \internal
39 Returns a translated list of details field names for a contact. 48 Returns a list of details field names for a contact.
40*/ 49*/
41QStringList OContactFields::trdetailsfields( bool sorted ) 50QStringList OContactFields::detailsfields( bool sorted, bool translated )
42{ 51{
43 QStringList list; 52 QStringList list;
44 QMap<int, QString> mapIdToStr = idToTrFields(); 53 QMap<int, QString> mapIdToStr;
54 if ( translated )
55 mapIdToStr = idToTrFields();
56 else
57 mapIdToStr = idToUntrFields();
45 58
46 list.append( mapIdToStr[Qtopia::Office] ); 59 list.append( mapIdToStr[ Qtopia::Office ] );
47 list.append( mapIdToStr[Qtopia::Profession] ); 60 list.append( mapIdToStr[ Qtopia::Profession ] );
48 list.append( mapIdToStr[Qtopia::Assistant] ); 61 list.append( mapIdToStr[ Qtopia::Assistant ] );
49 list.append( mapIdToStr[Qtopia::Manager] ); 62 list.append( mapIdToStr[ Qtopia::Manager ] );
50 63
51 list.append( mapIdToStr[Qtopia::Spouse] ); 64 list.append( mapIdToStr[ Qtopia::Spouse ] );
52 list.append( mapIdToStr[Qtopia::Gender] ); 65 list.append( mapIdToStr[ Qtopia::Gender ] );
53 list.append( mapIdToStr[Qtopia::Birthday] ); 66 list.append( mapIdToStr[ Qtopia::Birthday ] );
54 list.append( mapIdToStr[Qtopia::Anniversary] ); 67 list.append( mapIdToStr[ Qtopia::Anniversary ] );
55 list.append( mapIdToStr[Qtopia::Nickname] ); 68 list.append( mapIdToStr[ Qtopia::Nickname ] );
56 list.append( mapIdToStr[Qtopia::Children] ); 69 list.append( mapIdToStr[ Qtopia::Children ] );
57 70
58 if (sorted) list.sort(); 71 if (sorted) list.sort();
59 return list; 72 return list;
60} 73}
61 74
62
63/*! 75/*!
64 \internal 76 \internal
65 Returns a translated list of phone field names for a contact. 77 Returns a list of phone field names for a contact.
66*/ 78*/
67QStringList OContactFields::trphonefields( bool sorted ) 79QStringList OContactFields::phonefields( bool sorted, bool translated )
68{ 80{
69 QStringList list; 81 QStringList list;
70 QMap<int, QString> mapIdToStr = idToTrFields(); 82 QMap<int, QString> mapIdToStr;
83 if ( translated )
84 mapIdToStr = idToTrFields();
85 else
86 mapIdToStr = idToUntrFields();
71 87
72 list.append( mapIdToStr[Qtopia::BusinessPhone] ); 88 list.append( mapIdToStr[Qtopia::BusinessPhone] );
73 list.append( mapIdToStr[Qtopia::BusinessFax] ); 89 list.append( mapIdToStr[Qtopia::BusinessFax] );
74 list.append( mapIdToStr[Qtopia::BusinessMobile] ); 90 list.append( mapIdToStr[Qtopia::BusinessMobile] );
75 list.append( mapIdToStr[Qtopia::BusinessPager] ); 91 list.append( mapIdToStr[Qtopia::BusinessPager] );
76 list.append( mapIdToStr[Qtopia::BusinessWebPage] ); 92 list.append( mapIdToStr[Qtopia::BusinessWebPage] );
77 93
78 list.append( mapIdToStr[Qtopia::DefaultEmail] ); 94 list.append( mapIdToStr[Qtopia::DefaultEmail] );
79 list.append( mapIdToStr[Qtopia::Emails] ); 95 list.append( mapIdToStr[Qtopia::Emails] );
80 96
81 list.append( mapIdToStr[Qtopia::HomePhone] ); 97 list.append( mapIdToStr[Qtopia::HomePhone] );
82 list.append( mapIdToStr[Qtopia::HomeFax] ); 98 list.append( mapIdToStr[Qtopia::HomeFax] );
83 list.append( mapIdToStr[Qtopia::HomeMobile] ); 99 list.append( mapIdToStr[Qtopia::HomeMobile] );
84 // list.append( mapIdToStr[Qtopia::HomePager] ); 100 // list.append( mapIdToStr[Qtopia::HomePager] );
85 list.append( mapIdToStr[Qtopia::HomeWebPage] ); 101 list.append( mapIdToStr[Qtopia::HomeWebPage] );
86 102
87 if (sorted) list.sort(); 103 if (sorted) list.sort();
88 104
89 return list; 105 return list;
90} 106}
91 107
92
93/*! 108/*!
94 \internal 109 \internal
95 Returns a list of phone field names for a contact. 110 Returns a list of field names for a contact.
96*/ 111*/
97QStringList OContactFields::untrphonefields( bool sorted ) 112QStringList OContactFields::fields( bool sorted, bool translated )
98{ 113{
99 QStringList list; 114 QStringList list;
100 QMap<int, QString> mapIdToStr = idToUntrFields(); 115 QMap<int, QString> mapIdToStr;
101 116 if ( translated )
102 list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); 117 mapIdToStr = idToTrFields();
103 list.append( mapIdToStr[ Qtopia::BusinessFax ] ); 118 else
104 list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); 119 mapIdToStr = idToUntrFields();
105 list.append( mapIdToStr[ Qtopia::BusinessPager ] );
106 list.append( mapIdToStr[ Qtopia::BusinessWebPage ] );
107
108 list.append( mapIdToStr[ Qtopia::DefaultEmail ] );
109 list.append( mapIdToStr[ Qtopia::Emails ] );
110 120
111 list.append( mapIdToStr[ Qtopia::HomePhone ] ); 121 list += personalfields( sorted, translated );
112 list.append( mapIdToStr[ Qtopia::HomeFax ] );
113 list.append( mapIdToStr[ Qtopia::HomeMobile ] );
114 //list.append( mapIdToStr[Qtopia::HomePager] );
115 list.append( mapIdToStr[Qtopia::HomeWebPage] );
116 122
117 if (sorted) list.sort(); 123 list += phonefields( sorted, translated );
118
119 return list;
120}
121
122
123/*!
124 \internal
125 Returns a translated list of field names for a contact.
126*/
127QStringList OContactFields::trfields( bool sorted )
128{
129 QStringList list;
130 QMap<int, QString> mapIdToStr = idToTrFields();
131
132 list.append( mapIdToStr[Qtopia::Title]);
133 list.append( mapIdToStr[Qtopia::FirstName] );
134 list.append( mapIdToStr[Qtopia::MiddleName] );
135 list.append( mapIdToStr[Qtopia::LastName] );
136 list.append( mapIdToStr[Qtopia::Suffix] );
137 list.append( mapIdToStr[Qtopia::FileAs] );
138
139 list.append( mapIdToStr[Qtopia::JobTitle] );
140 list.append( mapIdToStr[Qtopia::Department] );
141 list.append( mapIdToStr[Qtopia::Company] );
142
143 list += trphonefields( sorted );
144 124
145 list.append( mapIdToStr[Qtopia::BusinessStreet] ); 125 list.append( mapIdToStr[Qtopia::BusinessStreet] );
146 list.append( mapIdToStr[Qtopia::BusinessCity] ); 126 list.append( mapIdToStr[Qtopia::BusinessCity] );
147 list.append( mapIdToStr[Qtopia::BusinessState] ); 127 list.append( mapIdToStr[Qtopia::BusinessState] );
148 list.append( mapIdToStr[Qtopia::BusinessZip] ); 128 list.append( mapIdToStr[Qtopia::BusinessZip] );
149 list.append( mapIdToStr[Qtopia::BusinessCountry] ); 129 list.append( mapIdToStr[Qtopia::BusinessCountry] );
150 130
151 list.append( mapIdToStr[Qtopia::HomeStreet] ); 131 list.append( mapIdToStr[Qtopia::HomeStreet] );
152 list.append( mapIdToStr[Qtopia::HomeCity] ); 132 list.append( mapIdToStr[Qtopia::HomeCity] );
153 list.append( mapIdToStr[Qtopia::HomeState] ); 133 list.append( mapIdToStr[Qtopia::HomeState] );
154 list.append( mapIdToStr[Qtopia::HomeZip] ); 134 list.append( mapIdToStr[Qtopia::HomeZip] );
155 list.append( mapIdToStr[Qtopia::HomeCountry] ); 135 list.append( mapIdToStr[Qtopia::HomeCountry] );
156 136
157 list += trdetailsfields( sorted ); 137 list += detailsfields( sorted, translated );
158
159 list.append( mapIdToStr[Qtopia::Notes] );
160 list.append( mapIdToStr[Qtopia::Groups] );
161 138
162 if (sorted) list.sort(); 139 if (sorted) list.sort();
163 140
164 return list; 141 return list;
165} 142}
166 143
144
167/*! 145/*!
168 \internal 146 \internal
169 Returns an untranslated list of field names for a contact. 147 Returns an untranslated list of personal field names for a contact.
170*/ 148*/
171QStringList OContactFields::untrfields( bool sorted ) 149QStringList OContactFields::untrpersonalfields( bool sorted )
172{ 150{
173 QStringList list; 151 return personalfields( sorted, false );
174 QMap<int, QString> mapIdToStr = idToUntrFields(); 152}
175 153
176 list.append( mapIdToStr[ Qtopia::AddressUid ] );
177 list.append( mapIdToStr[ Qtopia::AddressCategory ] );
178 154
179 list.append( mapIdToStr[ Qtopia::Title ] ); 155/*!
180 list.append( mapIdToStr[ Qtopia::FirstName ] ); 156 \internal
181 list.append( mapIdToStr[ Qtopia::MiddleName ] ); 157 Returns a translated list of personal field names for a contact.
182 list.append( mapIdToStr[ Qtopia::LastName ] ); 158*/
183 list.append( mapIdToStr[ Qtopia::Suffix ] ); 159QStringList OContactFields::trpersonalfields( bool sorted )
184 list.append( mapIdToStr[ Qtopia::FileAs ] ); 160{
161 return personalfields( sorted, true );
162}
185 163
186 list.append( mapIdToStr[ Qtopia::JobTitle ] );
187 list.append( mapIdToStr[ Qtopia::Department ] );
188 list.append( mapIdToStr[ Qtopia::Company ] );
189 164
190 list += untrphonefields( sorted ); 165/*!
166 \internal
167 Returns an untranslated list of details field names for a contact.
168*/
169QStringList OContactFields::untrdetailsfields( bool sorted )
170{
171 return detailsfields( sorted, false );
172}
191 173
192 list.append( mapIdToStr[ Qtopia::BusinessStreet ] );
193 list.append( mapIdToStr[ Qtopia::BusinessCity ] );
194 list.append( mapIdToStr[ Qtopia::BusinessState ] );
195 list.append( mapIdToStr[ Qtopia::BusinessZip ] );
196 list.append( mapIdToStr[ Qtopia::BusinessCountry ] );
197 174
198 list.append( mapIdToStr[ Qtopia::HomeStreet ] ); 175/*!
199 list.append( mapIdToStr[ Qtopia::HomeCity ] ); 176 \internal
200 list.append( mapIdToStr[ Qtopia::HomeState ] ); 177 Returns a translated list of details field names for a contact.
201 list.append( mapIdToStr[ Qtopia::HomeZip ] ); 178*/
202 list.append( mapIdToStr[ Qtopia::HomeCountry ] ); 179QStringList OContactFields::trdetailsfields( bool sorted )
180{
181 return detailsfields( sorted, true );
182}
203 183
204 list += untrdetailsfields( sorted );
205 184
206 list.append( mapIdToStr[ Qtopia::Notes ] ); 185/*!
207 list.append( mapIdToStr[ Qtopia::Groups ] ); 186 \internal
187 Returns a translated list of phone field names for a contact.
188*/
189QStringList OContactFields::trphonefields( bool sorted )
190{
191 return phonefields( sorted, true );
192}
208 193
209 if (sorted) list.sort(); 194/*!
195 \internal
196 Returns an untranslated list of phone field names for a contact.
197*/
198QStringList OContactFields::untrphonefields( bool sorted )
199{
200 return phonefields( sorted, false );
201}
210 202
211 return list; 203
204/*!
205 \internal
206 Returns a translated list of field names for a contact.
207*/
208QStringList OContactFields::trfields( bool sorted )
209{
210 return fields( sorted, true );
211}
212
213/*!
214 \internal
215 Returns an untranslated list of field names for a contact.
216*/
217QStringList OContactFields::untrfields( bool sorted )
218{
219 return fields( sorted, false );
212} 220}
221
213QMap<int, QString> OContactFields::idToTrFields() 222QMap<int, QString> OContactFields::idToTrFields()
214{ 223{
215 QMap<int, QString> ret_map; 224 QMap<int, QString> ret_map;
216 225
217 ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); 226 ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) );
218 ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); 227 ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) );
219 228
220 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") ); 229 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") );
221 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); 230 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
222 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); 231 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
223 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); 232 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
224 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" )); 233 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ));
225 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); 234 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
226 235
227 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); 236 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
228 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); 237 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
229 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); 238 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
230 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); 239 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
231 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); 240 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
232 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" )); 241 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ));
233 242
234 // email 243 // email
235 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); 244 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
236 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); 245 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
@@ -308,76 +317,78 @@ QMap<int, QString> OContactFields::idToUntrFields()
308 // business 317 // business
309 ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); 318 ret_map.insert( Qtopia::BusinessStreet, "Business Street" );
310 ret_map.insert( Qtopia::BusinessCity, "Business City" ); 319 ret_map.insert( Qtopia::BusinessCity, "Business City" );
311 ret_map.insert( Qtopia::BusinessState, "Business State" ); 320 ret_map.insert( Qtopia::BusinessState, "Business State" );
312 ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); 321 ret_map.insert( Qtopia::BusinessZip, "Business Zip" );
313 ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); 322 ret_map.insert( Qtopia::BusinessCountry, "Business Country" );
314 ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); 323 ret_map.insert( Qtopia::BusinessPager, "Business Pager" );
315 ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); 324 ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" );
316 325
317 ret_map.insert( Qtopia::Office, "Office" ); 326 ret_map.insert( Qtopia::Office, "Office" );
318 ret_map.insert( Qtopia::Profession, "Profession" ); 327 ret_map.insert( Qtopia::Profession, "Profession" );
319 ret_map.insert( Qtopia::Assistant, "Assistant" ); 328 ret_map.insert( Qtopia::Assistant, "Assistant" );
320 ret_map.insert( Qtopia::Manager, "Manager" ); 329 ret_map.insert( Qtopia::Manager, "Manager" );
321 330
322 // home 331 // home
323 ret_map.insert( Qtopia::HomeStreet, "Home Street" ); 332 ret_map.insert( Qtopia::HomeStreet, "Home Street" );
324 ret_map.insert( Qtopia::HomeCity, "Home City" ); 333 ret_map.insert( Qtopia::HomeCity, "Home City" );
325 ret_map.insert( Qtopia::HomeState, "Home State" ); 334 ret_map.insert( Qtopia::HomeState, "Home State" );
326 ret_map.insert( Qtopia::HomeZip, "Home Zip" ); 335 ret_map.insert( Qtopia::HomeZip, "Home Zip" );
327 ret_map.insert( Qtopia::HomeCountry, "Home Country" ); 336 ret_map.insert( Qtopia::HomeCountry, "Home Country" );
328 ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); 337 ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" );
329 338
330 //personal 339 //personal
331 ret_map.insert( Qtopia::Spouse, "Spouse" ); 340 ret_map.insert( Qtopia::Spouse, "Spouse" );
332 ret_map.insert( Qtopia::Gender, "Gender" ); 341 ret_map.insert( Qtopia::Gender, "Gender" );
333 ret_map.insert( Qtopia::Birthday, "Birthday" ); 342 ret_map.insert( Qtopia::Birthday, "Birthday" );
334 ret_map.insert( Qtopia::Anniversary, "Anniversary" ); 343 ret_map.insert( Qtopia::Anniversary, "Anniversary" );
335 ret_map.insert( Qtopia::Nickname, "Nickname" ); 344 ret_map.insert( Qtopia::Nickname, "Nickname" );
336 ret_map.insert( Qtopia::Children, "Children" ); 345 ret_map.insert( Qtopia::Children, "Children" );
337 346
338 // other 347 // other
339 ret_map.insert( Qtopia::Notes, "Notes" ); 348 ret_map.insert( Qtopia::Notes, "Notes" );
340 ret_map.insert( Qtopia::Groups, "Groups" ); 349 ret_map.insert( Qtopia::Groups, "Groups" );
341 350
342 351
343 return ret_map; 352 return ret_map;
344} 353}
345 354
346QMap<QString, int> OContactFields::trFieldsToId() 355QMap<QString, int> OContactFields::trFieldsToId()
347{ 356{
348 QMap<int, QString> idtostr = idToTrFields(); 357 QMap<int, QString> idtostr = idToTrFields();
349 QMap<QString, int> ret_map; 358 QMap<QString, int> ret_map;
350 359
351 360
352 QMap<int, QString>::Iterator it; 361 QMap<int, QString>::Iterator it;
353 for( it = idtostr.begin(); it != idtostr.end(); ++it ) 362 for( it = idtostr.begin(); it != idtostr.end(); ++it )
354 ret_map.insert( *it, it.key() ); 363 ret_map.insert( *it, it.key() );
355 364
356 365
357 return ret_map; 366 return ret_map;
358} 367}
359 368
369/* ======================================================================= */
370
360QMap<QString, int> OContactFields::untrFieldsToId() 371QMap<QString, int> OContactFields::untrFieldsToId()
361{ 372{
362 QMap<int, QString> idtostr = idToUntrFields(); 373 QMap<int, QString> idtostr = idToUntrFields();
363 QMap<QString, int> ret_map; 374 QMap<QString, int> ret_map;
364 375
365 376
366 QMap<int, QString>::Iterator it; 377 QMap<int, QString>::Iterator it;
367 for( it = idtostr.begin(); it != idtostr.end(); ++it ) 378 for( it = idtostr.begin(); it != idtostr.end(); ++it )
368 ret_map.insert( *it, it.key() ); 379 ret_map.insert( *it, it.key() );
369 380
370 381
371 return ret_map; 382 return ret_map;
372} 383}
373 384
374 385
375OContactFields::OContactFields(): 386OContactFields::OContactFields():
376 fieldOrder( DEFAULT_FIELD_ORDER ), 387 fieldOrder( DEFAULT_FIELD_ORDER ),
377 changedFieldOrder( false ) 388 changedFieldOrder( false )
378{ 389{
379 // Get the global field order from the config file and 390 // Get the global field order from the config file and
380 // use it as a start pattern 391 // use it as a start pattern
381 Config cfg ( "AddressBook" ); 392 Config cfg ( "AddressBook" );
382 cfg.setGroup( "ContactFieldOrder" ); 393 cfg.setGroup( "ContactFieldOrder" );
383 globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); 394 globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER );
diff --git a/libopie/pim/ocontactfields.h b/libopie/pim/ocontactfields.h
index 9f6171b..f105de7 100644
--- a/libopie/pim/ocontactfields.h
+++ b/libopie/pim/ocontactfields.h
@@ -22,39 +22,46 @@ class OContactFields{
22 */ 22 */
23 void setFieldOrder( int num, int index ); 23 void setFieldOrder( int num, int index );
24 24
25 /** Get the index for combo boxes. 25 /** Get the index for combo boxes.
26 * Returns the index of combo <b>num</b> or defindex 26 * Returns the index of combo <b>num</b> or defindex
27 * if none was defined.. 27 * if none was defined..
28 * @param num Selects the number of the combo 28 * @param num Selects the number of the combo
29 * @param defIndex will be returned if none was defined (either 29 * @param defIndex will be returned if none was defined (either
30 * globally in the config file, nor by the contact which was used 30 * globally in the config file, nor by the contact which was used
31 * by loadFromRecord() ) 31 * by loadFromRecord() )
32 */ 32 */
33 int getFieldOrder( int num, int defIndex); 33 int getFieldOrder( int num, int defIndex);
34 34
35 /** Store fieldorder to contact. */ 35 /** Store fieldorder to contact. */
36 void saveToRecord( OContact& ); 36 void saveToRecord( OContact& );
37 /** Get Fieldorder from contact. */ 37 /** Get Fieldorder from contact. */
38 void loadFromRecord( const OContact& ); 38 void loadFromRecord( const OContact& );
39 39
40 private: 40 private:
41 QString fieldOrder; 41 QString fieldOrder;
42 QString globalFieldOrder; 42 QString globalFieldOrder;
43 bool changedFieldOrder; 43 bool changedFieldOrder;
44 44
45 public: 45 public:
46 static QStringList personalfields( bool sorted = true, bool translated = false );
47 static QStringList phonefields( bool sorted = true, bool translated = false );
48 static QStringList detailsfields( bool sorted = true, bool translated = false );
49 static QStringList fields( bool sorted = true, bool translated = false );
50
51 static QStringList trpersonalfields( bool sorted = true );
52 static QStringList untrpersonalfields( bool sorted = true );
46 static QStringList trphonefields( bool sorted = true ); 53 static QStringList trphonefields( bool sorted = true );
47 static QStringList untrphonefields( bool sorted = true ); 54 static QStringList untrphonefields( bool sorted = true );
48 static QStringList trdetailsfields( bool sorted = true ); 55 static QStringList trdetailsfields( bool sorted = true );
49 static QStringList untrdetailsfields( bool sorted = true ); 56 static QStringList untrdetailsfields( bool sorted = true );
50 static QStringList trfields( bool sorted = true ); 57 static QStringList trfields( bool sorted = true );
51 static QStringList untrfields( bool sorted = true ); 58 static QStringList untrfields( bool sorted = true );
52 59
53 static QMap<int, QString> idToTrFields(); 60 static QMap<int, QString> idToTrFields();
54 static QMap<QString, int> trFieldsToId(); 61 static QMap<QString, int> trFieldsToId();
55 static QMap<int, QString> idToUntrFields(); 62 static QMap<int, QString> idToUntrFields();
56 static QMap<QString, int> untrFieldsToId(); 63 static QMap<QString, int> untrFieldsToId();
57 64
58}; 65};
59 66
60#endif 67#endif
diff --git a/libopie/pim/opimnotifymanager.cpp b/libopie/pim/opimnotifymanager.cpp
index 06b5987..53ad4c3 100644
--- a/libopie/pim/opimnotifymanager.cpp
+++ b/libopie/pim/opimnotifymanager.cpp
@@ -1,26 +1,30 @@
1#include "opimnotifymanager.h" 1#include "opimnotifymanager.h"
2 2
3#include "oconversion.h"
4
5#include <qstringlist.h>
6
3OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) 7OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al)
4 : m_rem( rem ), m_al( al ) 8 : m_rem( rem ), m_al( al )
5{} 9{}
6OPimNotifyManager::~OPimNotifyManager() { 10OPimNotifyManager::~OPimNotifyManager() {
7} 11}
8/* use static_cast and type instead of dynamic... */ 12/* use static_cast and type instead of dynamic... */
9void OPimNotifyManager::add( const OPimNotify& noti) { 13void OPimNotifyManager::add( const OPimNotify& noti) {
10 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 14 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
11 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 15 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
12 m_rem.append( rem ); 16 m_rem.append( rem );
13 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 17 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
14 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 18 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
15 m_al.append( al ); 19 m_al.append( al );
16 } 20 }
17} 21}
18void OPimNotifyManager::remove( const OPimNotify& noti) { 22void OPimNotifyManager::remove( const OPimNotify& noti) {
19 if ( noti.type() == QString::fromLatin1("OPimReminder") ) { 23 if ( noti.type() == QString::fromLatin1("OPimReminder") ) {
20 const OPimReminder& rem = static_cast<const OPimReminder&>(noti); 24 const OPimReminder& rem = static_cast<const OPimReminder&>(noti);
21 m_rem.remove( rem ); 25 m_rem.remove( rem );
22 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { 26 }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) {
23 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); 27 const OPimAlarm& al = static_cast<const OPimAlarm&>(noti);
24 m_al.remove( al ); 28 m_al.remove( al );
25 } 29 }
26} 30}
@@ -46,29 +50,97 @@ void OPimNotifyManager::setAlarms( const Alarms& al) {
46} 50}
47void OPimNotifyManager::setReminders( const Reminders& rem) { 51void OPimNotifyManager::setReminders( const Reminders& rem) {
48 m_rem = rem; 52 m_rem = rem;
49} 53}
50/* FIXME!!! */ 54/* FIXME!!! */
51/** 55/**
52 * The idea is to check if the provider for our service 56 * The idea is to check if the provider for our service
53 * is online 57 * is online
54 * if it is we will use QCOP 58 * if it is we will use QCOP
55 * if not the Factory to get the backend... 59 * if not the Factory to get the backend...
56 * Qtopia1.6 services would be kewl to have here.... 60 * Qtopia1.6 services would be kewl to have here....
57 */ 61 */
58void OPimNotifyManager::registerNotify( const OPimNotify& ) { 62void OPimNotifyManager::registerNotify( const OPimNotify& ) {
59 63
60} 64}
61/* FIXME!!! */ 65/* FIXME!!! */
62/** 66/**
63 * same as above... 67 * same as above...
64 * Also implement Url model 68 * Also implement Url model
65 * have a MainWindow.... 69 * have a MainWindow....
66 */ 70 */
67void OPimNotifyManager::deregister( const OPimNotify& ) { 71void OPimNotifyManager::deregister( const OPimNotify& ) {
68 72
69} 73}
74
70bool OPimNotifyManager::isEmpty()const { 75bool OPimNotifyManager::isEmpty()const {
71 qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); 76 qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
72 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; 77 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
73 else return false; 78 else return false;
74} 79}
80
81// Taken from otodoaccessxml..
82QString OPimNotifyManager::alarmsToString() const
83{
84 QString str;
85
86 OPimNotifyManager::Alarms alarms = m_al;
87 if ( !alarms.isEmpty() ) {
88 QStringList als;
89 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
90 for ( ; it != alarms.end(); ++it ) {
91 /* only if time is valid */
92 if ( (*it).dateTime().isValid() ) {
93 als << OConversion::dateTimeToString( (*it).dateTime() )
94 + ":" + QString::number( (*it).duration() )
95 + ":" + QString::number( (*it).sound() )
96 + ":";
97 }
98 }
99 // now write the list
100 qWarning("als: %s", als.join("____________").latin1() );
101 str = als.join(";");
102 }
103
104 return str;
105}
106QString OPimNotifyManager::remindersToString() const
107{
108 QString str;
109
110 OPimNotifyManager::Reminders reminders = m_rem;
111 if (!reminders.isEmpty() ) {
112 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
113 QStringList records;
114 for ( ; it != reminders.end(); ++it ) {
115 records << QString::number( (*it).recordUid() );
116 }
117 str = records.join(";");
118 }
119
120 return str;
121}
122
123void OPimNotifyManager::alarmsFromString( const QString& str )
124{
125 QStringList als = QStringList::split(";", str );
126 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
127 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
128 qWarning("alarm: %s", alarm.join("___").latin1() );
129 qWarning("alarm[0]: %s %s", alarm[0].latin1(),
130 OConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
131 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ),
132 alarm[1].toInt() );
133 add( al );
134 }
135}
136
137void OPimNotifyManager::remindersFromString( const QString& str )
138{
139
140 QStringList rems = QStringList::split(";", str );
141 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
142 OPimReminder rem( (*it).toInt() );
143 add( rem );
144 }
145
146}
diff --git a/libopie/pim/opimnotifymanager.h b/libopie/pim/opimnotifymanager.h
index 0ac30a1..48410e7 100644
--- a/libopie/pim/opimnotifymanager.h
+++ b/libopie/pim/opimnotifymanager.h
@@ -18,37 +18,59 @@ public:
18 /* we will cast it for you ;) */ 18 /* we will cast it for you ;) */
19 void add( const OPimNotify& ); 19 void add( const OPimNotify& );
20 void remove( const OPimNotify& ); 20 void remove( const OPimNotify& );
21 /* replaces all with this one! */ 21 /* replaces all with this one! */
22 void replace( const OPimNotify& ); 22 void replace( const OPimNotify& );
23 23
24 Reminders reminders()const; 24 Reminders reminders()const;
25 Alarms alarms()const; 25 Alarms alarms()const;
26 26
27 void setAlarms( const Alarms& ); 27 void setAlarms( const Alarms& );
28 void setReminders( const Reminders& ); 28 void setReminders( const Reminders& );
29 29
30 /* register is a Ansi C keyword... */ 30 /* register is a Ansi C keyword... */
31 /** 31 /**
32 * This function will register the Notify to the Alarm Server 32 * This function will register the Notify to the Alarm Server
33 * or datebook depending on the type of the notify 33 * or datebook depending on the type of the notify
34 */ 34 */
35 void registerNotify( const OPimNotify& ); 35 void registerNotify( const OPimNotify& );
36 36
37 /** 37 /**
38 * this will do the opposite.. 38 * this will do the opposite..
39 */ 39 */
40 void deregister( const OPimNotify& ); 40 void deregister( const OPimNotify& );
41 41
42
43 bool isEmpty()const; 42 bool isEmpty()const;
44 43
44 /**
45 * Return all alarms as string
46 */
47 QString alarmsToString() const;
48 /**
49 * Return all notifiers as string
50 */
51 QString remindersToString() const;
52
53 /**
54 * Convert string to alarms
55 * @param str String created by alarmsToString()
56 */
57 void alarmsFromString( const QString& str );
58
59 /**
60 * Convert string to reminders
61 * @param str String created by remindersToString()
62 */
63 void remindersFromString( const QString& str );
64
65
66
45private: 67private:
46 Reminders m_rem; 68 Reminders m_rem;
47 Alarms m_al; 69 Alarms m_al;
48 70
49 class Private; 71 class Private;
50 Private *d; 72 Private *d;
51 73
52}; 74};
53 75
54#endif 76#endif
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp
index d255c66..ebd03bb 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/libopie/pim/otodoaccesssql.cpp
@@ -1,35 +1,38 @@
1 1
2#include <qdatetime.h> 2#include <qdatetime.h>
3 3
4#include <qpe/global.h> 4#include <qpe/global.h>
5 5
6#include <opie2/osqldriver.h> 6#include <opie2/osqldriver.h>
7#include <opie2/osqlresult.h> 7#include <opie2/osqlresult.h>
8#include <opie2/osqlmanager.h> 8#include <opie2/osqlmanager.h>
9#include <opie2/osqlquery.h> 9#include <opie2/osqlquery.h>
10 10
11#include "otodoaccesssql.h" 11#include "otodoaccesssql.h"
12#include "opimstate.h"
13#include "opimnotifymanager.h"
14#include "orecur.h"
12 15
13/* 16/*
14 * first some query 17 * first some query
15 * CREATE query 18 * CREATE query
16 * LOAD query 19 * LOAD query
17 * INSERT 20 * INSERT
18 * REMOVE 21 * REMOVE
19 * CLEAR 22 * CLEAR
20 */ 23 */
21namespace { 24namespace {
22 /** 25 /**
23 * CreateQuery for the Todolist Table 26 * CreateQuery for the Todolist Table
24 */ 27 */
25 class CreateQuery : public OSQLQuery { 28 class CreateQuery : public OSQLQuery {
26 public: 29 public:
27 CreateQuery(); 30 CreateQuery();
28 ~CreateQuery(); 31 ~CreateQuery();
29 QString query()const; 32 QString query()const;
30 }; 33 };
31 34
32 /** 35 /**
33 * LoadQuery 36 * LoadQuery
34 * this one queries for all uids 37 * this one queries for all uids
35 */ 38 */
@@ -99,49 +102,50 @@ namespace {
99 OverDueQuery(); 102 OverDueQuery();
100 ~OverDueQuery(); 103 ~OverDueQuery();
101 QString query()const; 104 QString query()const;
102 }; 105 };
103 class EffQuery : public OSQLQuery { 106 class EffQuery : public OSQLQuery {
104 public: 107 public:
105 EffQuery( const QDate&, const QDate&, bool inc ); 108 EffQuery( const QDate&, const QDate&, bool inc );
106 ~EffQuery(); 109 ~EffQuery();
107 QString query()const; 110 QString query()const;
108 private: 111 private:
109 QString with()const; 112 QString with()const;
110 QString out()const; 113 QString out()const;
111 QDate m_start; 114 QDate m_start;
112 QDate m_end; 115 QDate m_end;
113 bool m_inc :1; 116 bool m_inc :1;
114 }; 117 };
115 118
116 119
117 CreateQuery::CreateQuery() : OSQLQuery() {} 120 CreateQuery::CreateQuery() : OSQLQuery() {}
118 CreateQuery::~CreateQuery() {} 121 CreateQuery::~CreateQuery() {}
119 QString CreateQuery::query()const { 122 QString CreateQuery::query()const {
120 QString qu; 123 QString qu;
121 qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; 124 qu += "create table todolist( uid PRIMARY KEY, categories, completed, ";
122 qu += "description, summary, priority, DueDate, progress , state, "; 125 qu += "description, summary, priority, DueDate, progress , state, ";
123 qu += "Recurrence, notifiers, maintainer, startdate, completeddate)"; 126 qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);";
127 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
124 return qu; 128 return qu;
125 } 129 }
126 130
127 LoadQuery::LoadQuery() : OSQLQuery() {} 131 LoadQuery::LoadQuery() : OSQLQuery() {}
128 LoadQuery::~LoadQuery() {} 132 LoadQuery::~LoadQuery() {}
129 QString LoadQuery::query()const { 133 QString LoadQuery::query()const {
130 QString qu; 134 QString qu;
131 // We do not need "distinct" here. The primary key is always unique.. 135 // We do not need "distinct" here. The primary key is always unique..
132 //qu += "select distinct uid from todolist"; 136 //qu += "select distinct uid from todolist";
133 qu += "select uid from todolist"; 137 qu += "select uid from todolist";
134 138
135 return qu; 139 return qu;
136 } 140 }
137 141
138 InsertQuery::InsertQuery( const OTodo& todo ) 142 InsertQuery::InsertQuery( const OTodo& todo )
139 : OSQLQuery(), m_todo( todo ) { 143 : OSQLQuery(), m_todo( todo ) {
140 } 144 }
141 InsertQuery::~InsertQuery() { 145 InsertQuery::~InsertQuery() {
142 } 146 }
143 /* 147 /*
144 * converts from a OTodo to a query 148 * converts from a OTodo to a query
145 * we leave out X-Ref + Alarms 149 * we leave out X-Ref + Alarms
146 */ 150 */
147 QString InsertQuery::query()const{ 151 QString InsertQuery::query()const{
@@ -160,56 +164,65 @@ namespace {
160 sYear = sDate.year(); 164 sYear = sDate.year();
161 sMonth= sDate.month(); 165 sMonth= sDate.month();
162 sDay = sDate.day(); 166 sDay = sDate.day();
163 } 167 }
164 168
165 int eYear = 0, eMonth = 0, eDay = 0; 169 int eYear = 0, eMonth = 0, eDay = 0;
166 if( m_todo.hasCompletedDate() ){ 170 if( m_todo.hasCompletedDate() ){
167 QDate eDate = m_todo.completedDate(); 171 QDate eDate = m_todo.completedDate();
168 eYear = eDate.year(); 172 eYear = eDate.year();
169 eMonth= eDate.month(); 173 eMonth= eDate.month();
170 eDay = eDate.day(); 174 eDay = eDate.day();
171 } 175 }
172 QString qu; 176 QString qu;
173 qu = "insert into todolist VALUES(" 177 qu = "insert into todolist VALUES("
174 + QString::number( m_todo.uid() ) + "," 178 + QString::number( m_todo.uid() ) + ","
175 + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," 179 + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + ","
176 + QString::number( m_todo.isCompleted() ) + "," 180 + QString::number( m_todo.isCompleted() ) + ","
177 + "'" + m_todo.description() + "'" + "," 181 + "'" + m_todo.description() + "'" + ","
178 + "'" + m_todo.summary() + "'" + "," 182 + "'" + m_todo.summary() + "'" + ","
179 + QString::number(m_todo.priority() ) + "," 183 + QString::number(m_todo.priority() ) + ","
180 + "'" + QString::number(year) + "-" 184 + "'" + QString::number(year) + "-"
181 + QString::number(month) 185 + QString::number(month)
182 + "-" + QString::number( day ) + "'" + "," 186 + "-" + QString::number( day ) + "'" + ","
183 + QString::number( m_todo.progress() ) + "," 187 + QString::number( m_todo.progress() ) + ","
184 + "''" + "," // state (conversion needed) 188 + QString::number( m_todo.state().state() ) + ","
185 // + QString::number( m_todo.state() ) + "," 189 + "'" + m_todo.recurrence().toString() + "'"+ ",";
186 + "''" + "," // Recurrence (conversion needed) 190
187 + "''" + "," // Notifiers (conversion needed) 191 if ( m_todo.hasNotifiers() ) {
188 + "''" + "," // Maintainers (conversion needed) 192 OPimNotifyManager manager = m_todo.notifiers();
193 qu += "'" + manager.remindersToString() + "'" + ","
194 + "'" + manager.alarmsToString() + "'" + ",";
195 }
196 else{
197 qu += QString( "''" ) + ","
198 + "''" + ",";
199 }
200
201 qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !)
189 + "'" + QString::number(sYear) + "-" 202 + "'" + QString::number(sYear) + "-"
190 + QString::number(sMonth) 203 + QString::number(sMonth)
191 + "-" + QString::number(sDay) + "'" + "," 204 + "-" + QString::number(sDay) + "'" + ","
192 + "'" + QString::number(eYear) + "-" 205 + "'" + QString::number(eYear) + "-"
193 + QString::number(eMonth) 206 + QString::number(eMonth)
194 + "-"+QString::number(eDay) + "'" 207 + "-"+QString::number(eDay) + "'"
195 + ")"; 208 + ")";
196 209
197 qWarning("add %s", qu.latin1() ); 210 qWarning("add %s", qu.latin1() );
198 return qu; 211 return qu;
199 } 212 }
200 213
201 RemoveQuery::RemoveQuery(int uid ) 214 RemoveQuery::RemoveQuery(int uid )
202 : OSQLQuery(), m_uid( uid ) {} 215 : OSQLQuery(), m_uid( uid ) {}
203 RemoveQuery::~RemoveQuery() {} 216 RemoveQuery::~RemoveQuery() {}
204 QString RemoveQuery::query()const { 217 QString RemoveQuery::query()const {
205 QString qu = "DELETE from todolist where uid = " + QString::number(m_uid); 218 QString qu = "DELETE from todolist where uid = " + QString::number(m_uid);
206 return qu; 219 return qu;
207 } 220 }
208 221
209 222
210 ClearQuery::ClearQuery() 223 ClearQuery::ClearQuery()
211 : OSQLQuery() {} 224 : OSQLQuery() {}
212 ClearQuery::~ClearQuery() {} 225 ClearQuery::~ClearQuery() {}
213 QString ClearQuery::query()const { 226 QString ClearQuery::query()const {
214 QString qu = "drop table todolist"; 227 QString qu = "drop table todolist";
215 return qu; 228 return qu;
@@ -509,48 +522,59 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
509 qWarning("todo"); 522 qWarning("todo");
510 bool hasDueDate = false; QDate dueDate = QDate::currentDate(); 523 bool hasDueDate = false; QDate dueDate = QDate::currentDate();
511 hasDueDate = date( dueDate, item.data("DueDate") ); 524 hasDueDate = date( dueDate, item.data("DueDate") );
512 QStringList cats = QStringList::split(";", item.data("categories") ); 525 QStringList cats = QStringList::split(";", item.data("categories") );
513 526
514 OTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), 527 OTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(),
515 cats, item.data("summary"), item.data("description"), 528 cats, item.data("summary"), item.data("description"),
516 item.data("progress").toUShort(), hasDueDate, dueDate, 529 item.data("progress").toUShort(), hasDueDate, dueDate,
517 item.data("uid").toInt() ); 530 item.data("uid").toInt() );
518 531
519 bool isOk; 532 bool isOk;
520 int prioInt = QString( item.data("priority") ).toInt( &isOk ); 533 int prioInt = QString( item.data("priority") ).toInt( &isOk );
521 if ( isOk ) 534 if ( isOk )
522 to.setPriority( prioInt ); 535 to.setPriority( prioInt );
523 536
524 bool hasStartDate = false; QDate startDate = QDate::currentDate(); 537 bool hasStartDate = false; QDate startDate = QDate::currentDate();
525 hasStartDate = date( startDate, item.data("startdate") ); 538 hasStartDate = date( startDate, item.data("startdate") );
526 bool hasCompletedDate = false; QDate completedDate = QDate::currentDate(); 539 bool hasCompletedDate = false; QDate completedDate = QDate::currentDate();
527 hasCompletedDate = date( completedDate, item.data("completeddate") ); 540 hasCompletedDate = date( completedDate, item.data("completeddate") );
528 541
529 if ( hasStartDate ) 542 if ( hasStartDate )
530 to.setStartDate( startDate ); 543 to.setStartDate( startDate );
531 if ( hasCompletedDate ) 544 if ( hasCompletedDate )
532 to.setCompletedDate( completedDate ); 545 to.setCompletedDate( completedDate );
546
547 OPimNotifyManager& manager = to.notifiers();
548 manager.alarmsFromString( item.data("alarms") );
549 manager.remindersFromString( item.data("reminders") );
550
551 OPimState pimState;
552 pimState.setState( QString( item.data("state") ).toInt() );
553 to.setState( pimState );
554
555 // Recurrence not supported yet
556 // to.setRecurrence(
533 557
534 return to; 558 return to;
535} 559}
536OTodo OTodoAccessBackendSQL::todo( int uid )const { 560OTodo OTodoAccessBackendSQL::todo( int uid )const {
537 FindQuery find( uid ); 561 FindQuery find( uid );
538 return todo( m_driver->query(&find) ); 562 return todo( m_driver->query(&find) );
539} 563}
540/* 564/*
541 * update the dict 565 * update the dict
542 */ 566 */
543void OTodoAccessBackendSQL::fillDict() { 567void OTodoAccessBackendSQL::fillDict() {
544 /* initialize dict */ 568 /* initialize dict */
545 /* 569 /*
546 * UPDATE dict if you change anything!!! 570 * UPDATE dict if you change anything!!!
547 * FIXME: Isn't this dict obsolete ? (eilers) 571 * FIXME: Isn't this dict obsolete ? (eilers)
548 */ 572 */
549 m_dict.setAutoDelete( TRUE ); 573 m_dict.setAutoDelete( TRUE );
550 m_dict.insert("Categories" , new int(OTodo::Category) ); 574 m_dict.insert("Categories" , new int(OTodo::Category) );
551 m_dict.insert("Uid" , new int(OTodo::Uid) ); 575 m_dict.insert("Uid" , new int(OTodo::Uid) );
552 m_dict.insert("HasDate" , new int(OTodo::HasDate) ); 576 m_dict.insert("HasDate" , new int(OTodo::HasDate) );
553 m_dict.insert("Completed" , new int(OTodo::Completed) ); 577 m_dict.insert("Completed" , new int(OTodo::Completed) );
554 m_dict.insert("Description" , new int(OTodo::Description) ); 578 m_dict.insert("Description" , new int(OTodo::Description) );
555 m_dict.insert("Summary" , new int(OTodo::Summary) ); 579 m_dict.insert("Summary" , new int(OTodo::Summary) );
556 m_dict.insert("Priority" , new int(OTodo::Priority) ); 580 m_dict.insert("Priority" , new int(OTodo::Priority) );
@@ -600,52 +624,44 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
600 624
601 Copied from xml-backend by not adapted to sql (eilers) 625 Copied from xml-backend by not adapted to sql (eilers)
602 626
603 QArray<int> m_currentQuery( m_events.count() ); 627 QArray<int> m_currentQuery( m_events.count() );
604 uint arraycounter = 0; 628 uint arraycounter = 0;
605 629
606 630
607 631
608 QMap<int, OTodo>::ConstIterator it; 632 QMap<int, OTodo>::ConstIterator it;
609 for (it = m_events.begin(); it != m_events.end(); ++it ) { 633 for (it = m_events.begin(); it != m_events.end(); ++it ) {
610 if ( it.data().match( r ) ) 634 if ( it.data().match( r ) )
611 m_currentQuery[arraycounter++] = it.data().uid(); 635 m_currentQuery[arraycounter++] = it.data().uid();
612 636
613 } 637 }
614 // Shrink to fit.. 638 // Shrink to fit..
615 m_currentQuery.resize(arraycounter); 639 m_currentQuery.resize(arraycounter);
616 640
617 return m_currentQuery; 641 return m_currentQuery;
618#endif 642#endif
619 QArray<int> empty; 643 QArray<int> empty;
620 return empty; 644 return empty;
621} 645}
622QBitArray OTodoAccessBackendSQL::supports()const { 646QBitArray OTodoAccessBackendSQL::supports()const {
623 647
624 QBitArray ar( OTodo::CompletedDate + 1 ); 648 return sup();
625 ar.fill( true );
626 ar[OTodo::CrossReference] = false;
627 ar[OTodo::State ] = false;
628 ar[OTodo::Reminders] = false;
629 ar[OTodo::Notifiers] = false;
630 ar[OTodo::Maintainer] = false;
631
632 return ar;
633} 649}
634 650
635QBitArray OTodoAccessBackendSQL::sup() { 651QBitArray OTodoAccessBackendSQL::sup() const{
636 652
637 QBitArray ar( OTodo::CompletedDate + 1 ); 653 QBitArray ar( OTodo::CompletedDate + 1 );
638 ar.fill( true ); 654 ar.fill( true );
639 ar[OTodo::CrossReference] = false; 655 ar[OTodo::CrossReference] = false;
640 ar[OTodo::State ] = false; 656 ar[OTodo::State ] = false;
641 ar[OTodo::Reminders] = false; 657 ar[OTodo::Reminders] = false;
642 ar[OTodo::Notifiers] = false; 658 ar[OTodo::Notifiers] = false;
643 ar[OTodo::Maintainer] = false; 659 ar[OTodo::Maintainer] = false;
644 660
645 return ar; 661 return ar;
646} 662}
647 663
648void OTodoAccessBackendSQL::removeAllCompleted(){ 664void OTodoAccessBackendSQL::removeAllCompleted(){
649#warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !! 665#warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !!
650 666
651} 667}
diff --git a/libopie/pim/otodoaccesssql.h b/libopie/pim/otodoaccesssql.h
index 77d8b77..1c55567 100644
--- a/libopie/pim/otodoaccesssql.h
+++ b/libopie/pim/otodoaccesssql.h
@@ -23,34 +23,34 @@ public:
23 OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 23 OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
24 void clear(); 24 void clear();
25 bool add( const OTodo& t ); 25 bool add( const OTodo& t );
26 bool remove( int uid ); 26 bool remove( int uid );
27 bool replace( const OTodo& t ); 27 bool replace( const OTodo& t );
28 28
29 QArray<int> overDue(); 29 QArray<int> overDue();
30 QArray<int> effectiveToDos( const QDate& start, 30 QArray<int> effectiveToDos( const QDate& start,
31 const QDate& end, bool includeNoDates ); 31 const QDate& end, bool includeNoDates );
32 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); 32 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
33 33
34 QBitArray supports()const; 34 QBitArray supports()const;
35 QArray<int> matchRegexp( const QRegExp &r ) const; 35 QArray<int> matchRegexp( const QRegExp &r ) const;
36 void removeAllCompleted(); 36 void removeAllCompleted();
37 37
38 38
39private: 39private:
40 void update()const; 40 void update()const;
41 void fillDict(); 41 void fillDict();
42 inline bool date( QDate& date, const QString& )const; 42 inline bool date( QDate& date, const QString& )const;
43 inline OTodo todo( const OSQLResult& )const; 43 inline OTodo todo( const OSQLResult& )const;
44 inline OTodo todo( OSQLResultItem& )const; 44 inline OTodo todo( OSQLResultItem& )const;
45 inline QArray<int> uids( const OSQLResult& )const; 45 inline QArray<int> uids( const OSQLResult& )const;
46 OTodo todo( int uid )const; 46 OTodo todo( int uid )const;
47 QBitArray sup(); 47 QBitArray sup() const;
48 48
49 QAsciiDict<int> m_dict; 49 QAsciiDict<int> m_dict;
50 OSQLDriver* m_driver; 50 OSQLDriver* m_driver;
51 QArray<int> m_uids; 51 QArray<int> m_uids;
52 bool m_dirty : 1; 52 bool m_dirty : 1;
53}; 53};
54 54
55 55
56#endif 56#endif
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index f688735..4a5cb33 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -547,49 +547,49 @@ QString OTodoAccessXML::toString( const OTodo& ev )const {
547 * possible you can set custom fields 547 * possible you can set custom fields
548 * but don' iterate over the list 548 * but don' iterate over the list
549 * I may do #define private protected 549 * I may do #define private protected
550 * for this case - cough --zecke 550 * for this case - cough --zecke
551 */ 551 */
552 /* 552 /*
553 QMap<QString, QString> extras = ev.extras(); 553 QMap<QString, QString> extras = ev.extras();
554 QMap<QString, QString>::Iterator extIt; 554 QMap<QString, QString>::Iterator extIt;
555 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 555 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
556 str += extIt.key() + "=\"" + extIt.data() + "\" "; 556 str += extIt.key() + "=\"" + extIt.data() + "\" ";
557 */ 557 */
558 // cross refernce 558 // cross refernce
559 if ( ev.hasRecurrence() ) { 559 if ( ev.hasRecurrence() ) {
560 str += ev.recurrence().toString(); 560 str += ev.recurrence().toString();
561 } 561 }
562 if ( ev.hasStartDate() ) 562 if ( ev.hasStartDate() )
563 str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; 563 str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" ";
564 if ( ev.hasCompletedDate() ) 564 if ( ev.hasCompletedDate() )
565 str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; 565 str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" ";
566 if ( ev.hasState() ) 566 if ( ev.hasState() )
567 str += "State=\""+QString::number( ev.state().state() )+"\" "; 567 str += "State=\""+QString::number( ev.state().state() )+"\" ";
568 568
569 /* 569 /*
570 * save reminders and notifiers! 570 * save reminders and notifiers!
571 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... 571 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:....
572 */ 572 */
573 if ( ev.hasNotifiers() ) { 573 if ( ev.hasNotifiers() ) {
574 OPimNotifyManager manager = ev.notifiers(); 574 OPimNotifyManager manager = ev.notifiers();
575 OPimNotifyManager::Alarms alarms = manager.alarms(); 575 OPimNotifyManager::Alarms alarms = manager.alarms();
576 if (!alarms.isEmpty() ) { 576 if (!alarms.isEmpty() ) {
577 QStringList als; 577 QStringList als;
578 OPimNotifyManager::Alarms::Iterator it = alarms.begin(); 578 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
579 for ( ; it != alarms.end(); ++it ) { 579 for ( ; it != alarms.end(); ++it ) {
580 /* only if time is valid */ 580 /* only if time is valid */
581 if ( (*it).dateTime().isValid() ) { 581 if ( (*it).dateTime().isValid() ) {
582 als << OConversion::dateTimeToString( (*it).dateTime() ) 582 als << OConversion::dateTimeToString( (*it).dateTime() )
583 + ":" + QString::number( (*it).duration() ) 583 + ":" + QString::number( (*it).duration() )
584 + ":" + QString::number( (*it).sound() ) 584 + ":" + QString::number( (*it).sound() )
585 + ":"; 585 + ":";
586 } 586 }
587 } 587 }
588 // now write the list 588 // now write the list
589 qWarning("als: %s", als.join("____________").latin1() ); 589 qWarning("als: %s", als.join("____________").latin1() );
590 str += "Alarms=\""+als.join(";") +"\" "; 590 str += "Alarms=\""+als.join(";") +"\" ";
591 } 591 }
592 592
593 /* 593 /*
594 * now the same for reminders but more easy. We just save the uid of the OEvent. 594 * now the same for reminders but more easy. We just save the uid of the OEvent.
595 */ 595 */