summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-08-23 14:22:11 (UTC)
committer zautrix <zautrix>2005-08-23 14:22:11 (UTC)
commite6d678229580cd712ff82ea989e7b151be546dbd (patch) (unidiff)
tree1cf32674db62993bcdc636d90b3994e9343a8b5f
parent02fa432f183ad2b18380de0e41399efe3b867dba (diff)
downloadkdepimpi-e6d678229580cd712ff82ea989e7b151be546dbd.zip
kdepimpi-e6d678229580cd712ff82ea989e7b151be546dbd.tar.gz
kdepimpi-e6d678229580cd712ff82ea989e7b151be546dbd.tar.bz2
stdab fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/stdaddressbook.cpp27
-rw-r--r--kabc/stdaddressbook.h2
-rw-r--r--kaddressbook/kabcore.cpp2
3 files changed, 27 insertions, 4 deletions
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp
index a14ae20..43d9fde 100644
--- a/kabc/stdaddressbook.cpp
+++ b/kabc/stdaddressbook.cpp
@@ -1,230 +1,251 @@
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#include <qdir.h> 28#include <qdir.h>
29#include "resource.h" 29#include "resource.h"
30#include <kresources/manager.h> 30#include <kresources/manager.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33#include <kstaticdeleter.h> 33#include <kstaticdeleter.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35 35
36#include "stdaddressbook.h" 36#include "stdaddressbook.h"
37 37
38using namespace KABC; 38using namespace KABC;
39 39
40StdAddressBook *StdAddressBook::mSelf = 0; 40StdAddressBook *StdAddressBook::mSelf = 0;
41bool StdAddressBook::mAutomaticSave = false; 41bool StdAddressBook::mAutomaticSave = false;
42 42
43static KStaticDeleter<StdAddressBook> addressBookDeleter; 43static KStaticDeleter<StdAddressBook> addressBookDeleter;
44 44
45QString StdAddressBook::fileName() 45QString StdAddressBook::fileName()
46{ 46{
47 return locateLocal( "data", "kabc/std.vcf" ); 47 return locateLocal( "data", "kabc/std.vcf" );
48} 48}
49 49
50QString StdAddressBook::directoryName() 50QString StdAddressBook::directoryName()
51{ 51{
52 return locateLocal( "data", "kabc/stdvcf" ); 52 return locateLocal( "data", "kabc/stdvcf" );
53} 53}
54 54
55void StdAddressBook::handleCrash() 55void StdAddressBook::handleCrash()
56{ 56{
57 StdAddressBook::self()->cleanUp(); 57 StdAddressBook::self()->cleanUp();
58} 58}
59StdAddressBook *StdAddressBook::selfNoLoad()
60{
61
62 if ( !mSelf )
63 {
64 QString appdir = StdAddressBook::setTempAppDir();
65// US im am not sure why I have to use the other format here??
66#ifdef KAB_EMBEDDED
67 mSelf = addressBookDeleter.setObject( new StdAddressBook ( QString() ) );
68#else //KAB_EMBEDDED
69 addressBookDeleter.setObject( mSelf, new StdAddressBook( QString() ) );
70#endif //KAB_EMBEDDED
71 KStandardDirs::setAppDir( appdir );
72 }
73
74 return mSelf;
75}
59 76
60StdAddressBook *StdAddressBook::self() 77StdAddressBook *StdAddressBook::self()
61{ 78{
62 79
63 if ( !mSelf ) 80 if ( !mSelf )
64 { 81 {
65 QString appdir = StdAddressBook::setTempAppDir(); 82 QString appdir = StdAddressBook::setTempAppDir();
66// US im am not sure why I have to use the other format here?? 83// US im am not sure why I have to use the other format here??
67#ifdef KAB_EMBEDDED 84#ifdef KAB_EMBEDDED
68 mSelf = addressBookDeleter.setObject( new StdAddressBook ); 85 mSelf = addressBookDeleter.setObject( new StdAddressBook );
69#else //KAB_EMBEDDED 86#else //KAB_EMBEDDED
70 addressBookDeleter.setObject( mSelf, new StdAddressBook ); 87 addressBookDeleter.setObject( mSelf, new StdAddressBook );
71#endif //KAB_EMBEDDED 88#endif //KAB_EMBEDDED
72 KStandardDirs::setAppDir( appdir ); 89 KStandardDirs::setAppDir( appdir );
73 } 90 }
74 91
75 return mSelf; 92 return mSelf;
76} 93}
77 94
78QString StdAddressBook::setTempAppDir() 95QString StdAddressBook::setTempAppDir()
79{ 96{
80 QString appDIR = KStandardDirs::appDir(); 97 QString appDIR = KStandardDirs::appDir();
81#ifdef DESKTOP_VERSION 98#ifdef DESKTOP_VERSION
82 QString appdir = QDir::homeDirPath(); 99 QString appdir = QDir::homeDirPath();
83 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) 100 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
84 appdir += "kaddressbook/"; 101 appdir += "kaddressbook/";
85 else 102 else
86 appdir += "/kaddressbook/"; 103 appdir += "/kaddressbook/";
87 KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); 104 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
88#else 105#else
89 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; 106 QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook";
90 107
91 KStandardDirs::setAppDir( appdir ); 108 KStandardDirs::setAppDir( appdir );
92#endif 109#endif
93 110
94 return appDIR; 111 return appDIR;
95} 112}
96StdAddressBook *StdAddressBook::self( bool onlyFastResources ) 113StdAddressBook *StdAddressBook::self( bool onlyFastResources )
97{ 114{
98 115
99 if ( !mSelf ) 116 if ( !mSelf )
100 { 117 {
101 QString appdir =StdAddressBook::setTempAppDir(); 118 QString appdir =StdAddressBook::setTempAppDir();
102#ifdef KAB_EMBEDDED 119#ifdef KAB_EMBEDDED
103 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); 120 mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) );
104#else //KAB_EMBEDDED 121#else //KAB_EMBEDDED
105 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); 122 addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) );
106#endif //KAB_EMBEDDED 123#endif //KAB_EMBEDDED
107 KStandardDirs::setAppDir( appdir ); 124 KStandardDirs::setAppDir( appdir );
108 } 125 }
109 return mSelf; 126 return mSelf;
110} 127}
128StdAddressBook::StdAddressBook( QString )
129 : AddressBook( "kabcrc" )
130{
131
132}
111 133
112StdAddressBook::StdAddressBook() 134StdAddressBook::StdAddressBook()
113 : AddressBook( "kabcrc" ) 135 : AddressBook( "kabcrc" )
114{ 136{
115 137
116 //init( false ); 138 init( false );
117} 139}
118 140
119StdAddressBook::StdAddressBook( bool onlyFastResources ) 141StdAddressBook::StdAddressBook( bool onlyFastResources )
120 : AddressBook( "kabcrc" ) 142 : AddressBook( "kabcrc" )
121{ 143{
122 144
123 if ( onlyFastResources ) 145 init( onlyFastResources );
124 init( onlyFastResources );
125} 146}
126 147
127StdAddressBook::~StdAddressBook() 148StdAddressBook::~StdAddressBook()
128{ 149{
129 if ( mAutomaticSave ) 150 if ( mAutomaticSave )
130 save(); 151 save();
131} 152}
132 153
133void StdAddressBook::init( bool ) 154void StdAddressBook::init( bool )
134{ 155{
135 KRES::Manager<Resource> *manager = resourceManager(); 156 KRES::Manager<Resource> *manager = resourceManager();
136 KRES::Manager<Resource>::ActiveIterator it; 157 KRES::Manager<Resource>::ActiveIterator it;
137 158
138 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 159 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
139 (*it)->setAddressBook( this ); 160 (*it)->setAddressBook( this );
140 if ( !(*it)->open() ) 161 if ( !(*it)->open() )
141 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); 162 error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) );
142 } 163 }
143 164
144 Resource *res = standardResource(); 165 Resource *res = standardResource();
145 if ( !res ) { 166 if ( !res ) {
146 res = manager->createResource( "file" ); 167 res = manager->createResource( "file" );
147 if ( res ) 168 if ( res )
148 { 169 {
149 addResource( res ); 170 addResource( res );
150 } 171 }
151 else 172 else
152 qDebug(" No resource available!!!"); 173 qDebug(" No resource available!!!");
153 } 174 }
154 175
155 setStandardResource( res ); 176 setStandardResource( res );
156 manager->writeConfig(); 177 manager->writeConfig();
157 178
158 load(); 179 load();
159} 180}
160 181
161bool StdAddressBook::save() 182bool StdAddressBook::save()
162{ 183{
163 kdDebug(5700) << "StdAddressBook::save()" << endl; 184 kdDebug(5700) << "StdAddressBook::save()" << endl;
164 185
165 bool ok = true; 186 bool ok = true;
166 AddressBook *ab = self(); 187 AddressBook *ab = self();
167 188
168 ab->deleteRemovedAddressees(); 189 ab->deleteRemovedAddressees();
169 Iterator ait; 190 Iterator ait;
170 for ( ait = ab->begin(); ait != ab->end(); ++ait ) { 191 for ( ait = ab->begin(); ait != ab->end(); ++ait ) {
171 if ( !(*ait).IDStr().isEmpty() ) { 192 if ( !(*ait).IDStr().isEmpty() ) {
172 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() ); 193 (*ait).insertCustom( "KADDRESSBOOK", "X-ExternalID", (*ait).IDStr() );
173 } 194 }
174 } 195 }
175 KRES::Manager<Resource>::ActiveIterator it; 196 KRES::Manager<Resource>::ActiveIterator it;
176 KRES::Manager<Resource> *manager = ab->resourceManager(); 197 KRES::Manager<Resource> *manager = ab->resourceManager();
177 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { 198 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
178 if ( !(*it)->readOnly() && (*it)->isOpen() ) { 199 if ( !(*it)->readOnly() && (*it)->isOpen() ) {
179 Ticket *ticket = ab->requestSaveTicket( *it ); 200 Ticket *ticket = ab->requestSaveTicket( *it );
180// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); 201// qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() );
181 if ( !ticket ) { 202 if ( !ticket ) {
182 ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) 203 ab->error( i18n( "Unable to save to resource '%1'. It is locked." )
183 .arg( (*it)->resourceName() ) ); 204 .arg( (*it)->resourceName() ) );
184 return false; 205 return false;
185 } 206 }
186 207
187 if ( !ab->save( ticket ) ) 208 if ( !ab->save( ticket ) )
188 ok = false; 209 ok = false;
189 } 210 }
190 } 211 }
191 212
192 return ok; 213 return ok;
193} 214}
194 215
195void StdAddressBook::close() 216void StdAddressBook::close()
196{ 217{
197//US destructObject is not defined on my system???. Is setObject(0) the same ??? 218//US destructObject is not defined on my system???. Is setObject(0) the same ???
198//US addressBookDeleter.destructObject(); 219//US addressBookDeleter.destructObject();
199 addressBookDeleter.setObject(0); 220 addressBookDeleter.setObject(0);
200 221
201} 222}
202 223
203void StdAddressBook::setAutomaticSave( bool enable ) 224void StdAddressBook::setAutomaticSave( bool enable )
204{ 225{
205 mAutomaticSave = enable; 226 mAutomaticSave = enable;
206} 227}
207 228
208bool StdAddressBook::automaticSave() 229bool StdAddressBook::automaticSave()
209{ 230{
210 return mAutomaticSave; 231 return mAutomaticSave;
211} 232}
212 233
213// should get const for 4.X 234// should get const for 4.X
214Addressee StdAddressBook::whoAmI() 235Addressee StdAddressBook::whoAmI()
215{ 236{
216//US KConfig config( "kabcrc" ); 237//US KConfig config( "kabcrc" );
217 KConfig config( locateLocal("config", "kabcrc") ); 238 KConfig config( locateLocal("config", "kabcrc") );
218 config.setGroup( "General" ); 239 config.setGroup( "General" );
219 240
220 return findByUid( config.readEntry( "WhoAmI" ) ); 241 return findByUid( config.readEntry( "WhoAmI" ) );
221} 242}
222 243
223void StdAddressBook::setWhoAmI( const Addressee &addr ) 244void StdAddressBook::setWhoAmI( const Addressee &addr )
224{ 245{
225//US KConfig config( "kabcrc" ); 246//US KConfig config( "kabcrc" );
226 KConfig config( locateLocal("config", "kabcrc") ); 247 KConfig config( locateLocal("config", "kabcrc") );
227 config.setGroup( "General" ); 248 config.setGroup( "General" );
228 249
229 config.writeEntry( "WhoAmI", addr.uid() ); 250 config.writeEntry( "WhoAmI", addr.uid() );
230} 251}
diff --git a/kabc/stdaddressbook.h b/kabc/stdaddressbook.h
index cf130b3..3cd6363 100644
--- a/kabc/stdaddressbook.h
+++ b/kabc/stdaddressbook.h
@@ -1,151 +1,153 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#ifndef KABC_STDADDRESSBOOK_H 28#ifndef KABC_STDADDRESSBOOK_H
29#define KABC_STDADDRESSBOOK_H 29#define KABC_STDADDRESSBOOK_H
30 30
31#include "addressbook.h" 31#include "addressbook.h"
32 32
33namespace KABC { 33namespace KABC {
34 34
35/** 35/**
36 Standard KDE address book 36 Standard KDE address book
37 37
38 This class provides access to the standard KDE address book shared by all 38 This class provides access to the standard KDE address book shared by all
39 applications. 39 applications.
40 40
41 It's implemented as a singleton. Use @ref self() to get the address book 41 It's implemented as a singleton. Use @ref self() to get the address book
42 object. On the first self() call the address book also gets loaded. 42 object. On the first self() call the address book also gets loaded.
43 43
44 Example: 44 Example:
45 45
46 <pre> 46 <pre>
47 KABC::AddressBook *ab = KABC::StdAddressBook::self(); 47 KABC::AddressBook *ab = KABC::StdAddressBook::self();
48 48
49 KABC::AddressBook::Iterator it; 49 KABC::AddressBook::Iterator it;
50 for ( it = ab->begin(); it != ab->end(); ++it ) { 50 for ( it = ab->begin(); it != ab->end(); ++it ) {
51 kdDebug() << "UID=" << (*it).uid() << endl; 51 kdDebug() << "UID=" << (*it).uid() << endl;
52 52
53 // do some other stuff 53 // do some other stuff
54 } 54 }
55 55
56 KABC::StdAddressBook::save(); 56 KABC::StdAddressBook::save();
57 </pre> 57 </pre>
58*/ 58*/
59class StdAddressBook : public AddressBook 59class StdAddressBook : public AddressBook
60{ 60{
61 public: 61 public:
62 62
63 /** 63 /**
64 Destructor. 64 Destructor.
65 */ 65 */
66 ~StdAddressBook(); 66 ~StdAddressBook();
67 67
68 /** 68 /**
69 Return the standard addressbook object. It also loads slow resources. 69 Return the standard addressbook object. It also loads slow resources.
70 It is the same as self(false); . 70 It is the same as self(false); .
71 */ 71 */
72 static StdAddressBook *self(); 72 static StdAddressBook *self();
73 static StdAddressBook *selfNoLoad();
73 74
74 /** 75 /**
75 This is the same as above, but with specified 76 This is the same as above, but with specified
76 behaviour of resource loading. 77 behaviour of resource loading.
77 78
78 @param onlyFastResource Only resources marked as 'fast' should be loaded 79 @param onlyFastResource Only resources marked as 'fast' should be loaded
79 */ 80 */
80 // FIXME for KDE4 return StdAddressBook and merge with the metod above -zecke 81 // FIXME for KDE4 return StdAddressBook and merge with the metod above -zecke
81 static StdAddressBook *self( bool onlyFastResources ); 82 static StdAddressBook *self( bool onlyFastResources );
82 83
83 /** 84 /**
84 Save the standard address book to disk. 85 Save the standard address book to disk.
85 */ 86 */
86 static bool save(); 87 static bool save();
87 88
88 /** 89 /**
89 Call this method in your crash handler to allow the library clean up 90 Call this method in your crash handler to allow the library clean up
90 possible locks. 91 possible locks.
91 */ 92 */
92 static void handleCrash(); 93 static void handleCrash();
93 94
94 /** 95 /**
95 Returns the default file name for vcard-based addressbook 96 Returns the default file name for vcard-based addressbook
96 */ 97 */
97 static QString fileName(); 98 static QString fileName();
98 99
99 /** 100 /**
100 Returns the default directory name for vcard-based addressbook 101 Returns the default directory name for vcard-based addressbook
101 */ 102 */
102 static QString directoryName(); 103 static QString directoryName();
103 104
104 /** 105 /**
105 Set the automatic save property of the address book. 106 Set the automatic save property of the address book.
106 If @p enable is TRUE (default) the address book is saved at 107 If @p enable is TRUE (default) the address book is saved at
107 destruction time otherwise you have to call @ref save() to 108 destruction time otherwise you have to call @ref save() to
108 explicitely save it. 109 explicitely save it.
109 */ 110 */
110 static void setAutomaticSave( bool enable ); 111 static void setAutomaticSave( bool enable );
111 112
112 /** 113 /**
113 Closes the address book. Depending on @ref automaticSave() it will 114 Closes the address book. Depending on @ref automaticSave() it will
114 save the address book first. 115 save the address book first.
115 */ 116 */
116 static void close(); 117 static void close();
117 118
118 /** 119 /**
119 Returns whether the address book is saved at destruction time. 120 Returns whether the address book is saved at destruction time.
120 See also @ref setAutomaticSave(). 121 See also @ref setAutomaticSave().
121 */ 122 */
122 static bool automaticSave(); 123 static bool automaticSave();
123 124
124 /** 125 /**
125 Returns the contact, that is associated with the owner of the 126 Returns the contact, that is associated with the owner of the
126 address book. This contact should be used by other programs 127 address book. This contact should be used by other programs
127 to access user specific data. 128 to access user specific data.
128 */ 129 */
129 Addressee whoAmI(); 130 Addressee whoAmI();
130 131
131 /** 132 /**
132 Sets the users contact. See @ref whoAmI() for more information. 133 Sets the users contact. See @ref whoAmI() for more information.
133 134
134 @param uid The uid of the users contact. 135 @param uid The uid of the users contact.
135 */ 136 */
136 void setWhoAmI( const Addressee &addr ); 137 void setWhoAmI( const Addressee &addr );
137 void init( bool onlyFastResources ); 138 void init( bool onlyFastResources );
138 139
139 protected: 140 protected:
140 StdAddressBook(); 141 StdAddressBook();
142 StdAddressBook( QString );
141 StdAddressBook( bool onlyFastResources ); 143 StdAddressBook( bool onlyFastResources );
142 144
143 145
144 private: 146 private:
145 static QString setTempAppDir(); 147 static QString setTempAppDir();
146 static StdAddressBook *mSelf; 148 static StdAddressBook *mSelf;
147 static bool mAutomaticSave; 149 static bool mAutomaticSave;
148}; 150};
149 151
150} 152}
151#endif 153#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index c670b1f..77321aa 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1842 +1,1842 @@
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 Async a special exception, permission is given to link this program 19 Async 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#include <kprefsdialog.h> 99#include <kprefsdialog.h>
100 100
101 101
102//#include <qlabel.h> 102//#include <qlabel.h>
103 103
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 106#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 107#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 108#include <qtopia/qcopenvelope_qws.h>
109#else 109#else
110 110
111#include <qmenubar.h> 111#include <qmenubar.h>
112#endif 112#endif
113 113
114#endif // KAB_EMBEDDED 114#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 115#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 116#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 117#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 118#include "externalapphandler.h"
119#include "xxportselectdialog.h" 119#include "xxportselectdialog.h"
120 120
121 121
122#include <kresources/selectdialog.h> 122#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 123#include <kmessagebox.h>
124 124
125#include <picture.h> 125#include <picture.h>
126#include <resource.h> 126#include <resource.h>
127 127
128//US#include <qsplitter.h> 128//US#include <qsplitter.h>
129#include <qmap.h> 129#include <qmap.h>
130#include <qdir.h> 130#include <qdir.h>
131#include <qfile.h> 131#include <qfile.h>
132#include <qvbox.h> 132#include <qvbox.h>
133#include <qlayout.h> 133#include <qlayout.h>
134#include <qclipboard.h> 134#include <qclipboard.h>
135#include <qtextstream.h> 135#include <qtextstream.h>
136#include <qradiobutton.h> 136#include <qradiobutton.h>
137#include <qbuttongroup.h> 137#include <qbuttongroup.h>
138 138
139#include <libkdepim/categoryselectdialog.h> 139#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 140#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 141#include <kabc/vcardconverter.h>
142 142
143 143
144#include "addresseeutil.h" 144#include "addresseeutil.h"
145#include "undocmds.h" 145#include "undocmds.h"
146#include "addresseeeditordialog.h" 146#include "addresseeeditordialog.h"
147#include "viewmanager.h" 147#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 148#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#endif 161#endif
162#else 162#else
163#include <unistd.h> 163#include <unistd.h>
164#endif 164#endif
165// sync includes 165// sync includes
166#include <libkdepim/ksyncprofile.h> 166#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 167#include <libkdepim/ksyncprefsdialog.h>
168 168
169 169
170class KABCatPrefs : public QDialog 170class KABCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from addressees"), format ); 186 new QRadioButton(i18n("Remove from addressees"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202class KABFormatPrefs : public QDialog 202class KABFormatPrefs : public QDialog
203{ 203{
204 public: 204 public:
205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
206 QDialog( parent, name, true ) 206 QDialog( parent, name, true )
207 { 207 {
208 setCaption( i18n("Set formatted name") ); 208 setCaption( i18n("Set formatted name") );
209 QVBoxLayout* lay = new QVBoxLayout( this ); 209 QVBoxLayout* lay = new QVBoxLayout( this );
210 lay->setSpacing( 3 ); 210 lay->setSpacing( 3 );
211 lay->setMargin( 3 ); 211 lay->setMargin( 3 );
212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
213 lay->addWidget( lab ); 213 lay->addWidget( lab );
214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
215 lay->addWidget( format ); 215 lay->addWidget( format );
216 format->setExclusive ( true ) ; 216 format->setExclusive ( true ) ;
217 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 217 simple = new QRadioButton(i18n("Simple: James Bond"), format );
218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
220 company = new QRadioButton(i18n("Organization: MI6"), format ); 220 company = new QRadioButton(i18n("Organization: MI6"), format );
221 simple->setChecked( true ); 221 simple->setChecked( true );
222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
223 lay->addWidget( setCompany ); 223 lay->addWidget( setCompany );
224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
225 lay->addWidget( ok ); 225 lay->addWidget( ok );
226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
227 lay->addWidget( cancel ); 227 lay->addWidget( cancel );
228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
230 //resize( 200, 200 ); 230 //resize( 200, 200 );
231 231
232 } 232 }
233public: 233public:
234 QRadioButton* simple, *full, *reverse, *company; 234 QRadioButton* simple, *full, *reverse, *company;
235 QCheckBox* setCompany; 235 QCheckBox* setCompany;
236}; 236};
237 237
238 238
239 239
240class KAex2phonePrefs : public QDialog 240class KAex2phonePrefs : public QDialog
241{ 241{
242 public: 242 public:
243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
244 QDialog( parent, name, true ) 244 QDialog( parent, name, true )
245 { 245 {
246 setCaption( i18n("Export to phone options") ); 246 setCaption( i18n("Export to phone options") );
247 QVBoxLayout* lay = new QVBoxLayout( this ); 247 QVBoxLayout* lay = new QVBoxLayout( this );
248 lay->setSpacing( 3 ); 248 lay->setSpacing( 3 );
249 lay->setMargin( 3 ); 249 lay->setMargin( 3 );
250 QLabel *lab; 250 QLabel *lab;
251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
252 lab->setAlignment (AlignHCenter ); 252 lab->setAlignment (AlignHCenter );
253 QHBox* temphb; 253 QHBox* temphb;
254 temphb = new QHBox( this ); 254 temphb = new QHBox( this );
255 new QLabel( i18n("I/O device: "), temphb ); 255 new QLabel( i18n("I/O device: "), temphb );
256 mPhoneDevice = new QLineEdit( temphb); 256 mPhoneDevice = new QLineEdit( temphb);
257 lay->addWidget( temphb ); 257 lay->addWidget( temphb );
258 temphb = new QHBox( this ); 258 temphb = new QHBox( this );
259 new QLabel( i18n("Connection: "), temphb ); 259 new QLabel( i18n("Connection: "), temphb );
260 mPhoneConnection = new QLineEdit( temphb); 260 mPhoneConnection = new QLineEdit( temphb);
261 lay->addWidget( temphb ); 261 lay->addWidget( temphb );
262 temphb = new QHBox( this ); 262 temphb = new QHBox( this );
263 new QLabel( i18n("Model(opt.): "), temphb ); 263 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 264 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 265 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 267 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 269 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 271 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 273 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 276 resize( 220, 240 );
277 277
278 } 278 }
279 279
280public: 280public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 282 QCheckBox* mWriteToSim;
283}; 283};
284 284
285 285
286bool pasteWithNewUid = true; 286bool pasteWithNewUid = true;
287 287
288#ifdef KAB_EMBEDDED 288#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 293#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 297 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299{ 299{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 301 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 302 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 303 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 304 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 305 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::self(); 306 mAddressBook = KABC::StdAddressBook::selfNoLoad();
307 KABC::StdAddressBook::setAutomaticSave( false ); 307 KABC::StdAddressBook::setAutomaticSave( false );
308 308
309#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
312 312
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 314 SLOT( addressBookChanged() ) );
315 315
316#if 0 316#if 0
317 // LR moved to addressbook init method 317 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 319 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 321 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 323 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 325 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 327 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 329 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 331 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 333 "X-Anniversary", "KADDRESSBOOK" );
334 334
335 //US added this field to become compatible with Opie/qtopia addressbook 335 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 336 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 338 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 340 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 342 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 343#endif
344 initGUI(); 344 initGUI();
345 345
346 mIncSearchWidget->setFocus(); 346 mIncSearchWidget->setFocus();
347 347
348 348
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 349 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 350 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 351 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 352 SLOT( executeContact( const QString& ) ) );
353 353
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 354 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 355 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 356 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 357 SLOT( setModified() ) );
358 358
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 361
362 connect( mXXPortManager, SIGNAL( modified() ), 362 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 363 SLOT( setModified() ) );
364 364
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 366 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 368 mJumpButtonBar, SLOT( recreateButtons() ) );
369 369
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 371 SLOT( sendMail( const QString& ) ) );
372 372
373 373
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 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&))); 375 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&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 380
381 381
382#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 384 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 385
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 386 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 387 SLOT( browse( const QString& ) ) );
388 388
389 389
390 mAddressBookService = new KAddressBookService( this ); 390 mAddressBookService = new KAddressBookService( this );
391 391
392#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
393 393
394 mMessageTimer = new QTimer( this ); 394 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 396 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 397 createAddresseeEditorDialog( this );
398 setModified( false ); 398 setModified( false );
399 mBRdisabled = false; 399 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 infrared = 0; 401 infrared = 0;
402#endif 402#endif
403 //toggleBeamReceive( ); 403 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 404 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); 407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() ));
408} 408}
409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) 409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data )
410{ 410{
411 qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 411 qDebug("KO: QCOP start message received: %s ", cmsg.data() );
412 mCStringMess = cmsg; 412 mCStringMess = cmsg;
413 mByteData = data; 413 mByteData = data;
414} 414}
415 415
416void KABCore::loadDataAfterStart() 416void KABCore::loadDataAfterStart()
417{ 417{
418 qDebug("KABCore::loadDataAfterStart() "); 418 qDebug("KABCore::loadDataAfterStart() ");
419 ((StdAddressBook*)mAddressBook)->init( true ); 419 ((StdAddressBook*)mAddressBook)->init( true );
420 mViewManager->refreshView(); 420 mViewManager->refreshView();
421 421
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & )));
424 424
425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
426 if ( !mCStringMess.isEmpty() ) 426 if ( !mCStringMess.isEmpty() )
427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); 427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData );
428#endif 428#endif
429 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 429 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
430 setCaptionBack(); 430 setCaptionBack();
431} 431}
432void KABCore::updateToolBar() 432void KABCore::updateToolBar()
433{ 433{
434 static int iii = 0; 434 static int iii = 0;
435 ++iii; 435 ++iii;
436 mMainWindow->toolBar()->repaintMe(); 436 mMainWindow->toolBar()->repaintMe();
437 if ( iii < 4 ) 437 if ( iii < 4 )
438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
439} 439}
440KABCore::~KABCore() 440KABCore::~KABCore()
441{ 441{
442 // save(); 442 // save();
443 //saveSettings(); 443 //saveSettings();
444 //KABPrefs::instance()->writeConfig(); 444 //KABPrefs::instance()->writeConfig();
445 delete AddresseeConfig::instance(); 445 delete AddresseeConfig::instance();
446 mAddressBook = 0; 446 mAddressBook = 0;
447 KABC::StdAddressBook::close(); 447 KABC::StdAddressBook::close();
448 448
449 delete syncManager; 449 delete syncManager;
450#ifndef DESKTOP_VERSION 450#ifndef DESKTOP_VERSION
451 if ( infrared ) 451 if ( infrared )
452 delete infrared; 452 delete infrared;
453#endif 453#endif
454} 454}
455void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 455void KABCore::receive( const QCString& cmsg, const QByteArray& data )
456{ 456{
457 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 457 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
458 if ( cmsg == "setDocument(QString)" ) { 458 if ( cmsg == "setDocument(QString)" ) {
459 QDataStream stream( data, IO_ReadOnly ); 459 QDataStream stream( data, IO_ReadOnly );
460 QString fileName; 460 QString fileName;
461 stream >> fileName; 461 stream >> fileName;
462 recieve( fileName ); 462 recieve( fileName );
463 return; 463 return;
464 } 464 }
465} 465}
466void KABCore::toggleBeamReceive( ) 466void KABCore::toggleBeamReceive( )
467{ 467{
468 if ( mBRdisabled ) 468 if ( mBRdisabled )
469 return; 469 return;
470#ifndef DESKTOP_VERSION 470#ifndef DESKTOP_VERSION
471 if ( infrared ) { 471 if ( infrared ) {
472 qDebug("KA: AB disable BeamReceive "); 472 qDebug("KA: AB disable BeamReceive ");
473 delete infrared; 473 delete infrared;
474 infrared = 0; 474 infrared = 0;
475 mActionBR->setChecked(false); 475 mActionBR->setChecked(false);
476 return; 476 return;
477 } 477 }
478 qDebug("KA: AB enable BeamReceive "); 478 qDebug("KA: AB enable BeamReceive ");
479 mActionBR->setChecked(true); 479 mActionBR->setChecked(true);
480 480
481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
483#endif 483#endif
484} 484}
485 485
486 486
487void KABCore::disableBR(bool b) 487void KABCore::disableBR(bool b)
488{ 488{
489#ifndef DESKTOP_VERSION 489#ifndef DESKTOP_VERSION
490 if ( b ) { 490 if ( b ) {
491 if ( infrared ) { 491 if ( infrared ) {
492 toggleBeamReceive( ); 492 toggleBeamReceive( );
493 } 493 }
494 mBRdisabled = true; 494 mBRdisabled = true;
495 } else { 495 } else {
496 if ( mBRdisabled ) { 496 if ( mBRdisabled ) {
497 mBRdisabled = false; 497 mBRdisabled = false;
498 //toggleBeamReceive( ); 498 //toggleBeamReceive( );
499 } 499 }
500 } 500 }
501#endif 501#endif
502 502
503} 503}
504void KABCore::recieve( QString fn ) 504void KABCore::recieve( QString fn )
505{ 505{
506 //qDebug("KABCore::recieve "); 506 //qDebug("KABCore::recieve ");
507 int count = mAddressBook->importFromFile( fn, true ); 507 int count = mAddressBook->importFromFile( fn, true );
508 if ( count ) 508 if ( count )
509 setModified( true ); 509 setModified( true );
510 mViewManager->refreshView(); 510 mViewManager->refreshView();
511 message(i18n("%1 contact(s) received!").arg( count )); 511 message(i18n("%1 contact(s) received!").arg( count ));
512 topLevelWidget()->showMaximized(); 512 topLevelWidget()->showMaximized();
513 topLevelWidget()->raise(); 513 topLevelWidget()->raise();
514} 514}
515void KABCore::restoreSettings() 515void KABCore::restoreSettings()
516{ 516{
517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
518 518
519 bool state; 519 bool state;
520 520
521 if (mMultipleViewsAtOnce) 521 if (mMultipleViewsAtOnce)
522 state = KABPrefs::instance()->mDetailsPageVisible; 522 state = KABPrefs::instance()->mDetailsPageVisible;
523 else 523 else
524 state = false; 524 state = false;
525 525
526 mActionDetails->setChecked( state ); 526 mActionDetails->setChecked( state );
527 setDetailsVisible( state ); 527 setDetailsVisible( state );
528 528
529 state = KABPrefs::instance()->mJumpButtonBarVisible; 529 state = KABPrefs::instance()->mJumpButtonBarVisible;
530 530
531 mActionJumpBar->setChecked( state ); 531 mActionJumpBar->setChecked( state );
532 setJumpButtonBarVisible( state ); 532 setJumpButtonBarVisible( state );
533/*US 533/*US
534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
535 if ( splitterSize.count() == 0 ) { 535 if ( splitterSize.count() == 0 ) {
536 splitterSize.append( width() / 2 ); 536 splitterSize.append( width() / 2 );
537 splitterSize.append( width() / 2 ); 537 splitterSize.append( width() / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( splitterSize.count() == 0 ) { 542 if ( splitterSize.count() == 0 ) {
543 splitterSize.append( width() / 2 ); 543 splitterSize.append( width() / 2 );
544 splitterSize.append( width() / 2 ); 544 splitterSize.append( width() / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549*/ 549*/
550 mViewManager->restoreSettings(); 550 mViewManager->restoreSettings();
551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
552 mExtensionManager->restoreSettings(); 552 mExtensionManager->restoreSettings();
553#ifdef DESKTOP_VERSION 553#ifdef DESKTOP_VERSION
554 int wid = width(); 554 int wid = width();
555 if ( wid < 10 ) 555 if ( wid < 10 )
556 wid = 400; 556 wid = 400;
557#else 557#else
558 int wid = QApplication::desktop()->width(); 558 int wid = QApplication::desktop()->width();
559 if ( wid < 640 ) 559 if ( wid < 640 )
560 wid = QApplication::desktop()->height(); 560 wid = QApplication::desktop()->height();
561#endif 561#endif
562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
563 if ( true /*splitterSize.count() == 0*/ ) { 563 if ( true /*splitterSize.count() == 0*/ ) {
564 splitterSize.append( wid / 2 ); 564 splitterSize.append( wid / 2 );
565 splitterSize.append( wid / 2 ); 565 splitterSize.append( wid / 2 );
566 } 566 }
567 mMiniSplitter->setSizes( splitterSize ); 567 mMiniSplitter->setSizes( splitterSize );
568 if ( mExtensionBarSplitter ) { 568 if ( mExtensionBarSplitter ) {
569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
570 if ( true /*splitterSize.count() == 0*/ ) { 570 if ( true /*splitterSize.count() == 0*/ ) {
571 splitterSize.append( wid / 2 ); 571 splitterSize.append( wid / 2 );
572 splitterSize.append( wid / 2 ); 572 splitterSize.append( wid / 2 );
573 } 573 }
574 mExtensionBarSplitter->setSizes( splitterSize ); 574 mExtensionBarSplitter->setSizes( splitterSize );
575 575
576 } 576 }
577#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
578 KConfig *config = KABPrefs::instance()->getConfig(); 578 KConfig *config = KABPrefs::instance()->getConfig();
579 config->setGroup("WidgetLayout"); 579 config->setGroup("WidgetLayout");
580 QStringList list; 580 QStringList list;
581 list = config->readListEntry("MainLayout"); 581 list = config->readListEntry("MainLayout");
582 int x,y,w,h; 582 int x,y,w,h;
583 if ( ! list.isEmpty() ) { 583 if ( ! list.isEmpty() ) {
584 x = list[0].toInt(); 584 x = list[0].toInt();
585 y = list[1].toInt(); 585 y = list[1].toInt();
586 w = list[2].toInt(); 586 w = list[2].toInt();
587 h = list[3].toInt(); 587 h = list[3].toInt();
588 KApplication::testCoords( &x,&y,&w,&h ); 588 KApplication::testCoords( &x,&y,&w,&h );
589 topLevelWidget()->setGeometry(x,y,w,h); 589 topLevelWidget()->setGeometry(x,y,w,h);
590 590
591 } else { 591 } else {
592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
593 } 593 }
594#endif 594#endif
595} 595}
596 596
597void KABCore::saveSettings() 597void KABCore::saveSettings()
598{ 598{
599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
600 if ( mExtensionBarSplitter ) 600 if ( mExtensionBarSplitter )
601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
604#ifndef KAB_EMBEDDED 604#ifndef KAB_EMBEDDED
605 605
606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
608#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
609 mExtensionManager->saveSettings(); 609 mExtensionManager->saveSettings();
610 mViewManager->saveSettings(); 610 mViewManager->saveSettings();
611 611
612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
613 613
614 KABPrefs::instance()->writeConfig(); 614 KABPrefs::instance()->writeConfig();
615 qDebug("KA: KABCore::saveSettings() "); 615 qDebug("KA: KABCore::saveSettings() ");
616} 616}
617 617
618KABC::AddressBook *KABCore::addressBook() const 618KABC::AddressBook *KABCore::addressBook() const
619{ 619{
620 return mAddressBook; 620 return mAddressBook;
621} 621}
622 622
623KConfig *KABCore::config() 623KConfig *KABCore::config()
624{ 624{
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626 return KABPrefs::instance()->config(); 626 return KABPrefs::instance()->config();
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628 return KABPrefs::instance()->getConfig(); 628 return KABPrefs::instance()->getConfig();
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630} 630}
631 631
632KActionCollection *KABCore::actionCollection() const 632KActionCollection *KABCore::actionCollection() const
633{ 633{
634 return mGUIClient->actionCollection(); 634 return mGUIClient->actionCollection();
635} 635}
636 636
637KABC::Field *KABCore::currentSearchField() const 637KABC::Field *KABCore::currentSearchField() const
638{ 638{
639 if (mIncSearchWidget) 639 if (mIncSearchWidget)
640 return mIncSearchWidget->currentField(); 640 return mIncSearchWidget->currentField();
641 else 641 else
642 return 0; 642 return 0;
643} 643}
644 644
645QStringList KABCore::selectedUIDs() const 645QStringList KABCore::selectedUIDs() const
646{ 646{
647 return mViewManager->selectedUids(); 647 return mViewManager->selectedUids();
648} 648}
649 649
650KABC::Resource *KABCore::requestResource( QWidget *parent ) 650KABC::Resource *KABCore::requestResource( QWidget *parent )
651{ 651{
652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
653 653
654 QPtrList<KRES::Resource> kresResources; 654 QPtrList<KRES::Resource> kresResources;
655 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 655 QPtrListIterator<KABC::Resource> resIt( kabcResources );
656 KABC::Resource *resource; 656 KABC::Resource *resource;
657 while ( ( resource = resIt.current() ) != 0 ) { 657 while ( ( resource = resIt.current() ) != 0 ) {
658 ++resIt; 658 ++resIt;
659 if ( !resource->readOnly() ) { 659 if ( !resource->readOnly() ) {
660 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 660 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
661 if ( res ) 661 if ( res )
662 kresResources.append( res ); 662 kresResources.append( res );
663 } 663 }
664 } 664 }
665 665
666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
667 return static_cast<KABC::Resource*>( res ); 667 return static_cast<KABC::Resource*>( res );
668} 668}
669 669
670#ifndef KAB_EMBEDDED 670#ifndef KAB_EMBEDDED
671KAboutData *KABCore::createAboutData() 671KAboutData *KABCore::createAboutData()
672#else //KAB_EMBEDDED 672#else //KAB_EMBEDDED
673void KABCore::createAboutData() 673void KABCore::createAboutData()
674#endif //KAB_EMBEDDED 674#endif //KAB_EMBEDDED
675{ 675{
676 676
677 677
678 QString version; 678 QString version;
679#include <../version> 679#include <../version>
680 QMessageBox::about( this, "About KAddressbook/Pi", 680 QMessageBox::about( this, "About KAddressbook/Pi",
681 "KAddressbook/Platform-independent\n" 681 "KAddressbook/Platform-independent\n"
682 "(KA/Pi) " +version + " - " + 682 "(KA/Pi) " +version + " - " +
683#ifdef DESKTOP_VERSION 683#ifdef DESKTOP_VERSION
684 "Desktop Edition\n" 684 "Desktop Edition\n"
685#else 685#else
686 "PDA-Edition\n" 686 "PDA-Edition\n"
687 "for: Zaurus 5500 / 7x0 / 8x0\n" 687 "for: Zaurus 5500 / 7x0 / 8x0\n"
688#endif 688#endif
689 689
690 "(c) 2004 Ulf Schenk\n" 690 "(c) 2004 Ulf Schenk\n"
691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
692 "(c) 1997-2003, The KDE PIM Team\n" 692 "(c) 1997-2003, The KDE PIM Team\n"
693 "Tobias Koenig Maintainer\n" 693 "Tobias Koenig Maintainer\n"
694 "Don Sanders Original author\n" 694 "Don Sanders Original author\n"
695 "Cornelius Schumacher Co-maintainer\n" 695 "Cornelius Schumacher Co-maintainer\n"
696 "Mike Pilone GUI and framework redesign\n" 696 "Mike Pilone GUI and framework redesign\n"
697 "Greg Stern DCOP interface\n" 697 "Greg Stern DCOP interface\n"
698 "Mark Westcot Contact pinning\n" 698 "Mark Westcot Contact pinning\n"
699 "Michel Boyer de la Giroday LDAP Lookup\n" 699 "Michel Boyer de la Giroday LDAP Lookup\n"
700 "Steffen Hansen LDAP Lookup" 700 "Steffen Hansen LDAP Lookup"
701#ifdef _WIN32_ 701#ifdef _WIN32_
702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
703#endif 703#endif
704 ); 704 );
705} 705}
706 706
707void KABCore::setContactSelected( const QString &uid ) 707void KABCore::setContactSelected( const QString &uid )
708{ 708{
709 KABC::Addressee addr = mAddressBook->findByUid( uid ); 709 KABC::Addressee addr = mAddressBook->findByUid( uid );
710 if ( !mDetails->isHidden() ) 710 if ( !mDetails->isHidden() )
711 mDetails->setAddressee( addr ); 711 mDetails->setAddressee( addr );
712 712
713 if ( !addr.isEmpty() ) { 713 if ( !addr.isEmpty() ) {
714 emit contactSelected( addr.formattedName() ); 714 emit contactSelected( addr.formattedName() );
715 KABC::Picture pic = addr.photo(); 715 KABC::Picture pic = addr.photo();
716 if ( pic.isIntern() ) { 716 if ( pic.isIntern() ) {
717//US emit contactSelected( pic.data() ); 717//US emit contactSelected( pic.data() );
718//US instead use: 718//US instead use:
719 QPixmap px; 719 QPixmap px;
720 if (pic.data().isNull() != true) 720 if (pic.data().isNull() != true)
721 { 721 {
722 px.convertFromImage(pic.data()); 722 px.convertFromImage(pic.data());
723 } 723 }
724 724
725 emit contactSelected( px ); 725 emit contactSelected( px );
726 } 726 }
727 } 727 }
728 728
729 729
730 mExtensionManager->setSelectionChanged(); 730 mExtensionManager->setSelectionChanged();
731 731
732 // update the actions 732 // update the actions
733 bool selected = !uid.isEmpty(); 733 bool selected = !uid.isEmpty();
734 734
735 if ( mReadWrite ) { 735 if ( mReadWrite ) {
736 mActionCut->setEnabled( selected ); 736 mActionCut->setEnabled( selected );
737 mActionPaste->setEnabled( selected ); 737 mActionPaste->setEnabled( selected );
738 } 738 }
739 739
740 mActionCopy->setEnabled( selected ); 740 mActionCopy->setEnabled( selected );
741 mActionDelete->setEnabled( selected ); 741 mActionDelete->setEnabled( selected );
742 mActionEditAddressee->setEnabled( selected ); 742 mActionEditAddressee->setEnabled( selected );
743 mActionMail->setEnabled( selected ); 743 mActionMail->setEnabled( selected );
744 mActionMailVCard->setEnabled( selected ); 744 mActionMailVCard->setEnabled( selected );
745 //if (mActionBeam) 745 //if (mActionBeam)
746 //mActionBeam->setEnabled( selected ); 746 //mActionBeam->setEnabled( selected );
747 mActionWhoAmI->setEnabled( selected ); 747 mActionWhoAmI->setEnabled( selected );
748} 748}
749 749
750void KABCore::sendMail() 750void KABCore::sendMail()
751{ 751{
752 sendMail( mViewManager->selectedEmails().join( ", " ) ); 752 sendMail( mViewManager->selectedEmails().join( ", " ) );
753} 753}
754 754
755void KABCore::sendMail( const QString& emaillist ) 755void KABCore::sendMail( const QString& emaillist )
756{ 756{
757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
758 if (emaillist.contains(",") > 0) 758 if (emaillist.contains(",") > 0)
759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
760 else 760 else
761 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 761 ExternalAppHandler::instance()->mailToOneContact( emaillist );
762} 762}
763 763
764 764
765 765
766void KABCore::mailVCard() 766void KABCore::mailVCard()
767{ 767{
768 QStringList uids = mViewManager->selectedUids(); 768 QStringList uids = mViewManager->selectedUids();
769 if ( !uids.isEmpty() ) 769 if ( !uids.isEmpty() )
770 mailVCard( uids ); 770 mailVCard( uids );
771} 771}
772 772
773void KABCore::mailVCard( const QStringList& uids ) 773void KABCore::mailVCard( const QStringList& uids )
774{ 774{
775 QStringList urls; 775 QStringList urls;
776 776
777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
778 778
779 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 779 QString dirName = "/tmp/" + KApplication::randomString( 8 );
780 780
781 781
782 782
783 QDir().mkdir( dirName, true ); 783 QDir().mkdir( dirName, true );
784 784
785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
786 KABC::Addressee a = mAddressBook->findByUid( *it ); 786 KABC::Addressee a = mAddressBook->findByUid( *it );
787 787
788 if ( a.isEmpty() ) 788 if ( a.isEmpty() )
789 continue; 789 continue;
790 790
791 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 791 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
792 792
793 QString fileName = dirName + "/" + name; 793 QString fileName = dirName + "/" + name;
794 794
795 QFile outFile(fileName); 795 QFile outFile(fileName);
796 796
797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
798 KABC::VCardConverter converter; 798 KABC::VCardConverter converter;
799 QString vcard; 799 QString vcard;
800 800
801 converter.addresseeToVCard( a, vcard ); 801 converter.addresseeToVCard( a, vcard );
802 802
803 QTextStream t( &outFile ); // use a text stream 803 QTextStream t( &outFile ); // use a text stream
804 t.setEncoding( QTextStream::UnicodeUTF8 ); 804 t.setEncoding( QTextStream::UnicodeUTF8 );
805 t << vcard; 805 t << vcard;
806 806
807 outFile.close(); 807 outFile.close();
808 808
809 urls.append( fileName ); 809 urls.append( fileName );
810 } 810 }
811 } 811 }
812 812
813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
814 814
815 815
816/*US 816/*US
817 kapp->invokeMailer( QString::null, QString::null, QString::null, 817 kapp->invokeMailer( QString::null, QString::null, QString::null,
818 QString::null, // subject 818 QString::null, // subject
819 QString::null, // body 819 QString::null, // body
820 QString::null, 820 QString::null,
821 urls ); // attachments 821 urls ); // attachments
822*/ 822*/
823 823
824} 824}
825 825
826/** 826/**
827 Beams the "WhoAmI contact. 827 Beams the "WhoAmI contact.
828*/ 828*/
829void KABCore::beamMySelf() 829void KABCore::beamMySelf()
830{ 830{
831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
832 if (!a.isEmpty()) 832 if (!a.isEmpty())
833 { 833 {
834 QStringList uids; 834 QStringList uids;
835 uids << a.uid(); 835 uids << a.uid();
836 836
837 beamVCard(uids); 837 beamVCard(uids);
838 } else { 838 } else {
839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
840 840
841 841
842 } 842 }
843} 843}
844void KABCore::updateMainWindow() 844void KABCore::updateMainWindow()
845{ 845{
846 mMainWindow->showMaximized(); 846 mMainWindow->showMaximized();
847 mMainWindow->update(); 847 mMainWindow->update();
848} 848}
849void KABCore::resizeEvent(QResizeEvent* e ) 849void KABCore::resizeEvent(QResizeEvent* e )
850{ 850{
851 if ( !mMiniSplitter ) 851 if ( !mMiniSplitter )
852 return; 852 return;
853 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 853 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
854 if ( e->oldSize().width() != e->size().width() ) 854 if ( e->oldSize().width() != e->size().width() )
855 if ( QApplication::desktop()->width() >= 480 ) { 855 if ( QApplication::desktop()->width() >= 480 ) {
856 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 856 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
857 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 857 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
858 mMiniSplitter->setOrientation( Qt::Horizontal); 858 mMiniSplitter->setOrientation( Qt::Horizontal);
859 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 859 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
860 } 860 }
861 if ( QApplication::desktop()->width() <= 640 ) { 861 if ( QApplication::desktop()->width() <= 640 ) {
862 mMainWindow->showMinimized(); 862 mMainWindow->showMinimized();
863 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 863 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
864 mViewManager->getFilterAction()->setComboWidth( 150 ); 864 mViewManager->getFilterAction()->setComboWidth( 150 );
865 if ( mIncSearchWidget ) 865 if ( mIncSearchWidget )
866 mIncSearchWidget->setSize(); 866 mIncSearchWidget->setSize();
867 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 867 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
868 } 868 }
869 869
870 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 870 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
871 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 871 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
872 mMiniSplitter->setOrientation( Qt::Vertical ); 872 mMiniSplitter->setOrientation( Qt::Vertical );
873 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 873 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
874 } 874 }
875 if ( QApplication::desktop()->width() <= 640 ) { 875 if ( QApplication::desktop()->width() <= 640 ) {
876 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 876 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
877 mMainWindow->showMinimized(); 877 mMainWindow->showMinimized();
878 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 878 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
879 if ( mIncSearchWidget ) { 879 if ( mIncSearchWidget ) {
880 mIncSearchWidget->setSize(); 880 mIncSearchWidget->setSize();
881 } 881 }
882 } else { 882 } else {
883 mViewManager->getFilterAction()->setComboWidth( 0 ); 883 mViewManager->getFilterAction()->setComboWidth( 0 );
884 } 884 }
885 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 885 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
886 } 886 }
887 } 887 }
888 } 888 }
889 QWidget::resizeEvent( e ); 889 QWidget::resizeEvent( e );
890 890
891} 891}
892void KABCore::export2phone() 892void KABCore::export2phone()
893{ 893{
894 894
895 QStringList uids; 895 QStringList uids;
896 XXPortSelectDialog dlg( this, false, this ); 896 XXPortSelectDialog dlg( this, false, this );
897 if ( dlg.exec() ) 897 if ( dlg.exec() )
898 uids = dlg.uids(); 898 uids = dlg.uids();
899 else 899 else
900 return; 900 return;
901 if ( uids.isEmpty() ) 901 if ( uids.isEmpty() )
902 return; 902 return;
903 // qDebug("count %d ", uids.count()); 903 // qDebug("count %d ", uids.count());
904 904
905 KAex2phonePrefs ex2phone; 905 KAex2phonePrefs ex2phone;
906 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 906 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
907 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 907 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
908 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 908 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
909 909
910 if ( !ex2phone.exec() ) { 910 if ( !ex2phone.exec() ) {
911 return; 911 return;
912 } 912 }
913 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 913 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
914 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 914 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
915 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 915 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
916 916
917 917
918 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 918 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
919 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 919 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
920 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 920 KPimGlobalPrefs::instance()->mEx2PhoneModel );
921 921
922 QString fileName = getPhoneFile(); 922 QString fileName = getPhoneFile();
923 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 923 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
924 return; 924 return;
925 925
926 message(i18n("Exporting to phone...")); 926 message(i18n("Exporting to phone..."));
927 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 927 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
928 928
929} 929}
930QString KABCore::getPhoneFile() 930QString KABCore::getPhoneFile()
931{ 931{
932#ifdef DESKTOP_VERSION 932#ifdef DESKTOP_VERSION
933 return locateLocal("tmp", "phonefile.vcf"); 933 return locateLocal("tmp", "phonefile.vcf");
934#else 934#else
935 return "/tmp/phonefile.vcf"; 935 return "/tmp/phonefile.vcf";
936#endif 936#endif
937 937
938} 938}
939void KABCore::writeToPhone( ) 939void KABCore::writeToPhone( )
940{ 940{
941 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 941 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
942 message(i18n("Export to phone finished!")); 942 message(i18n("Export to phone finished!"));
943 else 943 else
944 qDebug(i18n("KA: Error exporting to phone")); 944 qDebug(i18n("KA: Error exporting to phone"));
945} 945}
946void KABCore::beamVCard() 946void KABCore::beamVCard()
947{ 947{
948 QStringList uids; 948 QStringList uids;
949 XXPortSelectDialog dlg( this, false, this ); 949 XXPortSelectDialog dlg( this, false, this );
950 if ( dlg.exec() ) 950 if ( dlg.exec() )
951 uids = dlg.uids(); 951 uids = dlg.uids();
952 else 952 else
953 return; 953 return;
954 if ( uids.isEmpty() ) 954 if ( uids.isEmpty() )
955 return; 955 return;
956 beamVCard( uids ); 956 beamVCard( uids );
957} 957}
958 958
959 959
960void KABCore::beamVCard(const QStringList& uids) 960void KABCore::beamVCard(const QStringList& uids)
961{ 961{
962 962
963 // LR: we should use the /tmp dir on the Zaurus, 963 // LR: we should use the /tmp dir on the Zaurus,
964 // because: /tmp = RAM, (HOME)/kdepim = flash memory 964 // because: /tmp = RAM, (HOME)/kdepim = flash memory
965 965
966#ifdef DESKTOP_VERSION 966#ifdef DESKTOP_VERSION
967 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 967 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
968#else 968#else
969 QString fileName = "/tmp/kapibeamfile.vcf"; 969 QString fileName = "/tmp/kapibeamfile.vcf";
970#endif 970#endif
971 971
972 KABC::VCardConverter converter; 972 KABC::VCardConverter converter;
973 QString description; 973 QString description;
974 QString datastream; 974 QString datastream;
975 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 975 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
976 KABC::Addressee a = mAddressBook->findByUid( *it ); 976 KABC::Addressee a = mAddressBook->findByUid( *it );
977 977
978 if ( a.isEmpty() ) 978 if ( a.isEmpty() )
979 continue; 979 continue;
980 980
981 if (description.isEmpty()) 981 if (description.isEmpty())
982 description = a.formattedName(); 982 description = a.formattedName();
983 983
984 QString vcard; 984 QString vcard;
985 converter.addresseeToVCard( a, vcard ); 985 converter.addresseeToVCard( a, vcard );
986 int start = 0; 986 int start = 0;
987 int next; 987 int next;
988 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 988 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
989 int semi = vcard.find(";", next); 989 int semi = vcard.find(";", next);
990 int dopp = vcard.find(":", next); 990 int dopp = vcard.find(":", next);
991 int sep; 991 int sep;
992 if ( semi < dopp && semi >= 0 ) 992 if ( semi < dopp && semi >= 0 )
993 sep = semi ; 993 sep = semi ;
994 else 994 else
995 sep = dopp; 995 sep = dopp;
996 datastream +=vcard.mid( start, next - start); 996 datastream +=vcard.mid( start, next - start);
997 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 997 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
998 start = sep; 998 start = sep;
999 } 999 }
1000 datastream += vcard.mid( start,vcard.length() ); 1000 datastream += vcard.mid( start,vcard.length() );
1001 } 1001 }
1002#ifndef DESKTOP_VERSION 1002#ifndef DESKTOP_VERSION
1003 QFile outFile(fileName); 1003 QFile outFile(fileName);
1004 if ( outFile.open(IO_WriteOnly) ) { 1004 if ( outFile.open(IO_WriteOnly) ) {
1005 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1005 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1006 QTextStream t( &outFile ); // use a text stream 1006 QTextStream t( &outFile ); // use a text stream
1007 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1007 //t.setEncoding( QTextStream::UnicodeUTF8 );
1008 t.setEncoding( QTextStream::Latin1 ); 1008 t.setEncoding( QTextStream::Latin1 );
1009 t <<datastream.latin1(); 1009 t <<datastream.latin1();
1010 outFile.close(); 1010 outFile.close();
1011 Ir *ir = new Ir( this ); 1011 Ir *ir = new Ir( this );
1012 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1012 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1013 ir->send( fileName, description, "text/x-vCard" ); 1013 ir->send( fileName, description, "text/x-vCard" );
1014 } else { 1014 } else {
1015 qDebug("KA: Error open temp beam file "); 1015 qDebug("KA: Error open temp beam file ");
1016 return; 1016 return;
1017 } 1017 }
1018#endif 1018#endif
1019 1019
1020} 1020}
1021 1021
1022void KABCore::beamDone( Ir *ir ) 1022void KABCore::beamDone( Ir *ir )
1023{ 1023{
1024#ifndef DESKTOP_VERSION 1024#ifndef DESKTOP_VERSION
1025 delete ir; 1025 delete ir;
1026#endif 1026#endif
1027 topLevelWidget()->raise(); 1027 topLevelWidget()->raise();
1028 message( i18n("Beaming finished!") ); 1028 message( i18n("Beaming finished!") );
1029} 1029}
1030 1030
1031 1031
1032void KABCore::browse( const QString& url ) 1032void KABCore::browse( const QString& url )
1033{ 1033{
1034#ifndef KAB_EMBEDDED 1034#ifndef KAB_EMBEDDED
1035 kapp->invokeBrowser( url ); 1035 kapp->invokeBrowser( url );
1036#else //KAB_EMBEDDED 1036#else //KAB_EMBEDDED
1037 qDebug("KABCore::browse must be fixed"); 1037 qDebug("KABCore::browse must be fixed");
1038#endif //KAB_EMBEDDED 1038#endif //KAB_EMBEDDED
1039} 1039}
1040 1040
1041void KABCore::selectAllContacts() 1041void KABCore::selectAllContacts()
1042{ 1042{
1043 mViewManager->setSelected( QString::null, true ); 1043 mViewManager->setSelected( QString::null, true );
1044} 1044}
1045 1045
1046void KABCore::deleteContacts() 1046void KABCore::deleteContacts()
1047{ 1047{
1048 QStringList uidList = mViewManager->selectedUids(); 1048 QStringList uidList = mViewManager->selectedUids();
1049 deleteContacts( uidList ); 1049 deleteContacts( uidList );
1050} 1050}
1051 1051
1052void KABCore::deleteContacts( const QStringList &uids ) 1052void KABCore::deleteContacts( const QStringList &uids )
1053{ 1053{
1054 1054
1055 if ( uids.count() > 0 ) { 1055 if ( uids.count() > 0 ) {
1056 1056
1057 if ( KABPrefs::instance()->mAskForDelete ) { 1057 if ( KABPrefs::instance()->mAskForDelete ) {
1058 int count = uids.count(); 1058 int count = uids.count();
1059 if ( count > 5 ) count = 5; 1059 if ( count > 5 ) count = 5;
1060 QString cNames; 1060 QString cNames;
1061 int i; 1061 int i;
1062 for ( i = 0; i < count ; ++i ) { 1062 for ( i = 0; i < count ; ++i ) {
1063 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1063 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1064 } 1064 }
1065 if ( uids.count() > 5 ) 1065 if ( uids.count() > 5 )
1066 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1066 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1067 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1067 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1068 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1068 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1069 return; 1069 return;
1070 } 1070 }
1071 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1071 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1072 UndoStack::instance()->push( command ); 1072 UndoStack::instance()->push( command );
1073 RedoStack::instance()->clear(); 1073 RedoStack::instance()->clear();
1074 1074
1075 // now if we deleted anything, refresh 1075 // now if we deleted anything, refresh
1076 setContactSelected( QString::null ); 1076 setContactSelected( QString::null );
1077 setModified( true ); 1077 setModified( true );
1078 } 1078 }
1079} 1079}
1080 1080
1081void KABCore::copyContacts() 1081void KABCore::copyContacts()
1082{ 1082{
1083 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1083 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1084 1084
1085 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1085 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1086 1086
1087 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1087 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1088 1088
1089 QClipboard *cb = QApplication::clipboard(); 1089 QClipboard *cb = QApplication::clipboard();
1090 cb->setText( clipText ); 1090 cb->setText( clipText );
1091} 1091}
1092 1092
1093void KABCore::cutContacts() 1093void KABCore::cutContacts()
1094{ 1094{
1095 QStringList uidList = mViewManager->selectedUids(); 1095 QStringList uidList = mViewManager->selectedUids();
1096 1096
1097//US if ( uidList.size() > 0 ) { 1097//US if ( uidList.size() > 0 ) {
1098 if ( uidList.count() > 0 ) { 1098 if ( uidList.count() > 0 ) {
1099 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1099 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1100 UndoStack::instance()->push( command ); 1100 UndoStack::instance()->push( command );
1101 RedoStack::instance()->clear(); 1101 RedoStack::instance()->clear();
1102 1102
1103 setModified( true ); 1103 setModified( true );
1104 } 1104 }
1105} 1105}
1106 1106
1107void KABCore::pasteContacts() 1107void KABCore::pasteContacts()
1108{ 1108{
1109 QClipboard *cb = QApplication::clipboard(); 1109 QClipboard *cb = QApplication::clipboard();
1110 1110
1111 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1111 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1112 1112
1113 pasteContacts( list ); 1113 pasteContacts( list );
1114} 1114}
1115 1115
1116void KABCore::pasteContacts( KABC::Addressee::List &list ) 1116void KABCore::pasteContacts( KABC::Addressee::List &list )
1117{ 1117{
1118 KABC::Resource *resource = requestResource( this ); 1118 KABC::Resource *resource = requestResource( this );
1119 KABC::Addressee::List::Iterator it; 1119 KABC::Addressee::List::Iterator it;
1120 for ( it = list.begin(); it != list.end(); ++it ) 1120 for ( it = list.begin(); it != list.end(); ++it )
1121 (*it).setResource( resource ); 1121 (*it).setResource( resource );
1122 1122
1123 PwPasteCommand *command = new PwPasteCommand( this, list ); 1123 PwPasteCommand *command = new PwPasteCommand( this, list );
1124 UndoStack::instance()->push( command ); 1124 UndoStack::instance()->push( command );
1125 RedoStack::instance()->clear(); 1125 RedoStack::instance()->clear();
1126 1126
1127 setModified( true ); 1127 setModified( true );
1128} 1128}
1129 1129
1130void KABCore::setWhoAmI() 1130void KABCore::setWhoAmI()
1131{ 1131{
1132 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1132 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1133 1133
1134 if ( addrList.count() > 1 ) { 1134 if ( addrList.count() > 1 ) {
1135 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1135 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1136 return; 1136 return;
1137 } 1137 }
1138 1138
1139 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1139 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1140 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1140 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1141 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1141 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1142} 1142}
1143void KABCore::editCategories() 1143void KABCore::editCategories()
1144{ 1144{
1145 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1145 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1146 dlg.exec(); 1146 dlg.exec();
1147} 1147}
1148void KABCore::setCategories() 1148void KABCore::setCategories()
1149{ 1149{
1150 1150
1151 QStringList uids; 1151 QStringList uids;
1152 XXPortSelectDialog dlgx( this, false, this ); 1152 XXPortSelectDialog dlgx( this, false, this );
1153 if ( dlgx.exec() ) 1153 if ( dlgx.exec() )
1154 uids = dlgx.uids(); 1154 uids = dlgx.uids();
1155 else 1155 else
1156 return; 1156 return;
1157 if ( uids.isEmpty() ) 1157 if ( uids.isEmpty() )
1158 return; 1158 return;
1159 // qDebug("count %d ", uids.count()); 1159 // qDebug("count %d ", uids.count());
1160 1160
1161 1161
1162 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1162 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1163 if ( !dlg.exec() ) { 1163 if ( !dlg.exec() ) {
1164 message( i18n("Setting categories cancelled") ); 1164 message( i18n("Setting categories cancelled") );
1165 return; 1165 return;
1166 } 1166 }
1167 bool merge = false; 1167 bool merge = false;
1168 QString msg = i18n( "Merge with existing categories?" ); 1168 QString msg = i18n( "Merge with existing categories?" );
1169 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1169 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1170 merge = true; 1170 merge = true;
1171 1171
1172 message( i18n("Setting categories ... please wait!") ); 1172 message( i18n("Setting categories ... please wait!") );
1173 QStringList categories = dlg.selectedCategories(); 1173 QStringList categories = dlg.selectedCategories();
1174 1174
1175 //QStringList uids = mViewManager->selectedUids(); 1175 //QStringList uids = mViewManager->selectedUids();
1176 QStringList::Iterator it; 1176 QStringList::Iterator it;
1177 for ( it = uids.begin(); it != uids.end(); ++it ) { 1177 for ( it = uids.begin(); it != uids.end(); ++it ) {
1178 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1178 KABC::Addressee addr = mAddressBook->findByUid( *it );
1179 if ( !addr.isEmpty() ) { 1179 if ( !addr.isEmpty() ) {
1180 if ( !merge ) 1180 if ( !merge )
1181 addr.setCategories( categories ); 1181 addr.setCategories( categories );
1182 else { 1182 else {
1183 QStringList addrCategories = addr.categories(); 1183 QStringList addrCategories = addr.categories();
1184 QStringList::Iterator catIt; 1184 QStringList::Iterator catIt;
1185 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1185 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1186 if ( !addrCategories.contains( *catIt ) ) 1186 if ( !addrCategories.contains( *catIt ) )
1187 addrCategories.append( *catIt ); 1187 addrCategories.append( *catIt );
1188 } 1188 }
1189 addr.setCategories( addrCategories ); 1189 addr.setCategories( addrCategories );
1190 } 1190 }
1191 mAddressBook->insertAddressee( addr ); 1191 mAddressBook->insertAddressee( addr );
1192 } 1192 }
1193 } 1193 }
1194 1194
1195 if ( uids.count() > 0 ) 1195 if ( uids.count() > 0 )
1196 setModified( true ); 1196 setModified( true );
1197 message( i18n("Setting categories completed!") ); 1197 message( i18n("Setting categories completed!") );
1198} 1198}
1199 1199
1200void KABCore::setSearchFields( const KABC::Field::List &fields ) 1200void KABCore::setSearchFields( const KABC::Field::List &fields )
1201{ 1201{
1202 mIncSearchWidget->setFields( fields ); 1202 mIncSearchWidget->setFields( fields );
1203} 1203}
1204 1204
1205void KABCore::incrementalSearch( const QString& text ) 1205void KABCore::incrementalSearch( const QString& text )
1206{ 1206{
1207 QString stext; 1207 QString stext;
1208 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1208 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1209 stext = "*" + text; 1209 stext = "*" + text;
1210 } else { 1210 } else {
1211 stext = text; 1211 stext = text;
1212 } 1212 }
1213 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1213 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1214} 1214}
1215void KABCore::incrementalSearchJump( const QString& text ) 1215void KABCore::incrementalSearchJump( const QString& text )
1216{ 1216{
1217 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1217 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1218} 1218}
1219 1219
1220void KABCore::setModified() 1220void KABCore::setModified()
1221{ 1221{
1222 setModified( true ); 1222 setModified( true );
1223} 1223}
1224 1224
1225void KABCore::setModifiedWOrefresh() 1225void KABCore::setModifiedWOrefresh()
1226{ 1226{
1227 // qDebug("KABCore::setModifiedWOrefresh() "); 1227 // qDebug("KABCore::setModifiedWOrefresh() ");
1228 mModified = true; 1228 mModified = true;
1229 mActionSave->setEnabled( mModified ); 1229 mActionSave->setEnabled( mModified );
1230 1230
1231 1231
1232} 1232}
1233void KABCore::setModified( bool modified ) 1233void KABCore::setModified( bool modified )
1234{ 1234{
1235 mModified = modified; 1235 mModified = modified;
1236 mActionSave->setEnabled( mModified ); 1236 mActionSave->setEnabled( mModified );
1237 1237
1238 if ( modified ) 1238 if ( modified )
1239 mJumpButtonBar->recreateButtons(); 1239 mJumpButtonBar->recreateButtons();
1240 1240
1241 mViewManager->refreshView(); 1241 mViewManager->refreshView();
1242 1242
1243} 1243}
1244 1244
1245bool KABCore::modified() const 1245bool KABCore::modified() const
1246{ 1246{
1247 return mModified; 1247 return mModified;
1248} 1248}
1249 1249
1250void KABCore::contactModified( const KABC::Addressee &addr ) 1250void KABCore::contactModified( const KABC::Addressee &addr )
1251{ 1251{
1252 addrModified( addr ); 1252 addrModified( addr );
1253#if 0 // debug only 1253#if 0 // debug only
1254 KABC::Addressee ad = addr; 1254 KABC::Addressee ad = addr;
1255 ad.computeCsum( "123"); 1255 ad.computeCsum( "123");
1256#endif 1256#endif
1257} 1257}
1258 1258
1259void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1259void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1260{ 1260{
1261 1261
1262 Command *command = 0; 1262 Command *command = 0;
1263 QString uid; 1263 QString uid;
1264 1264
1265 // check if it exists already 1265 // check if it exists already
1266 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1266 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1267 if ( origAddr.isEmpty() ) 1267 if ( origAddr.isEmpty() )
1268 command = new PwNewCommand( mAddressBook, addr ); 1268 command = new PwNewCommand( mAddressBook, addr );
1269 else { 1269 else {
1270 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1270 command = new PwEditCommand( mAddressBook, origAddr, addr );
1271 uid = addr.uid(); 1271 uid = addr.uid();
1272 } 1272 }
1273 1273
1274 UndoStack::instance()->push( command ); 1274 UndoStack::instance()->push( command );
1275 RedoStack::instance()->clear(); 1275 RedoStack::instance()->clear();
1276 if ( updateDetails ) 1276 if ( updateDetails )
1277 mDetails->setAddressee( addr ); 1277 mDetails->setAddressee( addr );
1278 setModified( true ); 1278 setModified( true );
1279} 1279}
1280 1280
1281void KABCore::newContact() 1281void KABCore::newContact()
1282{ 1282{
1283 1283
1284 1284
1285 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1285 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1286 1286
1287 QPtrList<KRES::Resource> kresResources; 1287 QPtrList<KRES::Resource> kresResources;
1288 QPtrListIterator<KABC::Resource> it( kabcResources ); 1288 QPtrListIterator<KABC::Resource> it( kabcResources );
1289 KABC::Resource *resource; 1289 KABC::Resource *resource;
1290 while ( ( resource = it.current() ) != 0 ) { 1290 while ( ( resource = it.current() ) != 0 ) {
1291 ++it; 1291 ++it;
1292 if ( !resource->readOnly() ) { 1292 if ( !resource->readOnly() ) {
1293 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1293 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1294 if ( res ) 1294 if ( res )
1295 kresResources.append( res ); 1295 kresResources.append( res );
1296 } 1296 }
1297 } 1297 }
1298 1298
1299 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1299 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1300 resource = static_cast<KABC::Resource*>( res ); 1300 resource = static_cast<KABC::Resource*>( res );
1301 1301
1302 if ( resource ) { 1302 if ( resource ) {
1303 KABC::Addressee addr; 1303 KABC::Addressee addr;
1304 addr.setResource( resource ); 1304 addr.setResource( resource );
1305 mEditorDialog->setAddressee( addr ); 1305 mEditorDialog->setAddressee( addr );
1306 mEditorDialog->setCaption( i18n("Edit new contact")); 1306 mEditorDialog->setCaption( i18n("Edit new contact"));
1307 KApplication::execDialog ( mEditorDialog ); 1307 KApplication::execDialog ( mEditorDialog );
1308 1308
1309 } else 1309 } else
1310 return; 1310 return;
1311 1311
1312 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1312 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1313 1313
1314 1314
1315} 1315}
1316 1316
1317void KABCore::addEmail( QString aStr ) 1317void KABCore::addEmail( QString aStr )
1318{ 1318{
1319#ifndef KAB_EMBEDDED 1319#ifndef KAB_EMBEDDED
1320 QString fullName, email; 1320 QString fullName, email;
1321 1321
1322 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1322 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1323 1323
1324 // Try to lookup the addressee matching the email address 1324 // Try to lookup the addressee matching the email address
1325 bool found = false; 1325 bool found = false;
1326 QStringList emailList; 1326 QStringList emailList;
1327 KABC::AddressBook::Iterator it; 1327 KABC::AddressBook::Iterator it;
1328 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1328 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1329 emailList = (*it).emails(); 1329 emailList = (*it).emails();
1330 if ( emailList.contains( email ) > 0 ) { 1330 if ( emailList.contains( email ) > 0 ) {
1331 found = true; 1331 found = true;
1332 (*it).setNameFromString( fullName ); 1332 (*it).setNameFromString( fullName );
1333 editContact( (*it).uid() ); 1333 editContact( (*it).uid() );
1334 } 1334 }
1335 } 1335 }
1336 1336
1337 if ( !found ) { 1337 if ( !found ) {
1338 KABC::Addressee addr; 1338 KABC::Addressee addr;
1339 addr.setNameFromString( fullName ); 1339 addr.setNameFromString( fullName );
1340 addr.insertEmail( email, true ); 1340 addr.insertEmail( email, true );
1341 1341
1342 mAddressBook->insertAddressee( addr ); 1342 mAddressBook->insertAddressee( addr );
1343 mViewManager->refreshView( addr.uid() ); 1343 mViewManager->refreshView( addr.uid() );
1344 editContact( addr.uid() ); 1344 editContact( addr.uid() );
1345 } 1345 }
1346#else //KAB_EMBEDDED 1346#else //KAB_EMBEDDED
1347 qDebug("KABCore::addEmail finsih method"); 1347 qDebug("KABCore::addEmail finsih method");
1348#endif //KAB_EMBEDDED 1348#endif //KAB_EMBEDDED
1349} 1349}
1350 1350
1351void KABCore::importVCard( const KURL &url, bool showPreview ) 1351void KABCore::importVCard( const KURL &url, bool showPreview )
1352{ 1352{
1353 mXXPortManager->importVCard( url, showPreview ); 1353 mXXPortManager->importVCard( url, showPreview );
1354} 1354}
1355void KABCore::importFromOL() 1355void KABCore::importFromOL()
1356{ 1356{
1357#ifdef _OL_IMPORT_ 1357#ifdef _OL_IMPORT_
1358 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1358 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1359 idgl->exec(); 1359 idgl->exec();
1360 KABC::Addressee::List list = idgl->getAddressList(); 1360 KABC::Addressee::List list = idgl->getAddressList();
1361 if ( list.count() > 0 ) { 1361 if ( list.count() > 0 ) {
1362 KABC::Addressee::List listNew; 1362 KABC::Addressee::List listNew;
1363 KABC::Addressee::List listExisting; 1363 KABC::Addressee::List listExisting;
1364 KABC::Addressee::List::Iterator it; 1364 KABC::Addressee::List::Iterator it;
1365 KABC::AddressBook::Iterator iter; 1365 KABC::AddressBook::Iterator iter;
1366 for ( it = list.begin(); it != list.end(); ++it ) { 1366 for ( it = list.begin(); it != list.end(); ++it ) {
1367 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1367 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1368 listNew.append( (*it) ); 1368 listNew.append( (*it) );
1369 else 1369 else
1370 listExisting.append( (*it) ); 1370 listExisting.append( (*it) );
1371 } 1371 }
1372 if ( listExisting.count() > 0 ) 1372 if ( listExisting.count() > 0 )
1373 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1373 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1374 if ( listNew.count() > 0 ) { 1374 if ( listNew.count() > 0 ) {
1375 pasteWithNewUid = false; 1375 pasteWithNewUid = false;
1376 pasteContacts( listNew ); 1376 pasteContacts( listNew );
1377 pasteWithNewUid = true; 1377 pasteWithNewUid = true;
1378 } 1378 }
1379 } 1379 }
1380 delete idgl; 1380 delete idgl;
1381#endif 1381#endif
1382} 1382}
1383 1383
1384void KABCore::importVCard( const QString &vCard, bool showPreview ) 1384void KABCore::importVCard( const QString &vCard, bool showPreview )
1385{ 1385{
1386 mXXPortManager->importVCard( vCard, showPreview ); 1386 mXXPortManager->importVCard( vCard, showPreview );
1387} 1387}
1388 1388
1389//US added a second method without defaultparameter 1389//US added a second method without defaultparameter
1390void KABCore::editContact2() { 1390void KABCore::editContact2() {
1391 editContact( QString::null ); 1391 editContact( QString::null );
1392} 1392}
1393 1393
1394void KABCore::editContact( const QString &uid ) 1394void KABCore::editContact( const QString &uid )
1395{ 1395{
1396 1396
1397 if ( mExtensionManager->isQuickEditVisible() ) 1397 if ( mExtensionManager->isQuickEditVisible() )
1398 return; 1398 return;
1399 1399
1400 // First, locate the contact entry 1400 // First, locate the contact entry
1401 QString localUID = uid; 1401 QString localUID = uid;
1402 if ( localUID.isNull() ) { 1402 if ( localUID.isNull() ) {
1403 QStringList uidList = mViewManager->selectedUids(); 1403 QStringList uidList = mViewManager->selectedUids();
1404 if ( uidList.count() > 0 ) 1404 if ( uidList.count() > 0 )
1405 localUID = *( uidList.at( 0 ) ); 1405 localUID = *( uidList.at( 0 ) );
1406 } 1406 }
1407 1407
1408 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1408 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1409 if ( !addr.isEmpty() ) { 1409 if ( !addr.isEmpty() ) {
1410 mEditorDialog->setAddressee( addr ); 1410 mEditorDialog->setAddressee( addr );
1411 KApplication::execDialog ( mEditorDialog ); 1411 KApplication::execDialog ( mEditorDialog );
1412 } 1412 }
1413} 1413}
1414 1414
1415/** 1415/**
1416 Shows or edits the detail view for the given uid. If the uid is QString::null, 1416 Shows or edits the detail view for the given uid. If the uid is QString::null,
1417 the method will try to find a selected addressee in the view. 1417 the method will try to find a selected addressee in the view.
1418 */ 1418 */
1419void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1419void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1420{ 1420{
1421 if ( mMultipleViewsAtOnce ) 1421 if ( mMultipleViewsAtOnce )
1422 { 1422 {
1423 editContact( uid ); 1423 editContact( uid );
1424 } 1424 }
1425 else 1425 else
1426 { 1426 {
1427 setDetailsVisible( true ); 1427 setDetailsVisible( true );
1428 mActionDetails->setChecked(true); 1428 mActionDetails->setChecked(true);
1429 } 1429 }
1430 1430
1431} 1431}
1432 1432
1433void KABCore::save() 1433void KABCore::save()
1434{ 1434{
1435 if (syncManager->blockSave()) 1435 if (syncManager->blockSave())
1436 return; 1436 return;
1437 if ( !mModified ) 1437 if ( !mModified )
1438 return; 1438 return;
1439 1439
1440 syncManager->setBlockSave(true); 1440 syncManager->setBlockSave(true);
1441 QString text = i18n( "There was an error while attempting to save\n the " 1441 QString text = i18n( "There was an error while attempting to save\n the "
1442 "address book. Please check that some \nother application is " 1442 "address book. Please check that some \nother application is "
1443 "not using it. " ); 1443 "not using it. " );
1444 message(i18n("Saving ... please wait! "), false); 1444 message(i18n("Saving ... please wait! "), false);
1445 //qApp->processEvents(); 1445 //qApp->processEvents();
1446#ifndef KAB_EMBEDDED 1446#ifndef KAB_EMBEDDED
1447 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1447 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1448 if ( !b || !b->save() ) { 1448 if ( !b || !b->save() ) {
1449 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1449 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1450 } 1450 }
1451#else //KAB_EMBEDDED 1451#else //KAB_EMBEDDED
1452 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1452 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1453 if ( !b || !b->save() ) { 1453 if ( !b || !b->save() ) {
1454 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1454 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1455 } 1455 }
1456#endif //KAB_EMBEDDED 1456#endif //KAB_EMBEDDED
1457 1457
1458 message(i18n("Addressbook saved!")); 1458 message(i18n("Addressbook saved!"));
1459 setModified( false ); 1459 setModified( false );
1460 syncManager->setBlockSave(false); 1460 syncManager->setBlockSave(false);
1461} 1461}
1462 1462
1463 1463
1464void KABCore::undo() 1464void KABCore::undo()
1465{ 1465{
1466 UndoStack::instance()->undo(); 1466 UndoStack::instance()->undo();
1467 1467
1468 // Refresh the view 1468 // Refresh the view
1469 mViewManager->refreshView(); 1469 mViewManager->refreshView();
1470} 1470}
1471 1471
1472void KABCore::redo() 1472void KABCore::redo()
1473{ 1473{
1474 RedoStack::instance()->redo(); 1474 RedoStack::instance()->redo();
1475 1475
1476 // Refresh the view 1476 // Refresh the view
1477 mViewManager->refreshView(); 1477 mViewManager->refreshView();
1478} 1478}
1479void KABCore::setJumpButtonBar( bool visible ) 1479void KABCore::setJumpButtonBar( bool visible )
1480{ 1480{
1481 setJumpButtonBarVisible(visible ); 1481 setJumpButtonBarVisible(visible );
1482 saveSettings(); 1482 saveSettings();
1483} 1483}
1484void KABCore::setJumpButtonBarVisible( bool visible ) 1484void KABCore::setJumpButtonBarVisible( bool visible )
1485{ 1485{
1486 if (mMultipleViewsAtOnce) 1486 if (mMultipleViewsAtOnce)
1487 { 1487 {
1488 if ( visible ) 1488 if ( visible )
1489 mJumpButtonBar->show(); 1489 mJumpButtonBar->show();
1490 else 1490 else
1491 mJumpButtonBar->hide(); 1491 mJumpButtonBar->hide();
1492 } 1492 }
1493 else 1493 else
1494 { 1494 {
1495 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1495 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1496 if (mViewManager->isVisible()) 1496 if (mViewManager->isVisible())
1497 { 1497 {
1498 if ( visible ) 1498 if ( visible )
1499 mJumpButtonBar->show(); 1499 mJumpButtonBar->show();
1500 else 1500 else
1501 mJumpButtonBar->hide(); 1501 mJumpButtonBar->hide();
1502 } 1502 }
1503 else 1503 else
1504 { 1504 {
1505 mJumpButtonBar->hide(); 1505 mJumpButtonBar->hide();
1506 } 1506 }
1507 } 1507 }
1508 if ( visible ) { 1508 if ( visible ) {
1509 if ( mIncSearchWidget->currentItem() == 0 ) { 1509 if ( mIncSearchWidget->currentItem() == 0 ) {
1510 message( i18n("Change search field enable jump bar") ); 1510 message( i18n("Change search field enable jump bar") );
1511 } 1511 }
1512 } 1512 }
1513} 1513}
1514 1514
1515 1515
1516void KABCore::setDetailsToState() 1516void KABCore::setDetailsToState()
1517{ 1517{
1518 setDetailsVisible( mActionDetails->isChecked() ); 1518 setDetailsVisible( mActionDetails->isChecked() );
1519} 1519}
1520void KABCore::setDetailsToggle() 1520void KABCore::setDetailsToggle()
1521{ 1521{
1522 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1522 mActionDetails->setChecked( !mActionDetails->isChecked() );
1523 setDetailsToState(); 1523 setDetailsToState();
1524} 1524}
1525 1525
1526 1526
1527 1527
1528void KABCore::setDetailsVisible( bool visible ) 1528void KABCore::setDetailsVisible( bool visible )
1529{ 1529{
1530 if (visible && mDetails->isHidden()) 1530 if (visible && mDetails->isHidden())
1531 { 1531 {
1532 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1532 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1533 if ( addrList.count() > 0 ) 1533 if ( addrList.count() > 0 )
1534 mDetails->setAddressee( addrList[ 0 ] ); 1534 mDetails->setAddressee( addrList[ 0 ] );
1535 } 1535 }
1536 1536
1537 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1537 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1538 // the listview and the detailview. We do that by changing the splitbar size. 1538 // the listview and the detailview. We do that by changing the splitbar size.
1539 if (mMultipleViewsAtOnce) 1539 if (mMultipleViewsAtOnce)
1540 { 1540 {
1541 if ( visible ) 1541 if ( visible )
1542 mDetails->show(); 1542 mDetails->show();
1543 else 1543 else
1544 mDetails->hide(); 1544 mDetails->hide();
1545 } 1545 }
1546 else 1546 else
1547 { 1547 {
1548 if ( visible ) { 1548 if ( visible ) {
1549 mViewManager->hide(); 1549 mViewManager->hide();
1550 mDetails->show(); 1550 mDetails->show();
1551 mIncSearchWidget->setFocus(); 1551 mIncSearchWidget->setFocus();
1552 } 1552 }
1553 else { 1553 else {
1554 mViewManager->show(); 1554 mViewManager->show();
1555 mDetails->hide(); 1555 mDetails->hide();
1556 mViewManager->setFocusAV(); 1556 mViewManager->setFocusAV();
1557 } 1557 }
1558 setJumpButtonBarVisible( !visible ); 1558 setJumpButtonBarVisible( !visible );
1559 } 1559 }
1560 1560
1561} 1561}
1562 1562
1563void KABCore::extensionChanged( int id ) 1563void KABCore::extensionChanged( int id )
1564{ 1564{
1565 //change the details view only for non desktop systems 1565 //change the details view only for non desktop systems
1566#ifndef DESKTOP_VERSION 1566#ifndef DESKTOP_VERSION
1567 1567
1568 if (id == 0) 1568 if (id == 0)
1569 { 1569 {
1570 //the user disabled the extension. 1570 //the user disabled the extension.
1571 1571
1572 if (mMultipleViewsAtOnce) 1572 if (mMultipleViewsAtOnce)
1573 { // enable detailsview again 1573 { // enable detailsview again
1574 setDetailsVisible( true ); 1574 setDetailsVisible( true );
1575 mActionDetails->setChecked( true ); 1575 mActionDetails->setChecked( true );
1576 } 1576 }
1577 else 1577 else
1578 { //go back to the listview 1578 { //go back to the listview
1579 setDetailsVisible( false ); 1579 setDetailsVisible( false );
1580 mActionDetails->setChecked( false ); 1580 mActionDetails->setChecked( false );
1581 mActionDetails->setEnabled(true); 1581 mActionDetails->setEnabled(true);
1582 } 1582 }
1583 1583
1584 } 1584 }
1585 else 1585 else
1586 { 1586 {
1587 //the user enabled the extension. 1587 //the user enabled the extension.
1588 setDetailsVisible( false ); 1588 setDetailsVisible( false );
1589 mActionDetails->setChecked( false ); 1589 mActionDetails->setChecked( false );
1590 1590
1591 if (!mMultipleViewsAtOnce) 1591 if (!mMultipleViewsAtOnce)
1592 { 1592 {
1593 mActionDetails->setEnabled(false); 1593 mActionDetails->setEnabled(false);
1594 } 1594 }
1595 1595
1596 mExtensionManager->setSelectionChanged(); 1596 mExtensionManager->setSelectionChanged();
1597 1597
1598 } 1598 }
1599 1599
1600#endif// DESKTOP_VERSION 1600#endif// DESKTOP_VERSION
1601 1601
1602} 1602}
1603 1603
1604 1604
1605void KABCore::extensionModified( const KABC::Addressee::List &list ) 1605void KABCore::extensionModified( const KABC::Addressee::List &list )
1606{ 1606{
1607 1607
1608 if ( list.count() != 0 ) { 1608 if ( list.count() != 0 ) {
1609 KABC::Addressee::List::ConstIterator it; 1609 KABC::Addressee::List::ConstIterator it;
1610 for ( it = list.begin(); it != list.end(); ++it ) 1610 for ( it = list.begin(); it != list.end(); ++it )
1611 mAddressBook->insertAddressee( *it ); 1611 mAddressBook->insertAddressee( *it );
1612 if ( list.count() > 1 ) 1612 if ( list.count() > 1 )
1613 setModified(); 1613 setModified();
1614 else 1614 else
1615 setModifiedWOrefresh(); 1615 setModifiedWOrefresh();
1616 } 1616 }
1617 if ( list.count() == 0 ) 1617 if ( list.count() == 0 )
1618 mViewManager->refreshView(); 1618 mViewManager->refreshView();
1619 else 1619 else
1620 mViewManager->refreshView( list[ 0 ].uid() ); 1620 mViewManager->refreshView( list[ 0 ].uid() );
1621 1621
1622 1622
1623 1623
1624} 1624}
1625 1625
1626QString KABCore::getNameByPhone( const QString &phone ) 1626QString KABCore::getNameByPhone( const QString &phone )
1627{ 1627{
1628#ifndef KAB_EMBEDDED 1628#ifndef KAB_EMBEDDED
1629 QRegExp r( "[/*/-/ ]" ); 1629 QRegExp r( "[/*/-/ ]" );
1630 QString localPhone( phone ); 1630 QString localPhone( phone );
1631 1631
1632 bool found = false; 1632 bool found = false;
1633 QString ownerName = ""; 1633 QString ownerName = "";
1634 KABC::AddressBook::Iterator iter; 1634 KABC::AddressBook::Iterator iter;
1635 KABC::PhoneNumber::List::Iterator phoneIter; 1635 KABC::PhoneNumber::List::Iterator phoneIter;
1636 KABC::PhoneNumber::List phoneList; 1636 KABC::PhoneNumber::List phoneList;
1637 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1637 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1638 phoneList = (*iter).phoneNumbers(); 1638 phoneList = (*iter).phoneNumbers();
1639 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1639 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1640 ++phoneIter) { 1640 ++phoneIter) {
1641 // Get rid of separator chars so just the numbers are compared. 1641 // Get rid of separator chars so just the numbers are compared.
1642 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1642 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1643 ownerName = (*iter).formattedName(); 1643 ownerName = (*iter).formattedName();
1644 found = true; 1644 found = true;
1645 } 1645 }
1646 } 1646 }
1647 } 1647 }
1648 1648
1649 return ownerName; 1649 return ownerName;
1650#else //KAB_EMBEDDED 1650#else //KAB_EMBEDDED
1651 qDebug("KABCore::getNameByPhone finsih method"); 1651 qDebug("KABCore::getNameByPhone finsih method");
1652 return ""; 1652 return "";
1653#endif //KAB_EMBEDDED 1653#endif //KAB_EMBEDDED
1654 1654
1655} 1655}
1656void KABCore::openConfigGlobalDialog() 1656void KABCore::openConfigGlobalDialog()
1657{ 1657{
1658 KPimPrefsGlobalDialog gc ( this ); 1658 KPimPrefsGlobalDialog gc ( this );
1659 gc.exec(); 1659 gc.exec();
1660} 1660}
1661void KABCore::openConfigDialog() 1661void KABCore::openConfigDialog()
1662{ 1662{
1663 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1663 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1664 1664
1665 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1665 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1666 ConfigureDialog->setMainWidget( kabcfg ); 1666 ConfigureDialog->setMainWidget( kabcfg );
1667 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1667 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1668 this, SLOT( configurationChanged() ) ); 1668 this, SLOT( configurationChanged() ) );
1669 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1669 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1670 kabcfg, SLOT( save() ) ); 1670 kabcfg, SLOT( save() ) );
1671 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1671 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1672 this, SLOT( configurationChanged() ) ); 1672 this, SLOT( configurationChanged() ) );
1673 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1673 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1674 kabcfg, SLOT( save() ) ); 1674 kabcfg, SLOT( save() ) );
1675 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1675 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1676 kabcfg, SLOT( defaults() ) ); 1676 kabcfg, SLOT( defaults() ) );
1677 saveSettings(); 1677 saveSettings();
1678 kabcfg->load(); 1678 kabcfg->load();
1679#ifndef DESKTOP_VERSION 1679#ifndef DESKTOP_VERSION
1680 if ( QApplication::desktop()->height() <= 480 ) 1680 if ( QApplication::desktop()->height() <= 480 )
1681 ConfigureDialog->hideButtons(); 1681 ConfigureDialog->hideButtons();
1682 ConfigureDialog->showMaximized(); 1682 ConfigureDialog->showMaximized();
1683#endif 1683#endif
1684 if ( ConfigureDialog->exec() ) 1684 if ( ConfigureDialog->exec() )
1685 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1685 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1686 delete ConfigureDialog; 1686 delete ConfigureDialog;
1687} 1687}
1688 1688
1689void KABCore::openLDAPDialog() 1689void KABCore::openLDAPDialog()
1690{ 1690{
1691#ifndef KAB_EMBEDDED 1691#ifndef KAB_EMBEDDED
1692 if ( !mLdapSearchDialog ) { 1692 if ( !mLdapSearchDialog ) {
1693 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1693 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1694 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1694 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1695 SLOT( refreshView() ) ); 1695 SLOT( refreshView() ) );
1696 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1696 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1697 SLOT( setModified() ) ); 1697 SLOT( setModified() ) );
1698 } else 1698 } else
1699 mLdapSearchDialog->restoreSettings(); 1699 mLdapSearchDialog->restoreSettings();
1700 1700
1701 if ( mLdapSearchDialog->isOK() ) 1701 if ( mLdapSearchDialog->isOK() )
1702 mLdapSearchDialog->exec(); 1702 mLdapSearchDialog->exec();
1703#else //KAB_EMBEDDED 1703#else //KAB_EMBEDDED
1704 qDebug("KABCore::openLDAPDialog() finsih method"); 1704 qDebug("KABCore::openLDAPDialog() finsih method");
1705#endif //KAB_EMBEDDED 1705#endif //KAB_EMBEDDED
1706} 1706}
1707 1707
1708void KABCore::print() 1708void KABCore::print()
1709{ 1709{
1710#ifndef KAB_EMBEDDED 1710#ifndef KAB_EMBEDDED
1711 KPrinter printer; 1711 KPrinter printer;
1712 if ( !printer.setup( this ) ) 1712 if ( !printer.setup( this ) )
1713 return; 1713 return;
1714 1714
1715 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1715 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1716 mViewManager->selectedUids(), this ); 1716 mViewManager->selectedUids(), this );
1717 1717
1718 wizard.exec(); 1718 wizard.exec();
1719#else //KAB_EMBEDDED 1719#else //KAB_EMBEDDED
1720 qDebug("KABCore::print() finsih method"); 1720 qDebug("KABCore::print() finsih method");
1721#endif //KAB_EMBEDDED 1721#endif //KAB_EMBEDDED
1722 1722
1723} 1723}
1724 1724
1725 1725
1726void KABCore::addGUIClient( KXMLGUIClient *client ) 1726void KABCore::addGUIClient( KXMLGUIClient *client )
1727{ 1727{
1728 if ( mGUIClient ) 1728 if ( mGUIClient )
1729 mGUIClient->insertChildClient( client ); 1729 mGUIClient->insertChildClient( client );
1730 else 1730 else
1731 KMessageBox::error( this, "no KXMLGUICLient"); 1731 KMessageBox::error( this, "no KXMLGUICLient");
1732} 1732}
1733 1733
1734 1734
1735void KABCore::configurationChanged() 1735void KABCore::configurationChanged()
1736{ 1736{
1737 mExtensionManager->reconfigure(); 1737 mExtensionManager->reconfigure();
1738} 1738}
1739 1739
1740void KABCore::addressBookChanged() 1740void KABCore::addressBookChanged()
1741{ 1741{
1742/*US 1742/*US
1743 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1743 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1744 while ( it.current() ) { 1744 while ( it.current() ) {
1745 if ( it.current()->dirty() ) { 1745 if ( it.current()->dirty() ) {
1746 QString text = i18n( "Data has been changed externally. Unsaved " 1746 QString text = i18n( "Data has been changed externally. Unsaved "
1747 "changes will be lost." ); 1747 "changes will be lost." );
1748 KMessageBox::information( this, text ); 1748 KMessageBox::information( this, text );
1749 } 1749 }
1750 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1750 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1751 ++it; 1751 ++it;
1752 } 1752 }
1753*/ 1753*/
1754 if (mEditorDialog) 1754 if (mEditorDialog)
1755 { 1755 {
1756 if (mEditorDialog->dirty()) 1756 if (mEditorDialog->dirty())
1757 { 1757 {
1758 QString text = i18n( "Data has been changed externally. Unsaved " 1758 QString text = i18n( "Data has been changed externally. Unsaved "
1759 "changes will be lost." ); 1759 "changes will be lost." );
1760 KMessageBox::information( this, text ); 1760 KMessageBox::information( this, text );
1761 } 1761 }
1762 QString currentuid = mEditorDialog->addressee().uid(); 1762 QString currentuid = mEditorDialog->addressee().uid();
1763 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1763 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1764 } 1764 }
1765 mViewManager->refreshView(); 1765 mViewManager->refreshView();
1766 1766
1767 1767
1768} 1768}
1769 1769
1770AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1770AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1771 const char *name ) 1771 const char *name )
1772{ 1772{
1773 1773
1774 if ( mEditorDialog == 0 ) { 1774 if ( mEditorDialog == 0 ) {
1775 mEditorDialog = new AddresseeEditorDialog( this, parent, 1775 mEditorDialog = new AddresseeEditorDialog( this, parent,
1776 name ? name : "editorDialog" ); 1776 name ? name : "editorDialog" );
1777 1777
1778 1778
1779 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1779 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1780 SLOT( contactModified( const KABC::Addressee& ) ) ); 1780 SLOT( contactModified( const KABC::Addressee& ) ) );
1781 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1781 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1782 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1782 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1783 } 1783 }
1784 1784
1785 return mEditorDialog; 1785 return mEditorDialog;
1786} 1786}
1787 1787
1788void KABCore::slotEditorDestroyed( const QString &uid ) 1788void KABCore::slotEditorDestroyed( const QString &uid )
1789{ 1789{
1790 //mEditorDict.remove( uid ); 1790 //mEditorDict.remove( uid );
1791} 1791}
1792 1792
1793void KABCore::initGUI() 1793void KABCore::initGUI()
1794{ 1794{
1795#ifndef KAB_EMBEDDED 1795#ifndef KAB_EMBEDDED
1796 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1796 QHBoxLayout *topLayout = new QHBoxLayout( this );
1797 topLayout->setSpacing( KDialogBase::spacingHint() ); 1797 topLayout->setSpacing( KDialogBase::spacingHint() );
1798 1798
1799 mExtensionBarSplitter = new QSplitter( this ); 1799 mExtensionBarSplitter = new QSplitter( this );
1800 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1800 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1801 1801
1802 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1802 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1803 1803
1804 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1804 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1805 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1805 mIncSearchWidget = new IncSearchWidget( viewSpace );
1806 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1806 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1807 SLOT( incrementalSearch( const QString& ) ) ); 1807 SLOT( incrementalSearch( const QString& ) ) );
1808 1808
1809 mViewManager = new ViewManager( this, viewSpace ); 1809 mViewManager = new ViewManager( this, viewSpace );
1810 viewSpace->setStretchFactor( mViewManager, 1 ); 1810 viewSpace->setStretchFactor( mViewManager, 1 );
1811 1811
1812 mDetails = new ViewContainer( mDetailsSplitter ); 1812 mDetails = new ViewContainer( mDetailsSplitter );
1813 1813
1814 mJumpButtonBar = new JumpButtonBar( this, this ); 1814 mJumpButtonBar = new JumpButtonBar( this, this );
1815 1815
1816 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1816 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1817 1817
1818 topLayout->addWidget( mExtensionBarSplitter ); 1818 topLayout->addWidget( mExtensionBarSplitter );
1819 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1819 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1820 topLayout->addWidget( mJumpButtonBar ); 1820 topLayout->addWidget( mJumpButtonBar );
1821 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1821 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1822 1822
1823 mXXPortManager = new XXPortManager( this, this ); 1823 mXXPortManager = new XXPortManager( this, this );
1824 1824
1825#else //KAB_EMBEDDED 1825#else //KAB_EMBEDDED
1826 //US initialize viewMenu before settingup viewmanager. 1826 //US initialize viewMenu before settingup viewmanager.
1827 // Viewmanager needs this menu to plugin submenues. 1827 // Viewmanager needs this menu to plugin submenues.
1828 viewMenu = new QPopupMenu( this ); 1828 viewMenu = new QPopupMenu( this );
1829 settingsMenu = new QPopupMenu( this ); 1829 settingsMenu = new QPopupMenu( this );
1830 //filterMenu = new QPopupMenu( this ); 1830 //filterMenu = new QPopupMenu( this );
1831 ImportMenu = new QPopupMenu( this ); 1831 ImportMenu = new QPopupMenu( this );
1832 ExportMenu = new QPopupMenu( this ); 1832 ExportMenu = new QPopupMenu( this );
1833 syncMenu = new QPopupMenu( this ); 1833 syncMenu = new QPopupMenu( this );
1834 changeMenu= new QPopupMenu( this ); 1834 changeMenu= new QPopupMenu( this );
1835 beamMenu= new QPopupMenu( this ); 1835 beamMenu= new QPopupMenu( this );
1836 1836
1837//US since we have no splitter for the embedded system, setup 1837//US since we have no splitter for the embedded system, setup
1838// a layout with two frames. One left and one right. 1838// a layout with two frames. One left and one right.
1839 1839
1840 QBoxLayout *topLayout; 1840 QBoxLayout *topLayout;
1841 1841
1842 // = new QHBoxLayout( this ); 1842 // = new QHBoxLayout( this );