author | zautrix <zautrix> | 2004-10-18 09:08:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-18 09:08:13 (UTC) |
commit | 56990d318b15eacf7d3cc7425ab62f68da099ddf (patch) (unidiff) | |
tree | b2f021bd75bc6a08fa8fc51a07ce1755b8e4a95e | |
parent | 1712d92ea25b220273859d985bc7211fa7a97a39 (diff) | |
download | kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.zip kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.tar.gz kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.tar.bz2 |
fix of tmp file path for desktop version
-rw-r--r-- | kaddressbook/kabcore.cpp | 57 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 4 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 6 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 4 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 4 | ||||
-rw-r--r-- | version | 2 |
7 files changed, 22 insertions, 60 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 2e408b7..11eeabc 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -327,841 +327,802 @@ KABCore::~KABCore() | |||
327 | delete syncManager; | 327 | delete syncManager; |
328 | 328 | ||
329 | } | 329 | } |
330 | 330 | ||
331 | void KABCore::recieve( QString fn ) | 331 | void KABCore::recieve( QString fn ) |
332 | { | 332 | { |
333 | //qDebug("KABCore::recieve "); | 333 | //qDebug("KABCore::recieve "); |
334 | int count = mAddressBook->importFromFile( fn, true ); | 334 | int count = mAddressBook->importFromFile( fn, true ); |
335 | mViewManager->refreshView(); | 335 | mViewManager->refreshView(); |
336 | message(i18n("%1 contact(s) received!").arg( count )); | 336 | message(i18n("%1 contact(s) received!").arg( count )); |
337 | topLevelWidget()->showMaximized(); | 337 | topLevelWidget()->showMaximized(); |
338 | topLevelWidget()->raise(); | 338 | topLevelWidget()->raise(); |
339 | } | 339 | } |
340 | void KABCore::restoreSettings() | 340 | void KABCore::restoreSettings() |
341 | { | 341 | { |
342 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; | 342 | mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; |
343 | 343 | ||
344 | bool state; | 344 | bool state; |
345 | 345 | ||
346 | if (mMultipleViewsAtOnce) | 346 | if (mMultipleViewsAtOnce) |
347 | state = KABPrefs::instance()->mDetailsPageVisible; | 347 | state = KABPrefs::instance()->mDetailsPageVisible; |
348 | else | 348 | else |
349 | state = false; | 349 | state = false; |
350 | 350 | ||
351 | mActionDetails->setChecked( state ); | 351 | mActionDetails->setChecked( state ); |
352 | setDetailsVisible( state ); | 352 | setDetailsVisible( state ); |
353 | 353 | ||
354 | state = KABPrefs::instance()->mJumpButtonBarVisible; | 354 | state = KABPrefs::instance()->mJumpButtonBarVisible; |
355 | 355 | ||
356 | mActionJumpBar->setChecked( state ); | 356 | mActionJumpBar->setChecked( state ); |
357 | setJumpButtonBarVisible( state ); | 357 | setJumpButtonBarVisible( state ); |
358 | /*US | 358 | /*US |
359 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 359 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
360 | if ( splitterSize.count() == 0 ) { | 360 | if ( splitterSize.count() == 0 ) { |
361 | splitterSize.append( width() / 2 ); | 361 | splitterSize.append( width() / 2 ); |
362 | splitterSize.append( width() / 2 ); | 362 | splitterSize.append( width() / 2 ); |
363 | } | 363 | } |
364 | mMiniSplitter->setSizes( splitterSize ); | 364 | mMiniSplitter->setSizes( splitterSize ); |
365 | if ( mExtensionBarSplitter ) { | 365 | if ( mExtensionBarSplitter ) { |
366 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 366 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
367 | if ( splitterSize.count() == 0 ) { | 367 | if ( splitterSize.count() == 0 ) { |
368 | splitterSize.append( width() / 2 ); | 368 | splitterSize.append( width() / 2 ); |
369 | splitterSize.append( width() / 2 ); | 369 | splitterSize.append( width() / 2 ); |
370 | } | 370 | } |
371 | mExtensionBarSplitter->setSizes( splitterSize ); | 371 | mExtensionBarSplitter->setSizes( splitterSize ); |
372 | 372 | ||
373 | } | 373 | } |
374 | */ | 374 | */ |
375 | mViewManager->restoreSettings(); | 375 | mViewManager->restoreSettings(); |
376 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 376 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
377 | mExtensionManager->restoreSettings(); | 377 | mExtensionManager->restoreSettings(); |
378 | #ifdef DESKTOP_VERSION | 378 | #ifdef DESKTOP_VERSION |
379 | int wid = width(); | 379 | int wid = width(); |
380 | if ( wid < 10 ) | 380 | if ( wid < 10 ) |
381 | wid = 400; | 381 | wid = 400; |
382 | #else | 382 | #else |
383 | int wid = QApplication::desktop()->width(); | 383 | int wid = QApplication::desktop()->width(); |
384 | if ( wid < 640 ) | 384 | if ( wid < 640 ) |
385 | wid = QApplication::desktop()->height(); | 385 | wid = QApplication::desktop()->height(); |
386 | #endif | 386 | #endif |
387 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; | 387 | QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; |
388 | if ( true /*splitterSize.count() == 0*/ ) { | 388 | if ( true /*splitterSize.count() == 0*/ ) { |
389 | splitterSize.append( wid / 2 ); | 389 | splitterSize.append( wid / 2 ); |
390 | splitterSize.append( wid / 2 ); | 390 | splitterSize.append( wid / 2 ); |
391 | } | 391 | } |
392 | mMiniSplitter->setSizes( splitterSize ); | 392 | mMiniSplitter->setSizes( splitterSize ); |
393 | if ( mExtensionBarSplitter ) { | 393 | if ( mExtensionBarSplitter ) { |
394 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 394 | //splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
395 | if ( true /*splitterSize.count() == 0*/ ) { | 395 | if ( true /*splitterSize.count() == 0*/ ) { |
396 | splitterSize.append( wid / 2 ); | 396 | splitterSize.append( wid / 2 ); |
397 | splitterSize.append( wid / 2 ); | 397 | splitterSize.append( wid / 2 ); |
398 | } | 398 | } |
399 | mExtensionBarSplitter->setSizes( splitterSize ); | 399 | mExtensionBarSplitter->setSizes( splitterSize ); |
400 | 400 | ||
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | } | 404 | } |
405 | 405 | ||
406 | void KABCore::saveSettings() | 406 | void KABCore::saveSettings() |
407 | { | 407 | { |
408 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 408 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
409 | if ( mExtensionBarSplitter ) | 409 | if ( mExtensionBarSplitter ) |
410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 410 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
411 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 411 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
412 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 412 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
413 | #ifndef KAB_EMBEDDED | 413 | #ifndef KAB_EMBEDDED |
414 | 414 | ||
415 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 415 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
416 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 416 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
417 | #endif //KAB_EMBEDDED | 417 | #endif //KAB_EMBEDDED |
418 | mExtensionManager->saveSettings(); | 418 | mExtensionManager->saveSettings(); |
419 | mViewManager->saveSettings(); | 419 | mViewManager->saveSettings(); |
420 | 420 | ||
421 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 421 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
422 | } | 422 | } |
423 | 423 | ||
424 | KABC::AddressBook *KABCore::addressBook() const | 424 | KABC::AddressBook *KABCore::addressBook() const |
425 | { | 425 | { |
426 | return mAddressBook; | 426 | return mAddressBook; |
427 | } | 427 | } |
428 | 428 | ||
429 | KConfig *KABCore::config() | 429 | KConfig *KABCore::config() |
430 | { | 430 | { |
431 | #ifndef KAB_EMBEDDED | 431 | #ifndef KAB_EMBEDDED |
432 | return KABPrefs::instance()->config(); | 432 | return KABPrefs::instance()->config(); |
433 | #else //KAB_EMBEDDED | 433 | #else //KAB_EMBEDDED |
434 | return KABPrefs::instance()->getConfig(); | 434 | return KABPrefs::instance()->getConfig(); |
435 | #endif //KAB_EMBEDDED | 435 | #endif //KAB_EMBEDDED |
436 | } | 436 | } |
437 | 437 | ||
438 | KActionCollection *KABCore::actionCollection() const | 438 | KActionCollection *KABCore::actionCollection() const |
439 | { | 439 | { |
440 | return mGUIClient->actionCollection(); | 440 | return mGUIClient->actionCollection(); |
441 | } | 441 | } |
442 | 442 | ||
443 | KABC::Field *KABCore::currentSearchField() const | 443 | KABC::Field *KABCore::currentSearchField() const |
444 | { | 444 | { |
445 | if (mIncSearchWidget) | 445 | if (mIncSearchWidget) |
446 | return mIncSearchWidget->currentField(); | 446 | return mIncSearchWidget->currentField(); |
447 | else | 447 | else |
448 | return 0; | 448 | return 0; |
449 | } | 449 | } |
450 | 450 | ||
451 | QStringList KABCore::selectedUIDs() const | 451 | QStringList KABCore::selectedUIDs() const |
452 | { | 452 | { |
453 | return mViewManager->selectedUids(); | 453 | return mViewManager->selectedUids(); |
454 | } | 454 | } |
455 | 455 | ||
456 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 456 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
457 | { | 457 | { |
458 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 458 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
459 | 459 | ||
460 | QPtrList<KRES::Resource> kresResources; | 460 | QPtrList<KRES::Resource> kresResources; |
461 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 461 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
462 | KABC::Resource *resource; | 462 | KABC::Resource *resource; |
463 | while ( ( resource = resIt.current() ) != 0 ) { | 463 | while ( ( resource = resIt.current() ) != 0 ) { |
464 | ++resIt; | 464 | ++resIt; |
465 | if ( !resource->readOnly() ) { | 465 | if ( !resource->readOnly() ) { |
466 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 466 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
467 | if ( res ) | 467 | if ( res ) |
468 | kresResources.append( res ); | 468 | kresResources.append( res ); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 472 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
473 | return static_cast<KABC::Resource*>( res ); | 473 | return static_cast<KABC::Resource*>( res ); |
474 | } | 474 | } |
475 | 475 | ||
476 | #ifndef KAB_EMBEDDED | 476 | #ifndef KAB_EMBEDDED |
477 | KAboutData *KABCore::createAboutData() | 477 | KAboutData *KABCore::createAboutData() |
478 | #else //KAB_EMBEDDED | 478 | #else //KAB_EMBEDDED |
479 | void KABCore::createAboutData() | 479 | void KABCore::createAboutData() |
480 | #endif //KAB_EMBEDDED | 480 | #endif //KAB_EMBEDDED |
481 | { | 481 | { |
482 | #ifndef KAB_EMBEDDED | 482 | #ifndef KAB_EMBEDDED |
483 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 483 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
484 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 484 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
485 | KAboutData::License_GPL_V2, | 485 | KAboutData::License_GPL_V2, |
486 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 486 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
487 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 487 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
488 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 488 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
489 | about->addAuthor( "Cornelius Schumacher", | 489 | about->addAuthor( "Cornelius Schumacher", |
490 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 490 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
491 | "schumacher@kde.org" ); | 491 | "schumacher@kde.org" ); |
492 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 492 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
493 | "mpilone@slac.com" ); | 493 | "mpilone@slac.com" ); |
494 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 494 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
495 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 495 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
496 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 496 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
497 | "michel@klaralvdalens-datakonsult.se" ); | 497 | "michel@klaralvdalens-datakonsult.se" ); |
498 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 498 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
499 | "hansen@kde.org" ); | 499 | "hansen@kde.org" ); |
500 | 500 | ||
501 | return about; | 501 | return about; |
502 | #endif //KAB_EMBEDDED | 502 | #endif //KAB_EMBEDDED |
503 | 503 | ||
504 | QString version; | 504 | QString version; |
505 | #include <../version> | 505 | #include <../version> |
506 | QMessageBox::about( this, "About KAddressbook/Pi", | 506 | QMessageBox::about( this, "About KAddressbook/Pi", |
507 | "KAddressbook/Platform-independent\n" | 507 | "KAddressbook/Platform-independent\n" |
508 | "(KA/Pi) " +version + " - " + | 508 | "(KA/Pi) " +version + " - " + |
509 | #ifdef DESKTOP_VERSION | 509 | #ifdef DESKTOP_VERSION |
510 | "Desktop Edition\n" | 510 | "Desktop Edition\n" |
511 | #else | 511 | #else |
512 | "PDA-Edition\n" | 512 | "PDA-Edition\n" |
513 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 513 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | "(c) 2004 Ulf Schenk\n" | 516 | "(c) 2004 Ulf Schenk\n" |
517 | "(c) 2004 Lutz Rogowski\n" | 517 | "(c) 2004 Lutz Rogowski\n" |
518 | "(c) 1997-2003, The KDE PIM Team\n" | 518 | "(c) 1997-2003, The KDE PIM Team\n" |
519 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" | 519 | "Tobias Koenig Current maintainer\ntokoe@kde.org\n" |
520 | "Don Sanders Original author\n" | 520 | "Don Sanders Original author\n" |
521 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" | 521 | "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" |
522 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" | 522 | "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" |
523 | "Greg Stern DCOP interface\n" | 523 | "Greg Stern DCOP interface\n" |
524 | "Mark Westcot Contact pinning\n" | 524 | "Mark Westcot Contact pinning\n" |
525 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 525 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
526 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" | 526 | "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" |
527 | #ifdef _WIN32_ | 527 | #ifdef _WIN32_ |
528 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" | 528 | "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" |
529 | #endif | 529 | #endif |
530 | ); | 530 | ); |
531 | } | 531 | } |
532 | 532 | ||
533 | void KABCore::setContactSelected( const QString &uid ) | 533 | void KABCore::setContactSelected( const QString &uid ) |
534 | { | 534 | { |
535 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 535 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
536 | if ( !mDetails->isHidden() ) | 536 | if ( !mDetails->isHidden() ) |
537 | mDetails->setAddressee( addr ); | 537 | mDetails->setAddressee( addr ); |
538 | 538 | ||
539 | if ( !addr.isEmpty() ) { | 539 | if ( !addr.isEmpty() ) { |
540 | emit contactSelected( addr.formattedName() ); | 540 | emit contactSelected( addr.formattedName() ); |
541 | KABC::Picture pic = addr.photo(); | 541 | KABC::Picture pic = addr.photo(); |
542 | if ( pic.isIntern() ) { | 542 | if ( pic.isIntern() ) { |
543 | //US emit contactSelected( pic.data() ); | 543 | //US emit contactSelected( pic.data() ); |
544 | //US instead use: | 544 | //US instead use: |
545 | QPixmap px; | 545 | QPixmap px; |
546 | if (pic.data().isNull() != true) | 546 | if (pic.data().isNull() != true) |
547 | { | 547 | { |
548 | px.convertFromImage(pic.data()); | 548 | px.convertFromImage(pic.data()); |
549 | } | 549 | } |
550 | 550 | ||
551 | emit contactSelected( px ); | 551 | emit contactSelected( px ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | 555 | ||
556 | mExtensionManager->setSelectionChanged(); | 556 | mExtensionManager->setSelectionChanged(); |
557 | 557 | ||
558 | // update the actions | 558 | // update the actions |
559 | bool selected = !uid.isEmpty(); | 559 | bool selected = !uid.isEmpty(); |
560 | 560 | ||
561 | if ( mReadWrite ) { | 561 | if ( mReadWrite ) { |
562 | mActionCut->setEnabled( selected ); | 562 | mActionCut->setEnabled( selected ); |
563 | mActionPaste->setEnabled( selected ); | 563 | mActionPaste->setEnabled( selected ); |
564 | } | 564 | } |
565 | 565 | ||
566 | mActionCopy->setEnabled( selected ); | 566 | mActionCopy->setEnabled( selected ); |
567 | mActionDelete->setEnabled( selected ); | 567 | mActionDelete->setEnabled( selected ); |
568 | mActionEditAddressee->setEnabled( selected ); | 568 | mActionEditAddressee->setEnabled( selected ); |
569 | mActionMail->setEnabled( selected ); | 569 | mActionMail->setEnabled( selected ); |
570 | mActionMailVCard->setEnabled( selected ); | 570 | mActionMailVCard->setEnabled( selected ); |
571 | //if (mActionBeam) | 571 | //if (mActionBeam) |
572 | //mActionBeam->setEnabled( selected ); | 572 | //mActionBeam->setEnabled( selected ); |
573 | 573 | ||
574 | if (mActionBeamVCard) | 574 | if (mActionBeamVCard) |
575 | mActionBeamVCard->setEnabled( selected ); | 575 | mActionBeamVCard->setEnabled( selected ); |
576 | 576 | ||
577 | mActionExport2phone->setEnabled( selected ); | 577 | mActionExport2phone->setEnabled( selected ); |
578 | mActionWhoAmI->setEnabled( selected ); | 578 | mActionWhoAmI->setEnabled( selected ); |
579 | mActionCategories->setEnabled( selected ); | 579 | mActionCategories->setEnabled( selected ); |
580 | } | 580 | } |
581 | 581 | ||
582 | void KABCore::sendMail() | 582 | void KABCore::sendMail() |
583 | { | 583 | { |
584 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 584 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
585 | } | 585 | } |
586 | 586 | ||
587 | void KABCore::sendMail( const QString& emaillist ) | 587 | void KABCore::sendMail( const QString& emaillist ) |
588 | { | 588 | { |
589 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " | 589 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
590 | if (emaillist.contains(",") > 0) | 590 | if (emaillist.contains(",") > 0) |
591 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | 591 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); |
592 | else | 592 | else |
593 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | 593 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); |
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | 597 | ||
598 | void KABCore::mailVCard() | 598 | void KABCore::mailVCard() |
599 | { | 599 | { |
600 | QStringList uids = mViewManager->selectedUids(); | 600 | QStringList uids = mViewManager->selectedUids(); |
601 | if ( !uids.isEmpty() ) | 601 | if ( !uids.isEmpty() ) |
602 | mailVCard( uids ); | 602 | mailVCard( uids ); |
603 | } | 603 | } |
604 | 604 | ||
605 | void KABCore::mailVCard( const QStringList& uids ) | 605 | void KABCore::mailVCard( const QStringList& uids ) |
606 | { | 606 | { |
607 | QStringList urls; | 607 | QStringList urls; |
608 | 608 | ||
609 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 609 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
610 | 610 | ||
611 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); | 611 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
612 | 612 | ||
613 | 613 | ||
614 | 614 | ||
615 | QDir().mkdir( dirName, true ); | 615 | QDir().mkdir( dirName, true ); |
616 | 616 | ||
617 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 617 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
618 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 618 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
619 | 619 | ||
620 | if ( a.isEmpty() ) | 620 | if ( a.isEmpty() ) |
621 | continue; | 621 | continue; |
622 | 622 | ||
623 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 623 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
624 | 624 | ||
625 | QString fileName = dirName + "/" + name; | 625 | QString fileName = dirName + "/" + name; |
626 | 626 | ||
627 | QFile outFile(fileName); | 627 | QFile outFile(fileName); |
628 | 628 | ||
629 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 629 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
630 | KABC::VCardConverter converter; | 630 | KABC::VCardConverter converter; |
631 | QString vcard; | 631 | QString vcard; |
632 | 632 | ||
633 | converter.addresseeToVCard( a, vcard ); | 633 | converter.addresseeToVCard( a, vcard ); |
634 | 634 | ||
635 | QTextStream t( &outFile ); // use a text stream | 635 | QTextStream t( &outFile ); // use a text stream |
636 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 636 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
637 | t << vcard; | 637 | t << vcard; |
638 | 638 | ||
639 | outFile.close(); | 639 | outFile.close(); |
640 | 640 | ||
641 | urls.append( fileName ); | 641 | urls.append( fileName ); |
642 | } | 642 | } |
643 | } | 643 | } |
644 | 644 | ||
645 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); | 645 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
646 | 646 | ||
647 | 647 | ||
648 | /*US | 648 | /*US |
649 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 649 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
650 | QString::null, // subject | 650 | QString::null, // subject |
651 | QString::null, // body | 651 | QString::null, // body |
652 | QString::null, | 652 | QString::null, |
653 | urls ); // attachments | 653 | urls ); // attachments |
654 | */ | 654 | */ |
655 | 655 | ||
656 | } | 656 | } |
657 | 657 | ||
658 | /** | 658 | /** |
659 | Beams the "WhoAmI contact. | 659 | Beams the "WhoAmI contact. |
660 | */ | 660 | */ |
661 | void KABCore::beamMySelf() | 661 | void KABCore::beamMySelf() |
662 | { | 662 | { |
663 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 663 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
664 | if (!a.isEmpty()) | 664 | if (!a.isEmpty()) |
665 | { | 665 | { |
666 | QStringList uids; | 666 | QStringList uids; |
667 | uids << a.uid(); | 667 | uids << a.uid(); |
668 | 668 | ||
669 | beamVCard(uids); | 669 | beamVCard(uids); |
670 | } else { | 670 | } else { |
671 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 671 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
672 | 672 | ||
673 | 673 | ||
674 | } | 674 | } |
675 | } | 675 | } |
676 | 676 | ||
677 | void KABCore::export2phone() | 677 | void KABCore::export2phone() |
678 | { | 678 | { |
679 | 679 | ||
680 | KAex2phonePrefs ex2phone; | 680 | KAex2phonePrefs ex2phone; |
681 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 681 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
682 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 682 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
683 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 683 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
684 | 684 | ||
685 | if ( !ex2phone.exec() ) { | 685 | if ( !ex2phone.exec() ) { |
686 | return; | 686 | return; |
687 | } | 687 | } |
688 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 688 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
689 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 689 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
690 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 690 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
691 | 691 | ||
692 | 692 | ||
693 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 693 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
694 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 694 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
695 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 695 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
696 | 696 | ||
697 | QStringList uids = mViewManager->selectedUids(); | 697 | QStringList uids = mViewManager->selectedUids(); |
698 | if ( uids.isEmpty() ) | 698 | if ( uids.isEmpty() ) |
699 | return; | 699 | return; |
700 | 700 | ||
701 | QString fileName = getPhoneFile(); | 701 | QString fileName = getPhoneFile(); |
702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) | 702 | if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) |
703 | return; | 703 | return; |
704 | 704 | ||
705 | message(i18n("Exporting to phone...")); | 705 | message(i18n("Exporting to phone...")); |
706 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); | 706 | QTimer::singleShot( 1, this , SLOT ( writeToPhone())); |
707 | 707 | ||
708 | } | 708 | } |
709 | QString KABCore::getPhoneFile() | 709 | QString KABCore::getPhoneFile() |
710 | { | 710 | { |
711 | #ifdef _WIN32_ | 711 | #ifdef DESKTOP_VERSION |
712 | return locateLocal("tmp", "phonefile.vcf"); | 712 | return locateLocal("tmp", "phonefile.vcf"); |
713 | #else | 713 | #else |
714 | return "/tmp/phonefile.vcf"; | 714 | return "/tmp/phonefile.vcf"; |
715 | #endif | 715 | #endif |
716 | 716 | ||
717 | } | 717 | } |
718 | void KABCore::writeToPhone( ) | 718 | void KABCore::writeToPhone( ) |
719 | { | 719 | { |
720 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) | 720 | if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) |
721 | message(i18n("Export to phone finished!")); | 721 | message(i18n("Export to phone finished!")); |
722 | else | 722 | else |
723 | qDebug(i18n("Error exporting to phone")); | 723 | qDebug(i18n("Error exporting to phone")); |
724 | } | 724 | } |
725 | void KABCore::beamVCard() | 725 | void KABCore::beamVCard() |
726 | { | 726 | { |
727 | QStringList uids = mViewManager->selectedUids(); | 727 | QStringList uids = mViewManager->selectedUids(); |
728 | if ( !uids.isEmpty() ) | 728 | if ( !uids.isEmpty() ) |
729 | beamVCard( uids ); | 729 | beamVCard( uids ); |
730 | } | 730 | } |
731 | 731 | ||
732 | 732 | ||
733 | void KABCore::beamVCard(const QStringList& uids) | 733 | void KABCore::beamVCard(const QStringList& uids) |
734 | { | 734 | { |
735 | /*US | ||
736 | QString beamFilename; | ||
737 | Opie::OPimContact c; | ||
738 | if ( actionPersonal->isOn() ) { | ||
739 | beamFilename = addressbookPersonalVCardName(); | ||
740 | if ( !QFile::exists( beamFilename ) ) | ||
741 | return; // can't beam a non-existent file | ||
742 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | ||
743 | beamFilename ); | ||
744 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | ||
745 | Opie::OPimContactAccess::List allList = access->allRecords(); | ||
746 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | ||
747 | c = *it; | ||
748 | |||
749 | delete access; | ||
750 | } else { | ||
751 | unlink( beamfile ); // delete if exists | ||
752 | mkdir("/tmp/obex/", 0755); | ||
753 | c = m_abView -> currentEntry(); | ||
754 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | ||
755 | beamfile ); | ||
756 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | ||
757 | access->add( c ); | ||
758 | access->save(); | ||
759 | delete access; | ||
760 | |||
761 | beamFilename = beamfile; | ||
762 | } | ||
763 | |||
764 | owarn << "Beaming: " << beamFilename << oendl; | ||
765 | */ | ||
766 | |||
767 | #if 0 | ||
768 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | ||
769 | |||
770 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | ||
771 | |||
772 | QString name = "contact.vcf"; | ||
773 | 735 | ||
774 | QString fileName = dirName + "/" + name; | 736 | // LR: we should use the /tmp dir on the Zaurus, |
775 | #endif | 737 | // because: /tmp = RAM, (HOME)/kdepim = flash memory |
776 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 738 | |
777 | // | 739 | #ifdef DESKTOP_VERSION |
740 | QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); | ||
741 | #else | ||
778 | QString fileName = "/tmp/kapibeamfile.vcf"; | 742 | QString fileName = "/tmp/kapibeamfile.vcf"; |
743 | #endif | ||
779 | 744 | ||
780 | |||
781 | //QDir().mkdir( dirName, true ); | ||
782 | |||
783 | |||
784 | KABC::VCardConverter converter; | 745 | KABC::VCardConverter converter; |
785 | QString description; | 746 | QString description; |
786 | QString datastream; | 747 | QString datastream; |
787 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 748 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
788 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 749 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
789 | 750 | ||
790 | if ( a.isEmpty() ) | 751 | if ( a.isEmpty() ) |
791 | continue; | 752 | continue; |
792 | 753 | ||
793 | if (description.isEmpty()) | 754 | if (description.isEmpty()) |
794 | description = a.formattedName(); | 755 | description = a.formattedName(); |
795 | 756 | ||
796 | QString vcard; | 757 | QString vcard; |
797 | converter.addresseeToVCard( a, vcard ); | 758 | converter.addresseeToVCard( a, vcard ); |
798 | int start = 0; | 759 | int start = 0; |
799 | int next; | 760 | int next; |
800 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { | 761 | while ( (next = vcard.find("TYPE=", start) )>= 0 ) { |
801 | int semi = vcard.find(";", next); | 762 | int semi = vcard.find(";", next); |
802 | int dopp = vcard.find(":", next); | 763 | int dopp = vcard.find(":", next); |
803 | int sep; | 764 | int sep; |
804 | if ( semi < dopp && semi >= 0 ) | 765 | if ( semi < dopp && semi >= 0 ) |
805 | sep = semi ; | 766 | sep = semi ; |
806 | else | 767 | else |
807 | sep = dopp; | 768 | sep = dopp; |
808 | datastream +=vcard.mid( start, next - start); | 769 | datastream +=vcard.mid( start, next - start); |
809 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); | 770 | datastream +=vcard.mid( next+5,sep -next -5 ).upper(); |
810 | start = sep; | 771 | start = sep; |
811 | } | 772 | } |
812 | datastream += vcard.mid( start,vcard.length() ); | 773 | datastream += vcard.mid( start,vcard.length() ); |
813 | } | 774 | } |
814 | #ifndef DESKTOP_VERSION | 775 | #ifndef DESKTOP_VERSION |
815 | QFile outFile(fileName); | 776 | QFile outFile(fileName); |
816 | if ( outFile.open(IO_WriteOnly) ) { | 777 | if ( outFile.open(IO_WriteOnly) ) { |
817 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); | 778 | datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); |
818 | QTextStream t( &outFile ); // use a text stream | 779 | QTextStream t( &outFile ); // use a text stream |
819 | //t.setEncoding( QTextStream::UnicodeUTF8 ); | 780 | //t.setEncoding( QTextStream::UnicodeUTF8 ); |
820 | t.setEncoding( QTextStream::Latin1 ); | 781 | t.setEncoding( QTextStream::Latin1 ); |
821 | t <<datastream.latin1(); | 782 | t <<datastream.latin1(); |
822 | outFile.close(); | 783 | outFile.close(); |
823 | Ir *ir = new Ir( this ); | 784 | Ir *ir = new Ir( this ); |
824 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 785 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
825 | ir->send( fileName, description, "text/x-vCard" ); | 786 | ir->send( fileName, description, "text/x-vCard" ); |
826 | } else { | 787 | } else { |
827 | qDebug("Error open temp beam file "); | 788 | qDebug("Error open temp beam file "); |
828 | return; | 789 | return; |
829 | } | 790 | } |
830 | #endif | 791 | #endif |
831 | 792 | ||
832 | } | 793 | } |
833 | 794 | ||
834 | void KABCore::beamDone( Ir *ir ) | 795 | void KABCore::beamDone( Ir *ir ) |
835 | { | 796 | { |
836 | #ifndef DESKTOP_VERSION | 797 | #ifndef DESKTOP_VERSION |
837 | delete ir; | 798 | delete ir; |
838 | #endif | 799 | #endif |
839 | topLevelWidget()->raise(); | 800 | topLevelWidget()->raise(); |
840 | message( i18n("Beaming finished!") ); | 801 | message( i18n("Beaming finished!") ); |
841 | } | 802 | } |
842 | 803 | ||
843 | 804 | ||
844 | void KABCore::browse( const QString& url ) | 805 | void KABCore::browse( const QString& url ) |
845 | { | 806 | { |
846 | #ifndef KAB_EMBEDDED | 807 | #ifndef KAB_EMBEDDED |
847 | kapp->invokeBrowser( url ); | 808 | kapp->invokeBrowser( url ); |
848 | #else //KAB_EMBEDDED | 809 | #else //KAB_EMBEDDED |
849 | qDebug("KABCore::browse must be fixed"); | 810 | qDebug("KABCore::browse must be fixed"); |
850 | #endif //KAB_EMBEDDED | 811 | #endif //KAB_EMBEDDED |
851 | } | 812 | } |
852 | 813 | ||
853 | void KABCore::selectAllContacts() | 814 | void KABCore::selectAllContacts() |
854 | { | 815 | { |
855 | mViewManager->setSelected( QString::null, true ); | 816 | mViewManager->setSelected( QString::null, true ); |
856 | } | 817 | } |
857 | 818 | ||
858 | void KABCore::deleteContacts() | 819 | void KABCore::deleteContacts() |
859 | { | 820 | { |
860 | QStringList uidList = mViewManager->selectedUids(); | 821 | QStringList uidList = mViewManager->selectedUids(); |
861 | deleteContacts( uidList ); | 822 | deleteContacts( uidList ); |
862 | } | 823 | } |
863 | 824 | ||
864 | void KABCore::deleteContacts( const QStringList &uids ) | 825 | void KABCore::deleteContacts( const QStringList &uids ) |
865 | { | 826 | { |
866 | if ( uids.count() > 0 ) { | 827 | if ( uids.count() > 0 ) { |
867 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 828 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
868 | UndoStack::instance()->push( command ); | 829 | UndoStack::instance()->push( command ); |
869 | RedoStack::instance()->clear(); | 830 | RedoStack::instance()->clear(); |
870 | 831 | ||
871 | // now if we deleted anything, refresh | 832 | // now if we deleted anything, refresh |
872 | setContactSelected( QString::null ); | 833 | setContactSelected( QString::null ); |
873 | setModified( true ); | 834 | setModified( true ); |
874 | } | 835 | } |
875 | } | 836 | } |
876 | 837 | ||
877 | void KABCore::copyContacts() | 838 | void KABCore::copyContacts() |
878 | { | 839 | { |
879 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 840 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
880 | 841 | ||
881 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 842 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
882 | 843 | ||
883 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 844 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
884 | 845 | ||
885 | QClipboard *cb = QApplication::clipboard(); | 846 | QClipboard *cb = QApplication::clipboard(); |
886 | cb->setText( clipText ); | 847 | cb->setText( clipText ); |
887 | } | 848 | } |
888 | 849 | ||
889 | void KABCore::cutContacts() | 850 | void KABCore::cutContacts() |
890 | { | 851 | { |
891 | QStringList uidList = mViewManager->selectedUids(); | 852 | QStringList uidList = mViewManager->selectedUids(); |
892 | 853 | ||
893 | //US if ( uidList.size() > 0 ) { | 854 | //US if ( uidList.size() > 0 ) { |
894 | if ( uidList.count() > 0 ) { | 855 | if ( uidList.count() > 0 ) { |
895 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 856 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
896 | UndoStack::instance()->push( command ); | 857 | UndoStack::instance()->push( command ); |
897 | RedoStack::instance()->clear(); | 858 | RedoStack::instance()->clear(); |
898 | 859 | ||
899 | setModified( true ); | 860 | setModified( true ); |
900 | } | 861 | } |
901 | } | 862 | } |
902 | 863 | ||
903 | void KABCore::pasteContacts() | 864 | void KABCore::pasteContacts() |
904 | { | 865 | { |
905 | QClipboard *cb = QApplication::clipboard(); | 866 | QClipboard *cb = QApplication::clipboard(); |
906 | 867 | ||
907 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 868 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
908 | 869 | ||
909 | pasteContacts( list ); | 870 | pasteContacts( list ); |
910 | } | 871 | } |
911 | 872 | ||
912 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 873 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
913 | { | 874 | { |
914 | KABC::Resource *resource = requestResource( this ); | 875 | KABC::Resource *resource = requestResource( this ); |
915 | KABC::Addressee::List::Iterator it; | 876 | KABC::Addressee::List::Iterator it; |
916 | for ( it = list.begin(); it != list.end(); ++it ) | 877 | for ( it = list.begin(); it != list.end(); ++it ) |
917 | (*it).setResource( resource ); | 878 | (*it).setResource( resource ); |
918 | 879 | ||
919 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 880 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
920 | UndoStack::instance()->push( command ); | 881 | UndoStack::instance()->push( command ); |
921 | RedoStack::instance()->clear(); | 882 | RedoStack::instance()->clear(); |
922 | 883 | ||
923 | setModified( true ); | 884 | setModified( true ); |
924 | } | 885 | } |
925 | 886 | ||
926 | void KABCore::setWhoAmI() | 887 | void KABCore::setWhoAmI() |
927 | { | 888 | { |
928 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 889 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
929 | 890 | ||
930 | if ( addrList.count() > 1 ) { | 891 | if ( addrList.count() > 1 ) { |
931 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 892 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
932 | return; | 893 | return; |
933 | } | 894 | } |
934 | 895 | ||
935 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 896 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
936 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 897 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
937 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 898 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
938 | } | 899 | } |
939 | 900 | ||
940 | void KABCore::setCategories() | 901 | void KABCore::setCategories() |
941 | { | 902 | { |
942 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 903 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
943 | if ( !dlg.exec() ) | 904 | if ( !dlg.exec() ) |
944 | return; | 905 | return; |
945 | 906 | ||
946 | bool merge = false; | 907 | bool merge = false; |
947 | QString msg = i18n( "Merge with existing categories?" ); | 908 | QString msg = i18n( "Merge with existing categories?" ); |
948 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 909 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
949 | merge = true; | 910 | merge = true; |
950 | 911 | ||
951 | QStringList categories = dlg.selectedCategories(); | 912 | QStringList categories = dlg.selectedCategories(); |
952 | 913 | ||
953 | QStringList uids = mViewManager->selectedUids(); | 914 | QStringList uids = mViewManager->selectedUids(); |
954 | QStringList::Iterator it; | 915 | QStringList::Iterator it; |
955 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 916 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
956 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 917 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
957 | if ( !addr.isEmpty() ) { | 918 | if ( !addr.isEmpty() ) { |
958 | if ( !merge ) | 919 | if ( !merge ) |
959 | addr.setCategories( categories ); | 920 | addr.setCategories( categories ); |
960 | else { | 921 | else { |
961 | QStringList addrCategories = addr.categories(); | 922 | QStringList addrCategories = addr.categories(); |
962 | QStringList::Iterator catIt; | 923 | QStringList::Iterator catIt; |
963 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 924 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
964 | if ( !addrCategories.contains( *catIt ) ) | 925 | if ( !addrCategories.contains( *catIt ) ) |
965 | addrCategories.append( *catIt ); | 926 | addrCategories.append( *catIt ); |
966 | } | 927 | } |
967 | addr.setCategories( addrCategories ); | 928 | addr.setCategories( addrCategories ); |
968 | } | 929 | } |
969 | 930 | ||
970 | mAddressBook->insertAddressee( addr ); | 931 | mAddressBook->insertAddressee( addr ); |
971 | } | 932 | } |
972 | } | 933 | } |
973 | 934 | ||
974 | if ( uids.count() > 0 ) | 935 | if ( uids.count() > 0 ) |
975 | setModified( true ); | 936 | setModified( true ); |
976 | } | 937 | } |
977 | 938 | ||
978 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 939 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
979 | { | 940 | { |
980 | mIncSearchWidget->setFields( fields ); | 941 | mIncSearchWidget->setFields( fields ); |
981 | } | 942 | } |
982 | 943 | ||
983 | void KABCore::incrementalSearch( const QString& text ) | 944 | void KABCore::incrementalSearch( const QString& text ) |
984 | { | 945 | { |
985 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); | 946 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
986 | } | 947 | } |
987 | 948 | ||
988 | void KABCore::setModified() | 949 | void KABCore::setModified() |
989 | { | 950 | { |
990 | setModified( true ); | 951 | setModified( true ); |
991 | } | 952 | } |
992 | 953 | ||
993 | void KABCore::setModifiedWOrefresh() | 954 | void KABCore::setModifiedWOrefresh() |
994 | { | 955 | { |
995 | // qDebug("KABCore::setModifiedWOrefresh() "); | 956 | // qDebug("KABCore::setModifiedWOrefresh() "); |
996 | mModified = true; | 957 | mModified = true; |
997 | mActionSave->setEnabled( mModified ); | 958 | mActionSave->setEnabled( mModified ); |
998 | #ifdef DESKTOP_VERSION | 959 | #ifdef DESKTOP_VERSION |
999 | mDetails->refreshView(); | 960 | mDetails->refreshView(); |
1000 | #endif | 961 | #endif |
1001 | 962 | ||
1002 | } | 963 | } |
1003 | void KABCore::setModified( bool modified ) | 964 | void KABCore::setModified( bool modified ) |
1004 | { | 965 | { |
1005 | mModified = modified; | 966 | mModified = modified; |
1006 | mActionSave->setEnabled( mModified ); | 967 | mActionSave->setEnabled( mModified ); |
1007 | 968 | ||
1008 | if ( modified ) | 969 | if ( modified ) |
1009 | mJumpButtonBar->recreateButtons(); | 970 | mJumpButtonBar->recreateButtons(); |
1010 | 971 | ||
1011 | mViewManager->refreshView(); | 972 | mViewManager->refreshView(); |
1012 | mDetails->refreshView(); | 973 | mDetails->refreshView(); |
1013 | 974 | ||
1014 | } | 975 | } |
1015 | 976 | ||
1016 | bool KABCore::modified() const | 977 | bool KABCore::modified() const |
1017 | { | 978 | { |
1018 | return mModified; | 979 | return mModified; |
1019 | } | 980 | } |
1020 | 981 | ||
1021 | void KABCore::contactModified( const KABC::Addressee &addr ) | 982 | void KABCore::contactModified( const KABC::Addressee &addr ) |
1022 | { | 983 | { |
1023 | 984 | ||
1024 | Command *command = 0; | 985 | Command *command = 0; |
1025 | QString uid; | 986 | QString uid; |
1026 | 987 | ||
1027 | // check if it exists already | 988 | // check if it exists already |
1028 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 989 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
1029 | if ( origAddr.isEmpty() ) | 990 | if ( origAddr.isEmpty() ) |
1030 | command = new PwNewCommand( mAddressBook, addr ); | 991 | command = new PwNewCommand( mAddressBook, addr ); |
1031 | else { | 992 | else { |
1032 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 993 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
1033 | uid = addr.uid(); | 994 | uid = addr.uid(); |
1034 | } | 995 | } |
1035 | 996 | ||
1036 | UndoStack::instance()->push( command ); | 997 | UndoStack::instance()->push( command ); |
1037 | RedoStack::instance()->clear(); | 998 | RedoStack::instance()->clear(); |
1038 | 999 | ||
1039 | setModified( true ); | 1000 | setModified( true ); |
1040 | } | 1001 | } |
1041 | 1002 | ||
1042 | void KABCore::newContact() | 1003 | void KABCore::newContact() |
1043 | { | 1004 | { |
1044 | 1005 | ||
1045 | 1006 | ||
1046 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 1007 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
1047 | 1008 | ||
1048 | QPtrList<KRES::Resource> kresResources; | 1009 | QPtrList<KRES::Resource> kresResources; |
1049 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 1010 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
1050 | KABC::Resource *resource; | 1011 | KABC::Resource *resource; |
1051 | while ( ( resource = it.current() ) != 0 ) { | 1012 | while ( ( resource = it.current() ) != 0 ) { |
1052 | ++it; | 1013 | ++it; |
1053 | if ( !resource->readOnly() ) { | 1014 | if ( !resource->readOnly() ) { |
1054 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 1015 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
1055 | if ( res ) | 1016 | if ( res ) |
1056 | kresResources.append( res ); | 1017 | kresResources.append( res ); |
1057 | } | 1018 | } |
1058 | } | 1019 | } |
1059 | 1020 | ||
1060 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 1021 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
1061 | resource = static_cast<KABC::Resource*>( res ); | 1022 | resource = static_cast<KABC::Resource*>( res ); |
1062 | 1023 | ||
1063 | if ( resource ) { | 1024 | if ( resource ) { |
1064 | KABC::Addressee addr; | 1025 | KABC::Addressee addr; |
1065 | addr.setResource( resource ); | 1026 | addr.setResource( resource ); |
1066 | mEditorDialog->setAddressee( addr ); | 1027 | mEditorDialog->setAddressee( addr ); |
1067 | KApplication::execDialog ( mEditorDialog ); | 1028 | KApplication::execDialog ( mEditorDialog ); |
1068 | 1029 | ||
1069 | } else | 1030 | } else |
1070 | return; | 1031 | return; |
1071 | 1032 | ||
1072 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 1033 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
1073 | 1034 | ||
1074 | 1035 | ||
1075 | } | 1036 | } |
1076 | 1037 | ||
1077 | void KABCore::addEmail( QString aStr ) | 1038 | void KABCore::addEmail( QString aStr ) |
1078 | { | 1039 | { |
1079 | #ifndef KAB_EMBEDDED | 1040 | #ifndef KAB_EMBEDDED |
1080 | QString fullName, email; | 1041 | QString fullName, email; |
1081 | 1042 | ||
1082 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 1043 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
1083 | 1044 | ||
1084 | // Try to lookup the addressee matching the email address | 1045 | // Try to lookup the addressee matching the email address |
1085 | bool found = false; | 1046 | bool found = false; |
1086 | QStringList emailList; | 1047 | QStringList emailList; |
1087 | KABC::AddressBook::Iterator it; | 1048 | KABC::AddressBook::Iterator it; |
1088 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 1049 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
1089 | emailList = (*it).emails(); | 1050 | emailList = (*it).emails(); |
1090 | if ( emailList.contains( email ) > 0 ) { | 1051 | if ( emailList.contains( email ) > 0 ) { |
1091 | found = true; | 1052 | found = true; |
1092 | (*it).setNameFromString( fullName ); | 1053 | (*it).setNameFromString( fullName ); |
1093 | editContact( (*it).uid() ); | 1054 | editContact( (*it).uid() ); |
1094 | } | 1055 | } |
1095 | } | 1056 | } |
1096 | 1057 | ||
1097 | if ( !found ) { | 1058 | if ( !found ) { |
1098 | KABC::Addressee addr; | 1059 | KABC::Addressee addr; |
1099 | addr.setNameFromString( fullName ); | 1060 | addr.setNameFromString( fullName ); |
1100 | addr.insertEmail( email, true ); | 1061 | addr.insertEmail( email, true ); |
1101 | 1062 | ||
1102 | mAddressBook->insertAddressee( addr ); | 1063 | mAddressBook->insertAddressee( addr ); |
1103 | mViewManager->refreshView( addr.uid() ); | 1064 | mViewManager->refreshView( addr.uid() ); |
1104 | editContact( addr.uid() ); | 1065 | editContact( addr.uid() ); |
1105 | } | 1066 | } |
1106 | #else //KAB_EMBEDDED | 1067 | #else //KAB_EMBEDDED |
1107 | qDebug("KABCore::addEmail finsih method"); | 1068 | qDebug("KABCore::addEmail finsih method"); |
1108 | #endif //KAB_EMBEDDED | 1069 | #endif //KAB_EMBEDDED |
1109 | } | 1070 | } |
1110 | 1071 | ||
1111 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 1072 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
1112 | { | 1073 | { |
1113 | mXXPortManager->importVCard( url, showPreview ); | 1074 | mXXPortManager->importVCard( url, showPreview ); |
1114 | } | 1075 | } |
1115 | void KABCore::importFromOL() | 1076 | void KABCore::importFromOL() |
1116 | { | 1077 | { |
1117 | #ifdef _WIN32_ | 1078 | #ifdef _WIN32_ |
1118 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); | 1079 | KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); |
1119 | idgl->exec(); | 1080 | idgl->exec(); |
1120 | KABC::Addressee::List list = idgl->getAddressList(); | 1081 | KABC::Addressee::List list = idgl->getAddressList(); |
1121 | if ( list.count() > 0 ) { | 1082 | if ( list.count() > 0 ) { |
1122 | KABC::Addressee::List listNew; | 1083 | KABC::Addressee::List listNew; |
1123 | KABC::Addressee::List listExisting; | 1084 | KABC::Addressee::List listExisting; |
1124 | KABC::Addressee::List::Iterator it; | 1085 | KABC::Addressee::List::Iterator it; |
1125 | KABC::AddressBook::Iterator iter; | 1086 | KABC::AddressBook::Iterator iter; |
1126 | for ( it = list.begin(); it != list.end(); ++it ) { | 1087 | for ( it = list.begin(); it != list.end(); ++it ) { |
1127 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) | 1088 | if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) |
1128 | listNew.append( (*it) ); | 1089 | listNew.append( (*it) ); |
1129 | else | 1090 | else |
1130 | listExisting.append( (*it) ); | 1091 | listExisting.append( (*it) ); |
1131 | } | 1092 | } |
1132 | if ( listExisting.count() > 0 ) | 1093 | if ( listExisting.count() > 0 ) |
1133 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); | 1094 | KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); |
1134 | if ( listNew.count() > 0 ) { | 1095 | if ( listNew.count() > 0 ) { |
1135 | pasteWithNewUid = false; | 1096 | pasteWithNewUid = false; |
1136 | pasteContacts( listNew ); | 1097 | pasteContacts( listNew ); |
1137 | pasteWithNewUid = true; | 1098 | pasteWithNewUid = true; |
1138 | } | 1099 | } |
1139 | } | 1100 | } |
1140 | delete idgl; | 1101 | delete idgl; |
1141 | #endif | 1102 | #endif |
1142 | } | 1103 | } |
1143 | 1104 | ||
1144 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 1105 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
1145 | { | 1106 | { |
1146 | mXXPortManager->importVCard( vCard, showPreview ); | 1107 | mXXPortManager->importVCard( vCard, showPreview ); |
1147 | } | 1108 | } |
1148 | 1109 | ||
1149 | //US added a second method without defaultparameter | 1110 | //US added a second method without defaultparameter |
1150 | void KABCore::editContact2() { | 1111 | void KABCore::editContact2() { |
1151 | editContact( QString::null ); | 1112 | editContact( QString::null ); |
1152 | } | 1113 | } |
1153 | 1114 | ||
1154 | void KABCore::editContact( const QString &uid ) | 1115 | void KABCore::editContact( const QString &uid ) |
1155 | { | 1116 | { |
1156 | 1117 | ||
1157 | if ( mExtensionManager->isQuickEditVisible() ) | 1118 | if ( mExtensionManager->isQuickEditVisible() ) |
1158 | return; | 1119 | return; |
1159 | 1120 | ||
1160 | // First, locate the contact entry | 1121 | // First, locate the contact entry |
1161 | QString localUID = uid; | 1122 | QString localUID = uid; |
1162 | if ( localUID.isNull() ) { | 1123 | if ( localUID.isNull() ) { |
1163 | QStringList uidList = mViewManager->selectedUids(); | 1124 | QStringList uidList = mViewManager->selectedUids(); |
1164 | if ( uidList.count() > 0 ) | 1125 | if ( uidList.count() > 0 ) |
1165 | localUID = *( uidList.at( 0 ) ); | 1126 | localUID = *( uidList.at( 0 ) ); |
1166 | } | 1127 | } |
1167 | 1128 | ||
@@ -2481,396 +2442,396 @@ bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBo | |||
2481 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); | 2442 | qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); |
2482 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); | 2443 | addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); |
2483 | if ( !addresseeR.isEmpty() ) { | 2444 | if ( !addresseeR.isEmpty() ) { |
2484 | addresseeRSync = addresseeR; | 2445 | addresseeRSync = addresseeR; |
2485 | remote->removeAddressee(addresseeR ); | 2446 | remote->removeAddressee(addresseeR ); |
2486 | 2447 | ||
2487 | } else { | 2448 | } else { |
2488 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2449 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2489 | addresseeRSync = addresseeLSync ; | 2450 | addresseeRSync = addresseeLSync ; |
2490 | } else { | 2451 | } else { |
2491 | qDebug("FULLDATE 1"); | 2452 | qDebug("FULLDATE 1"); |
2492 | fullDateRange = true; | 2453 | fullDateRange = true; |
2493 | Addressee newAdd; | 2454 | Addressee newAdd; |
2494 | addresseeRSync = newAdd; | 2455 | addresseeRSync = newAdd; |
2495 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); | 2456 | addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); |
2496 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); | 2457 | addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); |
2497 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2458 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2498 | addresseeRSync.setCategories( i18n("SyncAddressee") ); | 2459 | addresseeRSync.setCategories( i18n("SyncAddressee") ); |
2499 | } | 2460 | } |
2500 | } | 2461 | } |
2501 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { | 2462 | if ( addresseeLSync.revision() == mLastAddressbookSync ) { |
2502 | qDebug("FULLDATE 2"); | 2463 | qDebug("FULLDATE 2"); |
2503 | fullDateRange = true; | 2464 | fullDateRange = true; |
2504 | } | 2465 | } |
2505 | if ( ! fullDateRange ) { | 2466 | if ( ! fullDateRange ) { |
2506 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { | 2467 | if ( addresseeLSync.revision() != addresseeRSync.revision() ) { |
2507 | 2468 | ||
2508 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); | 2469 | // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); |
2509 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); | 2470 | //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); |
2510 | fullDateRange = true; | 2471 | fullDateRange = true; |
2511 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); | 2472 | qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); |
2512 | } | 2473 | } |
2513 | } | 2474 | } |
2514 | // fullDateRange = true; // debug only! | 2475 | // fullDateRange = true; // debug only! |
2515 | if ( fullDateRange ) | 2476 | if ( fullDateRange ) |
2516 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); | 2477 | mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); |
2517 | else | 2478 | else |
2518 | mLastAddressbookSync = addresseeLSync.revision(); | 2479 | mLastAddressbookSync = addresseeLSync.revision(); |
2519 | // for resyncing if own file has changed | 2480 | // for resyncing if own file has changed |
2520 | // PENDING fixme later when implemented | 2481 | // PENDING fixme later when implemented |
2521 | #if 0 | 2482 | #if 0 |
2522 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 2483 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
2523 | mLastAddressbookSync = loadedFileVersion; | 2484 | mLastAddressbookSync = loadedFileVersion; |
2524 | qDebug("setting mLastAddressbookSync "); | 2485 | qDebug("setting mLastAddressbookSync "); |
2525 | } | 2486 | } |
2526 | #endif | 2487 | #endif |
2527 | 2488 | ||
2528 | //qDebug("*************************** "); | 2489 | //qDebug("*************************** "); |
2529 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); | 2490 | // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); |
2530 | QStringList er = remote->uidList(); | 2491 | QStringList er = remote->uidList(); |
2531 | Addressee inR ;//= er.first(); | 2492 | Addressee inR ;//= er.first(); |
2532 | Addressee inL; | 2493 | Addressee inL; |
2533 | 2494 | ||
2534 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); | 2495 | syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); |
2535 | 2496 | ||
2536 | int modulo = (er.count()/10)+1; | 2497 | int modulo = (er.count()/10)+1; |
2537 | int incCounter = 0; | 2498 | int incCounter = 0; |
2538 | while ( incCounter < er.count()) { | 2499 | while ( incCounter < er.count()) { |
2539 | if (syncManager->isProgressBarCanceled()) | 2500 | if (syncManager->isProgressBarCanceled()) |
2540 | return false; | 2501 | return false; |
2541 | if ( incCounter % modulo == 0 ) | 2502 | if ( incCounter % modulo == 0 ) |
2542 | syncManager->showProgressBar(incCounter); | 2503 | syncManager->showProgressBar(incCounter); |
2543 | 2504 | ||
2544 | uid = er[ incCounter ]; | 2505 | uid = er[ incCounter ]; |
2545 | bool skipIncidence = false; | 2506 | bool skipIncidence = false; |
2546 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2507 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2547 | skipIncidence = true; | 2508 | skipIncidence = true; |
2548 | QString idS,OidS; | 2509 | QString idS,OidS; |
2549 | qApp->processEvents(); | 2510 | qApp->processEvents(); |
2550 | if ( !skipIncidence ) { | 2511 | if ( !skipIncidence ) { |
2551 | inL = local->findByUid( uid ); | 2512 | inL = local->findByUid( uid ); |
2552 | inR = remote->findByUid( uid ); | 2513 | inR = remote->findByUid( uid ); |
2553 | //inL.setResource( 0 ); | 2514 | //inL.setResource( 0 ); |
2554 | //inR.setResource( 0 ); | 2515 | //inR.setResource( 0 ); |
2555 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars | 2516 | if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars |
2556 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2517 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2557 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { | 2518 | if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { |
2558 | //qDebug("take %d %s ", take, inL.summary().latin1()); | 2519 | //qDebug("take %d %s ", take, inL.summary().latin1()); |
2559 | if ( take == 3 ) | 2520 | if ( take == 3 ) |
2560 | return false; | 2521 | return false; |
2561 | if ( take == 1 ) {// take local | 2522 | if ( take == 1 ) {// take local |
2562 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2523 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2563 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2524 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2564 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2525 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2565 | local->insertAddressee( inL, false ); | 2526 | local->insertAddressee( inL, false ); |
2566 | idS = inR.externalUID(); | 2527 | idS = inR.externalUID(); |
2567 | OidS = inR.originalExternalUID(); | 2528 | OidS = inR.originalExternalUID(); |
2568 | } | 2529 | } |
2569 | else | 2530 | else |
2570 | idS = inR.IDStr(); | 2531 | idS = inR.IDStr(); |
2571 | remote->removeAddressee( inR ); | 2532 | remote->removeAddressee( inR ); |
2572 | inR = inL; | 2533 | inR = inL; |
2573 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 2534 | inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
2574 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2535 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2575 | inR.setOriginalExternalUID( OidS ); | 2536 | inR.setOriginalExternalUID( OidS ); |
2576 | inR.setExternalUID( idS ); | 2537 | inR.setExternalUID( idS ); |
2577 | } else { | 2538 | } else { |
2578 | inR.setIDStr( idS ); | 2539 | inR.setIDStr( idS ); |
2579 | } | 2540 | } |
2580 | inR.setResource( 0 ); | 2541 | inR.setResource( 0 ); |
2581 | remote->insertAddressee( inR , false); | 2542 | remote->insertAddressee( inR , false); |
2582 | ++changedRemote; | 2543 | ++changedRemote; |
2583 | } else { // take == 2 take remote | 2544 | } else { // take == 2 take remote |
2584 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2545 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2585 | if ( inR.revision().date().year() < 2004 ) | 2546 | if ( inR.revision().date().year() < 2004 ) |
2586 | inR.setRevision( modifiedCalendar ); | 2547 | inR.setRevision( modifiedCalendar ); |
2587 | } | 2548 | } |
2588 | idS = inL.IDStr(); | 2549 | idS = inL.IDStr(); |
2589 | local->removeAddressee( inL ); | 2550 | local->removeAddressee( inL ); |
2590 | inL = inR; | 2551 | inL = inR; |
2591 | inL.setIDStr( idS ); | 2552 | inL.setIDStr( idS ); |
2592 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2553 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2593 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); | 2554 | inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); |
2594 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); | 2555 | inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); |
2595 | } | 2556 | } |
2596 | inL.setResource( 0 ); | 2557 | inL.setResource( 0 ); |
2597 | local->insertAddressee( inL , false ); | 2558 | local->insertAddressee( inL , false ); |
2598 | ++changedLocal; | 2559 | ++changedLocal; |
2599 | } | 2560 | } |
2600 | } | 2561 | } |
2601 | } | 2562 | } |
2602 | } else { // no conflict | 2563 | } else { // no conflict |
2603 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2564 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2604 | QString des = addresseeLSync.note(); | 2565 | QString des = addresseeLSync.note(); |
2605 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 2566 | if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
2606 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 2567 | inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
2607 | remote->insertAddressee( inR, false ); | 2568 | remote->insertAddressee( inR, false ); |
2608 | ++deletedAddresseeR; | 2569 | ++deletedAddresseeR; |
2609 | } else { | 2570 | } else { |
2610 | inR.setRevision( modifiedCalendar ); | 2571 | inR.setRevision( modifiedCalendar ); |
2611 | remote->insertAddressee( inR, false ); | 2572 | remote->insertAddressee( inR, false ); |
2612 | inL = inR; | 2573 | inL = inR; |
2613 | inL.setResource( 0 ); | 2574 | inL.setResource( 0 ); |
2614 | local->insertAddressee( inL , false); | 2575 | local->insertAddressee( inL , false); |
2615 | ++addedAddressee; | 2576 | ++addedAddressee; |
2616 | } | 2577 | } |
2617 | } else { | 2578 | } else { |
2618 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { | 2579 | if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { |
2619 | inR.setRevision( modifiedCalendar ); | 2580 | inR.setRevision( modifiedCalendar ); |
2620 | remote->insertAddressee( inR, false ); | 2581 | remote->insertAddressee( inR, false ); |
2621 | inR.setResource( 0 ); | 2582 | inR.setResource( 0 ); |
2622 | local->insertAddressee( inR, false ); | 2583 | local->insertAddressee( inR, false ); |
2623 | ++addedAddressee; | 2584 | ++addedAddressee; |
2624 | } else { | 2585 | } else { |
2625 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); | 2586 | // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); |
2626 | remote->removeAddressee( inR ); | 2587 | remote->removeAddressee( inR ); |
2627 | ++deletedAddresseeR; | 2588 | ++deletedAddresseeR; |
2628 | } | 2589 | } |
2629 | } | 2590 | } |
2630 | } | 2591 | } |
2631 | } | 2592 | } |
2632 | ++incCounter; | 2593 | ++incCounter; |
2633 | } | 2594 | } |
2634 | er.clear(); | 2595 | er.clear(); |
2635 | QStringList el = local->uidList(); | 2596 | QStringList el = local->uidList(); |
2636 | modulo = (el.count()/10)+1; | 2597 | modulo = (el.count()/10)+1; |
2637 | 2598 | ||
2638 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); | 2599 | syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); |
2639 | incCounter = 0; | 2600 | incCounter = 0; |
2640 | while ( incCounter < el.count()) { | 2601 | while ( incCounter < el.count()) { |
2641 | qApp->processEvents(); | 2602 | qApp->processEvents(); |
2642 | if (syncManager->isProgressBarCanceled()) | 2603 | if (syncManager->isProgressBarCanceled()) |
2643 | return false; | 2604 | return false; |
2644 | if ( incCounter % modulo == 0 ) | 2605 | if ( incCounter % modulo == 0 ) |
2645 | syncManager->showProgressBar(incCounter); | 2606 | syncManager->showProgressBar(incCounter); |
2646 | uid = el[ incCounter ]; | 2607 | uid = el[ incCounter ]; |
2647 | bool skipIncidence = false; | 2608 | bool skipIncidence = false; |
2648 | if ( uid.left(19) == QString("last-syncAddressee-") ) | 2609 | if ( uid.left(19) == QString("last-syncAddressee-") ) |
2649 | skipIncidence = true; | 2610 | skipIncidence = true; |
2650 | if ( !skipIncidence ) { | 2611 | if ( !skipIncidence ) { |
2651 | inL = local->findByUid( uid ); | 2612 | inL = local->findByUid( uid ); |
2652 | if ( !inL.resource() || inL.resource()->includeInSync() ) { | 2613 | if ( !inL.resource() || inL.resource()->includeInSync() ) { |
2653 | inR = remote->findByUid( uid ); | 2614 | inR = remote->findByUid( uid ); |
2654 | if ( inR.isEmpty() ) { | 2615 | if ( inR.isEmpty() ) { |
2655 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 2616 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
2656 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 2617 | if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
2657 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2618 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2658 | local->removeAddressee( inL ); | 2619 | local->removeAddressee( inL ); |
2659 | ++deletedAddresseeL; | 2620 | ++deletedAddresseeL; |
2660 | } else { | 2621 | } else { |
2661 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2622 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2662 | inL.removeID(mCurrentSyncDevice ); | 2623 | inL.removeID(mCurrentSyncDevice ); |
2663 | ++addedAddresseeR; | 2624 | ++addedAddresseeR; |
2664 | inL.setRevision( modifiedCalendar ); | 2625 | inL.setRevision( modifiedCalendar ); |
2665 | local->insertAddressee( inL, false ); | 2626 | local->insertAddressee( inL, false ); |
2666 | inR = inL; | 2627 | inR = inL; |
2667 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); | 2628 | inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); |
2668 | inR.setResource( 0 ); | 2629 | inR.setResource( 0 ); |
2669 | remote->insertAddressee( inR, false ); | 2630 | remote->insertAddressee( inR, false ); |
2670 | } | 2631 | } |
2671 | } | 2632 | } |
2672 | } else { | 2633 | } else { |
2673 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { | 2634 | if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { |
2674 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); | 2635 | // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); |
2675 | local->removeAddressee( inL ); | 2636 | local->removeAddressee( inL ); |
2676 | ++deletedAddresseeL; | 2637 | ++deletedAddresseeL; |
2677 | } else { | 2638 | } else { |
2678 | if ( ! syncManager->mWriteBackExistingOnly ) { | 2639 | if ( ! syncManager->mWriteBackExistingOnly ) { |
2679 | ++addedAddresseeR; | 2640 | ++addedAddresseeR; |
2680 | inL.setRevision( modifiedCalendar ); | 2641 | inL.setRevision( modifiedCalendar ); |
2681 | local->insertAddressee( inL, false ); | 2642 | local->insertAddressee( inL, false ); |
2682 | inR = inL; | 2643 | inR = inL; |
2683 | inR.setResource( 0 ); | 2644 | inR.setResource( 0 ); |
2684 | remote->insertAddressee( inR, false ); | 2645 | remote->insertAddressee( inR, false ); |
2685 | } | 2646 | } |
2686 | } | 2647 | } |
2687 | } | 2648 | } |
2688 | } | 2649 | } |
2689 | } | 2650 | } |
2690 | } | 2651 | } |
2691 | ++incCounter; | 2652 | ++incCounter; |
2692 | } | 2653 | } |
2693 | el.clear(); | 2654 | el.clear(); |
2694 | syncManager->hideProgressBar(); | 2655 | syncManager->hideProgressBar(); |
2695 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); | 2656 | mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); |
2696 | // get rid of micro seconds | 2657 | // get rid of micro seconds |
2697 | QTime t = mLastAddressbookSync.time(); | 2658 | QTime t = mLastAddressbookSync.time(); |
2698 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 2659 | mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
2699 | addresseeLSync.setRevision( mLastAddressbookSync ); | 2660 | addresseeLSync.setRevision( mLastAddressbookSync ); |
2700 | addresseeRSync.setRevision( mLastAddressbookSync ); | 2661 | addresseeRSync.setRevision( mLastAddressbookSync ); |
2701 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; | 2662 | addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; |
2702 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); | 2663 | addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); |
2703 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; | 2664 | addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; |
2704 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); | 2665 | addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); |
2705 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; | 2666 | addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; |
2706 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); | 2667 | addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); |
2707 | addresseeRSync.setNote( "" ) ; | 2668 | addresseeRSync.setNote( "" ) ; |
2708 | addresseeLSync.setNote( "" ); | 2669 | addresseeLSync.setNote( "" ); |
2709 | 2670 | ||
2710 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 2671 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
2711 | remote->insertAddressee( addresseeRSync, false ); | 2672 | remote->insertAddressee( addresseeRSync, false ); |
2712 | local->insertAddressee( addresseeLSync, false ); | 2673 | local->insertAddressee( addresseeLSync, false ); |
2713 | QString mes; | 2674 | QString mes; |
2714 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); | 2675 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); |
2715 | if ( syncManager->mShowSyncSummary ) { | 2676 | if ( syncManager->mShowSyncSummary ) { |
2716 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); | 2677 | KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); |
2717 | } | 2678 | } |
2718 | qDebug( mes ); | 2679 | qDebug( mes ); |
2719 | return syncOK; | 2680 | return syncOK; |
2720 | } | 2681 | } |
2721 | 2682 | ||
2722 | 2683 | ||
2723 | //this is a overwritten callbackmethods from the syncinterface | 2684 | //this is a overwritten callbackmethods from the syncinterface |
2724 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) | 2685 | bool KABCore::sync(KSyncManager* manager, QString filename, int mode) |
2725 | { | 2686 | { |
2726 | 2687 | ||
2727 | //pending prepare addresseeview for output | 2688 | //pending prepare addresseeview for output |
2728 | //pending detect, if remote file has REV field. if not switch to external sync | 2689 | //pending detect, if remote file has REV field. if not switch to external sync |
2729 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 2690 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
2730 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2691 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2731 | 2692 | ||
2732 | AddressBook abLocal(filename,"syncContact"); | 2693 | AddressBook abLocal(filename,"syncContact"); |
2733 | bool syncOK = false; | 2694 | bool syncOK = false; |
2734 | if ( abLocal.load() ) { | 2695 | if ( abLocal.load() ) { |
2735 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); | 2696 | qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); |
2736 | bool external = false; | 2697 | bool external = false; |
2737 | bool isXML = false; | 2698 | bool isXML = false; |
2738 | if ( filename.right(4) == ".xml") { | 2699 | if ( filename.right(4) == ".xml") { |
2739 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2700 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2740 | isXML = true; | 2701 | isXML = true; |
2741 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2702 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2742 | } else { | 2703 | } else { |
2743 | external = !manager->mIsKapiFile; | 2704 | external = !manager->mIsKapiFile; |
2744 | if ( external ) { | 2705 | if ( external ) { |
2745 | qDebug("Setting vcf mode to external "); | 2706 | qDebug("Setting vcf mode to external "); |
2746 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2707 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2747 | AddressBook::Iterator it; | 2708 | AddressBook::Iterator it; |
2748 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2709 | for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2749 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); | 2710 | (*it).setID( mCurrentSyncDevice, (*it).uid() ); |
2750 | (*it).computeCsum( mCurrentSyncDevice ); | 2711 | (*it).computeCsum( mCurrentSyncDevice ); |
2751 | } | 2712 | } |
2752 | } | 2713 | } |
2753 | } | 2714 | } |
2754 | //AddressBook::Iterator it; | 2715 | //AddressBook::Iterator it; |
2755 | //QStringList vcards; | 2716 | //QStringList vcards; |
2756 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { | 2717 | //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { |
2757 | // qDebug("Name %s ", (*it).familyName().latin1()); | 2718 | // qDebug("Name %s ", (*it).familyName().latin1()); |
2758 | //} | 2719 | //} |
2759 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); | 2720 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); |
2760 | if ( syncOK ) { | 2721 | if ( syncOK ) { |
2761 | if ( syncManager->mWriteBackFile ) | 2722 | if ( syncManager->mWriteBackFile ) |
2762 | { | 2723 | { |
2763 | if ( external ) | 2724 | if ( external ) |
2764 | abLocal.removeSyncAddressees( !isXML); | 2725 | abLocal.removeSyncAddressees( !isXML); |
2765 | qDebug("Saving remote AB "); | 2726 | qDebug("Saving remote AB "); |
2766 | if ( ! abLocal.saveAB()) | 2727 | if ( ! abLocal.saveAB()) |
2767 | qDebug("Error writing back AB to file "); | 2728 | qDebug("Error writing back AB to file "); |
2768 | if ( isXML ) { | 2729 | if ( isXML ) { |
2769 | // afterwrite processing | 2730 | // afterwrite processing |
2770 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2731 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2771 | } | 2732 | } |
2772 | } | 2733 | } |
2773 | } | 2734 | } |
2774 | setModified(); | 2735 | setModified(); |
2775 | 2736 | ||
2776 | } | 2737 | } |
2777 | if ( syncOK ) | 2738 | if ( syncOK ) |
2778 | mViewManager->refreshView(); | 2739 | mViewManager->refreshView(); |
2779 | return syncOK; | 2740 | return syncOK; |
2780 | 2741 | ||
2781 | } | 2742 | } |
2782 | 2743 | ||
2783 | 2744 | ||
2784 | //this is a overwritten callbackmethods from the syncinterface | 2745 | //this is a overwritten callbackmethods from the syncinterface |
2785 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) | 2746 | bool KABCore::syncExternal(KSyncManager* manager, QString resource) |
2786 | { | 2747 | { |
2787 | if ( resource == "phone" ) | 2748 | if ( resource == "phone" ) |
2788 | return syncPhone(); | 2749 | return syncPhone(); |
2789 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); | 2750 | QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); |
2790 | 2751 | ||
2791 | AddressBook abLocal( resource,"syncContact"); | 2752 | AddressBook abLocal( resource,"syncContact"); |
2792 | bool syncOK = false; | 2753 | bool syncOK = false; |
2793 | if ( abLocal.load() ) { | 2754 | if ( abLocal.load() ) { |
2794 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2755 | qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2795 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2756 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2796 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); | 2757 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); |
2797 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2758 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2798 | if ( syncOK ) { | 2759 | if ( syncOK ) { |
2799 | if ( syncManager->mWriteBackFile ) { | 2760 | if ( syncManager->mWriteBackFile ) { |
2800 | abLocal.removeSyncAddressees( false ); | 2761 | abLocal.removeSyncAddressees( false ); |
2801 | abLocal.saveAB(); | 2762 | abLocal.saveAB(); |
2802 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2763 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2803 | } | 2764 | } |
2804 | } | 2765 | } |
2805 | setModified(); | 2766 | setModified(); |
2806 | } | 2767 | } |
2807 | if ( syncOK ) | 2768 | if ( syncOK ) |
2808 | mViewManager->refreshView(); | 2769 | mViewManager->refreshView(); |
2809 | return syncOK; | 2770 | return syncOK; |
2810 | 2771 | ||
2811 | } | 2772 | } |
2812 | void KABCore::message( QString m ) | 2773 | void KABCore::message( QString m ) |
2813 | { | 2774 | { |
2814 | topLevelWidget()->setCaption( m ); | 2775 | topLevelWidget()->setCaption( m ); |
2815 | mMessageTimer->start( 15000, true ); | 2776 | mMessageTimer->start( 15000, true ); |
2816 | } | 2777 | } |
2817 | bool KABCore::syncPhone() | 2778 | bool KABCore::syncPhone() |
2818 | { | 2779 | { |
2819 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); | 2780 | QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); |
2820 | QString fileName = getPhoneFile(); | 2781 | QString fileName = getPhoneFile(); |
2821 | if ( !PhoneAccess::readFromPhone( fileName) ) { | 2782 | if ( !PhoneAccess::readFromPhone( fileName) ) { |
2822 | message(i18n("Phone access failed!")); | 2783 | message(i18n("Phone access failed!")); |
2823 | return false; | 2784 | return false; |
2824 | } | 2785 | } |
2825 | AddressBook abLocal( fileName,"syncContact"); | 2786 | AddressBook abLocal( fileName,"syncContact"); |
2826 | bool syncOK = false; | 2787 | bool syncOK = false; |
2827 | { | 2788 | { |
2828 | abLocal.importFromFile( fileName ); | 2789 | abLocal.importFromFile( fileName ); |
2829 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); | 2790 | qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); |
2830 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 2791 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
2831 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); | 2792 | abLocal.preparePhoneSync( mCurrentSyncDevice, true ); |
2832 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); | 2793 | abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); |
2833 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); | 2794 | syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); |
2834 | if ( syncOK ) { | 2795 | if ( syncOK ) { |
2835 | if ( syncManager->mWriteBackFile ) { | 2796 | if ( syncManager->mWriteBackFile ) { |
2836 | abLocal.removeSyncAddressees( true ); | 2797 | abLocal.removeSyncAddressees( true ); |
2837 | abLocal.saveABphone( fileName ); | 2798 | abLocal.saveABphone( fileName ); |
2838 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); | 2799 | abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); |
2839 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); | 2800 | //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); |
2840 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); | 2801 | abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); |
2841 | } | 2802 | } |
2842 | } | 2803 | } |
2843 | setModified(); | 2804 | setModified(); |
2844 | } | 2805 | } |
2845 | if ( syncOK ) | 2806 | if ( syncOK ) |
2846 | mViewManager->refreshView(); | 2807 | mViewManager->refreshView(); |
2847 | return syncOK; | 2808 | return syncOK; |
2848 | } | 2809 | } |
2849 | void KABCore::getFile( bool success ) | 2810 | void KABCore::getFile( bool success ) |
2850 | { | 2811 | { |
2851 | if ( ! success ) { | 2812 | if ( ! success ) { |
2852 | message( i18n("Error receiving file. Nothing changed!") ); | 2813 | message( i18n("Error receiving file. Nothing changed!") ); |
2853 | return; | 2814 | return; |
2854 | } | 2815 | } |
2855 | mAddressBook->importFromFile( sentSyncFile() , false, true ); | 2816 | mAddressBook->importFromFile( sentSyncFile() , false, true ); |
2856 | message( i18n("Pi-Sync successful!") ); | 2817 | message( i18n("Pi-Sync successful!") ); |
2857 | mViewManager->refreshView(); | 2818 | mViewManager->refreshView(); |
2858 | } | 2819 | } |
2859 | void KABCore::syncFileRequest() | 2820 | void KABCore::syncFileRequest() |
2860 | { | 2821 | { |
2861 | mAddressBook->export2File( sentSyncFile() ); | 2822 | mAddressBook->export2File( sentSyncFile() ); |
2862 | } | 2823 | } |
2863 | QString KABCore::sentSyncFile() | 2824 | QString KABCore::sentSyncFile() |
2864 | { | 2825 | { |
2865 | #ifdef _WIN32_ | 2826 | #ifdef DESKTOP_VERSION |
2866 | return locateLocal( "tmp", "copysyncab.vcf" ); | 2827 | return locateLocal( "tmp", "copysyncab.vcf" ); |
2867 | #else | 2828 | #else |
2868 | return QString( "/tmp/copysyncab.vcf" ); | 2829 | return QString( "/tmp/copysyncab.vcf" ); |
2869 | #endif | 2830 | #endif |
2870 | } | 2831 | } |
2871 | 2832 | ||
2872 | void KABCore::setCaptionBack() | 2833 | void KABCore::setCaptionBack() |
2873 | { | 2834 | { |
2874 | mMessageTimer->stop(); | 2835 | mMessageTimer->stop(); |
2875 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); | 2836 | topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); |
2876 | } | 2837 | } |
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 6e560d7..32a3b7c 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -1,527 +1,531 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | #include "composemail.h" | 2 | #include "composemail.h" |
3 | #include "viewmail.h" | 3 | #include "viewmail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
6 | #include <libmailwrapper/abstractmail.h> | 6 | #include <libmailwrapper/abstractmail.h> |
7 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
8 | #include <kapplication.h> | 8 | #include <kapplication.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/odebug.h> | 11 | //#include <opie2/odebug.h> |
12 | //#include <opie2/ofiledialog.h> | 12 | //#include <opie2/ofiledialog.h> |
13 | //#include <opie2/oimagescrollview.h> | 13 | //#include <opie2/oimagescrollview.h> |
14 | 14 | ||
15 | #include <kfiledialog.h> | 15 | #include <kfiledialog.h> |
16 | #include <kdialog.h> | 16 | #include <kdialog.h> |
17 | 17 | ||
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | 19 | ||
20 | /* QT */ | 20 | /* QT */ |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtextstream.h> | 23 | #include <qtextstream.h> |
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qpopupmenu.h> | 25 | #include <qpopupmenu.h> |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | 29 | ||
30 | //using namespace Opie::Ui; | 30 | //using namespace Opie::Ui; |
31 | //using namespace Opie::Core; | 31 | //using namespace Opie::Core; |
32 | 32 | ||
33 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 33 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
34 | const QString&fsize,int num,const QValueList<int>&path) | 34 | const QString&fsize,int num,const QValueList<int>&path) |
35 | : QListViewItem(parent,after),_partNum(num) | 35 | : QListViewItem(parent,after),_partNum(num) |
36 | { | 36 | { |
37 | _path=path; | 37 | _path=path; |
38 | setText(0, mime); | 38 | setText(0, mime); |
39 | setText(1, desc); | 39 | setText(1, desc); |
40 | setText(2, file); | 40 | setText(2, file); |
41 | setText(3, fsize); | 41 | setText(3, fsize); |
42 | } | 42 | } |
43 | 43 | ||
44 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 44 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
45 | const QString&fsize,int num,const QValueList<int>&path) | 45 | const QString&fsize,int num,const QValueList<int>&path) |
46 | : QListViewItem(parent,after),_partNum(num) | 46 | : QListViewItem(parent,after),_partNum(num) |
47 | { | 47 | { |
48 | _path=path; | 48 | _path=path; |
49 | setText(0, mime); | 49 | setText(0, mime); |
50 | setText(1, desc); | 50 | setText(1, desc); |
51 | setText(2, file); | 51 | setText(2, file); |
52 | setText(3, fsize); | 52 | setText(3, fsize); |
53 | } | 53 | } |
54 | 54 | ||
55 | bool AttachItem::isParentof(const QValueList<int>&path) | 55 | bool AttachItem::isParentof(const QValueList<int>&path) |
56 | { | 56 | { |
57 | /* if not set, then no parent */ | 57 | /* if not set, then no parent */ |
58 | if (path.count()==0||_path.count()==0) return false; | 58 | if (path.count()==0||_path.count()==0) return false; |
59 | /* the parent must have one digit less then a child */ | 59 | /* the parent must have one digit less then a child */ |
60 | if (path.count()!=_path.count()+1) return false; | 60 | if (path.count()!=_path.count()+1) return false; |
61 | for (unsigned int i=0; i < _path.count();++i) | 61 | for (unsigned int i=0; i < _path.count();++i) |
62 | { | 62 | { |
63 | if (_path[i]!=path[i]) return false; | 63 | if (_path[i]!=path[i]) return false; |
64 | } | 64 | } |
65 | return true; | 65 | return true; |
66 | } | 66 | } |
67 | 67 | ||
68 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 68 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
69 | { | 69 | { |
70 | QListViewItemIterator it( attachments ); | 70 | QListViewItemIterator it( attachments ); |
71 | for ( ; it.current(); ++it ) | 71 | for ( ; it.current(); ++it ) |
72 | { | 72 | { |
73 | AttachItem*ati = (AttachItem*)it.current(); | 73 | AttachItem*ati = (AttachItem*)it.current(); |
74 | if (ati->isParentof(path)) return ati; | 74 | if (ati->isParentof(path)) return ati; |
75 | } | 75 | } |
76 | return 0; | 76 | return 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 79 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
80 | { | 80 | { |
81 | if (!parent) return 0; | 81 | if (!parent) return 0; |
82 | AttachItem* item = (AttachItem*)parent->firstChild(); | 82 | AttachItem* item = (AttachItem*)parent->firstChild(); |
83 | if (!item) return item; | 83 | if (!item) return item; |
84 | AttachItem*temp=0; | 84 | AttachItem*temp=0; |
85 | while( (temp=(AttachItem*)item->nextSibling())) | 85 | while( (temp=(AttachItem*)item->nextSibling())) |
86 | { | 86 | { |
87 | item = temp; | 87 | item = temp; |
88 | } | 88 | } |
89 | return item; | 89 | return item; |
90 | } | 90 | } |
91 | 91 | ||
92 | void ViewMail::setBody(const RecBodyP&body ) | 92 | void ViewMail::setBody(const RecBodyP&body ) |
93 | { | 93 | { |
94 | 94 | ||
95 | m_body = body; | 95 | m_body = body; |
96 | m_mail[2] = body->Bodytext(); | 96 | m_mail[2] = body->Bodytext(); |
97 | attachbutton->setEnabled(body->Parts().count()>0); | 97 | attachbutton->setEnabled(body->Parts().count()>0); |
98 | attachments->setEnabled(body->Parts().count()>0); | 98 | attachments->setEnabled(body->Parts().count()>0); |
99 | if (body->Parts().count()==0) | 99 | if (body->Parts().count()==0) |
100 | { | 100 | { |
101 | return; | 101 | return; |
102 | } | 102 | } |
103 | AttachItem * curItem=0; | 103 | AttachItem * curItem=0; |
104 | AttachItem * parentItem = 0; | 104 | AttachItem * parentItem = 0; |
105 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); | 105 | QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); |
106 | QString desc,fsize; | 106 | QString desc,fsize; |
107 | double s = body->Description()->Size(); | 107 | double s = body->Description()->Size(); |
108 | int w; | 108 | int w; |
109 | w=0; | 109 | w=0; |
110 | 110 | ||
111 | while (s>1024) | 111 | while (s>1024) |
112 | { | 112 | { |
113 | s/=1024; | 113 | s/=1024; |
114 | ++w; | 114 | ++w; |
115 | if (w>=2) break; | 115 | if (w>=2) break; |
116 | } | 116 | } |
117 | 117 | ||
118 | QString q=""; | 118 | QString q=""; |
119 | switch(w) | 119 | switch(w) |
120 | { | 120 | { |
121 | case 1: | 121 | case 1: |
122 | q="k"; | 122 | q="k"; |
123 | break; | 123 | break; |
124 | case 2: | 124 | case 2: |
125 | q="M"; | 125 | q="M"; |
126 | break; | 126 | break; |
127 | default: | 127 | default: |
128 | break; | 128 | break; |
129 | } | 129 | } |
130 | 130 | ||
131 | { | 131 | { |
132 | /* I did not found a method to make a CONTENT reset on a QTextStream | 132 | /* I did not found a method to make a CONTENT reset on a QTextStream |
133 | so I use this construct that the stream will re-constructed in each | 133 | so I use this construct that the stream will re-constructed in each |
134 | loop. To let it work, the textstream is packed into a own area of | 134 | loop. To let it work, the textstream is packed into a own area of |
135 | code is it will be destructed after finishing its small job. | 135 | code is it will be destructed after finishing its small job. |
136 | */ | 136 | */ |
137 | QTextOStream o(&fsize); | 137 | QTextOStream o(&fsize); |
138 | if (w>0) o.precision(2); else o.precision(0); | 138 | if (w>0) o.precision(2); else o.precision(0); |
139 | o.setf(QTextStream::fixed); | 139 | o.setf(QTextStream::fixed); |
140 | o << s << " " << q << "Byte"; | 140 | o << s << " " << q << "Byte"; |
141 | } | 141 | } |
142 | 142 | ||
143 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); | 143 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); |
144 | QString filename = ""; | 144 | QString filename = ""; |
145 | 145 | ||
146 | for (unsigned int i = 0; i < body->Parts().count();++i) | 146 | for (unsigned int i = 0; i < body->Parts().count();++i) |
147 | { | 147 | { |
148 | filename = ""; | 148 | filename = ""; |
149 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); | 149 | type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); |
150 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); | 150 | part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); |
151 | for (;it!=body->Parts()[i]->Parameters().end();++it) | 151 | for (;it!=body->Parts()[i]->Parameters().end();++it) |
152 | { | 152 | { |
153 | if (it.key().lower()=="name") | 153 | if (it.key().lower()=="name") |
154 | { | 154 | { |
155 | filename=it.data(); | 155 | filename=it.data(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | s = body->Parts()[i]->Size(); | 158 | s = body->Parts()[i]->Size(); |
159 | w = 0; | 159 | w = 0; |
160 | while (s>1024) | 160 | while (s>1024) |
161 | { | 161 | { |
162 | s/=1024; | 162 | s/=1024; |
163 | ++w; | 163 | ++w; |
164 | if (w>=2) break; | 164 | if (w>=2) break; |
165 | } | 165 | } |
166 | switch(w) | 166 | switch(w) |
167 | { | 167 | { |
168 | case 1: | 168 | case 1: |
169 | q="k"; | 169 | q="k"; |
170 | break; | 170 | break; |
171 | case 2: | 171 | case 2: |
172 | q="M"; | 172 | q="M"; |
173 | break; | 173 | break; |
174 | default: | 174 | default: |
175 | q=""; | 175 | q=""; |
176 | break; | 176 | break; |
177 | } | 177 | } |
178 | QTextOStream o(&fsize); | 178 | QTextOStream o(&fsize); |
179 | if (w>0) o.precision(2); else o.precision(0); | 179 | if (w>0) o.precision(2); else o.precision(0); |
180 | o.setf(QTextStream::fixed); | 180 | o.setf(QTextStream::fixed); |
181 | o << s << " " << q << "Byte"; | 181 | o << s << " " << q << "Byte"; |
182 | desc = body->Parts()[i]->Description(); | 182 | desc = body->Parts()[i]->Description(); |
183 | parentItem = searchParent(body->Parts()[i]->Positionlist()); | 183 | parentItem = searchParent(body->Parts()[i]->Positionlist()); |
184 | if (parentItem) | 184 | if (parentItem) |
185 | { | 185 | { |
186 | AttachItem*temp = lastChild(parentItem); | 186 | AttachItem*temp = lastChild(parentItem); |
187 | if (temp) curItem = temp; | 187 | if (temp) curItem = temp; |
188 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 188 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
189 | attachments->setRootIsDecorated(true); | 189 | attachments->setRootIsDecorated(true); |
190 | curItem = parentItem; | 190 | curItem = parentItem; |
191 | } | 191 | } |
192 | else | 192 | else |
193 | { | 193 | { |
194 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); | 194 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | 199 | ||
200 | void ViewMail::slotShowHtml( bool state ) | 200 | void ViewMail::slotShowHtml( bool state ) |
201 | { | 201 | { |
202 | m_showHtml = state; | 202 | m_showHtml = state; |
203 | setText(); | 203 | setText(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 206 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
207 | { | 207 | { |
208 | if (!item ) | 208 | if (!item ) |
209 | return; | 209 | return; |
210 | 210 | ||
211 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 211 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
212 | { | 212 | { |
213 | setText(); | 213 | setText(); |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | QPopupMenu *menu = new QPopupMenu(); | 216 | QPopupMenu *menu = new QPopupMenu(); |
217 | int ret=0; | 217 | int ret=0; |
218 | 218 | ||
219 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 219 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
220 | { | 220 | { |
221 | menu->insertItem( tr( "Show Text" ), 1 ); | 221 | menu->insertItem( tr( "Show Text" ), 1 ); |
222 | } | 222 | } |
223 | if (item->text(0).left(6)=="image/") { | 223 | if (item->text(0).left(6)=="image/") { |
224 | menu->insertItem(tr("Display image preview"),2); | 224 | menu->insertItem(tr("Display image preview"),2); |
225 | } | 225 | } |
226 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 226 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
227 | menu->insertSeparator(1); | 227 | menu->insertSeparator(1); |
228 | 228 | ||
229 | ret = menu->exec( point, 0 ); | 229 | ret = menu->exec( point, 0 ); |
230 | 230 | ||
231 | switch(ret) | 231 | switch(ret) |
232 | { | 232 | { |
233 | case 0: | 233 | case 0: |
234 | { | 234 | { |
235 | //MimeTypes types; | 235 | //MimeTypes types; |
236 | //types.insert( "all", "*" ); | 236 | //types.insert( "all", "*" ); |
237 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); | 237 | QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); |
238 | 238 | ||
239 | if( !str.isEmpty() ) | 239 | if( !str.isEmpty() ) |
240 | { | 240 | { |
241 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 241 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
242 | if (content) | 242 | if (content) |
243 | { | 243 | { |
244 | QFile output(str); | 244 | QFile output(str); |
245 | output.open(IO_WriteOnly); | 245 | output.open(IO_WriteOnly); |
246 | output.writeBlock(content->Content(),content->Length()); | 246 | output.writeBlock(content->Content(),content->Length()); |
247 | output.close(); | 247 | output.close(); |
248 | delete content; | 248 | delete content; |
249 | } | 249 | } |
250 | } | 250 | } |
251 | } | 251 | } |
252 | break ; | 252 | break ; |
253 | 253 | ||
254 | case 2: | 254 | case 2: |
255 | { | 255 | { |
256 | #ifdef DESKTOP_VERSION | ||
257 | QString tmpfile = locateLocal( "tmp", "opiemail-image"); | ||
258 | #else | ||
256 | QString tmpfile = "/tmp/opiemail-image"; | 259 | QString tmpfile = "/tmp/opiemail-image"; |
260 | #endif | ||
257 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 261 | encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
258 | if (content) { | 262 | if (content) { |
259 | QFile output(tmpfile); | 263 | QFile output(tmpfile); |
260 | output.open(IO_WriteOnly); | 264 | output.open(IO_WriteOnly); |
261 | output.writeBlock(content->Content(),content->Length()); | 265 | output.writeBlock(content->Content(),content->Length()); |
262 | output.close(); | 266 | output.close(); |
263 | delete content; | 267 | delete content; |
264 | MailImageDlg iview(""); | 268 | MailImageDlg iview(""); |
265 | iview.setName(tmpfile); | 269 | iview.setName(tmpfile); |
266 | KApplication::execDialog(&iview); | 270 | KApplication::execDialog(&iview); |
267 | output.remove(); | 271 | output.remove(); |
268 | } | 272 | } |
269 | } | 273 | } |
270 | break; | 274 | break; |
271 | case 1: | 275 | case 1: |
272 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 276 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
273 | { | 277 | { |
274 | setText(); | 278 | setText(); |
275 | } | 279 | } |
276 | else | 280 | else |
277 | { | 281 | { |
278 | if ( m_recMail->Wrapper() != 0l ) | 282 | if ( m_recMail->Wrapper() != 0l ) |
279 | { // make sure that there is a wrapper , even after delete or simular actions | 283 | { // make sure that there is a wrapper , even after delete or simular actions |
280 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 284 | browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
281 | } | 285 | } |
282 | } | 286 | } |
283 | break; | 287 | break; |
284 | } | 288 | } |
285 | delete menu; | 289 | delete menu; |
286 | } | 290 | } |
287 | 291 | ||
288 | 292 | ||
289 | void ViewMail::setMail(const RecMailP&mail ) | 293 | void ViewMail::setMail(const RecMailP&mail ) |
290 | { | 294 | { |
291 | 295 | ||
292 | m_recMail = mail; | 296 | m_recMail = mail; |
293 | 297 | ||
294 | m_mail[0] = mail->getFrom(); | 298 | m_mail[0] = mail->getFrom(); |
295 | m_mail[1] = mail->getSubject(); | 299 | m_mail[1] = mail->getSubject(); |
296 | m_mail[3] = mail->getDate(); | 300 | m_mail[3] = mail->getDate(); |
297 | m_mail[4] = mail->Msgid(); | 301 | m_mail[4] = mail->Msgid(); |
298 | 302 | ||
299 | m_mail2[0] = mail->To(); | 303 | m_mail2[0] = mail->To(); |
300 | m_mail2[1] = mail->CC(); | 304 | m_mail2[1] = mail->CC(); |
301 | m_mail2[2] = mail->Bcc(); | 305 | m_mail2[2] = mail->Bcc(); |
302 | 306 | ||
303 | setText(); | 307 | setText(); |
304 | } | 308 | } |
305 | 309 | ||
306 | 310 | ||
307 | 311 | ||
308 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 312 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
309 | : ViewMailBase(parent, name, fl), _inLoop(false) | 313 | : ViewMailBase(parent, name, fl), _inLoop(false) |
310 | { | 314 | { |
311 | m_gotBody = false; | 315 | m_gotBody = false; |
312 | deleted = false; | 316 | deleted = false; |
313 | 317 | ||
314 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 318 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
315 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 319 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
316 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 320 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
317 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 321 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
318 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 322 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
319 | 323 | ||
320 | attachments->setEnabled(m_gotBody); | 324 | attachments->setEnabled(m_gotBody); |
321 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 325 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
322 | 326 | ||
323 | readConfig(); | 327 | readConfig(); |
324 | attachments->setSorting(-1); | 328 | attachments->setSorting(-1); |
325 | } | 329 | } |
326 | 330 | ||
327 | void ViewMail::readConfig() | 331 | void ViewMail::readConfig() |
328 | { | 332 | { |
329 | 333 | ||
330 | setFont ( KOPrefs::instance()->mReadFont ); | 334 | setFont ( KOPrefs::instance()->mReadFont ); |
331 | m_showHtml = KOPrefs::instance()->mViewAsHtml; | 335 | m_showHtml = KOPrefs::instance()->mViewAsHtml; |
332 | showHtml->setOn( m_showHtml ); | 336 | showHtml->setOn( m_showHtml ); |
333 | } | 337 | } |
334 | 338 | ||
335 | void ViewMail::setText() | 339 | void ViewMail::setText() |
336 | { | 340 | { |
337 | 341 | ||
338 | QString toString; | 342 | QString toString; |
339 | QString ccString; | 343 | QString ccString; |
340 | QString bccString; | 344 | QString bccString; |
341 | 345 | ||
342 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 346 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
343 | { | 347 | { |
344 | toString += (*it); | 348 | toString += (*it); |
345 | } | 349 | } |
346 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 350 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
347 | { | 351 | { |
348 | ccString += (*it); | 352 | ccString += (*it); |
349 | } | 353 | } |
350 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 354 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
351 | { | 355 | { |
352 | bccString += (*it); | 356 | bccString += (*it); |
353 | } | 357 | } |
354 | 358 | ||
355 | setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); | 359 | setCaption( tr("E-Mail by %1").arg( m_mail[0] ) ); |
356 | 360 | ||
357 | m_mailHtml = "<html><body>" | 361 | m_mailHtml = "<html><body>" |
358 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 362 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
359 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 363 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
360 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 364 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
361 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 365 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
362 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 366 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
363 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 367 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
364 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 368 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
365 | "</td></tr></table><font>"; | 369 | "</td></tr></table><font>"; |
366 | 370 | ||
367 | if ( !m_showHtml ) | 371 | if ( !m_showHtml ) |
368 | { | 372 | { |
369 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 373 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
370 | } | 374 | } |
371 | else | 375 | else |
372 | { | 376 | { |
373 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 377 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
374 | } | 378 | } |
375 | // remove later in favor of a real handling | 379 | // remove later in favor of a real handling |
376 | m_gotBody = true; | 380 | m_gotBody = true; |
377 | } | 381 | } |
378 | 382 | ||
379 | 383 | ||
380 | ViewMail::~ViewMail() | 384 | ViewMail::~ViewMail() |
381 | { | 385 | { |
382 | m_recMail->Wrapper()->cleanMimeCache(); | 386 | m_recMail->Wrapper()->cleanMimeCache(); |
383 | hide(); | 387 | hide(); |
384 | } | 388 | } |
385 | 389 | ||
386 | void ViewMail::hide() | 390 | void ViewMail::hide() |
387 | { | 391 | { |
388 | QWidget::hide(); | 392 | QWidget::hide(); |
389 | 393 | ||
390 | if (_inLoop) | 394 | if (_inLoop) |
391 | { | 395 | { |
392 | _inLoop = false; | 396 | _inLoop = false; |
393 | qApp->exit_loop(); | 397 | qApp->exit_loop(); |
394 | 398 | ||
395 | } | 399 | } |
396 | 400 | ||
397 | } | 401 | } |
398 | 402 | ||
399 | void ViewMail::exec() | 403 | void ViewMail::exec() |
400 | { | 404 | { |
401 | show(); | 405 | show(); |
402 | 406 | ||
403 | if (!_inLoop) | 407 | if (!_inLoop) |
404 | { | 408 | { |
405 | _inLoop = true; | 409 | _inLoop = true; |
406 | qApp->enter_loop(); | 410 | qApp->enter_loop(); |
407 | } | 411 | } |
408 | 412 | ||
409 | } | 413 | } |
410 | 414 | ||
411 | QString ViewMail::deHtml(const QString &string) | 415 | QString ViewMail::deHtml(const QString &string) |
412 | { | 416 | { |
413 | QString string_ = string; | 417 | QString string_ = string; |
414 | string_.replace(QRegExp("&"), "&"); | 418 | string_.replace(QRegExp("&"), "&"); |
415 | string_.replace(QRegExp("<"), "<"); | 419 | string_.replace(QRegExp("<"), "<"); |
416 | string_.replace(QRegExp(">"), ">"); | 420 | string_.replace(QRegExp(">"), ">"); |
417 | string_.replace(QRegExp("\\n"), "<br>"); | 421 | string_.replace(QRegExp("\\n"), "<br>"); |
418 | return string_; | 422 | return string_; |
419 | } | 423 | } |
420 | 424 | ||
421 | void ViewMail::slotReply() | 425 | void ViewMail::slotReply() |
422 | { | 426 | { |
423 | if (!m_gotBody) | 427 | if (!m_gotBody) |
424 | { | 428 | { |
425 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 429 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
426 | return; | 430 | return; |
427 | } | 431 | } |
428 | 432 | ||
429 | QString rtext; | 433 | QString rtext; |
430 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 434 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
431 | .arg( m_mail[0] ) | 435 | .arg( m_mail[0] ) |
432 | .arg( m_mail[3] ); | 436 | .arg( m_mail[3] ); |
433 | 437 | ||
434 | QString text = m_mail[2]; | 438 | QString text = m_mail[2]; |
435 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 439 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
436 | QStringList::Iterator it; | 440 | QStringList::Iterator it; |
437 | for (it = lines.begin(); it != lines.end(); it++) | 441 | for (it = lines.begin(); it != lines.end(); it++) |
438 | { | 442 | { |
439 | rtext += "> " + *it + "\n"; | 443 | rtext += "> " + *it + "\n"; |
440 | } | 444 | } |
441 | rtext += "\n"; | 445 | rtext += "\n"; |
442 | 446 | ||
443 | QString prefix; | 447 | QString prefix; |
444 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 448 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
445 | else prefix = "Re: "; // no i18n on purpose | 449 | else prefix = "Re: "; // no i18n on purpose |
446 | 450 | ||
447 | Settings *settings = new Settings(); | 451 | Settings *settings = new Settings(); |
448 | ComposeMail composer( settings ,this, 0, true); | 452 | ComposeMail composer( settings ,this, 0, true); |
449 | if (m_recMail->Replyto().isEmpty()) { | 453 | if (m_recMail->Replyto().isEmpty()) { |
450 | composer.setTo( m_recMail->getFrom()); | 454 | composer.setTo( m_recMail->getFrom()); |
451 | } else { | 455 | } else { |
452 | composer.setTo( m_recMail->Replyto()); | 456 | composer.setTo( m_recMail->Replyto()); |
453 | } | 457 | } |
454 | composer.setSubject( prefix + m_mail[1] ); | 458 | composer.setSubject( prefix + m_mail[1] ); |
455 | composer.setMessage( rtext ); | 459 | composer.setMessage( rtext ); |
456 | composer.setInReplyTo(m_recMail->Msgid()); | 460 | composer.setInReplyTo(m_recMail->Msgid()); |
457 | 461 | ||
458 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 462 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
459 | { | 463 | { |
460 | m_recMail->Wrapper()->answeredMail(m_recMail); | 464 | m_recMail->Wrapper()->answeredMail(m_recMail); |
461 | } | 465 | } |
462 | } | 466 | } |
463 | 467 | ||
464 | void ViewMail::slotForward() | 468 | void ViewMail::slotForward() |
465 | { | 469 | { |
466 | if (!m_gotBody) | 470 | if (!m_gotBody) |
467 | { | 471 | { |
468 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 472 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
469 | return; | 473 | return; |
470 | } | 474 | } |
471 | 475 | ||
472 | QString ftext; | 476 | QString ftext; |
473 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 477 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
474 | .arg( m_mail[0] ); | 478 | .arg( m_mail[0] ); |
475 | if (!m_mail[3].isNull()) | 479 | if (!m_mail[3].isNull()) |
476 | ftext += QString("Date: %1\n") | 480 | ftext += QString("Date: %1\n") |
477 | .arg( m_mail[3] ); | 481 | .arg( m_mail[3] ); |
478 | if (!m_mail[0].isNull()) | 482 | if (!m_mail[0].isNull()) |
479 | ftext += QString("From: %1\n") | 483 | ftext += QString("From: %1\n") |
480 | .arg( m_mail[0] ); | 484 | .arg( m_mail[0] ); |
481 | if (!m_mail[1].isNull()) | 485 | if (!m_mail[1].isNull()) |
482 | ftext += QString("Subject: %1\n") | 486 | ftext += QString("Subject: %1\n") |
483 | .arg( m_mail[1] ); | 487 | .arg( m_mail[1] ); |
484 | 488 | ||
485 | ftext += QString("\n%1\n") | 489 | ftext += QString("\n%1\n") |
486 | .arg( m_mail[2]); | 490 | .arg( m_mail[2]); |
487 | 491 | ||
488 | ftext += QString("----- End forwarded message -----\n"); | 492 | ftext += QString("----- End forwarded message -----\n"); |
489 | 493 | ||
490 | Settings *settings = new Settings(); | 494 | Settings *settings = new Settings(); |
491 | ComposeMail composer( settings ,this, 0, true); | 495 | ComposeMail composer( settings ,this, 0, true); |
492 | composer.setSubject( "Fwd: " + m_mail[1] ); | 496 | composer.setSubject( "Fwd: " + m_mail[1] ); |
493 | composer.setMessage( ftext ); | 497 | composer.setMessage( ftext ); |
494 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) | 498 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) |
495 | { | 499 | { |
496 | } | 500 | } |
497 | } | 501 | } |
498 | 502 | ||
499 | void ViewMail::slotDeleteMail( ) | 503 | void ViewMail::slotDeleteMail( ) |
500 | { | 504 | { |
501 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 505 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
502 | { | 506 | { |
503 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 507 | m_recMail->Wrapper()->deleteMail( m_recMail ); |
504 | hide(); | 508 | hide(); |
505 | deleted = true; | 509 | deleted = true; |
506 | } | 510 | } |
507 | } | 511 | } |
508 | 512 | ||
509 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 513 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
510 | : KDialog(parent,name,modal) | 514 | : KDialog(parent,name,modal) |
511 | { | 515 | { |
512 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 516 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
513 | dlglayout->setSpacing(2); | 517 | dlglayout->setSpacing(2); |
514 | dlglayout->setMargin(1); | 518 | dlglayout->setMargin(1); |
515 | //m_imageview = new Opie::MM::OImageScrollView(this); | 519 | //m_imageview = new Opie::MM::OImageScrollView(this); |
516 | //dlglayout->addWidget(m_imageview); | 520 | //dlglayout->addWidget(m_imageview); |
517 | } | 521 | } |
518 | 522 | ||
519 | MailImageDlg::~MailImageDlg() | 523 | MailImageDlg::~MailImageDlg() |
520 | { | 524 | { |
521 | } | 525 | } |
522 | 526 | ||
523 | void MailImageDlg::setName(const QString&fname) | 527 | void MailImageDlg::setName(const QString&fname) |
524 | { | 528 | { |
525 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); | 529 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); |
526 | // m_imageview->setImage(fname); | 530 | // m_imageview->setImage(fname); |
527 | } | 531 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 290c0b9..884c61a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1922,770 +1922,773 @@ void CalendarView::readFilterSettings(KConfig *config) | |||
1922 | 1922 | ||
1923 | if (mFilters.count() == 0) { | 1923 | if (mFilters.count() == 0) { |
1924 | CalFilter *filter = new CalFilter(i18n("Default")); | 1924 | CalFilter *filter = new CalFilter(i18n("Default")); |
1925 | mFilters.append(filter); | 1925 | mFilters.append(filter); |
1926 | } | 1926 | } |
1927 | mFilterView->updateFilters(); | 1927 | mFilterView->updateFilters(); |
1928 | config->setGroup("FilterView"); | 1928 | config->setGroup("FilterView"); |
1929 | 1929 | ||
1930 | mFilterView->blockSignals(true); | 1930 | mFilterView->blockSignals(true); |
1931 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1931 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1932 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1932 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1933 | mFilterView->blockSignals(false); | 1933 | mFilterView->blockSignals(false); |
1934 | // We do it manually to avoid it being done twice by the above calls | 1934 | // We do it manually to avoid it being done twice by the above calls |
1935 | updateFilter(); | 1935 | updateFilter(); |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | void CalendarView::writeFilterSettings(KConfig *config) | 1938 | void CalendarView::writeFilterSettings(KConfig *config) |
1939 | { | 1939 | { |
1940 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1940 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1941 | 1941 | ||
1942 | QStringList filterList; | 1942 | QStringList filterList; |
1943 | 1943 | ||
1944 | CalFilter *filter = mFilters.first(); | 1944 | CalFilter *filter = mFilters.first(); |
1945 | while(filter) { | 1945 | while(filter) { |
1946 | // kdDebug() << " fn: " << filter->name() << endl; | 1946 | // kdDebug() << " fn: " << filter->name() << endl; |
1947 | filterList << filter->name(); | 1947 | filterList << filter->name(); |
1948 | config->setGroup("Filter_" + filter->name()); | 1948 | config->setGroup("Filter_" + filter->name()); |
1949 | config->writeEntry("Criteria",filter->criteria()); | 1949 | config->writeEntry("Criteria",filter->criteria()); |
1950 | config->writeEntry("CategoryList",filter->categoryList()); | 1950 | config->writeEntry("CategoryList",filter->categoryList()); |
1951 | filter = mFilters.next(); | 1951 | filter = mFilters.next(); |
1952 | } | 1952 | } |
1953 | config->setGroup("General"); | 1953 | config->setGroup("General"); |
1954 | config->writeEntry("CalendarFilters",filterList); | 1954 | config->writeEntry("CalendarFilters",filterList); |
1955 | 1955 | ||
1956 | config->setGroup("FilterView"); | 1956 | config->setGroup("FilterView"); |
1957 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1957 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1958 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1958 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1959 | } | 1959 | } |
1960 | 1960 | ||
1961 | 1961 | ||
1962 | void CalendarView::goToday() | 1962 | void CalendarView::goToday() |
1963 | { | 1963 | { |
1964 | mNavigator->selectToday(); | 1964 | mNavigator->selectToday(); |
1965 | } | 1965 | } |
1966 | 1966 | ||
1967 | void CalendarView::goNext() | 1967 | void CalendarView::goNext() |
1968 | { | 1968 | { |
1969 | mNavigator->selectNext(); | 1969 | mNavigator->selectNext(); |
1970 | } | 1970 | } |
1971 | 1971 | ||
1972 | void CalendarView::goPrevious() | 1972 | void CalendarView::goPrevious() |
1973 | { | 1973 | { |
1974 | mNavigator->selectPrevious(); | 1974 | mNavigator->selectPrevious(); |
1975 | } | 1975 | } |
1976 | void CalendarView::goNextMonth() | 1976 | void CalendarView::goNextMonth() |
1977 | { | 1977 | { |
1978 | mNavigator->selectNextMonth(); | 1978 | mNavigator->selectNextMonth(); |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | void CalendarView::goPreviousMonth() | 1981 | void CalendarView::goPreviousMonth() |
1982 | { | 1982 | { |
1983 | mNavigator->selectPreviousMonth(); | 1983 | mNavigator->selectPreviousMonth(); |
1984 | } | 1984 | } |
1985 | void CalendarView::writeLocale() | 1985 | void CalendarView::writeLocale() |
1986 | { | 1986 | { |
1987 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1987 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1988 | #if 0 | 1988 | #if 0 |
1989 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1989 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1990 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1990 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1991 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1991 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1992 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1992 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1993 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1993 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1994 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1994 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1995 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1995 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1996 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1996 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1997 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1997 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1998 | KOPrefs::instance()->mDaylightsavingStart, | 1998 | KOPrefs::instance()->mDaylightsavingStart, |
1999 | KOPrefs::instance()->mDaylightsavingEnd ); | 1999 | KOPrefs::instance()->mDaylightsavingEnd ); |
2000 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 2000 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
2001 | #endif | 2001 | #endif |
2002 | } | 2002 | } |
2003 | void CalendarView::updateConfig() | 2003 | void CalendarView::updateConfig() |
2004 | { | 2004 | { |
2005 | writeLocale(); | 2005 | writeLocale(); |
2006 | if ( KOPrefs::instance()->mUseAppColors ) | 2006 | if ( KOPrefs::instance()->mUseAppColors ) |
2007 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2007 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2008 | emit configChanged(); | 2008 | emit configChanged(); |
2009 | mTodoList->updateConfig(); | 2009 | mTodoList->updateConfig(); |
2010 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2010 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2011 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2011 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2012 | // To make the "fill window" configurations work | 2012 | // To make the "fill window" configurations work |
2013 | //mViewManager->raiseCurrentView(); | 2013 | //mViewManager->raiseCurrentView(); |
2014 | } | 2014 | } |
2015 | 2015 | ||
2016 | 2016 | ||
2017 | void CalendarView::eventChanged(Event *event) | 2017 | void CalendarView::eventChanged(Event *event) |
2018 | { | 2018 | { |
2019 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2019 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2020 | //updateUnmanagedViews(); | 2020 | //updateUnmanagedViews(); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | void CalendarView::eventAdded(Event *event) | 2023 | void CalendarView::eventAdded(Event *event) |
2024 | { | 2024 | { |
2025 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2025 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | void CalendarView::eventToBeDeleted(Event *) | 2028 | void CalendarView::eventToBeDeleted(Event *) |
2029 | { | 2029 | { |
2030 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2030 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | void CalendarView::eventDeleted() | 2033 | void CalendarView::eventDeleted() |
2034 | { | 2034 | { |
2035 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2035 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2036 | } | 2036 | } |
2037 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2037 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2038 | { | 2038 | { |
2039 | changeIncidenceDisplay((Incidence *)which, action); | 2039 | changeIncidenceDisplay((Incidence *)which, action); |
2040 | mDateNavigator->updateView(); //LR | 2040 | mDateNavigator->updateView(); //LR |
2041 | //mDialogManager->updateSearchDialog(); | 2041 | //mDialogManager->updateSearchDialog(); |
2042 | 2042 | ||
2043 | if (which) { | 2043 | if (which) { |
2044 | mViewManager->updateWNview(); | 2044 | mViewManager->updateWNview(); |
2045 | //mTodoList->updateView(); | 2045 | //mTodoList->updateView(); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | } | 2048 | } |
2049 | 2049 | ||
2050 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2050 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2051 | { | 2051 | { |
2052 | updateUnmanagedViews(); | 2052 | updateUnmanagedViews(); |
2053 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2053 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2054 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2054 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2055 | mCalendar->checkAlarmForIncidence( 0, true ); | 2055 | mCalendar->checkAlarmForIncidence( 0, true ); |
2056 | if ( mEventViewerDialog ) | 2056 | if ( mEventViewerDialog ) |
2057 | mEventViewerDialog->hide(); | 2057 | mEventViewerDialog->hide(); |
2058 | } | 2058 | } |
2059 | else | 2059 | else |
2060 | mCalendar->checkAlarmForIncidence( which , false ); | 2060 | mCalendar->checkAlarmForIncidence( which , false ); |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | // most of the changeEventDisplays() right now just call the view's | 2063 | // most of the changeEventDisplays() right now just call the view's |
2064 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2064 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2065 | void CalendarView::changeEventDisplay(Event *which, int action) | 2065 | void CalendarView::changeEventDisplay(Event *which, int action) |
2066 | { | 2066 | { |
2067 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2067 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2068 | changeIncidenceDisplay((Incidence *)which, action); | 2068 | changeIncidenceDisplay((Incidence *)which, action); |
2069 | mDateNavigator->updateView(); | 2069 | mDateNavigator->updateView(); |
2070 | //mDialogManager->updateSearchDialog(); | 2070 | //mDialogManager->updateSearchDialog(); |
2071 | 2071 | ||
2072 | if (which) { | 2072 | if (which) { |
2073 | // If there is an event view visible update the display | 2073 | // If there is an event view visible update the display |
2074 | mViewManager->currentView()->changeEventDisplay(which,action); | 2074 | mViewManager->currentView()->changeEventDisplay(which,action); |
2075 | // TODO: check, if update needed | 2075 | // TODO: check, if update needed |
2076 | // if (which->getTodoStatus()) { | 2076 | // if (which->getTodoStatus()) { |
2077 | mTodoList->updateView(); | 2077 | mTodoList->updateView(); |
2078 | // } | 2078 | // } |
2079 | } else { | 2079 | } else { |
2080 | mViewManager->currentView()->updateView(); | 2080 | mViewManager->currentView()->updateView(); |
2081 | } | 2081 | } |
2082 | } | 2082 | } |
2083 | 2083 | ||
2084 | 2084 | ||
2085 | void CalendarView::updateTodoViews() | 2085 | void CalendarView::updateTodoViews() |
2086 | { | 2086 | { |
2087 | 2087 | ||
2088 | mTodoList->updateView(); | 2088 | mTodoList->updateView(); |
2089 | mViewManager->currentView()->updateView(); | 2089 | mViewManager->currentView()->updateView(); |
2090 | 2090 | ||
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | 2093 | ||
2094 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2094 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2095 | { | 2095 | { |
2096 | mTodoList->updateView(); | 2096 | mTodoList->updateView(); |
2097 | mViewManager->updateView(start, end); | 2097 | mViewManager->updateView(start, end); |
2098 | //mDateNavigator->updateView(); | 2098 | //mDateNavigator->updateView(); |
2099 | } | 2099 | } |
2100 | 2100 | ||
2101 | void CalendarView::updateView() | 2101 | void CalendarView::updateView() |
2102 | { | 2102 | { |
2103 | DateList tmpList = mNavigator->selectedDates(); | 2103 | DateList tmpList = mNavigator->selectedDates(); |
2104 | 2104 | ||
2105 | // We assume that the navigator only selects consecutive days. | 2105 | // We assume that the navigator only selects consecutive days. |
2106 | updateView( tmpList.first(), tmpList.last() ); | 2106 | updateView( tmpList.first(), tmpList.last() ); |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::updateUnmanagedViews() | 2109 | void CalendarView::updateUnmanagedViews() |
2110 | { | 2110 | { |
2111 | mDateNavigator->updateDayMatrix(); | 2111 | mDateNavigator->updateDayMatrix(); |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | int CalendarView::msgItemDelete() | 2114 | int CalendarView::msgItemDelete() |
2115 | { | 2115 | { |
2116 | return KMessageBox::warningContinueCancel(this, | 2116 | return KMessageBox::warningContinueCancel(this, |
2117 | i18n("This item will be\npermanently deleted."), | 2117 | i18n("This item will be\npermanently deleted."), |
2118 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2118 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | 2121 | ||
2122 | void CalendarView::edit_cut() | 2122 | void CalendarView::edit_cut() |
2123 | { | 2123 | { |
2124 | Event *anEvent=0; | 2124 | Event *anEvent=0; |
2125 | 2125 | ||
2126 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2126 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2127 | 2127 | ||
2128 | if (mViewManager->currentView()->isEventView()) { | 2128 | if (mViewManager->currentView()->isEventView()) { |
2129 | if ( incidence && incidence->type() == "Event" ) { | 2129 | if ( incidence && incidence->type() == "Event" ) { |
2130 | anEvent = static_cast<Event *>(incidence); | 2130 | anEvent = static_cast<Event *>(incidence); |
2131 | } | 2131 | } |
2132 | } | 2132 | } |
2133 | 2133 | ||
2134 | if (!anEvent) { | 2134 | if (!anEvent) { |
2135 | KNotifyClient::beep(); | 2135 | KNotifyClient::beep(); |
2136 | return; | 2136 | return; |
2137 | } | 2137 | } |
2138 | DndFactory factory( mCalendar ); | 2138 | DndFactory factory( mCalendar ); |
2139 | factory.cutEvent(anEvent); | 2139 | factory.cutEvent(anEvent); |
2140 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2140 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | void CalendarView::edit_copy() | 2143 | void CalendarView::edit_copy() |
2144 | { | 2144 | { |
2145 | Event *anEvent=0; | 2145 | Event *anEvent=0; |
2146 | 2146 | ||
2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2147 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2148 | 2148 | ||
2149 | if (mViewManager->currentView()->isEventView()) { | 2149 | if (mViewManager->currentView()->isEventView()) { |
2150 | if ( incidence && incidence->type() == "Event" ) { | 2150 | if ( incidence && incidence->type() == "Event" ) { |
2151 | anEvent = static_cast<Event *>(incidence); | 2151 | anEvent = static_cast<Event *>(incidence); |
2152 | } | 2152 | } |
2153 | } | 2153 | } |
2154 | 2154 | ||
2155 | if (!anEvent) { | 2155 | if (!anEvent) { |
2156 | KNotifyClient::beep(); | 2156 | KNotifyClient::beep(); |
2157 | return; | 2157 | return; |
2158 | } | 2158 | } |
2159 | DndFactory factory( mCalendar ); | 2159 | DndFactory factory( mCalendar ); |
2160 | factory.copyEvent(anEvent); | 2160 | factory.copyEvent(anEvent); |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | void CalendarView::edit_paste() | 2163 | void CalendarView::edit_paste() |
2164 | { | 2164 | { |
2165 | QDate date = mNavigator->selectedDates().first(); | 2165 | QDate date = mNavigator->selectedDates().first(); |
2166 | 2166 | ||
2167 | DndFactory factory( mCalendar ); | 2167 | DndFactory factory( mCalendar ); |
2168 | Event *pastedEvent = factory.pasteEvent( date ); | 2168 | Event *pastedEvent = factory.pasteEvent( date ); |
2169 | 2169 | ||
2170 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2170 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void CalendarView::edit_options() | 2173 | void CalendarView::edit_options() |
2174 | { | 2174 | { |
2175 | mDialogManager->showOptionsDialog(); | 2175 | mDialogManager->showOptionsDialog(); |
2176 | //writeSettings(); | 2176 | //writeSettings(); |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | void CalendarView::slotSelectPickerDate( QDate d) | 2179 | void CalendarView::slotSelectPickerDate( QDate d) |
2180 | { | 2180 | { |
2181 | mDateFrame->hide(); | 2181 | mDateFrame->hide(); |
2182 | if ( mDatePickerMode == 1 ) { | 2182 | if ( mDatePickerMode == 1 ) { |
2183 | mNavigator->slotDaySelect( d ); | 2183 | mNavigator->slotDaySelect( d ); |
2184 | } else if ( mDatePickerMode == 2 ) { | 2184 | } else if ( mDatePickerMode == 2 ) { |
2185 | if ( mMoveIncidence->type() == "Todo" ) { | 2185 | if ( mMoveIncidence->type() == "Todo" ) { |
2186 | Todo * to = (Todo *) mMoveIncidence; | 2186 | Todo * to = (Todo *) mMoveIncidence; |
2187 | QTime tim; | 2187 | QTime tim; |
2188 | if ( to->hasDueDate() ) | 2188 | if ( to->hasDueDate() ) |
2189 | tim = to->dtDue().time(); | 2189 | tim = to->dtDue().time(); |
2190 | else { | 2190 | else { |
2191 | tim = QTime ( 0,0,0 ); | 2191 | tim = QTime ( 0,0,0 ); |
2192 | to->setFloats( true ); | 2192 | to->setFloats( true ); |
2193 | to->setHasDueDate( true ); | 2193 | to->setHasDueDate( true ); |
2194 | } | 2194 | } |
2195 | QDateTime dt ( d,tim ); | 2195 | QDateTime dt ( d,tim ); |
2196 | to->setDtDue( dt ); | 2196 | to->setDtDue( dt ); |
2197 | todoChanged( to ); | 2197 | todoChanged( to ); |
2198 | } else { | 2198 | } else { |
2199 | QTime tim = mMoveIncidence->dtStart().time(); | 2199 | QTime tim = mMoveIncidence->dtStart().time(); |
2200 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2200 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2201 | QDateTime dt ( d,tim ); | 2201 | QDateTime dt ( d,tim ); |
2202 | mMoveIncidence->setDtStart( dt ); | 2202 | mMoveIncidence->setDtStart( dt ); |
2203 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2203 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2204 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2204 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2205 | } | 2205 | } |
2206 | 2206 | ||
2207 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2207 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2208 | } | 2208 | } |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | void CalendarView::removeCategories() | 2211 | void CalendarView::removeCategories() |
2212 | { | 2212 | { |
2213 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2213 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2214 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2214 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2215 | QStringList catIncList; | 2215 | QStringList catIncList; |
2216 | QStringList newCatList; | 2216 | QStringList newCatList; |
2217 | Incidence* inc = incList.first(); | 2217 | Incidence* inc = incList.first(); |
2218 | int i; | 2218 | int i; |
2219 | int count = 0; | 2219 | int count = 0; |
2220 | while ( inc ) { | 2220 | while ( inc ) { |
2221 | newCatList.clear(); | 2221 | newCatList.clear(); |
2222 | catIncList = inc->categories() ; | 2222 | catIncList = inc->categories() ; |
2223 | for( i = 0; i< catIncList.count(); ++i ) { | 2223 | for( i = 0; i< catIncList.count(); ++i ) { |
2224 | if ( catList.contains (catIncList[i])) | 2224 | if ( catList.contains (catIncList[i])) |
2225 | newCatList.append( catIncList[i] ); | 2225 | newCatList.append( catIncList[i] ); |
2226 | } | 2226 | } |
2227 | newCatList.sort(); | 2227 | newCatList.sort(); |
2228 | inc->setCategories( newCatList.join(",") ); | 2228 | inc->setCategories( newCatList.join(",") ); |
2229 | inc = incList.next(); | 2229 | inc = incList.next(); |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | int CalendarView::addCategories() | 2233 | int CalendarView::addCategories() |
2234 | { | 2234 | { |
2235 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2235 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2236 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2236 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2237 | QStringList catIncList; | 2237 | QStringList catIncList; |
2238 | Incidence* inc = incList.first(); | 2238 | Incidence* inc = incList.first(); |
2239 | int i; | 2239 | int i; |
2240 | int count = 0; | 2240 | int count = 0; |
2241 | while ( inc ) { | 2241 | while ( inc ) { |
2242 | catIncList = inc->categories() ; | 2242 | catIncList = inc->categories() ; |
2243 | for( i = 0; i< catIncList.count(); ++i ) { | 2243 | for( i = 0; i< catIncList.count(); ++i ) { |
2244 | if ( !catList.contains (catIncList[i])) { | 2244 | if ( !catList.contains (catIncList[i])) { |
2245 | catList.append( catIncList[i] ); | 2245 | catList.append( catIncList[i] ); |
2246 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2246 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2247 | ++count; | 2247 | ++count; |
2248 | } | 2248 | } |
2249 | } | 2249 | } |
2250 | inc = incList.next(); | 2250 | inc = incList.next(); |
2251 | } | 2251 | } |
2252 | catList.sort(); | 2252 | catList.sort(); |
2253 | KOPrefs::instance()->mCustomCategories = catList; | 2253 | KOPrefs::instance()->mCustomCategories = catList; |
2254 | return count; | 2254 | return count; |
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | void CalendarView::manageCategories() | 2257 | void CalendarView::manageCategories() |
2258 | { | 2258 | { |
2259 | KOCatPrefs* cp = new KOCatPrefs(); | 2259 | KOCatPrefs* cp = new KOCatPrefs(); |
2260 | cp->show(); | 2260 | cp->show(); |
2261 | int w =cp->sizeHint().width() ; | 2261 | int w =cp->sizeHint().width() ; |
2262 | int h = cp->sizeHint().height() ; | 2262 | int h = cp->sizeHint().height() ; |
2263 | int dw = QApplication::desktop()->width(); | 2263 | int dw = QApplication::desktop()->width(); |
2264 | int dh = QApplication::desktop()->height(); | 2264 | int dh = QApplication::desktop()->height(); |
2265 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2265 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2266 | if ( !cp->exec() ) { | 2266 | if ( !cp->exec() ) { |
2267 | delete cp; | 2267 | delete cp; |
2268 | return; | 2268 | return; |
2269 | } | 2269 | } |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | if ( cp->addCat() ) { | 2271 | if ( cp->addCat() ) { |
2272 | count = addCategories(); | 2272 | count = addCategories(); |
2273 | if ( count ) { | 2273 | if ( count ) { |
2274 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2274 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2275 | writeSettings(); | 2275 | writeSettings(); |
2276 | } | 2276 | } |
2277 | } else { | 2277 | } else { |
2278 | removeCategories(); | 2278 | removeCategories(); |
2279 | updateView(); | 2279 | updateView(); |
2280 | } | 2280 | } |
2281 | delete cp; | 2281 | delete cp; |
2282 | } | 2282 | } |
2283 | 2283 | ||
2284 | void CalendarView::beamIncidence(Incidence * Inc) | 2284 | void CalendarView::beamIncidence(Incidence * Inc) |
2285 | { | 2285 | { |
2286 | QPtrList<Incidence> delSel ; | 2286 | QPtrList<Incidence> delSel ; |
2287 | delSel.append(Inc); | 2287 | delSel.append(Inc); |
2288 | beamIncidenceList( delSel ); | 2288 | beamIncidenceList( delSel ); |
2289 | } | 2289 | } |
2290 | void CalendarView::beamCalendar() | 2290 | void CalendarView::beamCalendar() |
2291 | { | 2291 | { |
2292 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2292 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2293 | //qDebug("beamCalendar() "); | 2293 | //qDebug("beamCalendar() "); |
2294 | beamIncidenceList( delSel ); | 2294 | beamIncidenceList( delSel ); |
2295 | } | 2295 | } |
2296 | void CalendarView::beamFilteredCalendar() | 2296 | void CalendarView::beamFilteredCalendar() |
2297 | { | 2297 | { |
2298 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2298 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2299 | //qDebug("beamFilteredCalendar() "); | 2299 | //qDebug("beamFilteredCalendar() "); |
2300 | beamIncidenceList( delSel ); | 2300 | beamIncidenceList( delSel ); |
2301 | } | 2301 | } |
2302 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2302 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2303 | { | 2303 | { |
2304 | if ( beamDialog->exec () == QDialog::Rejected ) | 2304 | if ( beamDialog->exec () == QDialog::Rejected ) |
2305 | return; | 2305 | return; |
2306 | 2306 | #ifdef DESKTOP_VERSION | |
2307 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | ||
2308 | #else | ||
2307 | QString fn = "/tmp/kopibeamfile"; | 2309 | QString fn = "/tmp/kopibeamfile"; |
2310 | #endif | ||
2308 | QString mes; | 2311 | QString mes; |
2309 | bool createbup = true; | 2312 | bool createbup = true; |
2310 | if ( createbup ) { | 2313 | if ( createbup ) { |
2311 | QString description = "\n"; | 2314 | QString description = "\n"; |
2312 | CalendarLocal* cal = new CalendarLocal(); | 2315 | CalendarLocal* cal = new CalendarLocal(); |
2313 | if ( beamDialog->beamLocal() ) | 2316 | if ( beamDialog->beamLocal() ) |
2314 | cal->setLocalTime(); | 2317 | cal->setLocalTime(); |
2315 | else | 2318 | else |
2316 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2319 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2317 | Incidence *incidence = delSel.first(); | 2320 | Incidence *incidence = delSel.first(); |
2318 | bool addText = false; | 2321 | bool addText = false; |
2319 | if ( delSel.count() < 10 ) | 2322 | if ( delSel.count() < 10 ) |
2320 | addText = true; | 2323 | addText = true; |
2321 | else { | 2324 | else { |
2322 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2325 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2323 | } | 2326 | } |
2324 | while ( incidence ) { | 2327 | while ( incidence ) { |
2325 | Incidence *in = incidence->clone(); | 2328 | Incidence *in = incidence->clone(); |
2326 | if ( ! in->summary().isEmpty() ) { | 2329 | if ( ! in->summary().isEmpty() ) { |
2327 | in->setDescription(""); | 2330 | in->setDescription(""); |
2328 | } else { | 2331 | } else { |
2329 | in->setSummary( in->description().left(20)); | 2332 | in->setSummary( in->description().left(20)); |
2330 | in->setDescription(""); | 2333 | in->setDescription(""); |
2331 | } | 2334 | } |
2332 | if ( addText ) | 2335 | if ( addText ) |
2333 | description += in->summary() + "\n"; | 2336 | description += in->summary() + "\n"; |
2334 | cal->addIncidence( in ); | 2337 | cal->addIncidence( in ); |
2335 | incidence = delSel.next(); | 2338 | incidence = delSel.next(); |
2336 | } | 2339 | } |
2337 | if ( beamDialog->beamVcal() ) { | 2340 | if ( beamDialog->beamVcal() ) { |
2338 | fn += ".vcs"; | 2341 | fn += ".vcs"; |
2339 | FileStorage storage( cal, fn, new VCalFormat ); | 2342 | FileStorage storage( cal, fn, new VCalFormat ); |
2340 | storage.save(); | 2343 | storage.save(); |
2341 | } else { | 2344 | } else { |
2342 | fn += ".ics"; | 2345 | fn += ".ics"; |
2343 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2346 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2344 | storage.save(); | 2347 | storage.save(); |
2345 | } | 2348 | } |
2346 | delete cal; | 2349 | delete cal; |
2347 | mes = i18n("KO/Pi: Ready for beaming"); | 2350 | mes = i18n("KO/Pi: Ready for beaming"); |
2348 | topLevelWidget()->setCaption(mes); | 2351 | topLevelWidget()->setCaption(mes); |
2349 | KApplication::convert2latin1( fn ); | 2352 | KApplication::convert2latin1( fn ); |
2350 | #ifndef DESKTOP_VERSION | 2353 | #ifndef DESKTOP_VERSION |
2351 | Ir *ir = new Ir( this ); | 2354 | Ir *ir = new Ir( this ); |
2352 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2355 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2353 | ir->send( fn, description, "text/x-vCalendar" ); | 2356 | ir->send( fn, description, "text/x-vCalendar" ); |
2354 | #endif | 2357 | #endif |
2355 | } | 2358 | } |
2356 | } | 2359 | } |
2357 | void CalendarView::beamDone( Ir *ir ) | 2360 | void CalendarView::beamDone( Ir *ir ) |
2358 | { | 2361 | { |
2359 | #ifndef DESKTOP_VERSION | 2362 | #ifndef DESKTOP_VERSION |
2360 | delete ir; | 2363 | delete ir; |
2361 | #endif | 2364 | #endif |
2362 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2365 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2363 | topLevelWidget()->raise(); | 2366 | topLevelWidget()->raise(); |
2364 | } | 2367 | } |
2365 | 2368 | ||
2366 | void CalendarView::moveIncidence(Incidence * inc ) | 2369 | void CalendarView::moveIncidence(Incidence * inc ) |
2367 | { | 2370 | { |
2368 | if ( !inc ) return; | 2371 | if ( !inc ) return; |
2369 | // qDebug("showDatePickerForIncidence( ) "); | 2372 | // qDebug("showDatePickerForIncidence( ) "); |
2370 | if ( mDateFrame->isVisible() ) | 2373 | if ( mDateFrame->isVisible() ) |
2371 | mDateFrame->hide(); | 2374 | mDateFrame->hide(); |
2372 | else { | 2375 | else { |
2373 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2376 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2374 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2377 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2375 | int dw = QApplication::desktop()->width(); | 2378 | int dw = QApplication::desktop()->width(); |
2376 | int dh = QApplication::desktop()->height(); | 2379 | int dh = QApplication::desktop()->height(); |
2377 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2380 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2378 | mDateFrame->show(); | 2381 | mDateFrame->show(); |
2379 | } | 2382 | } |
2380 | mDatePickerMode = 2; | 2383 | mDatePickerMode = 2; |
2381 | mMoveIncidence = inc ; | 2384 | mMoveIncidence = inc ; |
2382 | QDate da; | 2385 | QDate da; |
2383 | if ( mMoveIncidence->type() == "Todo" ) { | 2386 | if ( mMoveIncidence->type() == "Todo" ) { |
2384 | Todo * to = (Todo *) mMoveIncidence; | 2387 | Todo * to = (Todo *) mMoveIncidence; |
2385 | if ( to->hasDueDate() ) | 2388 | if ( to->hasDueDate() ) |
2386 | da = to->dtDue().date(); | 2389 | da = to->dtDue().date(); |
2387 | else | 2390 | else |
2388 | da = QDate::currentDate(); | 2391 | da = QDate::currentDate(); |
2389 | } else { | 2392 | } else { |
2390 | da = mMoveIncidence->dtStart().date(); | 2393 | da = mMoveIncidence->dtStart().date(); |
2391 | } | 2394 | } |
2392 | mDatePicker->setDate( da ); | 2395 | mDatePicker->setDate( da ); |
2393 | } | 2396 | } |
2394 | void CalendarView::showDatePicker( ) | 2397 | void CalendarView::showDatePicker( ) |
2395 | { | 2398 | { |
2396 | //qDebug("CalendarView::showDatePicker( ) "); | 2399 | //qDebug("CalendarView::showDatePicker( ) "); |
2397 | if ( mDateFrame->isVisible() ) | 2400 | if ( mDateFrame->isVisible() ) |
2398 | mDateFrame->hide(); | 2401 | mDateFrame->hide(); |
2399 | else { | 2402 | else { |
2400 | int w =mDatePicker->sizeHint().width() ; | 2403 | int w =mDatePicker->sizeHint().width() ; |
2401 | int h = mDatePicker->sizeHint().height() ; | 2404 | int h = mDatePicker->sizeHint().height() ; |
2402 | int dw = QApplication::desktop()->width(); | 2405 | int dw = QApplication::desktop()->width(); |
2403 | int dh = QApplication::desktop()->height(); | 2406 | int dh = QApplication::desktop()->height(); |
2404 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2407 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2405 | mDateFrame->show(); | 2408 | mDateFrame->show(); |
2406 | } | 2409 | } |
2407 | mDatePickerMode = 1; | 2410 | mDatePickerMode = 1; |
2408 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2411 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2409 | } | 2412 | } |
2410 | 2413 | ||
2411 | void CalendarView::showEventEditor() | 2414 | void CalendarView::showEventEditor() |
2412 | { | 2415 | { |
2413 | #ifdef DESKTOP_VERSION | 2416 | #ifdef DESKTOP_VERSION |
2414 | mEventEditor->show(); | 2417 | mEventEditor->show(); |
2415 | #else | 2418 | #else |
2416 | mEventEditor->showMaximized(); | 2419 | mEventEditor->showMaximized(); |
2417 | #endif | 2420 | #endif |
2418 | } | 2421 | } |
2419 | void CalendarView::showTodoEditor() | 2422 | void CalendarView::showTodoEditor() |
2420 | { | 2423 | { |
2421 | #ifdef DESKTOP_VERSION | 2424 | #ifdef DESKTOP_VERSION |
2422 | mTodoEditor->show(); | 2425 | mTodoEditor->show(); |
2423 | #else | 2426 | #else |
2424 | mTodoEditor->showMaximized(); | 2427 | mTodoEditor->showMaximized(); |
2425 | #endif | 2428 | #endif |
2426 | } | 2429 | } |
2427 | 2430 | ||
2428 | void CalendarView::cloneIncidence() | 2431 | void CalendarView::cloneIncidence() |
2429 | { | 2432 | { |
2430 | Incidence *incidence = currentSelection(); | 2433 | Incidence *incidence = currentSelection(); |
2431 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2434 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2432 | if ( incidence ) { | 2435 | if ( incidence ) { |
2433 | cloneIncidence(incidence); | 2436 | cloneIncidence(incidence); |
2434 | } | 2437 | } |
2435 | } | 2438 | } |
2436 | void CalendarView::moveIncidence() | 2439 | void CalendarView::moveIncidence() |
2437 | { | 2440 | { |
2438 | Incidence *incidence = currentSelection(); | 2441 | Incidence *incidence = currentSelection(); |
2439 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2442 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2440 | if ( incidence ) { | 2443 | if ( incidence ) { |
2441 | moveIncidence(incidence); | 2444 | moveIncidence(incidence); |
2442 | } | 2445 | } |
2443 | } | 2446 | } |
2444 | void CalendarView::beamIncidence() | 2447 | void CalendarView::beamIncidence() |
2445 | { | 2448 | { |
2446 | Incidence *incidence = currentSelection(); | 2449 | Incidence *incidence = currentSelection(); |
2447 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2450 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2448 | if ( incidence ) { | 2451 | if ( incidence ) { |
2449 | beamIncidence(incidence); | 2452 | beamIncidence(incidence); |
2450 | } | 2453 | } |
2451 | } | 2454 | } |
2452 | void CalendarView::toggleCancelIncidence() | 2455 | void CalendarView::toggleCancelIncidence() |
2453 | { | 2456 | { |
2454 | Incidence *incidence = currentSelection(); | 2457 | Incidence *incidence = currentSelection(); |
2455 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2458 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2456 | if ( incidence ) { | 2459 | if ( incidence ) { |
2457 | cancelIncidence(incidence); | 2460 | cancelIncidence(incidence); |
2458 | } | 2461 | } |
2459 | } | 2462 | } |
2460 | 2463 | ||
2461 | 2464 | ||
2462 | void CalendarView::cancelIncidence(Incidence * inc ) | 2465 | void CalendarView::cancelIncidence(Incidence * inc ) |
2463 | { | 2466 | { |
2464 | inc->setCancelled( ! inc->cancelled() ); | 2467 | inc->setCancelled( ! inc->cancelled() ); |
2465 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2468 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2466 | updateView(); | 2469 | updateView(); |
2467 | } | 2470 | } |
2468 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2471 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2469 | { | 2472 | { |
2470 | Incidence * newInc = orgInc->clone(); | 2473 | Incidence * newInc = orgInc->clone(); |
2471 | newInc->recreate(); | 2474 | newInc->recreate(); |
2472 | 2475 | ||
2473 | if ( newInc->type() == "Todo" ) { | 2476 | if ( newInc->type() == "Todo" ) { |
2474 | Todo* t = (Todo*) newInc; | 2477 | Todo* t = (Todo*) newInc; |
2475 | mTodoEditor->editTodo( t ); | 2478 | mTodoEditor->editTodo( t ); |
2476 | showTodoEditor(); | 2479 | showTodoEditor(); |
2477 | if ( mTodoEditor->exec() ) { | 2480 | if ( mTodoEditor->exec() ) { |
2478 | mCalendar->addTodo( t ); | 2481 | mCalendar->addTodo( t ); |
2479 | updateView(); | 2482 | updateView(); |
2480 | } else { | 2483 | } else { |
2481 | delete t; | 2484 | delete t; |
2482 | } | 2485 | } |
2483 | } | 2486 | } |
2484 | else { | 2487 | else { |
2485 | Event* e = (Event*) newInc; | 2488 | Event* e = (Event*) newInc; |
2486 | mEventEditor->editEvent( e ); | 2489 | mEventEditor->editEvent( e ); |
2487 | showEventEditor(); | 2490 | showEventEditor(); |
2488 | if ( mEventEditor->exec() ) { | 2491 | if ( mEventEditor->exec() ) { |
2489 | mCalendar->addEvent( e ); | 2492 | mCalendar->addEvent( e ); |
2490 | updateView(); | 2493 | updateView(); |
2491 | } else { | 2494 | } else { |
2492 | delete e; | 2495 | delete e; |
2493 | } | 2496 | } |
2494 | } | 2497 | } |
2495 | } | 2498 | } |
2496 | 2499 | ||
2497 | void CalendarView::newEvent() | 2500 | void CalendarView::newEvent() |
2498 | { | 2501 | { |
2499 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2502 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2500 | KOAgendaView *aView = mViewManager->agendaView(); | 2503 | KOAgendaView *aView = mViewManager->agendaView(); |
2501 | if (aView) { | 2504 | if (aView) { |
2502 | if (aView->selectionStart().isValid()) { | 2505 | if (aView->selectionStart().isValid()) { |
2503 | if (aView->selectedIsAllDay()) { | 2506 | if (aView->selectedIsAllDay()) { |
2504 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2507 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2505 | } else { | 2508 | } else { |
2506 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2509 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2507 | } | 2510 | } |
2508 | return; | 2511 | return; |
2509 | } | 2512 | } |
2510 | } | 2513 | } |
2511 | 2514 | ||
2512 | QDate date = mNavigator->selectedDates().first(); | 2515 | QDate date = mNavigator->selectedDates().first(); |
2513 | QDateTime current = QDateTime::currentDateTime(); | 2516 | QDateTime current = QDateTime::currentDateTime(); |
2514 | if ( date <= current.date() ) { | 2517 | if ( date <= current.date() ) { |
2515 | int hour = current.time().hour() +1; | 2518 | int hour = current.time().hour() +1; |
2516 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2519 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2517 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2520 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2518 | } else | 2521 | } else |
2519 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2522 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2520 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2523 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2521 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2524 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2522 | } | 2525 | } |
2523 | 2526 | ||
2524 | void CalendarView::newEvent(QDateTime fh) | 2527 | void CalendarView::newEvent(QDateTime fh) |
2525 | { | 2528 | { |
2526 | newEvent(fh, | 2529 | newEvent(fh, |
2527 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2530 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2528 | } | 2531 | } |
2529 | 2532 | ||
2530 | void CalendarView::newEvent(QDate dt) | 2533 | void CalendarView::newEvent(QDate dt) |
2531 | { | 2534 | { |
2532 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2535 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2533 | QDateTime(dt, QTime(0,0,0)), true); | 2536 | QDateTime(dt, QTime(0,0,0)), true); |
2534 | } | 2537 | } |
2535 | 2538 | ||
2536 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2539 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2537 | { | 2540 | { |
2538 | 2541 | ||
2539 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2542 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2540 | if ( mFilterView->filtersEnabled() ) { | 2543 | if ( mFilterView->filtersEnabled() ) { |
2541 | CalFilter *filter = mFilterView->selectedFilter(); | 2544 | CalFilter *filter = mFilterView->selectedFilter(); |
2542 | if (filter && filter->showCategories()) { | 2545 | if (filter && filter->showCategories()) { |
2543 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2546 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2544 | } | 2547 | } |
2545 | if ( filter ) | 2548 | if ( filter ) |
2546 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2549 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2547 | } | 2550 | } |
2548 | showEventEditor(); | 2551 | showEventEditor(); |
2549 | } | 2552 | } |
2550 | void CalendarView::todoAdded(Todo * t) | 2553 | void CalendarView::todoAdded(Todo * t) |
2551 | { | 2554 | { |
2552 | 2555 | ||
2553 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2556 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2554 | updateTodoViews(); | 2557 | updateTodoViews(); |
2555 | } | 2558 | } |
2556 | void CalendarView::todoChanged(Todo * t) | 2559 | void CalendarView::todoChanged(Todo * t) |
2557 | { | 2560 | { |
2558 | emit todoModified( t, 4 ); | 2561 | emit todoModified( t, 4 ); |
2559 | // updateTodoViews(); | 2562 | // updateTodoViews(); |
2560 | } | 2563 | } |
2561 | void CalendarView::todoToBeDeleted(Todo *) | 2564 | void CalendarView::todoToBeDeleted(Todo *) |
2562 | { | 2565 | { |
2563 | //qDebug("todoToBeDeleted(Todo *) "); | 2566 | //qDebug("todoToBeDeleted(Todo *) "); |
2564 | updateTodoViews(); | 2567 | updateTodoViews(); |
2565 | } | 2568 | } |
2566 | void CalendarView::todoDeleted() | 2569 | void CalendarView::todoDeleted() |
2567 | { | 2570 | { |
2568 | //qDebug(" todoDeleted()"); | 2571 | //qDebug(" todoDeleted()"); |
2569 | updateTodoViews(); | 2572 | updateTodoViews(); |
2570 | } | 2573 | } |
2571 | 2574 | ||
2572 | 2575 | ||
2573 | 2576 | ||
2574 | void CalendarView::newTodo() | 2577 | void CalendarView::newTodo() |
2575 | { | 2578 | { |
2576 | 2579 | ||
2577 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2580 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2578 | if ( mFilterView->filtersEnabled() ) { | 2581 | if ( mFilterView->filtersEnabled() ) { |
2579 | CalFilter *filter = mFilterView->selectedFilter(); | 2582 | CalFilter *filter = mFilterView->selectedFilter(); |
2580 | if (filter && filter->showCategories()) { | 2583 | if (filter && filter->showCategories()) { |
2581 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2584 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2582 | } | 2585 | } |
2583 | if ( filter ) | 2586 | if ( filter ) |
2584 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2587 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2585 | } | 2588 | } |
2586 | showTodoEditor(); | 2589 | showTodoEditor(); |
2587 | } | 2590 | } |
2588 | 2591 | ||
2589 | void CalendarView::newSubTodo() | 2592 | void CalendarView::newSubTodo() |
2590 | { | 2593 | { |
2591 | Todo *todo = selectedTodo(); | 2594 | Todo *todo = selectedTodo(); |
2592 | if ( todo ) newSubTodo( todo ); | 2595 | if ( todo ) newSubTodo( todo ); |
2593 | } | 2596 | } |
2594 | 2597 | ||
2595 | void CalendarView::newSubTodo(Todo *parentEvent) | 2598 | void CalendarView::newSubTodo(Todo *parentEvent) |
2596 | { | 2599 | { |
2597 | 2600 | ||
2598 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2601 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2599 | showTodoEditor(); | 2602 | showTodoEditor(); |
2600 | } | 2603 | } |
2601 | 2604 | ||
2602 | void CalendarView::newFloatingEvent() | 2605 | void CalendarView::newFloatingEvent() |
2603 | { | 2606 | { |
2604 | DateList tmpList = mNavigator->selectedDates(); | 2607 | DateList tmpList = mNavigator->selectedDates(); |
2605 | QDate date = tmpList.first(); | 2608 | QDate date = tmpList.first(); |
2606 | 2609 | ||
2607 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2610 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2608 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2611 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2609 | } | 2612 | } |
2610 | 2613 | ||
2611 | 2614 | ||
2612 | void CalendarView::editEvent( Event *event ) | 2615 | void CalendarView::editEvent( Event *event ) |
2613 | { | 2616 | { |
2614 | 2617 | ||
2615 | if ( !event ) return; | 2618 | if ( !event ) return; |
2616 | if ( event->isReadOnly() ) { | 2619 | if ( event->isReadOnly() ) { |
2617 | showEvent( event ); | 2620 | showEvent( event ); |
2618 | return; | 2621 | return; |
2619 | } | 2622 | } |
2620 | mEventEditor->editEvent( event , mFlagEditDescription); | 2623 | mEventEditor->editEvent( event , mFlagEditDescription); |
2621 | showEventEditor(); | 2624 | showEventEditor(); |
2622 | } | 2625 | } |
2623 | void CalendarView::editJournal( Journal *jour ) | 2626 | void CalendarView::editJournal( Journal *jour ) |
2624 | { | 2627 | { |
2625 | if ( !jour ) return; | 2628 | if ( !jour ) return; |
2626 | mDialogManager->hideSearchDialog(); | 2629 | mDialogManager->hideSearchDialog(); |
2627 | mViewManager->showJournalView(); | 2630 | mViewManager->showJournalView(); |
2628 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2631 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2629 | } | 2632 | } |
2630 | void CalendarView::editTodo( Todo *todo ) | 2633 | void CalendarView::editTodo( Todo *todo ) |
2631 | { | 2634 | { |
2632 | if ( !todo ) return; | 2635 | if ( !todo ) return; |
2633 | 2636 | ||
2634 | if ( todo->isReadOnly() ) { | 2637 | if ( todo->isReadOnly() ) { |
2635 | showTodo( todo ); | 2638 | showTodo( todo ); |
2636 | return; | 2639 | return; |
2637 | } | 2640 | } |
2638 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2641 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2639 | showTodoEditor(); | 2642 | showTodoEditor(); |
2640 | 2643 | ||
2641 | } | 2644 | } |
2642 | 2645 | ||
2643 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2646 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2644 | { | 2647 | { |
2645 | if ( !mEventViewerDialog ) { | 2648 | if ( !mEventViewerDialog ) { |
2646 | mEventViewerDialog = new KOEventViewerDialog(this); | 2649 | mEventViewerDialog = new KOEventViewerDialog(this); |
2647 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2650 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2648 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2651 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2649 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2652 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2650 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2653 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2651 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2654 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2652 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2655 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2653 | mEventViewerDialog->resize( 640, 480 ); | 2656 | mEventViewerDialog->resize( 640, 480 ); |
2654 | 2657 | ||
2655 | } | 2658 | } |
2656 | return mEventViewerDialog; | 2659 | return mEventViewerDialog; |
2657 | } | 2660 | } |
2658 | void CalendarView::showEvent(Event *event) | 2661 | void CalendarView::showEvent(Event *event) |
2659 | { | 2662 | { |
2660 | getEventViewerDialog()->setEvent(event); | 2663 | getEventViewerDialog()->setEvent(event); |
2661 | getEventViewerDialog()->showMe(); | 2664 | getEventViewerDialog()->showMe(); |
2662 | } | 2665 | } |
2663 | 2666 | ||
2664 | void CalendarView::showTodo(Todo *event) | 2667 | void CalendarView::showTodo(Todo *event) |
2665 | { | 2668 | { |
2666 | getEventViewerDialog()->setTodo(event); | 2669 | getEventViewerDialog()->setTodo(event); |
2667 | getEventViewerDialog()->showMe(); | 2670 | getEventViewerDialog()->showMe(); |
2668 | } | 2671 | } |
2669 | void CalendarView::showJournal( Journal *jour ) | 2672 | void CalendarView::showJournal( Journal *jour ) |
2670 | { | 2673 | { |
2671 | getEventViewerDialog()->setJournal(jour); | 2674 | getEventViewerDialog()->setJournal(jour); |
2672 | getEventViewerDialog()->showMe(); | 2675 | getEventViewerDialog()->showMe(); |
2673 | 2676 | ||
2674 | } | 2677 | } |
2675 | // void CalendarView::todoModified (Todo *event, int changed) | 2678 | // void CalendarView::todoModified (Todo *event, int changed) |
2676 | // { | 2679 | // { |
2677 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2680 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2678 | // // kdDebug() << "Todo modified and open" << endl; | 2681 | // // kdDebug() << "Todo modified and open" << endl; |
2679 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2682 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2680 | // // temp->modified (changed); | 2683 | // // temp->modified (changed); |
2681 | 2684 | ||
2682 | // // } | 2685 | // // } |
2683 | 2686 | ||
2684 | // mViewManager->updateView(); | 2687 | // mViewManager->updateView(); |
2685 | // } | 2688 | // } |
2686 | 2689 | ||
2687 | void CalendarView::appointment_show() | 2690 | void CalendarView::appointment_show() |
2688 | { | 2691 | { |
2689 | Event *anEvent = 0; | 2692 | Event *anEvent = 0; |
2690 | 2693 | ||
2691 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2694 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 651442b..258f738 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,572 +1,566 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <libkdepim/kpimglobalprefs.h> | 44 | #include <libkdepim/kpimglobalprefs.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "mainwindow.h" | 47 | #include "mainwindow.h" |
48 | 48 | ||
49 | const char *germanwords[][2] = { | 49 | const char *germanwords[][2] = { |
50 | #include "wordsgerman.h" | 50 | #include "wordsgerman.h" |
51 | "", "" | 51 | "", "" |
52 | }; | 52 | }; |
53 | 53 | ||
54 | KOPrefs *KOPrefs::mInstance = 0; | 54 | KOPrefs *KOPrefs::mInstance = 0; |
55 | static KStaticDeleter<KOPrefs> insd; | 55 | static KStaticDeleter<KOPrefs> insd; |
56 | 56 | ||
57 | KOPrefs::KOPrefs() : | 57 | KOPrefs::KOPrefs() : |
58 | KPimPrefs("korganizerrc") | 58 | KPimPrefs("korganizerrc") |
59 | { | 59 | { |
60 | mCategoryColors.setAutoDelete(true); | 60 | mCategoryColors.setAutoDelete(true); |
61 | mLocaleDict = 0; | 61 | mLocaleDict = 0; |
62 | fillMailDefaults(); | 62 | fillMailDefaults(); |
63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 63 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
64 | QColor defaultHolidayColor = QColor(255,0,0); | 64 | QColor defaultHolidayColor = QColor(255,0,0); |
65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 65 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 66 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 67 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 68 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
69 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 69 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
70 | 70 | ||
71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 71 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
72 | mDefaultViewFont = QFont("helvetica",10); | 72 | mDefaultViewFont = QFont("helvetica",10); |
73 | mDefaultMonthViewFont = QFont("helvetica",8); | 73 | mDefaultMonthViewFont = QFont("helvetica",8); |
74 | mMarcusBainsFont= QFont("helvetica",10); | 74 | mMarcusBainsFont= QFont("helvetica",10); |
75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 75 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
76 | mEditBoxFont = QFont("helvetica",12); | 76 | mEditBoxFont = QFont("helvetica",12); |
77 | mJornalViewFont = QFont("helvetica",12); | 77 | mJornalViewFont = QFont("helvetica",12); |
78 | 78 | ||
79 | KPrefs::setCurrentGroup("General"); | 79 | KPrefs::setCurrentGroup("General"); |
80 | 80 | ||
81 | 81 | ||
82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 82 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
83 | 83 | ||
84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 84 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 85 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 86 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
87 | addItemBool("ShowIconList",&mShowIconList,true); | 87 | addItemBool("ShowIconList",&mShowIconList,true); |
88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 88 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 89 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 90 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 91 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 92 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 93 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
94 | addItemBool("ShowIconBack",&mShowIconBack,true); | 94 | addItemBool("ShowIconBack",&mShowIconBack,true); |
95 | addItemBool("ShowIconToday",&mShowIconToday,true); | 95 | addItemBool("ShowIconToday",&mShowIconToday,true); |
96 | addItemBool("ShowIconForward",&mShowIconForward,true); | 96 | addItemBool("ShowIconForward",&mShowIconForward,true); |
97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 97 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 98 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 99 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
100 | addItemBool("ShowIconNext",&mShowIconNext,true); | 100 | addItemBool("ShowIconNext",&mShowIconNext,true); |
101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 101 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 102 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
103 | addItemBool("LanguageChanged",&mLanguageChanged,false); | 103 | addItemBool("LanguageChanged",&mLanguageChanged,false); |
104 | 104 | ||
105 | addItemBool("AskForQuit",&mAskForQuit,false); | 105 | addItemBool("AskForQuit",&mAskForQuit,false); |
106 | 106 | ||
107 | #ifndef DESKTOP_VERSION | 107 | #ifndef DESKTOP_VERSION |
108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 108 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
109 | #else | 109 | #else |
110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 110 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
111 | #endif | 111 | #endif |
112 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 112 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
113 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 113 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 114 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 115 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 116 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
117 | 117 | ||
118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 118 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 119 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
120 | addItemInt("AllDay Size",&mAllDaySize,28); | 120 | addItemInt("AllDay Size",&mAllDaySize,28); |
121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 121 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 122 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
123 | 123 | ||
124 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 124 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
125 | addItemStringList("EventSummary User",&mEventSummaryUser); | 125 | addItemStringList("EventSummary User",&mEventSummaryUser); |
126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 126 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
127 | 127 | ||
128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 128 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
129 | addItemBool("Enable Project View",&mEnableProjectView,false); | 129 | addItemBool("Enable Project View",&mEnableProjectView,false); |
130 | addItemBool("Auto Save",&mAutoSave,false); | 130 | addItemBool("Auto Save",&mAutoSave,false); |
131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 131 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
132 | addItemBool("Confirm Deletes",&mConfirm,true); | 132 | addItemBool("Confirm Deletes",&mConfirm,true); |
133 | addItemString("Archive File",&mArchiveFile); | 133 | addItemString("Archive File",&mArchiveFile); |
134 | addItemString("Html Export File",&mHtmlExportFile, | 134 | addItemString("Html Export File",&mHtmlExportFile, |
135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 135 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
136 | addItemBool("Html With Save",&mHtmlWithSave,false); | 136 | addItemBool("Html With Save",&mHtmlWithSave,false); |
137 | 137 | ||
138 | KPrefs::setCurrentGroup("Personal Settings"); | 138 | KPrefs::setCurrentGroup("Personal Settings"); |
139 | 139 | ||
140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 140 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 141 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
142 | addItemBool("Bcc",&mBcc,false); | 142 | addItemBool("Bcc",&mBcc,false); |
143 | 143 | ||
144 | KPrefs::setCurrentGroup("Time & Date"); | 144 | KPrefs::setCurrentGroup("Time & Date"); |
145 | 145 | ||
146 | // addItemString("Time Zone",&mTimeZone,"+0100"); | 146 | // addItemString("Time Zone",&mTimeZone,"+0100"); |
147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 147 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | 148 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); |
149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 149 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 150 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 151 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
152 | 152 | ||
153 | 153 | ||
154 | addItemInt("Default Start Time",&mStartTime,10); | 154 | addItemInt("Default Start Time",&mStartTime,10); |
155 | addItemInt("Default Duration",&mDefaultDuration,2); | 155 | addItemInt("Default Duration",&mDefaultDuration,2); |
156 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 156 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
157 | addItemInt("Daylight Savings",&mDaylightSavings,0); | 157 | addItemInt("Daylight Savings",&mDaylightSavings,0); |
158 | KPrefs::setCurrentGroup("AlarmSettings"); | 158 | KPrefs::setCurrentGroup("AlarmSettings"); |
159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 159 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 160 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 161 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 162 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
163 | 163 | ||
164 | 164 | ||
165 | KPrefs::setCurrentGroup("Calendar"); | 165 | KPrefs::setCurrentGroup("Calendar"); |
166 | 166 | ||
167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 167 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
168 | 168 | ||
169 | KPrefs::setCurrentGroup("Fonts"); | 169 | KPrefs::setCurrentGroup("Fonts"); |
170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 170 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
171 | addItemFont("TimeBar Font",&mTimeBarFont); | 171 | addItemFont("TimeBar Font",&mTimeBarFont); |
172 | addItemFont("MonthView Font",&mMonthViewFont); | 172 | addItemFont("MonthView Font",&mMonthViewFont); |
173 | addItemFont("AgendaView Font",&mAgendaViewFont); | 173 | addItemFont("AgendaView Font",&mAgendaViewFont); |
174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 174 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 175 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
176 | addItemFont("TodoView Font",&mTodoViewFont); | 176 | addItemFont("TodoView Font",&mTodoViewFont); |
177 | addItemFont("ListView Font",&mListViewFont); | 177 | addItemFont("ListView Font",&mListViewFont); |
178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 178 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
179 | addItemFont("EditBox Font",&mEditBoxFont); | 179 | addItemFont("EditBox Font",&mEditBoxFont); |
180 | addItemFont("JournalView Font",&mJornalViewFont); | 180 | addItemFont("JournalView Font",&mJornalViewFont); |
181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 181 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
182 | addItemFont("EventView Font",&mEventViewFont); | 182 | addItemFont("EventView Font",&mEventViewFont); |
183 | 183 | ||
184 | // KPrefs::setCurrentGroup("SyncProfiles"); | 184 | // KPrefs::setCurrentGroup("SyncProfiles"); |
185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | 185 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); |
186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | 186 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); |
187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | 187 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); |
188 | 188 | ||
189 | KPrefs::setCurrentGroup("RemoteSyncing"); | 189 | KPrefs::setCurrentGroup("RemoteSyncing"); |
190 | // addItemBool("UsePasswd",&mUsePassWd,false); | 190 | // addItemBool("UsePasswd",&mUsePassWd,false); |
191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | 191 | // addItemBool("WriteBackFile",&mWriteBackFile,true); |
192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | 192 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); |
193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | 193 | // addItemBool("AskForPreferences",&mAskForPreferences,true); |
194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | 194 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); |
195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); | 195 | addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); |
196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); | 196 | addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); |
197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 197 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
198 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 198 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
199 | 199 | ||
200 | #ifdef _WIN32_ | 200 | #ifdef _WIN32_ |
201 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 201 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
202 | #else | 202 | #else |
203 | QString hdp= locateLocal("data","korganizer")+"/"; | 203 | QString hdp= locateLocal("data","korganizer")+"/"; |
204 | #endif | 204 | #endif |
205 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); | ||
206 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); | ||
207 | // addItemString("RemotePassWd",&mRemotePassWd, ""); | ||
208 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); | ||
209 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); | ||
210 | |||
211 | 205 | ||
212 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 206 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
213 | 207 | ||
214 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 208 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
215 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 209 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
216 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 210 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
217 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 211 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
218 | 212 | ||
219 | 213 | ||
220 | KPrefs::setCurrentGroup("Locale"); | 214 | KPrefs::setCurrentGroup("Locale"); |
221 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 215 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
222 | addItemInt("PreferredTime",&mPreferredTime,0); | 216 | addItemInt("PreferredTime",&mPreferredTime,0); |
223 | addItemInt("PreferredDate",&mPreferredDate,0); | 217 | addItemInt("PreferredDate",&mPreferredDate,0); |
224 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 218 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
225 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 219 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
226 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 220 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
227 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 221 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
228 | 222 | ||
229 | 223 | ||
230 | KPrefs::setCurrentGroup("Colors"); | 224 | KPrefs::setCurrentGroup("Colors"); |
231 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 225 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
232 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 226 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
233 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 227 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
234 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 228 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
235 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 229 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
236 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 230 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
237 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 231 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
238 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 232 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
239 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 233 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
240 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 234 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
241 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 235 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
242 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 236 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
243 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 237 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
244 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 238 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
245 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 239 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
246 | addItemBool("UseAppColors",&mUseAppColors,false); | 240 | addItemBool("UseAppColors",&mUseAppColors,false); |
247 | 241 | ||
248 | 242 | ||
249 | 243 | ||
250 | KPrefs::setCurrentGroup("Views"); | 244 | KPrefs::setCurrentGroup("Views"); |
251 | addItemInt("Hour Size",&mHourSize,8); | 245 | addItemInt("Hour Size",&mHourSize,8); |
252 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 246 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
253 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 247 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
254 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 248 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
255 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 249 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
256 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 250 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
257 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 251 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
258 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 252 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
259 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 253 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
260 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 254 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
261 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 255 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
262 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 256 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
263 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 257 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
264 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 258 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
265 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 259 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
266 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 260 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
267 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 261 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
268 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 262 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
269 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 263 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
270 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 264 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
271 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 265 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
272 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 266 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
273 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 267 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
274 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 268 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
275 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 269 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
276 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 270 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
277 | #ifdef DESKTOP_VERSION | 271 | #ifdef DESKTOP_VERSION |
278 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 272 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
279 | #else | 273 | #else |
280 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 274 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
281 | #endif | 275 | #endif |
282 | addItemInt("Day Begins",&mDayBegins,7); | 276 | addItemInt("Day Begins",&mDayBegins,7); |
283 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 277 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
284 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 278 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
285 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 279 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
286 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 280 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
287 | 281 | ||
288 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 282 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
289 | addItemBool("Full View Month",&mFullViewMonth,true); | 283 | addItemBool("Full View Month",&mFullViewMonth,true); |
290 | addItemBool("Full View Todo",&mFullViewTodo,true); | 284 | addItemBool("Full View Todo",&mFullViewTodo,true); |
291 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 285 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
292 | 286 | ||
293 | addItemInt("Next X Days",&mNextXDays,3); | 287 | addItemInt("Next X Days",&mNextXDays,3); |
294 | 288 | ||
295 | KPrefs::setCurrentGroup("Printer"); | 289 | KPrefs::setCurrentGroup("Printer"); |
296 | 290 | ||
297 | KPrefs::setCurrentGroup("Layout"); | 291 | KPrefs::setCurrentGroup("Layout"); |
298 | 292 | ||
299 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 293 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
300 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 294 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
301 | 295 | ||
302 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 296 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
303 | 297 | ||
304 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 298 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
305 | 299 | ||
306 | KPrefs::setCurrentGroup("Group Scheduling"); | 300 | KPrefs::setCurrentGroup("Group Scheduling"); |
307 | 301 | ||
308 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 302 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
309 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 303 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
310 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 304 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
311 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 305 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
312 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 306 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
313 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 307 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
314 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 308 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
315 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 309 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
316 | 310 | ||
317 | KPrefs::setCurrentGroup( "Editors" ); | 311 | KPrefs::setCurrentGroup( "Editors" ); |
318 | 312 | ||
319 | addItemStringList( "EventTemplates", &mEventTemplates ); | 313 | addItemStringList( "EventTemplates", &mEventTemplates ); |
320 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 314 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
321 | 315 | ||
322 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 316 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
323 | 317 | ||
324 | 318 | ||
325 | 319 | ||
326 | } | 320 | } |
327 | 321 | ||
328 | 322 | ||
329 | KOPrefs::~KOPrefs() | 323 | KOPrefs::~KOPrefs() |
330 | { | 324 | { |
331 | if (mInstance == this) | 325 | if (mInstance == this) |
332 | mInstance = insd.setObject(0); | 326 | mInstance = insd.setObject(0); |
333 | setLocaleDict( 0 ); | 327 | setLocaleDict( 0 ); |
334 | if ( mLocaleDict ) | 328 | if ( mLocaleDict ) |
335 | delete mLocaleDict; | 329 | delete mLocaleDict; |
336 | //qDebug("KOPrefs::~KOPrefs() "); | 330 | //qDebug("KOPrefs::~KOPrefs() "); |
337 | } | 331 | } |
338 | 332 | ||
339 | 333 | ||
340 | KOPrefs *KOPrefs::instance() | 334 | KOPrefs *KOPrefs::instance() |
341 | { | 335 | { |
342 | if (!mInstance) { | 336 | if (!mInstance) { |
343 | mInstance = insd.setObject(new KOPrefs()); | 337 | mInstance = insd.setObject(new KOPrefs()); |
344 | mInstance->readConfig(); | 338 | mInstance->readConfig(); |
345 | } | 339 | } |
346 | 340 | ||
347 | return mInstance; | 341 | return mInstance; |
348 | } | 342 | } |
349 | 343 | ||
350 | void KOPrefs::usrSetDefaults() | 344 | void KOPrefs::usrSetDefaults() |
351 | { | 345 | { |
352 | 346 | ||
353 | } | 347 | } |
354 | 348 | ||
355 | void KOPrefs::fillMailDefaults() | 349 | void KOPrefs::fillMailDefaults() |
356 | { | 350 | { |
357 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 351 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
358 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 352 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
359 | } | 353 | } |
360 | 354 | ||
361 | void KOPrefs::setTimeZoneIdDefault() | 355 | void KOPrefs::setTimeZoneIdDefault() |
362 | { | 356 | { |
363 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | 357 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); |
364 | } | 358 | } |
365 | 359 | ||
366 | void KOPrefs::setCategoryDefaults() | 360 | void KOPrefs::setCategoryDefaults() |
367 | { | 361 | { |
368 | mCustomCategories.clear(); | 362 | mCustomCategories.clear(); |
369 | mCustomCategories = getDefaultList(); | 363 | mCustomCategories = getDefaultList(); |
370 | 364 | ||
371 | QStringList::Iterator it; | 365 | QStringList::Iterator it; |
372 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 366 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
373 | setCategoryColor(*it,mDefaultCategoryColor); | 367 | setCategoryColor(*it,mDefaultCategoryColor); |
374 | } | 368 | } |
375 | } | 369 | } |
376 | 370 | ||
377 | QStringList KOPrefs::getDefaultList() | 371 | QStringList KOPrefs::getDefaultList() |
378 | { | 372 | { |
379 | QStringList retval ; | 373 | QStringList retval ; |
380 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 374 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
381 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 375 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
382 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 376 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
383 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 377 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
384 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 378 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
385 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 379 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
386 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 380 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
387 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 381 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
388 | retval.sort(); | 382 | retval.sort(); |
389 | return retval; | 383 | return retval; |
390 | } | 384 | } |
391 | 385 | ||
392 | void KOPrefs::usrReadConfig() | 386 | void KOPrefs::usrReadConfig() |
393 | { | 387 | { |
394 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; | 388 | mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; |
395 | mLocaleDict = 0; | 389 | mLocaleDict = 0; |
396 | // pending LR fix translation | 390 | // pending LR fix translation |
397 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 391 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
398 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | 392 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { |
399 | if ( mPreferredLanguage == 1 ) { | 393 | if ( mPreferredLanguage == 1 ) { |
400 | mLocaleDict = new QDict<QString>; | 394 | mLocaleDict = new QDict<QString>; |
401 | int i = 0; | 395 | int i = 0; |
402 | QString fw ( germanwords[i] [0]); | 396 | QString fw ( germanwords[i] [0]); |
403 | while ( !fw.isEmpty() ) { | 397 | while ( !fw.isEmpty() ) { |
404 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | 398 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
405 | ++i; | 399 | ++i; |
406 | fw = germanwords[i] [0]; | 400 | fw = germanwords[i] [0]; |
407 | } | 401 | } |
408 | 402 | ||
409 | setLocaleDict( mLocaleDict ); | 403 | setLocaleDict( mLocaleDict ); |
410 | } else { | 404 | } else { |
411 | QString fileName ; | 405 | QString fileName ; |
412 | if ( mPreferredLanguage == 4 ) | 406 | if ( mPreferredLanguage == 4 ) |
413 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | 407 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; |
414 | else if ( mPreferredLanguage == 2 ) | 408 | else if ( mPreferredLanguage == 2 ) |
415 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | 409 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; |
416 | else if ( mPreferredLanguage == 3 ) | 410 | else if ( mPreferredLanguage == 3 ) |
417 | fileName = MainWindow::resourcePath()+"italiantranslation.txt"; | 411 | fileName = MainWindow::resourcePath()+"italiantranslation.txt"; |
418 | QFile file( fileName ); | 412 | QFile file( fileName ); |
419 | if (file.open( IO_ReadOnly ) ) { | 413 | if (file.open( IO_ReadOnly ) ) { |
420 | QTextStream ts( &file ); | 414 | QTextStream ts( &file ); |
421 | ts.setEncoding( QTextStream::Latin1 ); | 415 | ts.setEncoding( QTextStream::Latin1 ); |
422 | //ts.setCodec( QTextCodec::latin1 ); | 416 | //ts.setCodec( QTextCodec::latin1 ); |
423 | QString text = ts.read(); | 417 | QString text = ts.read(); |
424 | file.close(); | 418 | file.close(); |
425 | text.replace( QRegExp("\\\\n"), "\n" ); | 419 | text.replace( QRegExp("\\\\n"), "\n" ); |
426 | QString line; | 420 | QString line; |
427 | QString we; | 421 | QString we; |
428 | QString wt; | 422 | QString wt; |
429 | int br = 0; | 423 | int br = 0; |
430 | int nbr; | 424 | int nbr; |
431 | nbr = text.find ( "},", br ); | 425 | nbr = text.find ( "},", br ); |
432 | line = text.mid( br, nbr - br ); | 426 | line = text.mid( br, nbr - br ); |
433 | br = nbr+1; | 427 | br = nbr+1; |
434 | int se, ee, st, et; | 428 | int se, ee, st, et; |
435 | mLocaleDict = new QDict<QString>; | 429 | mLocaleDict = new QDict<QString>; |
436 | QString end = "{ \"\",\"\" }"; | 430 | QString end = "{ \"\",\"\" }"; |
437 | while ( (line != end) && (br > 1) ) { | 431 | while ( (line != end) && (br > 1) ) { |
438 | //qDebug("%d *%s* ", br, line.latin1()); | 432 | //qDebug("%d *%s* ", br, line.latin1()); |
439 | se = line.find("\"")+1; | 433 | se = line.find("\"")+1; |
440 | et = line.findRev("\"",-1); | 434 | et = line.findRev("\"",-1); |
441 | ee = line.find("\",\""); | 435 | ee = line.find("\",\""); |
442 | st = ee+3; | 436 | st = ee+3; |
443 | we = line.mid( se, ee-se ); | 437 | we = line.mid( se, ee-se ); |
444 | wt = line.mid( st, et-st ); | 438 | wt = line.mid( st, et-st ); |
445 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 439 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
446 | mLocaleDict->insert( we, new QString (wt) ); | 440 | mLocaleDict->insert( we, new QString (wt) ); |
447 | nbr = text.find ( "}", br ); | 441 | nbr = text.find ( "}", br ); |
448 | line = text.mid( br, nbr - br ); | 442 | line = text.mid( br, nbr - br ); |
449 | br = nbr+1; | 443 | br = nbr+1; |
450 | } | 444 | } |
451 | //qDebug("end *%s* ", end.latin1()); | 445 | //qDebug("end *%s* ", end.latin1()); |
452 | 446 | ||
453 | setLocaleDict( mLocaleDict ); | 447 | setLocaleDict( mLocaleDict ); |
454 | } else { | 448 | } else { |
455 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 449 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
456 | } | 450 | } |
457 | 451 | ||
458 | } | 452 | } |
459 | } | 453 | } |
460 | config()->setGroup("General"); | 454 | config()->setGroup("General"); |
461 | 455 | ||
462 | mCustomCategories = config()->readListEntry("Custom Categories"); | 456 | mCustomCategories = config()->readListEntry("Custom Categories"); |
463 | if ( KOPrefs::instance()->mLanguageChanged ) { | 457 | if ( KOPrefs::instance()->mLanguageChanged ) { |
464 | mLocationDefaults.clear(); | 458 | mLocationDefaults.clear(); |
465 | mEventSummaryUser.clear(); | 459 | mEventSummaryUser.clear(); |
466 | mTodoSummaryUser.clear(); | 460 | mTodoSummaryUser.clear(); |
467 | } | 461 | } |
468 | if (mLocationDefaults.isEmpty()) { | 462 | if (mLocationDefaults.isEmpty()) { |
469 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") | 463 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
470 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") | 464 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
471 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 465 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
472 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 466 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
473 | mLocationDefaults.sort(); | 467 | mLocationDefaults.sort(); |
474 | } | 468 | } |
475 | 469 | ||
476 | if (mEventSummaryUser.isEmpty()) { | 470 | if (mEventSummaryUser.isEmpty()) { |
477 | mEventSummaryUser = getDefaultList() ; | 471 | mEventSummaryUser = getDefaultList() ; |
478 | } | 472 | } |
479 | if (mTodoSummaryUser.isEmpty()) { | 473 | if (mTodoSummaryUser.isEmpty()) { |
480 | mTodoSummaryUser = getDefaultList() ; | 474 | mTodoSummaryUser = getDefaultList() ; |
481 | } | 475 | } |
482 | 476 | ||
483 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 477 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
484 | 478 | ||
485 | config()->setGroup("Personal Settings"); | 479 | config()->setGroup("Personal Settings"); |
486 | mName = config()->readEntry("user_name",""); | 480 | mName = config()->readEntry("user_name",""); |
487 | mEmail = config()->readEntry("user_email",""); | 481 | mEmail = config()->readEntry("user_email",""); |
488 | fillMailDefaults(); | 482 | fillMailDefaults(); |
489 | 483 | ||
490 | config()->setGroup("Category Colors"); | 484 | config()->setGroup("Category Colors"); |
491 | QStringList::Iterator it; | 485 | QStringList::Iterator it; |
492 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 486 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
493 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 487 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
494 | 488 | ||
495 | } | 489 | } |
496 | 490 | ||
497 | if (mTimeZoneId.isEmpty()) { | 491 | if (mTimeZoneId.isEmpty()) { |
498 | setTimeZoneIdDefault(); | 492 | setTimeZoneIdDefault(); |
499 | } | 493 | } |
500 | KPimPrefs::usrReadConfig(); | 494 | KPimPrefs::usrReadConfig(); |
501 | } | 495 | } |
502 | 496 | ||
503 | 497 | ||
504 | void KOPrefs::usrWriteConfig() | 498 | void KOPrefs::usrWriteConfig() |
505 | { | 499 | { |
506 | config()->setGroup("General"); | 500 | config()->setGroup("General"); |
507 | config()->writeEntry("Custom Categories",mCustomCategories); | 501 | config()->writeEntry("Custom Categories",mCustomCategories); |
508 | 502 | ||
509 | config()->setGroup("Personal Settings"); | 503 | config()->setGroup("Personal Settings"); |
510 | config()->writeEntry("user_name",mName); | 504 | config()->writeEntry("user_name",mName); |
511 | config()->writeEntry("user_email",mEmail); | 505 | config()->writeEntry("user_email",mEmail); |
512 | 506 | ||
513 | config()->setGroup("Category Colors"); | 507 | config()->setGroup("Category Colors"); |
514 | QDictIterator<QColor> it(mCategoryColors); | 508 | QDictIterator<QColor> it(mCategoryColors); |
515 | while (it.current()) { | 509 | while (it.current()) { |
516 | config()->writeEntry(it.currentKey(),*(it.current())); | 510 | config()->writeEntry(it.currentKey(),*(it.current())); |
517 | ++it; | 511 | ++it; |
518 | } | 512 | } |
519 | 513 | ||
520 | 514 | ||
521 | KPimPrefs::usrWriteConfig(); | 515 | KPimPrefs::usrWriteConfig(); |
522 | } | 516 | } |
523 | 517 | ||
524 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 518 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
525 | { | 519 | { |
526 | mCategoryColors.replace(cat,new QColor(color)); | 520 | mCategoryColors.replace(cat,new QColor(color)); |
527 | } | 521 | } |
528 | 522 | ||
529 | QColor *KOPrefs::categoryColor(QString cat) | 523 | QColor *KOPrefs::categoryColor(QString cat) |
530 | { | 524 | { |
531 | QColor *color = 0; | 525 | QColor *color = 0; |
532 | 526 | ||
533 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 527 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
534 | 528 | ||
535 | if (color) return color; | 529 | if (color) return color; |
536 | else return &mDefaultCategoryColor; | 530 | else return &mDefaultCategoryColor; |
537 | } | 531 | } |
538 | 532 | ||
539 | void KOPrefs::setFullName(const QString &name) | 533 | void KOPrefs::setFullName(const QString &name) |
540 | { | 534 | { |
541 | mName = name; | 535 | mName = name; |
542 | } | 536 | } |
543 | 537 | ||
544 | void KOPrefs::setEmail(const QString &email) | 538 | void KOPrefs::setEmail(const QString &email) |
545 | { | 539 | { |
546 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 540 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
547 | mEmail = email; | 541 | mEmail = email; |
548 | } | 542 | } |
549 | 543 | ||
550 | QString KOPrefs::fullName() | 544 | QString KOPrefs::fullName() |
551 | { | 545 | { |
552 | if (mEmailControlCenter) { | 546 | if (mEmailControlCenter) { |
553 | KEMailSettings settings; | 547 | KEMailSettings settings; |
554 | return settings.getSetting(KEMailSettings::RealName); | 548 | return settings.getSetting(KEMailSettings::RealName); |
555 | } else { | 549 | } else { |
556 | return mName; | 550 | return mName; |
557 | } | 551 | } |
558 | } | 552 | } |
559 | 553 | ||
560 | QString KOPrefs::email() | 554 | QString KOPrefs::email() |
561 | { | 555 | { |
562 | if (mEmailControlCenter) { | 556 | if (mEmailControlCenter) { |
563 | KEMailSettings settings; | 557 | KEMailSettings settings; |
564 | return settings.getSetting(KEMailSettings::EmailAddress); | 558 | return settings.getSetting(KEMailSettings::EmailAddress); |
565 | } else { | 559 | } else { |
566 | return mEmail; | 560 | return mEmail; |
567 | } | 561 | } |
568 | } | 562 | } |
569 | KConfig* KOPrefs::getConfig() | 563 | KConfig* KOPrefs::getConfig() |
570 | { | 564 | { |
571 | return config(); | 565 | return config(); |
572 | } | 566 | } |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 06470b8..c3e9f75 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -833,772 +833,772 @@ void MainWindow::initActions() | |||
833 | 833 | ||
834 | // ****************************************************** | 834 | // ****************************************************** |
835 | // menubar icons | 835 | // menubar icons |
836 | 836 | ||
837 | 837 | ||
838 | iconToolBar->setHorizontalStretchable (true ); | 838 | iconToolBar->setHorizontalStretchable (true ); |
839 | //menuBar->insertItem( iconToolBar ); | 839 | //menuBar->insertItem( iconToolBar ); |
840 | //xdays_action | 840 | //xdays_action |
841 | if (p-> mShowIconNewEvent) | 841 | if (p-> mShowIconNewEvent) |
842 | ne_action->addTo( iconToolBar ); | 842 | ne_action->addTo( iconToolBar ); |
843 | if (p->mShowIconNewTodo ) | 843 | if (p->mShowIconNewTodo ) |
844 | nt_action->addTo( iconToolBar ); | 844 | nt_action->addTo( iconToolBar ); |
845 | if (p-> mShowIconSearch) | 845 | if (p-> mShowIconSearch) |
846 | search_action->addTo( iconToolBar ); | 846 | search_action->addTo( iconToolBar ); |
847 | if (p-> mShowIconNext) | 847 | if (p-> mShowIconNext) |
848 | whatsnext_action->addTo( iconToolBar ); | 848 | whatsnext_action->addTo( iconToolBar ); |
849 | if (p-> mShowIconNextDays) | 849 | if (p-> mShowIconNextDays) |
850 | xdays_action->addTo( iconToolBar ); | 850 | xdays_action->addTo( iconToolBar ); |
851 | if (p-> mShowIconList) | 851 | if (p-> mShowIconList) |
852 | showlist_action->addTo( iconToolBar ); | 852 | showlist_action->addTo( iconToolBar ); |
853 | if (p-> mShowIconDay1) | 853 | if (p-> mShowIconDay1) |
854 | day1_action->addTo( iconToolBar ); | 854 | day1_action->addTo( iconToolBar ); |
855 | if (p-> mShowIconDay5) | 855 | if (p-> mShowIconDay5) |
856 | day5_action->addTo( iconToolBar ); | 856 | day5_action->addTo( iconToolBar ); |
857 | if (p-> mShowIconDay7) | 857 | if (p-> mShowIconDay7) |
858 | day7_action->addTo( iconToolBar ); | 858 | day7_action->addTo( iconToolBar ); |
859 | if (p-> mShowIconMonth) | 859 | if (p-> mShowIconMonth) |
860 | month_action->addTo( iconToolBar ); | 860 | month_action->addTo( iconToolBar ); |
861 | if (p-> mShowIconTodoview) | 861 | if (p-> mShowIconTodoview) |
862 | todoview_action->addTo( iconToolBar ); | 862 | todoview_action->addTo( iconToolBar ); |
863 | if (p-> mShowIconJournal) | 863 | if (p-> mShowIconJournal) |
864 | viewjournal_action->addTo( iconToolBar ); | 864 | viewjournal_action->addTo( iconToolBar ); |
865 | icon = loadPixmap( pathString + "2leftarrowB" ); | 865 | icon = loadPixmap( pathString + "2leftarrowB" ); |
866 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 866 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
867 | if (p-> mShowIconBackFast) { | 867 | if (p-> mShowIconBackFast) { |
868 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 868 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
869 | connect( action, SIGNAL( activated() ), | 869 | connect( action, SIGNAL( activated() ), |
870 | mView, SLOT( goPreviousMonth() ) ); | 870 | mView, SLOT( goPreviousMonth() ) ); |
871 | action->addTo( iconToolBar ); | 871 | action->addTo( iconToolBar ); |
872 | } | 872 | } |
873 | icon = loadPixmap( pathString + "1leftarrowB" ); | 873 | icon = loadPixmap( pathString + "1leftarrowB" ); |
874 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 874 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
875 | if (p-> mShowIconBack) { | 875 | if (p-> mShowIconBack) { |
876 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 876 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
877 | connect( action, SIGNAL( activated() ), | 877 | connect( action, SIGNAL( activated() ), |
878 | mView, SLOT( goPrevious() ) ); | 878 | mView, SLOT( goPrevious() ) ); |
879 | action->addTo( iconToolBar ); | 879 | action->addTo( iconToolBar ); |
880 | } | 880 | } |
881 | if (p-> mShowIconToday) | 881 | if (p-> mShowIconToday) |
882 | today_action->addTo( iconToolBar ); | 882 | today_action->addTo( iconToolBar ); |
883 | icon = loadPixmap( pathString + "1rightarrowB" ); | 883 | icon = loadPixmap( pathString + "1rightarrowB" ); |
884 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 884 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
885 | if (p-> mShowIconForward) { | 885 | if (p-> mShowIconForward) { |
886 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 886 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
887 | connect( action, SIGNAL( activated() ), | 887 | connect( action, SIGNAL( activated() ), |
888 | mView, SLOT( goNext() ) ); | 888 | mView, SLOT( goNext() ) ); |
889 | action->addTo( iconToolBar ); | 889 | action->addTo( iconToolBar ); |
890 | } | 890 | } |
891 | icon = loadPixmap( pathString + "2rightarrowB" ); | 891 | icon = loadPixmap( pathString + "2rightarrowB" ); |
892 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 892 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
893 | if (p-> mShowIconForwardFast) { | 893 | if (p-> mShowIconForwardFast) { |
894 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 894 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
895 | connect( action, SIGNAL( activated() ), | 895 | connect( action, SIGNAL( activated() ), |
896 | mView, SLOT( goNextMonth() ) ); | 896 | mView, SLOT( goNextMonth() ) ); |
897 | action->addTo( iconToolBar ); | 897 | action->addTo( iconToolBar ); |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 901 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
902 | 902 | ||
903 | if (p-> mShowIconNewEvent) | 903 | if (p-> mShowIconNewEvent) |
904 | configureToolBarMenu->setItemChecked( 10, true ); | 904 | configureToolBarMenu->setItemChecked( 10, true ); |
905 | if (p->mShowIconNewTodo ) | 905 | if (p->mShowIconNewTodo ) |
906 | configureToolBarMenu->setItemChecked( 20, true ); | 906 | configureToolBarMenu->setItemChecked( 20, true ); |
907 | if (p-> mShowIconSearch) | 907 | if (p-> mShowIconSearch) |
908 | configureToolBarMenu->setItemChecked( 120, true ); | 908 | configureToolBarMenu->setItemChecked( 120, true ); |
909 | if (p-> mShowIconList) | 909 | if (p-> mShowIconList) |
910 | configureToolBarMenu->setItemChecked( 30, true ); | 910 | configureToolBarMenu->setItemChecked( 30, true ); |
911 | if (p-> mShowIconDay1) | 911 | if (p-> mShowIconDay1) |
912 | configureToolBarMenu->setItemChecked( 40, true ); | 912 | configureToolBarMenu->setItemChecked( 40, true ); |
913 | if (p-> mShowIconDay5) | 913 | if (p-> mShowIconDay5) |
914 | configureToolBarMenu->setItemChecked( 50, true ); | 914 | configureToolBarMenu->setItemChecked( 50, true ); |
915 | if (p-> mShowIconDay7) | 915 | if (p-> mShowIconDay7) |
916 | configureToolBarMenu->setItemChecked( 60, true ); | 916 | configureToolBarMenu->setItemChecked( 60, true ); |
917 | if (p-> mShowIconMonth) | 917 | if (p-> mShowIconMonth) |
918 | configureToolBarMenu->setItemChecked( 70, true ); | 918 | configureToolBarMenu->setItemChecked( 70, true ); |
919 | if (p-> mShowIconTodoview) | 919 | if (p-> mShowIconTodoview) |
920 | configureToolBarMenu->setItemChecked( 80, true ); | 920 | configureToolBarMenu->setItemChecked( 80, true ); |
921 | if (p-> mShowIconBackFast) | 921 | if (p-> mShowIconBackFast) |
922 | configureToolBarMenu->setItemChecked( 200, true ); | 922 | configureToolBarMenu->setItemChecked( 200, true ); |
923 | if (p-> mShowIconBack) | 923 | if (p-> mShowIconBack) |
924 | configureToolBarMenu->setItemChecked( 210, true ); | 924 | configureToolBarMenu->setItemChecked( 210, true ); |
925 | if (p-> mShowIconToday) | 925 | if (p-> mShowIconToday) |
926 | configureToolBarMenu->setItemChecked( 130, true ); | 926 | configureToolBarMenu->setItemChecked( 130, true ); |
927 | if (p-> mShowIconForward) | 927 | if (p-> mShowIconForward) |
928 | configureToolBarMenu->setItemChecked( 220, true ); | 928 | configureToolBarMenu->setItemChecked( 220, true ); |
929 | if (p-> mShowIconForwardFast) | 929 | if (p-> mShowIconForwardFast) |
930 | configureToolBarMenu->setItemChecked( 230, true ); | 930 | configureToolBarMenu->setItemChecked( 230, true ); |
931 | if (p-> mShowIconNextDays) | 931 | if (p-> mShowIconNextDays) |
932 | configureToolBarMenu->setItemChecked( 100, true ); | 932 | configureToolBarMenu->setItemChecked( 100, true ); |
933 | if (p-> mShowIconNext) | 933 | if (p-> mShowIconNext) |
934 | configureToolBarMenu->setItemChecked( 110, true ); | 934 | configureToolBarMenu->setItemChecked( 110, true ); |
935 | if (p-> mShowIconJournal) | 935 | if (p-> mShowIconJournal) |
936 | configureToolBarMenu->setItemChecked( 90, true ); | 936 | configureToolBarMenu->setItemChecked( 90, true ); |
937 | if (p-> mShowIconWhatsThis) | 937 | if (p-> mShowIconWhatsThis) |
938 | configureToolBarMenu->setItemChecked( 300, true ); | 938 | configureToolBarMenu->setItemChecked( 300, true ); |
939 | 939 | ||
940 | QLabel* dummy = new QLabel( iconToolBar ); | 940 | QLabel* dummy = new QLabel( iconToolBar ); |
941 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 941 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
942 | if (!p-> mShowIconStretch) | 942 | if (!p-> mShowIconStretch) |
943 | iconToolBar->setStretchableWidget ( dummy ) ; | 943 | iconToolBar->setStretchableWidget ( dummy ) ; |
944 | else | 944 | else |
945 | configureToolBarMenu->setItemChecked( 5, true ); | 945 | configureToolBarMenu->setItemChecked( 5, true ); |
946 | if (p-> mShowIconWhatsThis) | 946 | if (p-> mShowIconWhatsThis) |
947 | QWhatsThis::whatsThisButton ( iconToolBar ); | 947 | QWhatsThis::whatsThisButton ( iconToolBar ); |
948 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 948 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
949 | configureAgenda( p->mHourSize ); | 949 | configureAgenda( p->mHourSize ); |
950 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 950 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
951 | } | 951 | } |
952 | 952 | ||
953 | void MainWindow::exportToPhone( int mode ) | 953 | void MainWindow::exportToPhone( int mode ) |
954 | { | 954 | { |
955 | 955 | ||
956 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 956 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
957 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 957 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
958 | KOex2phonePrefs ex2phone; | 958 | KOex2phonePrefs ex2phone; |
959 | 959 | ||
960 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); | 960 | ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); |
961 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); | 961 | ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); |
962 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 962 | ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
963 | if ( mode == 1 ) | 963 | if ( mode == 1 ) |
964 | ex2phone.setCaption(i18n("Export complete calendar")); | 964 | ex2phone.setCaption(i18n("Export complete calendar")); |
965 | if ( mode == 2 ) | 965 | if ( mode == 2 ) |
966 | ex2phone.setCaption(i18n("Export filtered calendar")); | 966 | ex2phone.setCaption(i18n("Export filtered calendar")); |
967 | 967 | ||
968 | if ( !ex2phone.exec() ) { | 968 | if ( !ex2phone.exec() ) { |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 971 | KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
972 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 972 | KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
973 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 973 | KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
974 | 974 | ||
975 | int inFuture = 0; | 975 | int inFuture = 0; |
976 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 976 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
977 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 977 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
978 | QPtrList<Incidence> delSel; | 978 | QPtrList<Incidence> delSel; |
979 | if ( mode == 1 ) | 979 | if ( mode == 1 ) |
980 | delSel = mCalendar->rawIncidences(); | 980 | delSel = mCalendar->rawIncidences(); |
981 | if ( mode == 2 ) | 981 | if ( mode == 2 ) |
982 | delSel = mCalendar->incidences(); | 982 | delSel = mCalendar->incidences(); |
983 | CalendarLocal* cal = new CalendarLocal(); | 983 | CalendarLocal* cal = new CalendarLocal(); |
984 | cal->setLocalTime(); | 984 | cal->setLocalTime(); |
985 | Incidence *incidence = delSel.first(); | 985 | Incidence *incidence = delSel.first(); |
986 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 986 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
987 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 987 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
988 | while ( incidence ) { | 988 | while ( incidence ) { |
989 | if ( incidence->type() != "Journal" ) { | 989 | if ( incidence->type() != "Journal" ) { |
990 | bool add = true; | 990 | bool add = true; |
991 | if ( inFuture ) { | 991 | if ( inFuture ) { |
992 | QDateTime dt; | 992 | QDateTime dt; |
993 | if ( incidence->type() == "Todo" ) { | 993 | if ( incidence->type() == "Todo" ) { |
994 | Todo * t = (Todo*)incidence; | 994 | Todo * t = (Todo*)incidence; |
995 | if ( t->hasDueDate() ) | 995 | if ( t->hasDueDate() ) |
996 | dt = t->dtDue(); | 996 | dt = t->dtDue(); |
997 | else | 997 | else |
998 | dt = cur.addSecs( 62 ); | 998 | dt = cur.addSecs( 62 ); |
999 | } | 999 | } |
1000 | else { | 1000 | else { |
1001 | bool ok; | 1001 | bool ok; |
1002 | dt = incidence->getNextOccurence( cur, &ok ); | 1002 | dt = incidence->getNextOccurence( cur, &ok ); |
1003 | if ( !ok ) | 1003 | if ( !ok ) |
1004 | dt = cur.addSecs( -62 ); | 1004 | dt = cur.addSecs( -62 ); |
1005 | } | 1005 | } |
1006 | if ( dt < cur || dt > end ) { | 1006 | if ( dt < cur || dt > end ) { |
1007 | add = false; | 1007 | add = false; |
1008 | } | 1008 | } |
1009 | } | 1009 | } |
1010 | if ( add ) { | 1010 | if ( add ) { |
1011 | Incidence *in = incidence->clone(); | 1011 | Incidence *in = incidence->clone(); |
1012 | cal->addIncidence( in ); | 1012 | cal->addIncidence( in ); |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | incidence = delSel.next(); | 1015 | incidence = delSel.next(); |
1016 | } | 1016 | } |
1017 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, | 1017 | PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, |
1018 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, | 1018 | KPimGlobalPrefs::instance()->mEx2PhoneConnection, |
1019 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); | 1019 | KPimGlobalPrefs::instance()->mEx2PhoneModel ); |
1020 | 1020 | ||
1021 | setCaption( i18n("Writing to phone...")); | 1021 | setCaption( i18n("Writing to phone...")); |
1022 | if ( PhoneFormat::writeToPhone( cal ) ) | 1022 | if ( PhoneFormat::writeToPhone( cal ) ) |
1023 | setCaption( i18n("Export to phone successful!")); | 1023 | setCaption( i18n("Export to phone successful!")); |
1024 | else | 1024 | else |
1025 | setCaption( i18n("Error exporting to phone!")); | 1025 | setCaption( i18n("Error exporting to phone!")); |
1026 | delete cal; | 1026 | delete cal; |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | 1029 | ||
1030 | void MainWindow::setDefaultPreferences() | 1030 | void MainWindow::setDefaultPreferences() |
1031 | { | 1031 | { |
1032 | KOPrefs *p = KOPrefs::instance(); | 1032 | KOPrefs *p = KOPrefs::instance(); |
1033 | 1033 | ||
1034 | p->mCompactDialogs = true; | 1034 | p->mCompactDialogs = true; |
1035 | p->mConfirm = true; | 1035 | p->mConfirm = true; |
1036 | // p->mEnableQuickTodo = false; | 1036 | // p->mEnableQuickTodo = false; |
1037 | 1037 | ||
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | QString MainWindow::resourcePath() | 1040 | QString MainWindow::resourcePath() |
1041 | { | 1041 | { |
1042 | return KGlobal::iconLoader()->iconPath(); | 1042 | return KGlobal::iconLoader()->iconPath(); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | void MainWindow::displayText( QString text ,QString cap ) | 1045 | void MainWindow::displayText( QString text ,QString cap ) |
1046 | { | 1046 | { |
1047 | QDialog dia( this, "name", true ); ; | 1047 | QDialog dia( this, "name", true ); ; |
1048 | dia.setCaption( cap ); | 1048 | dia.setCaption( cap ); |
1049 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1049 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1050 | lay->setSpacing( 3 ); | 1050 | lay->setSpacing( 3 ); |
1051 | lay->setMargin( 3 ); | 1051 | lay->setMargin( 3 ); |
1052 | QTextBrowser tb ( &dia ); | 1052 | QTextBrowser tb ( &dia ); |
1053 | lay->addWidget( &tb ); | 1053 | lay->addWidget( &tb ); |
1054 | tb.setText( text ); | 1054 | tb.setText( text ); |
1055 | #ifdef DESKTOP_VERSION | 1055 | #ifdef DESKTOP_VERSION |
1056 | dia.resize( 640, 480); | 1056 | dia.resize( 640, 480); |
1057 | #else | 1057 | #else |
1058 | dia.showMaximized(); | 1058 | dia.showMaximized(); |
1059 | #endif | 1059 | #endif |
1060 | dia.exec(); | 1060 | dia.exec(); |
1061 | } | 1061 | } |
1062 | void MainWindow::displayFile( QString fn, QString cap ) | 1062 | void MainWindow::displayFile( QString fn, QString cap ) |
1063 | { | 1063 | { |
1064 | QString fileName = resourcePath() + fn; | 1064 | QString fileName = resourcePath() + fn; |
1065 | QString text; | 1065 | QString text; |
1066 | QFile file( fileName ); | 1066 | QFile file( fileName ); |
1067 | if (!file.open( IO_ReadOnly ) ) { | 1067 | if (!file.open( IO_ReadOnly ) ) { |
1068 | return ; | 1068 | return ; |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | QTextStream ts( &file ); | 1071 | QTextStream ts( &file ); |
1072 | text = ts.read(); | 1072 | text = ts.read(); |
1073 | file.close(); | 1073 | file.close(); |
1074 | displayText( text, cap); | 1074 | displayText( text, cap); |
1075 | } | 1075 | } |
1076 | void MainWindow::features() | 1076 | void MainWindow::features() |
1077 | { | 1077 | { |
1078 | 1078 | ||
1079 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1079 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | void MainWindow::usertrans() | 1082 | void MainWindow::usertrans() |
1083 | { | 1083 | { |
1084 | 1084 | ||
1085 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1085 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void MainWindow::synchowto() | 1088 | void MainWindow::synchowto() |
1089 | { | 1089 | { |
1090 | 1090 | ||
1091 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); | 1091 | KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); |
1092 | } | 1092 | } |
1093 | void MainWindow::faq() | 1093 | void MainWindow::faq() |
1094 | { | 1094 | { |
1095 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1095 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1096 | 1096 | ||
1097 | } | 1097 | } |
1098 | void MainWindow::whatsNew() | 1098 | void MainWindow::whatsNew() |
1099 | { | 1099 | { |
1100 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); | 1100 | KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); |
1101 | 1101 | ||
1102 | } | 1102 | } |
1103 | void MainWindow::licence() | 1103 | void MainWindow::licence() |
1104 | { | 1104 | { |
1105 | KApplication::showLicence(); | 1105 | KApplication::showLicence(); |
1106 | 1106 | ||
1107 | } | 1107 | } |
1108 | void MainWindow::about() | 1108 | void MainWindow::about() |
1109 | { | 1109 | { |
1110 | QString version; | 1110 | QString version; |
1111 | #include <../version> | 1111 | #include <../version> |
1112 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1112 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1113 | i18n("KOrganizer/Platform-independent\n") + | 1113 | i18n("KOrganizer/Platform-independent\n") + |
1114 | "(KO/Pi) " + version + " - " + | 1114 | "(KO/Pi) " + version + " - " + |
1115 | 1115 | ||
1116 | #ifdef DESKTOP_VERSION | 1116 | #ifdef DESKTOP_VERSION |
1117 | i18n("Desktop Edition\n") + | 1117 | i18n("Desktop Edition\n") + |
1118 | #else | 1118 | #else |
1119 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1119 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1120 | #endif | 1120 | #endif |
1121 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1121 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1122 | } | 1122 | } |
1123 | void MainWindow::keyBindings() | 1123 | void MainWindow::keyBindings() |
1124 | { | 1124 | { |
1125 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1125 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1126 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1126 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1127 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1127 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1128 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1128 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1129 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1129 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1130 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1130 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1131 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1131 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1132 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1132 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1133 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1133 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1134 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1134 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1135 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1135 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1136 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1136 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1137 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1137 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1138 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1138 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1139 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1139 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1140 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1140 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1141 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1141 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1142 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1142 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1143 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1143 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1144 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1144 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1145 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1145 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1146 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1146 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1147 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1147 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1148 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1148 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1149 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1149 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1150 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ | 1150 | i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ |
1151 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ | 1151 | i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ |
1152 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ | 1152 | i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ |
1153 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1153 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1154 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1154 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1155 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1155 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1156 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1156 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1157 | i18n("<p><h3>In list view:</h3></p>\n") + | 1157 | i18n("<p><h3>In list view:</h3></p>\n") + |
1158 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1158 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1159 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1159 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1160 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1160 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1161 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1161 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1162 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1162 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1163 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1163 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1164 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1164 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1165 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1165 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1166 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1166 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1167 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1167 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1168 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1168 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1169 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1169 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1170 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1170 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1171 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1171 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1172 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1172 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1173 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1173 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1174 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1174 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1175 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1175 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1176 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1176 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1177 | displayText( text, cap); | 1177 | displayText( text, cap); |
1178 | 1178 | ||
1179 | } | 1179 | } |
1180 | void MainWindow::aboutAutoSaving() | 1180 | void MainWindow::aboutAutoSaving() |
1181 | { | 1181 | { |
1182 | QMessageBox* msg; | 1182 | QMessageBox* msg; |
1183 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1183 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1184 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1184 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1185 | QMessageBox::Ok, | 1185 | QMessageBox::Ok, |
1186 | QMessageBox::NoButton, | 1186 | QMessageBox::NoButton, |
1187 | QMessageBox::NoButton); | 1187 | QMessageBox::NoButton); |
1188 | msg->exec(); | 1188 | msg->exec(); |
1189 | delete msg; | 1189 | delete msg; |
1190 | 1190 | ||
1191 | 1191 | ||
1192 | } | 1192 | } |
1193 | void MainWindow::aboutKnownBugs() | 1193 | void MainWindow::aboutKnownBugs() |
1194 | { | 1194 | { |
1195 | QMessageBox* msg; | 1195 | QMessageBox* msg; |
1196 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1196 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1197 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1197 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1198 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1198 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1199 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1199 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1200 | i18n("\nor report them in the bugtracker on\n") + | 1200 | i18n("\nor report them in the bugtracker on\n") + |
1201 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1201 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1202 | QMessageBox::NoIcon, | 1202 | QMessageBox::NoIcon, |
1203 | QMessageBox::Ok, | 1203 | QMessageBox::Ok, |
1204 | QMessageBox::NoButton, | 1204 | QMessageBox::NoButton, |
1205 | QMessageBox::NoButton); | 1205 | QMessageBox::NoButton); |
1206 | msg->exec(); | 1206 | msg->exec(); |
1207 | delete msg; | 1207 | delete msg; |
1208 | 1208 | ||
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | QString MainWindow::defaultFileName() | 1211 | QString MainWindow::defaultFileName() |
1212 | { | 1212 | { |
1213 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1213 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1214 | } | 1214 | } |
1215 | QString MainWindow::syncFileName() | 1215 | QString MainWindow::syncFileName() |
1216 | { | 1216 | { |
1217 | #ifdef _WIN32_ | 1217 | #ifdef DESKTOP_VERSION |
1218 | return locateLocal( "tmp", "synccalendar.ics" ); | 1218 | return locateLocal( "tmp", "synccalendar.ics" ); |
1219 | #else | 1219 | #else |
1220 | return QString( "/tmp/kopitempfile.ics" ); | 1220 | return QString( "/tmp/synccalendar.ics" ); |
1221 | #endif | 1221 | #endif |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1224 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1225 | { | 1225 | { |
1226 | if ( !incidence ) { | 1226 | if ( !incidence ) { |
1227 | enableIncidenceActions( false ); | 1227 | enableIncidenceActions( false ); |
1228 | 1228 | ||
1229 | mNewSubTodoAction->setEnabled( false ); | 1229 | mNewSubTodoAction->setEnabled( false ); |
1230 | setCaptionToDates(); | 1230 | setCaptionToDates(); |
1231 | return; | 1231 | return; |
1232 | 1232 | ||
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | //KGlobal::locale()->formatDateTime(nextA, true); | 1235 | //KGlobal::locale()->formatDateTime(nextA, true); |
1236 | QString startString = ""; | 1236 | QString startString = ""; |
1237 | if ( incidence->type() != "Todo" ) { | 1237 | if ( incidence->type() != "Todo" ) { |
1238 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1238 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1239 | if ( incidence->doesFloat() ) { | 1239 | if ( incidence->doesFloat() ) { |
1240 | startString += ": "+incidence->dtStartDateStr( true ); | 1240 | startString += ": "+incidence->dtStartDateStr( true ); |
1241 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1241 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1242 | 1242 | ||
1243 | } else { | 1243 | } else { |
1244 | startString = ": "+incidence->dtStartStr(true); | 1244 | startString = ": "+incidence->dtStartStr(true); |
1245 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1245 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1246 | 1246 | ||
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | } else { | 1249 | } else { |
1250 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1250 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1251 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1251 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1252 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1252 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1253 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1253 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | } | 1256 | } |
1257 | else | 1257 | else |
1258 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1258 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1259 | if ( !incidence->location().isEmpty() ) | 1259 | if ( !incidence->location().isEmpty() ) |
1260 | startString += " (" +incidence->location()+")"; | 1260 | startString += " (" +incidence->location()+")"; |
1261 | setCaption( incidence->summary()+startString); | 1261 | setCaption( incidence->summary()+startString); |
1262 | 1262 | ||
1263 | enableIncidenceActions( true ); | 1263 | enableIncidenceActions( true ); |
1264 | 1264 | ||
1265 | if ( incidence->type() == "Event" ) { | 1265 | if ( incidence->type() == "Event" ) { |
1266 | mShowAction->setText( i18n("Show Event...") ); | 1266 | mShowAction->setText( i18n("Show Event...") ); |
1267 | mEditAction->setText( i18n("Edit Event...") ); | 1267 | mEditAction->setText( i18n("Edit Event...") ); |
1268 | mDeleteAction->setText( i18n("Delete Event...") ); | 1268 | mDeleteAction->setText( i18n("Delete Event...") ); |
1269 | 1269 | ||
1270 | mNewSubTodoAction->setEnabled( false ); | 1270 | mNewSubTodoAction->setEnabled( false ); |
1271 | } else if ( incidence->type() == "Todo" ) { | 1271 | } else if ( incidence->type() == "Todo" ) { |
1272 | mShowAction->setText( i18n("Show Todo...") ); | 1272 | mShowAction->setText( i18n("Show Todo...") ); |
1273 | mEditAction->setText( i18n("Edit Todo...") ); | 1273 | mEditAction->setText( i18n("Edit Todo...") ); |
1274 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1274 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1275 | 1275 | ||
1276 | mNewSubTodoAction->setEnabled( true ); | 1276 | mNewSubTodoAction->setEnabled( true ); |
1277 | } else { | 1277 | } else { |
1278 | mShowAction->setText( i18n("Show...") ); | 1278 | mShowAction->setText( i18n("Show...") ); |
1279 | mShowAction->setText( i18n("Edit...") ); | 1279 | mShowAction->setText( i18n("Edit...") ); |
1280 | mShowAction->setText( i18n("Delete...") ); | 1280 | mShowAction->setText( i18n("Delete...") ); |
1281 | 1281 | ||
1282 | mNewSubTodoAction->setEnabled( false ); | 1282 | mNewSubTodoAction->setEnabled( false ); |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | 1285 | ||
1286 | void MainWindow::enableIncidenceActions( bool enabled ) | 1286 | void MainWindow::enableIncidenceActions( bool enabled ) |
1287 | { | 1287 | { |
1288 | mShowAction->setEnabled( enabled ); | 1288 | mShowAction->setEnabled( enabled ); |
1289 | mEditAction->setEnabled( enabled ); | 1289 | mEditAction->setEnabled( enabled ); |
1290 | mDeleteAction->setEnabled( enabled ); | 1290 | mDeleteAction->setEnabled( enabled ); |
1291 | 1291 | ||
1292 | mCloneAction->setEnabled( enabled ); | 1292 | mCloneAction->setEnabled( enabled ); |
1293 | mMoveAction->setEnabled( enabled ); | 1293 | mMoveAction->setEnabled( enabled ); |
1294 | mBeamAction->setEnabled( enabled ); | 1294 | mBeamAction->setEnabled( enabled ); |
1295 | mCancelAction->setEnabled( enabled ); | 1295 | mCancelAction->setEnabled( enabled ); |
1296 | } | 1296 | } |
1297 | 1297 | ||
1298 | void MainWindow::importOL() | 1298 | void MainWindow::importOL() |
1299 | { | 1299 | { |
1300 | #ifdef _WIN32_ | 1300 | #ifdef _WIN32_ |
1301 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1301 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1302 | id->exec(); | 1302 | id->exec(); |
1303 | delete id; | 1303 | delete id; |
1304 | mView->updateView(); | 1304 | mView->updateView(); |
1305 | #endif | 1305 | #endif |
1306 | } | 1306 | } |
1307 | void MainWindow::importBday() | 1307 | void MainWindow::importBday() |
1308 | { | 1308 | { |
1309 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1309 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1310 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1310 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1311 | i18n("Import!"), i18n("Cancel"), 0, | 1311 | i18n("Import!"), i18n("Cancel"), 0, |
1312 | 0, 1 ); | 1312 | 0, 1 ); |
1313 | if ( result == 0 ) { | 1313 | if ( result == 0 ) { |
1314 | mView->importBday(); | 1314 | mView->importBday(); |
1315 | 1315 | ||
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | 1318 | ||
1319 | } | 1319 | } |
1320 | void MainWindow::importQtopia() | 1320 | void MainWindow::importQtopia() |
1321 | { | 1321 | { |
1322 | #ifndef DESKTOP_VERSION | 1322 | #ifndef DESKTOP_VERSION |
1323 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1323 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1324 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1324 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1325 | i18n("Import!"), i18n("Cancel"), 0, | 1325 | i18n("Import!"), i18n("Cancel"), 0, |
1326 | 0, 1 ); | 1326 | 0, 1 ); |
1327 | if ( result == 0 ) { | 1327 | if ( result == 0 ) { |
1328 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1328 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1329 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1329 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1330 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1330 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1331 | mView->importQtopia( categories, datebook, todolist ); | 1331 | mView->importQtopia( categories, datebook, todolist ); |
1332 | } | 1332 | } |
1333 | #else | 1333 | #else |
1334 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1334 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1335 | i18n("Not supported \non desktop!\n"), | 1335 | i18n("Not supported \non desktop!\n"), |
1336 | i18n("Ok"), i18n("Cancel"), 0, | 1336 | i18n("Ok"), i18n("Cancel"), 0, |
1337 | 0, 1 ); | 1337 | 0, 1 ); |
1338 | 1338 | ||
1339 | #endif | 1339 | #endif |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | void MainWindow::saveOnClose() | 1342 | void MainWindow::saveOnClose() |
1343 | { | 1343 | { |
1344 | KOPrefs *p = KOPrefs::instance(); | 1344 | KOPrefs *p = KOPrefs::instance(); |
1345 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1345 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1346 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1346 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1347 | iconToolBar->y() > height()/2; | 1347 | iconToolBar->y() > height()/2; |
1348 | mView->writeSettings(); | 1348 | mView->writeSettings(); |
1349 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1349 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1350 | save(); | 1350 | save(); |
1351 | } | 1351 | } |
1352 | void MainWindow::slotModifiedChanged( bool changed ) | 1352 | void MainWindow::slotModifiedChanged( bool changed ) |
1353 | { | 1353 | { |
1354 | if ( mBlockAtStartup ) | 1354 | if ( mBlockAtStartup ) |
1355 | return; | 1355 | return; |
1356 | int msec; | 1356 | int msec; |
1357 | // we store the changes after 1 minute, | 1357 | // we store the changes after 1 minute, |
1358 | // and for safety reasons after 10 minutes again | 1358 | // and for safety reasons after 10 minutes again |
1359 | if ( !mSyncManager->blockSave() ) | 1359 | if ( !mSyncManager->blockSave() ) |
1360 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1360 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1361 | else | 1361 | else |
1362 | msec = 1000 * 600; | 1362 | msec = 1000 * 600; |
1363 | mSaveTimer.start( msec, true ); // 1 minute | 1363 | mSaveTimer.start( msec, true ); // 1 minute |
1364 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1364 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1365 | mCalendarModifiedFlag = true; | 1365 | mCalendarModifiedFlag = true; |
1366 | } | 1366 | } |
1367 | void MainWindow::save() | 1367 | void MainWindow::save() |
1368 | { | 1368 | { |
1369 | if ( mSyncManager->blockSave() ) | 1369 | if ( mSyncManager->blockSave() ) |
1370 | return; | 1370 | return; |
1371 | mSyncManager->setBlockSave(true); | 1371 | mSyncManager->setBlockSave(true); |
1372 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1372 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1373 | 1373 | ||
1374 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1374 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1375 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1375 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1376 | qDebug("KO: Start saving data to file!"); | 1376 | qDebug("KO: Start saving data to file!"); |
1377 | mView->saveCalendar( defaultFileName() ); | 1377 | mView->saveCalendar( defaultFileName() ); |
1378 | 1378 | ||
1379 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1379 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1380 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1380 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1381 | QString savemes; | 1381 | QString savemes; |
1382 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1382 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1383 | setCaption(savemes); | 1383 | setCaption(savemes); |
1384 | } else | 1384 | } else |
1385 | setCaption(i18n("Saving cancelled!")); | 1385 | setCaption(i18n("Saving cancelled!")); |
1386 | mCalendarModifiedFlag = false; | 1386 | mCalendarModifiedFlag = false; |
1387 | mSyncManager->setBlockSave( false ); | 1387 | mSyncManager->setBlockSave( false ); |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1390 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1391 | { | 1391 | { |
1392 | if ( !e->isAutoRepeat() ) { | 1392 | if ( !e->isAutoRepeat() ) { |
1393 | mFlagKeyPressed = false; | 1393 | mFlagKeyPressed = false; |
1394 | } | 1394 | } |
1395 | } | 1395 | } |
1396 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1396 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1397 | { | 1397 | { |
1398 | qApp->processEvents(); | 1398 | qApp->processEvents(); |
1399 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1399 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1400 | e->ignore(); | 1400 | e->ignore(); |
1401 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1401 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1402 | return; | 1402 | return; |
1403 | } | 1403 | } |
1404 | if (! e->isAutoRepeat() ) | 1404 | if (! e->isAutoRepeat() ) |
1405 | mFlagKeyPressed = true; | 1405 | mFlagKeyPressed = true; |
1406 | KOPrefs *p = KOPrefs::instance(); | 1406 | KOPrefs *p = KOPrefs::instance(); |
1407 | bool showSelectedDates = false; | 1407 | bool showSelectedDates = false; |
1408 | int size; | 1408 | int size; |
1409 | int pro = 0; | 1409 | int pro = 0; |
1410 | //qDebug("MainWindow::keyPressEvent "); | 1410 | //qDebug("MainWindow::keyPressEvent "); |
1411 | switch ( e->key() ) { | 1411 | switch ( e->key() ) { |
1412 | case Qt::Key_Right: | 1412 | case Qt::Key_Right: |
1413 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1413 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1414 | mView->goNextMonth(); | 1414 | mView->goNextMonth(); |
1415 | else | 1415 | else |
1416 | mView->goNext(); | 1416 | mView->goNext(); |
1417 | showSelectedDates = true; | 1417 | showSelectedDates = true; |
1418 | break; | 1418 | break; |
1419 | case Qt::Key_Left: | 1419 | case Qt::Key_Left: |
1420 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1420 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1421 | mView->goPreviousMonth(); | 1421 | mView->goPreviousMonth(); |
1422 | else | 1422 | else |
1423 | mView->goPrevious(); | 1423 | mView->goPrevious(); |
1424 | showSelectedDates = true; | 1424 | showSelectedDates = true; |
1425 | break; | 1425 | break; |
1426 | case Qt::Key_Down: | 1426 | case Qt::Key_Down: |
1427 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1427 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1428 | break; | 1428 | break; |
1429 | case Qt::Key_Up: | 1429 | case Qt::Key_Up: |
1430 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1430 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1431 | break; | 1431 | break; |
1432 | case Qt::Key_I: | 1432 | case Qt::Key_I: |
1433 | mView->showIncidence(); | 1433 | mView->showIncidence(); |
1434 | break; | 1434 | break; |
1435 | case Qt::Key_Delete: | 1435 | case Qt::Key_Delete: |
1436 | case Qt::Key_Backspace: | 1436 | case Qt::Key_Backspace: |
1437 | mView->deleteIncidence(); | 1437 | mView->deleteIncidence(); |
1438 | break; | 1438 | break; |
1439 | case Qt::Key_D: | 1439 | case Qt::Key_D: |
1440 | mView->viewManager()->showDayView(); | 1440 | mView->viewManager()->showDayView(); |
1441 | showSelectedDates = true; | 1441 | showSelectedDates = true; |
1442 | break; | 1442 | break; |
1443 | case Qt::Key_O: | 1443 | case Qt::Key_O: |
1444 | mView->toggleFilerEnabled( ); | 1444 | mView->toggleFilerEnabled( ); |
1445 | break; | 1445 | break; |
1446 | case Qt::Key_0: | 1446 | case Qt::Key_0: |
1447 | case Qt::Key_1: | 1447 | case Qt::Key_1: |
1448 | case Qt::Key_2: | 1448 | case Qt::Key_2: |
1449 | case Qt::Key_3: | 1449 | case Qt::Key_3: |
1450 | case Qt::Key_4: | 1450 | case Qt::Key_4: |
1451 | case Qt::Key_5: | 1451 | case Qt::Key_5: |
1452 | case Qt::Key_6: | 1452 | case Qt::Key_6: |
1453 | case Qt::Key_7: | 1453 | case Qt::Key_7: |
1454 | case Qt::Key_8: | 1454 | case Qt::Key_8: |
1455 | case Qt::Key_9: | 1455 | case Qt::Key_9: |
1456 | pro = e->key()-48; | 1456 | pro = e->key()-48; |
1457 | if ( pro == 0 ) | 1457 | if ( pro == 0 ) |
1458 | pro = 10; | 1458 | pro = 10; |
1459 | if ( e->state() == Qt::ControlButton) | 1459 | if ( e->state() == Qt::ControlButton) |
1460 | pro += 10; | 1460 | pro += 10; |
1461 | break; | 1461 | break; |
1462 | case Qt::Key_M: | 1462 | case Qt::Key_M: |
1463 | mView->viewManager()->showMonthView(); | 1463 | mView->viewManager()->showMonthView(); |
1464 | showSelectedDates = true; | 1464 | showSelectedDates = true; |
1465 | break; | 1465 | break; |
1466 | case Qt::Key_Insert: | 1466 | case Qt::Key_Insert: |
1467 | mView->newEvent(); | 1467 | mView->newEvent(); |
1468 | break; | 1468 | break; |
1469 | case Qt::Key_S : | 1469 | case Qt::Key_S : |
1470 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1470 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1471 | mView->newSubTodo(); | 1471 | mView->newSubTodo(); |
1472 | else | 1472 | else |
1473 | mView->dialogManager()->showSearchDialog(); | 1473 | mView->dialogManager()->showSearchDialog(); |
1474 | break; | 1474 | break; |
1475 | case Qt::Key_Y : | 1475 | case Qt::Key_Y : |
1476 | case Qt::Key_Z : | 1476 | case Qt::Key_Z : |
1477 | mView->viewManager()->showWorkWeekView(); | 1477 | mView->viewManager()->showWorkWeekView(); |
1478 | showSelectedDates = true; | 1478 | showSelectedDates = true; |
1479 | break; | 1479 | break; |
1480 | case Qt::Key_U : | 1480 | case Qt::Key_U : |
1481 | mView->viewManager()->showWeekView(); | 1481 | mView->viewManager()->showWeekView(); |
1482 | showSelectedDates = true; | 1482 | showSelectedDates = true; |
1483 | break; | 1483 | break; |
1484 | case Qt::Key_H : | 1484 | case Qt::Key_H : |
1485 | keyBindings(); | 1485 | keyBindings(); |
1486 | break; | 1486 | break; |
1487 | case Qt::Key_W: | 1487 | case Qt::Key_W: |
1488 | mView->viewManager()->showWhatsNextView(); | 1488 | mView->viewManager()->showWhatsNextView(); |
1489 | break; | 1489 | break; |
1490 | case Qt::Key_L: | 1490 | case Qt::Key_L: |
1491 | mView->viewManager()->showListView(); | 1491 | mView->viewManager()->showListView(); |
1492 | break; | 1492 | break; |
1493 | case Qt::Key_N: | 1493 | case Qt::Key_N: |
1494 | mView->viewManager()->showNextXView(); | 1494 | mView->viewManager()->showNextXView(); |
1495 | showSelectedDates = true; | 1495 | showSelectedDates = true; |
1496 | break; | 1496 | break; |
1497 | case Qt::Key_V: | 1497 | case Qt::Key_V: |
1498 | mView->viewManager()->showTodoView(); | 1498 | mView->viewManager()->showTodoView(); |
1499 | break; | 1499 | break; |
1500 | case Qt::Key_C: | 1500 | case Qt::Key_C: |
1501 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1501 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1502 | break; | 1502 | break; |
1503 | case Qt::Key_P: | 1503 | case Qt::Key_P: |
1504 | mView->showDatePicker( ); | 1504 | mView->showDatePicker( ); |
1505 | break; | 1505 | break; |
1506 | case Qt::Key_F: | 1506 | case Qt::Key_F: |
1507 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1507 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1508 | mView->editFilters(); | 1508 | mView->editFilters(); |
1509 | else | 1509 | else |
1510 | mView->toggleFilter(); | 1510 | mView->toggleFilter(); |
1511 | break; | 1511 | break; |
1512 | case Qt::Key_X: | 1512 | case Qt::Key_X: |
1513 | mView->toggleDateNavigatorWidget(); | 1513 | mView->toggleDateNavigatorWidget(); |
1514 | break; | 1514 | break; |
1515 | case Qt::Key_Space: | 1515 | case Qt::Key_Space: |
1516 | mView->toggleExpand(); | 1516 | mView->toggleExpand(); |
1517 | break; | 1517 | break; |
1518 | case Qt::Key_A: | 1518 | case Qt::Key_A: |
1519 | mView->toggleAllDaySize(); | 1519 | mView->toggleAllDaySize(); |
1520 | break; | 1520 | break; |
1521 | case Qt::Key_T: | 1521 | case Qt::Key_T: |
1522 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1522 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1523 | mView->newTodo(); | 1523 | mView->newTodo(); |
1524 | else { | 1524 | else { |
1525 | mView->goToday(); | 1525 | mView->goToday(); |
1526 | showSelectedDates = true; | 1526 | showSelectedDates = true; |
1527 | } | 1527 | } |
1528 | break; | 1528 | break; |
1529 | case Qt::Key_J: | 1529 | case Qt::Key_J: |
1530 | mView->viewManager()->showJournalView(); | 1530 | mView->viewManager()->showJournalView(); |
1531 | break; | 1531 | break; |
1532 | case Qt::Key_B: | 1532 | case Qt::Key_B: |
1533 | mView->editIncidenceDescription();; | 1533 | mView->editIncidenceDescription();; |
1534 | break; | 1534 | break; |
1535 | // case Qt::Key_Return: | 1535 | // case Qt::Key_Return: |
1536 | case Qt::Key_E: | 1536 | case Qt::Key_E: |
1537 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1537 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1538 | mView->newEvent(); | 1538 | mView->newEvent(); |
1539 | else | 1539 | else |
1540 | mView->editIncidence(); | 1540 | mView->editIncidence(); |
1541 | break; | 1541 | break; |
1542 | case Qt::Key_Plus: | 1542 | case Qt::Key_Plus: |
1543 | size = p->mHourSize +2; | 1543 | size = p->mHourSize +2; |
1544 | if ( size <= 18 ) | 1544 | if ( size <= 18 ) |
1545 | configureAgenda( size ); | 1545 | configureAgenda( size ); |
1546 | break; | 1546 | break; |
1547 | case Qt::Key_Minus: | 1547 | case Qt::Key_Minus: |
1548 | size = p->mHourSize - 2; | 1548 | size = p->mHourSize - 2; |
1549 | if ( size >= 4 ) | 1549 | if ( size >= 4 ) |
1550 | configureAgenda( size ); | 1550 | configureAgenda( size ); |
1551 | break; | 1551 | break; |
1552 | 1552 | ||
1553 | 1553 | ||
1554 | default: | 1554 | default: |
1555 | e->ignore(); | 1555 | e->ignore(); |
1556 | } | 1556 | } |
1557 | if ( pro > 0 ) { | 1557 | if ( pro > 0 ) { |
1558 | mView->selectFilter( pro-1 ); | 1558 | mView->selectFilter( pro-1 ); |
1559 | } | 1559 | } |
1560 | if ( showSelectedDates ) { | 1560 | if ( showSelectedDates ) { |
1561 | ;// setCaptionToDates(); | 1561 | ;// setCaptionToDates(); |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | void MainWindow::fillFilterMenu() | 1566 | void MainWindow::fillFilterMenu() |
1567 | { | 1567 | { |
1568 | selectFilterMenu->clear(); | 1568 | selectFilterMenu->clear(); |
1569 | bool disable = false; | 1569 | bool disable = false; |
1570 | if ( mView->filterView()->filtersEnabled() ) { | 1570 | if ( mView->filterView()->filtersEnabled() ) { |
1571 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1571 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1572 | } | 1572 | } |
1573 | else { | 1573 | else { |
1574 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1574 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1575 | disable = true; | 1575 | disable = true; |
1576 | } | 1576 | } |
1577 | selectFilterMenu->insertSeparator(); | 1577 | selectFilterMenu->insertSeparator(); |
1578 | QPtrList<CalFilter> fili = mView->filters(); | 1578 | QPtrList<CalFilter> fili = mView->filters(); |
1579 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1579 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1580 | CalFilter *filter = fili.first(); | 1580 | CalFilter *filter = fili.first(); |
1581 | int iii = 1; | 1581 | int iii = 1; |
1582 | while(filter) { | 1582 | while(filter) { |
1583 | selectFilterMenu->insertItem( filter->name(), iii ); | 1583 | selectFilterMenu->insertItem( filter->name(), iii ); |
1584 | if ( filter == curfilter) | 1584 | if ( filter == curfilter) |
1585 | selectFilterMenu->setItemChecked( iii, true ); | 1585 | selectFilterMenu->setItemChecked( iii, true ); |
1586 | if ( disable ) | 1586 | if ( disable ) |
1587 | selectFilterMenu->setItemEnabled( iii, false ); | 1587 | selectFilterMenu->setItemEnabled( iii, false ); |
1588 | filter = fili.next(); | 1588 | filter = fili.next(); |
1589 | ++iii; | 1589 | ++iii; |
1590 | } | 1590 | } |
1591 | } | 1591 | } |
1592 | void MainWindow::selectFilter( int fil ) | 1592 | void MainWindow::selectFilter( int fil ) |
1593 | { | 1593 | { |
1594 | if ( fil == 0 ) { | 1594 | if ( fil == 0 ) { |
1595 | mView->toggleFilerEnabled( ); | 1595 | mView->toggleFilerEnabled( ); |
1596 | } else { | 1596 | } else { |
1597 | mView->selectFilter( fil-1 ); | 1597 | mView->selectFilter( fil-1 ); |
1598 | } | 1598 | } |
1599 | } | 1599 | } |
1600 | void MainWindow::configureToolBar( int item ) | 1600 | void MainWindow::configureToolBar( int item ) |
1601 | { | 1601 | { |
1602 | 1602 | ||
1603 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1603 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1604 | KOPrefs *p = KOPrefs::instance(); | 1604 | KOPrefs *p = KOPrefs::instance(); |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 101db57..900fc04 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,620 +1,620 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | 4 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #include <phoneaccess.h> | 39 | #include <phoneaccess.h> |
40 | 40 | ||
41 | #include "calendar.h" | 41 | #include "calendar.h" |
42 | #include "alarm.h" | 42 | #include "alarm.h" |
43 | #include "recurrence.h" | 43 | #include "recurrence.h" |
44 | #include "calendarlocal.h" | 44 | #include "calendarlocal.h" |
45 | 45 | ||
46 | #include "phoneformat.h" | 46 | #include "phoneformat.h" |
47 | #include "syncdefines.h" | 47 | #include "syncdefines.h" |
48 | 48 | ||
49 | using namespace KCal; | 49 | using namespace KCal; |
50 | class PhoneParser : public QObject | 50 | class PhoneParser : public QObject |
51 | { | 51 | { |
52 | public: | 52 | public: |
53 | PhoneParser( ) { | 53 | PhoneParser( ) { |
54 | ; | 54 | ; |
55 | } | 55 | } |
56 | 56 | ||
57 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) | 57 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
58 | { | 58 | { |
59 | QString datestr; | 59 | QString datestr; |
60 | QString timestr; | 60 | QString timestr; |
61 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 61 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
62 | QDateTime dt; | 62 | QDateTime dt; |
63 | if (useTZ) | 63 | if (useTZ) |
64 | dt = dti.addSecs ( -(offset*60)); | 64 | dt = dti.addSecs ( -(offset*60)); |
65 | else | 65 | else |
66 | dt = dti; | 66 | dt = dti; |
67 | if(dt.date().isValid()){ | 67 | if(dt.date().isValid()){ |
68 | const QDate& date = dt.date(); | 68 | const QDate& date = dt.date(); |
69 | datestr.sprintf("%04d%02d%02d", | 69 | datestr.sprintf("%04d%02d%02d", |
70 | date.year(), date.month(), date.day()); | 70 | date.year(), date.month(), date.day()); |
71 | } | 71 | } |
72 | if(dt.time().isValid()){ | 72 | if(dt.time().isValid()){ |
73 | const QTime& time = dt.time(); | 73 | const QTime& time = dt.time(); |
74 | timestr.sprintf("T%02d%02d%02d", | 74 | timestr.sprintf("T%02d%02d%02d", |
75 | time.hour(), time.minute(), time.second()); | 75 | time.hour(), time.minute(), time.second()); |
76 | } | 76 | } |
77 | return datestr + timestr; | 77 | return datestr + timestr; |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 85 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
86 | { | 86 | { |
87 | mProfileName = profileName; | 87 | mProfileName = profileName; |
88 | PhoneAccess::writeConfig( device, connection, model ); | 88 | PhoneAccess::writeConfig( device, connection, model ); |
89 | } | 89 | } |
90 | 90 | ||
91 | PhoneFormat::~PhoneFormat() | 91 | PhoneFormat::~PhoneFormat() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | #if 0 | 95 | #if 0 |
96 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 96 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
97 | { | 97 | { |
98 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 98 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
99 | s->ConfigNum = 1; | 99 | s->ConfigNum = 1; |
100 | GSM_Config *cfg = &s->Config[0]; | 100 | GSM_Config *cfg = &s->Config[0]; |
101 | if ( ! mConnection.isEmpty() ) { | 101 | if ( ! mConnection.isEmpty() ) { |
102 | cfg->Connection = strdup(mConnection.latin1()); | 102 | cfg->Connection = strdup(mConnection.latin1()); |
103 | cfg->DefaultConnection = false; | 103 | cfg->DefaultConnection = false; |
104 | qDebug("Connection set %s ", cfg->Connection ); | 104 | qDebug("Connection set %s ", cfg->Connection ); |
105 | 105 | ||
106 | } | 106 | } |
107 | if ( ! mDevice.isEmpty() ) { | 107 | if ( ! mDevice.isEmpty() ) { |
108 | cfg->Device = strdup(mDevice.latin1()); | 108 | cfg->Device = strdup(mDevice.latin1()); |
109 | cfg->DefaultDevice = false; | 109 | cfg->DefaultDevice = false; |
110 | qDebug("Device set %s ", cfg->Device); | 110 | qDebug("Device set %s ", cfg->Device); |
111 | 111 | ||
112 | } | 112 | } |
113 | if ( ! mModel.isEmpty() ) { | 113 | if ( ! mModel.isEmpty() ) { |
114 | strcpy(cfg->Model,mModel.latin1() ); | 114 | strcpy(cfg->Model,mModel.latin1() ); |
115 | cfg->DefaultModel = false; | 115 | cfg->DefaultModel = false; |
116 | qDebug("Model set %s ",cfg->Model ); | 116 | qDebug("Model set %s ",cfg->Model ); |
117 | } | 117 | } |
118 | int error=GSM_InitConnection(s,3); | 118 | int error=GSM_InitConnection(s,3); |
119 | return error; | 119 | return error; |
120 | } | 120 | } |
121 | #endif | 121 | #endif |
122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 122 | ulong PhoneFormat::getCsumTodo( Todo* todo ) |
123 | { | 123 | { |
124 | QStringList attList; | 124 | QStringList attList; |
125 | if ( todo->hasDueDate() ) | 125 | if ( todo->hasDueDate() ) |
126 | attList << PhoneParser::dtToString ( todo->dtDue() ); | 126 | attList << PhoneParser::dtToString ( todo->dtDue() ); |
127 | attList << todo->summary(); | 127 | attList << todo->summary(); |
128 | QString completedString = "no"; | 128 | QString completedString = "no"; |
129 | if ( todo->isCompleted() ) | 129 | if ( todo->isCompleted() ) |
130 | completedString = "yes"; | 130 | completedString = "yes"; |
131 | attList << completedString; | 131 | attList << completedString; |
132 | int prio = todo->priority(); | 132 | int prio = todo->priority(); |
133 | if( prio == 2 ) prio = 1; | 133 | if( prio == 2 ) prio = 1; |
134 | if (prio == 4 ) prio = 5 ; | 134 | if (prio == 4 ) prio = 5 ; |
135 | attList << QString::number( prio ); | 135 | attList << QString::number( prio ); |
136 | QString alarmString = "na"; | 136 | QString alarmString = "na"; |
137 | Alarm *alarm; | 137 | Alarm *alarm; |
138 | if ( todo->alarms().count() > 0 ) { | 138 | if ( todo->alarms().count() > 0 ) { |
139 | alarm = todo->alarms().first(); | 139 | alarm = todo->alarms().first(); |
140 | if ( alarm->enabled() ) { | 140 | if ( alarm->enabled() ) { |
141 | alarmString = QString::number(alarm->offset() ); | 141 | alarmString = QString::number(alarm->offset() ); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | attList << alarmString; | 144 | attList << alarmString; |
145 | attList << todo->categoriesStr(); | 145 | attList << todo->categoriesStr(); |
146 | attList << todo->secrecyStr(); | 146 | attList << todo->secrecyStr(); |
147 | return PhoneFormat::getCsum(attList ); | 147 | return PhoneFormat::getCsum(attList ); |
148 | 148 | ||
149 | } | 149 | } |
150 | ulong PhoneFormat::getCsumEvent( Event* event ) | 150 | ulong PhoneFormat::getCsumEvent( Event* event ) |
151 | { | 151 | { |
152 | QStringList attList; | 152 | QStringList attList; |
153 | attList << PhoneParser::dtToString ( event->dtStart() ); | 153 | attList << PhoneParser::dtToString ( event->dtStart() ); |
154 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 154 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
155 | attList << event->summary(); | 155 | attList << event->summary(); |
156 | attList << event->location(); | 156 | attList << event->location(); |
157 | QString alarmString = "na"; | 157 | QString alarmString = "na"; |
158 | Alarm *alarm; | 158 | Alarm *alarm; |
159 | if ( event->alarms().count() > 0 ) { | 159 | if ( event->alarms().count() > 0 ) { |
160 | alarm = event->alarms().first(); | 160 | alarm = event->alarms().first(); |
161 | if ( alarm->enabled() ) { | 161 | if ( alarm->enabled() ) { |
162 | alarmString = QString::number( alarm->offset() ); | 162 | alarmString = QString::number( alarm->offset() ); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | attList << alarmString; | 165 | attList << alarmString; |
166 | Recurrence* rec = event->recurrence(); | 166 | Recurrence* rec = event->recurrence(); |
167 | QStringList list; | 167 | QStringList list; |
168 | bool writeEndDate = false; | 168 | bool writeEndDate = false; |
169 | switch ( rec->doesRecur() ) | 169 | switch ( rec->doesRecur() ) |
170 | { | 170 | { |
171 | case Recurrence::rDaily: // 0 | 171 | case Recurrence::rDaily: // 0 |
172 | list.append( "0" ); | 172 | list.append( "0" ); |
173 | list.append( QString::number( rec->frequency() ));//12 | 173 | list.append( QString::number( rec->frequency() ));//12 |
174 | list.append( "0" ); | 174 | list.append( "0" ); |
175 | list.append( "0" ); | 175 | list.append( "0" ); |
176 | writeEndDate = true; | 176 | writeEndDate = true; |
177 | break; | 177 | break; |
178 | case Recurrence::rWeekly:// 1 | 178 | case Recurrence::rWeekly:// 1 |
179 | list.append( "1" ); | 179 | list.append( "1" ); |
180 | list.append( QString::number( rec->frequency()) );//12 | 180 | list.append( QString::number( rec->frequency()) );//12 |
181 | list.append( "0" ); | 181 | list.append( "0" ); |
182 | { | 182 | { |
183 | int days = 0; | 183 | int days = 0; |
184 | QBitArray weekDays = rec->days(); | 184 | QBitArray weekDays = rec->days(); |
185 | int i; | 185 | int i; |
186 | for( i = 1; i <= 7; ++i ) { | 186 | for( i = 1; i <= 7; ++i ) { |
187 | if ( weekDays[i-1] ) { | 187 | if ( weekDays[i-1] ) { |
188 | days += 1 << (i-1); | 188 | days += 1 << (i-1); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | list.append( QString::number( days ) ); | 191 | list.append( QString::number( days ) ); |
192 | } | 192 | } |
193 | //pending weekdays | 193 | //pending weekdays |
194 | writeEndDate = true; | 194 | writeEndDate = true; |
195 | 195 | ||
196 | break; | 196 | break; |
197 | case Recurrence::rMonthlyPos:// 2 | 197 | case Recurrence::rMonthlyPos:// 2 |
198 | list.append( "2" ); | 198 | list.append( "2" ); |
199 | list.append( QString::number( rec->frequency()) );//12 | 199 | list.append( QString::number( rec->frequency()) );//12 |
200 | 200 | ||
201 | writeEndDate = true; | 201 | writeEndDate = true; |
202 | { | 202 | { |
203 | int count = 1; | 203 | int count = 1; |
204 | QPtrList<Recurrence::rMonthPos> rmp; | 204 | QPtrList<Recurrence::rMonthPos> rmp; |
205 | rmp = rec->monthPositions(); | 205 | rmp = rec->monthPositions(); |
206 | if ( rmp.first()->negative ) | 206 | if ( rmp.first()->negative ) |
207 | count = 5 - rmp.first()->rPos - 1; | 207 | count = 5 - rmp.first()->rPos - 1; |
208 | else | 208 | else |
209 | count = rmp.first()->rPos - 1; | 209 | count = rmp.first()->rPos - 1; |
210 | list.append( QString::number( count ) ); | 210 | list.append( QString::number( count ) ); |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | list.append( "0" ); | 214 | list.append( "0" ); |
215 | break; | 215 | break; |
216 | case Recurrence::rMonthlyDay:// 3 | 216 | case Recurrence::rMonthlyDay:// 3 |
217 | list.append( "3" ); | 217 | list.append( "3" ); |
218 | list.append( QString::number( rec->frequency()) );//12 | 218 | list.append( QString::number( rec->frequency()) );//12 |
219 | list.append( "0" ); | 219 | list.append( "0" ); |
220 | list.append( "0" ); | 220 | list.append( "0" ); |
221 | writeEndDate = true; | 221 | writeEndDate = true; |
222 | break; | 222 | break; |
223 | case Recurrence::rYearlyMonth://4 | 223 | case Recurrence::rYearlyMonth://4 |
224 | list.append( "4" ); | 224 | list.append( "4" ); |
225 | list.append( QString::number( rec->frequency()) );//12 | 225 | list.append( QString::number( rec->frequency()) );//12 |
226 | list.append( "0" ); | 226 | list.append( "0" ); |
227 | list.append( "0" ); | 227 | list.append( "0" ); |
228 | writeEndDate = true; | 228 | writeEndDate = true; |
229 | break; | 229 | break; |
230 | 230 | ||
231 | default: | 231 | default: |
232 | list.append( "255" ); | 232 | list.append( "255" ); |
233 | list.append( QString() ); | 233 | list.append( QString() ); |
234 | list.append( "0" ); | 234 | list.append( "0" ); |
235 | list.append( QString() ); | 235 | list.append( QString() ); |
236 | list.append( "0" ); | 236 | list.append( "0" ); |
237 | list.append( "20991231T000000" ); | 237 | list.append( "20991231T000000" ); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | if ( writeEndDate ) { | 240 | if ( writeEndDate ) { |
241 | 241 | ||
242 | if ( rec->endDate().isValid() ) { // 15 + 16 | 242 | if ( rec->endDate().isValid() ) { // 15 + 16 |
243 | list.append( "1" ); | 243 | list.append( "1" ); |
244 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 244 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
245 | } else { | 245 | } else { |
246 | list.append( "0" ); | 246 | list.append( "0" ); |
247 | list.append( "20991231T000000" ); | 247 | list.append( "20991231T000000" ); |
248 | } | 248 | } |
249 | 249 | ||
250 | } | 250 | } |
251 | attList << list.join(""); | 251 | attList << list.join(""); |
252 | attList << event->categoriesStr(); | 252 | attList << event->categoriesStr(); |
253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); | 253 | //qDebug("csum cat %s", event->categoriesStr().latin1()); |
254 | 254 | ||
255 | attList << event->secrecyStr(); | 255 | attList << event->secrecyStr(); |
256 | return PhoneFormat::getCsum(attList ); | 256 | return PhoneFormat::getCsum(attList ); |
257 | } | 257 | } |
258 | ulong PhoneFormat::getCsum( const QStringList & attList) | 258 | ulong PhoneFormat::getCsum( const QStringList & attList) |
259 | { | 259 | { |
260 | int max = attList.count(); | 260 | int max = attList.count(); |
261 | ulong cSum = 0; | 261 | ulong cSum = 0; |
262 | int j,k,i; | 262 | int j,k,i; |
263 | int add; | 263 | int add; |
264 | for ( i = 0; i < max ; ++i ) { | 264 | for ( i = 0; i < max ; ++i ) { |
265 | QString s = attList[i]; | 265 | QString s = attList[i]; |
266 | if ( ! s.isEmpty() ){ | 266 | if ( ! s.isEmpty() ){ |
267 | j = s.length(); | 267 | j = s.length(); |
268 | for ( k = 0; k < j; ++k ) { | 268 | for ( k = 0; k < j; ++k ) { |
269 | int mul = k +1; | 269 | int mul = k +1; |
270 | add = s[k].unicode (); | 270 | add = s[k].unicode (); |
271 | if ( k < 16 ) | 271 | if ( k < 16 ) |
272 | mul = mul * mul; | 272 | mul = mul * mul; |
273 | int ii = i+1; | 273 | int ii = i+1; |
274 | add = add * mul *ii*ii*ii; | 274 | add = add * mul *ii*ii*ii; |
275 | cSum += add; | 275 | cSum += add; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | } | 279 | } |
280 | //QString dump = attList.join(","); | 280 | //QString dump = attList.join(","); |
281 | //qDebug("csum: %d %s", cSum,dump.latin1()); | 281 | //qDebug("csum: %d %s", cSum,dump.latin1()); |
282 | 282 | ||
283 | return cSum; | 283 | return cSum; |
284 | 284 | ||
285 | } | 285 | } |
286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 286 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
287 | #include <stdlib.h> | 287 | #include <stdlib.h> |
288 | #define DEBUGMODE false | 288 | #define DEBUGMODE false |
289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 289 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
290 | { | 290 | { |
291 | 291 | ||
292 | QString fileName; | 292 | QString fileName; |
293 | #ifdef _WIN32_ | 293 | #ifdef DESKTOP_VERSION |
294 | fileName = locateLocal("tmp", "phonefile.vcs"); | 294 | fileName = locateLocal("tmp", "phonefile.vcs"); |
295 | #else | 295 | #else |
296 | fileName = "/tmp/phonefile.vcs"; | 296 | fileName = "/tmp/phonefile.vcs"; |
297 | #endif | 297 | #endif |
298 | QString command; | 298 | QString command; |
299 | if ( ! PhoneAccess::readFromPhone( fileName )) { | 299 | if ( ! PhoneAccess::readFromPhone( fileName )) { |
300 | return false; | 300 | return false; |
301 | } | 301 | } |
302 | VCalFormat vfload; | 302 | VCalFormat vfload; |
303 | vfload.setLocalTime ( true ); | 303 | vfload.setLocalTime ( true ); |
304 | qDebug("loading file ..."); | 304 | qDebug("loading file ..."); |
305 | 305 | ||
306 | if ( ! vfload.load( calendar, fileName ) ) | 306 | if ( ! vfload.load( calendar, fileName ) ) |
307 | return false; | 307 | return false; |
308 | QPtrList<Event> er = calendar->rawEvents(); | 308 | QPtrList<Event> er = calendar->rawEvents(); |
309 | Event* ev = er.first(); | 309 | Event* ev = er.first(); |
310 | qDebug("reading events... "); | 310 | qDebug("reading events... "); |
311 | while ( ev ) { | 311 | while ( ev ) { |
312 | QStringList cat = ev->categories(); | 312 | QStringList cat = ev->categories(); |
313 | if ( cat.contains( "MeetingDEF" )) { | 313 | if ( cat.contains( "MeetingDEF" )) { |
314 | ev->setCategories( QStringList() ); | 314 | ev->setCategories( QStringList() ); |
315 | } else | 315 | } else |
316 | if ( cat.contains( "Birthday" )) { | 316 | if ( cat.contains( "Birthday" )) { |
317 | ev->setFloats( true ); | 317 | ev->setFloats( true ); |
318 | QDate da = ev->dtStart().date(); | 318 | QDate da = ev->dtStart().date(); |
319 | ev->setDtStart( QDateTime( da) ); | 319 | ev->setDtStart( QDateTime( da) ); |
320 | ev->setDtEnd( QDateTime( da.addDays(1)) ); | 320 | ev->setDtEnd( QDateTime( da.addDays(1)) ); |
321 | 321 | ||
322 | } | 322 | } |
323 | uint cSum; | 323 | uint cSum; |
324 | cSum = PhoneFormat::getCsumEvent( ev ); | 324 | cSum = PhoneFormat::getCsumEvent( ev ); |
325 | int id = ev->pilotId(); | 325 | int id = ev->pilotId(); |
326 | Event *event; | 326 | Event *event; |
327 | event = existingCal->event( mProfileName ,QString::number( id ) ); | 327 | event = existingCal->event( mProfileName ,QString::number( id ) ); |
328 | if ( event ) { | 328 | if ( event ) { |
329 | event = (Event*)event->clone(); | 329 | event = (Event*)event->clone(); |
330 | copyEvent( event, ev ); | 330 | copyEvent( event, ev ); |
331 | calendar->deleteEvent( ev ); | 331 | calendar->deleteEvent( ev ); |
332 | calendar->addEvent( event); | 332 | calendar->addEvent( event); |
333 | } | 333 | } |
334 | else | 334 | else |
335 | event = ev; | 335 | event = ev; |
336 | event->setCsum( mProfileName, QString::number( cSum )); | 336 | event->setCsum( mProfileName, QString::number( cSum )); |
337 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 337 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
338 | event->setID( mProfileName,QString::number( id ) ); | 338 | event->setID( mProfileName,QString::number( id ) ); |
339 | ev = er.next(); | 339 | ev = er.next(); |
340 | } | 340 | } |
341 | { | 341 | { |
342 | qDebug("reading todos... "); | 342 | qDebug("reading todos... "); |
343 | QPtrList<Todo> tr = calendar->rawTodos(); | 343 | QPtrList<Todo> tr = calendar->rawTodos(); |
344 | Todo* ev = tr.first(); | 344 | Todo* ev = tr.first(); |
345 | while ( ev ) { | 345 | while ( ev ) { |
346 | 346 | ||
347 | QStringList cat = ev->categories(); | 347 | QStringList cat = ev->categories(); |
348 | if ( cat.contains( "MeetingDEF" )) { | 348 | if ( cat.contains( "MeetingDEF" )) { |
349 | ev->setCategories( QStringList() ); | 349 | ev->setCategories( QStringList() ); |
350 | } | 350 | } |
351 | int id = ev->pilotId(); | 351 | int id = ev->pilotId(); |
352 | uint cSum; | 352 | uint cSum; |
353 | cSum = PhoneFormat::getCsumTodo( ev ); | 353 | cSum = PhoneFormat::getCsumTodo( ev ); |
354 | Todo *event; | 354 | Todo *event; |
355 | event = existingCal->todo( mProfileName ,QString::number( id ) ); | 355 | event = existingCal->todo( mProfileName ,QString::number( id ) ); |
356 | if ( event ) { | 356 | if ( event ) { |
357 | //qDebug("copy todo %s ", event->summary().latin1()); | 357 | //qDebug("copy todo %s ", event->summary().latin1()); |
358 | 358 | ||
359 | event = (Todo*)event->clone(); | 359 | event = (Todo*)event->clone(); |
360 | copyTodo( event, ev ); | 360 | copyTodo( event, ev ); |
361 | calendar->deleteTodo( ev ); | 361 | calendar->deleteTodo( ev ); |
362 | calendar->addTodo( event); | 362 | calendar->addTodo( event); |
363 | } | 363 | } |
364 | else | 364 | else |
365 | event = ev; | 365 | event = ev; |
366 | event->setCsum( mProfileName, QString::number( cSum )); | 366 | event->setCsum( mProfileName, QString::number( cSum )); |
367 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 367 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
368 | event->setID( mProfileName,QString::number( id ) ); | 368 | event->setID( mProfileName,QString::number( id ) ); |
369 | ev = tr.next(); | 369 | ev = tr.next(); |
370 | } | 370 | } |
371 | } | 371 | } |
372 | return true; | 372 | return true; |
373 | } | 373 | } |
374 | void PhoneFormat::copyEvent( Event* to, Event* from ) | 374 | void PhoneFormat::copyEvent( Event* to, Event* from ) |
375 | { | 375 | { |
376 | if ( from->dtStart().isValid() ) | 376 | if ( from->dtStart().isValid() ) |
377 | to->setDtStart( from->dtStart() ); | 377 | to->setDtStart( from->dtStart() ); |
378 | if ( from->dtEnd().isValid() ) | 378 | if ( from->dtEnd().isValid() ) |
379 | to->setDtEnd( from->dtEnd() ); | 379 | to->setDtEnd( from->dtEnd() ); |
380 | if ( !from->location().isEmpty() ) | 380 | if ( !from->location().isEmpty() ) |
381 | to->setLocation( from->location() ); | 381 | to->setLocation( from->location() ); |
382 | if ( !from->description().isEmpty() ) | 382 | if ( !from->description().isEmpty() ) |
383 | to->setDescription( from->description() ); | 383 | to->setDescription( from->description() ); |
384 | if ( !from->summary().isEmpty() ) | 384 | if ( !from->summary().isEmpty() ) |
385 | to->setSummary( from->summary() ); | 385 | to->setSummary( from->summary() ); |
386 | 386 | ||
387 | if ( from->alarms().count() ) { | 387 | if ( from->alarms().count() ) { |
388 | to->clearAlarms(); | 388 | to->clearAlarms(); |
389 | Alarm *a = from->alarms().first(); | 389 | Alarm *a = from->alarms().first(); |
390 | Alarm *b = to->newAlarm( ); | 390 | Alarm *b = to->newAlarm( ); |
391 | b->setEnabled( a->enabled() ); | 391 | b->setEnabled( a->enabled() ); |
392 | b->setStartOffset(Duration( a->offset() ) ); | 392 | b->setStartOffset(Duration( a->offset() ) ); |
393 | 393 | ||
394 | } | 394 | } |
395 | QStringList cat = to->categories(); | 395 | QStringList cat = to->categories(); |
396 | QStringList catFrom = from->categories(); | 396 | QStringList catFrom = from->categories(); |
397 | QString nCat; | 397 | QString nCat; |
398 | int iii; | 398 | int iii; |
399 | for ( iii = 0; iii < catFrom.count();++iii ) { | 399 | for ( iii = 0; iii < catFrom.count();++iii ) { |
400 | nCat = catFrom[iii]; | 400 | nCat = catFrom[iii]; |
401 | if ( !nCat.isEmpty() ) | 401 | if ( !nCat.isEmpty() ) |
402 | if ( !cat.contains( nCat )) { | 402 | if ( !cat.contains( nCat )) { |
403 | cat << nCat; | 403 | cat << nCat; |
404 | } | 404 | } |
405 | } | 405 | } |
406 | to->setCategories( cat ); | 406 | to->setCategories( cat ); |
407 | if ( from->doesRecur() ) { | 407 | if ( from->doesRecur() ) { |
408 | Recurrence * r = new Recurrence( *from->recurrence(),to); | 408 | Recurrence * r = new Recurrence( *from->recurrence(),to); |
409 | to->setRecurrence( r ) ; | 409 | to->setRecurrence( r ) ; |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | } | 413 | } |
414 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) | 414 | void PhoneFormat::copyTodo( Todo* to, Todo* from ) |
415 | { | 415 | { |
416 | if ( from->hasStartDate() ) { | 416 | if ( from->hasStartDate() ) { |
417 | to->setHasStartDate( true ); | 417 | to->setHasStartDate( true ); |
418 | to->setDtStart( from->dtStart() ); | 418 | to->setDtStart( from->dtStart() ); |
419 | } | 419 | } |
420 | if ( from->hasDueDate() ){ | 420 | if ( from->hasDueDate() ){ |
421 | to->setHasDueDate( true ); | 421 | to->setHasDueDate( true ); |
422 | to->setDtDue( from->dtDue() ); | 422 | to->setDtDue( from->dtDue() ); |
423 | } | 423 | } |
424 | if ( !from->location().isEmpty() ) | 424 | if ( !from->location().isEmpty() ) |
425 | to->setLocation( from->location() ); | 425 | to->setLocation( from->location() ); |
426 | if ( !from->description().isEmpty() ) | 426 | if ( !from->description().isEmpty() ) |
427 | to->setDescription( from->description() ); | 427 | to->setDescription( from->description() ); |
428 | if ( !from->summary().isEmpty() ) | 428 | if ( !from->summary().isEmpty() ) |
429 | to->setSummary( from->summary() ); | 429 | to->setSummary( from->summary() ); |
430 | 430 | ||
431 | if ( from->alarms().count() ) { | 431 | if ( from->alarms().count() ) { |
432 | to->clearAlarms(); | 432 | to->clearAlarms(); |
433 | Alarm *a = from->alarms().first(); | 433 | Alarm *a = from->alarms().first(); |
434 | Alarm *b = to->newAlarm( ); | 434 | Alarm *b = to->newAlarm( ); |
435 | b->setEnabled( a->enabled() ); | 435 | b->setEnabled( a->enabled() ); |
436 | b->setStartOffset(Duration( a->offset() ) ); | 436 | b->setStartOffset(Duration( a->offset() ) ); |
437 | } | 437 | } |
438 | 438 | ||
439 | QStringList cat = to->categories(); | 439 | QStringList cat = to->categories(); |
440 | QStringList catFrom = from->categories(); | 440 | QStringList catFrom = from->categories(); |
441 | QString nCat; | 441 | QString nCat; |
442 | int iii; | 442 | int iii; |
443 | for ( iii = 0; iii < catFrom.count();++iii ) { | 443 | for ( iii = 0; iii < catFrom.count();++iii ) { |
444 | nCat = catFrom[iii]; | 444 | nCat = catFrom[iii]; |
445 | if ( !nCat.isEmpty() ) | 445 | if ( !nCat.isEmpty() ) |
446 | if ( !cat.contains( nCat )) { | 446 | if ( !cat.contains( nCat )) { |
447 | cat << nCat; | 447 | cat << nCat; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | to->setCategories( cat ); | 450 | to->setCategories( cat ); |
451 | if ( from->isCompleted() ) { | 451 | if ( from->isCompleted() ) { |
452 | to->setCompleted( true ); | 452 | to->setCompleted( true ); |
453 | if( from->completed().isValid() ) | 453 | if( from->completed().isValid() ) |
454 | to->setCompleted( from->completed() ); | 454 | to->setCompleted( from->completed() ); |
455 | } else { | 455 | } else { |
456 | // set percentcomplete only, if to->isCompleted() | 456 | // set percentcomplete only, if to->isCompleted() |
457 | if ( to->isCompleted() ) | 457 | if ( to->isCompleted() ) |
458 | to->setPercentComplete(from->percentComplete()); | 458 | to->setPercentComplete(from->percentComplete()); |
459 | } | 459 | } |
460 | if( to->priority() == 2 && from->priority() == 1 ) | 460 | if( to->priority() == 2 && from->priority() == 1 ) |
461 | ; //skip | 461 | ; //skip |
462 | else if (to->priority() == 4 && from->priority() == 5 ) | 462 | else if (to->priority() == 4 && from->priority() == 5 ) |
463 | ; | 463 | ; |
464 | else | 464 | else |
465 | to->setPriority(from->priority()); | 465 | to->setPriority(from->priority()); |
466 | 466 | ||
467 | } | 467 | } |
468 | #include <qcstring.h> | 468 | #include <qcstring.h> |
469 | 469 | ||
470 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) | 470 | void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) |
471 | { | 471 | { |
472 | inc->setID( mProfileName, id ); | 472 | inc->setID( mProfileName, id ); |
473 | inc->setCsum( mProfileName, csum); | 473 | inc->setCsum( mProfileName, csum); |
474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 474 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
475 | 475 | ||
476 | } | 476 | } |
477 | 477 | ||
478 | bool PhoneFormat::writeToPhone( Calendar * calendar) | 478 | bool PhoneFormat::writeToPhone( Calendar * calendar) |
479 | { | 479 | { |
480 | #ifdef _WIN32_ | 480 | #ifdef DESKTOP_VERSION |
481 | QString fileName = locateLocal("tmp", "phonefile.vcs"); | 481 | QString fileName = locateLocal("tmp", "phonefile.vcs"); |
482 | #else | 482 | #else |
483 | QString fileName = "/tmp/phonefile.vcs"; | 483 | QString fileName = "/tmp/phonefile.vcs"; |
484 | #endif | 484 | #endif |
485 | 485 | ||
486 | VCalFormat vfsave; | 486 | VCalFormat vfsave; |
487 | vfsave.setLocalTime ( true ); | 487 | vfsave.setLocalTime ( true ); |
488 | QString id = calendar->timeZoneId(); | 488 | QString id = calendar->timeZoneId(); |
489 | calendar->setLocalTime(); | 489 | calendar->setLocalTime(); |
490 | if ( ! vfsave.save( calendar, fileName ) ) | 490 | if ( ! vfsave.save( calendar, fileName ) ) |
491 | return false; | 491 | return false; |
492 | calendar->setTimeZoneId( id ); | 492 | calendar->setTimeZoneId( id ); |
493 | return PhoneAccess::writeToPhone( fileName ); | 493 | return PhoneAccess::writeToPhone( fileName ); |
494 | } | 494 | } |
495 | bool PhoneFormat::save( Calendar *calendar) | 495 | bool PhoneFormat::save( Calendar *calendar) |
496 | { | 496 | { |
497 | 497 | ||
498 | 498 | ||
499 | // 1 remove events which should be deleted | 499 | // 1 remove events which should be deleted |
500 | QPtrList<Event> er = calendar->rawEvents(); | 500 | QPtrList<Event> er = calendar->rawEvents(); |
501 | Event* ev = er.first(); | 501 | Event* ev = er.first(); |
502 | while ( ev ) { | 502 | while ( ev ) { |
503 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 503 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
504 | calendar->deleteEvent( ev ); | 504 | calendar->deleteEvent( ev ); |
505 | } else { | 505 | } else { |
506 | 506 | ||
507 | } | 507 | } |
508 | ev = er.next(); | 508 | ev = er.next(); |
509 | } | 509 | } |
510 | // 2 remove todos which should be deleted | 510 | // 2 remove todos which should be deleted |
511 | QPtrList<Todo> tl = calendar->rawTodos(); | 511 | QPtrList<Todo> tl = calendar->rawTodos(); |
512 | Todo* to = tl.first(); | 512 | Todo* to = tl.first(); |
513 | while ( to ) { | 513 | while ( to ) { |
514 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { | 514 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { |
515 | calendar->deleteTodo( to ); | 515 | calendar->deleteTodo( to ); |
516 | } else { | 516 | } else { |
517 | if ( to->isCompleted()) { | 517 | if ( to->isCompleted()) { |
518 | calendar->deleteTodo( to ); | 518 | calendar->deleteTodo( to ); |
519 | } | 519 | } |
520 | } | 520 | } |
521 | to = tl.next(); | 521 | to = tl.next(); |
522 | } | 522 | } |
523 | // 3 save file | 523 | // 3 save file |
524 | if ( !writeToPhone( calendar ) ) | 524 | if ( !writeToPhone( calendar ) ) |
525 | return false; | 525 | return false; |
526 | QLabel status ( i18n(" Opening device ..."), 0 ); | 526 | QLabel status ( i18n(" Opening device ..."), 0 ); |
527 | int w = status.sizeHint().width()+20 ; | 527 | int w = status.sizeHint().width()+20 ; |
528 | if ( w < 200 ) w = 230; | 528 | if ( w < 200 ) w = 230; |
529 | int h = status.sizeHint().height()+20 ; | 529 | int h = status.sizeHint().height()+20 ; |
530 | int dw = QApplication::desktop()->width(); | 530 | int dw = QApplication::desktop()->width(); |
531 | int dh = QApplication::desktop()->height(); | 531 | int dh = QApplication::desktop()->height(); |
532 | status.setCaption(i18n("Writing to phone...") ); | 532 | status.setCaption(i18n("Writing to phone...") ); |
533 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 533 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
534 | QString message; | 534 | QString message; |
535 | status.show(); | 535 | status.show(); |
536 | status.raise(); | 536 | status.raise(); |
537 | qApp->processEvents(); | 537 | qApp->processEvents(); |
538 | // 5 reread data | 538 | // 5 reread data |
539 | message = i18n(" Rereading all data ... "); | 539 | message = i18n(" Rereading all data ... "); |
540 | status.setText ( message ); | 540 | status.setText ( message ); |
541 | qApp->processEvents(); | 541 | qApp->processEvents(); |
542 | CalendarLocal* calendarTemp = new CalendarLocal(); | 542 | CalendarLocal* calendarTemp = new CalendarLocal(); |
543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 543 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
544 | if ( ! load( calendarTemp,calendar) ){ | 544 | if ( ! load( calendarTemp,calendar) ){ |
545 | qDebug("error reloading calendar "); | 545 | qDebug("error reloading calendar "); |
546 | delete calendarTemp; | 546 | delete calendarTemp; |
547 | return false; | 547 | return false; |
548 | } | 548 | } |
549 | // 6 compare data | 549 | // 6 compare data |
550 | 550 | ||
551 | //algo 6 compare event | 551 | //algo 6 compare event |
552 | er = calendar->rawEvents(); | 552 | er = calendar->rawEvents(); |
553 | ev = er.first(); | 553 | ev = er.first(); |
554 | message = i18n(" Comparing event # "); | 554 | message = i18n(" Comparing event # "); |
555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 555 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
556 | Event* ev1; | 556 | Event* ev1; |
557 | int procCount = 0; | 557 | int procCount = 0; |
558 | while ( ev ) { | 558 | while ( ev ) { |
559 | //qDebug("event new ID %s",ev->summary().latin1()); | 559 | //qDebug("event new ID %s",ev->summary().latin1()); |
560 | status.setText ( message + QString::number ( ++procCount ) ); | 560 | status.setText ( message + QString::number ( ++procCount ) ); |
561 | qApp->processEvents(); | 561 | qApp->processEvents(); |
562 | ev1 = er1.first(); | 562 | ev1 = er1.first(); |
563 | while ( ev1 ) { | 563 | while ( ev1 ) { |
564 | if ( ev->contains( ev1 ) ) { | 564 | if ( ev->contains( ev1 ) ) { |
565 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); | 565 | afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); |
566 | er1.remove( ev1 ); | 566 | er1.remove( ev1 ); |
567 | break; | 567 | break; |
568 | } | 568 | } |
569 | ev1 = er1.next(); | 569 | ev1 = er1.next(); |
570 | } | 570 | } |
571 | if ( ! ev1 ) { | 571 | if ( ! ev1 ) { |
572 | // ev->removeID(mProfileName); | 572 | // ev->removeID(mProfileName); |
573 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 573 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
574 | } | 574 | } |
575 | 575 | ||
576 | 576 | ||
577 | ev = er.next(); | 577 | ev = er.next(); |
578 | } | 578 | } |
579 | //algo 6 compare todo | 579 | //algo 6 compare todo |
580 | tl = calendar->rawTodos(); | 580 | tl = calendar->rawTodos(); |
581 | to = tl.first(); | 581 | to = tl.first(); |
582 | procCount = 0; | 582 | procCount = 0; |
583 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 583 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
584 | Todo* to1 ; | 584 | Todo* to1 ; |
585 | message = i18n(" Comparing todo # "); | 585 | message = i18n(" Comparing todo # "); |
586 | while ( to ) { | 586 | while ( to ) { |
587 | status.setText ( message + QString::number ( ++procCount ) ); | 587 | status.setText ( message + QString::number ( ++procCount ) ); |
588 | qApp->processEvents(); | 588 | qApp->processEvents(); |
589 | Todo* to1 = tl1.first(); | 589 | Todo* to1 = tl1.first(); |
590 | while ( to1 ) { | 590 | while ( to1 ) { |
591 | if ( to->contains( to1 ) ) { | 591 | if ( to->contains( to1 ) ) { |
592 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); | 592 | afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); |
593 | tl1.remove( to1 ); | 593 | tl1.remove( to1 ); |
594 | break; | 594 | break; |
595 | } | 595 | } |
596 | to1 = tl1.next(); | 596 | to1 = tl1.next(); |
597 | } | 597 | } |
598 | if ( ! to1 ) { | 598 | if ( ! to1 ) { |
599 | //to->removeID(mProfileName); | 599 | //to->removeID(mProfileName); |
600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 600 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
601 | } | 601 | } |
602 | 602 | ||
603 | to = tl.next(); | 603 | to = tl.next(); |
604 | } | 604 | } |
605 | delete calendarTemp; | 605 | delete calendarTemp; |
606 | return true; | 606 | return true; |
607 | 607 | ||
608 | 608 | ||
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | 612 | ||
613 | QString PhoneFormat::toString( Calendar * ) | 613 | QString PhoneFormat::toString( Calendar * ) |
614 | { | 614 | { |
615 | return QString::null; | 615 | return QString::null; |
616 | } | 616 | } |
617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 617 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
618 | { | 618 | { |
619 | return false; | 619 | return false; |
620 | } | 620 | } |
@@ -1 +1 @@ | |||
version = "1.9.8"; | version = "1.9.9"; | ||