summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp52
1 files changed, 30 insertions, 22 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9526f23..d393660 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -132,193 +132,194 @@ $Id$
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include "nameeditdialog.h" 154#include "nameeditdialog.h"
155#include <kcmultidialog.h> 155#include <kcmultidialog.h>
156 156
157#ifdef _WIN32_ 157#ifdef _WIN32_
158 158
159#include "kaimportoldialog.h" 159#include "kaimportoldialog.h"
160#else 160#else
161#include <unistd.h> 161#include <unistd.h>
162#endif 162#endif
163// sync includes 163// sync includes
164#include <libkdepim/ksyncprofile.h> 164#include <libkdepim/ksyncprofile.h>
165#include <libkdepim/ksyncprefsdialog.h> 165#include <libkdepim/ksyncprefsdialog.h>
166 166
167 167
168class KABCatPrefs : public QDialog 168class KABCatPrefs : public QDialog
169{ 169{
170 public: 170 public:
171 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 171 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
172 QDialog( parent, name, true ) 172 QDialog( parent, name, true )
173 { 173 {
174 setCaption( i18n("Manage new Categories") ); 174 setCaption( i18n("Manage new Categories") );
175 QVBoxLayout* lay = new QVBoxLayout( this ); 175 QVBoxLayout* lay = new QVBoxLayout( this );
176 lay->setSpacing( 3 ); 176 lay->setSpacing( 3 );
177 lay->setMargin( 3 ); 177 lay->setMargin( 3 );
178 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 ); 178 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 );
179 lay->addWidget( lab ); 179 lay->addWidget( lab );
180 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 180 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
181 lay->addWidget( format ); 181 lay->addWidget( format );
182 format->setExclusive ( true ) ; 182 format->setExclusive ( true ) ;
183 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 183 addCatBut = new QRadioButton(i18n("Add to category list"), format );
184 new QRadioButton(i18n("Remove from addressees"), format ); 184 new QRadioButton(i18n("Remove from addressees"), format );
185 addCatBut->setChecked( true ); 185 addCatBut->setChecked( true );
186 QPushButton * ok = new QPushButton( i18n("OK"), this ); 186 QPushButton * ok = new QPushButton( i18n("OK"), this );
187 lay->addWidget( ok ); 187 lay->addWidget( ok );
188 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 188 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
189 lay->addWidget( cancel ); 189 lay->addWidget( cancel );
190 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 190 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
191 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 191 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
192 resize( 200, 200 ); 192 resize( 200, 200 );
193 } 193 }
194 194
195 bool addCat() { return addCatBut->isChecked(); } 195 bool addCat() { return addCatBut->isChecked(); }
196private: 196private:
197 QRadioButton* addCatBut; 197 QRadioButton* addCatBut;
198}; 198};
199 199
200class KABFormatPrefs : public QDialog 200class KABFormatPrefs : public QDialog
201{ 201{
202 public: 202 public:
203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
204 QDialog( parent, name, true ) 204 QDialog( parent, name, true )
205 { 205 {
206 setCaption( i18n("Set formatted name") ); 206 setCaption( i18n("Set formatted name") );
207 QVBoxLayout* lay = new QVBoxLayout( this ); 207 QVBoxLayout* lay = new QVBoxLayout( this );
208 lay->setSpacing( 3 ); 208 lay->setSpacing( 3 );
209 lay->setMargin( 3 ); 209 lay->setMargin( 3 );
210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
211 lay->addWidget( lab ); 211 lay->addWidget( lab );
212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
213 lay->addWidget( format ); 213 lay->addWidget( format );
214 format->setExclusive ( true ) ; 214 format->setExclusive ( true ) ;
215 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 215 simple = new QRadioButton(i18n("Simple: James Bond"), format );
216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
218 company = new QRadioButton(i18n("Organization: MI6"), format ); 218 company = new QRadioButton(i18n("Organization: MI6"), format );
219 simple->setChecked( true ); 219 simple->setChecked( true );
220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
221 lay->addWidget( setCompany ); 221 lay->addWidget( setCompany );
222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
223 lay->addWidget( ok ); 223 lay->addWidget( ok );
224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
225 lay->addWidget( cancel ); 225 lay->addWidget( cancel );
226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
228 resize( 200, 200 ); 228 //resize( 200, 200 );
229
229 } 230 }
230public: 231public:
231 QRadioButton* simple, *full, *reverse, *company; 232 QRadioButton* simple, *full, *reverse, *company;
232 QCheckBox* setCompany; 233 QCheckBox* setCompany;
233}; 234};
234 235
235 236
236 237
237class KAex2phonePrefs : public QDialog 238class KAex2phonePrefs : public QDialog
238{ 239{
239 public: 240 public:
240 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 241 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
241 QDialog( parent, name, true ) 242 QDialog( parent, name, true )
242 { 243 {
243 setCaption( i18n("Export to phone options") ); 244 setCaption( i18n("Export to phone options") );
244 QVBoxLayout* lay = new QVBoxLayout( this ); 245 QVBoxLayout* lay = new QVBoxLayout( this );
245 lay->setSpacing( 3 ); 246 lay->setSpacing( 3 );
246 lay->setMargin( 3 ); 247 lay->setMargin( 3 );
247 QLabel *lab; 248 QLabel *lab;
248 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 249 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
249 lab->setAlignment (AlignHCenter ); 250 lab->setAlignment (AlignHCenter );
250 QHBox* temphb; 251 QHBox* temphb;
251 temphb = new QHBox( this ); 252 temphb = new QHBox( this );
252 new QLabel( i18n("I/O device: "), temphb ); 253 new QLabel( i18n("I/O device: "), temphb );
253 mPhoneDevice = new QLineEdit( temphb); 254 mPhoneDevice = new QLineEdit( temphb);
254 lay->addWidget( temphb ); 255 lay->addWidget( temphb );
255 temphb = new QHBox( this ); 256 temphb = new QHBox( this );
256 new QLabel( i18n("Connection: "), temphb ); 257 new QLabel( i18n("Connection: "), temphb );
257 mPhoneConnection = new QLineEdit( temphb); 258 mPhoneConnection = new QLineEdit( temphb);
258 lay->addWidget( temphb ); 259 lay->addWidget( temphb );
259 temphb = new QHBox( this ); 260 temphb = new QHBox( this );
260 new QLabel( i18n("Model(opt.): "), temphb ); 261 new QLabel( i18n("Model(opt.): "), temphb );
261 mPhoneModel = new QLineEdit( temphb); 262 mPhoneModel = new QLineEdit( temphb);
262 lay->addWidget( temphb ); 263 lay->addWidget( temphb );
263 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 264 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
264 // lay->addWidget( mWriteToSim ); 265 // lay->addWidget( mWriteToSim );
265 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 266 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
266 lab->setAlignment (AlignHCenter); 267 lab->setAlignment (AlignHCenter);
267 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 268 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
268 lay->addWidget( ok ); 269 lay->addWidget( ok );
269 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 270 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
270 lay->addWidget( cancel ); 271 lay->addWidget( cancel );
271 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 272 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
272 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 273 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
273 resize( 220, 240 ); 274 resize( 220, 240 );
274 275
275 } 276 }
276 277
277public: 278public:
278 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 279 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
279 QCheckBox* mWriteToSim; 280 QCheckBox* mWriteToSim;
280}; 281};
281 282
282 283
283bool pasteWithNewUid = true; 284bool pasteWithNewUid = true;
284 285
285#ifdef KAB_EMBEDDED 286#ifdef KAB_EMBEDDED
286KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 287KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
287 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 288 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
288 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 289 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
289 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 290 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
290#else //KAB_EMBEDDED 291#else //KAB_EMBEDDED
291KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 292KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
292 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 293 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
293 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 294 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
294 mReadWrite( readWrite ), mModified( false ) 295 mReadWrite( readWrite ), mModified( false )
295#endif //KAB_EMBEDDED 296#endif //KAB_EMBEDDED
296{ 297{
297 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 298 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
298 // syncManager->setBlockSave(false); 299 // syncManager->setBlockSave(false);
299 mMiniSplitter = 0; 300 mMiniSplitter = 0;
300 mExtensionBarSplitter = 0; 301 mExtensionBarSplitter = 0;
301 mIsPart = !parent->inherits( "KAddressBookMain" ); 302 mIsPart = !parent->inherits( "KAddressBookMain" );
302 mAddressBook = KABC::StdAddressBook::self(); 303 mAddressBook = KABC::StdAddressBook::self();
303 KABC::StdAddressBook::setAutomaticSave( false ); 304 KABC::StdAddressBook::setAutomaticSave( false );
304 305
305#ifndef KAB_EMBEDDED 306#ifndef KAB_EMBEDDED
306 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 307 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
307#endif //KAB_EMBEDDED 308#endif //KAB_EMBEDDED
308 309
309 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 310 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
310 SLOT( addressBookChanged() ) ); 311 SLOT( addressBookChanged() ) );
311 312
312#if 0 313#if 0
313 // LP moved to addressbook init method 314 // LP moved to addressbook init method
314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 315 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
315 "X-Department", "KADDRESSBOOK" ); 316 "X-Department", "KADDRESSBOOK" );
316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
317 "X-Profession", "KADDRESSBOOK" ); 318 "X-Profession", "KADDRESSBOOK" );
318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
319 "X-AssistantsName", "KADDRESSBOOK" ); 320 "X-AssistantsName", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
321 "X-ManagersName", "KADDRESSBOOK" ); 322 "X-ManagersName", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 323 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
323 "X-SpousesName", "KADDRESSBOOK" ); 324 "X-SpousesName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
@@ -1280,193 +1281,194 @@ void KABCore::addEmail( QString aStr )
1280#endif //KAB_EMBEDDED 1281#endif //KAB_EMBEDDED
1281} 1282}
1282 1283
1283void KABCore::importVCard( const KURL &url, bool showPreview ) 1284void KABCore::importVCard( const KURL &url, bool showPreview )
1284{ 1285{
1285 mXXPortManager->importVCard( url, showPreview ); 1286 mXXPortManager->importVCard( url, showPreview );
1286} 1287}
1287void KABCore::importFromOL() 1288void KABCore::importFromOL()
1288{ 1289{
1289#ifdef _WIN32_ 1290#ifdef _WIN32_
1290 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1291 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1291 idgl->exec(); 1292 idgl->exec();
1292 KABC::Addressee::List list = idgl->getAddressList(); 1293 KABC::Addressee::List list = idgl->getAddressList();
1293 if ( list.count() > 0 ) { 1294 if ( list.count() > 0 ) {
1294 KABC::Addressee::List listNew; 1295 KABC::Addressee::List listNew;
1295 KABC::Addressee::List listExisting; 1296 KABC::Addressee::List listExisting;
1296 KABC::Addressee::List::Iterator it; 1297 KABC::Addressee::List::Iterator it;
1297 KABC::AddressBook::Iterator iter; 1298 KABC::AddressBook::Iterator iter;
1298 for ( it = list.begin(); it != list.end(); ++it ) { 1299 for ( it = list.begin(); it != list.end(); ++it ) {
1299 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1300 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1300 listNew.append( (*it) ); 1301 listNew.append( (*it) );
1301 else 1302 else
1302 listExisting.append( (*it) ); 1303 listExisting.append( (*it) );
1303 } 1304 }
1304 if ( listExisting.count() > 0 ) 1305 if ( listExisting.count() > 0 )
1305 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1306 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1306 if ( listNew.count() > 0 ) { 1307 if ( listNew.count() > 0 ) {
1307 pasteWithNewUid = false; 1308 pasteWithNewUid = false;
1308 pasteContacts( listNew ); 1309 pasteContacts( listNew );
1309 pasteWithNewUid = true; 1310 pasteWithNewUid = true;
1310 } 1311 }
1311 } 1312 }
1312 delete idgl; 1313 delete idgl;
1313#endif 1314#endif
1314} 1315}
1315 1316
1316void KABCore::importVCard( const QString &vCard, bool showPreview ) 1317void KABCore::importVCard( const QString &vCard, bool showPreview )
1317{ 1318{
1318 mXXPortManager->importVCard( vCard, showPreview ); 1319 mXXPortManager->importVCard( vCard, showPreview );
1319} 1320}
1320 1321
1321//US added a second method without defaultparameter 1322//US added a second method without defaultparameter
1322void KABCore::editContact2() { 1323void KABCore::editContact2() {
1323 editContact( QString::null ); 1324 editContact( QString::null );
1324} 1325}
1325 1326
1326void KABCore::editContact( const QString &uid ) 1327void KABCore::editContact( const QString &uid )
1327{ 1328{
1328 1329
1329 if ( mExtensionManager->isQuickEditVisible() ) 1330 if ( mExtensionManager->isQuickEditVisible() )
1330 return; 1331 return;
1331 1332
1332 // First, locate the contact entry 1333 // First, locate the contact entry
1333 QString localUID = uid; 1334 QString localUID = uid;
1334 if ( localUID.isNull() ) { 1335 if ( localUID.isNull() ) {
1335 QStringList uidList = mViewManager->selectedUids(); 1336 QStringList uidList = mViewManager->selectedUids();
1336 if ( uidList.count() > 0 ) 1337 if ( uidList.count() > 0 )
1337 localUID = *( uidList.at( 0 ) ); 1338 localUID = *( uidList.at( 0 ) );
1338 } 1339 }
1339 1340
1340 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1341 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1341 if ( !addr.isEmpty() ) { 1342 if ( !addr.isEmpty() ) {
1342 mEditorDialog->setAddressee( addr ); 1343 mEditorDialog->setAddressee( addr );
1343 KApplication::execDialog ( mEditorDialog ); 1344 KApplication::execDialog ( mEditorDialog );
1344 } 1345 }
1345} 1346}
1346 1347
1347/** 1348/**
1348 Shows or edits the detail view for the given uid. If the uid is QString::null, 1349 Shows or edits the detail view for the given uid. If the uid is QString::null,
1349 the method will try to find a selected addressee in the view. 1350 the method will try to find a selected addressee in the view.
1350 */ 1351 */
1351void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1352{ 1353{
1353 if ( mMultipleViewsAtOnce ) 1354 if ( mMultipleViewsAtOnce )
1354 { 1355 {
1355 editContact( uid ); 1356 editContact( uid );
1356 } 1357 }
1357 else 1358 else
1358 { 1359 {
1359 setDetailsVisible( true ); 1360 setDetailsVisible( true );
1360 mActionDetails->setChecked(true); 1361 mActionDetails->setChecked(true);
1361 } 1362 }
1362 1363
1363} 1364}
1364 1365
1365void KABCore::save() 1366void KABCore::save()
1366{ 1367{
1367 if (syncManager->blockSave()) 1368 if (syncManager->blockSave())
1368 return; 1369 return;
1369 if ( !mModified ) 1370 if ( !mModified )
1370 return; 1371 return;
1371 1372
1372 syncManager->setBlockSave(true); 1373 syncManager->setBlockSave(true);
1373 QString text = i18n( "There was an error while attempting to save\n the " 1374 QString text = i18n( "There was an error while attempting to save\n the "
1374 "address book. Please check that some \nother application is " 1375 "address book. Please check that some \nother application is "
1375 "not using it. " ); 1376 "not using it. " );
1376 message(i18n("Saving addressbook ... ")); 1377 message(i18n("Saving ... please wait! "));
1378 qApp->processEvents();
1377#ifndef KAB_EMBEDDED 1379#ifndef KAB_EMBEDDED
1378 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1379 if ( !b || !b->save() ) { 1381 if ( !b || !b->save() ) {
1380 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1381 } 1383 }
1382#else //KAB_EMBEDDED 1384#else //KAB_EMBEDDED
1383 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1384 if ( !b || !b->save() ) { 1386 if ( !b || !b->save() ) {
1385 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1386 } 1388 }
1387#endif //KAB_EMBEDDED 1389#endif //KAB_EMBEDDED
1388 1390
1389 message(i18n("Addressbook saved!")); 1391 message(i18n("Addressbook saved!"));
1390 setModified( false ); 1392 setModified( false );
1391 syncManager->setBlockSave(false); 1393 syncManager->setBlockSave(false);
1392} 1394}
1393 1395
1394 1396
1395void KABCore::undo() 1397void KABCore::undo()
1396{ 1398{
1397 UndoStack::instance()->undo(); 1399 UndoStack::instance()->undo();
1398 1400
1399 // Refresh the view 1401 // Refresh the view
1400 mViewManager->refreshView(); 1402 mViewManager->refreshView();
1401} 1403}
1402 1404
1403void KABCore::redo() 1405void KABCore::redo()
1404{ 1406{
1405 RedoStack::instance()->redo(); 1407 RedoStack::instance()->redo();
1406 1408
1407 // Refresh the view 1409 // Refresh the view
1408 mViewManager->refreshView(); 1410 mViewManager->refreshView();
1409} 1411}
1410 1412
1411void KABCore::setJumpButtonBarVisible( bool visible ) 1413void KABCore::setJumpButtonBarVisible( bool visible )
1412{ 1414{
1413 if (mMultipleViewsAtOnce) 1415 if (mMultipleViewsAtOnce)
1414 { 1416 {
1415 if ( visible ) 1417 if ( visible )
1416 mJumpButtonBar->show(); 1418 mJumpButtonBar->show();
1417 else 1419 else
1418 mJumpButtonBar->hide(); 1420 mJumpButtonBar->hide();
1419 } 1421 }
1420 else 1422 else
1421 { 1423 {
1422 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1423 if (mViewManager->isVisible()) 1425 if (mViewManager->isVisible())
1424 { 1426 {
1425 if ( visible ) 1427 if ( visible )
1426 mJumpButtonBar->show(); 1428 mJumpButtonBar->show();
1427 else 1429 else
1428 mJumpButtonBar->hide(); 1430 mJumpButtonBar->hide();
1429 } 1431 }
1430 else 1432 else
1431 { 1433 {
1432 mJumpButtonBar->hide(); 1434 mJumpButtonBar->hide();
1433 } 1435 }
1434 } 1436 }
1435} 1437}
1436 1438
1437 1439
1438void KABCore::setDetailsToState() 1440void KABCore::setDetailsToState()
1439{ 1441{
1440 setDetailsVisible( mActionDetails->isChecked() ); 1442 setDetailsVisible( mActionDetails->isChecked() );
1441} 1443}
1442void KABCore::setDetailsToggle() 1444void KABCore::setDetailsToggle()
1443{ 1445{
1444 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1446 mActionDetails->setChecked( !mActionDetails->isChecked() );
1445 setDetailsToState(); 1447 setDetailsToState();
1446} 1448}
1447 1449
1448 1450
1449 1451
1450void KABCore::setDetailsVisible( bool visible ) 1452void KABCore::setDetailsVisible( bool visible )
1451{ 1453{
1452 if (visible && mDetails->isHidden()) 1454 if (visible && mDetails->isHidden())
1453 { 1455 {
1454 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1456 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1455 if ( addrList.count() > 0 ) 1457 if ( addrList.count() > 0 )
1456 mDetails->setAddressee( addrList[ 0 ] ); 1458 mDetails->setAddressee( addrList[ 0 ] );
1457 } 1459 }
1458 1460
1459 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1461 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1460 // the listview and the detailview. We do that by changing the splitbar size. 1462 // the listview and the detailview. We do that by changing the splitbar size.
1461 if (mMultipleViewsAtOnce) 1463 if (mMultipleViewsAtOnce)
1462 { 1464 {
1463 if ( visible ) 1465 if ( visible )
1464 mDetails->show(); 1466 mDetails->show();
1465 else 1467 else
1466 mDetails->hide(); 1468 mDetails->hide();
1467 } 1469 }
1468 else 1470 else
1469 { 1471 {
1470 if ( visible ) { 1472 if ( visible ) {
1471 mViewManager->hide(); 1473 mViewManager->hide();
1472 mDetails->show(); 1474 mDetails->show();
@@ -2270,217 +2272,223 @@ void KABCore::addActionsManually()
2270*/ 2272*/
2271 2273
2272#endif //KAB_EMBEDDED 2274#endif //KAB_EMBEDDED
2273 2275
2274 mActionExport2phone->plug( ExportMenu ); 2276 mActionExport2phone->plug( ExportMenu );
2275 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2276 syncManager->fillSyncMenu(); 2278 syncManager->fillSyncMenu();
2277 2279
2278} 2280}
2279void KABCore::showLicence() 2281void KABCore::showLicence()
2280{ 2282{
2281 KApplication::showLicence(); 2283 KApplication::showLicence();
2282} 2284}
2283 2285
2284void KABCore::manageCategories( ) 2286void KABCore::manageCategories( )
2285{ 2287{
2286 KABCatPrefs* cp = new KABCatPrefs(); 2288 KABCatPrefs* cp = new KABCatPrefs();
2287 cp->show(); 2289 cp->show();
2288 int w =cp->sizeHint().width() ; 2290 int w =cp->sizeHint().width() ;
2289 int h = cp->sizeHint().height() ; 2291 int h = cp->sizeHint().height() ;
2290 int dw = QApplication::desktop()->width(); 2292 int dw = QApplication::desktop()->width();
2291 int dh = QApplication::desktop()->height(); 2293 int dh = QApplication::desktop()->height();
2292 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2293 if ( !cp->exec() ) { 2295 if ( !cp->exec() ) {
2294 delete cp; 2296 delete cp;
2295 return; 2297 return;
2296 } 2298 }
2297 int count = 0; 2299 int count = 0;
2298 message( i18n("Please wait, processing categories...")); 2300 message( i18n("Please wait, processing categories..."));
2299 if ( cp->addCat() ) { 2301 if ( cp->addCat() ) {
2300 KABC::AddressBook::Iterator it; 2302 KABC::AddressBook::Iterator it;
2301 QStringList catList = KABPrefs::instance()->mCustomCategories; 2303 QStringList catList = KABPrefs::instance()->mCustomCategories;
2302 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2304 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2303 QStringList catIncList = (*it).categories(); 2305 QStringList catIncList = (*it).categories();
2304 int i; 2306 int i;
2305 for( i = 0; i< catIncList.count(); ++i ) { 2307 for( i = 0; i< catIncList.count(); ++i ) {
2306 if ( !catList.contains (catIncList[i])) { 2308 if ( !catList.contains (catIncList[i])) {
2307 catList.append( catIncList[i] ); 2309 catList.append( catIncList[i] );
2308 //qDebug("add cat %s ", catIncList[i].latin1()); 2310 //qDebug("add cat %s ", catIncList[i].latin1());
2309 ++count; 2311 ++count;
2310 } 2312 }
2311 } 2313 }
2312 } 2314 }
2313 catList.sort(); 2315 catList.sort();
2314 KABPrefs::instance()->mCustomCategories = catList; 2316 KABPrefs::instance()->mCustomCategories = catList;
2315 KABPrefs::instance()->writeConfig(); 2317 KABPrefs::instance()->writeConfig();
2316 message(QString::number( count )+ i18n(" categories added to list! ")); 2318 message(QString::number( count )+ i18n(" categories added to list! "));
2317 } else { 2319 } else {
2318 QStringList catList = KABPrefs::instance()->mCustomCategories; 2320 QStringList catList = KABPrefs::instance()->mCustomCategories;
2319 QStringList catIncList; 2321 QStringList catIncList;
2320 QStringList newCatList; 2322 QStringList newCatList;
2321 KABC::AddressBook::Iterator it; 2323 KABC::AddressBook::Iterator it;
2322 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2324 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2323 QStringList catIncList = (*it).categories(); 2325 QStringList catIncList = (*it).categories();
2324 int i; 2326 int i;
2325 if ( catIncList.count() ) { 2327 if ( catIncList.count() ) {
2326 newCatList.clear(); 2328 newCatList.clear();
2327 for( i = 0; i< catIncList.count(); ++i ) { 2329 for( i = 0; i< catIncList.count(); ++i ) {
2328 if ( catList.contains (catIncList[i])) { 2330 if ( catList.contains (catIncList[i])) {
2329 newCatList.append( catIncList[i] ); 2331 newCatList.append( catIncList[i] );
2330 } 2332 }
2331 } 2333 }
2332 newCatList.sort(); 2334 newCatList.sort();
2333 (*it).setCategories( newCatList ); 2335 (*it).setCategories( newCatList );
2334 mAddressBook->insertAddressee( (*it) ); 2336 mAddressBook->insertAddressee( (*it) );
2335 } 2337 }
2336 } 2338 }
2337 setModified( true ); 2339 setModified( true );
2338 mViewManager->refreshView(); 2340 mViewManager->refreshView();
2339 message( i18n("Removing categories done!")); 2341 message( i18n("Removing categories done!"));
2340 } 2342 }
2341 delete cp; 2343 delete cp;
2342} 2344}
2343void KABCore::removeVoice() 2345void KABCore::removeVoice()
2344{ 2346{
2345 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2347 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2346 return; 2348 return;
2347 KABC::Addressee::List list; 2349 KABC::Addressee::List list;
2348 XXPortSelectDialog dlg( this, false, this ); 2350 XXPortSelectDialog dlg( this, false, this );
2349 if ( dlg.exec() ) 2351 if ( dlg.exec() )
2350 list = dlg.contacts(); 2352 list = dlg.contacts();
2351 else 2353 else
2352 return; 2354 return;
2353 KABC::Addressee::List::Iterator it; 2355 KABC::Addressee::List::Iterator it;
2354 for ( it = list.begin(); it != list.end(); ++it ) { 2356 for ( it = list.begin(); it != list.end(); ++it ) {
2355 if ( (*it).removeVoice() ) 2357 if ( (*it).removeVoice() )
2356 addrModified((*it), false ); 2358 addrModified((*it), false );
2357 } 2359 }
2358} 2360}
2359 2361
2360void KABCore::setFormattedName() 2362void KABCore::setFormattedName()
2361{ 2363{
2362 KABFormatPrefs setpref; 2364 KABFormatPrefs setpref;
2363 if ( !setpref.exec() ) { 2365 if ( !setpref.exec() ) {
2364 return; 2366 return;
2365 } 2367 }
2366 KABC::Addressee::List list;
2367 XXPortSelectDialog dlg( this, false, this ); 2368 XXPortSelectDialog dlg( this, false, this );
2368 if ( dlg.exec() ) 2369 if ( !dlg.exec() )
2369 list = dlg.contacts();
2370 else
2371 return; 2370 return;
2372 KABC::Addressee::List::Iterator it; 2371 mAddressBook->setUntagged();
2373 for ( it = list.begin(); it != list.end(); ++it ) { 2372 dlg.tagSelected();
2374 QString fName; 2373 int count = 0;
2375 if ( setpref.simple->isChecked() ) 2374 KABC::AddressBook::Iterator it;
2376 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2375 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2377 else if ( setpref.full->isChecked() ) 2376 if ( (*it).tagged() ) {
2378 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2377 message(i18n("Changing contact #%1").arg( ++count ) );
2379 else if ( setpref.reverse->isChecked() ) 2378 qApp->processEvents();
2380 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2379 QString fName;
2381 else 2380 if ( setpref.simple->isChecked() )
2382 fName = (*it).organization(); 2381 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2383 if ( setpref.setCompany->isChecked() ) 2382 else if ( setpref.full->isChecked() )
2384 if ( fName.isEmpty() || fName =="," ) 2383 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2384 else if ( setpref.reverse->isChecked() )
2385 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2386 else
2385 fName = (*it).organization(); 2387 fName = (*it).organization();
2386 (*it).setFormattedName( fName ); 2388 if ( setpref.setCompany->isChecked() )
2387 addrModified((*it),false ); 2389 if ( fName.isEmpty() || fName =="," )
2390 fName = (*it).organization();
2391 (*it).setFormattedName( fName );
2392 }
2388 } 2393 }
2394 message(i18n("Refreshing view...") );
2395 mViewManager->refreshView( "" );
2389 Addressee add; 2396 Addressee add;
2390 mDetails->setAddressee( add ); 2397 mDetails->setAddressee( add );
2398 message(i18n("Setting formatted name completed!") );
2391} 2399}
2392 2400
2393void KABCore::clipboardDataChanged() 2401void KABCore::clipboardDataChanged()
2394{ 2402{
2395 2403
2396 if ( mReadWrite ) 2404 if ( mReadWrite )
2397 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2405 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2398 2406
2399} 2407}
2400 2408
2401void KABCore::updateActionMenu() 2409void KABCore::updateActionMenu()
2402{ 2410{
2403 UndoStack *undo = UndoStack::instance(); 2411 UndoStack *undo = UndoStack::instance();
2404 RedoStack *redo = RedoStack::instance(); 2412 RedoStack *redo = RedoStack::instance();
2405 2413
2406 if ( undo->isEmpty() ) 2414 if ( undo->isEmpty() )
2407 mActionUndo->setText( i18n( "Undo" ) ); 2415 mActionUndo->setText( i18n( "Undo" ) );
2408 else 2416 else
2409 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2417 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2410 2418
2411 mActionUndo->setEnabled( !undo->isEmpty() ); 2419 mActionUndo->setEnabled( !undo->isEmpty() );
2412 2420
2413 if ( !redo->top() ) 2421 if ( !redo->top() )
2414 mActionRedo->setText( i18n( "Redo" ) ); 2422 mActionRedo->setText( i18n( "Redo" ) );
2415 else 2423 else
2416 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2424 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2417 2425
2418 mActionRedo->setEnabled( !redo->isEmpty() ); 2426 mActionRedo->setEnabled( !redo->isEmpty() );
2419} 2427}
2420 2428
2421void KABCore::configureKeyBindings() 2429void KABCore::configureKeyBindings()
2422{ 2430{
2423#ifndef KAB_EMBEDDED 2431#ifndef KAB_EMBEDDED
2424 KKeyDialog::configure( actionCollection(), true ); 2432 KKeyDialog::configure( actionCollection(), true );
2425#else //KAB_EMBEDDED 2433#else //KAB_EMBEDDED
2426 qDebug("KABCore::configureKeyBindings() not implemented"); 2434 qDebug("KABCore::configureKeyBindings() not implemented");
2427#endif //KAB_EMBEDDED 2435#endif //KAB_EMBEDDED
2428} 2436}
2429 2437
2430#ifdef KAB_EMBEDDED 2438#ifdef KAB_EMBEDDED
2431void KABCore::configureResources() 2439void KABCore::configureResources()
2432{ 2440{
2433 KRES::KCMKResources dlg( this, "" , 0 ); 2441 KRES::KCMKResources dlg( this, "" , 0 );
2434 2442
2435 if ( !dlg.exec() ) 2443 if ( !dlg.exec() )
2436 return; 2444 return;
2437 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2445 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2438} 2446}
2439#endif //KAB_EMBEDDED 2447#endif //KAB_EMBEDDED
2440 2448
2441 2449
2442/* this method will be called through the QCop interface from Ko/Pi to select addresses 2450/* this method will be called through the QCop interface from Ko/Pi to select addresses
2443 * for the attendees list of an event. 2451 * for the attendees list of an event.
2444 */ 2452 */
2445void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2453void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2446{ 2454{
2447 QStringList nameList; 2455 QStringList nameList;
2448 QStringList emailList; 2456 QStringList emailList;
2449 QStringList uidList; 2457 QStringList uidList;
2450 2458
2451 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2459 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2452 uint i=0; 2460 uint i=0;
2453 for (i=0; i < list.count(); i++) 2461 for (i=0; i < list.count(); i++)
2454 { 2462 {
2455 nameList.append(list[i].realName()); 2463 nameList.append(list[i].realName());
2456 emailList.append(list[i].preferredEmail()); 2464 emailList.append(list[i].preferredEmail());
2457 uidList.append(list[i].uid()); 2465 uidList.append(list[i].uid());
2458 } 2466 }
2459 2467
2460 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2468 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2461 2469
2462} 2470}
2463 2471
2464/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2472/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2465 * to put them into the calendar. 2473 * to put them into the calendar.
2466 */ 2474 */
2467void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2475void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2468{ 2476{
2469 // qDebug("KABCore::requestForBirthdayList"); 2477 // qDebug("KABCore::requestForBirthdayList");
2470 QStringList birthdayList; 2478 QStringList birthdayList;
2471 QStringList anniversaryList; 2479 QStringList anniversaryList;
2472 QStringList realNameList; 2480 QStringList realNameList;
2473 QStringList preferredEmailList; 2481 QStringList preferredEmailList;
2474 QStringList assembledNameList; 2482 QStringList assembledNameList;
2475 QStringList uidList; 2483 QStringList uidList;
2476 2484
2477 KABC::AddressBook::Iterator it; 2485 KABC::AddressBook::Iterator it;
2478 2486
2479 int count = 0; 2487 int count = 0;
2480 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2488 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2481 ++count; 2489 ++count;
2482 } 2490 }
2483 QProgressBar bar(count,0 ); 2491 QProgressBar bar(count,0 );
2484 int w = 300; 2492 int w = 300;
2485 if ( QApplication::desktop()->width() < 320 ) 2493 if ( QApplication::desktop()->width() < 320 )
2486 w = 220; 2494 w = 220;
@@ -3113,164 +3121,164 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3113 AddressBook abLocal(filename,"syncContact"); 3121 AddressBook abLocal(filename,"syncContact");
3114 bool syncOK = false; 3122 bool syncOK = false;
3115 if ( abLocal.load() ) { 3123 if ( abLocal.load() ) {
3116 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3124 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3117 bool external = false; 3125 bool external = false;
3118 bool isXML = false; 3126 bool isXML = false;
3119 if ( filename.right(4) == ".xml") { 3127 if ( filename.right(4) == ".xml") {
3120 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3128 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3121 isXML = true; 3129 isXML = true;
3122 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3130 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3123 } else { 3131 } else {
3124 external = !manager->mIsKapiFile; 3132 external = !manager->mIsKapiFile;
3125 if ( external ) { 3133 if ( external ) {
3126 qDebug("Setting vcf mode to external "); 3134 qDebug("Setting vcf mode to external ");
3127 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3135 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3128 AddressBook::Iterator it; 3136 AddressBook::Iterator it;
3129 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3137 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3130 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3138 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3131 (*it).computeCsum( mCurrentSyncDevice ); 3139 (*it).computeCsum( mCurrentSyncDevice );
3132 } 3140 }
3133 } 3141 }
3134 } 3142 }
3135 //AddressBook::Iterator it; 3143 //AddressBook::Iterator it;
3136 //QStringList vcards; 3144 //QStringList vcards;
3137 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3145 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3138 // qDebug("Name %s ", (*it).familyName().latin1()); 3146 // qDebug("Name %s ", (*it).familyName().latin1());
3139 //} 3147 //}
3140 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3148 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3141 if ( syncOK ) { 3149 if ( syncOK ) {
3142 if ( syncManager->mWriteBackFile ) 3150 if ( syncManager->mWriteBackFile )
3143 { 3151 {
3144 if ( external ) 3152 if ( external )
3145 abLocal.removeSyncAddressees( !isXML); 3153 abLocal.removeSyncAddressees( !isXML);
3146 qDebug("Saving remote AB "); 3154 qDebug("Saving remote AB ");
3147 if ( ! abLocal.saveAB()) 3155 if ( ! abLocal.saveAB())
3148 qDebug("Error writing back AB to file "); 3156 qDebug("Error writing back AB to file ");
3149 if ( external ) { 3157 if ( external ) {
3150 // afterwrite processing 3158 // afterwrite processing
3151 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3159 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3152 } 3160 }
3153 } 3161 }
3154 } 3162 }
3155 setModified(); 3163 setModified();
3156 3164
3157 } 3165 }
3158 abLocal.removeResources(); 3166 abLocal.removeResources();
3159 if ( syncOK ) 3167 if ( syncOK )
3160 mViewManager->refreshView(); 3168 mViewManager->refreshView();
3161 return syncOK; 3169 return syncOK;
3162 3170
3163} 3171}
3164void KABCore::removeSyncInfo( QString syncProfile) 3172void KABCore::removeSyncInfo( QString syncProfile)
3165{ 3173{
3166 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3174 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3167 mAddressBook->removeSyncInfo( syncProfile ); 3175 mAddressBook->removeSyncInfo( syncProfile );
3168 setModified(); 3176 setModified();
3169} 3177}
3170 3178
3171 3179
3172//this is a overwritten callbackmethods from the syncinterface 3180//this is a overwritten callbackmethods from the syncinterface
3173bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3181bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3174{ 3182{
3175 if ( resource == "phone" ) 3183 if ( resource == "phone" )
3176 return syncPhone(); 3184 return syncPhone();
3177 disableBR( true ); 3185 disableBR( true );
3178 if ( manager != syncManager ) 3186 if ( manager != syncManager )
3179 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3187 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3180 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3188 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3181 3189
3182 AddressBook abLocal( resource,"syncContact"); 3190 AddressBook abLocal( resource,"syncContact");
3183 bool syncOK = false; 3191 bool syncOK = false;
3184 if ( abLocal.load() ) { 3192 if ( abLocal.load() ) {
3185 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3193 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3186 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3194 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3187 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3195 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3188 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3196 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3189 if ( syncOK ) { 3197 if ( syncOK ) {
3190 if ( syncManager->mWriteBackFile ) { 3198 if ( syncManager->mWriteBackFile ) {
3191 abLocal.removeSyncAddressees( false ); 3199 abLocal.removeSyncAddressees( false );
3192 abLocal.saveAB(); 3200 abLocal.saveAB();
3193 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3201 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3194 } 3202 }
3195 } else 3203 } else
3196 message( i18n("Sync cancelled or failed.") ); 3204 message( i18n("Sync cancelled or failed.") );
3197 setModified(); 3205 setModified();
3198 } 3206 }
3199 abLocal.removeResources(); 3207 abLocal.removeResources();
3200 if ( syncOK ) 3208 if ( syncOK )
3201 mViewManager->refreshView(); 3209 mViewManager->refreshView();
3202 disableBR( false ); 3210 disableBR( false );
3203 return syncOK; 3211 return syncOK;
3204 3212
3205} 3213}
3206void KABCore::message( QString m ) 3214void KABCore::message( QString m )
3207{ 3215{
3208 topLevelWidget()->setCaption( m ); 3216 topLevelWidget()->setCaption( m );
3209 mMessageTimer->start( 15000, true ); 3217 mMessageTimer->start( 20000, true );
3210} 3218}
3211bool KABCore::syncPhone() 3219bool KABCore::syncPhone()
3212{ 3220{
3213 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3221 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3214 QString fileName = getPhoneFile(); 3222 QString fileName = getPhoneFile();
3215 if ( !PhoneAccess::readFromPhone( fileName) ) { 3223 if ( !PhoneAccess::readFromPhone( fileName) ) {
3216 message(i18n("Phone access failed!")); 3224 message(i18n("Phone access failed!"));
3217 return false; 3225 return false;
3218 } 3226 }
3219 AddressBook abLocal( fileName,"syncContact"); 3227 AddressBook abLocal( fileName,"syncContact");
3220 bool syncOK = false; 3228 bool syncOK = false;
3221 { 3229 {
3222 abLocal.importFromFile( fileName ); 3230 abLocal.importFromFile( fileName );
3223 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3231 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3224 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3232 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3225 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3233 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3226 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3234 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3227 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3235 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3228 if ( syncOK ) { 3236 if ( syncOK ) {
3229 if ( syncManager->mWriteBackFile ) { 3237 if ( syncManager->mWriteBackFile ) {
3230 abLocal.removeSyncAddressees( true ); 3238 abLocal.removeSyncAddressees( true );
3231 abLocal.saveABphone( fileName ); 3239 abLocal.saveABphone( fileName );
3232 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3240 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3233 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3241 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3234 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3242 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3235 } 3243 }
3236 } 3244 }
3237 setModified(); 3245 setModified();
3238 } 3246 }
3239 abLocal.removeResources(); 3247 abLocal.removeResources();
3240 if ( syncOK ) 3248 if ( syncOK )
3241 mViewManager->refreshView(); 3249 mViewManager->refreshView();
3242 return syncOK; 3250 return syncOK;
3243} 3251}
3244void KABCore::getFile( bool success ) 3252void KABCore::getFile( bool success )
3245{ 3253{
3246 if ( ! success ) { 3254 if ( ! success ) {
3247 message( i18n("Error receiving file. Nothing changed!") ); 3255 message( i18n("Error receiving file. Nothing changed!") );
3248 return; 3256 return;
3249 } 3257 }
3250 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3258 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3251 if ( count ) 3259 if ( count )
3252 setModified( true ); 3260 setModified( true );
3253 message( i18n("Pi-Sync successful!") ); 3261 message( i18n("Pi-Sync successful!") );
3254 mViewManager->refreshView(); 3262 mViewManager->refreshView();
3255} 3263}
3256void KABCore::syncFileRequest() 3264void KABCore::syncFileRequest()
3257{ 3265{
3258 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3266 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3259 syncManager->slotSyncMenu( 999 ); 3267 syncManager->slotSyncMenu( 999 );
3260 } 3268 }
3261 mAddressBook->export2File( sentSyncFile() ); 3269 mAddressBook->export2File( sentSyncFile() );
3262} 3270}
3263QString KABCore::sentSyncFile() 3271QString KABCore::sentSyncFile()
3264{ 3272{
3265#ifdef DESKTOP_VERSION 3273#ifdef DESKTOP_VERSION
3266 return locateLocal( "tmp", "copysyncab.vcf" ); 3274 return locateLocal( "tmp", "copysyncab.vcf" );
3267#else 3275#else
3268 return QString( "/tmp/copysyncab.vcf" ); 3276 return QString( "/tmp/copysyncab.vcf" );
3269#endif 3277#endif
3270} 3278}
3271 3279
3272void KABCore::setCaptionBack() 3280void KABCore::setCaptionBack()
3273{ 3281{
3274 mMessageTimer->stop(); 3282 mMessageTimer->stop();
3275 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3283 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3276} 3284}