-rw-r--r-- | kabc/addressbook.cpp | 72 | ||||
-rw-r--r-- | kabc/addressbook.h | 4 | ||||
-rw-r--r-- | kabc/addressee.cpp | 12 | ||||
-rw-r--r-- | kabc/addressee.h | 5 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 |
5 files changed, 66 insertions, 29 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 1050f55..ff05f7e 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,1004 +1,1024 @@ | |||
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 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | 44 | ||
45 | #include <kglobal.h> | 45 | #include <kglobal.h> |
46 | #include <klocale.h> | 46 | #include <klocale.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kdebug.h> | 48 | #include <kdebug.h> |
49 | #include <libkcal/syncdefines.h> | 49 | #include <libkcal/syncdefines.h> |
50 | #include "addressbook.h" | 50 | #include "addressbook.h" |
51 | #include "resource.h" | 51 | #include "resource.h" |
52 | #include "vcardconverter.h" | 52 | #include "vcardconverter.h" |
53 | #include "vcardparser/vcardtool.h" | 53 | #include "vcardparser/vcardtool.h" |
54 | 54 | ||
55 | //US #include "addressbook.moc" | 55 | //US #include "addressbook.moc" |
56 | 56 | ||
57 | using namespace KABC; | 57 | using namespace KABC; |
58 | 58 | ||
59 | struct AddressBook::AddressBookData | 59 | struct AddressBook::AddressBookData |
60 | { | 60 | { |
61 | Addressee::List mAddressees; | 61 | Addressee::List mAddressees; |
62 | Addressee::List mRemovedAddressees; | 62 | Addressee::List mRemovedAddressees; |
63 | Field::List mAllFields; | 63 | Field::List mAllFields; |
64 | KConfig *mConfig; | 64 | KConfig *mConfig; |
65 | KRES::Manager<Resource> *mManager; | 65 | KRES::Manager<Resource> *mManager; |
66 | //US ErrorHandler *mErrorHandler; | 66 | //US ErrorHandler *mErrorHandler; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | struct AddressBook::Iterator::IteratorData | 69 | struct AddressBook::Iterator::IteratorData |
70 | { | 70 | { |
71 | Addressee::List::Iterator mIt; | 71 | Addressee::List::Iterator mIt; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | struct AddressBook::ConstIterator::ConstIteratorData | 74 | struct AddressBook::ConstIterator::ConstIteratorData |
75 | { | 75 | { |
76 | Addressee::List::ConstIterator mIt; | 76 | Addressee::List::ConstIterator mIt; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | AddressBook::Iterator::Iterator() | 79 | AddressBook::Iterator::Iterator() |
80 | { | 80 | { |
81 | d = new IteratorData; | 81 | d = new IteratorData; |
82 | } | 82 | } |
83 | 83 | ||
84 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 84 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
85 | { | 85 | { |
86 | d = new IteratorData; | 86 | d = new IteratorData; |
87 | d->mIt = i.d->mIt; | 87 | d->mIt = i.d->mIt; |
88 | } | 88 | } |
89 | 89 | ||
90 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 90 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
91 | { | 91 | { |
92 | if( this == &i ) return *this; // guard against self assignment | 92 | if( this == &i ) return *this; // guard against self assignment |
93 | delete d; // delete the old data the Iterator was completely constructed before | 93 | delete d; // delete the old data the Iterator was completely constructed before |
94 | d = new IteratorData; | 94 | d = new IteratorData; |
95 | d->mIt = i.d->mIt; | 95 | d->mIt = i.d->mIt; |
96 | return *this; | 96 | return *this; |
97 | } | 97 | } |
98 | 98 | ||
99 | AddressBook::Iterator::~Iterator() | 99 | AddressBook::Iterator::~Iterator() |
100 | { | 100 | { |
101 | delete d; | 101 | delete d; |
102 | } | 102 | } |
103 | 103 | ||
104 | const Addressee &AddressBook::Iterator::operator*() const | 104 | const Addressee &AddressBook::Iterator::operator*() const |
105 | { | 105 | { |
106 | return *(d->mIt); | 106 | return *(d->mIt); |
107 | } | 107 | } |
108 | 108 | ||
109 | Addressee &AddressBook::Iterator::operator*() | 109 | Addressee &AddressBook::Iterator::operator*() |
110 | { | 110 | { |
111 | return *(d->mIt); | 111 | return *(d->mIt); |
112 | } | 112 | } |
113 | 113 | ||
114 | Addressee *AddressBook::Iterator::operator->() | 114 | Addressee *AddressBook::Iterator::operator->() |
115 | { | 115 | { |
116 | return &(*(d->mIt)); | 116 | return &(*(d->mIt)); |
117 | } | 117 | } |
118 | 118 | ||
119 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 119 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
120 | { | 120 | { |
121 | (d->mIt)++; | 121 | (d->mIt)++; |
122 | return *this; | 122 | return *this; |
123 | } | 123 | } |
124 | 124 | ||
125 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 125 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
126 | { | 126 | { |
127 | (d->mIt)++; | 127 | (d->mIt)++; |
128 | return *this; | 128 | return *this; |
129 | } | 129 | } |
130 | 130 | ||
131 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 131 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
132 | { | 132 | { |
133 | (d->mIt)--; | 133 | (d->mIt)--; |
134 | return *this; | 134 | return *this; |
135 | } | 135 | } |
136 | 136 | ||
137 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 137 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
138 | { | 138 | { |
139 | (d->mIt)--; | 139 | (d->mIt)--; |
140 | return *this; | 140 | return *this; |
141 | } | 141 | } |
142 | 142 | ||
143 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 143 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
144 | { | 144 | { |
145 | return ( d->mIt == it.d->mIt ); | 145 | return ( d->mIt == it.d->mIt ); |
146 | } | 146 | } |
147 | 147 | ||
148 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 148 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
149 | { | 149 | { |
150 | return ( d->mIt != it.d->mIt ); | 150 | return ( d->mIt != it.d->mIt ); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | AddressBook::ConstIterator::ConstIterator() | 154 | AddressBook::ConstIterator::ConstIterator() |
155 | { | 155 | { |
156 | d = new ConstIteratorData; | 156 | d = new ConstIteratorData; |
157 | } | 157 | } |
158 | 158 | ||
159 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 159 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
160 | { | 160 | { |
161 | d = new ConstIteratorData; | 161 | d = new ConstIteratorData; |
162 | d->mIt = i.d->mIt; | 162 | d->mIt = i.d->mIt; |
163 | } | 163 | } |
164 | 164 | ||
165 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 165 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
166 | { | 166 | { |
167 | if( this == &i ) return *this; // guard for self assignment | 167 | if( this == &i ) return *this; // guard for self assignment |
168 | delete d; // delete the old data because the Iterator was really constructed before | 168 | delete d; // delete the old data because the Iterator was really constructed before |
169 | d = new ConstIteratorData; | 169 | d = new ConstIteratorData; |
170 | d->mIt = i.d->mIt; | 170 | d->mIt = i.d->mIt; |
171 | return *this; | 171 | return *this; |
172 | } | 172 | } |
173 | 173 | ||
174 | AddressBook::ConstIterator::~ConstIterator() | 174 | AddressBook::ConstIterator::~ConstIterator() |
175 | { | 175 | { |
176 | delete d; | 176 | delete d; |
177 | } | 177 | } |
178 | 178 | ||
179 | const Addressee &AddressBook::ConstIterator::operator*() const | 179 | const Addressee &AddressBook::ConstIterator::operator*() const |
180 | { | 180 | { |
181 | return *(d->mIt); | 181 | return *(d->mIt); |
182 | } | 182 | } |
183 | 183 | ||
184 | const Addressee* AddressBook::ConstIterator::operator->() const | 184 | const Addressee* AddressBook::ConstIterator::operator->() const |
185 | { | 185 | { |
186 | return &(*(d->mIt)); | 186 | return &(*(d->mIt)); |
187 | } | 187 | } |
188 | 188 | ||
189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
190 | { | 190 | { |
191 | (d->mIt)++; | 191 | (d->mIt)++; |
192 | return *this; | 192 | return *this; |
193 | } | 193 | } |
194 | 194 | ||
195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
196 | { | 196 | { |
197 | (d->mIt)++; | 197 | (d->mIt)++; |
198 | return *this; | 198 | return *this; |
199 | } | 199 | } |
200 | 200 | ||
201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
202 | { | 202 | { |
203 | (d->mIt)--; | 203 | (d->mIt)--; |
204 | return *this; | 204 | return *this; |
205 | } | 205 | } |
206 | 206 | ||
207 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 207 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
208 | { | 208 | { |
209 | (d->mIt)--; | 209 | (d->mIt)--; |
210 | return *this; | 210 | return *this; |
211 | } | 211 | } |
212 | 212 | ||
213 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 213 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
214 | { | 214 | { |
215 | return ( d->mIt == it.d->mIt ); | 215 | return ( d->mIt == it.d->mIt ); |
216 | } | 216 | } |
217 | 217 | ||
218 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 218 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
219 | { | 219 | { |
220 | return ( d->mIt != it.d->mIt ); | 220 | return ( d->mIt != it.d->mIt ); |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | AddressBook::AddressBook() | 224 | AddressBook::AddressBook() |
225 | { | 225 | { |
226 | init(0, "contact"); | 226 | init(0, "contact"); |
227 | } | 227 | } |
228 | 228 | ||
229 | AddressBook::AddressBook( const QString &config ) | 229 | AddressBook::AddressBook( const QString &config ) |
230 | { | 230 | { |
231 | init(config, "contact"); | 231 | init(config, "contact"); |
232 | } | 232 | } |
233 | 233 | ||
234 | AddressBook::AddressBook( const QString &config, const QString &family ) | 234 | AddressBook::AddressBook( const QString &config, const QString &family ) |
235 | { | 235 | { |
236 | init(config, family); | 236 | init(config, family); |
237 | 237 | ||
238 | } | 238 | } |
239 | 239 | ||
240 | // the default family is "contact" | 240 | // the default family is "contact" |
241 | void AddressBook::init(const QString &config, const QString &family ) | 241 | void AddressBook::init(const QString &config, const QString &family ) |
242 | { | 242 | { |
243 | blockLSEchange = false; | 243 | blockLSEchange = false; |
244 | d = new AddressBookData; | 244 | d = new AddressBookData; |
245 | QString fami = family; | 245 | QString fami = family; |
246 | if (config != 0) { | 246 | if (config != 0) { |
247 | if ( family == "syncContact" ) { | 247 | if ( family == "syncContact" ) { |
248 | qDebug("creating sync config "); | 248 | qDebug("creating sync config "); |
249 | fami = "contact"; | 249 | fami = "contact"; |
250 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 250 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
251 | con->setGroup( "General" ); | 251 | con->setGroup( "General" ); |
252 | con->writeEntry( "ResourceKeys", QString("sync") ); | 252 | con->writeEntry( "ResourceKeys", QString("sync") ); |
253 | con->writeEntry( "Standard", QString("sync") ); | 253 | con->writeEntry( "Standard", QString("sync") ); |
254 | con->setGroup( "Resource_sync" ); | 254 | con->setGroup( "Resource_sync" ); |
255 | con->writeEntry( "FileName", config ); | 255 | con->writeEntry( "FileName", config ); |
256 | con->writeEntry( "FileFormat", QString("vcard") ); | 256 | con->writeEntry( "FileFormat", QString("vcard") ); |
257 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 257 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
258 | con->writeEntry( "ResourceName", QString("sync_res") ); | 258 | con->writeEntry( "ResourceName", QString("sync_res") ); |
259 | if ( config.right(4) == ".xml" ) | 259 | if ( config.right(4) == ".xml" ) |
260 | con->writeEntry( "ResourceType", QString("qtopia") ); | 260 | con->writeEntry( "ResourceType", QString("qtopia") ); |
261 | else if ( config == "sharp" ) { | 261 | else if ( config == "sharp" ) { |
262 | con->writeEntry( "ResourceType", QString("sharp") ); | 262 | con->writeEntry( "ResourceType", QString("sharp") ); |
263 | } else { | 263 | } else { |
264 | con->writeEntry( "ResourceType", QString("file") ); | 264 | con->writeEntry( "ResourceType", QString("file") ); |
265 | } | 265 | } |
266 | //con->sync(); | 266 | //con->sync(); |
267 | d->mConfig = con; | 267 | d->mConfig = con; |
268 | } | 268 | } |
269 | else | 269 | else |
270 | d->mConfig = new KConfig( locateLocal("config", config) ); | 270 | d->mConfig = new KConfig( locateLocal("config", config) ); |
271 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 271 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
272 | } | 272 | } |
273 | else { | 273 | else { |
274 | d->mConfig = 0; | 274 | d->mConfig = 0; |
275 | // qDebug("AddressBook::init 1 config=0"); | 275 | // qDebug("AddressBook::init 1 config=0"); |
276 | } | 276 | } |
277 | 277 | ||
278 | //US d->mErrorHandler = 0; | 278 | //US d->mErrorHandler = 0; |
279 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 279 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
280 | d->mManager->readConfig( d->mConfig ); | 280 | d->mManager->readConfig( d->mConfig ); |
281 | if ( family == "syncContact" ) { | 281 | if ( family == "syncContact" ) { |
282 | KRES::Manager<Resource> *manager = d->mManager; | 282 | KRES::Manager<Resource> *manager = d->mManager; |
283 | KRES::Manager<Resource>::ActiveIterator it; | 283 | KRES::Manager<Resource>::ActiveIterator it; |
284 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 284 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
285 | (*it)->setAddressBook( this ); | 285 | (*it)->setAddressBook( this ); |
286 | if ( !(*it)->open() ) | 286 | if ( !(*it)->open() ) |
287 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 287 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
288 | } | 288 | } |
289 | Resource *res = standardResource(); | 289 | Resource *res = standardResource(); |
290 | if ( !res ) { | 290 | if ( !res ) { |
291 | qDebug("ERROR: no standard resource"); | 291 | qDebug("ERROR: no standard resource"); |
292 | res = manager->createResource( "file" ); | 292 | res = manager->createResource( "file" ); |
293 | if ( res ) | 293 | if ( res ) |
294 | { | 294 | { |
295 | addResource( res ); | 295 | addResource( res ); |
296 | } | 296 | } |
297 | else | 297 | else |
298 | qDebug(" No resource available!!!"); | 298 | qDebug(" No resource available!!!"); |
299 | } | 299 | } |
300 | setStandardResource( res ); | 300 | setStandardResource( res ); |
301 | manager->writeConfig(); | 301 | manager->writeConfig(); |
302 | } | 302 | } |
303 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 303 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
304 | "X-Department", "KADDRESSBOOK" ); | 304 | "X-Department", "KADDRESSBOOK" ); |
305 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 305 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
306 | "X-Profession", "KADDRESSBOOK" ); | 306 | "X-Profession", "KADDRESSBOOK" ); |
307 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 307 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
308 | "X-AssistantsName", "KADDRESSBOOK" ); | 308 | "X-AssistantsName", "KADDRESSBOOK" ); |
309 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 309 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
310 | "X-ManagersName", "KADDRESSBOOK" ); | 310 | "X-ManagersName", "KADDRESSBOOK" ); |
311 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 311 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
312 | "X-SpousesName", "KADDRESSBOOK" ); | 312 | "X-SpousesName", "KADDRESSBOOK" ); |
313 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 313 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
314 | "X-Office", "KADDRESSBOOK" ); | 314 | "X-Office", "KADDRESSBOOK" ); |
315 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 315 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
316 | "X-IMAddress", "KADDRESSBOOK" ); | 316 | "X-IMAddress", "KADDRESSBOOK" ); |
317 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 317 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
318 | "X-Anniversary", "KADDRESSBOOK" ); | 318 | "X-Anniversary", "KADDRESSBOOK" ); |
319 | 319 | ||
320 | //US added this field to become compatible with Opie/qtopia addressbook | 320 | //US added this field to become compatible with Opie/qtopia addressbook |
321 | // values can be "female" or "male" or "". An empty field represents undefined. | 321 | // values can be "female" or "male" or "". An empty field represents undefined. |
322 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 322 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
323 | "X-Gender", "KADDRESSBOOK" ); | 323 | "X-Gender", "KADDRESSBOOK" ); |
324 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 324 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
325 | "X-Children", "KADDRESSBOOK" ); | 325 | "X-Children", "KADDRESSBOOK" ); |
326 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 326 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
327 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 327 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
328 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 328 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
329 | "X-ExternalID", "KADDRESSBOOK" ); | 329 | "X-ExternalID", "KADDRESSBOOK" ); |
330 | } | 330 | } |
331 | 331 | ||
332 | AddressBook::~AddressBook() | 332 | AddressBook::~AddressBook() |
333 | { | 333 | { |
334 | delete d->mConfig; d->mConfig = 0; | 334 | delete d->mConfig; d->mConfig = 0; |
335 | delete d->mManager; d->mManager = 0; | 335 | delete d->mManager; d->mManager = 0; |
336 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 336 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
337 | delete d; d = 0; | 337 | delete d; d = 0; |
338 | } | 338 | } |
339 | 339 | ||
340 | bool AddressBook::load() | 340 | bool AddressBook::load() |
341 | { | 341 | { |
342 | 342 | ||
343 | 343 | ||
344 | clear(); | 344 | clear(); |
345 | 345 | ||
346 | KRES::Manager<Resource>::ActiveIterator it; | 346 | KRES::Manager<Resource>::ActiveIterator it; |
347 | bool ok = true; | 347 | bool ok = true; |
348 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 348 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
349 | if ( !(*it)->load() ) { | 349 | if ( !(*it)->load() ) { |
350 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 350 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
351 | ok = false; | 351 | ok = false; |
352 | } | 352 | } |
353 | 353 | ||
354 | // mark all addressees as unchanged | 354 | // mark all addressees as unchanged |
355 | Addressee::List::Iterator addrIt; | 355 | Addressee::List::Iterator addrIt; |
356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { | 356 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { |
357 | (*addrIt).setChanged( false ); | 357 | (*addrIt).setChanged( false ); |
358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); | 358 | QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); |
359 | if ( !id.isEmpty() ) { | 359 | if ( !id.isEmpty() ) { |
360 | //qDebug("setId aa %s ", id.latin1()); | 360 | //qDebug("setId aa %s ", id.latin1()); |
361 | (*addrIt).setIDStr(id ); | 361 | (*addrIt).setIDStr(id ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | blockLSEchange = true; | 364 | blockLSEchange = true; |
365 | return ok; | 365 | return ok; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool AddressBook::save( Ticket *ticket ) | 368 | bool AddressBook::save( Ticket *ticket ) |
369 | { | 369 | { |
370 | kdDebug(5700) << "AddressBook::save()"<< endl; | 370 | kdDebug(5700) << "AddressBook::save()"<< endl; |
371 | 371 | ||
372 | if ( ticket->resource() ) { | 372 | if ( ticket->resource() ) { |
373 | deleteRemovedAddressees(); | 373 | deleteRemovedAddressees(); |
374 | return ticket->resource()->save( ticket ); | 374 | return ticket->resource()->save( ticket ); |
375 | } | 375 | } |
376 | 376 | ||
377 | return false; | 377 | return false; |
378 | } | 378 | } |
379 | void AddressBook::export2File( QString fileName ) | 379 | void AddressBook::export2File( QString fileName ) |
380 | { | 380 | { |
381 | 381 | ||
382 | QFile outFile( fileName ); | 382 | QFile outFile( fileName ); |
383 | if ( !outFile.open( IO_WriteOnly ) ) { | 383 | if ( !outFile.open( IO_WriteOnly ) ) { |
384 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); | 384 | QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); |
385 | KMessageBox::error( 0, text.arg( fileName ) ); | 385 | KMessageBox::error( 0, text.arg( fileName ) ); |
386 | return ; | 386 | return ; |
387 | } | 387 | } |
388 | QTextStream t( &outFile ); | 388 | QTextStream t( &outFile ); |
389 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 389 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
390 | Iterator it; | 390 | Iterator it; |
391 | KABC::VCardConverter::Version version; | 391 | KABC::VCardConverter::Version version; |
392 | version = KABC::VCardConverter::v3_0; | 392 | version = KABC::VCardConverter::v3_0; |
393 | for ( it = begin(); it != end(); ++it ) { | 393 | for ( it = begin(); it != end(); ++it ) { |
394 | if ( !(*it).IDStr().isEmpty() ) { | 394 | if ( !(*it).IDStr().isEmpty() ) { |
395 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); | 395 | (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); |
396 | } | 396 | } |
397 | KABC::VCardConverter converter; | 397 | KABC::VCardConverter converter; |
398 | QString vcard; | 398 | QString vcard; |
399 | //Resource *resource() const; | 399 | //Resource *resource() const; |
400 | converter.addresseeToVCard( *it, vcard, version ); | 400 | converter.addresseeToVCard( *it, vcard, version ); |
401 | t << vcard << "\r\n"; | 401 | t << vcard << "\r\n"; |
402 | } | 402 | } |
403 | t << "\r\n\r\n"; | 403 | t << "\r\n\r\n"; |
404 | outFile.close(); | 404 | outFile.close(); |
405 | } | 405 | } |
406 | void AddressBook::importFromFile( QString fileName, bool replaceLabel ) | 406 | void AddressBook::importFromFile( QString fileName, bool replaceLabel, bool removeOld ) |
407 | { | 407 | { |
408 | 408 | ||
409 | KABC::Addressee::List list; | 409 | if ( removeOld ) |
410 | QFile file( fileName ); | 410 | setUntagged(); |
411 | 411 | KABC::Addressee::List list; | |
412 | file.open( IO_ReadOnly ); | 412 | QFile file( fileName ); |
413 | QByteArray rawData = file.readAll(); | 413 | file.open( IO_ReadOnly ); |
414 | file.close(); | 414 | QByteArray rawData = file.readAll(); |
415 | QString data; | 415 | file.close(); |
416 | if ( replaceLabel ) { | 416 | QString data; |
417 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); | 417 | if ( replaceLabel ) { |
418 | data.replace ( QRegExp("LABEL") , "ADR" ); | 418 | data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); |
419 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); | 419 | data.replace ( QRegExp("LABEL") , "ADR" ); |
420 | } else | 420 | data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); |
421 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); | 421 | } else |
422 | KABC::VCardTool tool; | 422 | data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); |
423 | list = tool.parseVCards( data ); | 423 | KABC::VCardTool tool; |
424 | KABC::Addressee::List::Iterator it; | 424 | list = tool.parseVCards( data ); |
425 | for ( it = list.begin(); it != list.end(); ++it ) { | 425 | KABC::Addressee::List::Iterator it; |
426 | (*it).setResource( 0 ); | 426 | for ( it = list.begin(); it != list.end(); ++it ) { |
427 | if ( replaceLabel ) | 427 | (*it).setResource( 0 ); |
428 | (*it).removeVoice(); | 428 | if ( replaceLabel ) |
429 | insertAddressee( (*it), false, true ); | 429 | (*it).removeVoice(); |
430 | if ( removeOld ) | ||
431 | (*it).setTagged( true ); | ||
432 | insertAddressee( (*it), false, true ); | ||
433 | } | ||
434 | if ( removeOld ) | ||
435 | removeUntagged(); | ||
436 | } | ||
437 | void AddressBook::setUntagged() | ||
438 | { | ||
439 | Iterator ait; | ||
440 | for ( ait = begin(); ait != end(); ++ait ) { | ||
441 | (*ait).setTagged( false ); | ||
442 | } | ||
443 | } | ||
444 | void AddressBook::removeUntagged() | ||
445 | { | ||
446 | Iterator ait; | ||
447 | for ( ait = begin(); ait != end(); ++ait ) { | ||
448 | if (!(*ait).tagged()) | ||
449 | removeAddressee( ait ); | ||
430 | } | 450 | } |
431 | 451 | ||
452 | deleteRemovedAddressees(); | ||
432 | } | 453 | } |
433 | |||
434 | bool AddressBook::saveAB() | 454 | bool AddressBook::saveAB() |
435 | { | 455 | { |
436 | bool ok = true; | 456 | bool ok = true; |
437 | 457 | ||
438 | deleteRemovedAddressees(); | 458 | deleteRemovedAddressees(); |
439 | Iterator ait; | 459 | Iterator ait; |
440 | for ( ait = begin(); ait != end(); ++ait ) { | 460 | for ( ait = begin(); ait != end(); ++ait ) { |
441 | if ( !(*ait).IDStr().isEmpty() ) { | 461 | if ( !(*ait).IDStr().isEmpty() ) { |
442 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); | 462 | (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); |
443 | } | 463 | } |
444 | } | 464 | } |
445 | KRES::Manager<Resource>::ActiveIterator it; | 465 | KRES::Manager<Resource>::ActiveIterator it; |
446 | KRES::Manager<Resource> *manager = d->mManager; | 466 | KRES::Manager<Resource> *manager = d->mManager; |
447 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 467 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
448 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 468 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
449 | Ticket *ticket = requestSaveTicket( *it ); | 469 | Ticket *ticket = requestSaveTicket( *it ); |
450 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 470 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
451 | if ( !ticket ) { | 471 | if ( !ticket ) { |
452 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 472 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
453 | .arg( (*it)->resourceName() ) ); | 473 | .arg( (*it)->resourceName() ) ); |
454 | return false; | 474 | return false; |
455 | } | 475 | } |
456 | 476 | ||
457 | //if ( !save( ticket ) ) | 477 | //if ( !save( ticket ) ) |
458 | if ( ticket->resource() ) { | 478 | if ( ticket->resource() ) { |
459 | if ( ! ticket->resource()->save( ticket ) ) | 479 | if ( ! ticket->resource()->save( ticket ) ) |
460 | ok = false; | 480 | ok = false; |
461 | } else | 481 | } else |
462 | ok = false; | 482 | ok = false; |
463 | 483 | ||
464 | } | 484 | } |
465 | } | 485 | } |
466 | return ok; | 486 | return ok; |
467 | } | 487 | } |
468 | 488 | ||
469 | AddressBook::Iterator AddressBook::begin() | 489 | AddressBook::Iterator AddressBook::begin() |
470 | { | 490 | { |
471 | Iterator it = Iterator(); | 491 | Iterator it = Iterator(); |
472 | it.d->mIt = d->mAddressees.begin(); | 492 | it.d->mIt = d->mAddressees.begin(); |
473 | return it; | 493 | return it; |
474 | } | 494 | } |
475 | 495 | ||
476 | AddressBook::ConstIterator AddressBook::begin() const | 496 | AddressBook::ConstIterator AddressBook::begin() const |
477 | { | 497 | { |
478 | ConstIterator it = ConstIterator(); | 498 | ConstIterator it = ConstIterator(); |
479 | it.d->mIt = d->mAddressees.begin(); | 499 | it.d->mIt = d->mAddressees.begin(); |
480 | return it; | 500 | return it; |
481 | } | 501 | } |
482 | 502 | ||
483 | AddressBook::Iterator AddressBook::end() | 503 | AddressBook::Iterator AddressBook::end() |
484 | { | 504 | { |
485 | Iterator it = Iterator(); | 505 | Iterator it = Iterator(); |
486 | it.d->mIt = d->mAddressees.end(); | 506 | it.d->mIt = d->mAddressees.end(); |
487 | return it; | 507 | return it; |
488 | } | 508 | } |
489 | 509 | ||
490 | AddressBook::ConstIterator AddressBook::end() const | 510 | AddressBook::ConstIterator AddressBook::end() const |
491 | { | 511 | { |
492 | ConstIterator it = ConstIterator(); | 512 | ConstIterator it = ConstIterator(); |
493 | it.d->mIt = d->mAddressees.end(); | 513 | it.d->mIt = d->mAddressees.end(); |
494 | return it; | 514 | return it; |
495 | } | 515 | } |
496 | 516 | ||
497 | void AddressBook::clear() | 517 | void AddressBook::clear() |
498 | { | 518 | { |
499 | d->mAddressees.clear(); | 519 | d->mAddressees.clear(); |
500 | } | 520 | } |
501 | 521 | ||
502 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 522 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
503 | { | 523 | { |
504 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 524 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
505 | 525 | ||
506 | if ( !resource ) | 526 | if ( !resource ) |
507 | { | 527 | { |
508 | qDebug("AddressBook::requestSaveTicket no resource" ); | 528 | qDebug("AddressBook::requestSaveTicket no resource" ); |
509 | resource = standardResource(); | 529 | resource = standardResource(); |
510 | } | 530 | } |
511 | 531 | ||
512 | KRES::Manager<Resource>::ActiveIterator it; | 532 | KRES::Manager<Resource>::ActiveIterator it; |
513 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 533 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
514 | if ( (*it) == resource ) { | 534 | if ( (*it) == resource ) { |
515 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 535 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
516 | return 0; | 536 | return 0; |
517 | else | 537 | else |
518 | return (*it)->requestSaveTicket(); | 538 | return (*it)->requestSaveTicket(); |
519 | } | 539 | } |
520 | } | 540 | } |
521 | 541 | ||
522 | return 0; | 542 | return 0; |
523 | } | 543 | } |
524 | 544 | ||
525 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) | 545 | void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) |
526 | { | 546 | { |
527 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { | 547 | if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { |
528 | //qDebug("block insert "); | 548 | //qDebug("block insert "); |
529 | return; | 549 | return; |
530 | } | 550 | } |
531 | //qDebug("inserting.... %s ",a.uid().latin1() ); | 551 | //qDebug("inserting.... %s ",a.uid().latin1() ); |
532 | bool found = false; | 552 | bool found = false; |
533 | Addressee::List::Iterator it; | 553 | Addressee::List::Iterator it; |
534 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 554 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
535 | if ( a.uid() == (*it).uid() ) { | 555 | if ( a.uid() == (*it).uid() ) { |
536 | 556 | ||
537 | bool changed = false; | 557 | bool changed = false; |
538 | Addressee addr = a; | 558 | Addressee addr = a; |
539 | if ( addr != (*it) ) | 559 | if ( addr != (*it) ) |
540 | changed = true; | 560 | changed = true; |
541 | 561 | ||
542 | if ( takeResource ) { | 562 | if ( takeResource ) { |
543 | Resource * res = (*it).resource(); | 563 | Resource * res = (*it).resource(); |
544 | (*it) = a; | 564 | (*it) = a; |
545 | (*it).setResource( res ); | 565 | (*it).setResource( res ); |
546 | } else { | 566 | } else { |
547 | (*it) = a; | 567 | (*it) = a; |
548 | if ( (*it).resource() == 0 ) | 568 | if ( (*it).resource() == 0 ) |
549 | (*it).setResource( standardResource() ); | 569 | (*it).setResource( standardResource() ); |
550 | } | 570 | } |
551 | if ( changed ) { | 571 | if ( changed ) { |
552 | if ( setRev ) { | 572 | if ( setRev ) { |
553 | 573 | ||
554 | // get rid of micro seconds | 574 | // get rid of micro seconds |
555 | QDateTime dt = QDateTime::currentDateTime(); | 575 | QDateTime dt = QDateTime::currentDateTime(); |
556 | QTime t = dt.time(); | 576 | QTime t = dt.time(); |
557 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 577 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
558 | (*it).setRevision( dt ); | 578 | (*it).setRevision( dt ); |
559 | } | 579 | } |
560 | (*it).setChanged( true ); | 580 | (*it).setChanged( true ); |
561 | } | 581 | } |
562 | 582 | ||
563 | found = true; | 583 | found = true; |
564 | } else { | 584 | } else { |
565 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 585 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
566 | QString name = (*it).uid().mid( 19 ); | 586 | QString name = (*it).uid().mid( 19 ); |
567 | Addressee b = a; | 587 | Addressee b = a; |
568 | QString id = b.getID( name ); | 588 | QString id = b.getID( name ); |
569 | if ( ! id.isEmpty() ) { | 589 | if ( ! id.isEmpty() ) { |
570 | QString des = (*it).note(); | 590 | QString des = (*it).note(); |
571 | int startN; | 591 | int startN; |
572 | if( (startN = des.find( id ) ) >= 0 ) { | 592 | if( (startN = des.find( id ) ) >= 0 ) { |
573 | int endN = des.find( ",", startN+1 ); | 593 | int endN = des.find( ",", startN+1 ); |
574 | des = des.left( startN ) + des.mid( endN+1 ); | 594 | des = des.left( startN ) + des.mid( endN+1 ); |
575 | (*it).setNote( des ); | 595 | (*it).setNote( des ); |
576 | } | 596 | } |
577 | } | 597 | } |
578 | } | 598 | } |
579 | } | 599 | } |
580 | } | 600 | } |
581 | if ( found ) | 601 | if ( found ) |
582 | return; | 602 | return; |
583 | d->mAddressees.append( a ); | 603 | d->mAddressees.append( a ); |
584 | Addressee& addr = d->mAddressees.last(); | 604 | Addressee& addr = d->mAddressees.last(); |
585 | if ( addr.resource() == 0 ) | 605 | if ( addr.resource() == 0 ) |
586 | addr.setResource( standardResource() ); | 606 | addr.setResource( standardResource() ); |
587 | 607 | ||
588 | addr.setChanged( true ); | 608 | addr.setChanged( true ); |
589 | } | 609 | } |
590 | 610 | ||
591 | void AddressBook::removeAddressee( const Addressee &a ) | 611 | void AddressBook::removeAddressee( const Addressee &a ) |
592 | { | 612 | { |
593 | Iterator it; | 613 | Iterator it; |
594 | Iterator it2; | 614 | Iterator it2; |
595 | bool found = false; | 615 | bool found = false; |
596 | for ( it = begin(); it != end(); ++it ) { | 616 | for ( it = begin(); it != end(); ++it ) { |
597 | if ( a.uid() == (*it).uid() ) { | 617 | if ( a.uid() == (*it).uid() ) { |
598 | found = true; | 618 | found = true; |
599 | it2 = it; | 619 | it2 = it; |
600 | } else { | 620 | } else { |
601 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { | 621 | if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { |
602 | QString name = (*it).uid().mid( 19 ); | 622 | QString name = (*it).uid().mid( 19 ); |
603 | Addressee b = a; | 623 | Addressee b = a; |
604 | QString id = b.getID( name ); | 624 | QString id = b.getID( name ); |
605 | if ( ! id.isEmpty() ) { | 625 | if ( ! id.isEmpty() ) { |
606 | QString des = (*it).note(); | 626 | QString des = (*it).note(); |
607 | if( des.find( id ) < 0 ) { | 627 | if( des.find( id ) < 0 ) { |
608 | des += id + ","; | 628 | des += id + ","; |
609 | (*it).setNote( des ); | 629 | (*it).setNote( des ); |
610 | } | 630 | } |
611 | } | 631 | } |
612 | } | 632 | } |
613 | 633 | ||
614 | } | 634 | } |
615 | } | 635 | } |
616 | 636 | ||
617 | if ( found ) | 637 | if ( found ) |
618 | removeAddressee( it2 ); | 638 | removeAddressee( it2 ); |
619 | 639 | ||
620 | } | 640 | } |
621 | 641 | ||
622 | void AddressBook::removeSyncAddressees( bool removeDeleted ) | 642 | void AddressBook::removeSyncAddressees( bool removeDeleted ) |
623 | { | 643 | { |
624 | Iterator it = begin(); | 644 | Iterator it = begin(); |
625 | Iterator it2 ; | 645 | Iterator it2 ; |
626 | QDateTime dt ( QDate( 2004,1,1) ); | 646 | QDateTime dt ( QDate( 2004,1,1) ); |
627 | while ( it != end() ) { | 647 | while ( it != end() ) { |
628 | (*it).setRevision( dt ); | 648 | (*it).setRevision( dt ); |
629 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); | 649 | (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); |
630 | (*it).setIDStr(""); | 650 | (*it).setIDStr(""); |
631 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { | 651 | if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { |
632 | it2 = it; | 652 | it2 = it; |
633 | //qDebug("removing %s ",(*it).uid().latin1() ); | 653 | //qDebug("removing %s ",(*it).uid().latin1() ); |
634 | ++it; | 654 | ++it; |
635 | removeAddressee( it2 ); | 655 | removeAddressee( it2 ); |
636 | } else { | 656 | } else { |
637 | //qDebug("skipping %s ",(*it).uid().latin1() ); | 657 | //qDebug("skipping %s ",(*it).uid().latin1() ); |
638 | ++it; | 658 | ++it; |
639 | } | 659 | } |
640 | } | 660 | } |
641 | deleteRemovedAddressees(); | 661 | deleteRemovedAddressees(); |
642 | } | 662 | } |
643 | 663 | ||
644 | void AddressBook::removeAddressee( const Iterator &it ) | 664 | void AddressBook::removeAddressee( const Iterator &it ) |
645 | { | 665 | { |
646 | d->mRemovedAddressees.append( (*it) ); | 666 | d->mRemovedAddressees.append( (*it) ); |
647 | d->mAddressees.remove( it.d->mIt ); | 667 | d->mAddressees.remove( it.d->mIt ); |
648 | } | 668 | } |
649 | 669 | ||
650 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 670 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
651 | { | 671 | { |
652 | Iterator it; | 672 | Iterator it; |
653 | for ( it = begin(); it != end(); ++it ) { | 673 | for ( it = begin(); it != end(); ++it ) { |
654 | if ( a.uid() == (*it).uid() ) { | 674 | if ( a.uid() == (*it).uid() ) { |
655 | return it; | 675 | return it; |
656 | } | 676 | } |
657 | } | 677 | } |
658 | return end(); | 678 | return end(); |
659 | } | 679 | } |
660 | 680 | ||
661 | Addressee AddressBook::findByUid( const QString &uid ) | 681 | Addressee AddressBook::findByUid( const QString &uid ) |
662 | { | 682 | { |
663 | Iterator it; | 683 | Iterator it; |
664 | for ( it = begin(); it != end(); ++it ) { | 684 | for ( it = begin(); it != end(); ++it ) { |
665 | if ( uid == (*it).uid() ) { | 685 | if ( uid == (*it).uid() ) { |
666 | return *it; | 686 | return *it; |
667 | } | 687 | } |
668 | } | 688 | } |
669 | return Addressee(); | 689 | return Addressee(); |
670 | } | 690 | } |
671 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | 691 | void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) |
672 | { | 692 | { |
673 | //qDebug("AddressBook::preExternSync "); | 693 | //qDebug("AddressBook::preExternSync "); |
674 | AddressBook::Iterator it; | 694 | AddressBook::Iterator it; |
675 | for ( it = begin(); it != end(); ++it ) { | 695 | for ( it = begin(); it != end(); ++it ) { |
676 | (*it).setID( csd, (*it).externalUID() ); | 696 | (*it).setID( csd, (*it).externalUID() ); |
677 | (*it).computeCsum( csd ); | 697 | (*it).computeCsum( csd ); |
678 | } | 698 | } |
679 | mergeAB( aBook ,csd ); | 699 | mergeAB( aBook ,csd ); |
680 | } | 700 | } |
681 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | 701 | void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) |
682 | { | 702 | { |
683 | //qDebug("AddressBook::postExternSync "); | 703 | //qDebug("AddressBook::postExternSync "); |
684 | AddressBook::Iterator it; | 704 | AddressBook::Iterator it; |
685 | for ( it = begin(); it != end(); ++it ) { | 705 | for ( it = begin(); it != end(); ++it ) { |
686 | // qDebug("check uid %s ", (*it).uid().latin1() ); | 706 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
687 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 707 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
688 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { | 708 | (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { |
689 | Addressee ad = aBook->findByUid( ( (*it).uid() )); | 709 | Addressee ad = aBook->findByUid( ( (*it).uid() )); |
690 | if ( ad.isEmpty() ) { | 710 | if ( ad.isEmpty() ) { |
691 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); | 711 | qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); |
692 | } else { | 712 | } else { |
693 | (*it).computeCsum( csd ); | 713 | (*it).computeCsum( csd ); |
694 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) | 714 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) |
695 | ad.setID( csd, (*it).externalUID() ); | 715 | ad.setID( csd, (*it).externalUID() ); |
696 | ad.setCsum( csd, (*it).getCsum( csd ) ); | 716 | ad.setCsum( csd, (*it).getCsum( csd ) ); |
697 | aBook->insertAddressee( ad ); | 717 | aBook->insertAddressee( ad ); |
698 | } | 718 | } |
699 | } | 719 | } |
700 | } | 720 | } |
701 | } | 721 | } |
702 | 722 | ||
703 | bool AddressBook::containsExternalUid( const QString& uid ) | 723 | bool AddressBook::containsExternalUid( const QString& uid ) |
704 | { | 724 | { |
705 | Iterator it; | 725 | Iterator it; |
706 | for ( it = begin(); it != end(); ++it ) { | 726 | for ( it = begin(); it != end(); ++it ) { |
707 | if ( uid == (*it).externalUID( ) ) | 727 | if ( uid == (*it).externalUID( ) ) |
708 | return true; | 728 | return true; |
709 | } | 729 | } |
710 | return false; | 730 | return false; |
711 | } | 731 | } |
712 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) | 732 | Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) |
713 | { | 733 | { |
714 | Iterator it; | 734 | Iterator it; |
715 | for ( it = begin(); it != end(); ++it ) { | 735 | for ( it = begin(); it != end(); ++it ) { |
716 | if ( uid == (*it).getID( profile ) ) | 736 | if ( uid == (*it).getID( profile ) ) |
717 | return (*it); | 737 | return (*it); |
718 | } | 738 | } |
719 | return Addressee(); | 739 | return Addressee(); |
720 | } | 740 | } |
721 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) | 741 | void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) |
722 | { | 742 | { |
723 | Iterator it; | 743 | Iterator it; |
724 | Addressee ad; | 744 | Addressee ad; |
725 | for ( it = begin(); it != end(); ++it ) { | 745 | for ( it = begin(); it != end(); ++it ) { |
726 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); | 746 | ad = aBook->findByExternUid( (*it).externalUID(), profile ); |
727 | if ( !ad.isEmpty() ) { | 747 | if ( !ad.isEmpty() ) { |
728 | (*it).mergeContact( ad ); | 748 | (*it).mergeContact( ad ); |
729 | } | 749 | } |
730 | } | 750 | } |
731 | #if 0 | 751 | #if 0 |
732 | // test only | 752 | // test only |
733 | for ( it = begin(); it != end(); ++it ) { | 753 | for ( it = begin(); it != end(); ++it ) { |
734 | 754 | ||
735 | qDebug("uid %s ", (*it).uid().latin1()); | 755 | qDebug("uid %s ", (*it).uid().latin1()); |
736 | } | 756 | } |
737 | #endif | 757 | #endif |
738 | } | 758 | } |
739 | 759 | ||
740 | #if 0 | 760 | #if 0 |
741 | Addressee::List AddressBook::getExternLastSyncAddressees() | 761 | Addressee::List AddressBook::getExternLastSyncAddressees() |
742 | { | 762 | { |
743 | Addressee::List results; | 763 | Addressee::List results; |
744 | 764 | ||
745 | Iterator it; | 765 | Iterator it; |
746 | for ( it = begin(); it != end(); ++it ) { | 766 | for ( it = begin(); it != end(); ++it ) { |
747 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { | 767 | if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { |
748 | if ( (*it).familyName().left(4) == "!E: " ) | 768 | if ( (*it).familyName().left(4) == "!E: " ) |
749 | results.append( *it ); | 769 | results.append( *it ); |
750 | } | 770 | } |
751 | } | 771 | } |
752 | 772 | ||
753 | return results; | 773 | return results; |
754 | } | 774 | } |
755 | #endif | 775 | #endif |
756 | void AddressBook::resetTempSyncStat() | 776 | void AddressBook::resetTempSyncStat() |
757 | { | 777 | { |
758 | Iterator it; | 778 | Iterator it; |
759 | for ( it = begin(); it != end(); ++it ) { | 779 | for ( it = begin(); it != end(); ++it ) { |
760 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | 780 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); |
761 | } | 781 | } |
762 | 782 | ||
763 | } | 783 | } |
764 | 784 | ||
765 | QStringList AddressBook:: uidList() | 785 | QStringList AddressBook:: uidList() |
766 | { | 786 | { |
767 | QStringList results; | 787 | QStringList results; |
768 | Iterator it; | 788 | Iterator it; |
769 | for ( it = begin(); it != end(); ++it ) { | 789 | for ( it = begin(); it != end(); ++it ) { |
770 | results.append( (*it).uid() ); | 790 | results.append( (*it).uid() ); |
771 | } | 791 | } |
772 | return results; | 792 | return results; |
773 | } | 793 | } |
774 | 794 | ||
775 | 795 | ||
776 | Addressee::List AddressBook::allAddressees() | 796 | Addressee::List AddressBook::allAddressees() |
777 | { | 797 | { |
778 | return d->mAddressees; | 798 | return d->mAddressees; |
779 | 799 | ||
780 | } | 800 | } |
781 | 801 | ||
782 | Addressee::List AddressBook::findByName( const QString &name ) | 802 | Addressee::List AddressBook::findByName( const QString &name ) |
783 | { | 803 | { |
784 | Addressee::List results; | 804 | Addressee::List results; |
785 | 805 | ||
786 | Iterator it; | 806 | Iterator it; |
787 | for ( it = begin(); it != end(); ++it ) { | 807 | for ( it = begin(); it != end(); ++it ) { |
788 | if ( name == (*it).realName() ) { | 808 | if ( name == (*it).realName() ) { |
789 | results.append( *it ); | 809 | results.append( *it ); |
790 | } | 810 | } |
791 | } | 811 | } |
792 | 812 | ||
793 | return results; | 813 | return results; |
794 | } | 814 | } |
795 | 815 | ||
796 | Addressee::List AddressBook::findByEmail( const QString &email ) | 816 | Addressee::List AddressBook::findByEmail( const QString &email ) |
797 | { | 817 | { |
798 | Addressee::List results; | 818 | Addressee::List results; |
799 | QStringList mailList; | 819 | QStringList mailList; |
800 | 820 | ||
801 | Iterator it; | 821 | Iterator it; |
802 | for ( it = begin(); it != end(); ++it ) { | 822 | for ( it = begin(); it != end(); ++it ) { |
803 | mailList = (*it).emails(); | 823 | mailList = (*it).emails(); |
804 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 824 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
805 | if ( email == (*ite) ) { | 825 | if ( email == (*ite) ) { |
806 | results.append( *it ); | 826 | results.append( *it ); |
807 | } | 827 | } |
808 | } | 828 | } |
809 | } | 829 | } |
810 | 830 | ||
811 | return results; | 831 | return results; |
812 | } | 832 | } |
813 | 833 | ||
814 | Addressee::List AddressBook::findByCategory( const QString &category ) | 834 | Addressee::List AddressBook::findByCategory( const QString &category ) |
815 | { | 835 | { |
816 | Addressee::List results; | 836 | Addressee::List results; |
817 | 837 | ||
818 | Iterator it; | 838 | Iterator it; |
819 | for ( it = begin(); it != end(); ++it ) { | 839 | for ( it = begin(); it != end(); ++it ) { |
820 | if ( (*it).hasCategory( category) ) { | 840 | if ( (*it).hasCategory( category) ) { |
821 | results.append( *it ); | 841 | results.append( *it ); |
822 | } | 842 | } |
823 | } | 843 | } |
824 | 844 | ||
825 | return results; | 845 | return results; |
826 | } | 846 | } |
827 | 847 | ||
828 | void AddressBook::dump() const | 848 | void AddressBook::dump() const |
829 | { | 849 | { |
830 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 850 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
831 | 851 | ||
832 | ConstIterator it; | 852 | ConstIterator it; |
833 | for( it = begin(); it != end(); ++it ) { | 853 | for( it = begin(); it != end(); ++it ) { |
834 | (*it).dump(); | 854 | (*it).dump(); |
835 | } | 855 | } |
836 | 856 | ||
837 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 857 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
838 | } | 858 | } |
839 | 859 | ||
840 | QString AddressBook::identifier() | 860 | QString AddressBook::identifier() |
841 | { | 861 | { |
842 | QStringList identifier; | 862 | QStringList identifier; |
843 | 863 | ||
844 | 864 | ||
845 | KRES::Manager<Resource>::ActiveIterator it; | 865 | KRES::Manager<Resource>::ActiveIterator it; |
846 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 866 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
847 | if ( !(*it)->identifier().isEmpty() ) | 867 | if ( !(*it)->identifier().isEmpty() ) |
848 | identifier.append( (*it)->identifier() ); | 868 | identifier.append( (*it)->identifier() ); |
849 | } | 869 | } |
850 | 870 | ||
851 | return identifier.join( ":" ); | 871 | return identifier.join( ":" ); |
852 | } | 872 | } |
853 | 873 | ||
854 | Field::List AddressBook::fields( int category ) | 874 | Field::List AddressBook::fields( int category ) |
855 | { | 875 | { |
856 | if ( d->mAllFields.isEmpty() ) { | 876 | if ( d->mAllFields.isEmpty() ) { |
857 | d->mAllFields = Field::allFields(); | 877 | d->mAllFields = Field::allFields(); |
858 | } | 878 | } |
859 | 879 | ||
860 | if ( category == Field::All ) return d->mAllFields; | 880 | if ( category == Field::All ) return d->mAllFields; |
861 | 881 | ||
862 | Field::List result; | 882 | Field::List result; |
863 | Field::List::ConstIterator it; | 883 | Field::List::ConstIterator it; |
864 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 884 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
865 | if ( (*it)->category() & category ) result.append( *it ); | 885 | if ( (*it)->category() & category ) result.append( *it ); |
866 | } | 886 | } |
867 | 887 | ||
868 | return result; | 888 | return result; |
869 | } | 889 | } |
870 | 890 | ||
871 | bool AddressBook::addCustomField( const QString &label, int category, | 891 | bool AddressBook::addCustomField( const QString &label, int category, |
872 | const QString &key, const QString &app ) | 892 | const QString &key, const QString &app ) |
873 | { | 893 | { |
874 | if ( d->mAllFields.isEmpty() ) { | 894 | if ( d->mAllFields.isEmpty() ) { |
875 | d->mAllFields = Field::allFields(); | 895 | d->mAllFields = Field::allFields(); |
876 | } | 896 | } |
877 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 897 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
878 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 898 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
879 | 899 | ||
880 | QString k = key.isNull() ? label : key; | 900 | QString k = key.isNull() ? label : key; |
881 | 901 | ||
882 | Field *field = Field::createCustomField( label, category, k, a ); | 902 | Field *field = Field::createCustomField( label, category, k, a ); |
883 | 903 | ||
884 | if ( !field ) return false; | 904 | if ( !field ) return false; |
885 | 905 | ||
886 | d->mAllFields.append( field ); | 906 | d->mAllFields.append( field ); |
887 | 907 | ||
888 | return true; | 908 | return true; |
889 | } | 909 | } |
890 | 910 | ||
891 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 911 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
892 | { | 912 | { |
893 | if (!ab.d) return s; | 913 | if (!ab.d) return s; |
894 | 914 | ||
895 | return s << ab.d->mAddressees; | 915 | return s << ab.d->mAddressees; |
896 | } | 916 | } |
897 | 917 | ||
898 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 918 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
899 | { | 919 | { |
900 | if (!ab.d) return s; | 920 | if (!ab.d) return s; |
901 | 921 | ||
902 | s >> ab.d->mAddressees; | 922 | s >> ab.d->mAddressees; |
903 | 923 | ||
904 | return s; | 924 | return s; |
905 | } | 925 | } |
906 | 926 | ||
907 | bool AddressBook::addResource( Resource *resource ) | 927 | bool AddressBook::addResource( Resource *resource ) |
908 | { | 928 | { |
909 | if ( !resource->open() ) { | 929 | if ( !resource->open() ) { |
910 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 930 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
911 | return false; | 931 | return false; |
912 | } | 932 | } |
913 | 933 | ||
914 | resource->setAddressBook( this ); | 934 | resource->setAddressBook( this ); |
915 | 935 | ||
916 | d->mManager->add( resource ); | 936 | d->mManager->add( resource ); |
917 | return true; | 937 | return true; |
918 | } | 938 | } |
919 | 939 | ||
920 | bool AddressBook::removeResource( Resource *resource ) | 940 | bool AddressBook::removeResource( Resource *resource ) |
921 | { | 941 | { |
922 | resource->close(); | 942 | resource->close(); |
923 | 943 | ||
924 | if ( resource == standardResource() ) | 944 | if ( resource == standardResource() ) |
925 | d->mManager->setStandardResource( 0 ); | 945 | d->mManager->setStandardResource( 0 ); |
926 | 946 | ||
927 | resource->setAddressBook( 0 ); | 947 | resource->setAddressBook( 0 ); |
928 | 948 | ||
929 | d->mManager->remove( resource ); | 949 | d->mManager->remove( resource ); |
930 | return true; | 950 | return true; |
931 | } | 951 | } |
932 | 952 | ||
933 | QPtrList<Resource> AddressBook::resources() | 953 | QPtrList<Resource> AddressBook::resources() |
934 | { | 954 | { |
935 | QPtrList<Resource> list; | 955 | QPtrList<Resource> list; |
936 | 956 | ||
937 | // qDebug("AddressBook::resources() 1"); | 957 | // qDebug("AddressBook::resources() 1"); |
938 | 958 | ||
939 | KRES::Manager<Resource>::ActiveIterator it; | 959 | KRES::Manager<Resource>::ActiveIterator it; |
940 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 960 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
941 | list.append( *it ); | 961 | list.append( *it ); |
942 | 962 | ||
943 | return list; | 963 | return list; |
944 | } | 964 | } |
945 | 965 | ||
946 | /*US | 966 | /*US |
947 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 967 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
948 | { | 968 | { |
949 | delete d->mErrorHandler; | 969 | delete d->mErrorHandler; |
950 | d->mErrorHandler = handler; | 970 | d->mErrorHandler = handler; |
951 | } | 971 | } |
952 | */ | 972 | */ |
953 | 973 | ||
954 | void AddressBook::error( const QString& msg ) | 974 | void AddressBook::error( const QString& msg ) |
955 | { | 975 | { |
956 | /*US | 976 | /*US |
957 | if ( !d->mErrorHandler ) // create default error handler | 977 | if ( !d->mErrorHandler ) // create default error handler |
958 | d->mErrorHandler = new ConsoleErrorHandler; | 978 | d->mErrorHandler = new ConsoleErrorHandler; |
959 | 979 | ||
960 | if ( d->mErrorHandler ) | 980 | if ( d->mErrorHandler ) |
961 | d->mErrorHandler->error( msg ); | 981 | d->mErrorHandler->error( msg ); |
962 | else | 982 | else |
963 | kdError(5700) << "no error handler defined" << endl; | 983 | kdError(5700) << "no error handler defined" << endl; |
964 | */ | 984 | */ |
965 | kdDebug(5700) << "msg" << endl; | 985 | kdDebug(5700) << "msg" << endl; |
966 | qDebug(msg); | 986 | qDebug(msg); |
967 | } | 987 | } |
968 | 988 | ||
969 | void AddressBook::deleteRemovedAddressees() | 989 | void AddressBook::deleteRemovedAddressees() |
970 | { | 990 | { |
971 | Addressee::List::Iterator it; | 991 | Addressee::List::Iterator it; |
972 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 992 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
973 | Resource *resource = (*it).resource(); | 993 | Resource *resource = (*it).resource(); |
974 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 994 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
975 | resource->removeAddressee( *it ); | 995 | resource->removeAddressee( *it ); |
976 | } | 996 | } |
977 | 997 | ||
978 | d->mRemovedAddressees.clear(); | 998 | d->mRemovedAddressees.clear(); |
979 | } | 999 | } |
980 | 1000 | ||
981 | void AddressBook::setStandardResource( Resource *resource ) | 1001 | void AddressBook::setStandardResource( Resource *resource ) |
982 | { | 1002 | { |
983 | // qDebug("AddressBook::setStandardResource 1"); | 1003 | // qDebug("AddressBook::setStandardResource 1"); |
984 | d->mManager->setStandardResource( resource ); | 1004 | d->mManager->setStandardResource( resource ); |
985 | } | 1005 | } |
986 | 1006 | ||
987 | Resource *AddressBook::standardResource() | 1007 | Resource *AddressBook::standardResource() |
988 | { | 1008 | { |
989 | return d->mManager->standardResource(); | 1009 | return d->mManager->standardResource(); |
990 | } | 1010 | } |
991 | 1011 | ||
992 | KRES::Manager<Resource> *AddressBook::resourceManager() | 1012 | KRES::Manager<Resource> *AddressBook::resourceManager() |
993 | { | 1013 | { |
994 | return d->mManager; | 1014 | return d->mManager; |
995 | } | 1015 | } |
996 | 1016 | ||
997 | void AddressBook::cleanUp() | 1017 | void AddressBook::cleanUp() |
998 | { | 1018 | { |
999 | KRES::Manager<Resource>::ActiveIterator it; | 1019 | KRES::Manager<Resource>::ActiveIterator it; |
1000 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 1020 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
1001 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 1021 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
1002 | (*it)->cleanUp(); | 1022 | (*it)->cleanUp(); |
1003 | } | 1023 | } |
1004 | } | 1024 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index cea1b03..532e05d 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,341 +1,343 @@ | |||
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 | void export2File( QString fileName ); | 145 | void export2File( QString fileName ); |
146 | void importFromFile( QString fileName, bool replaceLabel = false ); | 146 | void importFromFile( QString fileName, bool replaceLabel = false, bool removeOld = false ); |
147 | void setUntagged(); | ||
148 | void removeUntagged(); | ||
147 | /** | 149 | /** |
148 | Returns a iterator for first entry of address book. | 150 | Returns a iterator for first entry of address book. |
149 | */ | 151 | */ |
150 | Iterator begin(); | 152 | Iterator begin(); |
151 | 153 | ||
152 | /** | 154 | /** |
153 | Returns a const iterator for first entry of address book. | 155 | Returns a const iterator for first entry of address book. |
154 | */ | 156 | */ |
155 | ConstIterator begin() const; | 157 | ConstIterator begin() const; |
156 | 158 | ||
157 | /** | 159 | /** |
158 | Returns a iterator for first entry of address book. | 160 | Returns a iterator for first entry of address book. |
159 | */ | 161 | */ |
160 | Iterator end(); | 162 | Iterator end(); |
161 | 163 | ||
162 | /** | 164 | /** |
163 | Returns a const iterator for first entry of address book. | 165 | Returns a const iterator for first entry of address book. |
164 | */ | 166 | */ |
165 | ConstIterator end() const; | 167 | ConstIterator end() const; |
166 | 168 | ||
167 | /** | 169 | /** |
168 | Removes all entries from address book. | 170 | Removes all entries from address book. |
169 | */ | 171 | */ |
170 | void clear(); | 172 | void clear(); |
171 | 173 | ||
172 | /** | 174 | /** |
173 | Insert an Addressee object into address book. If an object with the same | 175 | Insert an Addressee object into address book. If an object with the same |
174 | unique id already exists in the address book it it replaced by the new | 176 | unique id already exists in the address book it it replaced by the new |
175 | one. If not the new object is appended to the address book. | 177 | one. If not the new object is appended to the address book. |
176 | */ | 178 | */ |
177 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); | 179 | void insertAddressee( const Addressee &, bool setRev = true, bool takeResource = false); |
178 | 180 | ||
179 | /** | 181 | /** |
180 | Removes entry from the address book. | 182 | Removes entry from the address book. |
181 | */ | 183 | */ |
182 | void removeAddressee( const Addressee & ); | 184 | void removeAddressee( const Addressee & ); |
183 | 185 | ||
184 | /** | 186 | /** |
185 | This is like @ref removeAddressee() just above, with the difference that | 187 | This is like @ref removeAddressee() just above, with the difference that |
186 | the first element is a iterator, returned by @ref begin(). | 188 | the first element is a iterator, returned by @ref begin(). |
187 | */ | 189 | */ |
188 | void removeAddressee( const Iterator & ); | 190 | void removeAddressee( const Iterator & ); |
189 | 191 | ||
190 | /** | 192 | /** |
191 | Find the specified entry in address book. Returns end(), if the entry | 193 | Find the specified entry in address book. Returns end(), if the entry |
192 | couldn't be found. | 194 | couldn't be found. |
193 | */ | 195 | */ |
194 | Iterator find( const Addressee & ); | 196 | Iterator find( const Addressee & ); |
195 | 197 | ||
196 | /** | 198 | /** |
197 | Find the entry specified by an unique id. Returns an empty Addressee | 199 | Find the entry specified by an unique id. Returns an empty Addressee |
198 | object, if the address book does not contain an entry with this id. | 200 | object, if the address book does not contain an entry with this id. |
199 | */ | 201 | */ |
200 | Addressee findByUid( const QString & ); | 202 | Addressee findByUid( const QString & ); |
201 | 203 | ||
202 | 204 | ||
203 | /** | 205 | /** |
204 | Returns a list of all addressees in the address book. This list can | 206 | Returns a list of all addressees in the address book. This list can |
205 | be sorted with @ref KABC::AddresseeList for example. | 207 | be sorted with @ref KABC::AddresseeList for example. |
206 | */ | 208 | */ |
207 | Addressee::List allAddressees(); | 209 | Addressee::List allAddressees(); |
208 | 210 | ||
209 | /** | 211 | /** |
210 | Find all entries with the specified name in the address book. Returns | 212 | Find all entries with the specified name in the address book. Returns |
211 | an empty list, if no entries could be found. | 213 | an empty list, if no entries could be found. |
212 | */ | 214 | */ |
213 | Addressee::List findByName( const QString & ); | 215 | Addressee::List findByName( const QString & ); |
214 | 216 | ||
215 | /** | 217 | /** |
216 | Find all entries with the specified email address in the address book. | 218 | Find all entries with the specified email address in the address book. |
217 | Returns an empty list, if no entries could be found. | 219 | Returns an empty list, if no entries could be found. |
218 | */ | 220 | */ |
219 | Addressee::List findByEmail( const QString & ); | 221 | Addressee::List findByEmail( const QString & ); |
220 | 222 | ||
221 | /** | 223 | /** |
222 | Find all entries wich have the specified category in the address book. | 224 | Find all entries wich have the specified category in the address book. |
223 | Returns an empty list, if no entries could be found. | 225 | Returns an empty list, if no entries could be found. |
224 | */ | 226 | */ |
225 | Addressee::List findByCategory( const QString & ); | 227 | Addressee::List findByCategory( const QString & ); |
226 | 228 | ||
227 | /** | 229 | /** |
228 | Return a string identifying this addressbook. | 230 | Return a string identifying this addressbook. |
229 | */ | 231 | */ |
230 | virtual QString identifier(); | 232 | virtual QString identifier(); |
231 | 233 | ||
232 | /** | 234 | /** |
233 | Used for debug output. | 235 | Used for debug output. |
234 | */ | 236 | */ |
235 | void dump() const; | 237 | void dump() const; |
236 | 238 | ||
237 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 239 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
238 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 240 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
239 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 241 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
240 | 242 | ||
241 | /** | 243 | /** |
242 | Return list of all Fields known to the address book which are associated | 244 | Return list of all Fields known to the address book which are associated |
243 | with the given field category. | 245 | with the given field category. |
244 | */ | 246 | */ |
245 | Field::List fields( int category = Field::All ); | 247 | Field::List fields( int category = Field::All ); |
246 | 248 | ||
247 | /** | 249 | /** |
248 | Add custom field to address book. | 250 | Add custom field to address book. |
249 | 251 | ||
250 | @param label User visible label of the field. | 252 | @param label User visible label of the field. |
251 | @param category Ored list of field categories. | 253 | @param category Ored list of field categories. |
252 | @param key Identifier used as key for reading and writing the field. | 254 | @param key Identifier used as key for reading and writing the field. |
253 | @param app String used as application key for reading and writing | 255 | @param app String used as application key for reading and writing |
254 | the field. | 256 | the field. |
255 | */ | 257 | */ |
256 | bool addCustomField( const QString &label, int category = Field::All, | 258 | bool addCustomField( const QString &label, int category = Field::All, |
257 | const QString &key = QString::null, | 259 | const QString &key = QString::null, |
258 | const QString &app = QString::null ); | 260 | const QString &app = QString::null ); |
259 | 261 | ||
260 | 262 | ||
261 | /** | 263 | /** |
262 | Add address book resource. | 264 | Add address book resource. |
263 | */ | 265 | */ |
264 | bool addResource( Resource * ); | 266 | bool addResource( Resource * ); |
265 | 267 | ||
266 | /** | 268 | /** |
267 | Remove address book resource. | 269 | Remove address book resource. |
268 | */ | 270 | */ |
269 | bool removeResource( Resource * ); | 271 | bool removeResource( Resource * ); |
270 | 272 | ||
271 | /** | 273 | /** |
272 | Return pointer list of all resources. | 274 | Return pointer list of all resources. |
273 | */ | 275 | */ |
274 | QPtrList<Resource> resources(); | 276 | QPtrList<Resource> resources(); |
275 | 277 | ||
276 | /** | 278 | /** |
277 | Set the @p ErrorHandler, that is used by @ref error() to | 279 | Set the @p ErrorHandler, that is used by @ref error() to |
278 | provide gui-independend error messages. | 280 | provide gui-independend error messages. |
279 | */ | 281 | */ |
280 | void setErrorHandler( ErrorHandler * ); | 282 | void setErrorHandler( ErrorHandler * ); |
281 | 283 | ||
282 | /** | 284 | /** |
283 | Shows gui independend error messages. | 285 | Shows gui independend error messages. |
284 | */ | 286 | */ |
285 | void error( const QString& ); | 287 | void error( const QString& ); |
286 | 288 | ||
287 | /** | 289 | /** |
288 | Query all resources to clean up their lock files | 290 | Query all resources to clean up their lock files |
289 | */ | 291 | */ |
290 | void cleanUp(); | 292 | void cleanUp(); |
291 | 293 | ||
292 | // sync stuff | 294 | // sync stuff |
293 | //Addressee::List getExternLastSyncAddressees(); | 295 | //Addressee::List getExternLastSyncAddressees(); |
294 | void resetTempSyncStat(); | 296 | void resetTempSyncStat(); |
295 | QStringList uidList(); | 297 | QStringList uidList(); |
296 | void removeSyncAddressees( bool removeDeleted = false ); | 298 | void removeSyncAddressees( bool removeDeleted = false ); |
297 | void mergeAB( AddressBook *aBook, const QString& profile ); | 299 | void mergeAB( AddressBook *aBook, const QString& profile ); |
298 | Addressee findByExternUid( const QString& uid , const QString& profile ); | 300 | Addressee findByExternUid( const QString& uid , const QString& profile ); |
299 | bool containsExternalUid( const QString& uid ); | 301 | bool containsExternalUid( const QString& uid ); |
300 | 302 | ||
301 | void preExternSync( AddressBook* aBook, const QString& csd ); | 303 | void preExternSync( AddressBook* aBook, const QString& csd ); |
302 | void postExternSync( AddressBook* aBook, const QString& csd ); | 304 | void postExternSync( AddressBook* aBook, const QString& csd ); |
303 | signals: | 305 | signals: |
304 | /** | 306 | /** |
305 | Emitted, when the address book has changed on disk. | 307 | Emitted, when the address book has changed on disk. |
306 | */ | 308 | */ |
307 | void addressBookChanged( AddressBook * ); | 309 | void addressBookChanged( AddressBook * ); |
308 | 310 | ||
309 | /** | 311 | /** |
310 | Emitted, when the address book has been locked for writing. | 312 | Emitted, when the address book has been locked for writing. |
311 | */ | 313 | */ |
312 | void addressBookLocked( AddressBook * ); | 314 | void addressBookLocked( AddressBook * ); |
313 | 315 | ||
314 | /** | 316 | /** |
315 | Emitted, when the address book has been unlocked. | 317 | Emitted, when the address book has been unlocked. |
316 | */ | 318 | */ |
317 | void addressBookUnlocked( AddressBook * ); | 319 | void addressBookUnlocked( AddressBook * ); |
318 | 320 | ||
319 | protected: | 321 | protected: |
320 | void deleteRemovedAddressees(); | 322 | void deleteRemovedAddressees(); |
321 | void setStandardResource( Resource * ); | 323 | void setStandardResource( Resource * ); |
322 | Resource *standardResource(); | 324 | Resource *standardResource(); |
323 | KRES::Manager<Resource> *resourceManager(); | 325 | KRES::Manager<Resource> *resourceManager(); |
324 | 326 | ||
325 | void init(const QString &config, const QString &family); | 327 | void init(const QString &config, const QString &family); |
326 | 328 | ||
327 | private: | 329 | private: |
328 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 330 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
329 | 331 | ||
330 | 332 | ||
331 | struct AddressBookData; | 333 | struct AddressBookData; |
332 | AddressBookData *d; | 334 | AddressBookData *d; |
333 | bool blockLSEchange; | 335 | bool blockLSEchange; |
334 | }; | 336 | }; |
335 | 337 | ||
336 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 338 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
337 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 339 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
338 | 340 | ||
339 | } | 341 | } |
340 | 342 | ||
341 | #endif | 343 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 3f3d5c0..607ae26 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1935 +1,1947 @@ | |||
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 | static bool matchBinaryPatternA( int value, int pattern ); | 46 | static bool matchBinaryPatternA( int value, int pattern ); |
47 | static bool matchBinaryPatternP( int value, int pattern ); | 47 | static bool matchBinaryPatternP( int value, int pattern ); |
48 | 48 | ||
49 | struct Addressee::AddresseeData : public KShared | 49 | struct Addressee::AddresseeData : public KShared |
50 | { | 50 | { |
51 | QString uid; | 51 | QString uid; |
52 | QString name; | 52 | QString name; |
53 | QString formattedName; | 53 | QString formattedName; |
54 | QString familyName; | 54 | QString familyName; |
55 | QString givenName; | 55 | QString givenName; |
56 | QString additionalName; | 56 | QString additionalName; |
57 | QString prefix; | 57 | QString prefix; |
58 | QString suffix; | 58 | QString suffix; |
59 | QString nickName; | 59 | QString nickName; |
60 | QDateTime birthday; | 60 | QDateTime birthday; |
61 | QString mailer; | 61 | QString mailer; |
62 | TimeZone timeZone; | 62 | TimeZone timeZone; |
63 | Geo geo; | 63 | Geo geo; |
64 | QString title; | 64 | QString title; |
65 | QString role; | 65 | QString role; |
66 | QString organization; | 66 | QString organization; |
67 | QString note; | 67 | QString note; |
68 | QString productId; | 68 | QString productId; |
69 | QDateTime revision; | 69 | QDateTime revision; |
70 | QString sortString; | 70 | QString sortString; |
71 | QString externalUID; | 71 | QString externalUID; |
72 | QString originalExternalUID; | 72 | QString originalExternalUID; |
73 | KURL url; | 73 | KURL url; |
74 | Secrecy secrecy; | 74 | Secrecy secrecy; |
75 | Picture logo; | 75 | Picture logo; |
76 | Picture photo; | 76 | Picture photo; |
77 | Sound sound; | 77 | Sound sound; |
78 | Agent agent; | 78 | Agent agent; |
79 | QString mExternalId; | 79 | QString mExternalId; |
80 | PhoneNumber::List phoneNumbers; | 80 | PhoneNumber::List phoneNumbers; |
81 | Address::List addresses; | 81 | Address::List addresses; |
82 | Key::List keys; | 82 | Key::List keys; |
83 | QStringList emails; | 83 | QStringList emails; |
84 | QStringList categories; | 84 | QStringList categories; |
85 | QStringList custom; | 85 | QStringList custom; |
86 | int mTempSyncStat; | 86 | int mTempSyncStat; |
87 | Resource *resource; | 87 | Resource *resource; |
88 | 88 | ||
89 | bool empty :1; | 89 | bool empty :1; |
90 | bool changed :1; | 90 | bool changed :1; |
91 | bool tagged :1; | ||
91 | }; | 92 | }; |
92 | 93 | ||
93 | Addressee::Addressee() | 94 | Addressee::Addressee() |
94 | { | 95 | { |
95 | mData = new AddresseeData; | 96 | mData = new AddresseeData; |
96 | mData->empty = true; | 97 | mData->empty = true; |
97 | mData->changed = false; | 98 | mData->changed = false; |
98 | mData->resource = 0; | 99 | mData->resource = 0; |
99 | mData->mExternalId = ":"; | 100 | mData->mExternalId = ":"; |
100 | mData->revision = QDateTime ( QDate( 2003,1,1)); | 101 | mData->revision = QDateTime ( QDate( 2003,1,1)); |
101 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 102 | mData->mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
102 | } | 103 | } |
103 | 104 | ||
104 | Addressee::~Addressee() | 105 | Addressee::~Addressee() |
105 | { | 106 | { |
106 | } | 107 | } |
107 | 108 | ||
108 | Addressee::Addressee( const Addressee &a ) | 109 | Addressee::Addressee( const Addressee &a ) |
109 | { | 110 | { |
110 | mData = a.mData; | 111 | mData = a.mData; |
111 | } | 112 | } |
112 | 113 | ||
113 | Addressee &Addressee::operator=( const Addressee &a ) | 114 | Addressee &Addressee::operator=( const Addressee &a ) |
114 | { | 115 | { |
115 | mData = a.mData; | 116 | mData = a.mData; |
116 | return (*this); | 117 | return (*this); |
117 | } | 118 | } |
118 | 119 | ||
119 | Addressee Addressee::copy() | 120 | Addressee Addressee::copy() |
120 | { | 121 | { |
121 | Addressee a; | 122 | Addressee a; |
122 | *(a.mData) = *mData; | 123 | *(a.mData) = *mData; |
123 | return a; | 124 | return a; |
124 | } | 125 | } |
125 | 126 | ||
126 | void Addressee::detach() | 127 | void Addressee::detach() |
127 | { | 128 | { |
128 | if ( mData.count() == 1 ) return; | 129 | if ( mData.count() == 1 ) return; |
129 | *this = copy(); | 130 | *this = copy(); |
130 | } | 131 | } |
131 | 132 | ||
132 | bool Addressee::operator==( const Addressee &a ) const | 133 | bool Addressee::operator==( const Addressee &a ) const |
133 | { | 134 | { |
134 | if ( uid() != a.uid() ) return false; | 135 | if ( uid() != a.uid() ) return false; |
135 | if ( mData->name != a.mData->name ) return false; | 136 | if ( mData->name != a.mData->name ) return false; |
136 | if ( mData->formattedName != a.mData->formattedName ) return false; | 137 | if ( mData->formattedName != a.mData->formattedName ) return false; |
137 | if ( mData->familyName != a.mData->familyName ) return false; | 138 | if ( mData->familyName != a.mData->familyName ) return false; |
138 | if ( mData->givenName != a.mData->givenName ) return false; | 139 | if ( mData->givenName != a.mData->givenName ) return false; |
139 | if ( mData->additionalName != a.mData->additionalName ) return false; | 140 | if ( mData->additionalName != a.mData->additionalName ) return false; |
140 | if ( mData->prefix != a.mData->prefix ) return false; | 141 | if ( mData->prefix != a.mData->prefix ) return false; |
141 | if ( mData->suffix != a.mData->suffix ) return false; | 142 | if ( mData->suffix != a.mData->suffix ) return false; |
142 | if ( mData->nickName != a.mData->nickName ) return false; | 143 | if ( mData->nickName != a.mData->nickName ) return false; |
143 | if ( mData->birthday != a.mData->birthday ) return false; | 144 | if ( mData->birthday != a.mData->birthday ) return false; |
144 | if ( mData->mailer != a.mData->mailer ) return false; | 145 | if ( mData->mailer != a.mData->mailer ) return false; |
145 | if ( mData->timeZone != a.mData->timeZone ) return false; | 146 | if ( mData->timeZone != a.mData->timeZone ) return false; |
146 | if ( mData->geo != a.mData->geo ) return false; | 147 | if ( mData->geo != a.mData->geo ) return false; |
147 | if ( mData->title != a.mData->title ) return false; | 148 | if ( mData->title != a.mData->title ) return false; |
148 | if ( mData->role != a.mData->role ) return false; | 149 | if ( mData->role != a.mData->role ) return false; |
149 | if ( mData->organization != a.mData->organization ) return false; | 150 | if ( mData->organization != a.mData->organization ) return false; |
150 | if ( mData->note != a.mData->note ) return false; | 151 | if ( mData->note != a.mData->note ) return false; |
151 | if ( mData->productId != a.mData->productId ) return false; | 152 | if ( mData->productId != a.mData->productId ) return false; |
152 | //if ( mData->revision != a.mData->revision ) return false; | 153 | //if ( mData->revision != a.mData->revision ) return false; |
153 | if ( mData->sortString != a.mData->sortString ) return false; | 154 | if ( mData->sortString != a.mData->sortString ) return false; |
154 | if ( mData->secrecy != a.mData->secrecy ) return false; | 155 | if ( mData->secrecy != a.mData->secrecy ) return false; |
155 | if ( mData->logo != a.mData->logo ) return false; | 156 | if ( mData->logo != a.mData->logo ) return false; |
156 | if ( mData->photo != a.mData->photo ) return false; | 157 | if ( mData->photo != a.mData->photo ) return false; |
157 | if ( mData->sound != a.mData->sound ) return false; | 158 | if ( mData->sound != a.mData->sound ) return false; |
158 | if ( mData->agent != a.mData->agent ) return false; | 159 | if ( mData->agent != a.mData->agent ) return false; |
159 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 160 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
160 | ( mData->url != a.mData->url ) ) return false; | 161 | ( mData->url != a.mData->url ) ) return false; |
161 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 162 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
162 | if ( mData->addresses != a.mData->addresses ) return false; | 163 | if ( mData->addresses != a.mData->addresses ) return false; |
163 | if ( mData->keys != a.mData->keys ) return false; | 164 | if ( mData->keys != a.mData->keys ) return false; |
164 | if ( mData->emails != a.mData->emails ) return false; | 165 | if ( mData->emails != a.mData->emails ) return false; |
165 | if ( mData->categories != a.mData->categories ) return false; | 166 | if ( mData->categories != a.mData->categories ) return false; |
166 | if ( mData->custom != a.mData->custom ) return false; | 167 | if ( mData->custom != a.mData->custom ) return false; |
167 | 168 | ||
168 | return true; | 169 | return true; |
169 | } | 170 | } |
170 | 171 | ||
171 | bool Addressee::operator!=( const Addressee &a ) const | 172 | bool Addressee::operator!=( const Addressee &a ) const |
172 | { | 173 | { |
173 | return !( a == *this ); | 174 | return !( a == *this ); |
174 | } | 175 | } |
175 | 176 | ||
176 | bool Addressee::isEmpty() const | 177 | bool Addressee::isEmpty() const |
177 | { | 178 | { |
178 | return mData->empty; | 179 | return mData->empty; |
179 | } | 180 | } |
180 | ulong Addressee::getCsum4List( const QStringList & attList) | 181 | ulong Addressee::getCsum4List( const QStringList & attList) |
181 | { | 182 | { |
182 | int max = attList.count(); | 183 | int max = attList.count(); |
183 | ulong cSum = 0; | 184 | ulong cSum = 0; |
184 | int j,k,i; | 185 | int j,k,i; |
185 | int add; | 186 | int add; |
186 | for ( i = 0; i < max ; ++i ) { | 187 | for ( i = 0; i < max ; ++i ) { |
187 | QString s = attList[i]; | 188 | QString s = attList[i]; |
188 | if ( ! s.isEmpty() ){ | 189 | if ( ! s.isEmpty() ){ |
189 | j = s.length(); | 190 | j = s.length(); |
190 | for ( k = 0; k < j; ++k ) { | 191 | for ( k = 0; k < j; ++k ) { |
191 | int mul = k +1; | 192 | int mul = k +1; |
192 | add = s[k].unicode (); | 193 | add = s[k].unicode (); |
193 | if ( k < 16 ) | 194 | if ( k < 16 ) |
194 | mul = mul * mul; | 195 | mul = mul * mul; |
195 | int ii = i+1; | 196 | int ii = i+1; |
196 | add = add * mul *ii*ii*ii; | 197 | add = add * mul *ii*ii*ii; |
197 | cSum += add; | 198 | cSum += add; |
198 | } | 199 | } |
199 | } | 200 | } |
200 | 201 | ||
201 | } | 202 | } |
202 | //QString dump = attList.join(","); | 203 | //QString dump = attList.join(","); |
203 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 204 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
204 | 205 | ||
205 | return cSum; | 206 | return cSum; |
206 | 207 | ||
207 | } | 208 | } |
208 | void Addressee::computeCsum(const QString &dev) | 209 | void Addressee::computeCsum(const QString &dev) |
209 | { | 210 | { |
210 | QStringList l; | 211 | QStringList l; |
211 | if ( !mData->name.isEmpty() ) l.append(mData->name); | 212 | if ( !mData->name.isEmpty() ) l.append(mData->name); |
212 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); | 213 | if ( !mData->formattedName.isEmpty() ) l.append(mData->formattedName ); |
213 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); | 214 | if ( !mData->familyName.isEmpty() ) l.append( mData->familyName ); |
214 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); | 215 | if ( !mData->givenName.isEmpty() ) l.append(mData->givenName ); |
215 | if ( !mData->additionalName ) l.append( mData->additionalName ); | 216 | if ( !mData->additionalName ) l.append( mData->additionalName ); |
216 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); | 217 | if ( !mData->prefix.isEmpty() ) l.append( mData->prefix ); |
217 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); | 218 | if ( !mData->suffix.isEmpty() ) l.append( mData->suffix ); |
218 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); | 219 | if ( !mData->nickName.isEmpty() ) l.append( mData->nickName ); |
219 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); | 220 | if ( mData->birthday.isValid() ) l.append( mData->birthday.toString() ); |
220 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); | 221 | if ( !mData->mailer.isEmpty() ) l.append( mData->mailer ); |
221 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); | 222 | if ( mData->timeZone.isValid() ) l.append( mData->timeZone.asString() ); |
222 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); | 223 | if ( mData->geo.isValid() ) l.append( mData->geo.asString() ); |
223 | if ( !mData->title .isEmpty() ) l.append( mData->title ); | 224 | if ( !mData->title .isEmpty() ) l.append( mData->title ); |
224 | if ( !mData->role.isEmpty() ) l.append( mData->role ); | 225 | if ( !mData->role.isEmpty() ) l.append( mData->role ); |
225 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); | 226 | if ( !mData->organization.isEmpty() ) l.append( mData->organization ); |
226 | if ( !mData->note.isEmpty() ) l.append( mData->note ); | 227 | if ( !mData->note.isEmpty() ) l.append( mData->note ); |
227 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); | 228 | if ( !mData->productId.isEmpty() ) l.append(mData->productId ); |
228 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); | 229 | if ( !mData->sortString.isEmpty() ) l.append( mData->sortString ); |
229 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); | 230 | if ( mData->secrecy.isValid() ) l.append( mData->secrecy.asString()); |
230 | // if ( !mData->logo.isEmpty() ) l.append( ); | 231 | // if ( !mData->logo.isEmpty() ) l.append( ); |
231 | //if ( !mData->photo.isEmpty() ) l.append( ); | 232 | //if ( !mData->photo.isEmpty() ) l.append( ); |
232 | //if ( !mData->sound.isEmpty() ) l.append( ); | 233 | //if ( !mData->sound.isEmpty() ) l.append( ); |
233 | //if ( !mData->agent.isEmpty() ) l.append( ); | 234 | //if ( !mData->agent.isEmpty() ) l.append( ); |
234 | //if ( mData->url.isValid() ) l.append( ); | 235 | //if ( mData->url.isValid() ) l.append( ); |
235 | #if 0 | 236 | #if 0 |
236 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); | 237 | if ( !mData->phoneNumbers.isEmpty() ) l.append( ); |
237 | if ( !mData->addresses.isEmpty() ) l.append( ); | 238 | if ( !mData->addresses.isEmpty() ) l.append( ); |
238 | //if ( !mData->keys.isEmpty() ) l.append( ); | 239 | //if ( !mData->keys.isEmpty() ) l.append( ); |
239 | if ( !mData->emails.isEmpty() ) l.append( ); | 240 | if ( !mData->emails.isEmpty() ) l.append( ); |
240 | if ( !mData->categories .isEmpty() ) l.append( ); | 241 | if ( !mData->categories .isEmpty() ) l.append( ); |
241 | if ( !mData->custom.isEmpty() ) l.append( ); | 242 | if ( !mData->custom.isEmpty() ) l.append( ); |
242 | #endif | 243 | #endif |
243 | KABC::PhoneNumber::List phoneNumbers; | 244 | KABC::PhoneNumber::List phoneNumbers; |
244 | KABC::PhoneNumber::List::Iterator phoneIter; | 245 | KABC::PhoneNumber::List::Iterator phoneIter; |
245 | 246 | ||
246 | QStringList t; | 247 | QStringList t; |
247 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 248 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
248 | ++phoneIter ) | 249 | ++phoneIter ) |
249 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); | 250 | t.append( ( *phoneIter ).number()+QString::number( ( *phoneIter ).type() ) ); |
250 | t.sort(); | 251 | t.sort(); |
251 | uint iii; | 252 | uint iii; |
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->emails; | 255 | t = mData->emails; |
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->categories; | 259 | t = mData->categories; |
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 | t = mData->custom; | 263 | t = mData->custom; |
263 | t.sort(); | 264 | t.sort(); |
264 | for ( iii = 0; iii < t.count(); ++iii) | 265 | for ( iii = 0; iii < t.count(); ++iii) |
265 | l.append( t[iii] ); | 266 | l.append( t[iii] ); |
266 | KABC::Address::List::Iterator addressIter; | 267 | KABC::Address::List::Iterator addressIter; |
267 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); | 268 | for ( addressIter = mData->addresses.begin(); addressIter != mData->addresses.end(); |
268 | ++addressIter ) { | 269 | ++addressIter ) { |
269 | t = (*addressIter).asList(); | 270 | t = (*addressIter).asList(); |
270 | t.sort(); | 271 | t.sort(); |
271 | for ( iii = 0; iii < t.count(); ++iii) | 272 | for ( iii = 0; iii < t.count(); ++iii) |
272 | l.append( t[iii] ); | 273 | l.append( t[iii] ); |
273 | } | 274 | } |
274 | uint cs = getCsum4List(l); | 275 | uint cs = getCsum4List(l); |
275 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); | 276 | // qDebug("CSUM computed %d %s %s", cs,QString::number (cs ).latin1(), uid().latin1() ); |
276 | setCsum( dev, QString::number (cs )); | 277 | setCsum( dev, QString::number (cs )); |
277 | } | 278 | } |
278 | 279 | ||
279 | void Addressee::mergeContact( const Addressee& ad ) | 280 | void Addressee::mergeContact( const Addressee& ad ) |
280 | { | 281 | { |
281 | 282 | ||
282 | detach(); | 283 | detach(); |
283 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; | 284 | if ( mData->name.isEmpty() ) mData->name = ad.mData->name; |
284 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; | 285 | if ( mData->formattedName.isEmpty() ) mData->formattedName = ad.mData->formattedName; |
285 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; | 286 | if ( mData->familyName.isEmpty() ) mData->familyName = ad.mData->familyName; |
286 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; | 287 | if ( mData->givenName.isEmpty() ) mData->givenName = ad.mData->givenName ; |
287 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; | 288 | if ( mData->additionalName ) mData->additionalName = ad.mData->additionalName; |
288 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; | 289 | if ( mData->prefix.isEmpty() ) mData->prefix = ad.mData->prefix; |
289 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; | 290 | if ( mData->suffix.isEmpty() ) mData->suffix = ad.mData->suffix; |
290 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; | 291 | if ( mData->nickName.isEmpty() ) mData->nickName = ad.mData->nickName; |
291 | if ( !mData->birthday.isValid() ) | 292 | if ( !mData->birthday.isValid() ) |
292 | if ( ad.mData->birthday.isValid()) | 293 | if ( ad.mData->birthday.isValid()) |
293 | mData->birthday = ad.mData->birthday; | 294 | mData->birthday = ad.mData->birthday; |
294 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; | 295 | if ( mData->mailer.isEmpty() ) mData->mailer = ad.mData->mailer; |
295 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; | 296 | if ( !mData->timeZone.isValid() ) mData->timeZone = ad.mData->timeZone; |
296 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; | 297 | if ( !mData->geo.isValid() ) mData->geo = ad.mData->geo; |
297 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; | 298 | if ( mData->title .isEmpty() ) mData->title = ad.mData->title ; |
298 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; | 299 | if ( mData->role.isEmpty() ) mData->role = ad.mData->role ; |
299 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; | 300 | if ( mData->organization.isEmpty() ) mData->organization = ad.mData->organization ; |
300 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; | 301 | if ( mData->note.isEmpty() ) mData->note = ad.mData->note ; |
301 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; | 302 | if ( mData->productId.isEmpty() ) mData->productId = ad.mData->productId; |
302 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; | 303 | if ( mData->sortString.isEmpty() ) mData->sortString = ad.mData->sortString; |
303 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; | 304 | if ( !mData->secrecy.isValid() ) mData->secrecy = ad.mData->secrecy; |
304 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; | 305 | if ( ( !mData->url.isValid() && ad.mData->url.isValid() ) ) mData->url = ad.mData->url ; |
305 | 306 | ||
306 | // pending: | 307 | // pending: |
307 | // merging phonenumbers | 308 | // merging phonenumbers |
308 | // merging addresses | 309 | // merging addresses |
309 | // merging emails; | 310 | // merging emails; |
310 | // merging categories; | 311 | // merging categories; |
311 | // merging custom; | 312 | // merging custom; |
312 | // merging keys | 313 | // merging keys |
313 | qDebug("merge contact %s ", ad.uid().latin1()); | 314 | qDebug("merge contact %s ", ad.uid().latin1()); |
314 | setUid( ad.uid() ); | 315 | setUid( ad.uid() ); |
315 | setRevision( ad.revision() ); | 316 | setRevision( ad.revision() ); |
316 | } | 317 | } |
317 | 318 | ||
318 | bool Addressee::removeVoice() | 319 | bool Addressee::removeVoice() |
319 | { | 320 | { |
320 | PhoneNumber::List phoneN = phoneNumbers(); | 321 | PhoneNumber::List phoneN = phoneNumbers(); |
321 | PhoneNumber::List::Iterator phoneIt; | 322 | PhoneNumber::List::Iterator phoneIt; |
322 | bool found = false; | 323 | bool found = false; |
323 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { | 324 | for ( phoneIt = phoneN.begin(); phoneIt != phoneN.end(); ++phoneIt ) { |
324 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 325 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
325 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 326 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
326 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 327 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
327 | insertPhoneNumber( (*phoneIt) ); | 328 | insertPhoneNumber( (*phoneIt) ); |
328 | found = true; | 329 | found = true; |
329 | } | 330 | } |
330 | } | 331 | } |
331 | 332 | ||
332 | } | 333 | } |
333 | return found; | 334 | return found; |
334 | } | 335 | } |
335 | void Addressee::simplifyAddresses() | 336 | void Addressee::simplifyAddresses() |
336 | { | 337 | { |
337 | if ( mData->addresses.count() < 3 ) return ; | 338 | if ( mData->addresses.count() < 3 ) return ; |
338 | int count = 0; | 339 | int count = 0; |
339 | Address::List list; | 340 | Address::List list; |
340 | Address::List::Iterator it; | 341 | Address::List::Iterator it; |
341 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 342 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
342 | if ( count > 1 ) | 343 | if ( count > 1 ) |
343 | list.append( *it ); | 344 | list.append( *it ); |
344 | ++count; | 345 | ++count; |
345 | } | 346 | } |
346 | for( it = list.begin(); it != list.end(); ++it ) { | 347 | for( it = list.begin(); it != list.end(); ++it ) { |
347 | removeAddress( (*it) ); | 348 | removeAddress( (*it) ); |
348 | } | 349 | } |
349 | } | 350 | } |
350 | 351 | ||
351 | // removes all emails but the first | 352 | // removes all emails but the first |
352 | // needed by phone sync | 353 | // needed by phone sync |
353 | void Addressee::simplifyEmails() | 354 | void Addressee::simplifyEmails() |
354 | { | 355 | { |
355 | if ( mData->emails.count() == 0 ) return ; | 356 | if ( mData->emails.count() == 0 ) return ; |
356 | QString email = mData->emails.first(); | 357 | QString email = mData->emails.first(); |
357 | detach(); | 358 | detach(); |
358 | mData->emails.clear(); | 359 | mData->emails.clear(); |
359 | mData->emails.append( email ); | 360 | mData->emails.append( email ); |
360 | } | 361 | } |
361 | 362 | ||
362 | void Addressee::simplifyPhoneNumbers() | 363 | void Addressee::simplifyPhoneNumbers() |
363 | { | 364 | { |
364 | KABC::PhoneNumber::List removeNumbers; | 365 | KABC::PhoneNumber::List removeNumbers; |
365 | KABC::PhoneNumber::List::Iterator phoneIter; | 366 | KABC::PhoneNumber::List::Iterator phoneIter; |
366 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 367 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
367 | ++phoneIter ) { | 368 | ++phoneIter ) { |
368 | if ( ! ( *phoneIter ).simplifyNumber() ) | 369 | if ( ! ( *phoneIter ).simplifyNumber() ) |
369 | removeNumbers.append( ( *phoneIter ) ); | 370 | removeNumbers.append( ( *phoneIter ) ); |
370 | } | 371 | } |
371 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); | 372 | for ( phoneIter = removeNumbers.begin(); phoneIter != removeNumbers.end(); |
372 | ++phoneIter ) { | 373 | ++phoneIter ) { |
373 | removePhoneNumber(( *phoneIter )); | 374 | removePhoneNumber(( *phoneIter )); |
374 | } | 375 | } |
375 | } | 376 | } |
376 | void Addressee::simplifyPhoneNumberTypes() | 377 | void Addressee::simplifyPhoneNumberTypes() |
377 | { | 378 | { |
378 | KABC::PhoneNumber::List::Iterator phoneIter; | 379 | KABC::PhoneNumber::List::Iterator phoneIter; |
379 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); | 380 | for ( phoneIter = mData->phoneNumbers.begin(); phoneIter != mData->phoneNumbers.end(); |
380 | ++phoneIter ) | 381 | ++phoneIter ) |
381 | ( *phoneIter ).simplifyType(); | 382 | ( *phoneIter ).simplifyType(); |
382 | } | 383 | } |
383 | void Addressee::removeID(const QString &prof) | 384 | void Addressee::removeID(const QString &prof) |
384 | { | 385 | { |
385 | detach(); | 386 | detach(); |
386 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | 387 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); |
387 | 388 | ||
388 | } | 389 | } |
389 | void Addressee::setID( const QString & prof , const QString & id ) | 390 | void Addressee::setID( const QString & prof , const QString & id ) |
390 | { | 391 | { |
391 | detach(); | 392 | detach(); |
392 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | 393 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); |
393 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 394 | //qDebug("setID2 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
394 | } | 395 | } |
395 | void Addressee::setTempSyncStat( int id ) | 396 | void Addressee::setTempSyncStat( int id ) |
396 | { | 397 | { |
397 | if ( mData->mTempSyncStat == id ) return; | 398 | if ( mData->mTempSyncStat == id ) return; |
398 | detach(); | 399 | detach(); |
399 | mData->mTempSyncStat = id; | 400 | mData->mTempSyncStat = id; |
400 | } | 401 | } |
401 | int Addressee::tempSyncStat() const | 402 | int Addressee::tempSyncStat() const |
402 | { | 403 | { |
403 | return mData->mTempSyncStat; | 404 | return mData->mTempSyncStat; |
404 | } | 405 | } |
405 | 406 | ||
406 | QString Addressee::getID( const QString & prof) | 407 | QString Addressee::getID( const QString & prof) |
407 | { | 408 | { |
408 | return KIdManager::getId ( mData->mExternalId, prof ); | 409 | return KIdManager::getId ( mData->mExternalId, prof ); |
409 | } | 410 | } |
410 | 411 | ||
411 | void Addressee::setCsum( const QString & prof , const QString & id ) | 412 | void Addressee::setCsum( const QString & prof , const QString & id ) |
412 | { | 413 | { |
413 | detach(); | 414 | detach(); |
414 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); | 415 | //qDebug("setcsum1 %s %s %s",mData->mExternalId.latin1(), prof.latin1(), id.latin1() ); |
415 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | 416 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); |
416 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); | 417 | //qDebug("setcsum2 %s ",mData->mExternalId.latin1() ); |
417 | } | 418 | } |
418 | 419 | ||
419 | QString Addressee::getCsum( const QString & prof) | 420 | QString Addressee::getCsum( const QString & prof) |
420 | { | 421 | { |
421 | return KIdManager::getCsum ( mData->mExternalId, prof ); | 422 | return KIdManager::getCsum ( mData->mExternalId, prof ); |
422 | } | 423 | } |
423 | 424 | ||
424 | void Addressee::setIDStr( const QString & s ) | 425 | void Addressee::setIDStr( const QString & s ) |
425 | { | 426 | { |
426 | detach(); | 427 | detach(); |
427 | mData->mExternalId = s; | 428 | mData->mExternalId = s; |
428 | } | 429 | } |
429 | 430 | ||
430 | QString Addressee::IDStr() const | 431 | QString Addressee::IDStr() const |
431 | { | 432 | { |
432 | return mData->mExternalId; | 433 | return mData->mExternalId; |
433 | } | 434 | } |
434 | 435 | ||
435 | void Addressee::setExternalUID( const QString &id ) | 436 | void Addressee::setExternalUID( const QString &id ) |
436 | { | 437 | { |
437 | if ( id == mData->externalUID ) return; | 438 | if ( id == mData->externalUID ) return; |
438 | detach(); | 439 | detach(); |
439 | mData->empty = false; | 440 | mData->empty = false; |
440 | mData->externalUID = id; | 441 | mData->externalUID = id; |
441 | } | 442 | } |
442 | 443 | ||
443 | QString Addressee::externalUID() const | 444 | QString Addressee::externalUID() const |
444 | { | 445 | { |
445 | return mData->externalUID; | 446 | return mData->externalUID; |
446 | } | 447 | } |
447 | void Addressee::setOriginalExternalUID( const QString &id ) | 448 | void Addressee::setOriginalExternalUID( const QString &id ) |
448 | { | 449 | { |
449 | if ( id == mData->originalExternalUID ) return; | 450 | if ( id == mData->originalExternalUID ) return; |
450 | detach(); | 451 | detach(); |
451 | mData->empty = false; | 452 | mData->empty = false; |
452 | //qDebug("*******Set orig uid %s ", id.latin1()); | 453 | //qDebug("*******Set orig uid %s ", id.latin1()); |
453 | mData->originalExternalUID = id; | 454 | mData->originalExternalUID = id; |
454 | } | 455 | } |
455 | 456 | ||
456 | QString Addressee::originalExternalUID() const | 457 | QString Addressee::originalExternalUID() const |
457 | { | 458 | { |
458 | return mData->originalExternalUID; | 459 | return mData->originalExternalUID; |
459 | } | 460 | } |
460 | 461 | ||
461 | void Addressee::setUid( const QString &id ) | 462 | void Addressee::setUid( const QString &id ) |
462 | { | 463 | { |
463 | if ( id == mData->uid ) return; | 464 | if ( id == mData->uid ) return; |
464 | detach(); | 465 | detach(); |
465 | //qDebug("****setuid %s ", id.latin1()); | 466 | //qDebug("****setuid %s ", id.latin1()); |
466 | mData->empty = false; | 467 | mData->empty = false; |
467 | mData->uid = id; | 468 | mData->uid = id; |
468 | } | 469 | } |
469 | 470 | ||
470 | QString Addressee::uid() const | 471 | QString Addressee::uid() const |
471 | { | 472 | { |
472 | if ( mData->uid.isEmpty() ) | 473 | if ( mData->uid.isEmpty() ) |
473 | mData->uid = KApplication::randomString( 10 ); | 474 | mData->uid = KApplication::randomString( 10 ); |
474 | 475 | ||
475 | return mData->uid; | 476 | return mData->uid; |
476 | } | 477 | } |
477 | 478 | ||
478 | QString Addressee::uidLabel() | 479 | QString Addressee::uidLabel() |
479 | { | 480 | { |
480 | return i18n("Unique Identifier"); | 481 | return i18n("Unique Identifier"); |
481 | } | 482 | } |
482 | 483 | ||
483 | void Addressee::setName( const QString &name ) | 484 | void Addressee::setName( const QString &name ) |
484 | { | 485 | { |
485 | if ( name == mData->name ) return; | 486 | if ( name == mData->name ) return; |
486 | detach(); | 487 | detach(); |
487 | mData->empty = false; | 488 | mData->empty = false; |
488 | mData->name = name; | 489 | mData->name = name; |
489 | } | 490 | } |
490 | 491 | ||
491 | QString Addressee::name() const | 492 | QString Addressee::name() const |
492 | { | 493 | { |
493 | return mData->name; | 494 | return mData->name; |
494 | } | 495 | } |
495 | 496 | ||
496 | QString Addressee::nameLabel() | 497 | QString Addressee::nameLabel() |
497 | { | 498 | { |
498 | return i18n("Name"); | 499 | return i18n("Name"); |
499 | } | 500 | } |
500 | 501 | ||
501 | 502 | ||
502 | void Addressee::setFormattedName( const QString &formattedName ) | 503 | void Addressee::setFormattedName( const QString &formattedName ) |
503 | { | 504 | { |
504 | if ( formattedName == mData->formattedName ) return; | 505 | if ( formattedName == mData->formattedName ) return; |
505 | detach(); | 506 | detach(); |
506 | mData->empty = false; | 507 | mData->empty = false; |
507 | mData->formattedName = formattedName; | 508 | mData->formattedName = formattedName; |
508 | } | 509 | } |
509 | 510 | ||
510 | QString Addressee::formattedName() const | 511 | QString Addressee::formattedName() const |
511 | { | 512 | { |
512 | return mData->formattedName; | 513 | return mData->formattedName; |
513 | } | 514 | } |
514 | 515 | ||
515 | QString Addressee::formattedNameLabel() | 516 | QString Addressee::formattedNameLabel() |
516 | { | 517 | { |
517 | return i18n("Formatted Name"); | 518 | return i18n("Formatted Name"); |
518 | } | 519 | } |
519 | 520 | ||
520 | 521 | ||
521 | void Addressee::setFamilyName( const QString &familyName ) | 522 | void Addressee::setFamilyName( const QString &familyName ) |
522 | { | 523 | { |
523 | if ( familyName == mData->familyName ) return; | 524 | if ( familyName == mData->familyName ) return; |
524 | detach(); | 525 | detach(); |
525 | mData->empty = false; | 526 | mData->empty = false; |
526 | mData->familyName = familyName; | 527 | mData->familyName = familyName; |
527 | } | 528 | } |
528 | 529 | ||
529 | QString Addressee::familyName() const | 530 | QString Addressee::familyName() const |
530 | { | 531 | { |
531 | return mData->familyName; | 532 | return mData->familyName; |
532 | } | 533 | } |
533 | 534 | ||
534 | QString Addressee::familyNameLabel() | 535 | QString Addressee::familyNameLabel() |
535 | { | 536 | { |
536 | return i18n("Family Name"); | 537 | return i18n("Family Name"); |
537 | } | 538 | } |
538 | 539 | ||
539 | 540 | ||
540 | void Addressee::setGivenName( const QString &givenName ) | 541 | void Addressee::setGivenName( const QString &givenName ) |
541 | { | 542 | { |
542 | if ( givenName == mData->givenName ) return; | 543 | if ( givenName == mData->givenName ) return; |
543 | detach(); | 544 | detach(); |
544 | mData->empty = false; | 545 | mData->empty = false; |
545 | mData->givenName = givenName; | 546 | mData->givenName = givenName; |
546 | } | 547 | } |
547 | 548 | ||
548 | QString Addressee::givenName() const | 549 | QString Addressee::givenName() const |
549 | { | 550 | { |
550 | return mData->givenName; | 551 | return mData->givenName; |
551 | } | 552 | } |
552 | 553 | ||
553 | QString Addressee::givenNameLabel() | 554 | QString Addressee::givenNameLabel() |
554 | { | 555 | { |
555 | return i18n("Given Name"); | 556 | return i18n("Given Name"); |
556 | } | 557 | } |
557 | 558 | ||
558 | 559 | ||
559 | void Addressee::setAdditionalName( const QString &additionalName ) | 560 | void Addressee::setAdditionalName( const QString &additionalName ) |
560 | { | 561 | { |
561 | if ( additionalName == mData->additionalName ) return; | 562 | if ( additionalName == mData->additionalName ) return; |
562 | detach(); | 563 | detach(); |
563 | mData->empty = false; | 564 | mData->empty = false; |
564 | mData->additionalName = additionalName; | 565 | mData->additionalName = additionalName; |
565 | } | 566 | } |
566 | 567 | ||
567 | QString Addressee::additionalName() const | 568 | QString Addressee::additionalName() const |
568 | { | 569 | { |
569 | return mData->additionalName; | 570 | return mData->additionalName; |
570 | } | 571 | } |
571 | 572 | ||
572 | QString Addressee::additionalNameLabel() | 573 | QString Addressee::additionalNameLabel() |
573 | { | 574 | { |
574 | return i18n("Additional Names"); | 575 | return i18n("Additional Names"); |
575 | } | 576 | } |
576 | 577 | ||
577 | 578 | ||
578 | void Addressee::setPrefix( const QString &prefix ) | 579 | void Addressee::setPrefix( const QString &prefix ) |
579 | { | 580 | { |
580 | if ( prefix == mData->prefix ) return; | 581 | if ( prefix == mData->prefix ) return; |
581 | detach(); | 582 | detach(); |
582 | mData->empty = false; | 583 | mData->empty = false; |
583 | mData->prefix = prefix; | 584 | mData->prefix = prefix; |
584 | } | 585 | } |
585 | 586 | ||
586 | QString Addressee::prefix() const | 587 | QString Addressee::prefix() const |
587 | { | 588 | { |
588 | return mData->prefix; | 589 | return mData->prefix; |
589 | } | 590 | } |
590 | 591 | ||
591 | QString Addressee::prefixLabel() | 592 | QString Addressee::prefixLabel() |
592 | { | 593 | { |
593 | return i18n("Honorific Prefixes"); | 594 | return i18n("Honorific Prefixes"); |
594 | } | 595 | } |
595 | 596 | ||
596 | 597 | ||
597 | void Addressee::setSuffix( const QString &suffix ) | 598 | void Addressee::setSuffix( const QString &suffix ) |
598 | { | 599 | { |
599 | if ( suffix == mData->suffix ) return; | 600 | if ( suffix == mData->suffix ) return; |
600 | detach(); | 601 | detach(); |
601 | mData->empty = false; | 602 | mData->empty = false; |
602 | mData->suffix = suffix; | 603 | mData->suffix = suffix; |
603 | } | 604 | } |
604 | 605 | ||
605 | QString Addressee::suffix() const | 606 | QString Addressee::suffix() const |
606 | { | 607 | { |
607 | return mData->suffix; | 608 | return mData->suffix; |
608 | } | 609 | } |
609 | 610 | ||
610 | QString Addressee::suffixLabel() | 611 | QString Addressee::suffixLabel() |
611 | { | 612 | { |
612 | return i18n("Honorific Suffixes"); | 613 | return i18n("Honorific Suffixes"); |
613 | } | 614 | } |
614 | 615 | ||
615 | 616 | ||
616 | void Addressee::setNickName( const QString &nickName ) | 617 | void Addressee::setNickName( const QString &nickName ) |
617 | { | 618 | { |
618 | if ( nickName == mData->nickName ) return; | 619 | if ( nickName == mData->nickName ) return; |
619 | detach(); | 620 | detach(); |
620 | mData->empty = false; | 621 | mData->empty = false; |
621 | mData->nickName = nickName; | 622 | mData->nickName = nickName; |
622 | } | 623 | } |
623 | 624 | ||
624 | QString Addressee::nickName() const | 625 | QString Addressee::nickName() const |
625 | { | 626 | { |
626 | return mData->nickName; | 627 | return mData->nickName; |
627 | } | 628 | } |
628 | 629 | ||
629 | QString Addressee::nickNameLabel() | 630 | QString Addressee::nickNameLabel() |
630 | { | 631 | { |
631 | return i18n("Nick Name"); | 632 | return i18n("Nick Name"); |
632 | } | 633 | } |
633 | 634 | ||
634 | 635 | ||
635 | void Addressee::setBirthday( const QDateTime &birthday ) | 636 | void Addressee::setBirthday( const QDateTime &birthday ) |
636 | { | 637 | { |
637 | if ( birthday == mData->birthday ) return; | 638 | if ( birthday == mData->birthday ) return; |
638 | detach(); | 639 | detach(); |
639 | mData->empty = false; | 640 | mData->empty = false; |
640 | mData->birthday = birthday; | 641 | mData->birthday = birthday; |
641 | } | 642 | } |
642 | 643 | ||
643 | QDateTime Addressee::birthday() const | 644 | QDateTime Addressee::birthday() const |
644 | { | 645 | { |
645 | return mData->birthday; | 646 | return mData->birthday; |
646 | } | 647 | } |
647 | 648 | ||
648 | QString Addressee::birthdayLabel() | 649 | QString Addressee::birthdayLabel() |
649 | { | 650 | { |
650 | return i18n("Birthday"); | 651 | return i18n("Birthday"); |
651 | } | 652 | } |
652 | 653 | ||
653 | 654 | ||
654 | QString Addressee::homeAddressStreetLabel() | 655 | QString Addressee::homeAddressStreetLabel() |
655 | { | 656 | { |
656 | return i18n("Home Address Street"); | 657 | return i18n("Home Address Street"); |
657 | } | 658 | } |
658 | 659 | ||
659 | 660 | ||
660 | QString Addressee::homeAddressLocalityLabel() | 661 | QString Addressee::homeAddressLocalityLabel() |
661 | { | 662 | { |
662 | return i18n("Home Address Locality"); | 663 | return i18n("Home Address Locality"); |
663 | } | 664 | } |
664 | 665 | ||
665 | 666 | ||
666 | QString Addressee::homeAddressRegionLabel() | 667 | QString Addressee::homeAddressRegionLabel() |
667 | { | 668 | { |
668 | return i18n("Home Address Region"); | 669 | return i18n("Home Address Region"); |
669 | } | 670 | } |
670 | 671 | ||
671 | 672 | ||
672 | QString Addressee::homeAddressPostalCodeLabel() | 673 | QString Addressee::homeAddressPostalCodeLabel() |
673 | { | 674 | { |
674 | return i18n("Home Address Postal Code"); | 675 | return i18n("Home Address Postal Code"); |
675 | } | 676 | } |
676 | 677 | ||
677 | 678 | ||
678 | QString Addressee::homeAddressCountryLabel() | 679 | QString Addressee::homeAddressCountryLabel() |
679 | { | 680 | { |
680 | return i18n("Home Address Country"); | 681 | return i18n("Home Address Country"); |
681 | } | 682 | } |
682 | 683 | ||
683 | 684 | ||
684 | QString Addressee::homeAddressLabelLabel() | 685 | QString Addressee::homeAddressLabelLabel() |
685 | { | 686 | { |
686 | return i18n("Home Address Label"); | 687 | return i18n("Home Address Label"); |
687 | } | 688 | } |
688 | 689 | ||
689 | 690 | ||
690 | QString Addressee::businessAddressStreetLabel() | 691 | QString Addressee::businessAddressStreetLabel() |
691 | { | 692 | { |
692 | return i18n("Business Address Street"); | 693 | return i18n("Business Address Street"); |
693 | } | 694 | } |
694 | 695 | ||
695 | 696 | ||
696 | QString Addressee::businessAddressLocalityLabel() | 697 | QString Addressee::businessAddressLocalityLabel() |
697 | { | 698 | { |
698 | return i18n("Business Address Locality"); | 699 | return i18n("Business Address Locality"); |
699 | } | 700 | } |
700 | 701 | ||
701 | 702 | ||
702 | QString Addressee::businessAddressRegionLabel() | 703 | QString Addressee::businessAddressRegionLabel() |
703 | { | 704 | { |
704 | return i18n("Business Address Region"); | 705 | return i18n("Business Address Region"); |
705 | } | 706 | } |
706 | 707 | ||
707 | 708 | ||
708 | QString Addressee::businessAddressPostalCodeLabel() | 709 | QString Addressee::businessAddressPostalCodeLabel() |
709 | { | 710 | { |
710 | return i18n("Business Address Postal Code"); | 711 | return i18n("Business Address Postal Code"); |
711 | } | 712 | } |
712 | 713 | ||
713 | 714 | ||
714 | QString Addressee::businessAddressCountryLabel() | 715 | QString Addressee::businessAddressCountryLabel() |
715 | { | 716 | { |
716 | return i18n("Business Address Country"); | 717 | return i18n("Business Address Country"); |
717 | } | 718 | } |
718 | 719 | ||
719 | 720 | ||
720 | QString Addressee::businessAddressLabelLabel() | 721 | QString Addressee::businessAddressLabelLabel() |
721 | { | 722 | { |
722 | return i18n("Business Address Label"); | 723 | return i18n("Business Address Label"); |
723 | } | 724 | } |
724 | 725 | ||
725 | 726 | ||
726 | QString Addressee::homePhoneLabel() | 727 | QString Addressee::homePhoneLabel() |
727 | { | 728 | { |
728 | return i18n("Home Phone"); | 729 | return i18n("Home Phone"); |
729 | } | 730 | } |
730 | 731 | ||
731 | 732 | ||
732 | QString Addressee::businessPhoneLabel() | 733 | QString Addressee::businessPhoneLabel() |
733 | { | 734 | { |
734 | return i18n("Business Phone"); | 735 | return i18n("Business Phone"); |
735 | } | 736 | } |
736 | 737 | ||
737 | 738 | ||
738 | QString Addressee::mobilePhoneLabel() | 739 | QString Addressee::mobilePhoneLabel() |
739 | { | 740 | { |
740 | return i18n("Mobile Phone"); | 741 | return i18n("Mobile Phone"); |
741 | } | 742 | } |
742 | 743 | ||
743 | 744 | ||
744 | QString Addressee::homeFaxLabel() | 745 | QString Addressee::homeFaxLabel() |
745 | { | 746 | { |
746 | return i18n("Home Fax"); | 747 | return i18n("Home Fax"); |
747 | } | 748 | } |
748 | 749 | ||
749 | 750 | ||
750 | QString Addressee::businessFaxLabel() | 751 | QString Addressee::businessFaxLabel() |
751 | { | 752 | { |
752 | return i18n("Business Fax"); | 753 | return i18n("Business Fax"); |
753 | } | 754 | } |
754 | 755 | ||
755 | 756 | ||
756 | QString Addressee::carPhoneLabel() | 757 | QString Addressee::carPhoneLabel() |
757 | { | 758 | { |
758 | return i18n("Car Phone"); | 759 | return i18n("Car Phone"); |
759 | } | 760 | } |
760 | 761 | ||
761 | 762 | ||
762 | QString Addressee::isdnLabel() | 763 | QString Addressee::isdnLabel() |
763 | { | 764 | { |
764 | return i18n("ISDN"); | 765 | return i18n("ISDN"); |
765 | } | 766 | } |
766 | 767 | ||
767 | 768 | ||
768 | QString Addressee::pagerLabel() | 769 | QString Addressee::pagerLabel() |
769 | { | 770 | { |
770 | return i18n("Pager"); | 771 | return i18n("Pager"); |
771 | } | 772 | } |
772 | 773 | ||
773 | QString Addressee::sipLabel() | 774 | QString Addressee::sipLabel() |
774 | { | 775 | { |
775 | return i18n("SIP"); | 776 | return i18n("SIP"); |
776 | } | 777 | } |
777 | 778 | ||
778 | QString Addressee::emailLabel() | 779 | QString Addressee::emailLabel() |
779 | { | 780 | { |
780 | return i18n("Email Address"); | 781 | return i18n("Email Address"); |
781 | } | 782 | } |
782 | 783 | ||
783 | 784 | ||
784 | void Addressee::setMailer( const QString &mailer ) | 785 | void Addressee::setMailer( const QString &mailer ) |
785 | { | 786 | { |
786 | if ( mailer == mData->mailer ) return; | 787 | if ( mailer == mData->mailer ) return; |
787 | detach(); | 788 | detach(); |
788 | mData->empty = false; | 789 | mData->empty = false; |
789 | mData->mailer = mailer; | 790 | mData->mailer = mailer; |
790 | } | 791 | } |
791 | 792 | ||
792 | QString Addressee::mailer() const | 793 | QString Addressee::mailer() const |
793 | { | 794 | { |
794 | return mData->mailer; | 795 | return mData->mailer; |
795 | } | 796 | } |
796 | 797 | ||
797 | QString Addressee::mailerLabel() | 798 | QString Addressee::mailerLabel() |
798 | { | 799 | { |
799 | return i18n("Mail Client"); | 800 | return i18n("Mail Client"); |
800 | } | 801 | } |
801 | 802 | ||
802 | 803 | ||
803 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 804 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
804 | { | 805 | { |
805 | if ( timeZone == mData->timeZone ) return; | 806 | if ( timeZone == mData->timeZone ) return; |
806 | detach(); | 807 | detach(); |
807 | mData->empty = false; | 808 | mData->empty = false; |
808 | mData->timeZone = timeZone; | 809 | mData->timeZone = timeZone; |
809 | } | 810 | } |
810 | 811 | ||
811 | TimeZone Addressee::timeZone() const | 812 | TimeZone Addressee::timeZone() const |
812 | { | 813 | { |
813 | return mData->timeZone; | 814 | return mData->timeZone; |
814 | } | 815 | } |
815 | 816 | ||
816 | QString Addressee::timeZoneLabel() | 817 | QString Addressee::timeZoneLabel() |
817 | { | 818 | { |
818 | return i18n("Time Zone"); | 819 | return i18n("Time Zone"); |
819 | } | 820 | } |
820 | 821 | ||
821 | 822 | ||
822 | void Addressee::setGeo( const Geo &geo ) | 823 | void Addressee::setGeo( const Geo &geo ) |
823 | { | 824 | { |
824 | if ( geo == mData->geo ) return; | 825 | if ( geo == mData->geo ) return; |
825 | detach(); | 826 | detach(); |
826 | mData->empty = false; | 827 | mData->empty = false; |
827 | mData->geo = geo; | 828 | mData->geo = geo; |
828 | } | 829 | } |
829 | 830 | ||
830 | Geo Addressee::geo() const | 831 | Geo Addressee::geo() const |
831 | { | 832 | { |
832 | return mData->geo; | 833 | return mData->geo; |
833 | } | 834 | } |
834 | 835 | ||
835 | QString Addressee::geoLabel() | 836 | QString Addressee::geoLabel() |
836 | { | 837 | { |
837 | return i18n("Geographic Position"); | 838 | return i18n("Geographic Position"); |
838 | } | 839 | } |
839 | 840 | ||
840 | 841 | ||
841 | void Addressee::setTitle( const QString &title ) | 842 | void Addressee::setTitle( const QString &title ) |
842 | { | 843 | { |
843 | if ( title == mData->title ) return; | 844 | if ( title == mData->title ) return; |
844 | detach(); | 845 | detach(); |
845 | mData->empty = false; | 846 | mData->empty = false; |
846 | mData->title = title; | 847 | mData->title = title; |
847 | } | 848 | } |
848 | 849 | ||
849 | QString Addressee::title() const | 850 | QString Addressee::title() const |
850 | { | 851 | { |
851 | return mData->title; | 852 | return mData->title; |
852 | } | 853 | } |
853 | 854 | ||
854 | QString Addressee::titleLabel() | 855 | QString Addressee::titleLabel() |
855 | { | 856 | { |
856 | return i18n("Title"); | 857 | return i18n("Title"); |
857 | } | 858 | } |
858 | 859 | ||
859 | 860 | ||
860 | void Addressee::setRole( const QString &role ) | 861 | void Addressee::setRole( const QString &role ) |
861 | { | 862 | { |
862 | if ( role == mData->role ) return; | 863 | if ( role == mData->role ) return; |
863 | detach(); | 864 | detach(); |
864 | mData->empty = false; | 865 | mData->empty = false; |
865 | mData->role = role; | 866 | mData->role = role; |
866 | } | 867 | } |
867 | 868 | ||
868 | QString Addressee::role() const | 869 | QString Addressee::role() const |
869 | { | 870 | { |
870 | return mData->role; | 871 | return mData->role; |
871 | } | 872 | } |
872 | 873 | ||
873 | QString Addressee::roleLabel() | 874 | QString Addressee::roleLabel() |
874 | { | 875 | { |
875 | return i18n("Role"); | 876 | return i18n("Role"); |
876 | } | 877 | } |
877 | 878 | ||
878 | 879 | ||
879 | void Addressee::setOrganization( const QString &organization ) | 880 | void Addressee::setOrganization( const QString &organization ) |
880 | { | 881 | { |
881 | if ( organization == mData->organization ) return; | 882 | if ( organization == mData->organization ) return; |
882 | detach(); | 883 | detach(); |
883 | mData->empty = false; | 884 | mData->empty = false; |
884 | mData->organization = organization; | 885 | mData->organization = organization; |
885 | } | 886 | } |
886 | 887 | ||
887 | QString Addressee::organization() const | 888 | QString Addressee::organization() const |
888 | { | 889 | { |
889 | return mData->organization; | 890 | return mData->organization; |
890 | } | 891 | } |
891 | 892 | ||
892 | QString Addressee::organizationLabel() | 893 | QString Addressee::organizationLabel() |
893 | { | 894 | { |
894 | return i18n("Organization"); | 895 | return i18n("Organization"); |
895 | } | 896 | } |
896 | 897 | ||
897 | 898 | ||
898 | void Addressee::setNote( const QString ¬e ) | 899 | void Addressee::setNote( const QString ¬e ) |
899 | { | 900 | { |
900 | if ( note == mData->note ) return; | 901 | if ( note == mData->note ) return; |
901 | detach(); | 902 | detach(); |
902 | mData->empty = false; | 903 | mData->empty = false; |
903 | mData->note = note; | 904 | mData->note = note; |
904 | } | 905 | } |
905 | 906 | ||
906 | QString Addressee::note() const | 907 | QString Addressee::note() const |
907 | { | 908 | { |
908 | return mData->note; | 909 | return mData->note; |
909 | } | 910 | } |
910 | 911 | ||
911 | QString Addressee::noteLabel() | 912 | QString Addressee::noteLabel() |
912 | { | 913 | { |
913 | return i18n("Note"); | 914 | return i18n("Note"); |
914 | } | 915 | } |
915 | 916 | ||
916 | 917 | ||
917 | void Addressee::setProductId( const QString &productId ) | 918 | void Addressee::setProductId( const QString &productId ) |
918 | { | 919 | { |
919 | if ( productId == mData->productId ) return; | 920 | if ( productId == mData->productId ) return; |
920 | detach(); | 921 | detach(); |
921 | mData->empty = false; | 922 | mData->empty = false; |
922 | mData->productId = productId; | 923 | mData->productId = productId; |
923 | } | 924 | } |
924 | 925 | ||
925 | QString Addressee::productId() const | 926 | QString Addressee::productId() const |
926 | { | 927 | { |
927 | return mData->productId; | 928 | return mData->productId; |
928 | } | 929 | } |
929 | 930 | ||
930 | QString Addressee::productIdLabel() | 931 | QString Addressee::productIdLabel() |
931 | { | 932 | { |
932 | return i18n("Product Identifier"); | 933 | return i18n("Product Identifier"); |
933 | } | 934 | } |
934 | 935 | ||
935 | 936 | ||
936 | void Addressee::setRevision( const QDateTime &revision ) | 937 | void Addressee::setRevision( const QDateTime &revision ) |
937 | { | 938 | { |
938 | if ( revision == mData->revision ) return; | 939 | if ( revision == mData->revision ) return; |
939 | detach(); | 940 | detach(); |
940 | mData->empty = false; | 941 | mData->empty = false; |
941 | mData->revision = revision; | 942 | mData->revision = revision; |
942 | } | 943 | } |
943 | 944 | ||
944 | QDateTime Addressee::revision() const | 945 | QDateTime Addressee::revision() const |
945 | { | 946 | { |
946 | return mData->revision; | 947 | return mData->revision; |
947 | } | 948 | } |
948 | 949 | ||
949 | QString Addressee::revisionLabel() | 950 | QString Addressee::revisionLabel() |
950 | { | 951 | { |
951 | return i18n("Revision Date"); | 952 | return i18n("Revision Date"); |
952 | } | 953 | } |
953 | 954 | ||
954 | 955 | ||
955 | void Addressee::setSortString( const QString &sortString ) | 956 | void Addressee::setSortString( const QString &sortString ) |
956 | { | 957 | { |
957 | if ( sortString == mData->sortString ) return; | 958 | if ( sortString == mData->sortString ) return; |
958 | detach(); | 959 | detach(); |
959 | mData->empty = false; | 960 | mData->empty = false; |
960 | mData->sortString = sortString; | 961 | mData->sortString = sortString; |
961 | } | 962 | } |
962 | 963 | ||
963 | QString Addressee::sortString() const | 964 | QString Addressee::sortString() const |
964 | { | 965 | { |
965 | return mData->sortString; | 966 | return mData->sortString; |
966 | } | 967 | } |
967 | 968 | ||
968 | QString Addressee::sortStringLabel() | 969 | QString Addressee::sortStringLabel() |
969 | { | 970 | { |
970 | return i18n("Sort String"); | 971 | return i18n("Sort String"); |
971 | } | 972 | } |
972 | 973 | ||
973 | 974 | ||
974 | void Addressee::setUrl( const KURL &url ) | 975 | void Addressee::setUrl( const KURL &url ) |
975 | { | 976 | { |
976 | if ( url == mData->url ) return; | 977 | if ( url == mData->url ) return; |
977 | detach(); | 978 | detach(); |
978 | mData->empty = false; | 979 | mData->empty = false; |
979 | mData->url = url; | 980 | mData->url = url; |
980 | } | 981 | } |
981 | 982 | ||
982 | KURL Addressee::url() const | 983 | KURL Addressee::url() const |
983 | { | 984 | { |
984 | return mData->url; | 985 | return mData->url; |
985 | } | 986 | } |
986 | 987 | ||
987 | QString Addressee::urlLabel() | 988 | QString Addressee::urlLabel() |
988 | { | 989 | { |
989 | return i18n("URL"); | 990 | return i18n("URL"); |
990 | } | 991 | } |
991 | 992 | ||
992 | 993 | ||
993 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 994 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
994 | { | 995 | { |
995 | if ( secrecy == mData->secrecy ) return; | 996 | if ( secrecy == mData->secrecy ) return; |
996 | detach(); | 997 | detach(); |
997 | mData->empty = false; | 998 | mData->empty = false; |
998 | mData->secrecy = secrecy; | 999 | mData->secrecy = secrecy; |
999 | } | 1000 | } |
1000 | 1001 | ||
1001 | Secrecy Addressee::secrecy() const | 1002 | Secrecy Addressee::secrecy() const |
1002 | { | 1003 | { |
1003 | return mData->secrecy; | 1004 | return mData->secrecy; |
1004 | } | 1005 | } |
1005 | 1006 | ||
1006 | QString Addressee::secrecyLabel() | 1007 | QString Addressee::secrecyLabel() |
1007 | { | 1008 | { |
1008 | return i18n("Security Class"); | 1009 | return i18n("Security Class"); |
1009 | } | 1010 | } |
1010 | 1011 | ||
1011 | 1012 | ||
1012 | void Addressee::setLogo( const Picture &logo ) | 1013 | void Addressee::setLogo( const Picture &logo ) |
1013 | { | 1014 | { |
1014 | if ( logo == mData->logo ) return; | 1015 | if ( logo == mData->logo ) return; |
1015 | detach(); | 1016 | detach(); |
1016 | mData->empty = false; | 1017 | mData->empty = false; |
1017 | mData->logo = logo; | 1018 | mData->logo = logo; |
1018 | } | 1019 | } |
1019 | 1020 | ||
1020 | Picture Addressee::logo() const | 1021 | Picture Addressee::logo() const |
1021 | { | 1022 | { |
1022 | return mData->logo; | 1023 | return mData->logo; |
1023 | } | 1024 | } |
1024 | 1025 | ||
1025 | QString Addressee::logoLabel() | 1026 | QString Addressee::logoLabel() |
1026 | { | 1027 | { |
1027 | return i18n("Logo"); | 1028 | return i18n("Logo"); |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | 1031 | ||
1031 | void Addressee::setPhoto( const Picture &photo ) | 1032 | void Addressee::setPhoto( const Picture &photo ) |
1032 | { | 1033 | { |
1033 | if ( photo == mData->photo ) return; | 1034 | if ( photo == mData->photo ) return; |
1034 | detach(); | 1035 | detach(); |
1035 | mData->empty = false; | 1036 | mData->empty = false; |
1036 | mData->photo = photo; | 1037 | mData->photo = photo; |
1037 | } | 1038 | } |
1038 | 1039 | ||
1039 | Picture Addressee::photo() const | 1040 | Picture Addressee::photo() const |
1040 | { | 1041 | { |
1041 | return mData->photo; | 1042 | return mData->photo; |
1042 | } | 1043 | } |
1043 | 1044 | ||
1044 | QString Addressee::photoLabel() | 1045 | QString Addressee::photoLabel() |
1045 | { | 1046 | { |
1046 | return i18n("Photo"); | 1047 | return i18n("Photo"); |
1047 | } | 1048 | } |
1048 | 1049 | ||
1049 | 1050 | ||
1050 | void Addressee::setSound( const Sound &sound ) | 1051 | void Addressee::setSound( const Sound &sound ) |
1051 | { | 1052 | { |
1052 | if ( sound == mData->sound ) return; | 1053 | if ( sound == mData->sound ) return; |
1053 | detach(); | 1054 | detach(); |
1054 | mData->empty = false; | 1055 | mData->empty = false; |
1055 | mData->sound = sound; | 1056 | mData->sound = sound; |
1056 | } | 1057 | } |
1057 | 1058 | ||
1058 | Sound Addressee::sound() const | 1059 | Sound Addressee::sound() const |
1059 | { | 1060 | { |
1060 | return mData->sound; | 1061 | return mData->sound; |
1061 | } | 1062 | } |
1062 | 1063 | ||
1063 | QString Addressee::soundLabel() | 1064 | QString Addressee::soundLabel() |
1064 | { | 1065 | { |
1065 | return i18n("Sound"); | 1066 | return i18n("Sound"); |
1066 | } | 1067 | } |
1067 | 1068 | ||
1068 | 1069 | ||
1069 | void Addressee::setAgent( const Agent &agent ) | 1070 | void Addressee::setAgent( const Agent &agent ) |
1070 | { | 1071 | { |
1071 | if ( agent == mData->agent ) return; | 1072 | if ( agent == mData->agent ) return; |
1072 | detach(); | 1073 | detach(); |
1073 | mData->empty = false; | 1074 | mData->empty = false; |
1074 | mData->agent = agent; | 1075 | mData->agent = agent; |
1075 | } | 1076 | } |
1076 | 1077 | ||
1077 | Agent Addressee::agent() const | 1078 | Agent Addressee::agent() const |
1078 | { | 1079 | { |
1079 | return mData->agent; | 1080 | return mData->agent; |
1080 | } | 1081 | } |
1081 | 1082 | ||
1082 | QString Addressee::agentLabel() | 1083 | QString Addressee::agentLabel() |
1083 | { | 1084 | { |
1084 | return i18n("Agent"); | 1085 | return i18n("Agent"); |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | 1088 | ||
1088 | 1089 | ||
1089 | void Addressee::setNameFromString( const QString &str ) | 1090 | void Addressee::setNameFromString( const QString &str ) |
1090 | { | 1091 | { |
1091 | setFormattedName( str ); | 1092 | setFormattedName( str ); |
1092 | setName( str ); | 1093 | setName( str ); |
1093 | 1094 | ||
1094 | static bool first = true; | 1095 | static bool first = true; |
1095 | static QStringList titles; | 1096 | static QStringList titles; |
1096 | static QStringList suffixes; | 1097 | static QStringList suffixes; |
1097 | static QStringList prefixes; | 1098 | static QStringList prefixes; |
1098 | 1099 | ||
1099 | if ( first ) { | 1100 | if ( first ) { |
1100 | first = false; | 1101 | first = false; |
1101 | titles += i18n( "Dr." ); | 1102 | titles += i18n( "Dr." ); |
1102 | titles += i18n( "Miss" ); | 1103 | titles += i18n( "Miss" ); |
1103 | titles += i18n( "Mr." ); | 1104 | titles += i18n( "Mr." ); |
1104 | titles += i18n( "Mrs." ); | 1105 | titles += i18n( "Mrs." ); |
1105 | titles += i18n( "Ms." ); | 1106 | titles += i18n( "Ms." ); |
1106 | titles += i18n( "Prof." ); | 1107 | titles += i18n( "Prof." ); |
1107 | 1108 | ||
1108 | suffixes += i18n( "I" ); | 1109 | suffixes += i18n( "I" ); |
1109 | suffixes += i18n( "II" ); | 1110 | suffixes += i18n( "II" ); |
1110 | suffixes += i18n( "III" ); | 1111 | suffixes += i18n( "III" ); |
1111 | suffixes += i18n( "Jr." ); | 1112 | suffixes += i18n( "Jr." ); |
1112 | suffixes += i18n( "Sr." ); | 1113 | suffixes += i18n( "Sr." ); |
1113 | 1114 | ||
1114 | prefixes += "van"; | 1115 | prefixes += "van"; |
1115 | prefixes += "von"; | 1116 | prefixes += "von"; |
1116 | prefixes += "de"; | 1117 | prefixes += "de"; |
1117 | 1118 | ||
1118 | KConfig config( locateLocal( "config", "kabcrc") ); | 1119 | KConfig config( locateLocal( "config", "kabcrc") ); |
1119 | config.setGroup( "General" ); | 1120 | config.setGroup( "General" ); |
1120 | titles += config.readListEntry( "Prefixes" ); | 1121 | titles += config.readListEntry( "Prefixes" ); |
1121 | titles.remove( "" ); | 1122 | titles.remove( "" ); |
1122 | prefixes += config.readListEntry( "Inclusions" ); | 1123 | prefixes += config.readListEntry( "Inclusions" ); |
1123 | prefixes.remove( "" ); | 1124 | prefixes.remove( "" ); |
1124 | suffixes += config.readListEntry( "Suffixes" ); | 1125 | suffixes += config.readListEntry( "Suffixes" ); |
1125 | suffixes.remove( "" ); | 1126 | suffixes.remove( "" ); |
1126 | } | 1127 | } |
1127 | 1128 | ||
1128 | // clear all name parts | 1129 | // clear all name parts |
1129 | setPrefix( "" ); | 1130 | setPrefix( "" ); |
1130 | setGivenName( "" ); | 1131 | setGivenName( "" ); |
1131 | setAdditionalName( "" ); | 1132 | setAdditionalName( "" ); |
1132 | setFamilyName( "" ); | 1133 | setFamilyName( "" ); |
1133 | setSuffix( "" ); | 1134 | setSuffix( "" ); |
1134 | 1135 | ||
1135 | if ( str.isEmpty() ) | 1136 | if ( str.isEmpty() ) |
1136 | return; | 1137 | return; |
1137 | 1138 | ||
1138 | int i = str.find(','); | 1139 | int i = str.find(','); |
1139 | if( i < 0 ) { | 1140 | if( i < 0 ) { |
1140 | QStringList parts = QStringList::split( " ", str ); | 1141 | QStringList parts = QStringList::split( " ", str ); |
1141 | int leftOffset = 0; | 1142 | int leftOffset = 0; |
1142 | int rightOffset = parts.count() - 1; | 1143 | int rightOffset = parts.count() - 1; |
1143 | 1144 | ||
1144 | QString suffix; | 1145 | QString suffix; |
1145 | while ( rightOffset >= 0 ) { | 1146 | while ( rightOffset >= 0 ) { |
1146 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1147 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1147 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1148 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1148 | rightOffset--; | 1149 | rightOffset--; |
1149 | } else | 1150 | } else |
1150 | break; | 1151 | break; |
1151 | } | 1152 | } |
1152 | setSuffix( suffix ); | 1153 | setSuffix( suffix ); |
1153 | 1154 | ||
1154 | if ( rightOffset < 0 ) | 1155 | if ( rightOffset < 0 ) |
1155 | return; | 1156 | return; |
1156 | 1157 | ||
1157 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1158 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1158 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1159 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1159 | rightOffset--; | 1160 | rightOffset--; |
1160 | } else | 1161 | } else |
1161 | setFamilyName( parts[ rightOffset ] ); | 1162 | setFamilyName( parts[ rightOffset ] ); |
1162 | 1163 | ||
1163 | QString prefix; | 1164 | QString prefix; |
1164 | while ( leftOffset < rightOffset ) { | 1165 | while ( leftOffset < rightOffset ) { |
1165 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1166 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1166 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1167 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1167 | leftOffset++; | 1168 | leftOffset++; |
1168 | } else | 1169 | } else |
1169 | break; | 1170 | break; |
1170 | } | 1171 | } |
1171 | setPrefix( prefix ); | 1172 | setPrefix( prefix ); |
1172 | 1173 | ||
1173 | if ( leftOffset < rightOffset ) { | 1174 | if ( leftOffset < rightOffset ) { |
1174 | setGivenName( parts[ leftOffset ] ); | 1175 | setGivenName( parts[ leftOffset ] ); |
1175 | leftOffset++; | 1176 | leftOffset++; |
1176 | } | 1177 | } |
1177 | 1178 | ||
1178 | QString additionalName; | 1179 | QString additionalName; |
1179 | while ( leftOffset < rightOffset ) { | 1180 | while ( leftOffset < rightOffset ) { |
1180 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1181 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1181 | leftOffset++; | 1182 | leftOffset++; |
1182 | } | 1183 | } |
1183 | setAdditionalName( additionalName ); | 1184 | setAdditionalName( additionalName ); |
1184 | } else { | 1185 | } else { |
1185 | QString part1 = str.left( i ); | 1186 | QString part1 = str.left( i ); |
1186 | QString part2 = str.mid( i + 1 ); | 1187 | QString part2 = str.mid( i + 1 ); |
1187 | 1188 | ||
1188 | QStringList parts = QStringList::split( " ", part1 ); | 1189 | QStringList parts = QStringList::split( " ", part1 ); |
1189 | int leftOffset = 0; | 1190 | int leftOffset = 0; |
1190 | int rightOffset = parts.count() - 1; | 1191 | int rightOffset = parts.count() - 1; |
1191 | 1192 | ||
1192 | QString suffix; | 1193 | QString suffix; |
1193 | while ( rightOffset >= 0 ) { | 1194 | while ( rightOffset >= 0 ) { |
1194 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 1195 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
1195 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 1196 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
1196 | rightOffset--; | 1197 | rightOffset--; |
1197 | } else | 1198 | } else |
1198 | break; | 1199 | break; |
1199 | } | 1200 | } |
1200 | setSuffix( suffix ); | 1201 | setSuffix( suffix ); |
1201 | 1202 | ||
1202 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 1203 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
1203 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 1204 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
1204 | rightOffset--; | 1205 | rightOffset--; |
1205 | } else | 1206 | } else |
1206 | setFamilyName( parts[ rightOffset ] ); | 1207 | setFamilyName( parts[ rightOffset ] ); |
1207 | 1208 | ||
1208 | QString prefix; | 1209 | QString prefix; |
1209 | while ( leftOffset < rightOffset ) { | 1210 | while ( leftOffset < rightOffset ) { |
1210 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1211 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1211 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1212 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1212 | leftOffset++; | 1213 | leftOffset++; |
1213 | } else | 1214 | } else |
1214 | break; | 1215 | break; |
1215 | } | 1216 | } |
1216 | 1217 | ||
1217 | parts = QStringList::split( " ", part2 ); | 1218 | parts = QStringList::split( " ", part2 ); |
1218 | 1219 | ||
1219 | leftOffset = 0; | 1220 | leftOffset = 0; |
1220 | rightOffset = parts.count(); | 1221 | rightOffset = parts.count(); |
1221 | 1222 | ||
1222 | while ( leftOffset < rightOffset ) { | 1223 | while ( leftOffset < rightOffset ) { |
1223 | if ( titles.contains( parts[ leftOffset ] ) ) { | 1224 | if ( titles.contains( parts[ leftOffset ] ) ) { |
1224 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1225 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1225 | leftOffset++; | 1226 | leftOffset++; |
1226 | } else | 1227 | } else |
1227 | break; | 1228 | break; |
1228 | } | 1229 | } |
1229 | setPrefix( prefix ); | 1230 | setPrefix( prefix ); |
1230 | 1231 | ||
1231 | if ( leftOffset < rightOffset ) { | 1232 | if ( leftOffset < rightOffset ) { |
1232 | setGivenName( parts[ leftOffset ] ); | 1233 | setGivenName( parts[ leftOffset ] ); |
1233 | leftOffset++; | 1234 | leftOffset++; |
1234 | } | 1235 | } |
1235 | 1236 | ||
1236 | QString additionalName; | 1237 | QString additionalName; |
1237 | while ( leftOffset < rightOffset ) { | 1238 | while ( leftOffset < rightOffset ) { |
1238 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1239 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
1239 | leftOffset++; | 1240 | leftOffset++; |
1240 | } | 1241 | } |
1241 | setAdditionalName( additionalName ); | 1242 | setAdditionalName( additionalName ); |
1242 | } | 1243 | } |
1243 | } | 1244 | } |
1244 | 1245 | ||
1245 | QString Addressee::realName() const | 1246 | QString Addressee::realName() const |
1246 | { | 1247 | { |
1247 | if ( !formattedName().isEmpty() ) | 1248 | if ( !formattedName().isEmpty() ) |
1248 | return formattedName(); | 1249 | return formattedName(); |
1249 | 1250 | ||
1250 | QString n = assembledName(); | 1251 | QString n = assembledName(); |
1251 | 1252 | ||
1252 | if ( n.isEmpty() ) | 1253 | if ( n.isEmpty() ) |
1253 | n = name(); | 1254 | n = name(); |
1254 | 1255 | ||
1255 | return n; | 1256 | return n; |
1256 | } | 1257 | } |
1257 | 1258 | ||
1258 | QString Addressee::assembledName() const | 1259 | QString Addressee::assembledName() const |
1259 | { | 1260 | { |
1260 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1261 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
1261 | familyName() + " " + suffix(); | 1262 | familyName() + " " + suffix(); |
1262 | 1263 | ||
1263 | return name.simplifyWhiteSpace(); | 1264 | return name.simplifyWhiteSpace(); |
1264 | } | 1265 | } |
1265 | 1266 | ||
1266 | QString Addressee::fullEmail( const QString &email ) const | 1267 | QString Addressee::fullEmail( const QString &email ) const |
1267 | { | 1268 | { |
1268 | QString e; | 1269 | QString e; |
1269 | if ( email.isNull() ) { | 1270 | if ( email.isNull() ) { |
1270 | e = preferredEmail(); | 1271 | e = preferredEmail(); |
1271 | } else { | 1272 | } else { |
1272 | e = email; | 1273 | e = email; |
1273 | } | 1274 | } |
1274 | if ( e.isEmpty() ) return QString::null; | 1275 | if ( e.isEmpty() ) return QString::null; |
1275 | 1276 | ||
1276 | QString text; | 1277 | QString text; |
1277 | if ( realName().isEmpty() ) | 1278 | if ( realName().isEmpty() ) |
1278 | text = e; | 1279 | text = e; |
1279 | else | 1280 | else |
1280 | text = assembledName() + " <" + e + ">"; | 1281 | text = assembledName() + " <" + e + ">"; |
1281 | 1282 | ||
1282 | return text; | 1283 | return text; |
1283 | } | 1284 | } |
1284 | 1285 | ||
1285 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1286 | void Addressee::insertEmail( const QString &email, bool preferred ) |
1286 | { | 1287 | { |
1287 | detach(); | 1288 | detach(); |
1288 | 1289 | ||
1289 | QStringList::Iterator it = mData->emails.find( email ); | 1290 | QStringList::Iterator it = mData->emails.find( email ); |
1290 | 1291 | ||
1291 | if ( it != mData->emails.end() ) { | 1292 | if ( it != mData->emails.end() ) { |
1292 | if ( !preferred || it == mData->emails.begin() ) return; | 1293 | if ( !preferred || it == mData->emails.begin() ) return; |
1293 | mData->emails.remove( it ); | 1294 | mData->emails.remove( it ); |
1294 | mData->emails.prepend( email ); | 1295 | mData->emails.prepend( email ); |
1295 | } else { | 1296 | } else { |
1296 | if ( preferred ) { | 1297 | if ( preferred ) { |
1297 | mData->emails.prepend( email ); | 1298 | mData->emails.prepend( email ); |
1298 | } else { | 1299 | } else { |
1299 | mData->emails.append( email ); | 1300 | mData->emails.append( email ); |
1300 | } | 1301 | } |
1301 | } | 1302 | } |
1302 | } | 1303 | } |
1303 | 1304 | ||
1304 | void Addressee::removeEmail( const QString &email ) | 1305 | void Addressee::removeEmail( const QString &email ) |
1305 | { | 1306 | { |
1306 | detach(); | 1307 | detach(); |
1307 | 1308 | ||
1308 | QStringList::Iterator it = mData->emails.find( email ); | 1309 | QStringList::Iterator it = mData->emails.find( email ); |
1309 | if ( it == mData->emails.end() ) return; | 1310 | if ( it == mData->emails.end() ) return; |
1310 | 1311 | ||
1311 | mData->emails.remove( it ); | 1312 | mData->emails.remove( it ); |
1312 | } | 1313 | } |
1313 | 1314 | ||
1314 | QString Addressee::preferredEmail() const | 1315 | QString Addressee::preferredEmail() const |
1315 | { | 1316 | { |
1316 | if ( mData->emails.count() == 0 ) return QString::null; | 1317 | if ( mData->emails.count() == 0 ) return QString::null; |
1317 | else return mData->emails.first(); | 1318 | else return mData->emails.first(); |
1318 | } | 1319 | } |
1319 | 1320 | ||
1320 | QStringList Addressee::emails() const | 1321 | QStringList Addressee::emails() const |
1321 | { | 1322 | { |
1322 | return mData->emails; | 1323 | return mData->emails; |
1323 | } | 1324 | } |
1324 | void Addressee::setEmails( const QStringList& emails ) { | 1325 | void Addressee::setEmails( const QStringList& emails ) { |
1325 | detach(); | 1326 | detach(); |
1326 | mData->emails = emails; | 1327 | mData->emails = emails; |
1327 | } | 1328 | } |
1328 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1329 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1329 | { | 1330 | { |
1330 | detach(); | 1331 | detach(); |
1331 | mData->empty = false; | 1332 | mData->empty = false; |
1332 | 1333 | ||
1333 | PhoneNumber::List::Iterator it; | 1334 | PhoneNumber::List::Iterator it; |
1334 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1335 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1335 | if ( (*it).id() == phoneNumber.id() ) { | 1336 | if ( (*it).id() == phoneNumber.id() ) { |
1336 | *it = phoneNumber; | 1337 | *it = phoneNumber; |
1337 | return; | 1338 | return; |
1338 | } | 1339 | } |
1339 | } | 1340 | } |
1340 | mData->phoneNumbers.append( phoneNumber ); | 1341 | mData->phoneNumbers.append( phoneNumber ); |
1341 | } | 1342 | } |
1342 | 1343 | ||
1343 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1344 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1344 | { | 1345 | { |
1345 | detach(); | 1346 | detach(); |
1346 | 1347 | ||
1347 | PhoneNumber::List::Iterator it; | 1348 | PhoneNumber::List::Iterator it; |
1348 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1349 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1349 | if ( (*it).id() == phoneNumber.id() ) { | 1350 | if ( (*it).id() == phoneNumber.id() ) { |
1350 | mData->phoneNumbers.remove( it ); | 1351 | mData->phoneNumbers.remove( it ); |
1351 | return; | 1352 | return; |
1352 | } | 1353 | } |
1353 | } | 1354 | } |
1354 | } | 1355 | } |
1355 | 1356 | ||
1356 | PhoneNumber Addressee::phoneNumber( int type ) const | 1357 | PhoneNumber Addressee::phoneNumber( int type ) const |
1357 | { | 1358 | { |
1358 | PhoneNumber phoneNumber( "", type ); | 1359 | PhoneNumber phoneNumber( "", type ); |
1359 | PhoneNumber::List::ConstIterator it; | 1360 | PhoneNumber::List::ConstIterator it; |
1360 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1361 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1361 | if ( matchBinaryPatternP( (*it).type(), type ) ) { | 1362 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1362 | if ( (*it).type() & PhoneNumber::Pref ) | 1363 | if ( (*it).type() & PhoneNumber::Pref ) |
1363 | return (*it); | 1364 | return (*it); |
1364 | else if ( phoneNumber.number().isEmpty() ) | 1365 | else if ( phoneNumber.number().isEmpty() ) |
1365 | phoneNumber = (*it); | 1366 | phoneNumber = (*it); |
1366 | } | 1367 | } |
1367 | } | 1368 | } |
1368 | 1369 | ||
1369 | return phoneNumber; | 1370 | return phoneNumber; |
1370 | } | 1371 | } |
1371 | 1372 | ||
1372 | PhoneNumber::List Addressee::phoneNumbers() const | 1373 | PhoneNumber::List Addressee::phoneNumbers() const |
1373 | { | 1374 | { |
1374 | return mData->phoneNumbers; | 1375 | return mData->phoneNumbers; |
1375 | } | 1376 | } |
1376 | 1377 | ||
1377 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1378 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1378 | { | 1379 | { |
1379 | PhoneNumber::List list; | 1380 | PhoneNumber::List list; |
1380 | 1381 | ||
1381 | PhoneNumber::List::ConstIterator it; | 1382 | PhoneNumber::List::ConstIterator it; |
1382 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1383 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1383 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1384 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1384 | list.append( *it ); | 1385 | list.append( *it ); |
1385 | } | 1386 | } |
1386 | } | 1387 | } |
1387 | return list; | 1388 | return list; |
1388 | } | 1389 | } |
1389 | 1390 | ||
1390 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1391 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1391 | { | 1392 | { |
1392 | PhoneNumber::List::ConstIterator it; | 1393 | PhoneNumber::List::ConstIterator it; |
1393 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1394 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1394 | if ( (*it).id() == id ) { | 1395 | if ( (*it).id() == id ) { |
1395 | return *it; | 1396 | return *it; |
1396 | } | 1397 | } |
1397 | } | 1398 | } |
1398 | return PhoneNumber(); | 1399 | return PhoneNumber(); |
1399 | } | 1400 | } |
1400 | 1401 | ||
1401 | void Addressee::insertKey( const Key &key ) | 1402 | void Addressee::insertKey( const Key &key ) |
1402 | { | 1403 | { |
1403 | detach(); | 1404 | detach(); |
1404 | mData->empty = false; | 1405 | mData->empty = false; |
1405 | 1406 | ||
1406 | Key::List::Iterator it; | 1407 | Key::List::Iterator it; |
1407 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1408 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1408 | if ( (*it).id() == key.id() ) { | 1409 | if ( (*it).id() == key.id() ) { |
1409 | *it = key; | 1410 | *it = key; |
1410 | return; | 1411 | return; |
1411 | } | 1412 | } |
1412 | } | 1413 | } |
1413 | mData->keys.append( key ); | 1414 | mData->keys.append( key ); |
1414 | } | 1415 | } |
1415 | 1416 | ||
1416 | void Addressee::removeKey( const Key &key ) | 1417 | void Addressee::removeKey( const Key &key ) |
1417 | { | 1418 | { |
1418 | detach(); | 1419 | detach(); |
1419 | 1420 | ||
1420 | Key::List::Iterator it; | 1421 | Key::List::Iterator it; |
1421 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1422 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1422 | if ( (*it).id() == key.id() ) { | 1423 | if ( (*it).id() == key.id() ) { |
1423 | mData->keys.remove( key ); | 1424 | mData->keys.remove( key ); |
1424 | return; | 1425 | return; |
1425 | } | 1426 | } |
1426 | } | 1427 | } |
1427 | } | 1428 | } |
1428 | 1429 | ||
1429 | Key Addressee::key( int type, QString customTypeString ) const | 1430 | Key Addressee::key( int type, QString customTypeString ) const |
1430 | { | 1431 | { |
1431 | Key::List::ConstIterator it; | 1432 | Key::List::ConstIterator it; |
1432 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1433 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1433 | if ( (*it).type() == type ) { | 1434 | if ( (*it).type() == type ) { |
1434 | if ( type == Key::Custom ) { | 1435 | if ( type == Key::Custom ) { |
1435 | if ( customTypeString.isEmpty() ) { | 1436 | if ( customTypeString.isEmpty() ) { |
1436 | return *it; | 1437 | return *it; |
1437 | } else { | 1438 | } else { |
1438 | if ( (*it).customTypeString() == customTypeString ) | 1439 | if ( (*it).customTypeString() == customTypeString ) |
1439 | return (*it); | 1440 | return (*it); |
1440 | } | 1441 | } |
1441 | } else { | 1442 | } else { |
1442 | return *it; | 1443 | return *it; |
1443 | } | 1444 | } |
1444 | } | 1445 | } |
1445 | } | 1446 | } |
1446 | return Key( QString(), type ); | 1447 | return Key( QString(), type ); |
1447 | } | 1448 | } |
1448 | void Addressee::setKeys( const Key::List& list ) { | 1449 | void Addressee::setKeys( const Key::List& list ) { |
1449 | detach(); | 1450 | detach(); |
1450 | mData->keys = list; | 1451 | mData->keys = list; |
1451 | } | 1452 | } |
1452 | 1453 | ||
1453 | Key::List Addressee::keys() const | 1454 | Key::List Addressee::keys() const |
1454 | { | 1455 | { |
1455 | return mData->keys; | 1456 | return mData->keys; |
1456 | } | 1457 | } |
1457 | 1458 | ||
1458 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1459 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1459 | { | 1460 | { |
1460 | Key::List list; | 1461 | Key::List list; |
1461 | 1462 | ||
1462 | Key::List::ConstIterator it; | 1463 | Key::List::ConstIterator it; |
1463 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1464 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1464 | if ( (*it).type() == type ) { | 1465 | if ( (*it).type() == type ) { |
1465 | if ( type == Key::Custom ) { | 1466 | if ( type == Key::Custom ) { |
1466 | if ( customTypeString.isEmpty() ) { | 1467 | if ( customTypeString.isEmpty() ) { |
1467 | list.append(*it); | 1468 | list.append(*it); |
1468 | } else { | 1469 | } else { |
1469 | if ( (*it).customTypeString() == customTypeString ) | 1470 | if ( (*it).customTypeString() == customTypeString ) |
1470 | list.append(*it); | 1471 | list.append(*it); |
1471 | } | 1472 | } |
1472 | } else { | 1473 | } else { |
1473 | list.append(*it); | 1474 | list.append(*it); |
1474 | } | 1475 | } |
1475 | } | 1476 | } |
1476 | } | 1477 | } |
1477 | return list; | 1478 | return list; |
1478 | } | 1479 | } |
1479 | 1480 | ||
1480 | Key Addressee::findKey( const QString &id ) const | 1481 | Key Addressee::findKey( const QString &id ) const |
1481 | { | 1482 | { |
1482 | Key::List::ConstIterator it; | 1483 | Key::List::ConstIterator it; |
1483 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1484 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1484 | if ( (*it).id() == id ) { | 1485 | if ( (*it).id() == id ) { |
1485 | return *it; | 1486 | return *it; |
1486 | } | 1487 | } |
1487 | } | 1488 | } |
1488 | return Key(); | 1489 | return Key(); |
1489 | } | 1490 | } |
1490 | 1491 | ||
1491 | QString Addressee::asString() const | 1492 | QString Addressee::asString() const |
1492 | { | 1493 | { |
1493 | return "Smith, agent Smith..."; | 1494 | return "Smith, agent Smith..."; |
1494 | } | 1495 | } |
1495 | 1496 | ||
1496 | void Addressee::dump() const | 1497 | void Addressee::dump() const |
1497 | { | 1498 | { |
1498 | return; | 1499 | return; |
1499 | kdDebug(5700) << "Addressee {" << endl; | 1500 | kdDebug(5700) << "Addressee {" << endl; |
1500 | 1501 | ||
1501 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1502 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1502 | 1503 | ||
1503 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1504 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1504 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1505 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1505 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1506 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1506 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1507 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1507 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1508 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1508 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1509 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1509 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1510 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1510 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1511 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1511 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1512 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1512 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1513 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1513 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1514 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1514 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1515 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1515 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1516 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1516 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1517 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1517 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1518 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1518 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1519 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1519 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1520 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1520 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1521 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1521 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1522 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1522 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1523 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1523 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1524 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1524 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1525 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1525 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1526 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1526 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1527 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1527 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1528 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1528 | 1529 | ||
1529 | kdDebug(5700) << " Emails {" << endl; | 1530 | kdDebug(5700) << " Emails {" << endl; |
1530 | QStringList e = emails(); | 1531 | QStringList e = emails(); |
1531 | QStringList::ConstIterator it; | 1532 | QStringList::ConstIterator it; |
1532 | for( it = e.begin(); it != e.end(); ++it ) { | 1533 | for( it = e.begin(); it != e.end(); ++it ) { |
1533 | kdDebug(5700) << " " << (*it) << endl; | 1534 | kdDebug(5700) << " " << (*it) << endl; |
1534 | } | 1535 | } |
1535 | kdDebug(5700) << " }" << endl; | 1536 | kdDebug(5700) << " }" << endl; |
1536 | 1537 | ||
1537 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1538 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1538 | PhoneNumber::List p = phoneNumbers(); | 1539 | PhoneNumber::List p = phoneNumbers(); |
1539 | PhoneNumber::List::ConstIterator it2; | 1540 | PhoneNumber::List::ConstIterator it2; |
1540 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1541 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1541 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1542 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1542 | } | 1543 | } |
1543 | kdDebug(5700) << " }" << endl; | 1544 | kdDebug(5700) << " }" << endl; |
1544 | 1545 | ||
1545 | Address::List a = addresses(); | 1546 | Address::List a = addresses(); |
1546 | Address::List::ConstIterator it3; | 1547 | Address::List::ConstIterator it3; |
1547 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1548 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1548 | (*it3).dump(); | 1549 | (*it3).dump(); |
1549 | } | 1550 | } |
1550 | 1551 | ||
1551 | kdDebug(5700) << " Keys {" << endl; | 1552 | kdDebug(5700) << " Keys {" << endl; |
1552 | Key::List k = keys(); | 1553 | Key::List k = keys(); |
1553 | Key::List::ConstIterator it4; | 1554 | Key::List::ConstIterator it4; |
1554 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1555 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1555 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1556 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1556 | " Key: " << (*it4).textData() << | 1557 | " Key: " << (*it4).textData() << |
1557 | " CustomString: " << (*it4).customTypeString() << endl; | 1558 | " CustomString: " << (*it4).customTypeString() << endl; |
1558 | } | 1559 | } |
1559 | kdDebug(5700) << " }" << endl; | 1560 | kdDebug(5700) << " }" << endl; |
1560 | 1561 | ||
1561 | kdDebug(5700) << "}" << endl; | 1562 | kdDebug(5700) << "}" << endl; |
1562 | } | 1563 | } |
1563 | 1564 | ||
1564 | 1565 | ||
1565 | void Addressee::insertAddress( const Address &address ) | 1566 | void Addressee::insertAddress( const Address &address ) |
1566 | { | 1567 | { |
1567 | detach(); | 1568 | detach(); |
1568 | mData->empty = false; | 1569 | mData->empty = false; |
1569 | 1570 | ||
1570 | Address::List::Iterator it; | 1571 | Address::List::Iterator it; |
1571 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1572 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1572 | if ( (*it).id() == address.id() ) { | 1573 | if ( (*it).id() == address.id() ) { |
1573 | *it = address; | 1574 | *it = address; |
1574 | return; | 1575 | return; |
1575 | } | 1576 | } |
1576 | } | 1577 | } |
1577 | mData->addresses.append( address ); | 1578 | mData->addresses.append( address ); |
1578 | } | 1579 | } |
1579 | 1580 | ||
1580 | void Addressee::removeAddress( const Address &address ) | 1581 | void Addressee::removeAddress( const Address &address ) |
1581 | { | 1582 | { |
1582 | detach(); | 1583 | detach(); |
1583 | 1584 | ||
1584 | Address::List::Iterator it; | 1585 | Address::List::Iterator it; |
1585 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1586 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1586 | if ( (*it).id() == address.id() ) { | 1587 | if ( (*it).id() == address.id() ) { |
1587 | mData->addresses.remove( it ); | 1588 | mData->addresses.remove( it ); |
1588 | return; | 1589 | return; |
1589 | } | 1590 | } |
1590 | } | 1591 | } |
1591 | } | 1592 | } |
1592 | 1593 | ||
1593 | Address Addressee::address( int type ) const | 1594 | Address Addressee::address( int type ) const |
1594 | { | 1595 | { |
1595 | Address address( type ); | 1596 | Address address( type ); |
1596 | Address::List::ConstIterator it; | 1597 | Address::List::ConstIterator it; |
1597 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1598 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1598 | if ( matchBinaryPatternA( (*it).type(), type ) ) { | 1599 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1599 | if ( (*it).type() & Address::Pref ) | 1600 | if ( (*it).type() & Address::Pref ) |
1600 | return (*it); | 1601 | return (*it); |
1601 | else if ( address.isEmpty() ) | 1602 | else if ( address.isEmpty() ) |
1602 | address = (*it); | 1603 | address = (*it); |
1603 | } | 1604 | } |
1604 | } | 1605 | } |
1605 | 1606 | ||
1606 | return address; | 1607 | return address; |
1607 | } | 1608 | } |
1608 | 1609 | ||
1609 | Address::List Addressee::addresses() const | 1610 | Address::List Addressee::addresses() const |
1610 | { | 1611 | { |
1611 | return mData->addresses; | 1612 | return mData->addresses; |
1612 | } | 1613 | } |
1613 | 1614 | ||
1614 | Address::List Addressee::addresses( int type ) const | 1615 | Address::List Addressee::addresses( int type ) const |
1615 | { | 1616 | { |
1616 | Address::List list; | 1617 | Address::List list; |
1617 | 1618 | ||
1618 | Address::List::ConstIterator it; | 1619 | Address::List::ConstIterator it; |
1619 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1620 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1620 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1621 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1621 | list.append( *it ); | 1622 | list.append( *it ); |
1622 | } | 1623 | } |
1623 | } | 1624 | } |
1624 | 1625 | ||
1625 | return list; | 1626 | return list; |
1626 | } | 1627 | } |
1627 | 1628 | ||
1628 | Address Addressee::findAddress( const QString &id ) const | 1629 | Address Addressee::findAddress( const QString &id ) const |
1629 | { | 1630 | { |
1630 | Address::List::ConstIterator it; | 1631 | Address::List::ConstIterator it; |
1631 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1632 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1632 | if ( (*it).id() == id ) { | 1633 | if ( (*it).id() == id ) { |
1633 | return *it; | 1634 | return *it; |
1634 | } | 1635 | } |
1635 | } | 1636 | } |
1636 | return Address(); | 1637 | return Address(); |
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | void Addressee::insertCategory( const QString &c ) | 1640 | void Addressee::insertCategory( const QString &c ) |
1640 | { | 1641 | { |
1641 | detach(); | 1642 | detach(); |
1642 | mData->empty = false; | 1643 | mData->empty = false; |
1643 | 1644 | ||
1644 | if ( mData->categories.contains( c ) ) return; | 1645 | if ( mData->categories.contains( c ) ) return; |
1645 | 1646 | ||
1646 | mData->categories.append( c ); | 1647 | mData->categories.append( c ); |
1647 | } | 1648 | } |
1648 | 1649 | ||
1649 | void Addressee::removeCategory( const QString &c ) | 1650 | void Addressee::removeCategory( const QString &c ) |
1650 | { | 1651 | { |
1651 | detach(); | 1652 | detach(); |
1652 | 1653 | ||
1653 | QStringList::Iterator it = mData->categories.find( c ); | 1654 | QStringList::Iterator it = mData->categories.find( c ); |
1654 | if ( it == mData->categories.end() ) return; | 1655 | if ( it == mData->categories.end() ) return; |
1655 | 1656 | ||
1656 | mData->categories.remove( it ); | 1657 | mData->categories.remove( it ); |
1657 | } | 1658 | } |
1658 | 1659 | ||
1659 | bool Addressee::hasCategory( const QString &c ) const | 1660 | bool Addressee::hasCategory( const QString &c ) const |
1660 | { | 1661 | { |
1661 | return ( mData->categories.contains( c ) ); | 1662 | return ( mData->categories.contains( c ) ); |
1662 | } | 1663 | } |
1663 | 1664 | ||
1664 | void Addressee::setCategories( const QStringList &c ) | 1665 | void Addressee::setCategories( const QStringList &c ) |
1665 | { | 1666 | { |
1666 | detach(); | 1667 | detach(); |
1667 | mData->empty = false; | 1668 | mData->empty = false; |
1668 | 1669 | ||
1669 | mData->categories = c; | 1670 | mData->categories = c; |
1670 | } | 1671 | } |
1671 | 1672 | ||
1672 | QStringList Addressee::categories() const | 1673 | QStringList Addressee::categories() const |
1673 | { | 1674 | { |
1674 | return mData->categories; | 1675 | return mData->categories; |
1675 | } | 1676 | } |
1676 | 1677 | ||
1677 | void Addressee::insertCustom( const QString &app, const QString &name, | 1678 | void Addressee::insertCustom( const QString &app, const QString &name, |
1678 | const QString &value ) | 1679 | const QString &value ) |
1679 | { | 1680 | { |
1680 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1681 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1681 | 1682 | ||
1682 | detach(); | 1683 | detach(); |
1683 | mData->empty = false; | 1684 | mData->empty = false; |
1684 | 1685 | ||
1685 | QString qualifiedName = app + "-" + name + ":"; | 1686 | QString qualifiedName = app + "-" + name + ":"; |
1686 | 1687 | ||
1687 | QStringList::Iterator it; | 1688 | QStringList::Iterator it; |
1688 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1689 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1689 | if ( (*it).startsWith( qualifiedName ) ) { | 1690 | if ( (*it).startsWith( qualifiedName ) ) { |
1690 | (*it) = qualifiedName + value; | 1691 | (*it) = qualifiedName + value; |
1691 | return; | 1692 | return; |
1692 | } | 1693 | } |
1693 | } | 1694 | } |
1694 | mData->custom.append( qualifiedName + value ); | 1695 | mData->custom.append( qualifiedName + value ); |
1695 | } | 1696 | } |
1696 | 1697 | ||
1697 | void Addressee::removeCustom( const QString &app, const QString &name) | 1698 | void Addressee::removeCustom( const QString &app, const QString &name) |
1698 | { | 1699 | { |
1699 | detach(); | 1700 | detach(); |
1700 | 1701 | ||
1701 | QString qualifiedName = app + "-" + name + ":"; | 1702 | QString qualifiedName = app + "-" + name + ":"; |
1702 | 1703 | ||
1703 | QStringList::Iterator it; | 1704 | QStringList::Iterator it; |
1704 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1705 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1705 | if ( (*it).startsWith( qualifiedName ) ) { | 1706 | if ( (*it).startsWith( qualifiedName ) ) { |
1706 | mData->custom.remove( it ); | 1707 | mData->custom.remove( it ); |
1707 | return; | 1708 | return; |
1708 | } | 1709 | } |
1709 | } | 1710 | } |
1710 | } | 1711 | } |
1711 | 1712 | ||
1712 | QString Addressee::custom( const QString &app, const QString &name ) const | 1713 | QString Addressee::custom( const QString &app, const QString &name ) const |
1713 | { | 1714 | { |
1714 | QString qualifiedName = app + "-" + name + ":"; | 1715 | QString qualifiedName = app + "-" + name + ":"; |
1715 | QString value; | 1716 | QString value; |
1716 | 1717 | ||
1717 | QStringList::ConstIterator it; | 1718 | QStringList::ConstIterator it; |
1718 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1719 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1719 | if ( (*it).startsWith( qualifiedName ) ) { | 1720 | if ( (*it).startsWith( qualifiedName ) ) { |
1720 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1721 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1721 | break; | 1722 | break; |
1722 | } | 1723 | } |
1723 | } | 1724 | } |
1724 | 1725 | ||
1725 | return value; | 1726 | return value; |
1726 | } | 1727 | } |
1727 | 1728 | ||
1728 | void Addressee::setCustoms( const QStringList &l ) | 1729 | void Addressee::setCustoms( const QStringList &l ) |
1729 | { | 1730 | { |
1730 | detach(); | 1731 | detach(); |
1731 | mData->empty = false; | 1732 | mData->empty = false; |
1732 | 1733 | ||
1733 | mData->custom = l; | 1734 | mData->custom = l; |
1734 | } | 1735 | } |
1735 | 1736 | ||
1736 | QStringList Addressee::customs() const | 1737 | QStringList Addressee::customs() const |
1737 | { | 1738 | { |
1738 | return mData->custom; | 1739 | return mData->custom; |
1739 | } | 1740 | } |
1740 | 1741 | ||
1741 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1742 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1742 | QString &email) | 1743 | QString &email) |
1743 | { | 1744 | { |
1744 | int startPos, endPos, len; | 1745 | int startPos, endPos, len; |
1745 | QString partA, partB, result; | 1746 | QString partA, partB, result; |
1746 | char endCh = '>'; | 1747 | char endCh = '>'; |
1747 | 1748 | ||
1748 | startPos = rawEmail.find('<'); | 1749 | startPos = rawEmail.find('<'); |
1749 | if (startPos < 0) | 1750 | if (startPos < 0) |
1750 | { | 1751 | { |
1751 | startPos = rawEmail.find('('); | 1752 | startPos = rawEmail.find('('); |
1752 | endCh = ')'; | 1753 | endCh = ')'; |
1753 | } | 1754 | } |
1754 | if (startPos < 0) | 1755 | if (startPos < 0) |
1755 | { | 1756 | { |
1756 | // We couldn't find any separators, so we assume the whole string | 1757 | // We couldn't find any separators, so we assume the whole string |
1757 | // is the email address | 1758 | // is the email address |
1758 | email = rawEmail; | 1759 | email = rawEmail; |
1759 | fullName = ""; | 1760 | fullName = ""; |
1760 | } | 1761 | } |
1761 | else | 1762 | else |
1762 | { | 1763 | { |
1763 | // We have a start position, try to find an end | 1764 | // We have a start position, try to find an end |
1764 | endPos = rawEmail.find(endCh, startPos+1); | 1765 | endPos = rawEmail.find(endCh, startPos+1); |
1765 | 1766 | ||
1766 | if (endPos < 0) | 1767 | if (endPos < 0) |
1767 | { | 1768 | { |
1768 | // We couldn't find the end of the email address. We can only | 1769 | // We couldn't find the end of the email address. We can only |
1769 | // assume the entire string is the email address. | 1770 | // assume the entire string is the email address. |
1770 | email = rawEmail; | 1771 | email = rawEmail; |
1771 | fullName = ""; | 1772 | fullName = ""; |
1772 | } | 1773 | } |
1773 | else | 1774 | else |
1774 | { | 1775 | { |
1775 | // We have a start and end to the email address | 1776 | // We have a start and end to the email address |
1776 | 1777 | ||
1777 | // Grab the name part | 1778 | // Grab the name part |
1778 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1779 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1779 | 1780 | ||
1780 | // grab the email part | 1781 | // grab the email part |
1781 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1782 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1782 | 1783 | ||
1783 | // Check that we do not have any extra characters on the end of the | 1784 | // Check that we do not have any extra characters on the end of the |
1784 | // strings | 1785 | // strings |
1785 | len = fullName.length(); | 1786 | len = fullName.length(); |
1786 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1787 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1787 | fullName = fullName.mid(1, len-2); | 1788 | fullName = fullName.mid(1, len-2); |
1788 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1789 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1789 | fullName = fullName.mid(1, len-2); | 1790 | fullName = fullName.mid(1, len-2); |
1790 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1791 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1791 | fullName = fullName.mid(1, len-2); | 1792 | fullName = fullName.mid(1, len-2); |
1792 | } | 1793 | } |
1793 | } | 1794 | } |
1794 | } | 1795 | } |
1795 | 1796 | ||
1796 | void Addressee::setResource( Resource *resource ) | 1797 | void Addressee::setResource( Resource *resource ) |
1797 | { | 1798 | { |
1798 | detach(); | 1799 | detach(); |
1799 | mData->resource = resource; | 1800 | mData->resource = resource; |
1800 | } | 1801 | } |
1801 | 1802 | ||
1802 | Resource *Addressee::resource() const | 1803 | Resource *Addressee::resource() const |
1803 | { | 1804 | { |
1804 | return mData->resource; | 1805 | return mData->resource; |
1805 | } | 1806 | } |
1806 | 1807 | ||
1807 | //US | 1808 | //US |
1808 | QString Addressee::resourceLabel() | 1809 | QString Addressee::resourceLabel() |
1809 | { | 1810 | { |
1810 | return i18n("Resource"); | 1811 | return i18n("Resource"); |
1811 | } | 1812 | } |
1812 | 1813 | ||
1813 | void Addressee::setChanged( bool value ) | 1814 | void Addressee::setChanged( bool value ) |
1814 | { | 1815 | { |
1815 | detach(); | 1816 | detach(); |
1816 | mData->changed = value; | 1817 | mData->changed = value; |
1817 | } | 1818 | } |
1818 | 1819 | ||
1819 | bool Addressee::changed() const | 1820 | bool Addressee::changed() const |
1820 | { | 1821 | { |
1821 | return mData->changed; | 1822 | return mData->changed; |
1822 | } | 1823 | } |
1823 | 1824 | ||
1825 | void Addressee::setTagged( bool value ) | ||
1826 | { | ||
1827 | detach(); | ||
1828 | mData->tagged = value; | ||
1829 | } | ||
1830 | |||
1831 | bool Addressee::tagged() const | ||
1832 | { | ||
1833 | return mData->tagged; | ||
1834 | } | ||
1835 | |||
1824 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1836 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1825 | { | 1837 | { |
1826 | if (!a.mData) return s; | 1838 | if (!a.mData) return s; |
1827 | 1839 | ||
1828 | s << a.uid(); | 1840 | s << a.uid(); |
1829 | 1841 | ||
1830 | s << a.mData->name; | 1842 | s << a.mData->name; |
1831 | s << a.mData->formattedName; | 1843 | s << a.mData->formattedName; |
1832 | s << a.mData->familyName; | 1844 | s << a.mData->familyName; |
1833 | s << a.mData->givenName; | 1845 | s << a.mData->givenName; |
1834 | s << a.mData->additionalName; | 1846 | s << a.mData->additionalName; |
1835 | s << a.mData->prefix; | 1847 | s << a.mData->prefix; |
1836 | s << a.mData->suffix; | 1848 | s << a.mData->suffix; |
1837 | s << a.mData->nickName; | 1849 | s << a.mData->nickName; |
1838 | s << a.mData->birthday; | 1850 | s << a.mData->birthday; |
1839 | s << a.mData->mailer; | 1851 | s << a.mData->mailer; |
1840 | s << a.mData->timeZone; | 1852 | s << a.mData->timeZone; |
1841 | s << a.mData->geo; | 1853 | s << a.mData->geo; |
1842 | s << a.mData->title; | 1854 | s << a.mData->title; |
1843 | s << a.mData->role; | 1855 | s << a.mData->role; |
1844 | s << a.mData->organization; | 1856 | s << a.mData->organization; |
1845 | s << a.mData->note; | 1857 | s << a.mData->note; |
1846 | s << a.mData->productId; | 1858 | s << a.mData->productId; |
1847 | s << a.mData->revision; | 1859 | s << a.mData->revision; |
1848 | s << a.mData->sortString; | 1860 | s << a.mData->sortString; |
1849 | s << a.mData->url; | 1861 | s << a.mData->url; |
1850 | s << a.mData->secrecy; | 1862 | s << a.mData->secrecy; |
1851 | s << a.mData->logo; | 1863 | s << a.mData->logo; |
1852 | s << a.mData->photo; | 1864 | s << a.mData->photo; |
1853 | s << a.mData->sound; | 1865 | s << a.mData->sound; |
1854 | s << a.mData->agent; | 1866 | s << a.mData->agent; |
1855 | s << a.mData->phoneNumbers; | 1867 | s << a.mData->phoneNumbers; |
1856 | s << a.mData->addresses; | 1868 | s << a.mData->addresses; |
1857 | s << a.mData->emails; | 1869 | s << a.mData->emails; |
1858 | s << a.mData->categories; | 1870 | s << a.mData->categories; |
1859 | s << a.mData->custom; | 1871 | s << a.mData->custom; |
1860 | s << a.mData->keys; | 1872 | s << a.mData->keys; |
1861 | return s; | 1873 | return s; |
1862 | } | 1874 | } |
1863 | 1875 | ||
1864 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1876 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1865 | { | 1877 | { |
1866 | if (!a.mData) return s; | 1878 | if (!a.mData) return s; |
1867 | 1879 | ||
1868 | s >> a.mData->uid; | 1880 | s >> a.mData->uid; |
1869 | 1881 | ||
1870 | s >> a.mData->name; | 1882 | s >> a.mData->name; |
1871 | s >> a.mData->formattedName; | 1883 | s >> a.mData->formattedName; |
1872 | s >> a.mData->familyName; | 1884 | s >> a.mData->familyName; |
1873 | s >> a.mData->givenName; | 1885 | s >> a.mData->givenName; |
1874 | s >> a.mData->additionalName; | 1886 | s >> a.mData->additionalName; |
1875 | s >> a.mData->prefix; | 1887 | s >> a.mData->prefix; |
1876 | s >> a.mData->suffix; | 1888 | s >> a.mData->suffix; |
1877 | s >> a.mData->nickName; | 1889 | s >> a.mData->nickName; |
1878 | s >> a.mData->birthday; | 1890 | s >> a.mData->birthday; |
1879 | s >> a.mData->mailer; | 1891 | s >> a.mData->mailer; |
1880 | s >> a.mData->timeZone; | 1892 | s >> a.mData->timeZone; |
1881 | s >> a.mData->geo; | 1893 | s >> a.mData->geo; |
1882 | s >> a.mData->title; | 1894 | s >> a.mData->title; |
1883 | s >> a.mData->role; | 1895 | s >> a.mData->role; |
1884 | s >> a.mData->organization; | 1896 | s >> a.mData->organization; |
1885 | s >> a.mData->note; | 1897 | s >> a.mData->note; |
1886 | s >> a.mData->productId; | 1898 | s >> a.mData->productId; |
1887 | s >> a.mData->revision; | 1899 | s >> a.mData->revision; |
1888 | s >> a.mData->sortString; | 1900 | s >> a.mData->sortString; |
1889 | s >> a.mData->url; | 1901 | s >> a.mData->url; |
1890 | s >> a.mData->secrecy; | 1902 | s >> a.mData->secrecy; |
1891 | s >> a.mData->logo; | 1903 | s >> a.mData->logo; |
1892 | s >> a.mData->photo; | 1904 | s >> a.mData->photo; |
1893 | s >> a.mData->sound; | 1905 | s >> a.mData->sound; |
1894 | s >> a.mData->agent; | 1906 | s >> a.mData->agent; |
1895 | s >> a.mData->phoneNumbers; | 1907 | s >> a.mData->phoneNumbers; |
1896 | s >> a.mData->addresses; | 1908 | s >> a.mData->addresses; |
1897 | s >> a.mData->emails; | 1909 | s >> a.mData->emails; |
1898 | s >> a.mData->categories; | 1910 | s >> a.mData->categories; |
1899 | s >> a.mData->custom; | 1911 | s >> a.mData->custom; |
1900 | s >> a.mData->keys; | 1912 | s >> a.mData->keys; |
1901 | 1913 | ||
1902 | a.mData->empty = false; | 1914 | a.mData->empty = false; |
1903 | 1915 | ||
1904 | return s; | 1916 | return s; |
1905 | } | 1917 | } |
1906 | bool matchBinaryPattern( int value, int pattern ) | 1918 | bool matchBinaryPattern( int value, int pattern ) |
1907 | { | 1919 | { |
1908 | /** | 1920 | /** |
1909 | We want to match all telephonnumbers/addresses which have the bits in the | 1921 | We want to match all telephonnumbers/addresses which have the bits in the |
1910 | pattern set. More are allowed. | 1922 | pattern set. More are allowed. |
1911 | if pattern == 0 we have a special handling, then we want only those with | 1923 | if pattern == 0 we have a special handling, then we want only those with |
1912 | exactly no bit set. | 1924 | exactly no bit set. |
1913 | */ | 1925 | */ |
1914 | if ( pattern == 0 ) | 1926 | if ( pattern == 0 ) |
1915 | return ( value == 0 ); | 1927 | return ( value == 0 ); |
1916 | else | 1928 | else |
1917 | return ( pattern == ( pattern & value ) ); | 1929 | return ( pattern == ( pattern & value ) ); |
1918 | } | 1930 | } |
1919 | 1931 | ||
1920 | bool matchBinaryPatternP( int value, int pattern ) | 1932 | bool matchBinaryPatternP( int value, int pattern ) |
1921 | { | 1933 | { |
1922 | 1934 | ||
1923 | if ( pattern == 0 ) | 1935 | if ( pattern == 0 ) |
1924 | return ( value == 0 ); | 1936 | return ( value == 0 ); |
1925 | else | 1937 | else |
1926 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | 1938 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); |
1927 | } | 1939 | } |
1928 | bool matchBinaryPatternA( int value, int pattern ) | 1940 | bool matchBinaryPatternA( int value, int pattern ) |
1929 | { | 1941 | { |
1930 | 1942 | ||
1931 | if ( pattern == 0 ) | 1943 | if ( pattern == 0 ) |
1932 | return ( value == 0 ); | 1944 | return ( value == 0 ); |
1933 | else | 1945 | else |
1934 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | 1946 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); |
1935 | } | 1947 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 9336edc..0aa2c51 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,849 +1,852 @@ | |||
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 | void setExternalUID( const QString &id ); | 115 | void setExternalUID( const QString &id ); |
116 | QString externalUID() const; | 116 | QString externalUID() const; |
117 | void setOriginalExternalUID( const QString &id ); | 117 | void setOriginalExternalUID( const QString &id ); |
118 | QString originalExternalUID() const; | 118 | QString originalExternalUID() const; |
119 | void mergeContact( const Addressee& ad ); | 119 | void mergeContact( const Addressee& ad ); |
120 | void simplifyEmails(); | 120 | void simplifyEmails(); |
121 | void simplifyAddresses(); | 121 | void simplifyAddresses(); |
122 | void simplifyPhoneNumbers(); | 122 | void simplifyPhoneNumbers(); |
123 | void simplifyPhoneNumberTypes(); | 123 | void simplifyPhoneNumberTypes(); |
124 | bool removeVoice(); | 124 | bool removeVoice(); |
125 | 125 | ||
126 | /** | 126 | /** |
127 | Set unique identifier. | 127 | Set unique identifier. |
128 | */ | 128 | */ |
129 | void setUid( const QString &uid ); | 129 | void setUid( const QString &uid ); |
130 | /** | 130 | /** |
131 | Return unique identifier. | 131 | Return unique identifier. |
132 | */ | 132 | */ |
133 | QString uid() const; | 133 | QString uid() const; |
134 | /** | 134 | /** |
135 | Return translated label for uid field. | 135 | Return translated label for uid field. |
136 | */ | 136 | */ |
137 | static QString uidLabel(); | 137 | static QString uidLabel(); |
138 | 138 | ||
139 | /** | 139 | /** |
140 | Set name. | 140 | Set name. |
141 | */ | 141 | */ |
142 | void setName( const QString &name ); | 142 | void setName( const QString &name ); |
143 | /** | 143 | /** |
144 | Return name. | 144 | Return name. |
145 | */ | 145 | */ |
146 | QString name() const; | 146 | QString name() const; |
147 | /** | 147 | /** |
148 | Return translated label for name field. | 148 | Return translated label for name field. |
149 | */ | 149 | */ |
150 | static QString nameLabel(); | 150 | static QString nameLabel(); |
151 | 151 | ||
152 | /** | 152 | /** |
153 | Set formatted name. | 153 | Set formatted name. |
154 | */ | 154 | */ |
155 | void setFormattedName( const QString &formattedName ); | 155 | void setFormattedName( const QString &formattedName ); |
156 | /** | 156 | /** |
157 | Return formatted name. | 157 | Return formatted name. |
158 | */ | 158 | */ |
159 | QString formattedName() const; | 159 | QString formattedName() const; |
160 | /** | 160 | /** |
161 | Return translated label for formattedName field. | 161 | Return translated label for formattedName field. |
162 | */ | 162 | */ |
163 | static QString formattedNameLabel(); | 163 | static QString formattedNameLabel(); |
164 | 164 | ||
165 | /** | 165 | /** |
166 | Set family name. | 166 | Set family name. |
167 | */ | 167 | */ |
168 | void setFamilyName( const QString &familyName ); | 168 | void setFamilyName( const QString &familyName ); |
169 | /** | 169 | /** |
170 | Return family name. | 170 | Return family name. |
171 | */ | 171 | */ |
172 | QString familyName() const; | 172 | QString familyName() const; |
173 | /** | 173 | /** |
174 | Return translated label for familyName field. | 174 | Return translated label for familyName field. |
175 | */ | 175 | */ |
176 | static QString familyNameLabel(); | 176 | static QString familyNameLabel(); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | Set given name. | 179 | Set given name. |
180 | */ | 180 | */ |
181 | void setGivenName( const QString &givenName ); | 181 | void setGivenName( const QString &givenName ); |
182 | /** | 182 | /** |
183 | Return given name. | 183 | Return given name. |
184 | */ | 184 | */ |
185 | QString givenName() const; | 185 | QString givenName() const; |
186 | /** | 186 | /** |
187 | Return translated label for givenName field. | 187 | Return translated label for givenName field. |
188 | */ | 188 | */ |
189 | static QString givenNameLabel(); | 189 | static QString givenNameLabel(); |
190 | 190 | ||
191 | /** | 191 | /** |
192 | Set additional names. | 192 | Set additional names. |
193 | */ | 193 | */ |
194 | void setAdditionalName( const QString &additionalName ); | 194 | void setAdditionalName( const QString &additionalName ); |
195 | /** | 195 | /** |
196 | Return additional names. | 196 | Return additional names. |
197 | */ | 197 | */ |
198 | QString additionalName() const; | 198 | QString additionalName() const; |
199 | /** | 199 | /** |
200 | Return translated label for additionalName field. | 200 | Return translated label for additionalName field. |
201 | */ | 201 | */ |
202 | static QString additionalNameLabel(); | 202 | static QString additionalNameLabel(); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Set honorific prefixes. | 205 | Set honorific prefixes. |
206 | */ | 206 | */ |
207 | void setPrefix( const QString &prefix ); | 207 | void setPrefix( const QString &prefix ); |
208 | /** | 208 | /** |
209 | Return honorific prefixes. | 209 | Return honorific prefixes. |
210 | */ | 210 | */ |
211 | QString prefix() const; | 211 | QString prefix() const; |
212 | /** | 212 | /** |
213 | Return translated label for prefix field. | 213 | Return translated label for prefix field. |
214 | */ | 214 | */ |
215 | static QString prefixLabel(); | 215 | static QString prefixLabel(); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | Set honorific suffixes. | 218 | Set honorific suffixes. |
219 | */ | 219 | */ |
220 | void setSuffix( const QString &suffix ); | 220 | void setSuffix( const QString &suffix ); |
221 | /** | 221 | /** |
222 | Return honorific suffixes. | 222 | Return honorific suffixes. |
223 | */ | 223 | */ |
224 | QString suffix() const; | 224 | QString suffix() const; |
225 | /** | 225 | /** |
226 | Return translated label for suffix field. | 226 | Return translated label for suffix field. |
227 | */ | 227 | */ |
228 | static QString suffixLabel(); | 228 | static QString suffixLabel(); |
229 | 229 | ||
230 | /** | 230 | /** |
231 | Set nick name. | 231 | Set nick name. |
232 | */ | 232 | */ |
233 | void setNickName( const QString &nickName ); | 233 | void setNickName( const QString &nickName ); |
234 | /** | 234 | /** |
235 | Return nick name. | 235 | Return nick name. |
236 | */ | 236 | */ |
237 | QString nickName() const; | 237 | QString nickName() const; |
238 | /** | 238 | /** |
239 | Return translated label for nickName field. | 239 | Return translated label for nickName field. |
240 | */ | 240 | */ |
241 | static QString nickNameLabel(); | 241 | static QString nickNameLabel(); |
242 | 242 | ||
243 | /** | 243 | /** |
244 | Set birthday. | 244 | Set birthday. |
245 | */ | 245 | */ |
246 | void setBirthday( const QDateTime &birthday ); | 246 | void setBirthday( const QDateTime &birthday ); |
247 | /** | 247 | /** |
248 | Return birthday. | 248 | Return birthday. |
249 | */ | 249 | */ |
250 | QDateTime birthday() const; | 250 | QDateTime birthday() const; |
251 | /** | 251 | /** |
252 | Return translated label for birthday field. | 252 | Return translated label for birthday field. |
253 | */ | 253 | */ |
254 | static QString birthdayLabel(); | 254 | static QString birthdayLabel(); |
255 | 255 | ||
256 | /** | 256 | /** |
257 | Return translated label for homeAddressStreet field. | 257 | Return translated label for homeAddressStreet field. |
258 | */ | 258 | */ |
259 | static QString homeAddressStreetLabel(); | 259 | static QString homeAddressStreetLabel(); |
260 | 260 | ||
261 | /** | 261 | /** |
262 | Return translated label for homeAddressLocality field. | 262 | Return translated label for homeAddressLocality field. |
263 | */ | 263 | */ |
264 | static QString homeAddressLocalityLabel(); | 264 | static QString homeAddressLocalityLabel(); |
265 | 265 | ||
266 | /** | 266 | /** |
267 | Return translated label for homeAddressRegion field. | 267 | Return translated label for homeAddressRegion field. |
268 | */ | 268 | */ |
269 | static QString homeAddressRegionLabel(); | 269 | static QString homeAddressRegionLabel(); |
270 | 270 | ||
271 | /** | 271 | /** |
272 | Return translated label for homeAddressPostalCode field. | 272 | Return translated label for homeAddressPostalCode field. |
273 | */ | 273 | */ |
274 | static QString homeAddressPostalCodeLabel(); | 274 | static QString homeAddressPostalCodeLabel(); |
275 | 275 | ||
276 | /** | 276 | /** |
277 | Return translated label for homeAddressCountry field. | 277 | Return translated label for homeAddressCountry field. |
278 | */ | 278 | */ |
279 | static QString homeAddressCountryLabel(); | 279 | static QString homeAddressCountryLabel(); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | Return translated label for homeAddressLabel field. | 282 | Return translated label for homeAddressLabel field. |
283 | */ | 283 | */ |
284 | static QString homeAddressLabelLabel(); | 284 | static QString homeAddressLabelLabel(); |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Return translated label for businessAddressStreet field. | 287 | Return translated label for businessAddressStreet field. |
288 | */ | 288 | */ |
289 | static QString businessAddressStreetLabel(); | 289 | static QString businessAddressStreetLabel(); |
290 | 290 | ||
291 | /** | 291 | /** |
292 | Return translated label for businessAddressLocality field. | 292 | Return translated label for businessAddressLocality field. |
293 | */ | 293 | */ |
294 | static QString businessAddressLocalityLabel(); | 294 | static QString businessAddressLocalityLabel(); |
295 | 295 | ||
296 | /** | 296 | /** |
297 | Return translated label for businessAddressRegion field. | 297 | Return translated label for businessAddressRegion field. |
298 | */ | 298 | */ |
299 | static QString businessAddressRegionLabel(); | 299 | static QString businessAddressRegionLabel(); |
300 | 300 | ||
301 | /** | 301 | /** |
302 | Return translated label for businessAddressPostalCode field. | 302 | Return translated label for businessAddressPostalCode field. |
303 | */ | 303 | */ |
304 | static QString businessAddressPostalCodeLabel(); | 304 | static QString businessAddressPostalCodeLabel(); |
305 | 305 | ||
306 | /** | 306 | /** |
307 | Return translated label for businessAddressCountry field. | 307 | Return translated label for businessAddressCountry field. |
308 | */ | 308 | */ |
309 | static QString businessAddressCountryLabel(); | 309 | static QString businessAddressCountryLabel(); |
310 | 310 | ||
311 | /** | 311 | /** |
312 | Return translated label for businessAddressLabel field. | 312 | Return translated label for businessAddressLabel field. |
313 | */ | 313 | */ |
314 | static QString businessAddressLabelLabel(); | 314 | static QString businessAddressLabelLabel(); |
315 | 315 | ||
316 | /** | 316 | /** |
317 | Return translated label for homePhone field. | 317 | Return translated label for homePhone field. |
318 | */ | 318 | */ |
319 | static QString homePhoneLabel(); | 319 | static QString homePhoneLabel(); |
320 | 320 | ||
321 | /** | 321 | /** |
322 | Return translated label for businessPhone field. | 322 | Return translated label for businessPhone field. |
323 | */ | 323 | */ |
324 | static QString businessPhoneLabel(); | 324 | static QString businessPhoneLabel(); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | Return translated label for mobilePhone field. | 327 | Return translated label for mobilePhone field. |
328 | */ | 328 | */ |
329 | static QString mobilePhoneLabel(); | 329 | static QString mobilePhoneLabel(); |
330 | 330 | ||
331 | /** | 331 | /** |
332 | Return translated label for homeFax field. | 332 | Return translated label for homeFax field. |
333 | */ | 333 | */ |
334 | static QString homeFaxLabel(); | 334 | static QString homeFaxLabel(); |
335 | 335 | ||
336 | /** | 336 | /** |
337 | Return translated label for businessFax field. | 337 | Return translated label for businessFax field. |
338 | */ | 338 | */ |
339 | static QString businessFaxLabel(); | 339 | static QString businessFaxLabel(); |
340 | 340 | ||
341 | /** | 341 | /** |
342 | Return translated label for carPhone field. | 342 | Return translated label for carPhone field. |
343 | */ | 343 | */ |
344 | static QString carPhoneLabel(); | 344 | static QString carPhoneLabel(); |
345 | 345 | ||
346 | /** | 346 | /** |
347 | Return translated label for isdn field. | 347 | Return translated label for isdn field. |
348 | */ | 348 | */ |
349 | static QString isdnLabel(); | 349 | static QString isdnLabel(); |
350 | 350 | ||
351 | /** | 351 | /** |
352 | Return translated label for pager field. | 352 | Return translated label for pager field. |
353 | */ | 353 | */ |
354 | static QString pagerLabel(); | 354 | static QString pagerLabel(); |
355 | 355 | ||
356 | /** | 356 | /** |
357 | Return translated label for sip field. | 357 | Return translated label for sip field. |
358 | */ | 358 | */ |
359 | static QString sipLabel(); | 359 | static QString sipLabel(); |
360 | 360 | ||
361 | /** | 361 | /** |
362 | Return translated label for email field. | 362 | Return translated label for email field. |
363 | */ | 363 | */ |
364 | static QString emailLabel(); | 364 | static QString emailLabel(); |
365 | 365 | ||
366 | /** | 366 | /** |
367 | Set mail client. | 367 | Set mail client. |
368 | */ | 368 | */ |
369 | void setMailer( const QString &mailer ); | 369 | void setMailer( const QString &mailer ); |
370 | /** | 370 | /** |
371 | Return mail client. | 371 | Return mail client. |
372 | */ | 372 | */ |
373 | QString mailer() const; | 373 | QString mailer() const; |
374 | /** | 374 | /** |
375 | Return translated label for mailer field. | 375 | Return translated label for mailer field. |
376 | */ | 376 | */ |
377 | static QString mailerLabel(); | 377 | static QString mailerLabel(); |
378 | 378 | ||
379 | /** | 379 | /** |
380 | Set time zone. | 380 | Set time zone. |
381 | */ | 381 | */ |
382 | void setTimeZone( const TimeZone &timeZone ); | 382 | void setTimeZone( const TimeZone &timeZone ); |
383 | /** | 383 | /** |
384 | Return time zone. | 384 | Return time zone. |
385 | */ | 385 | */ |
386 | TimeZone timeZone() const; | 386 | TimeZone timeZone() const; |
387 | /** | 387 | /** |
388 | Return translated label for timeZone field. | 388 | Return translated label for timeZone field. |
389 | */ | 389 | */ |
390 | static QString timeZoneLabel(); | 390 | static QString timeZoneLabel(); |
391 | 391 | ||
392 | /** | 392 | /** |
393 | Set geographic position. | 393 | Set geographic position. |
394 | */ | 394 | */ |
395 | void setGeo( const Geo &geo ); | 395 | void setGeo( const Geo &geo ); |
396 | /** | 396 | /** |
397 | Return geographic position. | 397 | Return geographic position. |
398 | */ | 398 | */ |
399 | Geo geo() const; | 399 | Geo geo() const; |
400 | /** | 400 | /** |
401 | Return translated label for geo field. | 401 | Return translated label for geo field. |
402 | */ | 402 | */ |
403 | static QString geoLabel(); | 403 | static QString geoLabel(); |
404 | 404 | ||
405 | /** | 405 | /** |
406 | Set title. | 406 | Set title. |
407 | */ | 407 | */ |
408 | void setTitle( const QString &title ); | 408 | void setTitle( const QString &title ); |
409 | /** | 409 | /** |
410 | Return title. | 410 | Return title. |
411 | */ | 411 | */ |
412 | QString title() const; | 412 | QString title() const; |
413 | /** | 413 | /** |
414 | Return translated label for title field. | 414 | Return translated label for title field. |
415 | */ | 415 | */ |
416 | static QString titleLabel(); | 416 | static QString titleLabel(); |
417 | 417 | ||
418 | /** | 418 | /** |
419 | Set role. | 419 | Set role. |
420 | */ | 420 | */ |
421 | void setRole( const QString &role ); | 421 | void setRole( const QString &role ); |
422 | /** | 422 | /** |
423 | Return role. | 423 | Return role. |
424 | */ | 424 | */ |
425 | QString role() const; | 425 | QString role() const; |
426 | /** | 426 | /** |
427 | Return translated label for role field. | 427 | Return translated label for role field. |
428 | */ | 428 | */ |
429 | static QString roleLabel(); | 429 | static QString roleLabel(); |
430 | 430 | ||
431 | /** | 431 | /** |
432 | Set organization. | 432 | Set organization. |
433 | */ | 433 | */ |
434 | void setOrganization( const QString &organization ); | 434 | void setOrganization( const QString &organization ); |
435 | /** | 435 | /** |
436 | Return organization. | 436 | Return organization. |
437 | */ | 437 | */ |
438 | QString organization() const; | 438 | QString organization() const; |
439 | /** | 439 | /** |
440 | Return translated label for organization field. | 440 | Return translated label for organization field. |
441 | */ | 441 | */ |
442 | static QString organizationLabel(); | 442 | static QString organizationLabel(); |
443 | 443 | ||
444 | /** | 444 | /** |
445 | Set note. | 445 | Set note. |
446 | */ | 446 | */ |
447 | void setNote( const QString ¬e ); | 447 | void setNote( const QString ¬e ); |
448 | /** | 448 | /** |
449 | Return note. | 449 | Return note. |
450 | */ | 450 | */ |
451 | QString note() const; | 451 | QString note() const; |
452 | /** | 452 | /** |
453 | Return translated label for note field. | 453 | Return translated label for note field. |
454 | */ | 454 | */ |
455 | static QString noteLabel(); | 455 | static QString noteLabel(); |
456 | 456 | ||
457 | /** | 457 | /** |
458 | Set product identifier. | 458 | Set product identifier. |
459 | */ | 459 | */ |
460 | void setProductId( const QString &productId ); | 460 | void setProductId( const QString &productId ); |
461 | /** | 461 | /** |
462 | Return product identifier. | 462 | Return product identifier. |
463 | */ | 463 | */ |
464 | QString productId() const; | 464 | QString productId() const; |
465 | /** | 465 | /** |
466 | Return translated label for productId field. | 466 | Return translated label for productId field. |
467 | */ | 467 | */ |
468 | static QString productIdLabel(); | 468 | static QString productIdLabel(); |
469 | 469 | ||
470 | /** | 470 | /** |
471 | Set revision date. | 471 | Set revision date. |
472 | */ | 472 | */ |
473 | void setRevision( const QDateTime &revision ); | 473 | void setRevision( const QDateTime &revision ); |
474 | /** | 474 | /** |
475 | Return revision date. | 475 | Return revision date. |
476 | */ | 476 | */ |
477 | QDateTime revision() const; | 477 | QDateTime revision() const; |
478 | /** | 478 | /** |
479 | Return translated label for revision field. | 479 | Return translated label for revision field. |
480 | */ | 480 | */ |
481 | static QString revisionLabel(); | 481 | static QString revisionLabel(); |
482 | 482 | ||
483 | /** | 483 | /** |
484 | Set sort string. | 484 | Set sort string. |
485 | */ | 485 | */ |
486 | void setSortString( const QString &sortString ); | 486 | void setSortString( const QString &sortString ); |
487 | /** | 487 | /** |
488 | Return sort string. | 488 | Return sort string. |
489 | */ | 489 | */ |
490 | QString sortString() const; | 490 | QString sortString() const; |
491 | /** | 491 | /** |
492 | Return translated label for sortString field. | 492 | Return translated label for sortString field. |
493 | */ | 493 | */ |
494 | static QString sortStringLabel(); | 494 | static QString sortStringLabel(); |
495 | 495 | ||
496 | /** | 496 | /** |
497 | Set URL. | 497 | Set URL. |
498 | */ | 498 | */ |
499 | void setUrl( const KURL &url ); | 499 | void setUrl( const KURL &url ); |
500 | /** | 500 | /** |
501 | Return URL. | 501 | Return URL. |
502 | */ | 502 | */ |
503 | KURL url() const; | 503 | KURL url() const; |
504 | /** | 504 | /** |
505 | Return translated label for url field. | 505 | Return translated label for url field. |
506 | */ | 506 | */ |
507 | static QString urlLabel(); | 507 | static QString urlLabel(); |
508 | 508 | ||
509 | /** | 509 | /** |
510 | Set security class. | 510 | Set security class. |
511 | */ | 511 | */ |
512 | void setSecrecy( const Secrecy &secrecy ); | 512 | void setSecrecy( const Secrecy &secrecy ); |
513 | /** | 513 | /** |
514 | Return security class. | 514 | Return security class. |
515 | */ | 515 | */ |
516 | Secrecy secrecy() const; | 516 | Secrecy secrecy() const; |
517 | /** | 517 | /** |
518 | Return translated label for secrecy field. | 518 | Return translated label for secrecy field. |
519 | */ | 519 | */ |
520 | static QString secrecyLabel(); | 520 | static QString secrecyLabel(); |
521 | 521 | ||
522 | /** | 522 | /** |
523 | Set logo. | 523 | Set logo. |
524 | */ | 524 | */ |
525 | void setLogo( const Picture &logo ); | 525 | void setLogo( const Picture &logo ); |
526 | /** | 526 | /** |
527 | Return logo. | 527 | Return logo. |
528 | */ | 528 | */ |
529 | Picture logo() const; | 529 | Picture logo() const; |
530 | /** | 530 | /** |
531 | Return translated label for logo field. | 531 | Return translated label for logo field. |
532 | */ | 532 | */ |
533 | static QString logoLabel(); | 533 | static QString logoLabel(); |
534 | 534 | ||
535 | /** | 535 | /** |
536 | Set photo. | 536 | Set photo. |
537 | */ | 537 | */ |
538 | void setPhoto( const Picture &photo ); | 538 | void setPhoto( const Picture &photo ); |
539 | /** | 539 | /** |
540 | Return photo. | 540 | Return photo. |
541 | */ | 541 | */ |
542 | Picture photo() const; | 542 | Picture photo() const; |
543 | /** | 543 | /** |
544 | Return translated label for photo field. | 544 | Return translated label for photo field. |
545 | */ | 545 | */ |
546 | static QString photoLabel(); | 546 | static QString photoLabel(); |
547 | 547 | ||
548 | /** | 548 | /** |
549 | Set sound. | 549 | Set sound. |
550 | */ | 550 | */ |
551 | void setSound( const Sound &sound ); | 551 | void setSound( const Sound &sound ); |
552 | /** | 552 | /** |
553 | Return sound. | 553 | Return sound. |
554 | */ | 554 | */ |
555 | Sound sound() const; | 555 | Sound sound() const; |
556 | /** | 556 | /** |
557 | Return translated label for sound field. | 557 | Return translated label for sound field. |
558 | */ | 558 | */ |
559 | static QString soundLabel(); | 559 | static QString soundLabel(); |
560 | 560 | ||
561 | /** | 561 | /** |
562 | Set agent. | 562 | Set agent. |
563 | */ | 563 | */ |
564 | void setAgent( const Agent &agent ); | 564 | void setAgent( const Agent &agent ); |
565 | /** | 565 | /** |
566 | Return agent. | 566 | Return agent. |
567 | */ | 567 | */ |
568 | Agent agent() const; | 568 | Agent agent() const; |
569 | /** | 569 | /** |
570 | Return translated label for agent field. | 570 | Return translated label for agent field. |
571 | */ | 571 | */ |
572 | static QString agentLabel(); | 572 | static QString agentLabel(); |
573 | 573 | ||
574 | /** | 574 | /** |
575 | Set name fields by parsing the given string and trying to associate the | 575 | Set name fields by parsing the given string and trying to associate the |
576 | parts of the string with according fields. This function should probably | 576 | parts of the string with according fields. This function should probably |
577 | be a bit more clever. | 577 | be a bit more clever. |
578 | */ | 578 | */ |
579 | void setNameFromString( const QString & ); | 579 | void setNameFromString( const QString & ); |
580 | 580 | ||
581 | /** | 581 | /** |
582 | Return the name of the addressee. This is calculated from all the name | 582 | Return the name of the addressee. This is calculated from all the name |
583 | fields. | 583 | fields. |
584 | */ | 584 | */ |
585 | QString realName() const; | 585 | QString realName() const; |
586 | 586 | ||
587 | /** | 587 | /** |
588 | Return the name that consists of all name parts. | 588 | Return the name that consists of all name parts. |
589 | */ | 589 | */ |
590 | QString assembledName() const; | 590 | QString assembledName() const; |
591 | 591 | ||
592 | /** | 592 | /** |
593 | Return email address including real name. | 593 | Return email address including real name. |
594 | 594 | ||
595 | @param email Email address to be used to construct the full email string. | 595 | @param email Email address to be used to construct the full email string. |
596 | If this is QString::null the preferred email address is used. | 596 | If this is QString::null the preferred email address is used. |
597 | */ | 597 | */ |
598 | QString fullEmail( const QString &email=QString::null ) const; | 598 | QString fullEmail( const QString &email=QString::null ) const; |
599 | 599 | ||
600 | /** | 600 | /** |
601 | Insert an email address. If the email address already exists in this | 601 | Insert an email address. If the email address already exists in this |
602 | addressee it is not duplicated. | 602 | addressee it is not duplicated. |
603 | 603 | ||
604 | @param email Email address | 604 | @param email Email address |
605 | @param preferred Set to true, if this is the preferred email address of | 605 | @param preferred Set to true, if this is the preferred email address of |
606 | the addressee. | 606 | the addressee. |
607 | */ | 607 | */ |
608 | void insertEmail( const QString &email, bool preferred=false ); | 608 | void insertEmail( const QString &email, bool preferred=false ); |
609 | 609 | ||
610 | /** | 610 | /** |
611 | Remove email address. If the email address doesn't exist, nothing happens. | 611 | Remove email address. If the email address doesn't exist, nothing happens. |
612 | */ | 612 | */ |
613 | void removeEmail( const QString &email ); | 613 | void removeEmail( const QString &email ); |
614 | 614 | ||
615 | /** | 615 | /** |
616 | Return preferred email address. This is the first email address or the | 616 | Return preferred email address. This is the first email address or the |
617 | last one added with @ref insertEmail() with a set preferred parameter. | 617 | last one added with @ref insertEmail() with a set preferred parameter. |
618 | */ | 618 | */ |
619 | QString preferredEmail() const; | 619 | QString preferredEmail() const; |
620 | 620 | ||
621 | /** | 621 | /** |
622 | Return list of all email addresses. | 622 | Return list of all email addresses. |
623 | */ | 623 | */ |
624 | QStringList emails() const; | 624 | QStringList emails() const; |
625 | 625 | ||
626 | /** | 626 | /** |
627 | Set the emails to @param. | 627 | Set the emails to @param. |
628 | The first email address gets the preferred one! | 628 | The first email address gets the preferred one! |
629 | @param list The list of email addresses. | 629 | @param list The list of email addresses. |
630 | */ | 630 | */ |
631 | void setEmails( const QStringList& list); | 631 | void setEmails( const QStringList& list); |
632 | 632 | ||
633 | /** | 633 | /** |
634 | Insert a phone number. If a phone number with the same id already exists | 634 | Insert a phone number. If a phone number with the same id already exists |
635 | in this addressee it is not duplicated. | 635 | in this addressee it is not duplicated. |
636 | */ | 636 | */ |
637 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 637 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
638 | 638 | ||
639 | /** | 639 | /** |
640 | Remove phone number. If no phone number with the given id exists for this | 640 | Remove phone number. If no phone number with the given id exists for this |
641 | addresse nothing happens. | 641 | addresse nothing happens. |
642 | */ | 642 | */ |
643 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 643 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
644 | 644 | ||
645 | /** | 645 | /** |
646 | Return phone number, which matches the given type. | 646 | Return phone number, which matches the given type. |
647 | */ | 647 | */ |
648 | PhoneNumber phoneNumber( int type ) const; | 648 | PhoneNumber phoneNumber( int type ) const; |
649 | 649 | ||
650 | /** | 650 | /** |
651 | Return list of all phone numbers. | 651 | Return list of all phone numbers. |
652 | */ | 652 | */ |
653 | PhoneNumber::List phoneNumbers() const; | 653 | PhoneNumber::List phoneNumbers() const; |
654 | 654 | ||
655 | /** | 655 | /** |
656 | Return list of phone numbers with a special type. | 656 | Return list of phone numbers with a special type. |
657 | */ | 657 | */ |
658 | PhoneNumber::List phoneNumbers( int type ) const; | 658 | PhoneNumber::List phoneNumbers( int type ) const; |
659 | 659 | ||
660 | /** | 660 | /** |
661 | Return phone number with the given id. | 661 | Return phone number with the given id. |
662 | */ | 662 | */ |
663 | PhoneNumber findPhoneNumber( const QString &id ) const; | 663 | PhoneNumber findPhoneNumber( const QString &id ) const; |
664 | 664 | ||
665 | /** | 665 | /** |
666 | Insert a key. If a key with the same id already exists | 666 | Insert a key. If a key with the same id already exists |
667 | in this addressee it is not duplicated. | 667 | in this addressee it is not duplicated. |
668 | */ | 668 | */ |
669 | void insertKey( const Key &key ); | 669 | void insertKey( const Key &key ); |
670 | 670 | ||
671 | /** | 671 | /** |
672 | Remove a key. If no key with the given id exists for this | 672 | Remove a key. If no key with the given id exists for this |
673 | addresse nothing happens. | 673 | addresse nothing happens. |
674 | */ | 674 | */ |
675 | void removeKey( const Key &key ); | 675 | void removeKey( const Key &key ); |
676 | 676 | ||
677 | /** | 677 | /** |
678 | Return key, which matches the given type. | 678 | Return key, which matches the given type. |
679 | If @p type == Key::Custom you can specify a string | 679 | If @p type == Key::Custom you can specify a string |
680 | that should match. If you leave the string empty, the first | 680 | that should match. If you leave the string empty, the first |
681 | key with a custom value is returned. | 681 | key with a custom value is returned. |
682 | */ | 682 | */ |
683 | Key key( int type, QString customTypeString = QString::null ) const; | 683 | Key key( int type, QString customTypeString = QString::null ) const; |
684 | 684 | ||
685 | /** | 685 | /** |
686 | Return list of all keys. | 686 | Return list of all keys. |
687 | */ | 687 | */ |
688 | Key::List keys() const; | 688 | Key::List keys() const; |
689 | 689 | ||
690 | /** | 690 | /** |
691 | Set the list of keys | 691 | Set the list of keys |
692 | @param keys The keys to be set. | 692 | @param keys The keys to be set. |
693 | */ | 693 | */ |
694 | void setKeys( const Key::List& keys); | 694 | void setKeys( const Key::List& keys); |
695 | 695 | ||
696 | /** | 696 | /** |
697 | Return list of keys with a special type. | 697 | Return list of keys with a special type. |
698 | If @p type == Key::Custom you can specify a string | 698 | If @p type == Key::Custom you can specify a string |
699 | that should match. If you leave the string empty, all custom | 699 | that should match. If you leave the string empty, all custom |
700 | keys will be returned. | 700 | keys will be returned. |
701 | */ | 701 | */ |
702 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 702 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
703 | 703 | ||
704 | /** | 704 | /** |
705 | Return key with the given id. | 705 | Return key with the given id. |
706 | */ | 706 | */ |
707 | Key findKey( const QString &id ) const; | 707 | Key findKey( const QString &id ) const; |
708 | 708 | ||
709 | /** | 709 | /** |
710 | Insert an address. If an address with the same id already exists | 710 | Insert an address. If an address with the same id already exists |
711 | in this addressee it is not duplicated. | 711 | in this addressee it is not duplicated. |
712 | */ | 712 | */ |
713 | void insertAddress( const Address &address ); | 713 | void insertAddress( const Address &address ); |
714 | 714 | ||
715 | /** | 715 | /** |
716 | Remove address. If no address with the given id exists for this | 716 | Remove address. If no address with the given id exists for this |
717 | addresse nothing happens. | 717 | addresse nothing happens. |
718 | */ | 718 | */ |
719 | void removeAddress( const Address &address ); | 719 | void removeAddress( const Address &address ); |
720 | 720 | ||
721 | /** | 721 | /** |
722 | Return address, which matches the given type. | 722 | Return address, which matches the given type. |
723 | */ | 723 | */ |
724 | Address address( int type ) const; | 724 | Address address( int type ) const; |
725 | 725 | ||
726 | /** | 726 | /** |
727 | Return list of all addresses. | 727 | Return list of all addresses. |
728 | */ | 728 | */ |
729 | Address::List addresses() const; | 729 | Address::List addresses() const; |
730 | 730 | ||
731 | /** | 731 | /** |
732 | Return list of addresses with a special type. | 732 | Return list of addresses with a special type. |
733 | */ | 733 | */ |
734 | Address::List addresses( int type ) const; | 734 | Address::List addresses( int type ) const; |
735 | 735 | ||
736 | /** | 736 | /** |
737 | Return address with the given id. | 737 | Return address with the given id. |
738 | */ | 738 | */ |
739 | Address findAddress( const QString &id ) const; | 739 | Address findAddress( const QString &id ) const; |
740 | 740 | ||
741 | /** | 741 | /** |
742 | Insert category. If the category already exists it is not duplicated. | 742 | Insert category. If the category already exists it is not duplicated. |
743 | */ | 743 | */ |
744 | void insertCategory( const QString & ); | 744 | void insertCategory( const QString & ); |
745 | 745 | ||
746 | /** | 746 | /** |
747 | Remove category. | 747 | Remove category. |
748 | */ | 748 | */ |
749 | void removeCategory( const QString & ); | 749 | void removeCategory( const QString & ); |
750 | 750 | ||
751 | /** | 751 | /** |
752 | Return, if addressee has the given category. | 752 | Return, if addressee has the given category. |
753 | */ | 753 | */ |
754 | bool hasCategory( const QString & ) const; | 754 | bool hasCategory( const QString & ) const; |
755 | 755 | ||
756 | /** | 756 | /** |
757 | Set categories to given value. | 757 | Set categories to given value. |
758 | */ | 758 | */ |
759 | void setCategories( const QStringList & ); | 759 | void setCategories( const QStringList & ); |
760 | 760 | ||
761 | /** | 761 | /** |
762 | Return list of all set categories. | 762 | Return list of all set categories. |
763 | */ | 763 | */ |
764 | QStringList categories() const; | 764 | QStringList categories() const; |
765 | 765 | ||
766 | /** | 766 | /** |
767 | Insert custom entry. The entry is identified by the name of the inserting | 767 | Insert custom entry. The entry is identified by the name of the inserting |
768 | application and a unique name. If an entry with the given app and name | 768 | application and a unique name. If an entry with the given app and name |
769 | already exists its value is replaced with the new given value. | 769 | already exists its value is replaced with the new given value. |
770 | */ | 770 | */ |
771 | void insertCustom( const QString &app, const QString &name, | 771 | void insertCustom( const QString &app, const QString &name, |
772 | const QString &value ); | 772 | const QString &value ); |
773 | 773 | ||
774 | /** | 774 | /** |
775 | Remove custom entry. | 775 | Remove custom entry. |
776 | */ | 776 | */ |
777 | void removeCustom( const QString &app, const QString &name ); | 777 | void removeCustom( const QString &app, const QString &name ); |
778 | 778 | ||
779 | /** | 779 | /** |
780 | Return value of custom entry, identified by app and entry name. | 780 | Return value of custom entry, identified by app and entry name. |
781 | */ | 781 | */ |
782 | QString custom( const QString &app, const QString &name ) const; | 782 | QString custom( const QString &app, const QString &name ) const; |
783 | 783 | ||
784 | /** | 784 | /** |
785 | Set all custom entries. | 785 | Set all custom entries. |
786 | */ | 786 | */ |
787 | void setCustoms( const QStringList & ); | 787 | void setCustoms( const QStringList & ); |
788 | 788 | ||
789 | /** | 789 | /** |
790 | Return list of all custom entries. | 790 | Return list of all custom entries. |
791 | */ | 791 | */ |
792 | QStringList customs() const; | 792 | QStringList customs() const; |
793 | 793 | ||
794 | /** | 794 | /** |
795 | Parse full email address. The result is given back in fullName and email. | 795 | Parse full email address. The result is given back in fullName and email. |
796 | */ | 796 | */ |
797 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 797 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
798 | QString &email ); | 798 | QString &email ); |
799 | 799 | ||
800 | /** | 800 | /** |
801 | Debug output. | 801 | Debug output. |
802 | */ | 802 | */ |
803 | void dump() const; | 803 | void dump() const; |
804 | 804 | ||
805 | /** | 805 | /** |
806 | Returns string representation of the addressee. | 806 | Returns string representation of the addressee. |
807 | */ | 807 | */ |
808 | QString asString() const; | 808 | QString asString() const; |
809 | 809 | ||
810 | /** | 810 | /** |
811 | Set resource where the addressee is from. | 811 | Set resource where the addressee is from. |
812 | */ | 812 | */ |
813 | void setResource( Resource *resource ); | 813 | void setResource( Resource *resource ); |
814 | 814 | ||
815 | /** | 815 | /** |
816 | Return pointer to resource. | 816 | Return pointer to resource. |
817 | */ | 817 | */ |
818 | Resource *resource() const; | 818 | Resource *resource() const; |
819 | 819 | ||
820 | /** | 820 | /** |
821 | Return resourcelabel. | 821 | Return resourcelabel. |
822 | */ | 822 | */ |
823 | //US | 823 | //US |
824 | static QString resourceLabel(); | 824 | static QString resourceLabel(); |
825 | 825 | ||
826 | /** | 826 | /** |
827 | Mark addressee as changed. | 827 | Mark addressee as changed. |
828 | */ | 828 | */ |
829 | void setChanged( bool value ); | 829 | void setChanged( bool value ); |
830 | 830 | ||
831 | /** | 831 | /** |
832 | Return whether the addressee is changed. | 832 | Return whether the addressee is changed. |
833 | */ | 833 | */ |
834 | bool changed() const; | 834 | bool changed() const; |
835 | |||
836 | void setTagged( bool value ); | ||
837 | bool tagged() const; | ||
835 | 838 | ||
836 | private: | 839 | private: |
837 | Addressee copy(); | 840 | Addressee copy(); |
838 | void detach(); | 841 | void detach(); |
839 | 842 | ||
840 | struct AddresseeData; | 843 | struct AddresseeData; |
841 | mutable KSharedPtr<AddresseeData> mData; | 844 | mutable KSharedPtr<AddresseeData> mData; |
842 | }; | 845 | }; |
843 | 846 | ||
844 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 847 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
845 | QDataStream &operator>>( QDataStream &, Addressee & ); | 848 | QDataStream &operator>>( QDataStream &, Addressee & ); |
846 | 849 | ||
847 | } | 850 | } |
848 | 851 | ||
849 | #endif | 852 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 7ec3fca..452f1bc 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2899 +1,2899 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /*s | 24 | /*s |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "kabcore.h" | 31 | #include "kabcore.h" |
32 | 32 | ||
33 | #include <stdaddressbook.h> | 33 | #include <stdaddressbook.h> |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kfiledialog.h> | 35 | #include <kfiledialog.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qlineedit.h> | 39 | #include <qlineedit.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qprogressbar.h> | 42 | #include <qprogressbar.h> |
43 | #include <libkdepim/phoneaccess.h> | 43 | #include <libkdepim/phoneaccess.h> |
44 | 44 | ||
45 | #ifndef KAB_EMBEDDED | 45 | #ifndef KAB_EMBEDDED |
46 | #include <qclipboard.h> | 46 | #include <qclipboard.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qfile.h> | 48 | #include <qfile.h> |
49 | #include <qapplicaton.h> | 49 | #include <qapplicaton.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qlayout.h> | 51 | #include <qlayout.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qvbox.h> | 53 | #include <qvbox.h> |
54 | #include <kabc/addresseelist.h> | 54 | #include <kabc/addresseelist.h> |
55 | #include <kabc/errorhandler.h> | 55 | #include <kabc/errorhandler.h> |
56 | #include <kabc/resource.h> | 56 | #include <kabc/resource.h> |
57 | #include <kabc/vcardconverter.h> | 57 | #include <kabc/vcardconverter.h> |
58 | #include <kapplication.h> | 58 | #include <kapplication.h> |
59 | #include <kactionclasses.h> | 59 | #include <kactionclasses.h> |
60 | #include <kcmultidialog.h> | 60 | #include <kcmultidialog.h> |
61 | #include <kdebug.h> | 61 | #include <kdebug.h> |
62 | #include <kdeversion.h> | 62 | #include <kdeversion.h> |
63 | #include <kkeydialog.h> | 63 | #include <kkeydialog.h> |
64 | #include <kmessagebox.h> | 64 | #include <kmessagebox.h> |
65 | #include <kprinter.h> | 65 | #include <kprinter.h> |
66 | #include <kprotocolinfo.h> | 66 | #include <kprotocolinfo.h> |
67 | #include <kresources/selectdialog.h> | 67 | #include <kresources/selectdialog.h> |
68 | #include <kstandarddirs.h> | 68 | #include <kstandarddirs.h> |
69 | #include <ktempfile.h> | 69 | #include <ktempfile.h> |
70 | #include <kxmlguiclient.h> | 70 | #include <kxmlguiclient.h> |
71 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> |
72 | #include <libkdepim/categoryselectdialog.h> | 72 | #include <libkdepim/categoryselectdialog.h> |
73 | 73 | ||
74 | #include "addresseeutil.h" | 74 | #include "addresseeutil.h" |
75 | #include "addresseeeditordialog.h" | 75 | #include "addresseeeditordialog.h" |
76 | #include "extensionmanager.h" | 76 | #include "extensionmanager.h" |
77 | #include "kstdaction.h" | 77 | #include "kstdaction.h" |
78 | #include "kaddressbookservice.h" | 78 | #include "kaddressbookservice.h" |
79 | #include "ldapsearchdialog.h" | 79 | #include "ldapsearchdialog.h" |
80 | #include "printing/printingwizard.h" | 80 | #include "printing/printingwizard.h" |
81 | #else // KAB_EMBEDDED | 81 | #else // KAB_EMBEDDED |
82 | 82 | ||
83 | #include <kapplication.h> | 83 | #include <kapplication.h> |
84 | #include "KDGanttMinimizeSplitter.h" | 84 | #include "KDGanttMinimizeSplitter.h" |
85 | #include "kaddressbookmain.h" | 85 | #include "kaddressbookmain.h" |
86 | #include "kactioncollection.h" | 86 | #include "kactioncollection.h" |
87 | #include "addresseedialog.h" | 87 | #include "addresseedialog.h" |
88 | //US | 88 | //US |
89 | #include <addresseeview.h> | 89 | #include <addresseeview.h> |
90 | 90 | ||
91 | #include <qapp.h> | 91 | #include <qapp.h> |
92 | #include <qmenubar.h> | 92 | #include <qmenubar.h> |
93 | //#include <qtoolbar.h> | 93 | //#include <qtoolbar.h> |
94 | #include <qmessagebox.h> | 94 | #include <qmessagebox.h> |
95 | #include <kdebug.h> | 95 | #include <kdebug.h> |
96 | #include <kiconloader.h> // needed for SmallIcon | 96 | #include <kiconloader.h> // needed for SmallIcon |
97 | #include <kresources/kcmkresources.h> | 97 | #include <kresources/kcmkresources.h> |
98 | #include <ktoolbar.h> | 98 | #include <ktoolbar.h> |
99 | 99 | ||
100 | 100 | ||
101 | //#include <qlabel.h> | 101 | //#include <qlabel.h> |
102 | 102 | ||
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | #include <qpe/ir.h> | 105 | #include <qpe/ir.h> |
106 | #include <qpe/qpemenubar.h> | 106 | #include <qpe/qpemenubar.h> |
107 | #include <qtopia/qcopenvelope_qws.h> | 107 | #include <qtopia/qcopenvelope_qws.h> |
108 | #else | 108 | #else |
109 | 109 | ||
110 | #include <qmenubar.h> | 110 | #include <qmenubar.h> |
111 | #endif | 111 | #endif |
112 | 112 | ||
113 | #endif // KAB_EMBEDDED | 113 | #endif // KAB_EMBEDDED |
114 | #include "kcmconfigs/kcmkabconfig.h" | 114 | #include "kcmconfigs/kcmkabconfig.h" |
115 | #include "kcmconfigs/kcmkdepimconfig.h" | 115 | #include "kcmconfigs/kcmkdepimconfig.h" |
116 | #include "kpimglobalprefs.h" | 116 | #include "kpimglobalprefs.h" |
117 | #include "externalapphandler.h" | 117 | #include "externalapphandler.h" |
118 | 118 | ||
119 | 119 | ||
120 | #include <kresources/selectdialog.h> | 120 | #include <kresources/selectdialog.h> |
121 | #include <kmessagebox.h> | 121 | #include <kmessagebox.h> |
122 | 122 | ||
123 | #include <picture.h> | 123 | #include <picture.h> |
124 | #include <resource.h> | 124 | #include <resource.h> |
125 | 125 | ||
126 | //US#include <qsplitter.h> | 126 | //US#include <qsplitter.h> |
127 | #include <qmap.h> | 127 | #include <qmap.h> |
128 | #include <qdir.h> | 128 | #include <qdir.h> |
129 | #include <qfile.h> | 129 | #include <qfile.h> |
130 | #include <qvbox.h> | 130 | #include <qvbox.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qclipboard.h> | 132 | #include <qclipboard.h> |
133 | #include <qtextstream.h> | 133 | #include <qtextstream.h> |
134 | 134 | ||
135 | #include <libkdepim/categoryselectdialog.h> | 135 | #include <libkdepim/categoryselectdialog.h> |
136 | #include <kabc/vcardconverter.h> | 136 | #include <kabc/vcardconverter.h> |
137 | 137 | ||
138 | 138 | ||
139 | #include "addresseeutil.h" | 139 | #include "addresseeutil.h" |
140 | #include "undocmds.h" | 140 | #include "undocmds.h" |
141 | #include "addresseeeditordialog.h" | 141 | #include "addresseeeditordialog.h" |
142 | #include "viewmanager.h" | 142 | #include "viewmanager.h" |
143 | #include "details/detailsviewcontainer.h" | 143 | #include "details/detailsviewcontainer.h" |
144 | #include "kabprefs.h" | 144 | #include "kabprefs.h" |
145 | #include "xxportmanager.h" | 145 | #include "xxportmanager.h" |
146 | #include "incsearchwidget.h" | 146 | #include "incsearchwidget.h" |
147 | #include "jumpbuttonbar.h" | 147 | #include "jumpbuttonbar.h" |
148 | #include "extensionmanager.h" | 148 | #include "extensionmanager.h" |
149 | #include "addresseeconfig.h" | 149 | #include "addresseeconfig.h" |
150 | #include <kcmultidialog.h> | 150 | #include <kcmultidialog.h> |
151 | 151 | ||
152 | #ifdef _WIN32_ | 152 | #ifdef _WIN32_ |
153 | 153 | ||
154 | #include "kaimportoldialog.h" | 154 | #include "kaimportoldialog.h" |
155 | #else | 155 | #else |
156 | #include <unistd.h> | 156 | #include <unistd.h> |
157 | #endif | 157 | #endif |
158 | // sync includes | 158 | // sync includes |
159 | #include <libkdepim/ksyncprofile.h> | 159 | #include <libkdepim/ksyncprofile.h> |
160 | #include <libkdepim/ksyncprefsdialog.h> | 160 | #include <libkdepim/ksyncprefsdialog.h> |
161 | 161 | ||
162 | class KAex2phonePrefs : public QDialog | 162 | class KAex2phonePrefs : public QDialog |
163 | { | 163 | { |
164 | public: | 164 | public: |
165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 165 | KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
166 | QDialog( parent, name, true ) | 166 | QDialog( parent, name, true ) |
167 | { | 167 | { |
168 | setCaption( i18n("Export to phone options") ); | 168 | setCaption( i18n("Export to phone options") ); |
169 | QVBoxLayout* lay = new QVBoxLayout( this ); | 169 | QVBoxLayout* lay = new QVBoxLayout( this ); |
170 | lay->setSpacing( 3 ); | 170 | lay->setSpacing( 3 ); |
171 | lay->setMargin( 3 ); | 171 | lay->setMargin( 3 ); |
172 | QLabel *lab; | 172 | QLabel *lab; |
173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 173 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
174 | lab->setAlignment (AlignHCenter ); | 174 | lab->setAlignment (AlignHCenter ); |
175 | QHBox* temphb; | 175 | QHBox* temphb; |
176 | temphb = new QHBox( this ); | 176 | temphb = new QHBox( this ); |
177 | new QLabel( i18n("I/O device: "), temphb ); | 177 | new QLabel( i18n("I/O device: "), temphb ); |
178 | mPhoneDevice = new QLineEdit( temphb); | 178 | mPhoneDevice = new QLineEdit( temphb); |
179 | lay->addWidget( temphb ); | 179 | lay->addWidget( temphb ); |
180 | temphb = new QHBox( this ); | 180 | temphb = new QHBox( this ); |
181 | new QLabel( i18n("Connection: "), temphb ); | 181 | new QLabel( i18n("Connection: "), temphb ); |
182 | mPhoneConnection = new QLineEdit( temphb); | 182 | mPhoneConnection = new QLineEdit( temphb); |
183 | lay->addWidget( temphb ); | 183 | lay->addWidget( temphb ); |
184 | temphb = new QHBox( this ); | 184 | temphb = new QHBox( this ); |
185 | new QLabel( i18n("Model(opt.): "), temphb ); | 185 | new QLabel( i18n("Model(opt.): "), temphb ); |
186 | mPhoneModel = new QLineEdit( temphb); | 186 | mPhoneModel = new QLineEdit( temphb); |
187 | lay->addWidget( temphb ); | 187 | lay->addWidget( temphb ); |
188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); | 188 | mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); |
189 | lay->addWidget( mWriteToSim ); | 189 | lay->addWidget( mWriteToSim ); |
190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); | 190 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); |
191 | lab->setAlignment (AlignHCenter ); | 191 | lab->setAlignment (AlignHCenter ); |
192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 192 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
193 | lay->addWidget( ok ); | 193 | lay->addWidget( ok ); |
194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 194 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
195 | lay->addWidget( cancel ); | 195 | lay->addWidget( cancel ); |
196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 196 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 197 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
198 | resize( 220, 240 ); | 198 | resize( 220, 240 ); |
199 | 199 | ||
200 | } | 200 | } |
201 | 201 | ||
202 | public: | 202 | public: |
203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 203 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
204 | QCheckBox* mWriteToSim; | 204 | QCheckBox* mWriteToSim; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | bool pasteWithNewUid = true; | 207 | bool pasteWithNewUid = true; |
208 | 208 | ||
209 | #ifdef KAB_EMBEDDED | 209 | #ifdef KAB_EMBEDDED |
210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 210 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 211 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 212 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 213 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
214 | #else //KAB_EMBEDDED | 214 | #else //KAB_EMBEDDED |
215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 215 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), | 216 | : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), |
217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 217 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
218 | mReadWrite( readWrite ), mModified( false ) | 218 | mReadWrite( readWrite ), mModified( false ) |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | { | 220 | { |
221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 221 | // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
222 | // syncManager->setBlockSave(false); | 222 | // syncManager->setBlockSave(false); |
223 | mExtensionBarSplitter = 0; | 223 | mExtensionBarSplitter = 0; |
224 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 224 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | 323 | ||
324 | delete syncManager; | 324 | delete syncManager; |
325 | 325 | ||
326 | } | 326 | } |
327 | 327 | ||
328 | void KABCore::recieve( QString fn ) | 328 | void KABCore::recieve( QString fn ) |
329 | { | 329 | { |
330 | //qDebug("KABCore::recieve "); | 330 | //qDebug("KABCore::recieve "); |
331 | mAddressBook->importFromFile( fn, true ); | 331 | mAddressBook->importFromFile( fn, true ); |
332 | mViewManager->refreshView(); | 332 | mViewManager->refreshView(); |
333 | topLevelWidget()->raise(); | 333 | topLevelWidget()->raise(); |
334 | } | 334 | } |
335 | void KABCore::restoreSettings() | 335 | void KABCore::restoreSettings() |
336 | { | 336 | { |
337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 337 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
338 | 338 | ||
339 | bool state; | 339 | bool state; |
340 | 340 | ||
341 | if (mMultipleViewsAtOnce) | 341 | if (mMultipleViewsAtOnce) |
342 | state = KABPrefs::instance()->mDetailsPageVisible; | 342 | state = KABPrefs::instance()->mDetailsPageVisible; |
343 | else | 343 | else |
344 | state = false; | 344 | state = false; |
345 | 345 | ||
346 | mActionDetails->setChecked( state ); | 346 | mActionDetails->setChecked( state ); |
347 | setDetailsVisible( state ); | 347 | setDetailsVisible( state ); |
348 | 348 | ||
349 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 349 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
350 | 350 | ||
351 | mActionJumpBar->setChecked( state ); | 351 | mActionJumpBar->setChecked( state ); |
352 | setJumpButtonBarVisible( state ); | 352 | setJumpButtonBarVisible( state ); |
353 | /*US | 353 | /*US |
354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 354 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
355 | if ( splitterSize.count() == 0 ) { | 355 | if ( splitterSize.count() == 0 ) { |
356 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
357 | splitterSize.append( width() / 2 ); | 357 | splitterSize.append( width() / 2 ); |
358 | } | 358 | } |
359 | mMiniSplitter->setSizes( splitterSize ); | 359 | mMiniSplitter->setSizes( splitterSize ); |
360 | if ( mExtensionBarSplitter ) { | 360 | if ( mExtensionBarSplitter ) { |
361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 361 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
362 | if ( splitterSize.count() == 0 ) { | 362 | if ( splitterSize.count() == 0 ) { |
363 | splitterSize.append( width() / 2 ); | 363 | splitterSize.append( width() / 2 ); |
364 | splitterSize.append( width() / 2 ); | 364 | splitterSize.append( width() / 2 ); |
365 | } | 365 | } |
366 | mExtensionBarSplitter->setSizes( splitterSize ); | 366 | mExtensionBarSplitter->setSizes( splitterSize ); |
367 | 367 | ||
368 | } | 368 | } |
369 | */ | 369 | */ |
370 | mViewManager->restoreSettings(); | 370 | mViewManager->restoreSettings(); |
371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 371 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
372 | mExtensionManager->restoreSettings(); | 372 | mExtensionManager->restoreSettings(); |
373 | #ifdef DESKTOP_VERSION | 373 | #ifdef DESKTOP_VERSION |
374 | int wid = width(); | 374 | int wid = width(); |
375 | if ( wid < 10 ) | 375 | if ( wid < 10 ) |
376 | wid = 400; | 376 | wid = 400; |
377 | #else | 377 | #else |
378 | int wid = QApplication::desktop()->width(); | 378 | int wid = QApplication::desktop()->width(); |
379 | if ( wid < 640 ) | 379 | if ( wid < 640 ) |
380 | wid = QApplication::desktop()->height(); | 380 | wid = QApplication::desktop()->height(); |
381 | #endif | 381 | #endif |
382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 382 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
383 | if ( true /*splitterSize.count() == 0*/ ) { | 383 | if ( true /*splitterSize.count() == 0*/ ) { |
384 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
385 | splitterSize.append( wid / 2 ); | 385 | splitterSize.append( wid / 2 ); |
386 | } | 386 | } |
387 | mMiniSplitter->setSizes( splitterSize ); | 387 | mMiniSplitter->setSizes( splitterSize ); |
388 | if ( mExtensionBarSplitter ) { | 388 | if ( mExtensionBarSplitter ) { |
389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 389 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
390 | if ( true /*splitterSize.count() == 0*/ ) { | 390 | if ( true /*splitterSize.count() == 0*/ ) { |
391 | splitterSize.append( wid / 2 ); | 391 | splitterSize.append( wid / 2 ); |
392 | splitterSize.append( wid / 2 ); | 392 | splitterSize.append( wid / 2 ); |
393 | } | 393 | } |
394 | mExtensionBarSplitter->setSizes( splitterSize ); | 394 | mExtensionBarSplitter->setSizes( splitterSize ); |
395 | 395 | ||
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | void KABCore::saveSettings() | 401 | void KABCore::saveSettings() |
402 | { | 402 | { |
403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 403 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
404 | if ( mExtensionBarSplitter ) | 404 | if ( mExtensionBarSplitter ) |
405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 405 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 406 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 407 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
408 | #ifndef KAB_EMBEDDED | 408 | #ifndef KAB_EMBEDDED |
409 | 409 | ||
410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 411 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
412 | #endif //KAB_EMBEDDED | 412 | #endif //KAB_EMBEDDED |
413 | mExtensionManager->saveSettings(); | 413 | mExtensionManager->saveSettings(); |
414 | mViewManager->saveSettings(); | 414 | mViewManager->saveSettings(); |
415 | 415 | ||
416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 416 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
417 | } | 417 | } |
418 | 418 | ||
419 | KABC::AddressBook *KABCore::addressBook() const | 419 | KABC::AddressBook *KABCore::addressBook() const |
420 | { | 420 | { |
421 | return mAddressBook; | 421 | return mAddressBook; |
422 | } | 422 | } |
423 | 423 | ||
424 | KConfig *KABCore::config() | 424 | KConfig *KABCore::config() |
425 | { | 425 | { |
426 | #ifndef KAB_EMBEDDED | 426 | #ifndef KAB_EMBEDDED |
427 | return KABPrefs::instance()->config(); | 427 | return KABPrefs::instance()->config(); |
428 | #else //KAB_EMBEDDED | 428 | #else //KAB_EMBEDDED |
429 | return KABPrefs::instance()->getConfig(); | 429 | return KABPrefs::instance()->getConfig(); |
430 | #endif //KAB_EMBEDDED | 430 | #endif //KAB_EMBEDDED |
431 | } | 431 | } |
432 | 432 | ||
433 | KActionCollection *KABCore::actionCollection() const | 433 | KActionCollection *KABCore::actionCollection() const |
434 | { | 434 | { |
435 | return mGUIClient->actionCollection(); | 435 | return mGUIClient->actionCollection(); |
436 | } | 436 | } |
437 | 437 | ||
438 | KABC::Field *KABCore::currentSearchField() const | 438 | KABC::Field *KABCore::currentSearchField() const |
439 | { | 439 | { |
440 | if (mIncSearchWidget) | 440 | if (mIncSearchWidget) |
441 | return mIncSearchWidget->currentField(); | 441 | return mIncSearchWidget->currentField(); |
442 | else | 442 | else |
443 | return 0; | 443 | return 0; |
444 | } | 444 | } |
445 | 445 | ||
446 | QStringList KABCore::selectedUIDs() const | 446 | QStringList KABCore::selectedUIDs() const |
447 | { | 447 | { |
448 | return mViewManager->selectedUids(); | 448 | return mViewManager->selectedUids(); |
449 | } | 449 | } |
450 | 450 | ||
451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 451 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
452 | { | 452 | { |
453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 453 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
454 | 454 | ||
455 | QPtrList<KRES::Resource> kresResources; | 455 | QPtrList<KRES::Resource> kresResources; |
456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 456 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
457 | KABC::Resource *resource; | 457 | KABC::Resource *resource; |
458 | while ( ( resource = resIt.current() ) != 0 ) { | 458 | while ( ( resource = resIt.current() ) != 0 ) { |
459 | ++resIt; | 459 | ++resIt; |
460 | if ( !resource->readOnly() ) { | 460 | if ( !resource->readOnly() ) { |
461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 461 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
462 | if ( res ) | 462 | if ( res ) |
463 | kresResources.append( res ); | 463 | kresResources.append( res ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 467 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
468 | return static_cast<KABC::Resource*>( res ); | 468 | return static_cast<KABC::Resource*>( res ); |
469 | } | 469 | } |
470 | 470 | ||
471 | #ifndef KAB_EMBEDDED | 471 | #ifndef KAB_EMBEDDED |
472 | KAboutData *KABCore::createAboutData() | 472 | KAboutData *KABCore::createAboutData() |
473 | #else //KAB_EMBEDDED | 473 | #else //KAB_EMBEDDED |
474 | void KABCore::createAboutData() | 474 | void KABCore::createAboutData() |
475 | #endif //KAB_EMBEDDED | 475 | #endif //KAB_EMBEDDED |
476 | { | 476 | { |
477 | #ifndef KAB_EMBEDDED | 477 | #ifndef KAB_EMBEDDED |
478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 478 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
479 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 479 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
480 | KAboutData::License_GPL_V2, | 480 | KAboutData::License_GPL_V2, |
481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 481 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 482 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 483 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
484 | about->addAuthor( "Cornelius Schumacher", | 484 | about->addAuthor( "Cornelius Schumacher", |
485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 485 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
486 | "schumacher@kde.org" ); | 486 | "schumacher@kde.org" ); |
487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 487 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
488 | "mpilone@slac.com" ); | 488 | "mpilone@slac.com" ); |
489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 489 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 490 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 491 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
492 | "michel@klaralvdalens-datakonsult.se" ); | 492 | "michel@klaralvdalens-datakonsult.se" ); |
493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 493 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
494 | "hansen@kde.org" ); | 494 | "hansen@kde.org" ); |
495 | 495 | ||
496 | return about; | 496 | return about; |
497 | #endif //KAB_EMBEDDED | 497 | #endif //KAB_EMBEDDED |
498 | 498 | ||
499 | QString version; | 499 | QString version; |
500 | #include <../version> | 500 | #include <../version> |
501 | QMessageBox::about( this, "About KAddressbook/Pi", | 501 | QMessageBox::about( this, "About KAddressbook/Pi", |
502 | "KAddressbook/Platform-independent\n" | 502 | "KAddressbook/Platform-independent\n" |
503 | "(KA/Pi) " +version + " - " + | 503 | "(KA/Pi) " +version + " - " + |
504 | #ifdef DESKTOP_VERSION | 504 | #ifdef DESKTOP_VERSION |
505 | "Desktop Edition\n" | 505 | "Desktop Edition\n" |
506 | #else | 506 | #else |
507 | "PDA-Edition\n" | 507 | "PDA-Edition\n" |
508 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 508 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
509 | #endif | 509 | #endif |
510 | 510 | ||
511 | "(c) 2004 Ulf Schenk\n" | 511 | "(c) 2004 Ulf Schenk\n" |
512 | "(c) 2004 Lutz Rogowski\n" | 512 | "(c) 2004 Lutz Rogowski\n" |
513 | "(c) 1997-2003, The KDE PIM Team\n" | 513 | "(c) 1997-2003, The KDE PIM Team\n" |
514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 514 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
515 | "Don Sanders Original author\n" | 515 | "Don Sanders Original author\n" |
516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 516 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 517 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
518 | "Greg Stern DCOP interface\n" | 518 | "Greg Stern DCOP interface\n" |
519 | "Mark Westcot Contact pinning\n" | 519 | "Mark Westcot Contact pinning\n" |
520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 520 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 521 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
522 | #ifdef _WIN32_ | 522 | #ifdef _WIN32_ |
523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 523 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
524 | #endif | 524 | #endif |
525 | ); | 525 | ); |
526 | } | 526 | } |
527 | 527 | ||
528 | void KABCore::setContactSelected( const QString &uid ) | 528 | void KABCore::setContactSelected( const QString &uid ) |
529 | { | 529 | { |
530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 530 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
531 | if ( !mDetails->isHidden() ) | 531 | if ( !mDetails->isHidden() ) |
532 | mDetails->setAddressee( addr ); | 532 | mDetails->setAddressee( addr ); |
533 | 533 | ||
534 | if ( !addr.isEmpty() ) { | 534 | if ( !addr.isEmpty() ) { |
535 | emit contactSelected( addr.formattedName() ); | 535 | emit contactSelected( addr.formattedName() ); |
536 | KABC::Picture pic = addr.photo(); | 536 | KABC::Picture pic = addr.photo(); |
537 | if ( pic.isIntern() ) { | 537 | if ( pic.isIntern() ) { |
538 | //US emit contactSelected( pic.data() ); | 538 | //US emit contactSelected( pic.data() ); |
539 | //US instead use: | 539 | //US instead use: |
540 | QPixmap px; | 540 | QPixmap px; |
541 | if (pic.data().isNull() != true) | 541 | if (pic.data().isNull() != true) |
542 | { | 542 | { |
543 | px.convertFromImage(pic.data()); | 543 | px.convertFromImage(pic.data()); |
544 | } | 544 | } |
545 | 545 | ||
546 | emit contactSelected( px ); | 546 | emit contactSelected( px ); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
550 | 550 | ||
551 | mExtensionManager->setSelectionChanged(); | 551 | mExtensionManager->setSelectionChanged(); |
552 | 552 | ||
553 | // update the actions | 553 | // update the actions |
554 | bool selected = !uid.isEmpty(); | 554 | bool selected = !uid.isEmpty(); |
555 | 555 | ||
556 | if ( mReadWrite ) { | 556 | if ( mReadWrite ) { |
557 | mActionCut->setEnabled( selected ); | 557 | mActionCut->setEnabled( selected ); |
558 | mActionPaste->setEnabled( selected ); | 558 | mActionPaste->setEnabled( selected ); |
559 | } | 559 | } |
560 | 560 | ||
561 | mActionCopy->setEnabled( selected ); | 561 | mActionCopy->setEnabled( selected ); |
562 | mActionDelete->setEnabled( selected ); | 562 | mActionDelete->setEnabled( selected ); |
563 | mActionEditAddressee->setEnabled( selected ); | 563 | mActionEditAddressee->setEnabled( selected ); |
564 | mActionMail->setEnabled( selected ); | 564 | mActionMail->setEnabled( selected ); |
565 | mActionMailVCard->setEnabled( selected ); | 565 | mActionMailVCard->setEnabled( selected ); |
566 | //if (mActionBeam) | 566 | //if (mActionBeam) |
567 | //mActionBeam->setEnabled( selected ); | 567 | //mActionBeam->setEnabled( selected ); |
568 | 568 | ||
569 | if (mActionBeamVCard) | 569 | if (mActionBeamVCard) |
570 | mActionBeamVCard->setEnabled( selected ); | 570 | mActionBeamVCard->setEnabled( selected ); |
571 | 571 | ||
572 | mActionExport2phone->setEnabled( selected ); | 572 | mActionExport2phone->setEnabled( selected ); |
573 | mActionWhoAmI->setEnabled( selected ); | 573 | mActionWhoAmI->setEnabled( selected ); |
574 | mActionCategories->setEnabled( selected ); | 574 | mActionCategories->setEnabled( selected ); |
575 | } | 575 | } |
576 | 576 | ||
577 | void KABCore::sendMail() | 577 | void KABCore::sendMail() |
578 | { | 578 | { |
579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 579 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
580 | } | 580 | } |
581 | 581 | ||
582 | void KABCore::sendMail( const QString& emaillist ) | 582 | void KABCore::sendMail( const QString& emaillist ) |
583 | { | 583 | { |
584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 584 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
585 | if (emaillist.contains(",") > 0) | 585 | if (emaillist.contains(",") > 0) |
586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 586 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
587 | else | 587 | else |
588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 588 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | 592 | ||
593 | void KABCore::mailVCard() | 593 | void KABCore::mailVCard() |
594 | { | 594 | { |
595 | QStringList uids = mViewManager->selectedUids(); | 595 | QStringList uids = mViewManager->selectedUids(); |
596 | if ( !uids.isEmpty() ) | 596 | if ( !uids.isEmpty() ) |
597 | mailVCard( uids ); | 597 | mailVCard( uids ); |
598 | } | 598 | } |
599 | 599 | ||
600 | void KABCore::mailVCard( const QStringList& uids ) | 600 | void KABCore::mailVCard( const QStringList& uids ) |
601 | { | 601 | { |
602 | QStringList urls; | 602 | QStringList urls; |
603 | 603 | ||
604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 604 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
605 | 605 | ||
606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 606 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | QDir().mkdir( dirName, true ); | 610 | QDir().mkdir( dirName, true ); |
611 | 611 | ||
612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 612 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
613 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 613 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
614 | 614 | ||
615 | if ( a.isEmpty() ) | 615 | if ( a.isEmpty() ) |
616 | continue; | 616 | continue; |
617 | 617 | ||
618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 618 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
619 | 619 | ||
620 | QString fileName = dirName + "/" + name; | 620 | QString fileName = dirName + "/" + name; |
621 | 621 | ||
622 | QFile outFile(fileName); | 622 | QFile outFile(fileName); |
623 | 623 | ||
624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 624 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
625 | KABC::VCardConverter converter; | 625 | KABC::VCardConverter converter; |
626 | QString vcard; | 626 | QString vcard; |
627 | 627 | ||
628 | converter.addresseeToVCard( a, vcard ); | 628 | converter.addresseeToVCard( a, vcard ); |
629 | 629 | ||
630 | QTextStream t( &outFile ); // use a text stream | 630 | QTextStream t( &outFile ); // use a text stream |
631 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 631 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
632 | t << vcard; | 632 | t << vcard; |
633 | 633 | ||
634 | outFile.close(); | 634 | outFile.close(); |
635 | 635 | ||
636 | urls.append( fileName ); | 636 | urls.append( fileName ); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||
640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 640 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
641 | 641 | ||
642 | 642 | ||
643 | /*US | 643 | /*US |
644 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 644 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
645 | QString::null, // subject | 645 | QString::null, // subject |
646 | QString::null, // body | 646 | QString::null, // body |
647 | QString::null, | 647 | QString::null, |
648 | urls ); // attachments | 648 | urls ); // attachments |
649 | */ | 649 | */ |
650 | 650 | ||
651 | } | 651 | } |
652 | 652 | ||
653 | /** | 653 | /** |
654 | Beams the "WhoAmI contact. | 654 | Beams the "WhoAmI contact. |
655 | */ | 655 | */ |
656 | void KABCore::beamMySelf() | 656 | void KABCore::beamMySelf() |
657 | { | 657 | { |
658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 658 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
659 | if (!a.isEmpty()) | 659 | if (!a.isEmpty()) |
660 | { | 660 | { |
661 | QStringList uids; | 661 | QStringList uids; |
662 | uids << a.uid(); | 662 | uids << a.uid(); |
663 | 663 | ||
664 | beamVCard(uids); | 664 | beamVCard(uids); |
665 | } else { | 665 | } else { |
666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 666 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
667 | 667 | ||
668 | 668 | ||
669 | } | 669 | } |
670 | } | 670 | } |
671 | 671 | ||
672 | void KABCore::export2phone() | 672 | void KABCore::export2phone() |
673 | { | 673 | { |
674 | 674 | ||
675 | KAex2phonePrefs ex2phone; | 675 | KAex2phonePrefs ex2phone; |
676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 676 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 677 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 678 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
679 | 679 | ||
680 | if ( !ex2phone.exec() ) { | 680 | if ( !ex2phone.exec() ) { |
681 | return; | 681 | return; |
682 | } | 682 | } |
683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 683 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 684 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 685 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
686 | 686 | ||
687 | 687 | ||
688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 688 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 689 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 690 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
691 | 691 | ||
692 | QStringList uids = mViewManager->selectedUids(); | 692 | QStringList uids = mViewManager->selectedUids(); |
693 | if ( uids.isEmpty() ) | 693 | if ( uids.isEmpty() ) |
694 | return; | 694 | return; |
695 | 695 | ||
696 | #ifdef _WIN32_ | 696 | #ifdef _WIN32_ |
697 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 697 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
698 | #else | 698 | #else |
699 | QString fileName = "/tmp/kdepimtemp.vcf"; | 699 | QString fileName = "/tmp/kdepimtemp.vcf"; |
700 | #endif | 700 | #endif |
701 | 701 | ||
702 | KABC::VCardConverter converter; | 702 | KABC::VCardConverter converter; |
703 | QString description; | 703 | QString description; |
704 | QString datastream; | 704 | QString datastream; |
705 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 705 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
706 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 706 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
707 | 707 | ||
708 | if ( a.isEmpty() ) | 708 | if ( a.isEmpty() ) |
709 | continue; | 709 | continue; |
710 | a.simplifyEmails(); | 710 | a.simplifyEmails(); |
711 | a.simplifyPhoneNumbers(); | 711 | a.simplifyPhoneNumbers(); |
712 | a.simplifyPhoneNumberTypes(); | 712 | a.simplifyPhoneNumberTypes(); |
713 | a.simplifyAddresses(); | 713 | a.simplifyAddresses(); |
714 | 714 | ||
715 | if (description.isEmpty()) | 715 | if (description.isEmpty()) |
716 | description = a.formattedName(); | 716 | description = a.formattedName(); |
717 | QString vcard; | 717 | QString vcard; |
718 | QString vcardnew; | 718 | QString vcardnew; |
719 | converter.addresseeToVCard( a, vcard ); | 719 | converter.addresseeToVCard( a, vcard ); |
720 | int start = 0; | 720 | int start = 0; |
721 | int next; | 721 | int next; |
722 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 722 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
723 | int semi = vcard.find(";", next); | 723 | int semi = vcard.find(";", next); |
724 | int dopp = vcard.find(":", next); | 724 | int dopp = vcard.find(":", next); |
725 | int sep; | 725 | int sep; |
726 | if ( semi < dopp && semi >= 0 ) | 726 | if ( semi < dopp && semi >= 0 ) |
727 | sep = semi ; | 727 | sep = semi ; |
728 | else | 728 | else |
729 | sep = dopp; | 729 | sep = dopp; |
730 | vcardnew +=vcard.mid( start, next - start); | 730 | vcardnew +=vcard.mid( start, next - start); |
731 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 731 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
732 | start = sep; | 732 | start = sep; |
733 | } | 733 | } |
734 | vcardnew += vcard.mid( start,vcard.length() ); | 734 | vcardnew += vcard.mid( start,vcard.length() ); |
735 | vcard = ""; | 735 | vcard = ""; |
736 | start = 0; | 736 | start = 0; |
737 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 737 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
738 | int sep = vcardnew.find(":", next); | 738 | int sep = vcardnew.find(":", next); |
739 | vcard +=vcardnew.mid( start, next - start+3); | 739 | vcard +=vcardnew.mid( start, next - start+3); |
740 | start = sep; | 740 | start = sep; |
741 | } | 741 | } |
742 | vcard += vcardnew.mid( start,vcardnew.length() ); | 742 | vcard += vcardnew.mid( start,vcardnew.length() ); |
743 | vcard.replace ( QRegExp(";;;") , "" ); | 743 | vcard.replace ( QRegExp(";;;") , "" ); |
744 | vcard.replace ( QRegExp(";;") , "" ); | 744 | vcard.replace ( QRegExp(";;") , "" ); |
745 | datastream += vcard; | 745 | datastream += vcard; |
746 | 746 | ||
747 | } | 747 | } |
748 | QFile outFile(fileName); | 748 | QFile outFile(fileName); |
749 | if ( outFile.open(IO_WriteOnly) ) { | 749 | if ( outFile.open(IO_WriteOnly) ) { |
750 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 750 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
751 | QTextStream t( &outFile ); // use a text stream | 751 | QTextStream t( &outFile ); // use a text stream |
752 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 752 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
753 | t <<datastream; | 753 | t <<datastream; |
754 | outFile.close(); | 754 | outFile.close(); |
755 | if ( PhoneAccess::writeToPhone( fileName ) ) | 755 | if ( PhoneAccess::writeToPhone( fileName ) ) |
756 | qDebug("Export okay "); | 756 | qDebug("Export okay "); |
757 | else | 757 | else |
758 | qDebug("Error export contacts "); | 758 | qDebug("Error export contacts "); |
759 | 759 | ||
760 | } else { | 760 | } else { |
761 | qDebug("Error open temp file "); | 761 | qDebug("Error open temp file "); |
762 | return; | 762 | return; |
763 | } | 763 | } |
764 | 764 | ||
765 | 765 | ||
766 | #if 0 | 766 | #if 0 |
767 | 767 | ||
768 | setCaption( i18n("Writing to phone...")); | 768 | setCaption( i18n("Writing to phone...")); |
769 | if ( PhoneFormat::writeToPhone( cal ) ) | 769 | if ( PhoneFormat::writeToPhone( cal ) ) |
770 | setCaption( i18n("Export to phone successful!")); | 770 | setCaption( i18n("Export to phone successful!")); |
771 | else | 771 | else |
772 | setCaption( i18n("Error exporting to phone!")); | 772 | setCaption( i18n("Error exporting to phone!")); |
773 | #endif | 773 | #endif |
774 | 774 | ||
775 | 775 | ||
776 | } | 776 | } |
777 | void KABCore::beamVCard() | 777 | void KABCore::beamVCard() |
778 | { | 778 | { |
779 | QStringList uids = mViewManager->selectedUids(); | 779 | QStringList uids = mViewManager->selectedUids(); |
780 | if ( !uids.isEmpty() ) | 780 | if ( !uids.isEmpty() ) |
781 | beamVCard( uids ); | 781 | beamVCard( uids ); |
782 | } | 782 | } |
783 | 783 | ||
784 | 784 | ||
785 | void KABCore::beamVCard(const QStringList& uids) | 785 | void KABCore::beamVCard(const QStringList& uids) |
786 | { | 786 | { |
787 | /*US | 787 | /*US |
788 | QString beamFilename; | 788 | QString beamFilename; |
789 | Opie::OPimContact c; | 789 | Opie::OPimContact c; |
790 | if ( actionPersonal->isOn() ) { | 790 | if ( actionPersonal->isOn() ) { |
791 | beamFilename = addressbookPersonalVCardName(); | 791 | beamFilename = addressbookPersonalVCardName(); |
792 | if ( !QFile::exists( beamFilename ) ) | 792 | if ( !QFile::exists( beamFilename ) ) |
793 | return; // can't beam a non-existent file | 793 | return; // can't beam a non-existent file |
794 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 794 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
795 | beamFilename ); | 795 | beamFilename ); |
796 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 796 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
797 | Opie::OPimContactAccess::List allList = access->allRecords(); | 797 | Opie::OPimContactAccess::List allList = access->allRecords(); |
798 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 798 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
799 | c = *it; | 799 | c = *it; |
800 | 800 | ||
801 | delete access; | 801 | delete access; |
802 | } else { | 802 | } else { |
803 | unlink( beamfile ); // delete if exists | 803 | unlink( beamfile ); // delete if exists |
804 | mkdir("/tmp/obex/", 0755); | 804 | mkdir("/tmp/obex/", 0755); |
805 | c = m_abView -> currentEntry(); | 805 | c = m_abView -> currentEntry(); |
806 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 806 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
807 | beamfile ); | 807 | beamfile ); |
808 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 808 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
809 | access->add( c ); | 809 | access->add( c ); |
810 | access->save(); | 810 | access->save(); |
811 | delete access; | 811 | delete access; |
812 | 812 | ||
813 | beamFilename = beamfile; | 813 | beamFilename = beamfile; |
814 | } | 814 | } |
815 | 815 | ||
816 | owarn << "Beaming: " << beamFilename << oendl; | 816 | owarn << "Beaming: " << beamFilename << oendl; |
817 | */ | 817 | */ |
818 | 818 | ||
819 | #if 0 | 819 | #if 0 |
820 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 820 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
821 | 821 | ||
822 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 822 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
823 | 823 | ||
824 | QString name = "contact.vcf"; | 824 | QString name = "contact.vcf"; |
825 | 825 | ||
826 | QString fileName = dirName + "/" + name; | 826 | QString fileName = dirName + "/" + name; |
827 | #endif | 827 | #endif |
828 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 828 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
829 | // | 829 | // |
830 | QString fileName = "/tmp/kapibeamfile.vcf"; | 830 | QString fileName = "/tmp/kapibeamfile.vcf"; |
831 | 831 | ||
832 | 832 | ||
833 | //QDir().mkdir( dirName, true ); | 833 | //QDir().mkdir( dirName, true ); |
834 | 834 | ||
835 | 835 | ||
836 | KABC::VCardConverter converter; | 836 | KABC::VCardConverter converter; |
837 | QString description; | 837 | QString description; |
838 | QString datastream; | 838 | QString datastream; |
839 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 839 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
840 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 840 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
841 | 841 | ||
842 | if ( a.isEmpty() ) | 842 | if ( a.isEmpty() ) |
843 | continue; | 843 | continue; |
844 | 844 | ||
845 | if (description.isEmpty()) | 845 | if (description.isEmpty()) |
846 | description = a.formattedName(); | 846 | description = a.formattedName(); |
847 | 847 | ||
848 | QString vcard; | 848 | QString vcard; |
849 | converter.addresseeToVCard( a, vcard ); | 849 | converter.addresseeToVCard( a, vcard ); |
850 | int start = 0; | 850 | int start = 0; |
851 | int next; | 851 | int next; |
852 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 852 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
853 | int semi = vcard.find(";", next); | 853 | int semi = vcard.find(";", next); |
854 | int dopp = vcard.find(":", next); | 854 | int dopp = vcard.find(":", next); |
855 | int sep; | 855 | int sep; |
856 | if ( semi < dopp && semi >= 0 ) | 856 | if ( semi < dopp && semi >= 0 ) |
857 | sep = semi ; | 857 | sep = semi ; |
858 | else | 858 | else |
859 | sep = dopp; | 859 | sep = dopp; |
860 | datastream +=vcard.mid( start, next - start); | 860 | datastream +=vcard.mid( start, next - start); |
861 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 861 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
862 | start = sep; | 862 | start = sep; |
863 | } | 863 | } |
864 | datastream += vcard.mid( start,vcard.length() ); | 864 | datastream += vcard.mid( start,vcard.length() ); |
865 | } | 865 | } |
866 | #ifndef DESKTOP_VERSION | 866 | #ifndef DESKTOP_VERSION |
867 | QFile outFile(fileName); | 867 | QFile outFile(fileName); |
868 | if ( outFile.open(IO_WriteOnly) ) { | 868 | if ( outFile.open(IO_WriteOnly) ) { |
869 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 869 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
870 | QTextStream t( &outFile ); // use a text stream | 870 | QTextStream t( &outFile ); // use a text stream |
871 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 871 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
872 | t <<datastream; | 872 | t <<datastream; |
873 | outFile.close(); | 873 | outFile.close(); |
874 | Ir *ir = new Ir( this ); | 874 | Ir *ir = new Ir( this ); |
875 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 875 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
876 | ir->send( fileName, description, "text/x-vCard" ); | 876 | ir->send( fileName, description, "text/x-vCard" ); |
877 | } else { | 877 | } else { |
878 | qDebug("Error open temp beam file "); | 878 | qDebug("Error open temp beam file "); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | #endif | 881 | #endif |
882 | 882 | ||
883 | } | 883 | } |
884 | 884 | ||
885 | void KABCore::beamDone( Ir *ir ) | 885 | void KABCore::beamDone( Ir *ir ) |
886 | { | 886 | { |
887 | #ifndef DESKTOP_VERSION | 887 | #ifndef DESKTOP_VERSION |
888 | delete ir; | 888 | delete ir; |
889 | #endif | 889 | #endif |
890 | } | 890 | } |
891 | 891 | ||
892 | 892 | ||
893 | void KABCore::browse( const QString& url ) | 893 | void KABCore::browse( const QString& url ) |
894 | { | 894 | { |
895 | #ifndef KAB_EMBEDDED | 895 | #ifndef KAB_EMBEDDED |
896 | kapp->invokeBrowser( url ); | 896 | kapp->invokeBrowser( url ); |
897 | #else //KAB_EMBEDDED | 897 | #else //KAB_EMBEDDED |
898 | qDebug("KABCore::browse must be fixed"); | 898 | qDebug("KABCore::browse must be fixed"); |
899 | #endif //KAB_EMBEDDED | 899 | #endif //KAB_EMBEDDED |
900 | } | 900 | } |
901 | 901 | ||
902 | void KABCore::selectAllContacts() | 902 | void KABCore::selectAllContacts() |
903 | { | 903 | { |
904 | mViewManager->setSelected( QString::null, true ); | 904 | mViewManager->setSelected( QString::null, true ); |
905 | } | 905 | } |
906 | 906 | ||
907 | void KABCore::deleteContacts() | 907 | void KABCore::deleteContacts() |
908 | { | 908 | { |
909 | QStringList uidList = mViewManager->selectedUids(); | 909 | QStringList uidList = mViewManager->selectedUids(); |
910 | deleteContacts( uidList ); | 910 | deleteContacts( uidList ); |
911 | } | 911 | } |
912 | 912 | ||
913 | void KABCore::deleteContacts( const QStringList &uids ) | 913 | void KABCore::deleteContacts( const QStringList &uids ) |
914 | { | 914 | { |
915 | if ( uids.count() > 0 ) { | 915 | if ( uids.count() > 0 ) { |
916 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 916 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
917 | UndoStack::instance()->push( command ); | 917 | UndoStack::instance()->push( command ); |
918 | RedoStack::instance()->clear(); | 918 | RedoStack::instance()->clear(); |
919 | 919 | ||
920 | // now if we deleted anything, refresh | 920 | // now if we deleted anything, refresh |
921 | setContactSelected( QString::null ); | 921 | setContactSelected( QString::null ); |
922 | setModified( true ); | 922 | setModified( true ); |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | void KABCore::copyContacts() | 926 | void KABCore::copyContacts() |
927 | { | 927 | { |
928 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 928 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
929 | 929 | ||
930 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 930 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
931 | 931 | ||
932 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 932 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
933 | 933 | ||
934 | QClipboard *cb = QApplication::clipboard(); | 934 | QClipboard *cb = QApplication::clipboard(); |
935 | cb->setText( clipText ); | 935 | cb->setText( clipText ); |
936 | } | 936 | } |
937 | 937 | ||
938 | void KABCore::cutContacts() | 938 | void KABCore::cutContacts() |
939 | { | 939 | { |
940 | QStringList uidList = mViewManager->selectedUids(); | 940 | QStringList uidList = mViewManager->selectedUids(); |
941 | 941 | ||
942 | //US if ( uidList.size() > 0 ) { | 942 | //US if ( uidList.size() > 0 ) { |
943 | if ( uidList.count() > 0 ) { | 943 | if ( uidList.count() > 0 ) { |
944 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 944 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
945 | UndoStack::instance()->push( command ); | 945 | UndoStack::instance()->push( command ); |
946 | RedoStack::instance()->clear(); | 946 | RedoStack::instance()->clear(); |
947 | 947 | ||
948 | setModified( true ); | 948 | setModified( true ); |
949 | } | 949 | } |
950 | } | 950 | } |
951 | 951 | ||
952 | void KABCore::pasteContacts() | 952 | void KABCore::pasteContacts() |
953 | { | 953 | { |
954 | QClipboard *cb = QApplication::clipboard(); | 954 | QClipboard *cb = QApplication::clipboard(); |
955 | 955 | ||
956 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 956 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
957 | 957 | ||
958 | pasteContacts( list ); | 958 | pasteContacts( list ); |
959 | } | 959 | } |
960 | 960 | ||
961 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 961 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
962 | { | 962 | { |
963 | KABC::Resource *resource = requestResource( this ); | 963 | KABC::Resource *resource = requestResource( this ); |
964 | KABC::Addressee::List::Iterator it; | 964 | KABC::Addressee::List::Iterator it; |
965 | for ( it = list.begin(); it != list.end(); ++it ) | 965 | for ( it = list.begin(); it != list.end(); ++it ) |
966 | (*it).setResource( resource ); | 966 | (*it).setResource( resource ); |
967 | 967 | ||
968 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 968 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
969 | UndoStack::instance()->push( command ); | 969 | UndoStack::instance()->push( command ); |
970 | RedoStack::instance()->clear(); | 970 | RedoStack::instance()->clear(); |
971 | 971 | ||
972 | setModified( true ); | 972 | setModified( true ); |
973 | } | 973 | } |
974 | 974 | ||
975 | void KABCore::setWhoAmI() | 975 | void KABCore::setWhoAmI() |
976 | { | 976 | { |
977 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 977 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
978 | 978 | ||
979 | if ( addrList.count() > 1 ) { | 979 | if ( addrList.count() > 1 ) { |
980 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 980 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
981 | return; | 981 | return; |
982 | } | 982 | } |
983 | 983 | ||
984 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 984 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
985 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 985 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
986 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 986 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
987 | } | 987 | } |
988 | 988 | ||
989 | void KABCore::setCategories() | 989 | void KABCore::setCategories() |
990 | { | 990 | { |
991 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 991 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
992 | if ( !dlg.exec() ) | 992 | if ( !dlg.exec() ) |
993 | return; | 993 | return; |
994 | 994 | ||
995 | bool merge = false; | 995 | bool merge = false; |
996 | QString msg = i18n( "Merge with existing categories?" ); | 996 | QString msg = i18n( "Merge with existing categories?" ); |
997 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 997 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
998 | merge = true; | 998 | merge = true; |
999 | 999 | ||
1000 | QStringList categories = dlg.selectedCategories(); | 1000 | QStringList categories = dlg.selectedCategories(); |
1001 | 1001 | ||
1002 | QStringList uids = mViewManager->selectedUids(); | 1002 | QStringList uids = mViewManager->selectedUids(); |
1003 | QStringList::Iterator it; | 1003 | QStringList::Iterator it; |
1004 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 1004 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
1005 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 1005 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
1006 | if ( !addr.isEmpty() ) { | 1006 | if ( !addr.isEmpty() ) { |
1007 | if ( !merge ) | 1007 | if ( !merge ) |
1008 | addr.setCategories( categories ); | 1008 | addr.setCategories( categories ); |
1009 | else { | 1009 | else { |
1010 | QStringList addrCategories = addr.categories(); | 1010 | QStringList addrCategories = addr.categories(); |
1011 | QStringList::Iterator catIt; | 1011 | QStringList::Iterator catIt; |
1012 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 1012 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
1013 | if ( !addrCategories.contains( *catIt ) ) | 1013 | if ( !addrCategories.contains( *catIt ) ) |
1014 | addrCategories.append( *catIt ); | 1014 | addrCategories.append( *catIt ); |
1015 | } | 1015 | } |
1016 | addr.setCategories( addrCategories ); | 1016 | addr.setCategories( addrCategories ); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | mAddressBook->insertAddressee( addr ); | 1019 | mAddressBook->insertAddressee( addr ); |
1020 | } | 1020 | } |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | if ( uids.count() > 0 ) | 1023 | if ( uids.count() > 0 ) |
1024 | setModified( true ); | 1024 | setModified( true ); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 1027 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
1028 | { | 1028 | { |
1029 | mIncSearchWidget->setFields( fields ); | 1029 | mIncSearchWidget->setFields( fields ); |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void KABCore::incrementalSearch( const QString& text ) | 1032 | void KABCore::incrementalSearch( const QString& text ) |
1033 | { | 1033 | { |
1034 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 1034 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | void KABCore::setModified() | 1037 | void KABCore::setModified() |
1038 | { | 1038 | { |
1039 | setModified( true ); | 1039 | setModified( true ); |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | void KABCore::setModifiedWOrefresh() | 1042 | void KABCore::setModifiedWOrefresh() |
1043 | { | 1043 | { |
1044 | // qDebug("KABCore::setModifiedWOrefresh() "); | 1044 | // qDebug("KABCore::setModifiedWOrefresh() "); |
1045 | mModified = true; | 1045 | mModified = true; |
1046 | mActionSave->setEnabled( mModified ); | 1046 | mActionSave->setEnabled( mModified ); |
1047 | #ifdef DESKTOP_VERSION | 1047 | #ifdef DESKTOP_VERSION |
1048 | mDetails->refreshView(); | 1048 | mDetails->refreshView(); |
1049 | #endif | 1049 | #endif |
1050 | 1050 | ||
1051 | } | 1051 | } |
1052 | void KABCore::setModified( bool modified ) | 1052 | void KABCore::setModified( bool modified ) |
1053 | { | 1053 | { |
1054 | mModified = modified; | 1054 | mModified = modified; |
1055 | mActionSave->setEnabled( mModified ); | 1055 | mActionSave->setEnabled( mModified ); |
1056 | 1056 | ||
1057 | if ( modified ) | 1057 | if ( modified ) |
1058 | mJumpButtonBar->recreateButtons(); | 1058 | mJumpButtonBar->recreateButtons(); |
1059 | 1059 | ||
1060 | mViewManager->refreshView(); | 1060 | mViewManager->refreshView(); |
1061 | mDetails->refreshView(); | 1061 | mDetails->refreshView(); |
1062 | 1062 | ||
1063 | } | 1063 | } |
1064 | 1064 | ||
1065 | bool KABCore::modified() const | 1065 | bool KABCore::modified() const |
1066 | { | 1066 | { |
1067 | return mModified; | 1067 | return mModified; |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | void KABCore::contactModified( const KABC::Addressee &addr ) | 1070 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1071 | { | 1071 | { |
1072 | 1072 | ||
1073 | Command *command = 0; | 1073 | Command *command = 0; |
1074 | QString uid; | 1074 | QString uid; |
1075 | 1075 | ||
1076 | // check if it exists already | 1076 | // check if it exists already |
1077 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 1077 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1078 | if ( origAddr.isEmpty() ) | 1078 | if ( origAddr.isEmpty() ) |
1079 | command = new PwNewCommand( mAddressBook, addr ); | 1079 | command = new PwNewCommand( mAddressBook, addr ); |
1080 | else { | 1080 | else { |
1081 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 1081 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1082 | uid = addr.uid(); | 1082 | uid = addr.uid(); |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | UndoStack::instance()->push( command ); | 1085 | UndoStack::instance()->push( command ); |
1086 | RedoStack::instance()->clear(); | 1086 | RedoStack::instance()->clear(); |
1087 | 1087 | ||
1088 | setModified( true ); | 1088 | setModified( true ); |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | void KABCore::newContact() | 1091 | void KABCore::newContact() |
1092 | { | 1092 | { |
1093 | 1093 | ||
1094 | 1094 | ||
1095 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1095 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1096 | 1096 | ||
1097 | QPtrList<KRES::Resource> kresResources; | 1097 | QPtrList<KRES::Resource> kresResources; |
1098 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1098 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1099 | KABC::Resource *resource; | 1099 | KABC::Resource *resource; |
1100 | while ( ( resource = it.current() ) != 0 ) { | 1100 | while ( ( resource = it.current() ) != 0 ) { |
1101 | ++it; | 1101 | ++it; |
1102 | if ( !resource->readOnly() ) { | 1102 | if ( !resource->readOnly() ) { |
1103 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1103 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1104 | if ( res ) | 1104 | if ( res ) |
1105 | kresResources.append( res ); | 1105 | kresResources.append( res ); |
1106 | } | 1106 | } |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1109 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1110 | resource = static_cast<KABC::Resource*>( res ); | 1110 | resource = static_cast<KABC::Resource*>( res ); |
1111 | 1111 | ||
1112 | if ( resource ) { | 1112 | if ( resource ) { |
1113 | KABC::Addressee addr; | 1113 | KABC::Addressee addr; |
1114 | addr.setResource( resource ); | 1114 | addr.setResource( resource ); |
1115 | mEditorDialog->setAddressee( addr ); | 1115 | mEditorDialog->setAddressee( addr ); |
1116 | KApplication::execDialog ( mEditorDialog ); | 1116 | KApplication::execDialog ( mEditorDialog ); |
1117 | 1117 | ||
1118 | } else | 1118 | } else |
1119 | return; | 1119 | return; |
1120 | 1120 | ||
1121 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1121 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1122 | 1122 | ||
1123 | 1123 | ||
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | void KABCore::addEmail( QString aStr ) | 1126 | void KABCore::addEmail( QString aStr ) |
1127 | { | 1127 | { |
1128 | #ifndef KAB_EMBEDDED | 1128 | #ifndef KAB_EMBEDDED |
1129 | QString fullName, email; | 1129 | QString fullName, email; |
1130 | 1130 | ||
1131 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1131 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1132 | 1132 | ||
1133 | // Try to lookup the addressee matching the email address | 1133 | // Try to lookup the addressee matching the email address |
1134 | bool found = false; | 1134 | bool found = false; |
1135 | QStringList emailList; | 1135 | QStringList emailList; |
1136 | KABC::AddressBook::Iterator it; | 1136 | KABC::AddressBook::Iterator it; |
1137 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1137 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1138 | emailList = (*it).emails(); | 1138 | emailList = (*it).emails(); |
1139 | if ( emailList.contains( email ) > 0 ) { | 1139 | if ( emailList.contains( email ) > 0 ) { |
1140 | found = true; | 1140 | found = true; |
1141 | (*it).setNameFromString( fullName ); | 1141 | (*it).setNameFromString( fullName ); |
1142 | editContact( (*it).uid() ); | 1142 | editContact( (*it).uid() ); |
1143 | } | 1143 | } |
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | if ( !found ) { | 1146 | if ( !found ) { |
1147 | KABC::Addressee addr; | 1147 | KABC::Addressee addr; |
1148 | addr.setNameFromString( fullName ); | 1148 | addr.setNameFromString( fullName ); |
1149 | addr.insertEmail( email, true ); | 1149 | addr.insertEmail( email, true ); |
1150 | 1150 | ||
1151 | mAddressBook->insertAddressee( addr ); | 1151 | mAddressBook->insertAddressee( addr ); |
1152 | mViewManager->refreshView( addr.uid() ); | 1152 | mViewManager->refreshView( addr.uid() ); |
1153 | editContact( addr.uid() ); | 1153 | editContact( addr.uid() ); |
1154 | } | 1154 | } |
1155 | #else //KAB_EMBEDDED | 1155 | #else //KAB_EMBEDDED |
1156 | qDebug("KABCore::addEmail finsih method"); | 1156 | qDebug("KABCore::addEmail finsih method"); |
1157 | #endif //KAB_EMBEDDED | 1157 | #endif //KAB_EMBEDDED |
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1160 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1161 | { | 1161 | { |
1162 | mXXPortManager->importVCard( url, showPreview ); | 1162 | mXXPortManager->importVCard( url, showPreview ); |
1163 | } | 1163 | } |
1164 | void KABCore::importFromOL() | 1164 | void KABCore::importFromOL() |
1165 | { | 1165 | { |
1166 | #ifdef _WIN32_ | 1166 | #ifdef _WIN32_ |
1167 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1167 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1168 | idgl->exec(); | 1168 | idgl->exec(); |
1169 | KABC::Addressee::List list = idgl->getAddressList(); | 1169 | KABC::Addressee::List list = idgl->getAddressList(); |
1170 | if ( list.count() > 0 ) { | 1170 | if ( list.count() > 0 ) { |
1171 | KABC::Addressee::List listNew; | 1171 | KABC::Addressee::List listNew; |
1172 | KABC::Addressee::List listExisting; | 1172 | KABC::Addressee::List listExisting; |
1173 | KABC::Addressee::List::Iterator it; | 1173 | KABC::Addressee::List::Iterator it; |
1174 | KABC::AddressBook::Iterator iter; | 1174 | KABC::AddressBook::Iterator iter; |
1175 | for ( it = list.begin(); it != list.end(); ++it ) { | 1175 | for ( it = list.begin(); it != list.end(); ++it ) { |
1176 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1176 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1177 | listNew.append( (*it) ); | 1177 | listNew.append( (*it) ); |
1178 | else | 1178 | else |
1179 | listExisting.append( (*it) ); | 1179 | listExisting.append( (*it) ); |
1180 | } | 1180 | } |
1181 | if ( listExisting.count() > 0 ) | 1181 | if ( listExisting.count() > 0 ) |
1182 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1182 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1183 | if ( listNew.count() > 0 ) { | 1183 | if ( listNew.count() > 0 ) { |
1184 | pasteWithNewUid = false; | 1184 | pasteWithNewUid = false; |
1185 | pasteContacts( listNew ); | 1185 | pasteContacts( listNew ); |
1186 | pasteWithNewUid = true; | 1186 | pasteWithNewUid = true; |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | delete idgl; | 1189 | delete idgl; |
1190 | #endif | 1190 | #endif |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1193 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1194 | { | 1194 | { |
1195 | mXXPortManager->importVCard( vCard, showPreview ); | 1195 | mXXPortManager->importVCard( vCard, showPreview ); |
1196 | } | 1196 | } |
1197 | 1197 | ||
1198 | //US added a second method without defaultparameter | 1198 | //US added a second method without defaultparameter |
1199 | void KABCore::editContact2() { | 1199 | void KABCore::editContact2() { |
1200 | editContact( QString::null ); | 1200 | editContact( QString::null ); |
1201 | } | 1201 | } |
1202 | 1202 | ||
1203 | void KABCore::editContact( const QString &uid ) | 1203 | void KABCore::editContact( const QString &uid ) |
1204 | { | 1204 | { |
1205 | 1205 | ||
1206 | if ( mExtensionManager->isQuickEditVisible() ) | 1206 | if ( mExtensionManager->isQuickEditVisible() ) |
1207 | return; | 1207 | return; |
1208 | 1208 | ||
1209 | // First, locate the contact entry | 1209 | // First, locate the contact entry |
1210 | QString localUID = uid; | 1210 | QString localUID = uid; |
1211 | if ( localUID.isNull() ) { | 1211 | if ( localUID.isNull() ) { |
1212 | QStringList uidList = mViewManager->selectedUids(); | 1212 | QStringList uidList = mViewManager->selectedUids(); |
1213 | if ( uidList.count() > 0 ) | 1213 | if ( uidList.count() > 0 ) |
1214 | localUID = *( uidList.at( 0 ) ); | 1214 | localUID = *( uidList.at( 0 ) ); |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1217 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1218 | if ( !addr.isEmpty() ) { | 1218 | if ( !addr.isEmpty() ) { |
1219 | mEditorDialog->setAddressee( addr ); | 1219 | mEditorDialog->setAddressee( addr ); |
1220 | KApplication::execDialog ( mEditorDialog ); | 1220 | KApplication::execDialog ( mEditorDialog ); |
1221 | } | 1221 | } |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | /** | 1224 | /** |
1225 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1225 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1226 | the method will try to find a selected addressee in the view. | 1226 | the method will try to find a selected addressee in the view. |
1227 | */ | 1227 | */ |
1228 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1228 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1229 | { | 1229 | { |
1230 | if ( mMultipleViewsAtOnce ) | 1230 | if ( mMultipleViewsAtOnce ) |
1231 | { | 1231 | { |
1232 | editContact( uid ); | 1232 | editContact( uid ); |
1233 | } | 1233 | } |
1234 | else | 1234 | else |
1235 | { | 1235 | { |
1236 | setDetailsVisible( true ); | 1236 | setDetailsVisible( true ); |
1237 | mActionDetails->setChecked(true); | 1237 | mActionDetails->setChecked(true); |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | } | 1240 | } |
1241 | 1241 | ||
1242 | void KABCore::save() | 1242 | void KABCore::save() |
1243 | { | 1243 | { |
1244 | if (syncManager->blockSave()) | 1244 | if (syncManager->blockSave()) |
1245 | return; | 1245 | return; |
1246 | if ( !mModified ) | 1246 | if ( !mModified ) |
1247 | return; | 1247 | return; |
1248 | 1248 | ||
1249 | syncManager->setBlockSave(true); | 1249 | syncManager->setBlockSave(true); |
1250 | QString text = i18n( "There was an error while attempting to save\n the " | 1250 | QString text = i18n( "There was an error while attempting to save\n the " |
1251 | "address book. Please check that some \nother application is " | 1251 | "address book. Please check that some \nother application is " |
1252 | "not using it. " ); | 1252 | "not using it. " ); |
1253 | statusMessage(i18n("Saving addressbook ... ")); | 1253 | statusMessage(i18n("Saving addressbook ... ")); |
1254 | #ifndef KAB_EMBEDDED | 1254 | #ifndef KAB_EMBEDDED |
1255 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1255 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1256 | if ( !b || !b->save() ) { | 1256 | if ( !b || !b->save() ) { |
1257 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1257 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1258 | } | 1258 | } |
1259 | #else //KAB_EMBEDDED | 1259 | #else //KAB_EMBEDDED |
1260 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1260 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1261 | if ( !b || !b->save() ) { | 1261 | if ( !b || !b->save() ) { |
1262 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1262 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1263 | } | 1263 | } |
1264 | #endif //KAB_EMBEDDED | 1264 | #endif //KAB_EMBEDDED |
1265 | 1265 | ||
1266 | statusMessage(i18n("Addressbook saved!")); | 1266 | statusMessage(i18n("Addressbook saved!")); |
1267 | setModified( false ); | 1267 | setModified( false ); |
1268 | syncManager->setBlockSave(false); | 1268 | syncManager->setBlockSave(false); |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | void KABCore::statusMessage(QString mess , int time ) | 1271 | void KABCore::statusMessage(QString mess , int time ) |
1272 | { | 1272 | { |
1273 | //topLevelWidget()->setCaption( mess ); | 1273 | //topLevelWidget()->setCaption( mess ); |
1274 | // pending setting timer to revome message | 1274 | // pending setting timer to revome message |
1275 | } | 1275 | } |
1276 | void KABCore::undo() | 1276 | void KABCore::undo() |
1277 | { | 1277 | { |
1278 | UndoStack::instance()->undo(); | 1278 | UndoStack::instance()->undo(); |
1279 | 1279 | ||
1280 | // Refresh the view | 1280 | // Refresh the view |
1281 | mViewManager->refreshView(); | 1281 | mViewManager->refreshView(); |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | void KABCore::redo() | 1284 | void KABCore::redo() |
1285 | { | 1285 | { |
1286 | RedoStack::instance()->redo(); | 1286 | RedoStack::instance()->redo(); |
1287 | 1287 | ||
1288 | // Refresh the view | 1288 | // Refresh the view |
1289 | mViewManager->refreshView(); | 1289 | mViewManager->refreshView(); |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1292 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1293 | { | 1293 | { |
1294 | if (mMultipleViewsAtOnce) | 1294 | if (mMultipleViewsAtOnce) |
1295 | { | 1295 | { |
1296 | if ( visible ) | 1296 | if ( visible ) |
1297 | mJumpButtonBar->show(); | 1297 | mJumpButtonBar->show(); |
1298 | else | 1298 | else |
1299 | mJumpButtonBar->hide(); | 1299 | mJumpButtonBar->hide(); |
1300 | } | 1300 | } |
1301 | else | 1301 | else |
1302 | { | 1302 | { |
1303 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1303 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1304 | if (mViewManager->isVisible()) | 1304 | if (mViewManager->isVisible()) |
1305 | { | 1305 | { |
1306 | if ( visible ) | 1306 | if ( visible ) |
1307 | mJumpButtonBar->show(); | 1307 | mJumpButtonBar->show(); |
1308 | else | 1308 | else |
1309 | mJumpButtonBar->hide(); | 1309 | mJumpButtonBar->hide(); |
1310 | } | 1310 | } |
1311 | else | 1311 | else |
1312 | { | 1312 | { |
1313 | mJumpButtonBar->hide(); | 1313 | mJumpButtonBar->hide(); |
1314 | } | 1314 | } |
1315 | } | 1315 | } |
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | 1318 | ||
1319 | void KABCore::setDetailsToState() | 1319 | void KABCore::setDetailsToState() |
1320 | { | 1320 | { |
1321 | setDetailsVisible( mActionDetails->isChecked() ); | 1321 | setDetailsVisible( mActionDetails->isChecked() ); |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | 1324 | ||
1325 | 1325 | ||
1326 | void KABCore::setDetailsVisible( bool visible ) | 1326 | void KABCore::setDetailsVisible( bool visible ) |
1327 | { | 1327 | { |
1328 | if (visible && mDetails->isHidden()) | 1328 | if (visible && mDetails->isHidden()) |
1329 | { | 1329 | { |
1330 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1330 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1331 | if ( addrList.count() > 0 ) | 1331 | if ( addrList.count() > 0 ) |
1332 | mDetails->setAddressee( addrList[ 0 ] ); | 1332 | mDetails->setAddressee( addrList[ 0 ] ); |
1333 | } | 1333 | } |
1334 | 1334 | ||
1335 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1335 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1336 | // the listview and the detailview. We do that by changing the splitbar size. | 1336 | // the listview and the detailview. We do that by changing the splitbar size. |
1337 | if (mMultipleViewsAtOnce) | 1337 | if (mMultipleViewsAtOnce) |
1338 | { | 1338 | { |
1339 | if ( visible ) | 1339 | if ( visible ) |
1340 | mDetails->show(); | 1340 | mDetails->show(); |
1341 | else | 1341 | else |
1342 | mDetails->hide(); | 1342 | mDetails->hide(); |
1343 | } | 1343 | } |
1344 | else | 1344 | else |
1345 | { | 1345 | { |
1346 | if ( visible ) { | 1346 | if ( visible ) { |
1347 | mViewManager->hide(); | 1347 | mViewManager->hide(); |
1348 | mDetails->show(); | 1348 | mDetails->show(); |
1349 | } | 1349 | } |
1350 | else { | 1350 | else { |
1351 | mViewManager->show(); | 1351 | mViewManager->show(); |
1352 | mDetails->hide(); | 1352 | mDetails->hide(); |
1353 | } | 1353 | } |
1354 | setJumpButtonBarVisible( !visible ); | 1354 | setJumpButtonBarVisible( !visible ); |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | void KABCore::extensionChanged( int id ) | 1359 | void KABCore::extensionChanged( int id ) |
1360 | { | 1360 | { |
1361 | //change the details view only for non desktop systems | 1361 | //change the details view only for non desktop systems |
1362 | #ifndef DESKTOP_VERSION | 1362 | #ifndef DESKTOP_VERSION |
1363 | 1363 | ||
1364 | if (id == 0) | 1364 | if (id == 0) |
1365 | { | 1365 | { |
1366 | //the user disabled the extension. | 1366 | //the user disabled the extension. |
1367 | 1367 | ||
1368 | if (mMultipleViewsAtOnce) | 1368 | if (mMultipleViewsAtOnce) |
1369 | { // enable detailsview again | 1369 | { // enable detailsview again |
1370 | setDetailsVisible( true ); | 1370 | setDetailsVisible( true ); |
1371 | mActionDetails->setChecked( true ); | 1371 | mActionDetails->setChecked( true ); |
1372 | } | 1372 | } |
1373 | else | 1373 | else |
1374 | { //go back to the listview | 1374 | { //go back to the listview |
1375 | setDetailsVisible( false ); | 1375 | setDetailsVisible( false ); |
1376 | mActionDetails->setChecked( false ); | 1376 | mActionDetails->setChecked( false ); |
1377 | mActionDetails->setEnabled(true); | 1377 | mActionDetails->setEnabled(true); |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | } | 1380 | } |
1381 | else | 1381 | else |
1382 | { | 1382 | { |
1383 | //the user enabled the extension. | 1383 | //the user enabled the extension. |
1384 | setDetailsVisible( false ); | 1384 | setDetailsVisible( false ); |
1385 | mActionDetails->setChecked( false ); | 1385 | mActionDetails->setChecked( false ); |
1386 | 1386 | ||
1387 | if (!mMultipleViewsAtOnce) | 1387 | if (!mMultipleViewsAtOnce) |
1388 | { | 1388 | { |
1389 | mActionDetails->setEnabled(false); | 1389 | mActionDetails->setEnabled(false); |
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | mExtensionManager->setSelectionChanged(); | 1392 | mExtensionManager->setSelectionChanged(); |
1393 | 1393 | ||
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | #endif// DESKTOP_VERSION | 1396 | #endif// DESKTOP_VERSION |
1397 | 1397 | ||
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | 1400 | ||
1401 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1401 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1402 | { | 1402 | { |
1403 | 1403 | ||
1404 | if ( list.count() != 0 ) { | 1404 | if ( list.count() != 0 ) { |
1405 | KABC::Addressee::List::ConstIterator it; | 1405 | KABC::Addressee::List::ConstIterator it; |
1406 | for ( it = list.begin(); it != list.end(); ++it ) | 1406 | for ( it = list.begin(); it != list.end(); ++it ) |
1407 | mAddressBook->insertAddressee( *it ); | 1407 | mAddressBook->insertAddressee( *it ); |
1408 | if ( list.count() > 1 ) | 1408 | if ( list.count() > 1 ) |
1409 | setModified(); | 1409 | setModified(); |
1410 | else | 1410 | else |
1411 | setModifiedWOrefresh(); | 1411 | setModifiedWOrefresh(); |
1412 | } | 1412 | } |
1413 | if ( list.count() == 0 ) | 1413 | if ( list.count() == 0 ) |
1414 | mViewManager->refreshView(); | 1414 | mViewManager->refreshView(); |
1415 | else | 1415 | else |
1416 | mViewManager->refreshView( list[ 0 ].uid() ); | 1416 | mViewManager->refreshView( list[ 0 ].uid() ); |
1417 | 1417 | ||
1418 | 1418 | ||
1419 | 1419 | ||
1420 | } | 1420 | } |
1421 | 1421 | ||
1422 | QString KABCore::getNameByPhone( const QString &phone ) | 1422 | QString KABCore::getNameByPhone( const QString &phone ) |
1423 | { | 1423 | { |
1424 | #ifndef KAB_EMBEDDED | 1424 | #ifndef KAB_EMBEDDED |
1425 | QRegExp r( "[/*/-/ ]" ); | 1425 | QRegExp r( "[/*/-/ ]" ); |
1426 | QString localPhone( phone ); | 1426 | QString localPhone( phone ); |
1427 | 1427 | ||
1428 | bool found = false; | 1428 | bool found = false; |
1429 | QString ownerName = ""; | 1429 | QString ownerName = ""; |
1430 | KABC::AddressBook::Iterator iter; | 1430 | KABC::AddressBook::Iterator iter; |
1431 | KABC::PhoneNumber::List::Iterator phoneIter; | 1431 | KABC::PhoneNumber::List::Iterator phoneIter; |
1432 | KABC::PhoneNumber::List phoneList; | 1432 | KABC::PhoneNumber::List phoneList; |
1433 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1433 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1434 | phoneList = (*iter).phoneNumbers(); | 1434 | phoneList = (*iter).phoneNumbers(); |
1435 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1435 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1436 | ++phoneIter) { | 1436 | ++phoneIter) { |
1437 | // Get rid of separator chars so just the numbers are compared. | 1437 | // Get rid of separator chars so just the numbers are compared. |
1438 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1438 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1439 | ownerName = (*iter).formattedName(); | 1439 | ownerName = (*iter).formattedName(); |
1440 | found = true; | 1440 | found = true; |
1441 | } | 1441 | } |
1442 | } | 1442 | } |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | return ownerName; | 1445 | return ownerName; |
1446 | #else //KAB_EMBEDDED | 1446 | #else //KAB_EMBEDDED |
1447 | qDebug("KABCore::getNameByPhone finsih method"); | 1447 | qDebug("KABCore::getNameByPhone finsih method"); |
1448 | return ""; | 1448 | return ""; |
1449 | #endif //KAB_EMBEDDED | 1449 | #endif //KAB_EMBEDDED |
1450 | 1450 | ||
1451 | } | 1451 | } |
1452 | 1452 | ||
1453 | void KABCore::openConfigDialog() | 1453 | void KABCore::openConfigDialog() |
1454 | { | 1454 | { |
1455 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1455 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1456 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1456 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1457 | ConfigureDialog->addModule(kabcfg ); | 1457 | ConfigureDialog->addModule(kabcfg ); |
1458 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1458 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1459 | ConfigureDialog->addModule(kdelibcfg ); | 1459 | ConfigureDialog->addModule(kdelibcfg ); |
1460 | 1460 | ||
1461 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1461 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1462 | this, SLOT( configurationChanged() ) ); | 1462 | this, SLOT( configurationChanged() ) ); |
1463 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1463 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1464 | this, SLOT( configurationChanged() ) ); | 1464 | this, SLOT( configurationChanged() ) ); |
1465 | saveSettings(); | 1465 | saveSettings(); |
1466 | #ifndef DESKTOP_VERSION | 1466 | #ifndef DESKTOP_VERSION |
1467 | ConfigureDialog->showMaximized(); | 1467 | ConfigureDialog->showMaximized(); |
1468 | #endif | 1468 | #endif |
1469 | if ( ConfigureDialog->exec() ) | 1469 | if ( ConfigureDialog->exec() ) |
1470 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1470 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1471 | delete ConfigureDialog; | 1471 | delete ConfigureDialog; |
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void KABCore::openLDAPDialog() | 1474 | void KABCore::openLDAPDialog() |
1475 | { | 1475 | { |
1476 | #ifndef KAB_EMBEDDED | 1476 | #ifndef KAB_EMBEDDED |
1477 | if ( !mLdapSearchDialog ) { | 1477 | if ( !mLdapSearchDialog ) { |
1478 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1478 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1479 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1479 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1480 | SLOT( refreshView() ) ); | 1480 | SLOT( refreshView() ) ); |
1481 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1481 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1482 | SLOT( setModified() ) ); | 1482 | SLOT( setModified() ) ); |
1483 | } else | 1483 | } else |
1484 | mLdapSearchDialog->restoreSettings(); | 1484 | mLdapSearchDialog->restoreSettings(); |
1485 | 1485 | ||
1486 | if ( mLdapSearchDialog->isOK() ) | 1486 | if ( mLdapSearchDialog->isOK() ) |
1487 | mLdapSearchDialog->exec(); | 1487 | mLdapSearchDialog->exec(); |
1488 | #else //KAB_EMBEDDED | 1488 | #else //KAB_EMBEDDED |
1489 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1489 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1490 | #endif //KAB_EMBEDDED | 1490 | #endif //KAB_EMBEDDED |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | void KABCore::print() | 1493 | void KABCore::print() |
1494 | { | 1494 | { |
1495 | #ifndef KAB_EMBEDDED | 1495 | #ifndef KAB_EMBEDDED |
1496 | KPrinter printer; | 1496 | KPrinter printer; |
1497 | if ( !printer.setup( this ) ) | 1497 | if ( !printer.setup( this ) ) |
1498 | return; | 1498 | return; |
1499 | 1499 | ||
1500 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1500 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1501 | mViewManager->selectedUids(), this ); | 1501 | mViewManager->selectedUids(), this ); |
1502 | 1502 | ||
1503 | wizard.exec(); | 1503 | wizard.exec(); |
1504 | #else //KAB_EMBEDDED | 1504 | #else //KAB_EMBEDDED |
1505 | qDebug("KABCore::print() finsih method"); | 1505 | qDebug("KABCore::print() finsih method"); |
1506 | #endif //KAB_EMBEDDED | 1506 | #endif //KAB_EMBEDDED |
1507 | 1507 | ||
1508 | } | 1508 | } |
1509 | 1509 | ||
1510 | 1510 | ||
1511 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1511 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1512 | { | 1512 | { |
1513 | if ( mGUIClient ) | 1513 | if ( mGUIClient ) |
1514 | mGUIClient->insertChildClient( client ); | 1514 | mGUIClient->insertChildClient( client ); |
1515 | else | 1515 | else |
1516 | KMessageBox::error( this, "no KXMLGUICLient"); | 1516 | KMessageBox::error( this, "no KXMLGUICLient"); |
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | void KABCore::configurationChanged() | 1520 | void KABCore::configurationChanged() |
1521 | { | 1521 | { |
1522 | mExtensionManager->reconfigure(); | 1522 | mExtensionManager->reconfigure(); |
1523 | } | 1523 | } |
1524 | 1524 | ||
1525 | void KABCore::addressBookChanged() | 1525 | void KABCore::addressBookChanged() |
1526 | { | 1526 | { |
1527 | /*US | 1527 | /*US |
1528 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1528 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1529 | while ( it.current() ) { | 1529 | while ( it.current() ) { |
1530 | if ( it.current()->dirty() ) { | 1530 | if ( it.current()->dirty() ) { |
1531 | QString text = i18n( "Data has been changed externally. Unsaved " | 1531 | QString text = i18n( "Data has been changed externally. Unsaved " |
1532 | "changes will be lost." ); | 1532 | "changes will be lost." ); |
1533 | KMessageBox::information( this, text ); | 1533 | KMessageBox::information( this, text ); |
1534 | } | 1534 | } |
1535 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1535 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1536 | ++it; | 1536 | ++it; |
1537 | } | 1537 | } |
1538 | */ | 1538 | */ |
1539 | if (mEditorDialog) | 1539 | if (mEditorDialog) |
1540 | { | 1540 | { |
1541 | if (mEditorDialog->dirty()) | 1541 | if (mEditorDialog->dirty()) |
1542 | { | 1542 | { |
1543 | QString text = i18n( "Data has been changed externally. Unsaved " | 1543 | QString text = i18n( "Data has been changed externally. Unsaved " |
1544 | "changes will be lost." ); | 1544 | "changes will be lost." ); |
1545 | KMessageBox::information( this, text ); | 1545 | KMessageBox::information( this, text ); |
1546 | } | 1546 | } |
1547 | QString currentuid = mEditorDialog->addressee().uid(); | 1547 | QString currentuid = mEditorDialog->addressee().uid(); |
1548 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1548 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1549 | } | 1549 | } |
1550 | mViewManager->refreshView(); | 1550 | mViewManager->refreshView(); |
1551 | // mDetails->refreshView(); | 1551 | // mDetails->refreshView(); |
1552 | 1552 | ||
1553 | 1553 | ||
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1556 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1557 | const char *name ) | 1557 | const char *name ) |
1558 | { | 1558 | { |
1559 | 1559 | ||
1560 | if ( mEditorDialog == 0 ) { | 1560 | if ( mEditorDialog == 0 ) { |
1561 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1561 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1562 | name ? name : "editorDialog" ); | 1562 | name ? name : "editorDialog" ); |
1563 | 1563 | ||
1564 | 1564 | ||
1565 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1565 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1566 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1566 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1567 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1567 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1568 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1568 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1569 | } | 1569 | } |
1570 | 1570 | ||
1571 | return mEditorDialog; | 1571 | return mEditorDialog; |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1574 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1575 | { | 1575 | { |
1576 | //mEditorDict.remove( uid ); | 1576 | //mEditorDict.remove( uid ); |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | void KABCore::initGUI() | 1579 | void KABCore::initGUI() |
1580 | { | 1580 | { |
1581 | #ifndef KAB_EMBEDDED | 1581 | #ifndef KAB_EMBEDDED |
1582 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1582 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1583 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1583 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1584 | 1584 | ||
1585 | mExtensionBarSplitter = new QSplitter( this ); | 1585 | mExtensionBarSplitter = new QSplitter( this ); |
1586 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1586 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1587 | 1587 | ||
1588 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1588 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1589 | 1589 | ||
1590 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1590 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1591 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1591 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1592 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1592 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1593 | SLOT( incrementalSearch( const QString& ) ) ); | 1593 | SLOT( incrementalSearch( const QString& ) ) ); |
1594 | 1594 | ||
1595 | mViewManager = new ViewManager( this, viewSpace ); | 1595 | mViewManager = new ViewManager( this, viewSpace ); |
1596 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1596 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1597 | 1597 | ||
1598 | mDetails = new ViewContainer( mDetailsSplitter ); | 1598 | mDetails = new ViewContainer( mDetailsSplitter ); |
1599 | 1599 | ||
1600 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1600 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1601 | 1601 | ||
1602 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1602 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1603 | 1603 | ||
1604 | topLayout->addWidget( mExtensionBarSplitter ); | 1604 | topLayout->addWidget( mExtensionBarSplitter ); |
1605 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1605 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1606 | topLayout->addWidget( mJumpButtonBar ); | 1606 | topLayout->addWidget( mJumpButtonBar ); |
1607 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1607 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1608 | 1608 | ||
1609 | mXXPortManager = new XXPortManager( this, this ); | 1609 | mXXPortManager = new XXPortManager( this, this ); |
1610 | 1610 | ||
1611 | #else //KAB_EMBEDDED | 1611 | #else //KAB_EMBEDDED |
1612 | //US initialize viewMenu before settingup viewmanager. | 1612 | //US initialize viewMenu before settingup viewmanager. |
1613 | // Viewmanager needs this menu to plugin submenues. | 1613 | // Viewmanager needs this menu to plugin submenues. |
1614 | viewMenu = new QPopupMenu( this ); | 1614 | viewMenu = new QPopupMenu( this ); |
1615 | settingsMenu = new QPopupMenu( this ); | 1615 | settingsMenu = new QPopupMenu( this ); |
1616 | //filterMenu = new QPopupMenu( this ); | 1616 | //filterMenu = new QPopupMenu( this ); |
1617 | ImportMenu = new QPopupMenu( this ); | 1617 | ImportMenu = new QPopupMenu( this ); |
1618 | ExportMenu = new QPopupMenu( this ); | 1618 | ExportMenu = new QPopupMenu( this ); |
1619 | syncMenu = new QPopupMenu( this ); | 1619 | syncMenu = new QPopupMenu( this ); |
1620 | changeMenu= new QPopupMenu( this ); | 1620 | changeMenu= new QPopupMenu( this ); |
1621 | 1621 | ||
1622 | //US since we have no splitter for the embedded system, setup | 1622 | //US since we have no splitter for the embedded system, setup |
1623 | // a layout with two frames. One left and one right. | 1623 | // a layout with two frames. One left and one right. |
1624 | 1624 | ||
1625 | QBoxLayout *topLayout; | 1625 | QBoxLayout *topLayout; |
1626 | 1626 | ||
1627 | // = new QHBoxLayout( this ); | 1627 | // = new QHBoxLayout( this ); |
1628 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1628 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1629 | 1629 | ||
1630 | // QWidget *mainBox = new QWidget( this ); | 1630 | // QWidget *mainBox = new QWidget( this ); |
1631 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1631 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1632 | 1632 | ||
1633 | #ifdef DESKTOP_VERSION | 1633 | #ifdef DESKTOP_VERSION |
1634 | topLayout = new QHBoxLayout( this ); | 1634 | topLayout = new QHBoxLayout( this ); |
1635 | 1635 | ||
1636 | 1636 | ||
1637 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1637 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1638 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1638 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1639 | 1639 | ||
1640 | topLayout->addWidget(mMiniSplitter ); | 1640 | topLayout->addWidget(mMiniSplitter ); |
1641 | 1641 | ||
1642 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1642 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1643 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1643 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1644 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1644 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1645 | mDetails = new ViewContainer( mMiniSplitter ); | 1645 | mDetails = new ViewContainer( mMiniSplitter ); |
1646 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1646 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1647 | #else | 1647 | #else |
1648 | if ( QApplication::desktop()->width() > 480 ) { | 1648 | if ( QApplication::desktop()->width() > 480 ) { |
1649 | topLayout = new QHBoxLayout( this ); | 1649 | topLayout = new QHBoxLayout( this ); |
1650 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1650 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1651 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1651 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1652 | } else { | 1652 | } else { |
1653 | 1653 | ||
1654 | topLayout = new QHBoxLayout( this ); | 1654 | topLayout = new QHBoxLayout( this ); |
1655 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1655 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1656 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1656 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1657 | } | 1657 | } |
1658 | 1658 | ||
1659 | topLayout->addWidget(mMiniSplitter ); | 1659 | topLayout->addWidget(mMiniSplitter ); |
1660 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1660 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1661 | mDetails = new ViewContainer( mMiniSplitter ); | 1661 | mDetails = new ViewContainer( mMiniSplitter ); |
1662 | 1662 | ||
1663 | 1663 | ||
1664 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1664 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1665 | #endif | 1665 | #endif |
1666 | //eh->hide(); | 1666 | //eh->hide(); |
1667 | // topLayout->addWidget(mExtensionManager ); | 1667 | // topLayout->addWidget(mExtensionManager ); |
1668 | 1668 | ||
1669 | 1669 | ||
1670 | /*US | 1670 | /*US |
1671 | #ifndef KAB_NOSPLITTER | 1671 | #ifndef KAB_NOSPLITTER |
1672 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1672 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1673 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1673 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1674 | topLayout->setSpacing( 10 ); | 1674 | topLayout->setSpacing( 10 ); |
1675 | 1675 | ||
1676 | mDetailsSplitter = new QSplitter( this ); | 1676 | mDetailsSplitter = new QSplitter( this ); |
1677 | 1677 | ||
1678 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1678 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1679 | 1679 | ||
1680 | mViewManager = new ViewManager( this, viewSpace ); | 1680 | mViewManager = new ViewManager( this, viewSpace ); |
1681 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1681 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1682 | 1682 | ||
1683 | mDetails = new ViewContainer( mDetailsSplitter ); | 1683 | mDetails = new ViewContainer( mDetailsSplitter ); |
1684 | 1684 | ||
1685 | topLayout->addWidget( mDetailsSplitter ); | 1685 | topLayout->addWidget( mDetailsSplitter ); |
1686 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1686 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1687 | #else //KAB_NOSPLITTER | 1687 | #else //KAB_NOSPLITTER |
1688 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1688 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1689 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1689 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1690 | topLayout->setSpacing( 10 ); | 1690 | topLayout->setSpacing( 10 ); |
1691 | 1691 | ||
1692 | // mDetailsSplitter = new QSplitter( this ); | 1692 | // mDetailsSplitter = new QSplitter( this ); |
1693 | 1693 | ||
1694 | QVBox *viewSpace = new QVBox( this ); | 1694 | QVBox *viewSpace = new QVBox( this ); |
1695 | 1695 | ||
1696 | mViewManager = new ViewManager( this, viewSpace ); | 1696 | mViewManager = new ViewManager( this, viewSpace ); |
1697 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1697 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1698 | 1698 | ||
1699 | mDetails = new ViewContainer( this ); | 1699 | mDetails = new ViewContainer( this ); |
1700 | 1700 | ||
1701 | topLayout->addWidget( viewSpace ); | 1701 | topLayout->addWidget( viewSpace ); |
1702 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1702 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1703 | topLayout->addWidget( mDetails ); | 1703 | topLayout->addWidget( mDetails ); |
1704 | #endif //KAB_NOSPLITTER | 1704 | #endif //KAB_NOSPLITTER |
1705 | */ | 1705 | */ |
1706 | 1706 | ||
1707 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); | 1707 | syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); |
1708 | syncManager->setBlockSave(false); | 1708 | syncManager->setBlockSave(false); |
1709 | 1709 | ||
1710 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 1710 | connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); |
1711 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 1711 | connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); |
1712 | syncManager->setDefaultFileName( sentSyncFile()); | 1712 | syncManager->setDefaultFileName( sentSyncFile()); |
1713 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); | 1713 | //connect(syncManager , SIGNAL( ), this, SLOT( ) ); |
1714 | 1714 | ||
1715 | #endif //KAB_EMBEDDED | 1715 | #endif //KAB_EMBEDDED |
1716 | initActions(); | 1716 | initActions(); |
1717 | 1717 | ||
1718 | #ifdef KAB_EMBEDDED | 1718 | #ifdef KAB_EMBEDDED |
1719 | addActionsManually(); | 1719 | addActionsManually(); |
1720 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1720 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1721 | mXXPortManager = new XXPortManager( this, this ); | 1721 | mXXPortManager = new XXPortManager( this, this ); |
1722 | 1722 | ||
1723 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1723 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1724 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1724 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1725 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1725 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1726 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1726 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1727 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1727 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1728 | // mIncSearchWidget->hide(); | 1728 | // mIncSearchWidget->hide(); |
1729 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1729 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1730 | SLOT( incrementalSearch( const QString& ) ) ); | 1730 | SLOT( incrementalSearch( const QString& ) ) ); |
1731 | 1731 | ||
1732 | 1732 | ||
1733 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1733 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1734 | 1734 | ||
1735 | topLayout->addWidget( mJumpButtonBar ); | 1735 | topLayout->addWidget( mJumpButtonBar ); |
1736 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1736 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1737 | 1737 | ||
1738 | // mMainWindow->getIconToolBar()->raise(); | 1738 | // mMainWindow->getIconToolBar()->raise(); |
1739 | 1739 | ||
1740 | #endif //KAB_EMBEDDED | 1740 | #endif //KAB_EMBEDDED |
1741 | 1741 | ||
1742 | } | 1742 | } |
1743 | void KABCore::initActions() | 1743 | void KABCore::initActions() |
1744 | { | 1744 | { |
1745 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1745 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1746 | 1746 | ||
1747 | #ifndef KAB_EMBEDDED | 1747 | #ifndef KAB_EMBEDDED |
1748 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1748 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1749 | SLOT( clipboardDataChanged() ) ); | 1749 | SLOT( clipboardDataChanged() ) ); |
1750 | #endif //KAB_EMBEDDED | 1750 | #endif //KAB_EMBEDDED |
1751 | 1751 | ||
1752 | // file menu | 1752 | // file menu |
1753 | if ( mIsPart ) { | 1753 | if ( mIsPart ) { |
1754 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1754 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1755 | SLOT( sendMail() ), actionCollection(), | 1755 | SLOT( sendMail() ), actionCollection(), |
1756 | "kaddressbook_mail" ); | 1756 | "kaddressbook_mail" ); |
1757 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1757 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1758 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1758 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1759 | 1759 | ||
1760 | } else { | 1760 | } else { |
1761 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1761 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1762 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1762 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1763 | } | 1763 | } |
1764 | 1764 | ||
1765 | 1765 | ||
1766 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1766 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1767 | SLOT( save() ), actionCollection(), "file_sync" ); | 1767 | SLOT( save() ), actionCollection(), "file_sync" ); |
1768 | 1768 | ||
1769 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1769 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1770 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1770 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1771 | 1771 | ||
1772 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1772 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1773 | this, SLOT( mailVCard() ), | 1773 | this, SLOT( mailVCard() ), |
1774 | actionCollection(), "file_mail_vcard"); | 1774 | actionCollection(), "file_mail_vcard"); |
1775 | 1775 | ||
1776 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, | 1776 | mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, |
1777 | SLOT( export2phone() ), actionCollection(), | 1777 | SLOT( export2phone() ), actionCollection(), |
1778 | "kaddressbook_ex2phone" ); | 1778 | "kaddressbook_ex2phone" ); |
1779 | 1779 | ||
1780 | mActionBeamVCard = 0; | 1780 | mActionBeamVCard = 0; |
1781 | mActionBeam = 0; | 1781 | mActionBeam = 0; |
1782 | 1782 | ||
1783 | #ifndef DESKTOP_VERSION | 1783 | #ifndef DESKTOP_VERSION |
1784 | if ( Ir::supported() ) { | 1784 | if ( Ir::supported() ) { |
1785 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1785 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1786 | SLOT( beamVCard() ), actionCollection(), | 1786 | SLOT( beamVCard() ), actionCollection(), |
1787 | "kaddressbook_beam_vcard" ); | 1787 | "kaddressbook_beam_vcard" ); |
1788 | 1788 | ||
1789 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1789 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1790 | SLOT( beamMySelf() ), actionCollection(), | 1790 | SLOT( beamMySelf() ), actionCollection(), |
1791 | "kaddressbook_beam_myself" ); | 1791 | "kaddressbook_beam_myself" ); |
1792 | } | 1792 | } |
1793 | #endif | 1793 | #endif |
1794 | 1794 | ||
1795 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1795 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1796 | this, SLOT( editContact2() ), | 1796 | this, SLOT( editContact2() ), |
1797 | actionCollection(), "file_properties" ); | 1797 | actionCollection(), "file_properties" ); |
1798 | 1798 | ||
1799 | #ifdef KAB_EMBEDDED | 1799 | #ifdef KAB_EMBEDDED |
1800 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1800 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1801 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1801 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1802 | mMainWindow, SLOT( exit() ), | 1802 | mMainWindow, SLOT( exit() ), |
1803 | actionCollection(), "quit" ); | 1803 | actionCollection(), "quit" ); |
1804 | #endif //KAB_EMBEDDED | 1804 | #endif //KAB_EMBEDDED |
1805 | 1805 | ||
1806 | // edit menu | 1806 | // edit menu |
1807 | if ( mIsPart ) { | 1807 | if ( mIsPart ) { |
1808 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1808 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1809 | SLOT( copyContacts() ), actionCollection(), | 1809 | SLOT( copyContacts() ), actionCollection(), |
1810 | "kaddressbook_copy" ); | 1810 | "kaddressbook_copy" ); |
1811 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1811 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1812 | SLOT( cutContacts() ), actionCollection(), | 1812 | SLOT( cutContacts() ), actionCollection(), |
1813 | "kaddressbook_cut" ); | 1813 | "kaddressbook_cut" ); |
1814 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1814 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1815 | SLOT( pasteContacts() ), actionCollection(), | 1815 | SLOT( pasteContacts() ), actionCollection(), |
1816 | "kaddressbook_paste" ); | 1816 | "kaddressbook_paste" ); |
1817 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1817 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1818 | SLOT( selectAllContacts() ), actionCollection(), | 1818 | SLOT( selectAllContacts() ), actionCollection(), |
1819 | "kaddressbook_select_all" ); | 1819 | "kaddressbook_select_all" ); |
1820 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1820 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1821 | SLOT( undo() ), actionCollection(), | 1821 | SLOT( undo() ), actionCollection(), |
1822 | "kaddressbook_undo" ); | 1822 | "kaddressbook_undo" ); |
1823 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1823 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1824 | this, SLOT( redo() ), actionCollection(), | 1824 | this, SLOT( redo() ), actionCollection(), |
1825 | "kaddressbook_redo" ); | 1825 | "kaddressbook_redo" ); |
1826 | } else { | 1826 | } else { |
1827 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1827 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1828 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1828 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1829 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1829 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1830 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1830 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1831 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1831 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1832 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1832 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1835 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1836 | Key_Delete, this, SLOT( deleteContacts() ), | 1836 | Key_Delete, this, SLOT( deleteContacts() ), |
1837 | actionCollection(), "edit_delete" ); | 1837 | actionCollection(), "edit_delete" ); |
1838 | 1838 | ||
1839 | mActionUndo->setEnabled( false ); | 1839 | mActionUndo->setEnabled( false ); |
1840 | mActionRedo->setEnabled( false ); | 1840 | mActionRedo->setEnabled( false ); |
1841 | 1841 | ||
1842 | // settings menu | 1842 | // settings menu |
1843 | #ifdef KAB_EMBEDDED | 1843 | #ifdef KAB_EMBEDDED |
1844 | //US special menuentry to configure the addressbook resources. On KDE | 1844 | //US special menuentry to configure the addressbook resources. On KDE |
1845 | // you do that through the control center !!! | 1845 | // you do that through the control center !!! |
1846 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1846 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1847 | SLOT( configureResources() ), actionCollection(), | 1847 | SLOT( configureResources() ), actionCollection(), |
1848 | "kaddressbook_configure_resources" ); | 1848 | "kaddressbook_configure_resources" ); |
1849 | #endif //KAB_EMBEDDED | 1849 | #endif //KAB_EMBEDDED |
1850 | 1850 | ||
1851 | if ( mIsPart ) { | 1851 | if ( mIsPart ) { |
1852 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1852 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1853 | SLOT( openConfigDialog() ), actionCollection(), | 1853 | SLOT( openConfigDialog() ), actionCollection(), |
1854 | "kaddressbook_configure" ); | 1854 | "kaddressbook_configure" ); |
1855 | 1855 | ||
1856 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1856 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1857 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1857 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1858 | "kaddressbook_configure_shortcuts" ); | 1858 | "kaddressbook_configure_shortcuts" ); |
1859 | #ifdef KAB_EMBEDDED | 1859 | #ifdef KAB_EMBEDDED |
1860 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1860 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1861 | mActionConfigureToolbars->setEnabled( false ); | 1861 | mActionConfigureToolbars->setEnabled( false ); |
1862 | #endif //KAB_EMBEDDED | 1862 | #endif //KAB_EMBEDDED |
1863 | 1863 | ||
1864 | } else { | 1864 | } else { |
1865 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1865 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1866 | 1866 | ||
1867 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1867 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1870 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1871 | actionCollection(), "options_show_jump_bar" ); | 1871 | actionCollection(), "options_show_jump_bar" ); |
1872 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1872 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1873 | 1873 | ||
1874 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1874 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1875 | actionCollection(), "options_show_details" ); | 1875 | actionCollection(), "options_show_details" ); |
1876 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1876 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1877 | 1877 | ||
1878 | // misc | 1878 | // misc |
1879 | // only enable LDAP lookup if we can handle the protocol | 1879 | // only enable LDAP lookup if we can handle the protocol |
1880 | #ifndef KAB_EMBEDDED | 1880 | #ifndef KAB_EMBEDDED |
1881 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1881 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1882 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1882 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1883 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1883 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1884 | "ldap_lookup" ); | 1884 | "ldap_lookup" ); |
1885 | } | 1885 | } |
1886 | #else //KAB_EMBEDDED | 1886 | #else //KAB_EMBEDDED |
1887 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1887 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1888 | #endif //KAB_EMBEDDED | 1888 | #endif //KAB_EMBEDDED |
1889 | 1889 | ||
1890 | 1890 | ||
1891 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1891 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1892 | SLOT( setWhoAmI() ), actionCollection(), | 1892 | SLOT( setWhoAmI() ), actionCollection(), |
1893 | "set_personal" ); | 1893 | "set_personal" ); |
1894 | 1894 | ||
1895 | 1895 | ||
1896 | 1896 | ||
1897 | 1897 | ||
1898 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1898 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1899 | SLOT( setCategories() ), actionCollection(), | 1899 | SLOT( setCategories() ), actionCollection(), |
1900 | "edit_set_categories" ); | 1900 | "edit_set_categories" ); |
1901 | 1901 | ||
1902 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1902 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1903 | SLOT( removeVoice() ), actionCollection(), | 1903 | SLOT( removeVoice() ), actionCollection(), |
1904 | "remove_voice" ); | 1904 | "remove_voice" ); |
1905 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1905 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1906 | SLOT( importFromOL() ), actionCollection(), | 1906 | SLOT( importFromOL() ), actionCollection(), |
1907 | "import_OL" ); | 1907 | "import_OL" ); |
1908 | #ifdef KAB_EMBEDDED | 1908 | #ifdef KAB_EMBEDDED |
1909 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1909 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1910 | this, SLOT( showLicence() ), actionCollection(), | 1910 | this, SLOT( showLicence() ), actionCollection(), |
1911 | "licence_about_data" ); | 1911 | "licence_about_data" ); |
1912 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1912 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1913 | this, SLOT( faq() ), actionCollection(), | 1913 | this, SLOT( faq() ), actionCollection(), |
1914 | "faq_about_data" ); | 1914 | "faq_about_data" ); |
1915 | 1915 | ||
1916 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1916 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1917 | this, SLOT( createAboutData() ), actionCollection(), | 1917 | this, SLOT( createAboutData() ), actionCollection(), |
1918 | "kaddressbook_about_data" ); | 1918 | "kaddressbook_about_data" ); |
1919 | #endif //KAB_EMBEDDED | 1919 | #endif //KAB_EMBEDDED |
1920 | 1920 | ||
1921 | clipboardDataChanged(); | 1921 | clipboardDataChanged(); |
1922 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1922 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1923 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1923 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1924 | } | 1924 | } |
1925 | 1925 | ||
1926 | //US we need this function, to plug all actions into the correct menues. | 1926 | //US we need this function, to plug all actions into the correct menues. |
1927 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1927 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1928 | void KABCore::addActionsManually() | 1928 | void KABCore::addActionsManually() |
1929 | { | 1929 | { |
1930 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1930 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1931 | 1931 | ||
1932 | #ifdef KAB_EMBEDDED | 1932 | #ifdef KAB_EMBEDDED |
1933 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1933 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1934 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1934 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1935 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1935 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1936 | 1936 | ||
1937 | KToolBar* tb = mMainWindow->toolBar(); | 1937 | KToolBar* tb = mMainWindow->toolBar(); |
1938 | 1938 | ||
1939 | #ifdef DESKTOP_VERSION | 1939 | #ifdef DESKTOP_VERSION |
1940 | QMenuBar* mb = mMainWindow->menuBar(); | 1940 | QMenuBar* mb = mMainWindow->menuBar(); |
1941 | 1941 | ||
1942 | //US setup menubar. | 1942 | //US setup menubar. |
1943 | //Disable the following block if you do not want to have a menubar. | 1943 | //Disable the following block if you do not want to have a menubar. |
1944 | mb->insertItem( "&File", fileMenu ); | 1944 | mb->insertItem( "&File", fileMenu ); |
1945 | mb->insertItem( "&Edit", editMenu ); | 1945 | mb->insertItem( "&Edit", editMenu ); |
1946 | mb->insertItem( "&View", viewMenu ); | 1946 | mb->insertItem( "&View", viewMenu ); |
1947 | mb->insertItem( "&Settings", settingsMenu ); | 1947 | mb->insertItem( "&Settings", settingsMenu ); |
1948 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1948 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1949 | mb->insertItem( "&Change selected", changeMenu ); | 1949 | mb->insertItem( "&Change selected", changeMenu ); |
1950 | mb->insertItem( "&Help", helpMenu ); | 1950 | mb->insertItem( "&Help", helpMenu ); |
1951 | mIncSearchWidget = new IncSearchWidget( tb ); | 1951 | mIncSearchWidget = new IncSearchWidget( tb ); |
1952 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1952 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1953 | 1953 | ||
1954 | #else | 1954 | #else |
1955 | //US setup toolbar | 1955 | //US setup toolbar |
1956 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1956 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1957 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1957 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1958 | menuBarTB->insertItem( "ME", popupBarTB); | 1958 | menuBarTB->insertItem( "ME", popupBarTB); |
1959 | tb->insertWidget(-1, 0, menuBarTB); | 1959 | tb->insertWidget(-1, 0, menuBarTB); |
1960 | mIncSearchWidget = new IncSearchWidget( tb ); | 1960 | mIncSearchWidget = new IncSearchWidget( tb ); |
1961 | 1961 | ||
1962 | tb->enableMoving(false); | 1962 | tb->enableMoving(false); |
1963 | popupBarTB->insertItem( "&File", fileMenu ); | 1963 | popupBarTB->insertItem( "&File", fileMenu ); |
1964 | popupBarTB->insertItem( "&Edit", editMenu ); | 1964 | popupBarTB->insertItem( "&Edit", editMenu ); |
1965 | popupBarTB->insertItem( "&View", viewMenu ); | 1965 | popupBarTB->insertItem( "&View", viewMenu ); |
1966 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1966 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1967 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1967 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1968 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1968 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1969 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1969 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1970 | popupBarTB->insertItem( "&Help", helpMenu ); | 1970 | popupBarTB->insertItem( "&Help", helpMenu ); |
1971 | if (QApplication::desktop()->width() > 320 ) { | 1971 | if (QApplication::desktop()->width() > 320 ) { |
1972 | // mViewManager->getFilterAction()->plug ( tb); | 1972 | // mViewManager->getFilterAction()->plug ( tb); |
1973 | } | 1973 | } |
1974 | #endif | 1974 | #endif |
1975 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1975 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1976 | 1976 | ||
1977 | 1977 | ||
1978 | 1978 | ||
1979 | //US Now connect the actions with the menue entries. | 1979 | //US Now connect the actions with the menue entries. |
1980 | mActionPrint->plug( fileMenu ); | 1980 | mActionPrint->plug( fileMenu ); |
1981 | mActionMail->plug( fileMenu ); | 1981 | mActionMail->plug( fileMenu ); |
1982 | fileMenu->insertSeparator(); | 1982 | fileMenu->insertSeparator(); |
1983 | 1983 | ||
1984 | mActionNewContact->plug( fileMenu ); | 1984 | mActionNewContact->plug( fileMenu ); |
1985 | mActionNewContact->plug( tb ); | 1985 | mActionNewContact->plug( tb ); |
1986 | 1986 | ||
1987 | mActionEditAddressee->plug( fileMenu ); | 1987 | mActionEditAddressee->plug( fileMenu ); |
1988 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1988 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1989 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1989 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1990 | mActionEditAddressee->plug( tb ); | 1990 | mActionEditAddressee->plug( tb ); |
1991 | 1991 | ||
1992 | fileMenu->insertSeparator(); | 1992 | fileMenu->insertSeparator(); |
1993 | mActionSave->plug( fileMenu ); | 1993 | mActionSave->plug( fileMenu ); |
1994 | fileMenu->insertItem( "&Import", ImportMenu ); | 1994 | fileMenu->insertItem( "&Import", ImportMenu ); |
1995 | fileMenu->insertItem( "&Export", ExportMenu ); | 1995 | fileMenu->insertItem( "&Export", ExportMenu ); |
1996 | fileMenu->insertSeparator(); | 1996 | fileMenu->insertSeparator(); |
1997 | mActionMailVCard->plug( fileMenu ); | 1997 | mActionMailVCard->plug( fileMenu ); |
1998 | #ifndef DESKTOP_VERSION | 1998 | #ifndef DESKTOP_VERSION |
1999 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1999 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
2000 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 2000 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
2001 | #endif | 2001 | #endif |
2002 | fileMenu->insertSeparator(); | 2002 | fileMenu->insertSeparator(); |
2003 | mActionQuit->plug( fileMenu ); | 2003 | mActionQuit->plug( fileMenu ); |
2004 | #ifdef _WIN32_ | 2004 | #ifdef _WIN32_ |
2005 | mActionImportOL->plug( ImportMenu ); | 2005 | mActionImportOL->plug( ImportMenu ); |
2006 | #endif | 2006 | #endif |
2007 | // edit menu | 2007 | // edit menu |
2008 | mActionUndo->plug( editMenu ); | 2008 | mActionUndo->plug( editMenu ); |
2009 | mActionRedo->plug( editMenu ); | 2009 | mActionRedo->plug( editMenu ); |
2010 | editMenu->insertSeparator(); | 2010 | editMenu->insertSeparator(); |
2011 | mActionCut->plug( editMenu ); | 2011 | mActionCut->plug( editMenu ); |
2012 | mActionCopy->plug( editMenu ); | 2012 | mActionCopy->plug( editMenu ); |
2013 | mActionPaste->plug( editMenu ); | 2013 | mActionPaste->plug( editMenu ); |
2014 | mActionDelete->plug( editMenu ); | 2014 | mActionDelete->plug( editMenu ); |
2015 | editMenu->insertSeparator(); | 2015 | editMenu->insertSeparator(); |
2016 | mActionSelectAll->plug( editMenu ); | 2016 | mActionSelectAll->plug( editMenu ); |
2017 | 2017 | ||
2018 | mActionRemoveVoice->plug( changeMenu ); | 2018 | mActionRemoveVoice->plug( changeMenu ); |
2019 | // settings menu | 2019 | // settings menu |
2020 | //US special menuentry to configure the addressbook resources. On KDE | 2020 | //US special menuentry to configure the addressbook resources. On KDE |
2021 | // you do that through the control center !!! | 2021 | // you do that through the control center !!! |
2022 | mActionConfigResources->plug( settingsMenu ); | 2022 | mActionConfigResources->plug( settingsMenu ); |
2023 | settingsMenu->insertSeparator(); | 2023 | settingsMenu->insertSeparator(); |
2024 | 2024 | ||
2025 | mActionConfigKAddressbook->plug( settingsMenu ); | 2025 | mActionConfigKAddressbook->plug( settingsMenu ); |
2026 | 2026 | ||
2027 | if ( mIsPart ) { | 2027 | if ( mIsPart ) { |
2028 | mActionConfigShortcuts->plug( settingsMenu ); | 2028 | mActionConfigShortcuts->plug( settingsMenu ); |
2029 | mActionConfigureToolbars->plug( settingsMenu ); | 2029 | mActionConfigureToolbars->plug( settingsMenu ); |
2030 | 2030 | ||
2031 | } else { | 2031 | } else { |
2032 | mActionKeyBindings->plug( settingsMenu ); | 2032 | mActionKeyBindings->plug( settingsMenu ); |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | settingsMenu->insertSeparator(); | 2035 | settingsMenu->insertSeparator(); |
2036 | 2036 | ||
2037 | mActionJumpBar->plug( settingsMenu ); | 2037 | mActionJumpBar->plug( settingsMenu ); |
2038 | mActionDetails->plug( settingsMenu ); | 2038 | mActionDetails->plug( settingsMenu ); |
2039 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 2039 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
2040 | mActionDetails->plug( tb ); | 2040 | mActionDetails->plug( tb ); |
2041 | settingsMenu->insertSeparator(); | 2041 | settingsMenu->insertSeparator(); |
2042 | 2042 | ||
2043 | mActionWhoAmI->plug( settingsMenu ); | 2043 | mActionWhoAmI->plug( settingsMenu ); |
2044 | mActionCategories->plug( settingsMenu ); | 2044 | mActionCategories->plug( settingsMenu ); |
2045 | 2045 | ||
2046 | mActionLicence->plug( helpMenu ); | 2046 | mActionLicence->plug( helpMenu ); |
2047 | mActionFaq->plug( helpMenu ); | 2047 | mActionFaq->plug( helpMenu ); |
2048 | mActionAboutKAddressbook->plug( helpMenu ); | 2048 | mActionAboutKAddressbook->plug( helpMenu ); |
2049 | 2049 | ||
2050 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 2050 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
2051 | 2051 | ||
2052 | mActionSave->plug( tb ); | 2052 | mActionSave->plug( tb ); |
2053 | mViewManager->getFilterAction()->plug ( tb); | 2053 | mViewManager->getFilterAction()->plug ( tb); |
2054 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 2054 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
2055 | mActionUndo->plug( tb ); | 2055 | mActionUndo->plug( tb ); |
2056 | mActionDelete->plug( tb ); | 2056 | mActionDelete->plug( tb ); |
2057 | mActionRedo->plug( tb ); | 2057 | mActionRedo->plug( tb ); |
2058 | } | 2058 | } |
2059 | } | 2059 | } |
2060 | //mActionQuit->plug ( tb ); | 2060 | //mActionQuit->plug ( tb ); |
2061 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 2061 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
2062 | 2062 | ||
2063 | //US link the searchwidget first to this. | 2063 | //US link the searchwidget first to this. |
2064 | // The real linkage to the toolbar happens later. | 2064 | // The real linkage to the toolbar happens later. |
2065 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 2065 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
2066 | //US tb->insertItem( mIncSearchWidget ); | 2066 | //US tb->insertItem( mIncSearchWidget ); |
2067 | /*US | 2067 | /*US |
2068 | mIncSearchWidget = new IncSearchWidget( tb ); | 2068 | mIncSearchWidget = new IncSearchWidget( tb ); |
2069 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 2069 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
2070 | SLOT( incrementalSearch( const QString& ) ) ); | 2070 | SLOT( incrementalSearch( const QString& ) ) ); |
2071 | 2071 | ||
2072 | mJumpButtonBar = new JumpButtonBar( this, this ); | 2072 | mJumpButtonBar = new JumpButtonBar( this, this ); |
2073 | 2073 | ||
2074 | //US topLayout->addWidget( mJumpButtonBar ); | 2074 | //US topLayout->addWidget( mJumpButtonBar ); |
2075 | this->layout()->add( mJumpButtonBar ); | 2075 | this->layout()->add( mJumpButtonBar ); |
2076 | */ | 2076 | */ |
2077 | 2077 | ||
2078 | #endif //KAB_EMBEDDED | 2078 | #endif //KAB_EMBEDDED |
2079 | 2079 | ||
2080 | mActionExport2phone->plug( ExportMenu ); | 2080 | mActionExport2phone->plug( ExportMenu ); |
2081 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); | 2081 | connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); |
2082 | syncManager->fillSyncMenu(); | 2082 | syncManager->fillSyncMenu(); |
2083 | 2083 | ||
2084 | } | 2084 | } |
2085 | void KABCore::showLicence() | 2085 | void KABCore::showLicence() |
2086 | { | 2086 | { |
2087 | KApplication::showLicence(); | 2087 | KApplication::showLicence(); |
2088 | } | 2088 | } |
2089 | void KABCore::removeVoice() | 2089 | void KABCore::removeVoice() |
2090 | { | 2090 | { |
2091 | 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 ) | 2091 | 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 ) |
2092 | return; | 2092 | return; |
2093 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 2093 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
2094 | KABC::Addressee::List::Iterator it; | 2094 | KABC::Addressee::List::Iterator it; |
2095 | for ( it = list.begin(); it != list.end(); ++it ) { | 2095 | for ( it = list.begin(); it != list.end(); ++it ) { |
2096 | 2096 | ||
2097 | if ( (*it).removeVoice() ) | 2097 | if ( (*it).removeVoice() ) |
2098 | contactModified((*it) ); | 2098 | contactModified((*it) ); |
2099 | } | 2099 | } |
2100 | } | 2100 | } |
2101 | 2101 | ||
2102 | 2102 | ||
2103 | 2103 | ||
2104 | void KABCore::clipboardDataChanged() | 2104 | void KABCore::clipboardDataChanged() |
2105 | { | 2105 | { |
2106 | 2106 | ||
2107 | if ( mReadWrite ) | 2107 | if ( mReadWrite ) |
2108 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 2108 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
2109 | 2109 | ||
2110 | } | 2110 | } |
2111 | 2111 | ||
2112 | void KABCore::updateActionMenu() | 2112 | void KABCore::updateActionMenu() |
2113 | { | 2113 | { |
2114 | UndoStack *undo = UndoStack::instance(); | 2114 | UndoStack *undo = UndoStack::instance(); |
2115 | RedoStack *redo = RedoStack::instance(); | 2115 | RedoStack *redo = RedoStack::instance(); |
2116 | 2116 | ||
2117 | if ( undo->isEmpty() ) | 2117 | if ( undo->isEmpty() ) |
2118 | mActionUndo->setText( i18n( "Undo" ) ); | 2118 | mActionUndo->setText( i18n( "Undo" ) ); |
2119 | else | 2119 | else |
2120 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 2120 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
2121 | 2121 | ||
2122 | mActionUndo->setEnabled( !undo->isEmpty() ); | 2122 | mActionUndo->setEnabled( !undo->isEmpty() ); |
2123 | 2123 | ||
2124 | if ( !redo->top() ) | 2124 | if ( !redo->top() ) |
2125 | mActionRedo->setText( i18n( "Redo" ) ); | 2125 | mActionRedo->setText( i18n( "Redo" ) ); |
2126 | else | 2126 | else |
2127 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 2127 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
2128 | 2128 | ||
2129 | mActionRedo->setEnabled( !redo->isEmpty() ); | 2129 | mActionRedo->setEnabled( !redo->isEmpty() ); |
2130 | } | 2130 | } |
2131 | 2131 | ||
2132 | void KABCore::configureKeyBindings() | 2132 | void KABCore::configureKeyBindings() |
2133 | { | 2133 | { |
2134 | #ifndef KAB_EMBEDDED | 2134 | #ifndef KAB_EMBEDDED |
2135 | KKeyDialog::configure( actionCollection(), true ); | 2135 | KKeyDialog::configure( actionCollection(), true ); |
2136 | #else //KAB_EMBEDDED | 2136 | #else //KAB_EMBEDDED |
2137 | qDebug("KABCore::configureKeyBindings() not implemented"); | 2137 | qDebug("KABCore::configureKeyBindings() not implemented"); |
2138 | #endif //KAB_EMBEDDED | 2138 | #endif //KAB_EMBEDDED |
2139 | } | 2139 | } |
2140 | 2140 | ||
2141 | #ifdef KAB_EMBEDDED | 2141 | #ifdef KAB_EMBEDDED |
2142 | void KABCore::configureResources() | 2142 | void KABCore::configureResources() |
2143 | { | 2143 | { |
2144 | KRES::KCMKResources dlg( this, "" , 0 ); | 2144 | KRES::KCMKResources dlg( this, "" , 0 ); |
2145 | 2145 | ||
2146 | if ( !dlg.exec() ) | 2146 | if ( !dlg.exec() ) |
2147 | return; | 2147 | return; |
2148 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 2148 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
2149 | } | 2149 | } |
2150 | #endif //KAB_EMBEDDED | 2150 | #endif //KAB_EMBEDDED |
2151 | 2151 | ||
2152 | 2152 | ||
2153 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 2153 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
2154 | * for the attendees list of an event. | 2154 | * for the attendees list of an event. |
2155 | */ | 2155 | */ |
2156 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 2156 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
2157 | { | 2157 | { |
2158 | QStringList nameList; | 2158 | QStringList nameList; |
2159 | QStringList emailList; | 2159 | QStringList emailList; |
2160 | QStringList uidList; | 2160 | QStringList uidList; |
2161 | 2161 | ||
2162 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 2162 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
2163 | uint i=0; | 2163 | uint i=0; |
2164 | for (i=0; i < list.count(); i++) | 2164 | for (i=0; i < list.count(); i++) |
2165 | { | 2165 | { |
2166 | nameList.append(list[i].realName()); | 2166 | nameList.append(list[i].realName()); |
2167 | emailList.append(list[i].preferredEmail()); | 2167 | emailList.append(list[i].preferredEmail()); |
2168 | uidList.append(list[i].uid()); | 2168 | uidList.append(list[i].uid()); |
2169 | } | 2169 | } |
2170 | 2170 | ||
2171 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2171 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2172 | 2172 | ||
2173 | } | 2173 | } |
2174 | 2174 | ||
2175 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays | 2175 | /* this method will be called through the QCop interface from Ko/Pi to select birthdays |
2176 | * to put them into the calendar. | 2176 | * to put them into the calendar. |
2177 | */ | 2177 | */ |
2178 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) | 2178 | void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) |
2179 | { | 2179 | { |
2180 | // qDebug("KABCore::requestForBirthdayList"); | 2180 | // qDebug("KABCore::requestForBirthdayList"); |
2181 | QStringList birthdayList; | 2181 | QStringList birthdayList; |
2182 | QStringList anniversaryList; | 2182 | QStringList anniversaryList; |
2183 | QStringList realNameList; | 2183 | QStringList realNameList; |
2184 | QStringList preferredEmailList; | 2184 | QStringList preferredEmailList; |
2185 | QStringList assembledNameList; | 2185 | QStringList assembledNameList; |
2186 | QStringList uidList; | 2186 | QStringList uidList; |
2187 | 2187 | ||
2188 | KABC::AddressBook::Iterator it; | 2188 | KABC::AddressBook::Iterator it; |
2189 | 2189 | ||
2190 | int count = 0; | 2190 | int count = 0; |
2191 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 2191 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
2192 | ++count; | 2192 | ++count; |
2193 | } | 2193 | } |
2194 | QProgressBar bar(count,0 ); | 2194 | QProgressBar bar(count,0 ); |
2195 | int w = 300; | 2195 | int w = 300; |
2196 | if ( QApplication::desktop()->width() < 320 ) | 2196 | if ( QApplication::desktop()->width() < 320 ) |
2197 | w = 220; | 2197 | w = 220; |
2198 | int h = bar.sizeHint().height() ; | 2198 | int h = bar.sizeHint().height() ; |
2199 | int dw = QApplication::desktop()->width(); | 2199 | int dw = QApplication::desktop()->width(); |
2200 | int dh = QApplication::desktop()->height(); | 2200 | int dh = QApplication::desktop()->height(); |
2201 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2201 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2202 | bar.show(); | 2202 | bar.show(); |
2203 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); | 2203 | bar.setCaption (i18n("collecting birthdays - close to abort!") ); |
2204 | qApp->processEvents(); | 2204 | qApp->processEvents(); |
2205 | 2205 | ||
2206 | QDate bday; | 2206 | QDate bday; |
2207 | QString anni; | 2207 | QString anni; |
2208 | QString formattedbday; | 2208 | QString formattedbday; |
2209 | 2209 | ||
2210 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) | 2210 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) |
2211 | { | 2211 | { |
2212 | if ( ! bar.isVisible() ) | 2212 | if ( ! bar.isVisible() ) |
2213 | return; | 2213 | return; |
2214 | bar.setProgress( count++ ); | 2214 | bar.setProgress( count++ ); |
2215 | qApp->processEvents(); | 2215 | qApp->processEvents(); |
2216 | bday = (*it).birthday().date(); | 2216 | bday = (*it).birthday().date(); |
2217 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); | 2217 | anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); |
2218 | 2218 | ||
2219 | if ( bday.isValid() || !anni.isEmpty()) | 2219 | if ( bday.isValid() || !anni.isEmpty()) |
2220 | { | 2220 | { |
2221 | if (bday.isValid()) | 2221 | if (bday.isValid()) |
2222 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); | 2222 | formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); |
2223 | else | 2223 | else |
2224 | formattedbday = "NOTVALID"; | 2224 | formattedbday = "NOTVALID"; |
2225 | if (anni.isEmpty()) | 2225 | if (anni.isEmpty()) |
2226 | anni = "INVALID"; | 2226 | anni = "INVALID"; |
2227 | 2227 | ||
2228 | birthdayList.append(formattedbday); | 2228 | birthdayList.append(formattedbday); |
2229 | anniversaryList.append(anni); //should be ISODate | 2229 | anniversaryList.append(anni); //should be ISODate |
2230 | realNameList.append((*it).realName()); | 2230 | realNameList.append((*it).realName()); |
2231 | preferredEmailList.append((*it).preferredEmail()); | 2231 | preferredEmailList.append((*it).preferredEmail()); |
2232 | assembledNameList.append((*it).assembledName()); | 2232 | assembledNameList.append((*it).assembledName()); |
2233 | uidList.append((*it).uid()); | 2233 | uidList.append((*it).uid()); |
2234 | 2234 | ||
2235 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); | 2235 | qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); |
2236 | } | 2236 | } |
2237 | } | 2237 | } |
2238 | 2238 | ||
2239 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); | 2239 | bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); |
2240 | 2240 | ||
2241 | } | 2241 | } |
2242 | 2242 | ||
2243 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2243 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2244 | */ | 2244 | */ |
2245 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2245 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2246 | { | 2246 | { |
2247 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2247 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2248 | 2248 | ||
2249 | QString foundUid = QString::null; | 2249 | QString foundUid = QString::null; |
2250 | if ( ! uid.isEmpty() ) { | 2250 | if ( ! uid.isEmpty() ) { |
2251 | Addressee adrr = mAddressBook->findByUid( uid ); | 2251 | Addressee adrr = mAddressBook->findByUid( uid ); |
2252 | if ( !adrr.isEmpty() ) { | 2252 | if ( !adrr.isEmpty() ) { |
2253 | foundUid = uid; | 2253 | foundUid = uid; |
2254 | } | 2254 | } |
2255 | if ( email == "sendbacklist" ) { | 2255 | if ( email == "sendbacklist" ) { |
2256 | //qDebug("ssssssssssssssssssssssend "); | 2256 | //qDebug("ssssssssssssssssssssssend "); |
2257 | QStringList nameList; | 2257 | QStringList nameList; |
2258 | QStringList emailList; | 2258 | QStringList emailList; |
2259 | QStringList uidList; | 2259 | QStringList uidList; |
2260 | nameList.append(adrr.realName()); | 2260 | nameList.append(adrr.realName()); |
2261 | emailList = adrr.emails(); | 2261 | emailList = adrr.emails(); |
2262 | uidList.append( adrr.preferredEmail()); | 2262 | uidList.append( adrr.preferredEmail()); |
2263 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2263 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2264 | return; | 2264 | return; |
2265 | } | 2265 | } |
2266 | 2266 | ||
2267 | } | 2267 | } |
2268 | 2268 | ||
2269 | if ( email == "sendbacklist" ) | 2269 | if ( email == "sendbacklist" ) |
2270 | return; | 2270 | return; |
2271 | if (foundUid.isEmpty()) | 2271 | if (foundUid.isEmpty()) |
2272 | { | 2272 | { |
2273 | //find the uid of the person first | 2273 | //find the uid of the person first |
2274 | Addressee::List namelist; | 2274 | Addressee::List namelist; |
2275 | Addressee::List emaillist; | 2275 | Addressee::List emaillist; |
2276 | 2276 | ||
2277 | if (!name.isEmpty()) | 2277 | if (!name.isEmpty()) |
2278 | namelist = mAddressBook->findByName( name ); | 2278 | namelist = mAddressBook->findByName( name ); |
2279 | 2279 | ||
2280 | if (!email.isEmpty()) | 2280 | if (!email.isEmpty()) |
2281 | emaillist = mAddressBook->findByEmail( email ); | 2281 | emaillist = mAddressBook->findByEmail( email ); |
2282 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2282 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2283 | //check if we have a match in Namelist and Emaillist | 2283 | //check if we have a match in Namelist and Emaillist |
2284 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2284 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2285 | foundUid = emaillist[0].uid(); | 2285 | foundUid = emaillist[0].uid(); |
2286 | } | 2286 | } |
2287 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2287 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2288 | foundUid = namelist[0].uid(); | 2288 | foundUid = namelist[0].uid(); |
2289 | else | 2289 | else |
2290 | { | 2290 | { |
2291 | for (int i = 0; i < namelist.count(); i++) | 2291 | for (int i = 0; i < namelist.count(); i++) |
2292 | { | 2292 | { |
2293 | for (int j = 0; j < emaillist.count(); j++) | 2293 | for (int j = 0; j < emaillist.count(); j++) |
2294 | { | 2294 | { |
2295 | if (namelist[i] == emaillist[j]) | 2295 | if (namelist[i] == emaillist[j]) |
2296 | { | 2296 | { |
2297 | foundUid = namelist[i].uid(); | 2297 | foundUid = namelist[i].uid(); |
2298 | } | 2298 | } |
2299 | } | 2299 | } |
2300 | } | 2300 | } |
2301 | } | 2301 | } |
2302 | } | 2302 | } |
2303 | else | 2303 | else |
2304 | { | 2304 | { |
2305 | foundUid = uid; | 2305 | foundUid = uid; |
2306 | } | 2306 | } |
2307 | 2307 | ||
2308 | if (!foundUid.isEmpty()) | 2308 | if (!foundUid.isEmpty()) |
2309 | { | 2309 | { |
2310 | 2310 | ||
2311 | // raise Ka/Pi if it is in the background | 2311 | // raise Ka/Pi if it is in the background |
2312 | #ifndef DESKTOP_VERSION | 2312 | #ifndef DESKTOP_VERSION |
2313 | #ifndef KORG_NODCOP | 2313 | #ifndef KORG_NODCOP |
2314 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2314 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2315 | #endif | 2315 | #endif |
2316 | #endif | 2316 | #endif |
2317 | 2317 | ||
2318 | mMainWindow->showMaximized(); | 2318 | mMainWindow->showMaximized(); |
2319 | mMainWindow-> raise(); | 2319 | mMainWindow-> raise(); |
2320 | 2320 | ||
2321 | mViewManager->setSelected( "", false); | 2321 | mViewManager->setSelected( "", false); |
2322 | mViewManager->refreshView( "" ); | 2322 | mViewManager->refreshView( "" ); |
2323 | mViewManager->setSelected( foundUid, true ); | 2323 | mViewManager->setSelected( foundUid, true ); |
2324 | mViewManager->refreshView( foundUid ); | 2324 | mViewManager->refreshView( foundUid ); |
2325 | 2325 | ||
2326 | if ( !mMultipleViewsAtOnce ) | 2326 | if ( !mMultipleViewsAtOnce ) |
2327 | { | 2327 | { |
2328 | setDetailsVisible( true ); | 2328 | setDetailsVisible( true ); |
2329 | mActionDetails->setChecked(true); | 2329 | mActionDetails->setChecked(true); |
2330 | } | 2330 | } |
2331 | } | 2331 | } |
2332 | } | 2332 | } |
2333 | 2333 | ||
2334 | 2334 | ||
2335 | void KABCore::faq() | 2335 | void KABCore::faq() |
2336 | { | 2336 | { |
2337 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2337 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2338 | } | 2338 | } |
2339 | 2339 | ||
2340 | #include <libkcal/syncdefines.h> | 2340 | #include <libkcal/syncdefines.h> |
2341 | 2341 | ||
2342 | KABC::Addressee KABCore::getLastSyncAddressee() | 2342 | KABC::Addressee KABCore::getLastSyncAddressee() |
2343 | { | 2343 | { |
2344 | Addressee lse; | 2344 | Addressee lse; |
2345 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2345 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2346 | 2346 | ||
2347 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 2347 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
2348 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2348 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2349 | if (lse.isEmpty()) { | 2349 | if (lse.isEmpty()) { |
2350 | qDebug("Creating new last-syncAddressee "); | 2350 | qDebug("Creating new last-syncAddressee "); |
2351 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2351 | lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2352 | QString sum = ""; | 2352 | QString sum = ""; |
2353 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2353 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2354 | sum = "E: "; | 2354 | sum = "E: "; |
2355 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); | 2355 | lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); |
2356 | lse.setRevision( mLastAddressbookSync ); | 2356 | lse.setRevision( mLastAddressbookSync ); |
2357 | lse.setCategories( i18n("SyncEvent") ); | 2357 | lse.setCategories( i18n("SyncEvent") ); |
2358 | mAddressBook->insertAddressee( lse ); | 2358 | mAddressBook->insertAddressee( lse ); |
2359 | } | 2359 | } |
2360 | return lse; | 2360 | return lse; |
2361 | } | 2361 | } |
2362 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) | 2362 | int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) |
2363 | { | 2363 | { |
2364 | 2364 | ||
2365 | //void setZaurusId(int id); | 2365 | //void setZaurusId(int id); |
2366 | // int zaurusId() const; | 2366 | // int zaurusId() const; |
2367 | // void setZaurusUid(int id); | 2367 | // void setZaurusUid(int id); |
2368 | // int zaurusUid() const; | 2368 | // int zaurusUid() const; |
2369 | // void setZaurusStat(int id); | 2369 | // void setZaurusStat(int id); |
2370 | // int zaurusStat() const; | 2370 | // int zaurusStat() const; |
2371 | // 0 equal | 2371 | // 0 equal |
2372 | // 1 take local | 2372 | // 1 take local |
2373 | // 2 take remote | 2373 | // 2 take remote |
2374 | // 3 cancel | 2374 | // 3 cancel |
2375 | QDateTime lastSync = mLastAddressbookSync; | 2375 | QDateTime lastSync = mLastAddressbookSync; |
2376 | QDateTime localMod = local->revision(); | 2376 | QDateTime localMod = local->revision(); |
2377 | QDateTime remoteMod = remote->revision(); | 2377 | QDateTime remoteMod = remote->revision(); |
2378 | 2378 | ||
2379 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2379 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2380 | 2380 | ||
2381 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2381 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2382 | bool remCh, locCh; | 2382 | bool remCh, locCh; |
2383 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 2383 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
2384 | 2384 | ||
2385 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 2385 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
2386 | locCh = ( localMod > mLastAddressbookSync ); | 2386 | locCh = ( localMod > mLastAddressbookSync ); |
2387 | if ( !remCh && ! locCh ) { | 2387 | if ( !remCh && ! locCh ) { |
2388 | //qDebug("both not changed "); | 2388 | //qDebug("both not changed "); |
2389 | lastSync = localMod.addDays(1); | 2389 | lastSync = localMod.addDays(1); |
2390 | if ( mode <= SYNC_PREF_ASK ) | 2390 | if ( mode <= SYNC_PREF_ASK ) |
2391 | return 0; | 2391 | return 0; |
2392 | } else { | 2392 | } else { |
2393 | if ( locCh ) { | 2393 | if ( locCh ) { |
2394 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); | 2394 | //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); |
2395 | lastSync = localMod.addDays( -1 ); | 2395 | lastSync = localMod.addDays( -1 ); |
2396 | if ( !remCh ) | 2396 | if ( !remCh ) |
2397 | remoteMod =( lastSync.addDays( -1 ) ); | 2397 | remoteMod =( lastSync.addDays( -1 ) ); |
2398 | } else { | 2398 | } else { |
2399 | //qDebug(" not loc changed "); | 2399 | //qDebug(" not loc changed "); |
2400 | lastSync = localMod.addDays( 1 ); | 2400 | lastSync = localMod.addDays( 1 ); |
2401 | if ( remCh ) | 2401 | if ( remCh ) |
2402 | remoteMod =( lastSync.addDays( 1 ) ); | 2402 | remoteMod =( lastSync.addDays( 1 ) ); |
2403 | 2403 | ||
2404 | } | 2404 | } |
2405 | } | 2405 | } |
2406 | full = true; | 2406 | full = true; |
2407 | if ( mode < SYNC_PREF_ASK ) | 2407 | if ( mode < SYNC_PREF_ASK ) |
2408 | mode = SYNC_PREF_ASK; | 2408 | mode = SYNC_PREF_ASK; |
2409 | } else { | 2409 | } else { |
2410 | if ( localMod == remoteMod ) | 2410 | if ( localMod == remoteMod ) |
2411 | return 0; | 2411 | return 0; |
2412 | 2412 | ||
2413 | } | 2413 | } |
2414 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 2414 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
2415 | 2415 | ||
2416 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); | 2416 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); |
2417 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 2417 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
2418 | //full = true; //debug only | 2418 | //full = true; //debug only |
2419 | if ( full ) { | 2419 | if ( full ) { |
2420 | bool equ = ( (*local) == (*remote) ); | 2420 | bool equ = ( (*local) == (*remote) ); |
2421 | if ( equ ) { | 2421 | if ( equ ) { |
2422 | //qDebug("equal "); | 2422 | //qDebug("equal "); |
2423 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2423 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2424 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 2424 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
2425 | } | 2425 | } |
2426 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 2426 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
2427 | return 0; | 2427 | return 0; |
2428 | 2428 | ||
2429 | }//else //debug only | 2429 | }//else //debug only |
2430 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 2430 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
2431 | } | 2431 | } |
2432 | int result; | 2432 | int result; |
2433 | bool localIsNew; | 2433 | bool localIsNew; |
2434 | //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() ); | 2434 | //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() ); |
2435 | 2435 | ||
2436 | if ( full && mode < SYNC_PREF_NEWEST ) | 2436 | if ( full && mode < SYNC_PREF_NEWEST ) |
2437 | mode = SYNC_PREF_ASK; | 2437 | mode = SYNC_PREF_ASK; |
2438 | 2438 | ||
2439 | switch( mode ) { | 2439 | switch( mode ) { |
2440 | case SYNC_PREF_LOCAL: | 2440 | case SYNC_PREF_LOCAL: |
2441 | if ( lastSync > remoteMod ) | 2441 | if ( lastSync > remoteMod ) |
2442 | return 1; | 2442 | return 1; |
2443 | if ( lastSync > localMod ) | 2443 | if ( lastSync > localMod ) |
2444 | return 2; | 2444 | return 2; |
2445 | return 1; | 2445 | return 1; |
2446 | break; | 2446 | break; |
2447 | case SYNC_PREF_REMOTE: | 2447 | case SYNC_PREF_REMOTE: |
2448 | if ( lastSync > remoteMod ) | 2448 | if ( lastSync > remoteMod ) |
2449 | return 1; | 2449 | return 1; |
2450 | if ( lastSync > localMod ) | 2450 | if ( lastSync > localMod ) |
2451 | return 2; | 2451 | return 2; |
2452 | return 2; | 2452 | return 2; |
2453 | break; | 2453 | break; |
2454 | case SYNC_PREF_NEWEST: | 2454 | case SYNC_PREF_NEWEST: |
2455 | if ( localMod > remoteMod ) | 2455 | if ( localMod > remoteMod ) |
2456 | return 1; | 2456 | return 1; |
2457 | else | 2457 | else |
2458 | return 2; | 2458 | return 2; |
2459 | break; | 2459 | break; |
2460 | case SYNC_PREF_ASK: | 2460 | case SYNC_PREF_ASK: |
2461 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 2461 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
2462 | if ( lastSync > remoteMod ) | 2462 | if ( lastSync > remoteMod ) |
2463 | return 1; | 2463 | return 1; |
2464 | if ( lastSync > localMod ) | 2464 | if ( lastSync > localMod ) |
2465 | return 2; | 2465 | return 2; |
2466 | localIsNew = localMod >= remoteMod; | 2466 | localIsNew = localMod >= remoteMod; |
2467 | //qDebug("conflict! ************************************** "); | 2467 | //qDebug("conflict! ************************************** "); |
2468 | { | 2468 | { |
2469 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); | 2469 | KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); |
2470 | result = acd.executeD(localIsNew); | 2470 | result = acd.executeD(localIsNew); |
2471 | return result; | 2471 | return result; |
2472 | } | 2472 | } |
2473 | break; | 2473 | break; |
2474 | case SYNC_PREF_FORCE_LOCAL: | 2474 | case SYNC_PREF_FORCE_LOCAL: |
2475 | return 1; | 2475 | return 1; |
2476 | break; | 2476 | break; |
2477 | case SYNC_PREF_FORCE_REMOTE: | 2477 | case SYNC_PREF_FORCE_REMOTE: |
2478 | return 2; | 2478 | return 2; |
2479 | break; | 2479 | break; |
2480 | 2480 | ||
2481 | default: | 2481 | default: |
2482 | // SYNC_PREF_TAKE_BOTH not implemented | 2482 | // SYNC_PREF_TAKE_BOTH not implemented |
2483 | break; | 2483 | break; |
2484 | } | 2484 | } |
2485 | return 0; | 2485 | return 0; |
2486 | } | 2486 | } |
2487 | 2487 | ||
2488 | 2488 | ||
2489 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2489 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2490 | { | 2490 | { |
2491 | bool syncOK = true; | 2491 | bool syncOK = true; |
2492 | int addedAddressee = 0; | 2492 | int addedAddressee = 0; |
2493 | int addedAddresseeR = 0; | 2493 | int addedAddresseeR = 0; |
2494 | int deletedAddresseeR = 0; | 2494 | int deletedAddresseeR = 0; |
2495 | int deletedAddresseeL = 0; | 2495 | int deletedAddresseeL = 0; |
2496 | int changedLocal = 0; | 2496 | int changedLocal = 0; |
2497 | int changedRemote = 0; | 2497 | int changedRemote = 0; |
2498 | 2498 | ||
2499 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); | 2499 | QString mCurrentSyncName = syncManager->getCurrentSyncName(); |
2500 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2500 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2501 | 2501 | ||
2502 | //QPtrList<Addressee> el = local->rawAddressees(); | 2502 | //QPtrList<Addressee> el = local->rawAddressees(); |
2503 | Addressee addresseeR; | 2503 | Addressee addresseeR; |
2504 | QString uid; | 2504 | QString uid; |
2505 | int take; | 2505 | int take; |
2506 | Addressee addresseeL; | 2506 | Addressee addresseeL; |
2507 | Addressee addresseeRSync; | 2507 | Addressee addresseeRSync; |
2508 | Addressee addresseeLSync; | 2508 | Addressee addresseeLSync; |
2509 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2509 | // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2510 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2510 | //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2511 | bool fullDateRange = false; | 2511 | bool fullDateRange = false; |
2512 | local->resetTempSyncStat(); | 2512 | local->resetTempSyncStat(); |
2513 | mLastAddressbookSync = QDateTime::currentDateTime(); | 2513 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2514 | QDateTime modifiedCalendar = mLastAddressbookSync;; | 2514 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2515 | addresseeLSync = getLastSyncAddressee(); | 2515 | addresseeLSync = getLastSyncAddressee(); |
2516 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2516 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2517 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2517 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2518 | if ( !addresseeR.isEmpty() ) { | 2518 | if ( !addresseeR.isEmpty() ) { |
2519 | addresseeRSync = addresseeR; | 2519 | addresseeRSync = addresseeR; |
2520 | remote->removeAddressee(addresseeR ); | 2520 | remote->removeAddressee(addresseeR ); |
2521 | 2521 | ||
2522 | } else { | 2522 | } else { |
2523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2524 | addresseeRSync = addresseeLSync ; | 2524 | addresseeRSync = addresseeLSync ; |
2525 | } else { | 2525 | } else { |
2526 | qDebug("FULLDATE 1"); | 2526 | qDebug("FULLDATE 1"); |
2527 | fullDateRange = true; | 2527 | fullDateRange = true; |
2528 | Addressee newAdd; | 2528 | Addressee newAdd; |
2529 | addresseeRSync = newAdd; | 2529 | addresseeRSync = newAdd; |
2530 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2530 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2531 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2531 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2532 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2532 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2533 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2533 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2534 | } | 2534 | } |
2535 | } | 2535 | } |
2536 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2536 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2537 | qDebug("FULLDATE 2"); | 2537 | qDebug("FULLDATE 2"); |
2538 | fullDateRange = true; | 2538 | fullDateRange = true; |
2539 | } | 2539 | } |
2540 | if ( ! fullDateRange ) { | 2540 | if ( ! fullDateRange ) { |
2541 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2541 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2542 | 2542 | ||
2543 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2543 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2544 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2544 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2545 | fullDateRange = true; | 2545 | fullDateRange = true; |
2546 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2546 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2547 | } | 2547 | } |
2548 | } | 2548 | } |
2549 | // fullDateRange = true; // debug only! | 2549 | // fullDateRange = true; // debug only! |
2550 | if ( fullDateRange ) | 2550 | if ( fullDateRange ) |
2551 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2551 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2552 | else | 2552 | else |
2553 | mLastAddressbookSync = addresseeLSync.revision(); | 2553 | mLastAddressbookSync = addresseeLSync.revision(); |
2554 | // for resyncing if own file has changed | 2554 | // for resyncing if own file has changed |
2555 | // PENDING fixme later when implemented | 2555 | // PENDING fixme later when implemented |
2556 | #if 0 | 2556 | #if 0 |
2557 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2557 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2558 | mLastAddressbookSync = loadedFileVersion; | 2558 | mLastAddressbookSync = loadedFileVersion; |
2559 | qDebug("setting mLastAddressbookSync "); | 2559 | qDebug("setting mLastAddressbookSync "); |
2560 | } | 2560 | } |
2561 | #endif | 2561 | #endif |
2562 | 2562 | ||
2563 | //qDebug("*************************** "); | 2563 | //qDebug("*************************** "); |
2564 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2564 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2565 | QStringList er = remote->uidList(); | 2565 | QStringList er = remote->uidList(); |
2566 | Addressee inR ;//= er.first(); | 2566 | Addressee inR ;//= er.first(); |
2567 | Addressee inL; | 2567 | Addressee inL; |
2568 | 2568 | ||
2569 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2569 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2570 | 2570 | ||
2571 | int modulo = (er.count()/10)+1; | 2571 | int modulo = (er.count()/10)+1; |
2572 | int incCounter = 0; | 2572 | int incCounter = 0; |
2573 | while ( incCounter < er.count()) { | 2573 | while ( incCounter < er.count()) { |
2574 | if (syncManager->isProgressBarCanceled()) | 2574 | if (syncManager->isProgressBarCanceled()) |
2575 | return false; | 2575 | return false; |
2576 | if ( incCounter % modulo == 0 ) | 2576 | if ( incCounter % modulo == 0 ) |
2577 | syncManager->showProgressBar(incCounter); | 2577 | syncManager->showProgressBar(incCounter); |
2578 | 2578 | ||
2579 | uid = er[ incCounter ]; | 2579 | uid = er[ incCounter ]; |
2580 | bool skipIncidence = false; | 2580 | bool skipIncidence = false; |
2581 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2581 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2582 | skipIncidence = true; | 2582 | skipIncidence = true; |
2583 | QString idS,OidS; | 2583 | QString idS,OidS; |
2584 | qApp->processEvents(); | 2584 | qApp->processEvents(); |
2585 | if ( !skipIncidence ) { | 2585 | if ( !skipIncidence ) { |
2586 | inL = local->findByUid( uid ); | 2586 | inL = local->findByUid( uid ); |
2587 | inR = remote->findByUid( uid ); | 2587 | inR = remote->findByUid( uid ); |
2588 | //inL.setResource( 0 ); | 2588 | //inL.setResource( 0 ); |
2589 | //inR.setResource( 0 ); | 2589 | //inR.setResource( 0 ); |
2590 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2590 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2591 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2591 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2592 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2592 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2593 | if ( take == 3 ) | 2593 | if ( take == 3 ) |
2594 | return false; | 2594 | return false; |
2595 | if ( take == 1 ) {// take local | 2595 | if ( take == 1 ) {// take local |
2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2596 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2597 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2597 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2598 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2598 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2599 | local->insertAddressee( inL, false ); | 2599 | local->insertAddressee( inL, false ); |
2600 | idS = inR.externalUID(); | 2600 | idS = inR.externalUID(); |
2601 | OidS = inR.originalExternalUID(); | 2601 | OidS = inR.originalExternalUID(); |
2602 | } | 2602 | } |
2603 | else | 2603 | else |
2604 | idS = inR.IDStr(); | 2604 | idS = inR.IDStr(); |
2605 | remote->removeAddressee( inR ); | 2605 | remote->removeAddressee( inR ); |
2606 | inR = inL; | 2606 | inR = inL; |
2607 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2607 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2608 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2608 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2609 | inR.setOriginalExternalUID( OidS ); | 2609 | inR.setOriginalExternalUID( OidS ); |
2610 | inR.setExternalUID( idS ); | 2610 | inR.setExternalUID( idS ); |
2611 | } else { | 2611 | } else { |
2612 | inR.setIDStr( idS ); | 2612 | inR.setIDStr( idS ); |
2613 | } | 2613 | } |
2614 | inR.setResource( 0 ); | 2614 | inR.setResource( 0 ); |
2615 | remote->insertAddressee( inR , false); | 2615 | remote->insertAddressee( inR , false); |
2616 | ++changedRemote; | 2616 | ++changedRemote; |
2617 | } else { // take == 2 take remote | 2617 | } else { // take == 2 take remote |
2618 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2618 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2619 | if ( inR.revision().date().year() < 2004 ) | 2619 | if ( inR.revision().date().year() < 2004 ) |
2620 | inR.setRevision( modifiedCalendar ); | 2620 | inR.setRevision( modifiedCalendar ); |
2621 | } | 2621 | } |
2622 | idS = inL.IDStr(); | 2622 | idS = inL.IDStr(); |
2623 | local->removeAddressee( inL ); | 2623 | local->removeAddressee( inL ); |
2624 | inL = inR; | 2624 | inL = inR; |
2625 | inL.setIDStr( idS ); | 2625 | inL.setIDStr( idS ); |
2626 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2626 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2627 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2627 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2628 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2628 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2629 | } | 2629 | } |
2630 | inL.setResource( 0 ); | 2630 | inL.setResource( 0 ); |
2631 | local->insertAddressee( inL , false ); | 2631 | local->insertAddressee( inL , false ); |
2632 | ++changedLocal; | 2632 | ++changedLocal; |
2633 | } | 2633 | } |
2634 | } | 2634 | } |
2635 | } else { // no conflict | 2635 | } else { // no conflict |
2636 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2636 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2637 | QString des = addresseeLSync.note(); | 2637 | QString des = addresseeLSync.note(); |
2638 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2638 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2639 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2639 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2640 | remote->insertAddressee( inR, false ); | 2640 | remote->insertAddressee( inR, false ); |
2641 | ++deletedAddresseeR; | 2641 | ++deletedAddresseeR; |
2642 | } else { | 2642 | } else { |
2643 | inR.setRevision( modifiedCalendar ); | 2643 | inR.setRevision( modifiedCalendar ); |
2644 | remote->insertAddressee( inR, false ); | 2644 | remote->insertAddressee( inR, false ); |
2645 | inL = inR; | 2645 | inL = inR; |
2646 | inL.setResource( 0 ); | 2646 | inL.setResource( 0 ); |
2647 | local->insertAddressee( inL , false); | 2647 | local->insertAddressee( inL , false); |
2648 | ++addedAddressee; | 2648 | ++addedAddressee; |
2649 | } | 2649 | } |
2650 | } else { | 2650 | } else { |
2651 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2651 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2652 | inR.setRevision( modifiedCalendar ); | 2652 | inR.setRevision( modifiedCalendar ); |
2653 | remote->insertAddressee( inR, false ); | 2653 | remote->insertAddressee( inR, false ); |
2654 | inR.setResource( 0 ); | 2654 | inR.setResource( 0 ); |
2655 | local->insertAddressee( inR, false ); | 2655 | local->insertAddressee( inR, false ); |
2656 | ++addedAddressee; | 2656 | ++addedAddressee; |
2657 | } else { | 2657 | } else { |
2658 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2658 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2659 | remote->removeAddressee( inR ); | 2659 | remote->removeAddressee( inR ); |
2660 | ++deletedAddresseeR; | 2660 | ++deletedAddresseeR; |
2661 | } | 2661 | } |
2662 | } | 2662 | } |
2663 | } | 2663 | } |
2664 | } | 2664 | } |
2665 | ++incCounter; | 2665 | ++incCounter; |
2666 | } | 2666 | } |
2667 | er.clear(); | 2667 | er.clear(); |
2668 | QStringList el = local->uidList(); | 2668 | QStringList el = local->uidList(); |
2669 | modulo = (el.count()/10)+1; | 2669 | modulo = (el.count()/10)+1; |
2670 | 2670 | ||
2671 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2671 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2672 | incCounter = 0; | 2672 | incCounter = 0; |
2673 | while ( incCounter < el.count()) { | 2673 | while ( incCounter < el.count()) { |
2674 | qApp->processEvents(); | 2674 | qApp->processEvents(); |
2675 | if (syncManager->isProgressBarCanceled()) | 2675 | if (syncManager->isProgressBarCanceled()) |
2676 | return false; | 2676 | return false; |
2677 | if ( incCounter % modulo == 0 ) | 2677 | if ( incCounter % modulo == 0 ) |
2678 | syncManager->showProgressBar(incCounter); | 2678 | syncManager->showProgressBar(incCounter); |
2679 | uid = el[ incCounter ]; | 2679 | uid = el[ incCounter ]; |
2680 | bool skipIncidence = false; | 2680 | bool skipIncidence = false; |
2681 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2681 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2682 | skipIncidence = true; | 2682 | skipIncidence = true; |
2683 | if ( !skipIncidence ) { | 2683 | if ( !skipIncidence ) { |
2684 | inL = local->findByUid( uid ); | 2684 | inL = local->findByUid( uid ); |
2685 | inR = remote->findByUid( uid ); | 2685 | inR = remote->findByUid( uid ); |
2686 | if ( inR.isEmpty() ) { | 2686 | if ( inR.isEmpty() ) { |
2687 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2687 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2688 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2688 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2689 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2689 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2690 | local->removeAddressee( inL ); | 2690 | local->removeAddressee( inL ); |
2691 | ++deletedAddresseeL; | 2691 | ++deletedAddresseeL; |
2692 | } else { | 2692 | } else { |
2693 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2693 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2694 | inL.removeID(mCurrentSyncDevice ); | 2694 | inL.removeID(mCurrentSyncDevice ); |
2695 | ++addedAddresseeR; | 2695 | ++addedAddresseeR; |
2696 | inL.setRevision( modifiedCalendar ); | 2696 | inL.setRevision( modifiedCalendar ); |
2697 | local->insertAddressee( inL, false ); | 2697 | local->insertAddressee( inL, false ); |
2698 | inR = inL; | 2698 | inR = inL; |
2699 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2699 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2700 | inR.setResource( 0 ); | 2700 | inR.setResource( 0 ); |
2701 | remote->insertAddressee( inR, false ); | 2701 | remote->insertAddressee( inR, false ); |
2702 | } | 2702 | } |
2703 | } | 2703 | } |
2704 | } else { | 2704 | } else { |
2705 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2705 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2706 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2706 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2707 | local->removeAddressee( inL ); | 2707 | local->removeAddressee( inL ); |
2708 | ++deletedAddresseeL; | 2708 | ++deletedAddresseeL; |
2709 | } else { | 2709 | } else { |
2710 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2710 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2711 | ++addedAddresseeR; | 2711 | ++addedAddresseeR; |
2712 | inL.setRevision( modifiedCalendar ); | 2712 | inL.setRevision( modifiedCalendar ); |
2713 | local->insertAddressee( inL, false ); | 2713 | local->insertAddressee( inL, false ); |
2714 | inR = inL; | 2714 | inR = inL; |
2715 | inR.setResource( 0 ); | 2715 | inR.setResource( 0 ); |
2716 | remote->insertAddressee( inR, false ); | 2716 | remote->insertAddressee( inR, false ); |
2717 | } | 2717 | } |
2718 | } | 2718 | } |
2719 | } | 2719 | } |
2720 | } | 2720 | } |
2721 | } | 2721 | } |
2722 | ++incCounter; | 2722 | ++incCounter; |
2723 | } | 2723 | } |
2724 | el.clear(); | 2724 | el.clear(); |
2725 | syncManager->hideProgressBar(); | 2725 | syncManager->hideProgressBar(); |
2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2726 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2727 | // get rid of micro seconds | 2727 | // get rid of micro seconds |
2728 | QTime t = mLastAddressbookSync.time(); | 2728 | QTime t = mLastAddressbookSync.time(); |
2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2729 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2730 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2730 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2731 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2731 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2732 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2733 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2734 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2735 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2736 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2737 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2738 | addresseeRSync.setNote( "" ) ; | 2738 | addresseeRSync.setNote( "" ) ; |
2739 | addresseeLSync.setNote( "" ); | 2739 | addresseeLSync.setNote( "" ); |
2740 | 2740 | ||
2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2741 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2742 | remote->insertAddressee( addresseeRSync, false ); | 2742 | remote->insertAddressee( addresseeRSync, false ); |
2743 | local->insertAddressee( addresseeLSync, false ); | 2743 | local->insertAddressee( addresseeLSync, false ); |
2744 | QString mes; | 2744 | QString mes; |
2745 | 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 ); | 2745 | 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 ); |
2746 | if ( syncManager->mShowSyncSummary ) { | 2746 | if ( syncManager->mShowSyncSummary ) { |
2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2747 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2748 | } | 2748 | } |
2749 | qDebug( mes ); | 2749 | qDebug( mes ); |
2750 | return syncOK; | 2750 | return syncOK; |
2751 | } | 2751 | } |
2752 | 2752 | ||
2753 | 2753 | ||
2754 | //this is a overwritten callbackmethods from the syncinterface | 2754 | //this is a overwritten callbackmethods from the syncinterface |
2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2755 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2756 | { | 2756 | { |
2757 | 2757 | ||
2758 | //pending prepare addresseeview for output | 2758 | //pending prepare addresseeview for output |
2759 | //pending detect, if remote file has REV field. if not switch to external sync | 2759 | //pending detect, if remote file has REV field. if not switch to external sync |
2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2760 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2761 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2762 | 2762 | ||
2763 | AddressBook abLocal(filename,"syncContact"); | 2763 | AddressBook abLocal(filename,"syncContact"); |
2764 | bool syncOK = false; | 2764 | bool syncOK = false; |
2765 | if ( abLocal.load() ) { | 2765 | if ( abLocal.load() ) { |
2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2766 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2767 | bool external = false; | 2767 | bool external = false; |
2768 | bool isXML = false; | 2768 | bool isXML = false; |
2769 | if ( filename.right(4) == ".xml") { | 2769 | if ( filename.right(4) == ".xml") { |
2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2770 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2771 | isXML = true; | 2771 | isXML = true; |
2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2772 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2773 | } else { | 2773 | } else { |
2774 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | 2774 | Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); |
2775 | if ( ! lse.isEmpty() ) { | 2775 | if ( ! lse.isEmpty() ) { |
2776 | if ( lse.familyName().left(4) == "!E: " ) | 2776 | if ( lse.familyName().left(4) == "!E: " ) |
2777 | external = true; | 2777 | external = true; |
2778 | } else { | 2778 | } else { |
2779 | bool found = false; | 2779 | bool found = false; |
2780 | AddressBook::Iterator it; | 2780 | AddressBook::Iterator it; |
2781 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2781 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2782 | if ( (*it).revision().date().year() > 2003 ) { | 2782 | if ( (*it).revision().date().year() > 2003 ) { |
2783 | found = true; | 2783 | found = true; |
2784 | break; | 2784 | break; |
2785 | } | 2785 | } |
2786 | } | 2786 | } |
2787 | external = ! found; | 2787 | external = ! found; |
2788 | } | 2788 | } |
2789 | 2789 | ||
2790 | if ( external ) { | 2790 | if ( external ) { |
2791 | qDebug("Setting vcf mode to external "); | 2791 | qDebug("Setting vcf mode to external "); |
2792 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2792 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2793 | AddressBook::Iterator it; | 2793 | AddressBook::Iterator it; |
2794 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2794 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2795 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2795 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2796 | (*it).computeCsum( mCurrentSyncDevice ); | 2796 | (*it).computeCsum( mCurrentSyncDevice ); |
2797 | } | 2797 | } |
2798 | } | 2798 | } |
2799 | } | 2799 | } |
2800 | //AddressBook::Iterator it; | 2800 | //AddressBook::Iterator it; |
2801 | //QStringList vcards; | 2801 | //QStringList vcards; |
2802 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2802 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2803 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2803 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2804 | //} | 2804 | //} |
2805 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2805 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2806 | if ( syncOK ) { | 2806 | if ( syncOK ) { |
2807 | if ( syncManager->mWriteBackFile ) | 2807 | if ( syncManager->mWriteBackFile ) |
2808 | { | 2808 | { |
2809 | if ( external ) | 2809 | if ( external ) |
2810 | abLocal.removeSyncAddressees( !isXML); | 2810 | abLocal.removeSyncAddressees( !isXML); |
2811 | qDebug("Saving remote AB "); | 2811 | qDebug("Saving remote AB "); |
2812 | if ( ! abLocal.saveAB()) | 2812 | if ( ! abLocal.saveAB()) |
2813 | qDebug("Error writing back AB to file "); | 2813 | qDebug("Error writing back AB to file "); |
2814 | if ( isXML ) { | 2814 | if ( isXML ) { |
2815 | // afterwrite processing | 2815 | // afterwrite processing |
2816 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2816 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2817 | } | 2817 | } |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | setModified(); | 2820 | setModified(); |
2821 | 2821 | ||
2822 | } | 2822 | } |
2823 | if ( syncOK ) | 2823 | if ( syncOK ) |
2824 | mViewManager->refreshView(); | 2824 | mViewManager->refreshView(); |
2825 | return syncOK; | 2825 | return syncOK; |
2826 | #if 0 | 2826 | #if 0 |
2827 | 2827 | ||
2828 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2828 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2829 | getEventViewerDialog()->setSyncMode( true ); | 2829 | getEventViewerDialog()->setSyncMode( true ); |
2830 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2830 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2831 | getEventViewerDialog()->setSyncMode( false ); | 2831 | getEventViewerDialog()->setSyncMode( false ); |
2832 | if ( syncOK ) { | 2832 | if ( syncOK ) { |
2833 | if ( KOPrefs::instance()->mWriteBackFile ) | 2833 | if ( KOPrefs::instance()->mWriteBackFile ) |
2834 | { | 2834 | { |
2835 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2835 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2836 | storage->save(); | 2836 | storage->save(); |
2837 | } | 2837 | } |
2838 | } | 2838 | } |
2839 | setModified(); | 2839 | setModified(); |
2840 | } | 2840 | } |
2841 | 2841 | ||
2842 | #endif | 2842 | #endif |
2843 | } | 2843 | } |
2844 | 2844 | ||
2845 | 2845 | ||
2846 | //this is a overwritten callbackmethods from the syncinterface | 2846 | //this is a overwritten callbackmethods from the syncinterface |
2847 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2847 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2848 | { | 2848 | { |
2849 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2849 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2850 | 2850 | ||
2851 | AddressBook abLocal( resource,"syncContact"); | 2851 | AddressBook abLocal( resource,"syncContact"); |
2852 | bool syncOK = false; | 2852 | bool syncOK = false; |
2853 | if ( abLocal.load() ) { | 2853 | if ( abLocal.load() ) { |
2854 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2854 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2855 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2855 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2856 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); | 2856 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); |
2857 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2857 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2858 | if ( syncOK ) { | 2858 | if ( syncOK ) { |
2859 | if ( syncManager->mWriteBackFile ) { | 2859 | if ( syncManager->mWriteBackFile ) { |
2860 | abLocal.saveAB(); | 2860 | abLocal.saveAB(); |
2861 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2861 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2862 | } | 2862 | } |
2863 | } | 2863 | } |
2864 | setModified(); | 2864 | setModified(); |
2865 | } | 2865 | } |
2866 | if ( syncOK ) | 2866 | if ( syncOK ) |
2867 | mViewManager->refreshView(); | 2867 | mViewManager->refreshView(); |
2868 | return syncOK; | 2868 | return syncOK; |
2869 | 2869 | ||
2870 | } | 2870 | } |
2871 | 2871 | ||
2872 | void KABCore::getFile( bool success ) | 2872 | void KABCore::getFile( bool success ) |
2873 | { | 2873 | { |
2874 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); | 2874 | QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); |
2875 | if ( ! success ) { | 2875 | if ( ! success ) { |
2876 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2876 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2877 | return; | 2877 | return; |
2878 | } | 2878 | } |
2879 | mAddressBook->importFromFile( sentSyncFile() ); | 2879 | mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2880 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); | 2880 | topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); |
2881 | mViewManager->refreshView(); | 2881 | mViewManager->refreshView(); |
2882 | } | 2882 | } |
2883 | void KABCore::syncFileRequest() | 2883 | void KABCore::syncFileRequest() |
2884 | { | 2884 | { |
2885 | mAddressBook->export2File( sentSyncFile() ); | 2885 | mAddressBook->export2File( sentSyncFile() ); |
2886 | } | 2886 | } |
2887 | QString KABCore::sentSyncFile() | 2887 | QString KABCore::sentSyncFile() |
2888 | { | 2888 | { |
2889 | #ifdef _WIN32_ | 2889 | #ifdef _WIN32_ |
2890 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2890 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2891 | #else | 2891 | #else |
2892 | return QString( "/tmp/copysyncab.vcf" ); | 2892 | return QString( "/tmp/copysyncab.vcf" ); |
2893 | #endif | 2893 | #endif |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | void KABCore::setCaptionBack() | 2896 | void KABCore::setCaptionBack() |
2897 | { | 2897 | { |
2898 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2898 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2899 | } | 2899 | } |