summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-01 13:59:52 (UTC)
committer zautrix <zautrix>2004-08-01 13:59:52 (UTC)
commit43d6cf3619675856333d82ae2fcad6ce81d824b8 (patch) (unidiff)
tree40629720fce9e0840fc4ab50ab1ef746a7c07375
parent47a3a79ddde4ab63d34ddb0ffaa92d65f04de8ad (diff)
downloadkdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.zip
kdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.tar.gz
kdepimpi-43d6cf3619675856333d82ae2fcad6ce81d824b8.tar.bz2
fixed sync config
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp1
-rw-r--r--korganizer/mainwindow.cpp4
-rw-r--r--libkdepim/ksyncprefsdialog.cpp5
3 files changed, 7 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 387b751..cfc6b10 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -436,513 +436,512 @@ void CalendarView::init()
436 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
437 437
438 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
441 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
442 mDateFrame->hide(); 442 mDateFrame->hide();
443 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
445 445
446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
447 447
448 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
449 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
450 450
451 mFlagEditDescription = false; 451 mFlagEditDescription = false;
452 452
453 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
454 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
455 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463} 463}
464 464
465 465
466CalendarView::~CalendarView() 466CalendarView::~CalendarView()
467{ 467{
468 // kdDebug() << "~CalendarView()" << endl; 468 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() "); 469 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager; 470 delete mDialogManager;
471 delete mViewManager; 471 delete mViewManager;
472 delete mStorage; 472 delete mStorage;
473 delete mDateFrame ; 473 delete mDateFrame ;
474 delete beamDialog; 474 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl; 475 //kdDebug() << "~CalendarView() done" << endl;
476} 476}
477void CalendarView::timerAlarm() 477void CalendarView::timerAlarm()
478{ 478{
479 //qDebug("CalendarView::timerAlarm() "); 479 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification ); 480 computeAlarm(mAlarmNotification );
481} 481}
482 482
483void CalendarView::suspendAlarm() 483void CalendarView::suspendAlarm()
484{ 484{
485 //qDebug(" CalendarView::suspendAlarm() "); 485 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification ); 486 computeAlarm(mSuspendAlarmNotification );
487 487
488} 488}
489 489
490void CalendarView::startAlarm( QString mess , QString filename) 490void CalendarView::startAlarm( QString mess , QString filename)
491{ 491{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 494
495} 495}
496 496
497void CalendarView::checkNextTimerAlarm() 497void CalendarView::checkNextTimerAlarm()
498{ 498{
499 mCalendar->checkAlarmForIncidence( 0, true ); 499 mCalendar->checkAlarmForIncidence( 0, true );
500} 500}
501 501
502void CalendarView::computeAlarm( QString msg ) 502void CalendarView::computeAlarm( QString msg )
503{ 503{
504 504
505 QString mess = msg; 505 QString mess = msg;
506 QString mAlarmMessage = mess.mid( 9 ); 506 QString mAlarmMessage = mess.mid( 9 );
507 QString filename = MainWindow::resourcePath(); 507 QString filename = MainWindow::resourcePath();
508 filename += "koalarm.wav"; 508 filename += "koalarm.wav";
509 QString tempfilename; 509 QString tempfilename;
510 if ( mess.left( 13 ) == "suspend_alarm") { 510 if ( mess.left( 13 ) == "suspend_alarm") {
511 bool error = false; 511 bool error = false;
512 int len = mess.mid( 13 ).find("+++"); 512 int len = mess.mid( 13 ).find("+++");
513 if ( len < 2 ) 513 if ( len < 2 )
514 error = true; 514 error = true;
515 else { 515 else {
516 tempfilename = mess.mid( 13, len ); 516 tempfilename = mess.mid( 13, len );
517 if ( !QFile::exists( tempfilename ) ) 517 if ( !QFile::exists( tempfilename ) )
518 error = true; 518 error = true;
519 } 519 }
520 if ( ! error ) { 520 if ( ! error ) {
521 filename = tempfilename; 521 filename = tempfilename;
522 } 522 }
523 mAlarmMessage = mess.mid( 13+len+3 ); 523 mAlarmMessage = mess.mid( 13+len+3 );
524 //qDebug("suspend file %s ",tempfilename.latin1() ); 524 //qDebug("suspend file %s ",tempfilename.latin1() );
525 startAlarm( mAlarmMessage, filename); 525 startAlarm( mAlarmMessage, filename);
526 return; 526 return;
527 } 527 }
528 if ( mess.left( 11 ) == "timer_alarm") { 528 if ( mess.left( 11 ) == "timer_alarm") {
529 //mTimerTime = 0; 529 //mTimerTime = 0;
530 startAlarm( mess.mid( 11 ), filename ); 530 startAlarm( mess.mid( 11 ), filename );
531 return; 531 return;
532 } 532 }
533 if ( mess.left( 10 ) == "proc_alarm") { 533 if ( mess.left( 10 ) == "proc_alarm") {
534 bool error = false; 534 bool error = false;
535 int len = mess.mid( 10 ).find("+++"); 535 int len = mess.mid( 10 ).find("+++");
536 if ( len < 2 ) 536 if ( len < 2 )
537 error = true; 537 error = true;
538 else { 538 else {
539 tempfilename = mess.mid( 10, len ); 539 tempfilename = mess.mid( 10, len );
540 if ( !QFile::exists( tempfilename ) ) 540 if ( !QFile::exists( tempfilename ) )
541 error = true; 541 error = true;
542 } 542 }
543 if ( error ) { 543 if ( error ) {
544 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 544 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
545 mAlarmMessage += mess.mid( 10+len+3+9 ); 545 mAlarmMessage += mess.mid( 10+len+3+9 );
546 } else { 546 } else {
547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
548 //qDebug("-----system command %s ",tempfilename.latin1() ); 548 //qDebug("-----system command %s ",tempfilename.latin1() );
549#ifndef _WIN32_ 549#ifndef _WIN32_
550 if ( vfork () == 0 ) { 550 if ( vfork () == 0 ) {
551 execl ( tempfilename.latin1(), 0 ); 551 execl ( tempfilename.latin1(), 0 );
552 return; 552 return;
553 } 553 }
554#else 554#else
555 QProcess* p = new QProcess(); 555 QProcess* p = new QProcess();
556 p->addArgument( tempfilename.latin1() ); 556 p->addArgument( tempfilename.latin1() );
557 p->start(); 557 p->start();
558 return; 558 return;
559#endif 559#endif
560 560
561 return; 561 return;
562 } 562 }
563 563
564 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 564 //qDebug("+++++++system command %s ",tempfilename.latin1() );
565 } 565 }
566 if ( mess.left( 11 ) == "audio_alarm") { 566 if ( mess.left( 11 ) == "audio_alarm") {
567 bool error = false; 567 bool error = false;
568 int len = mess.mid( 11 ).find("+++"); 568 int len = mess.mid( 11 ).find("+++");
569 if ( len < 2 ) 569 if ( len < 2 )
570 error = true; 570 error = true;
571 else { 571 else {
572 tempfilename = mess.mid( 11, len ); 572 tempfilename = mess.mid( 11, len );
573 if ( !QFile::exists( tempfilename ) ) 573 if ( !QFile::exists( tempfilename ) )
574 error = true; 574 error = true;
575 } 575 }
576 if ( ! error ) { 576 if ( ! error ) {
577 filename = tempfilename; 577 filename = tempfilename;
578 } 578 }
579 mAlarmMessage = mess.mid( 11+len+3+9 ); 579 mAlarmMessage = mess.mid( 11+len+3+9 );
580 //qDebug("audio file command %s ",tempfilename.latin1() ); 580 //qDebug("audio file command %s ",tempfilename.latin1() );
581 } 581 }
582 if ( mess.left( 9 ) == "cal_alarm") { 582 if ( mess.left( 9 ) == "cal_alarm") {
583 mAlarmMessage = mess.mid( 9 ) ; 583 mAlarmMessage = mess.mid( 9 ) ;
584 } 584 }
585 585
586 startAlarm( mAlarmMessage, filename ); 586 startAlarm( mAlarmMessage, filename );
587 587
588 588
589} 589}
590 590
591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
592{ 592{
593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
594 594
595 mSuspendAlarmNotification = noti; 595 mSuspendAlarmNotification = noti;
596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
598 mSuspendTimer->start( ms , true ); 598 mSuspendTimer->start( ms , true );
599 599
600} 600}
601 601
602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
603{ 603{
604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
606#ifndef DESKTOP_VERSION 606#ifndef DESKTOP_VERSION
607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
608#endif 608#endif
609 return; 609 return;
610 } 610 }
611 int maxSec; 611 int maxSec;
612 //maxSec = 5; //testing only 612 //maxSec = 5; //testing only
613 maxSec = 86400+3600; // one day+1hour 613 maxSec = 86400+3600; // one day+1hour
614 mAlarmNotification = noti; 614 mAlarmNotification = noti;
615 int sec = QDateTime::currentDateTime().secsTo( qdt ); 615 int sec = QDateTime::currentDateTime().secsTo( qdt );
616 if ( sec > maxSec ) { 616 if ( sec > maxSec ) {
617 mRecheckAlarmTimer->start( maxSec * 1000 ); 617 mRecheckAlarmTimer->start( maxSec * 1000 );
618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
619 return; 619 return;
620 } else { 620 } else {
621 mRecheckAlarmTimer->stop(); 621 mRecheckAlarmTimer->stop();
622 } 622 }
623 //qDebug("Alarm timer started with secs: %d ", sec); 623 //qDebug("Alarm timer started with secs: %d ", sec);
624 mAlarmTimer->start( sec *1000 , true ); 624 mAlarmTimer->start( sec *1000 , true );
625 625
626} 626}
627// called by mRecheckAlarmTimer to get next alarm 627// called by mRecheckAlarmTimer to get next alarm
628// we need this, because a QTimer has only a max range of 25 days 628// we need this, because a QTimer has only a max range of 25 days
629void CalendarView::recheckTimerAlarm() 629void CalendarView::recheckTimerAlarm()
630{ 630{
631 mAlarmTimer->stop(); 631 mAlarmTimer->stop();
632 mRecheckAlarmTimer->stop(); 632 mRecheckAlarmTimer->stop();
633 mCalendar->checkAlarmForIncidence( 0, true ); 633 mCalendar->checkAlarmForIncidence( 0, true );
634} 634}
635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
636{ 636{
637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
639#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
641#endif 641#endif
642 return; 642 return;
643 } 643 }
644 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
645} 645}
646void CalendarView::selectWeekNum ( int num ) 646void CalendarView::selectWeekNum ( int num )
647{ 647{
648 dateNavigator()->selectWeek( num ); 648 dateNavigator()->selectWeek( num );
649 mViewManager->showWeekView(); 649 mViewManager->showWeekView();
650} 650}
651KOViewManager *CalendarView::viewManager() 651KOViewManager *CalendarView::viewManager()
652{ 652{
653 return mViewManager; 653 return mViewManager;
654} 654}
655 655
656KODialogManager *CalendarView::dialogManager() 656KODialogManager *CalendarView::dialogManager()
657{ 657{
658 return mDialogManager; 658 return mDialogManager;
659} 659}
660 660
661QDate CalendarView::startDate() 661QDate CalendarView::startDate()
662{ 662{
663 DateList dates = mNavigator->selectedDates(); 663 DateList dates = mNavigator->selectedDates();
664 664
665 return dates.first(); 665 return dates.first();
666} 666}
667 667
668QDate CalendarView::endDate() 668QDate CalendarView::endDate()
669{ 669{
670 DateList dates = mNavigator->selectedDates(); 670 DateList dates = mNavigator->selectedDates();
671 671
672 return dates.last(); 672 return dates.last();
673} 673}
674 674
675 675
676void CalendarView::createPrinter() 676void CalendarView::createPrinter()
677{ 677{
678#ifndef KORG_NOPRINTER 678#ifndef KORG_NOPRINTER
679 if (!mCalPrinter) { 679 if (!mCalPrinter) {
680 mCalPrinter = new CalPrinter(this, mCalendar); 680 mCalPrinter = new CalPrinter(this, mCalendar);
681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
682 } 682 }
683#endif 683#endif
684} 684}
685 685
686void CalendarView::confSync() 686void CalendarView::confSync()
687{ 687{
688 static KSyncPrefsDialog* sp = 0; 688 static KSyncPrefsDialog* sp = 0;
689 if ( ! sp ) { 689 if ( ! sp ) {
690 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 690 sp = new KSyncPrefsDialog( this, "syncprefs", true );
691 } 691 }
692 sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName );
693 sp->usrReadConfig(); 692 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 693#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 694 sp->showMaximized();
696#else 695#else
697 sp->show(); 696 sp->show();
698#endif 697#endif
699 sp->exec(); 698 sp->exec();
700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
702} 701}
703 702
704 703
705//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
706//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
707 706
708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
714 713
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
716{ 715{
717 716
718 //void setZaurusId(int id); 717 //void setZaurusId(int id);
719 // int zaurusId() const; 718 // int zaurusId() const;
720 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
721 // int zaurusUid() const; 720 // int zaurusUid() const;
722 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
723 // int zaurusStat() const; 722 // int zaurusStat() const;
724 // 0 equal 723 // 0 equal
725 // 1 take local 724 // 1 take local
726 // 2 take remote 725 // 2 take remote
727 // 3 cancel 726 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 729 bool remCh, locCh;
731 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 730 remCh = ( remote->zaurusUid() != local->zaurusUid() );
732 locCh = ( local->lastModified() > mLastCalendarSync ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 734 //qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
737 } else { 736 } else {
738 if ( locCh ) { 737 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 740 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 742 } else {
744 //qDebug(" not loc changed "); 743 //qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 744 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 745 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 746 remote->setLastModified( lastSync.addDays( 1 ) );
748 747
749 } 748 }
750 } 749 }
751 full = true; 750 full = true;
752 if ( mode < SYNC_PREF_ASK ) 751 if ( mode < SYNC_PREF_ASK )
753 mode = SYNC_PREF_ASK; 752 mode = SYNC_PREF_ASK;
754 } else { 753 } else {
755 if ( local->lastModified() == remote->lastModified() ) 754 if ( local->lastModified() == remote->lastModified() )
756 if ( local->revision() == remote->revision() ) 755 if ( local->revision() == remote->revision() )
757 return 0; 756 return 0;
758 757
759 } 758 }
760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
761 760
762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
764 //full = true; //debug only 763 //full = true; //debug only
765 if ( full ) { 764 if ( full ) {
766 bool equ = false; 765 bool equ = false;
767 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
768 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
769 } 768 }
770 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
771 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
772 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
773 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
774 if ( equ ) { 773 if ( equ ) {
775 //qDebug("equal "); 774 //qDebug("equal ");
776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
777 local->setZaurusUid( remote->zaurusUid() ); 776 local->setZaurusUid( remote->zaurusUid() );
778 } 777 }
779 if ( mode < SYNC_PREF_FORCE_LOCAL ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
780 return 0; 779 return 0;
781 780
782 }//else //debug only 781 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 783 }
785 int result; 784 int result;
786 bool localIsNew; 785 bool localIsNew;
787 if ( full && mode < SYNC_PREF_NEWEST ) 786 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 787 mode = SYNC_PREF_ASK;
789 788
790 switch( mode ) { 789 switch( mode ) {
791 case SYNC_PREF_LOCAL: 790 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 791 if ( lastSync > remote->lastModified() )
793 return 1; 792 return 1;
794 if ( lastSync > local->lastModified() ) 793 if ( lastSync > local->lastModified() )
795 return 2; 794 return 2;
796 return 1; 795 return 1;
797 break; 796 break;
798 case SYNC_PREF_REMOTE: 797 case SYNC_PREF_REMOTE:
799 if ( lastSync > remote->lastModified() ) 798 if ( lastSync > remote->lastModified() )
800 return 1; 799 return 1;
801 if ( lastSync > local->lastModified() ) 800 if ( lastSync > local->lastModified() )
802 return 2; 801 return 2;
803 return 2; 802 return 2;
804 break; 803 break;
805 case SYNC_PREF_NEWEST: 804 case SYNC_PREF_NEWEST:
806 if ( local->lastModified() > remote->lastModified() ) 805 if ( local->lastModified() > remote->lastModified() )
807 return 1; 806 return 1;
808 else 807 else
809 return 2; 808 return 2;
810 break; 809 break;
811 case SYNC_PREF_ASK: 810 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
814 return 1; 813 return 1;
815 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
816 return 2; 815 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
819 if ( localIsNew ) 818 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
821 else 820 else
822 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 823 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
826 else 825 else
827 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 833 return result;
835 834
836 break; 835 break;
837 case SYNC_PREF_FORCE_LOCAL: 836 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 837 return 1;
839 break; 838 break;
840 case SYNC_PREF_FORCE_REMOTE: 839 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 840 return 2;
842 break; 841 break;
843 842
844 default: 843 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 844 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 845 break;
847 } 846 }
848 return 0; 847 return 0;
849} 848}
850Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
851{ 850{
852 Event* lse; 851 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
855 if (!lse) { 854 if (!lse) {
856 lse = new Event(); 855 lse = new Event();
857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
859 lse->setDtStart( mLastCalendarSync ); 858 lse->setDtStart( mLastCalendarSync );
860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
861 lse->setCategories( i18n("SyncEvent") ); 860 lse->setCategories( i18n("SyncEvent") );
862 lse->setReadOnly( true ); 861 lse->setReadOnly( true );
863 mCalendar->addEvent( lse ); 862 mCalendar->addEvent( lse );
864 } 863 }
865 864
866 return lse; 865 return lse;
867 866
868} 867}
869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
870{ 869{
871 if ( ! lastSync ) 870 if ( ! lastSync )
872 return; 871 return;
873 if ( toDelete->zaurusId() < 0 ) 872 if ( toDelete->zaurusId() < 0 )
874 return; 873 return;
875 if ( toDelete->type() == "Journal" ) 874 if ( toDelete->type() == "Journal" )
876 return; 875 return;
877 QString des = lastSync->description(); 876 QString des = lastSync->description();
878 QString pref = "e"; 877 QString pref = "e";
879 if ( toDelete->type() == "Todo" ) 878 if ( toDelete->type() == "Todo" )
880 pref = "t"; 879 pref = "t";
881 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 880 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
882 lastSync->setReadOnly( false ); 881 lastSync->setReadOnly( false );
883 lastSync->setDescription( des ); 882 lastSync->setDescription( des );
884 lastSync->setReadOnly( true ); 883 lastSync->setReadOnly( true );
885 884
886} 885}
887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
888{ 887{
889 bool syncOK = true; 888 bool syncOK = true;
890 int addedEvent = 0; 889 int addedEvent = 0;
891 int addedEventR = 0; 890 int addedEventR = 0;
892 int deletedEventR = 0; 891 int deletedEventR = 0;
893 int deletedEventL = 0; 892 int deletedEventL = 0;
894 int changedLocal = 0; 893 int changedLocal = 0;
895 int changedRemote = 0; 894 int changedRemote = 0;
896 //QPtrList<Event> el = local->rawEvents(); 895 //QPtrList<Event> el = local->rawEvents();
897 Event* eventR; 896 Event* eventR;
898 QString uid; 897 QString uid;
899 int take; 898 int take;
900 Event* eventL; 899 Event* eventL;
901 Event* eventRSync; 900 Event* eventRSync;
902 Event* eventLSync; 901 Event* eventLSync;
903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
905 bool fullDateRange = false; 904 bool fullDateRange = false;
906 mLastCalendarSync = QDateTime::currentDateTime(); 905 mLastCalendarSync = QDateTime::currentDateTime();
907 QDateTime modifiedCalendar = mLastCalendarSync;; 906 QDateTime modifiedCalendar = mLastCalendarSync;;
908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
909 if ( eventR ) { 908 if ( eventR ) {
910 eventRSync = (Event*) eventR->clone(); 909 eventRSync = (Event*) eventR->clone();
911 remote->deleteEvent(eventR ); 910 remote->deleteEvent(eventR );
912 911
913 } else { 912 } else {
914 fullDateRange = true; 913 fullDateRange = true;
915 eventRSync = new Event(); 914 eventRSync = new Event();
916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
918 eventRSync->setDtStart( mLastCalendarSync ); 917 eventRSync->setDtStart( mLastCalendarSync );
919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
920 eventRSync->setCategories( i18n("SyncEvent") ); 919 eventRSync->setCategories( i18n("SyncEvent") );
921 } 920 }
922 eventLSync = getLastSyncEvent(); 921 eventLSync = getLastSyncEvent();
923 if ( eventLSync->dtStart() == mLastCalendarSync ) 922 if ( eventLSync->dtStart() == mLastCalendarSync )
924 fullDateRange = true; 923 fullDateRange = true;
925 924
926 if ( ! fullDateRange ) { 925 if ( ! fullDateRange ) {
927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
928 927
929 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 929 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
931 fullDateRange = true; 930 fullDateRange = true;
932 } 931 }
933 } 932 }
934 if ( fullDateRange ) 933 if ( fullDateRange )
935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
936 else 935 else
937 mLastCalendarSync = eventLSync->dtStart(); 936 mLastCalendarSync = eventLSync->dtStart();
938 // for resyncing if own file has changed 937 // for resyncing if own file has changed
939 if ( mCurrentSyncDevice == "deleteaftersync" ) { 938 if ( mCurrentSyncDevice == "deleteaftersync" ) {
940 mLastCalendarSync = loadedFileVersion; 939 mLastCalendarSync = loadedFileVersion;
941 qDebug("setting mLastCalendarSync "); 940 qDebug("setting mLastCalendarSync ");
942 } 941 }
943 //qDebug("*************************** "); 942 //qDebug("*************************** ");
944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
945 QPtrList<Incidence> er = remote->rawIncidences(); 944 QPtrList<Incidence> er = remote->rawIncidences();
946 Incidence* inR = er.first(); 945 Incidence* inR = er.first();
947 Incidence* inL; 946 Incidence* inL;
948 QProgressBar bar( er.count(),0 ); 947 QProgressBar bar( er.count(),0 );
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 589ab2d..d0d1f3b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -568,525 +568,527 @@ void MainWindow::initActions()
568 // actionMenu->insertSeparator(); 568 // actionMenu->insertSeparator();
569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
570 this ); 570 this );
571 action->addTo( importMenu ); 571 action->addTo( importMenu );
572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
573 action = new QAction( "import_quick", i18n("Import last file"), 0, 573 action = new QAction( "import_quick", i18n("Import last file"), 0,
574 this ); 574 this );
575 action->addTo( importMenu ); 575 action->addTo( importMenu );
576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
577 importMenu->insertSeparator(); 577 importMenu->insertSeparator();
578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
579 this ); 579 this );
580 action->addTo( importMenu ); 580 action->addTo( importMenu );
581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
582#ifndef DESKTOP_VERSION 582#ifndef DESKTOP_VERSION
583 importMenu->insertSeparator(); 583 importMenu->insertSeparator();
584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
585 this ); 585 this );
586 action->addTo( importMenu ); 586 action->addTo( importMenu );
587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
588#else 588#else
589#ifdef _WIN32_ 589#ifdef _WIN32_
590 importMenu->insertSeparator(); 590 importMenu->insertSeparator();
591 action = new QAction( "import_ol", i18n("Import from OL"), 0, 591 action = new QAction( "import_ol", i18n("Import from OL"), 0,
592 this ); 592 this );
593 action->addTo( importMenu ); 593 action->addTo( importMenu );
594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
595#endif 595#endif
596#endif 596#endif
597 597
598 importMenu->insertSeparator(); 598 importMenu->insertSeparator();
599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
600 this ); 600 this );
601 action->addTo( importMenu ); 601 action->addTo( importMenu );
602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
603 603
604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
605 this ); 605 this );
606 action->addTo( importMenu ); 606 action->addTo( importMenu );
607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
608 608
609 importMenu->insertSeparator(); 609 importMenu->insertSeparator();
610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
611 this ); 611 this );
612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
613 importMenu->insertSeparator(); 613 importMenu->insertSeparator();
614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
615 this ); 615 this );
616 action->addTo( importMenu ); 616 action->addTo( importMenu );
617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
618#ifndef DESKTOP_VERSION 618#ifndef DESKTOP_VERSION
619 importMenu->insertSeparator(); 619 importMenu->insertSeparator();
620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
621 this ); 621 this );
622 action->addTo( importMenu ); 622 action->addTo( importMenu );
623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
624 624
625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
629#else 629#else
630 importMenu->insertSeparator(); 630 importMenu->insertSeparator();
631 icon = loadPixmap( pathString + "print" ); 631 icon = loadPixmap( pathString + "print" );
632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
633 action->addTo( importMenu ); 633 action->addTo( importMenu );
634 connect( action, SIGNAL( activated() ), 634 connect( action, SIGNAL( activated() ),
635 this, SLOT( printCal() ) ); 635 this, SLOT( printCal() ) );
636 636
637 icon = loadPixmap( pathString + "print" ); 637 icon = loadPixmap( pathString + "print" );
638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
639 action->addTo( importMenu ); 639 action->addTo( importMenu );
640 connect( action, SIGNAL( activated() ), 640 connect( action, SIGNAL( activated() ),
641 this, SLOT( printSel() ) ); 641 this, SLOT( printSel() ) );
642#endif 642#endif
643 importMenu->insertSeparator(); 643 importMenu->insertSeparator();
644 action = new QAction( "beam all", i18n("Save"), 0, 644 action = new QAction( "beam all", i18n("Save"), 0,
645 this ); 645 this );
646 action->addTo( importMenu ); 646 action->addTo( importMenu );
647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
648 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 648 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
649 this ); 649 this );
650 action->addTo( importMenu ); 650 action->addTo( importMenu );
651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
652 652
653 //menuBar->insertItem( "Configure",configureMenu ); 653 //menuBar->insertItem( "Configure",configureMenu );
654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
655 icon = loadPixmap( "korganizer/korganizer" ); 655 icon = loadPixmap( "korganizer/korganizer" );
656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
657 action->addTo( helpMenu ); 657 action->addTo( helpMenu );
658 connect( action, SIGNAL( activated() ), 658 connect( action, SIGNAL( activated() ),
659 SLOT( keyBindings() ) ); 659 SLOT( keyBindings() ) );
660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
661 action->addTo( helpMenu ); 661 action->addTo( helpMenu );
662 connect( action, SIGNAL( activated() ), 662 connect( action, SIGNAL( activated() ),
663 SLOT( features() ) ); 663 SLOT( features() ) );
664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
665 action->addTo( helpMenu ); 665 action->addTo( helpMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 SLOT( aboutAutoSaving() ) ); 667 SLOT( aboutAutoSaving() ) );
668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
669 action->addTo( helpMenu ); 669 action->addTo( helpMenu );
670 connect( action, SIGNAL( activated() ), 670 connect( action, SIGNAL( activated() ),
671 SLOT( aboutKnownBugs() ) ); 671 SLOT( aboutKnownBugs() ) );
672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
673 action->addTo( helpMenu ); 673 action->addTo( helpMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 SLOT( usertrans() ) ); 675 SLOT( usertrans() ) );
676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
677 action->addTo( helpMenu ); 677 action->addTo( helpMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 SLOT( synchowto() ) ); 679 SLOT( synchowto() ) );
680 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 680 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
681 action->addTo( helpMenu ); 681 action->addTo( helpMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 SLOT( whatsNew() ) ); 683 SLOT( whatsNew() ) );
684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
685 action->addTo( helpMenu ); 685 action->addTo( helpMenu );
686 connect( action, SIGNAL( activated() ), 686 connect( action, SIGNAL( activated() ),
687 SLOT( faq() ) ); 687 SLOT( faq() ) );
688 688
689 689
690 action = new QAction( "about", i18n("About..."), 0, this ); 690 action = new QAction( "about", i18n("About..."), 0, this );
691 action->addTo( helpMenu ); 691 action->addTo( helpMenu );
692 connect( action, SIGNAL( activated() ), 692 connect( action, SIGNAL( activated() ),
693 SLOT( about() ) ); 693 SLOT( about() ) );
694 //menuBar->insertSeparator(); 694 //menuBar->insertSeparator();
695 695
696 // ****************************************************** 696 // ******************************************************
697 // menubar icons 697 // menubar icons
698 698
699 699
700 iconToolBar->setHorizontalStretchable (true ); 700 iconToolBar->setHorizontalStretchable (true );
701 //menuBar->insertItem( iconToolBar ); 701 //menuBar->insertItem( iconToolBar );
702 //xdays_action 702 //xdays_action
703 if (p-> mShowIconNewEvent) 703 if (p-> mShowIconNewEvent)
704 ne_action->addTo( iconToolBar ); 704 ne_action->addTo( iconToolBar );
705 if (p->mShowIconNewTodo ) 705 if (p->mShowIconNewTodo )
706 nt_action->addTo( iconToolBar ); 706 nt_action->addTo( iconToolBar );
707 if (p-> mShowIconSearch) 707 if (p-> mShowIconSearch)
708 search_action->addTo( iconToolBar ); 708 search_action->addTo( iconToolBar );
709 if (p-> mShowIconNext) 709 if (p-> mShowIconNext)
710 whatsnext_action->addTo( iconToolBar ); 710 whatsnext_action->addTo( iconToolBar );
711 if (p-> mShowIconNextDays) 711 if (p-> mShowIconNextDays)
712 xdays_action->addTo( iconToolBar ); 712 xdays_action->addTo( iconToolBar );
713 if (p-> mShowIconList) 713 if (p-> mShowIconList)
714 showlist_action->addTo( iconToolBar ); 714 showlist_action->addTo( iconToolBar );
715 if (p-> mShowIconDay1) 715 if (p-> mShowIconDay1)
716 day1_action->addTo( iconToolBar ); 716 day1_action->addTo( iconToolBar );
717 if (p-> mShowIconDay5) 717 if (p-> mShowIconDay5)
718 day5_action->addTo( iconToolBar ); 718 day5_action->addTo( iconToolBar );
719 if (p-> mShowIconDay7) 719 if (p-> mShowIconDay7)
720 day7_action->addTo( iconToolBar ); 720 day7_action->addTo( iconToolBar );
721 if (p-> mShowIconMonth) 721 if (p-> mShowIconMonth)
722 month_action->addTo( iconToolBar ); 722 month_action->addTo( iconToolBar );
723 if (p-> mShowIconTodoview) 723 if (p-> mShowIconTodoview)
724 todoview_action->addTo( iconToolBar ); 724 todoview_action->addTo( iconToolBar );
725 if (p-> mShowIconJournal) 725 if (p-> mShowIconJournal)
726 viewjournal_action->addTo( iconToolBar ); 726 viewjournal_action->addTo( iconToolBar );
727 icon = loadPixmap( pathString + "2leftarrowB" ); 727 icon = loadPixmap( pathString + "2leftarrowB" );
728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
729 if (p-> mShowIconBackFast) { 729 if (p-> mShowIconBackFast) {
730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
731 connect( action, SIGNAL( activated() ), 731 connect( action, SIGNAL( activated() ),
732 mView, SLOT( goPreviousMonth() ) ); 732 mView, SLOT( goPreviousMonth() ) );
733 action->addTo( iconToolBar ); 733 action->addTo( iconToolBar );
734 } 734 }
735 icon = loadPixmap( pathString + "1leftarrowB" ); 735 icon = loadPixmap( pathString + "1leftarrowB" );
736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
737 if (p-> mShowIconBack) { 737 if (p-> mShowIconBack) {
738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
739 connect( action, SIGNAL( activated() ), 739 connect( action, SIGNAL( activated() ),
740 mView, SLOT( goPrevious() ) ); 740 mView, SLOT( goPrevious() ) );
741 action->addTo( iconToolBar ); 741 action->addTo( iconToolBar );
742 } 742 }
743 if (p-> mShowIconToday) 743 if (p-> mShowIconToday)
744 today_action->addTo( iconToolBar ); 744 today_action->addTo( iconToolBar );
745 icon = loadPixmap( pathString + "1rightarrowB" ); 745 icon = loadPixmap( pathString + "1rightarrowB" );
746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
747 if (p-> mShowIconForward) { 747 if (p-> mShowIconForward) {
748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
749 connect( action, SIGNAL( activated() ), 749 connect( action, SIGNAL( activated() ),
750 mView, SLOT( goNext() ) ); 750 mView, SLOT( goNext() ) );
751 action->addTo( iconToolBar ); 751 action->addTo( iconToolBar );
752 } 752 }
753 icon = loadPixmap( pathString + "2rightarrowB" ); 753 icon = loadPixmap( pathString + "2rightarrowB" );
754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
755 if (p-> mShowIconForwardFast) { 755 if (p-> mShowIconForwardFast) {
756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
757 connect( action, SIGNAL( activated() ), 757 connect( action, SIGNAL( activated() ),
758 mView, SLOT( goNextMonth() ) ); 758 mView, SLOT( goNextMonth() ) );
759 action->addTo( iconToolBar ); 759 action->addTo( iconToolBar );
760 } 760 }
761 761
762 762
763 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 763 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
764 764
765 if (p-> mShowIconNewEvent) 765 if (p-> mShowIconNewEvent)
766 configureToolBarMenu->setItemChecked( 10, true ); 766 configureToolBarMenu->setItemChecked( 10, true );
767 if (p->mShowIconNewTodo ) 767 if (p->mShowIconNewTodo )
768 configureToolBarMenu->setItemChecked( 20, true ); 768 configureToolBarMenu->setItemChecked( 20, true );
769 if (p-> mShowIconSearch) 769 if (p-> mShowIconSearch)
770 configureToolBarMenu->setItemChecked( 120, true ); 770 configureToolBarMenu->setItemChecked( 120, true );
771 if (p-> mShowIconList) 771 if (p-> mShowIconList)
772 configureToolBarMenu->setItemChecked( 30, true ); 772 configureToolBarMenu->setItemChecked( 30, true );
773 if (p-> mShowIconDay1) 773 if (p-> mShowIconDay1)
774 configureToolBarMenu->setItemChecked( 40, true ); 774 configureToolBarMenu->setItemChecked( 40, true );
775 if (p-> mShowIconDay5) 775 if (p-> mShowIconDay5)
776 configureToolBarMenu->setItemChecked( 50, true ); 776 configureToolBarMenu->setItemChecked( 50, true );
777 if (p-> mShowIconDay7) 777 if (p-> mShowIconDay7)
778 configureToolBarMenu->setItemChecked( 60, true ); 778 configureToolBarMenu->setItemChecked( 60, true );
779 if (p-> mShowIconMonth) 779 if (p-> mShowIconMonth)
780 configureToolBarMenu->setItemChecked( 70, true ); 780 configureToolBarMenu->setItemChecked( 70, true );
781 if (p-> mShowIconTodoview) 781 if (p-> mShowIconTodoview)
782 configureToolBarMenu->setItemChecked( 80, true ); 782 configureToolBarMenu->setItemChecked( 80, true );
783 if (p-> mShowIconBackFast) 783 if (p-> mShowIconBackFast)
784 configureToolBarMenu->setItemChecked( 200, true ); 784 configureToolBarMenu->setItemChecked( 200, true );
785 if (p-> mShowIconBack) 785 if (p-> mShowIconBack)
786 configureToolBarMenu->setItemChecked( 210, true ); 786 configureToolBarMenu->setItemChecked( 210, true );
787 if (p-> mShowIconToday) 787 if (p-> mShowIconToday)
788 configureToolBarMenu->setItemChecked( 130, true ); 788 configureToolBarMenu->setItemChecked( 130, true );
789 if (p-> mShowIconForward) 789 if (p-> mShowIconForward)
790 configureToolBarMenu->setItemChecked( 220, true ); 790 configureToolBarMenu->setItemChecked( 220, true );
791 if (p-> mShowIconForwardFast) 791 if (p-> mShowIconForwardFast)
792 configureToolBarMenu->setItemChecked( 230, true ); 792 configureToolBarMenu->setItemChecked( 230, true );
793 if (p-> mShowIconNextDays) 793 if (p-> mShowIconNextDays)
794 configureToolBarMenu->setItemChecked( 100, true ); 794 configureToolBarMenu->setItemChecked( 100, true );
795 if (p-> mShowIconNext) 795 if (p-> mShowIconNext)
796 configureToolBarMenu->setItemChecked( 110, true ); 796 configureToolBarMenu->setItemChecked( 110, true );
797 if (p-> mShowIconJournal) 797 if (p-> mShowIconJournal)
798 configureToolBarMenu->setItemChecked( 90, true ); 798 configureToolBarMenu->setItemChecked( 90, true );
799 if (p-> mShowIconWhatsThis) 799 if (p-> mShowIconWhatsThis)
800 configureToolBarMenu->setItemChecked( 300, true ); 800 configureToolBarMenu->setItemChecked( 300, true );
801 801
802 QLabel* dummy = new QLabel( iconToolBar ); 802 QLabel* dummy = new QLabel( iconToolBar );
803 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 803 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
804 if (!p-> mShowIconStretch) 804 if (!p-> mShowIconStretch)
805 iconToolBar->setStretchableWidget ( dummy ) ; 805 iconToolBar->setStretchableWidget ( dummy ) ;
806 else 806 else
807 configureToolBarMenu->setItemChecked( 5, true ); 807 configureToolBarMenu->setItemChecked( 5, true );
808 if (p-> mShowIconWhatsThis) 808 if (p-> mShowIconWhatsThis)
809 QWhatsThis::whatsThisButton ( iconToolBar ); 809 QWhatsThis::whatsThisButton ( iconToolBar );
810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
811 configureAgenda( p->mHourSize ); 811 configureAgenda( p->mHourSize );
812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
813} 813}
814void MainWindow::fillSyncMenu() 814void MainWindow::fillSyncMenu()
815{ 815{
816 syncMenu->clear(); 816 syncMenu->clear();
817 syncMenu->insertItem( i18n("Configure..."), 0 ); 817 syncMenu->insertItem( i18n("Configure..."), 0 );
818 syncMenu->insertSeparator(); 818 syncMenu->insertSeparator();
819 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 819 syncMenu->insertItem( i18n("Multiple sync"), 1 );
820 syncMenu->insertSeparator(); 820 syncMenu->insertSeparator();
821 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 821 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
822 config.setGroup("SyncProfiles"); 822 config.setGroup("SyncProfiles");
823 QStringList prof = config.readListEntry("SyncProfileNames"); 823 QStringList prof = config.readListEntry("SyncProfileNames");
824 824 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
825 if ( prof.count() < 3 ) { 825 if ( prof.count() < 3 ) {
826 prof.clear(); 826 prof.clear();
827 prof << i18n("Sharp-DTM"); 827 prof << i18n("Sharp-DTM");
828 prof << i18n("Local file"); 828 prof << i18n("Local file");
829 prof << i18n("Last file"); 829 prof << i18n("Last file");
830 KSyncProfile* temp = new KSyncProfile (); 830 KSyncProfile* temp = new KSyncProfile ();
831 temp->setName( prof[0] ); 831 temp->setName( prof[0] );
832 temp->writeConfig(&config); 832 temp->writeConfig(&config);
833 temp->setName( prof[1] ); 833 temp->setName( prof[1] );
834 temp->writeConfig(&config); 834 temp->writeConfig(&config);
835 temp->setName( prof[2] ); 835 temp->setName( prof[2] );
836 temp->writeConfig(&config); 836 temp->writeConfig(&config);
837 config.setGroup("SyncProfiles");
838 config.writeEntry("SyncProfileNames",prof);
837 config.sync(); 839 config.sync();
838 delete temp; 840 delete temp;
839 } 841 }
840 KOPrefs::instance()->mSyncProfileNames = prof; 842 KOPrefs::instance()->mSyncProfileNames = prof;
841 int i; 843 int i;
842 for ( i = 0; i < prof.count(); ++i ) { 844 for ( i = 0; i < prof.count(); ++i ) {
843 845
844 syncMenu->insertItem( prof[i], 1000+i ); 846 syncMenu->insertItem( prof[i], 1000+i );
845 if ( i == 2 ) 847 if ( i == 2 )
846 syncMenu->insertSeparator(); 848 syncMenu->insertSeparator();
847 } 849 }
848 QDir app_dir; 850 QDir app_dir;
849 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 851 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
850 syncMenu->setItemEnabled( false , 1000 ); 852 syncMenu->setItemEnabled( false , 1000 );
851 } 853 }
852} 854}
853 855
854int MainWindow::ringSync() 856int MainWindow::ringSync()
855{ 857{
856 int syncedProfiles = 0; 858 int syncedProfiles = 0;
857 int i; 859 int i;
858 QTime timer; 860 QTime timer;
859 KConfig *config = KOGlobals::config(); 861 KConfig *config = KOGlobals::config();
860 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 862 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
861 KSyncProfile* temp = new KSyncProfile (); 863 KSyncProfile* temp = new KSyncProfile ();
862 KOPrefs::instance()->mAskForPreferences = false; 864 KOPrefs::instance()->mAskForPreferences = false;
863 for ( i = 0; i < syncProfileNames.count(); ++i ) { 865 for ( i = 0; i < syncProfileNames.count(); ++i ) {
864 mCurrentSyncProfile = i; 866 mCurrentSyncProfile = i;
865 temp->setName(syncProfileNames[mCurrentSyncProfile]); 867 temp->setName(syncProfileNames[mCurrentSyncProfile]);
866 temp->readConfig(config); 868 temp->readConfig(config);
867 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 869 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
868 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 870 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
869 ++syncedProfiles; 871 ++syncedProfiles;
870 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 872 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
871 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 873 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
872 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 874 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
873 KOPrefs::instance()->mShowSyncSummary = false; 875 KOPrefs::instance()->mShowSyncSummary = false;
874 mView->setSyncDevice(syncProfileNames[i] ); 876 mView->setSyncDevice(syncProfileNames[i] );
875 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 877 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
876 if ( i == 0 ) { 878 if ( i == 0 ) {
877 syncSharp(); 879 syncSharp();
878 } else { 880 } else {
879 if ( temp->getIsLocalFileSync() ) { 881 if ( temp->getIsLocalFileSync() ) {
880 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 882 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
881 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 883 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
882 } else { 884 } else {
883 syncRemote( temp, false ); 885 syncRemote( temp, false );
884 886
885 } 887 }
886 } 888 }
887 timer.start(); 889 timer.start();
888 setCaption(i18n("Multiple sync in progress ... please wait!") ); 890 setCaption(i18n("Multiple sync in progress ... please wait!") );
889 while ( timer.elapsed () < 2000 ) { 891 while ( timer.elapsed () < 2000 ) {
890 qApp->processEvents(); 892 qApp->processEvents();
891#ifndef _WIN32_ 893#ifndef _WIN32_
892 sleep (1); 894 sleep (1);
893#endif 895#endif
894 } 896 }
895 897
896 } 898 }
897 899
898 } 900 }
899 delete temp; 901 delete temp;
900 return syncedProfiles; 902 return syncedProfiles;
901} 903}
902 904
903void MainWindow::multiSync( bool askforPrefs ) 905void MainWindow::multiSync( bool askforPrefs )
904{ 906{
905 if (mBlockSaveFlag) 907 if (mBlockSaveFlag)
906 return; 908 return;
907 mBlockSaveFlag = true; 909 mBlockSaveFlag = true;
908 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 910 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
909 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 911 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
910 question, 912 question,
911 i18n("Yes"), i18n("No"), 913 i18n("Yes"), i18n("No"),
912 0, 0 ) != 0 ) { 914 0, 0 ) != 0 ) {
913 mBlockSaveFlag = false; 915 mBlockSaveFlag = false;
914 setCaption(i18n("Aborted! Nothing synced!")); 916 setCaption(i18n("Aborted! Nothing synced!"));
915 return; 917 return;
916 } 918 }
917 mView->setSyncDevice(i18n("Multiple profiles") ); 919 mView->setSyncDevice(i18n("Multiple profiles") );
918 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 920 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
919 if ( askforPrefs ) { 921 if ( askforPrefs ) {
920 mView->edit_sync_options(); 922 mView->edit_sync_options();
921 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 923 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
922 } 924 }
923 setCaption(i18n("Multiple sync started.") ); 925 setCaption(i18n("Multiple sync started.") );
924 qApp->processEvents(); 926 qApp->processEvents();
925 int num = ringSync() ; 927 int num = ringSync() ;
926 if ( num > 1 ) 928 if ( num > 1 )
927 ringSync(); 929 ringSync();
928 mBlockSaveFlag = false; 930 mBlockSaveFlag = false;
929 if ( num ) 931 if ( num )
930 save(); 932 save();
931 if ( num ) 933 if ( num )
932 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 934 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
933 else 935 else
934 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 936 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
935 return; 937 return;
936} 938}
937void MainWindow::slotSyncMenu( int action ) 939void MainWindow::slotSyncMenu( int action )
938{ 940{
939 //qDebug("syncaction %d ", action); 941 //qDebug("syncaction %d ", action);
940 if ( action == 0 ) { 942 if ( action == 0 ) {
941 943
942 confSync(); 944 confSync();
943 945
944 return; 946 return;
945 } 947 }
946 if ( action == 1 ) { 948 if ( action == 1 ) {
947 multiSync( true ); 949 multiSync( true );
948 return; 950 return;
949 } 951 }
950 952
951 if (mBlockSaveFlag) 953 if (mBlockSaveFlag)
952 return; 954 return;
953 mBlockSaveFlag = true; 955 mBlockSaveFlag = true;
954 mCurrentSyncProfile = action - 1000 ; 956 mCurrentSyncProfile = action - 1000 ;
955 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 957 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
956 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 958 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
957 KConfig *config = KOGlobals::config(); 959 KConfig *config = KOGlobals::config();
958 KSyncProfile* temp = new KSyncProfile (); 960 KSyncProfile* temp = new KSyncProfile ();
959 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 961 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
960 temp->readConfig(config); 962 temp->readConfig(config);
961 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 963 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
962 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 964 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
963 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 965 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
964 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 966 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
965 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 967 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
966 if ( action == 1000 ) { 968 if ( action == 1000 ) {
967 syncSharp(); 969 syncSharp();
968 970
969 } else if ( action == 1001 ) { 971 } else if ( action == 1001 ) {
970 syncLocalFile(); 972 syncLocalFile();
971 973
972 } else if ( action == 1002 ) { 974 } else if ( action == 1002 ) {
973 quickSyncLocalFile(); 975 quickSyncLocalFile();
974 976
975 } else if ( action >= 1003 ) { 977 } else if ( action >= 1003 ) {
976 if ( temp->getIsLocalFileSync() ) { 978 if ( temp->getIsLocalFileSync() ) {
977 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 979 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
978 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 980 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
979 } else { 981 } else {
980 syncRemote( temp ); 982 syncRemote( temp );
981 983
982 } 984 }
983 } 985 }
984 delete temp; 986 delete temp;
985 mBlockSaveFlag = false; 987 mBlockSaveFlag = false;
986} 988}
987void MainWindow::setDefaultPreferences() 989void MainWindow::setDefaultPreferences()
988{ 990{
989 KOPrefs *p = KOPrefs::instance(); 991 KOPrefs *p = KOPrefs::instance();
990 992
991 p->mCompactDialogs = true; 993 p->mCompactDialogs = true;
992 p->mConfirm = true; 994 p->mConfirm = true;
993 // p->mEnableQuickTodo = false; 995 // p->mEnableQuickTodo = false;
994} 996}
995 997
996QString MainWindow::resourcePath() 998QString MainWindow::resourcePath()
997{ 999{
998 return KGlobal::iconLoader()->iconPath(); 1000 return KGlobal::iconLoader()->iconPath();
999} 1001}
1000 1002
1001void MainWindow::displayText( QString text ,QString cap ) 1003void MainWindow::displayText( QString text ,QString cap )
1002{ 1004{
1003 QDialog dia( this, "name", true ); ; 1005 QDialog dia( this, "name", true ); ;
1004 dia.setCaption( cap ); 1006 dia.setCaption( cap );
1005 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1007 QVBoxLayout* lay = new QVBoxLayout( &dia );
1006 lay->setSpacing( 3 ); 1008 lay->setSpacing( 3 );
1007 lay->setMargin( 3 ); 1009 lay->setMargin( 3 );
1008 QTextBrowser tb ( &dia ); 1010 QTextBrowser tb ( &dia );
1009 lay->addWidget( &tb ); 1011 lay->addWidget( &tb );
1010 tb.setText( text ); 1012 tb.setText( text );
1011#ifdef DESKTOP_VERSION 1013#ifdef DESKTOP_VERSION
1012 dia.resize( 640, 480); 1014 dia.resize( 640, 480);
1013#else 1015#else
1014 dia.showMaximized(); 1016 dia.showMaximized();
1015#endif 1017#endif
1016 dia.exec(); 1018 dia.exec();
1017} 1019}
1018void MainWindow::displayFile( QString fn, QString cap ) 1020void MainWindow::displayFile( QString fn, QString cap )
1019{ 1021{
1020 QString fileName = resourcePath() + fn; 1022 QString fileName = resourcePath() + fn;
1021 QString text; 1023 QString text;
1022 QFile file( fileName ); 1024 QFile file( fileName );
1023 if (!file.open( IO_ReadOnly ) ) { 1025 if (!file.open( IO_ReadOnly ) ) {
1024 return ; 1026 return ;
1025 1027
1026 } 1028 }
1027 QTextStream ts( &file ); 1029 QTextStream ts( &file );
1028 text = ts.read(); 1030 text = ts.read();
1029 file.close(); 1031 file.close();
1030 displayText( text, cap); 1032 displayText( text, cap);
1031} 1033}
1032void MainWindow::features() 1034void MainWindow::features()
1033{ 1035{
1034 1036
1035 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1037 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1036} 1038}
1037 1039
1038void MainWindow::usertrans() 1040void MainWindow::usertrans()
1039{ 1041{
1040 1042
1041 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1043 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1042} 1044}
1043void MainWindow::synchowto() 1045void MainWindow::synchowto()
1044{ 1046{
1045 1047
1046 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1048 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1047} 1049}
1048void MainWindow::faq() 1050void MainWindow::faq()
1049{ 1051{
1050 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1052 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1051 1053
1052} 1054}
1053void MainWindow::whatsNew() 1055void MainWindow::whatsNew()
1054{ 1056{
1055 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1057 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1056 1058
1057} 1059}
1058void MainWindow::about() 1060void MainWindow::about()
1059{ 1061{
1060 QString version; 1062 QString version;
1061#include <../version> 1063#include <../version>
1062 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1064 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1063 i18n("KOrganizer/Platform-independent\n") + 1065 i18n("KOrganizer/Platform-independent\n") +
1064 "(KO/Pi) " + version + " - " + 1066 "(KO/Pi) " + version + " - " +
1065 1067
1066#ifdef DESKTOP_VERSION 1068#ifdef DESKTOP_VERSION
1067 i18n("Desktop Edition\n") + 1069 i18n("Desktop Edition\n") +
1068#else 1070#else
1069 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1071 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1070#endif 1072#endif
1071 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") ); 1073 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") );
1072} 1074}
1073void MainWindow::keyBindings() 1075void MainWindow::keyBindings()
1074{ 1076{
1075 QString cap = i18n("Key bindings KOrganizer/Pi"); 1077 QString cap = i18n("Key bindings KOrganizer/Pi");
1076 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1078 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1077 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1079 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1078 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1080 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1079 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1081 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1080 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1082 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1081 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1083 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1082 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1084 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1083 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1085 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1084 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1086 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1085 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1087 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1086 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1088 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1087 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1089 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1088 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1090 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1089 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1091 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1090 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1092 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1091 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1093 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1092 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1094 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 8d610d8..3df2a3b 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -181,288 +181,291 @@ void KSyncPrefsDialog::setupSyncAlgTab()
181 localFileWidget = new QVBox( topFrame); 181 localFileWidget = new QVBox( topFrame);
182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
183 ++iii; 183 ++iii;
184 QHBox* temphb = new QHBox( localFileWidget ); 184 QHBox* temphb = new QHBox( localFileWidget );
185 lab = new QLabel( i18n("Local file:"), temphb); 185 lab = new QLabel( i18n("Local file:"), temphb);
186 mRemoteFile = new QLineEdit(localFileWidget); 186 mRemoteFile = new QLineEdit(localFileWidget);
187 187
188 button = new QPushButton( i18n("Choose..."), temphb ); 188 button = new QPushButton( i18n("Choose..."), temphb );
189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
190 190
191 191
192 remoteFileWidget = new QVBox( topFrame); 192 remoteFileWidget = new QVBox( topFrame);
193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
194 ++iii; 194 ++iii;
195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
196 mRemotePrecommand = new QLineEdit(remoteFileWidget); 196 mRemotePrecommand = new QLineEdit(remoteFileWidget);
197 197
198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
199 mLocalTempFile = new QLineEdit(remoteFileWidget); 199 mLocalTempFile = new QLineEdit(remoteFileWidget);
200 200
201 201
202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
203 mRemotePostcommand = new QLineEdit(remoteFileWidget); 203 mRemotePostcommand = new QLineEdit(remoteFileWidget);
204 204
205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
206 temphb = new QHBox( remoteFileWidget ); 206 temphb = new QHBox( remoteFileWidget );
207 button = new QPushButton( i18n("ssh/scp"), temphb ); 207 button = new QPushButton( i18n("ssh/scp"), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
209 button = new QPushButton( i18n("ftp"), temphb ); 209 button = new QPushButton( i18n("ftp"), temphb );
210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
212 212
213 213
214} 214}
215void KSyncPrefsDialog::slotOK() 215void KSyncPrefsDialog::slotOK()
216{ 216{
217 if ( mMyMachineName->text() == "undefined" ) { 217 if ( mMyMachineName->text() == "undefined" ) {
218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
219 return; 219 return;
220 } 220 }
221 int i; 221 int i;
222 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 222 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
224 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 224 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
225 return; 225 return;
226 } 226 }
227 } 227 }
228 usrWriteConfig(); 228 usrWriteConfig();
229 QDialog::accept(); 229 QDialog::accept();
230} 230}
231void KSyncPrefsDialog::accept() 231void KSyncPrefsDialog::accept()
232{ 232{
233 slotOK(); 233 slotOK();
234} 234}
235void KSyncPrefsDialog::chooseFile() 235void KSyncPrefsDialog::chooseFile()
236{ 236{
237 QString fn = QDir::homeDirPath(); 237 QString fn = QDir::homeDirPath();
238 238
239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
240 if ( fn == "" ) 240 if ( fn == "" )
241 return; 241 return;
242 mRemoteFile->setText( fn ); 242 mRemoteFile->setText( fn );
243} 243}
244 244
245void KSyncPrefsDialog::textChanged( const QString & s ) 245void KSyncPrefsDialog::textChanged( const QString & s )
246{ 246{
247 if ( mProfileBox->count() == 0 ) 247 if ( mProfileBox->count() == 0 )
248 return; 248 return;
249 if ( currentSelection < 3 ) { 249 if ( currentSelection < 3 ) {
250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
251 mProfileBox->blockSignals( true ); 251 mProfileBox->blockSignals( true );
252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
253 mProfileBox->blockSignals( false ); 253 mProfileBox->blockSignals( false );
254 return; 254 return;
255 } 255 }
256 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 256 //qDebug("cur i %d ",mProfileBox-> currentItem () );
257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
259 prof->setName( s ); 259 prof->setName( s );
260 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 260 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
261} 261}
262void KSyncPrefsDialog::profileChanged( int item ) 262void KSyncPrefsDialog::profileChanged( int item )
263{ 263{
264 //qDebug("KSyncPrefsDialog::profileChanged %d ", item ); 264 //qDebug("KSyncPrefsDialog::profileChanged %d ", item );
265 KSyncProfile* prof; 265 KSyncProfile* prof;
266 saveProfile(); 266 saveProfile();
267 currentSelection = item; 267 currentSelection = item;
268 prof = mSyncProfiles.at(item) ; 268 prof = mSyncProfiles.at(item) ;
269 mRemotePrecommand->setText(prof->getPreSyncCommand()); 269 mRemotePrecommand->setText(prof->getPreSyncCommand());
270 mRemotePostcommand->setText(prof->getPostSyncCommand()); 270 mRemotePostcommand->setText(prof->getPostSyncCommand());
271 mLocalTempFile->setText(prof->getLocalTempFile()); 271 mLocalTempFile->setText(prof->getLocalTempFile());
272 mRemoteFile->setText(prof->getRemoteFileName()) ; 272 mRemoteFile->setText(prof->getRemoteFileName()) ;
273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
274 mAskForPreferences->setChecked( prof->getAskForPreferences()); 274 mAskForPreferences->setChecked( prof->getAskForPreferences());
275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
276 mWriteBackFile->setChecked( prof->getWriteBackFile()); 276 mWriteBackFile->setChecked( prof->getWriteBackFile());
277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
278 278
279 switch ( prof->getSyncPrefs() ) { 279 switch ( prof->getSyncPrefs() ) {
280 case 0: 280 case 0:
281 loc->setChecked( true); 281 loc->setChecked( true);
282 break; 282 break;
283 case 1: 283 case 1:
284 rem->setChecked( true ); 284 rem->setChecked( true );
285 break; 285 break;
286 case 2: 286 case 2:
287 newest->setChecked( true); 287 newest->setChecked( true);
288 break; 288 break;
289 case 3: 289 case 3:
290 ask->setChecked( true); 290 ask->setChecked( true);
291 break; 291 break;
292 case 4: 292 case 4:
293 f_loc->setChecked( true); 293 f_loc->setChecked( true);
294 break; 294 break;
295 case 5: 295 case 5:
296 f_rem->setChecked( true); 296 f_rem->setChecked( true);
297 break; 297 break;
298 case 6: 298 case 6:
299 //both->setChecked( true); 299 //both->setChecked( true);
300 break; 300 break;
301 default: 301 default:
302 break; 302 break;
303 } 303 }
304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); 305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
306 proGr->setEnabled( item > 2 ); 306 proGr->setEnabled( item > 2 );
307 if ( item < 3 ) { 307 if ( item < 3 ) {
308 localFileWidget->setEnabled(false); 308 localFileWidget->setEnabled(false);
309 remoteFileWidget->setEnabled(false); 309 remoteFileWidget->setEnabled(false);
310 310
311 } else 311 } else
312 kindChanged( prof->getIsLocalFileSync() ); 312 kindChanged( prof->getIsLocalFileSync() );
313} 313}
314 314
315void KSyncPrefsDialog::fillSSH() 315void KSyncPrefsDialog::fillSSH()
316{ 316{
317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
318 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 318 mLocalTempFile->setText("/tmp/mycalendar.ics" );
319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
320} 320}
321void KSyncPrefsDialog::fillFTP() 321void KSyncPrefsDialog::fillFTP()
322{ 322{
323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
324 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 324 mLocalTempFile->setText("/tmp/mycalendar.ics" );
325 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 325 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
326 326
327} 327}
328void KSyncPrefsDialog::kindChanged( bool b ) 328void KSyncPrefsDialog::kindChanged( bool b )
329{ 329{
330 330
331 localFileWidget->setEnabled(b); 331 localFileWidget->setEnabled(b);
332 remoteFileWidget->setEnabled(!b); 332 remoteFileWidget->setEnabled(!b);
333 333
334} 334}
335void KSyncPrefsDialog::deleteProfile() 335void KSyncPrefsDialog::deleteProfile()
336{ 336{
337 //qDebug("KSyncPrefsDialog::deleteProfile() "); 337 //qDebug("KSyncPrefsDialog::deleteProfile() ");
338 if ( currentSelection >= 0 ) { 338 if ( currentSelection >= 0 ) {
339 if ( currentSelection < 3 ) { 339 if ( currentSelection < 3 ) {
340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
341 return; 341 return;
342 } 342 }
343 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 343 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
344 mSyncProfiles.remove( temp ); 344 mSyncProfiles.remove( temp );
345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
346 insertProfiles(); 346 insertProfiles();
347 } 347 }
348} 348}
349 349
350void KSyncPrefsDialog::saveProfile() 350void KSyncPrefsDialog::saveProfile()
351{ 351{
352 KSyncProfile* prof; 352 KSyncProfile* prof;
353 if ( currentSelection >= 0 ) { 353 if ( currentSelection >= 0 ) {
354 prof = mSyncProfiles.at(currentSelection) ; 354 prof = mSyncProfiles.at(currentSelection) ;
355 prof->setPreSyncCommand( mRemotePrecommand->text()); 355 prof->setPreSyncCommand( mRemotePrecommand->text());
356 prof->setPostSyncCommand( mRemotePostcommand->text() ); 356 prof->setPostSyncCommand( mRemotePostcommand->text() );
357 prof->setLocalTempFile( mLocalTempFile->text()); 357 prof->setLocalTempFile( mLocalTempFile->text());
358 prof->setRemoteFileName( mRemoteFile->text() ); 358 prof->setRemoteFileName( mRemoteFile->text() );
359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
360 prof->setAskForPreferences( mAskForPreferences->isChecked()); 360 prof->setAskForPreferences( mAskForPreferences->isChecked());
361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
362 prof->setWriteBackFile( mWriteBackFile->isChecked()); 362 prof->setWriteBackFile( mWriteBackFile->isChecked());
363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
365 prof->setSyncPrefs( syncprefs); 365 prof->setSyncPrefs( syncprefs);
366 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 366 prof->setIsLocalFileSync( mIsLocal->isChecked() );
367 } 367 }
368 368
369} 369}
370 370
371void KSyncPrefsDialog::insertProfiles() 371void KSyncPrefsDialog::insertProfiles()
372{ 372{
373 int curItem = mProfileBox->currentItem(); 373 int curItem = mProfileBox->currentItem();
374 mProfileBox->blockSignals( true ); 374 mProfileBox->blockSignals( true );
375 mProfileBox->clear(); 375 mProfileBox->clear();
376 mProfileBox->insertStringList (mSyncProfileNames ); 376 mProfileBox->insertStringList (mSyncProfileNames );
377 int item = mSyncProfileNames.count() -1; 377 int item = mSyncProfileNames.count() -1;
378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
379 mProfileBox->setCurrentItem( curItem ); 379 mProfileBox->setCurrentItem( curItem );
380 else if ( item >= 0 ) { 380 else if ( item >= 0 ) {
381 mProfileBox->setCurrentItem( item ); 381 mProfileBox->setCurrentItem( item );
382 } 382 }
383 currentSelection = -1; 383 currentSelection = -1;
384 if ( mSyncProfileNames.count() > 0 ) { 384 if ( mSyncProfileNames.count() > 0 ) {
385 //qDebug(" profileChanged( mProfileBox->currentItem() "); 385 //qDebug(" profileChanged( mProfileBox->currentItem() ");
386 profileChanged( mProfileBox->currentItem() ); 386 profileChanged( mProfileBox->currentItem() );
387 currentSelection = mProfileBox->currentItem(); 387 currentSelection = mProfileBox->currentItem();
388 } 388 }
389 mProfileBox->blockSignals( false ); 389 mProfileBox->blockSignals( false );
390} 390}
391 391
392void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 392void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
393{ 393{
394 saveProfile(); 394 saveProfile();
395 mSyncProfiles.append( temp ); 395 mSyncProfiles.append( temp );
396 mSyncProfileNames << temp->getName(); 396 mSyncProfileNames << temp->getName();
397 insertProfiles(); 397 insertProfiles();
398 int last = mProfileBox->count() -1; 398 int last = mProfileBox->count() -1;
399 mProfileBox->blockSignals( true ); 399 mProfileBox->blockSignals( true );
400 mProfileBox->setCurrentItem( last ); 400 mProfileBox->setCurrentItem( last );
401 mProfileBox->blockSignals( false ); 401 mProfileBox->blockSignals( false );
402 profileChanged(last); 402 profileChanged(last);
403} 403}
404void KSyncPrefsDialog::newProfile() 404void KSyncPrefsDialog::newProfile()
405{ 405{
406 addProfile ( new KSyncProfile () ); 406 addProfile ( new KSyncProfile () );
407} 407}
408 408
409void KSyncPrefsDialog::cloneProfile() 409void KSyncPrefsDialog::cloneProfile()
410{ 410{
411 if ( currentSelection >= 0 ) 411 if ( currentSelection >= 0 )
412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
413 else 413 else
414 newProfile(); 414 newProfile();
415} 415}
416 416
417void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 417void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
418{ 418{
419 mMyMachineName->setText( name ); 419 mMyMachineName->setText( name );
420 420
421} 421}
422QString KSyncPrefsDialog::getLocalMachineName ( ) 422QString KSyncPrefsDialog::getLocalMachineName ( )
423{ 423{
424 return mMyMachineName->text(); 424 return mMyMachineName->text();
425} 425}
426 426
427QStringList KSyncPrefsDialog::getSyncProfileNames() 427QStringList KSyncPrefsDialog::getSyncProfileNames()
428{ 428{
429 return mSyncProfileNames; 429 return mSyncProfileNames;
430} 430}
431void KSyncPrefsDialog::usrReadConfig() 431void KSyncPrefsDialog::usrReadConfig()
432{ 432{
433 //KConfig *config = KOGlobals::config(); 433 //KConfig *config = KOGlobals::config();
434 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 434 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
435 config.setGroup("SyncProfiles"); 435 config.setGroup("SyncProfiles");
436 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 436 mSyncProfileNames =config.readListEntry("SyncProfileNames");
437 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
437 int i; 438 int i;
438 KSyncProfile* temp ; 439 KSyncProfile* temp ;
439 mSyncProfiles.clear(); 440 mSyncProfiles.clear();
440 for ( i = 0; i < mSyncProfileNames.count();++i ) { 441 for ( i = 0; i < mSyncProfileNames.count();++i ) {
441 temp = new KSyncProfile (); 442 temp = new KSyncProfile ();
442 temp->setName( mSyncProfileNames[i] ); 443 temp->setName( mSyncProfileNames[i] );
443 temp->readConfig( &config ); 444 temp->readConfig( &config );
444 mSyncProfiles.append( temp ); 445 mSyncProfiles.append( temp );
445 } 446 }
446 insertProfiles(); 447 insertProfiles();
447 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 448 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
448} 449}
449 450
450 451
451void KSyncPrefsDialog::usrWriteConfig() 452void KSyncPrefsDialog::usrWriteConfig()
452{ 453{
453 saveProfile(); 454 saveProfile();
454 if ( currentSelection >= 0 ) 455 if ( currentSelection >= 0 )
455 profileChanged(currentSelection); 456 profileChanged(currentSelection);
456 //KConfig *config = KOGlobals::config(); 457 //KConfig *config = KOGlobals::config();
457 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 458 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
458 config.setGroup("SyncProfiles"); 459 config.setGroup("SyncProfiles");
459 KSyncProfile* prof = mSyncProfiles.first(); 460 KSyncProfile* prof = mSyncProfiles.first();
460 while ( prof ) { 461 while ( prof ) {
461 prof->writeConfig(&config); 462 prof->writeConfig(&config);
462 prof = mSyncProfiles.next(); 463 prof = mSyncProfiles.next();
463 } 464 }
464 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 465 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
465 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 466 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
466 config.writeEntry("SyncProfileNames",&mSyncProfileNames); 467 config.writeEntry("SyncProfileNames",mSyncProfileNames);
468 QString name = mMyMachineName->text();
469 config.writeEntry("LocalMachineName",name);
467} 470}
468 471