-rw-r--r-- | kabc/addressbook.cpp | 27 | ||||
-rw-r--r-- | kabc/addressbook.h | 5 | ||||
-rw-r--r-- | kabc/addressee.cpp | 54 | ||||
-rw-r--r-- | kabc/addressee.h | 12 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 93 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 2 |
6 files changed, 156 insertions, 37 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 70eda1b..9332e21 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,743 +1,770 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | 41 | ||
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <libkcal/syncdefines.h> | ||
45 | #include "addressbook.h" | 46 | #include "addressbook.h" |
46 | #include "resource.h" | 47 | #include "resource.h" |
47 | 48 | ||
48 | //US #include "addressbook.moc" | 49 | //US #include "addressbook.moc" |
49 | 50 | ||
50 | using namespace KABC; | 51 | using namespace KABC; |
51 | 52 | ||
52 | struct AddressBook::AddressBookData | 53 | struct AddressBook::AddressBookData |
53 | { | 54 | { |
54 | Addressee::List mAddressees; | 55 | Addressee::List mAddressees; |
55 | Addressee::List mRemovedAddressees; | 56 | Addressee::List mRemovedAddressees; |
56 | Field::List mAllFields; | 57 | Field::List mAllFields; |
57 | KConfig *mConfig; | 58 | KConfig *mConfig; |
58 | KRES::Manager<Resource> *mManager; | 59 | KRES::Manager<Resource> *mManager; |
59 | //US ErrorHandler *mErrorHandler; | 60 | //US ErrorHandler *mErrorHandler; |
60 | }; | 61 | }; |
61 | 62 | ||
62 | struct AddressBook::Iterator::IteratorData | 63 | struct AddressBook::Iterator::IteratorData |
63 | { | 64 | { |
64 | Addressee::List::Iterator mIt; | 65 | Addressee::List::Iterator mIt; |
65 | }; | 66 | }; |
66 | 67 | ||
67 | struct AddressBook::ConstIterator::ConstIteratorData | 68 | struct AddressBook::ConstIterator::ConstIteratorData |
68 | { | 69 | { |
69 | Addressee::List::ConstIterator mIt; | 70 | Addressee::List::ConstIterator mIt; |
70 | }; | 71 | }; |
71 | 72 | ||
72 | AddressBook::Iterator::Iterator() | 73 | AddressBook::Iterator::Iterator() |
73 | { | 74 | { |
74 | d = new IteratorData; | 75 | d = new IteratorData; |
75 | } | 76 | } |
76 | 77 | ||
77 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 78 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
78 | { | 79 | { |
79 | d = new IteratorData; | 80 | d = new IteratorData; |
80 | d->mIt = i.d->mIt; | 81 | d->mIt = i.d->mIt; |
81 | } | 82 | } |
82 | 83 | ||
83 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 84 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
84 | { | 85 | { |
85 | if( this == &i ) return *this; // guard against self assignment | 86 | if( this == &i ) return *this; // guard against self assignment |
86 | delete d; // delete the old data the Iterator was completely constructed before | 87 | delete d; // delete the old data the Iterator was completely constructed before |
87 | d = new IteratorData; | 88 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 89 | d->mIt = i.d->mIt; |
89 | return *this; | 90 | return *this; |
90 | } | 91 | } |
91 | 92 | ||
92 | AddressBook::Iterator::~Iterator() | 93 | AddressBook::Iterator::~Iterator() |
93 | { | 94 | { |
94 | delete d; | 95 | delete d; |
95 | } | 96 | } |
96 | 97 | ||
97 | const Addressee &AddressBook::Iterator::operator*() const | 98 | const Addressee &AddressBook::Iterator::operator*() const |
98 | { | 99 | { |
99 | return *(d->mIt); | 100 | return *(d->mIt); |
100 | } | 101 | } |
101 | 102 | ||
102 | Addressee &AddressBook::Iterator::operator*() | 103 | Addressee &AddressBook::Iterator::operator*() |
103 | { | 104 | { |
104 | return *(d->mIt); | 105 | return *(d->mIt); |
105 | } | 106 | } |
106 | 107 | ||
107 | Addressee *AddressBook::Iterator::operator->() | 108 | Addressee *AddressBook::Iterator::operator->() |
108 | { | 109 | { |
109 | return &(*(d->mIt)); | 110 | return &(*(d->mIt)); |
110 | } | 111 | } |
111 | 112 | ||
112 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 113 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
113 | { | 114 | { |
114 | (d->mIt)++; | 115 | (d->mIt)++; |
115 | return *this; | 116 | return *this; |
116 | } | 117 | } |
117 | 118 | ||
118 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 119 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
119 | { | 120 | { |
120 | (d->mIt)++; | 121 | (d->mIt)++; |
121 | return *this; | 122 | return *this; |
122 | } | 123 | } |
123 | 124 | ||
124 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 125 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
125 | { | 126 | { |
126 | (d->mIt)--; | 127 | (d->mIt)--; |
127 | return *this; | 128 | return *this; |
128 | } | 129 | } |
129 | 130 | ||
130 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 131 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
131 | { | 132 | { |
132 | (d->mIt)--; | 133 | (d->mIt)--; |
133 | return *this; | 134 | return *this; |
134 | } | 135 | } |
135 | 136 | ||
136 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 137 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
137 | { | 138 | { |
138 | return ( d->mIt == it.d->mIt ); | 139 | return ( d->mIt == it.d->mIt ); |
139 | } | 140 | } |
140 | 141 | ||
141 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 142 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
142 | { | 143 | { |
143 | return ( d->mIt != it.d->mIt ); | 144 | return ( d->mIt != it.d->mIt ); |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | AddressBook::ConstIterator::ConstIterator() | 148 | AddressBook::ConstIterator::ConstIterator() |
148 | { | 149 | { |
149 | d = new ConstIteratorData; | 150 | d = new ConstIteratorData; |
150 | } | 151 | } |
151 | 152 | ||
152 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 153 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
153 | { | 154 | { |
154 | d = new ConstIteratorData; | 155 | d = new ConstIteratorData; |
155 | d->mIt = i.d->mIt; | 156 | d->mIt = i.d->mIt; |
156 | } | 157 | } |
157 | 158 | ||
158 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 159 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
159 | { | 160 | { |
160 | if( this == &i ) return *this; // guard for self assignment | 161 | if( this == &i ) return *this; // guard for self assignment |
161 | delete d; // delete the old data because the Iterator was really constructed before | 162 | delete d; // delete the old data because the Iterator was really constructed before |
162 | d = new ConstIteratorData; | 163 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 164 | d->mIt = i.d->mIt; |
164 | return *this; | 165 | return *this; |
165 | } | 166 | } |
166 | 167 | ||
167 | AddressBook::ConstIterator::~ConstIterator() | 168 | AddressBook::ConstIterator::~ConstIterator() |
168 | { | 169 | { |
169 | delete d; | 170 | delete d; |
170 | } | 171 | } |
171 | 172 | ||
172 | const Addressee &AddressBook::ConstIterator::operator*() const | 173 | const Addressee &AddressBook::ConstIterator::operator*() const |
173 | { | 174 | { |
174 | return *(d->mIt); | 175 | return *(d->mIt); |
175 | } | 176 | } |
176 | 177 | ||
177 | const Addressee* AddressBook::ConstIterator::operator->() const | 178 | const Addressee* AddressBook::ConstIterator::operator->() const |
178 | { | 179 | { |
179 | return &(*(d->mIt)); | 180 | return &(*(d->mIt)); |
180 | } | 181 | } |
181 | 182 | ||
182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 183 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
183 | { | 184 | { |
184 | (d->mIt)++; | 185 | (d->mIt)++; |
185 | return *this; | 186 | return *this; |
186 | } | 187 | } |
187 | 188 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 189 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
189 | { | 190 | { |
190 | (d->mIt)++; | 191 | (d->mIt)++; |
191 | return *this; | 192 | return *this; |
192 | } | 193 | } |
193 | 194 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 195 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
195 | { | 196 | { |
196 | (d->mIt)--; | 197 | (d->mIt)--; |
197 | return *this; | 198 | return *this; |
198 | } | 199 | } |
199 | 200 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 201 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
201 | { | 202 | { |
202 | (d->mIt)--; | 203 | (d->mIt)--; |
203 | return *this; | 204 | return *this; |
204 | } | 205 | } |
205 | 206 | ||
206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 207 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
207 | { | 208 | { |
208 | return ( d->mIt == it.d->mIt ); | 209 | return ( d->mIt == it.d->mIt ); |
209 | } | 210 | } |
210 | 211 | ||
211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 212 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
212 | { | 213 | { |
213 | return ( d->mIt != it.d->mIt ); | 214 | return ( d->mIt != it.d->mIt ); |
214 | } | 215 | } |
215 | 216 | ||
216 | 217 | ||
217 | AddressBook::AddressBook() | 218 | AddressBook::AddressBook() |
218 | { | 219 | { |
219 | init(0, "contact"); | 220 | init(0, "contact"); |
220 | } | 221 | } |
221 | 222 | ||
222 | AddressBook::AddressBook( const QString &config ) | 223 | AddressBook::AddressBook( const QString &config ) |
223 | { | 224 | { |
224 | init(config, "contact"); | 225 | init(config, "contact"); |
225 | } | 226 | } |
226 | 227 | ||
227 | AddressBook::AddressBook( const QString &config, const QString &family ) | 228 | AddressBook::AddressBook( const QString &config, const QString &family ) |
228 | { | 229 | { |
229 | init(config, family); | 230 | init(config, family); |
230 | 231 | ||
231 | } | 232 | } |
232 | 233 | ||
233 | // the default family is "contact" | 234 | // the default family is "contact" |
234 | void AddressBook::init(const QString &config, const QString &family ) | 235 | void AddressBook::init(const QString &config, const QString &family ) |
235 | { | 236 | { |
236 | d = new AddressBookData; | 237 | d = new AddressBookData; |
237 | QString fami = family; | 238 | QString fami = family; |
238 | qDebug("new ab "); | 239 | qDebug("new ab "); |
239 | if (config != 0) { | 240 | if (config != 0) { |
240 | qDebug("config != 0 "); | 241 | qDebug("config != 0 "); |
241 | if ( family == "syncContact" ) { | 242 | if ( family == "syncContact" ) { |
242 | qDebug("creating sync config "); | 243 | qDebug("creating sync config "); |
243 | fami = "contact"; | 244 | fami = "contact"; |
244 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); | 245 | KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); |
245 | con->setGroup( "General" ); | 246 | con->setGroup( "General" ); |
246 | con->writeEntry( "ResourceKeys", QString("sync") ); | 247 | con->writeEntry( "ResourceKeys", QString("sync") ); |
247 | con->writeEntry( "Standard", QString("sync") ); | 248 | con->writeEntry( "Standard", QString("sync") ); |
248 | con->setGroup( "Resource_sync" ); | 249 | con->setGroup( "Resource_sync" ); |
249 | con->writeEntry( "FileFormat", QString("vcard") ); | 250 | con->writeEntry( "FileFormat", QString("vcard") ); |
250 | con->writeEntry( "FileName", config ); | 251 | con->writeEntry( "FileName", config ); |
251 | con->writeEntry( "ResourceIdentifier", QString("sync") ); | 252 | con->writeEntry( "ResourceIdentifier", QString("sync") ); |
252 | con->writeEntry( "ResourceName", QString("sync_res") ); | 253 | con->writeEntry( "ResourceName", QString("sync_res") ); |
253 | con->writeEntry( "ResourceType", QString("file") ); | 254 | con->writeEntry( "ResourceType", QString("file") ); |
254 | //con->sync(); | 255 | //con->sync(); |
255 | d->mConfig = con; | 256 | d->mConfig = con; |
256 | } | 257 | } |
257 | else | 258 | else |
258 | d->mConfig = new KConfig( locateLocal("config", config) ); | 259 | d->mConfig = new KConfig( locateLocal("config", config) ); |
259 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 260 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
260 | } | 261 | } |
261 | else { | 262 | else { |
262 | d->mConfig = 0; | 263 | d->mConfig = 0; |
263 | // qDebug("AddressBook::init 1 config=0"); | 264 | // qDebug("AddressBook::init 1 config=0"); |
264 | } | 265 | } |
265 | 266 | ||
266 | //US d->mErrorHandler = 0; | 267 | //US d->mErrorHandler = 0; |
267 | d->mManager = new KRES::Manager<Resource>( fami, false ); | 268 | d->mManager = new KRES::Manager<Resource>( fami, false ); |
268 | d->mManager->readConfig( d->mConfig ); | 269 | d->mManager->readConfig( d->mConfig ); |
269 | if ( family == "syncContact" ) { | 270 | if ( family == "syncContact" ) { |
270 | KRES::Manager<Resource> *manager = d->mManager; | 271 | KRES::Manager<Resource> *manager = d->mManager; |
271 | KRES::Manager<Resource>::ActiveIterator it; | 272 | KRES::Manager<Resource>::ActiveIterator it; |
272 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 273 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
273 | (*it)->setAddressBook( this ); | 274 | (*it)->setAddressBook( this ); |
274 | if ( !(*it)->open() ) | 275 | if ( !(*it)->open() ) |
275 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 276 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
276 | } | 277 | } |
277 | Resource *res = standardResource(); | 278 | Resource *res = standardResource(); |
278 | if ( !res ) { | 279 | if ( !res ) { |
279 | qDebug("ERROR: no standard resource"); | 280 | qDebug("ERROR: no standard resource"); |
280 | res = manager->createResource( "file" ); | 281 | res = manager->createResource( "file" ); |
281 | if ( res ) | 282 | if ( res ) |
282 | { | 283 | { |
283 | addResource( res ); | 284 | addResource( res ); |
284 | } | 285 | } |
285 | else | 286 | else |
286 | qDebug(" No resource available!!!"); | 287 | qDebug(" No resource available!!!"); |
287 | } | 288 | } |
288 | setStandardResource( res ); | 289 | setStandardResource( res ); |
289 | manager->writeConfig(); | 290 | manager->writeConfig(); |
290 | } | 291 | } |
291 | addCustomField( i18n( "Department" ), KABC::Field::Organization, | 292 | addCustomField( i18n( "Department" ), KABC::Field::Organization, |
292 | "X-Department", "KADDRESSBOOK" ); | 293 | "X-Department", "KADDRESSBOOK" ); |
293 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 294 | addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
294 | "X-Profession", "KADDRESSBOOK" ); | 295 | "X-Profession", "KADDRESSBOOK" ); |
295 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 296 | addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
296 | "X-AssistantsName", "KADDRESSBOOK" ); | 297 | "X-AssistantsName", "KADDRESSBOOK" ); |
297 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 298 | addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
298 | "X-ManagersName", "KADDRESSBOOK" ); | 299 | "X-ManagersName", "KADDRESSBOOK" ); |
299 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 300 | addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
300 | "X-SpousesName", "KADDRESSBOOK" ); | 301 | "X-SpousesName", "KADDRESSBOOK" ); |
301 | addCustomField( i18n( "Office" ), KABC::Field::Personal, | 302 | addCustomField( i18n( "Office" ), KABC::Field::Personal, |
302 | "X-Office", "KADDRESSBOOK" ); | 303 | "X-Office", "KADDRESSBOOK" ); |
303 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 304 | addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
304 | "X-IMAddress", "KADDRESSBOOK" ); | 305 | "X-IMAddress", "KADDRESSBOOK" ); |
305 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 306 | addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
306 | "X-Anniversary", "KADDRESSBOOK" ); | 307 | "X-Anniversary", "KADDRESSBOOK" ); |
307 | 308 | ||
308 | //US added this field to become compatible with Opie/qtopia addressbook | 309 | //US added this field to become compatible with Opie/qtopia addressbook |
309 | // values can be "female" or "male" or "". An empty field represents undefined. | 310 | // values can be "female" or "male" or "". An empty field represents undefined. |
310 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 311 | addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
311 | "X-Gender", "KADDRESSBOOK" ); | 312 | "X-Gender", "KADDRESSBOOK" ); |
312 | addCustomField( i18n( "Children" ), KABC::Field::Personal, | 313 | addCustomField( i18n( "Children" ), KABC::Field::Personal, |
313 | "X-Children", "KADDRESSBOOK" ); | 314 | "X-Children", "KADDRESSBOOK" ); |
314 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 315 | addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
315 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 316 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
316 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, | 317 | addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, |
317 | "X-ExternalID", "KADDRESSBOOK" ); | 318 | "X-ExternalID", "KADDRESSBOOK" ); |
318 | } | 319 | } |
319 | 320 | ||
320 | AddressBook::~AddressBook() | 321 | AddressBook::~AddressBook() |
321 | { | 322 | { |
322 | delete d->mConfig; d->mConfig = 0; | 323 | delete d->mConfig; d->mConfig = 0; |
323 | delete d->mManager; d->mManager = 0; | 324 | delete d->mManager; d->mManager = 0; |
324 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 325 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
325 | delete d; d = 0; | 326 | delete d; d = 0; |
326 | } | 327 | } |
327 | 328 | ||
328 | bool AddressBook::load() | 329 | bool AddressBook::load() |
329 | { | 330 | { |
330 | 331 | ||
331 | 332 | ||
332 | clear(); | 333 | clear(); |
333 | 334 | ||
334 | KRES::Manager<Resource>::ActiveIterator it; | 335 | KRES::Manager<Resource>::ActiveIterator it; |
335 | bool ok = true; | 336 | bool ok = true; |
336 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 337 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
337 | if ( !(*it)->load() ) { | 338 | if ( !(*it)->load() ) { |
338 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 339 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
339 | ok = false; | 340 | ok = false; |
340 | } | 341 | } |
341 | 342 | ||
342 | // mark all addressees as unchanged | 343 | // mark all addressees as unchanged |
343 | Addressee::List::Iterator addrIt; | 344 | Addressee::List::Iterator addrIt; |
344 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 345 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) |
345 | (*addrIt).setChanged( false ); | 346 | (*addrIt).setChanged( false ); |
346 | 347 | ||
347 | return ok; | 348 | return ok; |
348 | } | 349 | } |
349 | 350 | ||
350 | bool AddressBook::save( Ticket *ticket ) | 351 | bool AddressBook::save( Ticket *ticket ) |
351 | { | 352 | { |
352 | kdDebug(5700) << "AddressBook::save()"<< endl; | 353 | kdDebug(5700) << "AddressBook::save()"<< endl; |
353 | 354 | ||
354 | if ( ticket->resource() ) { | 355 | if ( ticket->resource() ) { |
355 | deleteRemovedAddressees(); | 356 | deleteRemovedAddressees(); |
356 | return ticket->resource()->save( ticket ); | 357 | return ticket->resource()->save( ticket ); |
357 | } | 358 | } |
358 | 359 | ||
359 | return false; | 360 | return false; |
360 | } | 361 | } |
361 | bool AddressBook::saveAB() | 362 | bool AddressBook::saveAB() |
362 | { | 363 | { |
363 | bool ok = true; | 364 | bool ok = true; |
364 | 365 | ||
365 | deleteRemovedAddressees(); | 366 | deleteRemovedAddressees(); |
366 | 367 | ||
367 | KRES::Manager<Resource>::ActiveIterator it; | 368 | KRES::Manager<Resource>::ActiveIterator it; |
368 | KRES::Manager<Resource> *manager = d->mManager; | 369 | KRES::Manager<Resource> *manager = d->mManager; |
369 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 370 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
370 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 371 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
371 | Ticket *ticket = requestSaveTicket( *it ); | 372 | Ticket *ticket = requestSaveTicket( *it ); |
372 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 373 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
373 | if ( !ticket ) { | 374 | if ( !ticket ) { |
374 | error( i18n( "Unable to save to resource '%1'. It is locked." ) | 375 | error( i18n( "Unable to save to resource '%1'. It is locked." ) |
375 | .arg( (*it)->resourceName() ) ); | 376 | .arg( (*it)->resourceName() ) ); |
376 | return false; | 377 | return false; |
377 | } | 378 | } |
378 | 379 | ||
379 | //if ( !save( ticket ) ) | 380 | //if ( !save( ticket ) ) |
380 | if ( ticket->resource() ) { | 381 | if ( ticket->resource() ) { |
381 | if ( ! ticket->resource()->save( ticket ) ) | 382 | if ( ! ticket->resource()->save( ticket ) ) |
382 | ok = false; | 383 | ok = false; |
383 | } else | 384 | } else |
384 | ok = false; | 385 | ok = false; |
385 | 386 | ||
386 | } | 387 | } |
387 | } | 388 | } |
388 | return ok; | 389 | return ok; |
389 | } | 390 | } |
390 | 391 | ||
391 | AddressBook::Iterator AddressBook::begin() | 392 | AddressBook::Iterator AddressBook::begin() |
392 | { | 393 | { |
393 | Iterator it = Iterator(); | 394 | Iterator it = Iterator(); |
394 | it.d->mIt = d->mAddressees.begin(); | 395 | it.d->mIt = d->mAddressees.begin(); |
395 | return it; | 396 | return it; |
396 | } | 397 | } |
397 | 398 | ||
398 | AddressBook::ConstIterator AddressBook::begin() const | 399 | AddressBook::ConstIterator AddressBook::begin() const |
399 | { | 400 | { |
400 | ConstIterator it = ConstIterator(); | 401 | ConstIterator it = ConstIterator(); |
401 | it.d->mIt = d->mAddressees.begin(); | 402 | it.d->mIt = d->mAddressees.begin(); |
402 | return it; | 403 | return it; |
403 | } | 404 | } |
404 | 405 | ||
405 | AddressBook::Iterator AddressBook::end() | 406 | AddressBook::Iterator AddressBook::end() |
406 | { | 407 | { |
407 | Iterator it = Iterator(); | 408 | Iterator it = Iterator(); |
408 | it.d->mIt = d->mAddressees.end(); | 409 | it.d->mIt = d->mAddressees.end(); |
409 | return it; | 410 | return it; |
410 | } | 411 | } |
411 | 412 | ||
412 | AddressBook::ConstIterator AddressBook::end() const | 413 | AddressBook::ConstIterator AddressBook::end() const |
413 | { | 414 | { |
414 | ConstIterator it = ConstIterator(); | 415 | ConstIterator it = ConstIterator(); |
415 | it.d->mIt = d->mAddressees.end(); | 416 | it.d->mIt = d->mAddressees.end(); |
416 | return it; | 417 | return it; |
417 | } | 418 | } |
418 | 419 | ||
419 | void AddressBook::clear() | 420 | void AddressBook::clear() |
420 | { | 421 | { |
421 | d->mAddressees.clear(); | 422 | d->mAddressees.clear(); |
422 | } | 423 | } |
423 | 424 | ||
424 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 425 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
425 | { | 426 | { |
426 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 427 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
427 | 428 | ||
428 | if ( !resource ) | 429 | if ( !resource ) |
429 | { | 430 | { |
430 | qDebug("AddressBook::requestSaveTicket no resource" ); | 431 | qDebug("AddressBook::requestSaveTicket no resource" ); |
431 | resource = standardResource(); | 432 | resource = standardResource(); |
432 | } | 433 | } |
433 | 434 | ||
434 | KRES::Manager<Resource>::ActiveIterator it; | 435 | KRES::Manager<Resource>::ActiveIterator it; |
435 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 436 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
436 | if ( (*it) == resource ) { | 437 | if ( (*it) == resource ) { |
437 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 438 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
438 | return 0; | 439 | return 0; |
439 | else | 440 | else |
440 | return (*it)->requestSaveTicket(); | 441 | return (*it)->requestSaveTicket(); |
441 | } | 442 | } |
442 | } | 443 | } |
443 | 444 | ||
444 | return 0; | 445 | return 0; |
445 | } | 446 | } |
446 | 447 | ||
447 | void AddressBook::insertAddressee( const Addressee &a ) | 448 | void AddressBook::insertAddressee( const Addressee &a ) |
448 | { | 449 | { |
449 | Addressee::List::Iterator it; | 450 | Addressee::List::Iterator it; |
450 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 451 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
451 | if ( a.uid() == (*it).uid() ) { | 452 | if ( a.uid() == (*it).uid() ) { |
452 | bool changed = false; | 453 | bool changed = false; |
453 | Addressee addr = a; | 454 | Addressee addr = a; |
454 | if ( addr != (*it) ) | 455 | if ( addr != (*it) ) |
455 | changed = true; | 456 | changed = true; |
456 | 457 | ||
457 | (*it) = a; | 458 | (*it) = a; |
458 | if ( (*it).resource() == 0 ) | 459 | if ( (*it).resource() == 0 ) |
459 | (*it).setResource( standardResource() ); | 460 | (*it).setResource( standardResource() ); |
460 | 461 | ||
461 | if ( changed ) { | 462 | if ( changed ) { |
462 | (*it).setRevision( QDateTime::currentDateTime() ); | 463 | (*it).setRevision( QDateTime::currentDateTime() ); |
463 | (*it).setChanged( true ); | 464 | (*it).setChanged( true ); |
464 | } | 465 | } |
465 | 466 | ||
466 | return; | 467 | return; |
467 | } | 468 | } |
468 | } | 469 | } |
469 | d->mAddressees.append( a ); | 470 | d->mAddressees.append( a ); |
470 | Addressee& addr = d->mAddressees.last(); | 471 | Addressee& addr = d->mAddressees.last(); |
471 | if ( addr.resource() == 0 ) | 472 | if ( addr.resource() == 0 ) |
472 | addr.setResource( standardResource() ); | 473 | addr.setResource( standardResource() ); |
473 | 474 | ||
474 | addr.setChanged( true ); | 475 | addr.setChanged( true ); |
475 | } | 476 | } |
476 | 477 | ||
477 | void AddressBook::removeAddressee( const Addressee &a ) | 478 | void AddressBook::removeAddressee( const Addressee &a ) |
478 | { | 479 | { |
479 | Iterator it; | 480 | Iterator it; |
480 | for ( it = begin(); it != end(); ++it ) { | 481 | for ( it = begin(); it != end(); ++it ) { |
481 | if ( a.uid() == (*it).uid() ) { | 482 | if ( a.uid() == (*it).uid() ) { |
482 | removeAddressee( it ); | 483 | removeAddressee( it ); |
483 | return; | 484 | return; |
484 | } | 485 | } |
485 | } | 486 | } |
486 | } | 487 | } |
487 | 488 | ||
488 | void AddressBook::removeAddressee( const Iterator &it ) | 489 | void AddressBook::removeAddressee( const Iterator &it ) |
489 | { | 490 | { |
490 | d->mRemovedAddressees.append( (*it) ); | 491 | d->mRemovedAddressees.append( (*it) ); |
491 | d->mAddressees.remove( it.d->mIt ); | 492 | d->mAddressees.remove( it.d->mIt ); |
492 | } | 493 | } |
493 | 494 | ||
494 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 495 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
495 | { | 496 | { |
496 | Iterator it; | 497 | Iterator it; |
497 | for ( it = begin(); it != end(); ++it ) { | 498 | for ( it = begin(); it != end(); ++it ) { |
498 | if ( a.uid() == (*it).uid() ) { | 499 | if ( a.uid() == (*it).uid() ) { |
499 | return it; | 500 | return it; |
500 | } | 501 | } |
501 | } | 502 | } |
502 | return end(); | 503 | return end(); |
503 | } | 504 | } |
504 | 505 | ||
505 | Addressee AddressBook::findByUid( const QString &uid ) | 506 | Addressee AddressBook::findByUid( const QString &uid ) |
506 | { | 507 | { |
507 | Iterator it; | 508 | Iterator it; |
508 | for ( it = begin(); it != end(); ++it ) { | 509 | for ( it = begin(); it != end(); ++it ) { |
509 | if ( uid == (*it).uid() ) { | 510 | if ( uid == (*it).uid() ) { |
510 | return *it; | 511 | return *it; |
511 | } | 512 | } |
512 | } | 513 | } |
513 | return Addressee(); | 514 | return Addressee(); |
514 | } | 515 | } |
516 | Addressee::List AddressBook::getExternLastSyncAddressees() | ||
517 | { | ||
518 | Addressee::List results; | ||
519 | |||
520 | Iterator it; | ||
521 | for ( it = begin(); it != end(); ++it ) { | ||
522 | if ( (*it).uid().left( 20 ) == "last-syncAddressee-" ) { | ||
523 | if ( (*it).familyName().left(3) == "E: " ) | ||
524 | results.append( *it ); | ||
525 | } | ||
526 | } | ||
527 | |||
528 | return results; | ||
529 | } | ||
530 | void AddressBook::resetTempSyncStat() | ||
531 | { | ||
532 | |||
533 | |||
534 | Iterator it; | ||
535 | for ( it = begin(); it != end(); ++it ) { | ||
536 | (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); | ||
537 | } | ||
538 | |||
539 | } | ||
540 | |||
541 | |||
515 | 542 | ||
516 | Addressee::List AddressBook::allAddressees() | 543 | Addressee::List AddressBook::allAddressees() |
517 | { | 544 | { |
518 | return d->mAddressees; | 545 | return d->mAddressees; |
519 | } | 546 | } |
520 | 547 | ||
521 | Addressee::List AddressBook::findByName( const QString &name ) | 548 | Addressee::List AddressBook::findByName( const QString &name ) |
522 | { | 549 | { |
523 | Addressee::List results; | 550 | Addressee::List results; |
524 | 551 | ||
525 | Iterator it; | 552 | Iterator it; |
526 | for ( it = begin(); it != end(); ++it ) { | 553 | for ( it = begin(); it != end(); ++it ) { |
527 | if ( name == (*it).realName() ) { | 554 | if ( name == (*it).realName() ) { |
528 | results.append( *it ); | 555 | results.append( *it ); |
529 | } | 556 | } |
530 | } | 557 | } |
531 | 558 | ||
532 | return results; | 559 | return results; |
533 | } | 560 | } |
534 | 561 | ||
535 | Addressee::List AddressBook::findByEmail( const QString &email ) | 562 | Addressee::List AddressBook::findByEmail( const QString &email ) |
536 | { | 563 | { |
537 | Addressee::List results; | 564 | Addressee::List results; |
538 | QStringList mailList; | 565 | QStringList mailList; |
539 | 566 | ||
540 | Iterator it; | 567 | Iterator it; |
541 | for ( it = begin(); it != end(); ++it ) { | 568 | for ( it = begin(); it != end(); ++it ) { |
542 | mailList = (*it).emails(); | 569 | mailList = (*it).emails(); |
543 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 570 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
544 | if ( email == (*ite) ) { | 571 | if ( email == (*ite) ) { |
545 | results.append( *it ); | 572 | results.append( *it ); |
546 | } | 573 | } |
547 | } | 574 | } |
548 | } | 575 | } |
549 | 576 | ||
550 | return results; | 577 | return results; |
551 | } | 578 | } |
552 | 579 | ||
553 | Addressee::List AddressBook::findByCategory( const QString &category ) | 580 | Addressee::List AddressBook::findByCategory( const QString &category ) |
554 | { | 581 | { |
555 | Addressee::List results; | 582 | Addressee::List results; |
556 | 583 | ||
557 | Iterator it; | 584 | Iterator it; |
558 | for ( it = begin(); it != end(); ++it ) { | 585 | for ( it = begin(); it != end(); ++it ) { |
559 | if ( (*it).hasCategory( category) ) { | 586 | if ( (*it).hasCategory( category) ) { |
560 | results.append( *it ); | 587 | results.append( *it ); |
561 | } | 588 | } |
562 | } | 589 | } |
563 | 590 | ||
564 | return results; | 591 | return results; |
565 | } | 592 | } |
566 | 593 | ||
567 | void AddressBook::dump() const | 594 | void AddressBook::dump() const |
568 | { | 595 | { |
569 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 596 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
570 | 597 | ||
571 | ConstIterator it; | 598 | ConstIterator it; |
572 | for( it = begin(); it != end(); ++it ) { | 599 | for( it = begin(); it != end(); ++it ) { |
573 | (*it).dump(); | 600 | (*it).dump(); |
574 | } | 601 | } |
575 | 602 | ||
576 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 603 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
577 | } | 604 | } |
578 | 605 | ||
579 | QString AddressBook::identifier() | 606 | QString AddressBook::identifier() |
580 | { | 607 | { |
581 | QStringList identifier; | 608 | QStringList identifier; |
582 | 609 | ||
583 | 610 | ||
584 | KRES::Manager<Resource>::ActiveIterator it; | 611 | KRES::Manager<Resource>::ActiveIterator it; |
585 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 612 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
586 | if ( !(*it)->identifier().isEmpty() ) | 613 | if ( !(*it)->identifier().isEmpty() ) |
587 | identifier.append( (*it)->identifier() ); | 614 | identifier.append( (*it)->identifier() ); |
588 | } | 615 | } |
589 | 616 | ||
590 | return identifier.join( ":" ); | 617 | return identifier.join( ":" ); |
591 | } | 618 | } |
592 | 619 | ||
593 | Field::List AddressBook::fields( int category ) | 620 | Field::List AddressBook::fields( int category ) |
594 | { | 621 | { |
595 | if ( d->mAllFields.isEmpty() ) { | 622 | if ( d->mAllFields.isEmpty() ) { |
596 | d->mAllFields = Field::allFields(); | 623 | d->mAllFields = Field::allFields(); |
597 | } | 624 | } |
598 | 625 | ||
599 | if ( category == Field::All ) return d->mAllFields; | 626 | if ( category == Field::All ) return d->mAllFields; |
600 | 627 | ||
601 | Field::List result; | 628 | Field::List result; |
602 | Field::List::ConstIterator it; | 629 | Field::List::ConstIterator it; |
603 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 630 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
604 | if ( (*it)->category() & category ) result.append( *it ); | 631 | if ( (*it)->category() & category ) result.append( *it ); |
605 | } | 632 | } |
606 | 633 | ||
607 | return result; | 634 | return result; |
608 | } | 635 | } |
609 | 636 | ||
610 | bool AddressBook::addCustomField( const QString &label, int category, | 637 | bool AddressBook::addCustomField( const QString &label, int category, |
611 | const QString &key, const QString &app ) | 638 | const QString &key, const QString &app ) |
612 | { | 639 | { |
613 | if ( d->mAllFields.isEmpty() ) { | 640 | if ( d->mAllFields.isEmpty() ) { |
614 | d->mAllFields = Field::allFields(); | 641 | d->mAllFields = Field::allFields(); |
615 | } | 642 | } |
616 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 643 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
617 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 644 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
618 | 645 | ||
619 | QString k = key.isNull() ? label : key; | 646 | QString k = key.isNull() ? label : key; |
620 | 647 | ||
621 | Field *field = Field::createCustomField( label, category, k, a ); | 648 | Field *field = Field::createCustomField( label, category, k, a ); |
622 | 649 | ||
623 | if ( !field ) return false; | 650 | if ( !field ) return false; |
624 | 651 | ||
625 | d->mAllFields.append( field ); | 652 | d->mAllFields.append( field ); |
626 | 653 | ||
627 | return true; | 654 | return true; |
628 | } | 655 | } |
629 | 656 | ||
630 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 657 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
631 | { | 658 | { |
632 | if (!ab.d) return s; | 659 | if (!ab.d) return s; |
633 | 660 | ||
634 | return s << ab.d->mAddressees; | 661 | return s << ab.d->mAddressees; |
635 | } | 662 | } |
636 | 663 | ||
637 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 664 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
638 | { | 665 | { |
639 | if (!ab.d) return s; | 666 | if (!ab.d) return s; |
640 | 667 | ||
641 | s >> ab.d->mAddressees; | 668 | s >> ab.d->mAddressees; |
642 | 669 | ||
643 | return s; | 670 | return s; |
644 | } | 671 | } |
645 | 672 | ||
646 | bool AddressBook::addResource( Resource *resource ) | 673 | bool AddressBook::addResource( Resource *resource ) |
647 | { | 674 | { |
648 | if ( !resource->open() ) { | 675 | if ( !resource->open() ) { |
649 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 676 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
650 | return false; | 677 | return false; |
651 | } | 678 | } |
652 | 679 | ||
653 | resource->setAddressBook( this ); | 680 | resource->setAddressBook( this ); |
654 | 681 | ||
655 | d->mManager->add( resource ); | 682 | d->mManager->add( resource ); |
656 | return true; | 683 | return true; |
657 | } | 684 | } |
658 | 685 | ||
659 | bool AddressBook::removeResource( Resource *resource ) | 686 | bool AddressBook::removeResource( Resource *resource ) |
660 | { | 687 | { |
661 | resource->close(); | 688 | resource->close(); |
662 | 689 | ||
663 | if ( resource == standardResource() ) | 690 | if ( resource == standardResource() ) |
664 | d->mManager->setStandardResource( 0 ); | 691 | d->mManager->setStandardResource( 0 ); |
665 | 692 | ||
666 | resource->setAddressBook( 0 ); | 693 | resource->setAddressBook( 0 ); |
667 | 694 | ||
668 | d->mManager->remove( resource ); | 695 | d->mManager->remove( resource ); |
669 | return true; | 696 | return true; |
670 | } | 697 | } |
671 | 698 | ||
672 | QPtrList<Resource> AddressBook::resources() | 699 | QPtrList<Resource> AddressBook::resources() |
673 | { | 700 | { |
674 | QPtrList<Resource> list; | 701 | QPtrList<Resource> list; |
675 | 702 | ||
676 | // qDebug("AddressBook::resources() 1"); | 703 | // qDebug("AddressBook::resources() 1"); |
677 | 704 | ||
678 | KRES::Manager<Resource>::ActiveIterator it; | 705 | KRES::Manager<Resource>::ActiveIterator it; |
679 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 706 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
680 | list.append( *it ); | 707 | list.append( *it ); |
681 | 708 | ||
682 | return list; | 709 | return list; |
683 | } | 710 | } |
684 | 711 | ||
685 | /*US | 712 | /*US |
686 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 713 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
687 | { | 714 | { |
688 | delete d->mErrorHandler; | 715 | delete d->mErrorHandler; |
689 | d->mErrorHandler = handler; | 716 | d->mErrorHandler = handler; |
690 | } | 717 | } |
691 | */ | 718 | */ |
692 | 719 | ||
693 | void AddressBook::error( const QString& msg ) | 720 | void AddressBook::error( const QString& msg ) |
694 | { | 721 | { |
695 | /*US | 722 | /*US |
696 | if ( !d->mErrorHandler ) // create default error handler | 723 | if ( !d->mErrorHandler ) // create default error handler |
697 | d->mErrorHandler = new ConsoleErrorHandler; | 724 | d->mErrorHandler = new ConsoleErrorHandler; |
698 | 725 | ||
699 | if ( d->mErrorHandler ) | 726 | if ( d->mErrorHandler ) |
700 | d->mErrorHandler->error( msg ); | 727 | d->mErrorHandler->error( msg ); |
701 | else | 728 | else |
702 | kdError(5700) << "no error handler defined" << endl; | 729 | kdError(5700) << "no error handler defined" << endl; |
703 | */ | 730 | */ |
704 | kdDebug(5700) << "msg" << endl; | 731 | kdDebug(5700) << "msg" << endl; |
705 | qDebug(msg); | 732 | qDebug(msg); |
706 | } | 733 | } |
707 | 734 | ||
708 | void AddressBook::deleteRemovedAddressees() | 735 | void AddressBook::deleteRemovedAddressees() |
709 | { | 736 | { |
710 | Addressee::List::Iterator it; | 737 | Addressee::List::Iterator it; |
711 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 738 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
712 | Resource *resource = (*it).resource(); | 739 | Resource *resource = (*it).resource(); |
713 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 740 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
714 | resource->removeAddressee( *it ); | 741 | resource->removeAddressee( *it ); |
715 | } | 742 | } |
716 | 743 | ||
717 | d->mRemovedAddressees.clear(); | 744 | d->mRemovedAddressees.clear(); |
718 | } | 745 | } |
719 | 746 | ||
720 | void AddressBook::setStandardResource( Resource *resource ) | 747 | void AddressBook::setStandardResource( Resource *resource ) |
721 | { | 748 | { |
722 | // qDebug("AddressBook::setStandardResource 1"); | 749 | // qDebug("AddressBook::setStandardResource 1"); |
723 | d->mManager->setStandardResource( resource ); | 750 | d->mManager->setStandardResource( resource ); |
724 | } | 751 | } |
725 | 752 | ||
726 | Resource *AddressBook::standardResource() | 753 | Resource *AddressBook::standardResource() |
727 | { | 754 | { |
728 | return d->mManager->standardResource(); | 755 | return d->mManager->standardResource(); |
729 | } | 756 | } |
730 | 757 | ||
731 | KRES::Manager<Resource> *AddressBook::resourceManager() | 758 | KRES::Manager<Resource> *AddressBook::resourceManager() |
732 | { | 759 | { |
733 | return d->mManager; | 760 | return d->mManager; |
734 | } | 761 | } |
735 | 762 | ||
736 | void AddressBook::cleanUp() | 763 | void AddressBook::cleanUp() |
737 | { | 764 | { |
738 | KRES::Manager<Resource>::ActiveIterator it; | 765 | KRES::Manager<Resource>::ActiveIterator it; |
739 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 766 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
740 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 767 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
741 | (*it)->cleanUp(); | 768 | (*it)->cleanUp(); |
742 | } | 769 | } |
743 | } | 770 | } |
diff --git a/kabc/addressbook.h b/kabc/addressbook.h index e43de31..05225f9 100644 --- a/kabc/addressbook.h +++ b/kabc/addressbook.h | |||
@@ -1,328 +1,333 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef KABC_ADDRESSBOOK_H | 28 | #ifndef KABC_ADDRESSBOOK_H |
29 | #define KABC_ADDRESSBOOK_H | 29 | #define KABC_ADDRESSBOOK_H |
30 | 30 | ||
31 | #include <qobject.h> | 31 | #include <qobject.h> |
32 | 32 | ||
33 | #include <kresources/manager.h> | 33 | #include <kresources/manager.h> |
34 | #include <qptrlist.h> | 34 | #include <qptrlist.h> |
35 | 35 | ||
36 | #include "addressee.h" | 36 | #include "addressee.h" |
37 | #include "field.h" | 37 | #include "field.h" |
38 | 38 | ||
39 | namespace KABC { | 39 | namespace KABC { |
40 | 40 | ||
41 | class ErrorHandler; | 41 | class ErrorHandler; |
42 | class Resource; | 42 | class Resource; |
43 | class Ticket; | 43 | class Ticket; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | @short Address Book | 46 | @short Address Book |
47 | 47 | ||
48 | This class provides access to a collection of address book entries. | 48 | This class provides access to a collection of address book entries. |
49 | */ | 49 | */ |
50 | class AddressBook : public QObject | 50 | class AddressBook : public QObject |
51 | { | 51 | { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | 53 | ||
54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); | 54 | friend QDataStream &operator<<( QDataStream &, const AddressBook & ); |
55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); | 55 | friend QDataStream &operator>>( QDataStream &, AddressBook & ); |
56 | friend class StdAddressBook; | 56 | friend class StdAddressBook; |
57 | 57 | ||
58 | public: | 58 | public: |
59 | /** | 59 | /** |
60 | @short Address Book Iterator | 60 | @short Address Book Iterator |
61 | 61 | ||
62 | This class provides an iterator for address book entries. | 62 | This class provides an iterator for address book entries. |
63 | */ | 63 | */ |
64 | class Iterator | 64 | class Iterator |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | Iterator(); | 67 | Iterator(); |
68 | Iterator( const Iterator & ); | 68 | Iterator( const Iterator & ); |
69 | ~Iterator(); | 69 | ~Iterator(); |
70 | 70 | ||
71 | Iterator &operator=( const Iterator & ); | 71 | Iterator &operator=( const Iterator & ); |
72 | const Addressee &operator*() const; | 72 | const Addressee &operator*() const; |
73 | Addressee &operator*(); | 73 | Addressee &operator*(); |
74 | Addressee* operator->(); | 74 | Addressee* operator->(); |
75 | Iterator &operator++(); | 75 | Iterator &operator++(); |
76 | Iterator &operator++(int); | 76 | Iterator &operator++(int); |
77 | Iterator &operator--(); | 77 | Iterator &operator--(); |
78 | Iterator &operator--(int); | 78 | Iterator &operator--(int); |
79 | bool operator==( const Iterator &it ); | 79 | bool operator==( const Iterator &it ); |
80 | bool operator!=( const Iterator &it ); | 80 | bool operator!=( const Iterator &it ); |
81 | 81 | ||
82 | struct IteratorData; | 82 | struct IteratorData; |
83 | IteratorData *d; | 83 | IteratorData *d; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | @short Address Book Const Iterator | 87 | @short Address Book Const Iterator |
88 | 88 | ||
89 | This class provides a const iterator for address book entries. | 89 | This class provides a const iterator for address book entries. |
90 | */ | 90 | */ |
91 | class ConstIterator | 91 | class ConstIterator |
92 | { | 92 | { |
93 | public: | 93 | public: |
94 | ConstIterator(); | 94 | ConstIterator(); |
95 | ConstIterator( const ConstIterator & ); | 95 | ConstIterator( const ConstIterator & ); |
96 | ~ConstIterator(); | 96 | ~ConstIterator(); |
97 | 97 | ||
98 | ConstIterator &operator=( const ConstIterator & ); | 98 | ConstIterator &operator=( const ConstIterator & ); |
99 | const Addressee &operator*() const; | 99 | const Addressee &operator*() const; |
100 | const Addressee* operator->() const; | 100 | const Addressee* operator->() const; |
101 | ConstIterator &operator++(); | 101 | ConstIterator &operator++(); |
102 | ConstIterator &operator++(int); | 102 | ConstIterator &operator++(int); |
103 | ConstIterator &operator--(); | 103 | ConstIterator &operator--(); |
104 | ConstIterator &operator--(int); | 104 | ConstIterator &operator--(int); |
105 | bool operator==( const ConstIterator &it ); | 105 | bool operator==( const ConstIterator &it ); |
106 | bool operator!=( const ConstIterator &it ); | 106 | bool operator!=( const ConstIterator &it ); |
107 | 107 | ||
108 | struct ConstIteratorData; | 108 | struct ConstIteratorData; |
109 | ConstIteratorData *d; | 109 | ConstIteratorData *d; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | Constructs a address book object. | 113 | Constructs a address book object. |
114 | 114 | ||
115 | @param format File format class. | 115 | @param format File format class. |
116 | */ | 116 | */ |
117 | AddressBook(); | 117 | AddressBook(); |
118 | AddressBook( const QString &config ); | 118 | AddressBook( const QString &config ); |
119 | AddressBook( const QString &config, const QString &family ); | 119 | AddressBook( const QString &config, const QString &family ); |
120 | virtual ~AddressBook(); | 120 | virtual ~AddressBook(); |
121 | 121 | ||
122 | /** | 122 | /** |
123 | Requests a ticket for saving the addressbook. Calling this function locks | 123 | Requests a ticket for saving the addressbook. Calling this function locks |
124 | the addressbook for all other processes. If the address book is already | 124 | the addressbook for all other processes. If the address book is already |
125 | locked the function returns 0. You need the returned @ref Ticket object | 125 | locked the function returns 0. You need the returned @ref Ticket object |
126 | for calling the @ref save() function. | 126 | for calling the @ref save() function. |
127 | 127 | ||
128 | @see save() | 128 | @see save() |
129 | */ | 129 | */ |
130 | Ticket *requestSaveTicket( Resource *resource=0 ); | 130 | Ticket *requestSaveTicket( Resource *resource=0 ); |
131 | 131 | ||
132 | /** | 132 | /** |
133 | Load address book from file. | 133 | Load address book from file. |
134 | */ | 134 | */ |
135 | bool load(); | 135 | bool load(); |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Save address book. The address book is saved to the file, the Ticket | 138 | Save address book. The address book is saved to the file, the Ticket |
139 | object has been requested for by @ref requestSaveTicket(). | 139 | object has been requested for by @ref requestSaveTicket(). |
140 | 140 | ||
141 | @param ticket a ticket object returned by @ref requestSaveTicket() | 141 | @param ticket a ticket object returned by @ref requestSaveTicket() |
142 | */ | 142 | */ |
143 | bool save( Ticket *ticket ); | 143 | bool save( Ticket *ticket ); |
144 | bool saveAB( ); | 144 | bool saveAB( ); |
145 | 145 | ||
146 | /** | 146 | /** |
147 | Returns a iterator for first entry of address book. | 147 | Returns a iterator for first entry of address book. |
148 | */ | 148 | */ |
149 | Iterator begin(); | 149 | Iterator begin(); |
150 | 150 | ||
151 | /** | 151 | /** |
152 | Returns a const iterator for first entry of address book. | 152 | Returns a const iterator for first entry of address book. |
153 | */ | 153 | */ |
154 | ConstIterator begin() const; | 154 | ConstIterator begin() const; |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Returns a iterator for first entry of address book. | 157 | Returns a iterator for first entry of address book. |
158 | */ | 158 | */ |
159 | Iterator end(); | 159 | Iterator end(); |
160 | 160 | ||
161 | /** | 161 | /** |
162 | Returns a const iterator for first entry of address book. | 162 | Returns a const iterator for first entry of address book. |
163 | */ | 163 | */ |
164 | ConstIterator end() const; | 164 | ConstIterator end() const; |
165 | 165 | ||
166 | /** | 166 | /** |
167 | Removes all entries from address book. | 167 | Removes all entries from address book. |
168 | */ | 168 | */ |
169 | void clear(); | 169 | void clear(); |
170 | 170 | ||
171 | /** | 171 | /** |
172 | Insert an Addressee object into address book. If an object with the same | 172 | Insert an Addressee object into address book. If an object with the same |
173 | unique id already exists in the address book it it replaced by the new | 173 | unique id already exists in the address book it it replaced by the new |
174 | one. If not the new object is appended to the address book. | 174 | one. If not the new object is appended to the address book. |
175 | */ | 175 | */ |
176 | void insertAddressee( const Addressee & ); | 176 | void insertAddressee( const Addressee & ); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | Removes entry from the address book. | 179 | Removes entry from the address book. |
180 | */ | 180 | */ |
181 | void removeAddressee( const Addressee & ); | 181 | void removeAddressee( const Addressee & ); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | This is like @ref removeAddressee() just above, with the difference that | 184 | This is like @ref removeAddressee() just above, with the difference that |
185 | the first element is a iterator, returned by @ref begin(). | 185 | the first element is a iterator, returned by @ref begin(). |
186 | */ | 186 | */ |
187 | void removeAddressee( const Iterator & ); | 187 | void removeAddressee( const Iterator & ); |
188 | 188 | ||
189 | /** | 189 | /** |
190 | Find the specified entry in address book. Returns end(), if the entry | 190 | Find the specified entry in address book. Returns end(), if the entry |
191 | couldn't be found. | 191 | couldn't be found. |
192 | */ | 192 | */ |
193 | Iterator find( const Addressee & ); | 193 | Iterator find( const Addressee & ); |
194 | 194 | ||
195 | /** | 195 | /** |
196 | Find the entry specified by an unique id. Returns an empty Addressee | 196 | Find the entry specified by an unique id. Returns an empty Addressee |
197 | object, if the address book does not contain an entry with this id. | 197 | object, if the address book does not contain an entry with this id. |
198 | */ | 198 | */ |
199 | Addressee findByUid( const QString & ); | 199 | Addressee findByUid( const QString & ); |
200 | 200 | ||
201 | 201 | ||
202 | /** | 202 | /** |
203 | Returns a list of all addressees in the address book. This list can | 203 | Returns a list of all addressees in the address book. This list can |
204 | be sorted with @ref KABC::AddresseeList for example. | 204 | be sorted with @ref KABC::AddresseeList for example. |
205 | */ | 205 | */ |
206 | Addressee::List allAddressees(); | 206 | Addressee::List allAddressees(); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Find all entries with the specified name in the address book. Returns | 209 | Find all entries with the specified name in the address book. Returns |
210 | an empty list, if no entries could be found. | 210 | an empty list, if no entries could be found. |
211 | */ | 211 | */ |
212 | Addressee::List findByName( const QString & ); | 212 | Addressee::List findByName( const QString & ); |
213 | 213 | ||
214 | /** | 214 | /** |
215 | Find all entries with the specified email address in the address book. | 215 | Find all entries with the specified email address in the address book. |
216 | Returns an empty list, if no entries could be found. | 216 | Returns an empty list, if no entries could be found. |
217 | */ | 217 | */ |
218 | Addressee::List findByEmail( const QString & ); | 218 | Addressee::List findByEmail( const QString & ); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | Find all entries wich have the specified category in the address book. | 221 | Find all entries wich have the specified category in the address book. |
222 | Returns an empty list, if no entries could be found. | 222 | Returns an empty list, if no entries could be found. |
223 | */ | 223 | */ |
224 | Addressee::List findByCategory( const QString & ); | 224 | Addressee::List findByCategory( const QString & ); |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Return a string identifying this addressbook. | 227 | Return a string identifying this addressbook. |
228 | */ | 228 | */ |
229 | virtual QString identifier(); | 229 | virtual QString identifier(); |
230 | 230 | ||
231 | /** | 231 | /** |
232 | Used for debug output. | 232 | Used for debug output. |
233 | */ | 233 | */ |
234 | void dump() const; | 234 | void dump() const; |
235 | 235 | ||
236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } | 236 | void emitAddressBookLocked() { emit addressBookLocked( this ); } |
237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } | 237 | void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } |
238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } | 238 | void emitAddressBookChanged() { emit addressBookChanged( this ); } |
239 | 239 | ||
240 | /** | 240 | /** |
241 | Return list of all Fields known to the address book which are associated | 241 | Return list of all Fields known to the address book which are associated |
242 | with the given field category. | 242 | with the given field category. |
243 | */ | 243 | */ |
244 | Field::List fields( int category = Field::All ); | 244 | Field::List fields( int category = Field::All ); |
245 | 245 | ||
246 | /** | 246 | /** |
247 | Add custom field to address book. | 247 | Add custom field to address book. |
248 | 248 | ||
249 | @param label User visible label of the field. | 249 | @param label User visible label of the field. |
250 | @param category Ored list of field categories. | 250 | @param category Ored list of field categories. |
251 | @param key Identifier used as key for reading and writing the field. | 251 | @param key Identifier used as key for reading and writing the field. |
252 | @param app String used as application key for reading and writing | 252 | @param app String used as application key for reading and writing |
253 | the field. | 253 | the field. |
254 | */ | 254 | */ |
255 | bool addCustomField( const QString &label, int category = Field::All, | 255 | bool addCustomField( const QString &label, int category = Field::All, |
256 | const QString &key = QString::null, | 256 | const QString &key = QString::null, |
257 | const QString &app = QString::null ); | 257 | const QString &app = QString::null ); |
258 | 258 | ||
259 | 259 | ||
260 | /** | 260 | /** |
261 | Add address book resource. | 261 | Add address book resource. |
262 | */ | 262 | */ |
263 | bool addResource( Resource * ); | 263 | bool addResource( Resource * ); |
264 | 264 | ||
265 | /** | 265 | /** |
266 | Remove address book resource. | 266 | Remove address book resource. |
267 | */ | 267 | */ |
268 | bool removeResource( Resource * ); | 268 | bool removeResource( Resource * ); |
269 | 269 | ||
270 | /** | 270 | /** |
271 | Return pointer list of all resources. | 271 | Return pointer list of all resources. |
272 | */ | 272 | */ |
273 | QPtrList<Resource> resources(); | 273 | QPtrList<Resource> resources(); |
274 | 274 | ||
275 | /** | 275 | /** |
276 | Set the @p ErrorHandler, that is used by @ref error() to | 276 | Set the @p ErrorHandler, that is used by @ref error() to |
277 | provide gui-independend error messages. | 277 | provide gui-independend error messages. |
278 | */ | 278 | */ |
279 | void setErrorHandler( ErrorHandler * ); | 279 | void setErrorHandler( ErrorHandler * ); |
280 | 280 | ||
281 | /** | 281 | /** |
282 | Shows gui independend error messages. | 282 | Shows gui independend error messages. |
283 | */ | 283 | */ |
284 | void error( const QString& ); | 284 | void error( const QString& ); |
285 | 285 | ||
286 | /** | 286 | /** |
287 | Query all resources to clean up their lock files | 287 | Query all resources to clean up their lock files |
288 | */ | 288 | */ |
289 | void cleanUp(); | 289 | void cleanUp(); |
290 | 290 | ||
291 | // sync stuff | ||
292 | Addressee::List getExternLastSyncAddressees(); | ||
293 | void resetTempSyncStat(); | ||
294 | |||
295 | |||
291 | signals: | 296 | signals: |
292 | /** | 297 | /** |
293 | Emitted, when the address book has changed on disk. | 298 | Emitted, when the address book has changed on disk. |
294 | */ | 299 | */ |
295 | void addressBookChanged( AddressBook * ); | 300 | void addressBookChanged( AddressBook * ); |
296 | 301 | ||
297 | /** | 302 | /** |
298 | Emitted, when the address book has been locked for writing. | 303 | Emitted, when the address book has been locked for writing. |
299 | */ | 304 | */ |
300 | void addressBookLocked( AddressBook * ); | 305 | void addressBookLocked( AddressBook * ); |
301 | 306 | ||
302 | /** | 307 | /** |
303 | Emitted, when the address book has been unlocked. | 308 | Emitted, when the address book has been unlocked. |
304 | */ | 309 | */ |
305 | void addressBookUnlocked( AddressBook * ); | 310 | void addressBookUnlocked( AddressBook * ); |
306 | 311 | ||
307 | protected: | 312 | protected: |
308 | void deleteRemovedAddressees(); | 313 | void deleteRemovedAddressees(); |
309 | void setStandardResource( Resource * ); | 314 | void setStandardResource( Resource * ); |
310 | Resource *standardResource(); | 315 | Resource *standardResource(); |
311 | KRES::Manager<Resource> *resourceManager(); | 316 | KRES::Manager<Resource> *resourceManager(); |
312 | 317 | ||
313 | void init(const QString &config, const QString &family); | 318 | void init(const QString &config, const QString &family); |
314 | 319 | ||
315 | private: | 320 | private: |
316 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 | 321 | //US QPtrList<Resource> mDummy; // Remove in KDE 4 |
317 | 322 | ||
318 | 323 | ||
319 | struct AddressBookData; | 324 | struct AddressBookData; |
320 | AddressBookData *d; | 325 | AddressBookData *d; |
321 | }; | 326 | }; |
322 | 327 | ||
323 | QDataStream &operator<<( QDataStream &, const AddressBook & ); | 328 | QDataStream &operator<<( QDataStream &, const AddressBook & ); |
324 | QDataStream &operator>>( QDataStream &, AddressBook & ); | 329 | QDataStream &operator>>( QDataStream &, AddressBook & ); |
325 | 330 | ||
326 | } | 331 | } |
327 | 332 | ||
328 | #endif | 333 | #endif |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index 4cdd5e5..fb32f6e 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -1,1630 +1,1682 @@ | |||
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 | //US | 36 | //US |
36 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <libkcal/syncdefines.h> | ||
37 | 39 | ||
38 | //US #include "resource.h" | 40 | //US #include "resource.h" |
39 | #include "addressee.h" | 41 | #include "addressee.h" |
40 | 42 | ||
41 | using namespace KABC; | 43 | using namespace KABC; |
42 | 44 | ||
43 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
44 | 46 | ||
45 | struct Addressee::AddresseeData : public KShared | 47 | struct Addressee::AddresseeData : public KShared |
46 | { | 48 | { |
47 | QString uid; | 49 | QString uid; |
48 | QString name; | 50 | QString name; |
49 | QString formattedName; | 51 | QString formattedName; |
50 | QString familyName; | 52 | QString familyName; |
51 | QString givenName; | 53 | QString givenName; |
52 | QString additionalName; | 54 | QString additionalName; |
53 | QString prefix; | 55 | QString prefix; |
54 | QString suffix; | 56 | QString suffix; |
55 | QString nickName; | 57 | QString nickName; |
56 | QDateTime birthday; | 58 | QDateTime birthday; |
57 | QString mailer; | 59 | QString mailer; |
58 | TimeZone timeZone; | 60 | TimeZone timeZone; |
59 | Geo geo; | 61 | Geo geo; |
60 | QString title; | 62 | QString title; |
61 | QString role; | 63 | QString role; |
62 | QString organization; | 64 | QString organization; |
63 | QString note; | 65 | QString note; |
64 | QString productId; | 66 | QString productId; |
65 | QDateTime revision; | 67 | QDateTime revision; |
66 | QString sortString; | 68 | QString sortString; |
67 | KURL url; | 69 | KURL url; |
68 | Secrecy secrecy; | 70 | Secrecy secrecy; |
69 | Picture logo; | 71 | Picture logo; |
70 | Picture photo; | 72 | Picture photo; |
71 | Sound sound; | 73 | Sound sound; |
72 | Agent agent; | 74 | Agent agent; |
73 | 75 | QString mExternalId; | |
74 | PhoneNumber::List phoneNumbers; | 76 | PhoneNumber::List phoneNumbers; |
75 | Address::List addresses; | 77 | Address::List addresses; |
76 | Key::List keys; | 78 | Key::List keys; |
77 | QStringList emails; | 79 | QStringList emails; |
78 | QStringList categories; | 80 | QStringList categories; |
79 | QStringList custom; | 81 | QStringList custom; |
80 | 82 | ||
81 | Resource *resource; | 83 | Resource *resource; |
82 | 84 | ||
83 | bool empty :1; | 85 | bool empty :1; |
84 | bool changed :1; | 86 | bool changed :1; |
85 | }; | 87 | }; |
86 | 88 | ||
87 | Addressee::Addressee() | 89 | Addressee::Addressee() |
88 | { | 90 | { |
89 | mData = new AddresseeData; | 91 | mData = new AddresseeData; |
90 | mData->empty = true; | 92 | mData->empty = true; |
91 | mData->changed = false; | 93 | mData->changed = false; |
92 | mData->resource = 0; | 94 | mData->resource = 0; |
95 | mData->mExternalId = ":"; | ||
96 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
93 | } | 97 | } |
94 | 98 | ||
95 | Addressee::~Addressee() | 99 | Addressee::~Addressee() |
96 | { | 100 | { |
97 | } | 101 | } |
98 | 102 | ||
99 | Addressee::Addressee( const Addressee &a ) | 103 | Addressee::Addressee( const Addressee &a ) |
100 | { | 104 | { |
101 | mData = a.mData; | 105 | mData = a.mData; |
106 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | ||
102 | } | 107 | } |
103 | 108 | ||
104 | Addressee &Addressee::operator=( const Addressee &a ) | 109 | Addressee &Addressee::operator=( const Addressee &a ) |
105 | { | 110 | { |
106 | mData = a.mData; | 111 | mData = a.mData; |
107 | return (*this); | 112 | return (*this); |
108 | } | 113 | } |
109 | 114 | ||
110 | Addressee Addressee::copy() | 115 | Addressee Addressee::copy() |
111 | { | 116 | { |
112 | Addressee a; | 117 | Addressee a; |
113 | *(a.mData) = *mData; | 118 | *(a.mData) = *mData; |
114 | return a; | 119 | return a; |
115 | } | 120 | } |
116 | 121 | ||
117 | void Addressee::detach() | 122 | void Addressee::detach() |
118 | { | 123 | { |
119 | if ( mData.count() == 1 ) return; | 124 | if ( mData.count() == 1 ) return; |
120 | *this = copy(); | 125 | *this = copy(); |
121 | } | 126 | } |
122 | 127 | ||
123 | bool Addressee::operator==( const Addressee &a ) const | 128 | bool Addressee::operator==( const Addressee &a ) const |
124 | { | 129 | { |
125 | if ( uid() != a.uid() ) return false; | 130 | if ( uid() != a.uid() ) return false; |
126 | if ( mData->name != a.mData->name ) return false; | 131 | if ( mData->name != a.mData->name ) return false; |
127 | if ( mData->formattedName != a.mData->formattedName ) return false; | 132 | if ( mData->formattedName != a.mData->formattedName ) return false; |
128 | if ( mData->familyName != a.mData->familyName ) return false; | 133 | if ( mData->familyName != a.mData->familyName ) return false; |
129 | if ( mData->givenName != a.mData->givenName ) return false; | 134 | if ( mData->givenName != a.mData->givenName ) return false; |
130 | if ( mData->additionalName != a.mData->additionalName ) return false; | 135 | if ( mData->additionalName != a.mData->additionalName ) return false; |
131 | if ( mData->prefix != a.mData->prefix ) return false; | 136 | if ( mData->prefix != a.mData->prefix ) return false; |
132 | if ( mData->suffix != a.mData->suffix ) return false; | 137 | if ( mData->suffix != a.mData->suffix ) return false; |
133 | if ( mData->nickName != a.mData->nickName ) return false; | 138 | if ( mData->nickName != a.mData->nickName ) return false; |
134 | if ( mData->birthday != a.mData->birthday ) return false; | 139 | if ( mData->birthday != a.mData->birthday ) return false; |
135 | if ( mData->mailer != a.mData->mailer ) return false; | 140 | if ( mData->mailer != a.mData->mailer ) return false; |
136 | if ( mData->timeZone != a.mData->timeZone ) return false; | 141 | if ( mData->timeZone != a.mData->timeZone ) return false; |
137 | if ( mData->geo != a.mData->geo ) return false; | 142 | if ( mData->geo != a.mData->geo ) return false; |
138 | if ( mData->title != a.mData->title ) return false; | 143 | if ( mData->title != a.mData->title ) return false; |
139 | if ( mData->role != a.mData->role ) return false; | 144 | if ( mData->role != a.mData->role ) return false; |
140 | if ( mData->organization != a.mData->organization ) return false; | 145 | if ( mData->organization != a.mData->organization ) return false; |
141 | if ( mData->note != a.mData->note ) return false; | 146 | if ( mData->note != a.mData->note ) return false; |
142 | if ( mData->productId != a.mData->productId ) return false; | 147 | if ( mData->productId != a.mData->productId ) return false; |
143 | if ( mData->revision != a.mData->revision ) return false; | 148 | if ( mData->revision != a.mData->revision ) return false; |
144 | if ( mData->sortString != a.mData->sortString ) return false; | 149 | if ( mData->sortString != a.mData->sortString ) return false; |
145 | if ( mData->secrecy != a.mData->secrecy ) return false; | 150 | if ( mData->secrecy != a.mData->secrecy ) return false; |
146 | if ( mData->logo != a.mData->logo ) return false; | 151 | if ( mData->logo != a.mData->logo ) return false; |
147 | if ( mData->photo != a.mData->photo ) return false; | 152 | if ( mData->photo != a.mData->photo ) return false; |
148 | if ( mData->sound != a.mData->sound ) return false; | 153 | if ( mData->sound != a.mData->sound ) return false; |
149 | if ( mData->agent != a.mData->agent ) return false; | 154 | if ( mData->agent != a.mData->agent ) return false; |
150 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && | 155 | if ( ( mData->url.isValid() || a.mData->url.isValid() ) && |
151 | ( mData->url != a.mData->url ) ) return false; | 156 | ( mData->url != a.mData->url ) ) return false; |
152 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; | 157 | if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false; |
153 | if ( mData->addresses != a.mData->addresses ) return false; | 158 | if ( mData->addresses != a.mData->addresses ) return false; |
154 | if ( mData->keys != a.mData->keys ) return false; | 159 | if ( mData->keys != a.mData->keys ) return false; |
155 | if ( mData->emails != a.mData->emails ) return false; | 160 | if ( mData->emails != a.mData->emails ) return false; |
156 | if ( mData->categories != a.mData->categories ) return false; | 161 | if ( mData->categories != a.mData->categories ) return false; |
157 | if ( mData->custom != a.mData->custom ) return false; | 162 | if ( mData->custom != a.mData->custom ) return false; |
158 | 163 | ||
159 | return true; | 164 | return true; |
160 | } | 165 | } |
161 | 166 | ||
162 | bool Addressee::operator!=( const Addressee &a ) const | 167 | bool Addressee::operator!=( const Addressee &a ) const |
163 | { | 168 | { |
164 | return !( a == *this ); | 169 | return !( a == *this ); |
165 | } | 170 | } |
166 | 171 | ||
167 | bool Addressee::isEmpty() const | 172 | bool Addressee::isEmpty() const |
168 | { | 173 | { |
169 | return mData->empty; | 174 | return mData->empty; |
170 | } | 175 | } |
176 | void Addressee::removeID(const QString &prof) | ||
177 | { | ||
178 | detach(); | ||
179 | mData->mExternalId = KIdManager::removeId ( mData->mExternalId, prof); | ||
180 | |||
181 | } | ||
182 | void Addressee::setID( const QString & prof , const QString & id ) | ||
183 | { | ||
184 | detach(); | ||
185 | mData->mExternalId = KIdManager::setId ( mData->mExternalId, prof, id ); | ||
186 | } | ||
187 | void Addressee::setTempSyncStat( int id ) | ||
188 | { | ||
189 | mTempSyncStat = id; | ||
190 | } | ||
191 | int Addressee::tempSyncStat() const | ||
192 | { | ||
193 | return mTempSyncStat; | ||
194 | } | ||
195 | |||
196 | QString Addressee::getID( const QString & prof) | ||
197 | { | ||
198 | return KIdManager::getId ( mData->mExternalId, prof ); | ||
199 | } | ||
200 | |||
201 | void Addressee::setCsum( const QString & prof , const QString & id ) | ||
202 | { | ||
203 | detach(); | ||
204 | mData->mExternalId = KIdManager::setCsum ( mData->mExternalId, prof, id ); | ||
205 | } | ||
206 | |||
207 | QString Addressee::getCsum( const QString & prof) | ||
208 | { | ||
209 | return KIdManager::getCsum ( mData->mExternalId, prof ); | ||
210 | } | ||
211 | |||
212 | void Addressee::setIDStr( const QString & s ) | ||
213 | { | ||
214 | detach(); | ||
215 | mData->mExternalId = s; | ||
216 | } | ||
217 | |||
218 | QString Addressee::IDStr() const | ||
219 | { | ||
220 | return mData->mExternalId; | ||
221 | } | ||
222 | |||
171 | 223 | ||
172 | void Addressee::setUid( const QString &id ) | 224 | void Addressee::setUid( const QString &id ) |
173 | { | 225 | { |
174 | if ( id == mData->uid ) return; | 226 | if ( id == mData->uid ) return; |
175 | detach(); | 227 | detach(); |
176 | mData->empty = false; | 228 | mData->empty = false; |
177 | mData->uid = id; | 229 | mData->uid = id; |
178 | } | 230 | } |
179 | 231 | ||
180 | QString Addressee::uid() const | 232 | QString Addressee::uid() const |
181 | { | 233 | { |
182 | if ( mData->uid.isEmpty() ) | 234 | if ( mData->uid.isEmpty() ) |
183 | mData->uid = KApplication::randomString( 10 ); | 235 | mData->uid = KApplication::randomString( 10 ); |
184 | 236 | ||
185 | return mData->uid; | 237 | return mData->uid; |
186 | } | 238 | } |
187 | 239 | ||
188 | QString Addressee::uidLabel() | 240 | QString Addressee::uidLabel() |
189 | { | 241 | { |
190 | return i18n("Unique Identifier"); | 242 | return i18n("Unique Identifier"); |
191 | } | 243 | } |
192 | 244 | ||
193 | void Addressee::setName( const QString &name ) | 245 | void Addressee::setName( const QString &name ) |
194 | { | 246 | { |
195 | if ( name == mData->name ) return; | 247 | if ( name == mData->name ) return; |
196 | detach(); | 248 | detach(); |
197 | mData->empty = false; | 249 | mData->empty = false; |
198 | mData->name = name; | 250 | mData->name = name; |
199 | } | 251 | } |
200 | 252 | ||
201 | QString Addressee::name() const | 253 | QString Addressee::name() const |
202 | { | 254 | { |
203 | return mData->name; | 255 | return mData->name; |
204 | } | 256 | } |
205 | 257 | ||
206 | QString Addressee::nameLabel() | 258 | QString Addressee::nameLabel() |
207 | { | 259 | { |
208 | return i18n("Name"); | 260 | return i18n("Name"); |
209 | } | 261 | } |
210 | 262 | ||
211 | 263 | ||
212 | void Addressee::setFormattedName( const QString &formattedName ) | 264 | void Addressee::setFormattedName( const QString &formattedName ) |
213 | { | 265 | { |
214 | if ( formattedName == mData->formattedName ) return; | 266 | if ( formattedName == mData->formattedName ) return; |
215 | detach(); | 267 | detach(); |
216 | mData->empty = false; | 268 | mData->empty = false; |
217 | mData->formattedName = formattedName; | 269 | mData->formattedName = formattedName; |
218 | } | 270 | } |
219 | 271 | ||
220 | QString Addressee::formattedName() const | 272 | QString Addressee::formattedName() const |
221 | { | 273 | { |
222 | return mData->formattedName; | 274 | return mData->formattedName; |
223 | } | 275 | } |
224 | 276 | ||
225 | QString Addressee::formattedNameLabel() | 277 | QString Addressee::formattedNameLabel() |
226 | { | 278 | { |
227 | return i18n("Formatted Name"); | 279 | return i18n("Formatted Name"); |
228 | } | 280 | } |
229 | 281 | ||
230 | 282 | ||
231 | void Addressee::setFamilyName( const QString &familyName ) | 283 | void Addressee::setFamilyName( const QString &familyName ) |
232 | { | 284 | { |
233 | if ( familyName == mData->familyName ) return; | 285 | if ( familyName == mData->familyName ) return; |
234 | detach(); | 286 | detach(); |
235 | mData->empty = false; | 287 | mData->empty = false; |
236 | mData->familyName = familyName; | 288 | mData->familyName = familyName; |
237 | } | 289 | } |
238 | 290 | ||
239 | QString Addressee::familyName() const | 291 | QString Addressee::familyName() const |
240 | { | 292 | { |
241 | return mData->familyName; | 293 | return mData->familyName; |
242 | } | 294 | } |
243 | 295 | ||
244 | QString Addressee::familyNameLabel() | 296 | QString Addressee::familyNameLabel() |
245 | { | 297 | { |
246 | return i18n("Family Name"); | 298 | return i18n("Family Name"); |
247 | } | 299 | } |
248 | 300 | ||
249 | 301 | ||
250 | void Addressee::setGivenName( const QString &givenName ) | 302 | void Addressee::setGivenName( const QString &givenName ) |
251 | { | 303 | { |
252 | if ( givenName == mData->givenName ) return; | 304 | if ( givenName == mData->givenName ) return; |
253 | detach(); | 305 | detach(); |
254 | mData->empty = false; | 306 | mData->empty = false; |
255 | mData->givenName = givenName; | 307 | mData->givenName = givenName; |
256 | } | 308 | } |
257 | 309 | ||
258 | QString Addressee::givenName() const | 310 | QString Addressee::givenName() const |
259 | { | 311 | { |
260 | return mData->givenName; | 312 | return mData->givenName; |
261 | } | 313 | } |
262 | 314 | ||
263 | QString Addressee::givenNameLabel() | 315 | QString Addressee::givenNameLabel() |
264 | { | 316 | { |
265 | return i18n("Given Name"); | 317 | return i18n("Given Name"); |
266 | } | 318 | } |
267 | 319 | ||
268 | 320 | ||
269 | void Addressee::setAdditionalName( const QString &additionalName ) | 321 | void Addressee::setAdditionalName( const QString &additionalName ) |
270 | { | 322 | { |
271 | if ( additionalName == mData->additionalName ) return; | 323 | if ( additionalName == mData->additionalName ) return; |
272 | detach(); | 324 | detach(); |
273 | mData->empty = false; | 325 | mData->empty = false; |
274 | mData->additionalName = additionalName; | 326 | mData->additionalName = additionalName; |
275 | } | 327 | } |
276 | 328 | ||
277 | QString Addressee::additionalName() const | 329 | QString Addressee::additionalName() const |
278 | { | 330 | { |
279 | return mData->additionalName; | 331 | return mData->additionalName; |
280 | } | 332 | } |
281 | 333 | ||
282 | QString Addressee::additionalNameLabel() | 334 | QString Addressee::additionalNameLabel() |
283 | { | 335 | { |
284 | return i18n("Additional Names"); | 336 | return i18n("Additional Names"); |
285 | } | 337 | } |
286 | 338 | ||
287 | 339 | ||
288 | void Addressee::setPrefix( const QString &prefix ) | 340 | void Addressee::setPrefix( const QString &prefix ) |
289 | { | 341 | { |
290 | if ( prefix == mData->prefix ) return; | 342 | if ( prefix == mData->prefix ) return; |
291 | detach(); | 343 | detach(); |
292 | mData->empty = false; | 344 | mData->empty = false; |
293 | mData->prefix = prefix; | 345 | mData->prefix = prefix; |
294 | } | 346 | } |
295 | 347 | ||
296 | QString Addressee::prefix() const | 348 | QString Addressee::prefix() const |
297 | { | 349 | { |
298 | return mData->prefix; | 350 | return mData->prefix; |
299 | } | 351 | } |
300 | 352 | ||
301 | QString Addressee::prefixLabel() | 353 | QString Addressee::prefixLabel() |
302 | { | 354 | { |
303 | return i18n("Honorific Prefixes"); | 355 | return i18n("Honorific Prefixes"); |
304 | } | 356 | } |
305 | 357 | ||
306 | 358 | ||
307 | void Addressee::setSuffix( const QString &suffix ) | 359 | void Addressee::setSuffix( const QString &suffix ) |
308 | { | 360 | { |
309 | if ( suffix == mData->suffix ) return; | 361 | if ( suffix == mData->suffix ) return; |
310 | detach(); | 362 | detach(); |
311 | mData->empty = false; | 363 | mData->empty = false; |
312 | mData->suffix = suffix; | 364 | mData->suffix = suffix; |
313 | } | 365 | } |
314 | 366 | ||
315 | QString Addressee::suffix() const | 367 | QString Addressee::suffix() const |
316 | { | 368 | { |
317 | return mData->suffix; | 369 | return mData->suffix; |
318 | } | 370 | } |
319 | 371 | ||
320 | QString Addressee::suffixLabel() | 372 | QString Addressee::suffixLabel() |
321 | { | 373 | { |
322 | return i18n("Honorific Suffixes"); | 374 | return i18n("Honorific Suffixes"); |
323 | } | 375 | } |
324 | 376 | ||
325 | 377 | ||
326 | void Addressee::setNickName( const QString &nickName ) | 378 | void Addressee::setNickName( const QString &nickName ) |
327 | { | 379 | { |
328 | if ( nickName == mData->nickName ) return; | 380 | if ( nickName == mData->nickName ) return; |
329 | detach(); | 381 | detach(); |
330 | mData->empty = false; | 382 | mData->empty = false; |
331 | mData->nickName = nickName; | 383 | mData->nickName = nickName; |
332 | } | 384 | } |
333 | 385 | ||
334 | QString Addressee::nickName() const | 386 | QString Addressee::nickName() const |
335 | { | 387 | { |
336 | return mData->nickName; | 388 | return mData->nickName; |
337 | } | 389 | } |
338 | 390 | ||
339 | QString Addressee::nickNameLabel() | 391 | QString Addressee::nickNameLabel() |
340 | { | 392 | { |
341 | return i18n("Nick Name"); | 393 | return i18n("Nick Name"); |
342 | } | 394 | } |
343 | 395 | ||
344 | 396 | ||
345 | void Addressee::setBirthday( const QDateTime &birthday ) | 397 | void Addressee::setBirthday( const QDateTime &birthday ) |
346 | { | 398 | { |
347 | if ( birthday == mData->birthday ) return; | 399 | if ( birthday == mData->birthday ) return; |
348 | detach(); | 400 | detach(); |
349 | mData->empty = false; | 401 | mData->empty = false; |
350 | mData->birthday = birthday; | 402 | mData->birthday = birthday; |
351 | } | 403 | } |
352 | 404 | ||
353 | QDateTime Addressee::birthday() const | 405 | QDateTime Addressee::birthday() const |
354 | { | 406 | { |
355 | return mData->birthday; | 407 | return mData->birthday; |
356 | } | 408 | } |
357 | 409 | ||
358 | QString Addressee::birthdayLabel() | 410 | QString Addressee::birthdayLabel() |
359 | { | 411 | { |
360 | return i18n("Birthday"); | 412 | return i18n("Birthday"); |
361 | } | 413 | } |
362 | 414 | ||
363 | 415 | ||
364 | QString Addressee::homeAddressStreetLabel() | 416 | QString Addressee::homeAddressStreetLabel() |
365 | { | 417 | { |
366 | return i18n("Home Address Street"); | 418 | return i18n("Home Address Street"); |
367 | } | 419 | } |
368 | 420 | ||
369 | 421 | ||
370 | QString Addressee::homeAddressLocalityLabel() | 422 | QString Addressee::homeAddressLocalityLabel() |
371 | { | 423 | { |
372 | return i18n("Home Address Locality"); | 424 | return i18n("Home Address Locality"); |
373 | } | 425 | } |
374 | 426 | ||
375 | 427 | ||
376 | QString Addressee::homeAddressRegionLabel() | 428 | QString Addressee::homeAddressRegionLabel() |
377 | { | 429 | { |
378 | return i18n("Home Address Region"); | 430 | return i18n("Home Address Region"); |
379 | } | 431 | } |
380 | 432 | ||
381 | 433 | ||
382 | QString Addressee::homeAddressPostalCodeLabel() | 434 | QString Addressee::homeAddressPostalCodeLabel() |
383 | { | 435 | { |
384 | return i18n("Home Address Postal Code"); | 436 | return i18n("Home Address Postal Code"); |
385 | } | 437 | } |
386 | 438 | ||
387 | 439 | ||
388 | QString Addressee::homeAddressCountryLabel() | 440 | QString Addressee::homeAddressCountryLabel() |
389 | { | 441 | { |
390 | return i18n("Home Address Country"); | 442 | return i18n("Home Address Country"); |
391 | } | 443 | } |
392 | 444 | ||
393 | 445 | ||
394 | QString Addressee::homeAddressLabelLabel() | 446 | QString Addressee::homeAddressLabelLabel() |
395 | { | 447 | { |
396 | return i18n("Home Address Label"); | 448 | return i18n("Home Address Label"); |
397 | } | 449 | } |
398 | 450 | ||
399 | 451 | ||
400 | QString Addressee::businessAddressStreetLabel() | 452 | QString Addressee::businessAddressStreetLabel() |
401 | { | 453 | { |
402 | return i18n("Business Address Street"); | 454 | return i18n("Business Address Street"); |
403 | } | 455 | } |
404 | 456 | ||
405 | 457 | ||
406 | QString Addressee::businessAddressLocalityLabel() | 458 | QString Addressee::businessAddressLocalityLabel() |
407 | { | 459 | { |
408 | return i18n("Business Address Locality"); | 460 | return i18n("Business Address Locality"); |
409 | } | 461 | } |
410 | 462 | ||
411 | 463 | ||
412 | QString Addressee::businessAddressRegionLabel() | 464 | QString Addressee::businessAddressRegionLabel() |
413 | { | 465 | { |
414 | return i18n("Business Address Region"); | 466 | return i18n("Business Address Region"); |
415 | } | 467 | } |
416 | 468 | ||
417 | 469 | ||
418 | QString Addressee::businessAddressPostalCodeLabel() | 470 | QString Addressee::businessAddressPostalCodeLabel() |
419 | { | 471 | { |
420 | return i18n("Business Address Postal Code"); | 472 | return i18n("Business Address Postal Code"); |
421 | } | 473 | } |
422 | 474 | ||
423 | 475 | ||
424 | QString Addressee::businessAddressCountryLabel() | 476 | QString Addressee::businessAddressCountryLabel() |
425 | { | 477 | { |
426 | return i18n("Business Address Country"); | 478 | return i18n("Business Address Country"); |
427 | } | 479 | } |
428 | 480 | ||
429 | 481 | ||
430 | QString Addressee::businessAddressLabelLabel() | 482 | QString Addressee::businessAddressLabelLabel() |
431 | { | 483 | { |
432 | return i18n("Business Address Label"); | 484 | return i18n("Business Address Label"); |
433 | } | 485 | } |
434 | 486 | ||
435 | 487 | ||
436 | QString Addressee::homePhoneLabel() | 488 | QString Addressee::homePhoneLabel() |
437 | { | 489 | { |
438 | return i18n("Home Phone"); | 490 | return i18n("Home Phone"); |
439 | } | 491 | } |
440 | 492 | ||
441 | 493 | ||
442 | QString Addressee::businessPhoneLabel() | 494 | QString Addressee::businessPhoneLabel() |
443 | { | 495 | { |
444 | return i18n("Business Phone"); | 496 | return i18n("Business Phone"); |
445 | } | 497 | } |
446 | 498 | ||
447 | 499 | ||
448 | QString Addressee::mobilePhoneLabel() | 500 | QString Addressee::mobilePhoneLabel() |
449 | { | 501 | { |
450 | return i18n("Mobile Phone"); | 502 | return i18n("Mobile Phone"); |
451 | } | 503 | } |
452 | 504 | ||
453 | 505 | ||
454 | QString Addressee::homeFaxLabel() | 506 | QString Addressee::homeFaxLabel() |
455 | { | 507 | { |
456 | return i18n("Home Fax"); | 508 | return i18n("Home Fax"); |
457 | } | 509 | } |
458 | 510 | ||
459 | 511 | ||
460 | QString Addressee::businessFaxLabel() | 512 | QString Addressee::businessFaxLabel() |
461 | { | 513 | { |
462 | return i18n("Business Fax"); | 514 | return i18n("Business Fax"); |
463 | } | 515 | } |
464 | 516 | ||
465 | 517 | ||
466 | QString Addressee::carPhoneLabel() | 518 | QString Addressee::carPhoneLabel() |
467 | { | 519 | { |
468 | return i18n("Car Phone"); | 520 | return i18n("Car Phone"); |
469 | } | 521 | } |
470 | 522 | ||
471 | 523 | ||
472 | QString Addressee::isdnLabel() | 524 | QString Addressee::isdnLabel() |
473 | { | 525 | { |
474 | return i18n("ISDN"); | 526 | return i18n("ISDN"); |
475 | } | 527 | } |
476 | 528 | ||
477 | 529 | ||
478 | QString Addressee::pagerLabel() | 530 | QString Addressee::pagerLabel() |
479 | { | 531 | { |
480 | return i18n("Pager"); | 532 | return i18n("Pager"); |
481 | } | 533 | } |
482 | 534 | ||
483 | QString Addressee::sipLabel() | 535 | QString Addressee::sipLabel() |
484 | { | 536 | { |
485 | return i18n("SIP"); | 537 | return i18n("SIP"); |
486 | } | 538 | } |
487 | 539 | ||
488 | QString Addressee::emailLabel() | 540 | QString Addressee::emailLabel() |
489 | { | 541 | { |
490 | return i18n("Email Address"); | 542 | return i18n("Email Address"); |
491 | } | 543 | } |
492 | 544 | ||
493 | 545 | ||
494 | void Addressee::setMailer( const QString &mailer ) | 546 | void Addressee::setMailer( const QString &mailer ) |
495 | { | 547 | { |
496 | if ( mailer == mData->mailer ) return; | 548 | if ( mailer == mData->mailer ) return; |
497 | detach(); | 549 | detach(); |
498 | mData->empty = false; | 550 | mData->empty = false; |
499 | mData->mailer = mailer; | 551 | mData->mailer = mailer; |
500 | } | 552 | } |
501 | 553 | ||
502 | QString Addressee::mailer() const | 554 | QString Addressee::mailer() const |
503 | { | 555 | { |
504 | return mData->mailer; | 556 | return mData->mailer; |
505 | } | 557 | } |
506 | 558 | ||
507 | QString Addressee::mailerLabel() | 559 | QString Addressee::mailerLabel() |
508 | { | 560 | { |
509 | return i18n("Mail Client"); | 561 | return i18n("Mail Client"); |
510 | } | 562 | } |
511 | 563 | ||
512 | 564 | ||
513 | void Addressee::setTimeZone( const TimeZone &timeZone ) | 565 | void Addressee::setTimeZone( const TimeZone &timeZone ) |
514 | { | 566 | { |
515 | if ( timeZone == mData->timeZone ) return; | 567 | if ( timeZone == mData->timeZone ) return; |
516 | detach(); | 568 | detach(); |
517 | mData->empty = false; | 569 | mData->empty = false; |
518 | mData->timeZone = timeZone; | 570 | mData->timeZone = timeZone; |
519 | } | 571 | } |
520 | 572 | ||
521 | TimeZone Addressee::timeZone() const | 573 | TimeZone Addressee::timeZone() const |
522 | { | 574 | { |
523 | return mData->timeZone; | 575 | return mData->timeZone; |
524 | } | 576 | } |
525 | 577 | ||
526 | QString Addressee::timeZoneLabel() | 578 | QString Addressee::timeZoneLabel() |
527 | { | 579 | { |
528 | return i18n("Time Zone"); | 580 | return i18n("Time Zone"); |
529 | } | 581 | } |
530 | 582 | ||
531 | 583 | ||
532 | void Addressee::setGeo( const Geo &geo ) | 584 | void Addressee::setGeo( const Geo &geo ) |
533 | { | 585 | { |
534 | if ( geo == mData->geo ) return; | 586 | if ( geo == mData->geo ) return; |
535 | detach(); | 587 | detach(); |
536 | mData->empty = false; | 588 | mData->empty = false; |
537 | mData->geo = geo; | 589 | mData->geo = geo; |
538 | } | 590 | } |
539 | 591 | ||
540 | Geo Addressee::geo() const | 592 | Geo Addressee::geo() const |
541 | { | 593 | { |
542 | return mData->geo; | 594 | return mData->geo; |
543 | } | 595 | } |
544 | 596 | ||
545 | QString Addressee::geoLabel() | 597 | QString Addressee::geoLabel() |
546 | { | 598 | { |
547 | return i18n("Geographic Position"); | 599 | return i18n("Geographic Position"); |
548 | } | 600 | } |
549 | 601 | ||
550 | 602 | ||
551 | void Addressee::setTitle( const QString &title ) | 603 | void Addressee::setTitle( const QString &title ) |
552 | { | 604 | { |
553 | if ( title == mData->title ) return; | 605 | if ( title == mData->title ) return; |
554 | detach(); | 606 | detach(); |
555 | mData->empty = false; | 607 | mData->empty = false; |
556 | mData->title = title; | 608 | mData->title = title; |
557 | } | 609 | } |
558 | 610 | ||
559 | QString Addressee::title() const | 611 | QString Addressee::title() const |
560 | { | 612 | { |
561 | return mData->title; | 613 | return mData->title; |
562 | } | 614 | } |
563 | 615 | ||
564 | QString Addressee::titleLabel() | 616 | QString Addressee::titleLabel() |
565 | { | 617 | { |
566 | return i18n("Title"); | 618 | return i18n("Title"); |
567 | } | 619 | } |
568 | 620 | ||
569 | 621 | ||
570 | void Addressee::setRole( const QString &role ) | 622 | void Addressee::setRole( const QString &role ) |
571 | { | 623 | { |
572 | if ( role == mData->role ) return; | 624 | if ( role == mData->role ) return; |
573 | detach(); | 625 | detach(); |
574 | mData->empty = false; | 626 | mData->empty = false; |
575 | mData->role = role; | 627 | mData->role = role; |
576 | } | 628 | } |
577 | 629 | ||
578 | QString Addressee::role() const | 630 | QString Addressee::role() const |
579 | { | 631 | { |
580 | return mData->role; | 632 | return mData->role; |
581 | } | 633 | } |
582 | 634 | ||
583 | QString Addressee::roleLabel() | 635 | QString Addressee::roleLabel() |
584 | { | 636 | { |
585 | return i18n("Role"); | 637 | return i18n("Role"); |
586 | } | 638 | } |
587 | 639 | ||
588 | 640 | ||
589 | void Addressee::setOrganization( const QString &organization ) | 641 | void Addressee::setOrganization( const QString &organization ) |
590 | { | 642 | { |
591 | if ( organization == mData->organization ) return; | 643 | if ( organization == mData->organization ) return; |
592 | detach(); | 644 | detach(); |
593 | mData->empty = false; | 645 | mData->empty = false; |
594 | mData->organization = organization; | 646 | mData->organization = organization; |
595 | } | 647 | } |
596 | 648 | ||
597 | QString Addressee::organization() const | 649 | QString Addressee::organization() const |
598 | { | 650 | { |
599 | return mData->organization; | 651 | return mData->organization; |
600 | } | 652 | } |
601 | 653 | ||
602 | QString Addressee::organizationLabel() | 654 | QString Addressee::organizationLabel() |
603 | { | 655 | { |
604 | return i18n("Organization"); | 656 | return i18n("Organization"); |
605 | } | 657 | } |
606 | 658 | ||
607 | 659 | ||
608 | void Addressee::setNote( const QString ¬e ) | 660 | void Addressee::setNote( const QString ¬e ) |
609 | { | 661 | { |
610 | if ( note == mData->note ) return; | 662 | if ( note == mData->note ) return; |
611 | detach(); | 663 | detach(); |
612 | mData->empty = false; | 664 | mData->empty = false; |
613 | mData->note = note; | 665 | mData->note = note; |
614 | } | 666 | } |
615 | 667 | ||
616 | QString Addressee::note() const | 668 | QString Addressee::note() const |
617 | { | 669 | { |
618 | return mData->note; | 670 | return mData->note; |
619 | } | 671 | } |
620 | 672 | ||
621 | QString Addressee::noteLabel() | 673 | QString Addressee::noteLabel() |
622 | { | 674 | { |
623 | return i18n("Note"); | 675 | return i18n("Note"); |
624 | } | 676 | } |
625 | 677 | ||
626 | 678 | ||
627 | void Addressee::setProductId( const QString &productId ) | 679 | void Addressee::setProductId( const QString &productId ) |
628 | { | 680 | { |
629 | if ( productId == mData->productId ) return; | 681 | if ( productId == mData->productId ) return; |
630 | detach(); | 682 | detach(); |
631 | mData->empty = false; | 683 | mData->empty = false; |
632 | mData->productId = productId; | 684 | mData->productId = productId; |
633 | } | 685 | } |
634 | 686 | ||
635 | QString Addressee::productId() const | 687 | QString Addressee::productId() const |
636 | { | 688 | { |
637 | return mData->productId; | 689 | return mData->productId; |
638 | } | 690 | } |
639 | 691 | ||
640 | QString Addressee::productIdLabel() | 692 | QString Addressee::productIdLabel() |
641 | { | 693 | { |
642 | return i18n("Product Identifier"); | 694 | return i18n("Product Identifier"); |
643 | } | 695 | } |
644 | 696 | ||
645 | 697 | ||
646 | void Addressee::setRevision( const QDateTime &revision ) | 698 | void Addressee::setRevision( const QDateTime &revision ) |
647 | { | 699 | { |
648 | if ( revision == mData->revision ) return; | 700 | if ( revision == mData->revision ) return; |
649 | detach(); | 701 | detach(); |
650 | mData->empty = false; | 702 | mData->empty = false; |
651 | mData->revision = revision; | 703 | mData->revision = revision; |
652 | } | 704 | } |
653 | 705 | ||
654 | QDateTime Addressee::revision() const | 706 | QDateTime Addressee::revision() const |
655 | { | 707 | { |
656 | return mData->revision; | 708 | return mData->revision; |
657 | } | 709 | } |
658 | 710 | ||
659 | QString Addressee::revisionLabel() | 711 | QString Addressee::revisionLabel() |
660 | { | 712 | { |
661 | return i18n("Revision Date"); | 713 | return i18n("Revision Date"); |
662 | } | 714 | } |
663 | 715 | ||
664 | 716 | ||
665 | void Addressee::setSortString( const QString &sortString ) | 717 | void Addressee::setSortString( const QString &sortString ) |
666 | { | 718 | { |
667 | if ( sortString == mData->sortString ) return; | 719 | if ( sortString == mData->sortString ) return; |
668 | detach(); | 720 | detach(); |
669 | mData->empty = false; | 721 | mData->empty = false; |
670 | mData->sortString = sortString; | 722 | mData->sortString = sortString; |
671 | } | 723 | } |
672 | 724 | ||
673 | QString Addressee::sortString() const | 725 | QString Addressee::sortString() const |
674 | { | 726 | { |
675 | return mData->sortString; | 727 | return mData->sortString; |
676 | } | 728 | } |
677 | 729 | ||
678 | QString Addressee::sortStringLabel() | 730 | QString Addressee::sortStringLabel() |
679 | { | 731 | { |
680 | return i18n("Sort String"); | 732 | return i18n("Sort String"); |
681 | } | 733 | } |
682 | 734 | ||
683 | 735 | ||
684 | void Addressee::setUrl( const KURL &url ) | 736 | void Addressee::setUrl( const KURL &url ) |
685 | { | 737 | { |
686 | if ( url == mData->url ) return; | 738 | if ( url == mData->url ) return; |
687 | detach(); | 739 | detach(); |
688 | mData->empty = false; | 740 | mData->empty = false; |
689 | mData->url = url; | 741 | mData->url = url; |
690 | } | 742 | } |
691 | 743 | ||
692 | KURL Addressee::url() const | 744 | KURL Addressee::url() const |
693 | { | 745 | { |
694 | return mData->url; | 746 | return mData->url; |
695 | } | 747 | } |
696 | 748 | ||
697 | QString Addressee::urlLabel() | 749 | QString Addressee::urlLabel() |
698 | { | 750 | { |
699 | return i18n("URL"); | 751 | return i18n("URL"); |
700 | } | 752 | } |
701 | 753 | ||
702 | 754 | ||
703 | void Addressee::setSecrecy( const Secrecy &secrecy ) | 755 | void Addressee::setSecrecy( const Secrecy &secrecy ) |
704 | { | 756 | { |
705 | if ( secrecy == mData->secrecy ) return; | 757 | if ( secrecy == mData->secrecy ) return; |
706 | detach(); | 758 | detach(); |
707 | mData->empty = false; | 759 | mData->empty = false; |
708 | mData->secrecy = secrecy; | 760 | mData->secrecy = secrecy; |
709 | } | 761 | } |
710 | 762 | ||
711 | Secrecy Addressee::secrecy() const | 763 | Secrecy Addressee::secrecy() const |
712 | { | 764 | { |
713 | return mData->secrecy; | 765 | return mData->secrecy; |
714 | } | 766 | } |
715 | 767 | ||
716 | QString Addressee::secrecyLabel() | 768 | QString Addressee::secrecyLabel() |
717 | { | 769 | { |
718 | return i18n("Security Class"); | 770 | return i18n("Security Class"); |
719 | } | 771 | } |
720 | 772 | ||
721 | 773 | ||
722 | void Addressee::setLogo( const Picture &logo ) | 774 | void Addressee::setLogo( const Picture &logo ) |
723 | { | 775 | { |
724 | if ( logo == mData->logo ) return; | 776 | if ( logo == mData->logo ) return; |
725 | detach(); | 777 | detach(); |
726 | mData->empty = false; | 778 | mData->empty = false; |
727 | mData->logo = logo; | 779 | mData->logo = logo; |
728 | } | 780 | } |
729 | 781 | ||
730 | Picture Addressee::logo() const | 782 | Picture Addressee::logo() const |
731 | { | 783 | { |
732 | return mData->logo; | 784 | return mData->logo; |
733 | } | 785 | } |
734 | 786 | ||
735 | QString Addressee::logoLabel() | 787 | QString Addressee::logoLabel() |
736 | { | 788 | { |
737 | return i18n("Logo"); | 789 | return i18n("Logo"); |
738 | } | 790 | } |
739 | 791 | ||
740 | 792 | ||
741 | void Addressee::setPhoto( const Picture &photo ) | 793 | void Addressee::setPhoto( const Picture &photo ) |
742 | { | 794 | { |
743 | if ( photo == mData->photo ) return; | 795 | if ( photo == mData->photo ) return; |
744 | detach(); | 796 | detach(); |
745 | mData->empty = false; | 797 | mData->empty = false; |
746 | mData->photo = photo; | 798 | mData->photo = photo; |
747 | } | 799 | } |
748 | 800 | ||
749 | Picture Addressee::photo() const | 801 | Picture Addressee::photo() const |
750 | { | 802 | { |
751 | return mData->photo; | 803 | return mData->photo; |
752 | } | 804 | } |
753 | 805 | ||
754 | QString Addressee::photoLabel() | 806 | QString Addressee::photoLabel() |
755 | { | 807 | { |
756 | return i18n("Photo"); | 808 | return i18n("Photo"); |
757 | } | 809 | } |
758 | 810 | ||
759 | 811 | ||
760 | void Addressee::setSound( const Sound &sound ) | 812 | void Addressee::setSound( const Sound &sound ) |
761 | { | 813 | { |
762 | if ( sound == mData->sound ) return; | 814 | if ( sound == mData->sound ) return; |
763 | detach(); | 815 | detach(); |
764 | mData->empty = false; | 816 | mData->empty = false; |
765 | mData->sound = sound; | 817 | mData->sound = sound; |
766 | } | 818 | } |
767 | 819 | ||
768 | Sound Addressee::sound() const | 820 | Sound Addressee::sound() const |
769 | { | 821 | { |
770 | return mData->sound; | 822 | return mData->sound; |
771 | } | 823 | } |
772 | 824 | ||
773 | QString Addressee::soundLabel() | 825 | QString Addressee::soundLabel() |
774 | { | 826 | { |
775 | return i18n("Sound"); | 827 | return i18n("Sound"); |
776 | } | 828 | } |
777 | 829 | ||
778 | 830 | ||
779 | void Addressee::setAgent( const Agent &agent ) | 831 | void Addressee::setAgent( const Agent &agent ) |
780 | { | 832 | { |
781 | if ( agent == mData->agent ) return; | 833 | if ( agent == mData->agent ) return; |
782 | detach(); | 834 | detach(); |
783 | mData->empty = false; | 835 | mData->empty = false; |
784 | mData->agent = agent; | 836 | mData->agent = agent; |
785 | } | 837 | } |
786 | 838 | ||
787 | Agent Addressee::agent() const | 839 | Agent Addressee::agent() const |
788 | { | 840 | { |
789 | return mData->agent; | 841 | return mData->agent; |
790 | } | 842 | } |
791 | 843 | ||
792 | QString Addressee::agentLabel() | 844 | QString Addressee::agentLabel() |
793 | { | 845 | { |
794 | return i18n("Agent"); | 846 | return i18n("Agent"); |
795 | } | 847 | } |
796 | 848 | ||
797 | 849 | ||
798 | 850 | ||
799 | void Addressee::setNameFromString( const QString &str ) | 851 | void Addressee::setNameFromString( const QString &str ) |
800 | { | 852 | { |
801 | setFormattedName( str ); | 853 | setFormattedName( str ); |
802 | setName( str ); | 854 | setName( str ); |
803 | 855 | ||
804 | static bool first = true; | 856 | static bool first = true; |
805 | static QStringList titles; | 857 | static QStringList titles; |
806 | static QStringList suffixes; | 858 | static QStringList suffixes; |
807 | static QStringList prefixes; | 859 | static QStringList prefixes; |
808 | 860 | ||
809 | if ( first ) { | 861 | if ( first ) { |
810 | first = false; | 862 | first = false; |
811 | titles += i18n( "Dr." ); | 863 | titles += i18n( "Dr." ); |
812 | titles += i18n( "Miss" ); | 864 | titles += i18n( "Miss" ); |
813 | titles += i18n( "Mr." ); | 865 | titles += i18n( "Mr." ); |
814 | titles += i18n( "Mrs." ); | 866 | titles += i18n( "Mrs." ); |
815 | titles += i18n( "Ms." ); | 867 | titles += i18n( "Ms." ); |
816 | titles += i18n( "Prof." ); | 868 | titles += i18n( "Prof." ); |
817 | 869 | ||
818 | suffixes += i18n( "I" ); | 870 | suffixes += i18n( "I" ); |
819 | suffixes += i18n( "II" ); | 871 | suffixes += i18n( "II" ); |
820 | suffixes += i18n( "III" ); | 872 | suffixes += i18n( "III" ); |
821 | suffixes += i18n( "Jr." ); | 873 | suffixes += i18n( "Jr." ); |
822 | suffixes += i18n( "Sr." ); | 874 | suffixes += i18n( "Sr." ); |
823 | 875 | ||
824 | prefixes += "van"; | 876 | prefixes += "van"; |
825 | prefixes += "von"; | 877 | prefixes += "von"; |
826 | prefixes += "de"; | 878 | prefixes += "de"; |
827 | 879 | ||
828 | KConfig config( locateLocal( "config", "kabcrc") ); | 880 | KConfig config( locateLocal( "config", "kabcrc") ); |
829 | config.setGroup( "General" ); | 881 | config.setGroup( "General" ); |
830 | titles += config.readListEntry( "Prefixes" ); | 882 | titles += config.readListEntry( "Prefixes" ); |
831 | titles.remove( "" ); | 883 | titles.remove( "" ); |
832 | prefixes += config.readListEntry( "Inclusions" ); | 884 | prefixes += config.readListEntry( "Inclusions" ); |
833 | prefixes.remove( "" ); | 885 | prefixes.remove( "" ); |
834 | suffixes += config.readListEntry( "Suffixes" ); | 886 | suffixes += config.readListEntry( "Suffixes" ); |
835 | suffixes.remove( "" ); | 887 | suffixes.remove( "" ); |
836 | } | 888 | } |
837 | 889 | ||
838 | // clear all name parts | 890 | // clear all name parts |
839 | setPrefix( "" ); | 891 | setPrefix( "" ); |
840 | setGivenName( "" ); | 892 | setGivenName( "" ); |
841 | setAdditionalName( "" ); | 893 | setAdditionalName( "" ); |
842 | setFamilyName( "" ); | 894 | setFamilyName( "" ); |
843 | setSuffix( "" ); | 895 | setSuffix( "" ); |
844 | 896 | ||
845 | if ( str.isEmpty() ) | 897 | if ( str.isEmpty() ) |
846 | return; | 898 | return; |
847 | 899 | ||
848 | int i = str.find(','); | 900 | int i = str.find(','); |
849 | if( i < 0 ) { | 901 | if( i < 0 ) { |
850 | QStringList parts = QStringList::split( " ", str ); | 902 | QStringList parts = QStringList::split( " ", str ); |
851 | int leftOffset = 0; | 903 | int leftOffset = 0; |
852 | int rightOffset = parts.count() - 1; | 904 | int rightOffset = parts.count() - 1; |
853 | 905 | ||
854 | QString suffix; | 906 | QString suffix; |
855 | while ( rightOffset >= 0 ) { | 907 | while ( rightOffset >= 0 ) { |
856 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 908 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
857 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 909 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
858 | rightOffset--; | 910 | rightOffset--; |
859 | } else | 911 | } else |
860 | break; | 912 | break; |
861 | } | 913 | } |
862 | setSuffix( suffix ); | 914 | setSuffix( suffix ); |
863 | 915 | ||
864 | if ( rightOffset < 0 ) | 916 | if ( rightOffset < 0 ) |
865 | return; | 917 | return; |
866 | 918 | ||
867 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 919 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
868 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 920 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
869 | rightOffset--; | 921 | rightOffset--; |
870 | } else | 922 | } else |
871 | setFamilyName( parts[ rightOffset ] ); | 923 | setFamilyName( parts[ rightOffset ] ); |
872 | 924 | ||
873 | QString prefix; | 925 | QString prefix; |
874 | while ( leftOffset < rightOffset ) { | 926 | while ( leftOffset < rightOffset ) { |
875 | if ( titles.contains( parts[ leftOffset ] ) ) { | 927 | if ( titles.contains( parts[ leftOffset ] ) ) { |
876 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 928 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
877 | leftOffset++; | 929 | leftOffset++; |
878 | } else | 930 | } else |
879 | break; | 931 | break; |
880 | } | 932 | } |
881 | setPrefix( prefix ); | 933 | setPrefix( prefix ); |
882 | 934 | ||
883 | if ( leftOffset < rightOffset ) { | 935 | if ( leftOffset < rightOffset ) { |
884 | setGivenName( parts[ leftOffset ] ); | 936 | setGivenName( parts[ leftOffset ] ); |
885 | leftOffset++; | 937 | leftOffset++; |
886 | } | 938 | } |
887 | 939 | ||
888 | QString additionalName; | 940 | QString additionalName; |
889 | while ( leftOffset < rightOffset ) { | 941 | while ( leftOffset < rightOffset ) { |
890 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 942 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
891 | leftOffset++; | 943 | leftOffset++; |
892 | } | 944 | } |
893 | setAdditionalName( additionalName ); | 945 | setAdditionalName( additionalName ); |
894 | } else { | 946 | } else { |
895 | QString part1 = str.left( i ); | 947 | QString part1 = str.left( i ); |
896 | QString part2 = str.mid( i + 1 ); | 948 | QString part2 = str.mid( i + 1 ); |
897 | 949 | ||
898 | QStringList parts = QStringList::split( " ", part1 ); | 950 | QStringList parts = QStringList::split( " ", part1 ); |
899 | int leftOffset = 0; | 951 | int leftOffset = 0; |
900 | int rightOffset = parts.count() - 1; | 952 | int rightOffset = parts.count() - 1; |
901 | 953 | ||
902 | QString suffix; | 954 | QString suffix; |
903 | while ( rightOffset >= 0 ) { | 955 | while ( rightOffset >= 0 ) { |
904 | if ( suffixes.contains( parts[ rightOffset ] ) ) { | 956 | if ( suffixes.contains( parts[ rightOffset ] ) ) { |
905 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); | 957 | suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " ")); |
906 | rightOffset--; | 958 | rightOffset--; |
907 | } else | 959 | } else |
908 | break; | 960 | break; |
909 | } | 961 | } |
910 | setSuffix( suffix ); | 962 | setSuffix( suffix ); |
911 | 963 | ||
912 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { | 964 | if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) { |
913 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); | 965 | setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] ); |
914 | rightOffset--; | 966 | rightOffset--; |
915 | } else | 967 | } else |
916 | setFamilyName( parts[ rightOffset ] ); | 968 | setFamilyName( parts[ rightOffset ] ); |
917 | 969 | ||
918 | QString prefix; | 970 | QString prefix; |
919 | while ( leftOffset < rightOffset ) { | 971 | while ( leftOffset < rightOffset ) { |
920 | if ( titles.contains( parts[ leftOffset ] ) ) { | 972 | if ( titles.contains( parts[ leftOffset ] ) ) { |
921 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 973 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
922 | leftOffset++; | 974 | leftOffset++; |
923 | } else | 975 | } else |
924 | break; | 976 | break; |
925 | } | 977 | } |
926 | 978 | ||
927 | parts = QStringList::split( " ", part2 ); | 979 | parts = QStringList::split( " ", part2 ); |
928 | 980 | ||
929 | leftOffset = 0; | 981 | leftOffset = 0; |
930 | rightOffset = parts.count(); | 982 | rightOffset = parts.count(); |
931 | 983 | ||
932 | while ( leftOffset < rightOffset ) { | 984 | while ( leftOffset < rightOffset ) { |
933 | if ( titles.contains( parts[ leftOffset ] ) ) { | 985 | if ( titles.contains( parts[ leftOffset ] ) ) { |
934 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 986 | prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
935 | leftOffset++; | 987 | leftOffset++; |
936 | } else | 988 | } else |
937 | break; | 989 | break; |
938 | } | 990 | } |
939 | setPrefix( prefix ); | 991 | setPrefix( prefix ); |
940 | 992 | ||
941 | if ( leftOffset < rightOffset ) { | 993 | if ( leftOffset < rightOffset ) { |
942 | setGivenName( parts[ leftOffset ] ); | 994 | setGivenName( parts[ leftOffset ] ); |
943 | leftOffset++; | 995 | leftOffset++; |
944 | } | 996 | } |
945 | 997 | ||
946 | QString additionalName; | 998 | QString additionalName; |
947 | while ( leftOffset < rightOffset ) { | 999 | while ( leftOffset < rightOffset ) { |
948 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); | 1000 | additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] ); |
949 | leftOffset++; | 1001 | leftOffset++; |
950 | } | 1002 | } |
951 | setAdditionalName( additionalName ); | 1003 | setAdditionalName( additionalName ); |
952 | } | 1004 | } |
953 | } | 1005 | } |
954 | 1006 | ||
955 | QString Addressee::realName() const | 1007 | QString Addressee::realName() const |
956 | { | 1008 | { |
957 | if ( !formattedName().isEmpty() ) | 1009 | if ( !formattedName().isEmpty() ) |
958 | return formattedName(); | 1010 | return formattedName(); |
959 | 1011 | ||
960 | QString n = assembledName(); | 1012 | QString n = assembledName(); |
961 | 1013 | ||
962 | if ( n.isEmpty() ) | 1014 | if ( n.isEmpty() ) |
963 | n = name(); | 1015 | n = name(); |
964 | 1016 | ||
965 | return n; | 1017 | return n; |
966 | } | 1018 | } |
967 | 1019 | ||
968 | QString Addressee::assembledName() const | 1020 | QString Addressee::assembledName() const |
969 | { | 1021 | { |
970 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + | 1022 | QString name = prefix() + " " + givenName() + " " + additionalName() + " " + |
971 | familyName() + " " + suffix(); | 1023 | familyName() + " " + suffix(); |
972 | 1024 | ||
973 | return name.simplifyWhiteSpace(); | 1025 | return name.simplifyWhiteSpace(); |
974 | } | 1026 | } |
975 | 1027 | ||
976 | QString Addressee::fullEmail( const QString &email ) const | 1028 | QString Addressee::fullEmail( const QString &email ) const |
977 | { | 1029 | { |
978 | QString e; | 1030 | QString e; |
979 | if ( email.isNull() ) { | 1031 | if ( email.isNull() ) { |
980 | e = preferredEmail(); | 1032 | e = preferredEmail(); |
981 | } else { | 1033 | } else { |
982 | e = email; | 1034 | e = email; |
983 | } | 1035 | } |
984 | if ( e.isEmpty() ) return QString::null; | 1036 | if ( e.isEmpty() ) return QString::null; |
985 | 1037 | ||
986 | QString text; | 1038 | QString text; |
987 | if ( realName().isEmpty() ) | 1039 | if ( realName().isEmpty() ) |
988 | text = e; | 1040 | text = e; |
989 | else | 1041 | else |
990 | text = assembledName() + " <" + e + ">"; | 1042 | text = assembledName() + " <" + e + ">"; |
991 | 1043 | ||
992 | return text; | 1044 | return text; |
993 | } | 1045 | } |
994 | 1046 | ||
995 | void Addressee::insertEmail( const QString &email, bool preferred ) | 1047 | void Addressee::insertEmail( const QString &email, bool preferred ) |
996 | { | 1048 | { |
997 | detach(); | 1049 | detach(); |
998 | 1050 | ||
999 | QStringList::Iterator it = mData->emails.find( email ); | 1051 | QStringList::Iterator it = mData->emails.find( email ); |
1000 | 1052 | ||
1001 | if ( it != mData->emails.end() ) { | 1053 | if ( it != mData->emails.end() ) { |
1002 | if ( !preferred || it == mData->emails.begin() ) return; | 1054 | if ( !preferred || it == mData->emails.begin() ) return; |
1003 | mData->emails.remove( it ); | 1055 | mData->emails.remove( it ); |
1004 | mData->emails.prepend( email ); | 1056 | mData->emails.prepend( email ); |
1005 | } else { | 1057 | } else { |
1006 | if ( preferred ) { | 1058 | if ( preferred ) { |
1007 | mData->emails.prepend( email ); | 1059 | mData->emails.prepend( email ); |
1008 | } else { | 1060 | } else { |
1009 | mData->emails.append( email ); | 1061 | mData->emails.append( email ); |
1010 | } | 1062 | } |
1011 | } | 1063 | } |
1012 | } | 1064 | } |
1013 | 1065 | ||
1014 | void Addressee::removeEmail( const QString &email ) | 1066 | void Addressee::removeEmail( const QString &email ) |
1015 | { | 1067 | { |
1016 | detach(); | 1068 | detach(); |
1017 | 1069 | ||
1018 | QStringList::Iterator it = mData->emails.find( email ); | 1070 | QStringList::Iterator it = mData->emails.find( email ); |
1019 | if ( it == mData->emails.end() ) return; | 1071 | if ( it == mData->emails.end() ) return; |
1020 | 1072 | ||
1021 | mData->emails.remove( it ); | 1073 | mData->emails.remove( it ); |
1022 | } | 1074 | } |
1023 | 1075 | ||
1024 | QString Addressee::preferredEmail() const | 1076 | QString Addressee::preferredEmail() const |
1025 | { | 1077 | { |
1026 | if ( mData->emails.count() == 0 ) return QString::null; | 1078 | if ( mData->emails.count() == 0 ) return QString::null; |
1027 | else return mData->emails.first(); | 1079 | else return mData->emails.first(); |
1028 | } | 1080 | } |
1029 | 1081 | ||
1030 | QStringList Addressee::emails() const | 1082 | QStringList Addressee::emails() const |
1031 | { | 1083 | { |
1032 | return mData->emails; | 1084 | return mData->emails; |
1033 | } | 1085 | } |
1034 | void Addressee::setEmails( const QStringList& emails ) { | 1086 | void Addressee::setEmails( const QStringList& emails ) { |
1035 | detach(); | 1087 | detach(); |
1036 | mData->emails = emails; | 1088 | mData->emails = emails; |
1037 | } | 1089 | } |
1038 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) | 1090 | void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber ) |
1039 | { | 1091 | { |
1040 | detach(); | 1092 | detach(); |
1041 | mData->empty = false; | 1093 | mData->empty = false; |
1042 | 1094 | ||
1043 | PhoneNumber::List::Iterator it; | 1095 | PhoneNumber::List::Iterator it; |
1044 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1096 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1045 | if ( (*it).id() == phoneNumber.id() ) { | 1097 | if ( (*it).id() == phoneNumber.id() ) { |
1046 | *it = phoneNumber; | 1098 | *it = phoneNumber; |
1047 | return; | 1099 | return; |
1048 | } | 1100 | } |
1049 | } | 1101 | } |
1050 | mData->phoneNumbers.append( phoneNumber ); | 1102 | mData->phoneNumbers.append( phoneNumber ); |
1051 | } | 1103 | } |
1052 | 1104 | ||
1053 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) | 1105 | void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber ) |
1054 | { | 1106 | { |
1055 | detach(); | 1107 | detach(); |
1056 | 1108 | ||
1057 | PhoneNumber::List::Iterator it; | 1109 | PhoneNumber::List::Iterator it; |
1058 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1110 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1059 | if ( (*it).id() == phoneNumber.id() ) { | 1111 | if ( (*it).id() == phoneNumber.id() ) { |
1060 | mData->phoneNumbers.remove( it ); | 1112 | mData->phoneNumbers.remove( it ); |
1061 | return; | 1113 | return; |
1062 | } | 1114 | } |
1063 | } | 1115 | } |
1064 | } | 1116 | } |
1065 | 1117 | ||
1066 | PhoneNumber Addressee::phoneNumber( int type ) const | 1118 | PhoneNumber Addressee::phoneNumber( int type ) const |
1067 | { | 1119 | { |
1068 | PhoneNumber phoneNumber( "", type ); | 1120 | PhoneNumber phoneNumber( "", type ); |
1069 | PhoneNumber::List::ConstIterator it; | 1121 | PhoneNumber::List::ConstIterator it; |
1070 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1122 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1071 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1123 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1072 | if ( (*it).type() & PhoneNumber::Pref ) | 1124 | if ( (*it).type() & PhoneNumber::Pref ) |
1073 | return (*it); | 1125 | return (*it); |
1074 | else if ( phoneNumber.number().isEmpty() ) | 1126 | else if ( phoneNumber.number().isEmpty() ) |
1075 | phoneNumber = (*it); | 1127 | phoneNumber = (*it); |
1076 | } | 1128 | } |
1077 | } | 1129 | } |
1078 | 1130 | ||
1079 | return phoneNumber; | 1131 | return phoneNumber; |
1080 | } | 1132 | } |
1081 | 1133 | ||
1082 | PhoneNumber::List Addressee::phoneNumbers() const | 1134 | PhoneNumber::List Addressee::phoneNumbers() const |
1083 | { | 1135 | { |
1084 | return mData->phoneNumbers; | 1136 | return mData->phoneNumbers; |
1085 | } | 1137 | } |
1086 | 1138 | ||
1087 | PhoneNumber::List Addressee::phoneNumbers( int type ) const | 1139 | PhoneNumber::List Addressee::phoneNumbers( int type ) const |
1088 | { | 1140 | { |
1089 | PhoneNumber::List list; | 1141 | PhoneNumber::List list; |
1090 | 1142 | ||
1091 | PhoneNumber::List::ConstIterator it; | 1143 | PhoneNumber::List::ConstIterator it; |
1092 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1144 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1093 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1145 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1094 | list.append( *it ); | 1146 | list.append( *it ); |
1095 | } | 1147 | } |
1096 | } | 1148 | } |
1097 | return list; | 1149 | return list; |
1098 | } | 1150 | } |
1099 | 1151 | ||
1100 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const | 1152 | PhoneNumber Addressee::findPhoneNumber( const QString &id ) const |
1101 | { | 1153 | { |
1102 | PhoneNumber::List::ConstIterator it; | 1154 | PhoneNumber::List::ConstIterator it; |
1103 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1155 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1104 | if ( (*it).id() == id ) { | 1156 | if ( (*it).id() == id ) { |
1105 | return *it; | 1157 | return *it; |
1106 | } | 1158 | } |
1107 | } | 1159 | } |
1108 | return PhoneNumber(); | 1160 | return PhoneNumber(); |
1109 | } | 1161 | } |
1110 | 1162 | ||
1111 | void Addressee::insertKey( const Key &key ) | 1163 | void Addressee::insertKey( const Key &key ) |
1112 | { | 1164 | { |
1113 | detach(); | 1165 | detach(); |
1114 | mData->empty = false; | 1166 | mData->empty = false; |
1115 | 1167 | ||
1116 | Key::List::Iterator it; | 1168 | Key::List::Iterator it; |
1117 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1169 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1118 | if ( (*it).id() == key.id() ) { | 1170 | if ( (*it).id() == key.id() ) { |
1119 | *it = key; | 1171 | *it = key; |
1120 | return; | 1172 | return; |
1121 | } | 1173 | } |
1122 | } | 1174 | } |
1123 | mData->keys.append( key ); | 1175 | mData->keys.append( key ); |
1124 | } | 1176 | } |
1125 | 1177 | ||
1126 | void Addressee::removeKey( const Key &key ) | 1178 | void Addressee::removeKey( const Key &key ) |
1127 | { | 1179 | { |
1128 | detach(); | 1180 | detach(); |
1129 | 1181 | ||
1130 | Key::List::Iterator it; | 1182 | Key::List::Iterator it; |
1131 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1183 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1132 | if ( (*it).id() == key.id() ) { | 1184 | if ( (*it).id() == key.id() ) { |
1133 | mData->keys.remove( key ); | 1185 | mData->keys.remove( key ); |
1134 | return; | 1186 | return; |
1135 | } | 1187 | } |
1136 | } | 1188 | } |
1137 | } | 1189 | } |
1138 | 1190 | ||
1139 | Key Addressee::key( int type, QString customTypeString ) const | 1191 | Key Addressee::key( int type, QString customTypeString ) const |
1140 | { | 1192 | { |
1141 | Key::List::ConstIterator it; | 1193 | Key::List::ConstIterator it; |
1142 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1194 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1143 | if ( (*it).type() == type ) { | 1195 | if ( (*it).type() == type ) { |
1144 | if ( type == Key::Custom ) { | 1196 | if ( type == Key::Custom ) { |
1145 | if ( customTypeString.isEmpty() ) { | 1197 | if ( customTypeString.isEmpty() ) { |
1146 | return *it; | 1198 | return *it; |
1147 | } else { | 1199 | } else { |
1148 | if ( (*it).customTypeString() == customTypeString ) | 1200 | if ( (*it).customTypeString() == customTypeString ) |
1149 | return (*it); | 1201 | return (*it); |
1150 | } | 1202 | } |
1151 | } else { | 1203 | } else { |
1152 | return *it; | 1204 | return *it; |
1153 | } | 1205 | } |
1154 | } | 1206 | } |
1155 | } | 1207 | } |
1156 | return Key( QString(), type ); | 1208 | return Key( QString(), type ); |
1157 | } | 1209 | } |
1158 | void Addressee::setKeys( const Key::List& list ) { | 1210 | void Addressee::setKeys( const Key::List& list ) { |
1159 | detach(); | 1211 | detach(); |
1160 | mData->keys = list; | 1212 | mData->keys = list; |
1161 | } | 1213 | } |
1162 | 1214 | ||
1163 | Key::List Addressee::keys() const | 1215 | Key::List Addressee::keys() const |
1164 | { | 1216 | { |
1165 | return mData->keys; | 1217 | return mData->keys; |
1166 | } | 1218 | } |
1167 | 1219 | ||
1168 | Key::List Addressee::keys( int type, QString customTypeString ) const | 1220 | Key::List Addressee::keys( int type, QString customTypeString ) const |
1169 | { | 1221 | { |
1170 | Key::List list; | 1222 | Key::List list; |
1171 | 1223 | ||
1172 | Key::List::ConstIterator it; | 1224 | Key::List::ConstIterator it; |
1173 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1225 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1174 | if ( (*it).type() == type ) { | 1226 | if ( (*it).type() == type ) { |
1175 | if ( type == Key::Custom ) { | 1227 | if ( type == Key::Custom ) { |
1176 | if ( customTypeString.isEmpty() ) { | 1228 | if ( customTypeString.isEmpty() ) { |
1177 | list.append(*it); | 1229 | list.append(*it); |
1178 | } else { | 1230 | } else { |
1179 | if ( (*it).customTypeString() == customTypeString ) | 1231 | if ( (*it).customTypeString() == customTypeString ) |
1180 | list.append(*it); | 1232 | list.append(*it); |
1181 | } | 1233 | } |
1182 | } else { | 1234 | } else { |
1183 | list.append(*it); | 1235 | list.append(*it); |
1184 | } | 1236 | } |
1185 | } | 1237 | } |
1186 | } | 1238 | } |
1187 | return list; | 1239 | return list; |
1188 | } | 1240 | } |
1189 | 1241 | ||
1190 | Key Addressee::findKey( const QString &id ) const | 1242 | Key Addressee::findKey( const QString &id ) const |
1191 | { | 1243 | { |
1192 | Key::List::ConstIterator it; | 1244 | Key::List::ConstIterator it; |
1193 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { | 1245 | for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) { |
1194 | if ( (*it).id() == id ) { | 1246 | if ( (*it).id() == id ) { |
1195 | return *it; | 1247 | return *it; |
1196 | } | 1248 | } |
1197 | } | 1249 | } |
1198 | return Key(); | 1250 | return Key(); |
1199 | } | 1251 | } |
1200 | 1252 | ||
1201 | QString Addressee::asString() const | 1253 | QString Addressee::asString() const |
1202 | { | 1254 | { |
1203 | return "Smith, agent Smith..."; | 1255 | return "Smith, agent Smith..."; |
1204 | } | 1256 | } |
1205 | 1257 | ||
1206 | void Addressee::dump() const | 1258 | void Addressee::dump() const |
1207 | { | 1259 | { |
1208 | return; | 1260 | return; |
1209 | kdDebug(5700) << "Addressee {" << endl; | 1261 | kdDebug(5700) << "Addressee {" << endl; |
1210 | 1262 | ||
1211 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; | 1263 | kdDebug(5700) << " Uid: '" << uid() << "'" << endl; |
1212 | 1264 | ||
1213 | kdDebug(5700) << " Name: '" << name() << "'" << endl; | 1265 | kdDebug(5700) << " Name: '" << name() << "'" << endl; |
1214 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; | 1266 | kdDebug(5700) << " FormattedName: '" << formattedName() << "'" << endl; |
1215 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; | 1267 | kdDebug(5700) << " FamilyName: '" << familyName() << "'" << endl; |
1216 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; | 1268 | kdDebug(5700) << " GivenName: '" << givenName() << "'" << endl; |
1217 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; | 1269 | kdDebug(5700) << " AdditionalName: '" << additionalName() << "'" << endl; |
1218 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; | 1270 | kdDebug(5700) << " Prefix: '" << prefix() << "'" << endl; |
1219 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; | 1271 | kdDebug(5700) << " Suffix: '" << suffix() << "'" << endl; |
1220 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; | 1272 | kdDebug(5700) << " NickName: '" << nickName() << "'" << endl; |
1221 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; | 1273 | kdDebug(5700) << " Birthday: '" << birthday().toString() << "'" << endl; |
1222 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; | 1274 | kdDebug(5700) << " Mailer: '" << mailer() << "'" << endl; |
1223 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; | 1275 | kdDebug(5700) << " TimeZone: '" << timeZone().asString() << "'" << endl; |
1224 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; | 1276 | kdDebug(5700) << " Geo: '" << geo().asString() << "'" << endl; |
1225 | kdDebug(5700) << " Title: '" << title() << "'" << endl; | 1277 | kdDebug(5700) << " Title: '" << title() << "'" << endl; |
1226 | kdDebug(5700) << " Role: '" << role() << "'" << endl; | 1278 | kdDebug(5700) << " Role: '" << role() << "'" << endl; |
1227 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; | 1279 | kdDebug(5700) << " Organization: '" << organization() << "'" << endl; |
1228 | kdDebug(5700) << " Note: '" << note() << "'" << endl; | 1280 | kdDebug(5700) << " Note: '" << note() << "'" << endl; |
1229 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; | 1281 | kdDebug(5700) << " ProductId: '" << productId() << "'" << endl; |
1230 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; | 1282 | kdDebug(5700) << " Revision: '" << revision().toString() << "'" << endl; |
1231 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; | 1283 | kdDebug(5700) << " SortString: '" << sortString() << "'" << endl; |
1232 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; | 1284 | kdDebug(5700) << " Url: '" << url().url() << "'" << endl; |
1233 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; | 1285 | kdDebug(5700) << " Secrecy: '" << secrecy().asString() << "'" << endl; |
1234 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; | 1286 | kdDebug(5700) << " Logo: '" << logo().asString() << "'" << endl; |
1235 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; | 1287 | kdDebug(5700) << " Photo: '" << photo().asString() << "'" << endl; |
1236 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; | 1288 | kdDebug(5700) << " Sound: '" << sound().asString() << "'" << endl; |
1237 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; | 1289 | kdDebug(5700) << " Agent: '" << agent().asString() << "'" << endl; |
1238 | 1290 | ||
1239 | kdDebug(5700) << " Emails {" << endl; | 1291 | kdDebug(5700) << " Emails {" << endl; |
1240 | QStringList e = emails(); | 1292 | QStringList e = emails(); |
1241 | QStringList::ConstIterator it; | 1293 | QStringList::ConstIterator it; |
1242 | for( it = e.begin(); it != e.end(); ++it ) { | 1294 | for( it = e.begin(); it != e.end(); ++it ) { |
1243 | kdDebug(5700) << " " << (*it) << endl; | 1295 | kdDebug(5700) << " " << (*it) << endl; |
1244 | } | 1296 | } |
1245 | kdDebug(5700) << " }" << endl; | 1297 | kdDebug(5700) << " }" << endl; |
1246 | 1298 | ||
1247 | kdDebug(5700) << " PhoneNumbers {" << endl; | 1299 | kdDebug(5700) << " PhoneNumbers {" << endl; |
1248 | PhoneNumber::List p = phoneNumbers(); | 1300 | PhoneNumber::List p = phoneNumbers(); |
1249 | PhoneNumber::List::ConstIterator it2; | 1301 | PhoneNumber::List::ConstIterator it2; |
1250 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { | 1302 | for( it2 = p.begin(); it2 != p.end(); ++it2 ) { |
1251 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; | 1303 | kdDebug(5700) << " Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl; |
1252 | } | 1304 | } |
1253 | kdDebug(5700) << " }" << endl; | 1305 | kdDebug(5700) << " }" << endl; |
1254 | 1306 | ||
1255 | Address::List a = addresses(); | 1307 | Address::List a = addresses(); |
1256 | Address::List::ConstIterator it3; | 1308 | Address::List::ConstIterator it3; |
1257 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { | 1309 | for( it3 = a.begin(); it3 != a.end(); ++it3 ) { |
1258 | (*it3).dump(); | 1310 | (*it3).dump(); |
1259 | } | 1311 | } |
1260 | 1312 | ||
1261 | kdDebug(5700) << " Keys {" << endl; | 1313 | kdDebug(5700) << " Keys {" << endl; |
1262 | Key::List k = keys(); | 1314 | Key::List k = keys(); |
1263 | Key::List::ConstIterator it4; | 1315 | Key::List::ConstIterator it4; |
1264 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { | 1316 | for( it4 = k.begin(); it4 != k.end(); ++it4 ) { |
1265 | kdDebug(5700) << " Type: " << int((*it4).type()) << | 1317 | kdDebug(5700) << " Type: " << int((*it4).type()) << |
1266 | " Key: " << (*it4).textData() << | 1318 | " Key: " << (*it4).textData() << |
1267 | " CustomString: " << (*it4).customTypeString() << endl; | 1319 | " CustomString: " << (*it4).customTypeString() << endl; |
1268 | } | 1320 | } |
1269 | kdDebug(5700) << " }" << endl; | 1321 | kdDebug(5700) << " }" << endl; |
1270 | 1322 | ||
1271 | kdDebug(5700) << "}" << endl; | 1323 | kdDebug(5700) << "}" << endl; |
1272 | } | 1324 | } |
1273 | 1325 | ||
1274 | 1326 | ||
1275 | void Addressee::insertAddress( const Address &address ) | 1327 | void Addressee::insertAddress( const Address &address ) |
1276 | { | 1328 | { |
1277 | detach(); | 1329 | detach(); |
1278 | mData->empty = false; | 1330 | mData->empty = false; |
1279 | 1331 | ||
1280 | Address::List::Iterator it; | 1332 | Address::List::Iterator it; |
1281 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1333 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1282 | if ( (*it).id() == address.id() ) { | 1334 | if ( (*it).id() == address.id() ) { |
1283 | *it = address; | 1335 | *it = address; |
1284 | return; | 1336 | return; |
1285 | } | 1337 | } |
1286 | } | 1338 | } |
1287 | mData->addresses.append( address ); | 1339 | mData->addresses.append( address ); |
1288 | } | 1340 | } |
1289 | 1341 | ||
1290 | void Addressee::removeAddress( const Address &address ) | 1342 | void Addressee::removeAddress( const Address &address ) |
1291 | { | 1343 | { |
1292 | detach(); | 1344 | detach(); |
1293 | 1345 | ||
1294 | Address::List::Iterator it; | 1346 | Address::List::Iterator it; |
1295 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1347 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1296 | if ( (*it).id() == address.id() ) { | 1348 | if ( (*it).id() == address.id() ) { |
1297 | mData->addresses.remove( it ); | 1349 | mData->addresses.remove( it ); |
1298 | return; | 1350 | return; |
1299 | } | 1351 | } |
1300 | } | 1352 | } |
1301 | } | 1353 | } |
1302 | 1354 | ||
1303 | Address Addressee::address( int type ) const | 1355 | Address Addressee::address( int type ) const |
1304 | { | 1356 | { |
1305 | Address address( type ); | 1357 | Address address( type ); |
1306 | Address::List::ConstIterator it; | 1358 | Address::List::ConstIterator it; |
1307 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1359 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1308 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1360 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1309 | if ( (*it).type() & Address::Pref ) | 1361 | if ( (*it).type() & Address::Pref ) |
1310 | return (*it); | 1362 | return (*it); |
1311 | else if ( address.isEmpty() ) | 1363 | else if ( address.isEmpty() ) |
1312 | address = (*it); | 1364 | address = (*it); |
1313 | } | 1365 | } |
1314 | } | 1366 | } |
1315 | 1367 | ||
1316 | return address; | 1368 | return address; |
1317 | } | 1369 | } |
1318 | 1370 | ||
1319 | Address::List Addressee::addresses() const | 1371 | Address::List Addressee::addresses() const |
1320 | { | 1372 | { |
1321 | return mData->addresses; | 1373 | return mData->addresses; |
1322 | } | 1374 | } |
1323 | 1375 | ||
1324 | Address::List Addressee::addresses( int type ) const | 1376 | Address::List Addressee::addresses( int type ) const |
1325 | { | 1377 | { |
1326 | Address::List list; | 1378 | Address::List list; |
1327 | 1379 | ||
1328 | Address::List::ConstIterator it; | 1380 | Address::List::ConstIterator it; |
1329 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1381 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1330 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1382 | if ( matchBinaryPattern( (*it).type(), type ) ) { |
1331 | list.append( *it ); | 1383 | list.append( *it ); |
1332 | } | 1384 | } |
1333 | } | 1385 | } |
1334 | 1386 | ||
1335 | return list; | 1387 | return list; |
1336 | } | 1388 | } |
1337 | 1389 | ||
1338 | Address Addressee::findAddress( const QString &id ) const | 1390 | Address Addressee::findAddress( const QString &id ) const |
1339 | { | 1391 | { |
1340 | Address::List::ConstIterator it; | 1392 | Address::List::ConstIterator it; |
1341 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1393 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1342 | if ( (*it).id() == id ) { | 1394 | if ( (*it).id() == id ) { |
1343 | return *it; | 1395 | return *it; |
1344 | } | 1396 | } |
1345 | } | 1397 | } |
1346 | return Address(); | 1398 | return Address(); |
1347 | } | 1399 | } |
1348 | 1400 | ||
1349 | void Addressee::insertCategory( const QString &c ) | 1401 | void Addressee::insertCategory( const QString &c ) |
1350 | { | 1402 | { |
1351 | detach(); | 1403 | detach(); |
1352 | mData->empty = false; | 1404 | mData->empty = false; |
1353 | 1405 | ||
1354 | if ( mData->categories.contains( c ) ) return; | 1406 | if ( mData->categories.contains( c ) ) return; |
1355 | 1407 | ||
1356 | mData->categories.append( c ); | 1408 | mData->categories.append( c ); |
1357 | } | 1409 | } |
1358 | 1410 | ||
1359 | void Addressee::removeCategory( const QString &c ) | 1411 | void Addressee::removeCategory( const QString &c ) |
1360 | { | 1412 | { |
1361 | detach(); | 1413 | detach(); |
1362 | 1414 | ||
1363 | QStringList::Iterator it = mData->categories.find( c ); | 1415 | QStringList::Iterator it = mData->categories.find( c ); |
1364 | if ( it == mData->categories.end() ) return; | 1416 | if ( it == mData->categories.end() ) return; |
1365 | 1417 | ||
1366 | mData->categories.remove( it ); | 1418 | mData->categories.remove( it ); |
1367 | } | 1419 | } |
1368 | 1420 | ||
1369 | bool Addressee::hasCategory( const QString &c ) const | 1421 | bool Addressee::hasCategory( const QString &c ) const |
1370 | { | 1422 | { |
1371 | return ( mData->categories.contains( c ) ); | 1423 | return ( mData->categories.contains( c ) ); |
1372 | } | 1424 | } |
1373 | 1425 | ||
1374 | void Addressee::setCategories( const QStringList &c ) | 1426 | void Addressee::setCategories( const QStringList &c ) |
1375 | { | 1427 | { |
1376 | detach(); | 1428 | detach(); |
1377 | mData->empty = false; | 1429 | mData->empty = false; |
1378 | 1430 | ||
1379 | mData->categories = c; | 1431 | mData->categories = c; |
1380 | } | 1432 | } |
1381 | 1433 | ||
1382 | QStringList Addressee::categories() const | 1434 | QStringList Addressee::categories() const |
1383 | { | 1435 | { |
1384 | return mData->categories; | 1436 | return mData->categories; |
1385 | } | 1437 | } |
1386 | 1438 | ||
1387 | void Addressee::insertCustom( const QString &app, const QString &name, | 1439 | void Addressee::insertCustom( const QString &app, const QString &name, |
1388 | const QString &value ) | 1440 | const QString &value ) |
1389 | { | 1441 | { |
1390 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; | 1442 | if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return; |
1391 | 1443 | ||
1392 | detach(); | 1444 | detach(); |
1393 | mData->empty = false; | 1445 | mData->empty = false; |
1394 | 1446 | ||
1395 | QString qualifiedName = app + "-" + name + ":"; | 1447 | QString qualifiedName = app + "-" + name + ":"; |
1396 | 1448 | ||
1397 | QStringList::Iterator it; | 1449 | QStringList::Iterator it; |
1398 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1450 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1399 | if ( (*it).startsWith( qualifiedName ) ) { | 1451 | if ( (*it).startsWith( qualifiedName ) ) { |
1400 | (*it) = qualifiedName + value; | 1452 | (*it) = qualifiedName + value; |
1401 | return; | 1453 | return; |
1402 | } | 1454 | } |
1403 | } | 1455 | } |
1404 | 1456 | ||
1405 | mData->custom.append( qualifiedName + value ); | 1457 | mData->custom.append( qualifiedName + value ); |
1406 | } | 1458 | } |
1407 | 1459 | ||
1408 | void Addressee::removeCustom( const QString &app, const QString &name) | 1460 | void Addressee::removeCustom( const QString &app, const QString &name) |
1409 | { | 1461 | { |
1410 | detach(); | 1462 | detach(); |
1411 | 1463 | ||
1412 | QString qualifiedName = app + "-" + name + ":"; | 1464 | QString qualifiedName = app + "-" + name + ":"; |
1413 | 1465 | ||
1414 | QStringList::Iterator it; | 1466 | QStringList::Iterator it; |
1415 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1467 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1416 | if ( (*it).startsWith( qualifiedName ) ) { | 1468 | if ( (*it).startsWith( qualifiedName ) ) { |
1417 | mData->custom.remove( it ); | 1469 | mData->custom.remove( it ); |
1418 | return; | 1470 | return; |
1419 | } | 1471 | } |
1420 | } | 1472 | } |
1421 | } | 1473 | } |
1422 | 1474 | ||
1423 | QString Addressee::custom( const QString &app, const QString &name ) const | 1475 | QString Addressee::custom( const QString &app, const QString &name ) const |
1424 | { | 1476 | { |
1425 | QString qualifiedName = app + "-" + name + ":"; | 1477 | QString qualifiedName = app + "-" + name + ":"; |
1426 | QString value; | 1478 | QString value; |
1427 | 1479 | ||
1428 | QStringList::ConstIterator it; | 1480 | QStringList::ConstIterator it; |
1429 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { | 1481 | for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) { |
1430 | if ( (*it).startsWith( qualifiedName ) ) { | 1482 | if ( (*it).startsWith( qualifiedName ) ) { |
1431 | value = (*it).mid( (*it).find( ":" ) + 1 ); | 1483 | value = (*it).mid( (*it).find( ":" ) + 1 ); |
1432 | break; | 1484 | break; |
1433 | } | 1485 | } |
1434 | } | 1486 | } |
1435 | 1487 | ||
1436 | return value; | 1488 | return value; |
1437 | } | 1489 | } |
1438 | 1490 | ||
1439 | void Addressee::setCustoms( const QStringList &l ) | 1491 | void Addressee::setCustoms( const QStringList &l ) |
1440 | { | 1492 | { |
1441 | detach(); | 1493 | detach(); |
1442 | mData->empty = false; | 1494 | mData->empty = false; |
1443 | 1495 | ||
1444 | mData->custom = l; | 1496 | mData->custom = l; |
1445 | } | 1497 | } |
1446 | 1498 | ||
1447 | QStringList Addressee::customs() const | 1499 | QStringList Addressee::customs() const |
1448 | { | 1500 | { |
1449 | return mData->custom; | 1501 | return mData->custom; |
1450 | } | 1502 | } |
1451 | 1503 | ||
1452 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, | 1504 | void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName, |
1453 | QString &email) | 1505 | QString &email) |
1454 | { | 1506 | { |
1455 | int startPos, endPos, len; | 1507 | int startPos, endPos, len; |
1456 | QString partA, partB, result; | 1508 | QString partA, partB, result; |
1457 | char endCh = '>'; | 1509 | char endCh = '>'; |
1458 | 1510 | ||
1459 | startPos = rawEmail.find('<'); | 1511 | startPos = rawEmail.find('<'); |
1460 | if (startPos < 0) | 1512 | if (startPos < 0) |
1461 | { | 1513 | { |
1462 | startPos = rawEmail.find('('); | 1514 | startPos = rawEmail.find('('); |
1463 | endCh = ')'; | 1515 | endCh = ')'; |
1464 | } | 1516 | } |
1465 | if (startPos < 0) | 1517 | if (startPos < 0) |
1466 | { | 1518 | { |
1467 | // We couldn't find any separators, so we assume the whole string | 1519 | // We couldn't find any separators, so we assume the whole string |
1468 | // is the email address | 1520 | // is the email address |
1469 | email = rawEmail; | 1521 | email = rawEmail; |
1470 | fullName = ""; | 1522 | fullName = ""; |
1471 | } | 1523 | } |
1472 | else | 1524 | else |
1473 | { | 1525 | { |
1474 | // We have a start position, try to find an end | 1526 | // We have a start position, try to find an end |
1475 | endPos = rawEmail.find(endCh, startPos+1); | 1527 | endPos = rawEmail.find(endCh, startPos+1); |
1476 | 1528 | ||
1477 | if (endPos < 0) | 1529 | if (endPos < 0) |
1478 | { | 1530 | { |
1479 | // We couldn't find the end of the email address. We can only | 1531 | // We couldn't find the end of the email address. We can only |
1480 | // assume the entire string is the email address. | 1532 | // assume the entire string is the email address. |
1481 | email = rawEmail; | 1533 | email = rawEmail; |
1482 | fullName = ""; | 1534 | fullName = ""; |
1483 | } | 1535 | } |
1484 | else | 1536 | else |
1485 | { | 1537 | { |
1486 | // We have a start and end to the email address | 1538 | // We have a start and end to the email address |
1487 | 1539 | ||
1488 | // Grab the name part | 1540 | // Grab the name part |
1489 | fullName = rawEmail.left(startPos).stripWhiteSpace(); | 1541 | fullName = rawEmail.left(startPos).stripWhiteSpace(); |
1490 | 1542 | ||
1491 | // grab the email part | 1543 | // grab the email part |
1492 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); | 1544 | email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace(); |
1493 | 1545 | ||
1494 | // Check that we do not have any extra characters on the end of the | 1546 | // Check that we do not have any extra characters on the end of the |
1495 | // strings | 1547 | // strings |
1496 | len = fullName.length(); | 1548 | len = fullName.length(); |
1497 | if (fullName[0]=='"' && fullName[len-1]=='"') | 1549 | if (fullName[0]=='"' && fullName[len-1]=='"') |
1498 | fullName = fullName.mid(1, len-2); | 1550 | fullName = fullName.mid(1, len-2); |
1499 | else if (fullName[0]=='<' && fullName[len-1]=='>') | 1551 | else if (fullName[0]=='<' && fullName[len-1]=='>') |
1500 | fullName = fullName.mid(1, len-2); | 1552 | fullName = fullName.mid(1, len-2); |
1501 | else if (fullName[0]=='(' && fullName[len-1]==')') | 1553 | else if (fullName[0]=='(' && fullName[len-1]==')') |
1502 | fullName = fullName.mid(1, len-2); | 1554 | fullName = fullName.mid(1, len-2); |
1503 | } | 1555 | } |
1504 | } | 1556 | } |
1505 | } | 1557 | } |
1506 | 1558 | ||
1507 | void Addressee::setResource( Resource *resource ) | 1559 | void Addressee::setResource( Resource *resource ) |
1508 | { | 1560 | { |
1509 | detach(); | 1561 | detach(); |
1510 | mData->resource = resource; | 1562 | mData->resource = resource; |
1511 | } | 1563 | } |
1512 | 1564 | ||
1513 | Resource *Addressee::resource() const | 1565 | Resource *Addressee::resource() const |
1514 | { | 1566 | { |
1515 | return mData->resource; | 1567 | return mData->resource; |
1516 | } | 1568 | } |
1517 | 1569 | ||
1518 | //US | 1570 | //US |
1519 | QString Addressee::resourceLabel() | 1571 | QString Addressee::resourceLabel() |
1520 | { | 1572 | { |
1521 | return i18n("Resource"); | 1573 | return i18n("Resource"); |
1522 | } | 1574 | } |
1523 | 1575 | ||
1524 | void Addressee::setChanged( bool value ) | 1576 | void Addressee::setChanged( bool value ) |
1525 | { | 1577 | { |
1526 | detach(); | 1578 | detach(); |
1527 | mData->changed = value; | 1579 | mData->changed = value; |
1528 | } | 1580 | } |
1529 | 1581 | ||
1530 | bool Addressee::changed() const | 1582 | bool Addressee::changed() const |
1531 | { | 1583 | { |
1532 | return mData->changed; | 1584 | return mData->changed; |
1533 | } | 1585 | } |
1534 | 1586 | ||
1535 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) | 1587 | QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a ) |
1536 | { | 1588 | { |
1537 | if (!a.mData) return s; | 1589 | if (!a.mData) return s; |
1538 | 1590 | ||
1539 | s << a.uid(); | 1591 | s << a.uid(); |
1540 | 1592 | ||
1541 | s << a.mData->name; | 1593 | s << a.mData->name; |
1542 | s << a.mData->formattedName; | 1594 | s << a.mData->formattedName; |
1543 | s << a.mData->familyName; | 1595 | s << a.mData->familyName; |
1544 | s << a.mData->givenName; | 1596 | s << a.mData->givenName; |
1545 | s << a.mData->additionalName; | 1597 | s << a.mData->additionalName; |
1546 | s << a.mData->prefix; | 1598 | s << a.mData->prefix; |
1547 | s << a.mData->suffix; | 1599 | s << a.mData->suffix; |
1548 | s << a.mData->nickName; | 1600 | s << a.mData->nickName; |
1549 | s << a.mData->birthday; | 1601 | s << a.mData->birthday; |
1550 | s << a.mData->mailer; | 1602 | s << a.mData->mailer; |
1551 | s << a.mData->timeZone; | 1603 | s << a.mData->timeZone; |
1552 | s << a.mData->geo; | 1604 | s << a.mData->geo; |
1553 | s << a.mData->title; | 1605 | s << a.mData->title; |
1554 | s << a.mData->role; | 1606 | s << a.mData->role; |
1555 | s << a.mData->organization; | 1607 | s << a.mData->organization; |
1556 | s << a.mData->note; | 1608 | s << a.mData->note; |
1557 | s << a.mData->productId; | 1609 | s << a.mData->productId; |
1558 | s << a.mData->revision; | 1610 | s << a.mData->revision; |
1559 | s << a.mData->sortString; | 1611 | s << a.mData->sortString; |
1560 | s << a.mData->url; | 1612 | s << a.mData->url; |
1561 | s << a.mData->secrecy; | 1613 | s << a.mData->secrecy; |
1562 | s << a.mData->logo; | 1614 | s << a.mData->logo; |
1563 | s << a.mData->photo; | 1615 | s << a.mData->photo; |
1564 | s << a.mData->sound; | 1616 | s << a.mData->sound; |
1565 | s << a.mData->agent; | 1617 | s << a.mData->agent; |
1566 | s << a.mData->phoneNumbers; | 1618 | s << a.mData->phoneNumbers; |
1567 | s << a.mData->addresses; | 1619 | s << a.mData->addresses; |
1568 | s << a.mData->emails; | 1620 | s << a.mData->emails; |
1569 | s << a.mData->categories; | 1621 | s << a.mData->categories; |
1570 | s << a.mData->custom; | 1622 | s << a.mData->custom; |
1571 | s << a.mData->keys; | 1623 | s << a.mData->keys; |
1572 | return s; | 1624 | return s; |
1573 | } | 1625 | } |
1574 | 1626 | ||
1575 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | 1627 | QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) |
1576 | { | 1628 | { |
1577 | if (!a.mData) return s; | 1629 | if (!a.mData) return s; |
1578 | 1630 | ||
1579 | s >> a.mData->uid; | 1631 | s >> a.mData->uid; |
1580 | 1632 | ||
1581 | s >> a.mData->name; | 1633 | s >> a.mData->name; |
1582 | s >> a.mData->formattedName; | 1634 | s >> a.mData->formattedName; |
1583 | s >> a.mData->familyName; | 1635 | s >> a.mData->familyName; |
1584 | s >> a.mData->givenName; | 1636 | s >> a.mData->givenName; |
1585 | s >> a.mData->additionalName; | 1637 | s >> a.mData->additionalName; |
1586 | s >> a.mData->prefix; | 1638 | s >> a.mData->prefix; |
1587 | s >> a.mData->suffix; | 1639 | s >> a.mData->suffix; |
1588 | s >> a.mData->nickName; | 1640 | s >> a.mData->nickName; |
1589 | s >> a.mData->birthday; | 1641 | s >> a.mData->birthday; |
1590 | s >> a.mData->mailer; | 1642 | s >> a.mData->mailer; |
1591 | s >> a.mData->timeZone; | 1643 | s >> a.mData->timeZone; |
1592 | s >> a.mData->geo; | 1644 | s >> a.mData->geo; |
1593 | s >> a.mData->title; | 1645 | s >> a.mData->title; |
1594 | s >> a.mData->role; | 1646 | s >> a.mData->role; |
1595 | s >> a.mData->organization; | 1647 | s >> a.mData->organization; |
1596 | s >> a.mData->note; | 1648 | s >> a.mData->note; |
1597 | s >> a.mData->productId; | 1649 | s >> a.mData->productId; |
1598 | s >> a.mData->revision; | 1650 | s >> a.mData->revision; |
1599 | s >> a.mData->sortString; | 1651 | s >> a.mData->sortString; |
1600 | s >> a.mData->url; | 1652 | s >> a.mData->url; |
1601 | s >> a.mData->secrecy; | 1653 | s >> a.mData->secrecy; |
1602 | s >> a.mData->logo; | 1654 | s >> a.mData->logo; |
1603 | s >> a.mData->photo; | 1655 | s >> a.mData->photo; |
1604 | s >> a.mData->sound; | 1656 | s >> a.mData->sound; |
1605 | s >> a.mData->agent; | 1657 | s >> a.mData->agent; |
1606 | s >> a.mData->phoneNumbers; | 1658 | s >> a.mData->phoneNumbers; |
1607 | s >> a.mData->addresses; | 1659 | s >> a.mData->addresses; |
1608 | s >> a.mData->emails; | 1660 | s >> a.mData->emails; |
1609 | s >> a.mData->categories; | 1661 | s >> a.mData->categories; |
1610 | s >> a.mData->custom; | 1662 | s >> a.mData->custom; |
1611 | s >> a.mData->keys; | 1663 | s >> a.mData->keys; |
1612 | 1664 | ||
1613 | a.mData->empty = false; | 1665 | a.mData->empty = false; |
1614 | 1666 | ||
1615 | return s; | 1667 | return s; |
1616 | } | 1668 | } |
1617 | 1669 | ||
1618 | bool matchBinaryPattern( int value, int pattern ) | 1670 | bool matchBinaryPattern( int value, int pattern ) |
1619 | { | 1671 | { |
1620 | /** | 1672 | /** |
1621 | We want to match all telephonnumbers/addresses which have the bits in the | 1673 | We want to match all telephonnumbers/addresses which have the bits in the |
1622 | pattern set. More are allowed. | 1674 | pattern set. More are allowed. |
1623 | if pattern == 0 we have a special handling, then we want only those with | 1675 | if pattern == 0 we have a special handling, then we want only those with |
1624 | exactly no bit set. | 1676 | exactly no bit set. |
1625 | */ | 1677 | */ |
1626 | if ( pattern == 0 ) | 1678 | if ( pattern == 0 ) |
1627 | return ( value == 0 ); | 1679 | return ( value == 0 ); |
1628 | else | 1680 | else |
1629 | return ( pattern == ( pattern & value ) ); | 1681 | return ( pattern == ( pattern & value ) ); |
1630 | } | 1682 | } |
diff --git a/kabc/addressee.h b/kabc/addressee.h index 27782f9..f098371 100644 --- a/kabc/addressee.h +++ b/kabc/addressee.h | |||
@@ -1,828 +1,838 @@ | |||
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 | 99 | // sync stuff | |
100 | void setTempSyncStat(int id); | ||
101 | int tempSyncStat() const; | ||
102 | void setIDStr( const QString & ); | ||
103 | QString IDStr() const; | ||
104 | void setID( const QString &, const QString & ); | ||
105 | QString getID( const QString & ); | ||
106 | void setCsum( const QString &, const QString & ); | ||
107 | QString getCsum( const QString & ); | ||
108 | void removeID(const QString &); | ||
100 | /** | 109 | /** |
101 | Return, if the address book entry is empty. | 110 | Return, if the address book entry is empty. |
102 | */ | 111 | */ |
103 | bool isEmpty() const; | 112 | bool isEmpty() const; |
104 | 113 | ||
105 | /** | 114 | /** |
106 | Set unique identifier. | 115 | Set unique identifier. |
107 | */ | 116 | */ |
108 | void setUid( const QString &uid ); | 117 | void setUid( const QString &uid ); |
109 | /** | 118 | /** |
110 | Return unique identifier. | 119 | Return unique identifier. |
111 | */ | 120 | */ |
112 | QString uid() const; | 121 | QString uid() const; |
113 | /** | 122 | /** |
114 | Return translated label for uid field. | 123 | Return translated label for uid field. |
115 | */ | 124 | */ |
116 | static QString uidLabel(); | 125 | static QString uidLabel(); |
117 | 126 | ||
118 | /** | 127 | /** |
119 | Set name. | 128 | Set name. |
120 | */ | 129 | */ |
121 | void setName( const QString &name ); | 130 | void setName( const QString &name ); |
122 | /** | 131 | /** |
123 | Return name. | 132 | Return name. |
124 | */ | 133 | */ |
125 | QString name() const; | 134 | QString name() const; |
126 | /** | 135 | /** |
127 | Return translated label for name field. | 136 | Return translated label for name field. |
128 | */ | 137 | */ |
129 | static QString nameLabel(); | 138 | static QString nameLabel(); |
130 | 139 | ||
131 | /** | 140 | /** |
132 | Set formatted name. | 141 | Set formatted name. |
133 | */ | 142 | */ |
134 | void setFormattedName( const QString &formattedName ); | 143 | void setFormattedName( const QString &formattedName ); |
135 | /** | 144 | /** |
136 | Return formatted name. | 145 | Return formatted name. |
137 | */ | 146 | */ |
138 | QString formattedName() const; | 147 | QString formattedName() const; |
139 | /** | 148 | /** |
140 | Return translated label for formattedName field. | 149 | Return translated label for formattedName field. |
141 | */ | 150 | */ |
142 | static QString formattedNameLabel(); | 151 | static QString formattedNameLabel(); |
143 | 152 | ||
144 | /** | 153 | /** |
145 | Set family name. | 154 | Set family name. |
146 | */ | 155 | */ |
147 | void setFamilyName( const QString &familyName ); | 156 | void setFamilyName( const QString &familyName ); |
148 | /** | 157 | /** |
149 | Return family name. | 158 | Return family name. |
150 | */ | 159 | */ |
151 | QString familyName() const; | 160 | QString familyName() const; |
152 | /** | 161 | /** |
153 | Return translated label for familyName field. | 162 | Return translated label for familyName field. |
154 | */ | 163 | */ |
155 | static QString familyNameLabel(); | 164 | static QString familyNameLabel(); |
156 | 165 | ||
157 | /** | 166 | /** |
158 | Set given name. | 167 | Set given name. |
159 | */ | 168 | */ |
160 | void setGivenName( const QString &givenName ); | 169 | void setGivenName( const QString &givenName ); |
161 | /** | 170 | /** |
162 | Return given name. | 171 | Return given name. |
163 | */ | 172 | */ |
164 | QString givenName() const; | 173 | QString givenName() const; |
165 | /** | 174 | /** |
166 | Return translated label for givenName field. | 175 | Return translated label for givenName field. |
167 | */ | 176 | */ |
168 | static QString givenNameLabel(); | 177 | static QString givenNameLabel(); |
169 | 178 | ||
170 | /** | 179 | /** |
171 | Set additional names. | 180 | Set additional names. |
172 | */ | 181 | */ |
173 | void setAdditionalName( const QString &additionalName ); | 182 | void setAdditionalName( const QString &additionalName ); |
174 | /** | 183 | /** |
175 | Return additional names. | 184 | Return additional names. |
176 | */ | 185 | */ |
177 | QString additionalName() const; | 186 | QString additionalName() const; |
178 | /** | 187 | /** |
179 | Return translated label for additionalName field. | 188 | Return translated label for additionalName field. |
180 | */ | 189 | */ |
181 | static QString additionalNameLabel(); | 190 | static QString additionalNameLabel(); |
182 | 191 | ||
183 | /** | 192 | /** |
184 | Set honorific prefixes. | 193 | Set honorific prefixes. |
185 | */ | 194 | */ |
186 | void setPrefix( const QString &prefix ); | 195 | void setPrefix( const QString &prefix ); |
187 | /** | 196 | /** |
188 | Return honorific prefixes. | 197 | Return honorific prefixes. |
189 | */ | 198 | */ |
190 | QString prefix() const; | 199 | QString prefix() const; |
191 | /** | 200 | /** |
192 | Return translated label for prefix field. | 201 | Return translated label for prefix field. |
193 | */ | 202 | */ |
194 | static QString prefixLabel(); | 203 | static QString prefixLabel(); |
195 | 204 | ||
196 | /** | 205 | /** |
197 | Set honorific suffixes. | 206 | Set honorific suffixes. |
198 | */ | 207 | */ |
199 | void setSuffix( const QString &suffix ); | 208 | void setSuffix( const QString &suffix ); |
200 | /** | 209 | /** |
201 | Return honorific suffixes. | 210 | Return honorific suffixes. |
202 | */ | 211 | */ |
203 | QString suffix() const; | 212 | QString suffix() const; |
204 | /** | 213 | /** |
205 | Return translated label for suffix field. | 214 | Return translated label for suffix field. |
206 | */ | 215 | */ |
207 | static QString suffixLabel(); | 216 | static QString suffixLabel(); |
208 | 217 | ||
209 | /** | 218 | /** |
210 | Set nick name. | 219 | Set nick name. |
211 | */ | 220 | */ |
212 | void setNickName( const QString &nickName ); | 221 | void setNickName( const QString &nickName ); |
213 | /** | 222 | /** |
214 | Return nick name. | 223 | Return nick name. |
215 | */ | 224 | */ |
216 | QString nickName() const; | 225 | QString nickName() const; |
217 | /** | 226 | /** |
218 | Return translated label for nickName field. | 227 | Return translated label for nickName field. |
219 | */ | 228 | */ |
220 | static QString nickNameLabel(); | 229 | static QString nickNameLabel(); |
221 | 230 | ||
222 | /** | 231 | /** |
223 | Set birthday. | 232 | Set birthday. |
224 | */ | 233 | */ |
225 | void setBirthday( const QDateTime &birthday ); | 234 | void setBirthday( const QDateTime &birthday ); |
226 | /** | 235 | /** |
227 | Return birthday. | 236 | Return birthday. |
228 | */ | 237 | */ |
229 | QDateTime birthday() const; | 238 | QDateTime birthday() const; |
230 | /** | 239 | /** |
231 | Return translated label for birthday field. | 240 | Return translated label for birthday field. |
232 | */ | 241 | */ |
233 | static QString birthdayLabel(); | 242 | static QString birthdayLabel(); |
234 | 243 | ||
235 | /** | 244 | /** |
236 | Return translated label for homeAddressStreet field. | 245 | Return translated label for homeAddressStreet field. |
237 | */ | 246 | */ |
238 | static QString homeAddressStreetLabel(); | 247 | static QString homeAddressStreetLabel(); |
239 | 248 | ||
240 | /** | 249 | /** |
241 | Return translated label for homeAddressLocality field. | 250 | Return translated label for homeAddressLocality field. |
242 | */ | 251 | */ |
243 | static QString homeAddressLocalityLabel(); | 252 | static QString homeAddressLocalityLabel(); |
244 | 253 | ||
245 | /** | 254 | /** |
246 | Return translated label for homeAddressRegion field. | 255 | Return translated label for homeAddressRegion field. |
247 | */ | 256 | */ |
248 | static QString homeAddressRegionLabel(); | 257 | static QString homeAddressRegionLabel(); |
249 | 258 | ||
250 | /** | 259 | /** |
251 | Return translated label for homeAddressPostalCode field. | 260 | Return translated label for homeAddressPostalCode field. |
252 | */ | 261 | */ |
253 | static QString homeAddressPostalCodeLabel(); | 262 | static QString homeAddressPostalCodeLabel(); |
254 | 263 | ||
255 | /** | 264 | /** |
256 | Return translated label for homeAddressCountry field. | 265 | Return translated label for homeAddressCountry field. |
257 | */ | 266 | */ |
258 | static QString homeAddressCountryLabel(); | 267 | static QString homeAddressCountryLabel(); |
259 | 268 | ||
260 | /** | 269 | /** |
261 | Return translated label for homeAddressLabel field. | 270 | Return translated label for homeAddressLabel field. |
262 | */ | 271 | */ |
263 | static QString homeAddressLabelLabel(); | 272 | static QString homeAddressLabelLabel(); |
264 | 273 | ||
265 | /** | 274 | /** |
266 | Return translated label for businessAddressStreet field. | 275 | Return translated label for businessAddressStreet field. |
267 | */ | 276 | */ |
268 | static QString businessAddressStreetLabel(); | 277 | static QString businessAddressStreetLabel(); |
269 | 278 | ||
270 | /** | 279 | /** |
271 | Return translated label for businessAddressLocality field. | 280 | Return translated label for businessAddressLocality field. |
272 | */ | 281 | */ |
273 | static QString businessAddressLocalityLabel(); | 282 | static QString businessAddressLocalityLabel(); |
274 | 283 | ||
275 | /** | 284 | /** |
276 | Return translated label for businessAddressRegion field. | 285 | Return translated label for businessAddressRegion field. |
277 | */ | 286 | */ |
278 | static QString businessAddressRegionLabel(); | 287 | static QString businessAddressRegionLabel(); |
279 | 288 | ||
280 | /** | 289 | /** |
281 | Return translated label for businessAddressPostalCode field. | 290 | Return translated label for businessAddressPostalCode field. |
282 | */ | 291 | */ |
283 | static QString businessAddressPostalCodeLabel(); | 292 | static QString businessAddressPostalCodeLabel(); |
284 | 293 | ||
285 | /** | 294 | /** |
286 | Return translated label for businessAddressCountry field. | 295 | Return translated label for businessAddressCountry field. |
287 | */ | 296 | */ |
288 | static QString businessAddressCountryLabel(); | 297 | static QString businessAddressCountryLabel(); |
289 | 298 | ||
290 | /** | 299 | /** |
291 | Return translated label for businessAddressLabel field. | 300 | Return translated label for businessAddressLabel field. |
292 | */ | 301 | */ |
293 | static QString businessAddressLabelLabel(); | 302 | static QString businessAddressLabelLabel(); |
294 | 303 | ||
295 | /** | 304 | /** |
296 | Return translated label for homePhone field. | 305 | Return translated label for homePhone field. |
297 | */ | 306 | */ |
298 | static QString homePhoneLabel(); | 307 | static QString homePhoneLabel(); |
299 | 308 | ||
300 | /** | 309 | /** |
301 | Return translated label for businessPhone field. | 310 | Return translated label for businessPhone field. |
302 | */ | 311 | */ |
303 | static QString businessPhoneLabel(); | 312 | static QString businessPhoneLabel(); |
304 | 313 | ||
305 | /** | 314 | /** |
306 | Return translated label for mobilePhone field. | 315 | Return translated label for mobilePhone field. |
307 | */ | 316 | */ |
308 | static QString mobilePhoneLabel(); | 317 | static QString mobilePhoneLabel(); |
309 | 318 | ||
310 | /** | 319 | /** |
311 | Return translated label for homeFax field. | 320 | Return translated label for homeFax field. |
312 | */ | 321 | */ |
313 | static QString homeFaxLabel(); | 322 | static QString homeFaxLabel(); |
314 | 323 | ||
315 | /** | 324 | /** |
316 | Return translated label for businessFax field. | 325 | Return translated label for businessFax field. |
317 | */ | 326 | */ |
318 | static QString businessFaxLabel(); | 327 | static QString businessFaxLabel(); |
319 | 328 | ||
320 | /** | 329 | /** |
321 | Return translated label for carPhone field. | 330 | Return translated label for carPhone field. |
322 | */ | 331 | */ |
323 | static QString carPhoneLabel(); | 332 | static QString carPhoneLabel(); |
324 | 333 | ||
325 | /** | 334 | /** |
326 | Return translated label for isdn field. | 335 | Return translated label for isdn field. |
327 | */ | 336 | */ |
328 | static QString isdnLabel(); | 337 | static QString isdnLabel(); |
329 | 338 | ||
330 | /** | 339 | /** |
331 | Return translated label for pager field. | 340 | Return translated label for pager field. |
332 | */ | 341 | */ |
333 | static QString pagerLabel(); | 342 | static QString pagerLabel(); |
334 | 343 | ||
335 | /** | 344 | /** |
336 | Return translated label for sip field. | 345 | Return translated label for sip field. |
337 | */ | 346 | */ |
338 | static QString sipLabel(); | 347 | static QString sipLabel(); |
339 | 348 | ||
340 | /** | 349 | /** |
341 | Return translated label for email field. | 350 | Return translated label for email field. |
342 | */ | 351 | */ |
343 | static QString emailLabel(); | 352 | static QString emailLabel(); |
344 | 353 | ||
345 | /** | 354 | /** |
346 | Set mail client. | 355 | Set mail client. |
347 | */ | 356 | */ |
348 | void setMailer( const QString &mailer ); | 357 | void setMailer( const QString &mailer ); |
349 | /** | 358 | /** |
350 | Return mail client. | 359 | Return mail client. |
351 | */ | 360 | */ |
352 | QString mailer() const; | 361 | QString mailer() const; |
353 | /** | 362 | /** |
354 | Return translated label for mailer field. | 363 | Return translated label for mailer field. |
355 | */ | 364 | */ |
356 | static QString mailerLabel(); | 365 | static QString mailerLabel(); |
357 | 366 | ||
358 | /** | 367 | /** |
359 | Set time zone. | 368 | Set time zone. |
360 | */ | 369 | */ |
361 | void setTimeZone( const TimeZone &timeZone ); | 370 | void setTimeZone( const TimeZone &timeZone ); |
362 | /** | 371 | /** |
363 | Return time zone. | 372 | Return time zone. |
364 | */ | 373 | */ |
365 | TimeZone timeZone() const; | 374 | TimeZone timeZone() const; |
366 | /** | 375 | /** |
367 | Return translated label for timeZone field. | 376 | Return translated label for timeZone field. |
368 | */ | 377 | */ |
369 | static QString timeZoneLabel(); | 378 | static QString timeZoneLabel(); |
370 | 379 | ||
371 | /** | 380 | /** |
372 | Set geographic position. | 381 | Set geographic position. |
373 | */ | 382 | */ |
374 | void setGeo( const Geo &geo ); | 383 | void setGeo( const Geo &geo ); |
375 | /** | 384 | /** |
376 | Return geographic position. | 385 | Return geographic position. |
377 | */ | 386 | */ |
378 | Geo geo() const; | 387 | Geo geo() const; |
379 | /** | 388 | /** |
380 | Return translated label for geo field. | 389 | Return translated label for geo field. |
381 | */ | 390 | */ |
382 | static QString geoLabel(); | 391 | static QString geoLabel(); |
383 | 392 | ||
384 | /** | 393 | /** |
385 | Set title. | 394 | Set title. |
386 | */ | 395 | */ |
387 | void setTitle( const QString &title ); | 396 | void setTitle( const QString &title ); |
388 | /** | 397 | /** |
389 | Return title. | 398 | Return title. |
390 | */ | 399 | */ |
391 | QString title() const; | 400 | QString title() const; |
392 | /** | 401 | /** |
393 | Return translated label for title field. | 402 | Return translated label for title field. |
394 | */ | 403 | */ |
395 | static QString titleLabel(); | 404 | static QString titleLabel(); |
396 | 405 | ||
397 | /** | 406 | /** |
398 | Set role. | 407 | Set role. |
399 | */ | 408 | */ |
400 | void setRole( const QString &role ); | 409 | void setRole( const QString &role ); |
401 | /** | 410 | /** |
402 | Return role. | 411 | Return role. |
403 | */ | 412 | */ |
404 | QString role() const; | 413 | QString role() const; |
405 | /** | 414 | /** |
406 | Return translated label for role field. | 415 | Return translated label for role field. |
407 | */ | 416 | */ |
408 | static QString roleLabel(); | 417 | static QString roleLabel(); |
409 | 418 | ||
410 | /** | 419 | /** |
411 | Set organization. | 420 | Set organization. |
412 | */ | 421 | */ |
413 | void setOrganization( const QString &organization ); | 422 | void setOrganization( const QString &organization ); |
414 | /** | 423 | /** |
415 | Return organization. | 424 | Return organization. |
416 | */ | 425 | */ |
417 | QString organization() const; | 426 | QString organization() const; |
418 | /** | 427 | /** |
419 | Return translated label for organization field. | 428 | Return translated label for organization field. |
420 | */ | 429 | */ |
421 | static QString organizationLabel(); | 430 | static QString organizationLabel(); |
422 | 431 | ||
423 | /** | 432 | /** |
424 | Set note. | 433 | Set note. |
425 | */ | 434 | */ |
426 | void setNote( const QString ¬e ); | 435 | void setNote( const QString ¬e ); |
427 | /** | 436 | /** |
428 | Return note. | 437 | Return note. |
429 | */ | 438 | */ |
430 | QString note() const; | 439 | QString note() const; |
431 | /** | 440 | /** |
432 | Return translated label for note field. | 441 | Return translated label for note field. |
433 | */ | 442 | */ |
434 | static QString noteLabel(); | 443 | static QString noteLabel(); |
435 | 444 | ||
436 | /** | 445 | /** |
437 | Set product identifier. | 446 | Set product identifier. |
438 | */ | 447 | */ |
439 | void setProductId( const QString &productId ); | 448 | void setProductId( const QString &productId ); |
440 | /** | 449 | /** |
441 | Return product identifier. | 450 | Return product identifier. |
442 | */ | 451 | */ |
443 | QString productId() const; | 452 | QString productId() const; |
444 | /** | 453 | /** |
445 | Return translated label for productId field. | 454 | Return translated label for productId field. |
446 | */ | 455 | */ |
447 | static QString productIdLabel(); | 456 | static QString productIdLabel(); |
448 | 457 | ||
449 | /** | 458 | /** |
450 | Set revision date. | 459 | Set revision date. |
451 | */ | 460 | */ |
452 | void setRevision( const QDateTime &revision ); | 461 | void setRevision( const QDateTime &revision ); |
453 | /** | 462 | /** |
454 | Return revision date. | 463 | Return revision date. |
455 | */ | 464 | */ |
456 | QDateTime revision() const; | 465 | QDateTime revision() const; |
457 | /** | 466 | /** |
458 | Return translated label for revision field. | 467 | Return translated label for revision field. |
459 | */ | 468 | */ |
460 | static QString revisionLabel(); | 469 | static QString revisionLabel(); |
461 | 470 | ||
462 | /** | 471 | /** |
463 | Set sort string. | 472 | Set sort string. |
464 | */ | 473 | */ |
465 | void setSortString( const QString &sortString ); | 474 | void setSortString( const QString &sortString ); |
466 | /** | 475 | /** |
467 | Return sort string. | 476 | Return sort string. |
468 | */ | 477 | */ |
469 | QString sortString() const; | 478 | QString sortString() const; |
470 | /** | 479 | /** |
471 | Return translated label for sortString field. | 480 | Return translated label for sortString field. |
472 | */ | 481 | */ |
473 | static QString sortStringLabel(); | 482 | static QString sortStringLabel(); |
474 | 483 | ||
475 | /** | 484 | /** |
476 | Set URL. | 485 | Set URL. |
477 | */ | 486 | */ |
478 | void setUrl( const KURL &url ); | 487 | void setUrl( const KURL &url ); |
479 | /** | 488 | /** |
480 | Return URL. | 489 | Return URL. |
481 | */ | 490 | */ |
482 | KURL url() const; | 491 | KURL url() const; |
483 | /** | 492 | /** |
484 | Return translated label for url field. | 493 | Return translated label for url field. |
485 | */ | 494 | */ |
486 | static QString urlLabel(); | 495 | static QString urlLabel(); |
487 | 496 | ||
488 | /** | 497 | /** |
489 | Set security class. | 498 | Set security class. |
490 | */ | 499 | */ |
491 | void setSecrecy( const Secrecy &secrecy ); | 500 | void setSecrecy( const Secrecy &secrecy ); |
492 | /** | 501 | /** |
493 | Return security class. | 502 | Return security class. |
494 | */ | 503 | */ |
495 | Secrecy secrecy() const; | 504 | Secrecy secrecy() const; |
496 | /** | 505 | /** |
497 | Return translated label for secrecy field. | 506 | Return translated label for secrecy field. |
498 | */ | 507 | */ |
499 | static QString secrecyLabel(); | 508 | static QString secrecyLabel(); |
500 | 509 | ||
501 | /** | 510 | /** |
502 | Set logo. | 511 | Set logo. |
503 | */ | 512 | */ |
504 | void setLogo( const Picture &logo ); | 513 | void setLogo( const Picture &logo ); |
505 | /** | 514 | /** |
506 | Return logo. | 515 | Return logo. |
507 | */ | 516 | */ |
508 | Picture logo() const; | 517 | Picture logo() const; |
509 | /** | 518 | /** |
510 | Return translated label for logo field. | 519 | Return translated label for logo field. |
511 | */ | 520 | */ |
512 | static QString logoLabel(); | 521 | static QString logoLabel(); |
513 | 522 | ||
514 | /** | 523 | /** |
515 | Set photo. | 524 | Set photo. |
516 | */ | 525 | */ |
517 | void setPhoto( const Picture &photo ); | 526 | void setPhoto( const Picture &photo ); |
518 | /** | 527 | /** |
519 | Return photo. | 528 | Return photo. |
520 | */ | 529 | */ |
521 | Picture photo() const; | 530 | Picture photo() const; |
522 | /** | 531 | /** |
523 | Return translated label for photo field. | 532 | Return translated label for photo field. |
524 | */ | 533 | */ |
525 | static QString photoLabel(); | 534 | static QString photoLabel(); |
526 | 535 | ||
527 | /** | 536 | /** |
528 | Set sound. | 537 | Set sound. |
529 | */ | 538 | */ |
530 | void setSound( const Sound &sound ); | 539 | void setSound( const Sound &sound ); |
531 | /** | 540 | /** |
532 | Return sound. | 541 | Return sound. |
533 | */ | 542 | */ |
534 | Sound sound() const; | 543 | Sound sound() const; |
535 | /** | 544 | /** |
536 | Return translated label for sound field. | 545 | Return translated label for sound field. |
537 | */ | 546 | */ |
538 | static QString soundLabel(); | 547 | static QString soundLabel(); |
539 | 548 | ||
540 | /** | 549 | /** |
541 | Set agent. | 550 | Set agent. |
542 | */ | 551 | */ |
543 | void setAgent( const Agent &agent ); | 552 | void setAgent( const Agent &agent ); |
544 | /** | 553 | /** |
545 | Return agent. | 554 | Return agent. |
546 | */ | 555 | */ |
547 | Agent agent() const; | 556 | Agent agent() const; |
548 | /** | 557 | /** |
549 | Return translated label for agent field. | 558 | Return translated label for agent field. |
550 | */ | 559 | */ |
551 | static QString agentLabel(); | 560 | static QString agentLabel(); |
552 | 561 | ||
553 | /** | 562 | /** |
554 | Set name fields by parsing the given string and trying to associate the | 563 | Set name fields by parsing the given string and trying to associate the |
555 | parts of the string with according fields. This function should probably | 564 | parts of the string with according fields. This function should probably |
556 | be a bit more clever. | 565 | be a bit more clever. |
557 | */ | 566 | */ |
558 | void setNameFromString( const QString & ); | 567 | void setNameFromString( const QString & ); |
559 | 568 | ||
560 | /** | 569 | /** |
561 | Return the name of the addressee. This is calculated from all the name | 570 | Return the name of the addressee. This is calculated from all the name |
562 | fields. | 571 | fields. |
563 | */ | 572 | */ |
564 | QString realName() const; | 573 | QString realName() const; |
565 | 574 | ||
566 | /** | 575 | /** |
567 | Return the name that consists of all name parts. | 576 | Return the name that consists of all name parts. |
568 | */ | 577 | */ |
569 | QString assembledName() const; | 578 | QString assembledName() const; |
570 | 579 | ||
571 | /** | 580 | /** |
572 | Return email address including real name. | 581 | Return email address including real name. |
573 | 582 | ||
574 | @param email Email address to be used to construct the full email string. | 583 | @param email Email address to be used to construct the full email string. |
575 | If this is QString::null the preferred email address is used. | 584 | If this is QString::null the preferred email address is used. |
576 | */ | 585 | */ |
577 | QString fullEmail( const QString &email=QString::null ) const; | 586 | QString fullEmail( const QString &email=QString::null ) const; |
578 | 587 | ||
579 | /** | 588 | /** |
580 | Insert an email address. If the email address already exists in this | 589 | Insert an email address. If the email address already exists in this |
581 | addressee it is not duplicated. | 590 | addressee it is not duplicated. |
582 | 591 | ||
583 | @param email Email address | 592 | @param email Email address |
584 | @param preferred Set to true, if this is the preferred email address of | 593 | @param preferred Set to true, if this is the preferred email address of |
585 | the addressee. | 594 | the addressee. |
586 | */ | 595 | */ |
587 | void insertEmail( const QString &email, bool preferred=false ); | 596 | void insertEmail( const QString &email, bool preferred=false ); |
588 | 597 | ||
589 | /** | 598 | /** |
590 | Remove email address. If the email address doesn't exist, nothing happens. | 599 | Remove email address. If the email address doesn't exist, nothing happens. |
591 | */ | 600 | */ |
592 | void removeEmail( const QString &email ); | 601 | void removeEmail( const QString &email ); |
593 | 602 | ||
594 | /** | 603 | /** |
595 | Return preferred email address. This is the first email address or the | 604 | Return preferred email address. This is the first email address or the |
596 | last one added with @ref insertEmail() with a set preferred parameter. | 605 | last one added with @ref insertEmail() with a set preferred parameter. |
597 | */ | 606 | */ |
598 | QString preferredEmail() const; | 607 | QString preferredEmail() const; |
599 | 608 | ||
600 | /** | 609 | /** |
601 | Return list of all email addresses. | 610 | Return list of all email addresses. |
602 | */ | 611 | */ |
603 | QStringList emails() const; | 612 | QStringList emails() const; |
604 | 613 | ||
605 | /** | 614 | /** |
606 | Set the emails to @param. | 615 | Set the emails to @param. |
607 | The first email address gets the preferred one! | 616 | The first email address gets the preferred one! |
608 | @param list The list of email addresses. | 617 | @param list The list of email addresses. |
609 | */ | 618 | */ |
610 | void setEmails( const QStringList& list); | 619 | void setEmails( const QStringList& list); |
611 | 620 | ||
612 | /** | 621 | /** |
613 | Insert a phone number. If a phone number with the same id already exists | 622 | Insert a phone number. If a phone number with the same id already exists |
614 | in this addressee it is not duplicated. | 623 | in this addressee it is not duplicated. |
615 | */ | 624 | */ |
616 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); | 625 | void insertPhoneNumber( const PhoneNumber &phoneNumber ); |
617 | 626 | ||
618 | /** | 627 | /** |
619 | Remove phone number. If no phone number with the given id exists for this | 628 | Remove phone number. If no phone number with the given id exists for this |
620 | addresse nothing happens. | 629 | addresse nothing happens. |
621 | */ | 630 | */ |
622 | void removePhoneNumber( const PhoneNumber &phoneNumber ); | 631 | void removePhoneNumber( const PhoneNumber &phoneNumber ); |
623 | 632 | ||
624 | /** | 633 | /** |
625 | Return phone number, which matches the given type. | 634 | Return phone number, which matches the given type. |
626 | */ | 635 | */ |
627 | PhoneNumber phoneNumber( int type ) const; | 636 | PhoneNumber phoneNumber( int type ) const; |
628 | 637 | ||
629 | /** | 638 | /** |
630 | Return list of all phone numbers. | 639 | Return list of all phone numbers. |
631 | */ | 640 | */ |
632 | PhoneNumber::List phoneNumbers() const; | 641 | PhoneNumber::List phoneNumbers() const; |
633 | 642 | ||
634 | /** | 643 | /** |
635 | Return list of phone numbers with a special type. | 644 | Return list of phone numbers with a special type. |
636 | */ | 645 | */ |
637 | PhoneNumber::List phoneNumbers( int type ) const; | 646 | PhoneNumber::List phoneNumbers( int type ) const; |
638 | 647 | ||
639 | /** | 648 | /** |
640 | Return phone number with the given id. | 649 | Return phone number with the given id. |
641 | */ | 650 | */ |
642 | PhoneNumber findPhoneNumber( const QString &id ) const; | 651 | PhoneNumber findPhoneNumber( const QString &id ) const; |
643 | 652 | ||
644 | /** | 653 | /** |
645 | Insert a key. If a key with the same id already exists | 654 | Insert a key. If a key with the same id already exists |
646 | in this addressee it is not duplicated. | 655 | in this addressee it is not duplicated. |
647 | */ | 656 | */ |
648 | void insertKey( const Key &key ); | 657 | void insertKey( const Key &key ); |
649 | 658 | ||
650 | /** | 659 | /** |
651 | Remove a key. If no key with the given id exists for this | 660 | Remove a key. If no key with the given id exists for this |
652 | addresse nothing happens. | 661 | addresse nothing happens. |
653 | */ | 662 | */ |
654 | void removeKey( const Key &key ); | 663 | void removeKey( const Key &key ); |
655 | 664 | ||
656 | /** | 665 | /** |
657 | Return key, which matches the given type. | 666 | Return key, which matches the given type. |
658 | If @p type == Key::Custom you can specify a string | 667 | If @p type == Key::Custom you can specify a string |
659 | that should match. If you leave the string empty, the first | 668 | that should match. If you leave the string empty, the first |
660 | key with a custom value is returned. | 669 | key with a custom value is returned. |
661 | */ | 670 | */ |
662 | Key key( int type, QString customTypeString = QString::null ) const; | 671 | Key key( int type, QString customTypeString = QString::null ) const; |
663 | 672 | ||
664 | /** | 673 | /** |
665 | Return list of all keys. | 674 | Return list of all keys. |
666 | */ | 675 | */ |
667 | Key::List keys() const; | 676 | Key::List keys() const; |
668 | 677 | ||
669 | /** | 678 | /** |
670 | Set the list of keys | 679 | Set the list of keys |
671 | @param keys The keys to be set. | 680 | @param keys The keys to be set. |
672 | */ | 681 | */ |
673 | void setKeys( const Key::List& keys); | 682 | void setKeys( const Key::List& keys); |
674 | 683 | ||
675 | /** | 684 | /** |
676 | Return list of keys with a special type. | 685 | Return list of keys with a special type. |
677 | If @p type == Key::Custom you can specify a string | 686 | If @p type == Key::Custom you can specify a string |
678 | that should match. If you leave the string empty, all custom | 687 | that should match. If you leave the string empty, all custom |
679 | keys will be returned. | 688 | keys will be returned. |
680 | */ | 689 | */ |
681 | Key::List keys( int type, QString customTypeString = QString::null ) const; | 690 | Key::List keys( int type, QString customTypeString = QString::null ) const; |
682 | 691 | ||
683 | /** | 692 | /** |
684 | Return key with the given id. | 693 | Return key with the given id. |
685 | */ | 694 | */ |
686 | Key findKey( const QString &id ) const; | 695 | Key findKey( const QString &id ) const; |
687 | 696 | ||
688 | /** | 697 | /** |
689 | Insert an address. If an address with the same id already exists | 698 | Insert an address. If an address with the same id already exists |
690 | in this addressee it is not duplicated. | 699 | in this addressee it is not duplicated. |
691 | */ | 700 | */ |
692 | void insertAddress( const Address &address ); | 701 | void insertAddress( const Address &address ); |
693 | 702 | ||
694 | /** | 703 | /** |
695 | Remove address. If no address with the given id exists for this | 704 | Remove address. If no address with the given id exists for this |
696 | addresse nothing happens. | 705 | addresse nothing happens. |
697 | */ | 706 | */ |
698 | void removeAddress( const Address &address ); | 707 | void removeAddress( const Address &address ); |
699 | 708 | ||
700 | /** | 709 | /** |
701 | Return address, which matches the given type. | 710 | Return address, which matches the given type. |
702 | */ | 711 | */ |
703 | Address address( int type ) const; | 712 | Address address( int type ) const; |
704 | 713 | ||
705 | /** | 714 | /** |
706 | Return list of all addresses. | 715 | Return list of all addresses. |
707 | */ | 716 | */ |
708 | Address::List addresses() const; | 717 | Address::List addresses() const; |
709 | 718 | ||
710 | /** | 719 | /** |
711 | Return list of addresses with a special type. | 720 | Return list of addresses with a special type. |
712 | */ | 721 | */ |
713 | Address::List addresses( int type ) const; | 722 | Address::List addresses( int type ) const; |
714 | 723 | ||
715 | /** | 724 | /** |
716 | Return address with the given id. | 725 | Return address with the given id. |
717 | */ | 726 | */ |
718 | Address findAddress( const QString &id ) const; | 727 | Address findAddress( const QString &id ) const; |
719 | 728 | ||
720 | /** | 729 | /** |
721 | Insert category. If the category already exists it is not duplicated. | 730 | Insert category. If the category already exists it is not duplicated. |
722 | */ | 731 | */ |
723 | void insertCategory( const QString & ); | 732 | void insertCategory( const QString & ); |
724 | 733 | ||
725 | /** | 734 | /** |
726 | Remove category. | 735 | Remove category. |
727 | */ | 736 | */ |
728 | void removeCategory( const QString & ); | 737 | void removeCategory( const QString & ); |
729 | 738 | ||
730 | /** | 739 | /** |
731 | Return, if addressee has the given category. | 740 | Return, if addressee has the given category. |
732 | */ | 741 | */ |
733 | bool hasCategory( const QString & ) const; | 742 | bool hasCategory( const QString & ) const; |
734 | 743 | ||
735 | /** | 744 | /** |
736 | Set categories to given value. | 745 | Set categories to given value. |
737 | */ | 746 | */ |
738 | void setCategories( const QStringList & ); | 747 | void setCategories( const QStringList & ); |
739 | 748 | ||
740 | /** | 749 | /** |
741 | Return list of all set categories. | 750 | Return list of all set categories. |
742 | */ | 751 | */ |
743 | QStringList categories() const; | 752 | QStringList categories() const; |
744 | 753 | ||
745 | /** | 754 | /** |
746 | Insert custom entry. The entry is identified by the name of the inserting | 755 | Insert custom entry. The entry is identified by the name of the inserting |
747 | application and a unique name. If an entry with the given app and name | 756 | application and a unique name. If an entry with the given app and name |
748 | already exists its value is replaced with the new given value. | 757 | already exists its value is replaced with the new given value. |
749 | */ | 758 | */ |
750 | void insertCustom( const QString &app, const QString &name, | 759 | void insertCustom( const QString &app, const QString &name, |
751 | const QString &value ); | 760 | const QString &value ); |
752 | 761 | ||
753 | /** | 762 | /** |
754 | Remove custom entry. | 763 | Remove custom entry. |
755 | */ | 764 | */ |
756 | void removeCustom( const QString &app, const QString &name ); | 765 | void removeCustom( const QString &app, const QString &name ); |
757 | 766 | ||
758 | /** | 767 | /** |
759 | Return value of custom entry, identified by app and entry name. | 768 | Return value of custom entry, identified by app and entry name. |
760 | */ | 769 | */ |
761 | QString custom( const QString &app, const QString &name ) const; | 770 | QString custom( const QString &app, const QString &name ) const; |
762 | 771 | ||
763 | /** | 772 | /** |
764 | Set all custom entries. | 773 | Set all custom entries. |
765 | */ | 774 | */ |
766 | void setCustoms( const QStringList & ); | 775 | void setCustoms( const QStringList & ); |
767 | 776 | ||
768 | /** | 777 | /** |
769 | Return list of all custom entries. | 778 | Return list of all custom entries. |
770 | */ | 779 | */ |
771 | QStringList customs() const; | 780 | QStringList customs() const; |
772 | 781 | ||
773 | /** | 782 | /** |
774 | Parse full email address. The result is given back in fullName and email. | 783 | Parse full email address. The result is given back in fullName and email. |
775 | */ | 784 | */ |
776 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, | 785 | static void parseEmailAddress( const QString &rawEmail, QString &fullName, |
777 | QString &email ); | 786 | QString &email ); |
778 | 787 | ||
779 | /** | 788 | /** |
780 | Debug output. | 789 | Debug output. |
781 | */ | 790 | */ |
782 | void dump() const; | 791 | void dump() const; |
783 | 792 | ||
784 | /** | 793 | /** |
785 | Returns string representation of the addressee. | 794 | Returns string representation of the addressee. |
786 | */ | 795 | */ |
787 | QString asString() const; | 796 | QString asString() const; |
788 | 797 | ||
789 | /** | 798 | /** |
790 | Set resource where the addressee is from. | 799 | Set resource where the addressee is from. |
791 | */ | 800 | */ |
792 | void setResource( Resource *resource ); | 801 | void setResource( Resource *resource ); |
793 | 802 | ||
794 | /** | 803 | /** |
795 | Return pointer to resource. | 804 | Return pointer to resource. |
796 | */ | 805 | */ |
797 | Resource *resource() const; | 806 | Resource *resource() const; |
798 | 807 | ||
799 | /** | 808 | /** |
800 | Return resourcelabel. | 809 | Return resourcelabel. |
801 | */ | 810 | */ |
802 | //US | 811 | //US |
803 | static QString resourceLabel(); | 812 | static QString resourceLabel(); |
804 | 813 | ||
805 | /** | 814 | /** |
806 | Mark addressee as changed. | 815 | Mark addressee as changed. |
807 | */ | 816 | */ |
808 | void setChanged( bool value ); | 817 | void setChanged( bool value ); |
809 | 818 | ||
810 | /** | 819 | /** |
811 | Return whether the addressee is changed. | 820 | Return whether the addressee is changed. |
812 | */ | 821 | */ |
813 | bool changed() const; | 822 | bool changed() const; |
814 | 823 | ||
815 | private: | 824 | private: |
816 | Addressee copy(); | 825 | Addressee copy(); |
817 | void detach(); | 826 | void detach(); |
827 | int mTempSyncStat; | ||
818 | 828 | ||
819 | struct AddresseeData; | 829 | struct AddresseeData; |
820 | mutable KSharedPtr<AddresseeData> mData; | 830 | mutable KSharedPtr<AddresseeData> mData; |
821 | }; | 831 | }; |
822 | 832 | ||
823 | QDataStream &operator<<( QDataStream &, const Addressee & ); | 833 | QDataStream &operator<<( QDataStream &, const Addressee & ); |
824 | QDataStream &operator>>( QDataStream &, Addressee & ); | 834 | QDataStream &operator>>( QDataStream &, Addressee & ); |
825 | 835 | ||
826 | } | 836 | } |
827 | 837 | ||
828 | #endif | 838 | #endif |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 1196360..53c63ff 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,2873 +1,2896 @@ | |||
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 | /* | 24 | /* |
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 | 36 | ||
37 | #ifndef KAB_EMBEDDED | 37 | #ifndef KAB_EMBEDDED |
38 | #include <qclipboard.h> | 38 | #include <qclipboard.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qapplicaton.h> | 41 | #include <qapplicaton.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qvbox.h> | 44 | #include <qvbox.h> |
45 | #include <kabc/addresseelist.h> | 45 | #include <kabc/addresseelist.h> |
46 | #include <kabc/errorhandler.h> | 46 | #include <kabc/errorhandler.h> |
47 | #include <kabc/resource.h> | 47 | #include <kabc/resource.h> |
48 | #include <kabc/vcardconverter.h> | 48 | #include <kabc/vcardconverter.h> |
49 | #include <kapplication.h> | 49 | #include <kapplication.h> |
50 | #include <kactionclasses.h> | 50 | #include <kactionclasses.h> |
51 | #include <kcmultidialog.h> | 51 | #include <kcmultidialog.h> |
52 | #include <kdebug.h> | 52 | #include <kdebug.h> |
53 | #include <kdeversion.h> | 53 | #include <kdeversion.h> |
54 | #include <kkeydialog.h> | 54 | #include <kkeydialog.h> |
55 | #include <kmessagebox.h> | 55 | #include <kmessagebox.h> |
56 | #include <kprinter.h> | 56 | #include <kprinter.h> |
57 | #include <kprotocolinfo.h> | 57 | #include <kprotocolinfo.h> |
58 | #include <kresources/selectdialog.h> | 58 | #include <kresources/selectdialog.h> |
59 | #include <kstandarddirs.h> | 59 | #include <kstandarddirs.h> |
60 | #include <ktempfile.h> | 60 | #include <ktempfile.h> |
61 | #include <kxmlguiclient.h> | 61 | #include <kxmlguiclient.h> |
62 | #include <kaboutdata.h> | 62 | #include <kaboutdata.h> |
63 | #include <libkdepim/categoryselectdialog.h> | 63 | #include <libkdepim/categoryselectdialog.h> |
64 | 64 | ||
65 | #include "addresseeutil.h" | 65 | #include "addresseeutil.h" |
66 | #include "addresseeeditordialog.h" | 66 | #include "addresseeeditordialog.h" |
67 | #include "extensionmanager.h" | 67 | #include "extensionmanager.h" |
68 | #include "kstdaction.h" | 68 | #include "kstdaction.h" |
69 | #include "kaddressbookservice.h" | 69 | #include "kaddressbookservice.h" |
70 | #include "ldapsearchdialog.h" | 70 | #include "ldapsearchdialog.h" |
71 | #include "printing/printingwizard.h" | 71 | #include "printing/printingwizard.h" |
72 | #else // KAB_EMBEDDED | 72 | #else // KAB_EMBEDDED |
73 | 73 | ||
74 | #include <kapplication.h> | 74 | #include <kapplication.h> |
75 | #include "KDGanttMinimizeSplitter.h" | 75 | #include "KDGanttMinimizeSplitter.h" |
76 | #include "kaddressbookmain.h" | 76 | #include "kaddressbookmain.h" |
77 | #include "kactioncollection.h" | 77 | #include "kactioncollection.h" |
78 | #include "addresseedialog.h" | 78 | #include "addresseedialog.h" |
79 | //US | 79 | //US |
80 | #include <addresseeview.h> | 80 | #include <addresseeview.h> |
81 | 81 | ||
82 | #include <qapp.h> | 82 | #include <qapp.h> |
83 | #include <qmenubar.h> | 83 | #include <qmenubar.h> |
84 | //#include <qtoolbar.h> | 84 | //#include <qtoolbar.h> |
85 | #include <qmessagebox.h> | 85 | #include <qmessagebox.h> |
86 | #include <kdebug.h> | 86 | #include <kdebug.h> |
87 | #include <kiconloader.h> // needed for SmallIcon | 87 | #include <kiconloader.h> // needed for SmallIcon |
88 | #include <kresources/kcmkresources.h> | 88 | #include <kresources/kcmkresources.h> |
89 | #include <ktoolbar.h> | 89 | #include <ktoolbar.h> |
90 | 90 | ||
91 | 91 | ||
92 | //#include <qlabel.h> | 92 | //#include <qlabel.h> |
93 | 93 | ||
94 | 94 | ||
95 | #ifndef DESKTOP_VERSION | 95 | #ifndef DESKTOP_VERSION |
96 | #include <qpe/ir.h> | 96 | #include <qpe/ir.h> |
97 | #include <qpe/qpemenubar.h> | 97 | #include <qpe/qpemenubar.h> |
98 | #include <qtopia/qcopenvelope_qws.h> | 98 | #include <qtopia/qcopenvelope_qws.h> |
99 | #else | 99 | #else |
100 | 100 | ||
101 | #include <qmenubar.h> | 101 | #include <qmenubar.h> |
102 | #endif | 102 | #endif |
103 | 103 | ||
104 | #endif // KAB_EMBEDDED | 104 | #endif // KAB_EMBEDDED |
105 | #include "kcmconfigs/kcmkabconfig.h" | 105 | #include "kcmconfigs/kcmkabconfig.h" |
106 | #include "kcmconfigs/kcmkdepimconfig.h" | 106 | #include "kcmconfigs/kcmkdepimconfig.h" |
107 | #include "kpimglobalprefs.h" | 107 | #include "kpimglobalprefs.h" |
108 | #include "externalapphandler.h" | 108 | #include "externalapphandler.h" |
109 | 109 | ||
110 | 110 | ||
111 | #include <kresources/selectdialog.h> | 111 | #include <kresources/selectdialog.h> |
112 | #include <kmessagebox.h> | 112 | #include <kmessagebox.h> |
113 | 113 | ||
114 | #include <picture.h> | 114 | #include <picture.h> |
115 | #include <resource.h> | 115 | #include <resource.h> |
116 | 116 | ||
117 | //US#include <qsplitter.h> | 117 | //US#include <qsplitter.h> |
118 | #include <qmap.h> | 118 | #include <qmap.h> |
119 | #include <qdir.h> | 119 | #include <qdir.h> |
120 | #include <qfile.h> | 120 | #include <qfile.h> |
121 | #include <qvbox.h> | 121 | #include <qvbox.h> |
122 | #include <qlayout.h> | 122 | #include <qlayout.h> |
123 | #include <qclipboard.h> | 123 | #include <qclipboard.h> |
124 | #include <qtextstream.h> | 124 | #include <qtextstream.h> |
125 | 125 | ||
126 | #include <libkdepim/categoryselectdialog.h> | 126 | #include <libkdepim/categoryselectdialog.h> |
127 | #include <kabc/vcardconverter.h> | 127 | #include <kabc/vcardconverter.h> |
128 | 128 | ||
129 | 129 | ||
130 | #include "addresseeutil.h" | 130 | #include "addresseeutil.h" |
131 | #include "undocmds.h" | 131 | #include "undocmds.h" |
132 | #include "addresseeeditordialog.h" | 132 | #include "addresseeeditordialog.h" |
133 | #include "viewmanager.h" | 133 | #include "viewmanager.h" |
134 | #include "details/detailsviewcontainer.h" | 134 | #include "details/detailsviewcontainer.h" |
135 | #include "kabprefs.h" | 135 | #include "kabprefs.h" |
136 | #include "xxportmanager.h" | 136 | #include "xxportmanager.h" |
137 | #include "incsearchwidget.h" | 137 | #include "incsearchwidget.h" |
138 | #include "jumpbuttonbar.h" | 138 | #include "jumpbuttonbar.h" |
139 | #include "extensionmanager.h" | 139 | #include "extensionmanager.h" |
140 | #include "addresseeconfig.h" | 140 | #include "addresseeconfig.h" |
141 | #include <kcmultidialog.h> | 141 | #include <kcmultidialog.h> |
142 | 142 | ||
143 | #ifdef _WIN32_ | 143 | #ifdef _WIN32_ |
144 | 144 | ||
145 | #include "kaimportoldialog.h" | 145 | #include "kaimportoldialog.h" |
146 | #else | 146 | #else |
147 | #include <unistd.h> | 147 | #include <unistd.h> |
148 | #endif | 148 | #endif |
149 | // sync includes | 149 | // sync includes |
150 | #include <libkdepim/ksyncprofile.h> | 150 | #include <libkdepim/ksyncprofile.h> |
151 | #include <libkdepim/ksyncprefsdialog.h> | 151 | #include <libkdepim/ksyncprefsdialog.h> |
152 | 152 | ||
153 | 153 | ||
154 | bool pasteWithNewUid = true; | 154 | bool pasteWithNewUid = true; |
155 | 155 | ||
156 | #ifdef KAB_EMBEDDED | 156 | #ifdef KAB_EMBEDDED |
157 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 157 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
158 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 158 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
159 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 159 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
160 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 160 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
161 | #else //KAB_EMBEDDED | 161 | #else //KAB_EMBEDDED |
162 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 162 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
163 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 163 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
164 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 164 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
165 | mReadWrite( readWrite ), mModified( false ) | 165 | mReadWrite( readWrite ), mModified( false ) |
166 | #endif //KAB_EMBEDDED | 166 | #endif //KAB_EMBEDDED |
167 | { | 167 | { |
168 | 168 | ||
169 | mBlockSaveFlag = false; | 169 | mBlockSaveFlag = false; |
170 | mExtensionBarSplitter = 0; | 170 | mExtensionBarSplitter = 0; |
171 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 171 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
172 | 172 | ||
173 | mAddressBook = KABC::StdAddressBook::self(); | 173 | mAddressBook = KABC::StdAddressBook::self(); |
174 | KABC::StdAddressBook::setAutomaticSave( false ); | 174 | KABC::StdAddressBook::setAutomaticSave( false ); |
175 | 175 | ||
176 | #ifndef KAB_EMBEDDED | 176 | #ifndef KAB_EMBEDDED |
177 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 177 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
178 | #endif //KAB_EMBEDDED | 178 | #endif //KAB_EMBEDDED |
179 | 179 | ||
180 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 180 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
181 | SLOT( addressBookChanged() ) ); | 181 | SLOT( addressBookChanged() ) ); |
182 | 182 | ||
183 | #if 0 | 183 | #if 0 |
184 | // LP moved to addressbook init method | 184 | // LP moved to addressbook init method |
185 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 185 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
186 | "X-Department", "KADDRESSBOOK" ); | 186 | "X-Department", "KADDRESSBOOK" ); |
187 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 187 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
188 | "X-Profession", "KADDRESSBOOK" ); | 188 | "X-Profession", "KADDRESSBOOK" ); |
189 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 189 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
190 | "X-AssistantsName", "KADDRESSBOOK" ); | 190 | "X-AssistantsName", "KADDRESSBOOK" ); |
191 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 191 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
192 | "X-ManagersName", "KADDRESSBOOK" ); | 192 | "X-ManagersName", "KADDRESSBOOK" ); |
193 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 193 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
194 | "X-SpousesName", "KADDRESSBOOK" ); | 194 | "X-SpousesName", "KADDRESSBOOK" ); |
195 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 195 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
196 | "X-Office", "KADDRESSBOOK" ); | 196 | "X-Office", "KADDRESSBOOK" ); |
197 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 197 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
198 | "X-IMAddress", "KADDRESSBOOK" ); | 198 | "X-IMAddress", "KADDRESSBOOK" ); |
199 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 199 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
200 | "X-Anniversary", "KADDRESSBOOK" ); | 200 | "X-Anniversary", "KADDRESSBOOK" ); |
201 | 201 | ||
202 | //US added this field to become compatible with Opie/qtopia addressbook | 202 | //US added this field to become compatible with Opie/qtopia addressbook |
203 | // values can be "female" or "male" or "". An empty field represents undefined. | 203 | // values can be "female" or "male" or "". An empty field represents undefined. |
204 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 204 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
205 | "X-Gender", "KADDRESSBOOK" ); | 205 | "X-Gender", "KADDRESSBOOK" ); |
206 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 206 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
207 | "X-Children", "KADDRESSBOOK" ); | 207 | "X-Children", "KADDRESSBOOK" ); |
208 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 208 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
209 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 209 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
210 | #endif | 210 | #endif |
211 | initGUI(); | 211 | initGUI(); |
212 | 212 | ||
213 | mIncSearchWidget->setFocus(); | 213 | mIncSearchWidget->setFocus(); |
214 | 214 | ||
215 | 215 | ||
216 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 216 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
217 | SLOT( setContactSelected( const QString& ) ) ); | 217 | SLOT( setContactSelected( const QString& ) ) ); |
218 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 218 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
219 | SLOT( executeContact( const QString& ) ) ); | 219 | SLOT( executeContact( const QString& ) ) ); |
220 | 220 | ||
221 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 221 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
222 | SLOT( deleteContacts( ) ) ); | 222 | SLOT( deleteContacts( ) ) ); |
223 | connect( mViewManager, SIGNAL( modified() ), | 223 | connect( mViewManager, SIGNAL( modified() ), |
224 | SLOT( setModified() ) ); | 224 | SLOT( setModified() ) ); |
225 | 225 | ||
226 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 226 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
227 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 227 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
228 | 228 | ||
229 | connect( mXXPortManager, SIGNAL( modified() ), | 229 | connect( mXXPortManager, SIGNAL( modified() ), |
230 | SLOT( setModified() ) ); | 230 | SLOT( setModified() ) ); |
231 | 231 | ||
232 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 232 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
233 | SLOT( incrementalSearch( const QString& ) ) ); | 233 | SLOT( incrementalSearch( const QString& ) ) ); |
234 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 234 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
235 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 235 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
236 | 236 | ||
237 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 237 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
238 | SLOT( sendMail( const QString& ) ) ); | 238 | SLOT( sendMail( const QString& ) ) ); |
239 | 239 | ||
240 | 240 | ||
241 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 241 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
242 | 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&))); | 242 | 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&))); |
243 | 243 | ||
244 | 244 | ||
245 | #ifndef KAB_EMBEDDED | 245 | #ifndef KAB_EMBEDDED |
246 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 246 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
247 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 247 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
248 | 248 | ||
249 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 249 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
250 | SLOT( browse( const QString& ) ) ); | 250 | SLOT( browse( const QString& ) ) ); |
251 | 251 | ||
252 | 252 | ||
253 | mAddressBookService = new KAddressBookService( this ); | 253 | mAddressBookService = new KAddressBookService( this ); |
254 | 254 | ||
255 | #endif //KAB_EMBEDDED | 255 | #endif //KAB_EMBEDDED |
256 | mEditorDialog = 0; | 256 | mEditorDialog = 0; |
257 | createAddresseeEditorDialog( this ); | 257 | createAddresseeEditorDialog( this ); |
258 | setModified( false ); | 258 | setModified( false ); |
259 | } | 259 | } |
260 | 260 | ||
261 | KABCore::~KABCore() | 261 | KABCore::~KABCore() |
262 | { | 262 | { |
263 | // save(); | 263 | // save(); |
264 | //saveSettings(); | 264 | //saveSettings(); |
265 | //KABPrefs::instance()->writeConfig(); | 265 | //KABPrefs::instance()->writeConfig(); |
266 | delete AddresseeConfig::instance(); | 266 | delete AddresseeConfig::instance(); |
267 | mAddressBook = 0; | 267 | mAddressBook = 0; |
268 | KABC::StdAddressBook::close(); | 268 | KABC::StdAddressBook::close(); |
269 | } | 269 | } |
270 | 270 | ||
271 | void KABCore::restoreSettings() | 271 | void KABCore::restoreSettings() |
272 | { | 272 | { |
273 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 273 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
274 | 274 | ||
275 | bool state; | 275 | bool state; |
276 | 276 | ||
277 | if (mMultipleViewsAtOnce) | 277 | if (mMultipleViewsAtOnce) |
278 | state = KABPrefs::instance()->mDetailsPageVisible; | 278 | state = KABPrefs::instance()->mDetailsPageVisible; |
279 | else | 279 | else |
280 | state = false; | 280 | state = false; |
281 | 281 | ||
282 | mActionDetails->setChecked( state ); | 282 | mActionDetails->setChecked( state ); |
283 | setDetailsVisible( state ); | 283 | setDetailsVisible( state ); |
284 | 284 | ||
285 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 285 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
286 | 286 | ||
287 | mActionJumpBar->setChecked( state ); | 287 | mActionJumpBar->setChecked( state ); |
288 | setJumpButtonBarVisible( state ); | 288 | setJumpButtonBarVisible( state ); |
289 | /*US | 289 | /*US |
290 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 290 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
291 | if ( splitterSize.count() == 0 ) { | 291 | if ( splitterSize.count() == 0 ) { |
292 | splitterSize.append( width() / 2 ); | 292 | splitterSize.append( width() / 2 ); |
293 | splitterSize.append( width() / 2 ); | 293 | splitterSize.append( width() / 2 ); |
294 | } | 294 | } |
295 | mMiniSplitter->setSizes( splitterSize ); | 295 | mMiniSplitter->setSizes( splitterSize ); |
296 | if ( mExtensionBarSplitter ) { | 296 | if ( mExtensionBarSplitter ) { |
297 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 297 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
298 | if ( splitterSize.count() == 0 ) { | 298 | if ( splitterSize.count() == 0 ) { |
299 | splitterSize.append( width() / 2 ); | 299 | splitterSize.append( width() / 2 ); |
300 | splitterSize.append( width() / 2 ); | 300 | splitterSize.append( width() / 2 ); |
301 | } | 301 | } |
302 | mExtensionBarSplitter->setSizes( splitterSize ); | 302 | mExtensionBarSplitter->setSizes( splitterSize ); |
303 | 303 | ||
304 | } | 304 | } |
305 | */ | 305 | */ |
306 | mViewManager->restoreSettings(); | 306 | mViewManager->restoreSettings(); |
307 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 307 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
308 | mExtensionManager->restoreSettings(); | 308 | mExtensionManager->restoreSettings(); |
309 | #ifdef DESKTOP_VERSION | 309 | #ifdef DESKTOP_VERSION |
310 | int wid = width(); | 310 | int wid = width(); |
311 | if ( wid < 10 ) | 311 | if ( wid < 10 ) |
312 | wid = 400; | 312 | wid = 400; |
313 | #else | 313 | #else |
314 | int wid = QApplication::desktop()->width(); | 314 | int wid = QApplication::desktop()->width(); |
315 | if ( wid < 640 ) | 315 | if ( wid < 640 ) |
316 | wid = QApplication::desktop()->height(); | 316 | wid = QApplication::desktop()->height(); |
317 | #endif | 317 | #endif |
318 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 318 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
319 | if ( true /*splitterSize.count() == 0*/ ) { | 319 | if ( true /*splitterSize.count() == 0*/ ) { |
320 | splitterSize.append( wid / 2 ); | 320 | splitterSize.append( wid / 2 ); |
321 | splitterSize.append( wid / 2 ); | 321 | splitterSize.append( wid / 2 ); |
322 | } | 322 | } |
323 | mMiniSplitter->setSizes( splitterSize ); | 323 | mMiniSplitter->setSizes( splitterSize ); |
324 | if ( mExtensionBarSplitter ) { | 324 | if ( mExtensionBarSplitter ) { |
325 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 325 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
326 | if ( true /*splitterSize.count() == 0*/ ) { | 326 | if ( true /*splitterSize.count() == 0*/ ) { |
327 | splitterSize.append( wid / 2 ); | 327 | splitterSize.append( wid / 2 ); |
328 | splitterSize.append( wid / 2 ); | 328 | splitterSize.append( wid / 2 ); |
329 | } | 329 | } |
330 | mExtensionBarSplitter->setSizes( splitterSize ); | 330 | mExtensionBarSplitter->setSizes( splitterSize ); |
331 | 331 | ||
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | } | 335 | } |
336 | 336 | ||
337 | void KABCore::saveSettings() | 337 | void KABCore::saveSettings() |
338 | { | 338 | { |
339 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 339 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
340 | if ( mExtensionBarSplitter ) | 340 | if ( mExtensionBarSplitter ) |
341 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 341 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
342 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 342 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
343 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 343 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
344 | #ifndef KAB_EMBEDDED | 344 | #ifndef KAB_EMBEDDED |
345 | 345 | ||
346 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 346 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
347 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 347 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
348 | #endif //KAB_EMBEDDED | 348 | #endif //KAB_EMBEDDED |
349 | mExtensionManager->saveSettings(); | 349 | mExtensionManager->saveSettings(); |
350 | mViewManager->saveSettings(); | 350 | mViewManager->saveSettings(); |
351 | 351 | ||
352 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 352 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
353 | } | 353 | } |
354 | 354 | ||
355 | KABC::AddressBook *KABCore::addressBook() const | 355 | KABC::AddressBook *KABCore::addressBook() const |
356 | { | 356 | { |
357 | return mAddressBook; | 357 | return mAddressBook; |
358 | } | 358 | } |
359 | 359 | ||
360 | KConfig *KABCore::config() | 360 | KConfig *KABCore::config() |
361 | { | 361 | { |
362 | #ifndef KAB_EMBEDDED | 362 | #ifndef KAB_EMBEDDED |
363 | return KABPrefs::instance()->config(); | 363 | return KABPrefs::instance()->config(); |
364 | #else //KAB_EMBEDDED | 364 | #else //KAB_EMBEDDED |
365 | return KABPrefs::instance()->getConfig(); | 365 | return KABPrefs::instance()->getConfig(); |
366 | #endif //KAB_EMBEDDED | 366 | #endif //KAB_EMBEDDED |
367 | } | 367 | } |
368 | 368 | ||
369 | KActionCollection *KABCore::actionCollection() const | 369 | KActionCollection *KABCore::actionCollection() const |
370 | { | 370 | { |
371 | return mGUIClient->actionCollection(); | 371 | return mGUIClient->actionCollection(); |
372 | } | 372 | } |
373 | 373 | ||
374 | KABC::Field *KABCore::currentSearchField() const | 374 | KABC::Field *KABCore::currentSearchField() const |
375 | { | 375 | { |
376 | if (mIncSearchWidget) | 376 | if (mIncSearchWidget) |
377 | return mIncSearchWidget->currentField(); | 377 | return mIncSearchWidget->currentField(); |
378 | else | 378 | else |
379 | return 0; | 379 | return 0; |
380 | } | 380 | } |
381 | 381 | ||
382 | QStringList KABCore::selectedUIDs() const | 382 | QStringList KABCore::selectedUIDs() const |
383 | { | 383 | { |
384 | return mViewManager->selectedUids(); | 384 | return mViewManager->selectedUids(); |
385 | } | 385 | } |
386 | 386 | ||
387 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 387 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
388 | { | 388 | { |
389 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 389 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
390 | 390 | ||
391 | QPtrList<KRES::Resource> kresResources; | 391 | QPtrList<KRES::Resource> kresResources; |
392 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 392 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
393 | KABC::Resource *resource; | 393 | KABC::Resource *resource; |
394 | while ( ( resource = resIt.current() ) != 0 ) { | 394 | while ( ( resource = resIt.current() ) != 0 ) { |
395 | ++resIt; | 395 | ++resIt; |
396 | if ( !resource->readOnly() ) { | 396 | if ( !resource->readOnly() ) { |
397 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 397 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
398 | if ( res ) | 398 | if ( res ) |
399 | kresResources.append( res ); | 399 | kresResources.append( res ); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 403 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
404 | return static_cast<KABC::Resource*>( res ); | 404 | return static_cast<KABC::Resource*>( res ); |
405 | } | 405 | } |
406 | 406 | ||
407 | #ifndef KAB_EMBEDDED | 407 | #ifndef KAB_EMBEDDED |
408 | KAboutData *KABCore::createAboutData() | 408 | KAboutData *KABCore::createAboutData() |
409 | #else //KAB_EMBEDDED | 409 | #else //KAB_EMBEDDED |
410 | void KABCore::createAboutData() | 410 | void KABCore::createAboutData() |
411 | #endif //KAB_EMBEDDED | 411 | #endif //KAB_EMBEDDED |
412 | { | 412 | { |
413 | #ifndef KAB_EMBEDDED | 413 | #ifndef KAB_EMBEDDED |
414 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 414 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
415 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 415 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
416 | KAboutData::License_GPL_V2, | 416 | KAboutData::License_GPL_V2, |
417 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 417 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
418 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 418 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
419 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 419 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
420 | about->addAuthor( "Cornelius Schumacher", | 420 | about->addAuthor( "Cornelius Schumacher", |
421 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 421 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
422 | "schumacher@kde.org" ); | 422 | "schumacher@kde.org" ); |
423 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 423 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
424 | "mpilone@slac.com" ); | 424 | "mpilone@slac.com" ); |
425 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 425 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
426 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 426 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
427 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 427 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
428 | "michel@klaralvdalens-datakonsult.se" ); | 428 | "michel@klaralvdalens-datakonsult.se" ); |
429 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 429 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
430 | "hansen@kde.org" ); | 430 | "hansen@kde.org" ); |
431 | 431 | ||
432 | return about; | 432 | return about; |
433 | #endif //KAB_EMBEDDED | 433 | #endif //KAB_EMBEDDED |
434 | 434 | ||
435 | QString version; | 435 | QString version; |
436 | #include <../version> | 436 | #include <../version> |
437 | QMessageBox::about( this, "About KAddressbook/Pi", | 437 | QMessageBox::about( this, "About KAddressbook/Pi", |
438 | "KAddressbook/Platform-independent\n" | 438 | "KAddressbook/Platform-independent\n" |
439 | "(KA/Pi) " +version + " - " + | 439 | "(KA/Pi) " +version + " - " + |
440 | #ifdef DESKTOP_VERSION | 440 | #ifdef DESKTOP_VERSION |
441 | "Desktop Edition\n" | 441 | "Desktop Edition\n" |
442 | #else | 442 | #else |
443 | "PDA-Edition\n" | 443 | "PDA-Edition\n" |
444 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 444 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
445 | #endif | 445 | #endif |
446 | 446 | ||
447 | "(c) 2004 Ulf Schenk\n" | 447 | "(c) 2004 Ulf Schenk\n" |
448 | "(c) 2004 Lutz Rogowski\n" | 448 | "(c) 2004 Lutz Rogowski\n" |
449 | "(c) 1997-2003, The KDE PIM Team\n" | 449 | "(c) 1997-2003, The KDE PIM Team\n" |
450 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 450 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
451 | "Don Sanders Original author\n" | 451 | "Don Sanders Original author\n" |
452 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 452 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
453 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 453 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
454 | "Greg Stern DCOP interface\n" | 454 | "Greg Stern DCOP interface\n" |
455 | "Mark Westcot Contact pinning\n" | 455 | "Mark Westcot Contact pinning\n" |
456 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 456 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
457 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 457 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
458 | #ifdef _WIN32_ | 458 | #ifdef _WIN32_ |
459 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 459 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
460 | #endif | 460 | #endif |
461 | ); | 461 | ); |
462 | } | 462 | } |
463 | 463 | ||
464 | void KABCore::setContactSelected( const QString &uid ) | 464 | void KABCore::setContactSelected( const QString &uid ) |
465 | { | 465 | { |
466 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 466 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
467 | if ( !mDetails->isHidden() ) | 467 | if ( !mDetails->isHidden() ) |
468 | mDetails->setAddressee( addr ); | 468 | mDetails->setAddressee( addr ); |
469 | 469 | ||
470 | if ( !addr.isEmpty() ) { | 470 | if ( !addr.isEmpty() ) { |
471 | emit contactSelected( addr.formattedName() ); | 471 | emit contactSelected( addr.formattedName() ); |
472 | KABC::Picture pic = addr.photo(); | 472 | KABC::Picture pic = addr.photo(); |
473 | if ( pic.isIntern() ) { | 473 | if ( pic.isIntern() ) { |
474 | //US emit contactSelected( pic.data() ); | 474 | //US emit contactSelected( pic.data() ); |
475 | //US instead use: | 475 | //US instead use: |
476 | QPixmap px; | 476 | QPixmap px; |
477 | if (pic.data().isNull() != true) | 477 | if (pic.data().isNull() != true) |
478 | { | 478 | { |
479 | px.convertFromImage(pic.data()); | 479 | px.convertFromImage(pic.data()); |
480 | } | 480 | } |
481 | 481 | ||
482 | emit contactSelected( px ); | 482 | emit contactSelected( px ); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | mExtensionManager->setSelectionChanged(); | 487 | mExtensionManager->setSelectionChanged(); |
488 | 488 | ||
489 | // update the actions | 489 | // update the actions |
490 | bool selected = !uid.isEmpty(); | 490 | bool selected = !uid.isEmpty(); |
491 | 491 | ||
492 | if ( mReadWrite ) { | 492 | if ( mReadWrite ) { |
493 | mActionCut->setEnabled( selected ); | 493 | mActionCut->setEnabled( selected ); |
494 | mActionPaste->setEnabled( selected ); | 494 | mActionPaste->setEnabled( selected ); |
495 | } | 495 | } |
496 | 496 | ||
497 | mActionCopy->setEnabled( selected ); | 497 | mActionCopy->setEnabled( selected ); |
498 | mActionDelete->setEnabled( selected ); | 498 | mActionDelete->setEnabled( selected ); |
499 | mActionEditAddressee->setEnabled( selected ); | 499 | mActionEditAddressee->setEnabled( selected ); |
500 | mActionMail->setEnabled( selected ); | 500 | mActionMail->setEnabled( selected ); |
501 | mActionMailVCard->setEnabled( selected ); | 501 | mActionMailVCard->setEnabled( selected ); |
502 | //if (mActionBeam) | 502 | //if (mActionBeam) |
503 | //mActionBeam->setEnabled( selected ); | 503 | //mActionBeam->setEnabled( selected ); |
504 | 504 | ||
505 | if (mActionBeamVCard) | 505 | if (mActionBeamVCard) |
506 | mActionBeamVCard->setEnabled( selected ); | 506 | mActionBeamVCard->setEnabled( selected ); |
507 | 507 | ||
508 | mActionWhoAmI->setEnabled( selected ); | 508 | mActionWhoAmI->setEnabled( selected ); |
509 | mActionCategories->setEnabled( selected ); | 509 | mActionCategories->setEnabled( selected ); |
510 | } | 510 | } |
511 | 511 | ||
512 | void KABCore::sendMail() | 512 | void KABCore::sendMail() |
513 | { | 513 | { |
514 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 514 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
515 | } | 515 | } |
516 | 516 | ||
517 | void KABCore::sendMail( const QString& emaillist ) | 517 | void KABCore::sendMail( const QString& emaillist ) |
518 | { | 518 | { |
519 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 519 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
520 | if (emaillist.contains(",") > 0) | 520 | if (emaillist.contains(",") > 0) |
521 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 521 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
522 | else | 522 | else |
523 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 523 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
524 | } | 524 | } |
525 | 525 | ||
526 | 526 | ||
527 | 527 | ||
528 | void KABCore::mailVCard() | 528 | void KABCore::mailVCard() |
529 | { | 529 | { |
530 | QStringList uids = mViewManager->selectedUids(); | 530 | QStringList uids = mViewManager->selectedUids(); |
531 | if ( !uids.isEmpty() ) | 531 | if ( !uids.isEmpty() ) |
532 | mailVCard( uids ); | 532 | mailVCard( uids ); |
533 | } | 533 | } |
534 | 534 | ||
535 | void KABCore::mailVCard( const QStringList& uids ) | 535 | void KABCore::mailVCard( const QStringList& uids ) |
536 | { | 536 | { |
537 | QStringList urls; | 537 | QStringList urls; |
538 | 538 | ||
539 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 539 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
540 | 540 | ||
541 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 541 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
542 | 542 | ||
543 | 543 | ||
544 | 544 | ||
545 | QDir().mkdir( dirName, true ); | 545 | QDir().mkdir( dirName, true ); |
546 | 546 | ||
547 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 547 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
548 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 548 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
549 | 549 | ||
550 | if ( a.isEmpty() ) | 550 | if ( a.isEmpty() ) |
551 | continue; | 551 | continue; |
552 | 552 | ||
553 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 553 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
554 | 554 | ||
555 | QString fileName = dirName + "/" + name; | 555 | QString fileName = dirName + "/" + name; |
556 | 556 | ||
557 | QFile outFile(fileName); | 557 | QFile outFile(fileName); |
558 | 558 | ||
559 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 559 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
560 | KABC::VCardConverter converter; | 560 | KABC::VCardConverter converter; |
561 | QString vcard; | 561 | QString vcard; |
562 | 562 | ||
563 | converter.addresseeToVCard( a, vcard ); | 563 | converter.addresseeToVCard( a, vcard ); |
564 | 564 | ||
565 | QTextStream t( &outFile ); // use a text stream | 565 | QTextStream t( &outFile ); // use a text stream |
566 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 566 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
567 | t << vcard; | 567 | t << vcard; |
568 | 568 | ||
569 | outFile.close(); | 569 | outFile.close(); |
570 | 570 | ||
571 | urls.append( fileName ); | 571 | urls.append( fileName ); |
572 | } | 572 | } |
573 | } | 573 | } |
574 | 574 | ||
575 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 575 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
576 | 576 | ||
577 | 577 | ||
578 | /*US | 578 | /*US |
579 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 579 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
580 | QString::null, // subject | 580 | QString::null, // subject |
581 | QString::null, // body | 581 | QString::null, // body |
582 | QString::null, | 582 | QString::null, |
583 | urls ); // attachments | 583 | urls ); // attachments |
584 | */ | 584 | */ |
585 | 585 | ||
586 | } | 586 | } |
587 | 587 | ||
588 | /** | 588 | /** |
589 | Beams the "WhoAmI contact. | 589 | Beams the "WhoAmI contact. |
590 | */ | 590 | */ |
591 | void KABCore::beamMySelf() | 591 | void KABCore::beamMySelf() |
592 | { | 592 | { |
593 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 593 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
594 | if (!a.isEmpty()) | 594 | if (!a.isEmpty()) |
595 | { | 595 | { |
596 | QStringList uids; | 596 | QStringList uids; |
597 | uids << a.uid(); | 597 | uids << a.uid(); |
598 | 598 | ||
599 | beamVCard(uids); | 599 | beamVCard(uids); |
600 | } else { | 600 | } else { |
601 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 601 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
602 | 602 | ||
603 | 603 | ||
604 | } | 604 | } |
605 | } | 605 | } |
606 | 606 | ||
607 | void KABCore::beamVCard() | 607 | void KABCore::beamVCard() |
608 | { | 608 | { |
609 | QStringList uids = mViewManager->selectedUids(); | 609 | QStringList uids = mViewManager->selectedUids(); |
610 | if ( !uids.isEmpty() ) | 610 | if ( !uids.isEmpty() ) |
611 | beamVCard( uids ); | 611 | beamVCard( uids ); |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | void KABCore::beamVCard(const QStringList& uids) | 615 | void KABCore::beamVCard(const QStringList& uids) |
616 | { | 616 | { |
617 | /*US | 617 | /*US |
618 | QString beamFilename; | 618 | QString beamFilename; |
619 | Opie::OPimContact c; | 619 | Opie::OPimContact c; |
620 | if ( actionPersonal->isOn() ) { | 620 | if ( actionPersonal->isOn() ) { |
621 | beamFilename = addressbookPersonalVCardName(); | 621 | beamFilename = addressbookPersonalVCardName(); |
622 | if ( !QFile::exists( beamFilename ) ) | 622 | if ( !QFile::exists( beamFilename ) ) |
623 | return; // can't beam a non-existent file | 623 | return; // can't beam a non-existent file |
624 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 624 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
625 | beamFilename ); | 625 | beamFilename ); |
626 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 626 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
627 | Opie::OPimContactAccess::List allList = access->allRecords(); | 627 | Opie::OPimContactAccess::List allList = access->allRecords(); |
628 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 628 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
629 | c = *it; | 629 | c = *it; |
630 | 630 | ||
631 | delete access; | 631 | delete access; |
632 | } else { | 632 | } else { |
633 | unlink( beamfile ); // delete if exists | 633 | unlink( beamfile ); // delete if exists |
634 | mkdir("/tmp/obex/", 0755); | 634 | mkdir("/tmp/obex/", 0755); |
635 | c = m_abView -> currentEntry(); | 635 | c = m_abView -> currentEntry(); |
636 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 636 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
637 | beamfile ); | 637 | beamfile ); |
638 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 638 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
639 | access->add( c ); | 639 | access->add( c ); |
640 | access->save(); | 640 | access->save(); |
641 | delete access; | 641 | delete access; |
642 | 642 | ||
643 | beamFilename = beamfile; | 643 | beamFilename = beamfile; |
644 | } | 644 | } |
645 | 645 | ||
646 | owarn << "Beaming: " << beamFilename << oendl; | 646 | owarn << "Beaming: " << beamFilename << oendl; |
647 | */ | 647 | */ |
648 | 648 | ||
649 | #if 0 | 649 | #if 0 |
650 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 650 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
651 | 651 | ||
652 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 652 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
653 | 653 | ||
654 | QString name = "contact.vcf"; | 654 | QString name = "contact.vcf"; |
655 | 655 | ||
656 | QString fileName = dirName + "/" + name; | 656 | QString fileName = dirName + "/" + name; |
657 | #endif | 657 | #endif |
658 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 658 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
659 | // | 659 | // |
660 | QString fileName = "/tmp/kapibeamfile.vcf"; | 660 | QString fileName = "/tmp/kapibeamfile.vcf"; |
661 | 661 | ||
662 | 662 | ||
663 | //QDir().mkdir( dirName, true ); | 663 | //QDir().mkdir( dirName, true ); |
664 | 664 | ||
665 | 665 | ||
666 | KABC::VCardConverter converter; | 666 | KABC::VCardConverter converter; |
667 | QString description; | 667 | QString description; |
668 | QString datastream; | 668 | QString datastream; |
669 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 669 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
670 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 670 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
671 | 671 | ||
672 | if ( a.isEmpty() ) | 672 | if ( a.isEmpty() ) |
673 | continue; | 673 | continue; |
674 | 674 | ||
675 | if (description.isEmpty()) | 675 | if (description.isEmpty()) |
676 | description = a.formattedName(); | 676 | description = a.formattedName(); |
677 | 677 | ||
678 | QString vcard; | 678 | QString vcard; |
679 | converter.addresseeToVCard( a, vcard ); | 679 | converter.addresseeToVCard( a, vcard ); |
680 | int start = 0; | 680 | int start = 0; |
681 | int next; | 681 | int next; |
682 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 682 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
683 | int semi = vcard.find(";", next); | 683 | int semi = vcard.find(";", next); |
684 | int dopp = vcard.find(":", next); | 684 | int dopp = vcard.find(":", next); |
685 | int sep; | 685 | int sep; |
686 | if ( semi < dopp && semi >= 0 ) | 686 | if ( semi < dopp && semi >= 0 ) |
687 | sep = semi ; | 687 | sep = semi ; |
688 | else | 688 | else |
689 | sep = dopp; | 689 | sep = dopp; |
690 | datastream +=vcard.mid( start, next - start); | 690 | datastream +=vcard.mid( start, next - start); |
691 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 691 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
692 | start = sep; | 692 | start = sep; |
693 | } | 693 | } |
694 | datastream += vcard.mid( start,vcard.length() ); | 694 | datastream += vcard.mid( start,vcard.length() ); |
695 | } | 695 | } |
696 | #ifndef DESKTOP_VERSION | 696 | #ifndef DESKTOP_VERSION |
697 | QFile outFile(fileName); | 697 | QFile outFile(fileName); |
698 | if ( outFile.open(IO_WriteOnly) ) { | 698 | if ( outFile.open(IO_WriteOnly) ) { |
699 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 699 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
700 | QTextStream t( &outFile ); // use a text stream | 700 | QTextStream t( &outFile ); // use a text stream |
701 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 701 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
702 | t <<datastream; | 702 | t <<datastream; |
703 | outFile.close(); | 703 | outFile.close(); |
704 | Ir *ir = new Ir( this ); | 704 | Ir *ir = new Ir( this ); |
705 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 705 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
706 | ir->send( fileName, description, "text/x-vCard" ); | 706 | ir->send( fileName, description, "text/x-vCard" ); |
707 | } else { | 707 | } else { |
708 | qDebug("Error open temp beam file "); | 708 | qDebug("Error open temp beam file "); |
709 | return; | 709 | return; |
710 | } | 710 | } |
711 | #endif | 711 | #endif |
712 | 712 | ||
713 | } | 713 | } |
714 | 714 | ||
715 | void KABCore::beamDone( Ir *ir ) | 715 | void KABCore::beamDone( Ir *ir ) |
716 | { | 716 | { |
717 | #ifndef DESKTOP_VERSION | 717 | #ifndef DESKTOP_VERSION |
718 | delete ir; | 718 | delete ir; |
719 | #endif | 719 | #endif |
720 | } | 720 | } |
721 | 721 | ||
722 | 722 | ||
723 | void KABCore::browse( const QString& url ) | 723 | void KABCore::browse( const QString& url ) |
724 | { | 724 | { |
725 | #ifndef KAB_EMBEDDED | 725 | #ifndef KAB_EMBEDDED |
726 | kapp->invokeBrowser( url ); | 726 | kapp->invokeBrowser( url ); |
727 | #else //KAB_EMBEDDED | 727 | #else //KAB_EMBEDDED |
728 | qDebug("KABCore::browse must be fixed"); | 728 | qDebug("KABCore::browse must be fixed"); |
729 | #endif //KAB_EMBEDDED | 729 | #endif //KAB_EMBEDDED |
730 | } | 730 | } |
731 | 731 | ||
732 | void KABCore::selectAllContacts() | 732 | void KABCore::selectAllContacts() |
733 | { | 733 | { |
734 | mViewManager->setSelected( QString::null, true ); | 734 | mViewManager->setSelected( QString::null, true ); |
735 | } | 735 | } |
736 | 736 | ||
737 | void KABCore::deleteContacts() | 737 | void KABCore::deleteContacts() |
738 | { | 738 | { |
739 | QStringList uidList = mViewManager->selectedUids(); | 739 | QStringList uidList = mViewManager->selectedUids(); |
740 | deleteContacts( uidList ); | 740 | deleteContacts( uidList ); |
741 | } | 741 | } |
742 | 742 | ||
743 | void KABCore::deleteContacts( const QStringList &uids ) | 743 | void KABCore::deleteContacts( const QStringList &uids ) |
744 | { | 744 | { |
745 | if ( uids.count() > 0 ) { | 745 | if ( uids.count() > 0 ) { |
746 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 746 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
747 | UndoStack::instance()->push( command ); | 747 | UndoStack::instance()->push( command ); |
748 | RedoStack::instance()->clear(); | 748 | RedoStack::instance()->clear(); |
749 | 749 | ||
750 | // now if we deleted anything, refresh | 750 | // now if we deleted anything, refresh |
751 | setContactSelected( QString::null ); | 751 | setContactSelected( QString::null ); |
752 | setModified( true ); | 752 | setModified( true ); |
753 | } | 753 | } |
754 | } | 754 | } |
755 | 755 | ||
756 | void KABCore::copyContacts() | 756 | void KABCore::copyContacts() |
757 | { | 757 | { |
758 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 758 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
759 | 759 | ||
760 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 760 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
761 | 761 | ||
762 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 762 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
763 | 763 | ||
764 | QClipboard *cb = QApplication::clipboard(); | 764 | QClipboard *cb = QApplication::clipboard(); |
765 | cb->setText( clipText ); | 765 | cb->setText( clipText ); |
766 | } | 766 | } |
767 | 767 | ||
768 | void KABCore::cutContacts() | 768 | void KABCore::cutContacts() |
769 | { | 769 | { |
770 | QStringList uidList = mViewManager->selectedUids(); | 770 | QStringList uidList = mViewManager->selectedUids(); |
771 | 771 | ||
772 | //US if ( uidList.size() > 0 ) { | 772 | //US if ( uidList.size() > 0 ) { |
773 | if ( uidList.count() > 0 ) { | 773 | if ( uidList.count() > 0 ) { |
774 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 774 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
775 | UndoStack::instance()->push( command ); | 775 | UndoStack::instance()->push( command ); |
776 | RedoStack::instance()->clear(); | 776 | RedoStack::instance()->clear(); |
777 | 777 | ||
778 | setModified( true ); | 778 | setModified( true ); |
779 | } | 779 | } |
780 | } | 780 | } |
781 | 781 | ||
782 | void KABCore::pasteContacts() | 782 | void KABCore::pasteContacts() |
783 | { | 783 | { |
784 | QClipboard *cb = QApplication::clipboard(); | 784 | QClipboard *cb = QApplication::clipboard(); |
785 | 785 | ||
786 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 786 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
787 | 787 | ||
788 | pasteContacts( list ); | 788 | pasteContacts( list ); |
789 | } | 789 | } |
790 | 790 | ||
791 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 791 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
792 | { | 792 | { |
793 | KABC::Resource *resource = requestResource( this ); | 793 | KABC::Resource *resource = requestResource( this ); |
794 | KABC::Addressee::List::Iterator it; | 794 | KABC::Addressee::List::Iterator it; |
795 | for ( it = list.begin(); it != list.end(); ++it ) | 795 | for ( it = list.begin(); it != list.end(); ++it ) |
796 | (*it).setResource( resource ); | 796 | (*it).setResource( resource ); |
797 | 797 | ||
798 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 798 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
799 | UndoStack::instance()->push( command ); | 799 | UndoStack::instance()->push( command ); |
800 | RedoStack::instance()->clear(); | 800 | RedoStack::instance()->clear(); |
801 | 801 | ||
802 | setModified( true ); | 802 | setModified( true ); |
803 | } | 803 | } |
804 | 804 | ||
805 | void KABCore::setWhoAmI() | 805 | void KABCore::setWhoAmI() |
806 | { | 806 | { |
807 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 807 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
808 | 808 | ||
809 | if ( addrList.count() > 1 ) { | 809 | if ( addrList.count() > 1 ) { |
810 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 810 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
811 | return; | 811 | return; |
812 | } | 812 | } |
813 | 813 | ||
814 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 814 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
815 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 815 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
816 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 816 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
817 | } | 817 | } |
818 | 818 | ||
819 | void KABCore::setCategories() | 819 | void KABCore::setCategories() |
820 | { | 820 | { |
821 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 821 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
822 | if ( !dlg.exec() ) | 822 | if ( !dlg.exec() ) |
823 | return; | 823 | return; |
824 | 824 | ||
825 | bool merge = false; | 825 | bool merge = false; |
826 | QString msg = i18n( "Merge with existing categories?" ); | 826 | QString msg = i18n( "Merge with existing categories?" ); |
827 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 827 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
828 | merge = true; | 828 | merge = true; |
829 | 829 | ||
830 | QStringList categories = dlg.selectedCategories(); | 830 | QStringList categories = dlg.selectedCategories(); |
831 | 831 | ||
832 | QStringList uids = mViewManager->selectedUids(); | 832 | QStringList uids = mViewManager->selectedUids(); |
833 | QStringList::Iterator it; | 833 | QStringList::Iterator it; |
834 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 834 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
835 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 835 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
836 | if ( !addr.isEmpty() ) { | 836 | if ( !addr.isEmpty() ) { |
837 | if ( !merge ) | 837 | if ( !merge ) |
838 | addr.setCategories( categories ); | 838 | addr.setCategories( categories ); |
839 | else { | 839 | else { |
840 | QStringList addrCategories = addr.categories(); | 840 | QStringList addrCategories = addr.categories(); |
841 | QStringList::Iterator catIt; | 841 | QStringList::Iterator catIt; |
842 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 842 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
843 | if ( !addrCategories.contains( *catIt ) ) | 843 | if ( !addrCategories.contains( *catIt ) ) |
844 | addrCategories.append( *catIt ); | 844 | addrCategories.append( *catIt ); |
845 | } | 845 | } |
846 | addr.setCategories( addrCategories ); | 846 | addr.setCategories( addrCategories ); |
847 | } | 847 | } |
848 | 848 | ||
849 | mAddressBook->insertAddressee( addr ); | 849 | mAddressBook->insertAddressee( addr ); |
850 | } | 850 | } |
851 | } | 851 | } |
852 | 852 | ||
853 | if ( uids.count() > 0 ) | 853 | if ( uids.count() > 0 ) |
854 | setModified( true ); | 854 | setModified( true ); |
855 | } | 855 | } |
856 | 856 | ||
857 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 857 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
858 | { | 858 | { |
859 | mIncSearchWidget->setFields( fields ); | 859 | mIncSearchWidget->setFields( fields ); |
860 | } | 860 | } |
861 | 861 | ||
862 | void KABCore::incrementalSearch( const QString& text ) | 862 | void KABCore::incrementalSearch( const QString& text ) |
863 | { | 863 | { |
864 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 864 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
865 | } | 865 | } |
866 | 866 | ||
867 | void KABCore::setModified() | 867 | void KABCore::setModified() |
868 | { | 868 | { |
869 | setModified( true ); | 869 | setModified( true ); |
870 | } | 870 | } |
871 | 871 | ||
872 | void KABCore::setModifiedWOrefresh() | 872 | void KABCore::setModifiedWOrefresh() |
873 | { | 873 | { |
874 | // qDebug("KABCore::setModifiedWOrefresh() "); | 874 | // qDebug("KABCore::setModifiedWOrefresh() "); |
875 | mModified = true; | 875 | mModified = true; |
876 | mActionSave->setEnabled( mModified ); | 876 | mActionSave->setEnabled( mModified ); |
877 | #ifdef DESKTOP_VERSION | 877 | #ifdef DESKTOP_VERSION |
878 | mDetails->refreshView(); | 878 | mDetails->refreshView(); |
879 | #endif | 879 | #endif |
880 | 880 | ||
881 | } | 881 | } |
882 | void KABCore::setModified( bool modified ) | 882 | void KABCore::setModified( bool modified ) |
883 | { | 883 | { |
884 | mModified = modified; | 884 | mModified = modified; |
885 | mActionSave->setEnabled( mModified ); | 885 | mActionSave->setEnabled( mModified ); |
886 | 886 | ||
887 | if ( modified ) | 887 | if ( modified ) |
888 | mJumpButtonBar->recreateButtons(); | 888 | mJumpButtonBar->recreateButtons(); |
889 | 889 | ||
890 | mViewManager->refreshView(); | 890 | mViewManager->refreshView(); |
891 | mDetails->refreshView(); | 891 | mDetails->refreshView(); |
892 | 892 | ||
893 | } | 893 | } |
894 | 894 | ||
895 | bool KABCore::modified() const | 895 | bool KABCore::modified() const |
896 | { | 896 | { |
897 | return mModified; | 897 | return mModified; |
898 | } | 898 | } |
899 | 899 | ||
900 | void KABCore::contactModified( const KABC::Addressee &addr ) | 900 | void KABCore::contactModified( const KABC::Addressee &addr ) |
901 | { | 901 | { |
902 | 902 | ||
903 | Command *command = 0; | 903 | Command *command = 0; |
904 | QString uid; | 904 | QString uid; |
905 | 905 | ||
906 | // check if it exists already | 906 | // check if it exists already |
907 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 907 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
908 | if ( origAddr.isEmpty() ) | 908 | if ( origAddr.isEmpty() ) |
909 | command = new PwNewCommand( mAddressBook, addr ); | 909 | command = new PwNewCommand( mAddressBook, addr ); |
910 | else { | 910 | else { |
911 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 911 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
912 | uid = addr.uid(); | 912 | uid = addr.uid(); |
913 | } | 913 | } |
914 | 914 | ||
915 | UndoStack::instance()->push( command ); | 915 | UndoStack::instance()->push( command ); |
916 | RedoStack::instance()->clear(); | 916 | RedoStack::instance()->clear(); |
917 | 917 | ||
918 | setModified( true ); | 918 | setModified( true ); |
919 | } | 919 | } |
920 | 920 | ||
921 | void KABCore::newContact() | 921 | void KABCore::newContact() |
922 | { | 922 | { |
923 | 923 | ||
924 | 924 | ||
925 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 925 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
926 | 926 | ||
927 | QPtrList<KRES::Resource> kresResources; | 927 | QPtrList<KRES::Resource> kresResources; |
928 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 928 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
929 | KABC::Resource *resource; | 929 | KABC::Resource *resource; |
930 | while ( ( resource = it.current() ) != 0 ) { | 930 | while ( ( resource = it.current() ) != 0 ) { |
931 | ++it; | 931 | ++it; |
932 | if ( !resource->readOnly() ) { | 932 | if ( !resource->readOnly() ) { |
933 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 933 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
934 | if ( res ) | 934 | if ( res ) |
935 | kresResources.append( res ); | 935 | kresResources.append( res ); |
936 | } | 936 | } |
937 | } | 937 | } |
938 | 938 | ||
939 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 939 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
940 | resource = static_cast<KABC::Resource*>( res ); | 940 | resource = static_cast<KABC::Resource*>( res ); |
941 | 941 | ||
942 | if ( resource ) { | 942 | if ( resource ) { |
943 | KABC::Addressee addr; | 943 | KABC::Addressee addr; |
944 | addr.setResource( resource ); | 944 | addr.setResource( resource ); |
945 | mEditorDialog->setAddressee( addr ); | 945 | mEditorDialog->setAddressee( addr ); |
946 | KApplication::execDialog ( mEditorDialog ); | 946 | KApplication::execDialog ( mEditorDialog ); |
947 | 947 | ||
948 | } else | 948 | } else |
949 | return; | 949 | return; |
950 | 950 | ||
951 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 951 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
952 | 952 | ||
953 | 953 | ||
954 | } | 954 | } |
955 | 955 | ||
956 | void KABCore::addEmail( QString aStr ) | 956 | void KABCore::addEmail( QString aStr ) |
957 | { | 957 | { |
958 | #ifndef KAB_EMBEDDED | 958 | #ifndef KAB_EMBEDDED |
959 | QString fullName, email; | 959 | QString fullName, email; |
960 | 960 | ||
961 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 961 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
962 | 962 | ||
963 | // Try to lookup the addressee matching the email address | 963 | // Try to lookup the addressee matching the email address |
964 | bool found = false; | 964 | bool found = false; |
965 | QStringList emailList; | 965 | QStringList emailList; |
966 | KABC::AddressBook::Iterator it; | 966 | KABC::AddressBook::Iterator it; |
967 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 967 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
968 | emailList = (*it).emails(); | 968 | emailList = (*it).emails(); |
969 | if ( emailList.contains( email ) > 0 ) { | 969 | if ( emailList.contains( email ) > 0 ) { |
970 | found = true; | 970 | found = true; |
971 | (*it).setNameFromString( fullName ); | 971 | (*it).setNameFromString( fullName ); |
972 | editContact( (*it).uid() ); | 972 | editContact( (*it).uid() ); |
973 | } | 973 | } |
974 | } | 974 | } |
975 | 975 | ||
976 | if ( !found ) { | 976 | if ( !found ) { |
977 | KABC::Addressee addr; | 977 | KABC::Addressee addr; |
978 | addr.setNameFromString( fullName ); | 978 | addr.setNameFromString( fullName ); |
979 | addr.insertEmail( email, true ); | 979 | addr.insertEmail( email, true ); |
980 | 980 | ||
981 | mAddressBook->insertAddressee( addr ); | 981 | mAddressBook->insertAddressee( addr ); |
982 | mViewManager->refreshView( addr.uid() ); | 982 | mViewManager->refreshView( addr.uid() ); |
983 | editContact( addr.uid() ); | 983 | editContact( addr.uid() ); |
984 | } | 984 | } |
985 | #else //KAB_EMBEDDED | 985 | #else //KAB_EMBEDDED |
986 | qDebug("KABCore::addEmail finsih method"); | 986 | qDebug("KABCore::addEmail finsih method"); |
987 | #endif //KAB_EMBEDDED | 987 | #endif //KAB_EMBEDDED |
988 | } | 988 | } |
989 | 989 | ||
990 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 990 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
991 | { | 991 | { |
992 | mXXPortManager->importVCard( url, showPreview ); | 992 | mXXPortManager->importVCard( url, showPreview ); |
993 | } | 993 | } |
994 | void KABCore::importFromOL() | 994 | void KABCore::importFromOL() |
995 | { | 995 | { |
996 | #ifdef _WIN32_ | 996 | #ifdef _WIN32_ |
997 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 997 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
998 | idgl->exec(); | 998 | idgl->exec(); |
999 | KABC::Addressee::List list = idgl->getAddressList(); | 999 | KABC::Addressee::List list = idgl->getAddressList(); |
1000 | if ( list.count() > 0 ) { | 1000 | if ( list.count() > 0 ) { |
1001 | KABC::Addressee::List listNew; | 1001 | KABC::Addressee::List listNew; |
1002 | KABC::Addressee::List listExisting; | 1002 | KABC::Addressee::List listExisting; |
1003 | KABC::Addressee::List::Iterator it; | 1003 | KABC::Addressee::List::Iterator it; |
1004 | KABC::AddressBook::Iterator iter; | 1004 | KABC::AddressBook::Iterator iter; |
1005 | for ( it = list.begin(); it != list.end(); ++it ) { | 1005 | for ( it = list.begin(); it != list.end(); ++it ) { |
1006 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1006 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1007 | listNew.append( (*it) ); | 1007 | listNew.append( (*it) ); |
1008 | else | 1008 | else |
1009 | listExisting.append( (*it) ); | 1009 | listExisting.append( (*it) ); |
1010 | } | 1010 | } |
1011 | if ( listExisting.count() > 0 ) | 1011 | if ( listExisting.count() > 0 ) |
1012 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1012 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1013 | if ( listNew.count() > 0 ) { | 1013 | if ( listNew.count() > 0 ) { |
1014 | pasteWithNewUid = false; | 1014 | pasteWithNewUid = false; |
1015 | pasteContacts( listNew ); | 1015 | pasteContacts( listNew ); |
1016 | pasteWithNewUid = true; | 1016 | pasteWithNewUid = true; |
1017 | } | 1017 | } |
1018 | } | 1018 | } |
1019 | delete idgl; | 1019 | delete idgl; |
1020 | #endif | 1020 | #endif |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1023 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1024 | { | 1024 | { |
1025 | mXXPortManager->importVCard( vCard, showPreview ); | 1025 | mXXPortManager->importVCard( vCard, showPreview ); |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | //US added a second method without defaultparameter | 1028 | //US added a second method without defaultparameter |
1029 | void KABCore::editContact2() { | 1029 | void KABCore::editContact2() { |
1030 | editContact( QString::null ); | 1030 | editContact( QString::null ); |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | void KABCore::editContact( const QString &uid ) | 1033 | void KABCore::editContact( const QString &uid ) |
1034 | { | 1034 | { |
1035 | 1035 | ||
1036 | if ( mExtensionManager->isQuickEditVisible() ) | 1036 | if ( mExtensionManager->isQuickEditVisible() ) |
1037 | return; | 1037 | return; |
1038 | 1038 | ||
1039 | // First, locate the contact entry | 1039 | // First, locate the contact entry |
1040 | QString localUID = uid; | 1040 | QString localUID = uid; |
1041 | if ( localUID.isNull() ) { | 1041 | if ( localUID.isNull() ) { |
1042 | QStringList uidList = mViewManager->selectedUids(); | 1042 | QStringList uidList = mViewManager->selectedUids(); |
1043 | if ( uidList.count() > 0 ) | 1043 | if ( uidList.count() > 0 ) |
1044 | localUID = *( uidList.at( 0 ) ); | 1044 | localUID = *( uidList.at( 0 ) ); |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 1047 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
1048 | if ( !addr.isEmpty() ) { | 1048 | if ( !addr.isEmpty() ) { |
1049 | mEditorDialog->setAddressee( addr ); | 1049 | mEditorDialog->setAddressee( addr ); |
1050 | KApplication::execDialog ( mEditorDialog ); | 1050 | KApplication::execDialog ( mEditorDialog ); |
1051 | } | 1051 | } |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | /** | 1054 | /** |
1055 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 1055 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
1056 | the method will try to find a selected addressee in the view. | 1056 | the method will try to find a selected addressee in the view. |
1057 | */ | 1057 | */ |
1058 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) | 1058 | void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) |
1059 | { | 1059 | { |
1060 | if ( mMultipleViewsAtOnce ) | 1060 | if ( mMultipleViewsAtOnce ) |
1061 | { | 1061 | { |
1062 | editContact( uid ); | 1062 | editContact( uid ); |
1063 | } | 1063 | } |
1064 | else | 1064 | else |
1065 | { | 1065 | { |
1066 | setDetailsVisible( true ); | 1066 | setDetailsVisible( true ); |
1067 | mActionDetails->setChecked(true); | 1067 | mActionDetails->setChecked(true); |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | void KABCore::save() | 1072 | void KABCore::save() |
1073 | { | 1073 | { |
1074 | if (mBlockSaveFlag) | 1074 | if (mBlockSaveFlag) |
1075 | return; | 1075 | return; |
1076 | mBlockSaveFlag = true; | 1076 | mBlockSaveFlag = true; |
1077 | if ( !mModified ) | 1077 | if ( !mModified ) |
1078 | return; | 1078 | return; |
1079 | QString text = i18n( "There was an error while attempting to save\n the " | 1079 | QString text = i18n( "There was an error while attempting to save\n the " |
1080 | "address book. Please check that some \nother application is " | 1080 | "address book. Please check that some \nother application is " |
1081 | "not using it. " ); | 1081 | "not using it. " ); |
1082 | statusMessage(i18n("Saving addressbook ... ")); | 1082 | statusMessage(i18n("Saving addressbook ... ")); |
1083 | #ifndef KAB_EMBEDDED | 1083 | #ifndef KAB_EMBEDDED |
1084 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 1084 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
1085 | if ( !b || !b->save() ) { | 1085 | if ( !b || !b->save() ) { |
1086 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 1086 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
1087 | } | 1087 | } |
1088 | #else //KAB_EMBEDDED | 1088 | #else //KAB_EMBEDDED |
1089 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 1089 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
1090 | if ( !b || !b->save() ) { | 1090 | if ( !b || !b->save() ) { |
1091 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 1091 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
1092 | } | 1092 | } |
1093 | #endif //KAB_EMBEDDED | 1093 | #endif //KAB_EMBEDDED |
1094 | 1094 | ||
1095 | statusMessage(i18n("Addressbook saved!")); | 1095 | statusMessage(i18n("Addressbook saved!")); |
1096 | setModified( false ); | 1096 | setModified( false ); |
1097 | mBlockSaveFlag = false; | 1097 | mBlockSaveFlag = false; |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | void KABCore::statusMessage(QString mess , int time ) | 1100 | void KABCore::statusMessage(QString mess , int time ) |
1101 | { | 1101 | { |
1102 | //topLevelWidget()->setCaption( mess ); | 1102 | //topLevelWidget()->setCaption( mess ); |
1103 | // pending setting timer to revome message | 1103 | // pending setting timer to revome message |
1104 | } | 1104 | } |
1105 | void KABCore::undo() | 1105 | void KABCore::undo() |
1106 | { | 1106 | { |
1107 | UndoStack::instance()->undo(); | 1107 | UndoStack::instance()->undo(); |
1108 | 1108 | ||
1109 | // Refresh the view | 1109 | // Refresh the view |
1110 | mViewManager->refreshView(); | 1110 | mViewManager->refreshView(); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void KABCore::redo() | 1113 | void KABCore::redo() |
1114 | { | 1114 | { |
1115 | RedoStack::instance()->redo(); | 1115 | RedoStack::instance()->redo(); |
1116 | 1116 | ||
1117 | // Refresh the view | 1117 | // Refresh the view |
1118 | mViewManager->refreshView(); | 1118 | mViewManager->refreshView(); |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | void KABCore::setJumpButtonBarVisible( bool visible ) | 1121 | void KABCore::setJumpButtonBarVisible( bool visible ) |
1122 | { | 1122 | { |
1123 | if (mMultipleViewsAtOnce) | 1123 | if (mMultipleViewsAtOnce) |
1124 | { | 1124 | { |
1125 | if ( visible ) | 1125 | if ( visible ) |
1126 | mJumpButtonBar->show(); | 1126 | mJumpButtonBar->show(); |
1127 | else | 1127 | else |
1128 | mJumpButtonBar->hide(); | 1128 | mJumpButtonBar->hide(); |
1129 | } | 1129 | } |
1130 | else | 1130 | else |
1131 | { | 1131 | { |
1132 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" | 1132 | // show the jumpbar only if "the details are hidden" == "viewmanager are shown" |
1133 | if (mViewManager->isVisible()) | 1133 | if (mViewManager->isVisible()) |
1134 | { | 1134 | { |
1135 | if ( visible ) | 1135 | if ( visible ) |
1136 | mJumpButtonBar->show(); | 1136 | mJumpButtonBar->show(); |
1137 | else | 1137 | else |
1138 | mJumpButtonBar->hide(); | 1138 | mJumpButtonBar->hide(); |
1139 | } | 1139 | } |
1140 | else | 1140 | else |
1141 | { | 1141 | { |
1142 | mJumpButtonBar->hide(); | 1142 | mJumpButtonBar->hide(); |
1143 | } | 1143 | } |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | 1147 | ||
1148 | void KABCore::setDetailsToState() | 1148 | void KABCore::setDetailsToState() |
1149 | { | 1149 | { |
1150 | setDetailsVisible( mActionDetails->isChecked() ); | 1150 | setDetailsVisible( mActionDetails->isChecked() ); |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | 1153 | ||
1154 | 1154 | ||
1155 | void KABCore::setDetailsVisible( bool visible ) | 1155 | void KABCore::setDetailsVisible( bool visible ) |
1156 | { | 1156 | { |
1157 | if (visible && mDetails->isHidden()) | 1157 | if (visible && mDetails->isHidden()) |
1158 | { | 1158 | { |
1159 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 1159 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
1160 | if ( addrList.count() > 0 ) | 1160 | if ( addrList.count() > 0 ) |
1161 | mDetails->setAddressee( addrList[ 0 ] ); | 1161 | mDetails->setAddressee( addrList[ 0 ] ); |
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between | 1164 | // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between |
1165 | // the listview and the detailview. We do that by changing the splitbar size. | 1165 | // the listview and the detailview. We do that by changing the splitbar size. |
1166 | if (mMultipleViewsAtOnce) | 1166 | if (mMultipleViewsAtOnce) |
1167 | { | 1167 | { |
1168 | if ( visible ) | 1168 | if ( visible ) |
1169 | mDetails->show(); | 1169 | mDetails->show(); |
1170 | else | 1170 | else |
1171 | mDetails->hide(); | 1171 | mDetails->hide(); |
1172 | } | 1172 | } |
1173 | else | 1173 | else |
1174 | { | 1174 | { |
1175 | if ( visible ) { | 1175 | if ( visible ) { |
1176 | mViewManager->hide(); | 1176 | mViewManager->hide(); |
1177 | mDetails->show(); | 1177 | mDetails->show(); |
1178 | } | 1178 | } |
1179 | else { | 1179 | else { |
1180 | mViewManager->show(); | 1180 | mViewManager->show(); |
1181 | mDetails->hide(); | 1181 | mDetails->hide(); |
1182 | } | 1182 | } |
1183 | setJumpButtonBarVisible( !visible ); | 1183 | setJumpButtonBarVisible( !visible ); |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void KABCore::extensionChanged( int id ) | 1188 | void KABCore::extensionChanged( int id ) |
1189 | { | 1189 | { |
1190 | //change the details view only for non desktop systems | 1190 | //change the details view only for non desktop systems |
1191 | #ifndef DESKTOP_VERSION | 1191 | #ifndef DESKTOP_VERSION |
1192 | 1192 | ||
1193 | if (id == 0) | 1193 | if (id == 0) |
1194 | { | 1194 | { |
1195 | //the user disabled the extension. | 1195 | //the user disabled the extension. |
1196 | 1196 | ||
1197 | if (mMultipleViewsAtOnce) | 1197 | if (mMultipleViewsAtOnce) |
1198 | { // enable detailsview again | 1198 | { // enable detailsview again |
1199 | setDetailsVisible( true ); | 1199 | setDetailsVisible( true ); |
1200 | mActionDetails->setChecked( true ); | 1200 | mActionDetails->setChecked( true ); |
1201 | } | 1201 | } |
1202 | else | 1202 | else |
1203 | { //go back to the listview | 1203 | { //go back to the listview |
1204 | setDetailsVisible( false ); | 1204 | setDetailsVisible( false ); |
1205 | mActionDetails->setChecked( false ); | 1205 | mActionDetails->setChecked( false ); |
1206 | mActionDetails->setEnabled(true); | 1206 | mActionDetails->setEnabled(true); |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | } | 1209 | } |
1210 | else | 1210 | else |
1211 | { | 1211 | { |
1212 | //the user enabled the extension. | 1212 | //the user enabled the extension. |
1213 | setDetailsVisible( false ); | 1213 | setDetailsVisible( false ); |
1214 | mActionDetails->setChecked( false ); | 1214 | mActionDetails->setChecked( false ); |
1215 | 1215 | ||
1216 | if (!mMultipleViewsAtOnce) | 1216 | if (!mMultipleViewsAtOnce) |
1217 | { | 1217 | { |
1218 | mActionDetails->setEnabled(false); | 1218 | mActionDetails->setEnabled(false); |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | mExtensionManager->setSelectionChanged(); | 1221 | mExtensionManager->setSelectionChanged(); |
1222 | 1222 | ||
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | #endif// DESKTOP_VERSION | 1225 | #endif// DESKTOP_VERSION |
1226 | 1226 | ||
1227 | } | 1227 | } |
1228 | 1228 | ||
1229 | 1229 | ||
1230 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 1230 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
1231 | { | 1231 | { |
1232 | 1232 | ||
1233 | if ( list.count() != 0 ) { | 1233 | if ( list.count() != 0 ) { |
1234 | KABC::Addressee::List::ConstIterator it; | 1234 | KABC::Addressee::List::ConstIterator it; |
1235 | for ( it = list.begin(); it != list.end(); ++it ) | 1235 | for ( it = list.begin(); it != list.end(); ++it ) |
1236 | mAddressBook->insertAddressee( *it ); | 1236 | mAddressBook->insertAddressee( *it ); |
1237 | if ( list.count() > 1 ) | 1237 | if ( list.count() > 1 ) |
1238 | setModified(); | 1238 | setModified(); |
1239 | else | 1239 | else |
1240 | setModifiedWOrefresh(); | 1240 | setModifiedWOrefresh(); |
1241 | } | 1241 | } |
1242 | if ( list.count() == 0 ) | 1242 | if ( list.count() == 0 ) |
1243 | mViewManager->refreshView(); | 1243 | mViewManager->refreshView(); |
1244 | else | 1244 | else |
1245 | mViewManager->refreshView( list[ 0 ].uid() ); | 1245 | mViewManager->refreshView( list[ 0 ].uid() ); |
1246 | 1246 | ||
1247 | 1247 | ||
1248 | 1248 | ||
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | QString KABCore::getNameByPhone( const QString &phone ) | 1251 | QString KABCore::getNameByPhone( const QString &phone ) |
1252 | { | 1252 | { |
1253 | #ifndef KAB_EMBEDDED | 1253 | #ifndef KAB_EMBEDDED |
1254 | QRegExp r( "[/*/-/ ]" ); | 1254 | QRegExp r( "[/*/-/ ]" ); |
1255 | QString localPhone( phone ); | 1255 | QString localPhone( phone ); |
1256 | 1256 | ||
1257 | bool found = false; | 1257 | bool found = false; |
1258 | QString ownerName = ""; | 1258 | QString ownerName = ""; |
1259 | KABC::AddressBook::Iterator iter; | 1259 | KABC::AddressBook::Iterator iter; |
1260 | KABC::PhoneNumber::List::Iterator phoneIter; | 1260 | KABC::PhoneNumber::List::Iterator phoneIter; |
1261 | KABC::PhoneNumber::List phoneList; | 1261 | KABC::PhoneNumber::List phoneList; |
1262 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 1262 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
1263 | phoneList = (*iter).phoneNumbers(); | 1263 | phoneList = (*iter).phoneNumbers(); |
1264 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 1264 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
1265 | ++phoneIter) { | 1265 | ++phoneIter) { |
1266 | // Get rid of separator chars so just the numbers are compared. | 1266 | // Get rid of separator chars so just the numbers are compared. |
1267 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 1267 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
1268 | ownerName = (*iter).formattedName(); | 1268 | ownerName = (*iter).formattedName(); |
1269 | found = true; | 1269 | found = true; |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | return ownerName; | 1274 | return ownerName; |
1275 | #else //KAB_EMBEDDED | 1275 | #else //KAB_EMBEDDED |
1276 | qDebug("KABCore::getNameByPhone finsih method"); | 1276 | qDebug("KABCore::getNameByPhone finsih method"); |
1277 | return ""; | 1277 | return ""; |
1278 | #endif //KAB_EMBEDDED | 1278 | #endif //KAB_EMBEDDED |
1279 | 1279 | ||
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | void KABCore::openConfigDialog() | 1282 | void KABCore::openConfigDialog() |
1283 | { | 1283 | { |
1284 | KABPrefs* kab_prefs = KABPrefs::instance(); | 1284 | KABPrefs* kab_prefs = KABPrefs::instance(); |
1285 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); | 1285 | KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); |
1286 | 1286 | ||
1287 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 1287 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
1288 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 1288 | KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
1289 | ConfigureDialog->addModule(kabcfg ); | 1289 | ConfigureDialog->addModule(kabcfg ); |
1290 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); | 1290 | KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); |
1291 | ConfigureDialog->addModule(kdelibcfg ); | 1291 | ConfigureDialog->addModule(kdelibcfg ); |
1292 | 1292 | ||
1293 | 1293 | ||
1294 | 1294 | ||
1295 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 1295 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
1296 | this, SLOT( configurationChanged() ) ); | 1296 | this, SLOT( configurationChanged() ) ); |
1297 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1297 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1298 | this, SLOT( configurationChanged() ) ); | 1298 | this, SLOT( configurationChanged() ) ); |
1299 | saveSettings(); | 1299 | saveSettings(); |
1300 | #ifndef DESKTOP_VERSION | 1300 | #ifndef DESKTOP_VERSION |
1301 | ConfigureDialog->showMaximized(); | 1301 | ConfigureDialog->showMaximized(); |
1302 | #endif | 1302 | #endif |
1303 | if ( ConfigureDialog->exec() ) | 1303 | if ( ConfigureDialog->exec() ) |
1304 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); | 1304 | KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); |
1305 | delete ConfigureDialog; | 1305 | delete ConfigureDialog; |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | void KABCore::openLDAPDialog() | 1308 | void KABCore::openLDAPDialog() |
1309 | { | 1309 | { |
1310 | #ifndef KAB_EMBEDDED | 1310 | #ifndef KAB_EMBEDDED |
1311 | if ( !mLdapSearchDialog ) { | 1311 | if ( !mLdapSearchDialog ) { |
1312 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1312 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1313 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1313 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1314 | SLOT( refreshView() ) ); | 1314 | SLOT( refreshView() ) ); |
1315 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1315 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1316 | SLOT( setModified() ) ); | 1316 | SLOT( setModified() ) ); |
1317 | } else | 1317 | } else |
1318 | mLdapSearchDialog->restoreSettings(); | 1318 | mLdapSearchDialog->restoreSettings(); |
1319 | 1319 | ||
1320 | if ( mLdapSearchDialog->isOK() ) | 1320 | if ( mLdapSearchDialog->isOK() ) |
1321 | mLdapSearchDialog->exec(); | 1321 | mLdapSearchDialog->exec(); |
1322 | #else //KAB_EMBEDDED | 1322 | #else //KAB_EMBEDDED |
1323 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1323 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1324 | #endif //KAB_EMBEDDED | 1324 | #endif //KAB_EMBEDDED |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | void KABCore::print() | 1327 | void KABCore::print() |
1328 | { | 1328 | { |
1329 | #ifndef KAB_EMBEDDED | 1329 | #ifndef KAB_EMBEDDED |
1330 | KPrinter printer; | 1330 | KPrinter printer; |
1331 | if ( !printer.setup( this ) ) | 1331 | if ( !printer.setup( this ) ) |
1332 | return; | 1332 | return; |
1333 | 1333 | ||
1334 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1334 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1335 | mViewManager->selectedUids(), this ); | 1335 | mViewManager->selectedUids(), this ); |
1336 | 1336 | ||
1337 | wizard.exec(); | 1337 | wizard.exec(); |
1338 | #else //KAB_EMBEDDED | 1338 | #else //KAB_EMBEDDED |
1339 | qDebug("KABCore::print() finsih method"); | 1339 | qDebug("KABCore::print() finsih method"); |
1340 | #endif //KAB_EMBEDDED | 1340 | #endif //KAB_EMBEDDED |
1341 | 1341 | ||
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | 1344 | ||
1345 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1345 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1346 | { | 1346 | { |
1347 | if ( mGUIClient ) | 1347 | if ( mGUIClient ) |
1348 | mGUIClient->insertChildClient( client ); | 1348 | mGUIClient->insertChildClient( client ); |
1349 | else | 1349 | else |
1350 | KMessageBox::error( this, "no KXMLGUICLient"); | 1350 | KMessageBox::error( this, "no KXMLGUICLient"); |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | 1353 | ||
1354 | void KABCore::configurationChanged() | 1354 | void KABCore::configurationChanged() |
1355 | { | 1355 | { |
1356 | mExtensionManager->reconfigure(); | 1356 | mExtensionManager->reconfigure(); |
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | void KABCore::addressBookChanged() | 1359 | void KABCore::addressBookChanged() |
1360 | { | 1360 | { |
1361 | /*US | 1361 | /*US |
1362 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1362 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1363 | while ( it.current() ) { | 1363 | while ( it.current() ) { |
1364 | if ( it.current()->dirty() ) { | 1364 | if ( it.current()->dirty() ) { |
1365 | QString text = i18n( "Data has been changed externally. Unsaved " | 1365 | QString text = i18n( "Data has been changed externally. Unsaved " |
1366 | "changes will be lost." ); | 1366 | "changes will be lost." ); |
1367 | KMessageBox::information( this, text ); | 1367 | KMessageBox::information( this, text ); |
1368 | } | 1368 | } |
1369 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1369 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1370 | ++it; | 1370 | ++it; |
1371 | } | 1371 | } |
1372 | */ | 1372 | */ |
1373 | if (mEditorDialog) | 1373 | if (mEditorDialog) |
1374 | { | 1374 | { |
1375 | if (mEditorDialog->dirty()) | 1375 | if (mEditorDialog->dirty()) |
1376 | { | 1376 | { |
1377 | QString text = i18n( "Data has been changed externally. Unsaved " | 1377 | QString text = i18n( "Data has been changed externally. Unsaved " |
1378 | "changes will be lost." ); | 1378 | "changes will be lost." ); |
1379 | KMessageBox::information( this, text ); | 1379 | KMessageBox::information( this, text ); |
1380 | } | 1380 | } |
1381 | QString currentuid = mEditorDialog->addressee().uid(); | 1381 | QString currentuid = mEditorDialog->addressee().uid(); |
1382 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); | 1382 | mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); |
1383 | } | 1383 | } |
1384 | mViewManager->refreshView(); | 1384 | mViewManager->refreshView(); |
1385 | // mDetails->refreshView(); | 1385 | // mDetails->refreshView(); |
1386 | 1386 | ||
1387 | 1387 | ||
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1390 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1391 | const char *name ) | 1391 | const char *name ) |
1392 | { | 1392 | { |
1393 | 1393 | ||
1394 | if ( mEditorDialog == 0 ) { | 1394 | if ( mEditorDialog == 0 ) { |
1395 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1395 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1396 | name ? name : "editorDialog" ); | 1396 | name ? name : "editorDialog" ); |
1397 | 1397 | ||
1398 | 1398 | ||
1399 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1399 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1400 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1400 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1401 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1401 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1402 | // SLOT( slotEditorDestroyed( const QString& ) ) ; | 1402 | // SLOT( slotEditorDestroyed( const QString& ) ) ; |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | return mEditorDialog; | 1405 | return mEditorDialog; |
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1408 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1409 | { | 1409 | { |
1410 | //mEditorDict.remove( uid ); | 1410 | //mEditorDict.remove( uid ); |
1411 | } | 1411 | } |
1412 | 1412 | ||
1413 | void KABCore::initGUI() | 1413 | void KABCore::initGUI() |
1414 | { | 1414 | { |
1415 | #ifndef KAB_EMBEDDED | 1415 | #ifndef KAB_EMBEDDED |
1416 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1416 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1417 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1417 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1418 | 1418 | ||
1419 | mExtensionBarSplitter = new QSplitter( this ); | 1419 | mExtensionBarSplitter = new QSplitter( this ); |
1420 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1420 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1421 | 1421 | ||
1422 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1422 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1423 | 1423 | ||
1424 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1424 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1425 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1425 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1426 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1426 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1427 | SLOT( incrementalSearch( const QString& ) ) ); | 1427 | SLOT( incrementalSearch( const QString& ) ) ); |
1428 | 1428 | ||
1429 | mViewManager = new ViewManager( this, viewSpace ); | 1429 | mViewManager = new ViewManager( this, viewSpace ); |
1430 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1430 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1431 | 1431 | ||
1432 | mDetails = new ViewContainer( mDetailsSplitter ); | 1432 | mDetails = new ViewContainer( mDetailsSplitter ); |
1433 | 1433 | ||
1434 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1434 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1435 | 1435 | ||
1436 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1436 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1437 | 1437 | ||
1438 | topLayout->addWidget( mExtensionBarSplitter ); | 1438 | topLayout->addWidget( mExtensionBarSplitter ); |
1439 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1439 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1440 | topLayout->addWidget( mJumpButtonBar ); | 1440 | topLayout->addWidget( mJumpButtonBar ); |
1441 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1441 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1442 | 1442 | ||
1443 | mXXPortManager = new XXPortManager( this, this ); | 1443 | mXXPortManager = new XXPortManager( this, this ); |
1444 | 1444 | ||
1445 | #else //KAB_EMBEDDED | 1445 | #else //KAB_EMBEDDED |
1446 | //US initialize viewMenu before settingup viewmanager. | 1446 | //US initialize viewMenu before settingup viewmanager. |
1447 | // Viewmanager needs this menu to plugin submenues. | 1447 | // Viewmanager needs this menu to plugin submenues. |
1448 | viewMenu = new QPopupMenu( this ); | 1448 | viewMenu = new QPopupMenu( this ); |
1449 | settingsMenu = new QPopupMenu( this ); | 1449 | settingsMenu = new QPopupMenu( this ); |
1450 | //filterMenu = new QPopupMenu( this ); | 1450 | //filterMenu = new QPopupMenu( this ); |
1451 | ImportMenu = new QPopupMenu( this ); | 1451 | ImportMenu = new QPopupMenu( this ); |
1452 | ExportMenu = new QPopupMenu( this ); | 1452 | ExportMenu = new QPopupMenu( this ); |
1453 | syncMenu = new QPopupMenu( this ); | 1453 | syncMenu = new QPopupMenu( this ); |
1454 | changeMenu= new QPopupMenu( this ); | 1454 | changeMenu= new QPopupMenu( this ); |
1455 | 1455 | ||
1456 | //US since we have no splitter for the embedded system, setup | 1456 | //US since we have no splitter for the embedded system, setup |
1457 | // a layout with two frames. One left and one right. | 1457 | // a layout with two frames. One left and one right. |
1458 | 1458 | ||
1459 | QBoxLayout *topLayout; | 1459 | QBoxLayout *topLayout; |
1460 | 1460 | ||
1461 | // = new QHBoxLayout( this ); | 1461 | // = new QHBoxLayout( this ); |
1462 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1462 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1463 | 1463 | ||
1464 | // QWidget *mainBox = new QWidget( this ); | 1464 | // QWidget *mainBox = new QWidget( this ); |
1465 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1465 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1466 | 1466 | ||
1467 | #ifdef DESKTOP_VERSION | 1467 | #ifdef DESKTOP_VERSION |
1468 | topLayout = new QHBoxLayout( this ); | 1468 | topLayout = new QHBoxLayout( this ); |
1469 | 1469 | ||
1470 | 1470 | ||
1471 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1471 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1472 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1472 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1473 | 1473 | ||
1474 | topLayout->addWidget(mMiniSplitter ); | 1474 | topLayout->addWidget(mMiniSplitter ); |
1475 | 1475 | ||
1476 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1476 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1477 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1477 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1478 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1478 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1479 | mDetails = new ViewContainer( mMiniSplitter ); | 1479 | mDetails = new ViewContainer( mMiniSplitter ); |
1480 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1480 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1481 | #else | 1481 | #else |
1482 | if ( QApplication::desktop()->width() > 480 ) { | 1482 | if ( QApplication::desktop()->width() > 480 ) { |
1483 | topLayout = new QHBoxLayout( this ); | 1483 | topLayout = new QHBoxLayout( this ); |
1484 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1484 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1485 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1485 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1486 | } else { | 1486 | } else { |
1487 | 1487 | ||
1488 | topLayout = new QHBoxLayout( this ); | 1488 | topLayout = new QHBoxLayout( this ); |
1489 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1489 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1490 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1490 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | topLayout->addWidget(mMiniSplitter ); | 1493 | topLayout->addWidget(mMiniSplitter ); |
1494 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1494 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1495 | mDetails = new ViewContainer( mMiniSplitter ); | 1495 | mDetails = new ViewContainer( mMiniSplitter ); |
1496 | 1496 | ||
1497 | 1497 | ||
1498 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1498 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1499 | #endif | 1499 | #endif |
1500 | //eh->hide(); | 1500 | //eh->hide(); |
1501 | // topLayout->addWidget(mExtensionManager ); | 1501 | // topLayout->addWidget(mExtensionManager ); |
1502 | 1502 | ||
1503 | 1503 | ||
1504 | /*US | 1504 | /*US |
1505 | #ifndef KAB_NOSPLITTER | 1505 | #ifndef KAB_NOSPLITTER |
1506 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1506 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1507 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1507 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1508 | topLayout->setSpacing( 10 ); | 1508 | topLayout->setSpacing( 10 ); |
1509 | 1509 | ||
1510 | mDetailsSplitter = new QSplitter( this ); | 1510 | mDetailsSplitter = new QSplitter( this ); |
1511 | 1511 | ||
1512 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1512 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1513 | 1513 | ||
1514 | mViewManager = new ViewManager( this, viewSpace ); | 1514 | mViewManager = new ViewManager( this, viewSpace ); |
1515 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1515 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1516 | 1516 | ||
1517 | mDetails = new ViewContainer( mDetailsSplitter ); | 1517 | mDetails = new ViewContainer( mDetailsSplitter ); |
1518 | 1518 | ||
1519 | topLayout->addWidget( mDetailsSplitter ); | 1519 | topLayout->addWidget( mDetailsSplitter ); |
1520 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1520 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1521 | #else //KAB_NOSPLITTER | 1521 | #else //KAB_NOSPLITTER |
1522 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1522 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1523 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1523 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1524 | topLayout->setSpacing( 10 ); | 1524 | topLayout->setSpacing( 10 ); |
1525 | 1525 | ||
1526 | // mDetailsSplitter = new QSplitter( this ); | 1526 | // mDetailsSplitter = new QSplitter( this ); |
1527 | 1527 | ||
1528 | QVBox *viewSpace = new QVBox( this ); | 1528 | QVBox *viewSpace = new QVBox( this ); |
1529 | 1529 | ||
1530 | mViewManager = new ViewManager( this, viewSpace ); | 1530 | mViewManager = new ViewManager( this, viewSpace ); |
1531 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1531 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1532 | 1532 | ||
1533 | mDetails = new ViewContainer( this ); | 1533 | mDetails = new ViewContainer( this ); |
1534 | 1534 | ||
1535 | topLayout->addWidget( viewSpace ); | 1535 | topLayout->addWidget( viewSpace ); |
1536 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1536 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1537 | topLayout->addWidget( mDetails ); | 1537 | topLayout->addWidget( mDetails ); |
1538 | #endif //KAB_NOSPLITTER | 1538 | #endif //KAB_NOSPLITTER |
1539 | */ | 1539 | */ |
1540 | 1540 | ||
1541 | 1541 | ||
1542 | #endif //KAB_EMBEDDED | 1542 | #endif //KAB_EMBEDDED |
1543 | initActions(); | 1543 | initActions(); |
1544 | 1544 | ||
1545 | #ifdef KAB_EMBEDDED | 1545 | #ifdef KAB_EMBEDDED |
1546 | addActionsManually(); | 1546 | addActionsManually(); |
1547 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1547 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1548 | mXXPortManager = new XXPortManager( this, this ); | 1548 | mXXPortManager = new XXPortManager( this, this ); |
1549 | 1549 | ||
1550 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1550 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1551 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1551 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1552 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1552 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1553 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1553 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1554 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1554 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1555 | // mIncSearchWidget->hide(); | 1555 | // mIncSearchWidget->hide(); |
1556 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1556 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1557 | SLOT( incrementalSearch( const QString& ) ) ); | 1557 | SLOT( incrementalSearch( const QString& ) ) ); |
1558 | 1558 | ||
1559 | 1559 | ||
1560 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1560 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1561 | 1561 | ||
1562 | topLayout->addWidget( mJumpButtonBar ); | 1562 | topLayout->addWidget( mJumpButtonBar ); |
1563 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1563 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1564 | 1564 | ||
1565 | // mMainWindow->getIconToolBar()->raise(); | 1565 | // mMainWindow->getIconToolBar()->raise(); |
1566 | 1566 | ||
1567 | #endif //KAB_EMBEDDED | 1567 | #endif //KAB_EMBEDDED |
1568 | 1568 | ||
1569 | } | 1569 | } |
1570 | void KABCore::initActions() | 1570 | void KABCore::initActions() |
1571 | { | 1571 | { |
1572 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1572 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1573 | 1573 | ||
1574 | #ifndef KAB_EMBEDDED | 1574 | #ifndef KAB_EMBEDDED |
1575 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1575 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1576 | SLOT( clipboardDataChanged() ) ); | 1576 | SLOT( clipboardDataChanged() ) ); |
1577 | #endif //KAB_EMBEDDED | 1577 | #endif //KAB_EMBEDDED |
1578 | 1578 | ||
1579 | // file menu | 1579 | // file menu |
1580 | if ( mIsPart ) { | 1580 | if ( mIsPart ) { |
1581 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1581 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1582 | SLOT( sendMail() ), actionCollection(), | 1582 | SLOT( sendMail() ), actionCollection(), |
1583 | "kaddressbook_mail" ); | 1583 | "kaddressbook_mail" ); |
1584 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1584 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1585 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1585 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1586 | 1586 | ||
1587 | } else { | 1587 | } else { |
1588 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1588 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1589 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1589 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1590 | } | 1590 | } |
1591 | 1591 | ||
1592 | 1592 | ||
1593 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1593 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1594 | SLOT( save() ), actionCollection(), "file_sync" ); | 1594 | SLOT( save() ), actionCollection(), "file_sync" ); |
1595 | 1595 | ||
1596 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1596 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1597 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1597 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1598 | 1598 | ||
1599 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1599 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1600 | this, SLOT( mailVCard() ), | 1600 | this, SLOT( mailVCard() ), |
1601 | actionCollection(), "file_mail_vcard"); | 1601 | actionCollection(), "file_mail_vcard"); |
1602 | 1602 | ||
1603 | mActionBeamVCard = 0; | 1603 | mActionBeamVCard = 0; |
1604 | mActionBeam = 0; | 1604 | mActionBeam = 0; |
1605 | 1605 | ||
1606 | #ifndef DESKTOP_VERSION | 1606 | #ifndef DESKTOP_VERSION |
1607 | if ( Ir::supported() ) { | 1607 | if ( Ir::supported() ) { |
1608 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, | 1608 | mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, |
1609 | SLOT( beamVCard() ), actionCollection(), | 1609 | SLOT( beamVCard() ), actionCollection(), |
1610 | "kaddressbook_beam_vcard" ); | 1610 | "kaddressbook_beam_vcard" ); |
1611 | 1611 | ||
1612 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, | 1612 | mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, |
1613 | SLOT( beamMySelf() ), actionCollection(), | 1613 | SLOT( beamMySelf() ), actionCollection(), |
1614 | "kaddressbook_beam_myself" ); | 1614 | "kaddressbook_beam_myself" ); |
1615 | } | 1615 | } |
1616 | #endif | 1616 | #endif |
1617 | 1617 | ||
1618 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1618 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1619 | this, SLOT( editContact2() ), | 1619 | this, SLOT( editContact2() ), |
1620 | actionCollection(), "file_properties" ); | 1620 | actionCollection(), "file_properties" ); |
1621 | 1621 | ||
1622 | #ifdef KAB_EMBEDDED | 1622 | #ifdef KAB_EMBEDDED |
1623 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1623 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1624 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1624 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1625 | mMainWindow, SLOT( exit() ), | 1625 | mMainWindow, SLOT( exit() ), |
1626 | actionCollection(), "quit" ); | 1626 | actionCollection(), "quit" ); |
1627 | #endif //KAB_EMBEDDED | 1627 | #endif //KAB_EMBEDDED |
1628 | 1628 | ||
1629 | // edit menu | 1629 | // edit menu |
1630 | if ( mIsPart ) { | 1630 | if ( mIsPart ) { |
1631 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1631 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1632 | SLOT( copyContacts() ), actionCollection(), | 1632 | SLOT( copyContacts() ), actionCollection(), |
1633 | "kaddressbook_copy" ); | 1633 | "kaddressbook_copy" ); |
1634 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1634 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1635 | SLOT( cutContacts() ), actionCollection(), | 1635 | SLOT( cutContacts() ), actionCollection(), |
1636 | "kaddressbook_cut" ); | 1636 | "kaddressbook_cut" ); |
1637 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1637 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1638 | SLOT( pasteContacts() ), actionCollection(), | 1638 | SLOT( pasteContacts() ), actionCollection(), |
1639 | "kaddressbook_paste" ); | 1639 | "kaddressbook_paste" ); |
1640 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1640 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1641 | SLOT( selectAllContacts() ), actionCollection(), | 1641 | SLOT( selectAllContacts() ), actionCollection(), |
1642 | "kaddressbook_select_all" ); | 1642 | "kaddressbook_select_all" ); |
1643 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1643 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1644 | SLOT( undo() ), actionCollection(), | 1644 | SLOT( undo() ), actionCollection(), |
1645 | "kaddressbook_undo" ); | 1645 | "kaddressbook_undo" ); |
1646 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1646 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1647 | this, SLOT( redo() ), actionCollection(), | 1647 | this, SLOT( redo() ), actionCollection(), |
1648 | "kaddressbook_redo" ); | 1648 | "kaddressbook_redo" ); |
1649 | } else { | 1649 | } else { |
1650 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1650 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1651 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1651 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1652 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1652 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1653 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1653 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1654 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1654 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1655 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1655 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1656 | } | 1656 | } |
1657 | 1657 | ||
1658 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1658 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1659 | Key_Delete, this, SLOT( deleteContacts() ), | 1659 | Key_Delete, this, SLOT( deleteContacts() ), |
1660 | actionCollection(), "edit_delete" ); | 1660 | actionCollection(), "edit_delete" ); |
1661 | 1661 | ||
1662 | mActionUndo->setEnabled( false ); | 1662 | mActionUndo->setEnabled( false ); |
1663 | mActionRedo->setEnabled( false ); | 1663 | mActionRedo->setEnabled( false ); |
1664 | 1664 | ||
1665 | // settings menu | 1665 | // settings menu |
1666 | #ifdef KAB_EMBEDDED | 1666 | #ifdef KAB_EMBEDDED |
1667 | //US special menuentry to configure the addressbook resources. On KDE | 1667 | //US special menuentry to configure the addressbook resources. On KDE |
1668 | // you do that through the control center !!! | 1668 | // you do that through the control center !!! |
1669 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1669 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1670 | SLOT( configureResources() ), actionCollection(), | 1670 | SLOT( configureResources() ), actionCollection(), |
1671 | "kaddressbook_configure_resources" ); | 1671 | "kaddressbook_configure_resources" ); |
1672 | #endif //KAB_EMBEDDED | 1672 | #endif //KAB_EMBEDDED |
1673 | 1673 | ||
1674 | if ( mIsPart ) { | 1674 | if ( mIsPart ) { |
1675 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1675 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1676 | SLOT( openConfigDialog() ), actionCollection(), | 1676 | SLOT( openConfigDialog() ), actionCollection(), |
1677 | "kaddressbook_configure" ); | 1677 | "kaddressbook_configure" ); |
1678 | 1678 | ||
1679 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1679 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1680 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1680 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1681 | "kaddressbook_configure_shortcuts" ); | 1681 | "kaddressbook_configure_shortcuts" ); |
1682 | #ifdef KAB_EMBEDDED | 1682 | #ifdef KAB_EMBEDDED |
1683 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1683 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1684 | mActionConfigureToolbars->setEnabled( false ); | 1684 | mActionConfigureToolbars->setEnabled( false ); |
1685 | #endif //KAB_EMBEDDED | 1685 | #endif //KAB_EMBEDDED |
1686 | 1686 | ||
1687 | } else { | 1687 | } else { |
1688 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1688 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1689 | 1689 | ||
1690 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1690 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1693 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1694 | actionCollection(), "options_show_jump_bar" ); | 1694 | actionCollection(), "options_show_jump_bar" ); |
1695 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1695 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1696 | 1696 | ||
1697 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, | 1697 | mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, |
1698 | actionCollection(), "options_show_details" ); | 1698 | actionCollection(), "options_show_details" ); |
1699 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1699 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1700 | 1700 | ||
1701 | // misc | 1701 | // misc |
1702 | // only enable LDAP lookup if we can handle the protocol | 1702 | // only enable LDAP lookup if we can handle the protocol |
1703 | #ifndef KAB_EMBEDDED | 1703 | #ifndef KAB_EMBEDDED |
1704 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1704 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1705 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1705 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1706 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1706 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1707 | "ldap_lookup" ); | 1707 | "ldap_lookup" ); |
1708 | } | 1708 | } |
1709 | #else //KAB_EMBEDDED | 1709 | #else //KAB_EMBEDDED |
1710 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1710 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1711 | #endif //KAB_EMBEDDED | 1711 | #endif //KAB_EMBEDDED |
1712 | 1712 | ||
1713 | 1713 | ||
1714 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1714 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1715 | SLOT( setWhoAmI() ), actionCollection(), | 1715 | SLOT( setWhoAmI() ), actionCollection(), |
1716 | "set_personal" ); | 1716 | "set_personal" ); |
1717 | 1717 | ||
1718 | 1718 | ||
1719 | 1719 | ||
1720 | 1720 | ||
1721 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1721 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1722 | SLOT( setCategories() ), actionCollection(), | 1722 | SLOT( setCategories() ), actionCollection(), |
1723 | "edit_set_categories" ); | 1723 | "edit_set_categories" ); |
1724 | 1724 | ||
1725 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, | 1725 | mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, |
1726 | SLOT( removeVoice() ), actionCollection(), | 1726 | SLOT( removeVoice() ), actionCollection(), |
1727 | "remove_voice" ); | 1727 | "remove_voice" ); |
1728 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, | 1728 | mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, |
1729 | SLOT( importFromOL() ), actionCollection(), | 1729 | SLOT( importFromOL() ), actionCollection(), |
1730 | "import_OL" ); | 1730 | "import_OL" ); |
1731 | #ifdef KAB_EMBEDDED | 1731 | #ifdef KAB_EMBEDDED |
1732 | mActionLicence = new KAction( i18n( "Licence" ), 0, | 1732 | mActionLicence = new KAction( i18n( "Licence" ), 0, |
1733 | this, SLOT( showLicence() ), actionCollection(), | 1733 | this, SLOT( showLicence() ), actionCollection(), |
1734 | "licence_about_data" ); | 1734 | "licence_about_data" ); |
1735 | mActionFaq = new KAction( i18n( "Faq" ), 0, | 1735 | mActionFaq = new KAction( i18n( "Faq" ), 0, |
1736 | this, SLOT( faq() ), actionCollection(), | 1736 | this, SLOT( faq() ), actionCollection(), |
1737 | "faq_about_data" ); | 1737 | "faq_about_data" ); |
1738 | 1738 | ||
1739 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1739 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1740 | this, SLOT( createAboutData() ), actionCollection(), | 1740 | this, SLOT( createAboutData() ), actionCollection(), |
1741 | "kaddressbook_about_data" ); | 1741 | "kaddressbook_about_data" ); |
1742 | #endif //KAB_EMBEDDED | 1742 | #endif //KAB_EMBEDDED |
1743 | 1743 | ||
1744 | clipboardDataChanged(); | 1744 | clipboardDataChanged(); |
1745 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1745 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1746 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1746 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | //US we need this function, to plug all actions into the correct menues. | 1749 | //US we need this function, to plug all actions into the correct menues. |
1750 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1750 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1751 | void KABCore::addActionsManually() | 1751 | void KABCore::addActionsManually() |
1752 | { | 1752 | { |
1753 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1753 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1754 | 1754 | ||
1755 | #ifdef KAB_EMBEDDED | 1755 | #ifdef KAB_EMBEDDED |
1756 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1756 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1757 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1757 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1758 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1758 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1759 | 1759 | ||
1760 | KToolBar* tb = mMainWindow->toolBar(); | 1760 | KToolBar* tb = mMainWindow->toolBar(); |
1761 | 1761 | ||
1762 | #ifdef DESKTOP_VERSION | 1762 | #ifdef DESKTOP_VERSION |
1763 | QMenuBar* mb = mMainWindow->menuBar(); | 1763 | QMenuBar* mb = mMainWindow->menuBar(); |
1764 | 1764 | ||
1765 | //US setup menubar. | 1765 | //US setup menubar. |
1766 | //Disable the following block if you do not want to have a menubar. | 1766 | //Disable the following block if you do not want to have a menubar. |
1767 | mb->insertItem( "&File", fileMenu ); | 1767 | mb->insertItem( "&File", fileMenu ); |
1768 | mb->insertItem( "&Edit", editMenu ); | 1768 | mb->insertItem( "&Edit", editMenu ); |
1769 | mb->insertItem( "&View", viewMenu ); | 1769 | mb->insertItem( "&View", viewMenu ); |
1770 | mb->insertItem( "&Settings", settingsMenu ); | 1770 | mb->insertItem( "&Settings", settingsMenu ); |
1771 | mb->insertItem( i18n("Synchronize"), syncMenu ); | 1771 | mb->insertItem( i18n("Synchronize"), syncMenu ); |
1772 | mb->insertItem( "&Change selected", changeMenu ); | 1772 | mb->insertItem( "&Change selected", changeMenu ); |
1773 | mb->insertItem( "&Help", helpMenu ); | 1773 | mb->insertItem( "&Help", helpMenu ); |
1774 | mIncSearchWidget = new IncSearchWidget( tb ); | 1774 | mIncSearchWidget = new IncSearchWidget( tb ); |
1775 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1775 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1776 | 1776 | ||
1777 | #else | 1777 | #else |
1778 | //US setup toolbar | 1778 | //US setup toolbar |
1779 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); | 1779 | QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); |
1780 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1780 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1781 | menuBarTB->insertItem( "ME", popupBarTB); | 1781 | menuBarTB->insertItem( "ME", popupBarTB); |
1782 | tb->insertWidget(-1, 0, menuBarTB); | 1782 | tb->insertWidget(-1, 0, menuBarTB); |
1783 | mIncSearchWidget = new IncSearchWidget( tb ); | 1783 | mIncSearchWidget = new IncSearchWidget( tb ); |
1784 | 1784 | ||
1785 | tb->enableMoving(false); | 1785 | tb->enableMoving(false); |
1786 | popupBarTB->insertItem( "&File", fileMenu ); | 1786 | popupBarTB->insertItem( "&File", fileMenu ); |
1787 | popupBarTB->insertItem( "&Edit", editMenu ); | 1787 | popupBarTB->insertItem( "&Edit", editMenu ); |
1788 | popupBarTB->insertItem( "&View", viewMenu ); | 1788 | popupBarTB->insertItem( "&View", viewMenu ); |
1789 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1789 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1790 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); | 1790 | popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); |
1791 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1791 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1792 | popupBarTB->insertItem( "&Change selected", changeMenu ); | 1792 | popupBarTB->insertItem( "&Change selected", changeMenu ); |
1793 | popupBarTB->insertItem( "&Help", helpMenu ); | 1793 | popupBarTB->insertItem( "&Help", helpMenu ); |
1794 | if (QApplication::desktop()->width() > 320 ) { | 1794 | if (QApplication::desktop()->width() > 320 ) { |
1795 | // mViewManager->getFilterAction()->plug ( tb); | 1795 | // mViewManager->getFilterAction()->plug ( tb); |
1796 | } | 1796 | } |
1797 | #endif | 1797 | #endif |
1798 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1798 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1799 | 1799 | ||
1800 | 1800 | ||
1801 | 1801 | ||
1802 | //US Now connect the actions with the menue entries. | 1802 | //US Now connect the actions with the menue entries. |
1803 | mActionPrint->plug( fileMenu ); | 1803 | mActionPrint->plug( fileMenu ); |
1804 | mActionMail->plug( fileMenu ); | 1804 | mActionMail->plug( fileMenu ); |
1805 | fileMenu->insertSeparator(); | 1805 | fileMenu->insertSeparator(); |
1806 | 1806 | ||
1807 | mActionNewContact->plug( fileMenu ); | 1807 | mActionNewContact->plug( fileMenu ); |
1808 | mActionNewContact->plug( tb ); | 1808 | mActionNewContact->plug( tb ); |
1809 | 1809 | ||
1810 | mActionEditAddressee->plug( fileMenu ); | 1810 | mActionEditAddressee->plug( fileMenu ); |
1811 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || | 1811 | if ((KGlobal::getDesktopSize() > KGlobal::Small ) || |
1812 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) | 1812 | (!KABPrefs::instance()->mMultipleViewsAtOnce )) |
1813 | mActionEditAddressee->plug( tb ); | 1813 | mActionEditAddressee->plug( tb ); |
1814 | 1814 | ||
1815 | fileMenu->insertSeparator(); | 1815 | fileMenu->insertSeparator(); |
1816 | mActionSave->plug( fileMenu ); | 1816 | mActionSave->plug( fileMenu ); |
1817 | fileMenu->insertItem( "&Import", ImportMenu ); | 1817 | fileMenu->insertItem( "&Import", ImportMenu ); |
1818 | fileMenu->insertItem( "&Export", ExportMenu ); | 1818 | fileMenu->insertItem( "&Export", ExportMenu ); |
1819 | fileMenu->insertSeparator(); | 1819 | fileMenu->insertSeparator(); |
1820 | mActionMailVCard->plug( fileMenu ); | 1820 | mActionMailVCard->plug( fileMenu ); |
1821 | #ifndef DESKTOP_VERSION | 1821 | #ifndef DESKTOP_VERSION |
1822 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); | 1822 | if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); |
1823 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); | 1823 | if ( Ir::supported() ) mActionBeam->plug(fileMenu ); |
1824 | #endif | 1824 | #endif |
1825 | fileMenu->insertSeparator(); | 1825 | fileMenu->insertSeparator(); |
1826 | mActionQuit->plug( fileMenu ); | 1826 | mActionQuit->plug( fileMenu ); |
1827 | #ifdef _WIN32_ | 1827 | #ifdef _WIN32_ |
1828 | mActionImportOL->plug( ImportMenu ); | 1828 | mActionImportOL->plug( ImportMenu ); |
1829 | #endif | 1829 | #endif |
1830 | // edit menu | 1830 | // edit menu |
1831 | mActionUndo->plug( editMenu ); | 1831 | mActionUndo->plug( editMenu ); |
1832 | mActionRedo->plug( editMenu ); | 1832 | mActionRedo->plug( editMenu ); |
1833 | editMenu->insertSeparator(); | 1833 | editMenu->insertSeparator(); |
1834 | mActionCut->plug( editMenu ); | 1834 | mActionCut->plug( editMenu ); |
1835 | mActionCopy->plug( editMenu ); | 1835 | mActionCopy->plug( editMenu ); |
1836 | mActionPaste->plug( editMenu ); | 1836 | mActionPaste->plug( editMenu ); |
1837 | mActionDelete->plug( editMenu ); | 1837 | mActionDelete->plug( editMenu ); |
1838 | editMenu->insertSeparator(); | 1838 | editMenu->insertSeparator(); |
1839 | mActionSelectAll->plug( editMenu ); | 1839 | mActionSelectAll->plug( editMenu ); |
1840 | 1840 | ||
1841 | mActionRemoveVoice->plug( changeMenu ); | 1841 | mActionRemoveVoice->plug( changeMenu ); |
1842 | // settings menu | 1842 | // settings menu |
1843 | //US special menuentry to configure the addressbook resources. On KDE | 1843 | //US special menuentry to configure the addressbook resources. On KDE |
1844 | // you do that through the control center !!! | 1844 | // you do that through the control center !!! |
1845 | mActionConfigResources->plug( settingsMenu ); | 1845 | mActionConfigResources->plug( settingsMenu ); |
1846 | settingsMenu->insertSeparator(); | 1846 | settingsMenu->insertSeparator(); |
1847 | 1847 | ||
1848 | mActionConfigKAddressbook->plug( settingsMenu ); | 1848 | mActionConfigKAddressbook->plug( settingsMenu ); |
1849 | 1849 | ||
1850 | if ( mIsPart ) { | 1850 | if ( mIsPart ) { |
1851 | mActionConfigShortcuts->plug( settingsMenu ); | 1851 | mActionConfigShortcuts->plug( settingsMenu ); |
1852 | mActionConfigureToolbars->plug( settingsMenu ); | 1852 | mActionConfigureToolbars->plug( settingsMenu ); |
1853 | 1853 | ||
1854 | } else { | 1854 | } else { |
1855 | mActionKeyBindings->plug( settingsMenu ); | 1855 | mActionKeyBindings->plug( settingsMenu ); |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | settingsMenu->insertSeparator(); | 1858 | settingsMenu->insertSeparator(); |
1859 | 1859 | ||
1860 | mActionJumpBar->plug( settingsMenu ); | 1860 | mActionJumpBar->plug( settingsMenu ); |
1861 | mActionDetails->plug( settingsMenu ); | 1861 | mActionDetails->plug( settingsMenu ); |
1862 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) | 1862 | if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) |
1863 | mActionDetails->plug( tb ); | 1863 | mActionDetails->plug( tb ); |
1864 | settingsMenu->insertSeparator(); | 1864 | settingsMenu->insertSeparator(); |
1865 | 1865 | ||
1866 | mActionWhoAmI->plug( settingsMenu ); | 1866 | mActionWhoAmI->plug( settingsMenu ); |
1867 | mActionCategories->plug( settingsMenu ); | 1867 | mActionCategories->plug( settingsMenu ); |
1868 | 1868 | ||
1869 | mActionLicence->plug( helpMenu ); | 1869 | mActionLicence->plug( helpMenu ); |
1870 | mActionFaq->plug( helpMenu ); | 1870 | mActionFaq->plug( helpMenu ); |
1871 | mActionAboutKAddressbook->plug( helpMenu ); | 1871 | mActionAboutKAddressbook->plug( helpMenu ); |
1872 | 1872 | ||
1873 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { | 1873 | if (KGlobal::getDesktopSize() > KGlobal::Small ) { |
1874 | 1874 | ||
1875 | mActionSave->plug( tb ); | 1875 | mActionSave->plug( tb ); |
1876 | mViewManager->getFilterAction()->plug ( tb); | 1876 | mViewManager->getFilterAction()->plug ( tb); |
1877 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { | 1877 | if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { |
1878 | mActionUndo->plug( tb ); | 1878 | mActionUndo->plug( tb ); |
1879 | mActionDelete->plug( tb ); | 1879 | mActionDelete->plug( tb ); |
1880 | mActionRedo->plug( tb ); | 1880 | mActionRedo->plug( tb ); |
1881 | } | 1881 | } |
1882 | } | 1882 | } |
1883 | //mActionQuit->plug ( tb ); | 1883 | //mActionQuit->plug ( tb ); |
1884 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1884 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1885 | 1885 | ||
1886 | //US link the searchwidget first to this. | 1886 | //US link the searchwidget first to this. |
1887 | // The real linkage to the toolbar happens later. | 1887 | // The real linkage to the toolbar happens later. |
1888 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1888 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1889 | //US tb->insertItem( mIncSearchWidget ); | 1889 | //US tb->insertItem( mIncSearchWidget ); |
1890 | /*US | 1890 | /*US |
1891 | mIncSearchWidget = new IncSearchWidget( tb ); | 1891 | mIncSearchWidget = new IncSearchWidget( tb ); |
1892 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1892 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1893 | SLOT( incrementalSearch( const QString& ) ) ); | 1893 | SLOT( incrementalSearch( const QString& ) ) ); |
1894 | 1894 | ||
1895 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1895 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1896 | 1896 | ||
1897 | //US topLayout->addWidget( mJumpButtonBar ); | 1897 | //US topLayout->addWidget( mJumpButtonBar ); |
1898 | this->layout()->add( mJumpButtonBar ); | 1898 | this->layout()->add( mJumpButtonBar ); |
1899 | */ | 1899 | */ |
1900 | 1900 | ||
1901 | #endif //KAB_EMBEDDED | 1901 | #endif //KAB_EMBEDDED |
1902 | 1902 | ||
1903 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 1903 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
1904 | fillSyncMenu(); | 1904 | fillSyncMenu(); |
1905 | 1905 | ||
1906 | } | 1906 | } |
1907 | void KABCore::showLicence() | 1907 | void KABCore::showLicence() |
1908 | { | 1908 | { |
1909 | KApplication::showLicence(); | 1909 | KApplication::showLicence(); |
1910 | } | 1910 | } |
1911 | void KABCore::removeVoice() | 1911 | void KABCore::removeVoice() |
1912 | { | 1912 | { |
1913 | 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 ) | 1913 | 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 ) |
1914 | return; | 1914 | return; |
1915 | KABC::Addressee::List list = mViewManager->selectedAddressees(); | 1915 | KABC::Addressee::List list = mViewManager->selectedAddressees(); |
1916 | KABC::Addressee::List::Iterator it; | 1916 | KABC::Addressee::List::Iterator it; |
1917 | for ( it = list.begin(); it != list.end(); ++it ) { | 1917 | for ( it = list.begin(); it != list.end(); ++it ) { |
1918 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); | 1918 | PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); |
1919 | PhoneNumber::List::Iterator phoneIt; | 1919 | PhoneNumber::List::Iterator phoneIt; |
1920 | bool found = false; | 1920 | bool found = false; |
1921 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { | 1921 | for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { |
1922 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found | 1922 | if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found |
1923 | if ((*phoneIt).type() - PhoneNumber::Voice ) { | 1923 | if ((*phoneIt).type() - PhoneNumber::Voice ) { |
1924 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); | 1924 | (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); |
1925 | (*it).insertPhoneNumber( (*phoneIt) ); | 1925 | (*it).insertPhoneNumber( (*phoneIt) ); |
1926 | found = true; | 1926 | found = true; |
1927 | } | 1927 | } |
1928 | } | 1928 | } |
1929 | 1929 | ||
1930 | } | 1930 | } |
1931 | if ( found ) | 1931 | if ( found ) |
1932 | contactModified((*it) ); | 1932 | contactModified((*it) ); |
1933 | } | 1933 | } |
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | 1936 | ||
1937 | 1937 | ||
1938 | void KABCore::clipboardDataChanged() | 1938 | void KABCore::clipboardDataChanged() |
1939 | { | 1939 | { |
1940 | 1940 | ||
1941 | if ( mReadWrite ) | 1941 | if ( mReadWrite ) |
1942 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1942 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1943 | 1943 | ||
1944 | } | 1944 | } |
1945 | 1945 | ||
1946 | void KABCore::updateActionMenu() | 1946 | void KABCore::updateActionMenu() |
1947 | { | 1947 | { |
1948 | UndoStack *undo = UndoStack::instance(); | 1948 | UndoStack *undo = UndoStack::instance(); |
1949 | RedoStack *redo = RedoStack::instance(); | 1949 | RedoStack *redo = RedoStack::instance(); |
1950 | 1950 | ||
1951 | if ( undo->isEmpty() ) | 1951 | if ( undo->isEmpty() ) |
1952 | mActionUndo->setText( i18n( "Undo" ) ); | 1952 | mActionUndo->setText( i18n( "Undo" ) ); |
1953 | else | 1953 | else |
1954 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1954 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1955 | 1955 | ||
1956 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1956 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1957 | 1957 | ||
1958 | if ( !redo->top() ) | 1958 | if ( !redo->top() ) |
1959 | mActionRedo->setText( i18n( "Redo" ) ); | 1959 | mActionRedo->setText( i18n( "Redo" ) ); |
1960 | else | 1960 | else |
1961 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1961 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1962 | 1962 | ||
1963 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1963 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1964 | } | 1964 | } |
1965 | 1965 | ||
1966 | void KABCore::configureKeyBindings() | 1966 | void KABCore::configureKeyBindings() |
1967 | { | 1967 | { |
1968 | #ifndef KAB_EMBEDDED | 1968 | #ifndef KAB_EMBEDDED |
1969 | KKeyDialog::configure( actionCollection(), true ); | 1969 | KKeyDialog::configure( actionCollection(), true ); |
1970 | #else //KAB_EMBEDDED | 1970 | #else //KAB_EMBEDDED |
1971 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1971 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1972 | #endif //KAB_EMBEDDED | 1972 | #endif //KAB_EMBEDDED |
1973 | } | 1973 | } |
1974 | 1974 | ||
1975 | #ifdef KAB_EMBEDDED | 1975 | #ifdef KAB_EMBEDDED |
1976 | void KABCore::configureResources() | 1976 | void KABCore::configureResources() |
1977 | { | 1977 | { |
1978 | KRES::KCMKResources dlg( this, "" , 0 ); | 1978 | KRES::KCMKResources dlg( this, "" , 0 ); |
1979 | 1979 | ||
1980 | if ( !dlg.exec() ) | 1980 | if ( !dlg.exec() ) |
1981 | return; | 1981 | return; |
1982 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1982 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1983 | } | 1983 | } |
1984 | #endif //KAB_EMBEDDED | 1984 | #endif //KAB_EMBEDDED |
1985 | 1985 | ||
1986 | 1986 | ||
1987 | /* this method will be called through the QCop interface from Ko/Pi to select addresses | 1987 | /* this method will be called through the QCop interface from Ko/Pi to select addresses |
1988 | * for the attendees list of an event. | 1988 | * for the attendees list of an event. |
1989 | */ | 1989 | */ |
1990 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) | 1990 | void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) |
1991 | { | 1991 | { |
1992 | QStringList nameList; | 1992 | QStringList nameList; |
1993 | QStringList emailList; | 1993 | QStringList emailList; |
1994 | QStringList uidList; | 1994 | QStringList uidList; |
1995 | 1995 | ||
1996 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 1996 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
1997 | uint i=0; | 1997 | uint i=0; |
1998 | for (i=0; i < list.count(); i++) | 1998 | for (i=0; i < list.count(); i++) |
1999 | { | 1999 | { |
2000 | nameList.append(list[i].realName()); | 2000 | nameList.append(list[i].realName()); |
2001 | emailList.append(list[i].preferredEmail()); | 2001 | emailList.append(list[i].preferredEmail()); |
2002 | uidList.append(list[i].uid()); | 2002 | uidList.append(list[i].uid()); |
2003 | } | 2003 | } |
2004 | 2004 | ||
2005 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); | 2005 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); |
2006 | 2006 | ||
2007 | } | 2007 | } |
2008 | 2008 | ||
2009 | /* this method will be called through the QCop interface from other apps to show details of a contact. | 2009 | /* this method will be called through the QCop interface from other apps to show details of a contact. |
2010 | */ | 2010 | */ |
2011 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) | 2011 | void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) |
2012 | { | 2012 | { |
2013 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); | 2013 | qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); |
2014 | 2014 | ||
2015 | QString foundUid = QString::null; | 2015 | QString foundUid = QString::null; |
2016 | if ( ! uid.isEmpty() ) { | 2016 | if ( ! uid.isEmpty() ) { |
2017 | Addressee adrr = mAddressBook->findByUid( uid ); | 2017 | Addressee adrr = mAddressBook->findByUid( uid ); |
2018 | if ( !adrr.isEmpty() ) { | 2018 | if ( !adrr.isEmpty() ) { |
2019 | foundUid = uid; | 2019 | foundUid = uid; |
2020 | } | 2020 | } |
2021 | if ( email == "sendbacklist" ) { | 2021 | if ( email == "sendbacklist" ) { |
2022 | //qDebug("ssssssssssssssssssssssend "); | 2022 | //qDebug("ssssssssssssssssssssssend "); |
2023 | QStringList nameList; | 2023 | QStringList nameList; |
2024 | QStringList emailList; | 2024 | QStringList emailList; |
2025 | QStringList uidList; | 2025 | QStringList uidList; |
2026 | nameList.append(adrr.realName()); | 2026 | nameList.append(adrr.realName()); |
2027 | emailList = adrr.emails(); | 2027 | emailList = adrr.emails(); |
2028 | uidList.append( adrr.preferredEmail()); | 2028 | uidList.append( adrr.preferredEmail()); |
2029 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 2029 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
2030 | return; | 2030 | return; |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | if ( email == "sendbacklist" ) | 2035 | if ( email == "sendbacklist" ) |
2036 | return; | 2036 | return; |
2037 | if (foundUid.isEmpty()) | 2037 | if (foundUid.isEmpty()) |
2038 | { | 2038 | { |
2039 | //find the uid of the person first | 2039 | //find the uid of the person first |
2040 | Addressee::List namelist; | 2040 | Addressee::List namelist; |
2041 | Addressee::List emaillist; | 2041 | Addressee::List emaillist; |
2042 | 2042 | ||
2043 | if (!name.isEmpty()) | 2043 | if (!name.isEmpty()) |
2044 | namelist = mAddressBook->findByName( name ); | 2044 | namelist = mAddressBook->findByName( name ); |
2045 | 2045 | ||
2046 | if (!email.isEmpty()) | 2046 | if (!email.isEmpty()) |
2047 | emaillist = mAddressBook->findByEmail( email ); | 2047 | emaillist = mAddressBook->findByEmail( email ); |
2048 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); | 2048 | qDebug("count %d %d ", namelist.count(),emaillist.count() ); |
2049 | //check if we have a match in Namelist and Emaillist | 2049 | //check if we have a match in Namelist and Emaillist |
2050 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { | 2050 | if ((namelist.count() == 0) && (emaillist.count() > 0)) { |
2051 | foundUid = emaillist[0].uid(); | 2051 | foundUid = emaillist[0].uid(); |
2052 | } | 2052 | } |
2053 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) | 2053 | else if ((namelist.count() > 0) && (emaillist.count() == 0)) |
2054 | foundUid = namelist[0].uid(); | 2054 | foundUid = namelist[0].uid(); |
2055 | else | 2055 | else |
2056 | { | 2056 | { |
2057 | for (int i = 0; i < namelist.count(); i++) | 2057 | for (int i = 0; i < namelist.count(); i++) |
2058 | { | 2058 | { |
2059 | for (int j = 0; j < emaillist.count(); j++) | 2059 | for (int j = 0; j < emaillist.count(); j++) |
2060 | { | 2060 | { |
2061 | if (namelist[i] == emaillist[j]) | 2061 | if (namelist[i] == emaillist[j]) |
2062 | { | 2062 | { |
2063 | foundUid = namelist[i].uid(); | 2063 | foundUid = namelist[i].uid(); |
2064 | } | 2064 | } |
2065 | } | 2065 | } |
2066 | } | 2066 | } |
2067 | } | 2067 | } |
2068 | } | 2068 | } |
2069 | else | 2069 | else |
2070 | { | 2070 | { |
2071 | foundUid = uid; | 2071 | foundUid = uid; |
2072 | } | 2072 | } |
2073 | 2073 | ||
2074 | if (!foundUid.isEmpty()) | 2074 | if (!foundUid.isEmpty()) |
2075 | { | 2075 | { |
2076 | 2076 | ||
2077 | // raise Ka/Pi if it is in the background | 2077 | // raise Ka/Pi if it is in the background |
2078 | #ifndef DESKTOP_VERSION | 2078 | #ifndef DESKTOP_VERSION |
2079 | #ifndef KORG_NODCOP | 2079 | #ifndef KORG_NODCOP |
2080 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); | 2080 | //QCopEnvelope e("QPE/Application/kapi", "raise()"); |
2081 | #endif | 2081 | #endif |
2082 | #endif | 2082 | #endif |
2083 | 2083 | ||
2084 | mMainWindow->showMaximized(); | 2084 | mMainWindow->showMaximized(); |
2085 | mMainWindow-> raise(); | 2085 | mMainWindow-> raise(); |
2086 | 2086 | ||
2087 | mViewManager->setSelected( "", false); | 2087 | mViewManager->setSelected( "", false); |
2088 | mViewManager->refreshView( "" ); | 2088 | mViewManager->refreshView( "" ); |
2089 | mViewManager->setSelected( foundUid, true ); | 2089 | mViewManager->setSelected( foundUid, true ); |
2090 | mViewManager->refreshView( foundUid ); | 2090 | mViewManager->refreshView( foundUid ); |
2091 | 2091 | ||
2092 | if ( !mMultipleViewsAtOnce ) | 2092 | if ( !mMultipleViewsAtOnce ) |
2093 | { | 2093 | { |
2094 | setDetailsVisible( true ); | 2094 | setDetailsVisible( true ); |
2095 | mActionDetails->setChecked(true); | 2095 | mActionDetails->setChecked(true); |
2096 | } | 2096 | } |
2097 | } | 2097 | } |
2098 | } | 2098 | } |
2099 | 2099 | ||
2100 | 2100 | ||
2101 | void KABCore::faq() | 2101 | void KABCore::faq() |
2102 | { | 2102 | { |
2103 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); | 2103 | KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); |
2104 | } | 2104 | } |
2105 | 2105 | ||
2106 | 2106 | ||
2107 | void KABCore::fillSyncMenu() | 2107 | void KABCore::fillSyncMenu() |
2108 | { | 2108 | { |
2109 | if ( syncMenu->count() ) | 2109 | if ( syncMenu->count() ) |
2110 | syncMenu->clear(); | 2110 | syncMenu->clear(); |
2111 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 2111 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
2112 | syncMenu->insertSeparator(); | 2112 | syncMenu->insertSeparator(); |
2113 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 2113 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
2114 | syncMenu->insertSeparator(); | 2114 | syncMenu->insertSeparator(); |
2115 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2115 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2116 | config.setGroup("General"); | 2116 | config.setGroup("General"); |
2117 | QStringList prof = config.readListEntry("SyncProfileNames"); | 2117 | QStringList prof = config.readListEntry("SyncProfileNames"); |
2118 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 2118 | KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
2119 | if ( prof.count() < 3 ) { | 2119 | if ( prof.count() < 3 ) { |
2120 | prof.clear(); | 2120 | prof.clear(); |
2121 | prof << i18n("Sharp_DTM"); | 2121 | prof << i18n("Sharp_DTM"); |
2122 | prof << i18n("Local_file"); | 2122 | prof << i18n("Local_file"); |
2123 | prof << i18n("Last_file"); | 2123 | prof << i18n("Last_file"); |
2124 | KSyncProfile* temp = new KSyncProfile (); | 2124 | KSyncProfile* temp = new KSyncProfile (); |
2125 | temp->setName( prof[0] ); | 2125 | temp->setName( prof[0] ); |
2126 | temp->writeConfig(&config); | 2126 | temp->writeConfig(&config); |
2127 | temp->setName( prof[1] ); | 2127 | temp->setName( prof[1] ); |
2128 | temp->writeConfig(&config); | 2128 | temp->writeConfig(&config); |
2129 | temp->setName( prof[2] ); | 2129 | temp->setName( prof[2] ); |
2130 | temp->writeConfig(&config); | 2130 | temp->writeConfig(&config); |
2131 | config.setGroup("General"); | 2131 | config.setGroup("General"); |
2132 | config.writeEntry("SyncProfileNames",prof); | 2132 | config.writeEntry("SyncProfileNames",prof); |
2133 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 2133 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
2134 | config.sync(); | 2134 | config.sync(); |
2135 | delete temp; | 2135 | delete temp; |
2136 | } | 2136 | } |
2137 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 2137 | KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
2138 | KABPrefs::instance()->mSyncProfileNames = prof; | 2138 | KABPrefs::instance()->mSyncProfileNames = prof; |
2139 | int i; | 2139 | int i; |
2140 | for ( i = 0; i < prof.count(); ++i ) { | 2140 | for ( i = 0; i < prof.count(); ++i ) { |
2141 | 2141 | ||
2142 | syncMenu->insertItem( prof[i], 1000+i ); | 2142 | syncMenu->insertItem( prof[i], 1000+i ); |
2143 | if ( i == 2 ) | 2143 | if ( i == 2 ) |
2144 | syncMenu->insertSeparator(); | 2144 | syncMenu->insertSeparator(); |
2145 | } | 2145 | } |
2146 | QDir app_dir; | 2146 | QDir app_dir; |
2147 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 2147 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
2148 | syncMenu->setItemEnabled( false , 1000 ); | 2148 | syncMenu->setItemEnabled( false , 1000 ); |
2149 | } | 2149 | } |
2150 | //probaly useless | 2150 | //probaly useless |
2151 | //mView->setupExternSyncProfiles(); | 2151 | //mView->setupExternSyncProfiles(); |
2152 | } | 2152 | } |
2153 | void KABCore::slotSyncMenu( int action ) | 2153 | void KABCore::slotSyncMenu( int action ) |
2154 | { | 2154 | { |
2155 | //qDebug("syncaction %d ", action); | 2155 | //qDebug("syncaction %d ", action); |
2156 | if ( action == 0 ) { | 2156 | if ( action == 0 ) { |
2157 | 2157 | ||
2158 | // seems to be a Qt2 event handling bug | 2158 | // seems to be a Qt2 event handling bug |
2159 | // syncmenu.clear causes a segfault at first time | 2159 | // syncmenu.clear causes a segfault at first time |
2160 | // when we call it after the main event loop, it is ok | 2160 | // when we call it after the main event loop, it is ok |
2161 | // same behaviour when calling OM/Pi via QCOP for the first time | 2161 | // same behaviour when calling OM/Pi via QCOP for the first time |
2162 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 2162 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
2163 | //confSync(); | 2163 | //confSync(); |
2164 | 2164 | ||
2165 | return; | 2165 | return; |
2166 | } | 2166 | } |
2167 | if ( action == 1 ) { | 2167 | if ( action == 1 ) { |
2168 | multiSync( true ); | 2168 | multiSync( true ); |
2169 | return; | 2169 | return; |
2170 | } | 2170 | } |
2171 | 2171 | ||
2172 | if (mBlockSaveFlag) | 2172 | if (mBlockSaveFlag) |
2173 | return; | 2173 | return; |
2174 | mBlockSaveFlag = true; | 2174 | mBlockSaveFlag = true; |
2175 | mCurrentSyncProfile = action - 1000 ; | 2175 | mCurrentSyncProfile = action - 1000 ; |
2176 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; | 2176 | mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; |
2177 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; | 2177 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; |
2178 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2178 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2179 | KSyncProfile* temp = new KSyncProfile (); | 2179 | KSyncProfile* temp = new KSyncProfile (); |
2180 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2180 | temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2181 | temp->readConfig(&config); | 2181 | temp->readConfig(&config); |
2182 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2182 | KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2183 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 2183 | KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
2184 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2184 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2185 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2185 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2186 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2186 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2187 | if ( temp->getWriteBackFuture() ) | 2187 | if ( temp->getWriteBackFuture() ) |
2188 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2188 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2189 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 2189 | KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
2190 | if ( action == 1000 ) { | 2190 | if ( action == 1000 ) { |
2191 | syncSharp(); | 2191 | syncSharp(); |
2192 | 2192 | ||
2193 | } else if ( action == 1001 ) { | 2193 | } else if ( action == 1001 ) { |
2194 | syncLocalFile(); | 2194 | syncLocalFile(); |
2195 | 2195 | ||
2196 | } else if ( action == 1002 ) { | 2196 | } else if ( action == 1002 ) { |
2197 | quickSyncLocalFile(); | 2197 | quickSyncLocalFile(); |
2198 | 2198 | ||
2199 | } else if ( action >= 1003 ) { | 2199 | } else if ( action >= 1003 ) { |
2200 | if ( temp->getIsLocalFileSync() ) { | 2200 | if ( temp->getIsLocalFileSync() ) { |
2201 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) | 2201 | if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) |
2202 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2202 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2203 | } else { | 2203 | } else { |
2204 | if ( temp->getIsPhoneSync() ) { | 2204 | if ( temp->getIsPhoneSync() ) { |
2205 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2205 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2206 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2206 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2207 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2207 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2208 | syncPhone(); | 2208 | syncPhone(); |
2209 | } else | 2209 | } else |
2210 | syncRemote( temp ); | 2210 | syncRemote( temp ); |
2211 | 2211 | ||
2212 | } | 2212 | } |
2213 | } | 2213 | } |
2214 | delete temp; | 2214 | delete temp; |
2215 | mBlockSaveFlag = false; | 2215 | mBlockSaveFlag = false; |
2216 | } | 2216 | } |
2217 | 2217 | ||
2218 | void KABCore::syncLocalFile() | 2218 | void KABCore::syncLocalFile() |
2219 | { | 2219 | { |
2220 | 2220 | ||
2221 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; | 2221 | QString fn =KABPrefs::instance()->mLastSyncedLocalFile; |
2222 | 2222 | ||
2223 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2223 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2224 | if ( fn == "" ) | 2224 | if ( fn == "" ) |
2225 | return; | 2225 | return; |
2226 | if ( syncWithFile( fn, false ) ) { | 2226 | if ( syncWithFile( fn, false ) ) { |
2227 | qDebug("syncLocalFile() successful "); | 2227 | qDebug("syncLocalFile() successful "); |
2228 | } | 2228 | } |
2229 | 2229 | ||
2230 | } | 2230 | } |
2231 | bool KABCore::syncWithFile( QString fn , bool quick ) | 2231 | bool KABCore::syncWithFile( QString fn , bool quick ) |
2232 | { | 2232 | { |
2233 | bool ret = false; | 2233 | bool ret = false; |
2234 | QFileInfo info; | 2234 | QFileInfo info; |
2235 | info.setFile( fn ); | 2235 | info.setFile( fn ); |
2236 | QString mess; | 2236 | QString mess; |
2237 | bool loadbup = true; | 2237 | bool loadbup = true; |
2238 | if ( !info. exists() ) { | 2238 | if ( !info. exists() ) { |
2239 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2239 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2240 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2240 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2241 | mess ); | 2241 | mess ); |
2242 | return ret; | 2242 | return ret; |
2243 | } | 2243 | } |
2244 | int result = 0; | 2244 | int result = 0; |
2245 | if ( !quick ) { | 2245 | if ( !quick ) { |
2246 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2246 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2247 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2247 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2248 | mess, | 2248 | mess, |
2249 | i18n("Sync"), i18n("Cancel"), 0, | 2249 | i18n("Sync"), i18n("Cancel"), 0, |
2250 | 0, 1 ); | 2250 | 0, 1 ); |
2251 | if ( result ) | 2251 | if ( result ) |
2252 | return false; | 2252 | return false; |
2253 | } | 2253 | } |
2254 | if ( KABPrefs::instance()->mAskForPreferences ) | 2254 | if ( KABPrefs::instance()->mAskForPreferences ) |
2255 | edit_sync_options(); | 2255 | edit_sync_options(); |
2256 | if ( result == 0 ) { | 2256 | if ( result == 0 ) { |
2257 | //qDebug("Now sycing ... "); | 2257 | //qDebug("Now sycing ... "); |
2258 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) | 2258 | if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) |
2259 | setCaption( i18n("Synchronization successful") ); | 2259 | setCaption( i18n("Synchronization successful") ); |
2260 | else | 2260 | else |
2261 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2261 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2262 | if ( ! quick ) | 2262 | if ( ! quick ) |
2263 | KABPrefs::instance()->mLastSyncedLocalFile = fn; | 2263 | KABPrefs::instance()->mLastSyncedLocalFile = fn; |
2264 | setModified(); | 2264 | setModified(); |
2265 | } | 2265 | } |
2266 | return ret; | 2266 | return ret; |
2267 | } | 2267 | } |
2268 | void KABCore::quickSyncLocalFile() | 2268 | void KABCore::quickSyncLocalFile() |
2269 | { | 2269 | { |
2270 | 2270 | ||
2271 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2271 | if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2272 | qDebug("quick syncLocalFile() successful "); | 2272 | qDebug("quick syncLocalFile() successful "); |
2273 | 2273 | ||
2274 | } | 2274 | } |
2275 | } | 2275 | } |
2276 | void KABCore::multiSync( bool askforPrefs ) | 2276 | void KABCore::multiSync( bool askforPrefs ) |
2277 | { | 2277 | { |
2278 | if (mBlockSaveFlag) | 2278 | if (mBlockSaveFlag) |
2279 | return; | 2279 | return; |
2280 | mBlockSaveFlag = true; | 2280 | mBlockSaveFlag = true; |
2281 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 2281 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
2282 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2282 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2283 | question, | 2283 | question, |
2284 | i18n("Yes"), i18n("No"), | 2284 | i18n("Yes"), i18n("No"), |
2285 | 0, 0 ) != 0 ) { | 2285 | 0, 0 ) != 0 ) { |
2286 | mBlockSaveFlag = false; | 2286 | mBlockSaveFlag = false; |
2287 | setCaption(i18n("Aborted! Nothing synced!")); | 2287 | setCaption(i18n("Aborted! Nothing synced!")); |
2288 | return; | 2288 | return; |
2289 | } | 2289 | } |
2290 | mCurrentSyncDevice = i18n("Multiple profiles") ; | 2290 | mCurrentSyncDevice = i18n("Multiple profiles") ; |
2291 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; | 2291 | KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; |
2292 | if ( askforPrefs ) { | 2292 | if ( askforPrefs ) { |
2293 | edit_sync_options(); | 2293 | edit_sync_options(); |
2294 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; | 2294 | KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; |
2295 | } | 2295 | } |
2296 | setCaption(i18n("Multiple sync started.") ); | 2296 | setCaption(i18n("Multiple sync started.") ); |
2297 | qApp->processEvents(); | 2297 | qApp->processEvents(); |
2298 | int num = ringSync() ; | 2298 | int num = ringSync() ; |
2299 | if ( num > 1 ) | 2299 | if ( num > 1 ) |
2300 | ringSync(); | 2300 | ringSync(); |
2301 | mBlockSaveFlag = false; | 2301 | mBlockSaveFlag = false; |
2302 | if ( num ) | 2302 | if ( num ) |
2303 | save(); | 2303 | save(); |
2304 | if ( num ) | 2304 | if ( num ) |
2305 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 2305 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
2306 | else | 2306 | else |
2307 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 2307 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
2308 | return; | 2308 | return; |
2309 | } | 2309 | } |
2310 | int KABCore::ringSync() | 2310 | int KABCore::ringSync() |
2311 | { | 2311 | { |
2312 | int syncedProfiles = 0; | 2312 | int syncedProfiles = 0; |
2313 | int i; | 2313 | int i; |
2314 | QTime timer; | 2314 | QTime timer; |
2315 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 2315 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
2316 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; | 2316 | QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; |
2317 | KSyncProfile* temp = new KSyncProfile (); | 2317 | KSyncProfile* temp = new KSyncProfile (); |
2318 | KABPrefs::instance()->mAskForPreferences = false; | 2318 | KABPrefs::instance()->mAskForPreferences = false; |
2319 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 2319 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
2320 | mCurrentSyncProfile = i; | 2320 | mCurrentSyncProfile = i; |
2321 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 2321 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
2322 | temp->readConfig(&config); | 2322 | temp->readConfig(&config); |
2323 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { | 2323 | if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { |
2324 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 2324 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
2325 | ++syncedProfiles; | 2325 | ++syncedProfiles; |
2326 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 2326 | // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
2327 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 2327 | KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
2328 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 2328 | KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
2329 | KABPrefs::instance()->mWriteBackInFuture = 0; | 2329 | KABPrefs::instance()->mWriteBackInFuture = 0; |
2330 | if ( temp->getWriteBackFuture() ) | 2330 | if ( temp->getWriteBackFuture() ) |
2331 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 2331 | KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
2332 | KABPrefs::instance()->mShowSyncSummary = false; | 2332 | KABPrefs::instance()->mShowSyncSummary = false; |
2333 | mCurrentSyncDevice = syncProfileNames[i] ; | 2333 | mCurrentSyncDevice = syncProfileNames[i] ; |
2334 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; | 2334 | mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; |
2335 | if ( i == 0 ) { | 2335 | if ( i == 0 ) { |
2336 | syncSharp(); | 2336 | syncSharp(); |
2337 | } else { | 2337 | } else { |
2338 | if ( temp->getIsLocalFileSync() ) { | 2338 | if ( temp->getIsLocalFileSync() ) { |
2339 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) | 2339 | if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) |
2340 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); | 2340 | KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); |
2341 | } else { | 2341 | } else { |
2342 | if ( temp->getIsPhoneSync() ) { | 2342 | if ( temp->getIsPhoneSync() ) { |
2343 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 2343 | KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
2344 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 2344 | KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
2345 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 2345 | KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
2346 | syncPhone(); | 2346 | syncPhone(); |
2347 | } else | 2347 | } else |
2348 | syncRemote( temp, false ); | 2348 | syncRemote( temp, false ); |
2349 | 2349 | ||
2350 | } | 2350 | } |
2351 | } | 2351 | } |
2352 | timer.start(); | 2352 | timer.start(); |
2353 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 2353 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
2354 | while ( timer.elapsed () < 2000 ) { | 2354 | while ( timer.elapsed () < 2000 ) { |
2355 | qApp->processEvents(); | 2355 | qApp->processEvents(); |
2356 | #ifndef _WIN32_ | 2356 | #ifndef _WIN32_ |
2357 | sleep (1); | 2357 | sleep (1); |
2358 | #endif | 2358 | #endif |
2359 | } | 2359 | } |
2360 | 2360 | ||
2361 | } | 2361 | } |
2362 | 2362 | ||
2363 | } | 2363 | } |
2364 | delete temp; | 2364 | delete temp; |
2365 | return syncedProfiles; | 2365 | return syncedProfiles; |
2366 | } | 2366 | } |
2367 | 2367 | ||
2368 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) | 2368 | void KABCore::syncRemote( KSyncProfile* prof, bool ask) |
2369 | { | 2369 | { |
2370 | QString question; | 2370 | QString question; |
2371 | if ( ask ) { | 2371 | if ( ask ) { |
2372 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2372 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2373 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2373 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2374 | question, | 2374 | question, |
2375 | i18n("Yes"), i18n("No"), | 2375 | i18n("Yes"), i18n("No"), |
2376 | 0, 0 ) != 0 ) | 2376 | 0, 0 ) != 0 ) |
2377 | return; | 2377 | return; |
2378 | } | 2378 | } |
2379 | QString command = prof->getPreSyncCommandAB(); | 2379 | QString command = prof->getPreSyncCommandAB(); |
2380 | int fi; | 2380 | int fi; |
2381 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2381 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2382 | QString pwd = getPassword(); | 2382 | QString pwd = getPassword(); |
2383 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2383 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2384 | 2384 | ||
2385 | } | 2385 | } |
2386 | int maxlen = 30; | 2386 | int maxlen = 30; |
2387 | if ( QApplication::desktop()->width() > 320 ) | 2387 | if ( QApplication::desktop()->width() > 320 ) |
2388 | maxlen += 25; | 2388 | maxlen += 25; |
2389 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2389 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2390 | int fileSize = 0; | 2390 | int fileSize = 0; |
2391 | int result = system ( command ); | 2391 | int result = system ( command ); |
2392 | // 0 : okay | 2392 | // 0 : okay |
2393 | // 256: no such file or dir | 2393 | // 256: no such file or dir |
2394 | // | 2394 | // |
2395 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2395 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2396 | if ( result != 0 ) { | 2396 | if ( result != 0 ) { |
2397 | int len = maxlen; | 2397 | int len = maxlen; |
2398 | while ( len < command.length() ) { | 2398 | while ( len < command.length() ) { |
2399 | command.insert( len , "\n" ); | 2399 | command.insert( len , "\n" ); |
2400 | len += maxlen +2; | 2400 | len += maxlen +2; |
2401 | } | 2401 | } |
2402 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2402 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2403 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2403 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2404 | question, | 2404 | question, |
2405 | i18n("Okay!")) ; | 2405 | i18n("Okay!")) ; |
2406 | setCaption ("KO/Pi"); | 2406 | setCaption ("KO/Pi"); |
2407 | return; | 2407 | return; |
2408 | } | 2408 | } |
2409 | setCaption ( i18n( "Copying succeed." ) ); | 2409 | setCaption ( i18n( "Copying succeed." ) ); |
2410 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2410 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2411 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { | 2411 | if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { |
2412 | // Event* e = mView->getLastSyncEvent(); | 2412 | // Event* e = mView->getLastSyncEvent(); |
2413 | // e->setReadOnly( false ); | 2413 | // e->setReadOnly( false ); |
2414 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2414 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2415 | // e->setReadOnly( true ); | 2415 | // e->setReadOnly( true ); |
2416 | if ( KABPrefs::instance()->mWriteBackFile ) { | 2416 | if ( KABPrefs::instance()->mWriteBackFile ) { |
2417 | command = prof->getPostSyncCommandAB(); | 2417 | command = prof->getPostSyncCommandAB(); |
2418 | int fi; | 2418 | int fi; |
2419 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2419 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2420 | QString pwd = getPassword(); | 2420 | QString pwd = getPassword(); |
2421 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2421 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2422 | 2422 | ||
2423 | } | 2423 | } |
2424 | setCaption ( i18n( "Writing back file ..." ) ); | 2424 | setCaption ( i18n( "Writing back file ..." ) ); |
2425 | result = system ( command ); | 2425 | result = system ( command ); |
2426 | qDebug("KO: Writing back file result: %d ", result); | 2426 | qDebug("KO: Writing back file result: %d ", result); |
2427 | if ( result != 0 ) { | 2427 | if ( result != 0 ) { |
2428 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2428 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2429 | return; | 2429 | return; |
2430 | } else { | 2430 | } else { |
2431 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2431 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2432 | } | 2432 | } |
2433 | } | 2433 | } |
2434 | } | 2434 | } |
2435 | return; | 2435 | return; |
2436 | } | 2436 | } |
2437 | #include <qpushbutton.h> | 2437 | #include <qpushbutton.h> |
2438 | #include <qradiobutton.h> | 2438 | #include <qradiobutton.h> |
2439 | #include <qbuttongroup.h> | 2439 | #include <qbuttongroup.h> |
2440 | void KABCore::edit_sync_options() | 2440 | void KABCore::edit_sync_options() |
2441 | { | 2441 | { |
2442 | //mDialogManager->showSyncOptions(); | 2442 | //mDialogManager->showSyncOptions(); |
2443 | //KABPrefs::instance()->mSyncAlgoPrefs | 2443 | //KABPrefs::instance()->mSyncAlgoPrefs |
2444 | QDialog dia( this, "dia", true ); | 2444 | QDialog dia( this, "dia", true ); |
2445 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2445 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2446 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2446 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2447 | QVBoxLayout lay ( &dia ); | 2447 | QVBoxLayout lay ( &dia ); |
2448 | lay.setSpacing( 2 ); | 2448 | lay.setSpacing( 2 ); |
2449 | lay.setMargin( 3 ); | 2449 | lay.setMargin( 3 ); |
2450 | lay.addWidget(&gr); | 2450 | lay.addWidget(&gr); |
2451 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2451 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2452 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2452 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2453 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2453 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2454 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2454 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2455 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2455 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2456 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2456 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2457 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2457 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2458 | QPushButton pb ( "OK", &dia); | 2458 | QPushButton pb ( "OK", &dia); |
2459 | lay.addWidget( &pb ); | 2459 | lay.addWidget( &pb ); |
2460 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2460 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2461 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { | 2461 | switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { |
2462 | case 0: | 2462 | case 0: |
2463 | loc.setChecked( true); | 2463 | loc.setChecked( true); |
2464 | break; | 2464 | break; |
2465 | case 1: | 2465 | case 1: |
2466 | rem.setChecked( true ); | 2466 | rem.setChecked( true ); |
2467 | break; | 2467 | break; |
2468 | case 2: | 2468 | case 2: |
2469 | newest.setChecked( true); | 2469 | newest.setChecked( true); |
2470 | break; | 2470 | break; |
2471 | case 3: | 2471 | case 3: |
2472 | ask.setChecked( true); | 2472 | ask.setChecked( true); |
2473 | break; | 2473 | break; |
2474 | case 4: | 2474 | case 4: |
2475 | f_loc.setChecked( true); | 2475 | f_loc.setChecked( true); |
2476 | break; | 2476 | break; |
2477 | case 5: | 2477 | case 5: |
2478 | f_rem.setChecked( true); | 2478 | f_rem.setChecked( true); |
2479 | break; | 2479 | break; |
2480 | case 6: | 2480 | case 6: |
2481 | // both.setChecked( true); | 2481 | // both.setChecked( true); |
2482 | break; | 2482 | break; |
2483 | default: | 2483 | default: |
2484 | break; | 2484 | break; |
2485 | } | 2485 | } |
2486 | if ( dia.exec() ) { | 2486 | if ( dia.exec() ) { |
2487 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2487 | KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2488 | } | 2488 | } |
2489 | 2489 | ||
2490 | 2490 | ||
2491 | } | 2491 | } |
2492 | QString KABCore::getPassword( ) | 2492 | QString KABCore::getPassword( ) |
2493 | { | 2493 | { |
2494 | QString retfile = ""; | 2494 | QString retfile = ""; |
2495 | QDialog dia ( this, "input-dialog", true ); | 2495 | QDialog dia ( this, "input-dialog", true ); |
2496 | QLineEdit lab ( &dia ); | 2496 | QLineEdit lab ( &dia ); |
2497 | lab.setEchoMode( QLineEdit::Password ); | 2497 | lab.setEchoMode( QLineEdit::Password ); |
2498 | QVBoxLayout lay( &dia ); | 2498 | QVBoxLayout lay( &dia ); |
2499 | lay.setMargin(7); | 2499 | lay.setMargin(7); |
2500 | lay.setSpacing(7); | 2500 | lay.setSpacing(7); |
2501 | lay.addWidget( &lab); | 2501 | lay.addWidget( &lab); |
2502 | dia.setFixedSize( 230,50 ); | 2502 | dia.setFixedSize( 230,50 ); |
2503 | dia.setCaption( i18n("Enter password") ); | 2503 | dia.setCaption( i18n("Enter password") ); |
2504 | QPushButton pb ( "OK", &dia); | 2504 | QPushButton pb ( "OK", &dia); |
2505 | lay.addWidget( &pb ); | 2505 | lay.addWidget( &pb ); |
2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2506 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2507 | dia.show(); | 2507 | dia.show(); |
2508 | int res = dia.exec(); | 2508 | int res = dia.exec(); |
2509 | if ( res ) | 2509 | if ( res ) |
2510 | retfile = lab.text(); | 2510 | retfile = lab.text(); |
2511 | dia.hide(); | 2511 | dia.hide(); |
2512 | qApp->processEvents(); | 2512 | qApp->processEvents(); |
2513 | return retfile; | 2513 | return retfile; |
2514 | 2514 | ||
2515 | } | 2515 | } |
2516 | #include <libkcal/syncdefines.h> | ||
2517 | |||
2518 | KABC::Addressee KABCore::getLastSyncAddressee() | ||
2519 | { | ||
2520 | Addressee lse; | ||
2521 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | ||
2522 | lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); | ||
2523 | if (lse.isEmpty()) { | ||
2524 | lse.setUid( "last-syncEvent-"+mCurrentSyncDevice ); | ||
2525 | QString sum = ""; | ||
2526 | if ( KABPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | ||
2527 | sum = "E: "; | ||
2528 | lse.setFamilyName(sum+mCurrentSyncDevice + i18n(" - sync event")); | ||
2529 | lse.setRevision( mLastAddressbookSync ); | ||
2530 | lse.setCategories( i18n("SyncEvent") ); | ||
2531 | mAddressBook->insertAddressee( lse ); | ||
2532 | } | ||
2533 | return lse; | ||
2534 | } | ||
2535 | |||
2516 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) | 2536 | bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) |
2517 | { | 2537 | { |
2518 | #if 0 | ||
2519 | bool syncOK = true; | 2538 | bool syncOK = true; |
2520 | int addedAddressee = 0; | 2539 | int addedAddressee = 0; |
2521 | int addedAddresseeR = 0; | 2540 | int addedAddresseeR = 0; |
2522 | int deletedAddresseeR = 0; | 2541 | int deletedAddresseeR = 0; |
2523 | int deletedAddresseeL = 0; | 2542 | int deletedAddresseeL = 0; |
2524 | int changedLocal = 0; | 2543 | int changedLocal = 0; |
2525 | int changedRemote = 0; | 2544 | int changedRemote = 0; |
2526 | //QPtrList<Addressee> el = local->rawAddressees(); | 2545 | //QPtrList<Addressee> el = local->rawAddressees(); |
2527 | Addressee* addresseeR; | 2546 | Addressee addresseeR; |
2528 | QString uid; | 2547 | QString uid; |
2529 | int take; | 2548 | int take; |
2530 | Addressee* addresseeL; | 2549 | Addressee addresseeL; |
2531 | Addressee* addresseeRSync; | 2550 | Addressee addresseeRSync; |
2532 | Addressee* addresseeLSync; | 2551 | Addressee addresseeLSync; |
2533 | QPtrList<Addressee> addresseeRSyncSharp = remote->getExternLastSyncAddressees(); | 2552 | KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); |
2534 | QPtrList<Addressee> addresseeLSyncSharp = local->getExternLastSyncAddressees(); | 2553 | KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); |
2535 | bool fullDateRange = false; | 2554 | bool fullDateRange = false; |
2536 | local->resetTempSyncStat(); | 2555 | local->resetTempSyncStat(); |
2537 | mLastCalendarSync = QDateTime::currentDateTime(); | 2556 | mLastAddressbookSync = QDateTime::currentDateTime(); |
2538 | QDateTime modifiedCalendar = mLastCalendarSync;; | 2557 | QDateTime modifiedCalendar = mLastAddressbookSync;; |
2539 | addresseeLSync = getLastSyncAddressee(); | 2558 | addresseeLSync = getLastSyncAddressee(); |
2540 | addresseeR = remote->addressee("last-syncAddressee-"+mCurrentSyncName ); | 2559 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2541 | if ( addresseeR ) { | 2560 | if ( !addresseeR.isEmpty() ) { |
2542 | addresseeRSync = (Addressee*) addresseeR->clone(); | 2561 | addresseeRSync = addresseeR; |
2543 | remote->deleteAddressee(addresseeR ); | 2562 | remote->removeAddressee(addresseeR ); |
2544 | 2563 | ||
2545 | } else { | 2564 | } else { |
2546 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2565 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2547 | addresseeRSync = (Addressee*)addresseeLSync->clone(); | 2566 | addresseeRSync = addresseeLSync ; |
2548 | } else { | 2567 | } else { |
2549 | fullDateRange = true; | 2568 | fullDateRange = true; |
2550 | addresseeRSync = new Addressee(); | 2569 | Addressee newAdd; |
2551 | addresseeRSync->setSummary(mCurrentSyncName + i18n(" - sync addressee")); | 2570 | addresseeRSync = newAdd; |
2552 | addresseeRSync->setUid("last-syncAddressee-"+mCurrentSyncName ); | 2571 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2553 | addresseeRSync->setDtStart( mLastCalendarSync ); | 2572 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2554 | addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 2573 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2555 | addresseeRSync->setCategories( i18n("SyncAddressee") ); | 2574 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2556 | } | 2575 | } |
2557 | } | 2576 | } |
2558 | if ( addresseeLSync->dtStart() == mLastCalendarSync ) | 2577 | if ( addresseeLSync.revision() == mLastAddressbookSync ) |
2559 | fullDateRange = true; | 2578 | fullDateRange = true; |
2560 | |||
2561 | if ( ! fullDateRange ) { | 2579 | if ( ! fullDateRange ) { |
2562 | if ( addresseeLSync->dtStart() != addresseeRSync->dtStart() ) { | 2580 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2563 | 2581 | ||
2564 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2582 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2565 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2583 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2566 | fullDateRange = true; | 2584 | fullDateRange = true; |
2567 | } | 2585 | } |
2568 | } | 2586 | } |
2569 | if ( fullDateRange ) | 2587 | if ( fullDateRange ) |
2570 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 2588 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2571 | else | 2589 | else |
2572 | mLastCalendarSync = addresseeLSync->dtStart(); | 2590 | mLastAddressbookSync = addresseeLSync.revision(); |
2573 | // for resyncing if own file has changed | 2591 | // for resyncing if own file has changed |
2592 | // PENDING fixme later when implemented | ||
2593 | #if 0 | ||
2574 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2594 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2575 | mLastCalendarSync = loadedFileVersion; | 2595 | mLastAddressbookSync = loadedFileVersion; |
2576 | qDebug("setting mLastCalendarSync "); | 2596 | qDebug("setting mLastAddressbookSync "); |
2577 | } | 2597 | } |
2598 | #endif | ||
2599 | |||
2600 | #if 0 | ||
2578 | //qDebug("*************************** "); | 2601 | //qDebug("*************************** "); |
2579 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 2602 | qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2580 | QPtrList<Incidence> er = remote->rawIncidences(); | 2603 | QPtrList<Incidence> er = remote->rawIncidences(); |
2581 | Incidence* inR = er.first(); | 2604 | Incidence* inR = er.first(); |
2582 | Incidence* inL; | 2605 | Incidence* inL; |
2583 | QProgressBar bar( er.count(),0 ); | 2606 | QProgressBar bar( er.count(),0 ); |
2584 | bar.setCaption (i18n("Syncing - close to abort!") ); | 2607 | bar.setCaption (i18n("Syncing - close to abort!") ); |
2585 | 2608 | ||
2586 | int w = 300; | 2609 | int w = 300; |
2587 | if ( QApplication::desktop()->width() < 320 ) | 2610 | if ( QApplication::desktop()->width() < 320 ) |
2588 | w = 220; | 2611 | w = 220; |
2589 | int h = bar.sizeHint().height() ; | 2612 | int h = bar.sizeHint().height() ; |
2590 | int dw = QApplication::desktop()->width(); | 2613 | int dw = QApplication::desktop()->width(); |
2591 | int dh = QApplication::desktop()->height(); | 2614 | int dh = QApplication::desktop()->height(); |
2592 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2615 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2593 | bar.show(); | 2616 | bar.show(); |
2594 | int modulo = (er.count()/10)+1; | 2617 | int modulo = (er.count()/10)+1; |
2595 | int incCounter = 0; | 2618 | int incCounter = 0; |
2596 | while ( inR ) { | 2619 | while ( inR ) { |
2597 | if ( ! bar.isVisible() ) | 2620 | if ( ! bar.isVisible() ) |
2598 | return false; | 2621 | return false; |
2599 | if ( incCounter % modulo == 0 ) | 2622 | if ( incCounter % modulo == 0 ) |
2600 | bar.setProgress( incCounter ); | 2623 | bar.setProgress( incCounter ); |
2601 | ++incCounter; | 2624 | ++incCounter; |
2602 | uid = inR->uid(); | 2625 | uid = inR->uid(); |
2603 | bool skipIncidence = false; | 2626 | bool skipIncidence = false; |
2604 | if ( uid.left(15) == QString("last-syncAddressee-") ) | 2627 | if ( uid.left(15) == QString("last-syncAddressee-") ) |
2605 | skipIncidence = true; | 2628 | skipIncidence = true; |
2606 | QString idS; | 2629 | QString idS; |
2607 | qApp->processAddressees(); | 2630 | qApp->processAddressees(); |
2608 | if ( !skipIncidence ) { | 2631 | if ( !skipIncidence ) { |
2609 | inL = local->incidence( uid ); | 2632 | inL = local->incidence( uid ); |
2610 | if ( inL ) { // maybe conflict - same uid in both calendars | 2633 | if ( inL ) { // maybe conflict - same uid in both calendars |
2611 | int maxrev = inL->revision(); | 2634 | int maxrev = inL->revision(); |
2612 | if ( maxrev < inR->revision() ) | 2635 | if ( maxrev < inR->revision() ) |
2613 | maxrev = inR->revision(); | 2636 | maxrev = inR->revision(); |
2614 | if ( (take = takeAddressee( inL, inR, mode, fullDateRange )) > 0 ) { | 2637 | if ( (take = takeAddressee( inL, inR, mode, fullDateRange )) > 0 ) { |
2615 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 2638 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
2616 | if ( take == 3 ) | 2639 | if ( take == 3 ) |
2617 | return false; | 2640 | return false; |
2618 | if ( take == 1 ) {// take local | 2641 | if ( take == 1 ) {// take local |
2619 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 2642 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
2620 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 2643 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
2621 | else | 2644 | else |
2622 | idS = inR->IDStr(); | 2645 | idS = inR->IDStr(); |
2623 | remote->deleteIncidence( inR ); | 2646 | remote->deleteIncidence( inR ); |
2624 | if ( inL->revision() < maxrev ) | 2647 | if ( inL->revision() < maxrev ) |
2625 | inL->setRevision( maxrev ); | 2648 | inL->setRevision( maxrev ); |
2626 | inR = inL->clone(); | 2649 | inR = inL->clone(); |
2627 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2650 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2628 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 2651 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
2629 | inR->setIDStr( idS ); | 2652 | inR->setIDStr( idS ); |
2630 | remote->addIncidence( inR ); | 2653 | remote->addIncidence( inR ); |
2631 | ++changedRemote; | 2654 | ++changedRemote; |
2632 | } else { | 2655 | } else { |
2633 | if ( inR->revision() < maxrev ) | 2656 | if ( inR->revision() < maxrev ) |
2634 | inR->setRevision( maxrev ); | 2657 | inR->setRevision( maxrev ); |
2635 | idS = inL->IDStr(); | 2658 | idS = inL->IDStr(); |
2636 | local->deleteIncidence( inL ); | 2659 | local->deleteIncidence( inL ); |
2637 | inL = inR->clone(); | 2660 | inL = inR->clone(); |
2638 | inL->setIDStr( idS ); | 2661 | inL->setIDStr( idS ); |
2639 | local->addIncidence( inL ); | 2662 | local->addIncidence( inL ); |
2640 | ++changedLocal; | 2663 | ++changedLocal; |
2641 | } | 2664 | } |
2642 | } | 2665 | } |
2643 | } else { // no conflict | 2666 | } else { // no conflict |
2644 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2667 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2645 | QString des = addresseeLSync->description(); | 2668 | QString des = addresseeLSync->description(); |
2646 | QString pref = "e"; | 2669 | QString pref = "e"; |
2647 | if ( inR->type() == "Todo" ) | 2670 | if ( inR->type() == "Todo" ) |
2648 | pref = "t"; | 2671 | pref = "t"; |
2649 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2672 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2650 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2673 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2651 | //remote->deleteIncidence( inR ); | 2674 | //remote->deleteIncidence( inR ); |
2652 | ++deletedAddresseeR; | 2675 | ++deletedAddresseeR; |
2653 | } else { | 2676 | } else { |
2654 | inR->setLastModified( modifiedCalendar ); | 2677 | inR->setLastModified( modifiedCalendar ); |
2655 | inL = inR->clone(); | 2678 | inL = inR->clone(); |
2656 | local->addIncidence( inL ); | 2679 | local->addIncidence( inL ); |
2657 | ++addedAddressee; | 2680 | ++addedAddressee; |
2658 | } | 2681 | } |
2659 | } else { | 2682 | } else { |
2660 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 2683 | if ( inR->lastModified() > mLastAddressbookSync || mode == 5 ) { |
2661 | inR->setLastModified( modifiedCalendar ); | 2684 | inR->setLastModified( modifiedCalendar ); |
2662 | local->addIncidence( inR->clone() ); | 2685 | local->addIncidence( inR->clone() ); |
2663 | ++addedAddressee; | 2686 | ++addedAddressee; |
2664 | } else { | 2687 | } else { |
2665 | checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2688 | checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2666 | remote->deleteIncidence( inR ); | 2689 | remote->deleteIncidence( inR ); |
2667 | ++deletedAddresseeR; | 2690 | ++deletedAddresseeR; |
2668 | } | 2691 | } |
2669 | } | 2692 | } |
2670 | } | 2693 | } |
2671 | } | 2694 | } |
2672 | inR = er.next(); | 2695 | inR = er.next(); |
2673 | } | 2696 | } |
2674 | QPtrList<Incidence> el = local->rawIncidences(); | 2697 | QPtrList<Incidence> el = local->rawIncidences(); |
2675 | inL = el.first(); | 2698 | inL = el.first(); |
2676 | modulo = (el.count()/10)+1; | 2699 | modulo = (el.count()/10)+1; |
2677 | bar.setCaption (i18n("Add / remove addressees") ); | 2700 | bar.setCaption (i18n("Add / remove addressees") ); |
2678 | bar.setTotalSteps ( el.count() ) ; | 2701 | bar.setTotalSteps ( el.count() ) ; |
2679 | bar.show(); | 2702 | bar.show(); |
2680 | incCounter = 0; | 2703 | incCounter = 0; |
2681 | 2704 | ||
2682 | while ( inL ) { | 2705 | while ( inL ) { |
2683 | 2706 | ||
2684 | qApp->processAddressees(); | 2707 | qApp->processAddressees(); |
2685 | if ( ! bar.isVisible() ) | 2708 | if ( ! bar.isVisible() ) |
2686 | return false; | 2709 | return false; |
2687 | if ( incCounter % modulo == 0 ) | 2710 | if ( incCounter % modulo == 0 ) |
2688 | bar.setProgress( incCounter ); | 2711 | bar.setProgress( incCounter ); |
2689 | ++incCounter; | 2712 | ++incCounter; |
2690 | uid = inL->uid(); | 2713 | uid = inL->uid(); |
2691 | bool skipIncidence = false; | 2714 | bool skipIncidence = false; |
2692 | if ( uid.left(15) == QString("last-syncAddressee-") ) | 2715 | if ( uid.left(15) == QString("last-syncAddressee-") ) |
2693 | skipIncidence = true; | 2716 | skipIncidence = true; |
2694 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 2717 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
2695 | skipIncidence = true; | 2718 | skipIncidence = true; |
2696 | if ( !skipIncidence ) { | 2719 | if ( !skipIncidence ) { |
2697 | inR = remote->incidence( uid ); | 2720 | inR = remote->incidence( uid ); |
2698 | if ( ! inR ) { | 2721 | if ( ! inR ) { |
2699 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2722 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2700 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2723 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2701 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2724 | checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2702 | local->deleteIncidence( inL ); | 2725 | local->deleteIncidence( inL ); |
2703 | ++deletedAddresseeL; | 2726 | ++deletedAddresseeL; |
2704 | } else { | 2727 | } else { |
2705 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2728 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
2706 | inL->removeID(mCurrentSyncDevice ); | 2729 | inL->removeID(mCurrentSyncDevice ); |
2707 | ++addedAddresseeR; | 2730 | ++addedAddresseeR; |
2708 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 2731 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
2709 | inL->setLastModified( modifiedCalendar ); | 2732 | inL->setLastModified( modifiedCalendar ); |
2710 | inR = inL->clone(); | 2733 | inR = inL->clone(); |
2711 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2734 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2712 | remote->addIncidence( inR ); | 2735 | remote->addIncidence( inR ); |
2713 | } | 2736 | } |
2714 | } | 2737 | } |
2715 | } else { | 2738 | } else { |
2716 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 2739 | if ( inL->lastModified() < mLastAddressbookSync && mode != 4 ) { |
2717 | checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2740 | checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2718 | local->deleteIncidence( inL ); | 2741 | local->deleteIncidence( inL ); |
2719 | ++deletedAddresseeL; | 2742 | ++deletedAddresseeL; |
2720 | } else { | 2743 | } else { |
2721 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 2744 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
2722 | ++addedAddresseeR; | 2745 | ++addedAddresseeR; |
2723 | inL->setLastModified( modifiedCalendar ); | 2746 | inL->setLastModified( modifiedCalendar ); |
2724 | remote->addIncidence( inL->clone() ); | 2747 | remote->addIncidence( inL->clone() ); |
2725 | } | 2748 | } |
2726 | } | 2749 | } |
2727 | } | 2750 | } |
2728 | } | 2751 | } |
2729 | } | 2752 | } |
2730 | inL = el.next(); | 2753 | inL = el.next(); |
2731 | } | 2754 | } |
2732 | int delFut = 0; | 2755 | int delFut = 0; |
2733 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 2756 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
2734 | er = remote->rawIncidences(); | 2757 | er = remote->rawIncidences(); |
2735 | inR = er.first(); | 2758 | inR = er.first(); |
2736 | QDateTime dt; | 2759 | QDateTime dt; |
2737 | QDateTime cur = QDateTime::currentDateTime(); | 2760 | QDateTime cur = QDateTime::currentDateTime(); |
2738 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 2761 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
2739 | while ( inR ) { | 2762 | while ( inR ) { |
2740 | if ( inR->type() == "Todo" ) { | 2763 | if ( inR->type() == "Todo" ) { |
2741 | Todo * t = (Todo*)inR; | 2764 | Todo * t = (Todo*)inR; |
2742 | if ( t->hasDueDate() ) | 2765 | if ( t->hasDueDate() ) |
2743 | dt = t->dtDue(); | 2766 | dt = t->dtDue(); |
2744 | else | 2767 | else |
2745 | dt = cur.addSecs( 62 ); | 2768 | dt = cur.addSecs( 62 ); |
2746 | } | 2769 | } |
2747 | else if (inR->type() == "Addressee" ) { | 2770 | else if (inR->type() == "Addressee" ) { |
2748 | bool ok; | 2771 | bool ok; |
2749 | dt = inR->getNextOccurence( cur, &ok ); | 2772 | dt = inR->getNextOccurence( cur, &ok ); |
2750 | if ( !ok ) | 2773 | if ( !ok ) |
2751 | dt = cur.addSecs( -62 ); | 2774 | dt = cur.addSecs( -62 ); |
2752 | } | 2775 | } |
2753 | else | 2776 | else |
2754 | dt = inR->dtStart(); | 2777 | dt = inR->dtStart(); |
2755 | if ( dt < cur || dt > end ) { | 2778 | if ( dt < cur || dt > end ) { |
2756 | remote->deleteIncidence( inR ); | 2779 | remote->deleteIncidence( inR ); |
2757 | ++delFut; | 2780 | ++delFut; |
2758 | } | 2781 | } |
2759 | inR = er.next(); | 2782 | inR = er.next(); |
2760 | } | 2783 | } |
2761 | } | 2784 | } |
2762 | bar.hide(); | 2785 | bar.hide(); |
2763 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 2786 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2764 | addresseeLSync->setReadOnly( false ); | 2787 | addresseeLSync->setReadOnly( false ); |
2765 | addresseeLSync->setDtStart( mLastCalendarSync ); | 2788 | addresseeLSync->setDtStart( mLastAddressbookSync ); |
2766 | addresseeRSync->setDtStart( mLastCalendarSync ); | 2789 | addresseeRSync->setDtStart( mLastAddressbookSync ); |
2767 | addresseeLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 2790 | addresseeLSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); |
2768 | addresseeRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 2791 | addresseeRSync->setDtEnd( mLastAddressbookSync.addSecs( 3600 ) ); |
2769 | addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 2792 | addresseeRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
2770 | addresseeLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 2793 | addresseeLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
2771 | addresseeLSync->setReadOnly( true ); | 2794 | addresseeLSync->setReadOnly( true ); |
2772 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2795 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2773 | remote->addAddressee( addresseeRSync ); | 2796 | remote->addAddressee( addresseeRSync ); |
2774 | QString mes; | 2797 | QString mes; |
2775 | 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 ); | 2798 | 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 ); |
2776 | QString delmess; | 2799 | QString delmess; |
2777 | if ( delFut ) { | 2800 | if ( delFut ) { |
2778 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 2801 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
2779 | mes += delmess; | 2802 | mes += delmess; |
2780 | } | 2803 | } |
2781 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 2804 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
2782 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 2805 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
2783 | } | 2806 | } |
2784 | qDebug( mes ); | 2807 | qDebug( mes ); |
2785 | mCalendar->checkAlarmForIncidence( 0, true ); | 2808 | mCalendar->checkAlarmForIncidence( 0, true ); |
2786 | return syncOK; | 2809 | return syncOK; |
2787 | #endif | 2810 | #endif |
2788 | return false; | 2811 | return false; |
2789 | } | 2812 | } |
2790 | bool KABCore::syncAB(QString filename, int mode) | 2813 | bool KABCore::syncAB(QString filename, int mode) |
2791 | { | 2814 | { |
2792 | 2815 | ||
2793 | //pending prepare addresseeview for output | 2816 | //pending prepare addresseeview for output |
2794 | //pending detect, if remote file has REV field. if not switch to external sync | 2817 | //pending detect, if remote file has REV field. if not switch to external sync |
2795 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2818 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2796 | AddressBook abLocal(filename,"syncContact"); | 2819 | AddressBook abLocal(filename,"syncContact"); |
2797 | bool syncOK = false; | 2820 | bool syncOK = false; |
2798 | if ( abLocal.load() ) { | 2821 | if ( abLocal.load() ) { |
2799 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); | 2822 | qDebug("AB loaded %s mode %d",filename.latin1(), mode ); |
2800 | AddressBook::Iterator it; | 2823 | AddressBook::Iterator it; |
2801 | QStringList vcards; | 2824 | QStringList vcards; |
2802 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2825 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2803 | qDebug("Name %s ", (*it).familyName().latin1()); | 2826 | qDebug("Name %s ", (*it).familyName().latin1()); |
2804 | } | 2827 | } |
2805 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2828 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2806 | if ( syncOK ) { | 2829 | if ( syncOK ) { |
2807 | if ( KABPrefs::instance()->mWriteBackFile ) | 2830 | if ( KABPrefs::instance()->mWriteBackFile ) |
2808 | { | 2831 | { |
2809 | qDebug("saving remote AB "); | 2832 | qDebug("saving remote AB "); |
2810 | abLocal.saveAB(); | 2833 | abLocal.saveAB(); |
2811 | } | 2834 | } |
2812 | } | 2835 | } |
2813 | setModified(); | 2836 | setModified(); |
2814 | 2837 | ||
2815 | } | 2838 | } |
2816 | if ( syncOK ) | 2839 | if ( syncOK ) |
2817 | mViewManager->refreshView(); | 2840 | mViewManager->refreshView(); |
2818 | return syncOK; | 2841 | return syncOK; |
2819 | #if 0 | 2842 | #if 0 |
2820 | 2843 | ||
2821 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 2844 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
2822 | getEventViewerDialog()->setSyncMode( true ); | 2845 | getEventViewerDialog()->setSyncMode( true ); |
2823 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 2846 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
2824 | getEventViewerDialog()->setSyncMode( false ); | 2847 | getEventViewerDialog()->setSyncMode( false ); |
2825 | if ( syncOK ) { | 2848 | if ( syncOK ) { |
2826 | if ( KOPrefs::instance()->mWriteBackFile ) | 2849 | if ( KOPrefs::instance()->mWriteBackFile ) |
2827 | { | 2850 | { |
2828 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2851 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2829 | storage->save(); | 2852 | storage->save(); |
2830 | } | 2853 | } |
2831 | } | 2854 | } |
2832 | setModified(); | 2855 | setModified(); |
2833 | } | 2856 | } |
2834 | 2857 | ||
2835 | #endif | 2858 | #endif |
2836 | } | 2859 | } |
2837 | 2860 | ||
2838 | 2861 | ||
2839 | void KABCore::confSync() | 2862 | void KABCore::confSync() |
2840 | { | 2863 | { |
2841 | static KSyncPrefsDialog* sp = 0; | 2864 | static KSyncPrefsDialog* sp = 0; |
2842 | if ( ! sp ) { | 2865 | if ( ! sp ) { |
2843 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 2866 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
2844 | } | 2867 | } |
2845 | sp->usrReadConfig(); | 2868 | sp->usrReadConfig(); |
2846 | #ifndef DESKTOP_VERSION | 2869 | #ifndef DESKTOP_VERSION |
2847 | sp->showMaximized(); | 2870 | sp->showMaximized(); |
2848 | #else | 2871 | #else |
2849 | sp->show(); | 2872 | sp->show(); |
2850 | #endif | 2873 | #endif |
2851 | sp->exec(); | 2874 | sp->exec(); |
2852 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 2875 | KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
2853 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 2876 | KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
2854 | fillSyncMenu(); | 2877 | fillSyncMenu(); |
2855 | } | 2878 | } |
2856 | void KABCore::syncSharp() | 2879 | void KABCore::syncSharp() |
2857 | { | 2880 | { |
2858 | if ( mModified ) | 2881 | if ( mModified ) |
2859 | save(); | 2882 | save(); |
2860 | qDebug("pending syncSharp() "); | 2883 | qDebug("pending syncSharp() "); |
2861 | //mView->syncSharp(); | 2884 | //mView->syncSharp(); |
2862 | setModified(); | 2885 | setModified(); |
2863 | 2886 | ||
2864 | } | 2887 | } |
2865 | void KABCore::syncPhone() | 2888 | void KABCore::syncPhone() |
2866 | { | 2889 | { |
2867 | if ( mModified ) | 2890 | if ( mModified ) |
2868 | save(); | 2891 | save(); |
2869 | qDebug("pending syncPhone(); "); | 2892 | qDebug("pending syncPhone(); "); |
2870 | //mView->syncPhone(); | 2893 | //mView->syncPhone(); |
2871 | setModified(); | 2894 | setModified(); |
2872 | 2895 | ||
2873 | } | 2896 | } |
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 4487a8a..c67cee6 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h | |||
@@ -1,481 +1,483 @@ | |||
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 | #ifndef KABCORE_H | 24 | #ifndef KABCORE_H |
25 | #define KABCORE_H | 25 | #define KABCORE_H |
26 | 26 | ||
27 | #include <kabc/field.h> | 27 | #include <kabc/field.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #endif //KAB_EMBEDDED | 30 | #endif //KAB_EMBEDDED |
31 | #include <qdict.h> | 31 | #include <qdict.h> |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | 35 | ||
36 | namespace KABC { | 36 | namespace KABC { |
37 | class AddressBook; | 37 | class AddressBook; |
38 | } | 38 | } |
39 | 39 | ||
40 | #ifndef KAB_EMBEDDED | 40 | #ifndef KAB_EMBEDDED |
41 | class KAboutData; | 41 | class KAboutData; |
42 | class KConfig; | 42 | class KConfig; |
43 | 43 | ||
44 | class KAddressBookService; | 44 | class KAddressBookService; |
45 | class LDAPSearchDialog; | 45 | class LDAPSearchDialog; |
46 | #else //KAB_EMBEDDED | 46 | #else //KAB_EMBEDDED |
47 | class KAddressBookMain; | 47 | class KAddressBookMain; |
48 | //US class QAction; | 48 | //US class QAction; |
49 | #endif //KAB_EMBEDDED | 49 | #endif //KAB_EMBEDDED |
50 | class KCMultiDialog; | 50 | class KCMultiDialog; |
51 | class KXMLGUIClient; | 51 | class KXMLGUIClient; |
52 | class ExtensionManager; | 52 | class ExtensionManager; |
53 | class XXPortManager; | 53 | class XXPortManager; |
54 | class JumpButtonBar; | 54 | class JumpButtonBar; |
55 | class IncSearchWidget; | 55 | class IncSearchWidget; |
56 | class KDGanttMinimizeSplitter; | 56 | class KDGanttMinimizeSplitter; |
57 | class KAction; | 57 | class KAction; |
58 | class KActionCollection; | 58 | class KActionCollection; |
59 | class KToggleAction; | 59 | class KToggleAction; |
60 | class KSyncProfile; | 60 | class KSyncProfile; |
61 | 61 | ||
62 | class QAction; | 62 | class QAction; |
63 | class QMenuBar; | 63 | class QMenuBar; |
64 | class QSplitter; | 64 | class QSplitter; |
65 | class ViewContainer; | 65 | class ViewContainer; |
66 | class ViewManager; | 66 | class ViewManager; |
67 | class AddresseeEditorDialog; | 67 | class AddresseeEditorDialog; |
68 | class Ir; | 68 | class Ir; |
69 | 69 | ||
70 | class KABCore : public QWidget | 70 | class KABCore : public QWidget |
71 | { | 71 | { |
72 | Q_OBJECT | 72 | Q_OBJECT |
73 | 73 | ||
74 | public: | 74 | public: |
75 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); | 75 | KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); |
76 | 76 | ||
77 | 77 | ||
78 | ~KABCore(); | 78 | ~KABCore(); |
79 | 79 | ||
80 | 80 | ||
81 | #ifdef KAB_EMBEDDED | 81 | #ifdef KAB_EMBEDDED |
82 | //US added functionality | 82 | //US added functionality |
83 | QPopupMenu* getViewMenu() {return viewMenu;} | 83 | QPopupMenu* getViewMenu() {return viewMenu;} |
84 | QPopupMenu* getFilterMenu() {return filterMenu;} | 84 | QPopupMenu* getFilterMenu() {return filterMenu;} |
85 | QPopupMenu* getSettingsMenu() {return settingsMenu;} | 85 | QPopupMenu* getSettingsMenu() {return settingsMenu;} |
86 | void addActionsManually(); | 86 | void addActionsManually(); |
87 | #endif //KAB_EMBEDDED | 87 | #endif //KAB_EMBEDDED |
88 | /** | 88 | /** |
89 | Restores the global settings. | 89 | Restores the global settings. |
90 | */ | 90 | */ |
91 | void restoreSettings(); | 91 | void restoreSettings(); |
92 | 92 | ||
93 | /** | 93 | /** |
94 | Saves the global settings. | 94 | Saves the global settings. |
95 | */ | 95 | */ |
96 | void saveSettings(); | 96 | void saveSettings(); |
97 | 97 | ||
98 | /** | 98 | /** |
99 | Returns a pointer to the StdAddressBook of the application. | 99 | Returns a pointer to the StdAddressBook of the application. |
100 | */ | 100 | */ |
101 | KABC::AddressBook *addressBook() const; | 101 | KABC::AddressBook *addressBook() const; |
102 | 102 | ||
103 | /** | 103 | /** |
104 | Returns a pointer to the KConfig object of the application. | 104 | Returns a pointer to the KConfig object of the application. |
105 | */ | 105 | */ |
106 | static KConfig *config(); | 106 | static KConfig *config(); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | Returns a pointer to the global KActionCollection object. So | 109 | Returns a pointer to the global KActionCollection object. So |
110 | other classes can register their actions easily. | 110 | other classes can register their actions easily. |
111 | */ | 111 | */ |
112 | KActionCollection *actionCollection() const; | 112 | KActionCollection *actionCollection() const; |
113 | 113 | ||
114 | /** | 114 | /** |
115 | Returns the current search field of the Incremental Search Widget. | 115 | Returns the current search field of the Incremental Search Widget. |
116 | */ | 116 | */ |
117 | KABC::Field *currentSearchField() const; | 117 | KABC::Field *currentSearchField() const; |
118 | 118 | ||
119 | /** | 119 | /** |
120 | Returns the uid list of the currently selected contacts. | 120 | Returns the uid list of the currently selected contacts. |
121 | */ | 121 | */ |
122 | QStringList selectedUIDs() const; | 122 | QStringList selectedUIDs() const; |
123 | 123 | ||
124 | /** | 124 | /** |
125 | Displays the ResourceSelectDialog and returns the selected | 125 | Displays the ResourceSelectDialog and returns the selected |
126 | resource or a null pointer if no resource was selected by | 126 | resource or a null pointer if no resource was selected by |
127 | the user. | 127 | the user. |
128 | */ | 128 | */ |
129 | KABC::Resource *requestResource( QWidget *parent ); | 129 | KABC::Resource *requestResource( QWidget *parent ); |
130 | 130 | ||
131 | #ifndef KAB_EMBEDDED | 131 | #ifndef KAB_EMBEDDED |
132 | static KAboutData *createAboutData(); | 132 | static KAboutData *createAboutData(); |
133 | #endif //KAB_EMBEDDED | 133 | #endif //KAB_EMBEDDED |
134 | 134 | ||
135 | #ifdef KAB_EMBEDDED | 135 | #ifdef KAB_EMBEDDED |
136 | inline QPopupMenu* getImportMenu() { return ImportMenu;} | 136 | inline QPopupMenu* getImportMenu() { return ImportMenu;} |
137 | inline QPopupMenu* getExportMenu() { return ExportMenu;} | 137 | inline QPopupMenu* getExportMenu() { return ExportMenu;} |
138 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
139 | 139 | ||
140 | public slots: | 140 | public slots: |
141 | #ifdef KAB_EMBEDDED | 141 | #ifdef KAB_EMBEDDED |
142 | void createAboutData(); | 142 | void createAboutData(); |
143 | #endif //KAB_EMBEDDED | 143 | #endif //KAB_EMBEDDED |
144 | 144 | ||
145 | void statusMessage(QString, int time = 0 ); | 145 | void statusMessage(QString, int time = 0 ); |
146 | void showLicence(); | 146 | void showLicence(); |
147 | void faq(); | 147 | void faq(); |
148 | 148 | ||
149 | /** | 149 | /** |
150 | Is called whenever a contact is selected in the view. | 150 | Is called whenever a contact is selected in the view. |
151 | */ | 151 | */ |
152 | void setContactSelected( const QString &uid ); | 152 | void setContactSelected( const QString &uid ); |
153 | 153 | ||
154 | /** | 154 | /** |
155 | Opens the preferred mail composer with all selected contacts as | 155 | Opens the preferred mail composer with all selected contacts as |
156 | arguments. | 156 | arguments. |
157 | */ | 157 | */ |
158 | void sendMail(); | 158 | void sendMail(); |
159 | 159 | ||
160 | /** | 160 | /** |
161 | Opens the preferred mail composer with the given contacts as | 161 | Opens the preferred mail composer with the given contacts as |
162 | arguments. | 162 | arguments. |
163 | */ | 163 | */ |
164 | void sendMail( const QString& email ); | 164 | void sendMail( const QString& email ); |
165 | 165 | ||
166 | 166 | ||
167 | void mailVCard(); | 167 | void mailVCard(); |
168 | void mailVCard(const QStringList& uids); | 168 | void mailVCard(const QStringList& uids); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | Beams the "WhoAmI contact. | 171 | Beams the "WhoAmI contact. |
172 | */ | 172 | */ |
173 | void beamMySelf(); | 173 | void beamMySelf(); |
174 | 174 | ||
175 | void beamVCard(); | 175 | void beamVCard(); |
176 | void beamVCard(const QStringList& uids); | 176 | void beamVCard(const QStringList& uids); |
177 | void beamDone( Ir *ir ); | 177 | void beamDone( Ir *ir ); |
178 | 178 | ||
179 | 179 | ||
180 | /** | 180 | /** |
181 | Starts the preferred web browser with the given URL as argument. | 181 | Starts the preferred web browser with the given URL as argument. |
182 | */ | 182 | */ |
183 | void browse( const QString& url ); | 183 | void browse( const QString& url ); |
184 | 184 | ||
185 | /** | 185 | /** |
186 | Select all contacts in the view. | 186 | Select all contacts in the view. |
187 | */ | 187 | */ |
188 | void selectAllContacts(); | 188 | void selectAllContacts(); |
189 | 189 | ||
190 | /** | 190 | /** |
191 | Deletes all selected contacts from the address book. | 191 | Deletes all selected contacts from the address book. |
192 | */ | 192 | */ |
193 | void deleteContacts(); | 193 | void deleteContacts(); |
194 | 194 | ||
195 | /** | 195 | /** |
196 | Deletes given contacts from the address book. | 196 | Deletes given contacts from the address book. |
197 | 197 | ||
198 | @param uids The uids of the contacts, which shall be deleted. | 198 | @param uids The uids of the contacts, which shall be deleted. |
199 | */ | 199 | */ |
200 | void deleteContacts( const QStringList &uids ); | 200 | void deleteContacts( const QStringList &uids ); |
201 | 201 | ||
202 | /** | 202 | /** |
203 | Copys the selected contacts into clipboard for later pasting. | 203 | Copys the selected contacts into clipboard for later pasting. |
204 | */ | 204 | */ |
205 | void copyContacts(); | 205 | void copyContacts(); |
206 | 206 | ||
207 | /** | 207 | /** |
208 | Cuts the selected contacts and stores them for later pasting. | 208 | Cuts the selected contacts and stores them for later pasting. |
209 | */ | 209 | */ |
210 | void cutContacts(); | 210 | void cutContacts(); |
211 | 211 | ||
212 | /** | 212 | /** |
213 | Paste contacts from clipboard into the address book. | 213 | Paste contacts from clipboard into the address book. |
214 | */ | 214 | */ |
215 | void pasteContacts(); | 215 | void pasteContacts(); |
216 | 216 | ||
217 | /** | 217 | /** |
218 | Paste given contacts into the address book. | 218 | Paste given contacts into the address book. |
219 | 219 | ||
220 | @param list The list of addressee, which shall be pasted. | 220 | @param list The list of addressee, which shall be pasted. |
221 | */ | 221 | */ |
222 | void pasteContacts( KABC::Addressee::List &list ); | 222 | void pasteContacts( KABC::Addressee::List &list ); |
223 | 223 | ||
224 | /** | 224 | /** |
225 | Sets the whoAmI contact, that is used by many other programs to | 225 | Sets the whoAmI contact, that is used by many other programs to |
226 | get personal information about the current user. | 226 | get personal information about the current user. |
227 | */ | 227 | */ |
228 | void setWhoAmI(); | 228 | void setWhoAmI(); |
229 | 229 | ||
230 | /** | 230 | /** |
231 | Displays the category dialog and applies the result to all | 231 | Displays the category dialog and applies the result to all |
232 | selected contacts. | 232 | selected contacts. |
233 | */ | 233 | */ |
234 | void setCategories(); | 234 | void setCategories(); |
235 | 235 | ||
236 | /** | 236 | /** |
237 | Sets the field list of the Incremental Search Widget. | 237 | Sets the field list of the Incremental Search Widget. |
238 | */ | 238 | */ |
239 | void setSearchFields( const KABC::Field::List &fields ); | 239 | void setSearchFields( const KABC::Field::List &fields ); |
240 | 240 | ||
241 | /** | 241 | /** |
242 | Search with the current search field for a contact, that matches | 242 | Search with the current search field for a contact, that matches |
243 | the given text, and selects it in the view. | 243 | the given text, and selects it in the view. |
244 | */ | 244 | */ |
245 | void incrementalSearch( const QString& text ); | 245 | void incrementalSearch( const QString& text ); |
246 | 246 | ||
247 | /** | 247 | /** |
248 | Marks the address book as modified. | 248 | Marks the address book as modified. |
249 | */ | 249 | */ |
250 | void setModified(); | 250 | void setModified(); |
251 | /** | 251 | /** |
252 | Marks the address book as modified without refreshing the view. | 252 | Marks the address book as modified without refreshing the view. |
253 | */ | 253 | */ |
254 | void setModifiedWOrefresh(); | 254 | void setModifiedWOrefresh(); |
255 | 255 | ||
256 | /** | 256 | /** |
257 | Marks the address book as modified concerning the argument. | 257 | Marks the address book as modified concerning the argument. |
258 | */ | 258 | */ |
259 | void setModified( bool modified ); | 259 | void setModified( bool modified ); |
260 | 260 | ||
261 | /** | 261 | /** |
262 | Returns whether the address book is modified. | 262 | Returns whether the address book is modified. |
263 | */ | 263 | */ |
264 | bool modified() const; | 264 | bool modified() const; |
265 | 265 | ||
266 | /** | 266 | /** |
267 | Called whenever an contact is modified in the contact editor | 267 | Called whenever an contact is modified in the contact editor |
268 | dialog or the quick edit. | 268 | dialog or the quick edit. |
269 | */ | 269 | */ |
270 | void contactModified( const KABC::Addressee &addr ); | 270 | void contactModified( const KABC::Addressee &addr ); |
271 | 271 | ||
272 | /** | 272 | /** |
273 | DCOP METHODS. | 273 | DCOP METHODS. |
274 | */ | 274 | */ |
275 | void addEmail( QString addr ); | 275 | void addEmail( QString addr ); |
276 | void importVCard( const KURL& url, bool showPreview ); | 276 | void importVCard( const KURL& url, bool showPreview ); |
277 | void importVCard( const QString& vCard, bool showPreview ); | 277 | void importVCard( const QString& vCard, bool showPreview ); |
278 | void newContact(); | 278 | void newContact(); |
279 | QString getNameByPhone( const QString& phone ); | 279 | QString getNameByPhone( const QString& phone ); |
280 | /** | 280 | /** |
281 | END DCOP METHODS | 281 | END DCOP METHODS |
282 | */ | 282 | */ |
283 | 283 | ||
284 | /** | 284 | /** |
285 | Saves the contents of the AddressBook back to disk. | 285 | Saves the contents of the AddressBook back to disk. |
286 | */ | 286 | */ |
287 | void save(); | 287 | void save(); |
288 | 288 | ||
289 | /** | 289 | /** |
290 | Undos the last command using the undo stack. | 290 | Undos the last command using the undo stack. |
291 | */ | 291 | */ |
292 | void undo(); | 292 | void undo(); |
293 | 293 | ||
294 | /** | 294 | /** |
295 | Redos the last command that was undone, using the redo stack. | 295 | Redos the last command that was undone, using the redo stack. |
296 | */ | 296 | */ |
297 | void redo(); | 297 | void redo(); |
298 | 298 | ||
299 | /** | 299 | /** |
300 | Shows the edit dialog for the given uid. If the uid is QString::null, | 300 | Shows the edit dialog for the given uid. If the uid is QString::null, |
301 | the method will try to find a selected addressee in the view. | 301 | the method will try to find a selected addressee in the view. |
302 | */ | 302 | */ |
303 | void editContact( const QString &uid /*US = QString::null*/ ); | 303 | void editContact( const QString &uid /*US = QString::null*/ ); |
304 | //US added a second method without defaultparameter | 304 | //US added a second method without defaultparameter |
305 | void editContact2(); | 305 | void editContact2(); |
306 | 306 | ||
307 | /** | 307 | /** |
308 | Shows or edits the detail view for the given uid. If the uid is QString::null, | 308 | Shows or edits the detail view for the given uid. If the uid is QString::null, |
309 | the method will try to find a selected addressee in the view. | 309 | the method will try to find a selected addressee in the view. |
310 | */ | 310 | */ |
311 | void executeContact( const QString &uid /*US = QString::null*/ ); | 311 | void executeContact( const QString &uid /*US = QString::null*/ ); |
312 | 312 | ||
313 | /** | 313 | /** |
314 | Launches the configuration dialog. | 314 | Launches the configuration dialog. |
315 | */ | 315 | */ |
316 | void openConfigDialog(); | 316 | void openConfigDialog(); |
317 | 317 | ||
318 | /** | 318 | /** |
319 | Launches the ldap search dialog. | 319 | Launches the ldap search dialog. |
320 | */ | 320 | */ |
321 | void openLDAPDialog(); | 321 | void openLDAPDialog(); |
322 | 322 | ||
323 | /** | 323 | /** |
324 | Creates a KAddressBookPrinter, which will display the print | 324 | Creates a KAddressBookPrinter, which will display the print |
325 | dialog and do the printing. | 325 | dialog and do the printing. |
326 | */ | 326 | */ |
327 | void print(); | 327 | void print(); |
328 | 328 | ||
329 | /** | 329 | /** |
330 | Registers a new GUI client, so plugins can register its actions. | 330 | Registers a new GUI client, so plugins can register its actions. |
331 | */ | 331 | */ |
332 | void addGUIClient( KXMLGUIClient *client ); | 332 | void addGUIClient( KXMLGUIClient *client ); |
333 | 333 | ||
334 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); | 334 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); |
335 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 335 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
336 | 336 | ||
337 | 337 | ||
338 | signals: | 338 | signals: |
339 | void contactSelected( const QString &name ); | 339 | void contactSelected( const QString &name ); |
340 | void contactSelected( const QPixmap &pixmap ); | 340 | void contactSelected( const QPixmap &pixmap ); |
341 | public slots: | 341 | public slots: |
342 | void setDetailsVisible( bool visible ); | 342 | void setDetailsVisible( bool visible ); |
343 | void setDetailsToState(); | 343 | void setDetailsToState(); |
344 | void slotSyncMenu( int ); | 344 | void slotSyncMenu( int ); |
345 | private slots: | 345 | private slots: |
346 | void setJumpButtonBarVisible( bool visible ); | 346 | void setJumpButtonBarVisible( bool visible ); |
347 | void importFromOL(); | 347 | void importFromOL(); |
348 | void extensionModified( const KABC::Addressee::List &list ); | 348 | void extensionModified( const KABC::Addressee::List &list ); |
349 | void extensionChanged( int id ); | 349 | void extensionChanged( int id ); |
350 | void clipboardDataChanged(); | 350 | void clipboardDataChanged(); |
351 | void updateActionMenu(); | 351 | void updateActionMenu(); |
352 | void configureKeyBindings(); | 352 | void configureKeyBindings(); |
353 | void removeVoice(); | 353 | void removeVoice(); |
354 | #ifdef KAB_EMBEDDED | 354 | #ifdef KAB_EMBEDDED |
355 | void configureResources(); | 355 | void configureResources(); |
356 | #endif //KAB_EMBEDDED | 356 | #endif //KAB_EMBEDDED |
357 | 357 | ||
358 | void slotEditorDestroyed( const QString &uid ); | 358 | void slotEditorDestroyed( const QString &uid ); |
359 | void configurationChanged(); | 359 | void configurationChanged(); |
360 | void addressBookChanged(); | 360 | void addressBookChanged(); |
361 | 361 | ||
362 | private: | 362 | private: |
363 | void initGUI(); | 363 | void initGUI(); |
364 | void initActions(); | 364 | void initActions(); |
365 | 365 | ||
366 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, | 366 | AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, |
367 | const char *name = 0 ); | 367 | const char *name = 0 ); |
368 | 368 | ||
369 | KXMLGUIClient *mGUIClient; | 369 | KXMLGUIClient *mGUIClient; |
370 | 370 | ||
371 | KABC::AddressBook *mAddressBook; | 371 | KABC::AddressBook *mAddressBook; |
372 | 372 | ||
373 | ViewManager *mViewManager; | 373 | ViewManager *mViewManager; |
374 | // QSplitter *mDetailsSplitter; | 374 | // QSplitter *mDetailsSplitter; |
375 | KDGanttMinimizeSplitter *mExtensionBarSplitter; | 375 | KDGanttMinimizeSplitter *mExtensionBarSplitter; |
376 | ViewContainer *mDetails; | 376 | ViewContainer *mDetails; |
377 | KDGanttMinimizeSplitter* mMiniSplitter; | 377 | KDGanttMinimizeSplitter* mMiniSplitter; |
378 | XXPortManager *mXXPortManager; | 378 | XXPortManager *mXXPortManager; |
379 | JumpButtonBar *mJumpButtonBar; | 379 | JumpButtonBar *mJumpButtonBar; |
380 | IncSearchWidget *mIncSearchWidget; | 380 | IncSearchWidget *mIncSearchWidget; |
381 | ExtensionManager *mExtensionManager; | 381 | ExtensionManager *mExtensionManager; |
382 | 382 | ||
383 | KCMultiDialog *mConfigureDialog; | 383 | KCMultiDialog *mConfigureDialog; |
384 | 384 | ||
385 | #ifndef KAB_EMBEDDED | 385 | #ifndef KAB_EMBEDDED |
386 | LDAPSearchDialog *mLdapSearchDialog; | 386 | LDAPSearchDialog *mLdapSearchDialog; |
387 | #endif //KAB_EMBEDDED | 387 | #endif //KAB_EMBEDDED |
388 | // QDict<AddresseeEditorDialog> mEditorDict; | 388 | // QDict<AddresseeEditorDialog> mEditorDict; |
389 | AddresseeEditorDialog *mEditorDialog; | 389 | AddresseeEditorDialog *mEditorDialog; |
390 | bool mReadWrite; | 390 | bool mReadWrite; |
391 | bool mModified; | 391 | bool mModified; |
392 | bool mIsPart; | 392 | bool mIsPart; |
393 | bool mMultipleViewsAtOnce; | 393 | bool mMultipleViewsAtOnce; |
394 | 394 | ||
395 | 395 | ||
396 | //US file menu | 396 | //US file menu |
397 | KAction *mActionMail; | 397 | KAction *mActionMail; |
398 | KAction *mActionBeam; | 398 | KAction *mActionBeam; |
399 | KAction* mActionPrint; | 399 | KAction* mActionPrint; |
400 | KAction* mActionNewContact; | 400 | KAction* mActionNewContact; |
401 | KAction *mActionSave; | 401 | KAction *mActionSave; |
402 | KAction *mActionEditAddressee; | 402 | KAction *mActionEditAddressee; |
403 | KAction *mActionMailVCard; | 403 | KAction *mActionMailVCard; |
404 | KAction *mActionBeamVCard; | 404 | KAction *mActionBeamVCard; |
405 | 405 | ||
406 | KAction *mActionQuit; | 406 | KAction *mActionQuit; |
407 | 407 | ||
408 | //US edit menu | 408 | //US edit menu |
409 | KAction *mActionCopy; | 409 | KAction *mActionCopy; |
410 | KAction *mActionCut; | 410 | KAction *mActionCut; |
411 | KAction *mActionPaste; | 411 | KAction *mActionPaste; |
412 | KAction *mActionSelectAll; | 412 | KAction *mActionSelectAll; |
413 | KAction *mActionUndo; | 413 | KAction *mActionUndo; |
414 | KAction *mActionRedo; | 414 | KAction *mActionRedo; |
415 | KAction *mActionDelete; | 415 | KAction *mActionDelete; |
416 | 416 | ||
417 | //US settings menu | 417 | //US settings menu |
418 | KAction *mActionConfigResources; | 418 | KAction *mActionConfigResources; |
419 | KAction *mActionConfigKAddressbook; | 419 | KAction *mActionConfigKAddressbook; |
420 | KAction *mActionConfigShortcuts; | 420 | KAction *mActionConfigShortcuts; |
421 | KAction *mActionConfigureToolbars; | 421 | KAction *mActionConfigureToolbars; |
422 | KAction *mActionKeyBindings; | 422 | KAction *mActionKeyBindings; |
423 | KToggleAction *mActionJumpBar; | 423 | KToggleAction *mActionJumpBar; |
424 | KToggleAction *mActionDetails; | 424 | KToggleAction *mActionDetails; |
425 | KAction *mActionWhoAmI; | 425 | KAction *mActionWhoAmI; |
426 | KAction *mActionCategories; | 426 | KAction *mActionCategories; |
427 | KAction *mActionAboutKAddressbook; | 427 | KAction *mActionAboutKAddressbook; |
428 | KAction *mActionLicence; | 428 | KAction *mActionLicence; |
429 | KAction *mActionFaq; | 429 | KAction *mActionFaq; |
430 | 430 | ||
431 | KAction *mActionDeleteView; | 431 | KAction *mActionDeleteView; |
432 | 432 | ||
433 | QPopupMenu *viewMenu; | 433 | QPopupMenu *viewMenu; |
434 | QPopupMenu *filterMenu; | 434 | QPopupMenu *filterMenu; |
435 | QPopupMenu *settingsMenu; | 435 | QPopupMenu *settingsMenu; |
436 | QPopupMenu *changeMenu; | 436 | QPopupMenu *changeMenu; |
437 | //US QAction *mActionSave; | 437 | //US QAction *mActionSave; |
438 | QPopupMenu *ImportMenu; | 438 | QPopupMenu *ImportMenu; |
439 | QPopupMenu *ExportMenu; | 439 | QPopupMenu *ExportMenu; |
440 | //LR additional methods | 440 | //LR additional methods |
441 | KAction *mActionRemoveVoice; | 441 | KAction *mActionRemoveVoice; |
442 | KAction * mActionImportOL; | 442 | KAction * mActionImportOL; |
443 | 443 | ||
444 | #ifndef KAB_EMBEDDED | 444 | #ifndef KAB_EMBEDDED |
445 | KAddressBookService *mAddressBookService; | 445 | KAddressBookService *mAddressBookService; |
446 | #endif //KAB_EMBEDDED | 446 | #endif //KAB_EMBEDDED |
447 | 447 | ||
448 | class KABCorePrivate; | 448 | class KABCorePrivate; |
449 | KABCorePrivate *d; | 449 | KABCorePrivate *d; |
450 | bool mBlockSaveFlag; | 450 | bool mBlockSaveFlag; |
451 | 451 | ||
452 | #ifdef KAB_EMBEDDED | 452 | #ifdef KAB_EMBEDDED |
453 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient | 453 | KAddressBookMain *mMainWindow; // should be the same like mGUIClient |
454 | #endif //KAB_EMBEDDED | 454 | #endif //KAB_EMBEDDED |
455 | // LR ******************************* | 455 | // LR ******************************* |
456 | // sync stuff! | 456 | // sync stuff! |
457 | QPopupMenu *syncMenu; | 457 | QPopupMenu *syncMenu; |
458 | void fillSyncMenu(); | 458 | void fillSyncMenu(); |
459 | QString mCurrentSyncDevice; | 459 | QString mCurrentSyncDevice; |
460 | QString mCurrentSyncName; | 460 | QString mCurrentSyncName; |
461 | void quickSyncLocalFile(); | 461 | void quickSyncLocalFile(); |
462 | bool syncWithFile( QString fn , bool quick ); | 462 | bool syncWithFile( QString fn , bool quick ); |
463 | void KABCore::syncLocalFile(); | 463 | void KABCore::syncLocalFile(); |
464 | void KABCore::syncPhone(); | 464 | void KABCore::syncPhone(); |
465 | void KABCore::syncSharp(); | 465 | void KABCore::syncSharp(); |
466 | void multiSync( bool askforPrefs ); | 466 | void multiSync( bool askforPrefs ); |
467 | int mCurrentSyncProfile ; | 467 | int mCurrentSyncProfile ; |
468 | void syncRemote( KSyncProfile* prof, bool ask = true); | 468 | void syncRemote( KSyncProfile* prof, bool ask = true); |
469 | void edit_sync_options(); | 469 | void edit_sync_options(); |
470 | bool syncAB(QString filename, int mode); | 470 | bool syncAB(QString filename, int mode); |
471 | int ringSync(); | 471 | int ringSync(); |
472 | QString getPassword( ); | 472 | QString getPassword( ); |
473 | int mGlobalSyncMode; | 473 | int mGlobalSyncMode; |
474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); | 474 | bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); |
475 | KABC::Addressee getLastSyncAddressee(); | ||
476 | QDateTime mLastAddressbookSync; | ||
475 | public slots: | 477 | public slots: |
476 | void confSync(); | 478 | void confSync(); |
477 | // ********************* | 479 | // ********************* |
478 | 480 | ||
479 | }; | 481 | }; |
480 | 482 | ||
481 | #endif | 483 | #endif |