summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-06-29 05:32:00 (UTC)
committer ulf69 <ulf69>2004-06-29 05:32:00 (UTC)
commited68714fca68286417778f0f5378b9f65d4acaa3 (patch) (unidiff)
treeeced04ffbb16d2dcd19dfe07e5d83dd9794c4f4d
parent32ccd8d1cd509afdccea7ce62406ad260a2e6f8f (diff)
downloadkdepimpi-ed68714fca68286417778f0f5378b9f65d4acaa3.zip
kdepimpi-ed68714fca68286417778f0f5378b9f65d4acaa3.tar.gz
kdepimpi-ed68714fca68286417778f0f5378b9f65d4acaa3.tar.bz2
removed references to macro KAB_EMBEDDED
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp36
1 files changed, 11 insertions, 25 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 203efc2..97bd3ef 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -4,86 +4,80 @@
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KAB_EMBEDDED 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#else //KAB_EMBEDDED
41#include <qptrlist.h> 40#include <qptrlist.h>
42#endif //KAB_EMBEDDED
43 41
44#include <kglobal.h> 42#include <kglobal.h>
45#include <klocale.h> 43#include <klocale.h>
46#include <kdebug.h> 44#include <kdebug.h>
47#include "addressbook.h" 45#include "addressbook.h"
48#include "resource.h" 46#include "resource.h"
49 47
50#ifndef KAB_EMBEDDED 48//US #include "addressbook.moc"
51#include "addressbook.moc"
52#endif //KAB_EMBEDDED
53 49
54using namespace KABC; 50using namespace KABC;
55 51
56struct AddressBook::AddressBookData 52struct AddressBook::AddressBookData
57{ 53{
58 Addressee::List mAddressees; 54 Addressee::List mAddressees;
59 Addressee::List mRemovedAddressees; 55 Addressee::List mRemovedAddressees;
60 Field::List mAllFields; 56 Field::List mAllFields;
61 KConfig *mConfig; 57 KConfig *mConfig;
62 KRES::Manager<Resource> *mManager; 58 KRES::Manager<Resource> *mManager;
63#ifndef KAB_EMBEDDED 59//US ErrorHandler *mErrorHandler;
64 ErrorHandler *mErrorHandler;
65#endif //KAB_EMBEDDED
66}; 60};
67 61
68struct AddressBook::Iterator::IteratorData 62struct AddressBook::Iterator::IteratorData
69{ 63{
70 Addressee::List::Iterator mIt; 64 Addressee::List::Iterator mIt;
71}; 65};
72 66
73struct AddressBook::ConstIterator::ConstIteratorData 67struct AddressBook::ConstIterator::ConstIteratorData
74{ 68{
75 Addressee::List::ConstIterator mIt; 69 Addressee::List::ConstIterator mIt;
76}; 70};
77 71
78AddressBook::Iterator::Iterator() 72AddressBook::Iterator::Iterator()
79{ 73{
80 d = new IteratorData; 74 d = new IteratorData;
81} 75}
82 76
83AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) 77AddressBook::Iterator::Iterator( const AddressBook::Iterator &i )
84{ 78{
85 d = new IteratorData; 79 d = new IteratorData;
86 d->mIt = i.d->mIt; 80 d->mIt = i.d->mIt;
87} 81}
88 82
89AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) 83AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i )
@@ -221,62 +215,58 @@ bool AddressBook::ConstIterator::operator!=( const ConstIterator &it )
221 215
222 216
223AddressBook::AddressBook() 217AddressBook::AddressBook()
224{ 218{
225 init(0); 219 init(0);
226} 220}
227 221
228AddressBook::AddressBook( const QString &config ) 222AddressBook::AddressBook( const QString &config )
229{ 223{
230 init(config); 224 init(config);
231} 225}
232 226
233void AddressBook::init(const QString &config) 227void AddressBook::init(const QString &config)
234{ 228{
235 d = new AddressBookData; 229 d = new AddressBookData;
236 if (config != 0) { 230 if (config != 0) {
237 d->mConfig = new KConfig( config ); 231 d->mConfig = new KConfig( config );
238// qDebug("AddressBook::init 1 config=%s",config.latin1() ); 232// qDebug("AddressBook::init 1 config=%s",config.latin1() );
239 } 233 }
240 else { 234 else {
241 d->mConfig = 0; 235 d->mConfig = 0;
242// qDebug("AddressBook::init 1 config=0"); 236// qDebug("AddressBook::init 1 config=0");
243 } 237 }
244 238
245#ifndef KAB_EMBEDDED 239//US d->mErrorHandler = 0;
246 d->mErrorHandler = 0;
247#endif //KAB_EMBEDDED
248 d->mManager = new KRES::Manager<Resource>( "contact" ); 240 d->mManager = new KRES::Manager<Resource>( "contact" );
249 d->mManager->readConfig( d->mConfig ); 241 d->mManager->readConfig( d->mConfig );
250} 242}
251 243
252AddressBook::~AddressBook() 244AddressBook::~AddressBook()
253{ 245{
254 delete d->mConfig; d->mConfig = 0; 246 delete d->mConfig; d->mConfig = 0;
255 delete d->mManager; d->mManager = 0; 247 delete d->mManager; d->mManager = 0;
256#ifndef KAB_EMBEDDED 248//US delete d->mErrorHandler; d->mErrorHandler = 0;
257 delete d->mErrorHandler; d->mErrorHandler = 0;
258#endif //KAB_EMBEDDED
259 delete d; d = 0; 249 delete d; d = 0;
260} 250}
261 251
262bool AddressBook::load() 252bool AddressBook::load()
263{ 253{
264 kdDebug(5700) << "AddressBook::load()" << endl; 254 kdDebug(5700) << "AddressBook::load()" << endl;
265 255
266 clear(); 256 clear();
267 257
268 KRES::Manager<Resource>::ActiveIterator it; 258 KRES::Manager<Resource>::ActiveIterator it;
269 bool ok = true; 259 bool ok = true;
270 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 260 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
271 if ( !(*it)->load() ) { 261 if ( !(*it)->load() ) {
272 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); 262 error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) );
273 ok = false; 263 ok = false;
274 } 264 }
275 265
276 // mark all addressees as unchanged 266 // mark all addressees as unchanged
277 Addressee::List::Iterator addrIt; 267 Addressee::List::Iterator addrIt;
278 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) 268 for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt )
279 (*addrIt).setChanged( false ); 269 (*addrIt).setChanged( false );
280 270
281 return ok; 271 return ok;
282} 272}
@@ -498,53 +488,50 @@ QString AddressBook::identifier()
498 488
499Field::List AddressBook::fields( int category ) 489Field::List AddressBook::fields( int category )
500{ 490{
501 if ( d->mAllFields.isEmpty() ) { 491 if ( d->mAllFields.isEmpty() ) {
502 d->mAllFields = Field::allFields(); 492 d->mAllFields = Field::allFields();
503 } 493 }
504 494
505 if ( category == Field::All ) return d->mAllFields; 495 if ( category == Field::All ) return d->mAllFields;
506 496
507 Field::List result; 497 Field::List result;
508 Field::List::ConstIterator it; 498 Field::List::ConstIterator it;
509 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 499 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
510 if ( (*it)->category() & category ) result.append( *it ); 500 if ( (*it)->category() & category ) result.append( *it );
511 } 501 }
512 502
513 return result; 503 return result;
514} 504}
515 505
516bool AddressBook::addCustomField( const QString &label, int category, 506bool AddressBook::addCustomField( const QString &label, int category,
517 const QString &key, const QString &app ) 507 const QString &key, const QString &app )
518{ 508{
519 if ( d->mAllFields.isEmpty() ) { 509 if ( d->mAllFields.isEmpty() ) {
520 d->mAllFields = Field::allFields(); 510 d->mAllFields = Field::allFields();
521 } 511 }
522#ifndef KAB_EMBEDDED 512//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
523 QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
524#else //KAB_EMBEDDED
525 QString a = app.isNull() ? KGlobal::getAppName() : app; 513 QString a = app.isNull() ? KGlobal::getAppName() : app;
526#endif //KAB_EMBEDDED
527 514
528 QString k = key.isNull() ? label : key; 515 QString k = key.isNull() ? label : key;
529 516
530 Field *field = Field::createCustomField( label, category, k, a ); 517 Field *field = Field::createCustomField( label, category, k, a );
531 518
532 if ( !field ) return false; 519 if ( !field ) return false;
533 520
534 d->mAllFields.append( field ); 521 d->mAllFields.append( field );
535 522
536 return true; 523 return true;
537} 524}
538 525
539QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 526QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
540{ 527{
541 if (!ab.d) return s; 528 if (!ab.d) return s;
542 529
543 return s << ab.d->mAddressees; 530 return s << ab.d->mAddressees;
544} 531}
545 532
546QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 533QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
547{ 534{
548 if (!ab.d) return s; 535 if (!ab.d) return s;
549 536
550 s >> ab.d->mAddressees; 537 s >> ab.d->mAddressees;
@@ -572,70 +559,69 @@ bool AddressBook::removeResource( Resource *resource )
572 resource->close(); 559 resource->close();
573 560
574 if ( resource == standardResource() ) 561 if ( resource == standardResource() )
575 d->mManager->setStandardResource( 0 ); 562 d->mManager->setStandardResource( 0 );
576 563
577 resource->setAddressBook( 0 ); 564 resource->setAddressBook( 0 );
578 565
579 d->mManager->remove( resource ); 566 d->mManager->remove( resource );
580 return true; 567 return true;
581} 568}
582 569
583QPtrList<Resource> AddressBook::resources() 570QPtrList<Resource> AddressBook::resources()
584{ 571{
585 QPtrList<Resource> list; 572 QPtrList<Resource> list;
586 573
587// qDebug("AddressBook::resources() 1"); 574// qDebug("AddressBook::resources() 1");
588 575
589 KRES::Manager<Resource>::ActiveIterator it; 576 KRES::Manager<Resource>::ActiveIterator it;
590 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 577 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
591 list.append( *it ); 578 list.append( *it );
592 579
593 return list; 580 return list;
594} 581}
595 582
596#ifndef KAB_EMBEDDED 583/*US
597void AddressBook::setErrorHandler( ErrorHandler *handler ) 584void AddressBook::setErrorHandler( ErrorHandler *handler )
598{ 585{
599 delete d->mErrorHandler; 586 delete d->mErrorHandler;
600 d->mErrorHandler = handler; 587 d->mErrorHandler = handler;
601} 588}
602#endif //KAB_EMBEDDED 589*/
603 590
604void AddressBook::error( const QString& msg ) 591void AddressBook::error( const QString& msg )
605{ 592{
606#ifndef KAB_EMBEDDED 593/*US
607 if ( !d->mErrorHandler ) // create default error handler 594 if ( !d->mErrorHandler ) // create default error handler
608 d->mErrorHandler = new ConsoleErrorHandler; 595 d->mErrorHandler = new ConsoleErrorHandler;
609 596
610 if ( d->mErrorHandler ) 597 if ( d->mErrorHandler )
611 d->mErrorHandler->error( msg ); 598 d->mErrorHandler->error( msg );
612 else 599 else
613 kdError(5700) << "no error handler defined" << endl; 600 kdError(5700) << "no error handler defined" << endl;
614#else //KAB_EMBEDDED 601*/
615 kdDebug(5700) << "msg" << endl; 602 kdDebug(5700) << "msg" << endl;
616 qDebug(msg); 603 qDebug(msg);
617#endif //KAB_EMBEDDED
618} 604}
619 605
620void AddressBook::deleteRemovedAddressees() 606void AddressBook::deleteRemovedAddressees()
621{ 607{
622 Addressee::List::Iterator it; 608 Addressee::List::Iterator it;
623 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 609 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
624 Resource *resource = (*it).resource(); 610 Resource *resource = (*it).resource();
625 if ( resource && !resource->readOnly() && resource->isOpen() ) 611 if ( resource && !resource->readOnly() && resource->isOpen() )
626 resource->removeAddressee( *it ); 612 resource->removeAddressee( *it );
627 } 613 }
628 614
629 d->mRemovedAddressees.clear(); 615 d->mRemovedAddressees.clear();
630} 616}
631 617
632void AddressBook::setStandardResource( Resource *resource ) 618void AddressBook::setStandardResource( Resource *resource )
633{ 619{
634// qDebug("AddressBook::setStandardResource 1"); 620// qDebug("AddressBook::setStandardResource 1");
635 d->mManager->setStandardResource( resource ); 621 d->mManager->setStandardResource( resource );
636} 622}
637 623
638Resource *AddressBook::standardResource() 624Resource *AddressBook::standardResource()
639{ 625{
640 return d->mManager->standardResource(); 626 return d->mManager->standardResource();
641} 627}