summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp101
-rw-r--r--kabc/addressbook.h1
-rw-r--r--kaddressbook/kabcore.cpp95
-rw-r--r--kaddressbook/kabcore.h5
4 files changed, 186 insertions, 16 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 47d298a..70eda1b 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,646 +1,743 @@
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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (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 "addressbook.h" 45#include "addressbook.h"
46#include "resource.h" 46#include "resource.h"
47 47
48//US #include "addressbook.moc" 48//US #include "addressbook.moc"
49 49
50using namespace KABC; 50using namespace KABC;
51 51
52struct AddressBook::AddressBookData 52struct AddressBook::AddressBookData
53{ 53{
54 Addressee::List mAddressees; 54 Addressee::List mAddressees;
55 Addressee::List mRemovedAddressees; 55 Addressee::List mRemovedAddressees;
56 Field::List mAllFields; 56 Field::List mAllFields;
57 KConfig *mConfig; 57 KConfig *mConfig;
58 KRES::Manager<Resource> *mManager; 58 KRES::Manager<Resource> *mManager;
59//US ErrorHandler *mErrorHandler; 59//US ErrorHandler *mErrorHandler;
60}; 60};
61 61
62struct AddressBook::Iterator::IteratorData 62struct AddressBook::Iterator::IteratorData
63{ 63{
64 Addressee::List::Iterator mIt; 64 Addressee::List::Iterator mIt;
65}; 65};
66 66
67struct AddressBook::ConstIterator::ConstIteratorData 67struct AddressBook::ConstIterator::ConstIteratorData
68{ 68{
69 Addressee::List::ConstIterator mIt; 69 Addressee::List::ConstIterator mIt;
70}; 70};
71 71
72AddressBook::Iterator::Iterator() 72AddressBook::Iterator::Iterator()
73{ 73{
74 d = new IteratorData; 74 d = new IteratorData;
75} 75}
76 76
77AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 77AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
78{ 78{
79 d = new IteratorData; 79 d = new IteratorData;
80 d->mIt = i.d->mIt; 80 d->mIt = i.d->mIt;
81} 81}
82 82
83AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 83AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
84{ 84{
85 if( this == &i ) return *this; // guard against self assignment 85 if( this == &i ) return *this; // guard against self assignment
86 delete d; // delete the old data the Iterator was completely constructed before 86 delete d; // delete the old data the Iterator was completely constructed before
87 d = new IteratorData; 87 d = new IteratorData;
88 d->mIt = i.d->mIt; 88 d->mIt = i.d->mIt;
89 return *this; 89 return *this;
90} 90}
91 91
92AddressBook::Iterator::~Iterator() 92AddressBook::Iterator::~Iterator()
93{ 93{
94 delete d; 94 delete d;
95} 95}
96 96
97const Addressee &AddressBook::Iterator::operator*() const 97const Addressee &AddressBook::Iterator::operator*() const
98{ 98{
99 return *(d->mIt); 99 return *(d->mIt);
100} 100}
101 101
102Addressee &AddressBook::Iterator::operator*() 102Addressee &AddressBook::Iterator::operator*()
103{ 103{
104 return *(d->mIt); 104 return *(d->mIt);
105} 105}
106 106
107Addressee *AddressBook::Iterator::operator->() 107Addressee *AddressBook::Iterator::operator->()
108{ 108{
109 return &(*(d->mIt)); 109 return &(*(d->mIt));
110} 110}
111 111
112AddressBook::Iterator &AddressBook::Iterator::operator++() 112AddressBook::Iterator &AddressBook::Iterator::operator++()
113{ 113{
114 (d->mIt)++; 114 (d->mIt)++;
115 return *this; 115 return *this;
116} 116}
117 117
118AddressBook::Iterator &AddressBook::Iterator::operator++(int) 118AddressBook::Iterator &AddressBook::Iterator::operator++(int)
119{ 119{
120 (d->mIt)++; 120 (d->mIt)++;
121 return *this; 121 return *this;
122} 122}
123 123
124AddressBook::Iterator &AddressBook::Iterator::operator--() 124AddressBook::Iterator &AddressBook::Iterator::operator--()
125{ 125{
126 (d->mIt)--; 126 (d->mIt)--;
127 return *this; 127 return *this;
128} 128}
129 129
130AddressBook::Iterator &AddressBook::Iterator::operator--(int) 130AddressBook::Iterator &AddressBook::Iterator::operator--(int)
131{ 131{
132 (d->mIt)--; 132 (d->mIt)--;
133 return *this; 133 return *this;
134} 134}
135 135
136bool AddressBook::Iterator::operator==( const Iterator &it ) 136bool AddressBook::Iterator::operator==( const Iterator &it )
137{ 137{
138 return ( d->mIt == it.d->mIt ); 138 return ( d->mIt == it.d->mIt );
139} 139}
140 140
141bool AddressBook::Iterator::operator!=( const Iterator &it ) 141bool AddressBook::Iterator::operator!=( const Iterator &it )
142{ 142{
143 return ( d->mIt != it.d->mIt ); 143 return ( d->mIt != it.d->mIt );
144} 144}
145 145
146 146
147AddressBook::ConstIterator::ConstIterator() 147AddressBook::ConstIterator::ConstIterator()
148{ 148{
149 d = new ConstIteratorData; 149 d = new ConstIteratorData;
150} 150}
151 151
152AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 152AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
153{ 153{
154 d = new ConstIteratorData; 154 d = new ConstIteratorData;
155 d->mIt = i.d->mIt; 155 d->mIt = i.d->mIt;
156} 156}
157 157
158AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
159{ 159{
160 if( this == &i ) return *this; // guard for self assignment 160 if( this == &i ) return *this; // guard for self assignment
161 delete d; // delete the old data because the Iterator was really constructed before 161 delete d; // delete the old data because the Iterator was really constructed before
162 d = new ConstIteratorData; 162 d = new ConstIteratorData;
163 d->mIt = i.d->mIt; 163 d->mIt = i.d->mIt;
164 return *this; 164 return *this;
165} 165}
166 166
167AddressBook::ConstIterator::~ConstIterator() 167AddressBook::ConstIterator::~ConstIterator()
168{ 168{
169 delete d; 169 delete d;
170} 170}
171 171
172const Addressee &AddressBook::ConstIterator::operator*() const 172const Addressee &AddressBook::ConstIterator::operator*() const
173{ 173{
174 return *(d->mIt); 174 return *(d->mIt);
175} 175}
176 176
177const Addressee* AddressBook::ConstIterator::operator->() const 177const Addressee* AddressBook::ConstIterator::operator->() const
178{ 178{
179 return &(*(d->mIt)); 179 return &(*(d->mIt));
180} 180}
181 181
182AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 182AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
183{ 183{
184 (d->mIt)++; 184 (d->mIt)++;
185 return *this; 185 return *this;
186} 186}
187 187
188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
189{ 189{
190 (d->mIt)++; 190 (d->mIt)++;
191 return *this; 191 return *this;
192} 192}
193 193
194AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
195{ 195{
196 (d->mIt)--; 196 (d->mIt)--;
197 return *this; 197 return *this;
198} 198}
199 199
200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
201{ 201{
202 (d->mIt)--; 202 (d->mIt)--;
203 return *this; 203 return *this;
204} 204}
205 205
206bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 206bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
207{ 207{
208 return ( d->mIt == it.d->mIt ); 208 return ( d->mIt == it.d->mIt );
209} 209}
210 210
211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 211bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
212{ 212{
213 return ( d->mIt != it.d->mIt ); 213 return ( d->mIt != it.d->mIt );
214} 214}
215 215
216 216
217AddressBook::AddressBook() 217AddressBook::AddressBook()
218{ 218{
219 init(0, "contact"); 219 init(0, "contact");
220} 220}
221 221
222AddressBook::AddressBook( const QString &config ) 222AddressBook::AddressBook( const QString &config )
223{ 223{
224 init(config, "contact"); 224 init(config, "contact");
225} 225}
226 226
227AddressBook::AddressBook( const QString &config, const QString &family ) 227AddressBook::AddressBook( const QString &config, const QString &family )
228{ 228{
229 init(config, family); 229 init(config, family);
230 230
231} 231}
232 232
233// the default family is "contact" 233// the default family is "contact"
234void AddressBook::init(const QString &config, const QString &family ) 234void AddressBook::init(const QString &config, const QString &family )
235{ 235{
236 d = new AddressBookData; 236 d = new AddressBookData;
237 QString fami = family;
238 qDebug("new ab ");
237 if (config != 0) { 239 if (config != 0) {
240 qDebug("config != 0 ");
241 if ( family == "syncContact" ) {
242 qDebug("creating sync config ");
243 fami = "contact";
244 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
245 con->setGroup( "General" );
246 con->writeEntry( "ResourceKeys", QString("sync") );
247 con->writeEntry( "Standard", QString("sync") );
248 con->setGroup( "Resource_sync" );
249 con->writeEntry( "FileFormat", QString("vcard") );
250 con->writeEntry( "FileName", config );
251 con->writeEntry( "ResourceIdentifier", QString("sync") );
252 con->writeEntry( "ResourceName", QString("sync_res") );
253 con->writeEntry( "ResourceType", QString("file") );
254 //con->sync();
255 d->mConfig = con;
256 }
257 else
238 d->mConfig = new KConfig( locateLocal("config", config) ); 258 d->mConfig = new KConfig( locateLocal("config", config) );
239// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 259// qDebug("AddressBook::init 1 config=%s",config.latin1() );
240 } 260 }
241 else { 261 else {
242 d->mConfig = 0; 262 d->mConfig = 0;
243// qDebug("AddressBook::init 1 config=0"); 263// qDebug("AddressBook::init 1 config=0");
244 } 264 }
245 265
246//US d->mErrorHandler = 0; 266//US d->mErrorHandler = 0;
247 d->mManager = new KRES::Manager<Resource>( family, false ); 267 d->mManager = new KRES::Manager<Resource>( fami, false );
248 d->mManager->readConfig( d->mConfig ); 268 d->mManager->readConfig( d->mConfig );
269 if ( family == "syncContact" ) {
270 KRES::Manager<Resource> *manager = d->mManager;
271 KRES::Manager<Resource>::ActiveIterator it;
272 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
273 (*it)->setAddressBook( this );
274 if ( !(*it)->open() )
275 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
276 }
277 Resource *res = standardResource();
278 if ( !res ) {
279 qDebug("ERROR: no standard resource");
280 res = manager->createResource( "file" );
281 if ( res )
282 {
283 addResource( res );
284 }
285 else
286 qDebug(" No resource available!!!");
287 }
288 setStandardResource( res );
289 manager->writeConfig();
290 }
291 addCustomField( i18n( "Department" ), KABC::Field::Organization,
292 "X-Department", "KADDRESSBOOK" );
293 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
294 "X-Profession", "KADDRESSBOOK" );
295 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
296 "X-AssistantsName", "KADDRESSBOOK" );
297 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
298 "X-ManagersName", "KADDRESSBOOK" );
299 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
300 "X-SpousesName", "KADDRESSBOOK" );
301 addCustomField( i18n( "Office" ), KABC::Field::Personal,
302 "X-Office", "KADDRESSBOOK" );
303 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
304 "X-IMAddress", "KADDRESSBOOK" );
305 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
306 "X-Anniversary", "KADDRESSBOOK" );
307
308 //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 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
311 "X-Gender", "KADDRESSBOOK" );
312 addCustomField( i18n( "Children" ), KABC::Field::Personal,
313 "X-Children", "KADDRESSBOOK" );
314 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
315 "X-FreeBusyUrl", "KADDRESSBOOK" );
316 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
317 "X-ExternalID", "KADDRESSBOOK" );
249} 318}
250 319
251AddressBook::~AddressBook() 320AddressBook::~AddressBook()
252{ 321{
253 delete d->mConfig; d->mConfig = 0; 322 delete d->mConfig; d->mConfig = 0;
254 delete d->mManager; d->mManager = 0; 323 delete d->mManager; d->mManager = 0;
255//US delete d->mErrorHandler; d->mErrorHandler = 0; 324//US delete d->mErrorHandler; d->mErrorHandler = 0;
256 delete d; d = 0; 325 delete d; d = 0;
257} 326}
258 327
259bool AddressBook::load() 328bool AddressBook::load()
260{ 329{
261 330
262 331
263 clear(); 332 clear();
264 333
265 KRES::Manager<Resource>::ActiveIterator it; 334 KRES::Manager<Resource>::ActiveIterator it;
266 bool ok = true; 335 bool ok = true;
267 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 336 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
268 if ( !(*it)->load() ) { 337 if ( !(*it)->load() ) {
269 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 338 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
270 ok = false; 339 ok = false;
271 } 340 }
272 341
273 // mark all addressees as unchanged 342 // mark all addressees as unchanged
274 Addressee::List::Iterator addrIt; 343 Addressee::List::Iterator addrIt;
275 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) 344 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt )
276 (*addrIt).setChanged( false ); 345 (*addrIt).setChanged( false );
277 346
278 return ok; 347 return ok;
279} 348}
280 349
281bool AddressBook::save( Ticket *ticket ) 350bool AddressBook::save( Ticket *ticket )
282{ 351{
283 kdDebug(5700) << "AddressBook::save()"<< endl; 352 kdDebug(5700) << "AddressBook::save()"<< endl;
284 353
285 if ( ticket->resource() ) { 354 if ( ticket->resource() ) {
286 deleteRemovedAddressees(); 355 deleteRemovedAddressees();
287
288 return ticket->resource()->save( ticket ); 356 return ticket->resource()->save( ticket );
289 } 357 }
290 358
291 return false; 359 return false;
292} 360}
361bool AddressBook::saveAB()
362{
363 bool ok = true;
364
365 deleteRemovedAddressees();
366
367 KRES::Manager<Resource>::ActiveIterator it;
368 KRES::Manager<Resource> *manager = d->mManager;
369 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
370 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
371 Ticket *ticket = requestSaveTicket( *it );
372// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
373 if ( !ticket ) {
374 error( i18n( "Unable to save to resource '%1'. It is locked." )
375 .arg( (*it)->resourceName() ) );
376 return false;
377 }
378
379 //if ( !save( ticket ) )
380 if ( ticket->resource() ) {
381 if ( ! ticket->resource()->save( ticket ) )
382 ok = false;
383 } else
384 ok = false;
385
386 }
387 }
388 return ok;
389}
293 390
294AddressBook::Iterator AddressBook::begin() 391AddressBook::Iterator AddressBook::begin()
295{ 392{
296 Iterator it = Iterator(); 393 Iterator it = Iterator();
297 it.d->mIt = d->mAddressees.begin(); 394 it.d->mIt = d->mAddressees.begin();
298 return it; 395 return it;
299} 396}
300 397
301AddressBook::ConstIterator AddressBook::begin() const 398AddressBook::ConstIterator AddressBook::begin() const
302{ 399{
303 ConstIterator it = ConstIterator(); 400 ConstIterator it = ConstIterator();
304 it.d->mIt = d->mAddressees.begin(); 401 it.d->mIt = d->mAddressees.begin();
305 return it; 402 return it;
306} 403}
307 404
308AddressBook::Iterator AddressBook::end() 405AddressBook::Iterator AddressBook::end()
309{ 406{
310 Iterator it = Iterator(); 407 Iterator it = Iterator();
311 it.d->mIt = d->mAddressees.end(); 408 it.d->mIt = d->mAddressees.end();
312 return it; 409 return it;
313} 410}
314 411
315AddressBook::ConstIterator AddressBook::end() const 412AddressBook::ConstIterator AddressBook::end() const
316{ 413{
317 ConstIterator it = ConstIterator(); 414 ConstIterator it = ConstIterator();
318 it.d->mIt = d->mAddressees.end(); 415 it.d->mIt = d->mAddressees.end();
319 return it; 416 return it;
320} 417}
321 418
322void AddressBook::clear() 419void AddressBook::clear()
323{ 420{
324 d->mAddressees.clear(); 421 d->mAddressees.clear();
325} 422}
326 423
327Ticket *AddressBook::requestSaveTicket( Resource *resource ) 424Ticket *AddressBook::requestSaveTicket( Resource *resource )
328{ 425{
329 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 426 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
330 427
331 if ( !resource ) 428 if ( !resource )
332 { 429 {
333 qDebug("AddressBook::requestSaveTicket no resource" ); 430 qDebug("AddressBook::requestSaveTicket no resource" );
334 resource = standardResource(); 431 resource = standardResource();
335 } 432 }
336 433
337 KRES::Manager<Resource>::ActiveIterator it; 434 KRES::Manager<Resource>::ActiveIterator it;
338 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 435 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
339 if ( (*it) == resource ) { 436 if ( (*it) == resource ) {
340 if ( (*it)->readOnly() || !(*it)->isOpen() ) 437 if ( (*it)->readOnly() || !(*it)->isOpen() )
341 return 0; 438 return 0;
342 else 439 else
343 return (*it)->requestSaveTicket(); 440 return (*it)->requestSaveTicket();
344 } 441 }
345 } 442 }
346 443
347 return 0; 444 return 0;
348} 445}
349 446
350void AddressBook::insertAddressee( const Addressee &a ) 447void AddressBook::insertAddressee( const Addressee &a )
351{ 448{
352 Addressee::List::Iterator it; 449 Addressee::List::Iterator it;
353 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 450 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
354 if ( a.uid() == (*it).uid() ) { 451 if ( a.uid() == (*it).uid() ) {
355 bool changed = false; 452 bool changed = false;
356 Addressee addr = a; 453 Addressee addr = a;
357 if ( addr != (*it) ) 454 if ( addr != (*it) )
358 changed = true; 455 changed = true;
359 456
360 (*it) = a; 457 (*it) = a;
361 if ( (*it).resource() == 0 ) 458 if ( (*it).resource() == 0 )
362 (*it).setResource( standardResource() ); 459 (*it).setResource( standardResource() );
363 460
364 if ( changed ) { 461 if ( changed ) {
365 (*it).setRevision( QDateTime::currentDateTime() ); 462 (*it).setRevision( QDateTime::currentDateTime() );
366 (*it).setChanged( true ); 463 (*it).setChanged( true );
367 } 464 }
368 465
369 return; 466 return;
370 } 467 }
371 } 468 }
372 d->mAddressees.append( a ); 469 d->mAddressees.append( a );
373 Addressee& addr = d->mAddressees.last(); 470 Addressee& addr = d->mAddressees.last();
374 if ( addr.resource() == 0 ) 471 if ( addr.resource() == 0 )
375 addr.setResource( standardResource() ); 472 addr.setResource( standardResource() );
376 473
377 addr.setChanged( true ); 474 addr.setChanged( true );
378} 475}
379 476
380void AddressBook::removeAddressee( const Addressee &a ) 477void AddressBook::removeAddressee( const Addressee &a )
381{ 478{
382 Iterator it; 479 Iterator it;
383 for ( it = begin(); it != end(); ++it ) { 480 for ( it = begin(); it != end(); ++it ) {
384 if ( a.uid() == (*it).uid() ) { 481 if ( a.uid() == (*it).uid() ) {
385 removeAddressee( it ); 482 removeAddressee( it );
386 return; 483 return;
387 } 484 }
388 } 485 }
389} 486}
390 487
391void AddressBook::removeAddressee( const Iterator &it ) 488void AddressBook::removeAddressee( const Iterator &it )
392{ 489{
393 d->mRemovedAddressees.append( (*it) ); 490 d->mRemovedAddressees.append( (*it) );
394 d->mAddressees.remove( it.d->mIt ); 491 d->mAddressees.remove( it.d->mIt );
395} 492}
396 493
397AddressBook::Iterator AddressBook::find( const Addressee &a ) 494AddressBook::Iterator AddressBook::find( const Addressee &a )
398{ 495{
399 Iterator it; 496 Iterator it;
400 for ( it = begin(); it != end(); ++it ) { 497 for ( it = begin(); it != end(); ++it ) {
401 if ( a.uid() == (*it).uid() ) { 498 if ( a.uid() == (*it).uid() ) {
402 return it; 499 return it;
403 } 500 }
404 } 501 }
405 return end(); 502 return end();
406} 503}
407 504
408Addressee AddressBook::findByUid( const QString &uid ) 505Addressee AddressBook::findByUid( const QString &uid )
409{ 506{
410 Iterator it; 507 Iterator it;
411 for ( it = begin(); it != end(); ++it ) { 508 for ( it = begin(); it != end(); ++it ) {
412 if ( uid == (*it).uid() ) { 509 if ( uid == (*it).uid() ) {
413 return *it; 510 return *it;
414 } 511 }
415 } 512 }
416 return Addressee(); 513 return Addressee();
417} 514}
418 515
419Addressee::List AddressBook::allAddressees() 516Addressee::List AddressBook::allAddressees()
420{ 517{
421 return d->mAddressees; 518 return d->mAddressees;
422} 519}
423 520
424Addressee::List AddressBook::findByName( const QString &name ) 521Addressee::List AddressBook::findByName( const QString &name )
425{ 522{
426 Addressee::List results; 523 Addressee::List results;
427 524
428 Iterator it; 525 Iterator it;
429 for ( it = begin(); it != end(); ++it ) { 526 for ( it = begin(); it != end(); ++it ) {
430 if ( name == (*it).realName() ) { 527 if ( name == (*it).realName() ) {
431 results.append( *it ); 528 results.append( *it );
432 } 529 }
433 } 530 }
434 531
435 return results; 532 return results;
436} 533}
437 534
438Addressee::List AddressBook::findByEmail( const QString &email ) 535Addressee::List AddressBook::findByEmail( const QString &email )
439{ 536{
440 Addressee::List results; 537 Addressee::List results;
441 QStringList mailList; 538 QStringList mailList;
442 539
443 Iterator it; 540 Iterator it;
444 for ( it = begin(); it != end(); ++it ) { 541 for ( it = begin(); it != end(); ++it ) {
445 mailList = (*it).emails(); 542 mailList = (*it).emails();
446 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 543 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
447 if ( email == (*ite) ) { 544 if ( email == (*ite) ) {
448 results.append( *it ); 545 results.append( *it );
449 } 546 }
450 } 547 }
451 } 548 }
452 549
453 return results; 550 return results;
454} 551}
455 552
456Addressee::List AddressBook::findByCategory( const QString &category ) 553Addressee::List AddressBook::findByCategory( const QString &category )
457{ 554{
458 Addressee::List results; 555 Addressee::List results;
459 556
460 Iterator it; 557 Iterator it;
461 for ( it = begin(); it != end(); ++it ) { 558 for ( it = begin(); it != end(); ++it ) {
462 if ( (*it).hasCategory( category) ) { 559 if ( (*it).hasCategory( category) ) {
463 results.append( *it ); 560 results.append( *it );
464 } 561 }
465 } 562 }
466 563
467 return results; 564 return results;
468} 565}
469 566
470void AddressBook::dump() const 567void AddressBook::dump() const
471{ 568{
472 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 569 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
473 570
474 ConstIterator it; 571 ConstIterator it;
475 for( it = begin(); it != end(); ++it ) { 572 for( it = begin(); it != end(); ++it ) {
476 (*it).dump(); 573 (*it).dump();
477 } 574 }
478 575
479 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 576 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
480} 577}
481 578
482QString AddressBook::identifier() 579QString AddressBook::identifier()
483{ 580{
484 QStringList identifier; 581 QStringList identifier;
485 582
486 583
487 KRES::Manager<Resource>::ActiveIterator it; 584 KRES::Manager<Resource>::ActiveIterator it;
488 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 585 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
489 if ( !(*it)->identifier().isEmpty() ) 586 if ( !(*it)->identifier().isEmpty() )
490 identifier.append( (*it)->identifier() ); 587 identifier.append( (*it)->identifier() );
491 } 588 }
492 589
493 return identifier.join( ":" ); 590 return identifier.join( ":" );
494} 591}
495 592
496Field::List AddressBook::fields( int category ) 593Field::List AddressBook::fields( int category )
497{ 594{
498 if ( d->mAllFields.isEmpty() ) { 595 if ( d->mAllFields.isEmpty() ) {
499 d->mAllFields = Field::allFields(); 596 d->mAllFields = Field::allFields();
500 } 597 }
501 598
502 if ( category == Field::All ) return d->mAllFields; 599 if ( category == Field::All ) return d->mAllFields;
503 600
504 Field::List result; 601 Field::List result;
505 Field::List::ConstIterator it; 602 Field::List::ConstIterator it;
506 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 603 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
507 if ( (*it)->category() & category ) result.append( *it ); 604 if ( (*it)->category() & category ) result.append( *it );
508 } 605 }
509 606
510 return result; 607 return result;
511} 608}
512 609
513bool AddressBook::addCustomField( const QString &label, int category, 610bool AddressBook::addCustomField( const QString &label, int category,
514 const QString &key, const QString &app ) 611 const QString &key, const QString &app )
515{ 612{
516 if ( d->mAllFields.isEmpty() ) { 613 if ( d->mAllFields.isEmpty() ) {
517 d->mAllFields = Field::allFields(); 614 d->mAllFields = Field::allFields();
518 } 615 }
519//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 616//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
520 QString a = app.isNull() ? KGlobal::getAppName() : app; 617 QString a = app.isNull() ? KGlobal::getAppName() : app;
521 618
522 QString k = key.isNull() ? label : key; 619 QString k = key.isNull() ? label : key;
523 620
524 Field *field = Field::createCustomField( label, category, k, a ); 621 Field *field = Field::createCustomField( label, category, k, a );
525 622
526 if ( !field ) return false; 623 if ( !field ) return false;
527 624
528 d->mAllFields.append( field ); 625 d->mAllFields.append( field );
529 626
530 return true; 627 return true;
531} 628}
532 629
533QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 630QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
534{ 631{
535 if (!ab.d) return s; 632 if (!ab.d) return s;
536 633
537 return s << ab.d->mAddressees; 634 return s << ab.d->mAddressees;
538} 635}
539 636
540QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 637QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
541{ 638{
542 if (!ab.d) return s; 639 if (!ab.d) return s;
543 640
544 s >> ab.d->mAddressees; 641 s >> ab.d->mAddressees;
545 642
546 return s; 643 return s;
547} 644}
548 645
549bool AddressBook::addResource( Resource *resource ) 646bool AddressBook::addResource( Resource *resource )
550{ 647{
551 if ( !resource->open() ) { 648 if ( !resource->open() ) {
552 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 649 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
553 return false; 650 return false;
554 } 651 }
555 652
556 resource->setAddressBook( this ); 653 resource->setAddressBook( this );
557 654
558 d->mManager->add( resource ); 655 d->mManager->add( resource );
559 return true; 656 return true;
560} 657}
561 658
562bool AddressBook::removeResource( Resource *resource ) 659bool AddressBook::removeResource( Resource *resource )
563{ 660{
564 resource->close(); 661 resource->close();
565 662
566 if ( resource == standardResource() ) 663 if ( resource == standardResource() )
567 d->mManager->setStandardResource( 0 ); 664 d->mManager->setStandardResource( 0 );
568 665
569 resource->setAddressBook( 0 ); 666 resource->setAddressBook( 0 );
570 667
571 d->mManager->remove( resource ); 668 d->mManager->remove( resource );
572 return true; 669 return true;
573} 670}
574 671
575QPtrList<Resource> AddressBook::resources() 672QPtrList<Resource> AddressBook::resources()
576{ 673{
577 QPtrList<Resource> list; 674 QPtrList<Resource> list;
578 675
579// qDebug("AddressBook::resources() 1"); 676// qDebug("AddressBook::resources() 1");
580 677
581 KRES::Manager<Resource>::ActiveIterator it; 678 KRES::Manager<Resource>::ActiveIterator it;
582 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 679 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
583 list.append( *it ); 680 list.append( *it );
584 681
585 return list; 682 return list;
586} 683}
587 684
588/*US 685/*US
589void AddressBook::setErrorHandler( ErrorHandler *handler ) 686void AddressBook::setErrorHandler( ErrorHandler *handler )
590{ 687{
591 delete d->mErrorHandler; 688 delete d->mErrorHandler;
592 d->mErrorHandler = handler; 689 d->mErrorHandler = handler;
593} 690}
594*/ 691*/
595 692
596void AddressBook::error( const QString& msg ) 693void AddressBook::error( const QString& msg )
597{ 694{
598/*US 695/*US
599 if ( !d->mErrorHandler ) // create default error handler 696 if ( !d->mErrorHandler ) // create default error handler
600 d->mErrorHandler = new ConsoleErrorHandler; 697 d->mErrorHandler = new ConsoleErrorHandler;
601 698
602 if ( d->mErrorHandler ) 699 if ( d->mErrorHandler )
603 d->mErrorHandler->error( msg ); 700 d->mErrorHandler->error( msg );
604 else 701 else
605 kdError(5700) << "no error handler defined" << endl; 702 kdError(5700) << "no error handler defined" << endl;
606*/ 703*/
607 kdDebug(5700) << "msg" << endl; 704 kdDebug(5700) << "msg" << endl;
608 qDebug(msg); 705 qDebug(msg);
609} 706}
610 707
611void AddressBook::deleteRemovedAddressees() 708void AddressBook::deleteRemovedAddressees()
612{ 709{
613 Addressee::List::Iterator it; 710 Addressee::List::Iterator it;
614 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 711 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
615 Resource *resource = (*it).resource(); 712 Resource *resource = (*it).resource();
616 if ( resource && !resource->readOnly() && resource->isOpen() ) 713 if ( resource && !resource->readOnly() && resource->isOpen() )
617 resource->removeAddressee( *it ); 714 resource->removeAddressee( *it );
618 } 715 }
619 716
620 d->mRemovedAddressees.clear(); 717 d->mRemovedAddressees.clear();
621} 718}
622 719
623void AddressBook::setStandardResource( Resource *resource ) 720void AddressBook::setStandardResource( Resource *resource )
624{ 721{
625// qDebug("AddressBook::setStandardResource 1"); 722// qDebug("AddressBook::setStandardResource 1");
626 d->mManager->setStandardResource( resource ); 723 d->mManager->setStandardResource( resource );
627} 724}
628 725
629Resource *AddressBook::standardResource() 726Resource *AddressBook::standardResource()
630{ 727{
631 return d->mManager->standardResource(); 728 return d->mManager->standardResource();
632} 729}
633 730
634KRES::Manager<Resource> *AddressBook::resourceManager() 731KRES::Manager<Resource> *AddressBook::resourceManager()
635{ 732{
636 return d->mManager; 733 return d->mManager;
637} 734}
638 735
639void AddressBook::cleanUp() 736void AddressBook::cleanUp()
640{ 737{
641 KRES::Manager<Resource>::ActiveIterator it; 738 KRES::Manager<Resource>::ActiveIterator it;
642 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 739 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
643 if ( !(*it)->readOnly() && (*it)->isOpen() ) 740 if ( !(*it)->readOnly() && (*it)->isOpen() )
644 (*it)->cleanUp(); 741 (*it)->cleanUp();
645 } 742 }
646} 743}
diff --git a/kabc/addressbook.h b/kabc/addressbook.h
index f89d7da..e43de31 100644
--- a/kabc/addressbook.h
+++ b/kabc/addressbook.h
@@ -1,327 +1,328 @@
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/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (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
39namespace KABC { 39namespace KABC {
40 40
41class ErrorHandler; 41class ErrorHandler;
42class Resource; 42class Resource;
43class Ticket; 43class 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*/
50class AddressBook : public QObject 50class 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 145
145 /** 146 /**
146 Returns a iterator for first entry of address book. 147 Returns a iterator for first entry of address book.
147 */ 148 */
148 Iterator begin(); 149 Iterator begin();
149 150
150 /** 151 /**
151 Returns a const iterator for first entry of address book. 152 Returns a const iterator for first entry of address book.
152 */ 153 */
153 ConstIterator begin() const; 154 ConstIterator begin() const;
154 155
155 /** 156 /**
156 Returns a iterator for first entry of address book. 157 Returns a iterator for first entry of address book.
157 */ 158 */
158 Iterator end(); 159 Iterator end();
159 160
160 /** 161 /**
161 Returns a const iterator for first entry of address book. 162 Returns a const iterator for first entry of address book.
162 */ 163 */
163 ConstIterator end() const; 164 ConstIterator end() const;
164 165
165 /** 166 /**
166 Removes all entries from address book. 167 Removes all entries from address book.
167 */ 168 */
168 void clear(); 169 void clear();
169 170
170 /** 171 /**
171 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
172 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
173 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.
174 */ 175 */
175 void insertAddressee( const Addressee & ); 176 void insertAddressee( const Addressee & );
176 177
177 /** 178 /**
178 Removes entry from the address book. 179 Removes entry from the address book.
179 */ 180 */
180 void removeAddressee( const Addressee & ); 181 void removeAddressee( const Addressee & );
181 182
182 /** 183 /**
183 This is like @ref removeAddressee() just above, with the difference that 184 This is like @ref removeAddressee() just above, with the difference that
184 the first element is a iterator, returned by @ref begin(). 185 the first element is a iterator, returned by @ref begin().
185 */ 186 */
186 void removeAddressee( const Iterator & ); 187 void removeAddressee( const Iterator & );
187 188
188 /** 189 /**
189 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
190 couldn't be found. 191 couldn't be found.
191 */ 192 */
192 Iterator find( const Addressee & ); 193 Iterator find( const Addressee & );
193 194
194 /** 195 /**
195 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
196 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.
197 */ 198 */
198 Addressee findByUid( const QString & ); 199 Addressee findByUid( const QString & );
199 200
200 201
201 /** 202 /**
202 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
203 be sorted with @ref KABC::AddresseeList for example. 204 be sorted with @ref KABC::AddresseeList for example.
204 */ 205 */
205 Addressee::List allAddressees(); 206 Addressee::List allAddressees();
206 207
207 /** 208 /**
208 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
209 an empty list, if no entries could be found. 210 an empty list, if no entries could be found.
210 */ 211 */
211 Addressee::List findByName( const QString & ); 212 Addressee::List findByName( const QString & );
212 213
213 /** 214 /**
214 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.
215 Returns an empty list, if no entries could be found. 216 Returns an empty list, if no entries could be found.
216 */ 217 */
217 Addressee::List findByEmail( const QString & ); 218 Addressee::List findByEmail( const QString & );
218 219
219 /** 220 /**
220 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.
221 Returns an empty list, if no entries could be found. 222 Returns an empty list, if no entries could be found.
222 */ 223 */
223 Addressee::List findByCategory( const QString & ); 224 Addressee::List findByCategory( const QString & );
224 225
225 /** 226 /**
226 Return a string identifying this addressbook. 227 Return a string identifying this addressbook.
227 */ 228 */
228 virtual QString identifier(); 229 virtual QString identifier();
229 230
230 /** 231 /**
231 Used for debug output. 232 Used for debug output.
232 */ 233 */
233 void dump() const; 234 void dump() const;
234 235
235 void emitAddressBookLocked() { emit addressBookLocked( this ); } 236 void emitAddressBookLocked() { emit addressBookLocked( this ); }
236 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); } 237 void emitAddressBookUnlocked() { emit addressBookUnlocked( this ); }
237 void emitAddressBookChanged() { emit addressBookChanged( this ); } 238 void emitAddressBookChanged() { emit addressBookChanged( this ); }
238 239
239 /** 240 /**
240 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
241 with the given field category. 242 with the given field category.
242 */ 243 */
243 Field::List fields( int category = Field::All ); 244 Field::List fields( int category = Field::All );
244 245
245 /** 246 /**
246 Add custom field to address book. 247 Add custom field to address book.
247 248
248 @param label User visible label of the field. 249 @param label User visible label of the field.
249 @param category Ored list of field categories. 250 @param category Ored list of field categories.
250 @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.
251 @param app String used as application key for reading and writing 252 @param app String used as application key for reading and writing
252 the field. 253 the field.
253 */ 254 */
254 bool addCustomField( const QString &label, int category = Field::All, 255 bool addCustomField( const QString &label, int category = Field::All,
255 const QString &key = QString::null, 256 const QString &key = QString::null,
256 const QString &app = QString::null ); 257 const QString &app = QString::null );
257 258
258 259
259 /** 260 /**
260 Add address book resource. 261 Add address book resource.
261 */ 262 */
262 bool addResource( Resource * ); 263 bool addResource( Resource * );
263 264
264 /** 265 /**
265 Remove address book resource. 266 Remove address book resource.
266 */ 267 */
267 bool removeResource( Resource * ); 268 bool removeResource( Resource * );
268 269
269 /** 270 /**
270 Return pointer list of all resources. 271 Return pointer list of all resources.
271 */ 272 */
272 QPtrList<Resource> resources(); 273 QPtrList<Resource> resources();
273 274
274 /** 275 /**
275 Set the @p ErrorHandler, that is used by @ref error() to 276 Set the @p ErrorHandler, that is used by @ref error() to
276 provide gui-independend error messages. 277 provide gui-independend error messages.
277 */ 278 */
278 void setErrorHandler( ErrorHandler * ); 279 void setErrorHandler( ErrorHandler * );
279 280
280 /** 281 /**
281 Shows gui independend error messages. 282 Shows gui independend error messages.
282 */ 283 */
283 void error( const QString& ); 284 void error( const QString& );
284 285
285 /** 286 /**
286 Query all resources to clean up their lock files 287 Query all resources to clean up their lock files
287 */ 288 */
288 void cleanUp(); 289 void cleanUp();
289 290
290 signals: 291 signals:
291 /** 292 /**
292 Emitted, when the address book has changed on disk. 293 Emitted, when the address book has changed on disk.
293 */ 294 */
294 void addressBookChanged( AddressBook * ); 295 void addressBookChanged( AddressBook * );
295 296
296 /** 297 /**
297 Emitted, when the address book has been locked for writing. 298 Emitted, when the address book has been locked for writing.
298 */ 299 */
299 void addressBookLocked( AddressBook * ); 300 void addressBookLocked( AddressBook * );
300 301
301 /** 302 /**
302 Emitted, when the address book has been unlocked. 303 Emitted, when the address book has been unlocked.
303 */ 304 */
304 void addressBookUnlocked( AddressBook * ); 305 void addressBookUnlocked( AddressBook * );
305 306
306 protected: 307 protected:
307 void deleteRemovedAddressees(); 308 void deleteRemovedAddressees();
308 void setStandardResource( Resource * ); 309 void setStandardResource( Resource * );
309 Resource *standardResource(); 310 Resource *standardResource();
310 KRES::Manager<Resource> *resourceManager(); 311 KRES::Manager<Resource> *resourceManager();
311 312
312 void init(const QString &config, const QString &family); 313 void init(const QString &config, const QString &family);
313 314
314 private: 315 private:
315//US QPtrList<Resource> mDummy; // Remove in KDE 4 316//US QPtrList<Resource> mDummy; // Remove in KDE 4
316 317
317 318
318 struct AddressBookData; 319 struct AddressBookData;
319 AddressBookData *d; 320 AddressBookData *d;
320}; 321};
321 322
322QDataStream &operator<<( QDataStream &, const AddressBook & ); 323QDataStream &operator<<( QDataStream &, const AddressBook & );
323QDataStream &operator>>( QDataStream &, AddressBook & ); 324QDataStream &operator>>( QDataStream &, AddressBook & );
324 325
325} 326}
326 327
327#endif 328#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 49c3b19..e912941 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2543 +1,2612 @@
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/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (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 152
152 153
153bool pasteWithNewUid = true; 154bool pasteWithNewUid = true;
154 155
155#ifdef KAB_EMBEDDED 156#ifdef KAB_EMBEDDED
156KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 157KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
157 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 158 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
158 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 159 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
159 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 160 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
160#else //KAB_EMBEDDED 161#else //KAB_EMBEDDED
161KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 162KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
162 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 163 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
163 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 164 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
164 mReadWrite( readWrite ), mModified( false ) 165 mReadWrite( readWrite ), mModified( false )
165#endif //KAB_EMBEDDED 166#endif //KAB_EMBEDDED
166{ 167{
167 168
168 mBlockSaveFlag = false; 169 mBlockSaveFlag = false;
169 mExtensionBarSplitter = 0; 170 mExtensionBarSplitter = 0;
170 mIsPart = !parent->inherits( "KAddressBookMain" ); 171 mIsPart = !parent->inherits( "KAddressBookMain" );
171 172
172 mAddressBook = KABC::StdAddressBook::self(); 173 mAddressBook = KABC::StdAddressBook::self();
173 KABC::StdAddressBook::setAutomaticSave( false ); 174 KABC::StdAddressBook::setAutomaticSave( false );
174 175
175#ifndef KAB_EMBEDDED 176#ifndef KAB_EMBEDDED
176 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 177 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
177#endif //KAB_EMBEDDED 178#endif //KAB_EMBEDDED
178 179
179 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 180 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
180 SLOT( addressBookChanged() ) ); 181 SLOT( addressBookChanged() ) );
181 182
183#if 0
184 // LP moved to addressbook init method
182 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 185 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
183 "X-Department", "KADDRESSBOOK" ); 186 "X-Department", "KADDRESSBOOK" );
184 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 187 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
185 "X-Profession", "KADDRESSBOOK" ); 188 "X-Profession", "KADDRESSBOOK" );
186 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 189 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
187 "X-AssistantsName", "KADDRESSBOOK" ); 190 "X-AssistantsName", "KADDRESSBOOK" );
188 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 191 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
189 "X-ManagersName", "KADDRESSBOOK" ); 192 "X-ManagersName", "KADDRESSBOOK" );
190 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 193 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
191 "X-SpousesName", "KADDRESSBOOK" ); 194 "X-SpousesName", "KADDRESSBOOK" );
192 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 195 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
193 "X-Office", "KADDRESSBOOK" ); 196 "X-Office", "KADDRESSBOOK" );
194 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 197 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
195 "X-IMAddress", "KADDRESSBOOK" ); 198 "X-IMAddress", "KADDRESSBOOK" );
196 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 199 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
197 "X-Anniversary", "KADDRESSBOOK" ); 200 "X-Anniversary", "KADDRESSBOOK" );
198 201
199 //US added this field to become compatible with Opie/qtopia addressbook 202 //US added this field to become compatible with Opie/qtopia addressbook
200 // 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.
201 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 204 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
202 "X-Gender", "KADDRESSBOOK" ); 205 "X-Gender", "KADDRESSBOOK" );
203 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 206 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
204 "X-Children", "KADDRESSBOOK" ); 207 "X-Children", "KADDRESSBOOK" );
205 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 208 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
206 "X-FreeBusyUrl", "KADDRESSBOOK" ); 209 "X-FreeBusyUrl", "KADDRESSBOOK" );
207 210#endif
208 initGUI(); 211 initGUI();
209 212
210 mIncSearchWidget->setFocus(); 213 mIncSearchWidget->setFocus();
211 214
212 215
213 connect( mViewManager, SIGNAL( selected( const QString& ) ), 216 connect( mViewManager, SIGNAL( selected( const QString& ) ),
214 SLOT( setContactSelected( const QString& ) ) ); 217 SLOT( setContactSelected( const QString& ) ) );
215 connect( mViewManager, SIGNAL( executed( const QString& ) ), 218 connect( mViewManager, SIGNAL( executed( const QString& ) ),
216 SLOT( executeContact( const QString& ) ) ); 219 SLOT( executeContact( const QString& ) ) );
217 220
218 connect( mViewManager, SIGNAL( deleteRequest( ) ), 221 connect( mViewManager, SIGNAL( deleteRequest( ) ),
219 SLOT( deleteContacts( ) ) ); 222 SLOT( deleteContacts( ) ) );
220 connect( mViewManager, SIGNAL( modified() ), 223 connect( mViewManager, SIGNAL( modified() ),
221 SLOT( setModified() ) ); 224 SLOT( setModified() ) );
222 225
223 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& ) ) );
224 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 227 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
225 228
226 connect( mXXPortManager, SIGNAL( modified() ), 229 connect( mXXPortManager, SIGNAL( modified() ),
227 SLOT( setModified() ) ); 230 SLOT( setModified() ) );
228 231
229 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 232 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
230 SLOT( incrementalSearch( const QString& ) ) ); 233 SLOT( incrementalSearch( const QString& ) ) );
231 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 234 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
232 mJumpButtonBar, SLOT( recreateButtons() ) ); 235 mJumpButtonBar, SLOT( recreateButtons() ) );
233 236
234 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 237 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
235 SLOT( sendMail( const QString& ) ) ); 238 SLOT( sendMail( const QString& ) ) );
236 239
237 240
238 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&)));
239 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&)));
240 243
241 244
242#ifndef KAB_EMBEDDED 245#ifndef KAB_EMBEDDED
243 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 246 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
244 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 247 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
245 248
246 connect( mDetails, SIGNAL( browse( const QString& ) ), 249 connect( mDetails, SIGNAL( browse( const QString& ) ),
247 SLOT( browse( const QString& ) ) ); 250 SLOT( browse( const QString& ) ) );
248 251
249 252
250 mAddressBookService = new KAddressBookService( this ); 253 mAddressBookService = new KAddressBookService( this );
251 254
252#endif //KAB_EMBEDDED 255#endif //KAB_EMBEDDED
253 mEditorDialog = 0; 256 mEditorDialog = 0;
254 createAddresseeEditorDialog( this ); 257 createAddresseeEditorDialog( this );
255 setModified( false ); 258 setModified( false );
256} 259}
257 260
258KABCore::~KABCore() 261KABCore::~KABCore()
259{ 262{
260 // save(); 263 // save();
261 //saveSettings(); 264 //saveSettings();
262 //KABPrefs::instance()->writeConfig(); 265 //KABPrefs::instance()->writeConfig();
263 delete AddresseeConfig::instance(); 266 delete AddresseeConfig::instance();
264 mAddressBook = 0; 267 mAddressBook = 0;
265 KABC::StdAddressBook::close(); 268 KABC::StdAddressBook::close();
266} 269}
267 270
268void KABCore::restoreSettings() 271void KABCore::restoreSettings()
269{ 272{
270 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 273 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
271 274
272 bool state; 275 bool state;
273 276
274 if (mMultipleViewsAtOnce) 277 if (mMultipleViewsAtOnce)
275 state = KABPrefs::instance()->mDetailsPageVisible; 278 state = KABPrefs::instance()->mDetailsPageVisible;
276 else 279 else
277 state = false; 280 state = false;
278 281
279 mActionDetails->setChecked( state ); 282 mActionDetails->setChecked( state );
280 setDetailsVisible( state ); 283 setDetailsVisible( state );
281 284
282 state = KABPrefs::instance()->mJumpButtonBarVisible; 285 state = KABPrefs::instance()->mJumpButtonBarVisible;
283 286
284 mActionJumpBar->setChecked( state ); 287 mActionJumpBar->setChecked( state );
285 setJumpButtonBarVisible( state ); 288 setJumpButtonBarVisible( state );
286/*US 289/*US
287 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 290 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
288 if ( splitterSize.count() == 0 ) { 291 if ( splitterSize.count() == 0 ) {
289 splitterSize.append( width() / 2 ); 292 splitterSize.append( width() / 2 );
290 splitterSize.append( width() / 2 ); 293 splitterSize.append( width() / 2 );
291 } 294 }
292 mMiniSplitter->setSizes( splitterSize ); 295 mMiniSplitter->setSizes( splitterSize );
293 if ( mExtensionBarSplitter ) { 296 if ( mExtensionBarSplitter ) {
294 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 297 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
295 if ( splitterSize.count() == 0 ) { 298 if ( splitterSize.count() == 0 ) {
296 splitterSize.append( width() / 2 ); 299 splitterSize.append( width() / 2 );
297 splitterSize.append( width() / 2 ); 300 splitterSize.append( width() / 2 );
298 } 301 }
299 mExtensionBarSplitter->setSizes( splitterSize ); 302 mExtensionBarSplitter->setSizes( splitterSize );
300 303
301 } 304 }
302*/ 305*/
303 mViewManager->restoreSettings(); 306 mViewManager->restoreSettings();
304 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 307 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
305 mExtensionManager->restoreSettings(); 308 mExtensionManager->restoreSettings();
306#ifdef DESKTOP_VERSION 309#ifdef DESKTOP_VERSION
307 int wid = width(); 310 int wid = width();
308 if ( wid < 10 ) 311 if ( wid < 10 )
309 wid = 400; 312 wid = 400;
310#else 313#else
311 int wid = QApplication::desktop()->width(); 314 int wid = QApplication::desktop()->width();
312 if ( wid < 640 ) 315 if ( wid < 640 )
313 wid = QApplication::desktop()->height(); 316 wid = QApplication::desktop()->height();
314#endif 317#endif
315 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 318 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
316 if ( true /*splitterSize.count() == 0*/ ) { 319 if ( true /*splitterSize.count() == 0*/ ) {
317 splitterSize.append( wid / 2 ); 320 splitterSize.append( wid / 2 );
318 splitterSize.append( wid / 2 ); 321 splitterSize.append( wid / 2 );
319 } 322 }
320 mMiniSplitter->setSizes( splitterSize ); 323 mMiniSplitter->setSizes( splitterSize );
321 if ( mExtensionBarSplitter ) { 324 if ( mExtensionBarSplitter ) {
322 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 325 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
323 if ( true /*splitterSize.count() == 0*/ ) { 326 if ( true /*splitterSize.count() == 0*/ ) {
324 splitterSize.append( wid / 2 ); 327 splitterSize.append( wid / 2 );
325 splitterSize.append( wid / 2 ); 328 splitterSize.append( wid / 2 );
326 } 329 }
327 mExtensionBarSplitter->setSizes( splitterSize ); 330 mExtensionBarSplitter->setSizes( splitterSize );
328 331
329 } 332 }
330 333
331 334
332} 335}
333 336
334void KABCore::saveSettings() 337void KABCore::saveSettings()
335{ 338{
336 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 339 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
337 if ( mExtensionBarSplitter ) 340 if ( mExtensionBarSplitter )
338 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 341 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
339 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 342 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
340 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 343 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
341#ifndef KAB_EMBEDDED 344#ifndef KAB_EMBEDDED
342 345
343 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 346 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
344 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 347 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
345#endif //KAB_EMBEDDED 348#endif //KAB_EMBEDDED
346 mExtensionManager->saveSettings(); 349 mExtensionManager->saveSettings();
347 mViewManager->saveSettings(); 350 mViewManager->saveSettings();
348 351
349 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 352 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
350} 353}
351 354
352KABC::AddressBook *KABCore::addressBook() const 355KABC::AddressBook *KABCore::addressBook() const
353{ 356{
354 return mAddressBook; 357 return mAddressBook;
355} 358}
356 359
357KConfig *KABCore::config() 360KConfig *KABCore::config()
358{ 361{
359#ifndef KAB_EMBEDDED 362#ifndef KAB_EMBEDDED
360 return KABPrefs::instance()->config(); 363 return KABPrefs::instance()->config();
361#else //KAB_EMBEDDED 364#else //KAB_EMBEDDED
362 return KABPrefs::instance()->getConfig(); 365 return KABPrefs::instance()->getConfig();
363#endif //KAB_EMBEDDED 366#endif //KAB_EMBEDDED
364} 367}
365 368
366KActionCollection *KABCore::actionCollection() const 369KActionCollection *KABCore::actionCollection() const
367{ 370{
368 return mGUIClient->actionCollection(); 371 return mGUIClient->actionCollection();
369} 372}
370 373
371KABC::Field *KABCore::currentSearchField() const 374KABC::Field *KABCore::currentSearchField() const
372{ 375{
373 if (mIncSearchWidget) 376 if (mIncSearchWidget)
374 return mIncSearchWidget->currentField(); 377 return mIncSearchWidget->currentField();
375 else 378 else
376 return 0; 379 return 0;
377} 380}
378 381
379QStringList KABCore::selectedUIDs() const 382QStringList KABCore::selectedUIDs() const
380{ 383{
381 return mViewManager->selectedUids(); 384 return mViewManager->selectedUids();
382} 385}
383 386
384KABC::Resource *KABCore::requestResource( QWidget *parent ) 387KABC::Resource *KABCore::requestResource( QWidget *parent )
385{ 388{
386 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 389 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
387 390
388 QPtrList<KRES::Resource> kresResources; 391 QPtrList<KRES::Resource> kresResources;
389 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 392 QPtrListIterator<KABC::Resource> resIt( kabcResources );
390 KABC::Resource *resource; 393 KABC::Resource *resource;
391 while ( ( resource = resIt.current() ) != 0 ) { 394 while ( ( resource = resIt.current() ) != 0 ) {
392 ++resIt; 395 ++resIt;
393 if ( !resource->readOnly() ) { 396 if ( !resource->readOnly() ) {
394 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 397 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
395 if ( res ) 398 if ( res )
396 kresResources.append( res ); 399 kresResources.append( res );
397 } 400 }
398 } 401 }
399 402
400 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 403 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
401 return static_cast<KABC::Resource*>( res ); 404 return static_cast<KABC::Resource*>( res );
402} 405}
403 406
404#ifndef KAB_EMBEDDED 407#ifndef KAB_EMBEDDED
405KAboutData *KABCore::createAboutData() 408KAboutData *KABCore::createAboutData()
406#else //KAB_EMBEDDED 409#else //KAB_EMBEDDED
407void KABCore::createAboutData() 410void KABCore::createAboutData()
408#endif //KAB_EMBEDDED 411#endif //KAB_EMBEDDED
409{ 412{
410#ifndef KAB_EMBEDDED 413#ifndef KAB_EMBEDDED
411 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 414 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
412 "3.1", I18N_NOOP( "The KDE Address Book" ), 415 "3.1", I18N_NOOP( "The KDE Address Book" ),
413 KAboutData::License_GPL_V2, 416 KAboutData::License_GPL_V2,
414 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 417 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
415 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 418 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
416 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 419 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
417 about->addAuthor( "Cornelius Schumacher", 420 about->addAuthor( "Cornelius Schumacher",
418 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 421 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
419 "schumacher@kde.org" ); 422 "schumacher@kde.org" );
420 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 423 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
421 "mpilone@slac.com" ); 424 "mpilone@slac.com" );
422 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 425 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
423 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 426 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
424 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" ),
425 "michel@klaralvdalens-datakonsult.se" ); 428 "michel@klaralvdalens-datakonsult.se" );
426 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 429 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
427 "hansen@kde.org" ); 430 "hansen@kde.org" );
428 431
429 return about; 432 return about;
430#endif //KAB_EMBEDDED 433#endif //KAB_EMBEDDED
431 434
432 QString version; 435 QString version;
433#include <../version> 436#include <../version>
434 QMessageBox::about( this, "About KAddressbook/Pi", 437 QMessageBox::about( this, "About KAddressbook/Pi",
435 "KAddressbook/Platform-independent\n" 438 "KAddressbook/Platform-independent\n"
436 "(KA/Pi) " +version + " - " + 439 "(KA/Pi) " +version + " - " +
437#ifdef DESKTOP_VERSION 440#ifdef DESKTOP_VERSION
438 "Desktop Edition\n" 441 "Desktop Edition\n"
439#else 442#else
440 "PDA-Edition\n" 443 "PDA-Edition\n"
441 "for: Zaurus 5500 / 7x0 / 8x0\n" 444 "for: Zaurus 5500 / 7x0 / 8x0\n"
442#endif 445#endif
443 446
444 "(c) 2004 Ulf Schenk\n" 447 "(c) 2004 Ulf Schenk\n"
445 "(c) 2004 Lutz Rogowski\n" 448 "(c) 2004 Lutz Rogowski\n"
446 "(c) 1997-2003, The KDE PIM Team\n" 449 "(c) 1997-2003, The KDE PIM Team\n"
447 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 450 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
448 "Don Sanders Original author\n" 451 "Don Sanders Original author\n"
449 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 452 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
450 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 453 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
451 "Greg Stern DCOP interface\n" 454 "Greg Stern DCOP interface\n"
452 "Mark Westcot Contact pinning\n" 455 "Mark Westcot Contact pinning\n"
453 "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"
454 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 457 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
455#ifdef _WIN32_ 458#ifdef _WIN32_
456 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 459 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
457#endif 460#endif
458 ); 461 );
459} 462}
460 463
461void KABCore::setContactSelected( const QString &uid ) 464void KABCore::setContactSelected( const QString &uid )
462{ 465{
463 KABC::Addressee addr = mAddressBook->findByUid( uid ); 466 KABC::Addressee addr = mAddressBook->findByUid( uid );
464 if ( !mDetails->isHidden() ) 467 if ( !mDetails->isHidden() )
465 mDetails->setAddressee( addr ); 468 mDetails->setAddressee( addr );
466 469
467 if ( !addr.isEmpty() ) { 470 if ( !addr.isEmpty() ) {
468 emit contactSelected( addr.formattedName() ); 471 emit contactSelected( addr.formattedName() );
469 KABC::Picture pic = addr.photo(); 472 KABC::Picture pic = addr.photo();
470 if ( pic.isIntern() ) { 473 if ( pic.isIntern() ) {
471//US emit contactSelected( pic.data() ); 474//US emit contactSelected( pic.data() );
472//US instead use: 475//US instead use:
473 QPixmap px; 476 QPixmap px;
474 if (pic.data().isNull() != true) 477 if (pic.data().isNull() != true)
475 { 478 {
476 px.convertFromImage(pic.data()); 479 px.convertFromImage(pic.data());
477 } 480 }
478 481
479 emit contactSelected( px ); 482 emit contactSelected( px );
480 } 483 }
481 } 484 }
482 485
483 486
484 mExtensionManager->setSelectionChanged(); 487 mExtensionManager->setSelectionChanged();
485 488
486 // update the actions 489 // update the actions
487 bool selected = !uid.isEmpty(); 490 bool selected = !uid.isEmpty();
488 491
489 if ( mReadWrite ) { 492 if ( mReadWrite ) {
490 mActionCut->setEnabled( selected ); 493 mActionCut->setEnabled( selected );
491 mActionPaste->setEnabled( selected ); 494 mActionPaste->setEnabled( selected );
492 } 495 }
493 496
494 mActionCopy->setEnabled( selected ); 497 mActionCopy->setEnabled( selected );
495 mActionDelete->setEnabled( selected ); 498 mActionDelete->setEnabled( selected );
496 mActionEditAddressee->setEnabled( selected ); 499 mActionEditAddressee->setEnabled( selected );
497 mActionMail->setEnabled( selected ); 500 mActionMail->setEnabled( selected );
498 mActionMailVCard->setEnabled( selected ); 501 mActionMailVCard->setEnabled( selected );
499 //if (mActionBeam) 502 //if (mActionBeam)
500 //mActionBeam->setEnabled( selected ); 503 //mActionBeam->setEnabled( selected );
501 504
502 if (mActionBeamVCard) 505 if (mActionBeamVCard)
503 mActionBeamVCard->setEnabled( selected ); 506 mActionBeamVCard->setEnabled( selected );
504 507
505 mActionWhoAmI->setEnabled( selected ); 508 mActionWhoAmI->setEnabled( selected );
506 mActionCategories->setEnabled( selected ); 509 mActionCategories->setEnabled( selected );
507} 510}
508 511
509void KABCore::sendMail() 512void KABCore::sendMail()
510{ 513{
511 sendMail( mViewManager->selectedEmails().join( ", " ) ); 514 sendMail( mViewManager->selectedEmails().join( ", " ) );
512} 515}
513 516
514void KABCore::sendMail( const QString& emaillist ) 517void KABCore::sendMail( const QString& emaillist )
515{ 518{
516 // 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>;... "
517 if (emaillist.contains(",") > 0) 520 if (emaillist.contains(",") > 0)
518 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 521 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
519 else 522 else
520 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 523 ExternalAppHandler::instance()->mailToOneContact( emaillist );
521} 524}
522 525
523 526
524 527
525void KABCore::mailVCard() 528void KABCore::mailVCard()
526{ 529{
527 QStringList uids = mViewManager->selectedUids(); 530 QStringList uids = mViewManager->selectedUids();
528 if ( !uids.isEmpty() ) 531 if ( !uids.isEmpty() )
529 mailVCard( uids ); 532 mailVCard( uids );
530} 533}
531 534
532void KABCore::mailVCard( const QStringList& uids ) 535void KABCore::mailVCard( const QStringList& uids )
533{ 536{
534 QStringList urls; 537 QStringList urls;
535 538
536// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 539// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
537 540
538 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 541 QString dirName = "/tmp/" + KApplication::randomString( 8 );
539 542
540 543
541 544
542 QDir().mkdir( dirName, true ); 545 QDir().mkdir( dirName, true );
543 546
544 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 547 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
545 KABC::Addressee a = mAddressBook->findByUid( *it ); 548 KABC::Addressee a = mAddressBook->findByUid( *it );
546 549
547 if ( a.isEmpty() ) 550 if ( a.isEmpty() )
548 continue; 551 continue;
549 552
550 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 553 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
551 554
552 QString fileName = dirName + "/" + name; 555 QString fileName = dirName + "/" + name;
553 556
554 QFile outFile(fileName); 557 QFile outFile(fileName);
555 558
556 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 559 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
557 KABC::VCardConverter converter; 560 KABC::VCardConverter converter;
558 QString vcard; 561 QString vcard;
559 562
560 converter.addresseeToVCard( a, vcard ); 563 converter.addresseeToVCard( a, vcard );
561 564
562 QTextStream t( &outFile ); // use a text stream 565 QTextStream t( &outFile ); // use a text stream
563 t.setEncoding( QTextStream::UnicodeUTF8 ); 566 t.setEncoding( QTextStream::UnicodeUTF8 );
564 t << vcard; 567 t << vcard;
565 568
566 outFile.close(); 569 outFile.close();
567 570
568 urls.append( fileName ); 571 urls.append( fileName );
569 } 572 }
570 } 573 }
571 574
572 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 575 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
573 576
574 577
575/*US 578/*US
576 kapp->invokeMailer( QString::null, QString::null, QString::null, 579 kapp->invokeMailer( QString::null, QString::null, QString::null,
577 QString::null, // subject 580 QString::null, // subject
578 QString::null, // body 581 QString::null, // body
579 QString::null, 582 QString::null,
580 urls ); // attachments 583 urls ); // attachments
581*/ 584*/
582 585
583} 586}
584 587
585/** 588/**
586 Beams the "WhoAmI contact. 589 Beams the "WhoAmI contact.
587*/ 590*/
588void KABCore::beamMySelf() 591void KABCore::beamMySelf()
589{ 592{
590 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 593 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
591 if (!a.isEmpty()) 594 if (!a.isEmpty())
592 { 595 {
593 QStringList uids; 596 QStringList uids;
594 uids << a.uid(); 597 uids << a.uid();
595 598
596 beamVCard(uids); 599 beamVCard(uids);
597 } else { 600 } else {
598 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" ) );
599 602
600 603
601 } 604 }
602} 605}
603 606
604void KABCore::beamVCard() 607void KABCore::beamVCard()
605{ 608{
606 QStringList uids = mViewManager->selectedUids(); 609 QStringList uids = mViewManager->selectedUids();
607 if ( !uids.isEmpty() ) 610 if ( !uids.isEmpty() )
608 beamVCard( uids ); 611 beamVCard( uids );
609} 612}
610 613
611 614
612void KABCore::beamVCard(const QStringList& uids) 615void KABCore::beamVCard(const QStringList& uids)
613{ 616{
614/*US 617/*US
615 QString beamFilename; 618 QString beamFilename;
616 Opie::OPimContact c; 619 Opie::OPimContact c;
617 if ( actionPersonal->isOn() ) { 620 if ( actionPersonal->isOn() ) {
618 beamFilename = addressbookPersonalVCardName(); 621 beamFilename = addressbookPersonalVCardName();
619 if ( !QFile::exists( beamFilename ) ) 622 if ( !QFile::exists( beamFilename ) )
620 return; // can't beam a non-existent file 623 return; // can't beam a non-existent file
621 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 624 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
622 beamFilename ); 625 beamFilename );
623 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 );
624 Opie::OPimContactAccess::List allList = access->allRecords(); 627 Opie::OPimContactAccess::List allList = access->allRecords();
625 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 628 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
626 c = *it; 629 c = *it;
627 630
628 delete access; 631 delete access;
629 } else { 632 } else {
630 unlink( beamfile ); // delete if exists 633 unlink( beamfile ); // delete if exists
631 mkdir("/tmp/obex/", 0755); 634 mkdir("/tmp/obex/", 0755);
632 c = m_abView -> currentEntry(); 635 c = m_abView -> currentEntry();
633 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 636 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
634 beamfile ); 637 beamfile );
635 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 );
636 access->add( c ); 639 access->add( c );
637 access->save(); 640 access->save();
638 delete access; 641 delete access;
639 642
640 beamFilename = beamfile; 643 beamFilename = beamfile;
641 } 644 }
642 645
643 owarn << "Beaming: " << beamFilename << oendl; 646 owarn << "Beaming: " << beamFilename << oendl;
644*/ 647*/
645 648
646#if 0 649#if 0
647 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 650 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
648 651
649 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 652 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
650 653
651 QString name = "contact.vcf"; 654 QString name = "contact.vcf";
652 655
653 QString fileName = dirName + "/" + name; 656 QString fileName = dirName + "/" + name;
654#endif 657#endif
655 // 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
656 // 659 //
657 QString fileName = "/tmp/kapibeamfile.vcf"; 660 QString fileName = "/tmp/kapibeamfile.vcf";
658 661
659 662
660 //QDir().mkdir( dirName, true ); 663 //QDir().mkdir( dirName, true );
661 664
662 665
663 KABC::VCardConverter converter; 666 KABC::VCardConverter converter;
664 QString description; 667 QString description;
665 QString datastream; 668 QString datastream;
666 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 669 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
667 KABC::Addressee a = mAddressBook->findByUid( *it ); 670 KABC::Addressee a = mAddressBook->findByUid( *it );
668 671
669 if ( a.isEmpty() ) 672 if ( a.isEmpty() )
670 continue; 673 continue;
671 674
672 if (description.isEmpty()) 675 if (description.isEmpty())
673 description = a.formattedName(); 676 description = a.formattedName();
674 677
675 QString vcard; 678 QString vcard;
676 converter.addresseeToVCard( a, vcard ); 679 converter.addresseeToVCard( a, vcard );
677 int start = 0; 680 int start = 0;
678 int next; 681 int next;
679 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 682 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
680 int semi = vcard.find(";", next); 683 int semi = vcard.find(";", next);
681 int dopp = vcard.find(":", next); 684 int dopp = vcard.find(":", next);
682 int sep; 685 int sep;
683 if ( semi < dopp && semi >= 0 ) 686 if ( semi < dopp && semi >= 0 )
684 sep = semi ; 687 sep = semi ;
685 else 688 else
686 sep = dopp; 689 sep = dopp;
687 datastream +=vcard.mid( start, next - start); 690 datastream +=vcard.mid( start, next - start);
688 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 691 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
689 start = sep; 692 start = sep;
690 } 693 }
691 datastream += vcard.mid( start,vcard.length() ); 694 datastream += vcard.mid( start,vcard.length() );
692 } 695 }
693#ifndef DESKTOP_VERSION 696#ifndef DESKTOP_VERSION
694 QFile outFile(fileName); 697 QFile outFile(fileName);
695 if ( outFile.open(IO_WriteOnly) ) { 698 if ( outFile.open(IO_WriteOnly) ) {
696 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 699 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
697 QTextStream t( &outFile ); // use a text stream 700 QTextStream t( &outFile ); // use a text stream
698 t.setEncoding( QTextStream::UnicodeUTF8 ); 701 t.setEncoding( QTextStream::UnicodeUTF8 );
699 t <<datastream; 702 t <<datastream;
700 outFile.close(); 703 outFile.close();
701 Ir *ir = new Ir( this ); 704 Ir *ir = new Ir( this );
702 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 705 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
703 ir->send( fileName, description, "text/x-vCard" ); 706 ir->send( fileName, description, "text/x-vCard" );
704 } else { 707 } else {
705 qDebug("Error open temp beam file "); 708 qDebug("Error open temp beam file ");
706 return; 709 return;
707 } 710 }
708#endif 711#endif
709 712
710} 713}
711 714
712void KABCore::beamDone( Ir *ir ) 715void KABCore::beamDone( Ir *ir )
713{ 716{
714#ifndef DESKTOP_VERSION 717#ifndef DESKTOP_VERSION
715 delete ir; 718 delete ir;
716#endif 719#endif
717} 720}
718 721
719 722
720void KABCore::browse( const QString& url ) 723void KABCore::browse( const QString& url )
721{ 724{
722#ifndef KAB_EMBEDDED 725#ifndef KAB_EMBEDDED
723 kapp->invokeBrowser( url ); 726 kapp->invokeBrowser( url );
724#else //KAB_EMBEDDED 727#else //KAB_EMBEDDED
725 qDebug("KABCore::browse must be fixed"); 728 qDebug("KABCore::browse must be fixed");
726#endif //KAB_EMBEDDED 729#endif //KAB_EMBEDDED
727} 730}
728 731
729void KABCore::selectAllContacts() 732void KABCore::selectAllContacts()
730{ 733{
731 mViewManager->setSelected( QString::null, true ); 734 mViewManager->setSelected( QString::null, true );
732} 735}
733 736
734void KABCore::deleteContacts() 737void KABCore::deleteContacts()
735{ 738{
736 QStringList uidList = mViewManager->selectedUids(); 739 QStringList uidList = mViewManager->selectedUids();
737 deleteContacts( uidList ); 740 deleteContacts( uidList );
738} 741}
739 742
740void KABCore::deleteContacts( const QStringList &uids ) 743void KABCore::deleteContacts( const QStringList &uids )
741{ 744{
742 if ( uids.count() > 0 ) { 745 if ( uids.count() > 0 ) {
743 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 746 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
744 UndoStack::instance()->push( command ); 747 UndoStack::instance()->push( command );
745 RedoStack::instance()->clear(); 748 RedoStack::instance()->clear();
746 749
747 // now if we deleted anything, refresh 750 // now if we deleted anything, refresh
748 setContactSelected( QString::null ); 751 setContactSelected( QString::null );
749 setModified( true ); 752 setModified( true );
750 } 753 }
751} 754}
752 755
753void KABCore::copyContacts() 756void KABCore::copyContacts()
754{ 757{
755 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 758 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
756 759
757 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 760 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
758 761
759 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 762 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
760 763
761 QClipboard *cb = QApplication::clipboard(); 764 QClipboard *cb = QApplication::clipboard();
762 cb->setText( clipText ); 765 cb->setText( clipText );
763} 766}
764 767
765void KABCore::cutContacts() 768void KABCore::cutContacts()
766{ 769{
767 QStringList uidList = mViewManager->selectedUids(); 770 QStringList uidList = mViewManager->selectedUids();
768 771
769//US if ( uidList.size() > 0 ) { 772//US if ( uidList.size() > 0 ) {
770 if ( uidList.count() > 0 ) { 773 if ( uidList.count() > 0 ) {
771 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 774 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
772 UndoStack::instance()->push( command ); 775 UndoStack::instance()->push( command );
773 RedoStack::instance()->clear(); 776 RedoStack::instance()->clear();
774 777
775 setModified( true ); 778 setModified( true );
776 } 779 }
777} 780}
778 781
779void KABCore::pasteContacts() 782void KABCore::pasteContacts()
780{ 783{
781 QClipboard *cb = QApplication::clipboard(); 784 QClipboard *cb = QApplication::clipboard();
782 785
783 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 786 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
784 787
785 pasteContacts( list ); 788 pasteContacts( list );
786} 789}
787 790
788void KABCore::pasteContacts( KABC::Addressee::List &list ) 791void KABCore::pasteContacts( KABC::Addressee::List &list )
789{ 792{
790 KABC::Resource *resource = requestResource( this ); 793 KABC::Resource *resource = requestResource( this );
791 KABC::Addressee::List::Iterator it; 794 KABC::Addressee::List::Iterator it;
792 for ( it = list.begin(); it != list.end(); ++it ) 795 for ( it = list.begin(); it != list.end(); ++it )
793 (*it).setResource( resource ); 796 (*it).setResource( resource );
794 797
795 PwPasteCommand *command = new PwPasteCommand( this, list ); 798 PwPasteCommand *command = new PwPasteCommand( this, list );
796 UndoStack::instance()->push( command ); 799 UndoStack::instance()->push( command );
797 RedoStack::instance()->clear(); 800 RedoStack::instance()->clear();
798 801
799 setModified( true ); 802 setModified( true );
800} 803}
801 804
802void KABCore::setWhoAmI() 805void KABCore::setWhoAmI()
803{ 806{
804 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 807 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
805 808
806 if ( addrList.count() > 1 ) { 809 if ( addrList.count() > 1 ) {
807 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 810 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
808 return; 811 return;
809 } 812 }
810 813
811 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>" ) );
812 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 815 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
813 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 816 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
814} 817}
815 818
816void KABCore::setCategories() 819void KABCore::setCategories()
817{ 820{
818 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 821 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
819 if ( !dlg.exec() ) 822 if ( !dlg.exec() )
820 return; 823 return;
821 824
822 bool merge = false; 825 bool merge = false;
823 QString msg = i18n( "Merge with existing categories?" ); 826 QString msg = i18n( "Merge with existing categories?" );
824 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 827 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
825 merge = true; 828 merge = true;
826 829
827 QStringList categories = dlg.selectedCategories(); 830 QStringList categories = dlg.selectedCategories();
828 831
829 QStringList uids = mViewManager->selectedUids(); 832 QStringList uids = mViewManager->selectedUids();
830 QStringList::Iterator it; 833 QStringList::Iterator it;
831 for ( it = uids.begin(); it != uids.end(); ++it ) { 834 for ( it = uids.begin(); it != uids.end(); ++it ) {
832 KABC::Addressee addr = mAddressBook->findByUid( *it ); 835 KABC::Addressee addr = mAddressBook->findByUid( *it );
833 if ( !addr.isEmpty() ) { 836 if ( !addr.isEmpty() ) {
834 if ( !merge ) 837 if ( !merge )
835 addr.setCategories( categories ); 838 addr.setCategories( categories );
836 else { 839 else {
837 QStringList addrCategories = addr.categories(); 840 QStringList addrCategories = addr.categories();
838 QStringList::Iterator catIt; 841 QStringList::Iterator catIt;
839 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 842 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
840 if ( !addrCategories.contains( *catIt ) ) 843 if ( !addrCategories.contains( *catIt ) )
841 addrCategories.append( *catIt ); 844 addrCategories.append( *catIt );
842 } 845 }
843 addr.setCategories( addrCategories ); 846 addr.setCategories( addrCategories );
844 } 847 }
845 848
846 mAddressBook->insertAddressee( addr ); 849 mAddressBook->insertAddressee( addr );
847 } 850 }
848 } 851 }
849 852
850 if ( uids.count() > 0 ) 853 if ( uids.count() > 0 )
851 setModified( true ); 854 setModified( true );
852} 855}
853 856
854void KABCore::setSearchFields( const KABC::Field::List &fields ) 857void KABCore::setSearchFields( const KABC::Field::List &fields )
855{ 858{
856 mIncSearchWidget->setFields( fields ); 859 mIncSearchWidget->setFields( fields );
857} 860}
858 861
859void KABCore::incrementalSearch( const QString& text ) 862void KABCore::incrementalSearch( const QString& text )
860{ 863{
861 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 864 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
862} 865}
863 866
864void KABCore::setModified() 867void KABCore::setModified()
865{ 868{
866 setModified( true ); 869 setModified( true );
867} 870}
868 871
869void KABCore::setModifiedWOrefresh() 872void KABCore::setModifiedWOrefresh()
870{ 873{
871 // qDebug("KABCore::setModifiedWOrefresh() "); 874 // qDebug("KABCore::setModifiedWOrefresh() ");
872 mModified = true; 875 mModified = true;
873 mActionSave->setEnabled( mModified ); 876 mActionSave->setEnabled( mModified );
874#ifdef DESKTOP_VERSION 877#ifdef DESKTOP_VERSION
875 mDetails->refreshView(); 878 mDetails->refreshView();
876#endif 879#endif
877 880
878} 881}
879void KABCore::setModified( bool modified ) 882void KABCore::setModified( bool modified )
880{ 883{
881 mModified = modified; 884 mModified = modified;
882 mActionSave->setEnabled( mModified ); 885 mActionSave->setEnabled( mModified );
883 886
884 if ( modified ) 887 if ( modified )
885 mJumpButtonBar->recreateButtons(); 888 mJumpButtonBar->recreateButtons();
886 889
887 mViewManager->refreshView(); 890 mViewManager->refreshView();
888 mDetails->refreshView(); 891 mDetails->refreshView();
889 892
890} 893}
891 894
892bool KABCore::modified() const 895bool KABCore::modified() const
893{ 896{
894 return mModified; 897 return mModified;
895} 898}
896 899
897void KABCore::contactModified( const KABC::Addressee &addr ) 900void KABCore::contactModified( const KABC::Addressee &addr )
898{ 901{
899 902
900 Command *command = 0; 903 Command *command = 0;
901 QString uid; 904 QString uid;
902 905
903 // check if it exists already 906 // check if it exists already
904 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 907 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
905 if ( origAddr.isEmpty() ) 908 if ( origAddr.isEmpty() )
906 command = new PwNewCommand( mAddressBook, addr ); 909 command = new PwNewCommand( mAddressBook, addr );
907 else { 910 else {
908 command = new PwEditCommand( mAddressBook, origAddr, addr ); 911 command = new PwEditCommand( mAddressBook, origAddr, addr );
909 uid = addr.uid(); 912 uid = addr.uid();
910 } 913 }
911 914
912 UndoStack::instance()->push( command ); 915 UndoStack::instance()->push( command );
913 RedoStack::instance()->clear(); 916 RedoStack::instance()->clear();
914 917
915 setModified( true ); 918 setModified( true );
916} 919}
917 920
918void KABCore::newContact() 921void KABCore::newContact()
919{ 922{
920 923
921 924
922 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 925 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
923 926
924 QPtrList<KRES::Resource> kresResources; 927 QPtrList<KRES::Resource> kresResources;
925 QPtrListIterator<KABC::Resource> it( kabcResources ); 928 QPtrListIterator<KABC::Resource> it( kabcResources );
926 KABC::Resource *resource; 929 KABC::Resource *resource;
927 while ( ( resource = it.current() ) != 0 ) { 930 while ( ( resource = it.current() ) != 0 ) {
928 ++it; 931 ++it;
929 if ( !resource->readOnly() ) { 932 if ( !resource->readOnly() ) {
930 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 933 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
931 if ( res ) 934 if ( res )
932 kresResources.append( res ); 935 kresResources.append( res );
933 } 936 }
934 } 937 }
935 938
936 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 939 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
937 resource = static_cast<KABC::Resource*>( res ); 940 resource = static_cast<KABC::Resource*>( res );
938 941
939 if ( resource ) { 942 if ( resource ) {
940 KABC::Addressee addr; 943 KABC::Addressee addr;
941 addr.setResource( resource ); 944 addr.setResource( resource );
942 mEditorDialog->setAddressee( addr ); 945 mEditorDialog->setAddressee( addr );
943 KApplication::execDialog ( mEditorDialog ); 946 KApplication::execDialog ( mEditorDialog );
944 947
945 } else 948 } else
946 return; 949 return;
947 950
948 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 951 // mEditorDict.insert( dialog->addressee().uid(), dialog );
949 952
950 953
951} 954}
952 955
953void KABCore::addEmail( QString aStr ) 956void KABCore::addEmail( QString aStr )
954{ 957{
955#ifndef KAB_EMBEDDED 958#ifndef KAB_EMBEDDED
956 QString fullName, email; 959 QString fullName, email;
957 960
958 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 961 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
959 962
960 // Try to lookup the addressee matching the email address 963 // Try to lookup the addressee matching the email address
961 bool found = false; 964 bool found = false;
962 QStringList emailList; 965 QStringList emailList;
963 KABC::AddressBook::Iterator it; 966 KABC::AddressBook::Iterator it;
964 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 967 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
965 emailList = (*it).emails(); 968 emailList = (*it).emails();
966 if ( emailList.contains( email ) > 0 ) { 969 if ( emailList.contains( email ) > 0 ) {
967 found = true; 970 found = true;
968 (*it).setNameFromString( fullName ); 971 (*it).setNameFromString( fullName );
969 editContact( (*it).uid() ); 972 editContact( (*it).uid() );
970 } 973 }
971 } 974 }
972 975
973 if ( !found ) { 976 if ( !found ) {
974 KABC::Addressee addr; 977 KABC::Addressee addr;
975 addr.setNameFromString( fullName ); 978 addr.setNameFromString( fullName );
976 addr.insertEmail( email, true ); 979 addr.insertEmail( email, true );
977 980
978 mAddressBook->insertAddressee( addr ); 981 mAddressBook->insertAddressee( addr );
979 mViewManager->refreshView( addr.uid() ); 982 mViewManager->refreshView( addr.uid() );
980 editContact( addr.uid() ); 983 editContact( addr.uid() );
981 } 984 }
982#else //KAB_EMBEDDED 985#else //KAB_EMBEDDED
983 qDebug("KABCore::addEmail finsih method"); 986 qDebug("KABCore::addEmail finsih method");
984#endif //KAB_EMBEDDED 987#endif //KAB_EMBEDDED
985} 988}
986 989
987void KABCore::importVCard( const KURL &url, bool showPreview ) 990void KABCore::importVCard( const KURL &url, bool showPreview )
988{ 991{
989 mXXPortManager->importVCard( url, showPreview ); 992 mXXPortManager->importVCard( url, showPreview );
990} 993}
991void KABCore::importFromOL() 994void KABCore::importFromOL()
992{ 995{
993#ifdef _WIN32_ 996#ifdef _WIN32_
994 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 997 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
995 idgl->exec(); 998 idgl->exec();
996 KABC::Addressee::List list = idgl->getAddressList(); 999 KABC::Addressee::List list = idgl->getAddressList();
997 if ( list.count() > 0 ) { 1000 if ( list.count() > 0 ) {
998 KABC::Addressee::List listNew; 1001 KABC::Addressee::List listNew;
999 KABC::Addressee::List listExisting; 1002 KABC::Addressee::List listExisting;
1000 KABC::Addressee::List::Iterator it; 1003 KABC::Addressee::List::Iterator it;
1001 KABC::AddressBook::Iterator iter; 1004 KABC::AddressBook::Iterator iter;
1002 for ( it = list.begin(); it != list.end(); ++it ) { 1005 for ( it = list.begin(); it != list.end(); ++it ) {
1003 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1006 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1004 listNew.append( (*it) ); 1007 listNew.append( (*it) );
1005 else 1008 else
1006 listExisting.append( (*it) ); 1009 listExisting.append( (*it) );
1007 } 1010 }
1008 if ( listExisting.count() > 0 ) 1011 if ( listExisting.count() > 0 )
1009 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() ));
1010 if ( listNew.count() > 0 ) { 1013 if ( listNew.count() > 0 ) {
1011 pasteWithNewUid = false; 1014 pasteWithNewUid = false;
1012 pasteContacts( listNew ); 1015 pasteContacts( listNew );
1013 pasteWithNewUid = true; 1016 pasteWithNewUid = true;
1014 } 1017 }
1015 } 1018 }
1016 delete idgl; 1019 delete idgl;
1017#endif 1020#endif
1018} 1021}
1019 1022
1020void KABCore::importVCard( const QString &vCard, bool showPreview ) 1023void KABCore::importVCard( const QString &vCard, bool showPreview )
1021{ 1024{
1022 mXXPortManager->importVCard( vCard, showPreview ); 1025 mXXPortManager->importVCard( vCard, showPreview );
1023} 1026}
1024 1027
1025//US added a second method without defaultparameter 1028//US added a second method without defaultparameter
1026void KABCore::editContact2() { 1029void KABCore::editContact2() {
1027 editContact( QString::null ); 1030 editContact( QString::null );
1028} 1031}
1029 1032
1030void KABCore::editContact( const QString &uid ) 1033void KABCore::editContact( const QString &uid )
1031{ 1034{
1032 1035
1033 if ( mExtensionManager->isQuickEditVisible() ) 1036 if ( mExtensionManager->isQuickEditVisible() )
1034 return; 1037 return;
1035 1038
1036 // First, locate the contact entry 1039 // First, locate the contact entry
1037 QString localUID = uid; 1040 QString localUID = uid;
1038 if ( localUID.isNull() ) { 1041 if ( localUID.isNull() ) {
1039 QStringList uidList = mViewManager->selectedUids(); 1042 QStringList uidList = mViewManager->selectedUids();
1040 if ( uidList.count() > 0 ) 1043 if ( uidList.count() > 0 )
1041 localUID = *( uidList.at( 0 ) ); 1044 localUID = *( uidList.at( 0 ) );
1042 } 1045 }
1043 1046
1044 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1047 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1045 if ( !addr.isEmpty() ) { 1048 if ( !addr.isEmpty() ) {
1046 mEditorDialog->setAddressee( addr ); 1049 mEditorDialog->setAddressee( addr );
1047 KApplication::execDialog ( mEditorDialog ); 1050 KApplication::execDialog ( mEditorDialog );
1048 } 1051 }
1049} 1052}
1050 1053
1051/** 1054/**
1052 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,
1053 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.
1054 */ 1057 */
1055void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1058void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1056{ 1059{
1057 if ( mMultipleViewsAtOnce ) 1060 if ( mMultipleViewsAtOnce )
1058 { 1061 {
1059 editContact( uid ); 1062 editContact( uid );
1060 } 1063 }
1061 else 1064 else
1062 { 1065 {
1063 setDetailsVisible( true ); 1066 setDetailsVisible( true );
1064 mActionDetails->setChecked(true); 1067 mActionDetails->setChecked(true);
1065 } 1068 }
1066 1069
1067} 1070}
1068 1071
1069void KABCore::save() 1072void KABCore::save()
1070{ 1073{
1071 if (mBlockSaveFlag) 1074 if (mBlockSaveFlag)
1072 return; 1075 return;
1073 mBlockSaveFlag = true; 1076 mBlockSaveFlag = true;
1074 if ( !mModified ) 1077 if ( !mModified )
1075 return; 1078 return;
1076 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 "
1077 "address book. Please check that some \nother application is " 1080 "address book. Please check that some \nother application is "
1078 "not using it. " ); 1081 "not using it. " );
1079 statusMessage(i18n("Saving addressbook ... ")); 1082 statusMessage(i18n("Saving addressbook ... "));
1080#ifndef KAB_EMBEDDED 1083#ifndef KAB_EMBEDDED
1081 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1084 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1082 if ( !b || !b->save() ) { 1085 if ( !b || !b->save() ) {
1083 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1086 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1084 } 1087 }
1085#else //KAB_EMBEDDED 1088#else //KAB_EMBEDDED
1086 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1089 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1087 if ( !b || !b->save() ) { 1090 if ( !b || !b->save() ) {
1088 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1091 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1089 } 1092 }
1090#endif //KAB_EMBEDDED 1093#endif //KAB_EMBEDDED
1091 1094
1092 statusMessage(i18n("Addressbook saved!")); 1095 statusMessage(i18n("Addressbook saved!"));
1093 setModified( false ); 1096 setModified( false );
1094 mBlockSaveFlag = false; 1097 mBlockSaveFlag = false;
1095} 1098}
1096 1099
1097void KABCore::statusMessage(QString mess , int time ) 1100void KABCore::statusMessage(QString mess , int time )
1098{ 1101{
1099 //topLevelWidget()->setCaption( mess ); 1102 //topLevelWidget()->setCaption( mess );
1100 // pending setting timer to revome message 1103 // pending setting timer to revome message
1101} 1104}
1102void KABCore::undo() 1105void KABCore::undo()
1103{ 1106{
1104 UndoStack::instance()->undo(); 1107 UndoStack::instance()->undo();
1105 1108
1106 // Refresh the view 1109 // Refresh the view
1107 mViewManager->refreshView(); 1110 mViewManager->refreshView();
1108} 1111}
1109 1112
1110void KABCore::redo() 1113void KABCore::redo()
1111{ 1114{
1112 RedoStack::instance()->redo(); 1115 RedoStack::instance()->redo();
1113 1116
1114 // Refresh the view 1117 // Refresh the view
1115 mViewManager->refreshView(); 1118 mViewManager->refreshView();
1116} 1119}
1117 1120
1118void KABCore::setJumpButtonBarVisible( bool visible ) 1121void KABCore::setJumpButtonBarVisible( bool visible )
1119{ 1122{
1120 if (mMultipleViewsAtOnce) 1123 if (mMultipleViewsAtOnce)
1121 { 1124 {
1122 if ( visible ) 1125 if ( visible )
1123 mJumpButtonBar->show(); 1126 mJumpButtonBar->show();
1124 else 1127 else
1125 mJumpButtonBar->hide(); 1128 mJumpButtonBar->hide();
1126 } 1129 }
1127 else 1130 else
1128 { 1131 {
1129 // 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"
1130 if (mViewManager->isVisible()) 1133 if (mViewManager->isVisible())
1131 { 1134 {
1132 if ( visible ) 1135 if ( visible )
1133 mJumpButtonBar->show(); 1136 mJumpButtonBar->show();
1134 else 1137 else
1135 mJumpButtonBar->hide(); 1138 mJumpButtonBar->hide();
1136 } 1139 }
1137 else 1140 else
1138 { 1141 {
1139 mJumpButtonBar->hide(); 1142 mJumpButtonBar->hide();
1140 } 1143 }
1141 } 1144 }
1142} 1145}
1143 1146
1144 1147
1145void KABCore::setDetailsToState() 1148void KABCore::setDetailsToState()
1146{ 1149{
1147 setDetailsVisible( mActionDetails->isChecked() ); 1150 setDetailsVisible( mActionDetails->isChecked() );
1148} 1151}
1149 1152
1150 1153
1151 1154
1152void KABCore::setDetailsVisible( bool visible ) 1155void KABCore::setDetailsVisible( bool visible )
1153{ 1156{
1154 if (visible && mDetails->isHidden()) 1157 if (visible && mDetails->isHidden())
1155 { 1158 {
1156 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1159 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1157 if ( addrList.count() > 0 ) 1160 if ( addrList.count() > 0 )
1158 mDetails->setAddressee( addrList[ 0 ] ); 1161 mDetails->setAddressee( addrList[ 0 ] );
1159 } 1162 }
1160 1163
1161 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1164 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1162 // 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.
1163 if (mMultipleViewsAtOnce) 1166 if (mMultipleViewsAtOnce)
1164 { 1167 {
1165 if ( visible ) 1168 if ( visible )
1166 mDetails->show(); 1169 mDetails->show();
1167 else 1170 else
1168 mDetails->hide(); 1171 mDetails->hide();
1169 } 1172 }
1170 else 1173 else
1171 { 1174 {
1172 if ( visible ) { 1175 if ( visible ) {
1173 mViewManager->hide(); 1176 mViewManager->hide();
1174 mDetails->show(); 1177 mDetails->show();
1175 } 1178 }
1176 else { 1179 else {
1177 mViewManager->show(); 1180 mViewManager->show();
1178 mDetails->hide(); 1181 mDetails->hide();
1179 } 1182 }
1180 setJumpButtonBarVisible( !visible ); 1183 setJumpButtonBarVisible( !visible );
1181 } 1184 }
1182 1185
1183} 1186}
1184 1187
1185void KABCore::extensionChanged( int id ) 1188void KABCore::extensionChanged( int id )
1186{ 1189{
1187 //change the details view only for non desktop systems 1190 //change the details view only for non desktop systems
1188#ifndef DESKTOP_VERSION 1191#ifndef DESKTOP_VERSION
1189 1192
1190 if (id == 0) 1193 if (id == 0)
1191 { 1194 {
1192 //the user disabled the extension. 1195 //the user disabled the extension.
1193 1196
1194 if (mMultipleViewsAtOnce) 1197 if (mMultipleViewsAtOnce)
1195 { // enable detailsview again 1198 { // enable detailsview again
1196 setDetailsVisible( true ); 1199 setDetailsVisible( true );
1197 mActionDetails->setChecked( true ); 1200 mActionDetails->setChecked( true );
1198 } 1201 }
1199 else 1202 else
1200 { //go back to the listview 1203 { //go back to the listview
1201 setDetailsVisible( false ); 1204 setDetailsVisible( false );
1202 mActionDetails->setChecked( false ); 1205 mActionDetails->setChecked( false );
1203 mActionDetails->setEnabled(true); 1206 mActionDetails->setEnabled(true);
1204 } 1207 }
1205 1208
1206 } 1209 }
1207 else 1210 else
1208 { 1211 {
1209 //the user enabled the extension. 1212 //the user enabled the extension.
1210 setDetailsVisible( false ); 1213 setDetailsVisible( false );
1211 mActionDetails->setChecked( false ); 1214 mActionDetails->setChecked( false );
1212 1215
1213 if (!mMultipleViewsAtOnce) 1216 if (!mMultipleViewsAtOnce)
1214 { 1217 {
1215 mActionDetails->setEnabled(false); 1218 mActionDetails->setEnabled(false);
1216 } 1219 }
1217 1220
1218 mExtensionManager->setSelectionChanged(); 1221 mExtensionManager->setSelectionChanged();
1219 1222
1220 } 1223 }
1221 1224
1222#endif// DESKTOP_VERSION 1225#endif// DESKTOP_VERSION
1223 1226
1224} 1227}
1225 1228
1226 1229
1227void KABCore::extensionModified( const KABC::Addressee::List &list ) 1230void KABCore::extensionModified( const KABC::Addressee::List &list )
1228{ 1231{
1229 1232
1230 if ( list.count() != 0 ) { 1233 if ( list.count() != 0 ) {
1231 KABC::Addressee::List::ConstIterator it; 1234 KABC::Addressee::List::ConstIterator it;
1232 for ( it = list.begin(); it != list.end(); ++it ) 1235 for ( it = list.begin(); it != list.end(); ++it )
1233 mAddressBook->insertAddressee( *it ); 1236 mAddressBook->insertAddressee( *it );
1234 if ( list.count() > 1 ) 1237 if ( list.count() > 1 )
1235 setModified(); 1238 setModified();
1236 else 1239 else
1237 setModifiedWOrefresh(); 1240 setModifiedWOrefresh();
1238 } 1241 }
1239 if ( list.count() == 0 ) 1242 if ( list.count() == 0 )
1240 mViewManager->refreshView(); 1243 mViewManager->refreshView();
1241 else 1244 else
1242 mViewManager->refreshView( list[ 0 ].uid() ); 1245 mViewManager->refreshView( list[ 0 ].uid() );
1243 1246
1244 1247
1245 1248
1246} 1249}
1247 1250
1248QString KABCore::getNameByPhone( const QString &phone ) 1251QString KABCore::getNameByPhone( const QString &phone )
1249{ 1252{
1250#ifndef KAB_EMBEDDED 1253#ifndef KAB_EMBEDDED
1251 QRegExp r( "[/*/-/ ]" ); 1254 QRegExp r( "[/*/-/ ]" );
1252 QString localPhone( phone ); 1255 QString localPhone( phone );
1253 1256
1254 bool found = false; 1257 bool found = false;
1255 QString ownerName = ""; 1258 QString ownerName = "";
1256 KABC::AddressBook::Iterator iter; 1259 KABC::AddressBook::Iterator iter;
1257 KABC::PhoneNumber::List::Iterator phoneIter; 1260 KABC::PhoneNumber::List::Iterator phoneIter;
1258 KABC::PhoneNumber::List phoneList; 1261 KABC::PhoneNumber::List phoneList;
1259 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1262 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1260 phoneList = (*iter).phoneNumbers(); 1263 phoneList = (*iter).phoneNumbers();
1261 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1264 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1262 ++phoneIter) { 1265 ++phoneIter) {
1263 // Get rid of separator chars so just the numbers are compared. 1266 // Get rid of separator chars so just the numbers are compared.
1264 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1267 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1265 ownerName = (*iter).formattedName(); 1268 ownerName = (*iter).formattedName();
1266 found = true; 1269 found = true;
1267 } 1270 }
1268 } 1271 }
1269 } 1272 }
1270 1273
1271 return ownerName; 1274 return ownerName;
1272#else //KAB_EMBEDDED 1275#else //KAB_EMBEDDED
1273 qDebug("KABCore::getNameByPhone finsih method"); 1276 qDebug("KABCore::getNameByPhone finsih method");
1274 return ""; 1277 return "";
1275#endif //KAB_EMBEDDED 1278#endif //KAB_EMBEDDED
1276 1279
1277} 1280}
1278 1281
1279void KABCore::openConfigDialog() 1282void KABCore::openConfigDialog()
1280{ 1283{
1281 KABPrefs* kab_prefs = KABPrefs::instance(); 1284 KABPrefs* kab_prefs = KABPrefs::instance();
1282 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); 1285 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1283 1286
1284 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1287 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1285 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1288 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1286 ConfigureDialog->addModule(kabcfg ); 1289 ConfigureDialog->addModule(kabcfg );
1287 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1290 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1288 ConfigureDialog->addModule(kdelibcfg ); 1291 ConfigureDialog->addModule(kdelibcfg );
1289 1292
1290 1293
1291 1294
1292 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1295 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1293 this, SLOT( configurationChanged() ) ); 1296 this, SLOT( configurationChanged() ) );
1294 connect( ConfigureDialog, SIGNAL( okClicked() ), 1297 connect( ConfigureDialog, SIGNAL( okClicked() ),
1295 this, SLOT( configurationChanged() ) ); 1298 this, SLOT( configurationChanged() ) );
1296 saveSettings(); 1299 saveSettings();
1297#ifndef DESKTOP_VERSION 1300#ifndef DESKTOP_VERSION
1298 ConfigureDialog->showMaximized(); 1301 ConfigureDialog->showMaximized();
1299#endif 1302#endif
1300 if ( ConfigureDialog->exec() ) 1303 if ( ConfigureDialog->exec() )
1301 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") );
1302 delete ConfigureDialog; 1305 delete ConfigureDialog;
1303} 1306}
1304 1307
1305void KABCore::openLDAPDialog() 1308void KABCore::openLDAPDialog()
1306{ 1309{
1307#ifndef KAB_EMBEDDED 1310#ifndef KAB_EMBEDDED
1308 if ( !mLdapSearchDialog ) { 1311 if ( !mLdapSearchDialog ) {
1309 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1312 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1310 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1313 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1311 SLOT( refreshView() ) ); 1314 SLOT( refreshView() ) );
1312 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1315 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1313 SLOT( setModified() ) ); 1316 SLOT( setModified() ) );
1314 } else 1317 } else
1315 mLdapSearchDialog->restoreSettings(); 1318 mLdapSearchDialog->restoreSettings();
1316 1319
1317 if ( mLdapSearchDialog->isOK() ) 1320 if ( mLdapSearchDialog->isOK() )
1318 mLdapSearchDialog->exec(); 1321 mLdapSearchDialog->exec();
1319#else //KAB_EMBEDDED 1322#else //KAB_EMBEDDED
1320 qDebug("KABCore::openLDAPDialog() finsih method"); 1323 qDebug("KABCore::openLDAPDialog() finsih method");
1321#endif //KAB_EMBEDDED 1324#endif //KAB_EMBEDDED
1322} 1325}
1323 1326
1324void KABCore::print() 1327void KABCore::print()
1325{ 1328{
1326#ifndef KAB_EMBEDDED 1329#ifndef KAB_EMBEDDED
1327 KPrinter printer; 1330 KPrinter printer;
1328 if ( !printer.setup( this ) ) 1331 if ( !printer.setup( this ) )
1329 return; 1332 return;
1330 1333
1331 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1334 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1332 mViewManager->selectedUids(), this ); 1335 mViewManager->selectedUids(), this );
1333 1336
1334 wizard.exec(); 1337 wizard.exec();
1335#else //KAB_EMBEDDED 1338#else //KAB_EMBEDDED
1336 qDebug("KABCore::print() finsih method"); 1339 qDebug("KABCore::print() finsih method");
1337#endif //KAB_EMBEDDED 1340#endif //KAB_EMBEDDED
1338 1341
1339} 1342}
1340 1343
1341 1344
1342void KABCore::addGUIClient( KXMLGUIClient *client ) 1345void KABCore::addGUIClient( KXMLGUIClient *client )
1343{ 1346{
1344 if ( mGUIClient ) 1347 if ( mGUIClient )
1345 mGUIClient->insertChildClient( client ); 1348 mGUIClient->insertChildClient( client );
1346 else 1349 else
1347 KMessageBox::error( this, "no KXMLGUICLient"); 1350 KMessageBox::error( this, "no KXMLGUICLient");
1348} 1351}
1349 1352
1350 1353
1351void KABCore::configurationChanged() 1354void KABCore::configurationChanged()
1352{ 1355{
1353 mExtensionManager->reconfigure(); 1356 mExtensionManager->reconfigure();
1354} 1357}
1355 1358
1356void KABCore::addressBookChanged() 1359void KABCore::addressBookChanged()
1357{ 1360{
1358/*US 1361/*US
1359 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1362 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1360 while ( it.current() ) { 1363 while ( it.current() ) {
1361 if ( it.current()->dirty() ) { 1364 if ( it.current()->dirty() ) {
1362 QString text = i18n( "Data has been changed externally. Unsaved " 1365 QString text = i18n( "Data has been changed externally. Unsaved "
1363 "changes will be lost." ); 1366 "changes will be lost." );
1364 KMessageBox::information( this, text ); 1367 KMessageBox::information( this, text );
1365 } 1368 }
1366 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1369 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1367 ++it; 1370 ++it;
1368 } 1371 }
1369*/ 1372*/
1370 if (mEditorDialog) 1373 if (mEditorDialog)
1371 { 1374 {
1372 if (mEditorDialog->dirty()) 1375 if (mEditorDialog->dirty())
1373 { 1376 {
1374 QString text = i18n( "Data has been changed externally. Unsaved " 1377 QString text = i18n( "Data has been changed externally. Unsaved "
1375 "changes will be lost." ); 1378 "changes will be lost." );
1376 KMessageBox::information( this, text ); 1379 KMessageBox::information( this, text );
1377 } 1380 }
1378 QString currentuid = mEditorDialog->addressee().uid(); 1381 QString currentuid = mEditorDialog->addressee().uid();
1379 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1382 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1380 } 1383 }
1381 mViewManager->refreshView(); 1384 mViewManager->refreshView();
1382// mDetails->refreshView(); 1385// mDetails->refreshView();
1383 1386
1384 1387
1385} 1388}
1386 1389
1387AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1390AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1388 const char *name ) 1391 const char *name )
1389{ 1392{
1390 1393
1391 if ( mEditorDialog == 0 ) { 1394 if ( mEditorDialog == 0 ) {
1392 mEditorDialog = new AddresseeEditorDialog( this, parent, 1395 mEditorDialog = new AddresseeEditorDialog( this, parent,
1393 name ? name : "editorDialog" ); 1396 name ? name : "editorDialog" );
1394 1397
1395 1398
1396 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1399 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1397 SLOT( contactModified( const KABC::Addressee& ) ) ); 1400 SLOT( contactModified( const KABC::Addressee& ) ) );
1398 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1401 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1399 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1402 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1400 } 1403 }
1401 1404
1402 return mEditorDialog; 1405 return mEditorDialog;
1403} 1406}
1404 1407
1405void KABCore::slotEditorDestroyed( const QString &uid ) 1408void KABCore::slotEditorDestroyed( const QString &uid )
1406{ 1409{
1407 //mEditorDict.remove( uid ); 1410 //mEditorDict.remove( uid );
1408} 1411}
1409 1412
1410void KABCore::initGUI() 1413void KABCore::initGUI()
1411{ 1414{
1412#ifndef KAB_EMBEDDED 1415#ifndef KAB_EMBEDDED
1413 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1416 QHBoxLayout *topLayout = new QHBoxLayout( this );
1414 topLayout->setSpacing( KDialogBase::spacingHint() ); 1417 topLayout->setSpacing( KDialogBase::spacingHint() );
1415 1418
1416 mExtensionBarSplitter = new QSplitter( this ); 1419 mExtensionBarSplitter = new QSplitter( this );
1417 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1420 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1418 1421
1419 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1422 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1420 1423
1421 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1424 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1422 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1425 mIncSearchWidget = new IncSearchWidget( viewSpace );
1423 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1426 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1424 SLOT( incrementalSearch( const QString& ) ) ); 1427 SLOT( incrementalSearch( const QString& ) ) );
1425 1428
1426 mViewManager = new ViewManager( this, viewSpace ); 1429 mViewManager = new ViewManager( this, viewSpace );
1427 viewSpace->setStretchFactor( mViewManager, 1 ); 1430 viewSpace->setStretchFactor( mViewManager, 1 );
1428 1431
1429 mDetails = new ViewContainer( mDetailsSplitter ); 1432 mDetails = new ViewContainer( mDetailsSplitter );
1430 1433
1431 mJumpButtonBar = new JumpButtonBar( this, this ); 1434 mJumpButtonBar = new JumpButtonBar( this, this );
1432 1435
1433 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1436 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1434 1437
1435 topLayout->addWidget( mExtensionBarSplitter ); 1438 topLayout->addWidget( mExtensionBarSplitter );
1436 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1439 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1437 topLayout->addWidget( mJumpButtonBar ); 1440 topLayout->addWidget( mJumpButtonBar );
1438 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1441 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1439 1442
1440 mXXPortManager = new XXPortManager( this, this ); 1443 mXXPortManager = new XXPortManager( this, this );
1441 1444
1442#else //KAB_EMBEDDED 1445#else //KAB_EMBEDDED
1443 //US initialize viewMenu before settingup viewmanager. 1446 //US initialize viewMenu before settingup viewmanager.
1444 // Viewmanager needs this menu to plugin submenues. 1447 // Viewmanager needs this menu to plugin submenues.
1445 viewMenu = new QPopupMenu( this ); 1448 viewMenu = new QPopupMenu( this );
1446 settingsMenu = new QPopupMenu( this ); 1449 settingsMenu = new QPopupMenu( this );
1447 //filterMenu = new QPopupMenu( this ); 1450 //filterMenu = new QPopupMenu( this );
1448 ImportMenu = new QPopupMenu( this ); 1451 ImportMenu = new QPopupMenu( this );
1449 ExportMenu = new QPopupMenu( this ); 1452 ExportMenu = new QPopupMenu( this );
1450 syncMenu = new QPopupMenu( this ); 1453 syncMenu = new QPopupMenu( this );
1451 changeMenu= new QPopupMenu( this ); 1454 changeMenu= new QPopupMenu( this );
1452 1455
1453//US since we have no splitter for the embedded system, setup 1456//US since we have no splitter for the embedded system, setup
1454// a layout with two frames. One left and one right. 1457// a layout with two frames. One left and one right.
1455 1458
1456 QBoxLayout *topLayout; 1459 QBoxLayout *topLayout;
1457 1460
1458 // = new QHBoxLayout( this ); 1461 // = new QHBoxLayout( this );
1459// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1462// QBoxLayout *topLayout = (QBoxLayout*)layout();
1460 1463
1461// QWidget *mainBox = new QWidget( this ); 1464// QWidget *mainBox = new QWidget( this );
1462// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1465// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1463 1466
1464#ifdef DESKTOP_VERSION 1467#ifdef DESKTOP_VERSION
1465 topLayout = new QHBoxLayout( this ); 1468 topLayout = new QHBoxLayout( this );
1466 1469
1467 1470
1468 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1471 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1469 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1472 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1470 1473
1471 topLayout->addWidget(mMiniSplitter ); 1474 topLayout->addWidget(mMiniSplitter );
1472 1475
1473 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1476 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1474 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1477 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1475 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1478 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1476 mDetails = new ViewContainer( mMiniSplitter ); 1479 mDetails = new ViewContainer( mMiniSplitter );
1477 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1480 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1478#else 1481#else
1479 if ( QApplication::desktop()->width() > 480 ) { 1482 if ( QApplication::desktop()->width() > 480 ) {
1480 topLayout = new QHBoxLayout( this ); 1483 topLayout = new QHBoxLayout( this );
1481 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1484 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1482 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1485 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1483 } else { 1486 } else {
1484 1487
1485 topLayout = new QHBoxLayout( this ); 1488 topLayout = new QHBoxLayout( this );
1486 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1489 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1487 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1490 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1488 } 1491 }
1489 1492
1490 topLayout->addWidget(mMiniSplitter ); 1493 topLayout->addWidget(mMiniSplitter );
1491 mViewManager = new ViewManager( this, mMiniSplitter ); 1494 mViewManager = new ViewManager( this, mMiniSplitter );
1492 mDetails = new ViewContainer( mMiniSplitter ); 1495 mDetails = new ViewContainer( mMiniSplitter );
1493 1496
1494 1497
1495 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1498 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1496#endif 1499#endif
1497 //eh->hide(); 1500 //eh->hide();
1498 // topLayout->addWidget(mExtensionManager ); 1501 // topLayout->addWidget(mExtensionManager );
1499 1502
1500 1503
1501/*US 1504/*US
1502#ifndef KAB_NOSPLITTER 1505#ifndef KAB_NOSPLITTER
1503 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1506 QHBoxLayout *topLayout = new QHBoxLayout( this );
1504//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1507//US topLayout->setSpacing( KDialogBase::spacingHint() );
1505 topLayout->setSpacing( 10 ); 1508 topLayout->setSpacing( 10 );
1506 1509
1507 mDetailsSplitter = new QSplitter( this ); 1510 mDetailsSplitter = new QSplitter( this );
1508 1511
1509 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1512 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1510 1513
1511 mViewManager = new ViewManager( this, viewSpace ); 1514 mViewManager = new ViewManager( this, viewSpace );
1512 viewSpace->setStretchFactor( mViewManager, 1 ); 1515 viewSpace->setStretchFactor( mViewManager, 1 );
1513 1516
1514 mDetails = new ViewContainer( mDetailsSplitter ); 1517 mDetails = new ViewContainer( mDetailsSplitter );
1515 1518
1516 topLayout->addWidget( mDetailsSplitter ); 1519 topLayout->addWidget( mDetailsSplitter );
1517 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1520 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1518#else //KAB_NOSPLITTER 1521#else //KAB_NOSPLITTER
1519 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1522 QHBoxLayout *topLayout = new QHBoxLayout( this );
1520//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1523//US topLayout->setSpacing( KDialogBase::spacingHint() );
1521 topLayout->setSpacing( 10 ); 1524 topLayout->setSpacing( 10 );
1522 1525
1523// mDetailsSplitter = new QSplitter( this ); 1526// mDetailsSplitter = new QSplitter( this );
1524 1527
1525 QVBox *viewSpace = new QVBox( this ); 1528 QVBox *viewSpace = new QVBox( this );
1526 1529
1527 mViewManager = new ViewManager( this, viewSpace ); 1530 mViewManager = new ViewManager( this, viewSpace );
1528 viewSpace->setStretchFactor( mViewManager, 1 ); 1531 viewSpace->setStretchFactor( mViewManager, 1 );
1529 1532
1530 mDetails = new ViewContainer( this ); 1533 mDetails = new ViewContainer( this );
1531 1534
1532 topLayout->addWidget( viewSpace ); 1535 topLayout->addWidget( viewSpace );
1533// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1536// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1534 topLayout->addWidget( mDetails ); 1537 topLayout->addWidget( mDetails );
1535#endif //KAB_NOSPLITTER 1538#endif //KAB_NOSPLITTER
1536*/ 1539*/
1537 1540
1538 1541
1539#endif //KAB_EMBEDDED 1542#endif //KAB_EMBEDDED
1540 initActions(); 1543 initActions();
1541 1544
1542#ifdef KAB_EMBEDDED 1545#ifdef KAB_EMBEDDED
1543 addActionsManually(); 1546 addActionsManually();
1544 //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.
1545 mXXPortManager = new XXPortManager( this, this ); 1548 mXXPortManager = new XXPortManager( this, this );
1546 1549
1547 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1550 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1548 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1551 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1549 // mActionQuit->plug ( mMainWindow->toolBar()); 1552 // mActionQuit->plug ( mMainWindow->toolBar());
1550 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1553 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1551 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1554 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1552 // mIncSearchWidget->hide(); 1555 // mIncSearchWidget->hide();
1553 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1556 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1554 SLOT( incrementalSearch( const QString& ) ) ); 1557 SLOT( incrementalSearch( const QString& ) ) );
1555 1558
1556 1559
1557 mJumpButtonBar = new JumpButtonBar( this, this ); 1560 mJumpButtonBar = new JumpButtonBar( this, this );
1558 1561
1559 topLayout->addWidget( mJumpButtonBar ); 1562 topLayout->addWidget( mJumpButtonBar );
1560//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1563//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1561 1564
1562// mMainWindow->getIconToolBar()->raise(); 1565// mMainWindow->getIconToolBar()->raise();
1563 1566
1564#endif //KAB_EMBEDDED 1567#endif //KAB_EMBEDDED
1565 1568
1566} 1569}
1567void KABCore::initActions() 1570void KABCore::initActions()
1568{ 1571{
1569//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1572//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1570 1573
1571#ifndef KAB_EMBEDDED 1574#ifndef KAB_EMBEDDED
1572 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1575 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1573 SLOT( clipboardDataChanged() ) ); 1576 SLOT( clipboardDataChanged() ) );
1574#endif //KAB_EMBEDDED 1577#endif //KAB_EMBEDDED
1575 1578
1576 // file menu 1579 // file menu
1577 if ( mIsPart ) { 1580 if ( mIsPart ) {
1578 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1581 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1579 SLOT( sendMail() ), actionCollection(), 1582 SLOT( sendMail() ), actionCollection(),
1580 "kaddressbook_mail" ); 1583 "kaddressbook_mail" );
1581 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1584 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1582 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1585 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1583 1586
1584 } else { 1587 } else {
1585 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1588 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1586 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1589 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1587 } 1590 }
1588 1591
1589 1592
1590 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1593 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1591 SLOT( save() ), actionCollection(), "file_sync" ); 1594 SLOT( save() ), actionCollection(), "file_sync" );
1592 1595
1593 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1596 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1594 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1597 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1595 1598
1596 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1599 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1597 this, SLOT( mailVCard() ), 1600 this, SLOT( mailVCard() ),
1598 actionCollection(), "file_mail_vcard"); 1601 actionCollection(), "file_mail_vcard");
1599 1602
1600 mActionBeamVCard = 0; 1603 mActionBeamVCard = 0;
1601 mActionBeam = 0; 1604 mActionBeam = 0;
1602 1605
1603#ifndef DESKTOP_VERSION 1606#ifndef DESKTOP_VERSION
1604 if ( Ir::supported() ) { 1607 if ( Ir::supported() ) {
1605 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,
1606 SLOT( beamVCard() ), actionCollection(), 1609 SLOT( beamVCard() ), actionCollection(),
1607 "kaddressbook_beam_vcard" ); 1610 "kaddressbook_beam_vcard" );
1608 1611
1609 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1612 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1610 SLOT( beamMySelf() ), actionCollection(), 1613 SLOT( beamMySelf() ), actionCollection(),
1611 "kaddressbook_beam_myself" ); 1614 "kaddressbook_beam_myself" );
1612 } 1615 }
1613#endif 1616#endif
1614 1617
1615 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1618 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1616 this, SLOT( editContact2() ), 1619 this, SLOT( editContact2() ),
1617 actionCollection(), "file_properties" ); 1620 actionCollection(), "file_properties" );
1618 1621
1619#ifdef KAB_EMBEDDED 1622#ifdef KAB_EMBEDDED
1620 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1623 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1621 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1624 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1622 mMainWindow, SLOT( exit() ), 1625 mMainWindow, SLOT( exit() ),
1623 actionCollection(), "quit" ); 1626 actionCollection(), "quit" );
1624#endif //KAB_EMBEDDED 1627#endif //KAB_EMBEDDED
1625 1628
1626 // edit menu 1629 // edit menu
1627 if ( mIsPart ) { 1630 if ( mIsPart ) {
1628 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1631 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1629 SLOT( copyContacts() ), actionCollection(), 1632 SLOT( copyContacts() ), actionCollection(),
1630 "kaddressbook_copy" ); 1633 "kaddressbook_copy" );
1631 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1634 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1632 SLOT( cutContacts() ), actionCollection(), 1635 SLOT( cutContacts() ), actionCollection(),
1633 "kaddressbook_cut" ); 1636 "kaddressbook_cut" );
1634 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1637 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1635 SLOT( pasteContacts() ), actionCollection(), 1638 SLOT( pasteContacts() ), actionCollection(),
1636 "kaddressbook_paste" ); 1639 "kaddressbook_paste" );
1637 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1640 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1638 SLOT( selectAllContacts() ), actionCollection(), 1641 SLOT( selectAllContacts() ), actionCollection(),
1639 "kaddressbook_select_all" ); 1642 "kaddressbook_select_all" );
1640 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1643 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1641 SLOT( undo() ), actionCollection(), 1644 SLOT( undo() ), actionCollection(),
1642 "kaddressbook_undo" ); 1645 "kaddressbook_undo" );
1643 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1646 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1644 this, SLOT( redo() ), actionCollection(), 1647 this, SLOT( redo() ), actionCollection(),
1645 "kaddressbook_redo" ); 1648 "kaddressbook_redo" );
1646 } else { 1649 } else {
1647 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1650 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1648 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1651 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1649 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1652 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1650 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1653 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1651 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1654 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1652 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1655 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1653 } 1656 }
1654 1657
1655 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1658 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1656 Key_Delete, this, SLOT( deleteContacts() ), 1659 Key_Delete, this, SLOT( deleteContacts() ),
1657 actionCollection(), "edit_delete" ); 1660 actionCollection(), "edit_delete" );
1658 1661
1659 mActionUndo->setEnabled( false ); 1662 mActionUndo->setEnabled( false );
1660 mActionRedo->setEnabled( false ); 1663 mActionRedo->setEnabled( false );
1661 1664
1662 // settings menu 1665 // settings menu
1663#ifdef KAB_EMBEDDED 1666#ifdef KAB_EMBEDDED
1664//US special menuentry to configure the addressbook resources. On KDE 1667//US special menuentry to configure the addressbook resources. On KDE
1665// you do that through the control center !!! 1668// you do that through the control center !!!
1666 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1669 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1667 SLOT( configureResources() ), actionCollection(), 1670 SLOT( configureResources() ), actionCollection(),
1668 "kaddressbook_configure_resources" ); 1671 "kaddressbook_configure_resources" );
1669#endif //KAB_EMBEDDED 1672#endif //KAB_EMBEDDED
1670 1673
1671 if ( mIsPart ) { 1674 if ( mIsPart ) {
1672 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1675 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1673 SLOT( openConfigDialog() ), actionCollection(), 1676 SLOT( openConfigDialog() ), actionCollection(),
1674 "kaddressbook_configure" ); 1677 "kaddressbook_configure" );
1675 1678
1676 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1679 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1677 this, SLOT( configureKeyBindings() ), actionCollection(), 1680 this, SLOT( configureKeyBindings() ), actionCollection(),
1678 "kaddressbook_configure_shortcuts" ); 1681 "kaddressbook_configure_shortcuts" );
1679#ifdef KAB_EMBEDDED 1682#ifdef KAB_EMBEDDED
1680 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1683 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1681 mActionConfigureToolbars->setEnabled( false ); 1684 mActionConfigureToolbars->setEnabled( false );
1682#endif //KAB_EMBEDDED 1685#endif //KAB_EMBEDDED
1683 1686
1684 } else { 1687 } else {
1685 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1688 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1686 1689
1687 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1690 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1688 } 1691 }
1689 1692
1690 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1693 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1691 actionCollection(), "options_show_jump_bar" ); 1694 actionCollection(), "options_show_jump_bar" );
1692 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1695 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1693 1696
1694 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1697 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1695 actionCollection(), "options_show_details" ); 1698 actionCollection(), "options_show_details" );
1696 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1699 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1697 1700
1698 // misc 1701 // misc
1699 // only enable LDAP lookup if we can handle the protocol 1702 // only enable LDAP lookup if we can handle the protocol
1700#ifndef KAB_EMBEDDED 1703#ifndef KAB_EMBEDDED
1701 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1704 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1702 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1705 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1703 this, SLOT( openLDAPDialog() ), actionCollection(), 1706 this, SLOT( openLDAPDialog() ), actionCollection(),
1704 "ldap_lookup" ); 1707 "ldap_lookup" );
1705 } 1708 }
1706#else //KAB_EMBEDDED 1709#else //KAB_EMBEDDED
1707 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1710 //qDebug("KABCore::initActions() LDAP has to be implemented");
1708#endif //KAB_EMBEDDED 1711#endif //KAB_EMBEDDED
1709 1712
1710 1713
1711 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1714 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1712 SLOT( setWhoAmI() ), actionCollection(), 1715 SLOT( setWhoAmI() ), actionCollection(),
1713 "set_personal" ); 1716 "set_personal" );
1714 1717
1715 1718
1716 1719
1717 1720
1718 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1721 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1719 SLOT( setCategories() ), actionCollection(), 1722 SLOT( setCategories() ), actionCollection(),
1720 "edit_set_categories" ); 1723 "edit_set_categories" );
1721 1724
1722 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1725 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1723 SLOT( removeVoice() ), actionCollection(), 1726 SLOT( removeVoice() ), actionCollection(),
1724 "remove_voice" ); 1727 "remove_voice" );
1725 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1728 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1726 SLOT( importFromOL() ), actionCollection(), 1729 SLOT( importFromOL() ), actionCollection(),
1727 "import_OL" ); 1730 "import_OL" );
1728#ifdef KAB_EMBEDDED 1731#ifdef KAB_EMBEDDED
1729 mActionLicence = new KAction( i18n( "Licence" ), 0, 1732 mActionLicence = new KAction( i18n( "Licence" ), 0,
1730 this, SLOT( showLicence() ), actionCollection(), 1733 this, SLOT( showLicence() ), actionCollection(),
1731 "licence_about_data" ); 1734 "licence_about_data" );
1732 mActionFaq = new KAction( i18n( "Faq" ), 0, 1735 mActionFaq = new KAction( i18n( "Faq" ), 0,
1733 this, SLOT( faq() ), actionCollection(), 1736 this, SLOT( faq() ), actionCollection(),
1734 "faq_about_data" ); 1737 "faq_about_data" );
1735 1738
1736 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1739 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1737 this, SLOT( createAboutData() ), actionCollection(), 1740 this, SLOT( createAboutData() ), actionCollection(),
1738 "kaddressbook_about_data" ); 1741 "kaddressbook_about_data" );
1739#endif //KAB_EMBEDDED 1742#endif //KAB_EMBEDDED
1740 1743
1741 clipboardDataChanged(); 1744 clipboardDataChanged();
1742 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1745 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1743 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1746 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1744} 1747}
1745 1748
1746//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.
1747// 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.
1748void KABCore::addActionsManually() 1751void KABCore::addActionsManually()
1749{ 1752{
1750//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1753//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1751 1754
1752#ifdef KAB_EMBEDDED 1755#ifdef KAB_EMBEDDED
1753 QPopupMenu *fileMenu = new QPopupMenu( this ); 1756 QPopupMenu *fileMenu = new QPopupMenu( this );
1754 QPopupMenu *editMenu = new QPopupMenu( this ); 1757 QPopupMenu *editMenu = new QPopupMenu( this );
1755 QPopupMenu *helpMenu = new QPopupMenu( this ); 1758 QPopupMenu *helpMenu = new QPopupMenu( this );
1756 1759
1757 KToolBar* tb = mMainWindow->toolBar(); 1760 KToolBar* tb = mMainWindow->toolBar();
1758 1761
1759#ifdef DESKTOP_VERSION 1762#ifdef DESKTOP_VERSION
1760 QMenuBar* mb = mMainWindow->menuBar(); 1763 QMenuBar* mb = mMainWindow->menuBar();
1761 1764
1762 //US setup menubar. 1765 //US setup menubar.
1763 //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.
1764 mb->insertItem( "&File", fileMenu ); 1767 mb->insertItem( "&File", fileMenu );
1765 mb->insertItem( "&Edit", editMenu ); 1768 mb->insertItem( "&Edit", editMenu );
1766 mb->insertItem( "&View", viewMenu ); 1769 mb->insertItem( "&View", viewMenu );
1767 mb->insertItem( "&Settings", settingsMenu ); 1770 mb->insertItem( "&Settings", settingsMenu );
1768 mb->insertItem( i18n("Synchronize"), syncMenu ); 1771 mb->insertItem( i18n("Synchronize"), syncMenu );
1769 mb->insertItem( "&Change selected", changeMenu ); 1772 mb->insertItem( "&Change selected", changeMenu );
1770 mb->insertItem( "&Help", helpMenu ); 1773 mb->insertItem( "&Help", helpMenu );
1771 mIncSearchWidget = new IncSearchWidget( tb ); 1774 mIncSearchWidget = new IncSearchWidget( tb );
1772 // tb->insertWidget(-1, 0, mIncSearchWidget); 1775 // tb->insertWidget(-1, 0, mIncSearchWidget);
1773 1776
1774#else 1777#else
1775 //US setup toolbar 1778 //US setup toolbar
1776 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1779 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1777 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1780 QPopupMenu *popupBarTB = new QPopupMenu( this );
1778 menuBarTB->insertItem( "ME", popupBarTB); 1781 menuBarTB->insertItem( "ME", popupBarTB);
1779 tb->insertWidget(-1, 0, menuBarTB); 1782 tb->insertWidget(-1, 0, menuBarTB);
1780 mIncSearchWidget = new IncSearchWidget( tb ); 1783 mIncSearchWidget = new IncSearchWidget( tb );
1781 1784
1782 tb->enableMoving(false); 1785 tb->enableMoving(false);
1783 popupBarTB->insertItem( "&File", fileMenu ); 1786 popupBarTB->insertItem( "&File", fileMenu );
1784 popupBarTB->insertItem( "&Edit", editMenu ); 1787 popupBarTB->insertItem( "&Edit", editMenu );
1785 popupBarTB->insertItem( "&View", viewMenu ); 1788 popupBarTB->insertItem( "&View", viewMenu );
1786 popupBarTB->insertItem( "&Settings", settingsMenu ); 1789 popupBarTB->insertItem( "&Settings", settingsMenu );
1787 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1790 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1788 mViewManager->getFilterAction()->plug ( popupBarTB); 1791 mViewManager->getFilterAction()->plug ( popupBarTB);
1789 popupBarTB->insertItem( "&Change selected", changeMenu ); 1792 popupBarTB->insertItem( "&Change selected", changeMenu );
1790 popupBarTB->insertItem( "&Help", helpMenu ); 1793 popupBarTB->insertItem( "&Help", helpMenu );
1791 if (QApplication::desktop()->width() > 320 ) { 1794 if (QApplication::desktop()->width() > 320 ) {
1792 // mViewManager->getFilterAction()->plug ( tb); 1795 // mViewManager->getFilterAction()->plug ( tb);
1793 } 1796 }
1794#endif 1797#endif
1795 // mActionQuit->plug ( mMainWindow->toolBar()); 1798 // mActionQuit->plug ( mMainWindow->toolBar());
1796 1799
1797 1800
1798 1801
1799 //US Now connect the actions with the menue entries. 1802 //US Now connect the actions with the menue entries.
1800 mActionPrint->plug( fileMenu ); 1803 mActionPrint->plug( fileMenu );
1801 mActionMail->plug( fileMenu ); 1804 mActionMail->plug( fileMenu );
1802 fileMenu->insertSeparator(); 1805 fileMenu->insertSeparator();
1803 1806
1804 mActionNewContact->plug( fileMenu ); 1807 mActionNewContact->plug( fileMenu );
1805 mActionNewContact->plug( tb ); 1808 mActionNewContact->plug( tb );
1806 1809
1807 mActionEditAddressee->plug( fileMenu ); 1810 mActionEditAddressee->plug( fileMenu );
1808 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1811 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1809 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1812 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1810 mActionEditAddressee->plug( tb ); 1813 mActionEditAddressee->plug( tb );
1811 1814
1812 fileMenu->insertSeparator(); 1815 fileMenu->insertSeparator();
1813 mActionSave->plug( fileMenu ); 1816 mActionSave->plug( fileMenu );
1814 fileMenu->insertItem( "&Import", ImportMenu ); 1817 fileMenu->insertItem( "&Import", ImportMenu );
1815 fileMenu->insertItem( "&Export", ExportMenu ); 1818 fileMenu->insertItem( "&Export", ExportMenu );
1816 fileMenu->insertSeparator(); 1819 fileMenu->insertSeparator();
1817 mActionMailVCard->plug( fileMenu ); 1820 mActionMailVCard->plug( fileMenu );
1818#ifndef DESKTOP_VERSION 1821#ifndef DESKTOP_VERSION
1819 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1822 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1820 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1823 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1821#endif 1824#endif
1822 fileMenu->insertSeparator(); 1825 fileMenu->insertSeparator();
1823 mActionQuit->plug( fileMenu ); 1826 mActionQuit->plug( fileMenu );
1824#ifdef _WIN32_ 1827#ifdef _WIN32_
1825 mActionImportOL->plug( ImportMenu ); 1828 mActionImportOL->plug( ImportMenu );
1826#endif 1829#endif
1827 // edit menu 1830 // edit menu
1828 mActionUndo->plug( editMenu ); 1831 mActionUndo->plug( editMenu );
1829 mActionRedo->plug( editMenu ); 1832 mActionRedo->plug( editMenu );
1830 editMenu->insertSeparator(); 1833 editMenu->insertSeparator();
1831 mActionCut->plug( editMenu ); 1834 mActionCut->plug( editMenu );
1832 mActionCopy->plug( editMenu ); 1835 mActionCopy->plug( editMenu );
1833 mActionPaste->plug( editMenu ); 1836 mActionPaste->plug( editMenu );
1834 mActionDelete->plug( editMenu ); 1837 mActionDelete->plug( editMenu );
1835 editMenu->insertSeparator(); 1838 editMenu->insertSeparator();
1836 mActionSelectAll->plug( editMenu ); 1839 mActionSelectAll->plug( editMenu );
1837 1840
1838 mActionRemoveVoice->plug( changeMenu ); 1841 mActionRemoveVoice->plug( changeMenu );
1839 // settings menu 1842 // settings menu
1840//US special menuentry to configure the addressbook resources. On KDE 1843//US special menuentry to configure the addressbook resources. On KDE
1841// you do that through the control center !!! 1844// you do that through the control center !!!
1842 mActionConfigResources->plug( settingsMenu ); 1845 mActionConfigResources->plug( settingsMenu );
1843 settingsMenu->insertSeparator(); 1846 settingsMenu->insertSeparator();
1844 1847
1845 mActionConfigKAddressbook->plug( settingsMenu ); 1848 mActionConfigKAddressbook->plug( settingsMenu );
1846 1849
1847 if ( mIsPart ) { 1850 if ( mIsPart ) {
1848 mActionConfigShortcuts->plug( settingsMenu ); 1851 mActionConfigShortcuts->plug( settingsMenu );
1849 mActionConfigureToolbars->plug( settingsMenu ); 1852 mActionConfigureToolbars->plug( settingsMenu );
1850 1853
1851 } else { 1854 } else {
1852 mActionKeyBindings->plug( settingsMenu ); 1855 mActionKeyBindings->plug( settingsMenu );
1853 } 1856 }
1854 1857
1855 settingsMenu->insertSeparator(); 1858 settingsMenu->insertSeparator();
1856 1859
1857 mActionJumpBar->plug( settingsMenu ); 1860 mActionJumpBar->plug( settingsMenu );
1858 mActionDetails->plug( settingsMenu ); 1861 mActionDetails->plug( settingsMenu );
1859 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1862 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1860 mActionDetails->plug( tb ); 1863 mActionDetails->plug( tb );
1861 settingsMenu->insertSeparator(); 1864 settingsMenu->insertSeparator();
1862 1865
1863 mActionWhoAmI->plug( settingsMenu ); 1866 mActionWhoAmI->plug( settingsMenu );
1864 mActionCategories->plug( settingsMenu ); 1867 mActionCategories->plug( settingsMenu );
1865 1868
1866 mActionLicence->plug( helpMenu ); 1869 mActionLicence->plug( helpMenu );
1867 mActionFaq->plug( helpMenu ); 1870 mActionFaq->plug( helpMenu );
1868 mActionAboutKAddressbook->plug( helpMenu ); 1871 mActionAboutKAddressbook->plug( helpMenu );
1869 1872
1870 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1873 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1871 1874
1872 mActionSave->plug( tb ); 1875 mActionSave->plug( tb );
1873 mViewManager->getFilterAction()->plug ( tb); 1876 mViewManager->getFilterAction()->plug ( tb);
1874 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1877 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1875 mActionUndo->plug( tb ); 1878 mActionUndo->plug( tb );
1876 mActionDelete->plug( tb ); 1879 mActionDelete->plug( tb );
1877 mActionRedo->plug( tb ); 1880 mActionRedo->plug( tb );
1878 } 1881 }
1879 } 1882 }
1880 //mActionQuit->plug ( tb ); 1883 //mActionQuit->plug ( tb );
1881 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1884 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1882 1885
1883 //US link the searchwidget first to this. 1886 //US link the searchwidget first to this.
1884 // The real linkage to the toolbar happens later. 1887 // The real linkage to the toolbar happens later.
1885//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1888//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1886//US tb->insertItem( mIncSearchWidget ); 1889//US tb->insertItem( mIncSearchWidget );
1887/*US 1890/*US
1888 mIncSearchWidget = new IncSearchWidget( tb ); 1891 mIncSearchWidget = new IncSearchWidget( tb );
1889 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1892 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1890 SLOT( incrementalSearch( const QString& ) ) ); 1893 SLOT( incrementalSearch( const QString& ) ) );
1891 1894
1892 mJumpButtonBar = new JumpButtonBar( this, this ); 1895 mJumpButtonBar = new JumpButtonBar( this, this );
1893 1896
1894//US topLayout->addWidget( mJumpButtonBar ); 1897//US topLayout->addWidget( mJumpButtonBar );
1895 this->layout()->add( mJumpButtonBar ); 1898 this->layout()->add( mJumpButtonBar );
1896*/ 1899*/
1897 1900
1898#endif //KAB_EMBEDDED 1901#endif //KAB_EMBEDDED
1899 1902
1900 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 1903 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
1901 fillSyncMenu(); 1904 fillSyncMenu();
1902 1905
1903} 1906}
1904void KABCore::showLicence() 1907void KABCore::showLicence()
1905{ 1908{
1906 KApplication::showLicence(); 1909 KApplication::showLicence();
1907} 1910}
1908void KABCore::removeVoice() 1911void KABCore::removeVoice()
1909{ 1912{
1910 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 )
1911 return; 1914 return;
1912 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1915 KABC::Addressee::List list = mViewManager->selectedAddressees();
1913 KABC::Addressee::List::Iterator it; 1916 KABC::Addressee::List::Iterator it;
1914 for ( it = list.begin(); it != list.end(); ++it ) { 1917 for ( it = list.begin(); it != list.end(); ++it ) {
1915 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1918 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1916 PhoneNumber::List::Iterator phoneIt; 1919 PhoneNumber::List::Iterator phoneIt;
1917 bool found = false; 1920 bool found = false;
1918 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1921 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1919 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1922 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1920 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1923 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1921 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1924 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1922 (*it).insertPhoneNumber( (*phoneIt) ); 1925 (*it).insertPhoneNumber( (*phoneIt) );
1923 found = true; 1926 found = true;
1924 } 1927 }
1925 } 1928 }
1926 1929
1927 } 1930 }
1928 if ( found ) 1931 if ( found )
1929 contactModified((*it) ); 1932 contactModified((*it) );
1930 } 1933 }
1931} 1934}
1932 1935
1933 1936
1934 1937
1935void KABCore::clipboardDataChanged() 1938void KABCore::clipboardDataChanged()
1936{ 1939{
1937 1940
1938 if ( mReadWrite ) 1941 if ( mReadWrite )
1939 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1942 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1940 1943
1941} 1944}
1942 1945
1943void KABCore::updateActionMenu() 1946void KABCore::updateActionMenu()
1944{ 1947{
1945 UndoStack *undo = UndoStack::instance(); 1948 UndoStack *undo = UndoStack::instance();
1946 RedoStack *redo = RedoStack::instance(); 1949 RedoStack *redo = RedoStack::instance();
1947 1950
1948 if ( undo->isEmpty() ) 1951 if ( undo->isEmpty() )
1949 mActionUndo->setText( i18n( "Undo" ) ); 1952 mActionUndo->setText( i18n( "Undo" ) );
1950 else 1953 else
1951 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1954 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1952 1955
1953 mActionUndo->setEnabled( !undo->isEmpty() ); 1956 mActionUndo->setEnabled( !undo->isEmpty() );
1954 1957
1955 if ( !redo->top() ) 1958 if ( !redo->top() )
1956 mActionRedo->setText( i18n( "Redo" ) ); 1959 mActionRedo->setText( i18n( "Redo" ) );
1957 else 1960 else
1958 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1961 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1959 1962
1960 mActionRedo->setEnabled( !redo->isEmpty() ); 1963 mActionRedo->setEnabled( !redo->isEmpty() );
1961} 1964}
1962 1965
1963void KABCore::configureKeyBindings() 1966void KABCore::configureKeyBindings()
1964{ 1967{
1965#ifndef KAB_EMBEDDED 1968#ifndef KAB_EMBEDDED
1966 KKeyDialog::configure( actionCollection(), true ); 1969 KKeyDialog::configure( actionCollection(), true );
1967#else //KAB_EMBEDDED 1970#else //KAB_EMBEDDED
1968 qDebug("KABCore::configureKeyBindings() not implemented"); 1971 qDebug("KABCore::configureKeyBindings() not implemented");
1969#endif //KAB_EMBEDDED 1972#endif //KAB_EMBEDDED
1970} 1973}
1971 1974
1972#ifdef KAB_EMBEDDED 1975#ifdef KAB_EMBEDDED
1973void KABCore::configureResources() 1976void KABCore::configureResources()
1974{ 1977{
1975 KRES::KCMKResources dlg( this, "" , 0 ); 1978 KRES::KCMKResources dlg( this, "" , 0 );
1976 1979
1977 if ( !dlg.exec() ) 1980 if ( !dlg.exec() )
1978 return; 1981 return;
1979 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") );
1980} 1983}
1981#endif //KAB_EMBEDDED 1984#endif //KAB_EMBEDDED
1982 1985
1983 1986
1984/* 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
1985 * for the attendees list of an event. 1988 * for the attendees list of an event.
1986 */ 1989 */
1987void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 1990void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
1988{ 1991{
1989 QStringList nameList; 1992 QStringList nameList;
1990 QStringList emailList; 1993 QStringList emailList;
1991 QStringList uidList; 1994 QStringList uidList;
1992 1995
1993 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 1996 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
1994 uint i=0; 1997 uint i=0;
1995 for (i=0; i < list.count(); i++) 1998 for (i=0; i < list.count(); i++)
1996 { 1999 {
1997 nameList.append(list[i].realName()); 2000 nameList.append(list[i].realName());
1998 emailList.append(list[i].preferredEmail()); 2001 emailList.append(list[i].preferredEmail());
1999 uidList.append(list[i].uid()); 2002 uidList.append(list[i].uid());
2000 } 2003 }
2001 2004
2002 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2005 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2003 2006
2004} 2007}
2005 2008
2006/* 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.
2007 */ 2010 */
2008void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2011void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2009{ 2012{
2010 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());
2011 2014
2012 QString foundUid = QString::null; 2015 QString foundUid = QString::null;
2013 if ( ! uid.isEmpty() ) { 2016 if ( ! uid.isEmpty() ) {
2014 Addressee adrr = mAddressBook->findByUid( uid ); 2017 Addressee adrr = mAddressBook->findByUid( uid );
2015 if ( !adrr.isEmpty() ) { 2018 if ( !adrr.isEmpty() ) {
2016 foundUid = uid; 2019 foundUid = uid;
2017 } 2020 }
2018 if ( email == "sendbacklist" ) { 2021 if ( email == "sendbacklist" ) {
2019 //qDebug("ssssssssssssssssssssssend "); 2022 //qDebug("ssssssssssssssssssssssend ");
2020 QStringList nameList; 2023 QStringList nameList;
2021 QStringList emailList; 2024 QStringList emailList;
2022 QStringList uidList; 2025 QStringList uidList;
2023 nameList.append(adrr.realName()); 2026 nameList.append(adrr.realName());
2024 emailList = adrr.emails(); 2027 emailList = adrr.emails();
2025 uidList.append( adrr.preferredEmail()); 2028 uidList.append( adrr.preferredEmail());
2026 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);
2027 return; 2030 return;
2028 } 2031 }
2029 2032
2030 } 2033 }
2031 2034
2032 if ( email == "sendbacklist" ) 2035 if ( email == "sendbacklist" )
2033 return; 2036 return;
2034 if (foundUid.isEmpty()) 2037 if (foundUid.isEmpty())
2035 { 2038 {
2036 //find the uid of the person first 2039 //find the uid of the person first
2037 Addressee::List namelist; 2040 Addressee::List namelist;
2038 Addressee::List emaillist; 2041 Addressee::List emaillist;
2039 2042
2040 if (!name.isEmpty()) 2043 if (!name.isEmpty())
2041 namelist = mAddressBook->findByName( name ); 2044 namelist = mAddressBook->findByName( name );
2042 2045
2043 if (!email.isEmpty()) 2046 if (!email.isEmpty())
2044 emaillist = mAddressBook->findByEmail( email ); 2047 emaillist = mAddressBook->findByEmail( email );
2045 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2048 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2046 //check if we have a match in Namelist and Emaillist 2049 //check if we have a match in Namelist and Emaillist
2047 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2050 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2048 foundUid = emaillist[0].uid(); 2051 foundUid = emaillist[0].uid();
2049 } 2052 }
2050 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2053 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2051 foundUid = namelist[0].uid(); 2054 foundUid = namelist[0].uid();
2052 else 2055 else
2053 { 2056 {
2054 for (int i = 0; i < namelist.count(); i++) 2057 for (int i = 0; i < namelist.count(); i++)
2055 { 2058 {
2056 for (int j = 0; j < emaillist.count(); j++) 2059 for (int j = 0; j < emaillist.count(); j++)
2057 { 2060 {
2058 if (namelist[i] == emaillist[j]) 2061 if (namelist[i] == emaillist[j])
2059 { 2062 {
2060 foundUid = namelist[i].uid(); 2063 foundUid = namelist[i].uid();
2061 } 2064 }
2062 } 2065 }
2063 } 2066 }
2064 } 2067 }
2065 } 2068 }
2066 else 2069 else
2067 { 2070 {
2068 foundUid = uid; 2071 foundUid = uid;
2069 } 2072 }
2070 2073
2071 if (!foundUid.isEmpty()) 2074 if (!foundUid.isEmpty())
2072 { 2075 {
2073 2076
2074 // raise Ka/Pi if it is in the background 2077 // raise Ka/Pi if it is in the background
2075#ifndef DESKTOP_VERSION 2078#ifndef DESKTOP_VERSION
2076#ifndef KORG_NODCOP 2079#ifndef KORG_NODCOP
2077 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2080 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2078#endif 2081#endif
2079#endif 2082#endif
2080 2083
2081 mMainWindow->showMaximized(); 2084 mMainWindow->showMaximized();
2082 mMainWindow-> raise(); 2085 mMainWindow-> raise();
2083 2086
2084 mViewManager->setSelected( "", false); 2087 mViewManager->setSelected( "", false);
2085 mViewManager->refreshView( "" ); 2088 mViewManager->refreshView( "" );
2086 mViewManager->setSelected( foundUid, true ); 2089 mViewManager->setSelected( foundUid, true );
2087 mViewManager->refreshView( foundUid ); 2090 mViewManager->refreshView( foundUid );
2088 2091
2089 if ( !mMultipleViewsAtOnce ) 2092 if ( !mMultipleViewsAtOnce )
2090 { 2093 {
2091 setDetailsVisible( true ); 2094 setDetailsVisible( true );
2092 mActionDetails->setChecked(true); 2095 mActionDetails->setChecked(true);
2093 } 2096 }
2094 } 2097 }
2095} 2098}
2096 2099
2097 2100
2098void KABCore::faq() 2101void KABCore::faq()
2099{ 2102{
2100 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2103 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2101} 2104}
2102 2105
2103 2106
2104void KABCore::fillSyncMenu() 2107void KABCore::fillSyncMenu()
2105{ 2108{
2106 if ( syncMenu->count() ) 2109 if ( syncMenu->count() )
2107 syncMenu->clear(); 2110 syncMenu->clear();
2108 syncMenu->insertItem( i18n("Configure..."), 0 ); 2111 syncMenu->insertItem( i18n("Configure..."), 0 );
2109 syncMenu->insertSeparator(); 2112 syncMenu->insertSeparator();
2110 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 2113 syncMenu->insertItem( i18n("Multiple sync"), 1 );
2111 syncMenu->insertSeparator(); 2114 syncMenu->insertSeparator();
2112 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2115 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2113 config.setGroup("General"); 2116 config.setGroup("General");
2114 QStringList prof = config.readListEntry("SyncProfileNames"); 2117 QStringList prof = config.readListEntry("SyncProfileNames");
2115 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 2118 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
2116 if ( prof.count() < 3 ) { 2119 if ( prof.count() < 3 ) {
2117 prof.clear(); 2120 prof.clear();
2118 prof << i18n("Sharp_DTM"); 2121 prof << i18n("Sharp_DTM");
2119 prof << i18n("Local_file"); 2122 prof << i18n("Local_file");
2120 prof << i18n("Last_file"); 2123 prof << i18n("Last_file");
2121 KSyncProfile* temp = new KSyncProfile (); 2124 KSyncProfile* temp = new KSyncProfile ();
2122 temp->setName( prof[0] ); 2125 temp->setName( prof[0] );
2123 temp->writeConfig(&config); 2126 temp->writeConfig(&config);
2124 temp->setName( prof[1] ); 2127 temp->setName( prof[1] );
2125 temp->writeConfig(&config); 2128 temp->writeConfig(&config);
2126 temp->setName( prof[2] ); 2129 temp->setName( prof[2] );
2127 temp->writeConfig(&config); 2130 temp->writeConfig(&config);
2128 config.setGroup("General"); 2131 config.setGroup("General");
2129 config.writeEntry("SyncProfileNames",prof); 2132 config.writeEntry("SyncProfileNames",prof);
2130 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 2133 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
2131 config.sync(); 2134 config.sync();
2132 delete temp; 2135 delete temp;
2133 } 2136 }
2134 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 2137 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
2135 KABPrefs::instance()->mSyncProfileNames = prof; 2138 KABPrefs::instance()->mSyncProfileNames = prof;
2136 int i; 2139 int i;
2137 for ( i = 0; i < prof.count(); ++i ) { 2140 for ( i = 0; i < prof.count(); ++i ) {
2138 2141
2139 syncMenu->insertItem( prof[i], 1000+i ); 2142 syncMenu->insertItem( prof[i], 1000+i );
2140 if ( i == 2 ) 2143 if ( i == 2 )
2141 syncMenu->insertSeparator(); 2144 syncMenu->insertSeparator();
2142 } 2145 }
2143 QDir app_dir; 2146 QDir app_dir;
2144 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 2147 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
2145 syncMenu->setItemEnabled( false , 1000 ); 2148 syncMenu->setItemEnabled( false , 1000 );
2146 } 2149 }
2147 //probaly useless 2150 //probaly useless
2148 //mView->setupExternSyncProfiles(); 2151 //mView->setupExternSyncProfiles();
2149} 2152}
2150void KABCore::slotSyncMenu( int action ) 2153void KABCore::slotSyncMenu( int action )
2151{ 2154{
2152 //qDebug("syncaction %d ", action); 2155 //qDebug("syncaction %d ", action);
2153 if ( action == 0 ) { 2156 if ( action == 0 ) {
2154 2157
2155 // seems to be a Qt2 event handling bug 2158 // seems to be a Qt2 event handling bug
2156 // syncmenu.clear causes a segfault at first time 2159 // syncmenu.clear causes a segfault at first time
2157 // 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
2158 // 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
2159 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 2162 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
2160 //confSync(); 2163 //confSync();
2161 2164
2162 return; 2165 return;
2163 } 2166 }
2164 if ( action == 1 ) { 2167 if ( action == 1 ) {
2165 multiSync( true ); 2168 multiSync( true );
2166 return; 2169 return;
2167 } 2170 }
2168 2171
2169 if (mBlockSaveFlag) 2172 if (mBlockSaveFlag)
2170 return; 2173 return;
2171 mBlockSaveFlag = true; 2174 mBlockSaveFlag = true;
2172 mCurrentSyncProfile = action - 1000 ; 2175 mCurrentSyncProfile = action - 1000 ;
2173 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; 2176 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
2174 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; 2177 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
2175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2178 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2176 KSyncProfile* temp = new KSyncProfile (); 2179 KSyncProfile* temp = new KSyncProfile ();
2177 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2180 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2178 temp->readConfig(&config); 2181 temp->readConfig(&config);
2179 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2182 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2180 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2183 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2181 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2184 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2182 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2185 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2183 KABPrefs::instance()->mWriteBackInFuture = 0; 2186 KABPrefs::instance()->mWriteBackInFuture = 0;
2184 if ( temp->getWriteBackFuture() ) 2187 if ( temp->getWriteBackFuture() )
2185 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2188 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2186 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2189 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2187 if ( action == 1000 ) { 2190 if ( action == 1000 ) {
2188 syncSharp(); 2191 syncSharp();
2189 2192
2190 } else if ( action == 1001 ) { 2193 } else if ( action == 1001 ) {
2191 syncLocalFile(); 2194 syncLocalFile();
2192 2195
2193 } else if ( action == 1002 ) { 2196 } else if ( action == 1002 ) {
2194 quickSyncLocalFile(); 2197 quickSyncLocalFile();
2195 2198
2196 } else if ( action >= 1003 ) { 2199 } else if ( action >= 1003 ) {
2197 if ( temp->getIsLocalFileSync() ) { 2200 if ( temp->getIsLocalFileSync() ) {
2198 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 2201 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
2199 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 2202 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2200 } else { 2203 } else {
2201 if ( temp->getIsPhoneSync() ) { 2204 if ( temp->getIsPhoneSync() ) {
2202 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2205 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2203 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2206 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2204 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2207 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2205 syncPhone(); 2208 syncPhone();
2206 } else 2209 } else
2207 syncRemote( temp ); 2210 syncRemote( temp );
2208 2211
2209 } 2212 }
2210 } 2213 }
2211 delete temp; 2214 delete temp;
2212 mBlockSaveFlag = false; 2215 mBlockSaveFlag = false;
2213} 2216}
2214 2217
2215void KABCore::syncLocalFile() 2218void KABCore::syncLocalFile()
2216{ 2219{
2217 2220
2218 QString fn =KABPrefs::instance()->mLastSyncedLocalFile; 2221 QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
2219 2222
2220 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2223 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2221 if ( fn == "" ) 2224 if ( fn == "" )
2222 return; 2225 return;
2223 if ( syncWithFile( fn, false ) ) { 2226 if ( syncWithFile( fn, false ) ) {
2224 qDebug("syncLocalFile() successful "); 2227 qDebug("syncLocalFile() successful ");
2225 } 2228 }
2226 2229
2227} 2230}
2228bool KABCore::syncWithFile( QString fn , bool quick ) 2231bool KABCore::syncWithFile( QString fn , bool quick )
2229{ 2232{
2230 bool ret = false; 2233 bool ret = false;
2231 QFileInfo info; 2234 QFileInfo info;
2232 info.setFile( fn ); 2235 info.setFile( fn );
2233 QString mess; 2236 QString mess;
2234 bool loadbup = true; 2237 bool loadbup = true;
2235 if ( !info. exists() ) { 2238 if ( !info. exists() ) {
2236 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) );
2237 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2240 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2238 mess ); 2241 mess );
2239 return ret; 2242 return ret;
2240 } 2243 }
2241 int result = 0; 2244 int result = 0;
2242 if ( !quick ) { 2245 if ( !quick ) {
2243 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 ));
2244 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2247 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2245 mess, 2248 mess,
2246 i18n("Sync"), i18n("Cancel"), 0, 2249 i18n("Sync"), i18n("Cancel"), 0,
2247 0, 1 ); 2250 0, 1 );
2248 if ( result ) 2251 if ( result )
2249 return false; 2252 return false;
2250 } 2253 }
2251 if ( KABPrefs::instance()->mAskForPreferences ) 2254 if ( KABPrefs::instance()->mAskForPreferences )
2252 edit_sync_options(); 2255 edit_sync_options();
2253 if ( result == 0 ) { 2256 if ( result == 0 ) {
2254 //qDebug("Now sycing ... "); 2257 //qDebug("Now sycing ... ");
2255 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) 2258 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
2256 setCaption( i18n("Synchronization successful") ); 2259 setCaption( i18n("Synchronization successful") );
2257 else 2260 else
2258 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2261 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2259 if ( ! quick ) 2262 if ( ! quick )
2260 KABPrefs::instance()->mLastSyncedLocalFile = fn; 2263 KABPrefs::instance()->mLastSyncedLocalFile = fn;
2261 setModified(); 2264 setModified();
2262 } 2265 }
2263 return ret; 2266 return ret;
2264} 2267}
2265void KABCore::quickSyncLocalFile() 2268void KABCore::quickSyncLocalFile()
2266{ 2269{
2267 2270
2268 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2271 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2269 qDebug("quick syncLocalFile() successful "); 2272 qDebug("quick syncLocalFile() successful ");
2270 2273
2271 } 2274 }
2272} 2275}
2273void KABCore::multiSync( bool askforPrefs ) 2276void KABCore::multiSync( bool askforPrefs )
2274{ 2277{
2275 if (mBlockSaveFlag) 2278 if (mBlockSaveFlag)
2276 return; 2279 return;
2277 mBlockSaveFlag = true; 2280 mBlockSaveFlag = true;
2278 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!");
2279 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2282 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2280 question, 2283 question,
2281 i18n("Yes"), i18n("No"), 2284 i18n("Yes"), i18n("No"),
2282 0, 0 ) != 0 ) { 2285 0, 0 ) != 0 ) {
2283 mBlockSaveFlag = false; 2286 mBlockSaveFlag = false;
2284 setCaption(i18n("Aborted! Nothing synced!")); 2287 setCaption(i18n("Aborted! Nothing synced!"));
2285 return; 2288 return;
2286 } 2289 }
2287 mCurrentSyncDevice = i18n("Multiple profiles") ; 2290 mCurrentSyncDevice = i18n("Multiple profiles") ;
2288 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; 2291 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
2289 if ( askforPrefs ) { 2292 if ( askforPrefs ) {
2290 edit_sync_options(); 2293 edit_sync_options();
2291 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; 2294 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
2292 } 2295 }
2293 setCaption(i18n("Multiple sync started.") ); 2296 setCaption(i18n("Multiple sync started.") );
2294 qApp->processEvents(); 2297 qApp->processEvents();
2295 int num = ringSync() ; 2298 int num = ringSync() ;
2296 if ( num > 1 ) 2299 if ( num > 1 )
2297 ringSync(); 2300 ringSync();
2298 mBlockSaveFlag = false; 2301 mBlockSaveFlag = false;
2299 if ( num ) 2302 if ( num )
2300 save(); 2303 save();
2301 if ( num ) 2304 if ( num )
2302 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 2305 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
2303 else 2306 else
2304 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 2307 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
2305 return; 2308 return;
2306} 2309}
2307int KABCore::ringSync() 2310int KABCore::ringSync()
2308{ 2311{
2309 int syncedProfiles = 0; 2312 int syncedProfiles = 0;
2310 int i; 2313 int i;
2311 QTime timer; 2314 QTime timer;
2312 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2315 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2313 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; 2316 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
2314 KSyncProfile* temp = new KSyncProfile (); 2317 KSyncProfile* temp = new KSyncProfile ();
2315 KABPrefs::instance()->mAskForPreferences = false; 2318 KABPrefs::instance()->mAskForPreferences = false;
2316 for ( i = 0; i < syncProfileNames.count(); ++i ) { 2319 for ( i = 0; i < syncProfileNames.count(); ++i ) {
2317 mCurrentSyncProfile = i; 2320 mCurrentSyncProfile = i;
2318 temp->setName(syncProfileNames[mCurrentSyncProfile]); 2321 temp->setName(syncProfileNames[mCurrentSyncProfile]);
2319 temp->readConfig(&config); 2322 temp->readConfig(&config);
2320 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 2323 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
2321 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 2324 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
2322 ++syncedProfiles; 2325 ++syncedProfiles;
2323 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2326 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2324 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2327 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2325 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2328 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2326 KABPrefs::instance()->mWriteBackInFuture = 0; 2329 KABPrefs::instance()->mWriteBackInFuture = 0;
2327 if ( temp->getWriteBackFuture() ) 2330 if ( temp->getWriteBackFuture() )
2328 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2331 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2329 KABPrefs::instance()->mShowSyncSummary = false; 2332 KABPrefs::instance()->mShowSyncSummary = false;
2330 mCurrentSyncDevice = syncProfileNames[i] ; 2333 mCurrentSyncDevice = syncProfileNames[i] ;
2331 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; 2334 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
2332 if ( i == 0 ) { 2335 if ( i == 0 ) {
2333 syncSharp(); 2336 syncSharp();
2334 } else { 2337 } else {
2335 if ( temp->getIsLocalFileSync() ) { 2338 if ( temp->getIsLocalFileSync() ) {
2336 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 2339 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
2337 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 2340 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2338 } else { 2341 } else {
2339 if ( temp->getIsPhoneSync() ) { 2342 if ( temp->getIsPhoneSync() ) {
2340 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2343 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2341 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2344 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2342 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2345 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2343 syncPhone(); 2346 syncPhone();
2344 } else 2347 } else
2345 syncRemote( temp, false ); 2348 syncRemote( temp, false );
2346 2349
2347 } 2350 }
2348 } 2351 }
2349 timer.start(); 2352 timer.start();
2350 setCaption(i18n("Multiple sync in progress ... please wait!") ); 2353 setCaption(i18n("Multiple sync in progress ... please wait!") );
2351 while ( timer.elapsed () < 2000 ) { 2354 while ( timer.elapsed () < 2000 ) {
2352 qApp->processEvents(); 2355 qApp->processEvents();
2353#ifndef _WIN32_ 2356#ifndef _WIN32_
2354 sleep (1); 2357 sleep (1);
2355#endif 2358#endif
2356 } 2359 }
2357 2360
2358 } 2361 }
2359 2362
2360 } 2363 }
2361 delete temp; 2364 delete temp;
2362 return syncedProfiles; 2365 return syncedProfiles;
2363} 2366}
2364 2367
2365void KABCore::syncRemote( KSyncProfile* prof, bool ask) 2368void KABCore::syncRemote( KSyncProfile* prof, bool ask)
2366{ 2369{
2367 QString question; 2370 QString question;
2368 if ( ask ) { 2371 if ( ask ) {
2369 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";
2370 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2373 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2371 question, 2374 question,
2372 i18n("Yes"), i18n("No"), 2375 i18n("Yes"), i18n("No"),
2373 0, 0 ) != 0 ) 2376 0, 0 ) != 0 )
2374 return; 2377 return;
2375 } 2378 }
2376 QString command = prof->getPreSyncCommand(); 2379 QString command = prof->getPreSyncCommandAB();
2377 int fi; 2380 int fi;
2378 if ( (fi = command.find("$PWD$")) > 0 ) { 2381 if ( (fi = command.find("$PWD$")) > 0 ) {
2379 QString pwd = getPassword(); 2382 QString pwd = getPassword();
2380 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2383 command = command.left( fi )+ pwd + command.mid( fi+5 );
2381 2384
2382 } 2385 }
2383 int maxlen = 30; 2386 int maxlen = 30;
2384 if ( QApplication::desktop()->width() > 320 ) 2387 if ( QApplication::desktop()->width() > 320 )
2385 maxlen += 25; 2388 maxlen += 25;
2386 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2389 setCaption ( i18n( "Copy remote file to local machine..." ) );
2387 int fileSize = 0; 2390 int fileSize = 0;
2388 int result = system ( command ); 2391 int result = system ( command );
2389 // 0 : okay 2392 // 0 : okay
2390 // 256: no such file or dir 2393 // 256: no such file or dir
2391 // 2394 //
2392 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2395 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2393 if ( result != 0 ) { 2396 if ( result != 0 ) {
2394 int len = maxlen; 2397 int len = maxlen;
2395 while ( len < command.length() ) { 2398 while ( len < command.length() ) {
2396 command.insert( len , "\n" ); 2399 command.insert( len , "\n" );
2397 len += maxlen +2; 2400 len += maxlen +2;
2398 } 2401 }
2399 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) ;
2400 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2403 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2401 question, 2404 question,
2402 i18n("Okay!")) ; 2405 i18n("Okay!")) ;
2403 setCaption ("KO/Pi"); 2406 setCaption ("KO/Pi");
2404 return; 2407 return;
2405 } 2408 }
2406 setCaption ( i18n( "Copying succeed." ) ); 2409 setCaption ( i18n( "Copying succeed." ) );
2407 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2410 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2408 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2411 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) {
2409// Event* e = mView->getLastSyncEvent(); 2412// Event* e = mView->getLastSyncEvent();
2410// e->setReadOnly( false ); 2413// e->setReadOnly( false );
2411// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2414// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2412// e->setReadOnly( true ); 2415// e->setReadOnly( true );
2413 if ( KABPrefs::instance()->mWriteBackFile ) { 2416 if ( KABPrefs::instance()->mWriteBackFile ) {
2414 command = prof->getPostSyncCommand(); 2417 command = prof->getPostSyncCommandAB();
2415 int fi; 2418 int fi;
2416 if ( (fi = command.find("$PWD$")) > 0 ) { 2419 if ( (fi = command.find("$PWD$")) > 0 ) {
2417 QString pwd = getPassword(); 2420 QString pwd = getPassword();
2418 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2421 command = command.left( fi )+ pwd + command.mid( fi+5 );
2419 2422
2420 } 2423 }
2421 setCaption ( i18n( "Writing back file ..." ) ); 2424 setCaption ( i18n( "Writing back file ..." ) );
2422 result = system ( command ); 2425 result = system ( command );
2423 qDebug("KO: Writing back file result: %d ", result); 2426 qDebug("KO: Writing back file result: %d ", result);
2424 if ( result != 0 ) { 2427 if ( result != 0 ) {
2425 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2428 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2426 return; 2429 return;
2427 } else { 2430 } else {
2428 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2431 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2429 } 2432 }
2430 } 2433 }
2431 } 2434 }
2432 return; 2435 return;
2433} 2436}
2434#include <qpushbutton.h> 2437#include <qpushbutton.h>
2435#include <qradiobutton.h> 2438#include <qradiobutton.h>
2436#include <qbuttongroup.h> 2439#include <qbuttongroup.h>
2437void KABCore::edit_sync_options() 2440void KABCore::edit_sync_options()
2438{ 2441{
2439 //mDialogManager->showSyncOptions(); 2442 //mDialogManager->showSyncOptions();
2440 //KABPrefs::instance()->mSyncAlgoPrefs 2443 //KABPrefs::instance()->mSyncAlgoPrefs
2441 QDialog dia( this, "dia", true ); 2444 QDialog dia( this, "dia", true );
2442 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2445 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2443 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2446 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2444 QVBoxLayout lay ( &dia ); 2447 QVBoxLayout lay ( &dia );
2445 lay.setSpacing( 2 ); 2448 lay.setSpacing( 2 );
2446 lay.setMargin( 3 ); 2449 lay.setMargin( 3 );
2447 lay.addWidget(&gr); 2450 lay.addWidget(&gr);
2448 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2451 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2449 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2452 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2450 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2453 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2451 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2454 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2452 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2455 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2453 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2456 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2454 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2457 //QRadioButton both( i18n("Take both on conflict"), &gr );
2455 QPushButton pb ( "OK", &dia); 2458 QPushButton pb ( "OK", &dia);
2456 lay.addWidget( &pb ); 2459 lay.addWidget( &pb );
2457 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2460 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2458 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { 2461 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
2459 case 0: 2462 case 0:
2460 loc.setChecked( true); 2463 loc.setChecked( true);
2461 break; 2464 break;
2462 case 1: 2465 case 1:
2463 rem.setChecked( true ); 2466 rem.setChecked( true );
2464 break; 2467 break;
2465 case 2: 2468 case 2:
2466 newest.setChecked( true); 2469 newest.setChecked( true);
2467 break; 2470 break;
2468 case 3: 2471 case 3:
2469 ask.setChecked( true); 2472 ask.setChecked( true);
2470 break; 2473 break;
2471 case 4: 2474 case 4:
2472 f_loc.setChecked( true); 2475 f_loc.setChecked( true);
2473 break; 2476 break;
2474 case 5: 2477 case 5:
2475 f_rem.setChecked( true); 2478 f_rem.setChecked( true);
2476 break; 2479 break;
2477 case 6: 2480 case 6:
2478 // both.setChecked( true); 2481 // both.setChecked( true);
2479 break; 2482 break;
2480 default: 2483 default:
2481 break; 2484 break;
2482 } 2485 }
2483 if ( dia.exec() ) { 2486 if ( dia.exec() ) {
2484 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 ;
2485 } 2488 }
2486 2489
2487 2490
2488} 2491}
2489QString KABCore::getPassword( ) 2492QString KABCore::getPassword( )
2490{ 2493{
2491 QString retfile = ""; 2494 QString retfile = "";
2492 QDialog dia ( this, "input-dialog", true ); 2495 QDialog dia ( this, "input-dialog", true );
2493 QLineEdit lab ( &dia ); 2496 QLineEdit lab ( &dia );
2494 lab.setEchoMode( QLineEdit::Password ); 2497 lab.setEchoMode( QLineEdit::Password );
2495 QVBoxLayout lay( &dia ); 2498 QVBoxLayout lay( &dia );
2496 lay.setMargin(7); 2499 lay.setMargin(7);
2497 lay.setSpacing(7); 2500 lay.setSpacing(7);
2498 lay.addWidget( &lab); 2501 lay.addWidget( &lab);
2499 dia.setFixedSize( 230,50 ); 2502 dia.setFixedSize( 230,50 );
2500 dia.setCaption( i18n("Enter password") ); 2503 dia.setCaption( i18n("Enter password") );
2501 QPushButton pb ( "OK", &dia); 2504 QPushButton pb ( "OK", &dia);
2502 lay.addWidget( &pb ); 2505 lay.addWidget( &pb );
2503 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2506 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2504 dia.show(); 2507 dia.show();
2505 int res = dia.exec(); 2508 int res = dia.exec();
2506 if ( res ) 2509 if ( res )
2507 retfile = lab.text(); 2510 retfile = lab.text();
2508 dia.hide(); 2511 dia.hide();
2509 qApp->processEvents(); 2512 qApp->processEvents();
2510 return retfile; 2513 return retfile;
2511 2514
2512} 2515}
2516bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2517{
2513 2518
2519}
2514bool KABCore::syncAB(QString filename, int mode) 2520bool KABCore::syncAB(QString filename, int mode)
2515{ 2521{
2516 2522
2523
2524
2525 mGlobalSyncMode = SYNC_MODE_NORMAL;
2526 AddressBook abLocal(filename,"syncContact");
2527 bool syncOK = false;
2528 if ( abLocal.load() ) {
2529 qDebug("AB loaded %s mode %d",filename.latin1(), mode );
2530 AddressBook::Iterator it;
2531 QStringList vcards;
2532 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2533 qDebug("Name %s ", (*it).familyName().latin1());
2534 }
2535 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2536 if ( syncOK ) {
2537 if ( KABPrefs::instance()->mWriteBackFile )
2538 {
2539 abLocal.saveAB();
2540 }
2541 }
2542 setModified();
2543
2544 }
2545 if ( syncOK )
2546 ;//updateView();
2547 return syncOK;
2548#if 0
2549 mGlobalSyncMode = SYNC_MODE_NORMAL;
2550 CalendarLocal* calendar = new CalendarLocal();
2551 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2552 FileStorage* storage = new FileStorage( calendar );
2553 bool syncOK = false;
2554 storage->setFileName( filename );
2555 // qDebug("loading ... ");
2556 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2557 getEventViewerDialog()->setSyncMode( true );
2558 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2559 getEventViewerDialog()->setSyncMode( false );
2560 if ( syncOK ) {
2561 if ( KOPrefs::instance()->mWriteBackFile )
2562 {
2563 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2564 storage->save();
2565 }
2566 }
2567 setModified();
2568 }
2569 delete storage;
2570 delete calendar;
2571 if ( syncOK )
2572 updateView();
2573 return syncOK;
2574#endif
2517} 2575}
2518 2576
2519 2577
2520void KABCore::confSync() 2578void KABCore::confSync()
2521{ 2579{
2522 //mView->confSync(); 2580 static KSyncPrefsDialog* sp = 0;
2523 qDebug("pending KABCore::confSync() "); 2581 if ( ! sp ) {
2582 sp = new KSyncPrefsDialog( this, "syncprefs", true );
2583 }
2584 sp->usrReadConfig();
2585#ifndef DESKTOP_VERSION
2586 sp->showMaximized();
2587#else
2588 sp->show();
2589#endif
2590 sp->exec();
2591 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
2592 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
2524 fillSyncMenu(); 2593 fillSyncMenu();
2525} 2594}
2526void KABCore::syncSharp() 2595void KABCore::syncSharp()
2527{ 2596{
2528 if ( mModified ) 2597 if ( mModified )
2529 save(); 2598 save();
2530 qDebug("pending syncSharp() "); 2599 qDebug("pending syncSharp() ");
2531 //mView->syncSharp(); 2600 //mView->syncSharp();
2532 mModified = true ; 2601 setModified();
2533 2602
2534} 2603}
2535void KABCore::syncPhone() 2604void KABCore::syncPhone()
2536{ 2605{
2537 if ( mModified ) 2606 if ( mModified )
2538 save(); 2607 save();
2539 qDebug("pending syncPhone(); "); 2608 qDebug("pending syncPhone(); ");
2540 //mView->syncPhone(); 2609 //mView->syncPhone();
2541 setModified(); 2610 setModified();
2542 2611
2543} 2612}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 10ce8f4..4487a8a 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,478 +1,481 @@
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
36namespace KABC { 36namespace KABC {
37class AddressBook; 37class AddressBook;
38} 38}
39 39
40#ifndef KAB_EMBEDDED 40#ifndef KAB_EMBEDDED
41class KAboutData; 41class KAboutData;
42class KConfig; 42class KConfig;
43 43
44class KAddressBookService; 44class KAddressBookService;
45class LDAPSearchDialog; 45class LDAPSearchDialog;
46#else //KAB_EMBEDDED 46#else //KAB_EMBEDDED
47class KAddressBookMain; 47class KAddressBookMain;
48//US class QAction; 48//US class QAction;
49#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
50class KCMultiDialog; 50class KCMultiDialog;
51class KXMLGUIClient; 51class KXMLGUIClient;
52class ExtensionManager; 52class ExtensionManager;
53class XXPortManager; 53class XXPortManager;
54class JumpButtonBar; 54class JumpButtonBar;
55class IncSearchWidget; 55class IncSearchWidget;
56class KDGanttMinimizeSplitter; 56class KDGanttMinimizeSplitter;
57class KAction; 57class KAction;
58class KActionCollection; 58class KActionCollection;
59class KToggleAction; 59class KToggleAction;
60class KSyncProfile; 60class KSyncProfile;
61 61
62class QAction; 62class QAction;
63class QMenuBar; 63class QMenuBar;
64class QSplitter; 64class QSplitter;
65class ViewContainer; 65class ViewContainer;
66class ViewManager; 66class ViewManager;
67class AddresseeEditorDialog; 67class AddresseeEditorDialog;
68class Ir; 68class Ir;
69 69
70class KABCore : public QWidget 70class 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 void confSync();
460 QString mCurrentSyncDevice; 459 QString mCurrentSyncDevice;
461 QString mCurrentSyncName; 460 QString mCurrentSyncName;
462 void quickSyncLocalFile(); 461 void quickSyncLocalFile();
463 bool syncWithFile( QString fn , bool quick ); 462 bool syncWithFile( QString fn , bool quick );
464 void KABCore::syncLocalFile(); 463 void KABCore::syncLocalFile();
465 void KABCore::syncPhone(); 464 void KABCore::syncPhone();
466 void KABCore::syncSharp(); 465 void KABCore::syncSharp();
467 void multiSync( bool askforPrefs ); 466 void multiSync( bool askforPrefs );
468 int mCurrentSyncProfile ; 467 int mCurrentSyncProfile ;
469 void syncRemote( KSyncProfile* prof, bool ask = true); 468 void syncRemote( KSyncProfile* prof, bool ask = true);
470 void edit_sync_options(); 469 void edit_sync_options();
471 bool syncAB(QString filename, int mode); 470 bool syncAB(QString filename, int mode);
472 int ringSync(); 471 int ringSync();
473 QString getPassword( ); 472 QString getPassword( );
473 int mGlobalSyncMode;
474 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
475 public slots:
476 void confSync();
474 // ********************* 477 // *********************
475 478
476}; 479};
477 480
478#endif 481#endif