-rw-r--r-- | kabc/address.h | 1 | ||||
-rw-r--r-- | kabc/addressbook.cpp | 28 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kabc/addressee.cpp | 39 | ||||
-rw-r--r-- | kabc/addressee.h | 4 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 |
7 files changed, 81 insertions, 6 deletions
diff --git a/kabc/address.h b/kabc/address.h index 6b53c7e..37dd851 100644 --- a/kabc/address.h +++ b/kabc/address.h | |||
@@ -1,347 +1,348 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESS_H | 28 | #ifndef KABC_ADDRESS_H |
29 | #define KABC_ADDRESS_H | 29 | #define KABC_ADDRESS_H |
30 | 30 | ||
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qstring.h> | 32 | #include <qstring.h> |
33 | #include <qstringlist.h> | ||
33 | #include <qvaluelist.h> | 34 | #include <qvaluelist.h> |
34 | 35 | ||
35 | // template tags for address formatting localization | 36 | // template tags for address formatting localization |
36 | #define KABC_FMTTAG_realname QString("%n") | 37 | #define KABC_FMTTAG_realname QString("%n") |
37 | #define KABC_FMTTAG_REALNAME QString("%N") | 38 | #define KABC_FMTTAG_REALNAME QString("%N") |
38 | #define KABC_FMTTAG_company QString("%cm") | 39 | #define KABC_FMTTAG_company QString("%cm") |
39 | #define KABC_FMTTAG_COMPANY QString("%CM") | 40 | #define KABC_FMTTAG_COMPANY QString("%CM") |
40 | #define KABC_FMTTAG_pobox QString("%p") | 41 | #define KABC_FMTTAG_pobox QString("%p") |
41 | #define KABC_FMTTAG_street QString("%s") | 42 | #define KABC_FMTTAG_street QString("%s") |
42 | #define KABC_FMTTAG_STREET QString("%S") | 43 | #define KABC_FMTTAG_STREET QString("%S") |
43 | #define KABC_FMTTAG_zipcode QString("%z") | 44 | #define KABC_FMTTAG_zipcode QString("%z") |
44 | #define KABC_FMTTAG_location QString("%l") | 45 | #define KABC_FMTTAG_location QString("%l") |
45 | #define KABC_FMTTAG_LOCATION QString("%L") | 46 | #define KABC_FMTTAG_LOCATION QString("%L") |
46 | #define KABC_FMTTAG_region QString("%r") | 47 | #define KABC_FMTTAG_region QString("%r") |
47 | #define KABC_FMTTAG_REGION QString("%R") | 48 | #define KABC_FMTTAG_REGION QString("%R") |
48 | #define KABC_FMTTAG_newline QString("\\n") | 49 | #define KABC_FMTTAG_newline QString("\\n") |
49 | #define KABC_FMTTAG_condcomma QString("%,") | 50 | #define KABC_FMTTAG_condcomma QString("%,") |
50 | #define KABC_FMTTAG_condwhite QString("%w") | 51 | #define KABC_FMTTAG_condwhite QString("%w") |
51 | #define KABC_FMTTAG_purgeempty QString("%0") | 52 | #define KABC_FMTTAG_purgeempty QString("%0") |
52 | 53 | ||
53 | namespace KABC { | 54 | namespace KABC { |
54 | 55 | ||
55 | /** | 56 | /** |
56 | @short Postal address information. | 57 | @short Postal address information. |
57 | 58 | ||
58 | This class represents information about a postal address. | 59 | This class represents information about a postal address. |
59 | */ | 60 | */ |
60 | class Address | 61 | class Address |
61 | { | 62 | { |
62 | friend QDataStream &operator<<( QDataStream &, const Address & ); | 63 | friend QDataStream &operator<<( QDataStream &, const Address & ); |
63 | friend QDataStream &operator>>( QDataStream &, Address & ); | 64 | friend QDataStream &operator>>( QDataStream &, Address & ); |
64 | 65 | ||
65 | public: | 66 | public: |
66 | /** | 67 | /** |
67 | List of addresses. | 68 | List of addresses. |
68 | */ | 69 | */ |
69 | typedef QValueList<Address> List; | 70 | typedef QValueList<Address> List; |
70 | typedef QValueList<int> TypeList; | 71 | typedef QValueList<int> TypeList; |
71 | 72 | ||
72 | /** | 73 | /** |
73 | Address types: | 74 | Address types: |
74 | 75 | ||
75 | @li @p Dom - domestic | 76 | @li @p Dom - domestic |
76 | @li @p Intl - international | 77 | @li @p Intl - international |
77 | @li @p Postal - postal | 78 | @li @p Postal - postal |
78 | @li @p Parcel - parcel | 79 | @li @p Parcel - parcel |
79 | @li @p Home - home address | 80 | @li @p Home - home address |
80 | @li @p Work - address at work | 81 | @li @p Work - address at work |
81 | @li @p Pref - preferred address | 82 | @li @p Pref - preferred address |
82 | */ | 83 | */ |
83 | enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, | 84 | enum Type { Dom = 1, Intl = 2, Postal = 4, Parcel = 8, Home = 16, Work = 32, |
84 | Pref = 64 }; | 85 | Pref = 64 }; |
85 | 86 | ||
86 | /** | 87 | /** |
87 | Constructor that creates an empty Address, which is initialized | 88 | Constructor that creates an empty Address, which is initialized |
88 | with a unique id (see @ref id()). | 89 | with a unique id (see @ref id()). |
89 | */ | 90 | */ |
90 | Address(); | 91 | Address(); |
91 | 92 | ||
92 | /** | 93 | /** |
93 | This is like @ref Address() just above, with the difference | 94 | This is like @ref Address() just above, with the difference |
94 | that you can specify the type. | 95 | that you can specify the type. |
95 | */ | 96 | */ |
96 | Address( int ); | 97 | Address( int ); |
97 | 98 | ||
98 | bool operator==( const Address & ) const; | 99 | bool operator==( const Address & ) const; |
99 | bool operator!=( const Address & ) const; | 100 | bool operator!=( const Address & ) const; |
100 | 101 | ||
101 | /** | 102 | /** |
102 | Returns true, if the address is empty. | 103 | Returns true, if the address is empty. |
103 | */ | 104 | */ |
104 | bool isEmpty() const; | 105 | bool isEmpty() const; |
105 | 106 | ||
106 | /** | 107 | /** |
107 | Clears all entries of the address. | 108 | Clears all entries of the address. |
108 | */ | 109 | */ |
109 | void clear(); | 110 | void clear(); |
110 | QStringList asList(); | 111 | QStringList asList(); |
111 | 112 | ||
112 | /** | 113 | /** |
113 | Sets the unique id. | 114 | Sets the unique id. |
114 | */ | 115 | */ |
115 | void setId( const QString & ); | 116 | void setId( const QString & ); |
116 | 117 | ||
117 | /* | 118 | /* |
118 | Returns the unique id. | 119 | Returns the unique id. |
119 | */ | 120 | */ |
120 | QString id() const; | 121 | QString id() const; |
121 | 122 | ||
122 | /** | 123 | /** |
123 | Sets the type of address. See enum for definiton of types. | 124 | Sets the type of address. See enum for definiton of types. |
124 | 125 | ||
125 | @param type type, can be a bitwise or of multiple types. | 126 | @param type type, can be a bitwise or of multiple types. |
126 | */ | 127 | */ |
127 | void setType( int type ); | 128 | void setType( int type ); |
128 | 129 | ||
129 | /** | 130 | /** |
130 | Returns the type of address. Can be a bitwise or of multiple types. | 131 | Returns the type of address. Can be a bitwise or of multiple types. |
131 | */ | 132 | */ |
132 | int type() const; | 133 | int type() const; |
133 | 134 | ||
134 | /** | 135 | /** |
135 | Returns a translated string of all types the address has. | 136 | Returns a translated string of all types the address has. |
136 | */ | 137 | */ |
137 | QString typeLabel() const; | 138 | QString typeLabel() const; |
138 | 139 | ||
139 | /** | 140 | /** |
140 | Sets the post office box. | 141 | Sets the post office box. |
141 | */ | 142 | */ |
142 | void setPostOfficeBox( const QString & ); | 143 | void setPostOfficeBox( const QString & ); |
143 | 144 | ||
144 | /** | 145 | /** |
145 | Returns the post office box. | 146 | Returns the post office box. |
146 | */ | 147 | */ |
147 | QString postOfficeBox() const; | 148 | QString postOfficeBox() const; |
148 | 149 | ||
149 | /** | 150 | /** |
150 | Returns the translated label for post office box field. | 151 | Returns the translated label for post office box field. |
151 | */ | 152 | */ |
152 | static QString postOfficeBoxLabel(); | 153 | static QString postOfficeBoxLabel(); |
153 | 154 | ||
154 | /** | 155 | /** |
155 | Sets the extended address information. | 156 | Sets the extended address information. |
156 | */ | 157 | */ |
157 | void setExtended( const QString & ); | 158 | void setExtended( const QString & ); |
158 | 159 | ||
159 | /** | 160 | /** |
160 | Returns the extended address information. | 161 | Returns the extended address information. |
161 | */ | 162 | */ |
162 | QString extended() const; | 163 | QString extended() const; |
163 | 164 | ||
164 | /** | 165 | /** |
165 | Returns the translated label for extended field. | 166 | Returns the translated label for extended field. |
166 | */ | 167 | */ |
167 | static QString extendedLabel(); | 168 | static QString extendedLabel(); |
168 | 169 | ||
169 | /** | 170 | /** |
170 | Sets the street (including number). | 171 | Sets the street (including number). |
171 | */ | 172 | */ |
172 | void setStreet( const QString & ); | 173 | void setStreet( const QString & ); |
173 | 174 | ||
174 | /** | 175 | /** |
175 | Returns the street. | 176 | Returns the street. |
176 | */ | 177 | */ |
177 | QString street() const; | 178 | QString street() const; |
178 | 179 | ||
179 | /** | 180 | /** |
180 | Returns the translated label for street field. | 181 | Returns the translated label for street field. |
181 | */ | 182 | */ |
182 | static QString streetLabel(); | 183 | static QString streetLabel(); |
183 | 184 | ||
184 | /** | 185 | /** |
185 | Sets the locality, e.g. city. | 186 | Sets the locality, e.g. city. |
186 | */ | 187 | */ |
187 | void setLocality( const QString & ); | 188 | void setLocality( const QString & ); |
188 | 189 | ||
189 | /** | 190 | /** |
190 | Returns the locality. | 191 | Returns the locality. |
191 | */ | 192 | */ |
192 | QString locality() const; | 193 | QString locality() const; |
193 | 194 | ||
194 | /** | 195 | /** |
195 | Returns the translated label for locality field. | 196 | Returns the translated label for locality field. |
196 | */ | 197 | */ |
197 | static QString localityLabel(); | 198 | static QString localityLabel(); |
198 | 199 | ||
199 | /** | 200 | /** |
200 | Sets the region, e.g. state. | 201 | Sets the region, e.g. state. |
201 | */ | 202 | */ |
202 | void setRegion( const QString & ); | 203 | void setRegion( const QString & ); |
203 | 204 | ||
204 | /** | 205 | /** |
205 | Returns the region. | 206 | Returns the region. |
206 | */ | 207 | */ |
207 | QString region() const; | 208 | QString region() const; |
208 | 209 | ||
209 | /** | 210 | /** |
210 | Returns the translated label for region field. | 211 | Returns the translated label for region field. |
211 | */ | 212 | */ |
212 | static QString regionLabel(); | 213 | static QString regionLabel(); |
213 | 214 | ||
214 | /** | 215 | /** |
215 | Sets the postal code. | 216 | Sets the postal code. |
216 | */ | 217 | */ |
217 | void setPostalCode( const QString & ); | 218 | void setPostalCode( const QString & ); |
218 | 219 | ||
219 | /** | 220 | /** |
220 | Returns the postal code. | 221 | Returns the postal code. |
221 | */ | 222 | */ |
222 | QString postalCode() const; | 223 | QString postalCode() const; |
223 | 224 | ||
224 | /** | 225 | /** |
225 | Returns the translated label for postal code field. | 226 | Returns the translated label for postal code field. |
226 | */ | 227 | */ |
227 | static QString postalCodeLabel(); | 228 | static QString postalCodeLabel(); |
228 | 229 | ||
229 | /** | 230 | /** |
230 | Sets the country. | 231 | Sets the country. |
231 | */ | 232 | */ |
232 | void setCountry( const QString & ); | 233 | void setCountry( const QString & ); |
233 | 234 | ||
234 | /** | 235 | /** |
235 | Returns the country. | 236 | Returns the country. |
236 | */ | 237 | */ |
237 | QString country() const; | 238 | QString country() const; |
238 | 239 | ||
239 | /** | 240 | /** |
240 | Returns the translated label for country field. | 241 | Returns the translated label for country field. |
241 | */ | 242 | */ |
242 | static QString countryLabel(); | 243 | static QString countryLabel(); |
243 | 244 | ||
244 | /** | 245 | /** |
245 | Sets the delivery label. This is the literal text to be used as label. | 246 | Sets the delivery label. This is the literal text to be used as label. |
246 | */ | 247 | */ |
247 | void setLabel( const QString & ); | 248 | void setLabel( const QString & ); |
248 | 249 | ||
249 | /** | 250 | /** |
250 | Returns the delivery label. | 251 | Returns the delivery label. |
251 | */ | 252 | */ |
252 | QString label() const; | 253 | QString label() const; |
253 | 254 | ||
254 | /** | 255 | /** |
255 | Returns the translated label for delivery label field. | 256 | Returns the translated label for delivery label field. |
256 | */ | 257 | */ |
257 | static QString labelLabel(); | 258 | static QString labelLabel(); |
258 | 259 | ||
259 | /** | 260 | /** |
260 | Returns the list of available types. | 261 | Returns the list of available types. |
261 | */ | 262 | */ |
262 | static TypeList typeList(); | 263 | static TypeList typeList(); |
263 | 264 | ||
264 | /** | 265 | /** |
265 | Returns the translated label for a special type. | 266 | Returns the translated label for a special type. |
266 | */ | 267 | */ |
267 | static QString typeLabel( int type ); | 268 | static QString typeLabel( int type ); |
268 | 269 | ||
269 | /** | 270 | /** |
270 | Used for debug output. | 271 | Used for debug output. |
271 | */ | 272 | */ |
272 | void dump() const; | 273 | void dump() const; |
273 | 274 | ||
274 | /** | 275 | /** |
275 | Returns this address formatted according to the country-specific | 276 | Returns this address formatted according to the country-specific |
276 | address formatting rules. The formatting rules applied depend on | 277 | address formatting rules. The formatting rules applied depend on |
277 | either the addresses {@link #country country} field, or (if the | 278 | either the addresses {@link #country country} field, or (if the |
278 | latter is empty) on the system country setting. If companyName is | 279 | latter is empty) on the system country setting. If companyName is |
279 | provided, an available business address format will be preferred. | 280 | provided, an available business address format will be preferred. |
280 | 281 | ||
281 | @param realName the formatted name of the contact | 282 | @param realName the formatted name of the contact |
282 | @param orgaName the name of the organization or company | 283 | @param orgaName the name of the organization or company |
283 | @return the formatted address (containing newline characters) | 284 | @return the formatted address (containing newline characters) |
284 | */ | 285 | */ |
285 | QString formattedAddress( const QString &realName=QString::null | 286 | QString formattedAddress( const QString &realName=QString::null |
286 | , const QString &orgaName=QString::null ) const; | 287 | , const QString &orgaName=QString::null ) const; |
287 | 288 | ||
288 | /** | 289 | /** |
289 | Returns ISO code for a localized country name. Only localized country | 290 | Returns ISO code for a localized country name. Only localized country |
290 | names will be understood. This might be replaced by a KLocale method in | 291 | names will be understood. This might be replaced by a KLocale method in |
291 | the future. | 292 | the future. |
292 | @param cname name of the country | 293 | @param cname name of the country |
293 | @return two digit ISO code | 294 | @return two digit ISO code |
294 | */ | 295 | */ |
295 | static QString countryToISO( const QString &cname ); | 296 | static QString countryToISO( const QString &cname ); |
296 | 297 | ||
297 | /** | 298 | /** |
298 | Returns a localized country name for a ISO code. | 299 | Returns a localized country name for a ISO code. |
299 | This might be replaced by a KLocale method in the future. | 300 | This might be replaced by a KLocale method in the future. |
300 | @param ISOname two digit ISO code | 301 | @param ISOname two digit ISO code |
301 | @return localized name of the country | 302 | @return localized name of the country |
302 | @since 3.2 | 303 | @since 3.2 |
303 | */ | 304 | */ |
304 | static QString ISOtoCountry( const QString &ISOname ); | 305 | static QString ISOtoCountry( const QString &ISOname ); |
305 | 306 | ||
306 | private: | 307 | private: |
307 | /** | 308 | /** |
308 | Parses a snippet of an address template | 309 | Parses a snippet of an address template |
309 | @param tsection the template string to be parsed | 310 | @param tsection the template string to be parsed |
310 | @param result QString reference in which the result will be stored | 311 | @param result QString reference in which the result will be stored |
311 | @return true if at least one tag evaluated positively, else false | 312 | @return true if at least one tag evaluated positively, else false |
312 | */ | 313 | */ |
313 | bool parseAddressTemplateSection( const QString &tsection | 314 | bool parseAddressTemplateSection( const QString &tsection |
314 | , QString &result | 315 | , QString &result |
315 | , const QString &realName | 316 | , const QString &realName |
316 | , const QString &orgaName ) const; | 317 | , const QString &orgaName ) const; |
317 | 318 | ||
318 | /** | 319 | /** |
319 | Finds the balanced closing bracket starting from the opening bracket at | 320 | Finds the balanced closing bracket starting from the opening bracket at |
320 | pos in tsection. | 321 | pos in tsection. |
321 | @return position of closing bracket, -1 for unbalanced brackets | 322 | @return position of closing bracket, -1 for unbalanced brackets |
322 | */ | 323 | */ |
323 | int findBalancedBracket( const QString &tsection, int pos ) const; | 324 | int findBalancedBracket( const QString &tsection, int pos ) const; |
324 | 325 | ||
325 | bool mEmpty; | 326 | bool mEmpty; |
326 | 327 | ||
327 | QString mId; | 328 | QString mId; |
328 | int mType; | 329 | int mType; |
329 | 330 | ||
330 | QString mPostOfficeBox; | 331 | QString mPostOfficeBox; |
331 | QString mExtended; | 332 | QString mExtended; |
332 | QString mStreet; | 333 | QString mStreet; |
333 | QString mLocality; | 334 | QString mLocality; |
334 | QString mRegion; | 335 | QString mRegion; |
335 | QString mPostalCode; | 336 | QString mPostalCode; |
336 | QString mCountry; | 337 | QString mCountry; |
337 | QString mLabel; | 338 | QString mLabel; |
338 | 339 | ||
339 | static QMap<QString, QString> mISOMap; | 340 | static QMap<QString, QString> mISOMap; |
340 | }; | 341 | }; |
341 | 342 | ||
342 | QDataStream &operator<<( QDataStream &, const Address & ); | 343 | QDataStream &operator<<( QDataStream &, const Address & ); |
343 | QDataStream &operator>>( QDataStream &, Address & ); | 344 | QDataStream &operator>>( QDataStream &, Address & ); |
344 | 345 | ||
345 | } | 346 | } |
346 | 347 | ||
347 | #endif | 348 | #endif |
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 46a9cf4..64832f1 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,866 +1,890 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | 41 | ||
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <libkcal/syncdefines.h> | 45 | #include <libkcal/syncdefines.h> |
46 | #include "addressbook.h" | 46 | #include "addressbook.h" |
47 | #include "resource.h" | 47 | #include "resource.h" |
48 | 48 | ||
49 | //US #include "addressbook.moc" | 49 | //US #include "addressbook.moc" |
50 | 50 | ||
51 | using namespace KABC; | 51 | using namespace KABC; |
52 | 52 | ||
53 | struct AddressBook::AddressBookData | 53 | struct AddressBook::AddressBookData |
54 | { | 54 | { |
55 | Addressee::List mAddressees; | 55 | Addressee::List mAddressees; |
56 | Addressee::List mRemovedAddressees; | 56 | Addressee::List mRemovedAddressees; |
57 | Field::List mAllFields; | 57 | Field::List mAllFields; |
58 | KConfig *mConfig; | 58 | KConfig *mConfig; |
59 | KRES::Manager<Resource> *mManager; | 59 | KRES::Manager<Resource> *mManager; |
60 | //US ErrorHandler *mErrorHandler; | 60 | //US ErrorHandler *mErrorHandler; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | struct AddressBook::Iterator::IteratorData | 63 | struct AddressBook::Iterator::IteratorData |
64 | { | 64 | { |
65 | Addressee::List::Iterator mIt; | 65 | Addressee::List::Iterator mIt; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | struct AddressBook::ConstIterator::ConstIteratorData | 68 | struct AddressBook::ConstIterator::ConstIteratorData |
69 | { | 69 | { |
70 | Addressee::List::ConstIterator mIt; | 70 | Addressee::List::ConstIterator mIt; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | AddressBook::Iterator::Iterator() | 73 | AddressBook::Iterator::Iterator() |
74 | { | 74 | { |
75 | d = new IteratorData; | 75 | d = new IteratorData; |
76 | } | 76 | } |
77 | 77 | ||
78 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 78 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
79 | { | 79 | { |
80 | d = new IteratorData; | 80 | d = new IteratorData; |
81 | d->mIt = i.d->mIt; | 81 | d->mIt = i.d->mIt; |
82 | } | 82 | } |
83 | 83 | ||
84 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 84 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
85 | { | 85 | { |
86 | if( this == &i ) return *this; // guard against self assignment | 86 | if( this == &i ) return *this; // guard against self assignment |
87 | delete d; // delete the old data the Iterator was completely constructed before | 87 | delete d; // delete the old data the Iterator was completely constructed before |
88 | d = new IteratorData; | 88 | d = new IteratorData; |
89 | d->mIt = i.d->mIt; | 89 | d->mIt = i.d->mIt; |
90 | return *this; | 90 | return *this; |
91 | } | 91 | } |
92 | 92 | ||
93 | AddressBook::Iterator::~Iterator() | 93 | AddressBook::Iterator::~Iterator() |
94 | { | 94 | { |
95 | delete d; | 95 | delete d; |
96 | } | 96 | } |
97 | 97 | ||
98 | const Addressee &AddressBook::Iterator::operator*() const | 98 | const Addressee &AddressBook::Iterator::operator*() const |
99 | { | 99 | { |
100 | return *(d->mIt); | 100 | return *(d->mIt); |
101 | } | 101 | } |
102 | 102 | ||
103 | Addressee &AddressBook::Iterator::operator*() | 103 | Addressee &AddressBook::Iterator::operator*() |
104 | { | 104 | { |
105 | return *(d->mIt); | 105 | return *(d->mIt); |
106 | } | 106 | } |
107 | 107 | ||
108 | Addressee *AddressBook::Iterator::operator->() | 108 | Addressee *AddressBook::Iterator::operator->() |
109 | { | 109 | { |
110 | return &(*(d->mIt)); | 110 | return &(*(d->mIt)); |
111 | } | 111 | } |
112 | 112 | ||
113 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 113 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
114 | { | 114 | { |
115 | (d->mIt)++; | 115 | (d->mIt)++; |
116 | return *this; | 116 | return *this; |
117 | } | 117 | } |
118 | 118 | ||
119 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 119 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
120 | { | 120 | { |
121 | (d->mIt)++; | 121 | (d->mIt)++; |
122 | return *this; | 122 | return *this; |
123 | } | 123 | } |
124 | 124 | ||
125 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 125 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
126 | { | 126 | { |
127 | (d->mIt)--; | 127 | (d->mIt)--; |
128 | return *this; | 128 | return *this; |
129 | } | 129 | } |
130 | 130 | ||
131 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 131 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
132 | { | 132 | { |
133 | (d->mIt)--; | 133 | (d->mIt)--; |
134 | return *this; | 134 | return *this; |
135 | } | 135 | } |
136 | 136 | ||
137 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 137 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
138 | { | 138 | { |
139 | return ( d->mIt == it.d->mIt ); | 139 | return ( d->mIt == it.d->mIt ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
143 | { | 143 | { |
144 | return ( d->mIt != it.d->mIt ); | 144 | return ( d->mIt != it.d->mIt ); |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | AddressBook::ConstIterator::ConstIterator() | 148 | AddressBook::ConstIterator::ConstIterator() |
149 | { | 149 | { |
150 | d = new ConstIteratorData; | 150 | d = new ConstIteratorData; |
151 | } | 151 | } |
152 | 152 | ||
153 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 153 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
154 | { | 154 | { |
155 | d = new ConstIteratorData; | 155 | d = new ConstIteratorData; |
156 | d->mIt = i.d->mIt; | 156 | d->mIt = i.d->mIt; |
157 | } | 157 | } |
158 | 158 | ||
159 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 159 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
160 | { | 160 | { |
161 | if( this == &i ) return *this; // guard for self assignment | 161 | if( this == &i ) return *this; // guard for self assignment |
162 | delete d; // delete the old data because the Iterator was really constructed before | 162 | delete d; // delete the old data because the Iterator was really constructed before |
163 | d = new ConstIteratorData; | 163 | d = new ConstIteratorData; |
164 | d->mIt = i.d->mIt; | 164 | d->mIt = i.d->mIt; |
165 | return *this; | 165 | return *this; |
166 | } | 166 | } |
167 | 167 | ||
168 | AddressBook::ConstIterator::~ConstIterator() | 168 | AddressBook::ConstIterator::~ConstIterator() |
169 | { | 169 | { |
170 | delete d; | 170 | delete d; |
171 | } | 171 | } |
172 | 172 | ||
173 | const Addressee &AddressBook::ConstIterator::operator*() const | 173 | const Addressee &AddressBook::ConstIterator::operator*() const |
174 | { | 174 | { |
175 | return *(d->mIt); | 175 | return *(d->mIt); |
176 | } | 176 | } |
177 | 177 | ||
178 | const Addressee* AddressBook::ConstIterator::operator->() const | 178 | const Addressee* AddressBook::ConstIterator::operator->() const |
179 | { | 179 | { |
180 | return &(*(d->mIt)); | 180 | return &(*(d->mIt)); |
181 | } | 181 | } |
182 | 182 | ||
183 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 183 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
184 | { | 184 | { |
185 | (d->mIt)++; | 185 | (d->mIt)++; |
186 | return *this; | 186 | return *this; |
187 | } | 187 | } |
188 | 188 | ||
189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
190 | { | 190 | { |
191 | (d->mIt)++; | 191 | (d->mIt)++; |
192 | return *this; | 192 | return *this; |
193 | } | 193 | } |
194 | 194 | ||
195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
196 | { | 196 | { |
197 | (d->mIt)--; | 197 | (d->mIt)--; |
198 | return *this; | 198 | return *this; |
199 | } | 199 | } |
200 | 200 | ||
201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
202 | { | 202 | { |
203 | (d->mIt)--; | 203 | (d->mIt)--; |
204 | return *this; | 204 | return *this; |
205 | } | 205 | } |
206 | 206 | ||
207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
208 | { | 208 | { |
209 | return ( d->mIt == it.d->mIt ); | 209 | return ( d->mIt == it.d->mIt ); |
210 | } | 210 | } |
211 | 211 | ||
212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
213 | { | 213 | { |
214 | return ( d->mIt != it.d->mIt ); | 214 | return ( d->mIt != it.d->mIt ); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | AddressBook::AddressBook() | 218 | AddressBook::AddressBook() |
219 | { | 219 | { |
220 | init(0, "contact"); | 220 | init(0, "contact"); |
221 | } | 221 | } |
222 | 222 | ||
223 | AddressBook::AddressBook( const QString &config ) | 223 | AddressBook::AddressBook( const QString &config ) |
224 | { | 224 | { |
225 | init(config, "contact"); | 225 | init(config, "contact"); |
226 | } | 226 | } |
227 | 227 | ||
228 | AddressBook::AddressBook( const QString &config, const QString &family ) | 228 | AddressBook::AddressBook( const QString &config, const QString &family ) |
229 | { | 229 | { |
230 | init(config, family); | 230 | init(config, family); |
231 | 231 | ||
232 | } | 232 | } |
233 | 233 | ||
234 | // the default family is "contact" | 234 | // the default family is "contact" |
235 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
236 | { | 236 | { |
237 | blockLSEchange = false; | 237 | blockLSEchange = false; |
238 | d = new AddressBookData; | 238 | d = new AddressBookData; |
239 | QString fami = family; | 239 | QString fami = family; |
240 | qDebug("new ab "); | 240 | qDebug("new ab "); |
241 | if (config != 0) { | 241 | if (config != 0) { |
242 | qDebug("config != 0 "); | 242 | qDebug("config != 0 "); |
243 | if ( family == "syncContact" ) { | 243 | if ( family == "syncContact" ) { |
244 | qDebug("creating sync config "); | 244 | qDebug("creating sync config "); |
245 | fami = "contact"; | 245 | fami = "contact"; |
246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 246 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
247 | con->setGroup( "General" ); | 247 | con->setGroup( "General" ); |
248 | con->writeEntry( "ResourceKeys", QString("sync") ); | 248 | con->writeEntry( "ResourceKeys", QString("sync") ); |
249 | con->writeEntry( "Standard", QString("sync") ); | 249 | con->writeEntry( "Standard", QString("sync") ); |
250 | con->setGroup( "Resource_sync" ); | 250 | con->setGroup( "Resource_sync" ); |
251 | con->writeEntry( "FileFormat", QString("vcard") ); | ||
252 | con->writeEntry( "FileName", config ); | 251 | con->writeEntry( "FileName", config ); |
252 | con->writeEntry( "FileFormat", QString("vcard") ); | ||
253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 253 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
254 | con->writeEntry( "ResourceName", QString("sync_res") ); | 254 | con->writeEntry( "ResourceName", QString("sync_res") ); |
255 | con->writeEntry( "ResourceType", QString("file") ); | 255 | if ( config.right(4) == ".xml" ) |
256 | con->writeEntry( "ResourceType", QString("qtopia") ); | ||
257 | else | ||
258 | con->writeEntry( "ResourceType", QString("file") ); | ||
256 | //con->sync(); | 259 | //con->sync(); |
257 | d->mConfig = con; | 260 | d->mConfig = con; |
258 | } | 261 | } |
259 | else | 262 | else |
260 | d->mConfig = new KConfig( locateLocal("config", config) ); | 263 | d->mConfig = new KConfig( locateLocal("config", config) ); |
261 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 264 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
262 | } | 265 | } |
263 | else { | 266 | else { |
264 | d->mConfig = 0; | 267 | d->mConfig = 0; |
265 | // qDebug("AddressBook::init 1 config=0"); | 268 | // qDebug("AddressBook::init 1 config=0"); |
266 | } | 269 | } |
267 | 270 | ||
268 | //US d->mErrorHandler = 0; | 271 | //US d->mErrorHandler = 0; |
269 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 272 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
270 | d->mManager->readConfig( d->mConfig ); | 273 | d->mManager->readConfig( d->mConfig ); |
271 | if ( family == "syncContact" ) { | 274 | if ( family == "syncContact" ) { |
272 | KRES::Manager<Resource> *manager = d->mManager; | 275 | KRES::Manager<Resource> *manager = d->mManager; |
273 | KRES::Manager<Resource>::ActiveIterator it; | 276 | KRES::Manager<Resource>::ActiveIterator it; |
274 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 277 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
275 | (*it)->setAddressBook( this ); | 278 | (*it)->setAddressBook( this ); |
276 | if ( !(*it)->open() ) | 279 | if ( !(*it)->open() ) |
277 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 280 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
278 | } | 281 | } |
279 | Resource *res = standardResource(); | 282 | Resource *res = standardResource(); |
280 | if ( !res ) { | 283 | if ( !res ) { |
281 | qDebug("ERROR: no standard resource"); | 284 | qDebug("ERROR: no standard resource"); |
282 | res = manager->createResource( "file" ); | 285 | res = manager->createResource( "file" ); |
283 | if ( res ) | 286 | if ( res ) |
284 | { | 287 | { |
285 | addResource( res ); | 288 | addResource( res ); |
286 | } | 289 | } |
287 | else | 290 | else |
288 | qDebug(" No resource available!!!"); | 291 | qDebug(" No resource available!!!"); |
289 | } | 292 | } |
290 | setStandardResource( res ); | 293 | setStandardResource( res ); |
291 | manager->writeConfig(); | 294 | manager->writeConfig(); |
292 | } | 295 | } |
293 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 296 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
294 | "X-Department", "KADDRESSBOOK" ); | 297 | "X-Department", "KADDRESSBOOK" ); |
295 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 298 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
296 | "X-Profession", "KADDRESSBOOK" ); | 299 | "X-Profession", "KADDRESSBOOK" ); |
297 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 300 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
298 | "X-AssistantsName", "KADDRESSBOOK" ); | 301 | "X-AssistantsName", "KADDRESSBOOK" ); |
299 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 302 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
300 | "X-ManagersName", "KADDRESSBOOK" ); | 303 | "X-ManagersName", "KADDRESSBOOK" ); |
301 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 304 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
302 | "X-SpousesName", "KADDRESSBOOK" ); | 305 | "X-SpousesName", "KADDRESSBOOK" ); |
303 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 306 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
304 | "X-Office", "KADDRESSBOOK" ); | 307 | "X-Office", "KADDRESSBOOK" ); |
305 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 308 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
306 | "X-IMAddress", "KADDRESSBOOK" ); | 309 | "X-IMAddress", "KADDRESSBOOK" ); |
307 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 310 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
308 | "X-Anniversary", "KADDRESSBOOK" ); | 311 | "X-Anniversary", "KADDRESSBOOK" ); |
309 | 312 | ||
310 | //US added this field to become compatible with Opie/qtopia addressbook | 313 | //US added this field to become compatible with Opie/qtopia addressbook |
311 | // values can be "female" or "male" or "". An empty field represents undefined. | 314 | // values can be "female" or "male" or "". An empty field represents undefined. |
312 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 315 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
313 | "X-Gender", "KADDRESSBOOK" ); | 316 | "X-Gender", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 317 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
315 | "X-Children", "KADDRESSBOOK" ); | 318 | "X-Children", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 319 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
317 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 320 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
318 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 321 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
319 | "X-ExternalID", "KADDRESSBOOK" ); | 322 | "X-ExternalID", "KADDRESSBOOK" ); |
320 | } | 323 | } |
321 | 324 | ||
322 | AddressBook::~AddressBook() | 325 | AddressBook::~AddressBook() |
323 | { | 326 | { |
324 | delete d->mConfig; d->mConfig = 0; | 327 | delete d->mConfig; d->mConfig = 0; |
325 | delete d->mManager; d->mManager = 0; | 328 | delete d->mManager; d->mManager = 0; |
326 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 329 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
327 | delete d; d = 0; | 330 | delete d; d = 0; |
328 | } | 331 | } |
329 | 332 | ||
330 | bool AddressBook::load() | 333 | bool AddressBook::load() |
331 | { | 334 | { |
332 | 335 | ||
333 | 336 | ||
334 | clear(); | 337 | clear(); |
335 | 338 | ||
336 | KRES::Manager<Resource>::ActiveIterator it; | 339 | KRES::Manager<Resource>::ActiveIterator it; |
337 | bool ok = true; | 340 | bool ok = true; |
338 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 341 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
339 | if ( !(*it)->load() ) { | 342 | if ( !(*it)->load() ) { |
340 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 343 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
341 | ok = false; | 344 | ok = false; |
342 | } | 345 | } |
343 | 346 | ||
344 | // mark all addressees as unchanged | 347 | // mark all addressees as unchanged |
345 | Addressee::List::Iterator addrIt; | 348 | Addressee::List::Iterator addrIt; |
346 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 349 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
347 | (*addrIt).setChanged( false ); | 350 | (*addrIt).setChanged( false ); |
348 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 351 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
349 | if ( !id.isEmpty() ) { | 352 | if ( !id.isEmpty() ) { |
350 | //qDebug("setId aa %s ", id.latin1()); | 353 | //qDebug("setId aa %s ", id.latin1()); |
351 | (*addrIt).setIDStr(id ); | 354 | (*addrIt).setIDStr(id ); |
352 | } | 355 | } |
353 | } | 356 | } |
354 | blockLSEchange = true; | 357 | blockLSEchange = true; |
355 | return ok; | 358 | return ok; |
356 | } | 359 | } |
357 | 360 | ||
358 | bool AddressBook::save( Ticket *ticket ) | 361 | bool AddressBook::save( Ticket *ticket ) |
359 | { | 362 | { |
360 | kdDebug(5700) << "AddressBook::save()"<< endl; | 363 | kdDebug(5700) << "AddressBook::save()"<< endl; |
361 | 364 | ||
362 | if ( ticket->resource() ) { | 365 | if ( ticket->resource() ) { |
363 | deleteRemovedAddressees(); | 366 | deleteRemovedAddressees(); |
364 | return ticket->resource()->save( ticket ); | 367 | return ticket->resource()->save( ticket ); |
365 | } | 368 | } |
366 | 369 | ||
367 | return false; | 370 | return false; |
368 | } | 371 | } |
369 | bool AddressBook::saveAB() | 372 | bool AddressBook::saveAB() |
370 | { | 373 | { |
371 | bool ok = true; | 374 | bool ok = true; |
372 | 375 | ||
373 | deleteRemovedAddressees(); | 376 | deleteRemovedAddressees(); |
374 | Iterator ait; | 377 | Iterator ait; |
375 | for ( ait = begin(); ait != end(); ++ait ) { | 378 | for ( ait = begin(); ait != end(); ++ait ) { |
376 | if ( !(*ait).IDStr().isEmpty() ) { | 379 | if ( !(*ait).IDStr().isEmpty() ) { |
377 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 380 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
378 | } | 381 | } |
379 | } | 382 | } |
380 | KRES::Manager<Resource>::ActiveIterator it; | 383 | KRES::Manager<Resource>::ActiveIterator it; |
381 | KRES::Manager<Resource> *manager = d->mManager; | 384 | KRES::Manager<Resource> *manager = d->mManager; |
382 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 385 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
383 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 386 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
384 | Ticket *ticket = requestSaveTicket( *it ); | 387 | Ticket *ticket = requestSaveTicket( *it ); |
385 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 388 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
386 | if ( !ticket ) { | 389 | if ( !ticket ) { |
387 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 390 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
388 | .arg( (*it)->resourceName() ) ); | 391 | .arg( (*it)->resourceName() ) ); |
389 | return false; | 392 | return false; |
390 | } | 393 | } |
391 | 394 | ||
392 | //if ( !save( ticket ) ) | 395 | //if ( !save( ticket ) ) |
393 | if ( ticket->resource() ) { | 396 | if ( ticket->resource() ) { |
394 | if ( ! ticket->resource()->save( ticket ) ) | 397 | if ( ! ticket->resource()->save( ticket ) ) |
395 | ok = false; | 398 | ok = false; |
396 | } else | 399 | } else |
397 | ok = false; | 400 | ok = false; |
398 | 401 | ||
399 | } | 402 | } |
400 | } | 403 | } |
401 | return ok; | 404 | return ok; |
402 | } | 405 | } |
403 | 406 | ||
404 | AddressBook::Iterator AddressBook::begin() | 407 | AddressBook::Iterator AddressBook::begin() |
405 | { | 408 | { |
406 | Iterator it = Iterator(); | 409 | Iterator it = Iterator(); |
407 | it.d->mIt = d->mAddressees.begin(); | 410 | it.d->mIt = d->mAddressees.begin(); |
408 | return it; | 411 | return it; |
409 | } | 412 | } |
410 | 413 | ||
411 | AddressBook::ConstIterator AddressBook::begin() const | 414 | AddressBook::ConstIterator AddressBook::begin() const |
412 | { | 415 | { |
413 | ConstIterator it = ConstIterator(); | 416 | ConstIterator it = ConstIterator(); |
414 | it.d->mIt = d->mAddressees.begin(); | 417 | it.d->mIt = d->mAddressees.begin(); |
415 | return it; | 418 | return it; |
416 | } | 419 | } |
417 | 420 | ||
418 | AddressBook::Iterator AddressBook::end() | 421 | AddressBook::Iterator AddressBook::end() |
419 | { | 422 | { |
420 | Iterator it = Iterator(); | 423 | Iterator it = Iterator(); |
421 | it.d->mIt = d->mAddressees.end(); | 424 | it.d->mIt = d->mAddressees.end(); |
422 | return it; | 425 | return it; |
423 | } | 426 | } |
424 | 427 | ||
425 | AddressBook::ConstIterator AddressBook::end() const | 428 | AddressBook::ConstIterator AddressBook::end() const |
426 | { | 429 | { |
427 | ConstIterator it = ConstIterator(); | 430 | ConstIterator it = ConstIterator(); |
428 | it.d->mIt = d->mAddressees.end(); | 431 | it.d->mIt = d->mAddressees.end(); |
429 | return it; | 432 | return it; |
430 | } | 433 | } |
431 | 434 | ||
432 | void AddressBook::clear() | 435 | void AddressBook::clear() |
433 | { | 436 | { |
434 | d->mAddressees.clear(); | 437 | d->mAddressees.clear(); |
435 | } | 438 | } |
436 | 439 | ||
437 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 440 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
438 | { | 441 | { |
439 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 442 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
440 | 443 | ||
441 | if ( !resource ) | 444 | if ( !resource ) |
442 | { | 445 | { |
443 | qDebug("AddressBook::requestSaveTicket no resource" ); | 446 | qDebug("AddressBook::requestSaveTicket no resource" ); |
444 | resource = standardResource(); | 447 | resource = standardResource(); |
445 | } | 448 | } |
446 | 449 | ||
447 | KRES::Manager<Resource>::ActiveIterator it; | 450 | KRES::Manager<Resource>::ActiveIterator it; |
448 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 451 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
449 | if ( (*it) == resource ) { | 452 | if ( (*it) == resource ) { |
450 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 453 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
451 | return 0; | 454 | return 0; |
452 | else | 455 | else |
453 | return (*it)->requestSaveTicket(); | 456 | return (*it)->requestSaveTicket(); |
454 | } | 457 | } |
455 | } | 458 | } |
456 | 459 | ||
457 | return 0; | 460 | return 0; |
458 | } | 461 | } |
459 | 462 | ||
460 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) | 463 | void AddressBook::insertAddressee( const Addressee &a, bool setRev ) |
461 | { | 464 | { |
462 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 465 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
463 | //qDebug("block insert "); | 466 | //qDebug("block insert "); |
464 | return; | 467 | return; |
465 | } | 468 | } |
466 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 469 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
467 | bool found = false; | 470 | bool found = false; |
468 | Addressee::List::Iterator it; | 471 | Addressee::List::Iterator it; |
469 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 472 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
470 | if ( a.uid() == (*it).uid() ) { | 473 | if ( a.uid() == (*it).uid() ) { |
471 | 474 | ||
472 | bool changed = false; | 475 | bool changed = false; |
473 | Addressee addr = a; | 476 | Addressee addr = a; |
474 | if ( addr != (*it) ) | 477 | if ( addr != (*it) ) |
475 | changed = true; | 478 | changed = true; |
476 | 479 | ||
477 | (*it) = a; | 480 | (*it) = a; |
478 | if ( (*it).resource() == 0 ) | 481 | if ( (*it).resource() == 0 ) |
479 | (*it).setResource( standardResource() ); | 482 | (*it).setResource( standardResource() ); |
480 | 483 | ||
481 | if ( changed ) { | 484 | if ( changed ) { |
482 | if ( setRev ) { | 485 | if ( setRev ) { |
483 | 486 | ||
484 | // get rid of micro seconds | 487 | // get rid of micro seconds |
485 | QDateTime dt = QDateTime::currentDateTime(); | 488 | QDateTime dt = QDateTime::currentDateTime(); |
486 | QTime t = dt.time(); | 489 | QTime t = dt.time(); |
487 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 490 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
488 | (*it).setRevision( dt ); | 491 | (*it).setRevision( dt ); |
489 | } | 492 | } |
490 | (*it).setChanged( true ); | 493 | (*it).setChanged( true ); |
491 | } | 494 | } |
492 | 495 | ||
493 | found = true; | 496 | found = true; |
494 | } else { | 497 | } else { |
495 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 498 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
496 | QString name = (*it).uid().mid( 19 ); | 499 | QString name = (*it).uid().mid( 19 ); |
497 | Addressee b = a; | 500 | Addressee b = a; |
498 | QString id = b.getID( name ); | 501 | QString id = b.getID( name ); |
499 | if ( ! id.isEmpty() ) { | 502 | if ( ! id.isEmpty() ) { |
500 | QString des = (*it).note(); | 503 | QString des = (*it).note(); |
501 | int startN; | 504 | int startN; |
502 | if( (startN = des.find( id ) ) >= 0 ) { | 505 | if( (startN = des.find( id ) ) >= 0 ) { |
503 | int endN = des.find( ",", startN+1 ); | 506 | int endN = des.find( ",", startN+1 ); |
504 | des = des.left( startN ) + des.mid( endN+1 ); | 507 | des = des.left( startN ) + des.mid( endN+1 ); |
505 | (*it).setNote( des ); | 508 | (*it).setNote( des ); |
506 | } | 509 | } |
507 | } | 510 | } |
508 | } | 511 | } |
509 | } | 512 | } |
510 | } | 513 | } |
511 | if ( found ) | 514 | if ( found ) |
512 | return; | 515 | return; |
513 | d->mAddressees.append( a ); | 516 | d->mAddressees.append( a ); |
514 | Addressee& addr = d->mAddressees.last(); | 517 | Addressee& addr = d->mAddressees.last(); |
515 | if ( addr.resource() == 0 ) | 518 | if ( addr.resource() == 0 ) |
516 | addr.setResource( standardResource() ); | 519 | addr.setResource( standardResource() ); |
517 | 520 | ||
518 | addr.setChanged( true ); | 521 | addr.setChanged( true ); |
519 | } | 522 | } |
520 | 523 | ||
521 | void AddressBook::removeAddressee( const Addressee &a ) | 524 | void AddressBook::removeAddressee( const Addressee &a ) |
522 | { | 525 | { |
523 | Iterator it; | 526 | Iterator it; |
524 | Iterator it2; | 527 | Iterator it2; |
525 | bool found = false; | 528 | bool found = false; |
526 | for ( it = begin(); it != end(); ++it ) { | 529 | for ( it = begin(); it != end(); ++it ) { |
527 | if ( a.uid() == (*it).uid() ) { | 530 | if ( a.uid() == (*it).uid() ) { |
528 | found = true; | 531 | found = true; |
529 | it2 = it; | 532 | it2 = it; |
530 | } else { | 533 | } else { |
531 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 534 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
532 | QString name = (*it).uid().mid( 19 ); | 535 | QString name = (*it).uid().mid( 19 ); |
533 | Addressee b = a; | 536 | Addressee b = a; |
534 | QString id = b.getID( name ); | 537 | QString id = b.getID( name ); |
535 | if ( ! id.isEmpty() ) { | 538 | if ( ! id.isEmpty() ) { |
536 | QString des = (*it).note(); | 539 | QString des = (*it).note(); |
537 | if( des.find( id ) < 0 ) { | 540 | if( des.find( id ) < 0 ) { |
538 | des += id + ","; | 541 | des += id + ","; |
539 | (*it).setNote( des ); | 542 | (*it).setNote( des ); |
540 | } | 543 | } |
541 | } | 544 | } |
542 | } | 545 | } |
543 | 546 | ||
544 | } | 547 | } |
545 | } | 548 | } |
546 | 549 | ||
547 | if ( found ) | 550 | if ( found ) |
548 | removeAddressee( it2 ); | 551 | removeAddressee( it2 ); |
549 | 552 | ||
550 | } | 553 | } |
551 | 554 | ||
552 | void AddressBook::removeDeletedAddressees() | 555 | void AddressBook::removeDeletedAddressees() |
553 | { | 556 | { |
554 | deleteRemovedAddressees(); | 557 | deleteRemovedAddressees(); |
555 | Iterator it = begin(); | 558 | Iterator it = begin(); |
556 | Iterator it2 ; | 559 | Iterator it2 ; |
557 | QDateTime dt ( QDate( 2004,1,1) ); | 560 | QDateTime dt ( QDate( 2004,1,1) ); |
558 | while ( it != end() ) { | 561 | while ( it != end() ) { |
559 | (*it).setRevision( dt ); | 562 | (*it).setRevision( dt ); |
560 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 563 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
561 | (*it).setIDStr(""); | 564 | (*it).setIDStr(""); |
562 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 565 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE || (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
563 | it2 = it; | 566 | it2 = it; |
564 | //qDebug("removing %s ",(*it).uid().latin1() ); | 567 | //qDebug("removing %s ",(*it).uid().latin1() ); |
565 | ++it; | 568 | ++it; |
566 | removeAddressee( it2 ); | 569 | removeAddressee( it2 ); |
567 | } else { | 570 | } else { |
568 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 571 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
569 | ++it; | 572 | ++it; |
570 | } | 573 | } |
571 | } | 574 | } |
572 | deleteRemovedAddressees(); | 575 | deleteRemovedAddressees(); |
573 | } | 576 | } |
574 | 577 | ||
575 | void AddressBook::removeAddressee( const Iterator &it ) | 578 | void AddressBook::removeAddressee( const Iterator &it ) |
576 | { | 579 | { |
577 | d->mRemovedAddressees.append( (*it) ); | 580 | d->mRemovedAddressees.append( (*it) ); |
578 | d->mAddressees.remove( it.d->mIt ); | 581 | d->mAddressees.remove( it.d->mIt ); |
579 | } | 582 | } |
580 | 583 | ||
581 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 584 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
582 | { | 585 | { |
583 | Iterator it; | 586 | Iterator it; |
584 | for ( it = begin(); it != end(); ++it ) { | 587 | for ( it = begin(); it != end(); ++it ) { |
585 | if ( a.uid() == (*it).uid() ) { | 588 | if ( a.uid() == (*it).uid() ) { |
586 | return it; | 589 | return it; |
587 | } | 590 | } |
588 | } | 591 | } |
589 | return end(); | 592 | return end(); |
590 | } | 593 | } |
591 | 594 | ||
592 | Addressee AddressBook::findByUid( const QString &uid ) | 595 | Addressee AddressBook::findByUid( const QString &uid ) |
593 | { | 596 | { |
594 | Iterator it; | 597 | Iterator it; |
595 | for ( it = begin(); it != end(); ++it ) { | 598 | for ( it = begin(); it != end(); ++it ) { |
596 | if ( uid == (*it).uid() ) { | 599 | if ( uid == (*it).uid() ) { |
597 | return *it; | 600 | return *it; |
598 | } | 601 | } |
599 | } | 602 | } |
600 | return Addressee(); | 603 | return Addressee(); |
601 | } | 604 | } |
605 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | ||
606 | { | ||
607 | Iterator it; | ||
608 | for ( it = begin(); it != end(); ++it ) { | ||
609 | if ( uid == (*it).getID( profile ) ) | ||
610 | return (*it); | ||
611 | } | ||
612 | return Addressee(); | ||
613 | } | ||
614 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | ||
615 | { | ||
616 | Iterator it; | ||
617 | Addressee ad; | ||
618 | for ( it = begin(); it != end(); ++it ) { | ||
619 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | ||
620 | if ( !ad.isEmpty() ) { | ||
621 | (*it).mergeContact( ad ); | ||
622 | } | ||
623 | } | ||
624 | } | ||
625 | |||
602 | #if 0 | 626 | #if 0 |
603 | Addressee::List AddressBook::getExternLastSyncAddressees() | 627 | Addressee::List AddressBook::getExternLastSyncAddressees() |
604 | { | 628 | { |
605 | Addressee::List results; | 629 | Addressee::List results; |
606 | 630 | ||
607 | Iterator it; | 631 | Iterator it; |
608 | for ( it = begin(); it != end(); ++it ) { | 632 | for ( it = begin(); it != end(); ++it ) { |
609 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 633 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
610 | if ( (*it).familyName().left(4) == "!E: " ) | 634 | if ( (*it).familyName().left(4) == "!E: " ) |
611 | results.append( *it ); | 635 | results.append( *it ); |
612 | } | 636 | } |
613 | } | 637 | } |
614 | 638 | ||
615 | return results; | 639 | return results; |
616 | } | 640 | } |
617 | #endif | 641 | #endif |
618 | void AddressBook::resetTempSyncStat() | 642 | void AddressBook::resetTempSyncStat() |
619 | { | 643 | { |
620 | Iterator it; | 644 | Iterator it; |
621 | for ( it = begin(); it != end(); ++it ) { | 645 | for ( it = begin(); it != end(); ++it ) { |
622 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 646 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
623 | } | 647 | } |
624 | 648 | ||
625 | } | 649 | } |
626 | 650 | ||
627 | QStringList AddressBook:: uidList() | 651 | QStringList AddressBook:: uidList() |
628 | { | 652 | { |
629 | QStringList results; | 653 | QStringList results; |
630 | Iterator it; | 654 | Iterator it; |
631 | for ( it = begin(); it != end(); ++it ) { | 655 | for ( it = begin(); it != end(); ++it ) { |
632 | results.append( (*it).uid() ); | 656 | results.append( (*it).uid() ); |
633 | } | 657 | } |
634 | return results; | 658 | return results; |
635 | } | 659 | } |
636 | 660 | ||
637 | 661 | ||
638 | Addressee::List AddressBook::allAddressees() | 662 | Addressee::List AddressBook::allAddressees() |
639 | { | 663 | { |
640 | return d->mAddressees; | 664 | return d->mAddressees; |
641 | 665 | ||
642 | } | 666 | } |
643 | 667 | ||
644 | Addressee::List AddressBook::findByName( const QString &name ) | 668 | Addressee::List AddressBook::findByName( const QString &name ) |
645 | { | 669 | { |
646 | Addressee::List results; | 670 | Addressee::List results; |
647 | 671 | ||
648 | Iterator it; | 672 | Iterator it; |
649 | for ( it = begin(); it != end(); ++it ) { | 673 | for ( it = begin(); it != end(); ++it ) { |
650 | if ( name == (*it).realName() ) { | 674 | if ( name == (*it).realName() ) { |
651 | results.append( *it ); | 675 | results.append( *it ); |
652 | } | 676 | } |
653 | } | 677 | } |
654 | 678 | ||
655 | return results; | 679 | return results; |
656 | } | 680 | } |
657 | 681 | ||
658 | Addressee::List AddressBook::findByEmail( const QString &email ) | 682 | Addressee::List AddressBook::findByEmail( const QString &email ) |
659 | { | 683 | { |
660 | Addressee::List results; | 684 | Addressee::List results; |
661 | QStringList mailList; | 685 | QStringList mailList; |
662 | 686 | ||
663 | Iterator it; | 687 | Iterator it; |
664 | for ( it = begin(); it != end(); ++it ) { | 688 | for ( it = begin(); it != end(); ++it ) { |
665 | mailList = (*it).emails(); | 689 | mailList = (*it).emails(); |
666 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 690 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
667 | if ( email == (*ite) ) { | 691 | if ( email == (*ite) ) { |
668 | results.append( *it ); | 692 | results.append( *it ); |
669 | } | 693 | } |
670 | } | 694 | } |
671 | } | 695 | } |
672 | 696 | ||
673 | return results; | 697 | return results; |
674 | } | 698 | } |
675 | 699 | ||
676 | Addressee::List AddressBook::findByCategory( const QString &category ) | 700 | Addressee::List AddressBook::findByCategory( const QString &category ) |
677 | { | 701 | { |
678 | Addressee::List results; | 702 | Addressee::List results; |
679 | 703 | ||
680 | Iterator it; | 704 | Iterator it; |
681 | for ( it = begin(); it != end(); ++it ) { | 705 | for ( it = begin(); it != end(); ++it ) { |
682 | if ( (*it).hasCategory( category) ) { | 706 | if ( (*it).hasCategory( category) ) { |
683 | results.append( *it ); | 707 | results.append( *it ); |
684 | } | 708 | } |
685 | } | 709 | } |
686 | 710 | ||
687 | return results; | 711 | return results; |
688 | } | 712 | } |
689 | 713 | ||
690 | void AddressBook::dump() const | 714 | void AddressBook::dump() const |
691 | { | 715 | { |
692 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 716 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
693 | 717 | ||
694 | ConstIterator it; | 718 | ConstIterator it; |
695 | for( it = begin(); it != end(); ++it ) { | 719 | for( it = begin(); it != end(); ++it ) { |
696 | (*it).dump(); | 720 | (*it).dump(); |
697 | } | 721 | } |
698 | 722 | ||
699 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 723 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
700 | } | 724 | } |
701 | 725 | ||
702 | QString AddressBook::identifier() | 726 | QString AddressBook::identifier() |
703 | { | 727 | { |
704 | QStringList identifier; | 728 | QStringList identifier; |
705 | 729 | ||
706 | 730 | ||
707 | KRES::Manager<Resource>::ActiveIterator it; | 731 | KRES::Manager<Resource>::ActiveIterator it; |
708 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 732 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
709 | if ( !(*it)->identifier().isEmpty() ) | 733 | if ( !(*it)->identifier().isEmpty() ) |
710 | identifier.append( (*it)->identifier() ); | 734 | identifier.append( (*it)->identifier() ); |
711 | } | 735 | } |
712 | 736 | ||
713 | return identifier.join( ":" ); | 737 | return identifier.join( ":" ); |
714 | } | 738 | } |
715 | 739 | ||
716 | Field::List AddressBook::fields( int category ) | 740 | Field::List AddressBook::fields( int category ) |
717 | { | 741 | { |
718 | if ( d->mAllFields.isEmpty() ) { | 742 | if ( d->mAllFields.isEmpty() ) { |
719 | d->mAllFields = Field::allFields(); | 743 | d->mAllFields = Field::allFields(); |
720 | } | 744 | } |
721 | 745 | ||
722 | if ( category == Field::All ) return d->mAllFields; | 746 | if ( category == Field::All ) return d->mAllFields; |
723 | 747 | ||
724 | Field::List result; | 748 | Field::List result; |
725 | Field::List::ConstIterator it; | 749 | Field::List::ConstIterator it; |
726 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 750 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
727 | if ( (*it)->category() & category ) result.append( *it ); | 751 | if ( (*it)->category() & category ) result.append( *it ); |
728 | } | 752 | } |
729 | 753 | ||
730 | return result; | 754 | return result; |
731 | } | 755 | } |
732 | 756 | ||
733 | bool AddressBook::addCustomField( const QString &label, int category, | 757 | bool AddressBook::addCustomField( const QString &label, int category, |
734 | const QString &key, const QString &app ) | 758 | const QString &key, const QString &app ) |
735 | { | 759 | { |
736 | if ( d->mAllFields.isEmpty() ) { | 760 | if ( d->mAllFields.isEmpty() ) { |
737 | d->mAllFields = Field::allFields(); | 761 | d->mAllFields = Field::allFields(); |
738 | } | 762 | } |
739 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 763 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
740 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 764 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
741 | 765 | ||
742 | QString k = key.isNull() ? label : key; | 766 | QString k = key.isNull() ? label : key; |
743 | 767 | ||
744 | Field *field = Field::createCustomField( label, category, k, a ); | 768 | Field *field = Field::createCustomField( label, category, k, a ); |
745 | 769 | ||
746 | if ( !field ) return false; | 770 | if ( !field ) return false; |
747 | 771 | ||
748 | d->mAllFields.append( field ); | 772 | d->mAllFields.append( field ); |
749 | 773 | ||
750 | return true; | 774 | return true; |
751 | } | 775 | } |
752 | 776 | ||
753 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 777 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
754 | { | 778 | { |
755 | if (!ab.d) return s; | 779 | if (!ab.d) return s; |
756 | 780 | ||
757 | return s << ab.d->mAddressees; | 781 | return s << ab.d->mAddressees; |
758 | } | 782 | } |
759 | 783 | ||
760 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 784 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
761 | { | 785 | { |
762 | if (!ab.d) return s; | 786 | if (!ab.d) return s; |
763 | 787 | ||
764 | s >> ab.d->mAddressees; | 788 | s >> ab.d->mAddressees; |
765 | 789 | ||
766 | return s; | 790 | return s; |
767 | } | 791 | } |
768 | 792 | ||
769 | bool AddressBook::addResource( Resource *resource ) | 793 | bool AddressBook::addResource( Resource *resource ) |
770 | { | 794 | { |
771 | if ( !resource->open() ) { | 795 | if ( !resource->open() ) { |
772 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 796 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
773 | return false; | 797 | return false; |
774 | } | 798 | } |
775 | 799 | ||
776 | resource->setAddressBook( this ); | 800 | resource->setAddressBook( this ); |
777 | 801 | ||
778 | d->mManager->add( resource ); | 802 | d->mManager->add( resource ); |
779 | return true; | 803 | return true; |
780 | } | 804 | } |
781 | 805 | ||
782 | bool AddressBook::removeResource( Resource *resource ) | 806 | bool AddressBook::removeResource( Resource *resource ) |
783 | { | 807 | { |
784 | resource->close(); | 808 | resource->close(); |
785 | 809 | ||
786 | if ( resource == standardResource() ) | 810 | if ( resource == standardResource() ) |
787 | d->mManager->setStandardResource( 0 ); | 811 | d->mManager->setStandardResource( 0 ); |
788 | 812 | ||
789 | resource->setAddressBook( 0 ); | 813 | resource->setAddressBook( 0 ); |
790 | 814 | ||
791 | d->mManager->remove( resource ); | 815 | d->mManager->remove( resource ); |
792 | return true; | 816 | return true; |
793 | } | 817 | } |
794 | 818 | ||
795 | QPtrList<Resource> AddressBook::resources() | 819 | QPtrList<Resource> AddressBook::resources() |
796 | { | 820 | { |
797 | QPtrList<Resource> list; | 821 | QPtrList<Resource> list; |
798 | 822 | ||
799 | // qDebug("AddressBook::resources() 1"); | 823 | // qDebug("AddressBook::resources() 1"); |
800 | 824 | ||
801 | KRES::Manager<Resource>::ActiveIterator it; | 825 | KRES::Manager<Resource>::ActiveIterator it; |
802 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 826 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
803 | list.append( *it ); | 827 | list.append( *it ); |
804 | 828 | ||
805 | return list; | 829 | return list; |
806 | } | 830 | } |
807 | 831 | ||
808 | /*US | 832 | /*US |
809 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 833 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
810 | { | 834 | { |
811 | delete d->mErrorHandler; | 835 | delete d->mErrorHandler; |
812 | d->mErrorHandler = handler; | 836 | d->mErrorHandler = handler; |
813 | } | 837 | } |
814 | */ | 838 | */ |
815 | 839 | ||
816 | void AddressBook::error( const QString& msg ) | 840 | void AddressBook::error( const QString& msg ) |
817 | { | 841 | { |
818 | /*US | 842 | /*US |
819 | if ( !d->mErrorHandler ) // create default error handler | 843 | if ( !d->mErrorHandler ) // create default error handler |
820 | d->mErrorHandler = new ConsoleErrorHandler; | 844 | d->mErrorHandler = new ConsoleErrorHandler; |
821 | 845 | ||
822 | if ( d->mErrorHandler ) | 846 | if ( d->mErrorHandler ) |
823 | d->mErrorHandler->error( msg ); | 847 | d->mErrorHandler->error( msg ); |
824 | else | 848 | else |
825 | kdError(5700) << "no error handler defined" << endl; | 849 | kdError(5700) << "no error handler defined" << endl; |
826 | */ | 850 | */ |
827 | kdDebug(5700) << "msg" << endl; | 851 | kdDebug(5700) << "msg" << endl; |
828 | qDebug(msg); | 852 | qDebug(msg); |
829 | } | 853 | } |
830 | 854 | ||
831 | void AddressBook::deleteRemovedAddressees() | 855 | void AddressBook::deleteRemovedAddressees() |
832 | { | 856 | { |
833 | Addressee::List::Iterator it; | 857 | Addressee::List::Iterator it; |
834 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 858 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
835 | Resource *resource = (*it).resource(); | 859 | Resource *resource = (*it).resource(); |
836 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 860 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
837 | resource->removeAddressee( *it ); | 861 | resource->removeAddressee( *it ); |
838 | } | 862 | } |
839 | 863 | ||
840 | d->mRemovedAddressees.clear(); | 864 | d->mRemovedAddressees.clear(); |
841 | } | 865 | } |
842 | 866 | ||
843 | void AddressBook::setStandardResource( Resource *resource ) | 867 | void AddressBook::setStandardResource( Resource *resource ) |
844 | { | 868 | { |
845 | // qDebug("AddressBook::setStandardResource 1"); | 869 | // qDebug("AddressBook::setStandardResource 1"); |
846 | d->mManager->setStandardResource( resource ); | 870 | d->mManager->setStandardResource( resource ); |
847 | } | 871 | } |
848 | 872 | ||
849 | Resource *AddressBook::standardResource() | 873 | Resource *AddressBook::standardResource() |
850 | { | 874 | { |
851 | return d->mManager->standardResource(); | 875 | return d->mManager->standardResource(); |
852 | } | 876 | } |
853 | 877 | ||
854 | KRES::Manager<Resource> *AddressBook::resourceManager() | 878 | KRES::Manager<Resource> *AddressBook::resourceManager() |
855 | { | 879 | { |
856 | return d->mManager; | 880 | return d->mManager; |
857 | } | 881 | } |
858 | 882 | ||
859 | void AddressBook::cleanUp() | 883 | void AddressBook::cleanUp() |
860 | { | 884 | { |
861 | KRES::Manager<Resource>::ActiveIterator it; | 885 | KRES::Manager<Resource>::ActiveIterator it; |
862 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 886 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
863 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 887 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
864 | (*it)->cleanUp(); | 888 | (*it)->cleanUp(); |
865 | } | 889 | } |
866 | } | 890 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index 2f2678b..f40e015 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,336 +1,336 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | 145 | ||
146 | /** | 146 | /** |
147 | Returns a iterator for first entry of address book. | 147 | Returns a iterator for first entry of address book. |
148 | */ | 148 | */ |
149 | Iterator begin(); | 149 | Iterator begin(); |
150 | 150 | ||
151 | /** | 151 | /** |
152 | Returns a const iterator for first entry of address book. | 152 | Returns a const iterator for first entry of address book. |
153 | */ | 153 | */ |
154 | ConstIterator begin() const; | 154 | ConstIterator begin() const; |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Returns a iterator for first entry of address book. | 157 | Returns a iterator for first entry of address book. |
158 | */ | 158 | */ |
159 | Iterator end(); | 159 | Iterator end(); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Returns a const iterator for first entry of address book. | 162 | Returns a const iterator for first entry of address book. |
163 | */ | 163 | */ |
164 | ConstIterator end() const; | 164 | ConstIterator end() const; |
165 | 165 | ||
166 | /** | 166 | /** |
167 | Removes all entries from address book. | 167 | Removes all entries from address book. |
168 | */ | 168 | */ |
169 | void clear(); | 169 | void clear(); |
170 | 170 | ||
171 | /** | 171 | /** |
172 | Insert an Addressee object into address book. If an object with the same | 172 | Insert an Addressee object into address book. If an object with the same |
173 | unique id already exists in the address book it it replaced by the new | 173 | unique id already exists in the address book it it replaced by the new |
174 | one. If not the new object is appended to the address book. | 174 | one. If not the new object is appended to the address book. |
175 | */ | 175 | */ |
176 | void insertAddressee( const Addressee &, bool setRev = true ); | 176 | void insertAddressee( const Addressee &, bool setRev = true ); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | Removes entry from the address book. | 179 | Removes entry from the address book. |
180 | */ | 180 | */ |
181 | void removeAddressee( const Addressee & ); | 181 | void removeAddressee( const Addressee & ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | This is like @ref removeAddressee() just above, with the difference that | 184 | This is like @ref removeAddressee() just above, with the difference that |
185 | the first element is a iterator, returned by @ref begin(). | 185 | the first element is a iterator, returned by @ref begin(). |
186 | */ | 186 | */ |
187 | void removeAddressee( const Iterator & ); | 187 | void removeAddressee( const Iterator & ); |
188 | 188 | ||
189 | /** | 189 | /** |
190 | Find the specified entry in address book. Returns end(), if the entry | 190 | Find the specified entry in address book. Returns end(), if the entry |
191 | couldn't be found. | 191 | couldn't be found. |
192 | */ | 192 | */ |
193 | Iterator find( const Addressee & ); | 193 | Iterator find( const Addressee & ); |
194 | 194 | ||
195 | /** | 195 | /** |
196 | Find the entry specified by an unique id. Returns an empty Addressee | 196 | Find the entry specified by an unique id. Returns an empty Addressee |
197 | object, if the address book does not contain an entry with this id. | 197 | object, if the address book does not contain an entry with this id. |
198 | */ | 198 | */ |
199 | Addressee findByUid( const QString & ); | 199 | Addressee findByUid( const QString & ); |
200 | 200 | ||
201 | 201 | ||
202 | /** | 202 | /** |
203 | Returns a list of all addressees in the address book. This list can | 203 | Returns a list of all addressees in the address book. This list can |
204 | be sorted with @ref KABC::AddresseeList for example. | 204 | be sorted with @ref KABC::AddresseeList for example. |
205 | */ | 205 | */ |
206 | Addressee::List allAddressees(); | 206 | Addressee::List allAddressees(); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Find all entries with the specified name in the address book. Returns | 209 | Find all entries with the specified name in the address book. Returns |
210 | an empty list, if no entries could be found. | 210 | an empty list, if no entries could be found. |
211 | */ | 211 | */ |
212 | Addressee::List findByName( const QString & ); | 212 | Addressee::List findByName( const QString & ); |
213 | 213 | ||
214 | /** | 214 | /** |
215 | Find all entries with the specified email address in the address book. | 215 | Find all entries with the specified email address in the address book. |
216 | Returns an empty list, if no entries could be found. | 216 | Returns an empty list, if no entries could be found. |
217 | */ | 217 | */ |
218 | Addressee::List findByEmail( const QString & ); | 218 | Addressee::List findByEmail( const QString & ); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | Find all entries wich have the specified category in the address book. | 221 | Find all entries wich have the specified category in the address book. |
222 | Returns an empty list, if no entries could be found. | 222 | Returns an empty list, if no entries could be found. |
223 | */ | 223 | */ |
224 | Addressee::List findByCategory( const QString & ); | 224 | Addressee::List findByCategory( const QString & ); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Return a string identifying this addressbook. | 227 | Return a string identifying this addressbook. |
228 | */ | 228 | */ |
229 | virtual QString identifier(); | 229 | virtual QString identifier(); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Used for debug output. | 232 | Used for debug output. |
233 | */ | 233 | */ |
234 | void dump() const; | 234 | void dump() const; |
235 | 235 | ||
236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Return list of all Fields known to the address book which are associated | 241 | Return list of all Fields known to the address book which are associated |
242 | with the given field category. | 242 | with the given field category. |
243 | */ | 243 | */ |
244 | Field::List fields( int category = Field::All ); | 244 | Field::List fields( int category = Field::All ); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | Add custom field to address book. | 247 | Add custom field to address book. |
248 | 248 | ||
249 | @param label User visible label of the field. | 249 | @param label User visible label of the field. |
250 | @param category Ored list of field categories. | 250 | @param category Ored list of field categories. |
251 | @param key Identifier used as key for reading and writing the field. | 251 | @param key Identifier used as key for reading and writing the field. |
252 | @param app String used as application key for reading and writing | 252 | @param app String used as application key for reading and writing |
253 | the field. | 253 | the field. |
254 | */ | 254 | */ |
255 | bool addCustomField( const QString &label, int category = Field::All, | 255 | bool addCustomField( const QString &label, int category = Field::All, |
256 | const QString &key = QString::null, | 256 | const QString &key = QString::null, |
257 | const QString &app = QString::null ); | 257 | const QString &app = QString::null ); |
258 | 258 | ||
259 | 259 | ||
260 | /** | 260 | /** |
261 | Add address book resource. | 261 | Add address book resource. |
262 | */ | 262 | */ |
263 | bool addResource( Resource * ); | 263 | bool addResource( Resource * ); |
264 | 264 | ||
265 | /** | 265 | /** |
266 | Remove address book resource. | 266 | Remove address book resource. |
267 | */ | 267 | */ |
268 | bool removeResource( Resource * ); | 268 | bool removeResource( Resource * ); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | Return pointer list of all resources. | 271 | Return pointer list of all resources. |
272 | */ | 272 | */ |
273 | QPtrList<Resource> resources(); | 273 | QPtrList<Resource> resources(); |
274 | 274 | ||
275 | /** | 275 | /** |
276 | Set the @p ErrorHandler, that is used by @ref error() to | 276 | Set the @p ErrorHandler, that is used by @ref error() to |
277 | provide gui-independend error messages. | 277 | provide gui-independend error messages. |
278 | */ | 278 | */ |
279 | void setErrorHandler( ErrorHandler * ); | 279 | void setErrorHandler( ErrorHandler * ); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | Shows gui independend error messages. | 282 | Shows gui independend error messages. |
283 | */ | 283 | */ |
284 | void error( const QString& ); | 284 | void error( const QString& ); |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Query all resources to clean up their lock files | 287 | Query all resources to clean up their lock files |
288 | */ | 288 | */ |
289 | void cleanUp(); | 289 | void cleanUp(); |
290 | 290 | ||
291 | // sync stuff | 291 | // sync stuff |
292 | //Addressee::List getExternLastSyncAddressees(); | 292 | //Addressee::List getExternLastSyncAddressees(); |
293 | void resetTempSyncStat(); | 293 | void resetTempSyncStat(); |
294 | QStringList uidList(); | 294 | QStringList uidList(); |
295 | void removeDeletedAddressees(); | 295 | void removeDeletedAddressees(); |
296 | 296 | void mergeAB( AddressBook *aBook, const QString& profile ); | |
297 | 297 | Addressee findByExternUid( const QString& uid , const QString& profile ); | |
298 | signals: | 298 | signals: |
299 | /** | 299 | /** |
300 | Emitted, when the address book has changed on disk. | 300 | Emitted, when the address book has changed on disk. |
301 | */ | 301 | */ |
302 | void addressBookChanged( AddressBook * ); | 302 | void addressBookChanged( AddressBook * ); |
303 | 303 | ||
304 | /** | 304 | /** |
305 | Emitted, when the address book has been locked for writing. | 305 | Emitted, when the address book has been locked for writing. |
306 | */ | 306 | */ |
307 | void addressBookLocked( AddressBook * ); | 307 | void addressBookLocked( AddressBook * ); |
308 | 308 | ||
309 | /** | 309 | /** |
310 | Emitted, when the address book has been unlocked. | 310 | Emitted, when the address book has been unlocked. |
311 | */ | 311 | */ |
312 | void addressBookUnlocked( AddressBook * ); | 312 | void addressBookUnlocked( AddressBook * ); |
313 | 313 | ||
314 | protected: | 314 | protected: |
315 | void deleteRemovedAddressees(); | 315 | void deleteRemovedAddressees(); |
316 | void setStandardResource( Resource * ); | 316 | void setStandardResource( Resource * ); |
317 | Resource *standardResource(); | 317 | Resource *standardResource(); |
318 | KRES::Manager<Resource> *resourceManager(); | 318 | KRES::Manager<Resource> *resourceManager(); |
319 | 319 | ||
320 | void init(const QString &config, const QString &family); | 320 | void init(const QString &config, const QString &family); |
321 | 321 | ||
322 | private: | 322 | private: |
323 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 323 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
324 | 324 | ||
325 | 325 | ||
326 | struct AddressBookData; | 326 | struct AddressBookData; |
327 | AddressBookData *d; | 327 | AddressBookData *d; |
328 | bool blockLSEchange; | 328 | bool blockLSEchange; |
329 | }; | 329 | }; |
330 | 330 | ||
331 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 331 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
332 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 332 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
333 | 333 | ||
334 | } | 334 | } |
335 | 335 | ||
336 | #endif | 336 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index c34f671..711c261 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1784 +1,1823 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | 30 | ||
31 | #include <ksharedptr.h> | 31 | #include <ksharedptr.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kapplication.h> | 33 | #include <kapplication.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kidmanager.h> | 35 | #include <kidmanager.h> |
36 | //US | 36 | //US |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | 38 | #include <libkcal/syncdefines.h> |
39 | 39 | ||
40 | //US #include "resource.h" | 40 | //US #include "resource.h" |
41 | #include "addressee.h" | 41 | #include "addressee.h" |
42 | 42 | ||
43 | using namespace KABC; | 43 | using namespace KABC; |
44 | 44 | ||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | 46 | ||
47 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
48 | { | 48 | { |
49 | QString uid; | 49 | QString uid; |
50 | QString name; | 50 | QString name; |
51 | QString formattedName; | 51 | QString formattedName; |
52 | QString familyName; | 52 | QString familyName; |
53 | QString givenName; | 53 | QString givenName; |
54 | QString additionalName; | 54 | QString additionalName; |
55 | QString prefix; | 55 | QString prefix; |
56 | QString suffix; | 56 | QString suffix; |
57 | QString nickName; | 57 | QString nickName; |
58 | QDateTime birthday; | 58 | QDateTime birthday; |
59 | QString mailer; | 59 | QString mailer; |
60 | TimeZone timeZone; | 60 | TimeZone timeZone; |
61 | Geo geo; | 61 | Geo geo; |
62 | QString title; | 62 | QString title; |
63 | QString role; | 63 | QString role; |
64 | QString organization; | 64 | QString organization; |
65 | QString note; | 65 | QString note; |
66 | QString productId; | 66 | QString productId; |
67 | QDateTime revision; | 67 | QDateTime revision; |
68 | QString sortString; | 68 | QString sortString; |
69 | QString externalUID; | ||
69 | KURL url; | 70 | KURL url; |
70 | Secrecy secrecy; | 71 | Secrecy secrecy; |
71 | Picture logo; | 72 | Picture logo; |
72 | Picture photo; | 73 | Picture photo; |
73 | Sound sound; | 74 | Sound sound; |
74 | Agent agent; | 75 | Agent agent; |
75 | QString mExternalId; | 76 | QString mExternalId; |
76 | PhoneNumber::List phoneNumbers; | 77 | PhoneNumber::List phoneNumbers; |
77 | Address::List addresses; | 78 | Address::List addresses; |
78 | Key::List keys; | 79 | Key::List keys; |
79 | QStringList emails; | 80 | QStringList emails; |
80 | QStringList categories; | 81 | QStringList categories; |
81 | QStringList custom; | 82 | QStringList custom; |
82 | int mTempSyncStat; | 83 | int mTempSyncStat; |
83 | Resource *resource; | 84 | Resource *resource; |
84 | 85 | ||
85 | bool empty :1; | 86 | bool empty :1; |
86 | bool changed :1; | 87 | bool changed :1; |
87 | }; | 88 | }; |
88 | 89 | ||
89 | Addressee::Addressee() | 90 | Addressee::Addressee() |
90 | { | 91 | { |
91 | mData = new AddresseeData; | 92 | mData = new AddresseeData; |
92 | mData->empty = true; | 93 | mData->empty = true; |
93 | mData->changed = false; | 94 | mData->changed = false; |
94 | mData->resource = 0; | 95 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | 96 | mData->mExternalId = ":"; |
96 | mData->revision = QDateTime ( QDate( 2004,1,1)); | 97 | mData->revision = QDateTime ( QDate( 2004,1,1)); |
97 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 98 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
98 | } | 99 | } |
99 | 100 | ||
100 | Addressee::~Addressee() | 101 | Addressee::~Addressee() |
101 | { | 102 | { |
102 | } | 103 | } |
103 | 104 | ||
104 | Addressee::Addressee( const Addressee &a ) | 105 | Addressee::Addressee( const Addressee &a ) |
105 | { | 106 | { |
106 | mData = a.mData; | 107 | mData = a.mData; |
107 | } | 108 | } |
108 | 109 | ||
109 | Addressee &Addressee::operator=( const Addressee &a ) | 110 | Addressee &Addressee::operator=( const Addressee &a ) |
110 | { | 111 | { |
111 | mData = a.mData; | 112 | mData = a.mData; |
112 | return (*this); | 113 | return (*this); |
113 | } | 114 | } |
114 | 115 | ||
115 | Addressee Addressee::copy() | 116 | Addressee Addressee::copy() |
116 | { | 117 | { |
117 | Addressee a; | 118 | Addressee a; |
118 | *(a.mData) = *mData; | 119 | *(a.mData) = *mData; |
119 | return a; | 120 | return a; |
120 | } | 121 | } |
121 | 122 | ||
122 | void Addressee::detach() | 123 | void Addressee::detach() |
123 | { | 124 | { |
124 | if ( mData.count() == 1 ) return; | 125 | if ( mData.count() == 1 ) return; |
125 | *this = copy(); | 126 | *this = copy(); |
126 | } | 127 | } |
127 | 128 | ||
128 | bool Addressee::operator==( const Addressee &a ) const | 129 | bool Addressee::operator==( const Addressee &a ) const |
129 | { | 130 | { |
130 | if ( uid() != a.uid() ) return false; | 131 | if ( uid() != a.uid() ) return false; |
131 | if ( mData->name != a.mData->name ) return false; | 132 | if ( mData->name != a.mData->name ) return false; |
132 | if ( mData->formattedName != a.mData->formattedName ) return false; | 133 | if ( mData->formattedName != a.mData->formattedName ) return false; |
133 | if ( mData->familyName != a.mData->familyName ) return false; | 134 | if ( mData->familyName != a.mData->familyName ) return false; |
134 | if ( mData->givenName != a.mData->givenName ) return false; | 135 | if ( mData->givenName != a.mData->givenName ) return false; |
135 | if ( mData->additionalName != a.mData->additionalName ) return false; | 136 | if ( mData->additionalName != a.mData->additionalName ) return false; |
136 | if ( mData->prefix != a.mData->prefix ) return false; | 137 | if ( mData->prefix != a.mData->prefix ) return false; |
137 | if ( mData->suffix != a.mData->suffix ) return false; | 138 | if ( mData->suffix != a.mData->suffix ) return false; |
138 | if ( mData->nickName != a.mData->nickName ) return false; | 139 | if ( mData->nickName != a.mData->nickName ) return false; |
139 | if ( mData->birthday != a.mData->birthday ) return false; | 140 | if ( mData->birthday != a.mData->birthday ) return false; |
140 | if ( mData->mailer != a.mData->mailer ) return false; | 141 | if ( mData->mailer != a.mData->mailer ) return false; |
141 | if ( mData->timeZone != a.mData->timeZone ) return false; | 142 | if ( mData->timeZone != a.mData->timeZone ) return false; |
142 | if ( mData->geo != a.mData->geo ) return false; | 143 | if ( mData->geo != a.mData->geo ) return false; |
143 | if ( mData->title != a.mData->title ) return false; | 144 | if ( mData->title != a.mData->title ) return false; |
144 | if ( mData->role != a.mData->role ) return false; | 145 | if ( mData->role != a.mData->role ) return false; |
145 | if ( mData->organization != a.mData->organization ) return false; | 146 | if ( mData->organization != a.mData->organization ) return false; |
146 | if ( mData->note != a.mData->note ) return false; | 147 | if ( mData->note != a.mData->note ) return false; |
147 | if ( mData->productId != a.mData->productId ) return false; | 148 | if ( mData->productId != a.mData->productId ) return false; |
148 | if ( mData->revision != a.mData->revision ) return false; | 149 | if ( mData->revision != a.mData->revision ) return false; |
149 | if ( mData->sortString != a.mData->sortString ) return false; | 150 | if ( mData->sortString != a.mData->sortString ) return false; |
150 | if ( mData->secrecy != a.mData->secrecy ) return false; | 151 | if ( mData->secrecy != a.mData->secrecy ) return false; |
151 | if ( mData->logo != a.mData->logo ) return false; | 152 | if ( mData->logo != a.mData->logo ) return false; |
152 | if ( mData->photo != a.mData->photo ) return false; | 153 | if ( mData->photo != a.mData->photo ) return false; |
153 | if ( mData->sound != a.mData->sound ) return false; | 154 | if ( mData->sound != a.mData->sound ) return false; |
154 | if ( mData->agent != a.mData->agent ) return false; | 155 | if ( mData->agent != a.mData->agent ) return false; |
155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 156 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
156 | ( mData->url != a.mData->url ) ) return false; | 157 | ( mData->url != a.mData->url ) ) return false; |
157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 158 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
158 | if ( mData->addresses != a.mData->addresses ) return false; | 159 | if ( mData->addresses != a.mData->addresses ) return false; |
159 | if ( mData->keys != a.mData->keys ) return false; | 160 | if ( mData->keys != a.mData->keys ) return false; |
160 | if ( mData->emails != a.mData->emails ) return false; | 161 | if ( mData->emails != a.mData->emails ) return false; |
161 | if ( mData->categories != a.mData->categories ) return false; | 162 | if ( mData->categories != a.mData->categories ) return false; |
162 | if ( mData->custom != a.mData->custom ) return false; | 163 | if ( mData->custom != a.mData->custom ) return false; |
163 | 164 | ||
164 | return true; | 165 | return true; |
165 | } | 166 | } |
166 | 167 | ||
167 | bool Addressee::operator!=( const Addressee &a ) const | 168 | bool Addressee::operator!=( const Addressee &a ) const |
168 | { | 169 | { |
169 | return !( a == *this ); | 170 | return !( a == *this ); |
170 | } | 171 | } |
171 | 172 | ||
172 | bool Addressee::isEmpty() const | 173 | bool Addressee::isEmpty() const |
173 | { | 174 | { |
174 | return mData->empty; | 175 | return mData->empty; |
175 | } | 176 | } |
176 | ulong Addressee::getCsum4List( const QStringList & attList) | 177 | ulong Addressee::getCsum4List( const QStringList & attList) |
177 | { | 178 | { |
178 | int max = attList.count(); | 179 | int max = attList.count(); |
179 | ulong cSum = 0; | 180 | ulong cSum = 0; |
180 | int j,k,i; | 181 | int j,k,i; |
181 | int add; | 182 | int add; |
182 | for ( i = 0; i < max ; ++i ) { | 183 | for ( i = 0; i < max ; ++i ) { |
183 | QString s = attList[i]; | 184 | QString s = attList[i]; |
184 | if ( ! s.isEmpty() ){ | 185 | if ( ! s.isEmpty() ){ |
185 | j = s.length(); | 186 | j = s.length(); |
186 | for ( k = 0; k < j; ++k ) { | 187 | for ( k = 0; k < j; ++k ) { |
187 | int mul = k +1; | 188 | int mul = k +1; |
188 | add = s[k].unicode (); | 189 | add = s[k].unicode (); |
189 | if ( k < 16 ) | 190 | if ( k < 16 ) |
190 | mul = mul * mul; | 191 | mul = mul * mul; |
191 | int ii = i+1; | 192 | int ii = i+1; |
192 | add = add * mul *ii*ii*ii; | 193 | add = add * mul *ii*ii*ii; |
193 | cSum += add; | 194 | cSum += add; |
194 | } | 195 | } |
195 | } | 196 | } |
196 | 197 | ||
197 | } | 198 | } |
198 | //QString dump = attList.join(","); | 199 | //QString dump = attList.join(","); |
199 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 200 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
200 | 201 | ||
201 | return cSum; | 202 | return cSum; |
202 | 203 | ||
203 | } | 204 | } |
204 | void Addressee::computeCsum(const QString &dev) | 205 | void Addressee::computeCsum(const QString &dev) |
205 | { | 206 | { |
206 | QStringList l; | 207 | QStringList l; |
207 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 208 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
208 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 209 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
209 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 210 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
210 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 211 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
211 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 212 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
212 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 213 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
213 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 214 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
214 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 215 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
215 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 216 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
216 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 217 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
217 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 218 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
218 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 219 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
219 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 220 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
220 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 221 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
221 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 222 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
222 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 223 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
223 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 224 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
224 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 225 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
225 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 226 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
226 | // if ( !mData->logo.isEmpty() ) l.append( ); | 227 | // if ( !mData->logo.isEmpty() ) l.append( ); |
227 | //if ( !mData->photo.isEmpty() ) l.append( ); | 228 | //if ( !mData->photo.isEmpty() ) l.append( ); |
228 | //if ( !mData->sound.isEmpty() ) l.append( ); | 229 | //if ( !mData->sound.isEmpty() ) l.append( ); |
229 | //if ( !mData->agent.isEmpty() ) l.append( ); | 230 | //if ( !mData->agent.isEmpty() ) l.append( ); |
230 | //if ( mData->url.isValid() ) l.append( ); | 231 | //if ( mData->url.isValid() ) l.append( ); |
231 | #if 0 | 232 | #if 0 |
232 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 233 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
233 | if ( !mData->addresses.isEmpty() ) l.append( ); | 234 | if ( !mData->addresses.isEmpty() ) l.append( ); |
234 | //if ( !mData->keys.isEmpty() ) l.append( ); | 235 | //if ( !mData->keys.isEmpty() ) l.append( ); |
235 | if ( !mData->emails.isEmpty() ) l.append( ); | 236 | if ( !mData->emails.isEmpty() ) l.append( ); |
236 | if ( !mData->categories .isEmpty() ) l.append( ); | 237 | if ( !mData->categories .isEmpty() ) l.append( ); |
237 | if ( !mData->custom.isEmpty() ) l.append( ); | 238 | if ( !mData->custom.isEmpty() ) l.append( ); |
238 | #endif | 239 | #endif |
239 | KABC::PhoneNumber::List phoneNumbers; | 240 | KABC::PhoneNumber::List phoneNumbers; |
240 | KABC::PhoneNumber::List::Iterator phoneIter; | 241 | KABC::PhoneNumber::List::Iterator phoneIter; |
241 | 242 | ||
242 | QStringList t; | 243 | QStringList t; |
243 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 244 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
244 | ++phoneIter ) | 245 | ++phoneIter ) |
245 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 246 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
246 | t.sort(); | 247 | t.sort(); |
247 | uint iii; | 248 | uint iii; |
248 | for ( iii = 0; iii < t.count(); ++iii) | 249 | for ( iii = 0; iii < t.count(); ++iii) |
249 | l.append( t[iii] ); | 250 | l.append( t[iii] ); |
250 | t = mData->emails; | 251 | t = mData->emails; |
251 | t.sort(); | 252 | t.sort(); |
252 | for ( iii = 0; iii < t.count(); ++iii) | 253 | for ( iii = 0; iii < t.count(); ++iii) |
253 | l.append( t[iii] ); | 254 | l.append( t[iii] ); |
254 | t = mData->categories; | 255 | t = mData->categories; |
255 | t.sort(); | 256 | t.sort(); |
256 | for ( iii = 0; iii < t.count(); ++iii) | 257 | for ( iii = 0; iii < t.count(); ++iii) |
257 | l.append( t[iii] ); | 258 | l.append( t[iii] ); |
258 | t = mData->custom; | 259 | t = mData->custom; |
259 | t.sort(); | 260 | t.sort(); |
260 | for ( iii = 0; iii < t.count(); ++iii) | 261 | for ( iii = 0; iii < t.count(); ++iii) |
261 | l.append( t[iii] ); | 262 | l.append( t[iii] ); |
262 | KABC::Address::List::Iterator addressIter; | 263 | KABC::Address::List::Iterator addressIter; |
263 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 264 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
264 | ++addressIter ) { | 265 | ++addressIter ) { |
265 | t = (*addressIter).asList(); | 266 | t = (*addressIter).asList(); |
266 | t.sort(); | 267 | t.sort(); |
267 | for ( iii = 0; iii < t.count(); ++iii) | 268 | for ( iii = 0; iii < t.count(); ++iii) |
268 | l.append( t[iii] ); | 269 | l.append( t[iii] ); |
269 | } | 270 | } |
270 | uint cs = getCsum4List(l); | 271 | uint cs = getCsum4List(l); |
271 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 272 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
272 | setCsum( dev, QString::number (cs )); | 273 | setCsum( dev, QString::number (cs )); |
273 | } | 274 | } |
275 | |||
276 | void Addressee::mergeContact( Addressee ad ) | ||
277 | { | ||
278 | #if 0 | ||
279 | if ( !mData->name.isEmpty() ) l.append(mData->name); | ||
280 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | ||
281 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | ||
282 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | ||
283 | if ( !mData->additionalName ) l.append( mData->additionalName ); | ||
284 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | ||
285 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | ||
286 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | ||
287 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | ||
288 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | ||
289 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | ||
290 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | ||
291 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | ||
292 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | ||
293 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | ||
294 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | ||
295 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | ||
296 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | ||
297 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | ||
298 | #endif | ||
299 | } | ||
300 | |||
274 | void Addressee::removeID(const QString &prof) | 301 | void Addressee::removeID(const QString &prof) |
275 | { | 302 | { |
276 | detach(); | 303 | detach(); |
277 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 304 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
278 | 305 | ||
279 | } | 306 | } |
280 | void Addressee::setID( const QString & prof , const QString & id ) | 307 | void Addressee::setID( const QString & prof , const QString & id ) |
281 | { | 308 | { |
282 | detach(); | 309 | detach(); |
283 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 310 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
284 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 311 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
285 | } | 312 | } |
286 | void Addressee::setTempSyncStat( int id ) | 313 | void Addressee::setTempSyncStat( int id ) |
287 | { | 314 | { |
288 | if ( mData->mTempSyncStat == id ) return; | 315 | if ( mData->mTempSyncStat == id ) return; |
289 | detach(); | 316 | detach(); |
290 | mData->mTempSyncStat = id; | 317 | mData->mTempSyncStat = id; |
291 | } | 318 | } |
292 | int Addressee::tempSyncStat() const | 319 | int Addressee::tempSyncStat() const |
293 | { | 320 | { |
294 | return mData->mTempSyncStat; | 321 | return mData->mTempSyncStat; |
295 | } | 322 | } |
296 | 323 | ||
297 | QString Addressee::getID( const QString & prof) | 324 | QString Addressee::getID( const QString & prof) |
298 | { | 325 | { |
299 | return KIdManager::getId ( mData->mExternalId, prof ); | 326 | return KIdManager::getId ( mData->mExternalId, prof ); |
300 | } | 327 | } |
301 | 328 | ||
302 | void Addressee::setCsum( const QString & prof , const QString & id ) | 329 | void Addressee::setCsum( const QString & prof , const QString & id ) |
303 | { | 330 | { |
304 | detach(); | 331 | detach(); |
305 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 332 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
306 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 333 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
307 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 334 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
308 | } | 335 | } |
309 | 336 | ||
310 | QString Addressee::getCsum( const QString & prof) | 337 | QString Addressee::getCsum( const QString & prof) |
311 | { | 338 | { |
312 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 339 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
313 | } | 340 | } |
314 | 341 | ||
315 | void Addressee::setIDStr( const QString & s ) | 342 | void Addressee::setIDStr( const QString & s ) |
316 | { | 343 | { |
317 | detach(); | 344 | detach(); |
318 | mData->mExternalId = s; | 345 | mData->mExternalId = s; |
319 | } | 346 | } |
320 | 347 | ||
321 | QString Addressee::IDStr() const | 348 | QString Addressee::IDStr() const |
322 | { | 349 | { |
323 | return mData->mExternalId; | 350 | return mData->mExternalId; |
324 | } | 351 | } |
325 | 352 | ||
353 | void Addressee::setExternalUID( const QString &id ) | ||
354 | { | ||
355 | if ( id == mData->externalUID ) return; | ||
356 | detach(); | ||
357 | mData->empty = false; | ||
358 | mData->externalUID = id; | ||
359 | } | ||
360 | |||
361 | QString Addressee::externalUID() const | ||
362 | { | ||
363 | return mData->externalUID; | ||
364 | } | ||
326 | 365 | ||
327 | void Addressee::setUid( const QString &id ) | 366 | void Addressee::setUid( const QString &id ) |
328 | { | 367 | { |
329 | if ( id == mData->uid ) return; | 368 | if ( id == mData->uid ) return; |
330 | detach(); | 369 | detach(); |
331 | mData->empty = false; | 370 | mData->empty = false; |
332 | mData->uid = id; | 371 | mData->uid = id; |
333 | } | 372 | } |
334 | 373 | ||
335 | QString Addressee::uid() const | 374 | QString Addressee::uid() const |
336 | { | 375 | { |
337 | if ( mData->uid.isEmpty() ) | 376 | if ( mData->uid.isEmpty() ) |
338 | mData->uid = KApplication::randomString( 10 ); | 377 | mData->uid = KApplication::randomString( 10 ); |
339 | 378 | ||
340 | return mData->uid; | 379 | return mData->uid; |
341 | } | 380 | } |
342 | 381 | ||
343 | QString Addressee::uidLabel() | 382 | QString Addressee::uidLabel() |
344 | { | 383 | { |
345 | return i18n("Unique Identifier"); | 384 | return i18n("Unique Identifier"); |
346 | } | 385 | } |
347 | 386 | ||
348 | void Addressee::setName( const QString &name ) | 387 | void Addressee::setName( const QString &name ) |
349 | { | 388 | { |
350 | if ( name == mData->name ) return; | 389 | if ( name == mData->name ) return; |
351 | detach(); | 390 | detach(); |
352 | mData->empty = false; | 391 | mData->empty = false; |
353 | mData->name = name; | 392 | mData->name = name; |
354 | } | 393 | } |
355 | 394 | ||
356 | QString Addressee::name() const | 395 | QString Addressee::name() const |
357 | { | 396 | { |
358 | return mData->name; | 397 | return mData->name; |
359 | } | 398 | } |
360 | 399 | ||
361 | QString Addressee::nameLabel() | 400 | QString Addressee::nameLabel() |
362 | { | 401 | { |
363 | return i18n("Name"); | 402 | return i18n("Name"); |
364 | } | 403 | } |
365 | 404 | ||
366 | 405 | ||
367 | void Addressee::setFormattedName( const QString &formattedName ) | 406 | void Addressee::setFormattedName( const QString &formattedName ) |
368 | { | 407 | { |
369 | if ( formattedName == mData->formattedName ) return; | 408 | if ( formattedName == mData->formattedName ) return; |
370 | detach(); | 409 | detach(); |
371 | mData->empty = false; | 410 | mData->empty = false; |
372 | mData->formattedName = formattedName; | 411 | mData->formattedName = formattedName; |
373 | } | 412 | } |
374 | 413 | ||
375 | QString Addressee::formattedName() const | 414 | QString Addressee::formattedName() const |
376 | { | 415 | { |
377 | return mData->formattedName; | 416 | return mData->formattedName; |
378 | } | 417 | } |
379 | 418 | ||
380 | QString Addressee::formattedNameLabel() | 419 | QString Addressee::formattedNameLabel() |
381 | { | 420 | { |
382 | return i18n("Formatted Name"); | 421 | return i18n("Formatted Name"); |
383 | } | 422 | } |
384 | 423 | ||
385 | 424 | ||
386 | void Addressee::setFamilyName( const QString &familyName ) | 425 | void Addressee::setFamilyName( const QString &familyName ) |
387 | { | 426 | { |
388 | if ( familyName == mData->familyName ) return; | 427 | if ( familyName == mData->familyName ) return; |
389 | detach(); | 428 | detach(); |
390 | mData->empty = false; | 429 | mData->empty = false; |
391 | mData->familyName = familyName; | 430 | mData->familyName = familyName; |
392 | } | 431 | } |
393 | 432 | ||
394 | QString Addressee::familyName() const | 433 | QString Addressee::familyName() const |
395 | { | 434 | { |
396 | return mData->familyName; | 435 | return mData->familyName; |
397 | } | 436 | } |
398 | 437 | ||
399 | QString Addressee::familyNameLabel() | 438 | QString Addressee::familyNameLabel() |
400 | { | 439 | { |
401 | return i18n("Family Name"); | 440 | return i18n("Family Name"); |
402 | } | 441 | } |
403 | 442 | ||
404 | 443 | ||
405 | void Addressee::setGivenName( const QString &givenName ) | 444 | void Addressee::setGivenName( const QString &givenName ) |
406 | { | 445 | { |
407 | if ( givenName == mData->givenName ) return; | 446 | if ( givenName == mData->givenName ) return; |
408 | detach(); | 447 | detach(); |
409 | mData->empty = false; | 448 | mData->empty = false; |
410 | mData->givenName = givenName; | 449 | mData->givenName = givenName; |
411 | } | 450 | } |
412 | 451 | ||
413 | QString Addressee::givenName() const | 452 | QString Addressee::givenName() const |
414 | { | 453 | { |
415 | return mData->givenName; | 454 | return mData->givenName; |
416 | } | 455 | } |
417 | 456 | ||
418 | QString Addressee::givenNameLabel() | 457 | QString Addressee::givenNameLabel() |
419 | { | 458 | { |
420 | return i18n("Given Name"); | 459 | return i18n("Given Name"); |
421 | } | 460 | } |
422 | 461 | ||
423 | 462 | ||
424 | void Addressee::setAdditionalName( const QString &additionalName ) | 463 | void Addressee::setAdditionalName( const QString &additionalName ) |
425 | { | 464 | { |
426 | if ( additionalName == mData->additionalName ) return; | 465 | if ( additionalName == mData->additionalName ) return; |
427 | detach(); | 466 | detach(); |
428 | mData->empty = false; | 467 | mData->empty = false; |
429 | mData->additionalName = additionalName; | 468 | mData->additionalName = additionalName; |
430 | } | 469 | } |
431 | 470 | ||
432 | QString Addressee::additionalName() const | 471 | QString Addressee::additionalName() const |
433 | { | 472 | { |
434 | return mData->additionalName; | 473 | return mData->additionalName; |
435 | } | 474 | } |
436 | 475 | ||
437 | QString Addressee::additionalNameLabel() | 476 | QString Addressee::additionalNameLabel() |
438 | { | 477 | { |
439 | return i18n("Additional Names"); | 478 | return i18n("Additional Names"); |
440 | } | 479 | } |
441 | 480 | ||
442 | 481 | ||
443 | void Addressee::setPrefix( const QString &prefix ) | 482 | void Addressee::setPrefix( const QString &prefix ) |
444 | { | 483 | { |
445 | if ( prefix == mData->prefix ) return; | 484 | if ( prefix == mData->prefix ) return; |
446 | detach(); | 485 | detach(); |
447 | mData->empty = false; | 486 | mData->empty = false; |
448 | mData->prefix = prefix; | 487 | mData->prefix = prefix; |
449 | } | 488 | } |
450 | 489 | ||
451 | QString Addressee::prefix() const | 490 | QString Addressee::prefix() const |
452 | { | 491 | { |
453 | return mData->prefix; | 492 | return mData->prefix; |
454 | } | 493 | } |
455 | 494 | ||
456 | QString Addressee::prefixLabel() | 495 | QString Addressee::prefixLabel() |
457 | { | 496 | { |
458 | return i18n("Honorific Prefixes"); | 497 | return i18n("Honorific Prefixes"); |
459 | } | 498 | } |
460 | 499 | ||
461 | 500 | ||
462 | void Addressee::setSuffix( const QString &suffix ) | 501 | void Addressee::setSuffix( const QString &suffix ) |
463 | { | 502 | { |
464 | if ( suffix == mData->suffix ) return; | 503 | if ( suffix == mData->suffix ) return; |
465 | detach(); | 504 | detach(); |
466 | mData->empty = false; | 505 | mData->empty = false; |
467 | mData->suffix = suffix; | 506 | mData->suffix = suffix; |
468 | } | 507 | } |
469 | 508 | ||
470 | QString Addressee::suffix() const | 509 | QString Addressee::suffix() const |
471 | { | 510 | { |
472 | return mData->suffix; | 511 | return mData->suffix; |
473 | } | 512 | } |
474 | 513 | ||
475 | QString Addressee::suffixLabel() | 514 | QString Addressee::suffixLabel() |
476 | { | 515 | { |
477 | return i18n("Honorific Suffixes"); | 516 | return i18n("Honorific Suffixes"); |
478 | } | 517 | } |
479 | 518 | ||
480 | 519 | ||
481 | void Addressee::setNickName( const QString &nickName ) | 520 | void Addressee::setNickName( const QString &nickName ) |
482 | { | 521 | { |
483 | if ( nickName == mData->nickName ) return; | 522 | if ( nickName == mData->nickName ) return; |
484 | detach(); | 523 | detach(); |
485 | mData->empty = false; | 524 | mData->empty = false; |
486 | mData->nickName = nickName; | 525 | mData->nickName = nickName; |
487 | } | 526 | } |
488 | 527 | ||
489 | QString Addressee::nickName() const | 528 | QString Addressee::nickName() const |
490 | { | 529 | { |
491 | return mData->nickName; | 530 | return mData->nickName; |
492 | } | 531 | } |
493 | 532 | ||
494 | QString Addressee::nickNameLabel() | 533 | QString Addressee::nickNameLabel() |
495 | { | 534 | { |
496 | return i18n("Nick Name"); | 535 | return i18n("Nick Name"); |
497 | } | 536 | } |
498 | 537 | ||
499 | 538 | ||
500 | void Addressee::setBirthday( const QDateTime &birthday ) | 539 | void Addressee::setBirthday( const QDateTime &birthday ) |
501 | { | 540 | { |
502 | if ( birthday == mData->birthday ) return; | 541 | if ( birthday == mData->birthday ) return; |
503 | detach(); | 542 | detach(); |
504 | mData->empty = false; | 543 | mData->empty = false; |
505 | mData->birthday = birthday; | 544 | mData->birthday = birthday; |
506 | } | 545 | } |
507 | 546 | ||
508 | QDateTime Addressee::birthday() const | 547 | QDateTime Addressee::birthday() const |
509 | { | 548 | { |
510 | return mData->birthday; | 549 | return mData->birthday; |
511 | } | 550 | } |
512 | 551 | ||
513 | QString Addressee::birthdayLabel() | 552 | QString Addressee::birthdayLabel() |
514 | { | 553 | { |
515 | return i18n("Birthday"); | 554 | return i18n("Birthday"); |
516 | } | 555 | } |
517 | 556 | ||
518 | 557 | ||
519 | QString Addressee::homeAddressStreetLabel() | 558 | QString Addressee::homeAddressStreetLabel() |
520 | { | 559 | { |
521 | return i18n("Home Address Street"); | 560 | return i18n("Home Address Street"); |
522 | } | 561 | } |
523 | 562 | ||
524 | 563 | ||
525 | QString Addressee::homeAddressLocalityLabel() | 564 | QString Addressee::homeAddressLocalityLabel() |
526 | { | 565 | { |
527 | return i18n("Home Address Locality"); | 566 | return i18n("Home Address Locality"); |
528 | } | 567 | } |
529 | 568 | ||
530 | 569 | ||
531 | QString Addressee::homeAddressRegionLabel() | 570 | QString Addressee::homeAddressRegionLabel() |
532 | { | 571 | { |
533 | return i18n("Home Address Region"); | 572 | return i18n("Home Address Region"); |
534 | } | 573 | } |
535 | 574 | ||
536 | 575 | ||
537 | QString Addressee::homeAddressPostalCodeLabel() | 576 | QString Addressee::homeAddressPostalCodeLabel() |
538 | { | 577 | { |
539 | return i18n("Home Address Postal Code"); | 578 | return i18n("Home Address Postal Code"); |
540 | } | 579 | } |
541 | 580 | ||
542 | 581 | ||
543 | QString Addressee::homeAddressCountryLabel() | 582 | QString Addressee::homeAddressCountryLabel() |
544 | { | 583 | { |
545 | return i18n("Home Address Country"); | 584 | return i18n("Home Address Country"); |
546 | } | 585 | } |
547 | 586 | ||
548 | 587 | ||
549 | QString Addressee::homeAddressLabelLabel() | 588 | QString Addressee::homeAddressLabelLabel() |
550 | { | 589 | { |
551 | return i18n("Home Address Label"); | 590 | return i18n("Home Address Label"); |
552 | } | 591 | } |
553 | 592 | ||
554 | 593 | ||
555 | QString Addressee::businessAddressStreetLabel() | 594 | QString Addressee::businessAddressStreetLabel() |
556 | { | 595 | { |
557 | return i18n("Business Address Street"); | 596 | return i18n("Business Address Street"); |
558 | } | 597 | } |
559 | 598 | ||
560 | 599 | ||
561 | QString Addressee::businessAddressLocalityLabel() | 600 | QString Addressee::businessAddressLocalityLabel() |
562 | { | 601 | { |
563 | return i18n("Business Address Locality"); | 602 | return i18n("Business Address Locality"); |
564 | } | 603 | } |
565 | 604 | ||
566 | 605 | ||
567 | QString Addressee::businessAddressRegionLabel() | 606 | QString Addressee::businessAddressRegionLabel() |
568 | { | 607 | { |
569 | return i18n("Business Address Region"); | 608 | return i18n("Business Address Region"); |
570 | } | 609 | } |
571 | 610 | ||
572 | 611 | ||
573 | QString Addressee::businessAddressPostalCodeLabel() | 612 | QString Addressee::businessAddressPostalCodeLabel() |
574 | { | 613 | { |
575 | return i18n("Business Address Postal Code"); | 614 | return i18n("Business Address Postal Code"); |
576 | } | 615 | } |
577 | 616 | ||
578 | 617 | ||
579 | QString Addressee::businessAddressCountryLabel() | 618 | QString Addressee::businessAddressCountryLabel() |
580 | { | 619 | { |
581 | return i18n("Business Address Country"); | 620 | return i18n("Business Address Country"); |
582 | } | 621 | } |
583 | 622 | ||
584 | 623 | ||
585 | QString Addressee::businessAddressLabelLabel() | 624 | QString Addressee::businessAddressLabelLabel() |
586 | { | 625 | { |
587 | return i18n("Business Address Label"); | 626 | return i18n("Business Address Label"); |
588 | } | 627 | } |
589 | 628 | ||
590 | 629 | ||
591 | QString Addressee::homePhoneLabel() | 630 | QString Addressee::homePhoneLabel() |
592 | { | 631 | { |
593 | return i18n("Home Phone"); | 632 | return i18n("Home Phone"); |
594 | } | 633 | } |
595 | 634 | ||
596 | 635 | ||
597 | QString Addressee::businessPhoneLabel() | 636 | QString Addressee::businessPhoneLabel() |
598 | { | 637 | { |
599 | return i18n("Business Phone"); | 638 | return i18n("Business Phone"); |
600 | } | 639 | } |
601 | 640 | ||
602 | 641 | ||
603 | QString Addressee::mobilePhoneLabel() | 642 | QString Addressee::mobilePhoneLabel() |
604 | { | 643 | { |
605 | return i18n("Mobile Phone"); | 644 | return i18n("Mobile Phone"); |
606 | } | 645 | } |
607 | 646 | ||
608 | 647 | ||
609 | QString Addressee::homeFaxLabel() | 648 | QString Addressee::homeFaxLabel() |
610 | { | 649 | { |
611 | return i18n("Home Fax"); | 650 | return i18n("Home Fax"); |
612 | } | 651 | } |
613 | 652 | ||
614 | 653 | ||
615 | QString Addressee::businessFaxLabel() | 654 | QString Addressee::businessFaxLabel() |
616 | { | 655 | { |
617 | return i18n("Business Fax"); | 656 | return i18n("Business Fax"); |
618 | } | 657 | } |
619 | 658 | ||
620 | 659 | ||
621 | QString Addressee::carPhoneLabel() | 660 | QString Addressee::carPhoneLabel() |
622 | { | 661 | { |
623 | return i18n("Car Phone"); | 662 | return i18n("Car Phone"); |
624 | } | 663 | } |
625 | 664 | ||
626 | 665 | ||
627 | QString Addressee::isdnLabel() | 666 | QString Addressee::isdnLabel() |
628 | { | 667 | { |
629 | return i18n("ISDN"); | 668 | return i18n("ISDN"); |
630 | } | 669 | } |
631 | 670 | ||
632 | 671 | ||
633 | QString Addressee::pagerLabel() | 672 | QString Addressee::pagerLabel() |
634 | { | 673 | { |
635 | return i18n("Pager"); | 674 | return i18n("Pager"); |
636 | } | 675 | } |
637 | 676 | ||
638 | QString Addressee::sipLabel() | 677 | QString Addressee::sipLabel() |
639 | { | 678 | { |
640 | return i18n("SIP"); | 679 | return i18n("SIP"); |
641 | } | 680 | } |
642 | 681 | ||
643 | QString Addressee::emailLabel() | 682 | QString Addressee::emailLabel() |
644 | { | 683 | { |
645 | return i18n("Email Address"); | 684 | return i18n("Email Address"); |
646 | } | 685 | } |
647 | 686 | ||
648 | 687 | ||
649 | void Addressee::setMailer( const QString &mailer ) | 688 | void Addressee::setMailer( const QString &mailer ) |
650 | { | 689 | { |
651 | if ( mailer == mData->mailer ) return; | 690 | if ( mailer == mData->mailer ) return; |
652 | detach(); | 691 | detach(); |
653 | mData->empty = false; | 692 | mData->empty = false; |
654 | mData->mailer = mailer; | 693 | mData->mailer = mailer; |
655 | } | 694 | } |
656 | 695 | ||
657 | QString Addressee::mailer() const | 696 | QString Addressee::mailer() const |
658 | { | 697 | { |
659 | return mData->mailer; | 698 | return mData->mailer; |
660 | } | 699 | } |
661 | 700 | ||
662 | QString Addressee::mailerLabel() | 701 | QString Addressee::mailerLabel() |
663 | { | 702 | { |
664 | return i18n("Mail Client"); | 703 | return i18n("Mail Client"); |
665 | } | 704 | } |
666 | 705 | ||
667 | 706 | ||
668 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 707 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
669 | { | 708 | { |
670 | if ( timeZone == mData->timeZone ) return; | 709 | if ( timeZone == mData->timeZone ) return; |
671 | detach(); | 710 | detach(); |
672 | mData->empty = false; | 711 | mData->empty = false; |
673 | mData->timeZone = timeZone; | 712 | mData->timeZone = timeZone; |
674 | } | 713 | } |
675 | 714 | ||
676 | TimeZone Addressee::timeZone() const | 715 | TimeZone Addressee::timeZone() const |
677 | { | 716 | { |
678 | return mData->timeZone; | 717 | return mData->timeZone; |
679 | } | 718 | } |
680 | 719 | ||
681 | QString Addressee::timeZoneLabel() | 720 | QString Addressee::timeZoneLabel() |
682 | { | 721 | { |
683 | return i18n("Time Zone"); | 722 | return i18n("Time Zone"); |
684 | } | 723 | } |
685 | 724 | ||
686 | 725 | ||
687 | void Addressee::setGeo( const Geo &geo ) | 726 | void Addressee::setGeo( const Geo &geo ) |
688 | { | 727 | { |
689 | if ( geo == mData->geo ) return; | 728 | if ( geo == mData->geo ) return; |
690 | detach(); | 729 | detach(); |
691 | mData->empty = false; | 730 | mData->empty = false; |
692 | mData->geo = geo; | 731 | mData->geo = geo; |
693 | } | 732 | } |
694 | 733 | ||
695 | Geo Addressee::geo() const | 734 | Geo Addressee::geo() const |
696 | { | 735 | { |
697 | return mData->geo; | 736 | return mData->geo; |
698 | } | 737 | } |
699 | 738 | ||
700 | QString Addressee::geoLabel() | 739 | QString Addressee::geoLabel() |
701 | { | 740 | { |
702 | return i18n("Geographic Position"); | 741 | return i18n("Geographic Position"); |
703 | } | 742 | } |
704 | 743 | ||
705 | 744 | ||
706 | void Addressee::setTitle( const QString &title ) | 745 | void Addressee::setTitle( const QString &title ) |
707 | { | 746 | { |
708 | if ( title == mData->title ) return; | 747 | if ( title == mData->title ) return; |
709 | detach(); | 748 | detach(); |
710 | mData->empty = false; | 749 | mData->empty = false; |
711 | mData->title = title; | 750 | mData->title = title; |
712 | } | 751 | } |
713 | 752 | ||
714 | QString Addressee::title() const | 753 | QString Addressee::title() const |
715 | { | 754 | { |
716 | return mData->title; | 755 | return mData->title; |
717 | } | 756 | } |
718 | 757 | ||
719 | QString Addressee::titleLabel() | 758 | QString Addressee::titleLabel() |
720 | { | 759 | { |
721 | return i18n("Title"); | 760 | return i18n("Title"); |
722 | } | 761 | } |
723 | 762 | ||
724 | 763 | ||
725 | void Addressee::setRole( const QString &role ) | 764 | void Addressee::setRole( const QString &role ) |
726 | { | 765 | { |
727 | if ( role == mData->role ) return; | 766 | if ( role == mData->role ) return; |
728 | detach(); | 767 | detach(); |
729 | mData->empty = false; | 768 | mData->empty = false; |
730 | mData->role = role; | 769 | mData->role = role; |
731 | } | 770 | } |
732 | 771 | ||
733 | QString Addressee::role() const | 772 | QString Addressee::role() const |
734 | { | 773 | { |
735 | return mData->role; | 774 | return mData->role; |
736 | } | 775 | } |
737 | 776 | ||
738 | QString Addressee::roleLabel() | 777 | QString Addressee::roleLabel() |
739 | { | 778 | { |
740 | return i18n("Role"); | 779 | return i18n("Role"); |
741 | } | 780 | } |
742 | 781 | ||
743 | 782 | ||
744 | void Addressee::setOrganization( const QString &organization ) | 783 | void Addressee::setOrganization( const QString &organization ) |
745 | { | 784 | { |
746 | if ( organization == mData->organization ) return; | 785 | if ( organization == mData->organization ) return; |
747 | detach(); | 786 | detach(); |
748 | mData->empty = false; | 787 | mData->empty = false; |
749 | mData->organization = organization; | 788 | mData->organization = organization; |
750 | } | 789 | } |
751 | 790 | ||
752 | QString Addressee::organization() const | 791 | QString Addressee::organization() const |
753 | { | 792 | { |
754 | return mData->organization; | 793 | return mData->organization; |
755 | } | 794 | } |
756 | 795 | ||
757 | QString Addressee::organizationLabel() | 796 | QString Addressee::organizationLabel() |
758 | { | 797 | { |
759 | return i18n("Organization"); | 798 | return i18n("Organization"); |
760 | } | 799 | } |
761 | 800 | ||
762 | 801 | ||
763 | void Addressee::setNote( const QString ¬e ) | 802 | void Addressee::setNote( const QString ¬e ) |
764 | { | 803 | { |
765 | if ( note == mData->note ) return; | 804 | if ( note == mData->note ) return; |
766 | detach(); | 805 | detach(); |
767 | mData->empty = false; | 806 | mData->empty = false; |
768 | mData->note = note; | 807 | mData->note = note; |
769 | } | 808 | } |
770 | 809 | ||
771 | QString Addressee::note() const | 810 | QString Addressee::note() const |
772 | { | 811 | { |
773 | return mData->note; | 812 | return mData->note; |
774 | } | 813 | } |
775 | 814 | ||
776 | QString Addressee::noteLabel() | 815 | QString Addressee::noteLabel() |
777 | { | 816 | { |
778 | return i18n("Note"); | 817 | return i18n("Note"); |
779 | } | 818 | } |
780 | 819 | ||
781 | 820 | ||
782 | void Addressee::setProductId( const QString &productId ) | 821 | void Addressee::setProductId( const QString &productId ) |
783 | { | 822 | { |
784 | if ( productId == mData->productId ) return; | 823 | if ( productId == mData->productId ) return; |
785 | detach(); | 824 | detach(); |
786 | mData->empty = false; | 825 | mData->empty = false; |
787 | mData->productId = productId; | 826 | mData->productId = productId; |
788 | } | 827 | } |
789 | 828 | ||
790 | QString Addressee::productId() const | 829 | QString Addressee::productId() const |
791 | { | 830 | { |
792 | return mData->productId; | 831 | return mData->productId; |
793 | } | 832 | } |
794 | 833 | ||
795 | QString Addressee::productIdLabel() | 834 | QString Addressee::productIdLabel() |
796 | { | 835 | { |
797 | return i18n("Product Identifier"); | 836 | return i18n("Product Identifier"); |
798 | } | 837 | } |
799 | 838 | ||
800 | 839 | ||
801 | void Addressee::setRevision( const QDateTime &revision ) | 840 | void Addressee::setRevision( const QDateTime &revision ) |
802 | { | 841 | { |
803 | if ( revision == mData->revision ) return; | 842 | if ( revision == mData->revision ) return; |
804 | detach(); | 843 | detach(); |
805 | mData->empty = false; | 844 | mData->empty = false; |
806 | mData->revision = revision; | 845 | mData->revision = revision; |
807 | } | 846 | } |
808 | 847 | ||
809 | QDateTime Addressee::revision() const | 848 | QDateTime Addressee::revision() const |
810 | { | 849 | { |
811 | return mData->revision; | 850 | return mData->revision; |
812 | } | 851 | } |
813 | 852 | ||
814 | QString Addressee::revisionLabel() | 853 | QString Addressee::revisionLabel() |
815 | { | 854 | { |
816 | return i18n("Revision Date"); | 855 | return i18n("Revision Date"); |
817 | } | 856 | } |
818 | 857 | ||
819 | 858 | ||
820 | void Addressee::setSortString( const QString &sortString ) | 859 | void Addressee::setSortString( const QString &sortString ) |
821 | { | 860 | { |
822 | if ( sortString == mData->sortString ) return; | 861 | if ( sortString == mData->sortString ) return; |
823 | detach(); | 862 | detach(); |
824 | mData->empty = false; | 863 | mData->empty = false; |
825 | mData->sortString = sortString; | 864 | mData->sortString = sortString; |
826 | } | 865 | } |
827 | 866 | ||
828 | QString Addressee::sortString() const | 867 | QString Addressee::sortString() const |
829 | { | 868 | { |
830 | return mData->sortString; | 869 | return mData->sortString; |
831 | } | 870 | } |
832 | 871 | ||
833 | QString Addressee::sortStringLabel() | 872 | QString Addressee::sortStringLabel() |
834 | { | 873 | { |
835 | return i18n("Sort String"); | 874 | return i18n("Sort String"); |
836 | } | 875 | } |
837 | 876 | ||
838 | 877 | ||
839 | void Addressee::setUrl( const KURL &url ) | 878 | void Addressee::setUrl( const KURL &url ) |
840 | { | 879 | { |
841 | if ( url == mData->url ) return; | 880 | if ( url == mData->url ) return; |
842 | detach(); | 881 | detach(); |
843 | mData->empty = false; | 882 | mData->empty = false; |
844 | mData->url = url; | 883 | mData->url = url; |
845 | } | 884 | } |
846 | 885 | ||
847 | KURL Addressee::url() const | 886 | KURL Addressee::url() const |
848 | { | 887 | { |
849 | return mData->url; | 888 | return mData->url; |
850 | } | 889 | } |
851 | 890 | ||
852 | QString Addressee::urlLabel() | 891 | QString Addressee::urlLabel() |
853 | { | 892 | { |
854 | return i18n("URL"); | 893 | return i18n("URL"); |
855 | } | 894 | } |
856 | 895 | ||
857 | 896 | ||
858 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 897 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
859 | { | 898 | { |
860 | if ( secrecy == mData->secrecy ) return; | 899 | if ( secrecy == mData->secrecy ) return; |
861 | detach(); | 900 | detach(); |
862 | mData->empty = false; | 901 | mData->empty = false; |
863 | mData->secrecy = secrecy; | 902 | mData->secrecy = secrecy; |
864 | } | 903 | } |
865 | 904 | ||
866 | Secrecy Addressee::secrecy() const | 905 | Secrecy Addressee::secrecy() const |
867 | { | 906 | { |
868 | return mData->secrecy; | 907 | return mData->secrecy; |
869 | } | 908 | } |
870 | 909 | ||
871 | QString Addressee::secrecyLabel() | 910 | QString Addressee::secrecyLabel() |
872 | { | 911 | { |
873 | return i18n("Security Class"); | 912 | return i18n("Security Class"); |
874 | } | 913 | } |
875 | 914 | ||
876 | 915 | ||
877 | void Addressee::setLogo( const Picture &logo ) | 916 | void Addressee::setLogo( const Picture &logo ) |
878 | { | 917 | { |
879 | if ( logo == mData->logo ) return; | 918 | if ( logo == mData->logo ) return; |
880 | detach(); | 919 | detach(); |
881 | mData->empty = false; | 920 | mData->empty = false; |
882 | mData->logo = logo; | 921 | mData->logo = logo; |
883 | } | 922 | } |
884 | 923 | ||
885 | Picture Addressee::logo() const | 924 | Picture Addressee::logo() const |
886 | { | 925 | { |
887 | return mData->logo; | 926 | return mData->logo; |
888 | } | 927 | } |
889 | 928 | ||
890 | QString Addressee::logoLabel() | 929 | QString Addressee::logoLabel() |
891 | { | 930 | { |
892 | return i18n("Logo"); | 931 | return i18n("Logo"); |
893 | } | 932 | } |
894 | 933 | ||
895 | 934 | ||
896 | void Addressee::setPhoto( const Picture &photo ) | 935 | void Addressee::setPhoto( const Picture &photo ) |
897 | { | 936 | { |
898 | if ( photo == mData->photo ) return; | 937 | if ( photo == mData->photo ) return; |
899 | detach(); | 938 | detach(); |
900 | mData->empty = false; | 939 | mData->empty = false; |
901 | mData->photo = photo; | 940 | mData->photo = photo; |
902 | } | 941 | } |
903 | 942 | ||
904 | Picture Addressee::photo() const | 943 | Picture Addressee::photo() const |
905 | { | 944 | { |
906 | return mData->photo; | 945 | return mData->photo; |
907 | } | 946 | } |
908 | 947 | ||
909 | QString Addressee::photoLabel() | 948 | QString Addressee::photoLabel() |
910 | { | 949 | { |
911 | return i18n("Photo"); | 950 | return i18n("Photo"); |
912 | } | 951 | } |
913 | 952 | ||
914 | 953 | ||
915 | void Addressee::setSound( const Sound &sound ) | 954 | void Addressee::setSound( const Sound &sound ) |
916 | { | 955 | { |
917 | if ( sound == mData->sound ) return; | 956 | if ( sound == mData->sound ) return; |
918 | detach(); | 957 | detach(); |
919 | mData->empty = false; | 958 | mData->empty = false; |
920 | mData->sound = sound; | 959 | mData->sound = sound; |
921 | } | 960 | } |
922 | 961 | ||
923 | Sound Addressee::sound() const | 962 | Sound Addressee::sound() const |
924 | { | 963 | { |
925 | return mData->sound; | 964 | return mData->sound; |
926 | } | 965 | } |
927 | 966 | ||
928 | QString Addressee::soundLabel() | 967 | QString Addressee::soundLabel() |
929 | { | 968 | { |
930 | return i18n("Sound"); | 969 | return i18n("Sound"); |
931 | } | 970 | } |
932 | 971 | ||
933 | 972 | ||
934 | void Addressee::setAgent( const Agent &agent ) | 973 | void Addressee::setAgent( const Agent &agent ) |
935 | { | 974 | { |
936 | if ( agent == mData->agent ) return; | 975 | if ( agent == mData->agent ) return; |
937 | detach(); | 976 | detach(); |
938 | mData->empty = false; | 977 | mData->empty = false; |
939 | mData->agent = agent; | 978 | mData->agent = agent; |
940 | } | 979 | } |
941 | 980 | ||
942 | Agent Addressee::agent() const | 981 | Agent Addressee::agent() const |
943 | { | 982 | { |
944 | return mData->agent; | 983 | return mData->agent; |
945 | } | 984 | } |
946 | 985 | ||
947 | QString Addressee::agentLabel() | 986 | QString Addressee::agentLabel() |
948 | { | 987 | { |
949 | return i18n("Agent"); | 988 | return i18n("Agent"); |
950 | } | 989 | } |
951 | 990 | ||
952 | 991 | ||
953 | 992 | ||
954 | void Addressee::setNameFromString( const QString &str ) | 993 | void Addressee::setNameFromString( const QString &str ) |
955 | { | 994 | { |
956 | setFormattedName( str ); | 995 | setFormattedName( str ); |
957 | setName( str ); | 996 | setName( str ); |
958 | 997 | ||
959 | static bool first = true; | 998 | static bool first = true; |
960 | static QStringList titles; | 999 | static QStringList titles; |
961 | static QStringList suffixes; | 1000 | static QStringList suffixes; |
962 | static QStringList prefixes; | 1001 | static QStringList prefixes; |
963 | 1002 | ||
964 | if ( first ) { | 1003 | if ( first ) { |
965 | first = false; | 1004 | first = false; |
966 | titles += i18n( "Dr." ); | 1005 | titles += i18n( "Dr." ); |
967 | titles += i18n( "Miss" ); | 1006 | titles += i18n( "Miss" ); |
968 | titles += i18n( "Mr." ); | 1007 | titles += i18n( "Mr." ); |
969 | titles += i18n( "Mrs." ); | 1008 | titles += i18n( "Mrs." ); |
970 | titles += i18n( "Ms." ); | 1009 | titles += i18n( "Ms." ); |
971 | titles += i18n( "Prof." ); | 1010 | titles += i18n( "Prof." ); |
972 | 1011 | ||
973 | suffixes += i18n( "I" ); | 1012 | suffixes += i18n( "I" ); |
974 | suffixes += i18n( "II" ); | 1013 | suffixes += i18n( "II" ); |
975 | suffixes += i18n( "III" ); | 1014 | suffixes += i18n( "III" ); |
976 | suffixes += i18n( "Jr." ); | 1015 | suffixes += i18n( "Jr." ); |
977 | suffixes += i18n( "Sr." ); | 1016 | suffixes += i18n( "Sr." ); |
978 | 1017 | ||
979 | prefixes += "van"; | 1018 | prefixes += "van"; |
980 | prefixes += "von"; | 1019 | prefixes += "von"; |
981 | prefixes += "de"; | 1020 | prefixes += "de"; |
982 | 1021 | ||
983 | KConfig config( locateLocal( "config", "kabcrc") ); | 1022 | KConfig config( locateLocal( "config", "kabcrc") ); |
984 | config.setGroup( "General" ); | 1023 | config.setGroup( "General" ); |
985 | titles += config.readListEntry( "Prefixes" ); | 1024 | titles += config.readListEntry( "Prefixes" ); |
986 | titles.remove( "" ); | 1025 | titles.remove( "" ); |
987 | prefixes += config.readListEntry( "Inclusions" ); | 1026 | prefixes += config.readListEntry( "Inclusions" ); |
988 | prefixes.remove( "" ); | 1027 | prefixes.remove( "" ); |
989 | suffixes += config.readListEntry( "Suffixes" ); | 1028 | suffixes += config.readListEntry( "Suffixes" ); |
990 | suffixes.remove( "" ); | 1029 | suffixes.remove( "" ); |
991 | } | 1030 | } |
992 | 1031 | ||
993 | // clear all name parts | 1032 | // clear all name parts |
994 | setPrefix( "" ); | 1033 | setPrefix( "" ); |
995 | setGivenName( "" ); | 1034 | setGivenName( "" ); |
996 | setAdditionalName( "" ); | 1035 | setAdditionalName( "" ); |
997 | setFamilyName( "" ); | 1036 | setFamilyName( "" ); |
998 | setSuffix( "" ); | 1037 | setSuffix( "" ); |
999 | 1038 | ||
1000 | if ( str.isEmpty() ) | 1039 | if ( str.isEmpty() ) |
1001 | return; | 1040 | return; |
1002 | 1041 | ||
1003 | int i = str.find(','); | 1042 | int i = str.find(','); |
1004 | if( i < 0 ) { | 1043 | if( i < 0 ) { |
1005 | QStringList parts = QStringList::split( " ", str ); | 1044 | QStringList parts = QStringList::split( " ", str ); |
1006 | int leftOffset = 0; | 1045 | int leftOffset = 0; |
1007 | int rightOffset = parts.count() - 1; | 1046 | int rightOffset = parts.count() - 1; |
1008 | 1047 | ||
1009 | QString suffix; | 1048 | QString suffix; |
1010 | while ( rightOffset >= 0 ) { | 1049 | while ( rightOffset >= 0 ) { |
1011 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1050 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1012 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1051 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1013 | rightOffset--; | 1052 | rightOffset--; |
1014 | } else | 1053 | } else |
1015 | break; | 1054 | break; |
1016 | } | 1055 | } |
1017 | setSuffix( suffix ); | 1056 | setSuffix( suffix ); |
1018 | 1057 | ||
1019 | if ( rightOffset < 0 ) | 1058 | if ( rightOffset < 0 ) |
1020 | return; | 1059 | return; |
1021 | 1060 | ||
1022 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1061 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1023 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1062 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1024 | rightOffset--; | 1063 | rightOffset--; |
1025 | } else | 1064 | } else |
1026 | setFamilyName( parts[ rightOffset ] ); | 1065 | setFamilyName( parts[ rightOffset ] ); |
1027 | 1066 | ||
1028 | QString prefix; | 1067 | QString prefix; |
1029 | while ( leftOffset < rightOffset ) { | 1068 | while ( leftOffset < rightOffset ) { |
1030 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1069 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1031 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1070 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1032 | leftOffset++; | 1071 | leftOffset++; |
1033 | } else | 1072 | } else |
1034 | break; | 1073 | break; |
1035 | } | 1074 | } |
1036 | setPrefix( prefix ); | 1075 | setPrefix( prefix ); |
1037 | 1076 | ||
1038 | if ( leftOffset < rightOffset ) { | 1077 | if ( leftOffset < rightOffset ) { |
1039 | setGivenName( parts[ leftOffset ] ); | 1078 | setGivenName( parts[ leftOffset ] ); |
1040 | leftOffset++; | 1079 | leftOffset++; |
1041 | } | 1080 | } |
1042 | 1081 | ||
1043 | QString additionalName; | 1082 | QString additionalName; |
1044 | while ( leftOffset < rightOffset ) { | 1083 | while ( leftOffset < rightOffset ) { |
1045 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1084 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1046 | leftOffset++; | 1085 | leftOffset++; |
1047 | } | 1086 | } |
1048 | setAdditionalName( additionalName ); | 1087 | setAdditionalName( additionalName ); |
1049 | } else { | 1088 | } else { |
1050 | QString part1 = str.left( i ); | 1089 | QString part1 = str.left( i ); |
1051 | QString part2 = str.mid( i + 1 ); | 1090 | QString part2 = str.mid( i + 1 ); |
1052 | 1091 | ||
1053 | QStringList parts = QStringList::split( " ", part1 ); | 1092 | QStringList parts = QStringList::split( " ", part1 ); |
1054 | int leftOffset = 0; | 1093 | int leftOffset = 0; |
1055 | int rightOffset = parts.count() - 1; | 1094 | int rightOffset = parts.count() - 1; |
1056 | 1095 | ||
1057 | QString suffix; | 1096 | QString suffix; |
1058 | while ( rightOffset >= 0 ) { | 1097 | while ( rightOffset >= 0 ) { |
1059 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1098 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1060 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1099 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1061 | rightOffset--; | 1100 | rightOffset--; |
1062 | } else | 1101 | } else |
1063 | break; | 1102 | break; |
1064 | } | 1103 | } |
1065 | setSuffix( suffix ); | 1104 | setSuffix( suffix ); |
1066 | 1105 | ||
1067 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1106 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1068 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1107 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1069 | rightOffset--; | 1108 | rightOffset--; |
1070 | } else | 1109 | } else |
1071 | setFamilyName( parts[ rightOffset ] ); | 1110 | setFamilyName( parts[ rightOffset ] ); |
1072 | 1111 | ||
1073 | QString prefix; | 1112 | QString prefix; |
1074 | while ( leftOffset < rightOffset ) { | 1113 | while ( leftOffset < rightOffset ) { |
1075 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1114 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1076 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1115 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1077 | leftOffset++; | 1116 | leftOffset++; |
1078 | } else | 1117 | } else |
1079 | break; | 1118 | break; |
1080 | } | 1119 | } |
1081 | 1120 | ||
1082 | parts = QStringList::split( " ", part2 ); | 1121 | parts = QStringList::split( " ", part2 ); |
1083 | 1122 | ||
1084 | leftOffset = 0; | 1123 | leftOffset = 0; |
1085 | rightOffset = parts.count(); | 1124 | rightOffset = parts.count(); |
1086 | 1125 | ||
1087 | while ( leftOffset < rightOffset ) { | 1126 | while ( leftOffset < rightOffset ) { |
1088 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1127 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1089 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1128 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1090 | leftOffset++; | 1129 | leftOffset++; |
1091 | } else | 1130 | } else |
1092 | break; | 1131 | break; |
1093 | } | 1132 | } |
1094 | setPrefix( prefix ); | 1133 | setPrefix( prefix ); |
1095 | 1134 | ||
1096 | if ( leftOffset < rightOffset ) { | 1135 | if ( leftOffset < rightOffset ) { |
1097 | setGivenName( parts[ leftOffset ] ); | 1136 | setGivenName( parts[ leftOffset ] ); |
1098 | leftOffset++; | 1137 | leftOffset++; |
1099 | } | 1138 | } |
1100 | 1139 | ||
1101 | QString additionalName; | 1140 | QString additionalName; |
1102 | while ( leftOffset < rightOffset ) { | 1141 | while ( leftOffset < rightOffset ) { |
1103 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1142 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1104 | leftOffset++; | 1143 | leftOffset++; |
1105 | } | 1144 | } |
1106 | setAdditionalName( additionalName ); | 1145 | setAdditionalName( additionalName ); |
1107 | } | 1146 | } |
1108 | } | 1147 | } |
1109 | 1148 | ||
1110 | QString Addressee::realName() const | 1149 | QString Addressee::realName() const |
1111 | { | 1150 | { |
1112 | if ( !formattedName().isEmpty() ) | 1151 | if ( !formattedName().isEmpty() ) |
1113 | return formattedName(); | 1152 | return formattedName(); |
1114 | 1153 | ||
1115 | QString n = assembledName(); | 1154 | QString n = assembledName(); |
1116 | 1155 | ||
1117 | if ( n.isEmpty() ) | 1156 | if ( n.isEmpty() ) |
1118 | n = name(); | 1157 | n = name(); |
1119 | 1158 | ||
1120 | return n; | 1159 | return n; |
1121 | } | 1160 | } |
1122 | 1161 | ||
1123 | QString Addressee::assembledName() const | 1162 | QString Addressee::assembledName() const |
1124 | { | 1163 | { |
1125 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1164 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1126 | familyName() + " " + suffix(); | 1165 | familyName() + " " + suffix(); |
1127 | 1166 | ||
1128 | return name.simplifyWhiteSpace(); | 1167 | return name.simplifyWhiteSpace(); |
1129 | } | 1168 | } |
1130 | 1169 | ||
1131 | QString Addressee::fullEmail( const QString &email ) const | 1170 | QString Addressee::fullEmail( const QString &email ) const |
1132 | { | 1171 | { |
1133 | QString e; | 1172 | QString e; |
1134 | if ( email.isNull() ) { | 1173 | if ( email.isNull() ) { |
1135 | e = preferredEmail(); | 1174 | e = preferredEmail(); |
1136 | } else { | 1175 | } else { |
1137 | e = email; | 1176 | e = email; |
1138 | } | 1177 | } |
1139 | if ( e.isEmpty() ) return QString::null; | 1178 | if ( e.isEmpty() ) return QString::null; |
1140 | 1179 | ||
1141 | QString text; | 1180 | QString text; |
1142 | if ( realName().isEmpty() ) | 1181 | if ( realName().isEmpty() ) |
1143 | text = e; | 1182 | text = e; |
1144 | else | 1183 | else |
1145 | text = assembledName() + " <" + e + ">"; | 1184 | text = assembledName() + " <" + e + ">"; |
1146 | 1185 | ||
1147 | return text; | 1186 | return text; |
1148 | } | 1187 | } |
1149 | 1188 | ||
1150 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1189 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1151 | { | 1190 | { |
1152 | detach(); | 1191 | detach(); |
1153 | 1192 | ||
1154 | QStringList::Iterator it = mData->emails.find( email ); | 1193 | QStringList::Iterator it = mData->emails.find( email ); |
1155 | 1194 | ||
1156 | if ( it != mData->emails.end() ) { | 1195 | if ( it != mData->emails.end() ) { |
1157 | if ( !preferred || it == mData->emails.begin() ) return; | 1196 | if ( !preferred || it == mData->emails.begin() ) return; |
1158 | mData->emails.remove( it ); | 1197 | mData->emails.remove( it ); |
1159 | mData->emails.prepend( email ); | 1198 | mData->emails.prepend( email ); |
1160 | } else { | 1199 | } else { |
1161 | if ( preferred ) { | 1200 | if ( preferred ) { |
1162 | mData->emails.prepend( email ); | 1201 | mData->emails.prepend( email ); |
1163 | } else { | 1202 | } else { |
1164 | mData->emails.append( email ); | 1203 | mData->emails.append( email ); |
1165 | } | 1204 | } |
1166 | } | 1205 | } |
1167 | } | 1206 | } |
1168 | 1207 | ||
1169 | void Addressee::removeEmail( const QString &email ) | 1208 | void Addressee::removeEmail( const QString &email ) |
1170 | { | 1209 | { |
1171 | detach(); | 1210 | detach(); |
1172 | 1211 | ||
1173 | QStringList::Iterator it = mData->emails.find( email ); | 1212 | QStringList::Iterator it = mData->emails.find( email ); |
1174 | if ( it == mData->emails.end() ) return; | 1213 | if ( it == mData->emails.end() ) return; |
1175 | 1214 | ||
1176 | mData->emails.remove( it ); | 1215 | mData->emails.remove( it ); |
1177 | } | 1216 | } |
1178 | 1217 | ||
1179 | QString Addressee::preferredEmail() const | 1218 | QString Addressee::preferredEmail() const |
1180 | { | 1219 | { |
1181 | if ( mData->emails.count() == 0 ) return QString::null; | 1220 | if ( mData->emails.count() == 0 ) return QString::null; |
1182 | else return mData->emails.first(); | 1221 | else return mData->emails.first(); |
1183 | } | 1222 | } |
1184 | 1223 | ||
1185 | QStringList Addressee::emails() const | 1224 | QStringList Addressee::emails() const |
1186 | { | 1225 | { |
1187 | return mData->emails; | 1226 | return mData->emails; |
1188 | } | 1227 | } |
1189 | void Addressee::setEmails( const QStringList& emails ) { | 1228 | void Addressee::setEmails( const QStringList& emails ) { |
1190 | detach(); | 1229 | detach(); |
1191 | mData->emails = emails; | 1230 | mData->emails = emails; |
1192 | } | 1231 | } |
1193 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1232 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1194 | { | 1233 | { |
1195 | detach(); | 1234 | detach(); |
1196 | mData->empty = false; | 1235 | mData->empty = false; |
1197 | 1236 | ||
1198 | PhoneNumber::List::Iterator it; | 1237 | PhoneNumber::List::Iterator it; |
1199 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1238 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1200 | if ( (*it).id() == phoneNumber.id() ) { | 1239 | if ( (*it).id() == phoneNumber.id() ) { |
1201 | *it = phoneNumber; | 1240 | *it = phoneNumber; |
1202 | return; | 1241 | return; |
1203 | } | 1242 | } |
1204 | } | 1243 | } |
1205 | mData->phoneNumbers.append( phoneNumber ); | 1244 | mData->phoneNumbers.append( phoneNumber ); |
1206 | } | 1245 | } |
1207 | 1246 | ||
1208 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1247 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1209 | { | 1248 | { |
1210 | detach(); | 1249 | detach(); |
1211 | 1250 | ||
1212 | PhoneNumber::List::Iterator it; | 1251 | PhoneNumber::List::Iterator it; |
1213 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1252 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1214 | if ( (*it).id() == phoneNumber.id() ) { | 1253 | if ( (*it).id() == phoneNumber.id() ) { |
1215 | mData->phoneNumbers.remove( it ); | 1254 | mData->phoneNumbers.remove( it ); |
1216 | return; | 1255 | return; |
1217 | } | 1256 | } |
1218 | } | 1257 | } |
1219 | } | 1258 | } |
1220 | 1259 | ||
1221 | PhoneNumber Addressee::phoneNumber( int type ) const | 1260 | PhoneNumber Addressee::phoneNumber( int type ) const |
1222 | { | 1261 | { |
1223 | PhoneNumber phoneNumber( "", type ); | 1262 | PhoneNumber phoneNumber( "", type ); |
1224 | PhoneNumber::List::ConstIterator it; | 1263 | PhoneNumber::List::ConstIterator it; |
1225 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1264 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1226 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1265 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1227 | if ( (*it).type() & PhoneNumber::Pref ) | 1266 | if ( (*it).type() & PhoneNumber::Pref ) |
1228 | return (*it); | 1267 | return (*it); |
1229 | else if ( phoneNumber.number().isEmpty() ) | 1268 | else if ( phoneNumber.number().isEmpty() ) |
1230 | phoneNumber = (*it); | 1269 | phoneNumber = (*it); |
1231 | } | 1270 | } |
1232 | } | 1271 | } |
1233 | 1272 | ||
1234 | return phoneNumber; | 1273 | return phoneNumber; |
1235 | } | 1274 | } |
1236 | 1275 | ||
1237 | PhoneNumber::List Addressee::phoneNumbers() const | 1276 | PhoneNumber::List Addressee::phoneNumbers() const |
1238 | { | 1277 | { |
1239 | return mData->phoneNumbers; | 1278 | return mData->phoneNumbers; |
1240 | } | 1279 | } |
1241 | 1280 | ||
1242 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1281 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1243 | { | 1282 | { |
1244 | PhoneNumber::List list; | 1283 | PhoneNumber::List list; |
1245 | 1284 | ||
1246 | PhoneNumber::List::ConstIterator it; | 1285 | PhoneNumber::List::ConstIterator it; |
1247 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1286 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1248 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1287 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1249 | list.append( *it ); | 1288 | list.append( *it ); |
1250 | } | 1289 | } |
1251 | } | 1290 | } |
1252 | return list; | 1291 | return list; |
1253 | } | 1292 | } |
1254 | 1293 | ||
1255 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1294 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1256 | { | 1295 | { |
1257 | PhoneNumber::List::ConstIterator it; | 1296 | PhoneNumber::List::ConstIterator it; |
1258 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1297 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1259 | if ( (*it).id() == id ) { | 1298 | if ( (*it).id() == id ) { |
1260 | return *it; | 1299 | return *it; |
1261 | } | 1300 | } |
1262 | } | 1301 | } |
1263 | return PhoneNumber(); | 1302 | return PhoneNumber(); |
1264 | } | 1303 | } |
1265 | 1304 | ||
1266 | void Addressee::insertKey( const Key &key ) | 1305 | void Addressee::insertKey( const Key &key ) |
1267 | { | 1306 | { |
1268 | detach(); | 1307 | detach(); |
1269 | mData->empty = false; | 1308 | mData->empty = false; |
1270 | 1309 | ||
1271 | Key::List::Iterator it; | 1310 | Key::List::Iterator it; |
1272 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1311 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1273 | if ( (*it).id() == key.id() ) { | 1312 | if ( (*it).id() == key.id() ) { |
1274 | *it = key; | 1313 | *it = key; |
1275 | return; | 1314 | return; |
1276 | } | 1315 | } |
1277 | } | 1316 | } |
1278 | mData->keys.append( key ); | 1317 | mData->keys.append( key ); |
1279 | } | 1318 | } |
1280 | 1319 | ||
1281 | void Addressee::removeKey( const Key &key ) | 1320 | void Addressee::removeKey( const Key &key ) |
1282 | { | 1321 | { |
1283 | detach(); | 1322 | detach(); |
1284 | 1323 | ||
1285 | Key::List::Iterator it; | 1324 | Key::List::Iterator it; |
1286 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1325 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1287 | if ( (*it).id() == key.id() ) { | 1326 | if ( (*it).id() == key.id() ) { |
1288 | mData->keys.remove( key ); | 1327 | mData->keys.remove( key ); |
1289 | return; | 1328 | return; |
1290 | } | 1329 | } |
1291 | } | 1330 | } |
1292 | } | 1331 | } |
1293 | 1332 | ||
1294 | Key Addressee::key( int type, QString customTypeString ) const | 1333 | Key Addressee::key( int type, QString customTypeString ) const |
1295 | { | 1334 | { |
1296 | Key::List::ConstIterator it; | 1335 | Key::List::ConstIterator it; |
1297 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1336 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1298 | if ( (*it).type() == type ) { | 1337 | if ( (*it).type() == type ) { |
1299 | if ( type == Key::Custom ) { | 1338 | if ( type == Key::Custom ) { |
1300 | if ( customTypeString.isEmpty() ) { | 1339 | if ( customTypeString.isEmpty() ) { |
1301 | return *it; | 1340 | return *it; |
1302 | } else { | 1341 | } else { |
1303 | if ( (*it).customTypeString() == customTypeString ) | 1342 | if ( (*it).customTypeString() == customTypeString ) |
1304 | return (*it); | 1343 | return (*it); |
1305 | } | 1344 | } |
1306 | } else { | 1345 | } else { |
1307 | return *it; | 1346 | return *it; |
1308 | } | 1347 | } |
1309 | } | 1348 | } |
1310 | } | 1349 | } |
1311 | return Key( QString(), type ); | 1350 | return Key( QString(), type ); |
1312 | } | 1351 | } |
1313 | void Addressee::setKeys( const Key::List& list ) { | 1352 | void Addressee::setKeys( const Key::List& list ) { |
1314 | detach(); | 1353 | detach(); |
1315 | mData->keys = list; | 1354 | mData->keys = list; |
1316 | } | 1355 | } |
1317 | 1356 | ||
1318 | Key::List Addressee::keys() const | 1357 | Key::List Addressee::keys() const |
1319 | { | 1358 | { |
1320 | return mData->keys; | 1359 | return mData->keys; |
1321 | } | 1360 | } |
1322 | 1361 | ||
1323 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1362 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1324 | { | 1363 | { |
1325 | Key::List list; | 1364 | Key::List list; |
1326 | 1365 | ||
1327 | Key::List::ConstIterator it; | 1366 | Key::List::ConstIterator it; |
1328 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1367 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1329 | if ( (*it).type() == type ) { | 1368 | if ( (*it).type() == type ) { |
1330 | if ( type == Key::Custom ) { | 1369 | if ( type == Key::Custom ) { |
1331 | if ( customTypeString.isEmpty() ) { | 1370 | if ( customTypeString.isEmpty() ) { |
1332 | list.append(*it); | 1371 | list.append(*it); |
1333 | } else { | 1372 | } else { |
1334 | if ( (*it).customTypeString() == customTypeString ) | 1373 | if ( (*it).customTypeString() == customTypeString ) |
1335 | list.append(*it); | 1374 | list.append(*it); |
1336 | } | 1375 | } |
1337 | } else { | 1376 | } else { |
1338 | list.append(*it); | 1377 | list.append(*it); |
1339 | } | 1378 | } |
1340 | } | 1379 | } |
1341 | } | 1380 | } |
1342 | return list; | 1381 | return list; |
1343 | } | 1382 | } |
1344 | 1383 | ||
1345 | Key Addressee::findKey( const QString &id ) const | 1384 | Key Addressee::findKey( const QString &id ) const |
1346 | { | 1385 | { |
1347 | Key::List::ConstIterator it; | 1386 | Key::List::ConstIterator it; |
1348 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1387 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1349 | if ( (*it).id() == id ) { | 1388 | if ( (*it).id() == id ) { |
1350 | return *it; | 1389 | return *it; |
1351 | } | 1390 | } |
1352 | } | 1391 | } |
1353 | return Key(); | 1392 | return Key(); |
1354 | } | 1393 | } |
1355 | 1394 | ||
1356 | QString Addressee::asString() const | 1395 | QString Addressee::asString() const |
1357 | { | 1396 | { |
1358 | return "Smith, agent Smith..."; | 1397 | return "Smith, agent Smith..."; |
1359 | } | 1398 | } |
1360 | 1399 | ||
1361 | void Addressee::dump() const | 1400 | void Addressee::dump() const |
1362 | { | 1401 | { |
1363 | return; | 1402 | return; |
1364 | kdDebug(5700) << "Addressee {" << endl; | 1403 | kdDebug(5700) << "Addressee {" << endl; |
1365 | 1404 | ||
1366 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1405 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1367 | 1406 | ||
1368 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1407 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1369 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1408 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1370 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1409 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1371 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1410 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1372 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1411 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1373 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1412 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1374 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1413 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1375 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1414 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1376 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1415 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1377 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1416 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1378 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1417 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1379 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1418 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1380 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1419 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1381 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1420 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1382 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1421 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1383 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1422 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1384 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1423 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1385 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1424 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1386 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1425 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1387 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1426 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1388 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1427 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1389 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1428 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1390 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1429 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1391 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1430 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1392 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1431 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1393 | 1432 | ||
1394 | kdDebug(5700) << " Emails {" << endl; | 1433 | kdDebug(5700) << " Emails {" << endl; |
1395 | QStringList e = emails(); | 1434 | QStringList e = emails(); |
1396 | QStringList::ConstIterator it; | 1435 | QStringList::ConstIterator it; |
1397 | for( it = e.begin(); it != e.end(); ++it ) { | 1436 | for( it = e.begin(); it != e.end(); ++it ) { |
1398 | kdDebug(5700) << " " << (*it) << endl; | 1437 | kdDebug(5700) << " " << (*it) << endl; |
1399 | } | 1438 | } |
1400 | kdDebug(5700) << " }" << endl; | 1439 | kdDebug(5700) << " }" << endl; |
1401 | 1440 | ||
1402 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1441 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1403 | PhoneNumber::List p = phoneNumbers(); | 1442 | PhoneNumber::List p = phoneNumbers(); |
1404 | PhoneNumber::List::ConstIterator it2; | 1443 | PhoneNumber::List::ConstIterator it2; |
1405 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1444 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1406 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1445 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1407 | } | 1446 | } |
1408 | kdDebug(5700) << " }" << endl; | 1447 | kdDebug(5700) << " }" << endl; |
1409 | 1448 | ||
1410 | Address::List a = addresses(); | 1449 | Address::List a = addresses(); |
1411 | Address::List::ConstIterator it3; | 1450 | Address::List::ConstIterator it3; |
1412 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1451 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1413 | (*it3).dump(); | 1452 | (*it3).dump(); |
1414 | } | 1453 | } |
1415 | 1454 | ||
1416 | kdDebug(5700) << " Keys {" << endl; | 1455 | kdDebug(5700) << " Keys {" << endl; |
1417 | Key::List k = keys(); | 1456 | Key::List k = keys(); |
1418 | Key::List::ConstIterator it4; | 1457 | Key::List::ConstIterator it4; |
1419 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1458 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1420 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1459 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1421 | " Key: " << (*it4).textData() << | 1460 | " Key: " << (*it4).textData() << |
1422 | " CustomString: " << (*it4).customTypeString() << endl; | 1461 | " CustomString: " << (*it4).customTypeString() << endl; |
1423 | } | 1462 | } |
1424 | kdDebug(5700) << " }" << endl; | 1463 | kdDebug(5700) << " }" << endl; |
1425 | 1464 | ||
1426 | kdDebug(5700) << "}" << endl; | 1465 | kdDebug(5700) << "}" << endl; |
1427 | } | 1466 | } |
1428 | 1467 | ||
1429 | 1468 | ||
1430 | void Addressee::insertAddress( const Address &address ) | 1469 | void Addressee::insertAddress( const Address &address ) |
1431 | { | 1470 | { |
1432 | detach(); | 1471 | detach(); |
1433 | mData->empty = false; | 1472 | mData->empty = false; |
1434 | 1473 | ||
1435 | Address::List::Iterator it; | 1474 | Address::List::Iterator it; |
1436 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1475 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1437 | if ( (*it).id() == address.id() ) { | 1476 | if ( (*it).id() == address.id() ) { |
1438 | *it = address; | 1477 | *it = address; |
1439 | return; | 1478 | return; |
1440 | } | 1479 | } |
1441 | } | 1480 | } |
1442 | mData->addresses.append( address ); | 1481 | mData->addresses.append( address ); |
1443 | } | 1482 | } |
1444 | 1483 | ||
1445 | void Addressee::removeAddress( const Address &address ) | 1484 | void Addressee::removeAddress( const Address &address ) |
1446 | { | 1485 | { |
1447 | detach(); | 1486 | detach(); |
1448 | 1487 | ||
1449 | Address::List::Iterator it; | 1488 | Address::List::Iterator it; |
1450 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1489 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1451 | if ( (*it).id() == address.id() ) { | 1490 | if ( (*it).id() == address.id() ) { |
1452 | mData->addresses.remove( it ); | 1491 | mData->addresses.remove( it ); |
1453 | return; | 1492 | return; |
1454 | } | 1493 | } |
1455 | } | 1494 | } |
1456 | } | 1495 | } |
1457 | 1496 | ||
1458 | Address Addressee::address( int type ) const | 1497 | Address Addressee::address( int type ) const |
1459 | { | 1498 | { |
1460 | Address address( type ); | 1499 | Address address( type ); |
1461 | Address::List::ConstIterator it; | 1500 | Address::List::ConstIterator it; |
1462 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1501 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1463 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1502 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1464 | if ( (*it).type() & Address::Pref ) | 1503 | if ( (*it).type() & Address::Pref ) |
1465 | return (*it); | 1504 | return (*it); |
1466 | else if ( address.isEmpty() ) | 1505 | else if ( address.isEmpty() ) |
1467 | address = (*it); | 1506 | address = (*it); |
1468 | } | 1507 | } |
1469 | } | 1508 | } |
1470 | 1509 | ||
1471 | return address; | 1510 | return address; |
1472 | } | 1511 | } |
1473 | 1512 | ||
1474 | Address::List Addressee::addresses() const | 1513 | Address::List Addressee::addresses() const |
1475 | { | 1514 | { |
1476 | return mData->addresses; | 1515 | return mData->addresses; |
1477 | } | 1516 | } |
1478 | 1517 | ||
1479 | Address::List Addressee::addresses( int type ) const | 1518 | Address::List Addressee::addresses( int type ) const |
1480 | { | 1519 | { |
1481 | Address::List list; | 1520 | Address::List list; |
1482 | 1521 | ||
1483 | Address::List::ConstIterator it; | 1522 | Address::List::ConstIterator it; |
1484 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1523 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1485 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1524 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1486 | list.append( *it ); | 1525 | list.append( *it ); |
1487 | } | 1526 | } |
1488 | } | 1527 | } |
1489 | 1528 | ||
1490 | return list; | 1529 | return list; |
1491 | } | 1530 | } |
1492 | 1531 | ||
1493 | Address Addressee::findAddress( const QString &id ) const | 1532 | Address Addressee::findAddress( const QString &id ) const |
1494 | { | 1533 | { |
1495 | Address::List::ConstIterator it; | 1534 | Address::List::ConstIterator it; |
1496 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1535 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1497 | if ( (*it).id() == id ) { | 1536 | if ( (*it).id() == id ) { |
1498 | return *it; | 1537 | return *it; |
1499 | } | 1538 | } |
1500 | } | 1539 | } |
1501 | return Address(); | 1540 | return Address(); |
1502 | } | 1541 | } |
1503 | 1542 | ||
1504 | void Addressee::insertCategory( const QString &c ) | 1543 | void Addressee::insertCategory( const QString &c ) |
1505 | { | 1544 | { |
1506 | detach(); | 1545 | detach(); |
1507 | mData->empty = false; | 1546 | mData->empty = false; |
1508 | 1547 | ||
1509 | if ( mData->categories.contains( c ) ) return; | 1548 | if ( mData->categories.contains( c ) ) return; |
1510 | 1549 | ||
1511 | mData->categories.append( c ); | 1550 | mData->categories.append( c ); |
1512 | } | 1551 | } |
1513 | 1552 | ||
1514 | void Addressee::removeCategory( const QString &c ) | 1553 | void Addressee::removeCategory( const QString &c ) |
1515 | { | 1554 | { |
1516 | detach(); | 1555 | detach(); |
1517 | 1556 | ||
1518 | QStringList::Iterator it = mData->categories.find( c ); | 1557 | QStringList::Iterator it = mData->categories.find( c ); |
1519 | if ( it == mData->categories.end() ) return; | 1558 | if ( it == mData->categories.end() ) return; |
1520 | 1559 | ||
1521 | mData->categories.remove( it ); | 1560 | mData->categories.remove( it ); |
1522 | } | 1561 | } |
1523 | 1562 | ||
1524 | bool Addressee::hasCategory( const QString &c ) const | 1563 | bool Addressee::hasCategory( const QString &c ) const |
1525 | { | 1564 | { |
1526 | return ( mData->categories.contains( c ) ); | 1565 | return ( mData->categories.contains( c ) ); |
1527 | } | 1566 | } |
1528 | 1567 | ||
1529 | void Addressee::setCategories( const QStringList &c ) | 1568 | void Addressee::setCategories( const QStringList &c ) |
1530 | { | 1569 | { |
1531 | detach(); | 1570 | detach(); |
1532 | mData->empty = false; | 1571 | mData->empty = false; |
1533 | 1572 | ||
1534 | mData->categories = c; | 1573 | mData->categories = c; |
1535 | } | 1574 | } |
1536 | 1575 | ||
1537 | QStringList Addressee::categories() const | 1576 | QStringList Addressee::categories() const |
1538 | { | 1577 | { |
1539 | return mData->categories; | 1578 | return mData->categories; |
1540 | } | 1579 | } |
1541 | 1580 | ||
1542 | void Addressee::insertCustom( const QString &app, const QString &name, | 1581 | void Addressee::insertCustom( const QString &app, const QString &name, |
1543 | const QString &value ) | 1582 | const QString &value ) |
1544 | { | 1583 | { |
1545 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1584 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1546 | 1585 | ||
1547 | detach(); | 1586 | detach(); |
1548 | mData->empty = false; | 1587 | mData->empty = false; |
1549 | 1588 | ||
1550 | QString qualifiedName = app + "-" + name + ":"; | 1589 | QString qualifiedName = app + "-" + name + ":"; |
1551 | 1590 | ||
1552 | QStringList::Iterator it; | 1591 | QStringList::Iterator it; |
1553 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1592 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1554 | if ( (*it).startsWith( qualifiedName ) ) { | 1593 | if ( (*it).startsWith( qualifiedName ) ) { |
1555 | (*it) = qualifiedName + value; | 1594 | (*it) = qualifiedName + value; |
1556 | return; | 1595 | return; |
1557 | } | 1596 | } |
1558 | } | 1597 | } |
1559 | mData->custom.append( qualifiedName + value ); | 1598 | mData->custom.append( qualifiedName + value ); |
1560 | } | 1599 | } |
1561 | 1600 | ||
1562 | void Addressee::removeCustom( const QString &app, const QString &name) | 1601 | void Addressee::removeCustom( const QString &app, const QString &name) |
1563 | { | 1602 | { |
1564 | detach(); | 1603 | detach(); |
1565 | 1604 | ||
1566 | QString qualifiedName = app + "-" + name + ":"; | 1605 | QString qualifiedName = app + "-" + name + ":"; |
1567 | 1606 | ||
1568 | QStringList::Iterator it; | 1607 | QStringList::Iterator it; |
1569 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1608 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1570 | if ( (*it).startsWith( qualifiedName ) ) { | 1609 | if ( (*it).startsWith( qualifiedName ) ) { |
1571 | mData->custom.remove( it ); | 1610 | mData->custom.remove( it ); |
1572 | return; | 1611 | return; |
1573 | } | 1612 | } |
1574 | } | 1613 | } |
1575 | } | 1614 | } |
1576 | 1615 | ||
1577 | QString Addressee::custom( const QString &app, const QString &name ) const | 1616 | QString Addressee::custom( const QString &app, const QString &name ) const |
1578 | { | 1617 | { |
1579 | QString qualifiedName = app + "-" + name + ":"; | 1618 | QString qualifiedName = app + "-" + name + ":"; |
1580 | QString value; | 1619 | QString value; |
1581 | 1620 | ||
1582 | QStringList::ConstIterator it; | 1621 | QStringList::ConstIterator it; |
1583 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1622 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1584 | if ( (*it).startsWith( qualifiedName ) ) { | 1623 | if ( (*it).startsWith( qualifiedName ) ) { |
1585 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1624 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1586 | break; | 1625 | break; |
1587 | } | 1626 | } |
1588 | } | 1627 | } |
1589 | 1628 | ||
1590 | return value; | 1629 | return value; |
1591 | } | 1630 | } |
1592 | 1631 | ||
1593 | void Addressee::setCustoms( const QStringList &l ) | 1632 | void Addressee::setCustoms( const QStringList &l ) |
1594 | { | 1633 | { |
1595 | detach(); | 1634 | detach(); |
1596 | mData->empty = false; | 1635 | mData->empty = false; |
1597 | 1636 | ||
1598 | mData->custom = l; | 1637 | mData->custom = l; |
1599 | } | 1638 | } |
1600 | 1639 | ||
1601 | QStringList Addressee::customs() const | 1640 | QStringList Addressee::customs() const |
1602 | { | 1641 | { |
1603 | return mData->custom; | 1642 | return mData->custom; |
1604 | } | 1643 | } |
1605 | 1644 | ||
1606 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1645 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1607 | QString &email) | 1646 | QString &email) |
1608 | { | 1647 | { |
1609 | int startPos, endPos, len; | 1648 | int startPos, endPos, len; |
1610 | QString partA, partB, result; | 1649 | QString partA, partB, result; |
1611 | char endCh = '>'; | 1650 | char endCh = '>'; |
1612 | 1651 | ||
1613 | startPos = rawEmail.find('<'); | 1652 | startPos = rawEmail.find('<'); |
1614 | if (startPos < 0) | 1653 | if (startPos < 0) |
1615 | { | 1654 | { |
1616 | startPos = rawEmail.find('('); | 1655 | startPos = rawEmail.find('('); |
1617 | endCh = ')'; | 1656 | endCh = ')'; |
1618 | } | 1657 | } |
1619 | if (startPos < 0) | 1658 | if (startPos < 0) |
1620 | { | 1659 | { |
1621 | // We couldn't find any separators, so we assume the whole string | 1660 | // We couldn't find any separators, so we assume the whole string |
1622 | // is the email address | 1661 | // is the email address |
1623 | email = rawEmail; | 1662 | email = rawEmail; |
1624 | fullName = ""; | 1663 | fullName = ""; |
1625 | } | 1664 | } |
1626 | else | 1665 | else |
1627 | { | 1666 | { |
1628 | // We have a start position, try to find an end | 1667 | // We have a start position, try to find an end |
1629 | endPos = rawEmail.find(endCh, startPos+1); | 1668 | endPos = rawEmail.find(endCh, startPos+1); |
1630 | 1669 | ||
1631 | if (endPos < 0) | 1670 | if (endPos < 0) |
1632 | { | 1671 | { |
1633 | // We couldn't find the end of the email address. We can only | 1672 | // We couldn't find the end of the email address. We can only |
1634 | // assume the entire string is the email address. | 1673 | // assume the entire string is the email address. |
1635 | email = rawEmail; | 1674 | email = rawEmail; |
1636 | fullName = ""; | 1675 | fullName = ""; |
1637 | } | 1676 | } |
1638 | else | 1677 | else |
1639 | { | 1678 | { |
1640 | // We have a start and end to the email address | 1679 | // We have a start and end to the email address |
1641 | 1680 | ||
1642 | // Grab the name part | 1681 | // Grab the name part |
1643 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1682 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1644 | 1683 | ||
1645 | // grab the email part | 1684 | // grab the email part |
1646 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1685 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1647 | 1686 | ||
1648 | // Check that we do not have any extra characters on the end of the | 1687 | // Check that we do not have any extra characters on the end of the |
1649 | // strings | 1688 | // strings |
1650 | len = fullName.length(); | 1689 | len = fullName.length(); |
1651 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1690 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1652 | fullName = fullName.mid(1, len-2); | 1691 | fullName = fullName.mid(1, len-2); |
1653 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1692 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1654 | fullName = fullName.mid(1, len-2); | 1693 | fullName = fullName.mid(1, len-2); |
1655 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1694 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1656 | fullName = fullName.mid(1, len-2); | 1695 | fullName = fullName.mid(1, len-2); |
1657 | } | 1696 | } |
1658 | } | 1697 | } |
1659 | } | 1698 | } |
1660 | 1699 | ||
1661 | void Addressee::setResource( Resource *resource ) | 1700 | void Addressee::setResource( Resource *resource ) |
1662 | { | 1701 | { |
1663 | detach(); | 1702 | detach(); |
1664 | mData->resource = resource; | 1703 | mData->resource = resource; |
1665 | } | 1704 | } |
1666 | 1705 | ||
1667 | Resource *Addressee::resource() const | 1706 | Resource *Addressee::resource() const |
1668 | { | 1707 | { |
1669 | return mData->resource; | 1708 | return mData->resource; |
1670 | } | 1709 | } |
1671 | 1710 | ||
1672 | //US | 1711 | //US |
1673 | QString Addressee::resourceLabel() | 1712 | QString Addressee::resourceLabel() |
1674 | { | 1713 | { |
1675 | return i18n("Resource"); | 1714 | return i18n("Resource"); |
1676 | } | 1715 | } |
1677 | 1716 | ||
1678 | void Addressee::setChanged( bool value ) | 1717 | void Addressee::setChanged( bool value ) |
1679 | { | 1718 | { |
1680 | detach(); | 1719 | detach(); |
1681 | mData->changed = value; | 1720 | mData->changed = value; |
1682 | } | 1721 | } |
1683 | 1722 | ||
1684 | bool Addressee::changed() const | 1723 | bool Addressee::changed() const |
1685 | { | 1724 | { |
1686 | return mData->changed; | 1725 | return mData->changed; |
1687 | } | 1726 | } |
1688 | 1727 | ||
1689 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1728 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1690 | { | 1729 | { |
1691 | if (!a.mData) return s; | 1730 | if (!a.mData) return s; |
1692 | 1731 | ||
1693 | s << a.uid(); | 1732 | s << a.uid(); |
1694 | 1733 | ||
1695 | s << a.mData->name; | 1734 | s << a.mData->name; |
1696 | s << a.mData->formattedName; | 1735 | s << a.mData->formattedName; |
1697 | s << a.mData->familyName; | 1736 | s << a.mData->familyName; |
1698 | s << a.mData->givenName; | 1737 | s << a.mData->givenName; |
1699 | s << a.mData->additionalName; | 1738 | s << a.mData->additionalName; |
1700 | s << a.mData->prefix; | 1739 | s << a.mData->prefix; |
1701 | s << a.mData->suffix; | 1740 | s << a.mData->suffix; |
1702 | s << a.mData->nickName; | 1741 | s << a.mData->nickName; |
1703 | s << a.mData->birthday; | 1742 | s << a.mData->birthday; |
1704 | s << a.mData->mailer; | 1743 | s << a.mData->mailer; |
1705 | s << a.mData->timeZone; | 1744 | s << a.mData->timeZone; |
1706 | s << a.mData->geo; | 1745 | s << a.mData->geo; |
1707 | s << a.mData->title; | 1746 | s << a.mData->title; |
1708 | s << a.mData->role; | 1747 | s << a.mData->role; |
1709 | s << a.mData->organization; | 1748 | s << a.mData->organization; |
1710 | s << a.mData->note; | 1749 | s << a.mData->note; |
1711 | s << a.mData->productId; | 1750 | s << a.mData->productId; |
1712 | s << a.mData->revision; | 1751 | s << a.mData->revision; |
1713 | s << a.mData->sortString; | 1752 | s << a.mData->sortString; |
1714 | s << a.mData->url; | 1753 | s << a.mData->url; |
1715 | s << a.mData->secrecy; | 1754 | s << a.mData->secrecy; |
1716 | s << a.mData->logo; | 1755 | s << a.mData->logo; |
1717 | s << a.mData->photo; | 1756 | s << a.mData->photo; |
1718 | s << a.mData->sound; | 1757 | s << a.mData->sound; |
1719 | s << a.mData->agent; | 1758 | s << a.mData->agent; |
1720 | s << a.mData->phoneNumbers; | 1759 | s << a.mData->phoneNumbers; |
1721 | s << a.mData->addresses; | 1760 | s << a.mData->addresses; |
1722 | s << a.mData->emails; | 1761 | s << a.mData->emails; |
1723 | s << a.mData->categories; | 1762 | s << a.mData->categories; |
1724 | s << a.mData->custom; | 1763 | s << a.mData->custom; |
1725 | s << a.mData->keys; | 1764 | s << a.mData->keys; |
1726 | return s; | 1765 | return s; |
1727 | } | 1766 | } |
1728 | 1767 | ||
1729 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1768 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1730 | { | 1769 | { |
1731 | if (!a.mData) return s; | 1770 | if (!a.mData) return s; |
1732 | 1771 | ||
1733 | s >> a.mData->uid; | 1772 | s >> a.mData->uid; |
1734 | 1773 | ||
1735 | s >> a.mData->name; | 1774 | s >> a.mData->name; |
1736 | s >> a.mData->formattedName; | 1775 | s >> a.mData->formattedName; |
1737 | s >> a.mData->familyName; | 1776 | s >> a.mData->familyName; |
1738 | s >> a.mData->givenName; | 1777 | s >> a.mData->givenName; |
1739 | s >> a.mData->additionalName; | 1778 | s >> a.mData->additionalName; |
1740 | s >> a.mData->prefix; | 1779 | s >> a.mData->prefix; |
1741 | s >> a.mData->suffix; | 1780 | s >> a.mData->suffix; |
1742 | s >> a.mData->nickName; | 1781 | s >> a.mData->nickName; |
1743 | s >> a.mData->birthday; | 1782 | s >> a.mData->birthday; |
1744 | s >> a.mData->mailer; | 1783 | s >> a.mData->mailer; |
1745 | s >> a.mData->timeZone; | 1784 | s >> a.mData->timeZone; |
1746 | s >> a.mData->geo; | 1785 | s >> a.mData->geo; |
1747 | s >> a.mData->title; | 1786 | s >> a.mData->title; |
1748 | s >> a.mData->role; | 1787 | s >> a.mData->role; |
1749 | s >> a.mData->organization; | 1788 | s >> a.mData->organization; |
1750 | s >> a.mData->note; | 1789 | s >> a.mData->note; |
1751 | s >> a.mData->productId; | 1790 | s >> a.mData->productId; |
1752 | s >> a.mData->revision; | 1791 | s >> a.mData->revision; |
1753 | s >> a.mData->sortString; | 1792 | s >> a.mData->sortString; |
1754 | s >> a.mData->url; | 1793 | s >> a.mData->url; |
1755 | s >> a.mData->secrecy; | 1794 | s >> a.mData->secrecy; |
1756 | s >> a.mData->logo; | 1795 | s >> a.mData->logo; |
1757 | s >> a.mData->photo; | 1796 | s >> a.mData->photo; |
1758 | s >> a.mData->sound; | 1797 | s >> a.mData->sound; |
1759 | s >> a.mData->agent; | 1798 | s >> a.mData->agent; |
1760 | s >> a.mData->phoneNumbers; | 1799 | s >> a.mData->phoneNumbers; |
1761 | s >> a.mData->addresses; | 1800 | s >> a.mData->addresses; |
1762 | s >> a.mData->emails; | 1801 | s >> a.mData->emails; |
1763 | s >> a.mData->categories; | 1802 | s >> a.mData->categories; |
1764 | s >> a.mData->custom; | 1803 | s >> a.mData->custom; |
1765 | s >> a.mData->keys; | 1804 | s >> a.mData->keys; |
1766 | 1805 | ||
1767 | a.mData->empty = false; | 1806 | a.mData->empty = false; |
1768 | 1807 | ||
1769 | return s; | 1808 | return s; |
1770 | } | 1809 | } |
1771 | 1810 | ||
1772 | bool matchBinaryPattern( int value, int pattern ) | 1811 | bool matchBinaryPattern( int value, int pattern ) |
1773 | { | 1812 | { |
1774 | /** | 1813 | /** |
1775 | We want to match all telephonnumbers/addresses which have the bits in the | 1814 | We want to match all telephonnumbers/addresses which have the bits in the |
1776 | pattern set. More are allowed. | 1815 | pattern set. More are allowed. |
1777 | if pattern == 0 we have a special handling, then we want only those with | 1816 | if pattern == 0 we have a special handling, then we want only those with |
1778 | exactly no bit set. | 1817 | exactly no bit set. |
1779 | */ | 1818 | */ |
1780 | if ( pattern == 0 ) | 1819 | if ( pattern == 0 ) |
1781 | return ( value == 0 ); | 1820 | return ( value == 0 ); |
1782 | else | 1821 | else |
1783 | return ( pattern == ( pattern & value ) ); | 1822 | return ( pattern == ( pattern & value ) ); |
1784 | } | 1823 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index bfb0840..59fcbd8 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,839 +1,841 @@ | |||
1 | /*** Warning! This file has been generated by the script makeaddressee ***/ | 1 | /*** Warning! This file has been generated by the script makeaddressee ***/ |
2 | /* | 2 | /* |
3 | This file is part of libkabc. | 3 | This file is part of libkabc. |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | /* | 22 | /* |
23 | Enhanced Version of the file for platform independent KDE tools. | 23 | Enhanced Version of the file for platform independent KDE tools. |
24 | Copyright (c) 2004 Ulf Schenk | 24 | Copyright (c) 2004 Ulf Schenk |
25 | 25 | ||
26 | $Id$ | 26 | $Id$ |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef KABC_ADDRESSEE_H | 29 | #ifndef KABC_ADDRESSEE_H |
30 | #define KABC_ADDRESSEE_H | 30 | #define KABC_ADDRESSEE_H |
31 | 31 | ||
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | #include <qstringlist.h> | 34 | #include <qstringlist.h> |
35 | #include <qvaluelist.h> | 35 | #include <qvaluelist.h> |
36 | 36 | ||
37 | #include <ksharedptr.h> | 37 | #include <ksharedptr.h> |
38 | #include <kurl.h> | 38 | #include <kurl.h> |
39 | 39 | ||
40 | #include "address.h" | 40 | #include "address.h" |
41 | #include "agent.h" | 41 | #include "agent.h" |
42 | #include "geo.h" | 42 | #include "geo.h" |
43 | #include "key.h" | 43 | #include "key.h" |
44 | #include "phonenumber.h" | 44 | #include "phonenumber.h" |
45 | #include "picture.h" | 45 | #include "picture.h" |
46 | #include "secrecy.h" | 46 | #include "secrecy.h" |
47 | #include "sound.h" | 47 | #include "sound.h" |
48 | #include "timezone.h" | 48 | #include "timezone.h" |
49 | 49 | ||
50 | namespace KABC { | 50 | namespace KABC { |
51 | 51 | ||
52 | class Resource; | 52 | class Resource; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | @short address book entry | 55 | @short address book entry |
56 | 56 | ||
57 | This class represents an entry in the address book. | 57 | This class represents an entry in the address book. |
58 | 58 | ||
59 | The data of this class is implicitly shared. You can pass this class by value. | 59 | The data of this class is implicitly shared. You can pass this class by value. |
60 | 60 | ||
61 | If you need the name of a field for presenting it to the user you should use | 61 | If you need the name of a field for presenting it to the user you should use |
62 | the functions ending in Label(). They return a translated string which can be | 62 | the functions ending in Label(). They return a translated string which can be |
63 | used as label for the corresponding field. | 63 | used as label for the corresponding field. |
64 | 64 | ||
65 | About the name fields: | 65 | About the name fields: |
66 | 66 | ||
67 | givenName() is the first name and familyName() the last name. In some | 67 | givenName() is the first name and familyName() the last name. In some |
68 | countries the family name comes first, that's the reason for the | 68 | countries the family name comes first, that's the reason for the |
69 | naming. formattedName() is the full name with the correct formatting. | 69 | naming. formattedName() is the full name with the correct formatting. |
70 | It is used as an override, when the correct formatting can't be generated | 70 | It is used as an override, when the correct formatting can't be generated |
71 | from the other name fields automatically. | 71 | from the other name fields automatically. |
72 | 72 | ||
73 | realName() returns a fully formatted name(). It uses formattedName, if set, | 73 | realName() returns a fully formatted name(). It uses formattedName, if set, |
74 | otherwise it constucts the name from the name fields. As fallback, if | 74 | otherwise it constucts the name from the name fields. As fallback, if |
75 | nothing else is set it uses name(). | 75 | nothing else is set it uses name(). |
76 | 76 | ||
77 | name() is the NAME type of RFC2426. It can be used as internal name for the | 77 | name() is the NAME type of RFC2426. It can be used as internal name for the |
78 | data enty, but shouldn't be used for displaying the data to the user. | 78 | data enty, but shouldn't be used for displaying the data to the user. |
79 | */ | 79 | */ |
80 | class Addressee | 80 | class Addressee |
81 | { | 81 | { |
82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); | 82 | friend QDataStream &operator<<( QDataStream &, const Addressee & ); |
83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); | 83 | friend QDataStream &operator>>( QDataStream &, Addressee & ); |
84 | 84 | ||
85 | public: | 85 | public: |
86 | typedef QValueList<Addressee> List; | 86 | typedef QValueList<Addressee> List; |
87 | 87 | ||
88 | /** | 88 | /** |
89 | Construct an empty address book entry. | 89 | Construct an empty address book entry. |
90 | */ | 90 | */ |
91 | Addressee(); | 91 | Addressee(); |
92 | ~Addressee(); | 92 | ~Addressee(); |
93 | 93 | ||
94 | Addressee( const Addressee & ); | 94 | Addressee( const Addressee & ); |
95 | Addressee &operator=( const Addressee & ); | 95 | Addressee &operator=( const Addressee & ); |
96 | 96 | ||
97 | bool operator==( const Addressee & ) const; | 97 | bool operator==( const Addressee & ) const; |
98 | bool operator!=( const Addressee & ) const; | 98 | bool operator!=( const Addressee & ) const; |
99 | // sync stuff | 99 | // sync stuff |
100 | void setTempSyncStat(int id); | 100 | void setTempSyncStat(int id); |
101 | int tempSyncStat() const; | 101 | int tempSyncStat() const; |
102 | void setIDStr( const QString & ); | 102 | void setIDStr( const QString & ); |
103 | QString IDStr() const; | 103 | QString IDStr() const; |
104 | void setID( const QString &, const QString & ); | 104 | void setID( const QString &, const QString & ); |
105 | QString getID( const QString & ); | 105 | QString getID( const QString & ); |
106 | void setCsum( const QString &, const QString & ); | 106 | void setCsum( const QString &, const QString & ); |
107 | QString getCsum( const QString & ); | 107 | QString getCsum( const QString & ); |
108 | void removeID(const QString &); | 108 | void removeID(const QString &); |
109 | void computeCsum(const QString &dev); | 109 | void computeCsum(const QString &dev); |
110 | ulong getCsum4List( const QStringList & attList); | 110 | ulong getCsum4List( const QStringList & attList); |
111 | /** | 111 | /** |
112 | Return, if the address book entry is empty. | 112 | Return, if the address book entry is empty. |
113 | */ | 113 | */ |
114 | bool isEmpty() const; | 114 | bool isEmpty() const; |
115 | 115 | void setExternalUID( const QString &id ); | |
116 | QString externalUID() const; | ||
117 | void mergeContact( Addressee ad ); | ||
116 | /** | 118 | /** |
117 | Set unique identifier. | 119 | Set unique identifier. |
118 | */ | 120 | */ |
119 | void setUid( const QString &uid ); | 121 | void setUid( const QString &uid ); |
120 | /** | 122 | /** |
121 | Return unique identifier. | 123 | Return unique identifier. |
122 | */ | 124 | */ |
123 | QString uid() const; | 125 | QString uid() const; |
124 | /** | 126 | /** |
125 | Return translated label for uid field. | 127 | Return translated label for uid field. |
126 | */ | 128 | */ |
127 | static QString uidLabel(); | 129 | static QString uidLabel(); |
128 | 130 | ||
129 | /** | 131 | /** |
130 | Set name. | 132 | Set name. |
131 | */ | 133 | */ |
132 | void setName( const QString &name ); | 134 | void setName( const QString &name ); |
133 | /** | 135 | /** |
134 | Return name. | 136 | Return name. |
135 | */ | 137 | */ |
136 | QString name() const; | 138 | QString name() const; |
137 | /** | 139 | /** |
138 | Return translated label for name field. | 140 | Return translated label for name field. |
139 | */ | 141 | */ |
140 | static QString nameLabel(); | 142 | static QString nameLabel(); |
141 | 143 | ||
142 | /** | 144 | /** |
143 | Set formatted name. | 145 | Set formatted name. |
144 | */ | 146 | */ |
145 | void setFormattedName( const QString &formattedName ); | 147 | void setFormattedName( const QString &formattedName ); |
146 | /** | 148 | /** |
147 | Return formatted name. | 149 | Return formatted name. |
148 | */ | 150 | */ |
149 | QString formattedName() const; | 151 | QString formattedName() const; |
150 | /** | 152 | /** |
151 | Return translated label for formattedName field. | 153 | Return translated label for formattedName field. |
152 | */ | 154 | */ |
153 | static QString formattedNameLabel(); | 155 | static QString formattedNameLabel(); |
154 | 156 | ||
155 | /** | 157 | /** |
156 | Set family name. | 158 | Set family name. |
157 | */ | 159 | */ |
158 | void setFamilyName( const QString &familyName ); | 160 | void setFamilyName( const QString &familyName ); |
159 | /** | 161 | /** |
160 | Return family name. | 162 | Return family name. |
161 | */ | 163 | */ |
162 | QString familyName() const; | 164 | QString familyName() const; |
163 | /** | 165 | /** |
164 | Return translated label for familyName field. | 166 | Return translated label for familyName field. |
165 | */ | 167 | */ |
166 | static QString familyNameLabel(); | 168 | static QString familyNameLabel(); |
167 | 169 | ||
168 | /** | 170 | /** |
169 | Set given name. | 171 | Set given name. |
170 | */ | 172 | */ |
171 | void setGivenName( const QString &givenName ); | 173 | void setGivenName( const QString &givenName ); |
172 | /** | 174 | /** |
173 | Return given name. | 175 | Return given name. |
174 | */ | 176 | */ |
175 | QString givenName() const; | 177 | QString givenName() const; |
176 | /** | 178 | /** |
177 | Return translated label for givenName field. | 179 | Return translated label for givenName field. |
178 | */ | 180 | */ |
179 | static QString givenNameLabel(); | 181 | static QString givenNameLabel(); |
180 | 182 | ||
181 | /** | 183 | /** |
182 | Set additional names. | 184 | Set additional names. |
183 | */ | 185 | */ |
184 | void setAdditionalName( const QString &additionalName ); | 186 | void setAdditionalName( const QString &additionalName ); |
185 | /** | 187 | /** |
186 | Return additional names. | 188 | Return additional names. |
187 | */ | 189 | */ |
188 | QString additionalName() const; | 190 | QString additionalName() const; |
189 | /** | 191 | /** |
190 | Return translated label for additionalName field. | 192 | Return translated label for additionalName field. |
191 | */ | 193 | */ |
192 | static QString additionalNameLabel(); | 194 | static QString additionalNameLabel(); |
193 | 195 | ||
194 | /** | 196 | /** |
195 | Set honorific prefixes. | 197 | Set honorific prefixes. |
196 | */ | 198 | */ |
197 | void setPrefix( const QString &prefix ); | 199 | void setPrefix( const QString &prefix ); |
198 | /** | 200 | /** |
199 | Return honorific prefixes. | 201 | Return honorific prefixes. |
200 | */ | 202 | */ |
201 | QString prefix() const; | 203 | QString prefix() const; |
202 | /** | 204 | /** |
203 | Return translated label for prefix field. | 205 | Return translated label for prefix field. |
204 | */ | 206 | */ |
205 | static QString prefixLabel(); | 207 | static QString prefixLabel(); |
206 | 208 | ||
207 | /** | 209 | /** |
208 | Set honorific suffixes. | 210 | Set honorific suffixes. |
209 | */ | 211 | */ |
210 | void setSuffix( const QString &suffix ); | 212 | void setSuffix( const QString &suffix ); |
211 | /** | 213 | /** |
212 | Return honorific suffixes. | 214 | Return honorific suffixes. |
213 | */ | 215 | */ |
214 | QString suffix() const; | 216 | QString suffix() const; |
215 | /** | 217 | /** |
216 | Return translated label for suffix field. | 218 | Return translated label for suffix field. |
217 | */ | 219 | */ |
218 | static QString suffixLabel(); | 220 | static QString suffixLabel(); |
219 | 221 | ||
220 | /** | 222 | /** |
221 | Set nick name. | 223 | Set nick name. |
222 | */ | 224 | */ |
223 | void setNickName( const QString &nickName ); | 225 | void setNickName( const QString &nickName ); |
224 | /** | 226 | /** |
225 | Return nick name. | 227 | Return nick name. |
226 | */ | 228 | */ |
227 | QString nickName() const; | 229 | QString nickName() const; |
228 | /** | 230 | /** |
229 | Return translated label for nickName field. | 231 | Return translated label for nickName field. |
230 | */ | 232 | */ |
231 | static QString nickNameLabel(); | 233 | static QString nickNameLabel(); |
232 | 234 | ||
233 | /** | 235 | /** |
234 | Set birthday. | 236 | Set birthday. |
235 | */ | 237 | */ |
236 | void setBirthday( const QDateTime &birthday ); | 238 | void setBirthday( const QDateTime &birthday ); |
237 | /** | 239 | /** |
238 | Return birthday. | 240 | Return birthday. |
239 | */ | 241 | */ |
240 | QDateTime birthday() const; | 242 | QDateTime birthday() const; |
241 | /** | 243 | /** |
242 | Return translated label for birthday field. | 244 | Return translated label for birthday field. |
243 | */ | 245 | */ |
244 | static QString birthdayLabel(); | 246 | static QString birthdayLabel(); |
245 | 247 | ||
246 | /** | 248 | /** |
247 | Return translated label for homeAddressStreet field. | 249 | Return translated label for homeAddressStreet field. |
248 | */ | 250 | */ |
249 | static QString homeAddressStreetLabel(); | 251 | static QString homeAddressStreetLabel(); |
250 | 252 | ||
251 | /** | 253 | /** |
252 | Return translated label for homeAddressLocality field. | 254 | Return translated label for homeAddressLocality field. |
253 | */ | 255 | */ |
254 | static QString homeAddressLocalityLabel(); | 256 | static QString homeAddressLocalityLabel(); |
255 | 257 | ||
256 | /** | 258 | /** |
257 | Return translated label for homeAddressRegion field. | 259 | Return translated label for homeAddressRegion field. |
258 | */ | 260 | */ |
259 | static QString homeAddressRegionLabel(); | 261 | static QString homeAddressRegionLabel(); |
260 | 262 | ||
261 | /** | 263 | /** |
262 | Return translated label for homeAddressPostalCode field. | 264 | Return translated label for homeAddressPostalCode field. |
263 | */ | 265 | */ |
264 | static QString homeAddressPostalCodeLabel(); | 266 | static QString homeAddressPostalCodeLabel(); |
265 | 267 | ||
266 | /** | 268 | /** |
267 | Return translated label for homeAddressCountry field. | 269 | Return translated label for homeAddressCountry field. |
268 | */ | 270 | */ |
269 | static QString homeAddressCountryLabel(); | 271 | static QString homeAddressCountryLabel(); |
270 | 272 | ||
271 | /** | 273 | /** |
272 | Return translated label for homeAddressLabel field. | 274 | Return translated label for homeAddressLabel field. |
273 | */ | 275 | */ |
274 | static QString homeAddressLabelLabel(); | 276 | static QString homeAddressLabelLabel(); |
275 | 277 | ||
276 | /** | 278 | /** |
277 | Return translated label for businessAddressStreet field. | 279 | Return translated label for businessAddressStreet field. |
278 | */ | 280 | */ |
279 | static QString businessAddressStreetLabel(); | 281 | static QString businessAddressStreetLabel(); |
280 | 282 | ||
281 | /** | 283 | /** |
282 | Return translated label for businessAddressLocality field. | 284 | Return translated label for businessAddressLocality field. |
283 | */ | 285 | */ |
284 | static QString businessAddressLocalityLabel(); | 286 | static QString businessAddressLocalityLabel(); |
285 | 287 | ||
286 | /** | 288 | /** |
287 | Return translated label for businessAddressRegion field. | 289 | Return translated label for businessAddressRegion field. |
288 | */ | 290 | */ |
289 | static QString businessAddressRegionLabel(); | 291 | static QString businessAddressRegionLabel(); |
290 | 292 | ||
291 | /** | 293 | /** |
292 | Return translated label for businessAddressPostalCode field. | 294 | Return translated label for businessAddressPostalCode field. |
293 | */ | 295 | */ |
294 | static QString businessAddressPostalCodeLabel(); | 296 | static QString businessAddressPostalCodeLabel(); |
295 | 297 | ||
296 | /** | 298 | /** |
297 | Return translated label for businessAddressCountry field. | 299 | Return translated label for businessAddressCountry field. |
298 | */ | 300 | */ |
299 | static QString businessAddressCountryLabel(); | 301 | static QString businessAddressCountryLabel(); |
300 | 302 | ||
301 | /** | 303 | /** |
302 | Return translated label for businessAddressLabel field. | 304 | Return translated label for businessAddressLabel field. |
303 | */ | 305 | */ |
304 | static QString businessAddressLabelLabel(); | 306 | static QString businessAddressLabelLabel(); |
305 | 307 | ||
306 | /** | 308 | /** |
307 | Return translated label for homePhone field. | 309 | Return translated label for homePhone field. |
308 | */ | 310 | */ |
309 | static QString homePhoneLabel(); | 311 | static QString homePhoneLabel(); |
310 | 312 | ||
311 | /** | 313 | /** |
312 | Return translated label for businessPhone field. | 314 | Return translated label for businessPhone field. |
313 | */ | 315 | */ |
314 | static QString businessPhoneLabel(); | 316 | static QString businessPhoneLabel(); |
315 | 317 | ||
316 | /** | 318 | /** |
317 | Return translated label for mobilePhone field. | 319 | Return translated label for mobilePhone field. |
318 | */ | 320 | */ |
319 | static QString mobilePhoneLabel(); | 321 | static QString mobilePhoneLabel(); |
320 | 322 | ||
321 | /** | 323 | /** |
322 | Return translated label for homeFax field. | 324 | Return translated label for homeFax field. |
323 | */ | 325 | */ |
324 | static QString homeFaxLabel(); | 326 | static QString homeFaxLabel(); |
325 | 327 | ||
326 | /** | 328 | /** |
327 | Return translated label for businessFax field. | 329 | Return translated label for businessFax field. |
328 | */ | 330 | */ |
329 | static QString businessFaxLabel(); | 331 | static QString businessFaxLabel(); |
330 | 332 | ||
331 | /** | 333 | /** |
332 | Return translated label for carPhone field. | 334 | Return translated label for carPhone field. |
333 | */ | 335 | */ |
334 | static QString carPhoneLabel(); | 336 | static QString carPhoneLabel(); |
335 | 337 | ||
336 | /** | 338 | /** |
337 | Return translated label for isdn field. | 339 | Return translated label for isdn field. |
338 | */ | 340 | */ |
339 | static QString isdnLabel(); | 341 | static QString isdnLabel(); |
340 | 342 | ||
341 | /** | 343 | /** |
342 | Return translated label for pager field. | 344 | Return translated label for pager field. |
343 | */ | 345 | */ |
344 | static QString pagerLabel(); | 346 | static QString pagerLabel(); |
345 | 347 | ||
346 | /** | 348 | /** |
347 | Return translated label for sip field. | 349 | Return translated label for sip field. |
348 | */ | 350 | */ |
349 | static QString sipLabel(); | 351 | static QString sipLabel(); |
350 | 352 | ||
351 | /** | 353 | /** |
352 | Return translated label for email field. | 354 | Return translated label for email field. |
353 | */ | 355 | */ |
354 | static QString emailLabel(); | 356 | static QString emailLabel(); |
355 | 357 | ||
356 | /** | 358 | /** |
357 | Set mail client. | 359 | Set mail client. |
358 | */ | 360 | */ |
359 | void setMailer( const QString &mailer ); | 361 | void setMailer( const QString &mailer ); |
360 | /** | 362 | /** |
361 | Return mail client. | 363 | Return mail client. |
362 | */ | 364 | */ |
363 | QString mailer() const; | 365 | QString mailer() const; |
364 | /** | 366 | /** |
365 | Return translated label for mailer field. | 367 | Return translated label for mailer field. |
366 | */ | 368 | */ |
367 | static QString mailerLabel(); | 369 | static QString mailerLabel(); |
368 | 370 | ||
369 | /** | 371 | /** |
370 | Set time zone. | 372 | Set time zone. |
371 | */ | 373 | */ |
372 | void setTimeZone( const TimeZone &timeZone ); | 374 | void setTimeZone( const TimeZone &timeZone ); |
373 | /** | 375 | /** |
374 | Return time zone. | 376 | Return time zone. |
375 | */ | 377 | */ |
376 | TimeZone timeZone() const; | 378 | TimeZone timeZone() const; |
377 | /** | 379 | /** |
378 | Return translated label for timeZone field. | 380 | Return translated label for timeZone field. |
379 | */ | 381 | */ |
380 | static QString timeZoneLabel(); | 382 | static QString timeZoneLabel(); |
381 | 383 | ||
382 | /** | 384 | /** |
383 | Set geographic position. | 385 | Set geographic position. |
384 | */ | 386 | */ |
385 | void setGeo( const Geo &geo ); | 387 | void setGeo( const Geo &geo ); |
386 | /** | 388 | /** |
387 | Return geographic position. | 389 | Return geographic position. |
388 | */ | 390 | */ |
389 | Geo geo() const; | 391 | Geo geo() const; |
390 | /** | 392 | /** |
391 | Return translated label for geo field. | 393 | Return translated label for geo field. |
392 | */ | 394 | */ |
393 | static QString geoLabel(); | 395 | static QString geoLabel(); |
394 | 396 | ||
395 | /** | 397 | /** |
396 | Set title. | 398 | Set title. |
397 | */ | 399 | */ |
398 | void setTitle( const QString &title ); | 400 | void setTitle( const QString &title ); |
399 | /** | 401 | /** |
400 | Return title. | 402 | Return title. |
401 | */ | 403 | */ |
402 | QString title() const; | 404 | QString title() const; |
403 | /** | 405 | /** |
404 | Return translated label for title field. | 406 | Return translated label for title field. |
405 | */ | 407 | */ |
406 | static QString titleLabel(); | 408 | static QString titleLabel(); |
407 | 409 | ||
408 | /** | 410 | /** |
409 | Set role. | 411 | Set role. |
410 | */ | 412 | */ |
411 | void setRole( const QString &role ); | 413 | void setRole( const QString &role ); |
412 | /** | 414 | /** |
413 | Return role. | 415 | Return role. |
414 | */ | 416 | */ |
415 | QString role() const; | 417 | QString role() const; |
416 | /** | 418 | /** |
417 | Return translated label for role field. | 419 | Return translated label for role field. |
418 | */ | 420 | */ |
419 | static QString roleLabel(); | 421 | static QString roleLabel(); |
420 | 422 | ||
421 | /** | 423 | /** |
422 | Set organization. | 424 | Set organization. |
423 | */ | 425 | */ |
424 | void setOrganization( const QString &organization ); | 426 | void setOrganization( const QString &organization ); |
425 | /** | 427 | /** |
426 | Return organization. | 428 | Return organization. |
427 | */ | 429 | */ |
428 | QString organization() const; | 430 | QString organization() const; |
429 | /** | 431 | /** |
430 | Return translated label for organization field. | 432 | Return translated label for organization field. |
431 | */ | 433 | */ |
432 | static QString organizationLabel(); | 434 | static QString organizationLabel(); |
433 | 435 | ||
434 | /** | 436 | /** |
435 | Set note. | 437 | Set note. |
436 | */ | 438 | */ |
437 | void setNote( const QString ¬e ); | 439 | void setNote( const QString ¬e ); |
438 | /** | 440 | /** |
439 | Return note. | 441 | Return note. |
440 | */ | 442 | */ |
441 | QString note() const; | 443 | QString note() const; |
442 | /** | 444 | /** |
443 | Return translated label for note field. | 445 | Return translated label for note field. |
444 | */ | 446 | */ |
445 | static QString noteLabel(); | 447 | static QString noteLabel(); |
446 | 448 | ||
447 | /** | 449 | /** |
448 | Set product identifier. | 450 | Set product identifier. |
449 | */ | 451 | */ |
450 | void setProductId( const QString &productId ); | 452 | void setProductId( const QString &productId ); |
451 | /** | 453 | /** |
452 | Return product identifier. | 454 | Return product identifier. |
453 | */ | 455 | */ |
454 | QString productId() const; | 456 | QString productId() const; |
455 | /** | 457 | /** |
456 | Return translated label for productId field. | 458 | Return translated label for productId field. |
457 | */ | 459 | */ |
458 | static QString productIdLabel(); | 460 | static QString productIdLabel(); |
459 | 461 | ||
460 | /** | 462 | /** |
461 | Set revision date. | 463 | Set revision date. |
462 | */ | 464 | */ |
463 | void setRevision( const QDateTime &revision ); | 465 | void setRevision( const QDateTime &revision ); |
464 | /** | 466 | /** |
465 | Return revision date. | 467 | Return revision date. |
466 | */ | 468 | */ |
467 | QDateTime revision() const; | 469 | QDateTime revision() const; |
468 | /** | 470 | /** |
469 | Return translated label for revision field. | 471 | Return translated label for revision field. |
470 | */ | 472 | */ |
471 | static QString revisionLabel(); | 473 | static QString revisionLabel(); |
472 | 474 | ||
473 | /** | 475 | /** |
474 | Set sort string. | 476 | Set sort string. |
475 | */ | 477 | */ |
476 | void setSortString( const QString &sortString ); | 478 | void setSortString( const QString &sortString ); |
477 | /** | 479 | /** |
478 | Return sort string. | 480 | Return sort string. |
479 | */ | 481 | */ |
480 | QString sortString() const; | 482 | QString sortString() const; |
481 | /** | 483 | /** |
482 | Return translated label for sortString field. | 484 | Return translated label for sortString field. |
483 | */ | 485 | */ |
484 | static QString sortStringLabel(); | 486 | static QString sortStringLabel(); |
485 | 487 | ||
486 | /** | 488 | /** |
487 | Set URL. | 489 | Set URL. |
488 | */ | 490 | */ |
489 | void setUrl( const KURL &url ); | 491 | void setUrl( const KURL &url ); |
490 | /** | 492 | /** |
491 | Return URL. | 493 | Return URL. |
492 | */ | 494 | */ |
493 | KURL url() const; | 495 | KURL url() const; |
494 | /** | 496 | /** |
495 | Return translated label for url field. | 497 | Return translated label for url field. |
496 | */ | 498 | */ |
497 | static QString urlLabel(); | 499 | static QString urlLabel(); |
498 | 500 | ||
499 | /** | 501 | /** |
500 | Set security class. | 502 | Set security class. |
501 | */ | 503 | */ |
502 | void setSecrecy( const Secrecy &secrecy ); | 504 | void setSecrecy( const Secrecy &secrecy ); |
503 | /** | 505 | /** |
504 | Return security class. | 506 | Return security class. |
505 | */ | 507 | */ |
506 | Secrecy secrecy() const; | 508 | Secrecy secrecy() const; |
507 | /** | 509 | /** |
508 | Return translated label for secrecy field. | 510 | Return translated label for secrecy field. |
509 | */ | 511 | */ |
510 | static QString secrecyLabel(); | 512 | static QString secrecyLabel(); |
511 | 513 | ||
512 | /** | 514 | /** |
513 | Set logo. | 515 | Set logo. |
514 | */ | 516 | */ |
515 | void setLogo( const Picture &logo ); | 517 | void setLogo( const Picture &logo ); |
516 | /** | 518 | /** |
517 | Return logo. | 519 | Return logo. |
518 | */ | 520 | */ |
519 | Picture logo() const; | 521 | Picture logo() const; |
520 | /** | 522 | /** |
521 | Return translated label for logo field. | 523 | Return translated label for logo field. |
522 | */ | 524 | */ |
523 | static QString logoLabel(); | 525 | static QString logoLabel(); |
524 | 526 | ||
525 | /** | 527 | /** |
526 | Set photo. | 528 | Set photo. |
527 | */ | 529 | */ |
528 | void setPhoto( const Picture &photo ); | 530 | void setPhoto( const Picture &photo ); |
529 | /** | 531 | /** |
530 | Return photo. | 532 | Return photo. |
531 | */ | 533 | */ |
532 | Picture photo() const; | 534 | Picture photo() const; |
533 | /** | 535 | /** |
534 | Return translated label for photo field. | 536 | Return translated label for photo field. |
535 | */ | 537 | */ |
536 | static QString photoLabel(); | 538 | static QString photoLabel(); |
537 | 539 | ||
538 | /** | 540 | /** |
539 | Set sound. | 541 | Set sound. |
540 | */ | 542 | */ |
541 | void setSound( const Sound &sound ); | 543 | void setSound( const Sound &sound ); |
542 | /** | 544 | /** |
543 | Return sound. | 545 | Return sound. |
544 | */ | 546 | */ |
545 | Sound sound() const; | 547 | Sound sound() const; |
546 | /** | 548 | /** |
547 | Return translated label for sound field. | 549 | Return translated label for sound field. |
548 | */ | 550 | */ |
549 | static QString soundLabel(); | 551 | static QString soundLabel(); |
550 | 552 | ||
551 | /** | 553 | /** |
552 | Set agent. | 554 | Set agent. |
553 | */ | 555 | */ |
554 | void setAgent( const Agent &agent ); | 556 | void setAgent( const Agent &agent ); |
555 | /** | 557 | /** |
556 | Return agent. | 558 | Return agent. |
557 | */ | 559 | */ |
558 | Agent agent() const; | 560 | Agent agent() const; |
559 | /** | 561 | /** |
560 | Return translated label for agent field. | 562 | Return translated label for agent field. |
561 | */ | 563 | */ |
562 | static QString agentLabel(); | 564 | static QString agentLabel(); |
563 | 565 | ||
564 | /** | 566 | /** |
565 | Set name fields by parsing the given string and trying to associate the | 567 | Set name fields by parsing the given string and trying to associate the |
566 | parts of the string with according fields. This function should probably | 568 | parts of the string with according fields. This function should probably |
567 | be a bit more clever. | 569 | be a bit more clever. |
568 | */ | 570 | */ |
569 | void setNameFromString( const QString & ); | 571 | void setNameFromString( const QString & ); |
570 | 572 | ||
571 | /** | 573 | /** |
572 | Return the name of the addressee. This is calculated from all the name | 574 | Return the name of the addressee. This is calculated from all the name |
573 | fields. | 575 | fields. |
574 | */ | 576 | */ |
575 | QString realName() const; | 577 | QString realName() const; |
576 | 578 | ||
577 | /** | 579 | /** |
578 | Return the name that consists of all name parts. | 580 | Return the name that consists of all name parts. |
579 | */ | 581 | */ |
580 | QString assembledName() const; | 582 | QString assembledName() const; |
581 | 583 | ||
582 | /** | 584 | /** |
583 | Return email address including real name. | 585 | Return email address including real name. |
584 | 586 | ||
585 | @param email Email address to be used to construct the full email string. | 587 | @param email Email address to be used to construct the full email string. |
586 | If this is QString::null the preferred email address is used. | 588 | If this is QString::null the preferred email address is used. |
587 | */ | 589 | */ |
588 | QString fullEmail( const QString &email=QString::null ) const; | 590 | QString fullEmail( const QString &email=QString::null ) const; |
589 | 591 | ||
590 | /** | 592 | /** |
591 | Insert an email address. If the email address already exists in this | 593 | Insert an email address. If the email address already exists in this |
592 | addressee it is not duplicated. | 594 | addressee it is not duplicated. |
593 | 595 | ||
594 | @param email Email address | 596 | @param email Email address |
595 | @param preferred Set to true, if this is the preferred email address of | 597 | @param preferred Set to true, if this is the preferred email address of |
596 | the addressee. | 598 | the addressee. |
597 | */ | 599 | */ |
598 | void insertEmail( const QString &email, bool preferred=false ); | 600 | void insertEmail( const QString &email, bool preferred=false ); |
599 | 601 | ||
600 | /** | 602 | /** |
601 | Remove email address. If the email address doesn't exist, nothing happens. | 603 | Remove email address. If the email address doesn't exist, nothing happens. |
602 | */ | 604 | */ |
603 | void removeEmail( const QString &email ); | 605 | void removeEmail( const QString &email ); |
604 | 606 | ||
605 | /** | 607 | /** |
606 | Return preferred email address. This is the first email address or the | 608 | Return preferred email address. This is the first email address or the |
607 | last one added with @ref insertEmail() with a set preferred parameter. | 609 | last one added with @ref insertEmail() with a set preferred parameter. |
608 | */ | 610 | */ |
609 | QString preferredEmail() const; | 611 | QString preferredEmail() const; |
610 | 612 | ||
611 | /** | 613 | /** |
612 | Return list of all email addresses. | 614 | Return list of all email addresses. |
613 | */ | 615 | */ |
614 | QStringList emails() const; | 616 | QStringList emails() const; |
615 | 617 | ||
616 | /** | 618 | /** |
617 | Set the emails to @param. | 619 | Set the emails to @param. |
618 | The first email address gets the preferred one! | 620 | The first email address gets the preferred one! |
619 | @param list The list of email addresses. | 621 | @param list The list of email addresses. |
620 | */ | 622 | */ |
621 | void setEmails( const QStringList& list); | 623 | void setEmails( const QStringList& list); |
622 | 624 | ||
623 | /** | 625 | /** |
624 | Insert a phone number. If a phone number with the same id already exists | 626 | Insert a phone number. If a phone number with the same id already exists |
625 | in this addressee it is not duplicated. | 627 | in this addressee it is not duplicated. |
626 | */ | 628 | */ |
627 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 629 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
628 | 630 | ||
629 | /** | 631 | /** |
630 | Remove phone number. If no phone number with the given id exists for this | 632 | Remove phone number. If no phone number with the given id exists for this |
631 | addresse nothing happens. | 633 | addresse nothing happens. |
632 | */ | 634 | */ |
633 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 635 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
634 | 636 | ||
635 | /** | 637 | /** |
636 | Return phone number, which matches the given type. | 638 | Return phone number, which matches the given type. |
637 | */ | 639 | */ |
638 | PhoneNumber phoneNumber( int type ) const; | 640 | PhoneNumber phoneNumber( int type ) const; |
639 | 641 | ||
640 | /** | 642 | /** |
641 | Return list of all phone numbers. | 643 | Return list of all phone numbers. |
642 | */ | 644 | */ |
643 | PhoneNumber::List phoneNumbers() const; | 645 | PhoneNumber::List phoneNumbers() const; |
644 | 646 | ||
645 | /** | 647 | /** |
646 | Return list of phone numbers with a special type. | 648 | Return list of phone numbers with a special type. |
647 | */ | 649 | */ |
648 | PhoneNumber::List phoneNumbers( int type ) const; | 650 | PhoneNumber::List phoneNumbers( int type ) const; |
649 | 651 | ||
650 | /** | 652 | /** |
651 | Return phone number with the given id. | 653 | Return phone number with the given id. |
652 | */ | 654 | */ |
653 | PhoneNumber findPhoneNumber( const QString &id ) const; | 655 | PhoneNumber findPhoneNumber( const QString &id ) const; |
654 | 656 | ||
655 | /** | 657 | /** |
656 | Insert a key. If a key with the same id already exists | 658 | Insert a key. If a key with the same id already exists |
657 | in this addressee it is not duplicated. | 659 | in this addressee it is not duplicated. |
658 | */ | 660 | */ |
659 | void insertKey( const Key &key ); | 661 | void insertKey( const Key &key ); |
660 | 662 | ||
661 | /** | 663 | /** |
662 | Remove a key. If no key with the given id exists for this | 664 | Remove a key. If no key with the given id exists for this |
663 | addresse nothing happens. | 665 | addresse nothing happens. |
664 | */ | 666 | */ |
665 | void removeKey( const Key &key ); | 667 | void removeKey( const Key &key ); |
666 | 668 | ||
667 | /** | 669 | /** |
668 | Return key, which matches the given type. | 670 | Return key, which matches the given type. |
669 | If @p type == Key::Custom you can specify a string | 671 | If @p type == Key::Custom you can specify a string |
670 | that should match. If you leave the string empty, the first | 672 | that should match. If you leave the string empty, the first |
671 | key with a custom value is returned. | 673 | key with a custom value is returned. |
672 | */ | 674 | */ |
673 | Key key( int type, QString customTypeString = QString::null ) const; | 675 | Key key( int type, QString customTypeString = QString::null ) const; |
674 | 676 | ||
675 | /** | 677 | /** |
676 | Return list of all keys. | 678 | Return list of all keys. |
677 | */ | 679 | */ |
678 | Key::List keys() const; | 680 | Key::List keys() const; |
679 | 681 | ||
680 | /** | 682 | /** |
681 | Set the list of keys | 683 | Set the list of keys |
682 | @param keys The keys to be set. | 684 | @param keys The keys to be set. |
683 | */ | 685 | */ |
684 | void setKeys( const Key::List& keys); | 686 | void setKeys( const Key::List& keys); |
685 | 687 | ||
686 | /** | 688 | /** |
687 | Return list of keys with a special type. | 689 | Return list of keys with a special type. |
688 | If @p type == Key::Custom you can specify a string | 690 | If @p type == Key::Custom you can specify a string |
689 | that should match. If you leave the string empty, all custom | 691 | that should match. If you leave the string empty, all custom |
690 | keys will be returned. | 692 | keys will be returned. |
691 | */ | 693 | */ |
692 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 694 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
693 | 695 | ||
694 | /** | 696 | /** |
695 | Return key with the given id. | 697 | Return key with the given id. |
696 | */ | 698 | */ |
697 | Key findKey( const QString &id ) const; | 699 | Key findKey( const QString &id ) const; |
698 | 700 | ||
699 | /** | 701 | /** |
700 | Insert an address. If an address with the same id already exists | 702 | Insert an address. If an address with the same id already exists |
701 | in this addressee it is not duplicated. | 703 | in this addressee it is not duplicated. |
702 | */ | 704 | */ |
703 | void insertAddress( const Address &address ); | 705 | void insertAddress( const Address &address ); |
704 | 706 | ||
705 | /** | 707 | /** |
706 | Remove address. If no address with the given id exists for this | 708 | Remove address. If no address with the given id exists for this |
707 | addresse nothing happens. | 709 | addresse nothing happens. |
708 | */ | 710 | */ |
709 | void removeAddress( const Address &address ); | 711 | void removeAddress( const Address &address ); |
710 | 712 | ||
711 | /** | 713 | /** |
712 | Return address, which matches the given type. | 714 | Return address, which matches the given type. |
713 | */ | 715 | */ |
714 | Address address( int type ) const; | 716 | Address address( int type ) const; |
715 | 717 | ||
716 | /** | 718 | /** |
717 | Return list of all addresses. | 719 | Return list of all addresses. |
718 | */ | 720 | */ |
719 | Address::List addresses() const; | 721 | Address::List addresses() const; |
720 | 722 | ||
721 | /** | 723 | /** |
722 | Return list of addresses with a special type. | 724 | Return list of addresses with a special type. |
723 | */ | 725 | */ |
724 | Address::List addresses( int type ) const; | 726 | Address::List addresses( int type ) const; |
725 | 727 | ||
726 | /** | 728 | /** |
727 | Return address with the given id. | 729 | Return address with the given id. |
728 | */ | 730 | */ |
729 | Address findAddress( const QString &id ) const; | 731 | Address findAddress( const QString &id ) const; |
730 | 732 | ||
731 | /** | 733 | /** |
732 | Insert category. If the category already exists it is not duplicated. | 734 | Insert category. If the category already exists it is not duplicated. |
733 | */ | 735 | */ |
734 | void insertCategory( const QString & ); | 736 | void insertCategory( const QString & ); |
735 | 737 | ||
736 | /** | 738 | /** |
737 | Remove category. | 739 | Remove category. |
738 | */ | 740 | */ |
739 | void removeCategory( const QString & ); | 741 | void removeCategory( const QString & ); |
740 | 742 | ||
741 | /** | 743 | /** |
742 | Return, if addressee has the given category. | 744 | Return, if addressee has the given category. |
743 | */ | 745 | */ |
744 | bool hasCategory( const QString & ) const; | 746 | bool hasCategory( const QString & ) const; |
745 | 747 | ||
746 | /** | 748 | /** |
747 | Set categories to given value. | 749 | Set categories to given value. |
748 | */ | 750 | */ |
749 | void setCategories( const QStringList & ); | 751 | void setCategories( const QStringList & ); |
750 | 752 | ||
751 | /** | 753 | /** |
752 | Return list of all set categories. | 754 | Return list of all set categories. |
753 | */ | 755 | */ |
754 | QStringList categories() const; | 756 | QStringList categories() const; |
755 | 757 | ||
756 | /** | 758 | /** |
757 | Insert custom entry. The entry is identified by the name of the inserting | 759 | Insert custom entry. The entry is identified by the name of the inserting |
758 | application and a unique name. If an entry with the given app and name | 760 | application and a unique name. If an entry with the given app and name |
759 | already exists its value is replaced with the new given value. | 761 | already exists its value is replaced with the new given value. |
760 | */ | 762 | */ |
761 | void insertCustom( const QString &app, const QString &name, | 763 | void insertCustom( const QString &app, const QString &name, |
762 | const QString &value ); | 764 | const QString &value ); |
763 | 765 | ||
764 | /** | 766 | /** |
765 | Remove custom entry. | 767 | Remove custom entry. |
766 | */ | 768 | */ |
767 | void removeCustom( const QString &app, const QString &name ); | 769 | void removeCustom( const QString &app, const QString &name ); |
768 | 770 | ||
769 | /** | 771 | /** |
770 | Return value of custom entry, identified by app and entry name. | 772 | Return value of custom entry, identified by app and entry name. |
771 | */ | 773 | */ |
772 | QString custom( const QString &app, const QString &name ) const; | 774 | QString custom( const QString &app, const QString &name ) const; |
773 | 775 | ||
774 | /** | 776 | /** |
775 | Set all custom entries. | 777 | Set all custom entries. |
776 | */ | 778 | */ |
777 | void setCustoms( const QStringList & ); | 779 | void setCustoms( const QStringList & ); |
778 | 780 | ||
779 | /** | 781 | /** |
780 | Return list of all custom entries. | 782 | Return list of all custom entries. |
781 | */ | 783 | */ |
782 | QStringList customs() const; | 784 | QStringList customs() const; |
783 | 785 | ||
784 | /** | 786 | /** |
785 | Parse full email address. The result is given back in fullName and email. | 787 | Parse full email address. The result is given back in fullName and email. |
786 | */ | 788 | */ |
787 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 789 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
788 | QString &email ); | 790 | QString &email ); |
789 | 791 | ||
790 | /** | 792 | /** |
791 | Debug output. | 793 | Debug output. |
792 | */ | 794 | */ |
793 | void dump() const; | 795 | void dump() const; |
794 | 796 | ||
795 | /** | 797 | /** |
796 | Returns string representation of the addressee. | 798 | Returns string representation of the addressee. |
797 | */ | 799 | */ |
798 | QString asString() const; | 800 | QString asString() const; |
799 | 801 | ||
800 | /** | 802 | /** |
801 | Set resource where the addressee is from. | 803 | Set resource where the addressee is from. |
802 | */ | 804 | */ |
803 | void setResource( Resource *resource ); | 805 | void setResource( Resource *resource ); |
804 | 806 | ||
805 | /** | 807 | /** |
806 | Return pointer to resource. | 808 | Return pointer to resource. |
807 | */ | 809 | */ |
808 | Resource *resource() const; | 810 | Resource *resource() const; |
809 | 811 | ||
810 | /** | 812 | /** |
811 | Return resourcelabel. | 813 | Return resourcelabel. |
812 | */ | 814 | */ |
813 | //US | 815 | //US |
814 | static QString resourceLabel(); | 816 | static QString resourceLabel(); |
815 | 817 | ||
816 | /** | 818 | /** |
817 | Mark addressee as changed. | 819 | Mark addressee as changed. |
818 | */ | 820 | */ |
819 | void setChanged( bool value ); | 821 | void setChanged( bool value ); |
820 | 822 | ||
821 | /** | 823 | /** |
822 | Return whether the addressee is changed. | 824 | Return whether the addressee is changed. |
823 | */ | 825 | */ |
824 | bool changed() const; | 826 | bool changed() const; |
825 | 827 | ||
826 | private: | 828 | private: |
827 | Addressee copy(); | 829 | Addressee copy(); |
828 | void detach(); | 830 | void detach(); |
829 | 831 | ||
830 | struct AddresseeData; | 832 | struct AddresseeData; |
831 | mutable KSharedPtr<AddresseeData> mData; | 833 | mutable KSharedPtr<AddresseeData> mData; |
832 | }; | 834 | }; |
833 | 835 | ||
834 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 836 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
835 | QDataStream &operator>>( QDataStream &, Addressee & ); | 837 | QDataStream &operator>>( QDataStream &, Addressee & ); |
836 | 838 | ||
837 | } | 839 | } |
838 | 840 | ||
839 | #endif | 841 | #endif |
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index ac513b6..7d00a3f 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp | |||
@@ -1,362 +1,369 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | //US | 28 | //US |
29 | #include "kglobal.h" | 29 | #include "kglobal.h" |
30 | 30 | ||
31 | 31 | ||
32 | #include "qtopiaconverter.h" | 32 | #include "qtopiaconverter.h" |
33 | 33 | ||
34 | #include <qpe/categories.h> | 34 | #include <qpe/categories.h> |
35 | //US #include <qpe/categoryselect.h> | 35 | //US #include <qpe/categoryselect.h> |
36 | 36 | ||
37 | 37 | ||
38 | using namespace KABC; | 38 | using namespace KABC; |
39 | 39 | ||
40 | QtopiaConverter::QtopiaConverter() : catDB(0) | 40 | QtopiaConverter::QtopiaConverter() : catDB(0) |
41 | { | 41 | { |
42 | } | 42 | } |
43 | 43 | ||
44 | QtopiaConverter::~QtopiaConverter() | 44 | QtopiaConverter::~QtopiaConverter() |
45 | { | 45 | { |
46 | deinit(); | 46 | deinit(); |
47 | } | 47 | } |
48 | 48 | ||
49 | bool QtopiaConverter::init() | 49 | bool QtopiaConverter::init() |
50 | { | 50 | { |
51 | catDB = new Categories(); | 51 | catDB = new Categories(); |
52 | 52 | ||
53 | if (!catDB) | 53 | if (!catDB) |
54 | return false; | 54 | return false; |
55 | 55 | ||
56 | catDB->load( categoryFileName() ); | 56 | catDB->load( categoryFileName() ); |
57 | return true; | 57 | return true; |
58 | } | 58 | } |
59 | 59 | ||
60 | void QtopiaConverter::deinit() | 60 | void QtopiaConverter::deinit() |
61 | { | 61 | { |
62 | if (catDB) | 62 | if (catDB) |
63 | { | 63 | { |
64 | delete catDB; | 64 | delete catDB; |
65 | catDB = 0; | 65 | catDB = 0; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) | 69 | bool QtopiaConverter::qtopiaToAddressee( const PimContact &contact, Addressee &addr ) |
70 | { | 70 | { |
71 | // name | 71 | // name |
72 | addr.setFormattedName(contact.fileAs()); | 72 | addr.setFormattedName(contact.fileAs()); |
73 | addr.setFamilyName( contact.lastName() ); | 73 | addr.setFamilyName( contact.lastName() ); |
74 | addr.setGivenName( contact.firstName() ); | 74 | addr.setGivenName( contact.firstName() ); |
75 | addr.setAdditionalName( contact.middleName() ); | 75 | addr.setAdditionalName( contact.middleName() ); |
76 | addr.setPrefix( contact.nameTitle() ); | 76 | addr.setPrefix( contact.nameTitle() ); |
77 | addr.setSuffix( contact.suffix() ); | 77 | addr.setSuffix( contact.suffix() ); |
78 | 78 | QString exuid = contact.uid().toString(); | |
79 | int ente = exuid.find( "-0000"); | ||
80 | if ( exuid.left(1) == "{" ) | ||
81 | exuid = exuid.mid(1); | ||
82 | if ( ente > -1 ) | ||
83 | exuid = exuid.left( ente-1 ); | ||
84 | addr.setExternalUID( exuid ); | ||
85 | //qDebug("QtopiaConverter:set uid %s ",addr.externalUID().latin1() ); | ||
79 | 86 | ||
80 | 87 | ||
81 | QStringList emails = contact.emailList(); | 88 | QStringList emails = contact.emailList(); |
82 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 89 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
83 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); | 90 | addr.insertEmail( *it, ((*it) == contact.defaultEmail()) ); |
84 | } | 91 | } |
85 | 92 | ||
86 | if (!contact.defaultEmail().isEmpty()) | 93 | if (!contact.defaultEmail().isEmpty()) |
87 | addr.insertEmail(contact.defaultEmail(), true); | 94 | addr.insertEmail(contact.defaultEmail(), true); |
88 | 95 | ||
89 | // home | 96 | // home |
90 | if ((!contact.homeStreet().isEmpty()) || | 97 | if ((!contact.homeStreet().isEmpty()) || |
91 | (!contact.homeCity().isEmpty()) || | 98 | (!contact.homeCity().isEmpty()) || |
92 | (!contact.homeState().isEmpty()) || | 99 | (!contact.homeState().isEmpty()) || |
93 | (!contact.homeZip().isEmpty()) || | 100 | (!contact.homeZip().isEmpty()) || |
94 | (!contact.homeCountry().isEmpty())) | 101 | (!contact.homeCountry().isEmpty())) |
95 | { | 102 | { |
96 | Address homeaddress; | 103 | Address homeaddress; |
97 | homeaddress.setType(Address::Home); | 104 | homeaddress.setType(Address::Home); |
98 | //US homeaddress.setPostOfficeBox( "" ); | 105 | //US homeaddress.setPostOfficeBox( "" ); |
99 | //US homeaddress.setExtended( "" ); | 106 | //US homeaddress.setExtended( "" ); |
100 | homeaddress.setStreet( contact.homeStreet() ); | 107 | homeaddress.setStreet( contact.homeStreet() ); |
101 | homeaddress.setLocality( contact.homeCity() ); | 108 | homeaddress.setLocality( contact.homeCity() ); |
102 | homeaddress.setRegion( contact.homeState() ); | 109 | homeaddress.setRegion( contact.homeState() ); |
103 | homeaddress.setPostalCode( contact.homeZip() ); | 110 | homeaddress.setPostalCode( contact.homeZip() ); |
104 | homeaddress.setCountry( contact.homeCountry() ); | 111 | homeaddress.setCountry( contact.homeCountry() ); |
105 | 112 | ||
106 | addr.insertAddress( homeaddress ); | 113 | addr.insertAddress( homeaddress ); |
107 | } | 114 | } |
108 | 115 | ||
109 | if (!contact.homePhone().isEmpty()) | 116 | if (!contact.homePhone().isEmpty()) |
110 | { | 117 | { |
111 | PhoneNumber homephone; | 118 | PhoneNumber homephone; |
112 | homephone.setType( PhoneNumber::Home ); | 119 | homephone.setType( PhoneNumber::Home ); |
113 | homephone.setNumber( contact.homePhone() ); | 120 | homephone.setNumber( contact.homePhone() ); |
114 | addr.insertPhoneNumber( homephone ); | 121 | addr.insertPhoneNumber( homephone ); |
115 | } | 122 | } |
116 | 123 | ||
117 | if (!contact.homeFax().isEmpty()) | 124 | if (!contact.homeFax().isEmpty()) |
118 | { | 125 | { |
119 | PhoneNumber homefax; | 126 | PhoneNumber homefax; |
120 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); | 127 | homefax.setType( PhoneNumber::Home | PhoneNumber::Fax ); |
121 | homefax.setNumber( contact.homeFax() ); | 128 | homefax.setNumber( contact.homeFax() ); |
122 | addr.insertPhoneNumber( homefax ); | 129 | addr.insertPhoneNumber( homefax ); |
123 | } | 130 | } |
124 | 131 | ||
125 | if (!contact.homeMobile().isEmpty()) | 132 | if (!contact.homeMobile().isEmpty()) |
126 | { | 133 | { |
127 | PhoneNumber homemobile; | 134 | PhoneNumber homemobile; |
128 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); | 135 | homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell ); |
129 | homemobile.setNumber( contact.homeMobile() ); | 136 | homemobile.setNumber( contact.homeMobile() ); |
130 | addr.insertPhoneNumber( homemobile ); | 137 | addr.insertPhoneNumber( homemobile ); |
131 | } | 138 | } |
132 | 139 | ||
133 | addr.setUrl( contact.homeWebpage() ); | 140 | addr.setUrl( contact.homeWebpage() ); |
134 | 141 | ||
135 | 142 | ||
136 | // business | 143 | // business |
137 | if ((!contact.businessStreet().isEmpty()) || | 144 | if ((!contact.businessStreet().isEmpty()) || |
138 | (!contact.businessCity().isEmpty()) || | 145 | (!contact.businessCity().isEmpty()) || |
139 | (!contact.businessState().isEmpty()) || | 146 | (!contact.businessState().isEmpty()) || |
140 | (!contact.businessZip().isEmpty()) || | 147 | (!contact.businessZip().isEmpty()) || |
141 | (!contact.businessCountry().isEmpty())) | 148 | (!contact.businessCountry().isEmpty())) |
142 | { | 149 | { |
143 | Address businessaddress; | 150 | Address businessaddress; |
144 | businessaddress.setType(Address::Work); | 151 | businessaddress.setType(Address::Work); |
145 | //US businessaddress.setPostOfficeBox( "" ); | 152 | //US businessaddress.setPostOfficeBox( "" ); |
146 | //US businessaddress.setExtended( "" ); | 153 | //US businessaddress.setExtended( "" ); |
147 | businessaddress.setStreet( contact.businessStreet() ); | 154 | businessaddress.setStreet( contact.businessStreet() ); |
148 | businessaddress.setLocality( contact.businessCity() ); | 155 | businessaddress.setLocality( contact.businessCity() ); |
149 | businessaddress.setRegion( contact.businessState() ); | 156 | businessaddress.setRegion( contact.businessState() ); |
150 | businessaddress.setPostalCode( contact.businessZip() ); | 157 | businessaddress.setPostalCode( contact.businessZip() ); |
151 | businessaddress.setCountry( contact.businessCountry() ); | 158 | businessaddress.setCountry( contact.businessCountry() ); |
152 | 159 | ||
153 | addr.insertAddress( businessaddress ); | 160 | addr.insertAddress( businessaddress ); |
154 | } | 161 | } |
155 | 162 | ||
156 | 163 | ||
157 | if (!contact.businessPhone().isEmpty()) | 164 | if (!contact.businessPhone().isEmpty()) |
158 | { | 165 | { |
159 | PhoneNumber businessphone; | 166 | PhoneNumber businessphone; |
160 | businessphone.setType( PhoneNumber::Work ); | 167 | businessphone.setType( PhoneNumber::Work ); |
161 | businessphone.setNumber( contact.businessPhone() ); | 168 | businessphone.setNumber( contact.businessPhone() ); |
162 | addr.insertPhoneNumber( businessphone ); | 169 | addr.insertPhoneNumber( businessphone ); |
163 | } | 170 | } |
164 | 171 | ||
165 | if (!contact.businessFax().isEmpty()) | 172 | if (!contact.businessFax().isEmpty()) |
166 | { | 173 | { |
167 | PhoneNumber businessfax; | 174 | PhoneNumber businessfax; |
168 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); | 175 | businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax ); |
169 | businessfax.setNumber( contact.businessFax() ); | 176 | businessfax.setNumber( contact.businessFax() ); |
170 | addr.insertPhoneNumber( businessfax ); | 177 | addr.insertPhoneNumber( businessfax ); |
171 | } | 178 | } |
172 | 179 | ||
173 | if (!contact.businessMobile().isEmpty()) | 180 | if (!contact.businessMobile().isEmpty()) |
174 | { | 181 | { |
175 | PhoneNumber businessmobile; | 182 | PhoneNumber businessmobile; |
176 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); | 183 | businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell ); |
177 | businessmobile.setNumber( contact.businessMobile() ); | 184 | businessmobile.setNumber( contact.businessMobile() ); |
178 | addr.insertPhoneNumber( businessmobile ); | 185 | addr.insertPhoneNumber( businessmobile ); |
179 | } | 186 | } |
180 | 187 | ||
181 | if (!contact.businessPager().isEmpty()) | 188 | if (!contact.businessPager().isEmpty()) |
182 | { | 189 | { |
183 | PhoneNumber businesspager; | 190 | PhoneNumber businesspager; |
184 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); | 191 | businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager ); |
185 | businesspager.setNumber( contact.businessPager() ); | 192 | businesspager.setNumber( contact.businessPager() ); |
186 | addr.insertPhoneNumber( businesspager ); | 193 | addr.insertPhoneNumber( businesspager ); |
187 | } | 194 | } |
188 | 195 | ||
189 | addr.setRole( contact.jobTitle() ); //? | 196 | addr.setRole( contact.jobTitle() ); //? |
190 | addr.setOrganization( contact.company() ); | 197 | addr.setOrganization( contact.company() ); |
191 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); | 198 | addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() ); |
192 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); | 199 | addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() ); |
193 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); | 200 | addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() ); |
194 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); | 201 | addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() ); |
195 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); | 202 | addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() ); |
196 | 203 | ||
197 | //personal | 204 | //personal |
198 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); | 205 | addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() ); |
199 | // qtopia uses this categorization: | 206 | // qtopia uses this categorization: |
200 | // enum GenderType { UnspecifiedGender=0, Male, Female }; | 207 | // enum GenderType { UnspecifiedGender=0, Male, Female }; |
201 | if (contact.gender() == PimContact::Male) | 208 | if (contact.gender() == PimContact::Male) |
202 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); | 209 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); |
203 | else if (contact.gender() == PimContact::Female) | 210 | else if (contact.gender() == PimContact::Female) |
204 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); | 211 | addr.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); |
205 | 212 | ||
206 | if (contact.anniversary().isValid()) { | 213 | if (contact.anniversary().isValid()) { |
207 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); | 214 | QString dt = KGlobal::locale()->formatDate(contact.anniversary(), true, KLocale::ISODate); |
208 | //US | 215 | //US |
209 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); | 216 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); |
210 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 217 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
211 | } | 218 | } |
212 | 219 | ||
213 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); | 220 | addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() ); |
214 | if (contact.birthday().isValid()) | 221 | if (contact.birthday().isValid()) |
215 | addr.setBirthday( contact.birthday() ); | 222 | addr.setBirthday( contact.birthday() ); |
216 | 223 | ||
217 | addr.setNickName( contact.nickname() ); | 224 | addr.setNickName( contact.nickname() ); |
218 | 225 | ||
219 | // others | 226 | // others |
220 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. | 227 | //US I put opies BusinessWebPage into Ka/Pi's notes block, because no other native field is available. |
221 | QString notes = contact.notes(); | 228 | QString notes = contact.notes(); |
222 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; | 229 | notes += "\nBusinessWebPage: " + contact.businessWebpage() + "\n"; |
223 | 230 | ||
224 | addr.setNote( contact.notes() ); | 231 | addr.setNote( contact.notes() ); |
225 | 232 | ||
226 | 233 | ||
227 | 234 | ||
228 | //US QString groups() const { return find( Qtopia::Groups ); } | 235 | //US QString groups() const { return find( Qtopia::Groups ); } |
229 | //US QStringList groupList() const; | 236 | //US QStringList groupList() const; |
230 | 237 | ||
231 | QArray<int> catArray = contact.categories(); | 238 | QArray<int> catArray = contact.categories(); |
232 | QString cat; | 239 | QString cat; |
233 | 240 | ||
234 | for ( unsigned int i=0; i < catArray.size(); i++ ) { | 241 | for ( unsigned int i=0; i < catArray.size(); i++ ) { |
235 | cat = catDB->label("contact", catArray[i]); | 242 | cat = catDB->label("contact", catArray[i]); |
236 | if ( cat.isEmpty() ) | 243 | if ( cat.isEmpty() ) |
237 | addr.insertCategory(QString::number(catArray[i])); | 244 | addr.insertCategory(QString::number(catArray[i])); |
238 | else | 245 | else |
239 | addr.insertCategory( cat ); | 246 | addr.insertCategory( cat ); |
240 | } | 247 | } |
241 | 248 | ||
242 | return true; | 249 | return true; |
243 | } | 250 | } |
244 | 251 | ||
245 | bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) | 252 | bool QtopiaConverter::addresseeToQtopia( const Addressee &addr, PimContact &contact ) |
246 | { | 253 | { |
247 | // name | 254 | // name |
248 | contact.setLastName(addr.familyName()); | 255 | contact.setLastName(addr.familyName()); |
249 | contact.setFirstName(addr.givenName()); | 256 | contact.setFirstName(addr.givenName()); |
250 | contact.setMiddleName(addr.additionalName()); | 257 | contact.setMiddleName(addr.additionalName()); |
251 | contact.setNameTitle(addr.prefix()); | 258 | contact.setNameTitle(addr.prefix()); |
252 | contact.setSuffix(addr.suffix()); | 259 | contact.setSuffix(addr.suffix()); |
253 | contact.setFileAs(); | 260 | contact.setFileAs(); |
254 | 261 | ||
255 | 262 | ||
256 | 263 | ||
257 | QStringList emails = addr.emails(); | 264 | QStringList emails = addr.emails(); |
258 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 265 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
259 | contact.insertEmail(*it); | 266 | contact.insertEmail(*it); |
260 | } | 267 | } |
261 | contact.setDefaultEmail( addr.preferredEmail() ); | 268 | contact.setDefaultEmail( addr.preferredEmail() ); |
262 | 269 | ||
263 | 270 | ||
264 | // home | 271 | // home |
265 | const Address homeaddress = addr.address(Address::Home); | 272 | const Address homeaddress = addr.address(Address::Home); |
266 | if (!homeaddress.isEmpty()) { | 273 | if (!homeaddress.isEmpty()) { |
267 | contact.setHomeStreet(homeaddress.street()); | 274 | contact.setHomeStreet(homeaddress.street()); |
268 | contact.setHomeCity(homeaddress.locality()); | 275 | contact.setHomeCity(homeaddress.locality()); |
269 | contact.setHomeState(homeaddress.region()); | 276 | contact.setHomeState(homeaddress.region()); |
270 | contact.setHomeZip(homeaddress.postalCode()); | 277 | contact.setHomeZip(homeaddress.postalCode()); |
271 | contact.setHomeCountry(homeaddress.country()); | 278 | contact.setHomeCountry(homeaddress.country()); |
272 | } | 279 | } |
273 | 280 | ||
274 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); | 281 | PhoneNumber homephone = addr.phoneNumber( PhoneNumber::Home ); |
275 | if (!homephone.number().isEmpty()) | 282 | if (!homephone.number().isEmpty()) |
276 | contact.setHomePhone(homephone.number()); | 283 | contact.setHomePhone(homephone.number()); |
277 | 284 | ||
278 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); | 285 | PhoneNumber homefax = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Fax ); |
279 | if (!homefax.number().isEmpty()) | 286 | if (!homefax.number().isEmpty()) |
280 | contact.setHomeFax(homefax.number()); | 287 | contact.setHomeFax(homefax.number()); |
281 | 288 | ||
282 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 289 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
283 | if (!homemobile.number().isEmpty()) | 290 | if (!homemobile.number().isEmpty()) |
284 | contact.setHomeMobile(homemobile.number()); | 291 | contact.setHomeMobile(homemobile.number()); |
285 | 292 | ||
286 | contact.setHomeWebpage(addr.url().url()); | 293 | contact.setHomeWebpage(addr.url().url()); |
287 | 294 | ||
288 | 295 | ||
289 | // business | 296 | // business |
290 | const Address businessaddress = addr.address(Address::Work); | 297 | const Address businessaddress = addr.address(Address::Work); |
291 | if (!businessaddress.isEmpty()) { | 298 | if (!businessaddress.isEmpty()) { |
292 | contact.setBusinessStreet(businessaddress.street()); | 299 | contact.setBusinessStreet(businessaddress.street()); |
293 | contact.setBusinessCity(businessaddress.locality()); | 300 | contact.setBusinessCity(businessaddress.locality()); |
294 | contact.setBusinessState(businessaddress.region()); | 301 | contact.setBusinessState(businessaddress.region()); |
295 | contact.setBusinessZip(businessaddress.postalCode()); | 302 | contact.setBusinessZip(businessaddress.postalCode()); |
296 | contact.setBusinessCountry(businessaddress.country()); | 303 | contact.setBusinessCountry(businessaddress.country()); |
297 | } | 304 | } |
298 | 305 | ||
299 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); | 306 | PhoneNumber businessphone = addr.phoneNumber( PhoneNumber::Work ); |
300 | if (!businessphone.number().isEmpty()) | 307 | if (!businessphone.number().isEmpty()) |
301 | contact.setBusinessPhone(businessphone.number()); | 308 | contact.setBusinessPhone(businessphone.number()); |
302 | 309 | ||
303 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); | 310 | PhoneNumber businessfax = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Fax ); |
304 | if (!businessfax.number().isEmpty()) | 311 | if (!businessfax.number().isEmpty()) |
305 | contact.setBusinessFax(businessfax.number()); | 312 | contact.setBusinessFax(businessfax.number()); |
306 | 313 | ||
307 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 314 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
308 | if (!businessmobile.number().isEmpty()) | 315 | if (!businessmobile.number().isEmpty()) |
309 | contact.setBusinessMobile(businessmobile.number()); | 316 | contact.setBusinessMobile(businessmobile.number()); |
310 | 317 | ||
311 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); | 318 | PhoneNumber businesspager = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Pager ); |
312 | if (!businesspager.number().isEmpty()) | 319 | if (!businesspager.number().isEmpty()) |
313 | contact.setBusinessPager(businesspager.number()); | 320 | contact.setBusinessPager(businesspager.number()); |
314 | 321 | ||
315 | contact.setJobTitle(addr.role()); | 322 | contact.setJobTitle(addr.role()); |
316 | contact.setCompany(addr.organization()); | 323 | contact.setCompany(addr.organization()); |
317 | 324 | ||
318 | contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); | 325 | contact.setProfession(addr.custom( "KADDRESSBOOK", "X-Profession" )); |
319 | contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); | 326 | contact.setAssistant(addr.custom( "KADDRESSBOOK", "X-AssistantsName" )); |
320 | contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); | 327 | contact.setDepartment(addr.custom( "KADDRESSBOOK", "X-Department" )); |
321 | contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); | 328 | contact.setManager(addr.custom( "KADDRESSBOOK", "X-ManagersName" )); |
322 | contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); | 329 | contact.setOffice(addr.custom( "KADDRESSBOOK", "X-Office" )); |
323 | 330 | ||
324 | //personal | 331 | //personal |
325 | contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); | 332 | contact.setSpouse(addr.custom( "KADDRESSBOOK", "X-Spouse" )); |
326 | // qtopia uses this categorization: | 333 | // qtopia uses this categorization: |
327 | // enum GenderType { UnspecifiedGender=0, Male, Female }; | 334 | // enum GenderType { UnspecifiedGender=0, Male, Female }; |
328 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 335 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
329 | if (gt = "male") | 336 | if (gt = "male") |
330 | contact.setGender(PimContact::Male); | 337 | contact.setGender(PimContact::Male); |
331 | else if (gt = "female") | 338 | else if (gt = "female") |
332 | contact.setGender(PimContact::Female); | 339 | contact.setGender(PimContact::Female); |
333 | else | 340 | else |
334 | contact.setGender(PimContact::UnspecifiedGender); | 341 | contact.setGender(PimContact::UnspecifiedGender); |
335 | 342 | ||
336 | 343 | ||
337 | QDate dt = KGlobal::locale()->readDate( | 344 | QDate dt = KGlobal::locale()->readDate( |
338 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 345 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
339 | contact.setAnniversary( dt ); | 346 | contact.setAnniversary( dt ); |
340 | 347 | ||
341 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); | 348 | contact.setChildren(addr.custom( "KADDRESSBOOK", "X-Children" )); |
342 | 349 | ||
343 | contact.setBirthday(addr.birthday().date()); | 350 | contact.setBirthday(addr.birthday().date()); |
344 | contact.setNickname(addr.nickName()); | 351 | contact.setNickname(addr.nickName()); |
345 | 352 | ||
346 | // other | 353 | // other |
347 | contact.setNotes(addr.note()); | 354 | contact.setNotes(addr.note()); |
348 | 355 | ||
349 | //US QString groups() const { return find( Qtopia::Groups ); } | 356 | //US QString groups() const { return find( Qtopia::Groups ); } |
350 | //US QStringList groupList() const; | 357 | //US QStringList groupList() const; |
351 | 358 | ||
352 | 359 | ||
353 | QStringList cats = addr.categories(); | 360 | QStringList cats = addr.categories(); |
354 | 361 | ||
355 | QArray<int> iar; | 362 | QArray<int> iar; |
356 | if ( !cats.isEmpty() ) { | 363 | if ( !cats.isEmpty() ) { |
357 | QArray<int> iar = catDB->ids("contact", cats); | 364 | QArray<int> iar = catDB->ids("contact", cats); |
358 | contact.setCategories(iar); | 365 | contact.setCategories(iar); |
359 | } | 366 | } |
360 | 367 | ||
361 | return true; | 368 | return true; |
362 | } | 369 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index fa0c51f..d6482fb 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1417,1606 +1417,1608 @@ void KABCore::initGUI() | |||
1417 | #ifndef KAB_EMBEDDED | 1417 | #ifndef KAB_EMBEDDED |
1418 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1418 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1419 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1419 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1420 | 1420 | ||
1421 | mExtensionBarSplitter = new QSplitter( this ); | 1421 | mExtensionBarSplitter = new QSplitter( this ); |
1422 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1422 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1423 | 1423 | ||
1424 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1424 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1425 | 1425 | ||
1426 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1426 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1427 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1427 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1428 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1428 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1429 | SLOT( incrementalSearch( const QString& ) ) ); | 1429 | SLOT( incrementalSearch( const QString& ) ) ); |
1430 | 1430 | ||
1431 | mViewManager = new ViewManager( this, viewSpace ); | 1431 | mViewManager = new ViewManager( this, viewSpace ); |
1432 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1432 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1433 | 1433 | ||
1434 | mDetails = new ViewContainer( mDetailsSplitter ); | 1434 | mDetails = new ViewContainer( mDetailsSplitter ); |
1435 | 1435 | ||
1436 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1436 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1437 | 1437 | ||
1438 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1438 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1439 | 1439 | ||
1440 | topLayout->addWidget( mExtensionBarSplitter ); | 1440 | topLayout->addWidget( mExtensionBarSplitter ); |
1441 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1441 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1442 | topLayout->addWidget( mJumpButtonBar ); | 1442 | topLayout->addWidget( mJumpButtonBar ); |
1443 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1443 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1444 | 1444 | ||
1445 | mXXPortManager = new XXPortManager( this, this ); | 1445 | mXXPortManager = new XXPortManager( this, this ); |
1446 | 1446 | ||
1447 | #else //KAB_EMBEDDED | 1447 | #else //KAB_EMBEDDED |
1448 | //US initialize viewMenu before settingup viewmanager. | 1448 | //US initialize viewMenu before settingup viewmanager. |
1449 | // Viewmanager needs this menu to plugin submenues. | 1449 | // Viewmanager needs this menu to plugin submenues. |
1450 | viewMenu = new QPopupMenu( this ); | 1450 | viewMenu = new QPopupMenu( this ); |
1451 | settingsMenu = new QPopupMenu( this ); | 1451 | settingsMenu = new QPopupMenu( this ); |
1452 | //filterMenu = new QPopupMenu( this ); | 1452 | //filterMenu = new QPopupMenu( this ); |
1453 | ImportMenu = new QPopupMenu( this ); | 1453 | ImportMenu = new QPopupMenu( this ); |
1454 | ExportMenu = new QPopupMenu( this ); | 1454 | ExportMenu = new QPopupMenu( this ); |
1455 | syncMenu = new QPopupMenu( this ); | 1455 | syncMenu = new QPopupMenu( this ); |
1456 | changeMenu= new QPopupMenu( this ); | 1456 | changeMenu= new QPopupMenu( this ); |
1457 | 1457 | ||
1458 | //US since we have no splitter for the embedded system, setup | 1458 | //US since we have no splitter for the embedded system, setup |
1459 | // a layout with two frames. One left and one right. | 1459 | // a layout with two frames. One left and one right. |
1460 | 1460 | ||
1461 | QBoxLayout *topLayout; | 1461 | QBoxLayout *topLayout; |
1462 | 1462 | ||
1463 | // = new QHBoxLayout( this ); | 1463 | // = new QHBoxLayout( this ); |
1464 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1464 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1465 | 1465 | ||
1466 | // QWidget *mainBox = new QWidget( this ); | 1466 | // QWidget *mainBox = new QWidget( this ); |
1467 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1467 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1468 | 1468 | ||
1469 | #ifdef DESKTOP_VERSION | 1469 | #ifdef DESKTOP_VERSION |
1470 | topLayout = new QHBoxLayout( this ); | 1470 | topLayout = new QHBoxLayout( this ); |
1471 | 1471 | ||
1472 | 1472 | ||
1473 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1473 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1474 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1474 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1475 | 1475 | ||
1476 | topLayout->addWidget(mMiniSplitter ); | 1476 | topLayout->addWidget(mMiniSplitter ); |
1477 | 1477 | ||
1478 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1478 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1479 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1479 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1480 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1480 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1481 | mDetails = new ViewContainer( mMiniSplitter ); | 1481 | mDetails = new ViewContainer( mMiniSplitter ); |
1482 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1482 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1483 | #else | 1483 | #else |
1484 | if ( QApplication::desktop()->width() > 480 ) { | 1484 | if ( QApplication::desktop()->width() > 480 ) { |
1485 | topLayout = new QHBoxLayout( this ); | 1485 | topLayout = new QHBoxLayout( this ); |
1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1486 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1487 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1488 | } else { | 1488 | } else { |
1489 | 1489 | ||
1490 | topLayout = new QHBoxLayout( this ); | 1490 | topLayout = new QHBoxLayout( this ); |
1491 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1491 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1492 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1492 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | topLayout->addWidget(mMiniSplitter ); | 1495 | topLayout->addWidget(mMiniSplitter ); |
1496 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1496 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1497 | mDetails = new ViewContainer( mMiniSplitter ); | 1497 | mDetails = new ViewContainer( mMiniSplitter ); |
1498 | 1498 | ||
1499 | 1499 | ||
1500 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1500 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1501 | #endif | 1501 | #endif |
1502 | //eh->hide(); | 1502 | //eh->hide(); |
1503 | // topLayout->addWidget(mExtensionManager ); | 1503 | // topLayout->addWidget(mExtensionManager ); |
1504 | 1504 | ||
1505 | 1505 | ||
1506 | /*US | 1506 | /*US |
1507 | #ifndef KAB_NOSPLITTER | 1507 | #ifndef KAB_NOSPLITTER |
1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1508 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1509 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1510 | topLayout->setSpacing( 10 ); | 1510 | topLayout->setSpacing( 10 ); |
1511 | 1511 | ||
1512 | mDetailsSplitter = new QSplitter( this ); | 1512 | mDetailsSplitter = new QSplitter( this ); |
1513 | 1513 | ||
1514 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1514 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1515 | 1515 | ||
1516 | mViewManager = new ViewManager( this, viewSpace ); | 1516 | mViewManager = new ViewManager( this, viewSpace ); |
1517 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1517 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1518 | 1518 | ||
1519 | mDetails = new ViewContainer( mDetailsSplitter ); | 1519 | mDetails = new ViewContainer( mDetailsSplitter ); |
1520 | 1520 | ||
1521 | topLayout->addWidget( mDetailsSplitter ); | 1521 | topLayout->addWidget( mDetailsSplitter ); |
1522 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1522 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1523 | #else //KAB_NOSPLITTER | 1523 | #else //KAB_NOSPLITTER |
1524 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1524 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1525 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1525 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1526 | topLayout->setSpacing( 10 ); | 1526 | topLayout->setSpacing( 10 ); |
1527 | 1527 | ||
1528 | // mDetailsSplitter = new QSplitter( this ); | 1528 | // mDetailsSplitter = new QSplitter( this ); |
1529 | 1529 | ||
1530 | QVBox *viewSpace = new QVBox( this ); | 1530 | QVBox *viewSpace = new QVBox( this ); |
1531 | 1531 | ||
1532 | mViewManager = new ViewManager( this, viewSpace ); | 1532 | mViewManager = new ViewManager( this, viewSpace ); |
1533 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1533 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1534 | 1534 | ||
1535 | mDetails = new ViewContainer( this ); | 1535 | mDetails = new ViewContainer( this ); |
1536 | 1536 | ||
1537 | topLayout->addWidget( viewSpace ); | 1537 | topLayout->addWidget( viewSpace ); |
1538 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1538 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1539 | topLayout->addWidget( mDetails ); | 1539 | topLayout->addWidget( mDetails ); |
1540 | #endif //KAB_NOSPLITTER | 1540 | #endif //KAB_NOSPLITTER |
1541 | */ | 1541 | */ |
1542 | 1542 | ||
1543 | 1543 | ||
1544 | #endif //KAB_EMBEDDED | 1544 | #endif //KAB_EMBEDDED |
1545 | initActions(); | 1545 | initActions(); |
1546 | 1546 | ||
1547 | #ifdef KAB_EMBEDDED | 1547 | #ifdef KAB_EMBEDDED |
1548 | addActionsManually(); | 1548 | addActionsManually(); |
1549 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1549 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1550 | mXXPortManager = new XXPortManager( this, this ); | 1550 | mXXPortManager = new XXPortManager( this, this ); |
1551 | 1551 | ||
1552 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1552 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1553 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1553 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1554 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1554 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1555 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1555 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1556 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1556 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1557 | // mIncSearchWidget->hide(); | 1557 | // mIncSearchWidget->hide(); |
1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1558 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1559 | SLOT( incrementalSearch( const QString& ) ) ); | 1559 | SLOT( incrementalSearch( const QString& ) ) ); |
1560 | 1560 | ||
1561 | 1561 | ||
1562 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1562 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1563 | 1563 | ||
1564 | topLayout->addWidget( mJumpButtonBar ); | 1564 | topLayout->addWidget( mJumpButtonBar ); |
1565 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1565 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1566 | 1566 | ||
1567 | // mMainWindow->getIconToolBar()->raise(); | 1567 | // mMainWindow->getIconToolBar()->raise(); |
1568 | 1568 | ||
1569 | #endif //KAB_EMBEDDED | 1569 | #endif //KAB_EMBEDDED |
1570 | 1570 | ||
1571 | } | 1571 | } |
1572 | void KABCore::initActions() | 1572 | void KABCore::initActions() |
1573 | { | 1573 | { |
1574 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1574 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1575 | 1575 | ||
1576 | #ifndef KAB_EMBEDDED | 1576 | #ifndef KAB_EMBEDDED |
1577 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1577 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1578 | SLOT( clipboardDataChanged() ) ); | 1578 | SLOT( clipboardDataChanged() ) ); |
1579 | #endif //KAB_EMBEDDED | 1579 | #endif //KAB_EMBEDDED |
1580 | 1580 | ||
1581 | // file menu | 1581 | // file menu |
1582 | if ( mIsPart ) { | 1582 | if ( mIsPart ) { |
1583 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1583 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1584 | SLOT( sendMail() ), actionCollection(), | 1584 | SLOT( sendMail() ), actionCollection(), |
1585 | "kaddressbook_mail" ); | 1585 | "kaddressbook_mail" ); |
1586 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1586 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1587 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1587 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1588 | 1588 | ||
1589 | } else { | 1589 | } else { |
1590 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1590 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1591 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1591 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1592 | } | 1592 | } |
1593 | 1593 | ||
1594 | 1594 | ||
1595 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1595 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1596 | SLOT( save() ), actionCollection(), "file_sync" ); | 1596 | SLOT( save() ), actionCollection(), "file_sync" ); |
1597 | 1597 | ||
1598 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1598 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1599 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1599 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1600 | 1600 | ||
1601 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1601 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1602 | this, SLOT( mailVCard() ), | 1602 | this, SLOT( mailVCard() ), |
1603 | actionCollection(), "file_mail_vcard"); | 1603 | actionCollection(), "file_mail_vcard"); |
1604 | 1604 | ||
1605 | mActionBeamVCard = 0; | 1605 | mActionBeamVCard = 0; |
1606 | mActionBeam = 0; | 1606 | mActionBeam = 0; |
1607 | 1607 | ||
1608 | #ifndef DESKTOP_VERSION | 1608 | #ifndef DESKTOP_VERSION |
1609 | if ( Ir::supported() ) { | 1609 | if ( Ir::supported() ) { |
1610 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1610 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1611 | SLOT( beamVCard() ), actionCollection(), | 1611 | SLOT( beamVCard() ), actionCollection(), |
1612 | "kaddressbook_beam_vcard" ); | 1612 | "kaddressbook_beam_vcard" ); |
1613 | 1613 | ||
1614 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1614 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1615 | SLOT( beamMySelf() ), actionCollection(), | 1615 | SLOT( beamMySelf() ), actionCollection(), |
1616 | "kaddressbook_beam_myself" ); | 1616 | "kaddressbook_beam_myself" ); |
1617 | } | 1617 | } |
1618 | #endif | 1618 | #endif |
1619 | 1619 | ||
1620 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1620 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1621 | this, SLOT( editContact2() ), | 1621 | this, SLOT( editContact2() ), |
1622 | actionCollection(), "file_properties" ); | 1622 | actionCollection(), "file_properties" ); |
1623 | 1623 | ||
1624 | #ifdef KAB_EMBEDDED | 1624 | #ifdef KAB_EMBEDDED |
1625 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1625 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1626 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1626 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1627 | mMainWindow, SLOT( exit() ), | 1627 | mMainWindow, SLOT( exit() ), |
1628 | actionCollection(), "quit" ); | 1628 | actionCollection(), "quit" ); |
1629 | #endif //KAB_EMBEDDED | 1629 | #endif //KAB_EMBEDDED |
1630 | 1630 | ||
1631 | // edit menu | 1631 | // edit menu |
1632 | if ( mIsPart ) { | 1632 | if ( mIsPart ) { |
1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1633 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1634 | SLOT( copyContacts() ), actionCollection(), | 1634 | SLOT( copyContacts() ), actionCollection(), |
1635 | "kaddressbook_copy" ); | 1635 | "kaddressbook_copy" ); |
1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1636 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1637 | SLOT( cutContacts() ), actionCollection(), | 1637 | SLOT( cutContacts() ), actionCollection(), |
1638 | "kaddressbook_cut" ); | 1638 | "kaddressbook_cut" ); |
1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1639 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1640 | SLOT( pasteContacts() ), actionCollection(), | 1640 | SLOT( pasteContacts() ), actionCollection(), |
1641 | "kaddressbook_paste" ); | 1641 | "kaddressbook_paste" ); |
1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1642 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1643 | SLOT( selectAllContacts() ), actionCollection(), | 1643 | SLOT( selectAllContacts() ), actionCollection(), |
1644 | "kaddressbook_select_all" ); | 1644 | "kaddressbook_select_all" ); |
1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1645 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1646 | SLOT( undo() ), actionCollection(), | 1646 | SLOT( undo() ), actionCollection(), |
1647 | "kaddressbook_undo" ); | 1647 | "kaddressbook_undo" ); |
1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1648 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1649 | this, SLOT( redo() ), actionCollection(), | 1649 | this, SLOT( redo() ), actionCollection(), |
1650 | "kaddressbook_redo" ); | 1650 | "kaddressbook_redo" ); |
1651 | } else { | 1651 | } else { |
1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1652 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1653 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1654 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1655 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1656 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1657 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1660 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1661 | Key_Delete, this, SLOT( deleteContacts() ), | 1661 | Key_Delete, this, SLOT( deleteContacts() ), |
1662 | actionCollection(), "edit_delete" ); | 1662 | actionCollection(), "edit_delete" ); |
1663 | 1663 | ||
1664 | mActionUndo->setEnabled( false ); | 1664 | mActionUndo->setEnabled( false ); |
1665 | mActionRedo->setEnabled( false ); | 1665 | mActionRedo->setEnabled( false ); |
1666 | 1666 | ||
1667 | // settings menu | 1667 | // settings menu |
1668 | #ifdef KAB_EMBEDDED | 1668 | #ifdef KAB_EMBEDDED |
1669 | //US special menuentry to configure the addressbook resources. On KDE | 1669 | //US special menuentry to configure the addressbook resources. On KDE |
1670 | // you do that through the control center !!! | 1670 | // you do that through the control center !!! |
1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1671 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1672 | SLOT( configureResources() ), actionCollection(), | 1672 | SLOT( configureResources() ), actionCollection(), |
1673 | "kaddressbook_configure_resources" ); | 1673 | "kaddressbook_configure_resources" ); |
1674 | #endif //KAB_EMBEDDED | 1674 | #endif //KAB_EMBEDDED |
1675 | 1675 | ||
1676 | if ( mIsPart ) { | 1676 | if ( mIsPart ) { |
1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1677 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1678 | SLOT( openConfigDialog() ), actionCollection(), | 1678 | SLOT( openConfigDialog() ), actionCollection(), |
1679 | "kaddressbook_configure" ); | 1679 | "kaddressbook_configure" ); |
1680 | 1680 | ||
1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1681 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1682 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1682 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1683 | "kaddressbook_configure_shortcuts" ); | 1683 | "kaddressbook_configure_shortcuts" ); |
1684 | #ifdef KAB_EMBEDDED | 1684 | #ifdef KAB_EMBEDDED |
1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1685 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1686 | mActionConfigureToolbars->setEnabled( false ); | 1686 | mActionConfigureToolbars->setEnabled( false ); |
1687 | #endif //KAB_EMBEDDED | 1687 | #endif //KAB_EMBEDDED |
1688 | 1688 | ||
1689 | } else { | 1689 | } else { |
1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1690 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1691 | 1691 | ||
1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1692 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1695 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1696 | actionCollection(), "options_show_jump_bar" ); | 1696 | actionCollection(), "options_show_jump_bar" ); |
1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1697 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1698 | 1698 | ||
1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1699 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1700 | actionCollection(), "options_show_details" ); | 1700 | actionCollection(), "options_show_details" ); |
1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1701 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1702 | 1702 | ||
1703 | // misc | 1703 | // misc |
1704 | // only enable LDAP lookup if we can handle the protocol | 1704 | // only enable LDAP lookup if we can handle the protocol |
1705 | #ifndef KAB_EMBEDDED | 1705 | #ifndef KAB_EMBEDDED |
1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1706 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1707 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1708 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1708 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1709 | "ldap_lookup" ); | 1709 | "ldap_lookup" ); |
1710 | } | 1710 | } |
1711 | #else //KAB_EMBEDDED | 1711 | #else //KAB_EMBEDDED |
1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1712 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1713 | #endif //KAB_EMBEDDED | 1713 | #endif //KAB_EMBEDDED |
1714 | 1714 | ||
1715 | 1715 | ||
1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1716 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1717 | SLOT( setWhoAmI() ), actionCollection(), | 1717 | SLOT( setWhoAmI() ), actionCollection(), |
1718 | "set_personal" ); | 1718 | "set_personal" ); |
1719 | 1719 | ||
1720 | 1720 | ||
1721 | 1721 | ||
1722 | 1722 | ||
1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1723 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1724 | SLOT( setCategories() ), actionCollection(), | 1724 | SLOT( setCategories() ), actionCollection(), |
1725 | "edit_set_categories" ); | 1725 | "edit_set_categories" ); |
1726 | 1726 | ||
1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1727 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1728 | SLOT( removeVoice() ), actionCollection(), | 1728 | SLOT( removeVoice() ), actionCollection(), |
1729 | "remove_voice" ); | 1729 | "remove_voice" ); |
1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1730 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1731 | SLOT( importFromOL() ), actionCollection(), | 1731 | SLOT( importFromOL() ), actionCollection(), |
1732 | "import_OL" ); | 1732 | "import_OL" ); |
1733 | #ifdef KAB_EMBEDDED | 1733 | #ifdef KAB_EMBEDDED |
1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1734 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1735 | this, SLOT( showLicence() ), actionCollection(), | 1735 | this, SLOT( showLicence() ), actionCollection(), |
1736 | "licence_about_data" ); | 1736 | "licence_about_data" ); |
1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1737 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1738 | this, SLOT( faq() ), actionCollection(), | 1738 | this, SLOT( faq() ), actionCollection(), |
1739 | "faq_about_data" ); | 1739 | "faq_about_data" ); |
1740 | 1740 | ||
1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1741 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1742 | this, SLOT( createAboutData() ), actionCollection(), | 1742 | this, SLOT( createAboutData() ), actionCollection(), |
1743 | "kaddressbook_about_data" ); | 1743 | "kaddressbook_about_data" ); |
1744 | #endif //KAB_EMBEDDED | 1744 | #endif //KAB_EMBEDDED |
1745 | 1745 | ||
1746 | clipboardDataChanged(); | 1746 | clipboardDataChanged(); |
1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1747 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1748 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1749 | } | 1749 | } |
1750 | 1750 | ||
1751 | //US we need this function, to plug all actions into the correct menues. | 1751 | //US we need this function, to plug all actions into the correct menues. |
1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1752 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1753 | void KABCore::addActionsManually() | 1753 | void KABCore::addActionsManually() |
1754 | { | 1754 | { |
1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1755 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1756 | 1756 | ||
1757 | #ifdef KAB_EMBEDDED | 1757 | #ifdef KAB_EMBEDDED |
1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1758 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1759 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1759 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1760 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1761 | 1761 | ||
1762 | KToolBar* tb = mMainWindow->toolBar(); | 1762 | KToolBar* tb = mMainWindow->toolBar(); |
1763 | 1763 | ||
1764 | #ifdef DESKTOP_VERSION | 1764 | #ifdef DESKTOP_VERSION |
1765 | QMenuBar* mb = mMainWindow->menuBar(); | 1765 | QMenuBar* mb = mMainWindow->menuBar(); |
1766 | 1766 | ||
1767 | //US setup menubar. | 1767 | //US setup menubar. |
1768 | //Disable the following block if you do not want to have a menubar. | 1768 | //Disable the following block if you do not want to have a menubar. |
1769 | mb->insertItem( "&File", fileMenu ); | 1769 | mb->insertItem( "&File", fileMenu ); |
1770 | mb->insertItem( "&Edit", editMenu ); | 1770 | mb->insertItem( "&Edit", editMenu ); |
1771 | mb->insertItem( "&View", viewMenu ); | 1771 | mb->insertItem( "&View", viewMenu ); |
1772 | mb->insertItem( "&Settings", settingsMenu ); | 1772 | mb->insertItem( "&Settings", settingsMenu ); |
1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1773 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1774 | mb->insertItem( "&Change selected", changeMenu ); | 1774 | mb->insertItem( "&Change selected", changeMenu ); |
1775 | mb->insertItem( "&Help", helpMenu ); | 1775 | mb->insertItem( "&Help", helpMenu ); |
1776 | mIncSearchWidget = new IncSearchWidget( tb ); | 1776 | mIncSearchWidget = new IncSearchWidget( tb ); |
1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1777 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1778 | 1778 | ||
1779 | #else | 1779 | #else |
1780 | //US setup toolbar | 1780 | //US setup toolbar |
1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1781 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1782 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1783 | menuBarTB->insertItem( "ME", popupBarTB); | 1783 | menuBarTB->insertItem( "ME", popupBarTB); |
1784 | tb->insertWidget(-1, 0, menuBarTB); | 1784 | tb->insertWidget(-1, 0, menuBarTB); |
1785 | mIncSearchWidget = new IncSearchWidget( tb ); | 1785 | mIncSearchWidget = new IncSearchWidget( tb ); |
1786 | 1786 | ||
1787 | tb->enableMoving(false); | 1787 | tb->enableMoving(false); |
1788 | popupBarTB->insertItem( "&File", fileMenu ); | 1788 | popupBarTB->insertItem( "&File", fileMenu ); |
1789 | popupBarTB->insertItem( "&Edit", editMenu ); | 1789 | popupBarTB->insertItem( "&Edit", editMenu ); |
1790 | popupBarTB->insertItem( "&View", viewMenu ); | 1790 | popupBarTB->insertItem( "&View", viewMenu ); |
1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1791 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1792 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1793 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1793 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1794 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1795 | popupBarTB->insertItem( "&Help", helpMenu ); | 1795 | popupBarTB->insertItem( "&Help", helpMenu ); |
1796 | if (QApplication::desktop()->width() > 320 ) { | 1796 | if (QApplication::desktop()->width() > 320 ) { |
1797 | // mViewManager->getFilterAction()->plug ( tb); | 1797 | // mViewManager->getFilterAction()->plug ( tb); |
1798 | } | 1798 | } |
1799 | #endif | 1799 | #endif |
1800 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1800 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1801 | 1801 | ||
1802 | 1802 | ||
1803 | 1803 | ||
1804 | //US Now connect the actions with the menue entries. | 1804 | //US Now connect the actions with the menue entries. |
1805 | mActionPrint->plug( fileMenu ); | 1805 | mActionPrint->plug( fileMenu ); |
1806 | mActionMail->plug( fileMenu ); | 1806 | mActionMail->plug( fileMenu ); |
1807 | fileMenu->insertSeparator(); | 1807 | fileMenu->insertSeparator(); |
1808 | 1808 | ||
1809 | mActionNewContact->plug( fileMenu ); | 1809 | mActionNewContact->plug( fileMenu ); |
1810 | mActionNewContact->plug( tb ); | 1810 | mActionNewContact->plug( tb ); |
1811 | 1811 | ||
1812 | mActionEditAddressee->plug( fileMenu ); | 1812 | mActionEditAddressee->plug( fileMenu ); |
1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1813 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1814 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1815 | mActionEditAddressee->plug( tb ); | 1815 | mActionEditAddressee->plug( tb ); |
1816 | 1816 | ||
1817 | fileMenu->insertSeparator(); | 1817 | fileMenu->insertSeparator(); |
1818 | mActionSave->plug( fileMenu ); | 1818 | mActionSave->plug( fileMenu ); |
1819 | fileMenu->insertItem( "&Import", ImportMenu ); | 1819 | fileMenu->insertItem( "&Import", ImportMenu ); |
1820 | fileMenu->insertItem( "&Export", ExportMenu ); | 1820 | fileMenu->insertItem( "&Export", ExportMenu ); |
1821 | fileMenu->insertSeparator(); | 1821 | fileMenu->insertSeparator(); |
1822 | mActionMailVCard->plug( fileMenu ); | 1822 | mActionMailVCard->plug( fileMenu ); |
1823 | #ifndef DESKTOP_VERSION | 1823 | #ifndef DESKTOP_VERSION |
1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1824 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1825 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1826 | #endif | 1826 | #endif |
1827 | fileMenu->insertSeparator(); | 1827 | fileMenu->insertSeparator(); |
1828 | mActionQuit->plug( fileMenu ); | 1828 | mActionQuit->plug( fileMenu ); |
1829 | #ifdef _WIN32_ | 1829 | #ifdef _WIN32_ |
1830 | mActionImportOL->plug( ImportMenu ); | 1830 | mActionImportOL->plug( ImportMenu ); |
1831 | #endif | 1831 | #endif |
1832 | // edit menu | 1832 | // edit menu |
1833 | mActionUndo->plug( editMenu ); | 1833 | mActionUndo->plug( editMenu ); |
1834 | mActionRedo->plug( editMenu ); | 1834 | mActionRedo->plug( editMenu ); |
1835 | editMenu->insertSeparator(); | 1835 | editMenu->insertSeparator(); |
1836 | mActionCut->plug( editMenu ); | 1836 | mActionCut->plug( editMenu ); |
1837 | mActionCopy->plug( editMenu ); | 1837 | mActionCopy->plug( editMenu ); |
1838 | mActionPaste->plug( editMenu ); | 1838 | mActionPaste->plug( editMenu ); |
1839 | mActionDelete->plug( editMenu ); | 1839 | mActionDelete->plug( editMenu ); |
1840 | editMenu->insertSeparator(); | 1840 | editMenu->insertSeparator(); |
1841 | mActionSelectAll->plug( editMenu ); | 1841 | mActionSelectAll->plug( editMenu ); |
1842 | 1842 | ||
1843 | mActionRemoveVoice->plug( changeMenu ); | 1843 | mActionRemoveVoice->plug( changeMenu ); |
1844 | // settings menu | 1844 | // settings menu |
1845 | //US special menuentry to configure the addressbook resources. On KDE | 1845 | //US special menuentry to configure the addressbook resources. On KDE |
1846 | // you do that through the control center !!! | 1846 | // you do that through the control center !!! |
1847 | mActionConfigResources->plug( settingsMenu ); | 1847 | mActionConfigResources->plug( settingsMenu ); |
1848 | settingsMenu->insertSeparator(); | 1848 | settingsMenu->insertSeparator(); |
1849 | 1849 | ||
1850 | mActionConfigKAddressbook->plug( settingsMenu ); | 1850 | mActionConfigKAddressbook->plug( settingsMenu ); |
1851 | 1851 | ||
1852 | if ( mIsPart ) { | 1852 | if ( mIsPart ) { |
1853 | mActionConfigShortcuts->plug( settingsMenu ); | 1853 | mActionConfigShortcuts->plug( settingsMenu ); |
1854 | mActionConfigureToolbars->plug( settingsMenu ); | 1854 | mActionConfigureToolbars->plug( settingsMenu ); |
1855 | 1855 | ||
1856 | } else { | 1856 | } else { |
1857 | mActionKeyBindings->plug( settingsMenu ); | 1857 | mActionKeyBindings->plug( settingsMenu ); |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | settingsMenu->insertSeparator(); | 1860 | settingsMenu->insertSeparator(); |
1861 | 1861 | ||
1862 | mActionJumpBar->plug( settingsMenu ); | 1862 | mActionJumpBar->plug( settingsMenu ); |
1863 | mActionDetails->plug( settingsMenu ); | 1863 | mActionDetails->plug( settingsMenu ); |
1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1864 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1865 | mActionDetails->plug( tb ); | 1865 | mActionDetails->plug( tb ); |
1866 | settingsMenu->insertSeparator(); | 1866 | settingsMenu->insertSeparator(); |
1867 | 1867 | ||
1868 | mActionWhoAmI->plug( settingsMenu ); | 1868 | mActionWhoAmI->plug( settingsMenu ); |
1869 | mActionCategories->plug( settingsMenu ); | 1869 | mActionCategories->plug( settingsMenu ); |
1870 | 1870 | ||
1871 | mActionLicence->plug( helpMenu ); | 1871 | mActionLicence->plug( helpMenu ); |
1872 | mActionFaq->plug( helpMenu ); | 1872 | mActionFaq->plug( helpMenu ); |
1873 | mActionAboutKAddressbook->plug( helpMenu ); | 1873 | mActionAboutKAddressbook->plug( helpMenu ); |
1874 | 1874 | ||
1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1875 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1876 | 1876 | ||
1877 | mActionSave->plug( tb ); | 1877 | mActionSave->plug( tb ); |
1878 | mViewManager->getFilterAction()->plug ( tb); | 1878 | mViewManager->getFilterAction()->plug ( tb); |
1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1879 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1880 | mActionUndo->plug( tb ); | 1880 | mActionUndo->plug( tb ); |
1881 | mActionDelete->plug( tb ); | 1881 | mActionDelete->plug( tb ); |
1882 | mActionRedo->plug( tb ); | 1882 | mActionRedo->plug( tb ); |
1883 | } | 1883 | } |
1884 | } | 1884 | } |
1885 | //mActionQuit->plug ( tb ); | 1885 | //mActionQuit->plug ( tb ); |
1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1886 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1887 | 1887 | ||
1888 | //US link the searchwidget first to this. | 1888 | //US link the searchwidget first to this. |
1889 | // The real linkage to the toolbar happens later. | 1889 | // The real linkage to the toolbar happens later. |
1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1890 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1891 | //US tb->insertItem( mIncSearchWidget ); | 1891 | //US tb->insertItem( mIncSearchWidget ); |
1892 | /*US | 1892 | /*US |
1893 | mIncSearchWidget = new IncSearchWidget( tb ); | 1893 | mIncSearchWidget = new IncSearchWidget( tb ); |
1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1894 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1895 | SLOT( incrementalSearch( const QString& ) ) ); | 1895 | SLOT( incrementalSearch( const QString& ) ) ); |
1896 | 1896 | ||
1897 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1897 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1898 | 1898 | ||
1899 | //US topLayout->addWidget( mJumpButtonBar ); | 1899 | //US topLayout->addWidget( mJumpButtonBar ); |
1900 | this->layout()->add( mJumpButtonBar ); | 1900 | this->layout()->add( mJumpButtonBar ); |
1901 | */ | 1901 | */ |
1902 | 1902 | ||
1903 | #endif //KAB_EMBEDDED | 1903 | #endif //KAB_EMBEDDED |
1904 | 1904 | ||
1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 1905 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
1906 | fillSyncMenu(); | 1906 | fillSyncMenu(); |
1907 | 1907 | ||
1908 | } | 1908 | } |
1909 | void KABCore::showLicence() | 1909 | void KABCore::showLicence() |
1910 | { | 1910 | { |
1911 | KApplication::showLicence(); | 1911 | KApplication::showLicence(); |
1912 | } | 1912 | } |
1913 | void KABCore::removeVoice() | 1913 | void KABCore::removeVoice() |
1914 | { | 1914 | { |
1915 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) | 1915 | if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) |
1916 | return; | 1916 | return; |
1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1917 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1918 | KABC::Addressee::List::Iterator it; | 1918 | KABC::Addressee::List::Iterator it; |
1919 | for ( it = list.begin(); it != list.end(); ++it ) { | 1919 | for ( it = list.begin(); it != list.end(); ++it ) { |
1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1920 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1921 | PhoneNumber::List::Iterator phoneIt; | 1921 | PhoneNumber::List::Iterator phoneIt; |
1922 | bool found = false; | 1922 | bool found = false; |
1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1923 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1924 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1925 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1926 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1927 | (*it).insertPhoneNumber( (*phoneIt) ); | 1927 | (*it).insertPhoneNumber( (*phoneIt) ); |
1928 | found = true; | 1928 | found = true; |
1929 | } | 1929 | } |
1930 | } | 1930 | } |
1931 | 1931 | ||
1932 | } | 1932 | } |
1933 | if ( found ) | 1933 | if ( found ) |
1934 | contactModified((*it) ); | 1934 | contactModified((*it) ); |
1935 | } | 1935 | } |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | 1938 | ||
1939 | 1939 | ||
1940 | void KABCore::clipboardDataChanged() | 1940 | void KABCore::clipboardDataChanged() |
1941 | { | 1941 | { |
1942 | 1942 | ||
1943 | if ( mReadWrite ) | 1943 | if ( mReadWrite ) |
1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1944 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1945 | 1945 | ||
1946 | } | 1946 | } |
1947 | 1947 | ||
1948 | void KABCore::updateActionMenu() | 1948 | void KABCore::updateActionMenu() |
1949 | { | 1949 | { |
1950 | UndoStack *undo = UndoStack::instance(); | 1950 | UndoStack *undo = UndoStack::instance(); |
1951 | RedoStack *redo = RedoStack::instance(); | 1951 | RedoStack *redo = RedoStack::instance(); |
1952 | 1952 | ||
1953 | if ( undo->isEmpty() ) | 1953 | if ( undo->isEmpty() ) |
1954 | mActionUndo->setText( i18n( "Undo" ) ); | 1954 | mActionUndo->setText( i18n( "Undo" ) ); |
1955 | else | 1955 | else |
1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1956 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1957 | 1957 | ||
1958 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1958 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1959 | 1959 | ||
1960 | if ( !redo->top() ) | 1960 | if ( !redo->top() ) |
1961 | mActionRedo->setText( i18n( "Redo" ) ); | 1961 | mActionRedo->setText( i18n( "Redo" ) ); |
1962 | else | 1962 | else |
1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1963 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1964 | 1964 | ||
1965 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1965 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void KABCore::configureKeyBindings() | 1968 | void KABCore::configureKeyBindings() |
1969 | { | 1969 | { |
1970 | #ifndef KAB_EMBEDDED | 1970 | #ifndef KAB_EMBEDDED |
1971 | KKeyDialog::configure( actionCollection(), true ); | 1971 | KKeyDialog::configure( actionCollection(), true ); |
1972 | #else //KAB_EMBEDDED | 1972 | #else //KAB_EMBEDDED |
1973 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1973 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1974 | #endif //KAB_EMBEDDED | 1974 | #endif //KAB_EMBEDDED |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | #ifdef KAB_EMBEDDED | 1977 | #ifdef KAB_EMBEDDED |
1978 | void KABCore::configureResources() | 1978 | void KABCore::configureResources() |
1979 | { | 1979 | { |
1980 | KRES::KCMKResources dlg( this, "" , 0 ); | 1980 | KRES::KCMKResources dlg( this, "" , 0 ); |
1981 | 1981 | ||
1982 | if ( !dlg.exec() ) | 1982 | if ( !dlg.exec() ) |
1983 | return; | 1983 | return; |
1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1984 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1985 | } | 1985 | } |
1986 | #endif //KAB_EMBEDDED | 1986 | #endif //KAB_EMBEDDED |
1987 | 1987 | ||
1988 | 1988 | ||
1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1989 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1990 | * for the attendees list of an event. | 1990 | * for the attendees list of an event. |
1991 | */ | 1991 | */ |
1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1992 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1993 | { | 1993 | { |
1994 | QStringList nameList; | 1994 | QStringList nameList; |
1995 | QStringList emailList; | 1995 | QStringList emailList; |
1996 | QStringList uidList; | 1996 | QStringList uidList; |
1997 | 1997 | ||
1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1998 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
1999 | uint i=0; | 1999 | uint i=0; |
2000 | for (i=0; i < list.count(); i++) | 2000 | for (i=0; i < list.count(); i++) |
2001 | { | 2001 | { |
2002 | nameList.append(list[i].realName()); | 2002 | nameList.append(list[i].realName()); |
2003 | emailList.append(list[i].preferredEmail()); | 2003 | emailList.append(list[i].preferredEmail()); |
2004 | uidList.append(list[i].uid()); | 2004 | uidList.append(list[i].uid()); |
2005 | } | 2005 | } |
2006 | 2006 | ||
2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2007 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2008 | 2008 | ||
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2011 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2012 | */ | 2012 | */ |
2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2013 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2014 | { | 2014 | { |
2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2015 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2016 | 2016 | ||
2017 | QString foundUid = QString::null; | 2017 | QString foundUid = QString::null; |
2018 | if ( ! uid.isEmpty() ) { | 2018 | if ( ! uid.isEmpty() ) { |
2019 | Addressee adrr = mAddressBook->findByUid( uid ); | 2019 | Addressee adrr = mAddressBook->findByUid( uid ); |
2020 | if ( !adrr.isEmpty() ) { | 2020 | if ( !adrr.isEmpty() ) { |
2021 | foundUid = uid; | 2021 | foundUid = uid; |
2022 | } | 2022 | } |
2023 | if ( email == "sendbacklist" ) { | 2023 | if ( email == "sendbacklist" ) { |
2024 | //qDebug("ssssssssssssssssssssssend "); | 2024 | //qDebug("ssssssssssssssssssssssend "); |
2025 | QStringList nameList; | 2025 | QStringList nameList; |
2026 | QStringList emailList; | 2026 | QStringList emailList; |
2027 | QStringList uidList; | 2027 | QStringList uidList; |
2028 | nameList.append(adrr.realName()); | 2028 | nameList.append(adrr.realName()); |
2029 | emailList = adrr.emails(); | 2029 | emailList = adrr.emails(); |
2030 | uidList.append( adrr.preferredEmail()); | 2030 | uidList.append( adrr.preferredEmail()); |
2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2031 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2032 | return; | 2032 | return; |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | } | 2035 | } |
2036 | 2036 | ||
2037 | if ( email == "sendbacklist" ) | 2037 | if ( email == "sendbacklist" ) |
2038 | return; | 2038 | return; |
2039 | if (foundUid.isEmpty()) | 2039 | if (foundUid.isEmpty()) |
2040 | { | 2040 | { |
2041 | //find the uid of the person first | 2041 | //find the uid of the person first |
2042 | Addressee::List namelist; | 2042 | Addressee::List namelist; |
2043 | Addressee::List emaillist; | 2043 | Addressee::List emaillist; |
2044 | 2044 | ||
2045 | if (!name.isEmpty()) | 2045 | if (!name.isEmpty()) |
2046 | namelist = mAddressBook->findByName( name ); | 2046 | namelist = mAddressBook->findByName( name ); |
2047 | 2047 | ||
2048 | if (!email.isEmpty()) | 2048 | if (!email.isEmpty()) |
2049 | emaillist = mAddressBook->findByEmail( email ); | 2049 | emaillist = mAddressBook->findByEmail( email ); |
2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2050 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2051 | //check if we have a match in Namelist and Emaillist | 2051 | //check if we have a match in Namelist and Emaillist |
2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2052 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2053 | foundUid = emaillist[0].uid(); | 2053 | foundUid = emaillist[0].uid(); |
2054 | } | 2054 | } |
2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2055 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2056 | foundUid = namelist[0].uid(); | 2056 | foundUid = namelist[0].uid(); |
2057 | else | 2057 | else |
2058 | { | 2058 | { |
2059 | for (int i = 0; i < namelist.count(); i++) | 2059 | for (int i = 0; i < namelist.count(); i++) |
2060 | { | 2060 | { |
2061 | for (int j = 0; j < emaillist.count(); j++) | 2061 | for (int j = 0; j < emaillist.count(); j++) |
2062 | { | 2062 | { |
2063 | if (namelist[i] == emaillist[j]) | 2063 | if (namelist[i] == emaillist[j]) |
2064 | { | 2064 | { |
2065 | foundUid = namelist[i].uid(); | 2065 | foundUid = namelist[i].uid(); |
2066 | } | 2066 | } |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
2069 | } | 2069 | } |
2070 | } | 2070 | } |
2071 | else | 2071 | else |
2072 | { | 2072 | { |
2073 | foundUid = uid; | 2073 | foundUid = uid; |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | if (!foundUid.isEmpty()) | 2076 | if (!foundUid.isEmpty()) |
2077 | { | 2077 | { |
2078 | 2078 | ||
2079 | // raise Ka/Pi if it is in the background | 2079 | // raise Ka/Pi if it is in the background |
2080 | #ifndef DESKTOP_VERSION | 2080 | #ifndef DESKTOP_VERSION |
2081 | #ifndef KORG_NODCOP | 2081 | #ifndef KORG_NODCOP |
2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2082 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2083 | #endif | 2083 | #endif |
2084 | #endif | 2084 | #endif |
2085 | 2085 | ||
2086 | mMainWindow->showMaximized(); | 2086 | mMainWindow->showMaximized(); |
2087 | mMainWindow-> raise(); | 2087 | mMainWindow-> raise(); |
2088 | 2088 | ||
2089 | mViewManager->setSelected( "", false); | 2089 | mViewManager->setSelected( "", false); |
2090 | mViewManager->refreshView( "" ); | 2090 | mViewManager->refreshView( "" ); |
2091 | mViewManager->setSelected( foundUid, true ); | 2091 | mViewManager->setSelected( foundUid, true ); |
2092 | mViewManager->refreshView( foundUid ); | 2092 | mViewManager->refreshView( foundUid ); |
2093 | 2093 | ||
2094 | if ( !mMultipleViewsAtOnce ) | 2094 | if ( !mMultipleViewsAtOnce ) |
2095 | { | 2095 | { |
2096 | setDetailsVisible( true ); | 2096 | setDetailsVisible( true ); |
2097 | mActionDetails->setChecked(true); | 2097 | mActionDetails->setChecked(true); |
2098 | } | 2098 | } |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | 2102 | ||
2103 | void KABCore::faq() | 2103 | void KABCore::faq() |
2104 | { | 2104 | { |
2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2105 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | 2108 | ||
2109 | void KABCore::fillSyncMenu() | 2109 | void KABCore::fillSyncMenu() |
2110 | { | 2110 | { |
2111 | if ( syncMenu->count() ) | 2111 | if ( syncMenu->count() ) |
2112 | syncMenu->clear(); | 2112 | syncMenu->clear(); |
2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 2113 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
2114 | syncMenu->insertSeparator(); | 2114 | syncMenu->insertSeparator(); |
2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 2115 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
2116 | syncMenu->insertSeparator(); | 2116 | syncMenu->insertSeparator(); |
2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2117 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2118 | config.setGroup("General"); | 2118 | config.setGroup("General"); |
2119 | QStringList prof = config.readListEntry("SyncProfileNames"); | 2119 | QStringList prof = config.readListEntry("SyncProfileNames"); |
2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 2120 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
2121 | if ( prof.count() < 3 ) { | 2121 | if ( prof.count() < 3 ) { |
2122 | prof.clear(); | 2122 | prof.clear(); |
2123 | prof << i18n("Sharp_DTM"); | 2123 | prof << i18n("Sharp_DTM"); |
2124 | prof << i18n("Local_file"); | 2124 | prof << i18n("Local_file"); |
2125 | prof << i18n("Last_file"); | 2125 | prof << i18n("Last_file"); |
2126 | KSyncProfile* temp = new KSyncProfile (); | 2126 | KSyncProfile* temp = new KSyncProfile (); |
2127 | temp->setName( prof[0] ); | 2127 | temp->setName( prof[0] ); |
2128 | temp->writeConfig(&config); | 2128 | temp->writeConfig(&config); |
2129 | temp->setName( prof[1] ); | 2129 | temp->setName( prof[1] ); |
2130 | temp->writeConfig(&config); | 2130 | temp->writeConfig(&config); |
2131 | temp->setName( prof[2] ); | 2131 | temp->setName( prof[2] ); |
2132 | temp->writeConfig(&config); | 2132 | temp->writeConfig(&config); |
2133 | config.setGroup("General"); | 2133 | config.setGroup("General"); |
2134 | config.writeEntry("SyncProfileNames",prof); | 2134 | config.writeEntry("SyncProfileNames",prof); |
2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 2135 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
2136 | config.sync(); | 2136 | config.sync(); |
2137 | delete temp; | 2137 | delete temp; |
2138 | } | 2138 | } |
2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 2139 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
2140 | KABPrefs::instance()->mSyncProfileNames = prof; | 2140 | KABPrefs::instance()->mSyncProfileNames = prof; |
2141 | int i; | 2141 | int i; |
2142 | for ( i = 0; i < prof.count(); ++i ) { | 2142 | for ( i = 0; i < prof.count(); ++i ) { |
2143 | 2143 | ||
2144 | syncMenu->insertItem( prof[i], 1000+i ); | 2144 | syncMenu->insertItem( prof[i], 1000+i ); |
2145 | if ( i == 2 ) | 2145 | if ( i == 2 ) |
2146 | syncMenu->insertSeparator(); | 2146 | syncMenu->insertSeparator(); |
2147 | } | 2147 | } |
2148 | QDir app_dir; | 2148 | QDir app_dir; |
2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 2149 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
2150 | syncMenu->setItemEnabled( false , 1000 ); | 2150 | syncMenu->setItemEnabled( false , 1000 ); |
2151 | } | 2151 | } |
2152 | //probaly useless | 2152 | //probaly useless |
2153 | //mView->setupExternSyncProfiles(); | 2153 | //mView->setupExternSyncProfiles(); |
2154 | } | 2154 | } |
2155 | void KABCore::slotSyncMenu( int action ) | 2155 | void KABCore::slotSyncMenu( int action ) |
2156 | { | 2156 | { |
2157 | //qDebug("syncaction %d ", action); | 2157 | //qDebug("syncaction %d ", action); |
2158 | if ( action == 0 ) { | 2158 | if ( action == 0 ) { |
2159 | 2159 | ||
2160 | // seems to be a Qt2 event handling bug | 2160 | // seems to be a Qt2 event handling bug |
2161 | // syncmenu.clear causes a segfault at first time | 2161 | // syncmenu.clear causes a segfault at first time |
2162 | // when we call it after the main event loop, it is ok | 2162 | // when we call it after the main event loop, it is ok |
2163 | // same behaviour when calling OM/Pi via QCOP for the first time | 2163 | // same behaviour when calling OM/Pi via QCOP for the first time |
2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 2164 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
2165 | //confSync(); | 2165 | //confSync(); |
2166 | 2166 | ||
2167 | return; | 2167 | return; |
2168 | } | 2168 | } |
2169 | if ( action == 1 ) { | 2169 | if ( action == 1 ) { |
2170 | multiSync( true ); | 2170 | multiSync( true ); |
2171 | return; | 2171 | return; |
2172 | } | 2172 | } |
2173 | 2173 | ||
2174 | if (mBlockSaveFlag) | 2174 | if (mBlockSaveFlag) |
2175 | return; | 2175 | return; |
2176 | mBlockSaveFlag = true; | 2176 | mBlockSaveFlag = true; |
2177 | mCurrentSyncProfile = action - 1000 ; | 2177 | mCurrentSyncProfile = action - 1000 ; |
2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | 2178 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; |
2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | 2179 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; |
2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2180 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2181 | KSyncProfile* temp = new KSyncProfile (); | 2181 | KSyncProfile* temp = new KSyncProfile (); |
2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2182 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2183 | temp->readConfig(&config); | 2183 | temp->readConfig(&config); |
2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2184 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2185 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2186 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2187 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2188 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2188 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2189 | if ( temp->getWriteBackFuture() ) | 2189 | if ( temp->getWriteBackFuture() ) |
2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2190 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2191 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2192 | if ( action == 1000 ) { | 2192 | if ( action == 1000 ) { |
2193 | syncSharp(); | 2193 | syncSharp(); |
2194 | 2194 | ||
2195 | } else if ( action == 1001 ) { | 2195 | } else if ( action == 1001 ) { |
2196 | syncLocalFile(); | 2196 | syncLocalFile(); |
2197 | 2197 | ||
2198 | } else if ( action == 1002 ) { | 2198 | } else if ( action == 1002 ) { |
2199 | quickSyncLocalFile(); | 2199 | quickSyncLocalFile(); |
2200 | 2200 | ||
2201 | } else if ( action >= 1003 ) { | 2201 | } else if ( action >= 1003 ) { |
2202 | if ( temp->getIsLocalFileSync() ) { | 2202 | if ( temp->getIsLocalFileSync() ) { |
2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 2203 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2204 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2205 | } else { | 2205 | } else { |
2206 | if ( temp->getIsPhoneSync() ) { | 2206 | if ( temp->getIsPhoneSync() ) { |
2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2207 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2208 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2209 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2210 | syncPhone(); | 2210 | syncPhone(); |
2211 | } else | 2211 | } else |
2212 | syncRemote( temp ); | 2212 | syncRemote( temp ); |
2213 | 2213 | ||
2214 | } | 2214 | } |
2215 | } | 2215 | } |
2216 | delete temp; | 2216 | delete temp; |
2217 | mBlockSaveFlag = false; | 2217 | mBlockSaveFlag = false; |
2218 | } | 2218 | } |
2219 | 2219 | ||
2220 | void KABCore::syncLocalFile() | 2220 | void KABCore::syncLocalFile() |
2221 | { | 2221 | { |
2222 | 2222 | ||
2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | 2223 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; |
2224 | 2224 | ||
2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2225 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2226 | if ( fn == "" ) | 2226 | if ( fn == "" ) |
2227 | return; | 2227 | return; |
2228 | if ( syncWithFile( fn, false ) ) { | 2228 | if ( syncWithFile( fn, false ) ) { |
2229 | qDebug("syncLocalFile() successful "); | 2229 | qDebug("syncLocalFile() successful "); |
2230 | } | 2230 | } |
2231 | 2231 | ||
2232 | } | 2232 | } |
2233 | bool KABCore::syncWithFile( QString fn , bool quick ) | 2233 | bool KABCore::syncWithFile( QString fn , bool quick ) |
2234 | { | 2234 | { |
2235 | bool ret = false; | 2235 | bool ret = false; |
2236 | QFileInfo info; | 2236 | QFileInfo info; |
2237 | info.setFile( fn ); | 2237 | info.setFile( fn ); |
2238 | QString mess; | 2238 | QString mess; |
2239 | bool loadbup = true; | 2239 | bool loadbup = true; |
2240 | if ( !info. exists() ) { | 2240 | if ( !info. exists() ) { |
2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2241 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2242 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2243 | mess ); | 2243 | mess ); |
2244 | return ret; | 2244 | return ret; |
2245 | } | 2245 | } |
2246 | int result = 0; | 2246 | int result = 0; |
2247 | if ( !quick ) { | 2247 | if ( !quick ) { |
2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2248 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2249 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2250 | mess, | 2250 | mess, |
2251 | i18n("Sync"), i18n("Cancel"), 0, | 2251 | i18n("Sync"), i18n("Cancel"), 0, |
2252 | 0, 1 ); | 2252 | 0, 1 ); |
2253 | if ( result ) | 2253 | if ( result ) |
2254 | return false; | 2254 | return false; |
2255 | } | 2255 | } |
2256 | if ( KABPrefs::instance()->mAskForPreferences ) | 2256 | if ( KABPrefs::instance()->mAskForPreferences ) |
2257 | edit_sync_options(); | 2257 | edit_sync_options(); |
2258 | if ( result == 0 ) { | 2258 | if ( result == 0 ) { |
2259 | //qDebug("Now sycing ... "); | 2259 | //qDebug("Now sycing ... "); |
2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | 2260 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) |
2261 | setCaption( i18n("Synchronization successful") ); | 2261 | setCaption( i18n("Synchronization successful") ); |
2262 | else | 2262 | else |
2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2263 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2264 | if ( ! quick ) | 2264 | if ( ! quick ) |
2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | 2265 | KABPrefs::instance()->mLastSyncedLocalFile = fn; |
2266 | setModified(); | 2266 | setModified(); |
2267 | } | 2267 | } |
2268 | return ret; | 2268 | return ret; |
2269 | } | 2269 | } |
2270 | void KABCore::quickSyncLocalFile() | 2270 | void KABCore::quickSyncLocalFile() |
2271 | { | 2271 | { |
2272 | 2272 | ||
2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2273 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2274 | qDebug("quick syncLocalFile() successful "); | 2274 | qDebug("quick syncLocalFile() successful "); |
2275 | 2275 | ||
2276 | } | 2276 | } |
2277 | } | 2277 | } |
2278 | void KABCore::multiSync( bool askforPrefs ) | 2278 | void KABCore::multiSync( bool askforPrefs ) |
2279 | { | 2279 | { |
2280 | if (mBlockSaveFlag) | 2280 | if (mBlockSaveFlag) |
2281 | return; | 2281 | return; |
2282 | mBlockSaveFlag = true; | 2282 | mBlockSaveFlag = true; |
2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 2283 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2284 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2285 | question, | 2285 | question, |
2286 | i18n("Yes"), i18n("No"), | 2286 | i18n("Yes"), i18n("No"), |
2287 | 0, 0 ) != 0 ) { | 2287 | 0, 0 ) != 0 ) { |
2288 | mBlockSaveFlag = false; | 2288 | mBlockSaveFlag = false; |
2289 | setCaption(i18n("Aborted! Nothing synced!")); | 2289 | setCaption(i18n("Aborted! Nothing synced!")); |
2290 | return; | 2290 | return; |
2291 | } | 2291 | } |
2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 2292 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | 2293 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; |
2294 | if ( askforPrefs ) { | 2294 | if ( askforPrefs ) { |
2295 | edit_sync_options(); | 2295 | edit_sync_options(); |
2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | 2296 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; |
2297 | } | 2297 | } |
2298 | setCaption(i18n("Multiple sync started.") ); | 2298 | setCaption(i18n("Multiple sync started.") ); |
2299 | qApp->processEvents(); | 2299 | qApp->processEvents(); |
2300 | int num = ringSync() ; | 2300 | int num = ringSync() ; |
2301 | if ( num > 1 ) | 2301 | if ( num > 1 ) |
2302 | ringSync(); | 2302 | ringSync(); |
2303 | mBlockSaveFlag = false; | 2303 | mBlockSaveFlag = false; |
2304 | if ( num ) | 2304 | if ( num ) |
2305 | save(); | 2305 | save(); |
2306 | if ( num ) | 2306 | if ( num ) |
2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 2307 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
2308 | else | 2308 | else |
2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 2309 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
2310 | return; | 2310 | return; |
2311 | } | 2311 | } |
2312 | int KABCore::ringSync() | 2312 | int KABCore::ringSync() |
2313 | { | 2313 | { |
2314 | int syncedProfiles = 0; | 2314 | int syncedProfiles = 0; |
2315 | int i; | 2315 | int i; |
2316 | QTime timer; | 2316 | QTime timer; |
2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2317 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | 2318 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; |
2319 | KSyncProfile* temp = new KSyncProfile (); | 2319 | KSyncProfile* temp = new KSyncProfile (); |
2320 | KABPrefs::instance()->mAskForPreferences = false; | 2320 | KABPrefs::instance()->mAskForPreferences = false; |
2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 2321 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
2322 | mCurrentSyncProfile = i; | 2322 | mCurrentSyncProfile = i; |
2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 2323 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
2324 | temp->readConfig(&config); | 2324 | temp->readConfig(&config); |
2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { | 2325 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { |
2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2326 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2327 | ++syncedProfiles; | 2327 | ++syncedProfiles; |
2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2328 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2329 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2330 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2331 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2331 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2332 | if ( temp->getWriteBackFuture() ) | 2332 | if ( temp->getWriteBackFuture() ) |
2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2333 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2334 | KABPrefs::instance()->mShowSyncSummary = false; | 2334 | KABPrefs::instance()->mShowSyncSummary = false; |
2335 | mCurrentSyncDevice = syncProfileNames[i] ; | 2335 | mCurrentSyncDevice = syncProfileNames[i] ; |
2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2336 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2337 | if ( i == 0 ) { | 2337 | if ( i == 0 ) { |
2338 | syncSharp(); | 2338 | syncSharp(); |
2339 | } else { | 2339 | } else { |
2340 | if ( temp->getIsLocalFileSync() ) { | 2340 | if ( temp->getIsLocalFileSync() ) { |
2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | 2341 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2342 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2343 | } else { | 2343 | } else { |
2344 | if ( temp->getIsPhoneSync() ) { | 2344 | if ( temp->getIsPhoneSync() ) { |
2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2345 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2346 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2347 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2348 | syncPhone(); | 2348 | syncPhone(); |
2349 | } else | 2349 | } else |
2350 | syncRemote( temp, false ); | 2350 | syncRemote( temp, false ); |
2351 | 2351 | ||
2352 | } | 2352 | } |
2353 | } | 2353 | } |
2354 | timer.start(); | 2354 | timer.start(); |
2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 2355 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
2356 | while ( timer.elapsed () < 2000 ) { | 2356 | while ( timer.elapsed () < 2000 ) { |
2357 | qApp->processEvents(); | 2357 | qApp->processEvents(); |
2358 | #ifndef _WIN32_ | 2358 | #ifndef _WIN32_ |
2359 | sleep (1); | 2359 | sleep (1); |
2360 | #endif | 2360 | #endif |
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | } | 2363 | } |
2364 | 2364 | ||
2365 | } | 2365 | } |
2366 | delete temp; | 2366 | delete temp; |
2367 | return syncedProfiles; | 2367 | return syncedProfiles; |
2368 | } | 2368 | } |
2369 | 2369 | ||
2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2370 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2371 | { | 2371 | { |
2372 | QString question; | 2372 | QString question; |
2373 | if ( ask ) { | 2373 | if ( ask ) { |
2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2374 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2375 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2376 | question, | 2376 | question, |
2377 | i18n("Yes"), i18n("No"), | 2377 | i18n("Yes"), i18n("No"), |
2378 | 0, 0 ) != 0 ) | 2378 | 0, 0 ) != 0 ) |
2379 | return; | 2379 | return; |
2380 | } | 2380 | } |
2381 | QString command = prof->getPreSyncCommandAB(); | 2381 | QString command = prof->getPreSyncCommandAB(); |
2382 | int fi; | 2382 | int fi; |
2383 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2383 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2384 | QString pwd = getPassword(); | 2384 | QString pwd = getPassword(); |
2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2385 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2386 | 2386 | ||
2387 | } | 2387 | } |
2388 | int maxlen = 30; | 2388 | int maxlen = 30; |
2389 | if ( QApplication::desktop()->width() > 320 ) | 2389 | if ( QApplication::desktop()->width() > 320 ) |
2390 | maxlen += 25; | 2390 | maxlen += 25; |
2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2391 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2392 | int fileSize = 0; | 2392 | int fileSize = 0; |
2393 | int result = system ( command ); | 2393 | int result = system ( command ); |
2394 | // 0 : okay | 2394 | // 0 : okay |
2395 | // 256: no such file or dir | 2395 | // 256: no such file or dir |
2396 | // | 2396 | // |
2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2397 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2398 | if ( result != 0 ) { | 2398 | if ( result != 0 ) { |
2399 | int len = maxlen; | 2399 | int len = maxlen; |
2400 | while ( len < command.length() ) { | 2400 | while ( len < command.length() ) { |
2401 | command.insert( len , "\n" ); | 2401 | command.insert( len , "\n" ); |
2402 | len += maxlen +2; | 2402 | len += maxlen +2; |
2403 | } | 2403 | } |
2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2404 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2405 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2406 | question, | 2406 | question, |
2407 | i18n("Okay!")) ; | 2407 | i18n("Okay!")) ; |
2408 | setCaption ("KO/Pi"); | 2408 | setCaption ("KO/Pi"); |
2409 | return; | 2409 | return; |
2410 | } | 2410 | } |
2411 | setCaption ( i18n( "Copying succeed." ) ); | 2411 | setCaption ( i18n( "Copying succeed." ) ); |
2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2412 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2413 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2414 | // Event* e = mView->getLastSyncEvent(); | 2414 | // Event* e = mView->getLastSyncEvent(); |
2415 | // e->setReadOnly( false ); | 2415 | // e->setReadOnly( false ); |
2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2416 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2417 | // e->setReadOnly( true ); | 2417 | // e->setReadOnly( true ); |
2418 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2418 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2419 | command = prof->getPostSyncCommandAB(); | 2419 | command = prof->getPostSyncCommandAB(); |
2420 | int fi; | 2420 | int fi; |
2421 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2421 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2422 | QString pwd = getPassword(); | 2422 | QString pwd = getPassword(); |
2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2423 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2424 | 2424 | ||
2425 | } | 2425 | } |
2426 | setCaption ( i18n( "Writing back file ..." ) ); | 2426 | setCaption ( i18n( "Writing back file ..." ) ); |
2427 | result = system ( command ); | 2427 | result = system ( command ); |
2428 | qDebug("KO: Writing back file result: %d ", result); | 2428 | qDebug("KO: Writing back file result: %d ", result); |
2429 | if ( result != 0 ) { | 2429 | if ( result != 0 ) { |
2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2430 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2431 | return; | 2431 | return; |
2432 | } else { | 2432 | } else { |
2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2433 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2434 | } | 2434 | } |
2435 | } | 2435 | } |
2436 | } | 2436 | } |
2437 | return; | 2437 | return; |
2438 | } | 2438 | } |
2439 | #include <qpushbutton.h> | 2439 | #include <qpushbutton.h> |
2440 | #include <qradiobutton.h> | 2440 | #include <qradiobutton.h> |
2441 | #include <qbuttongroup.h> | 2441 | #include <qbuttongroup.h> |
2442 | void KABCore::edit_sync_options() | 2442 | void KABCore::edit_sync_options() |
2443 | { | 2443 | { |
2444 | //mDialogManager->showSyncOptions(); | 2444 | //mDialogManager->showSyncOptions(); |
2445 | //KABPrefs::instance()->mSyncAlgoPrefs | 2445 | //KABPrefs::instance()->mSyncAlgoPrefs |
2446 | QDialog dia( this, "dia", true ); | 2446 | QDialog dia( this, "dia", true ); |
2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2447 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2448 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2449 | QVBoxLayout lay ( &dia ); | 2449 | QVBoxLayout lay ( &dia ); |
2450 | lay.setSpacing( 2 ); | 2450 | lay.setSpacing( 2 ); |
2451 | lay.setMargin( 3 ); | 2451 | lay.setMargin( 3 ); |
2452 | lay.addWidget(&gr); | 2452 | lay.addWidget(&gr); |
2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2453 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2454 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2455 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2456 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2457 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2458 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2459 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2460 | QPushButton pb ( "OK", &dia); | 2460 | QPushButton pb ( "OK", &dia); |
2461 | lay.addWidget( &pb ); | 2461 | lay.addWidget( &pb ); |
2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2462 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2463 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2464 | case 0: | 2464 | case 0: |
2465 | loc.setChecked( true); | 2465 | loc.setChecked( true); |
2466 | break; | 2466 | break; |
2467 | case 1: | 2467 | case 1: |
2468 | rem.setChecked( true ); | 2468 | rem.setChecked( true ); |
2469 | break; | 2469 | break; |
2470 | case 2: | 2470 | case 2: |
2471 | newest.setChecked( true); | 2471 | newest.setChecked( true); |
2472 | break; | 2472 | break; |
2473 | case 3: | 2473 | case 3: |
2474 | ask.setChecked( true); | 2474 | ask.setChecked( true); |
2475 | break; | 2475 | break; |
2476 | case 4: | 2476 | case 4: |
2477 | f_loc.setChecked( true); | 2477 | f_loc.setChecked( true); |
2478 | break; | 2478 | break; |
2479 | case 5: | 2479 | case 5: |
2480 | f_rem.setChecked( true); | 2480 | f_rem.setChecked( true); |
2481 | break; | 2481 | break; |
2482 | case 6: | 2482 | case 6: |
2483 | // both.setChecked( true); | 2483 | // both.setChecked( true); |
2484 | break; | 2484 | break; |
2485 | default: | 2485 | default: |
2486 | break; | 2486 | break; |
2487 | } | 2487 | } |
2488 | if ( dia.exec() ) { | 2488 | if ( dia.exec() ) { |
2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2489 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2490 | } | 2490 | } |
2491 | 2491 | ||
2492 | 2492 | ||
2493 | } | 2493 | } |
2494 | QString KABCore::getPassword( ) | 2494 | QString KABCore::getPassword( ) |
2495 | { | 2495 | { |
2496 | QString retfile = ""; | 2496 | QString retfile = ""; |
2497 | QDialog dia ( this, "input-dialog", true ); | 2497 | QDialog dia ( this, "input-dialog", true ); |
2498 | QLineEdit lab ( &dia ); | 2498 | QLineEdit lab ( &dia ); |
2499 | lab.setEchoMode( QLineEdit::Password ); | 2499 | lab.setEchoMode( QLineEdit::Password ); |
2500 | QVBoxLayout lay( &dia ); | 2500 | QVBoxLayout lay( &dia ); |
2501 | lay.setMargin(7); | 2501 | lay.setMargin(7); |
2502 | lay.setSpacing(7); | 2502 | lay.setSpacing(7); |
2503 | lay.addWidget( &lab); | 2503 | lay.addWidget( &lab); |
2504 | dia.setFixedSize( 230,50 ); | 2504 | dia.setFixedSize( 230,50 ); |
2505 | dia.setCaption( i18n("Enter password") ); | 2505 | dia.setCaption( i18n("Enter password") ); |
2506 | QPushButton pb ( "OK", &dia); | 2506 | QPushButton pb ( "OK", &dia); |
2507 | lay.addWidget( &pb ); | 2507 | lay.addWidget( &pb ); |
2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2508 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2509 | dia.show(); | 2509 | dia.show(); |
2510 | int res = dia.exec(); | 2510 | int res = dia.exec(); |
2511 | if ( res ) | 2511 | if ( res ) |
2512 | retfile = lab.text(); | 2512 | retfile = lab.text(); |
2513 | dia.hide(); | 2513 | dia.hide(); |
2514 | qApp->processEvents(); | 2514 | qApp->processEvents(); |
2515 | return retfile; | 2515 | return retfile; |
2516 | 2516 | ||
2517 | } | 2517 | } |
2518 | #include <libkcal/syncdefines.h> | 2518 | #include <libkcal/syncdefines.h> |
2519 | 2519 | ||
2520 | KABC::Addressee KABCore::getLastSyncAddressee() | 2520 | KABC::Addressee KABCore::getLastSyncAddressee() |
2521 | { | 2521 | { |
2522 | Addressee lse; | 2522 | Addressee lse; |
2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2523 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2524 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2525 | if (lse.isEmpty()) { | 2525 | if (lse.isEmpty()) { |
2526 | qDebug("Creating new last-syncAddressee "); | 2526 | qDebug("Creating new last-syncAddressee "); |
2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2527 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2528 | QString sum = ""; | 2528 | QString sum = ""; |
2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2529 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2530 | sum = "E: "; | 2530 | sum = "E: "; |
2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2531 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2532 | lse.setRevision( mLastAddressbookSync ); | 2532 | lse.setRevision( mLastAddressbookSync ); |
2533 | lse.setCategories( i18n("SyncEvent") ); | 2533 | lse.setCategories( i18n("SyncEvent") ); |
2534 | mAddressBook->insertAddressee( lse ); | 2534 | mAddressBook->insertAddressee( lse ); |
2535 | } | 2535 | } |
2536 | return lse; | 2536 | return lse; |
2537 | } | 2537 | } |
2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2538 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2539 | { | 2539 | { |
2540 | 2540 | ||
2541 | //void setZaurusId(int id); | 2541 | //void setZaurusId(int id); |
2542 | // int zaurusId() const; | 2542 | // int zaurusId() const; |
2543 | // void setZaurusUid(int id); | 2543 | // void setZaurusUid(int id); |
2544 | // int zaurusUid() const; | 2544 | // int zaurusUid() const; |
2545 | // void setZaurusStat(int id); | 2545 | // void setZaurusStat(int id); |
2546 | // int zaurusStat() const; | 2546 | // int zaurusStat() const; |
2547 | // 0 equal | 2547 | // 0 equal |
2548 | // 1 take local | 2548 | // 1 take local |
2549 | // 2 take remote | 2549 | // 2 take remote |
2550 | // 3 cancel | 2550 | // 3 cancel |
2551 | QDateTime lastSync = mLastAddressbookSync; | 2551 | QDateTime lastSync = mLastAddressbookSync; |
2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2552 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2553 | bool remCh, locCh; | 2553 | bool remCh, locCh; |
2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2554 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2555 | 2555 | ||
2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2556 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2557 | locCh = ( local->revision() > mLastAddressbookSync ); | 2557 | locCh = ( local->revision() > mLastAddressbookSync ); |
2558 | if ( !remCh && ! locCh ) { | 2558 | if ( !remCh && ! locCh ) { |
2559 | //qDebug("both not changed "); | 2559 | //qDebug("both not changed "); |
2560 | lastSync = local->revision().addDays(1); | 2560 | lastSync = local->revision().addDays(1); |
2561 | if ( mode <= SYNC_PREF_ASK ) | 2561 | if ( mode <= SYNC_PREF_ASK ) |
2562 | return 0; | 2562 | return 0; |
2563 | } else { | 2563 | } else { |
2564 | if ( locCh ) { | 2564 | if ( locCh ) { |
2565 | //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2565 | //qDebug("loc changed %s %s", local->revision().toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2566 | lastSync = local->revision().addDays( -1 ); | 2566 | lastSync = local->revision().addDays( -1 ); |
2567 | if ( !remCh ) | 2567 | if ( !remCh ) |
2568 | remote->setRevision( lastSync.addDays( -1 ) ); | 2568 | remote->setRevision( lastSync.addDays( -1 ) ); |
2569 | } else { | 2569 | } else { |
2570 | //qDebug(" not loc changed "); | 2570 | //qDebug(" not loc changed "); |
2571 | lastSync = local->revision().addDays( 1 ); | 2571 | lastSync = local->revision().addDays( 1 ); |
2572 | if ( remCh ) | 2572 | if ( remCh ) |
2573 | remote->setRevision( lastSync.addDays( 1 ) ); | 2573 | remote->setRevision( lastSync.addDays( 1 ) ); |
2574 | 2574 | ||
2575 | } | 2575 | } |
2576 | } | 2576 | } |
2577 | full = true; | 2577 | full = true; |
2578 | if ( mode < SYNC_PREF_ASK ) | 2578 | if ( mode < SYNC_PREF_ASK ) |
2579 | mode = SYNC_PREF_ASK; | 2579 | mode = SYNC_PREF_ASK; |
2580 | } else { | 2580 | } else { |
2581 | if ( local->revision() == remote->revision() ) | 2581 | if ( local->revision() == remote->revision() ) |
2582 | return 0; | 2582 | return 0; |
2583 | 2583 | ||
2584 | } | 2584 | } |
2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2585 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2586 | 2586 | ||
2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 2587 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2588 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2589 | //full = true; //debug only | 2589 | //full = true; //debug only |
2590 | if ( full ) { | 2590 | if ( full ) { |
2591 | bool equ = ( (*local) == (*remote) ); | 2591 | bool equ = ( (*local) == (*remote) ); |
2592 | if ( equ ) { | 2592 | if ( equ ) { |
2593 | //qDebug("equal "); | 2593 | //qDebug("equal "); |
2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2594 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2595 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2596 | } | 2596 | } |
2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2597 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2598 | return 0; | 2598 | return 0; |
2599 | 2599 | ||
2600 | }//else //debug only | 2600 | }//else //debug only |
2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2601 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2602 | } | 2602 | } |
2603 | int result; | 2603 | int result; |
2604 | bool localIsNew; | 2604 | bool localIsNew; |
2605 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 2605 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); |
2606 | 2606 | ||
2607 | if ( full && mode < SYNC_PREF_NEWEST ) | 2607 | if ( full && mode < SYNC_PREF_NEWEST ) |
2608 | mode = SYNC_PREF_ASK; | 2608 | mode = SYNC_PREF_ASK; |
2609 | 2609 | ||
2610 | switch( mode ) { | 2610 | switch( mode ) { |
2611 | case SYNC_PREF_LOCAL: | 2611 | case SYNC_PREF_LOCAL: |
2612 | if ( lastSync > remote->revision() ) | 2612 | if ( lastSync > remote->revision() ) |
2613 | return 1; | 2613 | return 1; |
2614 | if ( lastSync > local->revision() ) | 2614 | if ( lastSync > local->revision() ) |
2615 | return 2; | 2615 | return 2; |
2616 | return 1; | 2616 | return 1; |
2617 | break; | 2617 | break; |
2618 | case SYNC_PREF_REMOTE: | 2618 | case SYNC_PREF_REMOTE: |
2619 | if ( lastSync > remote->revision() ) | 2619 | if ( lastSync > remote->revision() ) |
2620 | return 1; | 2620 | return 1; |
2621 | if ( lastSync > local->revision() ) | 2621 | if ( lastSync > local->revision() ) |
2622 | return 2; | 2622 | return 2; |
2623 | return 2; | 2623 | return 2; |
2624 | break; | 2624 | break; |
2625 | case SYNC_PREF_NEWEST: | 2625 | case SYNC_PREF_NEWEST: |
2626 | if ( local->revision() > remote->revision() ) | 2626 | if ( local->revision() > remote->revision() ) |
2627 | return 1; | 2627 | return 1; |
2628 | else | 2628 | else |
2629 | return 2; | 2629 | return 2; |
2630 | break; | 2630 | break; |
2631 | case SYNC_PREF_ASK: | 2631 | case SYNC_PREF_ASK: |
2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); | 2632 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->revision().toString().latin1(), remote->revision().toString().latin1() ); |
2633 | if ( lastSync > remote->revision() ) | 2633 | if ( lastSync > remote->revision() ) |
2634 | return 1; | 2634 | return 1; |
2635 | if ( lastSync > local->revision() ) | 2635 | if ( lastSync > local->revision() ) |
2636 | return 2; | 2636 | return 2; |
2637 | localIsNew = local->revision() >= remote->revision(); | 2637 | localIsNew = local->revision() >= remote->revision(); |
2638 | //qDebug("conflict! ************************************** "); | 2638 | //qDebug("conflict! ************************************** "); |
2639 | { | 2639 | { |
2640 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2640 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2641 | result = acd.executeD(localIsNew); | 2641 | result = acd.executeD(localIsNew); |
2642 | return result; | 2642 | return result; |
2643 | } | 2643 | } |
2644 | break; | 2644 | break; |
2645 | case SYNC_PREF_FORCE_LOCAL: | 2645 | case SYNC_PREF_FORCE_LOCAL: |
2646 | return 1; | 2646 | return 1; |
2647 | break; | 2647 | break; |
2648 | case SYNC_PREF_FORCE_REMOTE: | 2648 | case SYNC_PREF_FORCE_REMOTE: |
2649 | return 2; | 2649 | return 2; |
2650 | break; | 2650 | break; |
2651 | 2651 | ||
2652 | default: | 2652 | default: |
2653 | // SYNC_PREF_TAKE_BOTH not implemented | 2653 | // SYNC_PREF_TAKE_BOTH not implemented |
2654 | break; | 2654 | break; |
2655 | } | 2655 | } |
2656 | return 0; | 2656 | return 0; |
2657 | } | 2657 | } |
2658 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2658 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2659 | { | 2659 | { |
2660 | bool syncOK = true; | 2660 | bool syncOK = true; |
2661 | int addedAddressee = 0; | 2661 | int addedAddressee = 0; |
2662 | int addedAddresseeR = 0; | 2662 | int addedAddresseeR = 0; |
2663 | int deletedAddresseeR = 0; | 2663 | int deletedAddresseeR = 0; |
2664 | int deletedAddresseeL = 0; | 2664 | int deletedAddresseeL = 0; |
2665 | int changedLocal = 0; | 2665 | int changedLocal = 0; |
2666 | int changedRemote = 0; | 2666 | int changedRemote = 0; |
2667 | //QPtrList<Addressee> el = local->rawAddressees(); | 2667 | //QPtrList<Addressee> el = local->rawAddressees(); |
2668 | Addressee addresseeR; | 2668 | Addressee addresseeR; |
2669 | QString uid; | 2669 | QString uid; |
2670 | int take; | 2670 | int take; |
2671 | Addressee addresseeL; | 2671 | Addressee addresseeL; |
2672 | Addressee addresseeRSync; | 2672 | Addressee addresseeRSync; |
2673 | Addressee addresseeLSync; | 2673 | Addressee addresseeLSync; |
2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2674 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2675 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2676 | bool fullDateRange = false; | 2676 | bool fullDateRange = false; |
2677 | local->resetTempSyncStat(); | 2677 | local->resetTempSyncStat(); |
2678 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2678 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2679 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2680 | addresseeLSync = getLastSyncAddressee(); | 2680 | addresseeLSync = getLastSyncAddressee(); |
2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2681 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2682 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2683 | if ( !addresseeR.isEmpty() ) { | 2683 | if ( !addresseeR.isEmpty() ) { |
2684 | addresseeRSync = addresseeR; | 2684 | addresseeRSync = addresseeR; |
2685 | remote->removeAddressee(addresseeR ); | 2685 | remote->removeAddressee(addresseeR ); |
2686 | 2686 | ||
2687 | } else { | 2687 | } else { |
2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2688 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2689 | addresseeRSync = addresseeLSync ; | 2689 | addresseeRSync = addresseeLSync ; |
2690 | } else { | 2690 | } else { |
2691 | qDebug("FULLDATE 1"); | 2691 | qDebug("FULLDATE 1"); |
2692 | fullDateRange = true; | 2692 | fullDateRange = true; |
2693 | Addressee newAdd; | 2693 | Addressee newAdd; |
2694 | addresseeRSync = newAdd; | 2694 | addresseeRSync = newAdd; |
2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2695 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2696 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2697 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2697 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2698 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2699 | } | 2699 | } |
2700 | } | 2700 | } |
2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2701 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2702 | qDebug("FULLDATE 2"); | 2702 | qDebug("FULLDATE 2"); |
2703 | fullDateRange = true; | 2703 | fullDateRange = true; |
2704 | } | 2704 | } |
2705 | if ( ! fullDateRange ) { | 2705 | if ( ! fullDateRange ) { |
2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2706 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2707 | 2707 | ||
2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2708 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2709 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2710 | fullDateRange = true; | 2710 | fullDateRange = true; |
2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2711 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2712 | } | 2712 | } |
2713 | } | 2713 | } |
2714 | // fullDateRange = true; // debug only! | 2714 | // fullDateRange = true; // debug only! |
2715 | if ( fullDateRange ) | 2715 | if ( fullDateRange ) |
2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2716 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2717 | else | 2717 | else |
2718 | mLastAddressbookSync = addresseeLSync.revision(); | 2718 | mLastAddressbookSync = addresseeLSync.revision(); |
2719 | // for resyncing if own file has changed | 2719 | // for resyncing if own file has changed |
2720 | // PENDING fixme later when implemented | 2720 | // PENDING fixme later when implemented |
2721 | #if 0 | 2721 | #if 0 |
2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2722 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2723 | mLastAddressbookSync = loadedFileVersion; | 2723 | mLastAddressbookSync = loadedFileVersion; |
2724 | qDebug("setting mLastAddressbookSync "); | 2724 | qDebug("setting mLastAddressbookSync "); |
2725 | } | 2725 | } |
2726 | #endif | 2726 | #endif |
2727 | 2727 | ||
2728 | //qDebug("*************************** "); | 2728 | //qDebug("*************************** "); |
2729 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2729 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2730 | QStringList er = remote->uidList(); | 2730 | QStringList er = remote->uidList(); |
2731 | Addressee inR ;//= er.first(); | 2731 | Addressee inR ;//= er.first(); |
2732 | Addressee inL; | 2732 | Addressee inL; |
2733 | QProgressBar bar( er.count(),0 ); | 2733 | QProgressBar bar( er.count(),0 ); |
2734 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2734 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2735 | 2735 | ||
2736 | int w = 300; | 2736 | int w = 300; |
2737 | if ( QApplication::desktop()->width() < 320 ) | 2737 | if ( QApplication::desktop()->width() < 320 ) |
2738 | w = 220; | 2738 | w = 220; |
2739 | int h = bar.sizeHint().height() ; | 2739 | int h = bar.sizeHint().height() ; |
2740 | int dw = QApplication::desktop()->width(); | 2740 | int dw = QApplication::desktop()->width(); |
2741 | int dh = QApplication::desktop()->height(); | 2741 | int dh = QApplication::desktop()->height(); |
2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2742 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2743 | bar.show(); | 2743 | bar.show(); |
2744 | int modulo = (er.count()/10)+1; | 2744 | int modulo = (er.count()/10)+1; |
2745 | int incCounter = 0; | 2745 | int incCounter = 0; |
2746 | while ( incCounter < er.count()) { | 2746 | while ( incCounter < er.count()) { |
2747 | if ( ! bar.isVisible() ) | 2747 | if ( ! bar.isVisible() ) |
2748 | return false; | 2748 | return false; |
2749 | if ( incCounter % modulo == 0 ) | 2749 | if ( incCounter % modulo == 0 ) |
2750 | bar.setProgress( incCounter ); | 2750 | bar.setProgress( incCounter ); |
2751 | uid = er[ incCounter ]; | 2751 | uid = er[ incCounter ]; |
2752 | bool skipIncidence = false; | 2752 | bool skipIncidence = false; |
2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2753 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2754 | skipIncidence = true; | 2754 | skipIncidence = true; |
2755 | QString idS; | 2755 | QString idS; |
2756 | qApp->processEvents(); | 2756 | qApp->processEvents(); |
2757 | if ( !skipIncidence ) { | 2757 | if ( !skipIncidence ) { |
2758 | inL = local->findByUid( uid ); | 2758 | inL = local->findByUid( uid ); |
2759 | inR = remote->findByUid( uid ); | 2759 | inR = remote->findByUid( uid ); |
2760 | //inL.setResource( 0 ); | 2760 | //inL.setResource( 0 ); |
2761 | //inR.setResource( 0 ); | 2761 | //inR.setResource( 0 ); |
2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2762 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2763 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2764 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2765 | if ( take == 3 ) | 2765 | if ( take == 3 ) |
2766 | return false; | 2766 | return false; |
2767 | if ( take == 1 ) {// take local | 2767 | if ( take == 1 ) {// take local |
2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2768 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2769 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2770 | local->insertAddressee( inL, false ); | 2770 | local->insertAddressee( inL, false ); |
2771 | } | 2771 | } |
2772 | else | 2772 | else |
2773 | idS = inR.IDStr(); | 2773 | idS = inR.IDStr(); |
2774 | remote->removeAddressee( inR ); | 2774 | remote->removeAddressee( inR ); |
2775 | inR = inL; | 2775 | inR = inL; |
2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2776 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2777 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2778 | inR.setIDStr( idS ); | 2778 | inR.setIDStr( idS ); |
2779 | inR.setResource( 0 ); | 2779 | inR.setResource( 0 ); |
2780 | remote->insertAddressee( inR , false); | 2780 | remote->insertAddressee( inR , false); |
2781 | ++changedRemote; | 2781 | ++changedRemote; |
2782 | } else { | 2782 | } else { |
2783 | idS = inL.IDStr(); | 2783 | idS = inL.IDStr(); |
2784 | local->removeAddressee( inL ); | 2784 | local->removeAddressee( inL ); |
2785 | inL = inR; | 2785 | inL = inR; |
2786 | inL.setIDStr( idS ); | 2786 | inL.setIDStr( idS ); |
2787 | inL.setResource( 0 ); | 2787 | inL.setResource( 0 ); |
2788 | local->insertAddressee( inL , false ); | 2788 | local->insertAddressee( inL , false ); |
2789 | ++changedLocal; | 2789 | ++changedLocal; |
2790 | } | 2790 | } |
2791 | } | 2791 | } |
2792 | } else { // no conflict | 2792 | } else { // no conflict |
2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2793 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2794 | QString des = addresseeLSync.note(); | 2794 | QString des = addresseeLSync.note(); |
2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2795 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2796 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2797 | remote->insertAddressee( inR, false ); | 2797 | remote->insertAddressee( inR, false ); |
2798 | ++deletedAddresseeR; | 2798 | ++deletedAddresseeR; |
2799 | } else { | 2799 | } else { |
2800 | inR.setRevision( modifiedCalendar ); | 2800 | inR.setRevision( modifiedCalendar ); |
2801 | remote->insertAddressee( inR, false ); | 2801 | remote->insertAddressee( inR, false ); |
2802 | inL = inR; | 2802 | inL = inR; |
2803 | inL.setResource( 0 ); | 2803 | inL.setResource( 0 ); |
2804 | local->insertAddressee( inL , false); | 2804 | local->insertAddressee( inL , false); |
2805 | ++addedAddressee; | 2805 | ++addedAddressee; |
2806 | } | 2806 | } |
2807 | } else { | 2807 | } else { |
2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2808 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2809 | inR.setRevision( modifiedCalendar ); | 2809 | inR.setRevision( modifiedCalendar ); |
2810 | remote->insertAddressee( inR, false ); | 2810 | remote->insertAddressee( inR, false ); |
2811 | inR.setResource( 0 ); | 2811 | inR.setResource( 0 ); |
2812 | local->insertAddressee( inR, false ); | 2812 | local->insertAddressee( inR, false ); |
2813 | ++addedAddressee; | 2813 | ++addedAddressee; |
2814 | } else { | 2814 | } else { |
2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2815 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2816 | remote->removeAddressee( inR ); | 2816 | remote->removeAddressee( inR ); |
2817 | ++deletedAddresseeR; | 2817 | ++deletedAddresseeR; |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | } | 2820 | } |
2821 | } | 2821 | } |
2822 | ++incCounter; | 2822 | ++incCounter; |
2823 | } | 2823 | } |
2824 | er.clear(); | 2824 | er.clear(); |
2825 | QStringList el = local->uidList(); | 2825 | QStringList el = local->uidList(); |
2826 | modulo = (el.count()/10)+1; | 2826 | modulo = (el.count()/10)+1; |
2827 | bar.setCaption (i18n("Add / remove addressees") ); | 2827 | bar.setCaption (i18n("Add / remove addressees") ); |
2828 | bar.setTotalSteps ( el.count() ) ; | 2828 | bar.setTotalSteps ( el.count() ) ; |
2829 | bar.show(); | 2829 | bar.show(); |
2830 | incCounter = 0; | 2830 | incCounter = 0; |
2831 | while ( incCounter < el.count()) { | 2831 | while ( incCounter < el.count()) { |
2832 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2833 | if ( ! bar.isVisible() ) | 2833 | if ( ! bar.isVisible() ) |
2834 | return false; | 2834 | return false; |
2835 | if ( incCounter % modulo == 0 ) | 2835 | if ( incCounter % modulo == 0 ) |
2836 | bar.setProgress( incCounter ); | 2836 | bar.setProgress( incCounter ); |
2837 | uid = el[ incCounter ]; | 2837 | uid = el[ incCounter ]; |
2838 | bool skipIncidence = false; | 2838 | bool skipIncidence = false; |
2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2839 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2840 | skipIncidence = true; | 2840 | skipIncidence = true; |
2841 | if ( !skipIncidence ) { | 2841 | if ( !skipIncidence ) { |
2842 | inL = local->findByUid( uid ); | 2842 | inL = local->findByUid( uid ); |
2843 | inR = remote->findByUid( uid ); | 2843 | inR = remote->findByUid( uid ); |
2844 | if ( inR.isEmpty() ) { | 2844 | if ( inR.isEmpty() ) { |
2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2845 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2846 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2847 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2848 | local->removeAddressee( inL ); | 2848 | local->removeAddressee( inL ); |
2849 | ++deletedAddresseeL; | 2849 | ++deletedAddresseeL; |
2850 | } else { | 2850 | } else { |
2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2851 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2852 | inL.removeID(mCurrentSyncDevice ); | 2852 | inL.removeID(mCurrentSyncDevice ); |
2853 | ++addedAddresseeR; | 2853 | ++addedAddresseeR; |
2854 | inL.setRevision( modifiedCalendar ); | 2854 | inL.setRevision( modifiedCalendar ); |
2855 | local->insertAddressee( inL, false ); | 2855 | local->insertAddressee( inL, false ); |
2856 | inR = inL; | 2856 | inR = inL; |
2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2857 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2858 | inR.setResource( 0 ); | 2858 | inR.setResource( 0 ); |
2859 | remote->insertAddressee( inR, false ); | 2859 | remote->insertAddressee( inR, false ); |
2860 | } | 2860 | } |
2861 | } | 2861 | } |
2862 | } else { | 2862 | } else { |
2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2863 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2864 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2865 | local->removeAddressee( inL ); | 2865 | local->removeAddressee( inL ); |
2866 | ++deletedAddresseeL; | 2866 | ++deletedAddresseeL; |
2867 | } else { | 2867 | } else { |
2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { | 2868 | if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { |
2869 | ++addedAddresseeR; | 2869 | ++addedAddresseeR; |
2870 | inL.setRevision( modifiedCalendar ); | 2870 | inL.setRevision( modifiedCalendar ); |
2871 | local->insertAddressee( inL, false ); | 2871 | local->insertAddressee( inL, false ); |
2872 | inR = inL; | 2872 | inR = inL; |
2873 | inR.setResource( 0 ); | 2873 | inR.setResource( 0 ); |
2874 | remote->insertAddressee( inR, false ); | 2874 | remote->insertAddressee( inR, false ); |
2875 | } | 2875 | } |
2876 | } | 2876 | } |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | } | 2879 | } |
2880 | ++incCounter; | 2880 | ++incCounter; |
2881 | } | 2881 | } |
2882 | el.clear(); | 2882 | el.clear(); |
2883 | bar.hide(); | 2883 | bar.hide(); |
2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2884 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2885 | // get rid of micro seconds | 2885 | // get rid of micro seconds |
2886 | QTime t = mLastAddressbookSync.time(); | 2886 | QTime t = mLastAddressbookSync.time(); |
2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2887 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2888 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2888 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2889 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2889 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2890 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2891 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2892 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2893 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2894 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2895 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2896 | addresseeRSync.setNote( "" ) ; | 2896 | addresseeRSync.setNote( "" ) ; |
2897 | addresseeLSync.setNote( "" ); | 2897 | addresseeLSync.setNote( "" ); |
2898 | 2898 | ||
2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2899 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2900 | remote->insertAddressee( addresseeRSync, false ); | 2900 | remote->insertAddressee( addresseeRSync, false ); |
2901 | local->insertAddressee( addresseeLSync, false ); | 2901 | local->insertAddressee( addresseeLSync, false ); |
2902 | QString mes; | 2902 | QString mes; |
2903 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2903 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { | 2904 | if ( KABPrefs::instance()->mShowSyncSummary ) { |
2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2905 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2906 | } | 2906 | } |
2907 | qDebug( mes ); | 2907 | qDebug( mes ); |
2908 | return syncOK; | 2908 | return syncOK; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | bool KABCore::syncAB(QString filename, int mode) | 2911 | bool KABCore::syncAB(QString filename, int mode) |
2912 | { | 2912 | { |
2913 | 2913 | ||
2914 | //pending prepare addresseeview for output | 2914 | //pending prepare addresseeview for output |
2915 | //pending detect, if remote file has REV field. if not switch to external sync | 2915 | //pending detect, if remote file has REV field. if not switch to external sync |
2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2916 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2917 | AddressBook abLocal(filename,"syncContact"); | 2917 | AddressBook abLocal(filename,"syncContact"); |
2918 | bool syncOK = false; | 2918 | bool syncOK = false; |
2919 | if ( abLocal.load() ) { | 2919 | if ( abLocal.load() ) { |
2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2920 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2921 | bool external = false; | 2921 | bool external = false; |
2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2922 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2923 | if ( ! lse.isEmpty() ) { | 2923 | if ( ! lse.isEmpty() ) { |
2924 | if ( lse.familyName().left(4) == "!E: " ) | 2924 | if ( lse.familyName().left(4) == "!E: " ) |
2925 | external = true; | 2925 | external = true; |
2926 | } else { | 2926 | } else { |
2927 | bool found = false; | 2927 | bool found = false; |
2928 | QDateTime dt( QDate( 2004,1,1)); | 2928 | QDateTime dt( QDate( 2004,1,1)); |
2929 | AddressBook::Iterator it; | 2929 | AddressBook::Iterator it; |
2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2930 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2931 | if ( (*it).revision() != dt ) { | 2931 | if ( (*it).revision() != dt ) { |
2932 | found = true; | 2932 | found = true; |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | } | 2935 | } |
2936 | external = ! found; | 2936 | external = ! found; |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | if ( external ) { | 2939 | if ( external ) { |
2940 | qDebug("Setting vcf mode to external "); | 2940 | qDebug("Setting vcf mode to external "); |
2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2941 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2942 | AddressBook::Iterator it; | 2942 | AddressBook::Iterator it; |
2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2943 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2944 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2945 | (*it).computeCsum( mCurrentSyncDevice ); | 2945 | (*it).computeCsum( mCurrentSyncDevice ); |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | //AddressBook::Iterator it; | 2948 | //AddressBook::Iterator it; |
2949 | //QStringList vcards; | 2949 | //QStringList vcards; |
2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2950 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2951 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2951 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2952 | //} | 2952 | //} |
2953 | if ( filename.right(4) == ".xml") | ||
2954 | abLocal.mergeAB( mAddressBook ,mCurrentSyncDevice ); | ||
2953 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2955 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2954 | if ( syncOK ) { | 2956 | if ( syncOK ) { |
2955 | if ( KABPrefs::instance()->mWriteBackFile ) | 2957 | if ( KABPrefs::instance()->mWriteBackFile ) |
2956 | { | 2958 | { |
2957 | if ( external ) | 2959 | if ( external ) |
2958 | abLocal.removeDeletedAddressees(); | 2960 | abLocal.removeDeletedAddressees(); |
2959 | qDebug("Saving remote AB "); | 2961 | qDebug("Saving remote AB "); |
2960 | abLocal.saveAB(); | 2962 | abLocal.saveAB(); |
2961 | } | 2963 | } |
2962 | } | 2964 | } |
2963 | setModified(); | 2965 | setModified(); |
2964 | 2966 | ||
2965 | } | 2967 | } |
2966 | if ( syncOK ) | 2968 | if ( syncOK ) |
2967 | mViewManager->refreshView(); | 2969 | mViewManager->refreshView(); |
2968 | return syncOK; | 2970 | return syncOK; |
2969 | #if 0 | 2971 | #if 0 |
2970 | 2972 | ||
2971 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2973 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2972 | getEventViewerDialog()->setSyncMode( true ); | 2974 | getEventViewerDialog()->setSyncMode( true ); |
2973 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2975 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2974 | getEventViewerDialog()->setSyncMode( false ); | 2976 | getEventViewerDialog()->setSyncMode( false ); |
2975 | if ( syncOK ) { | 2977 | if ( syncOK ) { |
2976 | if ( KOPrefs::instance()->mWriteBackFile ) | 2978 | if ( KOPrefs::instance()->mWriteBackFile ) |
2977 | { | 2979 | { |
2978 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2980 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2979 | storage->save(); | 2981 | storage->save(); |
2980 | } | 2982 | } |
2981 | } | 2983 | } |
2982 | setModified(); | 2984 | setModified(); |
2983 | } | 2985 | } |
2984 | 2986 | ||
2985 | #endif | 2987 | #endif |
2986 | } | 2988 | } |
2987 | 2989 | ||
2988 | void KABCore::confSync() | 2990 | void KABCore::confSync() |
2989 | { | 2991 | { |
2990 | static KSyncPrefsDialog* sp = 0; | 2992 | static KSyncPrefsDialog* sp = 0; |
2991 | if ( ! sp ) { | 2993 | if ( ! sp ) { |
2992 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2994 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2993 | } | 2995 | } |
2994 | sp->usrReadConfig(); | 2996 | sp->usrReadConfig(); |
2995 | #ifndef DESKTOP_VERSION | 2997 | #ifndef DESKTOP_VERSION |
2996 | sp->showMaximized(); | 2998 | sp->showMaximized(); |
2997 | #else | 2999 | #else |
2998 | sp->show(); | 3000 | sp->show(); |
2999 | #endif | 3001 | #endif |
3000 | sp->exec(); | 3002 | sp->exec(); |
3001 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 3003 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
3002 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 3004 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
3003 | fillSyncMenu(); | 3005 | fillSyncMenu(); |
3004 | } | 3006 | } |
3005 | void KABCore::syncSharp() | 3007 | void KABCore::syncSharp() |
3006 | { | 3008 | { |
3007 | if ( mModified ) | 3009 | if ( mModified ) |
3008 | save(); | 3010 | save(); |
3009 | qDebug("pending syncSharp() "); | 3011 | qDebug("pending syncSharp() "); |
3010 | //mView->syncSharp(); | 3012 | //mView->syncSharp(); |
3011 | setModified(); | 3013 | setModified(); |
3012 | 3014 | ||
3013 | } | 3015 | } |
3014 | void KABCore::syncPhone() | 3016 | void KABCore::syncPhone() |
3015 | { | 3017 | { |
3016 | if ( mModified ) | 3018 | if ( mModified ) |
3017 | save(); | 3019 | save(); |
3018 | qDebug("pending syncPhone(); "); | 3020 | qDebug("pending syncPhone(); "); |
3019 | //mView->syncPhone(); | 3021 | //mView->syncPhone(); |
3020 | setModified(); | 3022 | setModified(); |
3021 | 3023 | ||
3022 | } | 3024 | } |