summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp1
-rw-r--r--kaddressbook/kabcore.cpp3
2 files changed, 2 insertions, 2 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index bf6d053..1a06956 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1,1004 +1,1003 @@
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#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qfile.h> 42#include <qfile.h>
43 43
44#include <kglobal.h> 44#include <kglobal.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kmessagebox.h> 46#include <kmessagebox.h>
47#include <kdebug.h> 47#include <kdebug.h>
48#include <libkcal/syncdefines.h> 48#include <libkcal/syncdefines.h>
49#include "addressbook.h" 49#include "addressbook.h"
50#include "resource.h" 50#include "resource.h"
51#include "vcardconverter.h" 51#include "vcardconverter.h"
52#include "vcardparser/vcardtool.h" 52#include "vcardparser/vcardtool.h"
53 53
54//US #include "addressbook.moc" 54//US #include "addressbook.moc"
55 55
56using namespace KABC; 56using namespace KABC;
57 57
58struct AddressBook::AddressBookData 58struct AddressBook::AddressBookData
59{ 59{
60 Addressee::List mAddressees; 60 Addressee::List mAddressees;
61 Addressee::List mRemovedAddressees; 61 Addressee::List mRemovedAddressees;
62 Field::List mAllFields; 62 Field::List mAllFields;
63 KConfig *mConfig; 63 KConfig *mConfig;
64 KRES::Manager<Resource> *mManager; 64 KRES::Manager<Resource> *mManager;
65//US ErrorHandler *mErrorHandler; 65//US ErrorHandler *mErrorHandler;
66}; 66};
67 67
68struct AddressBook::Iterator::IteratorData 68struct AddressBook::Iterator::IteratorData
69{ 69{
70 Addressee::List::Iterator mIt; 70 Addressee::List::Iterator mIt;
71}; 71};
72 72
73struct AddressBook::ConstIterator::ConstIteratorData 73struct AddressBook::ConstIterator::ConstIteratorData
74{ 74{
75 Addressee::List::ConstIterator mIt; 75 Addressee::List::ConstIterator mIt;
76}; 76};
77 77
78AddressBook::Iterator::Iterator() 78AddressBook::Iterator::Iterator()
79{ 79{
80 d = new IteratorData; 80 d = new IteratorData;
81} 81}
82 82
83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
84{ 84{
85 d = new IteratorData; 85 d = new IteratorData;
86 d->mIt = i.d->mIt; 86 d->mIt = i.d->mIt;
87} 87}
88 88
89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
90{ 90{
91 if( this == &i ) return *this; // guard against self assignment 91 if( this == &i ) return *this; // guard against self assignment
92 delete d; // delete the old data the Iterator was completely constructed before 92 delete d; // delete the old data the Iterator was completely constructed before
93 d = new IteratorData; 93 d = new IteratorData;
94 d->mIt = i.d->mIt; 94 d->mIt = i.d->mIt;
95 return *this; 95 return *this;
96} 96}
97 97
98AddressBook::Iterator::~Iterator() 98AddressBook::Iterator::~Iterator()
99{ 99{
100 delete d; 100 delete d;
101} 101}
102 102
103const Addressee &AddressBook::Iterator::operator*() const 103const Addressee &AddressBook::Iterator::operator*() const
104{ 104{
105 return *(d->mIt); 105 return *(d->mIt);
106} 106}
107 107
108Addressee &AddressBook::Iterator::operator*() 108Addressee &AddressBook::Iterator::operator*()
109{ 109{
110 return *(d->mIt); 110 return *(d->mIt);
111} 111}
112 112
113Addressee *AddressBook::Iterator::operator->() 113Addressee *AddressBook::Iterator::operator->()
114{ 114{
115 return &(*(d->mIt)); 115 return &(*(d->mIt));
116} 116}
117 117
118AddressBook::Iterator &AddressBook::Iterator::operator++() 118AddressBook::Iterator &AddressBook::Iterator::operator++()
119{ 119{
120 (d->mIt)++; 120 (d->mIt)++;
121 return *this; 121 return *this;
122} 122}
123 123
124AddressBook::Iterator &AddressBook::Iterator::operator++(int) 124AddressBook::Iterator &AddressBook::Iterator::operator++(int)
125{ 125{
126 (d->mIt)++; 126 (d->mIt)++;
127 return *this; 127 return *this;
128} 128}
129 129
130AddressBook::Iterator &AddressBook::Iterator::operator--() 130AddressBook::Iterator &AddressBook::Iterator::operator--()
131{ 131{
132 (d->mIt)--; 132 (d->mIt)--;
133 return *this; 133 return *this;
134} 134}
135 135
136AddressBook::Iterator &AddressBook::Iterator::operator--(int) 136AddressBook::Iterator &AddressBook::Iterator::operator--(int)
137{ 137{
138 (d->mIt)--; 138 (d->mIt)--;
139 return *this; 139 return *this;
140} 140}
141 141
142bool AddressBook::Iterator::operator==( const Iterator &it ) 142bool AddressBook::Iterator::operator==( const Iterator &it )
143{ 143{
144 return ( d->mIt == it.d->mIt ); 144 return ( d->mIt == it.d->mIt );
145} 145}
146 146
147bool AddressBook::Iterator::operator!=( const Iterator &it ) 147bool AddressBook::Iterator::operator!=( const Iterator &it )
148{ 148{
149 return ( d->mIt != it.d->mIt ); 149 return ( d->mIt != it.d->mIt );
150} 150}
151 151
152 152
153AddressBook::ConstIterator::ConstIterator() 153AddressBook::ConstIterator::ConstIterator()
154{ 154{
155 d = new ConstIteratorData; 155 d = new ConstIteratorData;
156} 156}
157 157
158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) 158AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i )
159{ 159{
160 d = new ConstIteratorData; 160 d = new ConstIteratorData;
161 d->mIt = i.d->mIt; 161 d->mIt = i.d->mIt;
162} 162}
163 163
164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) 164AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i )
165{ 165{
166 if( this == &i ) return *this; // guard for self assignment 166 if( this == &i ) return *this; // guard for self assignment
167 delete d; // delete the old data because the Iterator was really constructed before 167 delete d; // delete the old data because the Iterator was really constructed before
168 d = new ConstIteratorData; 168 d = new ConstIteratorData;
169 d->mIt = i.d->mIt; 169 d->mIt = i.d->mIt;
170 return *this; 170 return *this;
171} 171}
172 172
173AddressBook::ConstIterator::~ConstIterator() 173AddressBook::ConstIterator::~ConstIterator()
174{ 174{
175 delete d; 175 delete d;
176} 176}
177 177
178const Addressee &AddressBook::ConstIterator::operator*() const 178const Addressee &AddressBook::ConstIterator::operator*() const
179{ 179{
180 return *(d->mIt); 180 return *(d->mIt);
181} 181}
182 182
183const Addressee* AddressBook::ConstIterator::operator->() const 183const Addressee* AddressBook::ConstIterator::operator->() const
184{ 184{
185 return &(*(d->mIt)); 185 return &(*(d->mIt));
186} 186}
187 187
188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() 188AddressBook::ConstIterator &AddressBook::ConstIterator::operator++()
189{ 189{
190 (d->mIt)++; 190 (d->mIt)++;
191 return *this; 191 return *this;
192} 192}
193 193
194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) 194AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int)
195{ 195{
196 (d->mIt)++; 196 (d->mIt)++;
197 return *this; 197 return *this;
198} 198}
199 199
200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() 200AddressBook::ConstIterator &AddressBook::ConstIterator::operator--()
201{ 201{
202 (d->mIt)--; 202 (d->mIt)--;
203 return *this; 203 return *this;
204} 204}
205 205
206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) 206AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int)
207{ 207{
208 (d->mIt)--; 208 (d->mIt)--;
209 return *this; 209 return *this;
210} 210}
211 211
212bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) 212bool AddressBook::ConstIterator::operator==( const ConstIterator &it )
213{ 213{
214 return ( d->mIt == it.d->mIt ); 214 return ( d->mIt == it.d->mIt );
215} 215}
216 216
217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) 217bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
218{ 218{
219 return ( d->mIt != it.d->mIt ); 219 return ( d->mIt != it.d->mIt );
220} 220}
221 221
222 222
223AddressBook::AddressBook() 223AddressBook::AddressBook()
224{ 224{
225 init(0, "contact"); 225 init(0, "contact");
226} 226}
227 227
228AddressBook::AddressBook( const QString &config ) 228AddressBook::AddressBook( const QString &config )
229{ 229{
230 init(config, "contact"); 230 init(config, "contact");
231} 231}
232 232
233AddressBook::AddressBook( const QString &config, const QString &family ) 233AddressBook::AddressBook( const QString &config, const QString &family )
234{ 234{
235 init(config, family); 235 init(config, family);
236 236
237} 237}
238 238
239// the default family is "contact" 239// the default family is "contact"
240void AddressBook::init(const QString &config, const QString &family ) 240void AddressBook::init(const QString &config, const QString &family )
241{ 241{
242 blockLSEchange = false; 242 blockLSEchange = false;
243 d = new AddressBookData; 243 d = new AddressBookData;
244 QString fami = family; 244 QString fami = family;
245 if (config != 0) { 245 if (config != 0) {
246 if ( family == "syncContact" ) { 246 if ( family == "syncContact" ) {
247 qDebug("creating sync config "); 247 qDebug("creating sync config ");
248 fami = "contact"; 248 fami = "contact";
249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") ); 249 KConfig* con = new KConfig( locateLocal("config", "syncContactrc") );
250 con->setGroup( "General" ); 250 con->setGroup( "General" );
251 con->writeEntry( "ResourceKeys", QString("sync") ); 251 con->writeEntry( "ResourceKeys", QString("sync") );
252 con->writeEntry( "Standard", QString("sync") ); 252 con->writeEntry( "Standard", QString("sync") );
253 con->setGroup( "Resource_sync" ); 253 con->setGroup( "Resource_sync" );
254 con->writeEntry( "FileName", config ); 254 con->writeEntry( "FileName", config );
255 con->writeEntry( "FileFormat", QString("vcard") ); 255 con->writeEntry( "FileFormat", QString("vcard") );
256 con->writeEntry( "ResourceIdentifier", QString("sync") ); 256 con->writeEntry( "ResourceIdentifier", QString("sync") );
257 con->writeEntry( "ResourceName", QString("sync_res") ); 257 con->writeEntry( "ResourceName", QString("sync_res") );
258 if ( config.right(4) == ".xml" ) 258 if ( config.right(4) == ".xml" )
259 con->writeEntry( "ResourceType", QString("qtopia") ); 259 con->writeEntry( "ResourceType", QString("qtopia") );
260 else if ( config == "sharp" ) { 260 else if ( config == "sharp" ) {
261 con->writeEntry( "ResourceType", QString("sharp") ); 261 con->writeEntry( "ResourceType", QString("sharp") );
262 } else { 262 } else {
263 con->writeEntry( "ResourceType", QString("file") ); 263 con->writeEntry( "ResourceType", QString("file") );
264 } 264 }
265 //con->sync(); 265 //con->sync();
266 d->mConfig = con; 266 d->mConfig = con;
267 } 267 }
268 else 268 else
269 d->mConfig = new KConfig( locateLocal("config", config) ); 269 d->mConfig = new KConfig( locateLocal("config", config) );
270// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 270// qDebug("AddressBook::init 1 config=%s",config.latin1() );
271 } 271 }
272 else { 272 else {
273 d->mConfig = 0; 273 d->mConfig = 0;
274// qDebug("AddressBook::init 1 config=0"); 274// qDebug("AddressBook::init 1 config=0");
275 } 275 }
276 276
277//US d->mErrorHandler = 0; 277//US d->mErrorHandler = 0;
278 d->mManager = new KRES::Manager<Resource>( fami, false ); 278 d->mManager = new KRES::Manager<Resource>( fami, false );
279 d->mManager->readConfig( d->mConfig ); 279 d->mManager->readConfig( d->mConfig );
280 if ( family == "syncContact" ) { 280 if ( family == "syncContact" ) {
281 KRES::Manager<Resource> *manager = d->mManager; 281 KRES::Manager<Resource> *manager = d->mManager;
282 KRES::Manager<Resource>::ActiveIterator it; 282 KRES::Manager<Resource>::ActiveIterator it;
283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 283 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
284 (*it)->setAddressBook( this ); 284 (*it)->setAddressBook( this );
285 if ( !(*it)->open() ) 285 if ( !(*it)->open() )
286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 286 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
287 } 287 }
288 Resource *res = standardResource(); 288 Resource *res = standardResource();
289 if ( !res ) { 289 if ( !res ) {
290 qDebug("ERROR: no standard resource"); 290 qDebug("ERROR: no standard resource");
291 res = manager->createResource( "file" ); 291 res = manager->createResource( "file" );
292 if ( res ) 292 if ( res )
293 { 293 {
294 addResource( res ); 294 addResource( res );
295 } 295 }
296 else 296 else
297 qDebug(" No resource available!!!"); 297 qDebug(" No resource available!!!");
298 } 298 }
299 setStandardResource( res ); 299 setStandardResource( res );
300 manager->writeConfig(); 300 manager->writeConfig();
301 } 301 }
302 addCustomField( i18n( "Department" ), KABC::Field::Organization, 302 addCustomField( i18n( "Department" ), KABC::Field::Organization,
303 "X-Department", "KADDRESSBOOK" ); 303 "X-Department", "KADDRESSBOOK" );
304 addCustomField( i18n( "Profession" ), KABC::Field::Organization, 304 addCustomField( i18n( "Profession" ), KABC::Field::Organization,
305 "X-Profession", "KADDRESSBOOK" ); 305 "X-Profession", "KADDRESSBOOK" );
306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 306 addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
307 "X-AssistantsName", "KADDRESSBOOK" ); 307 "X-AssistantsName", "KADDRESSBOOK" );
308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 308 addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
309 "X-ManagersName", "KADDRESSBOOK" ); 309 "X-ManagersName", "KADDRESSBOOK" );
310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 310 addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
311 "X-SpousesName", "KADDRESSBOOK" ); 311 "X-SpousesName", "KADDRESSBOOK" );
312 addCustomField( i18n( "Office" ), KABC::Field::Personal, 312 addCustomField( i18n( "Office" ), KABC::Field::Personal,
313 "X-Office", "KADDRESSBOOK" ); 313 "X-Office", "KADDRESSBOOK" );
314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 314 addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
315 "X-IMAddress", "KADDRESSBOOK" ); 315 "X-IMAddress", "KADDRESSBOOK" );
316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 316 addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
317 "X-Anniversary", "KADDRESSBOOK" ); 317 "X-Anniversary", "KADDRESSBOOK" );
318 318
319 //US added this field to become compatible with Opie/qtopia addressbook 319 //US added this field to become compatible with Opie/qtopia addressbook
320 // values can be "female" or "male" or "". An empty field represents undefined. 320 // values can be "female" or "male" or "". An empty field represents undefined.
321 addCustomField( i18n( "Gender" ), KABC::Field::Personal, 321 addCustomField( i18n( "Gender" ), KABC::Field::Personal,
322 "X-Gender", "KADDRESSBOOK" ); 322 "X-Gender", "KADDRESSBOOK" );
323 addCustomField( i18n( "Children" ), KABC::Field::Personal, 323 addCustomField( i18n( "Children" ), KABC::Field::Personal,
324 "X-Children", "KADDRESSBOOK" ); 324 "X-Children", "KADDRESSBOOK" );
325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 325 addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
326 "X-FreeBusyUrl", "KADDRESSBOOK" ); 326 "X-FreeBusyUrl", "KADDRESSBOOK" );
327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal, 327 addCustomField( i18n( "ExternalID" ), KABC::Field::Personal,
328 "X-ExternalID", "KADDRESSBOOK" ); 328 "X-ExternalID", "KADDRESSBOOK" );
329} 329}
330 330
331AddressBook::~AddressBook() 331AddressBook::~AddressBook()
332{ 332{
333 delete d->mConfig; d->mConfig = 0; 333 delete d->mConfig; d->mConfig = 0;
334 delete d->mManager; d->mManager = 0; 334 delete d->mManager; d->mManager = 0;
335//US delete d->mErrorHandler; d->mErrorHandler = 0; 335//US delete d->mErrorHandler; d->mErrorHandler = 0;
336 delete d; d = 0; 336 delete d; d = 0;
337} 337}
338 338
339bool AddressBook::load() 339bool AddressBook::load()
340{ 340{
341 341
342 342
343 clear(); 343 clear();
344 344
345 KRES::Manager<Resource>::ActiveIterator it; 345 KRES::Manager<Resource>::ActiveIterator it;
346 bool ok = true; 346 bool ok = true;
347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 347 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
348 if ( !(*it)->load() ) { 348 if ( !(*it)->load() ) {
349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 349 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
350 ok = false; 350 ok = false;
351 } 351 }
352 352
353 // mark all addressees as unchanged 353 // mark all addressees as unchanged
354 Addressee::List::Iterator addrIt; 354 Addressee::List::Iterator addrIt;
355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) { 355 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) {
356 (*addrIt).setChanged( false ); 356 (*addrIt).setChanged( false );
357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" ); 357 QString id = (*addrIt).custom( "KADDRESSBOOK", "X-ExternalID" );
358 if ( !id.isEmpty() ) { 358 if ( !id.isEmpty() ) {
359 //qDebug("setId aa %s ", id.latin1()); 359 //qDebug("setId aa %s ", id.latin1());
360 (*addrIt).setIDStr(id ); 360 (*addrIt).setIDStr(id );
361 } 361 }
362 } 362 }
363 blockLSEchange = true; 363 blockLSEchange = true;
364 return ok; 364 return ok;
365} 365}
366 366
367bool AddressBook::save( Ticket *ticket ) 367bool AddressBook::save( Ticket *ticket )
368{ 368{
369 kdDebug(5700) << "AddressBook::save()"<< endl; 369 kdDebug(5700) << "AddressBook::save()"<< endl;
370 370
371 if ( ticket->resource() ) { 371 if ( ticket->resource() ) {
372 deleteRemovedAddressees(); 372 deleteRemovedAddressees();
373 return ticket->resource()->save( ticket ); 373 return ticket->resource()->save( ticket );
374 } 374 }
375 375
376 return false; 376 return false;
377} 377}
378void AddressBook::export2File( QString fileName ) 378void AddressBook::export2File( QString fileName )
379{ 379{
380 380
381 QFile outFile( fileName ); 381 QFile outFile( fileName );
382 if ( !outFile.open( IO_WriteOnly ) ) { 382 if ( !outFile.open( IO_WriteOnly ) ) {
383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" ); 383 QString text = i18n( "<qt>Unable to open file <b>%1</b> for export.</qt>" );
384 KMessageBox::error( 0, text.arg( fileName ) ); 384 KMessageBox::error( 0, text.arg( fileName ) );
385 return ; 385 return ;
386 } 386 }
387 QTextStream t( &outFile ); 387 QTextStream t( &outFile );
388 t.setEncoding( QTextStream::UnicodeUTF8 ); 388 t.setEncoding( QTextStream::UnicodeUTF8 );
389 Iterator it; 389 Iterator it;
390 KABC::VCardConverter::Version version; 390 KABC::VCardConverter::Version version;
391 version = KABC::VCardConverter::v3_0; 391 version = KABC::VCardConverter::v3_0;
392 for ( it = begin(); it != end(); ++it ) { 392 for ( it = begin(); it != end(); ++it ) {
393 if ( !(*it).IDStr().isEmpty() ) { 393 if ( !(*it).IDStr().isEmpty() ) {
394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() ); 394 (*it).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*it).IDStr() );
395 } 395 }
396 KABC::VCardConverter converter; 396 KABC::VCardConverter converter;
397 QString vcard; 397 QString vcard;
398 //Resource *resource() const; 398 //Resource *resource() const;
399 converter.addresseeToVCard( *it, vcard, version ); 399 converter.addresseeToVCard( *it, vcard, version );
400 t << vcard << "\r\n"; 400 t << vcard << "\r\n";
401 } 401 }
402 t << "\r\n\r\n"; 402 t << "\r\n\r\n";
403 outFile.close(); 403 outFile.close();
404} 404}
405void AddressBook::importFromFile( QString fileName, bool replaceLabel ) 405void AddressBook::importFromFile( QString fileName, bool replaceLabel )
406{ 406{
407 407
408 KABC::Addressee::List list; 408 KABC::Addressee::List list;
409 QFile file( fileName ); 409 QFile file( fileName );
410 410
411 file.open( IO_ReadOnly ); 411 file.open( IO_ReadOnly );
412 QByteArray rawData = file.readAll(); 412 QByteArray rawData = file.readAll();
413 file.close(); 413 file.close();
414 qDebug("AddressBook::importFromFile ");
415 QString data; 414 QString data;
416 if ( replaceLabel ) { 415 if ( replaceLabel ) {
417 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 ); 416 data = QString::fromLatin1( rawData.data(), rawData.size() + 1 );
418 data.replace ( QRegExp("LABEL") , "ADR" ); 417 data.replace ( QRegExp("LABEL") , "ADR" );
419 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" ); 418 data.replace ( QRegExp("CHARSET=ISO-8859-1") , "" );
420 } else 419 } else
421 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 ); 420 data = QString::fromUtf8( rawData.data(), rawData.size() + 1 );
422 KABC::VCardTool tool; 421 KABC::VCardTool tool;
423 list = tool.parseVCards( data ); 422 list = tool.parseVCards( data );
424 KABC::Addressee::List::Iterator it; 423 KABC::Addressee::List::Iterator it;
425 for ( it = list.begin(); it != list.end(); ++it ) { 424 for ( it = list.begin(); it != list.end(); ++it ) {
426 (*it).setResource( 0 ); 425 (*it).setResource( 0 );
427 if ( replaceLabel ) 426 if ( replaceLabel )
428 (*it).removeVoice(); 427 (*it).removeVoice();
429 insertAddressee( (*it), false, true ); 428 insertAddressee( (*it), false, true );
430 } 429 }
431 430
432} 431}
433 432
434bool AddressBook::saveAB() 433bool AddressBook::saveAB()
435{ 434{
436 bool ok = true; 435 bool ok = true;
437 436
438 deleteRemovedAddressees(); 437 deleteRemovedAddressees();
439 Iterator ait; 438 Iterator ait;
440 for ( ait = begin(); ait != end(); ++ait ) { 439 for ( ait = begin(); ait != end(); ++ait ) {
441 if ( !(*ait).IDStr().isEmpty() ) { 440 if ( !(*ait).IDStr().isEmpty() ) {
442 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 441 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
443 } 442 }
444 } 443 }
445 KRES::Manager<Resource>::ActiveIterator it; 444 KRES::Manager<Resource>::ActiveIterator it;
446 KRES::Manager<Resource> *manager = d->mManager; 445 KRES::Manager<Resource> *manager = d->mManager;
447 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 446 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
448 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 447 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
449 Ticket *ticket = requestSaveTicket( *it ); 448 Ticket *ticket = requestSaveTicket( *it );
450// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 449// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
451 if ( !ticket ) { 450 if ( !ticket ) {
452 error( i18n( "Unable to save to resource '%1'. It is locked." ) 451 error( i18n( "Unable to save to resource '%1'. It is locked." )
453 .arg( (*it)->resourceName() ) ); 452 .arg( (*it)->resourceName() ) );
454 return false; 453 return false;
455 } 454 }
456 455
457 //if ( !save( ticket ) ) 456 //if ( !save( ticket ) )
458 if ( ticket->resource() ) { 457 if ( ticket->resource() ) {
459 if ( ! ticket->resource()->save( ticket ) ) 458 if ( ! ticket->resource()->save( ticket ) )
460 ok = false; 459 ok = false;
461 } else 460 } else
462 ok = false; 461 ok = false;
463 462
464 } 463 }
465 } 464 }
466 return ok; 465 return ok;
467} 466}
468 467
469AddressBook::Iterator AddressBook::begin() 468AddressBook::Iterator AddressBook::begin()
470{ 469{
471 Iterator it = Iterator(); 470 Iterator it = Iterator();
472 it.d->mIt = d->mAddressees.begin(); 471 it.d->mIt = d->mAddressees.begin();
473 return it; 472 return it;
474} 473}
475 474
476AddressBook::ConstIterator AddressBook::begin() const 475AddressBook::ConstIterator AddressBook::begin() const
477{ 476{
478 ConstIterator it = ConstIterator(); 477 ConstIterator it = ConstIterator();
479 it.d->mIt = d->mAddressees.begin(); 478 it.d->mIt = d->mAddressees.begin();
480 return it; 479 return it;
481} 480}
482 481
483AddressBook::Iterator AddressBook::end() 482AddressBook::Iterator AddressBook::end()
484{ 483{
485 Iterator it = Iterator(); 484 Iterator it = Iterator();
486 it.d->mIt = d->mAddressees.end(); 485 it.d->mIt = d->mAddressees.end();
487 return it; 486 return it;
488} 487}
489 488
490AddressBook::ConstIterator AddressBook::end() const 489AddressBook::ConstIterator AddressBook::end() const
491{ 490{
492 ConstIterator it = ConstIterator(); 491 ConstIterator it = ConstIterator();
493 it.d->mIt = d->mAddressees.end(); 492 it.d->mIt = d->mAddressees.end();
494 return it; 493 return it;
495} 494}
496 495
497void AddressBook::clear() 496void AddressBook::clear()
498{ 497{
499 d->mAddressees.clear(); 498 d->mAddressees.clear();
500} 499}
501 500
502Ticket *AddressBook::requestSaveTicket( Resource *resource ) 501Ticket *AddressBook::requestSaveTicket( Resource *resource )
503{ 502{
504 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; 503 kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl;
505 504
506 if ( !resource ) 505 if ( !resource )
507 { 506 {
508 qDebug("AddressBook::requestSaveTicket no resource" ); 507 qDebug("AddressBook::requestSaveTicket no resource" );
509 resource = standardResource(); 508 resource = standardResource();
510 } 509 }
511 510
512 KRES::Manager<Resource>::ActiveIterator it; 511 KRES::Manager<Resource>::ActiveIterator it;
513 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 512 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
514 if ( (*it) == resource ) { 513 if ( (*it) == resource ) {
515 if ( (*it)->readOnly() || !(*it)->isOpen() ) 514 if ( (*it)->readOnly() || !(*it)->isOpen() )
516 return 0; 515 return 0;
517 else 516 else
518 return (*it)->requestSaveTicket(); 517 return (*it)->requestSaveTicket();
519 } 518 }
520 } 519 }
521 520
522 return 0; 521 return 0;
523} 522}
524 523
525void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource ) 524void AddressBook::insertAddressee( const Addressee &a, bool setRev, bool takeResource )
526{ 525{
527 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) { 526 if ( blockLSEchange && setRev && a.uid().left( 19 ) == QString("last-syncAddressee-") ) {
528 //qDebug("block insert "); 527 //qDebug("block insert ");
529 return; 528 return;
530 } 529 }
531 //qDebug("inserting.... %s ",a.uid().latin1() ); 530 //qDebug("inserting.... %s ",a.uid().latin1() );
532 bool found = false; 531 bool found = false;
533 Addressee::List::Iterator it; 532 Addressee::List::Iterator it;
534 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { 533 for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) {
535 if ( a.uid() == (*it).uid() ) { 534 if ( a.uid() == (*it).uid() ) {
536 535
537 bool changed = false; 536 bool changed = false;
538 Addressee addr = a; 537 Addressee addr = a;
539 if ( addr != (*it) ) 538 if ( addr != (*it) )
540 changed = true; 539 changed = true;
541 540
542 if ( takeResource ) { 541 if ( takeResource ) {
543 Resource * res = (*it).resource(); 542 Resource * res = (*it).resource();
544 (*it) = a; 543 (*it) = a;
545 (*it).setResource( res ); 544 (*it).setResource( res );
546 } else { 545 } else {
547 (*it) = a; 546 (*it) = a;
548 if ( (*it).resource() == 0 ) 547 if ( (*it).resource() == 0 )
549 (*it).setResource( standardResource() ); 548 (*it).setResource( standardResource() );
550 } 549 }
551 if ( changed ) { 550 if ( changed ) {
552 if ( setRev ) { 551 if ( setRev ) {
553 552
554 // get rid of micro seconds 553 // get rid of micro seconds
555 QDateTime dt = QDateTime::currentDateTime(); 554 QDateTime dt = QDateTime::currentDateTime();
556 QTime t = dt.time(); 555 QTime t = dt.time();
557 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 556 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
558 (*it).setRevision( dt ); 557 (*it).setRevision( dt );
559 } 558 }
560 (*it).setChanged( true ); 559 (*it).setChanged( true );
561 } 560 }
562 561
563 found = true; 562 found = true;
564 } else { 563 } else {
565 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 564 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
566 QString name = (*it).uid().mid( 19 ); 565 QString name = (*it).uid().mid( 19 );
567 Addressee b = a; 566 Addressee b = a;
568 QString id = b.getID( name ); 567 QString id = b.getID( name );
569 if ( ! id.isEmpty() ) { 568 if ( ! id.isEmpty() ) {
570 QString des = (*it).note(); 569 QString des = (*it).note();
571 int startN; 570 int startN;
572 if( (startN = des.find( id ) ) >= 0 ) { 571 if( (startN = des.find( id ) ) >= 0 ) {
573 int endN = des.find( ",", startN+1 ); 572 int endN = des.find( ",", startN+1 );
574 des = des.left( startN ) + des.mid( endN+1 ); 573 des = des.left( startN ) + des.mid( endN+1 );
575 (*it).setNote( des ); 574 (*it).setNote( des );
576 } 575 }
577 } 576 }
578 } 577 }
579 } 578 }
580 } 579 }
581 if ( found ) 580 if ( found )
582 return; 581 return;
583 d->mAddressees.append( a ); 582 d->mAddressees.append( a );
584 Addressee& addr = d->mAddressees.last(); 583 Addressee& addr = d->mAddressees.last();
585 if ( addr.resource() == 0 ) 584 if ( addr.resource() == 0 )
586 addr.setResource( standardResource() ); 585 addr.setResource( standardResource() );
587 586
588 addr.setChanged( true ); 587 addr.setChanged( true );
589} 588}
590 589
591void AddressBook::removeAddressee( const Addressee &a ) 590void AddressBook::removeAddressee( const Addressee &a )
592{ 591{
593 Iterator it; 592 Iterator it;
594 Iterator it2; 593 Iterator it2;
595 bool found = false; 594 bool found = false;
596 for ( it = begin(); it != end(); ++it ) { 595 for ( it = begin(); it != end(); ++it ) {
597 if ( a.uid() == (*it).uid() ) { 596 if ( a.uid() == (*it).uid() ) {
598 found = true; 597 found = true;
599 it2 = it; 598 it2 = it;
600 } else { 599 } else {
601 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) { 600 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) {
602 QString name = (*it).uid().mid( 19 ); 601 QString name = (*it).uid().mid( 19 );
603 Addressee b = a; 602 Addressee b = a;
604 QString id = b.getID( name ); 603 QString id = b.getID( name );
605 if ( ! id.isEmpty() ) { 604 if ( ! id.isEmpty() ) {
606 QString des = (*it).note(); 605 QString des = (*it).note();
607 if( des.find( id ) < 0 ) { 606 if( des.find( id ) < 0 ) {
608 des += id + ","; 607 des += id + ",";
609 (*it).setNote( des ); 608 (*it).setNote( des );
610 } 609 }
611 } 610 }
612 } 611 }
613 612
614 } 613 }
615 } 614 }
616 615
617 if ( found ) 616 if ( found )
618 removeAddressee( it2 ); 617 removeAddressee( it2 );
619 618
620} 619}
621 620
622void AddressBook::removeSyncAddressees( bool removeDeleted ) 621void AddressBook::removeSyncAddressees( bool removeDeleted )
623{ 622{
624 Iterator it = begin(); 623 Iterator it = begin();
625 Iterator it2 ; 624 Iterator it2 ;
626 QDateTime dt ( QDate( 2004,1,1) ); 625 QDateTime dt ( QDate( 2004,1,1) );
627 while ( it != end() ) { 626 while ( it != end() ) {
628 (*it).setRevision( dt ); 627 (*it).setRevision( dt );
629 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" ); 628 (*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
630 (*it).setIDStr(""); 629 (*it).setIDStr("");
631 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) { 630 if ( ( (*it).tempSyncStat() == SYNC_TEMPSTATE_DELETE && removeDeleted )|| (*it).uid().left( 19 ) == QString("last-syncAddressee-")) {
632 it2 = it; 631 it2 = it;
633 //qDebug("removing %s ",(*it).uid().latin1() ); 632 //qDebug("removing %s ",(*it).uid().latin1() );
634 ++it; 633 ++it;
635 removeAddressee( it2 ); 634 removeAddressee( it2 );
636 } else { 635 } else {
637 //qDebug("skipping %s ",(*it).uid().latin1() ); 636 //qDebug("skipping %s ",(*it).uid().latin1() );
638 ++it; 637 ++it;
639 } 638 }
640 } 639 }
641 deleteRemovedAddressees(); 640 deleteRemovedAddressees();
642} 641}
643 642
644void AddressBook::removeAddressee( const Iterator &it ) 643void AddressBook::removeAddressee( const Iterator &it )
645{ 644{
646 d->mRemovedAddressees.append( (*it) ); 645 d->mRemovedAddressees.append( (*it) );
647 d->mAddressees.remove( it.d->mIt ); 646 d->mAddressees.remove( it.d->mIt );
648} 647}
649 648
650AddressBook::Iterator AddressBook::find( const Addressee &a ) 649AddressBook::Iterator AddressBook::find( const Addressee &a )
651{ 650{
652 Iterator it; 651 Iterator it;
653 for ( it = begin(); it != end(); ++it ) { 652 for ( it = begin(); it != end(); ++it ) {
654 if ( a.uid() == (*it).uid() ) { 653 if ( a.uid() == (*it).uid() ) {
655 return it; 654 return it;
656 } 655 }
657 } 656 }
658 return end(); 657 return end();
659} 658}
660 659
661Addressee AddressBook::findByUid( const QString &uid ) 660Addressee AddressBook::findByUid( const QString &uid )
662{ 661{
663 Iterator it; 662 Iterator it;
664 for ( it = begin(); it != end(); ++it ) { 663 for ( it = begin(); it != end(); ++it ) {
665 if ( uid == (*it).uid() ) { 664 if ( uid == (*it).uid() ) {
666 return *it; 665 return *it;
667 } 666 }
668 } 667 }
669 return Addressee(); 668 return Addressee();
670} 669}
671void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) 670void AddressBook::preExternSync( AddressBook* aBook, const QString& csd )
672{ 671{
673 //qDebug("AddressBook::preExternSync "); 672 //qDebug("AddressBook::preExternSync ");
674 AddressBook::Iterator it; 673 AddressBook::Iterator it;
675 for ( it = begin(); it != end(); ++it ) { 674 for ( it = begin(); it != end(); ++it ) {
676 (*it).setID( csd, (*it).externalUID() ); 675 (*it).setID( csd, (*it).externalUID() );
677 (*it).computeCsum( csd ); 676 (*it).computeCsum( csd );
678 } 677 }
679 mergeAB( aBook ,csd ); 678 mergeAB( aBook ,csd );
680} 679}
681void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) 680void AddressBook::postExternSync( AddressBook* aBook , const QString& csd)
682{ 681{
683 //qDebug("AddressBook::postExternSync "); 682 //qDebug("AddressBook::postExternSync ");
684 AddressBook::Iterator it; 683 AddressBook::Iterator it;
685 for ( it = begin(); it != end(); ++it ) { 684 for ( it = begin(); it != end(); ++it ) {
686 // qDebug("check uid %s ", (*it).uid().latin1() ); 685 // qDebug("check uid %s ", (*it).uid().latin1() );
687 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || 686 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ||
688 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) { 687 (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_CSUM ) {
689 Addressee ad = aBook->findByUid( ( (*it).uid() )); 688 Addressee ad = aBook->findByUid( ( (*it).uid() ));
690 if ( ad.isEmpty() ) { 689 if ( ad.isEmpty() ) {
691 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1()); 690 qDebug("postExternSync:ERROR addressee is empty: %s ", (*it).uid().latin1());
692 } else { 691 } else {
693 (*it).computeCsum( csd ); 692 (*it).computeCsum( csd );
694 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) 693 if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID )
695 ad.setID( csd, (*it).externalUID() ); 694 ad.setID( csd, (*it).externalUID() );
696 ad.setCsum( csd, (*it).getCsum( csd ) ); 695 ad.setCsum( csd, (*it).getCsum( csd ) );
697 aBook->insertAddressee( ad ); 696 aBook->insertAddressee( ad );
698 } 697 }
699 } 698 }
700 } 699 }
701} 700}
702 701
703bool AddressBook::containsExternalUid( const QString& uid ) 702bool AddressBook::containsExternalUid( const QString& uid )
704{ 703{
705 Iterator it; 704 Iterator it;
706 for ( it = begin(); it != end(); ++it ) { 705 for ( it = begin(); it != end(); ++it ) {
707 if ( uid == (*it).externalUID( ) ) 706 if ( uid == (*it).externalUID( ) )
708 return true; 707 return true;
709 } 708 }
710 return false; 709 return false;
711} 710}
712Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile ) 711Addressee AddressBook::findByExternUid( const QString& uid , const QString& profile )
713{ 712{
714 Iterator it; 713 Iterator it;
715 for ( it = begin(); it != end(); ++it ) { 714 for ( it = begin(); it != end(); ++it ) {
716 if ( uid == (*it).getID( profile ) ) 715 if ( uid == (*it).getID( profile ) )
717 return (*it); 716 return (*it);
718 } 717 }
719 return Addressee(); 718 return Addressee();
720} 719}
721void AddressBook::mergeAB( AddressBook *aBook, const QString& profile ) 720void AddressBook::mergeAB( AddressBook *aBook, const QString& profile )
722{ 721{
723 Iterator it; 722 Iterator it;
724 Addressee ad; 723 Addressee ad;
725 for ( it = begin(); it != end(); ++it ) { 724 for ( it = begin(); it != end(); ++it ) {
726 ad = aBook->findByExternUid( (*it).externalUID(), profile ); 725 ad = aBook->findByExternUid( (*it).externalUID(), profile );
727 if ( !ad.isEmpty() ) { 726 if ( !ad.isEmpty() ) {
728 (*it).mergeContact( ad ); 727 (*it).mergeContact( ad );
729 } 728 }
730 } 729 }
731#if 0 730#if 0
732 // test only 731 // test only
733 for ( it = begin(); it != end(); ++it ) { 732 for ( it = begin(); it != end(); ++it ) {
734 733
735 qDebug("uid %s ", (*it).uid().latin1()); 734 qDebug("uid %s ", (*it).uid().latin1());
736 } 735 }
737#endif 736#endif
738} 737}
739 738
740#if 0 739#if 0
741Addressee::List AddressBook::getExternLastSyncAddressees() 740Addressee::List AddressBook::getExternLastSyncAddressees()
742{ 741{
743 Addressee::List results; 742 Addressee::List results;
744 743
745 Iterator it; 744 Iterator it;
746 for ( it = begin(); it != end(); ++it ) { 745 for ( it = begin(); it != end(); ++it ) {
747 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) { 746 if ( (*it).uid().left( 19 ) == "last-syncAddressee-" ) {
748 if ( (*it).familyName().left(4) == "!E: " ) 747 if ( (*it).familyName().left(4) == "!E: " )
749 results.append( *it ); 748 results.append( *it );
750 } 749 }
751 } 750 }
752 751
753 return results; 752 return results;
754} 753}
755#endif 754#endif
756void AddressBook::resetTempSyncStat() 755void AddressBook::resetTempSyncStat()
757{ 756{
758 Iterator it; 757 Iterator it;
759 for ( it = begin(); it != end(); ++it ) { 758 for ( it = begin(); it != end(); ++it ) {
760 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL ); 759 (*it).setTempSyncStat ( SYNC_TEMPSTATE_INITIAL );
761 } 760 }
762 761
763} 762}
764 763
765QStringList AddressBook:: uidList() 764QStringList AddressBook:: uidList()
766{ 765{
767 QStringList results; 766 QStringList results;
768 Iterator it; 767 Iterator it;
769 for ( it = begin(); it != end(); ++it ) { 768 for ( it = begin(); it != end(); ++it ) {
770 results.append( (*it).uid() ); 769 results.append( (*it).uid() );
771 } 770 }
772 return results; 771 return results;
773} 772}
774 773
775 774
776Addressee::List AddressBook::allAddressees() 775Addressee::List AddressBook::allAddressees()
777{ 776{
778 return d->mAddressees; 777 return d->mAddressees;
779 778
780} 779}
781 780
782Addressee::List AddressBook::findByName( const QString &name ) 781Addressee::List AddressBook::findByName( const QString &name )
783{ 782{
784 Addressee::List results; 783 Addressee::List results;
785 784
786 Iterator it; 785 Iterator it;
787 for ( it = begin(); it != end(); ++it ) { 786 for ( it = begin(); it != end(); ++it ) {
788 if ( name == (*it).realName() ) { 787 if ( name == (*it).realName() ) {
789 results.append( *it ); 788 results.append( *it );
790 } 789 }
791 } 790 }
792 791
793 return results; 792 return results;
794} 793}
795 794
796Addressee::List AddressBook::findByEmail( const QString &email ) 795Addressee::List AddressBook::findByEmail( const QString &email )
797{ 796{
798 Addressee::List results; 797 Addressee::List results;
799 QStringList mailList; 798 QStringList mailList;
800 799
801 Iterator it; 800 Iterator it;
802 for ( it = begin(); it != end(); ++it ) { 801 for ( it = begin(); it != end(); ++it ) {
803 mailList = (*it).emails(); 802 mailList = (*it).emails();
804 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 803 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
805 if ( email == (*ite) ) { 804 if ( email == (*ite) ) {
806 results.append( *it ); 805 results.append( *it );
807 } 806 }
808 } 807 }
809 } 808 }
810 809
811 return results; 810 return results;
812} 811}
813 812
814Addressee::List AddressBook::findByCategory( const QString &category ) 813Addressee::List AddressBook::findByCategory( const QString &category )
815{ 814{
816 Addressee::List results; 815 Addressee::List results;
817 816
818 Iterator it; 817 Iterator it;
819 for ( it = begin(); it != end(); ++it ) { 818 for ( it = begin(); it != end(); ++it ) {
820 if ( (*it).hasCategory( category) ) { 819 if ( (*it).hasCategory( category) ) {
821 results.append( *it ); 820 results.append( *it );
822 } 821 }
823 } 822 }
824 823
825 return results; 824 return results;
826} 825}
827 826
828void AddressBook::dump() const 827void AddressBook::dump() const
829{ 828{
830 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 829 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
831 830
832 ConstIterator it; 831 ConstIterator it;
833 for( it = begin(); it != end(); ++it ) { 832 for( it = begin(); it != end(); ++it ) {
834 (*it).dump(); 833 (*it).dump();
835 } 834 }
836 835
837 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 836 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
838} 837}
839 838
840QString AddressBook::identifier() 839QString AddressBook::identifier()
841{ 840{
842 QStringList identifier; 841 QStringList identifier;
843 842
844 843
845 KRES::Manager<Resource>::ActiveIterator it; 844 KRES::Manager<Resource>::ActiveIterator it;
846 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 845 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
847 if ( !(*it)->identifier().isEmpty() ) 846 if ( !(*it)->identifier().isEmpty() )
848 identifier.append( (*it)->identifier() ); 847 identifier.append( (*it)->identifier() );
849 } 848 }
850 849
851 return identifier.join( ":" ); 850 return identifier.join( ":" );
852} 851}
853 852
854Field::List AddressBook::fields( int category ) 853Field::List AddressBook::fields( int category )
855{ 854{
856 if ( d->mAllFields.isEmpty() ) { 855 if ( d->mAllFields.isEmpty() ) {
857 d->mAllFields = Field::allFields(); 856 d->mAllFields = Field::allFields();
858 } 857 }
859 858
860 if ( category == Field::All ) return d->mAllFields; 859 if ( category == Field::All ) return d->mAllFields;
861 860
862 Field::List result; 861 Field::List result;
863 Field::List::ConstIterator it; 862 Field::List::ConstIterator it;
864 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 863 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
865 if ( (*it)->category() & category ) result.append( *it ); 864 if ( (*it)->category() & category ) result.append( *it );
866 } 865 }
867 866
868 return result; 867 return result;
869} 868}
870 869
871bool AddressBook::addCustomField( const QString &label, int category, 870bool AddressBook::addCustomField( const QString &label, int category,
872 const QString &key, const QString &app ) 871 const QString &key, const QString &app )
873{ 872{
874 if ( d->mAllFields.isEmpty() ) { 873 if ( d->mAllFields.isEmpty() ) {
875 d->mAllFields = Field::allFields(); 874 d->mAllFields = Field::allFields();
876 } 875 }
877//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 876//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
878 QString a = app.isNull() ? KGlobal::getAppName() : app; 877 QString a = app.isNull() ? KGlobal::getAppName() : app;
879 878
880 QString k = key.isNull() ? label : key; 879 QString k = key.isNull() ? label : key;
881 880
882 Field *field = Field::createCustomField( label, category, k, a ); 881 Field *field = Field::createCustomField( label, category, k, a );
883 882
884 if ( !field ) return false; 883 if ( !field ) return false;
885 884
886 d->mAllFields.append( field ); 885 d->mAllFields.append( field );
887 886
888 return true; 887 return true;
889} 888}
890 889
891QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 890QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
892{ 891{
893 if (!ab.d) return s; 892 if (!ab.d) return s;
894 893
895 return s << ab.d->mAddressees; 894 return s << ab.d->mAddressees;
896} 895}
897 896
898QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 897QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
899{ 898{
900 if (!ab.d) return s; 899 if (!ab.d) return s;
901 900
902 s >> ab.d->mAddressees; 901 s >> ab.d->mAddressees;
903 902
904 return s; 903 return s;
905} 904}
906 905
907bool AddressBook::addResource( Resource *resource ) 906bool AddressBook::addResource( Resource *resource )
908{ 907{
909 if ( !resource->open() ) { 908 if ( !resource->open() ) {
910 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 909 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
911 return false; 910 return false;
912 } 911 }
913 912
914 resource->setAddressBook( this ); 913 resource->setAddressBook( this );
915 914
916 d->mManager->add( resource ); 915 d->mManager->add( resource );
917 return true; 916 return true;
918} 917}
919 918
920bool AddressBook::removeResource( Resource *resource ) 919bool AddressBook::removeResource( Resource *resource )
921{ 920{
922 resource->close(); 921 resource->close();
923 922
924 if ( resource == standardResource() ) 923 if ( resource == standardResource() )
925 d->mManager->setStandardResource( 0 ); 924 d->mManager->setStandardResource( 0 );
926 925
927 resource->setAddressBook( 0 ); 926 resource->setAddressBook( 0 );
928 927
929 d->mManager->remove( resource ); 928 d->mManager->remove( resource );
930 return true; 929 return true;
931} 930}
932 931
933QPtrList<Resource> AddressBook::resources() 932QPtrList<Resource> AddressBook::resources()
934{ 933{
935 QPtrList<Resource> list; 934 QPtrList<Resource> list;
936 935
937// qDebug("AddressBook::resources() 1"); 936// qDebug("AddressBook::resources() 1");
938 937
939 KRES::Manager<Resource>::ActiveIterator it; 938 KRES::Manager<Resource>::ActiveIterator it;
940 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 939 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
941 list.append( *it ); 940 list.append( *it );
942 941
943 return list; 942 return list;
944} 943}
945 944
946/*US 945/*US
947void AddressBook::setErrorHandler( ErrorHandler *handler ) 946void AddressBook::setErrorHandler( ErrorHandler *handler )
948{ 947{
949 delete d->mErrorHandler; 948 delete d->mErrorHandler;
950 d->mErrorHandler = handler; 949 d->mErrorHandler = handler;
951} 950}
952*/ 951*/
953 952
954void AddressBook::error( const QString& msg ) 953void AddressBook::error( const QString& msg )
955{ 954{
956/*US 955/*US
957 if ( !d->mErrorHandler ) // create default error handler 956 if ( !d->mErrorHandler ) // create default error handler
958 d->mErrorHandler = new ConsoleErrorHandler; 957 d->mErrorHandler = new ConsoleErrorHandler;
959 958
960 if ( d->mErrorHandler ) 959 if ( d->mErrorHandler )
961 d->mErrorHandler->error( msg ); 960 d->mErrorHandler->error( msg );
962 else 961 else
963 kdError(5700) << "no error handler defined" << endl; 962 kdError(5700) << "no error handler defined" << endl;
964*/ 963*/
965 kdDebug(5700) << "msg" << endl; 964 kdDebug(5700) << "msg" << endl;
966 qDebug(msg); 965 qDebug(msg);
967} 966}
968 967
969void AddressBook::deleteRemovedAddressees() 968void AddressBook::deleteRemovedAddressees()
970{ 969{
971 Addressee::List::Iterator it; 970 Addressee::List::Iterator it;
972 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 971 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
973 Resource *resource = (*it).resource(); 972 Resource *resource = (*it).resource();
974 if ( resource && !resource->readOnly() && resource->isOpen() ) 973 if ( resource && !resource->readOnly() && resource->isOpen() )
975 resource->removeAddressee( *it ); 974 resource->removeAddressee( *it );
976 } 975 }
977 976
978 d->mRemovedAddressees.clear(); 977 d->mRemovedAddressees.clear();
979} 978}
980 979
981void AddressBook::setStandardResource( Resource *resource ) 980void AddressBook::setStandardResource( Resource *resource )
982{ 981{
983// qDebug("AddressBook::setStandardResource 1"); 982// qDebug("AddressBook::setStandardResource 1");
984 d->mManager->setStandardResource( resource ); 983 d->mManager->setStandardResource( resource );
985} 984}
986 985
987Resource *AddressBook::standardResource() 986Resource *AddressBook::standardResource()
988{ 987{
989 return d->mManager->standardResource(); 988 return d->mManager->standardResource();
990} 989}
991 990
992KRES::Manager<Resource> *AddressBook::resourceManager() 991KRES::Manager<Resource> *AddressBook::resourceManager()
993{ 992{
994 return d->mManager; 993 return d->mManager;
995} 994}
996 995
997void AddressBook::cleanUp() 996void AddressBook::cleanUp()
998{ 997{
999 KRES::Manager<Resource>::ActiveIterator it; 998 KRES::Manager<Resource>::ActiveIterator it;
1000 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 999 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1001 if ( !(*it)->readOnly() && (*it)->isOpen() ) 1000 if ( !(*it)->readOnly() && (*it)->isOpen() )
1002 (*it)->cleanUp(); 1001 (*it)->cleanUp();
1003 } 1002 }
1004} 1003}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 3a542ba..efcd492 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1867 +1,1868 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
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#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 mWriteToSim= new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 lay->addWidget( mWriteToSim ); 189 lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207bool pasteWithNewUid = true; 207bool pasteWithNewUid = true;
208 208
209#ifdef KAB_EMBEDDED 209#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 214#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 218 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220{ 220{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 222 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 223 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 224 mIsPart = !parent->inherits( "KAddressBookMain" );
225 225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 295 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 297
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310 mEditorDialog = 0; 310 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 311 createAddresseeEditorDialog( this );
312 setModified( false ); 312 setModified( false );
313} 313}
314 314
315KABCore::~KABCore() 315KABCore::~KABCore()
316{ 316{
317 // save(); 317 // save();
318 //saveSettings(); 318 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 319 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 320 delete AddresseeConfig::instance();
321 mAddressBook = 0; 321 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 322 KABC::StdAddressBook::close();
323 323
324 delete syncManager; 324 delete syncManager;
325 325
326} 326}
327 327
328void KABCore::recieve( QString fn ) 328void KABCore::recieve( QString fn )
329{ 329{
330 qDebug("KABCore::recieve "); 330 //qDebug("KABCore::recieve ");
331 mAddressBook->importFromFile( fn, true ); 331 mAddressBook->importFromFile( fn, true );
332 mViewManager->refreshView();
332 topLevelWidget()->raise(); 333 topLevelWidget()->raise();
333} 334}
334void KABCore::restoreSettings() 335void KABCore::restoreSettings()
335{ 336{
336 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 337 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
337 338
338 bool state; 339 bool state;
339 340
340 if (mMultipleViewsAtOnce) 341 if (mMultipleViewsAtOnce)
341 state = KABPrefs::instance()->mDetailsPageVisible; 342 state = KABPrefs::instance()->mDetailsPageVisible;
342 else 343 else
343 state = false; 344 state = false;
344 345
345 mActionDetails->setChecked( state ); 346 mActionDetails->setChecked( state );
346 setDetailsVisible( state ); 347 setDetailsVisible( state );
347 348
348 state = KABPrefs::instance()->mJumpButtonBarVisible; 349 state = KABPrefs::instance()->mJumpButtonBarVisible;
349 350
350 mActionJumpBar->setChecked( state ); 351 mActionJumpBar->setChecked( state );
351 setJumpButtonBarVisible( state ); 352 setJumpButtonBarVisible( state );
352/*US 353/*US
353 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 354 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
354 if ( splitterSize.count() == 0 ) { 355 if ( splitterSize.count() == 0 ) {
355 splitterSize.append( width() / 2 ); 356 splitterSize.append( width() / 2 );
356 splitterSize.append( width() / 2 ); 357 splitterSize.append( width() / 2 );
357 } 358 }
358 mMiniSplitter->setSizes( splitterSize ); 359 mMiniSplitter->setSizes( splitterSize );
359 if ( mExtensionBarSplitter ) { 360 if ( mExtensionBarSplitter ) {
360 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 361 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
361 if ( splitterSize.count() == 0 ) { 362 if ( splitterSize.count() == 0 ) {
362 splitterSize.append( width() / 2 ); 363 splitterSize.append( width() / 2 );
363 splitterSize.append( width() / 2 ); 364 splitterSize.append( width() / 2 );
364 } 365 }
365 mExtensionBarSplitter->setSizes( splitterSize ); 366 mExtensionBarSplitter->setSizes( splitterSize );
366 367
367 } 368 }
368*/ 369*/
369 mViewManager->restoreSettings(); 370 mViewManager->restoreSettings();
370 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 371 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
371 mExtensionManager->restoreSettings(); 372 mExtensionManager->restoreSettings();
372#ifdef DESKTOP_VERSION 373#ifdef DESKTOP_VERSION
373 int wid = width(); 374 int wid = width();
374 if ( wid < 10 ) 375 if ( wid < 10 )
375 wid = 400; 376 wid = 400;
376#else 377#else
377 int wid = QApplication::desktop()->width(); 378 int wid = QApplication::desktop()->width();
378 if ( wid < 640 ) 379 if ( wid < 640 )
379 wid = QApplication::desktop()->height(); 380 wid = QApplication::desktop()->height();
380#endif 381#endif
381 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 382 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
382 if ( true /*splitterSize.count() == 0*/ ) { 383 if ( true /*splitterSize.count() == 0*/ ) {
383 splitterSize.append( wid / 2 ); 384 splitterSize.append( wid / 2 );
384 splitterSize.append( wid / 2 ); 385 splitterSize.append( wid / 2 );
385 } 386 }
386 mMiniSplitter->setSizes( splitterSize ); 387 mMiniSplitter->setSizes( splitterSize );
387 if ( mExtensionBarSplitter ) { 388 if ( mExtensionBarSplitter ) {
388 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 389 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
389 if ( true /*splitterSize.count() == 0*/ ) { 390 if ( true /*splitterSize.count() == 0*/ ) {
390 splitterSize.append( wid / 2 ); 391 splitterSize.append( wid / 2 );
391 splitterSize.append( wid / 2 ); 392 splitterSize.append( wid / 2 );
392 } 393 }
393 mExtensionBarSplitter->setSizes( splitterSize ); 394 mExtensionBarSplitter->setSizes( splitterSize );
394 395
395 } 396 }
396 397
397 398
398} 399}
399 400
400void KABCore::saveSettings() 401void KABCore::saveSettings()
401{ 402{
402 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 403 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
403 if ( mExtensionBarSplitter ) 404 if ( mExtensionBarSplitter )
404 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 405 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
405 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 406 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
406 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 407 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
407#ifndef KAB_EMBEDDED 408#ifndef KAB_EMBEDDED
408 409
409 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 410 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
410 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 411 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
411#endif //KAB_EMBEDDED 412#endif //KAB_EMBEDDED
412 mExtensionManager->saveSettings(); 413 mExtensionManager->saveSettings();
413 mViewManager->saveSettings(); 414 mViewManager->saveSettings();
414 415
415 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 416 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
416} 417}
417 418
418KABC::AddressBook *KABCore::addressBook() const 419KABC::AddressBook *KABCore::addressBook() const
419{ 420{
420 return mAddressBook; 421 return mAddressBook;
421} 422}
422 423
423KConfig *KABCore::config() 424KConfig *KABCore::config()
424{ 425{
425#ifndef KAB_EMBEDDED 426#ifndef KAB_EMBEDDED
426 return KABPrefs::instance()->config(); 427 return KABPrefs::instance()->config();
427#else //KAB_EMBEDDED 428#else //KAB_EMBEDDED
428 return KABPrefs::instance()->getConfig(); 429 return KABPrefs::instance()->getConfig();
429#endif //KAB_EMBEDDED 430#endif //KAB_EMBEDDED
430} 431}
431 432
432KActionCollection *KABCore::actionCollection() const 433KActionCollection *KABCore::actionCollection() const
433{ 434{
434 return mGUIClient->actionCollection(); 435 return mGUIClient->actionCollection();
435} 436}
436 437
437KABC::Field *KABCore::currentSearchField() const 438KABC::Field *KABCore::currentSearchField() const
438{ 439{
439 if (mIncSearchWidget) 440 if (mIncSearchWidget)
440 return mIncSearchWidget->currentField(); 441 return mIncSearchWidget->currentField();
441 else 442 else
442 return 0; 443 return 0;
443} 444}
444 445
445QStringList KABCore::selectedUIDs() const 446QStringList KABCore::selectedUIDs() const
446{ 447{
447 return mViewManager->selectedUids(); 448 return mViewManager->selectedUids();
448} 449}
449 450
450KABC::Resource *KABCore::requestResource( QWidget *parent ) 451KABC::Resource *KABCore::requestResource( QWidget *parent )
451{ 452{
452 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 453 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
453 454
454 QPtrList<KRES::Resource> kresResources; 455 QPtrList<KRES::Resource> kresResources;
455 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 456 QPtrListIterator<KABC::Resource> resIt( kabcResources );
456 KABC::Resource *resource; 457 KABC::Resource *resource;
457 while ( ( resource = resIt.current() ) != 0 ) { 458 while ( ( resource = resIt.current() ) != 0 ) {
458 ++resIt; 459 ++resIt;
459 if ( !resource->readOnly() ) { 460 if ( !resource->readOnly() ) {
460 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 461 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
461 if ( res ) 462 if ( res )
462 kresResources.append( res ); 463 kresResources.append( res );
463 } 464 }
464 } 465 }
465 466
466 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 467 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
467 return static_cast<KABC::Resource*>( res ); 468 return static_cast<KABC::Resource*>( res );
468} 469}
469 470
470#ifndef KAB_EMBEDDED 471#ifndef KAB_EMBEDDED
471KAboutData *KABCore::createAboutData() 472KAboutData *KABCore::createAboutData()
472#else //KAB_EMBEDDED 473#else //KAB_EMBEDDED
473void KABCore::createAboutData() 474void KABCore::createAboutData()
474#endif //KAB_EMBEDDED 475#endif //KAB_EMBEDDED
475{ 476{
476#ifndef KAB_EMBEDDED 477#ifndef KAB_EMBEDDED
477 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 478 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
478 "3.1", I18N_NOOP( "The KDE Address Book" ), 479 "3.1", I18N_NOOP( "The KDE Address Book" ),
479 KAboutData::License_GPL_V2, 480 KAboutData::License_GPL_V2,
480 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 481 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
481 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 482 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
482 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 483 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
483 about->addAuthor( "Cornelius Schumacher", 484 about->addAuthor( "Cornelius Schumacher",
484 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 485 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
485 "schumacher@kde.org" ); 486 "schumacher@kde.org" );
486 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 487 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
487 "mpilone@slac.com" ); 488 "mpilone@slac.com" );
488 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 489 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
489 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 490 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
490 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 491 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
491 "michel@klaralvdalens-datakonsult.se" ); 492 "michel@klaralvdalens-datakonsult.se" );
492 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 493 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
493 "hansen@kde.org" ); 494 "hansen@kde.org" );
494 495
495 return about; 496 return about;
496#endif //KAB_EMBEDDED 497#endif //KAB_EMBEDDED
497 498
498 QString version; 499 QString version;
499#include <../version> 500#include <../version>
500 QMessageBox::about( this, "About KAddressbook/Pi", 501 QMessageBox::about( this, "About KAddressbook/Pi",
501 "KAddressbook/Platform-independent\n" 502 "KAddressbook/Platform-independent\n"
502 "(KA/Pi) " +version + " - " + 503 "(KA/Pi) " +version + " - " +
503#ifdef DESKTOP_VERSION 504#ifdef DESKTOP_VERSION
504 "Desktop Edition\n" 505 "Desktop Edition\n"
505#else 506#else
506 "PDA-Edition\n" 507 "PDA-Edition\n"
507 "for: Zaurus 5500 / 7x0 / 8x0\n" 508 "for: Zaurus 5500 / 7x0 / 8x0\n"
508#endif 509#endif
509 510
510 "(c) 2004 Ulf Schenk\n" 511 "(c) 2004 Ulf Schenk\n"
511 "(c) 2004 Lutz Rogowski\n" 512 "(c) 2004 Lutz Rogowski\n"
512 "(c) 1997-2003, The KDE PIM Team\n" 513 "(c) 1997-2003, The KDE PIM Team\n"
513 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 514 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
514 "Don Sanders Original author\n" 515 "Don Sanders Original author\n"
515 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 516 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
516 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 517 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
517 "Greg Stern DCOP interface\n" 518 "Greg Stern DCOP interface\n"
518 "Mark Westcot Contact pinning\n" 519 "Mark Westcot Contact pinning\n"
519 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 520 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
520 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 521 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
521#ifdef _WIN32_ 522#ifdef _WIN32_
522 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 523 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
523#endif 524#endif
524 ); 525 );
525} 526}
526 527
527void KABCore::setContactSelected( const QString &uid ) 528void KABCore::setContactSelected( const QString &uid )
528{ 529{
529 KABC::Addressee addr = mAddressBook->findByUid( uid ); 530 KABC::Addressee addr = mAddressBook->findByUid( uid );
530 if ( !mDetails->isHidden() ) 531 if ( !mDetails->isHidden() )
531 mDetails->setAddressee( addr ); 532 mDetails->setAddressee( addr );
532 533
533 if ( !addr.isEmpty() ) { 534 if ( !addr.isEmpty() ) {
534 emit contactSelected( addr.formattedName() ); 535 emit contactSelected( addr.formattedName() );
535 KABC::Picture pic = addr.photo(); 536 KABC::Picture pic = addr.photo();
536 if ( pic.isIntern() ) { 537 if ( pic.isIntern() ) {
537//US emit contactSelected( pic.data() ); 538//US emit contactSelected( pic.data() );
538//US instead use: 539//US instead use:
539 QPixmap px; 540 QPixmap px;
540 if (pic.data().isNull() != true) 541 if (pic.data().isNull() != true)
541 { 542 {
542 px.convertFromImage(pic.data()); 543 px.convertFromImage(pic.data());
543 } 544 }
544 545
545 emit contactSelected( px ); 546 emit contactSelected( px );
546 } 547 }
547 } 548 }
548 549
549 550
550 mExtensionManager->setSelectionChanged(); 551 mExtensionManager->setSelectionChanged();
551 552
552 // update the actions 553 // update the actions
553 bool selected = !uid.isEmpty(); 554 bool selected = !uid.isEmpty();
554 555
555 if ( mReadWrite ) { 556 if ( mReadWrite ) {
556 mActionCut->setEnabled( selected ); 557 mActionCut->setEnabled( selected );
557 mActionPaste->setEnabled( selected ); 558 mActionPaste->setEnabled( selected );
558 } 559 }
559 560
560 mActionCopy->setEnabled( selected ); 561 mActionCopy->setEnabled( selected );
561 mActionDelete->setEnabled( selected ); 562 mActionDelete->setEnabled( selected );
562 mActionEditAddressee->setEnabled( selected ); 563 mActionEditAddressee->setEnabled( selected );
563 mActionMail->setEnabled( selected ); 564 mActionMail->setEnabled( selected );
564 mActionMailVCard->setEnabled( selected ); 565 mActionMailVCard->setEnabled( selected );
565 //if (mActionBeam) 566 //if (mActionBeam)
566 //mActionBeam->setEnabled( selected ); 567 //mActionBeam->setEnabled( selected );
567 568
568 if (mActionBeamVCard) 569 if (mActionBeamVCard)
569 mActionBeamVCard->setEnabled( selected ); 570 mActionBeamVCard->setEnabled( selected );
570 571
571 mActionExport2phone->setEnabled( selected ); 572 mActionExport2phone->setEnabled( selected );
572 mActionWhoAmI->setEnabled( selected ); 573 mActionWhoAmI->setEnabled( selected );
573 mActionCategories->setEnabled( selected ); 574 mActionCategories->setEnabled( selected );
574} 575}
575 576
576void KABCore::sendMail() 577void KABCore::sendMail()
577{ 578{
578 sendMail( mViewManager->selectedEmails().join( ", " ) ); 579 sendMail( mViewManager->selectedEmails().join( ", " ) );
579} 580}
580 581
581void KABCore::sendMail( const QString& emaillist ) 582void KABCore::sendMail( const QString& emaillist )
582{ 583{
583 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 584 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
584 if (emaillist.contains(",") > 0) 585 if (emaillist.contains(",") > 0)
585 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 586 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
586 else 587 else
587 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 588 ExternalAppHandler::instance()->mailToOneContact( emaillist );
588} 589}
589 590
590 591
591 592
592void KABCore::mailVCard() 593void KABCore::mailVCard()
593{ 594{
594 QStringList uids = mViewManager->selectedUids(); 595 QStringList uids = mViewManager->selectedUids();
595 if ( !uids.isEmpty() ) 596 if ( !uids.isEmpty() )
596 mailVCard( uids ); 597 mailVCard( uids );
597} 598}
598 599
599void KABCore::mailVCard( const QStringList& uids ) 600void KABCore::mailVCard( const QStringList& uids )
600{ 601{
601 QStringList urls; 602 QStringList urls;
602 603
603// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 604// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
604 605
605 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 606 QString dirName = "/tmp/" + KApplication::randomString( 8 );
606 607
607 608
608 609
609 QDir().mkdir( dirName, true ); 610 QDir().mkdir( dirName, true );
610 611
611 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 612 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
612 KABC::Addressee a = mAddressBook->findByUid( *it ); 613 KABC::Addressee a = mAddressBook->findByUid( *it );
613 614
614 if ( a.isEmpty() ) 615 if ( a.isEmpty() )
615 continue; 616 continue;
616 617
617 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 618 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
618 619
619 QString fileName = dirName + "/" + name; 620 QString fileName = dirName + "/" + name;
620 621
621 QFile outFile(fileName); 622 QFile outFile(fileName);
622 623
623 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 624 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
624 KABC::VCardConverter converter; 625 KABC::VCardConverter converter;
625 QString vcard; 626 QString vcard;
626 627
627 converter.addresseeToVCard( a, vcard ); 628 converter.addresseeToVCard( a, vcard );
628 629
629 QTextStream t( &outFile ); // use a text stream 630 QTextStream t( &outFile ); // use a text stream
630 t.setEncoding( QTextStream::UnicodeUTF8 ); 631 t.setEncoding( QTextStream::UnicodeUTF8 );
631 t << vcard; 632 t << vcard;
632 633
633 outFile.close(); 634 outFile.close();
634 635
635 urls.append( fileName ); 636 urls.append( fileName );
636 } 637 }
637 } 638 }
638 639
639 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 640 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
640 641
641 642
642/*US 643/*US
643 kapp->invokeMailer( QString::null, QString::null, QString::null, 644 kapp->invokeMailer( QString::null, QString::null, QString::null,
644 QString::null, // subject 645 QString::null, // subject
645 QString::null, // body 646 QString::null, // body
646 QString::null, 647 QString::null,
647 urls ); // attachments 648 urls ); // attachments
648*/ 649*/
649 650
650} 651}
651 652
652/** 653/**
653 Beams the "WhoAmI contact. 654 Beams the "WhoAmI contact.
654*/ 655*/
655void KABCore::beamMySelf() 656void KABCore::beamMySelf()
656{ 657{
657 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 658 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
658 if (!a.isEmpty()) 659 if (!a.isEmpty())
659 { 660 {
660 QStringList uids; 661 QStringList uids;
661 uids << a.uid(); 662 uids << a.uid();
662 663
663 beamVCard(uids); 664 beamVCard(uids);
664 } else { 665 } else {
665 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 666 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
666 667
667 668
668 } 669 }
669} 670}
670 671
671void KABCore::export2phone() 672void KABCore::export2phone()
672{ 673{
673 674
674 KAex2phonePrefs ex2phone; 675 KAex2phonePrefs ex2phone;
675 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 676 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
676 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 677 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
677 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 678 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
678 679
679 if ( !ex2phone.exec() ) { 680 if ( !ex2phone.exec() ) {
680 return; 681 return;
681 } 682 }
682 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 683 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
683 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 684 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
684 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 685 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
685 686
686 687
687 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
688 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 689 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
689 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 690 KPimGlobalPrefs::instance()->mEx2PhoneModel );
690 691
691 QStringList uids = mViewManager->selectedUids(); 692 QStringList uids = mViewManager->selectedUids();
692 if ( uids.isEmpty() ) 693 if ( uids.isEmpty() )
693 return; 694 return;
694 695
695#ifdef _WIN32_ 696#ifdef _WIN32_
696 QString fileName = locateLocal("tmp", "tempfile.vcf"); 697 QString fileName = locateLocal("tmp", "tempfile.vcf");
697#else 698#else
698 QString fileName = "/tmp/kdepimtemp.vcf"; 699 QString fileName = "/tmp/kdepimtemp.vcf";
699#endif 700#endif
700 701
701 KABC::VCardConverter converter; 702 KABC::VCardConverter converter;
702 QString description; 703 QString description;
703 QString datastream; 704 QString datastream;
704 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 705 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
705 KABC::Addressee a = mAddressBook->findByUid( *it ); 706 KABC::Addressee a = mAddressBook->findByUid( *it );
706 707
707 if ( a.isEmpty() ) 708 if ( a.isEmpty() )
708 continue; 709 continue;
709 a.simplifyEmails(); 710 a.simplifyEmails();
710 a.simplifyPhoneNumbers(); 711 a.simplifyPhoneNumbers();
711 a.simplifyPhoneNumberTypes(); 712 a.simplifyPhoneNumberTypes();
712 a.simplifyAddresses(); 713 a.simplifyAddresses();
713 714
714 if (description.isEmpty()) 715 if (description.isEmpty())
715 description = a.formattedName(); 716 description = a.formattedName();
716 QString vcard; 717 QString vcard;
717 QString vcardnew; 718 QString vcardnew;
718 converter.addresseeToVCard( a, vcard ); 719 converter.addresseeToVCard( a, vcard );
719 int start = 0; 720 int start = 0;
720 int next; 721 int next;
721 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 722 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
722 int semi = vcard.find(";", next); 723 int semi = vcard.find(";", next);
723 int dopp = vcard.find(":", next); 724 int dopp = vcard.find(":", next);
724 int sep; 725 int sep;
725 if ( semi < dopp && semi >= 0 ) 726 if ( semi < dopp && semi >= 0 )
726 sep = semi ; 727 sep = semi ;
727 else 728 else
728 sep = dopp; 729 sep = dopp;
729 vcardnew +=vcard.mid( start, next - start); 730 vcardnew +=vcard.mid( start, next - start);
730 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); 731 vcardnew +=vcard.mid( next+5,sep -next -5 ).upper();
731 start = sep; 732 start = sep;
732 } 733 }
733 vcardnew += vcard.mid( start,vcard.length() ); 734 vcardnew += vcard.mid( start,vcard.length() );
734 vcard = ""; 735 vcard = "";
735 start = 0; 736 start = 0;
736 while ( (next = vcardnew.find("ADR", start) )>= 0 ) { 737 while ( (next = vcardnew.find("ADR", start) )>= 0 ) {
737 int sep = vcardnew.find(":", next); 738 int sep = vcardnew.find(":", next);
738 vcard +=vcardnew.mid( start, next - start+3); 739 vcard +=vcardnew.mid( start, next - start+3);
739 start = sep; 740 start = sep;
740 } 741 }
741 vcard += vcardnew.mid( start,vcardnew.length() ); 742 vcard += vcardnew.mid( start,vcardnew.length() );
742 vcard.replace ( QRegExp(";;;") , "" ); 743 vcard.replace ( QRegExp(";;;") , "" );
743 vcard.replace ( QRegExp(";;") , "" ); 744 vcard.replace ( QRegExp(";;") , "" );
744 datastream += vcard; 745 datastream += vcard;
745 746
746 } 747 }
747 QFile outFile(fileName); 748 QFile outFile(fileName);
748 if ( outFile.open(IO_WriteOnly) ) { 749 if ( outFile.open(IO_WriteOnly) ) {
749 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 750 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
750 QTextStream t( &outFile ); // use a text stream 751 QTextStream t( &outFile ); // use a text stream
751 t.setEncoding( QTextStream::UnicodeUTF8 ); 752 t.setEncoding( QTextStream::UnicodeUTF8 );
752 t <<datastream; 753 t <<datastream;
753 outFile.close(); 754 outFile.close();
754 if ( PhoneAccess::writeToPhone( fileName ) ) 755 if ( PhoneAccess::writeToPhone( fileName ) )
755 qDebug("Export okay "); 756 qDebug("Export okay ");
756 else 757 else
757 qDebug("Error export contacts "); 758 qDebug("Error export contacts ");
758 759
759 } else { 760 } else {
760 qDebug("Error open temp file "); 761 qDebug("Error open temp file ");
761 return; 762 return;
762 } 763 }
763 764
764 765
765#if 0 766#if 0
766 767
767 setCaption( i18n("Writing to phone...")); 768 setCaption( i18n("Writing to phone..."));
768 if ( PhoneFormat::writeToPhone( cal ) ) 769 if ( PhoneFormat::writeToPhone( cal ) )
769 setCaption( i18n("Export to phone successful!")); 770 setCaption( i18n("Export to phone successful!"));
770 else 771 else
771 setCaption( i18n("Error exporting to phone!")); 772 setCaption( i18n("Error exporting to phone!"));
772#endif 773#endif
773 774
774 775
775} 776}
776void KABCore::beamVCard() 777void KABCore::beamVCard()
777{ 778{
778 QStringList uids = mViewManager->selectedUids(); 779 QStringList uids = mViewManager->selectedUids();
779 if ( !uids.isEmpty() ) 780 if ( !uids.isEmpty() )
780 beamVCard( uids ); 781 beamVCard( uids );
781} 782}
782 783
783 784
784void KABCore::beamVCard(const QStringList& uids) 785void KABCore::beamVCard(const QStringList& uids)
785{ 786{
786/*US 787/*US
787 QString beamFilename; 788 QString beamFilename;
788 Opie::OPimContact c; 789 Opie::OPimContact c;
789 if ( actionPersonal->isOn() ) { 790 if ( actionPersonal->isOn() ) {
790 beamFilename = addressbookPersonalVCardName(); 791 beamFilename = addressbookPersonalVCardName();
791 if ( !QFile::exists( beamFilename ) ) 792 if ( !QFile::exists( beamFilename ) )
792 return; // can't beam a non-existent file 793 return; // can't beam a non-existent file
793 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 794 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
794 beamFilename ); 795 beamFilename );
795 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 796 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
796 Opie::OPimContactAccess::List allList = access->allRecords(); 797 Opie::OPimContactAccess::List allList = access->allRecords();
797 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 798 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
798 c = *it; 799 c = *it;
799 800
800 delete access; 801 delete access;
801 } else { 802 } else {
802 unlink( beamfile ); // delete if exists 803 unlink( beamfile ); // delete if exists
803 mkdir("/tmp/obex/", 0755); 804 mkdir("/tmp/obex/", 0755);
804 c = m_abView -> currentEntry(); 805 c = m_abView -> currentEntry();
805 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 806 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
806 beamfile ); 807 beamfile );
807 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 808 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
808 access->add( c ); 809 access->add( c );
809 access->save(); 810 access->save();
810 delete access; 811 delete access;
811 812
812 beamFilename = beamfile; 813 beamFilename = beamfile;
813 } 814 }
814 815
815 owarn << "Beaming: " << beamFilename << oendl; 816 owarn << "Beaming: " << beamFilename << oendl;
816*/ 817*/
817 818
818#if 0 819#if 0
819 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 820 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
820 821
821 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 822 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
822 823
823 QString name = "contact.vcf"; 824 QString name = "contact.vcf";
824 825
825 QString fileName = dirName + "/" + name; 826 QString fileName = dirName + "/" + name;
826#endif 827#endif
827 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 828 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
828 // 829 //
829 QString fileName = "/tmp/kapibeamfile.vcf"; 830 QString fileName = "/tmp/kapibeamfile.vcf";
830 831
831 832
832 //QDir().mkdir( dirName, true ); 833 //QDir().mkdir( dirName, true );
833 834
834 835
835 KABC::VCardConverter converter; 836 KABC::VCardConverter converter;
836 QString description; 837 QString description;
837 QString datastream; 838 QString datastream;
838 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 839 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
839 KABC::Addressee a = mAddressBook->findByUid( *it ); 840 KABC::Addressee a = mAddressBook->findByUid( *it );
840 841
841 if ( a.isEmpty() ) 842 if ( a.isEmpty() )
842 continue; 843 continue;
843 844
844 if (description.isEmpty()) 845 if (description.isEmpty())
845 description = a.formattedName(); 846 description = a.formattedName();
846 847
847 QString vcard; 848 QString vcard;
848 converter.addresseeToVCard( a, vcard ); 849 converter.addresseeToVCard( a, vcard );
849 int start = 0; 850 int start = 0;
850 int next; 851 int next;
851 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 852 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
852 int semi = vcard.find(";", next); 853 int semi = vcard.find(";", next);
853 int dopp = vcard.find(":", next); 854 int dopp = vcard.find(":", next);
854 int sep; 855 int sep;
855 if ( semi < dopp && semi >= 0 ) 856 if ( semi < dopp && semi >= 0 )
856 sep = semi ; 857 sep = semi ;
857 else 858 else
858 sep = dopp; 859 sep = dopp;
859 datastream +=vcard.mid( start, next - start); 860 datastream +=vcard.mid( start, next - start);
860 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 861 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
861 start = sep; 862 start = sep;
862 } 863 }
863 datastream += vcard.mid( start,vcard.length() ); 864 datastream += vcard.mid( start,vcard.length() );
864 } 865 }
865#ifndef DESKTOP_VERSION 866#ifndef DESKTOP_VERSION
866 QFile outFile(fileName); 867 QFile outFile(fileName);
867 if ( outFile.open(IO_WriteOnly) ) { 868 if ( outFile.open(IO_WriteOnly) ) {
868 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 869 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
869 QTextStream t( &outFile ); // use a text stream 870 QTextStream t( &outFile ); // use a text stream
870 t.setEncoding( QTextStream::UnicodeUTF8 ); 871 t.setEncoding( QTextStream::UnicodeUTF8 );
871 t <<datastream; 872 t <<datastream;
872 outFile.close(); 873 outFile.close();
873 Ir *ir = new Ir( this ); 874 Ir *ir = new Ir( this );
874 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 875 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
875 ir->send( fileName, description, "text/x-vCard" ); 876 ir->send( fileName, description, "text/x-vCard" );
876 } else { 877 } else {
877 qDebug("Error open temp beam file "); 878 qDebug("Error open temp beam file ");
878 return; 879 return;
879 } 880 }
880#endif 881#endif
881 882
882} 883}
883 884
884void KABCore::beamDone( Ir *ir ) 885void KABCore::beamDone( Ir *ir )
885{ 886{
886#ifndef DESKTOP_VERSION 887#ifndef DESKTOP_VERSION
887 delete ir; 888 delete ir;
888#endif 889#endif
889} 890}
890 891
891 892
892void KABCore::browse( const QString& url ) 893void KABCore::browse( const QString& url )
893{ 894{
894#ifndef KAB_EMBEDDED 895#ifndef KAB_EMBEDDED
895 kapp->invokeBrowser( url ); 896 kapp->invokeBrowser( url );
896#else //KAB_EMBEDDED 897#else //KAB_EMBEDDED
897 qDebug("KABCore::browse must be fixed"); 898 qDebug("KABCore::browse must be fixed");
898#endif //KAB_EMBEDDED 899#endif //KAB_EMBEDDED
899} 900}
900 901
901void KABCore::selectAllContacts() 902void KABCore::selectAllContacts()
902{ 903{
903 mViewManager->setSelected( QString::null, true ); 904 mViewManager->setSelected( QString::null, true );
904} 905}
905 906
906void KABCore::deleteContacts() 907void KABCore::deleteContacts()
907{ 908{
908 QStringList uidList = mViewManager->selectedUids(); 909 QStringList uidList = mViewManager->selectedUids();
909 deleteContacts( uidList ); 910 deleteContacts( uidList );
910} 911}
911 912
912void KABCore::deleteContacts( const QStringList &uids ) 913void KABCore::deleteContacts( const QStringList &uids )
913{ 914{
914 if ( uids.count() > 0 ) { 915 if ( uids.count() > 0 ) {
915 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 916 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
916 UndoStack::instance()->push( command ); 917 UndoStack::instance()->push( command );
917 RedoStack::instance()->clear(); 918 RedoStack::instance()->clear();
918 919
919 // now if we deleted anything, refresh 920 // now if we deleted anything, refresh
920 setContactSelected( QString::null ); 921 setContactSelected( QString::null );
921 setModified( true ); 922 setModified( true );
922 } 923 }
923} 924}
924 925
925void KABCore::copyContacts() 926void KABCore::copyContacts()
926{ 927{
927 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 928 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
928 929
929 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 930 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
930 931
931 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 932 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
932 933
933 QClipboard *cb = QApplication::clipboard(); 934 QClipboard *cb = QApplication::clipboard();
934 cb->setText( clipText ); 935 cb->setText( clipText );
935} 936}
936 937
937void KABCore::cutContacts() 938void KABCore::cutContacts()
938{ 939{
939 QStringList uidList = mViewManager->selectedUids(); 940 QStringList uidList = mViewManager->selectedUids();
940 941
941//US if ( uidList.size() > 0 ) { 942//US if ( uidList.size() > 0 ) {
942 if ( uidList.count() > 0 ) { 943 if ( uidList.count() > 0 ) {
943 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 944 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
944 UndoStack::instance()->push( command ); 945 UndoStack::instance()->push( command );
945 RedoStack::instance()->clear(); 946 RedoStack::instance()->clear();
946 947
947 setModified( true ); 948 setModified( true );
948 } 949 }
949} 950}
950 951
951void KABCore::pasteContacts() 952void KABCore::pasteContacts()
952{ 953{
953 QClipboard *cb = QApplication::clipboard(); 954 QClipboard *cb = QApplication::clipboard();
954 955
955 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 956 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
956 957
957 pasteContacts( list ); 958 pasteContacts( list );
958} 959}
959 960
960void KABCore::pasteContacts( KABC::Addressee::List &list ) 961void KABCore::pasteContacts( KABC::Addressee::List &list )
961{ 962{
962 KABC::Resource *resource = requestResource( this ); 963 KABC::Resource *resource = requestResource( this );
963 KABC::Addressee::List::Iterator it; 964 KABC::Addressee::List::Iterator it;
964 for ( it = list.begin(); it != list.end(); ++it ) 965 for ( it = list.begin(); it != list.end(); ++it )
965 (*it).setResource( resource ); 966 (*it).setResource( resource );
966 967
967 PwPasteCommand *command = new PwPasteCommand( this, list ); 968 PwPasteCommand *command = new PwPasteCommand( this, list );
968 UndoStack::instance()->push( command ); 969 UndoStack::instance()->push( command );
969 RedoStack::instance()->clear(); 970 RedoStack::instance()->clear();
970 971
971 setModified( true ); 972 setModified( true );
972} 973}
973 974
974void KABCore::setWhoAmI() 975void KABCore::setWhoAmI()
975{ 976{
976 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 977 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
977 978
978 if ( addrList.count() > 1 ) { 979 if ( addrList.count() > 1 ) {
979 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 980 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
980 return; 981 return;
981 } 982 }
982 983
983 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 984 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
984 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 985 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
985 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 986 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
986} 987}
987 988
988void KABCore::setCategories() 989void KABCore::setCategories()
989{ 990{
990 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 991 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
991 if ( !dlg.exec() ) 992 if ( !dlg.exec() )
992 return; 993 return;
993 994
994 bool merge = false; 995 bool merge = false;
995 QString msg = i18n( "Merge with existing categories?" ); 996 QString msg = i18n( "Merge with existing categories?" );
996 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 997 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
997 merge = true; 998 merge = true;
998 999
999 QStringList categories = dlg.selectedCategories(); 1000 QStringList categories = dlg.selectedCategories();
1000 1001
1001 QStringList uids = mViewManager->selectedUids(); 1002 QStringList uids = mViewManager->selectedUids();
1002 QStringList::Iterator it; 1003 QStringList::Iterator it;
1003 for ( it = uids.begin(); it != uids.end(); ++it ) { 1004 for ( it = uids.begin(); it != uids.end(); ++it ) {
1004 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1005 KABC::Addressee addr = mAddressBook->findByUid( *it );
1005 if ( !addr.isEmpty() ) { 1006 if ( !addr.isEmpty() ) {
1006 if ( !merge ) 1007 if ( !merge )
1007 addr.setCategories( categories ); 1008 addr.setCategories( categories );
1008 else { 1009 else {
1009 QStringList addrCategories = addr.categories(); 1010 QStringList addrCategories = addr.categories();
1010 QStringList::Iterator catIt; 1011 QStringList::Iterator catIt;
1011 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1012 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1012 if ( !addrCategories.contains( *catIt ) ) 1013 if ( !addrCategories.contains( *catIt ) )
1013 addrCategories.append( *catIt ); 1014 addrCategories.append( *catIt );
1014 } 1015 }
1015 addr.setCategories( addrCategories ); 1016 addr.setCategories( addrCategories );
1016 } 1017 }
1017 1018
1018 mAddressBook->insertAddressee( addr ); 1019 mAddressBook->insertAddressee( addr );
1019 } 1020 }
1020 } 1021 }
1021 1022
1022 if ( uids.count() > 0 ) 1023 if ( uids.count() > 0 )
1023 setModified( true ); 1024 setModified( true );
1024} 1025}
1025 1026
1026void KABCore::setSearchFields( const KABC::Field::List &fields ) 1027void KABCore::setSearchFields( const KABC::Field::List &fields )
1027{ 1028{
1028 mIncSearchWidget->setFields( fields ); 1029 mIncSearchWidget->setFields( fields );
1029} 1030}
1030 1031
1031void KABCore::incrementalSearch( const QString& text ) 1032void KABCore::incrementalSearch( const QString& text )
1032{ 1033{
1033 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1034 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1034} 1035}
1035 1036
1036void KABCore::setModified() 1037void KABCore::setModified()
1037{ 1038{
1038 setModified( true ); 1039 setModified( true );
1039} 1040}
1040 1041
1041void KABCore::setModifiedWOrefresh() 1042void KABCore::setModifiedWOrefresh()
1042{ 1043{
1043 // qDebug("KABCore::setModifiedWOrefresh() "); 1044 // qDebug("KABCore::setModifiedWOrefresh() ");
1044 mModified = true; 1045 mModified = true;
1045 mActionSave->setEnabled( mModified ); 1046 mActionSave->setEnabled( mModified );
1046#ifdef DESKTOP_VERSION 1047#ifdef DESKTOP_VERSION
1047 mDetails->refreshView(); 1048 mDetails->refreshView();
1048#endif 1049#endif
1049 1050
1050} 1051}
1051void KABCore::setModified( bool modified ) 1052void KABCore::setModified( bool modified )
1052{ 1053{
1053 mModified = modified; 1054 mModified = modified;
1054 mActionSave->setEnabled( mModified ); 1055 mActionSave->setEnabled( mModified );
1055 1056
1056 if ( modified ) 1057 if ( modified )
1057 mJumpButtonBar->recreateButtons(); 1058 mJumpButtonBar->recreateButtons();
1058 1059
1059 mViewManager->refreshView(); 1060 mViewManager->refreshView();
1060 mDetails->refreshView(); 1061 mDetails->refreshView();
1061 1062
1062} 1063}
1063 1064
1064bool KABCore::modified() const 1065bool KABCore::modified() const
1065{ 1066{
1066 return mModified; 1067 return mModified;
1067} 1068}
1068 1069
1069void KABCore::contactModified( const KABC::Addressee &addr ) 1070void KABCore::contactModified( const KABC::Addressee &addr )
1070{ 1071{
1071 1072
1072 Command *command = 0; 1073 Command *command = 0;
1073 QString uid; 1074 QString uid;
1074 1075
1075 // check if it exists already 1076 // check if it exists already
1076 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1077 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1077 if ( origAddr.isEmpty() ) 1078 if ( origAddr.isEmpty() )
1078 command = new PwNewCommand( mAddressBook, addr ); 1079 command = new PwNewCommand( mAddressBook, addr );
1079 else { 1080 else {
1080 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1081 command = new PwEditCommand( mAddressBook, origAddr, addr );
1081 uid = addr.uid(); 1082 uid = addr.uid();
1082 } 1083 }
1083 1084
1084 UndoStack::instance()->push( command ); 1085 UndoStack::instance()->push( command );
1085 RedoStack::instance()->clear(); 1086 RedoStack::instance()->clear();
1086 1087
1087 setModified( true ); 1088 setModified( true );
1088} 1089}
1089 1090
1090void KABCore::newContact() 1091void KABCore::newContact()
1091{ 1092{
1092 1093
1093 1094
1094 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1095 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1095 1096
1096 QPtrList<KRES::Resource> kresResources; 1097 QPtrList<KRES::Resource> kresResources;
1097 QPtrListIterator<KABC::Resource> it( kabcResources ); 1098 QPtrListIterator<KABC::Resource> it( kabcResources );
1098 KABC::Resource *resource; 1099 KABC::Resource *resource;
1099 while ( ( resource = it.current() ) != 0 ) { 1100 while ( ( resource = it.current() ) != 0 ) {
1100 ++it; 1101 ++it;
1101 if ( !resource->readOnly() ) { 1102 if ( !resource->readOnly() ) {
1102 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1103 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1103 if ( res ) 1104 if ( res )
1104 kresResources.append( res ); 1105 kresResources.append( res );
1105 } 1106 }
1106 } 1107 }
1107 1108
1108 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1109 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1109 resource = static_cast<KABC::Resource*>( res ); 1110 resource = static_cast<KABC::Resource*>( res );
1110 1111
1111 if ( resource ) { 1112 if ( resource ) {
1112 KABC::Addressee addr; 1113 KABC::Addressee addr;
1113 addr.setResource( resource ); 1114 addr.setResource( resource );
1114 mEditorDialog->setAddressee( addr ); 1115 mEditorDialog->setAddressee( addr );
1115 KApplication::execDialog ( mEditorDialog ); 1116 KApplication::execDialog ( mEditorDialog );
1116 1117
1117 } else 1118 } else
1118 return; 1119 return;
1119 1120
1120 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1121 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1121 1122
1122 1123
1123} 1124}
1124 1125
1125void KABCore::addEmail( QString aStr ) 1126void KABCore::addEmail( QString aStr )
1126{ 1127{
1127#ifndef KAB_EMBEDDED 1128#ifndef KAB_EMBEDDED
1128 QString fullName, email; 1129 QString fullName, email;
1129 1130
1130 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1131 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1131 1132
1132 // Try to lookup the addressee matching the email address 1133 // Try to lookup the addressee matching the email address
1133 bool found = false; 1134 bool found = false;
1134 QStringList emailList; 1135 QStringList emailList;
1135 KABC::AddressBook::Iterator it; 1136 KABC::AddressBook::Iterator it;
1136 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1137 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1137 emailList = (*it).emails(); 1138 emailList = (*it).emails();
1138 if ( emailList.contains( email ) > 0 ) { 1139 if ( emailList.contains( email ) > 0 ) {
1139 found = true; 1140 found = true;
1140 (*it).setNameFromString( fullName ); 1141 (*it).setNameFromString( fullName );
1141 editContact( (*it).uid() ); 1142 editContact( (*it).uid() );
1142 } 1143 }
1143 } 1144 }
1144 1145
1145 if ( !found ) { 1146 if ( !found ) {
1146 KABC::Addressee addr; 1147 KABC::Addressee addr;
1147 addr.setNameFromString( fullName ); 1148 addr.setNameFromString( fullName );
1148 addr.insertEmail( email, true ); 1149 addr.insertEmail( email, true );
1149 1150
1150 mAddressBook->insertAddressee( addr ); 1151 mAddressBook->insertAddressee( addr );
1151 mViewManager->refreshView( addr.uid() ); 1152 mViewManager->refreshView( addr.uid() );
1152 editContact( addr.uid() ); 1153 editContact( addr.uid() );
1153 } 1154 }
1154#else //KAB_EMBEDDED 1155#else //KAB_EMBEDDED
1155 qDebug("KABCore::addEmail finsih method"); 1156 qDebug("KABCore::addEmail finsih method");
1156#endif //KAB_EMBEDDED 1157#endif //KAB_EMBEDDED
1157} 1158}
1158 1159
1159void KABCore::importVCard( const KURL &url, bool showPreview ) 1160void KABCore::importVCard( const KURL &url, bool showPreview )
1160{ 1161{
1161 mXXPortManager->importVCard( url, showPreview ); 1162 mXXPortManager->importVCard( url, showPreview );
1162} 1163}
1163void KABCore::importFromOL() 1164void KABCore::importFromOL()
1164{ 1165{
1165#ifdef _WIN32_ 1166#ifdef _WIN32_
1166 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1167 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1167 idgl->exec(); 1168 idgl->exec();
1168 KABC::Addressee::List list = idgl->getAddressList(); 1169 KABC::Addressee::List list = idgl->getAddressList();
1169 if ( list.count() > 0 ) { 1170 if ( list.count() > 0 ) {
1170 KABC::Addressee::List listNew; 1171 KABC::Addressee::List listNew;
1171 KABC::Addressee::List listExisting; 1172 KABC::Addressee::List listExisting;
1172 KABC::Addressee::List::Iterator it; 1173 KABC::Addressee::List::Iterator it;
1173 KABC::AddressBook::Iterator iter; 1174 KABC::AddressBook::Iterator iter;
1174 for ( it = list.begin(); it != list.end(); ++it ) { 1175 for ( it = list.begin(); it != list.end(); ++it ) {
1175 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1176 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1176 listNew.append( (*it) ); 1177 listNew.append( (*it) );
1177 else 1178 else
1178 listExisting.append( (*it) ); 1179 listExisting.append( (*it) );
1179 } 1180 }
1180 if ( listExisting.count() > 0 ) 1181 if ( listExisting.count() > 0 )
1181 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1182 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1182 if ( listNew.count() > 0 ) { 1183 if ( listNew.count() > 0 ) {
1183 pasteWithNewUid = false; 1184 pasteWithNewUid = false;
1184 pasteContacts( listNew ); 1185 pasteContacts( listNew );
1185 pasteWithNewUid = true; 1186 pasteWithNewUid = true;
1186 } 1187 }
1187 } 1188 }
1188 delete idgl; 1189 delete idgl;
1189#endif 1190#endif
1190} 1191}
1191 1192
1192void KABCore::importVCard( const QString &vCard, bool showPreview ) 1193void KABCore::importVCard( const QString &vCard, bool showPreview )
1193{ 1194{
1194 mXXPortManager->importVCard( vCard, showPreview ); 1195 mXXPortManager->importVCard( vCard, showPreview );
1195} 1196}
1196 1197
1197//US added a second method without defaultparameter 1198//US added a second method without defaultparameter
1198void KABCore::editContact2() { 1199void KABCore::editContact2() {
1199 editContact( QString::null ); 1200 editContact( QString::null );
1200} 1201}
1201 1202
1202void KABCore::editContact( const QString &uid ) 1203void KABCore::editContact( const QString &uid )
1203{ 1204{
1204 1205
1205 if ( mExtensionManager->isQuickEditVisible() ) 1206 if ( mExtensionManager->isQuickEditVisible() )
1206 return; 1207 return;
1207 1208
1208 // First, locate the contact entry 1209 // First, locate the contact entry
1209 QString localUID = uid; 1210 QString localUID = uid;
1210 if ( localUID.isNull() ) { 1211 if ( localUID.isNull() ) {
1211 QStringList uidList = mViewManager->selectedUids(); 1212 QStringList uidList = mViewManager->selectedUids();
1212 if ( uidList.count() > 0 ) 1213 if ( uidList.count() > 0 )
1213 localUID = *( uidList.at( 0 ) ); 1214 localUID = *( uidList.at( 0 ) );
1214 } 1215 }
1215 1216
1216 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1217 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1217 if ( !addr.isEmpty() ) { 1218 if ( !addr.isEmpty() ) {
1218 mEditorDialog->setAddressee( addr ); 1219 mEditorDialog->setAddressee( addr );
1219 KApplication::execDialog ( mEditorDialog ); 1220 KApplication::execDialog ( mEditorDialog );
1220 } 1221 }
1221} 1222}
1222 1223
1223/** 1224/**
1224 Shows or edits the detail view for the given uid. If the uid is QString::null, 1225 Shows or edits the detail view for the given uid. If the uid is QString::null,
1225 the method will try to find a selected addressee in the view. 1226 the method will try to find a selected addressee in the view.
1226 */ 1227 */
1227void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1228void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1228{ 1229{
1229 if ( mMultipleViewsAtOnce ) 1230 if ( mMultipleViewsAtOnce )
1230 { 1231 {
1231 editContact( uid ); 1232 editContact( uid );
1232 } 1233 }
1233 else 1234 else
1234 { 1235 {
1235 setDetailsVisible( true ); 1236 setDetailsVisible( true );
1236 mActionDetails->setChecked(true); 1237 mActionDetails->setChecked(true);
1237 } 1238 }
1238 1239
1239} 1240}
1240 1241
1241void KABCore::save() 1242void KABCore::save()
1242{ 1243{
1243 if (syncManager->blockSave()) 1244 if (syncManager->blockSave())
1244 return; 1245 return;
1245 if ( !mModified ) 1246 if ( !mModified )
1246 return; 1247 return;
1247 1248
1248 syncManager->setBlockSave(true); 1249 syncManager->setBlockSave(true);
1249 QString text = i18n( "There was an error while attempting to save\n the " 1250 QString text = i18n( "There was an error while attempting to save\n the "
1250 "address book. Please check that some \nother application is " 1251 "address book. Please check that some \nother application is "
1251 "not using it. " ); 1252 "not using it. " );
1252 statusMessage(i18n("Saving addressbook ... ")); 1253 statusMessage(i18n("Saving addressbook ... "));
1253#ifndef KAB_EMBEDDED 1254#ifndef KAB_EMBEDDED
1254 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1255 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1255 if ( !b || !b->save() ) { 1256 if ( !b || !b->save() ) {
1256 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1257 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1257 } 1258 }
1258#else //KAB_EMBEDDED 1259#else //KAB_EMBEDDED
1259 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1260 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1260 if ( !b || !b->save() ) { 1261 if ( !b || !b->save() ) {
1261 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1262 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1262 } 1263 }
1263#endif //KAB_EMBEDDED 1264#endif //KAB_EMBEDDED
1264 1265
1265 statusMessage(i18n("Addressbook saved!")); 1266 statusMessage(i18n("Addressbook saved!"));
1266 setModified( false ); 1267 setModified( false );
1267 syncManager->setBlockSave(false); 1268 syncManager->setBlockSave(false);
1268} 1269}
1269 1270
1270void KABCore::statusMessage(QString mess , int time ) 1271void KABCore::statusMessage(QString mess , int time )
1271{ 1272{
1272 //topLevelWidget()->setCaption( mess ); 1273 //topLevelWidget()->setCaption( mess );
1273 // pending setting timer to revome message 1274 // pending setting timer to revome message
1274} 1275}
1275void KABCore::undo() 1276void KABCore::undo()
1276{ 1277{
1277 UndoStack::instance()->undo(); 1278 UndoStack::instance()->undo();
1278 1279
1279 // Refresh the view 1280 // Refresh the view
1280 mViewManager->refreshView(); 1281 mViewManager->refreshView();
1281} 1282}
1282 1283
1283void KABCore::redo() 1284void KABCore::redo()
1284{ 1285{
1285 RedoStack::instance()->redo(); 1286 RedoStack::instance()->redo();
1286 1287
1287 // Refresh the view 1288 // Refresh the view
1288 mViewManager->refreshView(); 1289 mViewManager->refreshView();
1289} 1290}
1290 1291
1291void KABCore::setJumpButtonBarVisible( bool visible ) 1292void KABCore::setJumpButtonBarVisible( bool visible )
1292{ 1293{
1293 if (mMultipleViewsAtOnce) 1294 if (mMultipleViewsAtOnce)
1294 { 1295 {
1295 if ( visible ) 1296 if ( visible )
1296 mJumpButtonBar->show(); 1297 mJumpButtonBar->show();
1297 else 1298 else
1298 mJumpButtonBar->hide(); 1299 mJumpButtonBar->hide();
1299 } 1300 }
1300 else 1301 else
1301 { 1302 {
1302 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1303 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1303 if (mViewManager->isVisible()) 1304 if (mViewManager->isVisible())
1304 { 1305 {
1305 if ( visible ) 1306 if ( visible )
1306 mJumpButtonBar->show(); 1307 mJumpButtonBar->show();
1307 else 1308 else
1308 mJumpButtonBar->hide(); 1309 mJumpButtonBar->hide();
1309 } 1310 }
1310 else 1311 else
1311 { 1312 {
1312 mJumpButtonBar->hide(); 1313 mJumpButtonBar->hide();
1313 } 1314 }
1314 } 1315 }
1315} 1316}
1316 1317
1317 1318
1318void KABCore::setDetailsToState() 1319void KABCore::setDetailsToState()
1319{ 1320{
1320 setDetailsVisible( mActionDetails->isChecked() ); 1321 setDetailsVisible( mActionDetails->isChecked() );
1321} 1322}
1322 1323
1323 1324
1324 1325
1325void KABCore::setDetailsVisible( bool visible ) 1326void KABCore::setDetailsVisible( bool visible )
1326{ 1327{
1327 if (visible && mDetails->isHidden()) 1328 if (visible && mDetails->isHidden())
1328 { 1329 {
1329 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1330 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1330 if ( addrList.count() > 0 ) 1331 if ( addrList.count() > 0 )
1331 mDetails->setAddressee( addrList[ 0 ] ); 1332 mDetails->setAddressee( addrList[ 0 ] );
1332 } 1333 }
1333 1334
1334 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1335 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1335 // the listview and the detailview. We do that by changing the splitbar size. 1336 // the listview and the detailview. We do that by changing the splitbar size.
1336 if (mMultipleViewsAtOnce) 1337 if (mMultipleViewsAtOnce)
1337 { 1338 {
1338 if ( visible ) 1339 if ( visible )
1339 mDetails->show(); 1340 mDetails->show();
1340 else 1341 else
1341 mDetails->hide(); 1342 mDetails->hide();
1342 } 1343 }
1343 else 1344 else
1344 { 1345 {
1345 if ( visible ) { 1346 if ( visible ) {
1346 mViewManager->hide(); 1347 mViewManager->hide();
1347 mDetails->show(); 1348 mDetails->show();
1348 } 1349 }
1349 else { 1350 else {
1350 mViewManager->show(); 1351 mViewManager->show();
1351 mDetails->hide(); 1352 mDetails->hide();
1352 } 1353 }
1353 setJumpButtonBarVisible( !visible ); 1354 setJumpButtonBarVisible( !visible );
1354 } 1355 }
1355 1356
1356} 1357}
1357 1358
1358void KABCore::extensionChanged( int id ) 1359void KABCore::extensionChanged( int id )
1359{ 1360{
1360 //change the details view only for non desktop systems 1361 //change the details view only for non desktop systems
1361#ifndef DESKTOP_VERSION 1362#ifndef DESKTOP_VERSION
1362 1363
1363 if (id == 0) 1364 if (id == 0)
1364 { 1365 {
1365 //the user disabled the extension. 1366 //the user disabled the extension.
1366 1367
1367 if (mMultipleViewsAtOnce) 1368 if (mMultipleViewsAtOnce)
1368 { // enable detailsview again 1369 { // enable detailsview again
1369 setDetailsVisible( true ); 1370 setDetailsVisible( true );
1370 mActionDetails->setChecked( true ); 1371 mActionDetails->setChecked( true );
1371 } 1372 }
1372 else 1373 else
1373 { //go back to the listview 1374 { //go back to the listview
1374 setDetailsVisible( false ); 1375 setDetailsVisible( false );
1375 mActionDetails->setChecked( false ); 1376 mActionDetails->setChecked( false );
1376 mActionDetails->setEnabled(true); 1377 mActionDetails->setEnabled(true);
1377 } 1378 }
1378 1379
1379 } 1380 }
1380 else 1381 else
1381 { 1382 {
1382 //the user enabled the extension. 1383 //the user enabled the extension.
1383 setDetailsVisible( false ); 1384 setDetailsVisible( false );
1384 mActionDetails->setChecked( false ); 1385 mActionDetails->setChecked( false );
1385 1386
1386 if (!mMultipleViewsAtOnce) 1387 if (!mMultipleViewsAtOnce)
1387 { 1388 {
1388 mActionDetails->setEnabled(false); 1389 mActionDetails->setEnabled(false);
1389 } 1390 }
1390 1391
1391 mExtensionManager->setSelectionChanged(); 1392 mExtensionManager->setSelectionChanged();
1392 1393
1393 } 1394 }
1394 1395
1395#endif// DESKTOP_VERSION 1396#endif// DESKTOP_VERSION
1396 1397
1397} 1398}
1398 1399
1399 1400
1400void KABCore::extensionModified( const KABC::Addressee::List &list ) 1401void KABCore::extensionModified( const KABC::Addressee::List &list )
1401{ 1402{
1402 1403
1403 if ( list.count() != 0 ) { 1404 if ( list.count() != 0 ) {
1404 KABC::Addressee::List::ConstIterator it; 1405 KABC::Addressee::List::ConstIterator it;
1405 for ( it = list.begin(); it != list.end(); ++it ) 1406 for ( it = list.begin(); it != list.end(); ++it )
1406 mAddressBook->insertAddressee( *it ); 1407 mAddressBook->insertAddressee( *it );
1407 if ( list.count() > 1 ) 1408 if ( list.count() > 1 )
1408 setModified(); 1409 setModified();
1409 else 1410 else
1410 setModifiedWOrefresh(); 1411 setModifiedWOrefresh();
1411 } 1412 }
1412 if ( list.count() == 0 ) 1413 if ( list.count() == 0 )
1413 mViewManager->refreshView(); 1414 mViewManager->refreshView();
1414 else 1415 else
1415 mViewManager->refreshView( list[ 0 ].uid() ); 1416 mViewManager->refreshView( list[ 0 ].uid() );
1416 1417
1417 1418
1418 1419
1419} 1420}
1420 1421
1421QString KABCore::getNameByPhone( const QString &phone ) 1422QString KABCore::getNameByPhone( const QString &phone )
1422{ 1423{
1423#ifndef KAB_EMBEDDED 1424#ifndef KAB_EMBEDDED
1424 QRegExp r( "[/*/-/ ]" ); 1425 QRegExp r( "[/*/-/ ]" );
1425 QString localPhone( phone ); 1426 QString localPhone( phone );
1426 1427
1427 bool found = false; 1428 bool found = false;
1428 QString ownerName = ""; 1429 QString ownerName = "";
1429 KABC::AddressBook::Iterator iter; 1430 KABC::AddressBook::Iterator iter;
1430 KABC::PhoneNumber::List::Iterator phoneIter; 1431 KABC::PhoneNumber::List::Iterator phoneIter;
1431 KABC::PhoneNumber::List phoneList; 1432 KABC::PhoneNumber::List phoneList;
1432 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1433 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1433 phoneList = (*iter).phoneNumbers(); 1434 phoneList = (*iter).phoneNumbers();
1434 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1435 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1435 ++phoneIter) { 1436 ++phoneIter) {
1436 // Get rid of separator chars so just the numbers are compared. 1437 // Get rid of separator chars so just the numbers are compared.
1437 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1438 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1438 ownerName = (*iter).formattedName(); 1439 ownerName = (*iter).formattedName();
1439 found = true; 1440 found = true;
1440 } 1441 }
1441 } 1442 }
1442 } 1443 }
1443 1444
1444 return ownerName; 1445 return ownerName;
1445#else //KAB_EMBEDDED 1446#else //KAB_EMBEDDED
1446 qDebug("KABCore::getNameByPhone finsih method"); 1447 qDebug("KABCore::getNameByPhone finsih method");
1447 return ""; 1448 return "";
1448#endif //KAB_EMBEDDED 1449#endif //KAB_EMBEDDED
1449 1450
1450} 1451}
1451 1452
1452void KABCore::openConfigDialog() 1453void KABCore::openConfigDialog()
1453{ 1454{
1454 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1455 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1455 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1456 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1456 ConfigureDialog->addModule(kabcfg ); 1457 ConfigureDialog->addModule(kabcfg );
1457 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1458 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1458 ConfigureDialog->addModule(kdelibcfg ); 1459 ConfigureDialog->addModule(kdelibcfg );
1459 1460
1460 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1461 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1461 this, SLOT( configurationChanged() ) ); 1462 this, SLOT( configurationChanged() ) );
1462 connect( ConfigureDialog, SIGNAL( okClicked() ), 1463 connect( ConfigureDialog, SIGNAL( okClicked() ),
1463 this, SLOT( configurationChanged() ) ); 1464 this, SLOT( configurationChanged() ) );
1464 saveSettings(); 1465 saveSettings();
1465#ifndef DESKTOP_VERSION 1466#ifndef DESKTOP_VERSION
1466 ConfigureDialog->showMaximized(); 1467 ConfigureDialog->showMaximized();
1467#endif 1468#endif
1468 if ( ConfigureDialog->exec() ) 1469 if ( ConfigureDialog->exec() )
1469 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1470 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1470 delete ConfigureDialog; 1471 delete ConfigureDialog;
1471} 1472}
1472 1473
1473void KABCore::openLDAPDialog() 1474void KABCore::openLDAPDialog()
1474{ 1475{
1475#ifndef KAB_EMBEDDED 1476#ifndef KAB_EMBEDDED
1476 if ( !mLdapSearchDialog ) { 1477 if ( !mLdapSearchDialog ) {
1477 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1478 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1478 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1479 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1479 SLOT( refreshView() ) ); 1480 SLOT( refreshView() ) );
1480 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1481 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1481 SLOT( setModified() ) ); 1482 SLOT( setModified() ) );
1482 } else 1483 } else
1483 mLdapSearchDialog->restoreSettings(); 1484 mLdapSearchDialog->restoreSettings();
1484 1485
1485 if ( mLdapSearchDialog->isOK() ) 1486 if ( mLdapSearchDialog->isOK() )
1486 mLdapSearchDialog->exec(); 1487 mLdapSearchDialog->exec();
1487#else //KAB_EMBEDDED 1488#else //KAB_EMBEDDED
1488 qDebug("KABCore::openLDAPDialog() finsih method"); 1489 qDebug("KABCore::openLDAPDialog() finsih method");
1489#endif //KAB_EMBEDDED 1490#endif //KAB_EMBEDDED
1490} 1491}
1491 1492
1492void KABCore::print() 1493void KABCore::print()
1493{ 1494{
1494#ifndef KAB_EMBEDDED 1495#ifndef KAB_EMBEDDED
1495 KPrinter printer; 1496 KPrinter printer;
1496 if ( !printer.setup( this ) ) 1497 if ( !printer.setup( this ) )
1497 return; 1498 return;
1498 1499
1499 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1500 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1500 mViewManager->selectedUids(), this ); 1501 mViewManager->selectedUids(), this );
1501 1502
1502 wizard.exec(); 1503 wizard.exec();
1503#else //KAB_EMBEDDED 1504#else //KAB_EMBEDDED
1504 qDebug("KABCore::print() finsih method"); 1505 qDebug("KABCore::print() finsih method");
1505#endif //KAB_EMBEDDED 1506#endif //KAB_EMBEDDED
1506 1507
1507} 1508}
1508 1509
1509 1510
1510void KABCore::addGUIClient( KXMLGUIClient *client ) 1511void KABCore::addGUIClient( KXMLGUIClient *client )
1511{ 1512{
1512 if ( mGUIClient ) 1513 if ( mGUIClient )
1513 mGUIClient->insertChildClient( client ); 1514 mGUIClient->insertChildClient( client );
1514 else 1515 else
1515 KMessageBox::error( this, "no KXMLGUICLient"); 1516 KMessageBox::error( this, "no KXMLGUICLient");
1516} 1517}
1517 1518
1518 1519
1519void KABCore::configurationChanged() 1520void KABCore::configurationChanged()
1520{ 1521{
1521 mExtensionManager->reconfigure(); 1522 mExtensionManager->reconfigure();
1522} 1523}
1523 1524
1524void KABCore::addressBookChanged() 1525void KABCore::addressBookChanged()
1525{ 1526{
1526/*US 1527/*US
1527 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1528 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1528 while ( it.current() ) { 1529 while ( it.current() ) {
1529 if ( it.current()->dirty() ) { 1530 if ( it.current()->dirty() ) {
1530 QString text = i18n( "Data has been changed externally. Unsaved " 1531 QString text = i18n( "Data has been changed externally. Unsaved "
1531 "changes will be lost." ); 1532 "changes will be lost." );
1532 KMessageBox::information( this, text ); 1533 KMessageBox::information( this, text );
1533 } 1534 }
1534 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1535 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1535 ++it; 1536 ++it;
1536 } 1537 }
1537*/ 1538*/
1538 if (mEditorDialog) 1539 if (mEditorDialog)
1539 { 1540 {
1540 if (mEditorDialog->dirty()) 1541 if (mEditorDialog->dirty())
1541 { 1542 {
1542 QString text = i18n( "Data has been changed externally. Unsaved " 1543 QString text = i18n( "Data has been changed externally. Unsaved "
1543 "changes will be lost." ); 1544 "changes will be lost." );
1544 KMessageBox::information( this, text ); 1545 KMessageBox::information( this, text );
1545 } 1546 }
1546 QString currentuid = mEditorDialog->addressee().uid(); 1547 QString currentuid = mEditorDialog->addressee().uid();
1547 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1548 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1548 } 1549 }
1549 mViewManager->refreshView(); 1550 mViewManager->refreshView();
1550// mDetails->refreshView(); 1551// mDetails->refreshView();
1551 1552
1552 1553
1553} 1554}
1554 1555
1555AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1556AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1556 const char *name ) 1557 const char *name )
1557{ 1558{
1558 1559
1559 if ( mEditorDialog == 0 ) { 1560 if ( mEditorDialog == 0 ) {
1560 mEditorDialog = new AddresseeEditorDialog( this, parent, 1561 mEditorDialog = new AddresseeEditorDialog( this, parent,
1561 name ? name : "editorDialog" ); 1562 name ? name : "editorDialog" );
1562 1563
1563 1564
1564 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1565 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1565 SLOT( contactModified( const KABC::Addressee& ) ) ); 1566 SLOT( contactModified( const KABC::Addressee& ) ) );
1566 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1567 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1567 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1568 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1568 } 1569 }
1569 1570
1570 return mEditorDialog; 1571 return mEditorDialog;
1571} 1572}
1572 1573
1573void KABCore::slotEditorDestroyed( const QString &uid ) 1574void KABCore::slotEditorDestroyed( const QString &uid )
1574{ 1575{
1575 //mEditorDict.remove( uid ); 1576 //mEditorDict.remove( uid );
1576} 1577}
1577 1578
1578void KABCore::initGUI() 1579void KABCore::initGUI()
1579{ 1580{
1580#ifndef KAB_EMBEDDED 1581#ifndef KAB_EMBEDDED
1581 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1582 QHBoxLayout *topLayout = new QHBoxLayout( this );
1582 topLayout->setSpacing( KDialogBase::spacingHint() ); 1583 topLayout->setSpacing( KDialogBase::spacingHint() );
1583 1584
1584 mExtensionBarSplitter = new QSplitter( this ); 1585 mExtensionBarSplitter = new QSplitter( this );
1585 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1586 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1586 1587
1587 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1588 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1588 1589
1589 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1590 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1590 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1591 mIncSearchWidget = new IncSearchWidget( viewSpace );
1591 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1592 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1592 SLOT( incrementalSearch( const QString& ) ) ); 1593 SLOT( incrementalSearch( const QString& ) ) );
1593 1594
1594 mViewManager = new ViewManager( this, viewSpace ); 1595 mViewManager = new ViewManager( this, viewSpace );
1595 viewSpace->setStretchFactor( mViewManager, 1 ); 1596 viewSpace->setStretchFactor( mViewManager, 1 );
1596 1597
1597 mDetails = new ViewContainer( mDetailsSplitter ); 1598 mDetails = new ViewContainer( mDetailsSplitter );
1598 1599
1599 mJumpButtonBar = new JumpButtonBar( this, this ); 1600 mJumpButtonBar = new JumpButtonBar( this, this );
1600 1601
1601 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1602 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1602 1603
1603 topLayout->addWidget( mExtensionBarSplitter ); 1604 topLayout->addWidget( mExtensionBarSplitter );
1604 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1605 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1605 topLayout->addWidget( mJumpButtonBar ); 1606 topLayout->addWidget( mJumpButtonBar );
1606 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1607 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1607 1608
1608 mXXPortManager = new XXPortManager( this, this ); 1609 mXXPortManager = new XXPortManager( this, this );
1609 1610
1610#else //KAB_EMBEDDED 1611#else //KAB_EMBEDDED
1611 //US initialize viewMenu before settingup viewmanager. 1612 //US initialize viewMenu before settingup viewmanager.
1612 // Viewmanager needs this menu to plugin submenues. 1613 // Viewmanager needs this menu to plugin submenues.
1613 viewMenu = new QPopupMenu( this ); 1614 viewMenu = new QPopupMenu( this );
1614 settingsMenu = new QPopupMenu( this ); 1615 settingsMenu = new QPopupMenu( this );
1615 //filterMenu = new QPopupMenu( this ); 1616 //filterMenu = new QPopupMenu( this );
1616 ImportMenu = new QPopupMenu( this ); 1617 ImportMenu = new QPopupMenu( this );
1617 ExportMenu = new QPopupMenu( this ); 1618 ExportMenu = new QPopupMenu( this );
1618 syncMenu = new QPopupMenu( this ); 1619 syncMenu = new QPopupMenu( this );
1619 changeMenu= new QPopupMenu( this ); 1620 changeMenu= new QPopupMenu( this );
1620 1621
1621//US since we have no splitter for the embedded system, setup 1622//US since we have no splitter for the embedded system, setup
1622// a layout with two frames. One left and one right. 1623// a layout with two frames. One left and one right.
1623 1624
1624 QBoxLayout *topLayout; 1625 QBoxLayout *topLayout;
1625 1626
1626 // = new QHBoxLayout( this ); 1627 // = new QHBoxLayout( this );
1627// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1628// QBoxLayout *topLayout = (QBoxLayout*)layout();
1628 1629
1629// QWidget *mainBox = new QWidget( this ); 1630// QWidget *mainBox = new QWidget( this );
1630// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1631// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1631 1632
1632#ifdef DESKTOP_VERSION 1633#ifdef DESKTOP_VERSION
1633 topLayout = new QHBoxLayout( this ); 1634 topLayout = new QHBoxLayout( this );
1634 1635
1635 1636
1636 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1637 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1637 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1638 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1638 1639
1639 topLayout->addWidget(mMiniSplitter ); 1640 topLayout->addWidget(mMiniSplitter );
1640 1641
1641 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1642 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1642 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1643 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1643 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1644 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1644 mDetails = new ViewContainer( mMiniSplitter ); 1645 mDetails = new ViewContainer( mMiniSplitter );
1645 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1646 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1646#else 1647#else
1647 if ( QApplication::desktop()->width() > 480 ) { 1648 if ( QApplication::desktop()->width() > 480 ) {
1648 topLayout = new QHBoxLayout( this ); 1649 topLayout = new QHBoxLayout( this );
1649 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1650 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1650 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1651 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1651 } else { 1652 } else {
1652 1653
1653 topLayout = new QHBoxLayout( this ); 1654 topLayout = new QHBoxLayout( this );
1654 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1655 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1655 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1656 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1656 } 1657 }
1657 1658
1658 topLayout->addWidget(mMiniSplitter ); 1659 topLayout->addWidget(mMiniSplitter );
1659 mViewManager = new ViewManager( this, mMiniSplitter ); 1660 mViewManager = new ViewManager( this, mMiniSplitter );
1660 mDetails = new ViewContainer( mMiniSplitter ); 1661 mDetails = new ViewContainer( mMiniSplitter );
1661 1662
1662 1663
1663 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1664 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1664#endif 1665#endif
1665 //eh->hide(); 1666 //eh->hide();
1666 // topLayout->addWidget(mExtensionManager ); 1667 // topLayout->addWidget(mExtensionManager );
1667 1668
1668 1669
1669/*US 1670/*US
1670#ifndef KAB_NOSPLITTER 1671#ifndef KAB_NOSPLITTER
1671 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1672 QHBoxLayout *topLayout = new QHBoxLayout( this );
1672//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1673//US topLayout->setSpacing( KDialogBase::spacingHint() );
1673 topLayout->setSpacing( 10 ); 1674 topLayout->setSpacing( 10 );
1674 1675
1675 mDetailsSplitter = new QSplitter( this ); 1676 mDetailsSplitter = new QSplitter( this );
1676 1677
1677 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1678 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1678 1679
1679 mViewManager = new ViewManager( this, viewSpace ); 1680 mViewManager = new ViewManager( this, viewSpace );
1680 viewSpace->setStretchFactor( mViewManager, 1 ); 1681 viewSpace->setStretchFactor( mViewManager, 1 );
1681 1682
1682 mDetails = new ViewContainer( mDetailsSplitter ); 1683 mDetails = new ViewContainer( mDetailsSplitter );
1683 1684
1684 topLayout->addWidget( mDetailsSplitter ); 1685 topLayout->addWidget( mDetailsSplitter );
1685 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1686 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1686#else //KAB_NOSPLITTER 1687#else //KAB_NOSPLITTER
1687 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1688 QHBoxLayout *topLayout = new QHBoxLayout( this );
1688//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1689//US topLayout->setSpacing( KDialogBase::spacingHint() );
1689 topLayout->setSpacing( 10 ); 1690 topLayout->setSpacing( 10 );
1690 1691
1691// mDetailsSplitter = new QSplitter( this ); 1692// mDetailsSplitter = new QSplitter( this );
1692 1693
1693 QVBox *viewSpace = new QVBox( this ); 1694 QVBox *viewSpace = new QVBox( this );
1694 1695
1695 mViewManager = new ViewManager( this, viewSpace ); 1696 mViewManager = new ViewManager( this, viewSpace );
1696 viewSpace->setStretchFactor( mViewManager, 1 ); 1697 viewSpace->setStretchFactor( mViewManager, 1 );
1697 1698
1698 mDetails = new ViewContainer( this ); 1699 mDetails = new ViewContainer( this );
1699 1700
1700 topLayout->addWidget( viewSpace ); 1701 topLayout->addWidget( viewSpace );
1701// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1702// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1702 topLayout->addWidget( mDetails ); 1703 topLayout->addWidget( mDetails );
1703#endif //KAB_NOSPLITTER 1704#endif //KAB_NOSPLITTER
1704*/ 1705*/
1705 1706
1706 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1707 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1707 syncManager->setBlockSave(false); 1708 syncManager->setBlockSave(false);
1708 1709
1709 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1710 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1710 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1711 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1711 syncManager->setDefaultFileName( sentSyncFile()); 1712 syncManager->setDefaultFileName( sentSyncFile());
1712 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1713 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1713 1714
1714#endif //KAB_EMBEDDED 1715#endif //KAB_EMBEDDED
1715 initActions(); 1716 initActions();
1716 1717
1717#ifdef KAB_EMBEDDED 1718#ifdef KAB_EMBEDDED
1718 addActionsManually(); 1719 addActionsManually();
1719 //US make sure the export and import menues are initialized before creating the xxPortManager. 1720 //US make sure the export and import menues are initialized before creating the xxPortManager.
1720 mXXPortManager = new XXPortManager( this, this ); 1721 mXXPortManager = new XXPortManager( this, this );
1721 1722
1722 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1723 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1723 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1724 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1724 // mActionQuit->plug ( mMainWindow->toolBar()); 1725 // mActionQuit->plug ( mMainWindow->toolBar());
1725 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1726 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1726 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1727 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1727 // mIncSearchWidget->hide(); 1728 // mIncSearchWidget->hide();
1728 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1729 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1729 SLOT( incrementalSearch( const QString& ) ) ); 1730 SLOT( incrementalSearch( const QString& ) ) );
1730 1731
1731 1732
1732 mJumpButtonBar = new JumpButtonBar( this, this ); 1733 mJumpButtonBar = new JumpButtonBar( this, this );
1733 1734
1734 topLayout->addWidget( mJumpButtonBar ); 1735 topLayout->addWidget( mJumpButtonBar );
1735//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1736//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1736 1737
1737// mMainWindow->getIconToolBar()->raise(); 1738// mMainWindow->getIconToolBar()->raise();
1738 1739
1739#endif //KAB_EMBEDDED 1740#endif //KAB_EMBEDDED
1740 1741
1741} 1742}
1742void KABCore::initActions() 1743void KABCore::initActions()
1743{ 1744{
1744//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1745//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1745 1746
1746#ifndef KAB_EMBEDDED 1747#ifndef KAB_EMBEDDED
1747 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1748 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1748 SLOT( clipboardDataChanged() ) ); 1749 SLOT( clipboardDataChanged() ) );
1749#endif //KAB_EMBEDDED 1750#endif //KAB_EMBEDDED
1750 1751
1751 // file menu 1752 // file menu
1752 if ( mIsPart ) { 1753 if ( mIsPart ) {
1753 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1754 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1754 SLOT( sendMail() ), actionCollection(), 1755 SLOT( sendMail() ), actionCollection(),
1755 "kaddressbook_mail" ); 1756 "kaddressbook_mail" );
1756 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1757 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1757 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1758 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1758 1759
1759 } else { 1760 } else {
1760 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1761 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1761 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1762 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1762 } 1763 }
1763 1764
1764 1765
1765 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1766 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1766 SLOT( save() ), actionCollection(), "file_sync" ); 1767 SLOT( save() ), actionCollection(), "file_sync" );
1767 1768
1768 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1769 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1769 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1770 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1770 1771
1771 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1772 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1772 this, SLOT( mailVCard() ), 1773 this, SLOT( mailVCard() ),
1773 actionCollection(), "file_mail_vcard"); 1774 actionCollection(), "file_mail_vcard");
1774 1775
1775 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this, 1776 mActionExport2phone = new KAction( i18n( "Selected to phone" ), "ex2phone", 0, this,
1776 SLOT( export2phone() ), actionCollection(), 1777 SLOT( export2phone() ), actionCollection(),
1777 "kaddressbook_ex2phone" ); 1778 "kaddressbook_ex2phone" );
1778 1779
1779 mActionBeamVCard = 0; 1780 mActionBeamVCard = 0;
1780 mActionBeam = 0; 1781 mActionBeam = 0;
1781 1782
1782#ifndef DESKTOP_VERSION 1783#ifndef DESKTOP_VERSION
1783 if ( Ir::supported() ) { 1784 if ( Ir::supported() ) {
1784 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1785 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1785 SLOT( beamVCard() ), actionCollection(), 1786 SLOT( beamVCard() ), actionCollection(),
1786 "kaddressbook_beam_vcard" ); 1787 "kaddressbook_beam_vcard" );
1787 1788
1788 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1789 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1789 SLOT( beamMySelf() ), actionCollection(), 1790 SLOT( beamMySelf() ), actionCollection(),
1790 "kaddressbook_beam_myself" ); 1791 "kaddressbook_beam_myself" );
1791 } 1792 }
1792#endif 1793#endif
1793 1794
1794 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1795 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1795 this, SLOT( editContact2() ), 1796 this, SLOT( editContact2() ),
1796 actionCollection(), "file_properties" ); 1797 actionCollection(), "file_properties" );
1797 1798
1798#ifdef KAB_EMBEDDED 1799#ifdef KAB_EMBEDDED
1799 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1800 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1800 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1801 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1801 mMainWindow, SLOT( exit() ), 1802 mMainWindow, SLOT( exit() ),
1802 actionCollection(), "quit" ); 1803 actionCollection(), "quit" );
1803#endif //KAB_EMBEDDED 1804#endif //KAB_EMBEDDED
1804 1805
1805 // edit menu 1806 // edit menu
1806 if ( mIsPart ) { 1807 if ( mIsPart ) {
1807 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1808 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1808 SLOT( copyContacts() ), actionCollection(), 1809 SLOT( copyContacts() ), actionCollection(),
1809 "kaddressbook_copy" ); 1810 "kaddressbook_copy" );
1810 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1811 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1811 SLOT( cutContacts() ), actionCollection(), 1812 SLOT( cutContacts() ), actionCollection(),
1812 "kaddressbook_cut" ); 1813 "kaddressbook_cut" );
1813 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1814 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1814 SLOT( pasteContacts() ), actionCollection(), 1815 SLOT( pasteContacts() ), actionCollection(),
1815 "kaddressbook_paste" ); 1816 "kaddressbook_paste" );
1816 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1817 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1817 SLOT( selectAllContacts() ), actionCollection(), 1818 SLOT( selectAllContacts() ), actionCollection(),
1818 "kaddressbook_select_all" ); 1819 "kaddressbook_select_all" );
1819 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1820 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1820 SLOT( undo() ), actionCollection(), 1821 SLOT( undo() ), actionCollection(),
1821 "kaddressbook_undo" ); 1822 "kaddressbook_undo" );
1822 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1823 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1823 this, SLOT( redo() ), actionCollection(), 1824 this, SLOT( redo() ), actionCollection(),
1824 "kaddressbook_redo" ); 1825 "kaddressbook_redo" );
1825 } else { 1826 } else {
1826 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1827 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1827 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1828 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1828 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1829 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1829 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1830 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1830 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1831 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1831 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1832 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1832 } 1833 }
1833 1834
1834 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1835 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1835 Key_Delete, this, SLOT( deleteContacts() ), 1836 Key_Delete, this, SLOT( deleteContacts() ),
1836 actionCollection(), "edit_delete" ); 1837 actionCollection(), "edit_delete" );
1837 1838
1838 mActionUndo->setEnabled( false ); 1839 mActionUndo->setEnabled( false );
1839 mActionRedo->setEnabled( false ); 1840 mActionRedo->setEnabled( false );
1840 1841
1841 // settings menu 1842 // settings menu
1842#ifdef KAB_EMBEDDED 1843#ifdef KAB_EMBEDDED
1843//US special menuentry to configure the addressbook resources. On KDE 1844//US special menuentry to configure the addressbook resources. On KDE
1844// you do that through the control center !!! 1845// you do that through the control center !!!
1845 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1846 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1846 SLOT( configureResources() ), actionCollection(), 1847 SLOT( configureResources() ), actionCollection(),
1847 "kaddressbook_configure_resources" ); 1848 "kaddressbook_configure_resources" );
1848#endif //KAB_EMBEDDED 1849#endif //KAB_EMBEDDED
1849 1850
1850 if ( mIsPart ) { 1851 if ( mIsPart ) {
1851 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1852 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1852 SLOT( openConfigDialog() ), actionCollection(), 1853 SLOT( openConfigDialog() ), actionCollection(),
1853 "kaddressbook_configure" ); 1854 "kaddressbook_configure" );
1854 1855
1855 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1856 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1856 this, SLOT( configureKeyBindings() ), actionCollection(), 1857 this, SLOT( configureKeyBindings() ), actionCollection(),
1857 "kaddressbook_configure_shortcuts" ); 1858 "kaddressbook_configure_shortcuts" );
1858#ifdef KAB_EMBEDDED 1859#ifdef KAB_EMBEDDED
1859 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1860 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1860 mActionConfigureToolbars->setEnabled( false ); 1861 mActionConfigureToolbars->setEnabled( false );
1861#endif //KAB_EMBEDDED 1862#endif //KAB_EMBEDDED
1862 1863
1863 } else { 1864 } else {
1864 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1865 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1865 1866
1866 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1867 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1867 } 1868 }