-rw-r--r-- | kaddressbook/kabcore.cpp | 8 | ||||
-rw-r--r-- | kaddressbook/kabprefs.cpp | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 939296f..9b059d3 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -225,196 +225,197 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
225 | 225 | ||
226 | mAddressBook = KABC::StdAddressBook::self(); | 226 | mAddressBook = KABC::StdAddressBook::self(); |
227 | KABC::StdAddressBook::setAutomaticSave( false ); | 227 | KABC::StdAddressBook::setAutomaticSave( false ); |
228 | 228 | ||
229 | #ifndef KAB_EMBEDDED | 229 | #ifndef KAB_EMBEDDED |
230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 230 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
231 | #endif //KAB_EMBEDDED | 231 | #endif //KAB_EMBEDDED |
232 | 232 | ||
233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 233 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
234 | SLOT( addressBookChanged() ) ); | 234 | SLOT( addressBookChanged() ) ); |
235 | 235 | ||
236 | #if 0 | 236 | #if 0 |
237 | // LP moved to addressbook init method | 237 | // LP moved to addressbook init method |
238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 238 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
239 | "X-Department", "KADDRESSBOOK" ); | 239 | "X-Department", "KADDRESSBOOK" ); |
240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 240 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
241 | "X-Profession", "KADDRESSBOOK" ); | 241 | "X-Profession", "KADDRESSBOOK" ); |
242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 242 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
243 | "X-AssistantsName", "KADDRESSBOOK" ); | 243 | "X-AssistantsName", "KADDRESSBOOK" ); |
244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 244 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
245 | "X-ManagersName", "KADDRESSBOOK" ); | 245 | "X-ManagersName", "KADDRESSBOOK" ); |
246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 246 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
247 | "X-SpousesName", "KADDRESSBOOK" ); | 247 | "X-SpousesName", "KADDRESSBOOK" ); |
248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 248 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
249 | "X-Office", "KADDRESSBOOK" ); | 249 | "X-Office", "KADDRESSBOOK" ); |
250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 250 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
251 | "X-IMAddress", "KADDRESSBOOK" ); | 251 | "X-IMAddress", "KADDRESSBOOK" ); |
252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 252 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
253 | "X-Anniversary", "KADDRESSBOOK" ); | 253 | "X-Anniversary", "KADDRESSBOOK" ); |
254 | 254 | ||
255 | //US added this field to become compatible with Opie/qtopia addressbook | 255 | //US added this field to become compatible with Opie/qtopia addressbook |
256 | // values can be "female" or "male" or "". An empty field represents undefined. | 256 | // values can be "female" or "male" or "". An empty field represents undefined. |
257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 257 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
258 | "X-Gender", "KADDRESSBOOK" ); | 258 | "X-Gender", "KADDRESSBOOK" ); |
259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 259 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
260 | "X-Children", "KADDRESSBOOK" ); | 260 | "X-Children", "KADDRESSBOOK" ); |
261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, | 261 | mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, |
262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); | 262 | "X-FreeBusyUrl", "KADDRESSBOOK" ); |
263 | #endif | 263 | #endif |
264 | initGUI(); | 264 | initGUI(); |
265 | 265 | ||
266 | mIncSearchWidget->setFocus(); | 266 | mIncSearchWidget->setFocus(); |
267 | 267 | ||
268 | 268 | ||
269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 269 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
270 | SLOT( setContactSelected( const QString& ) ) ); | 270 | SLOT( setContactSelected( const QString& ) ) ); |
271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 271 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
272 | SLOT( executeContact( const QString& ) ) ); | 272 | SLOT( executeContact( const QString& ) ) ); |
273 | 273 | ||
274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 274 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
275 | SLOT( deleteContacts( ) ) ); | 275 | SLOT( deleteContacts( ) ) ); |
276 | connect( mViewManager, SIGNAL( modified() ), | 276 | connect( mViewManager, SIGNAL( modified() ), |
277 | SLOT( setModified() ) ); | 277 | SLOT( setModified() ) ); |
278 | 278 | ||
279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 279 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); | 280 | connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); |
281 | 281 | ||
282 | connect( mXXPortManager, SIGNAL( modified() ), | 282 | connect( mXXPortManager, SIGNAL( modified() ), |
283 | SLOT( setModified() ) ); | 283 | SLOT( setModified() ) ); |
284 | 284 | ||
285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 285 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
286 | SLOT( incrementalSearch( const QString& ) ) ); | 286 | SLOT( incrementalSearch( const QString& ) ) ); |
287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 287 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
288 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 288 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
289 | 289 | ||
290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 290 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
291 | SLOT( sendMail( const QString& ) ) ); | 291 | SLOT( sendMail( const QString& ) ) ); |
292 | 292 | ||
293 | 293 | ||
294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); | 294 | connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); |
295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 295 | connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); | 296 | connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); |
297 | 297 | ||
298 | 298 | ||
299 | #ifndef KAB_EMBEDDED | 299 | #ifndef KAB_EMBEDDED |
300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 300 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 301 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
302 | 302 | ||
303 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 303 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
304 | SLOT( browse( const QString& ) ) ); | 304 | SLOT( browse( const QString& ) ) ); |
305 | 305 | ||
306 | 306 | ||
307 | mAddressBookService = new KAddressBookService( this ); | 307 | mAddressBookService = new KAddressBookService( this ); |
308 | 308 | ||
309 | #endif //KAB_EMBEDDED | 309 | #endif //KAB_EMBEDDED |
310 | mEditorDialog = 0; | 310 | mEditorDialog = 0; |
311 | createAddresseeEditorDialog( this ); | 311 | createAddresseeEditorDialog( this ); |
312 | setModified( false ); | 312 | setModified( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | KABCore::~KABCore() | 315 | KABCore::~KABCore() |
316 | { | 316 | { |
317 | // save(); | 317 | // save(); |
318 | //saveSettings(); | 318 | //saveSettings(); |
319 | //KABPrefs::instance()->writeConfig(); | 319 | //KABPrefs::instance()->writeConfig(); |
320 | delete AddresseeConfig::instance(); | 320 | delete AddresseeConfig::instance(); |
321 | mAddressBook = 0; | 321 | mAddressBook = 0; |
322 | KABC::StdAddressBook::close(); | 322 | KABC::StdAddressBook::close(); |
323 | |||
324 | delete syncManager; | ||
323 | 325 | ||
324 | delete syncManager; | ||
325 | } | 326 | } |
326 | 327 | ||
327 | void KABCore::restoreSettings() | 328 | void KABCore::restoreSettings() |
328 | { | 329 | { |
329 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 330 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
330 | 331 | ||
331 | bool state; | 332 | bool state; |
332 | 333 | ||
333 | if (mMultipleViewsAtOnce) | 334 | if (mMultipleViewsAtOnce) |
334 | state = KABPrefs::instance()->mDetailsPageVisible; | 335 | state = KABPrefs::instance()->mDetailsPageVisible; |
335 | else | 336 | else |
336 | state = false; | 337 | state = false; |
337 | 338 | ||
338 | mActionDetails->setChecked( state ); | 339 | mActionDetails->setChecked( state ); |
339 | setDetailsVisible( state ); | 340 | setDetailsVisible( state ); |
340 | 341 | ||
341 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 342 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
342 | 343 | ||
343 | mActionJumpBar->setChecked( state ); | 344 | mActionJumpBar->setChecked( state ); |
344 | setJumpButtonBarVisible( state ); | 345 | setJumpButtonBarVisible( state ); |
345 | /*US | 346 | /*US |
346 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 347 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
347 | if ( splitterSize.count() == 0 ) { | 348 | if ( splitterSize.count() == 0 ) { |
348 | splitterSize.append( width() / 2 ); | 349 | splitterSize.append( width() / 2 ); |
349 | splitterSize.append( width() / 2 ); | 350 | splitterSize.append( width() / 2 ); |
350 | } | 351 | } |
351 | mMiniSplitter->setSizes( splitterSize ); | 352 | mMiniSplitter->setSizes( splitterSize ); |
352 | if ( mExtensionBarSplitter ) { | 353 | if ( mExtensionBarSplitter ) { |
353 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 354 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
354 | if ( splitterSize.count() == 0 ) { | 355 | if ( splitterSize.count() == 0 ) { |
355 | splitterSize.append( width() / 2 ); | 356 | splitterSize.append( width() / 2 ); |
356 | splitterSize.append( width() / 2 ); | 357 | splitterSize.append( width() / 2 ); |
357 | } | 358 | } |
358 | mExtensionBarSplitter->setSizes( splitterSize ); | 359 | mExtensionBarSplitter->setSizes( splitterSize ); |
359 | 360 | ||
360 | } | 361 | } |
361 | */ | 362 | */ |
362 | mViewManager->restoreSettings(); | 363 | mViewManager->restoreSettings(); |
363 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 364 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
364 | mExtensionManager->restoreSettings(); | 365 | mExtensionManager->restoreSettings(); |
365 | #ifdef DESKTOP_VERSION | 366 | #ifdef DESKTOP_VERSION |
366 | int wid = width(); | 367 | int wid = width(); |
367 | if ( wid < 10 ) | 368 | if ( wid < 10 ) |
368 | wid = 400; | 369 | wid = 400; |
369 | #else | 370 | #else |
370 | int wid = QApplication::desktop()->width(); | 371 | int wid = QApplication::desktop()->width(); |
371 | if ( wid < 640 ) | 372 | if ( wid < 640 ) |
372 | wid = QApplication::desktop()->height(); | 373 | wid = QApplication::desktop()->height(); |
373 | #endif | 374 | #endif |
374 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 375 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
375 | if ( true /*splitterSize.count() == 0*/ ) { | 376 | if ( true /*splitterSize.count() == 0*/ ) { |
376 | splitterSize.append( wid / 2 ); | 377 | splitterSize.append( wid / 2 ); |
377 | splitterSize.append( wid / 2 ); | 378 | splitterSize.append( wid / 2 ); |
378 | } | 379 | } |
379 | mMiniSplitter->setSizes( splitterSize ); | 380 | mMiniSplitter->setSizes( splitterSize ); |
380 | if ( mExtensionBarSplitter ) { | 381 | if ( mExtensionBarSplitter ) { |
381 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 382 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
382 | if ( true /*splitterSize.count() == 0*/ ) { | 383 | if ( true /*splitterSize.count() == 0*/ ) { |
383 | splitterSize.append( wid / 2 ); | 384 | splitterSize.append( wid / 2 ); |
384 | splitterSize.append( wid / 2 ); | 385 | splitterSize.append( wid / 2 ); |
385 | } | 386 | } |
386 | mExtensionBarSplitter->setSizes( splitterSize ); | 387 | mExtensionBarSplitter->setSizes( splitterSize ); |
387 | 388 | ||
388 | } | 389 | } |
389 | 390 | ||
390 | 391 | ||
391 | } | 392 | } |
392 | 393 | ||
393 | void KABCore::saveSettings() | 394 | void KABCore::saveSettings() |
394 | { | 395 | { |
395 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 396 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
396 | if ( mExtensionBarSplitter ) | 397 | if ( mExtensionBarSplitter ) |
397 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 398 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
398 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 399 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
399 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 400 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
400 | #ifndef KAB_EMBEDDED | 401 | #ifndef KAB_EMBEDDED |
401 | 402 | ||
402 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 403 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
403 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 404 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
404 | #endif //KAB_EMBEDDED | 405 | #endif //KAB_EMBEDDED |
405 | mExtensionManager->saveSettings(); | 406 | mExtensionManager->saveSettings(); |
406 | mViewManager->saveSettings(); | 407 | mViewManager->saveSettings(); |
407 | 408 | ||
408 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 409 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
409 | } | 410 | } |
410 | 411 | ||
411 | KABC::AddressBook *KABCore::addressBook() const | 412 | KABC::AddressBook *KABCore::addressBook() const |
412 | { | 413 | { |
413 | return mAddressBook; | 414 | return mAddressBook; |
414 | } | 415 | } |
415 | 416 | ||
416 | KConfig *KABCore::config() | 417 | KConfig *KABCore::config() |
417 | { | 418 | { |
418 | #ifndef KAB_EMBEDDED | 419 | #ifndef KAB_EMBEDDED |
419 | return KABPrefs::instance()->config(); | 420 | return KABPrefs::instance()->config(); |
420 | #else //KAB_EMBEDDED | 421 | #else //KAB_EMBEDDED |
@@ -609,192 +610,193 @@ void KABCore::mailVCard( const QStringList& uids ) | |||
609 | 610 | ||
610 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 611 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
611 | 612 | ||
612 | QString fileName = dirName + "/" + name; | 613 | QString fileName = dirName + "/" + name; |
613 | 614 | ||
614 | QFile outFile(fileName); | 615 | QFile outFile(fileName); |
615 | 616 | ||
616 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 617 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
617 | KABC::VCardConverter converter; | 618 | KABC::VCardConverter converter; |
618 | QString vcard; | 619 | QString vcard; |
619 | 620 | ||
620 | converter.addresseeToVCard( a, vcard ); | 621 | converter.addresseeToVCard( a, vcard ); |
621 | 622 | ||
622 | QTextStream t( &outFile ); // use a text stream | 623 | QTextStream t( &outFile ); // use a text stream |
623 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 624 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
624 | t << vcard; | 625 | t << vcard; |
625 | 626 | ||
626 | outFile.close(); | 627 | outFile.close(); |
627 | 628 | ||
628 | urls.append( fileName ); | 629 | urls.append( fileName ); |
629 | } | 630 | } |
630 | } | 631 | } |
631 | 632 | ||
632 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 633 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
633 | 634 | ||
634 | 635 | ||
635 | /*US | 636 | /*US |
636 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 637 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
637 | QString::null, // subject | 638 | QString::null, // subject |
638 | QString::null, // body | 639 | QString::null, // body |
639 | QString::null, | 640 | QString::null, |
640 | urls ); // attachments | 641 | urls ); // attachments |
641 | */ | 642 | */ |
642 | 643 | ||
643 | } | 644 | } |
644 | 645 | ||
645 | /** | 646 | /** |
646 | Beams the "WhoAmI contact. | 647 | Beams the "WhoAmI contact. |
647 | */ | 648 | */ |
648 | void KABCore::beamMySelf() | 649 | void KABCore::beamMySelf() |
649 | { | 650 | { |
650 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 651 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
651 | if (!a.isEmpty()) | 652 | if (!a.isEmpty()) |
652 | { | 653 | { |
653 | QStringList uids; | 654 | QStringList uids; |
654 | uids << a.uid(); | 655 | uids << a.uid(); |
655 | 656 | ||
656 | beamVCard(uids); | 657 | beamVCard(uids); |
657 | } else { | 658 | } else { |
658 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 659 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
659 | 660 | ||
660 | 661 | ||
661 | } | 662 | } |
662 | } | 663 | } |
663 | 664 | ||
664 | void KABCore::export2phone() | 665 | void KABCore::export2phone() |
665 | { | 666 | { |
666 | 667 | ||
667 | KAex2phonePrefs ex2phone; | 668 | KAex2phonePrefs ex2phone; |
668 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 669 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
669 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 670 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
670 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 671 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
671 | 672 | ||
672 | if ( !ex2phone.exec() ) { | 673 | if ( !ex2phone.exec() ) { |
673 | return; | 674 | return; |
674 | } | 675 | } |
675 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 676 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
676 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 677 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
677 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 678 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
678 | 679 | ||
679 | 680 | ||
680 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 681 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
681 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 682 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
682 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 683 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
683 | 684 | ||
684 | QStringList uids = mViewManager->selectedUids(); | 685 | QStringList uids = mViewManager->selectedUids(); |
685 | if ( uids.isEmpty() ) | 686 | if ( uids.isEmpty() ) |
686 | return; | 687 | return; |
687 | 688 | ||
688 | #ifdef _WIN32_ | 689 | #ifdef _WIN32_ |
689 | QString fileName = locateLocal("tmp", "tempfile.vcf"); | 690 | QString fileName = locateLocal("tmp", "tempfile.vcf"); |
690 | #else | 691 | #else |
691 | QString fileName = "/tmp/kdepimtemp.vcf"; | 692 | QString fileName = "/tmp/kdepimtemp.vcf"; |
692 | #endif | 693 | #endif |
693 | 694 | ||
694 | KABC::VCardConverter converter; | 695 | KABC::VCardConverter converter; |
695 | QString description; | 696 | QString description; |
696 | QString datastream; | 697 | QString datastream; |
697 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 698 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
698 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 699 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
699 | 700 | ||
700 | if ( a.isEmpty() ) | 701 | if ( a.isEmpty() ) |
701 | continue; | 702 | continue; |
702 | a.simplifyEmails(); | 703 | a.simplifyEmails(); |
703 | a.simplifyPhoneNumbers(); | 704 | a.simplifyPhoneNumbers(); |
704 | a.simplifyPhoneNumberTypes(); | 705 | a.simplifyPhoneNumberTypes(); |
706 | a.simplifyAddresses(); | ||
705 | 707 | ||
706 | if (description.isEmpty()) | 708 | if (description.isEmpty()) |
707 | description = a.formattedName(); | 709 | description = a.formattedName(); |
708 | QString vcard; | 710 | QString vcard; |
709 | QString vcardnew; | 711 | QString vcardnew; |
710 | converter.addresseeToVCard( a, vcard ); | 712 | converter.addresseeToVCard( a, vcard ); |
711 | int start = 0; | 713 | int start = 0; |
712 | int next; | 714 | int next; |
713 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 715 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
714 | int semi = vcard.find(";", next); | 716 | int semi = vcard.find(";", next); |
715 | int dopp = vcard.find(":", next); | 717 | int dopp = vcard.find(":", next); |
716 | int sep; | 718 | int sep; |
717 | if ( semi < dopp && semi >= 0 ) | 719 | if ( semi < dopp && semi >= 0 ) |
718 | sep = semi ; | 720 | sep = semi ; |
719 | else | 721 | else |
720 | sep = dopp; | 722 | sep = dopp; |
721 | vcardnew +=vcard.mid( start, next - start); | 723 | vcardnew +=vcard.mid( start, next - start); |
722 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); | 724 | vcardnew +=vcard.mid( next+5,sep -next -5 ).upper(); |
723 | start = sep; | 725 | start = sep; |
724 | } | 726 | } |
725 | vcardnew += vcard.mid( start,vcard.length() ); | 727 | vcardnew += vcard.mid( start,vcard.length() ); |
726 | vcard = ""; | 728 | vcard = ""; |
727 | start = 0; | 729 | start = 0; |
728 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { | 730 | while ( (next = vcardnew.find("ADR", start) )>= 0 ) { |
729 | int sep = vcardnew.find(":", next); | 731 | int sep = vcardnew.find(":", next); |
730 | vcard +=vcardnew.mid( start, next - start+3); | 732 | vcard +=vcardnew.mid( start, next - start+3); |
731 | start = sep; | 733 | start = sep; |
732 | } | 734 | } |
733 | vcard += vcardnew.mid( start,vcardnew.length() ); | 735 | vcard += vcardnew.mid( start,vcardnew.length() ); |
734 | vcard.replace ( QRegExp(";;;") , "" ); | 736 | vcard.replace ( QRegExp(";;;") , "" ); |
735 | vcard.replace ( QRegExp(";;") , "" ); | 737 | vcard.replace ( QRegExp(";;") , "" ); |
736 | datastream += vcard; | 738 | datastream += vcard; |
737 | 739 | ||
738 | } | 740 | } |
739 | QFile outFile(fileName); | 741 | QFile outFile(fileName); |
740 | if ( outFile.open(IO_WriteOnly) ) { | 742 | if ( outFile.open(IO_WriteOnly) ) { |
741 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 743 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
742 | QTextStream t( &outFile ); // use a text stream | 744 | QTextStream t( &outFile ); // use a text stream |
743 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 745 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
744 | t <<datastream; | 746 | t <<datastream; |
745 | outFile.close(); | 747 | outFile.close(); |
746 | if ( PhoneAccess::writeToPhone( fileName ) ) | 748 | if ( PhoneAccess::writeToPhone( fileName ) ) |
747 | qDebug("Export okay "); | 749 | qDebug("Export okay "); |
748 | else | 750 | else |
749 | qDebug("Error export contacts "); | 751 | qDebug("Error export contacts "); |
750 | 752 | ||
751 | } else { | 753 | } else { |
752 | qDebug("Error open temp file "); | 754 | qDebug("Error open temp file "); |
753 | return; | 755 | return; |
754 | } | 756 | } |
755 | 757 | ||
756 | 758 | ||
757 | #if 0 | 759 | #if 0 |
758 | 760 | ||
759 | setCaption( i18n("Writing to phone...")); | 761 | setCaption( i18n("Writing to phone...")); |
760 | if ( PhoneFormat::writeToPhone( cal ) ) | 762 | if ( PhoneFormat::writeToPhone( cal ) ) |
761 | setCaption( i18n("Export to phone successful!")); | 763 | setCaption( i18n("Export to phone successful!")); |
762 | else | 764 | else |
763 | setCaption( i18n("Error exporting to phone!")); | 765 | setCaption( i18n("Error exporting to phone!")); |
764 | #endif | 766 | #endif |
765 | 767 | ||
766 | 768 | ||
767 | } | 769 | } |
768 | void KABCore::beamVCard() | 770 | void KABCore::beamVCard() |
769 | { | 771 | { |
770 | QStringList uids = mViewManager->selectedUids(); | 772 | QStringList uids = mViewManager->selectedUids(); |
771 | if ( !uids.isEmpty() ) | 773 | if ( !uids.isEmpty() ) |
772 | beamVCard( uids ); | 774 | beamVCard( uids ); |
773 | } | 775 | } |
774 | 776 | ||
775 | 777 | ||
776 | void KABCore::beamVCard(const QStringList& uids) | 778 | void KABCore::beamVCard(const QStringList& uids) |
777 | { | 779 | { |
778 | /*US | 780 | /*US |
779 | QString beamFilename; | 781 | QString beamFilename; |
780 | Opie::OPimContact c; | 782 | Opie::OPimContact c; |
781 | if ( actionPersonal->isOn() ) { | 783 | if ( actionPersonal->isOn() ) { |
782 | beamFilename = addressbookPersonalVCardName(); | 784 | beamFilename = addressbookPersonalVCardName(); |
783 | if ( !QFile::exists( beamFilename ) ) | 785 | if ( !QFile::exists( beamFilename ) ) |
784 | return; // can't beam a non-existent file | 786 | return; // can't beam a non-existent file |
785 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 787 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
786 | beamFilename ); | 788 | beamFilename ); |
787 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 789 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
788 | Opie::OPimContactAccess::List allList = access->allRecords(); | 790 | Opie::OPimContactAccess::List allList = access->allRecords(); |
789 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 791 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
790 | c = *it; | 792 | c = *it; |
791 | 793 | ||
792 | delete access; | 794 | delete access; |
793 | } else { | 795 | } else { |
794 | unlink( beamfile ); // delete if exists | 796 | unlink( beamfile ); // delete if exists |
795 | mkdir("/tmp/obex/", 0755); | 797 | mkdir("/tmp/obex/", 0755); |
796 | c = m_abView -> currentEntry(); | 798 | c = m_abView -> currentEntry(); |
797 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 799 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
798 | beamfile ); | 800 | beamfile ); |
799 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 801 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
800 | access->add( c ); | 802 | access->add( c ); |
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 552c933..dded2bf 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp | |||
@@ -1,132 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> | 3 | Copyright (c) 2002 Mike Pilone <mpilone@slac.com> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //US#ifdef KAB_EMBEDDED | 24 | //US#ifdef KAB_EMBEDDED |
25 | //#include <qstring.h> | 25 | //#include <qstring.h> |
26 | //#endif //KAB_EMBEDDED | 26 | //#endif //KAB_EMBEDDED |
27 | 27 | ||
28 | 28 | ||
29 | #include <kconfig.h> | 29 | #include <kconfig.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | #include <kstaticdeleter.h> | 31 | #include <kstaticdeleter.h> |
32 | //US#include <kdebug.h> // defines kdDebug() | 32 | //US#include <kdebug.h> // defines kdDebug() |
33 | 33 | ||
34 | #include "kabprefs.h" | 34 | #include "kabprefs.h" |
35 | 35 | ||
36 | KABPrefs *KABPrefs::sInstance = 0; | 36 | KABPrefs *KABPrefs::sInstance = 0; |
37 | static KStaticDeleter<KABPrefs> staticDeleter; | 37 | static KStaticDeleter<KABPrefs> staticDeleter; |
38 | 38 | ||
39 | KABPrefs::KABPrefs() | 39 | KABPrefs::KABPrefs() |
40 | : KPimPrefs("kaddressbookrc") | 40 | : KPimPrefs("kaddressbookrc") |
41 | { | 41 | { |
42 | KPrefs::setCurrentGroup( "Views" ); | 42 | KPrefs::setCurrentGroup( "Views" ); |
43 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); | 43 | addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); |
44 | 44 | ||
45 | KPrefs::setCurrentGroup( "General" ); | 45 | KPrefs::setCurrentGroup( "General" ); |
46 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); | 46 | addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); |
47 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); | 47 | addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); |
48 | 48 | ||
49 | #ifdef KAB_EMBEDDED | 49 | #ifdef KAB_EMBEDDED |
50 | addItemBool("AskForQuit",&mAskForQuit,true); | 50 | addItemBool("AskForQuit",&mAskForQuit,true); |
51 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 51 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
52 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 52 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
53 | addItemBool("SearchWithReturn",&mSearchWithReturn, true ); | 53 | addItemBool("SearchWithReturn",&mSearchWithReturn, true ); |
54 | 54 | ||
55 | 55 | ||
56 | #endif //KAB_EMBEDDED | 56 | #endif //KAB_EMBEDDED |
57 | 57 | ||
58 | KPrefs::setCurrentGroup( "MainWindow" ); | 58 | KPrefs::setCurrentGroup( "MainWindow" ); |
59 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); | 59 | addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); |
60 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); | 60 | addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); |
61 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); | 61 | addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); |
62 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); | 62 | addItemIntList( "DetailsSplitter", &mDetailsSplitter ); |
63 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); | 63 | addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); |
64 | 64 | ||
65 | 65 | ||
66 | KPrefs::setCurrentGroup( "Extensions_General" ); | 66 | KPrefs::setCurrentGroup( "Extensions_General" ); |
67 | QStringList defaultExtensions; | 67 | QStringList defaultExtensions; |
68 | defaultExtensions << "merge"; | 68 | defaultExtensions << "merge"; |
69 | defaultExtensions << "distribution_list_editor"; | 69 | defaultExtensions << "distribution_list_editor"; |
70 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); | 70 | addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); |
71 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); | 71 | addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); |
72 | 72 | ||
73 | KPrefs::setCurrentGroup( "Views" ); | 73 | KPrefs::setCurrentGroup( "Views" ); |
74 | QString defaultView = i18n( "Default Table View" ); | 74 | QString defaultView = i18n( "Default Table View" ); |
75 | addItemString( "CurrentView", &mCurrentView, defaultView ); | 75 | addItemString( "CurrentView", &mCurrentView, defaultView ); |
76 | addItemStringList( "ViewNames", &mViewNames, defaultView ); | 76 | addItemStringList( "ViewNames", &mViewNames, defaultView ); |
77 | 77 | ||
78 | KPrefs::setCurrentGroup( "Filters" ); | 78 | KPrefs::setCurrentGroup( "Filters" ); |
79 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); | 79 | addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); |
80 | 80 | ||
81 | } | 81 | } |
82 | 82 | ||
83 | KABPrefs::~KABPrefs() | 83 | KABPrefs::~KABPrefs() |
84 | { | 84 | { |
85 | //qDebug("KABPrefs::~KABPrefs() "); | ||
85 | } | 86 | } |
86 | 87 | ||
87 | KABPrefs *KABPrefs::instance() | 88 | KABPrefs *KABPrefs::instance() |
88 | { | 89 | { |
89 | if ( !sInstance ) { | 90 | if ( !sInstance ) { |
90 | #ifdef KAB_EMBEDDED | 91 | #ifdef KAB_EMBEDDED |
91 | sInstance = staticDeleter.setObject( new KABPrefs() ); | 92 | sInstance = staticDeleter.setObject( new KABPrefs() ); |
92 | #else //KAB_EMBEDDED | 93 | #else //KAB_EMBEDDED |
93 | //US the following line has changed ???. Why | 94 | //US the following line has changed ???. Why |
94 | staticDeleter.setObject( sInstance, new KABPrefs() ); | 95 | staticDeleter.setObject( sInstance, new KABPrefs() ); |
95 | #endif //KAB_EMBEDDED | 96 | #endif //KAB_EMBEDDED |
96 | sInstance->readConfig(); | 97 | sInstance->readConfig(); |
97 | } | 98 | } |
98 | 99 | ||
99 | return sInstance; | 100 | return sInstance; |
100 | } | 101 | } |
101 | 102 | ||
102 | void KABPrefs::setCategoryDefaults() | 103 | void KABPrefs::setCategoryDefaults() |
103 | { | 104 | { |
104 | mCustomCategories.clear(); | 105 | mCustomCategories.clear(); |
105 | 106 | ||
106 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) | 107 | mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) |
107 | << i18n( "Customer" ) << i18n( "Friend" ); | 108 | << i18n( "Customer" ) << i18n( "Friend" ); |
108 | } | 109 | } |
109 | 110 | ||
110 | // US introduce a nonconst way to return the config object. | 111 | // US introduce a nonconst way to return the config object. |
111 | KConfig* KABPrefs::getConfig() | 112 | KConfig* KABPrefs::getConfig() |
112 | { | 113 | { |
113 | return config(); | 114 | return config(); |
114 | } | 115 | } |
115 | 116 | ||
116 | 117 | ||
117 | /*US | 118 | /*US |
118 | void KABPrefs::usrSetDefaults() | 119 | void KABPrefs::usrSetDefaults() |
119 | { | 120 | { |
120 | KPimPrefs::usrSetDefaults(); | 121 | KPimPrefs::usrSetDefaults(); |
121 | } | 122 | } |
122 | 123 | ||
123 | void KABPrefs::usrReadConfig() | 124 | void KABPrefs::usrReadConfig() |
124 | { | 125 | { |
125 | KPimPrefs::usrReadConfig(); | 126 | KPimPrefs::usrReadConfig(); |
126 | } | 127 | } |
127 | 128 | ||
128 | void KABPrefs::usrWriteConfig() | 129 | void KABPrefs::usrWriteConfig() |
129 | { | 130 | { |
130 | KPimPrefs::usrWriteConfig(); | 131 | KPimPrefs::usrWriteConfig(); |
131 | } | 132 | } |
132 | */ | 133 | */ |