summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp28
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/kosyncprefsdialog.cpp44
-rw-r--r--korganizer/kosyncprefsdialog.h4
-rw-r--r--korganizer/mainwindow.cpp21
5 files changed, 47 insertions, 52 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b543eca..c75d10e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -191,97 +191,96 @@ class KOCatPrefs : public QDialog
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201 201
202 202
203CalendarView::CalendarView( CalendarResources *calendar, 203CalendarView::CalendarView( CalendarResources *calendar,
204 QWidget *parent, const char *name ) 204 QWidget *parent, const char *name )
205 : CalendarViewBase( parent, name ), 205 : CalendarViewBase( parent, name ),
206 mCalendar( calendar ), 206 mCalendar( calendar ),
207 mResourceManager( calendar->resourceManager() ) 207 mResourceManager( calendar->resourceManager() )
208{ 208{
209 209
210 mEventEditor = 0; 210 mEventEditor = 0;
211 mTodoEditor = 0; 211 mTodoEditor = 0;
212 212
213 init(); 213 init();
214} 214}
215 215
216CalendarView::CalendarView( Calendar *calendar, 216CalendarView::CalendarView( Calendar *calendar,
217 QWidget *parent, const char *name ) 217 QWidget *parent, const char *name )
218 : CalendarViewBase( parent, name ), 218 : CalendarViewBase( parent, name ),
219 mCalendar( calendar ), 219 mCalendar( calendar ),
220 mResourceManager( 0 ) 220 mResourceManager( 0 )
221{ 221{
222 222
223 mEventEditor = 0; 223 mEventEditor = 0;
224 mTodoEditor = 0; 224 mTodoEditor = 0;
225 init();} 225 init();}
226 226
227void CalendarView::init() 227void CalendarView::init()
228{ 228{
229 beamDialog = new KOBeamPrefs(); 229 beamDialog = new KOBeamPrefs();
230 mDatePickerMode = 0; 230 mDatePickerMode = 0;
231 mCurrentSyncDevice = ""; 231 mCurrentSyncDevice = "";
232 writeLocale(); 232 writeLocale();
233 mViewManager = new KOViewManager( this ); 233 mViewManager = new KOViewManager( this );
234 mDialogManager = new KODialogManager( this ); 234 mDialogManager = new KODialogManager( this );
235 mEventViewerDialog = 0; 235 mEventViewerDialog = 0;
236 mModified = false; 236 mModified = false;
237 mReadOnly = false; 237 mReadOnly = false;
238 mSelectedIncidence = 0; 238 mSelectedIncidence = 0;
239 mSyncProfiles.setAutoDelete(true);
240 mCalPrinter = 0; 239 mCalPrinter = 0;
241 mFilters.setAutoDelete(true); 240 mFilters.setAutoDelete(true);
242 241
243 mCalendar->registerObserver( this ); 242 mCalendar->registerObserver( this );
244 // TODO: Make sure that view is updated, when calendar is changed. 243 // TODO: Make sure that view is updated, when calendar is changed.
245 244
246 mStorage = new FileStorage( mCalendar ); 245 mStorage = new FileStorage( mCalendar );
247 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 246 mNavigator = new DateNavigator( this, "datevav", mViewManager );
248 247
249 QBoxLayout *topLayout = (QBoxLayout*)layout(); 248 QBoxLayout *topLayout = (QBoxLayout*)layout();
250#ifndef KORG_NOSPLITTER 249#ifndef KORG_NOSPLITTER
251 // create the main layout frames. 250 // create the main layout frames.
252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
253 topLayout->addWidget(mPanner); 252 topLayout->addWidget(mPanner);
254 253
255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
256 "CalendarView::LeftFrame"); 255 "CalendarView::LeftFrame");
257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
258 257
259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
260 "CalendarView::DateNavigator", QDate::currentDate() ); 259 "CalendarView::DateNavigator", QDate::currentDate() );
261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
264 263
265#ifdef KORG_NORESOURCEVIEW 264#ifdef KORG_NORESOURCEVIEW
266 mResourceView = 0; 265 mResourceView = 0;
267#else 266#else
268 if ( mResourceManager ) { 267 if ( mResourceManager ) {
269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
270 mResourceView->updateView(); 269 mResourceView->updateView();
271 connect( mResourceView, SIGNAL( resourcesChanged() ), 270 connect( mResourceView, SIGNAL( resourcesChanged() ),
272 SLOT( updateView() ) ); 271 SLOT( updateView() ) );
273 } else { 272 } else {
274 mResourceView = 0; 273 mResourceView = 0;
275 } 274 }
276#endif 275#endif
277 QWidget *rightBox = new QWidget( mPanner ); 276 QWidget *rightBox = new QWidget( mPanner );
278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
279 278
280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
281 rightLayout->addWidget( mNavigatorBar ); 280 rightLayout->addWidget( mNavigatorBar );
282 281
283 mRightFrame = new QWidgetStack( rightBox ); 282 mRightFrame = new QWidgetStack( rightBox );
284 rightLayout->addWidget( mRightFrame, 1 ); 283 rightLayout->addWidget( mRightFrame, 1 );
285 284
286 mLeftFrame = mLeftSplitter; 285 mLeftFrame = mLeftSplitter;
287#else 286#else
@@ -645,104 +644,106 @@ void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
645 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
646} 645}
647void CalendarView::selectWeekNum ( int num ) 646void CalendarView::selectWeekNum ( int num )
648{ 647{
649 dateNavigator()->selectWeek( num ); 648 dateNavigator()->selectWeek( num );
650 mViewManager->showWeekView(); 649 mViewManager->showWeekView();
651} 650}
652KOViewManager *CalendarView::viewManager() 651KOViewManager *CalendarView::viewManager()
653{ 652{
654 return mViewManager; 653 return mViewManager;
655} 654}
656 655
657KODialogManager *CalendarView::dialogManager() 656KODialogManager *CalendarView::dialogManager()
658{ 657{
659 return mDialogManager; 658 return mDialogManager;
660} 659}
661 660
662QDate CalendarView::startDate() 661QDate CalendarView::startDate()
663{ 662{
664 DateList dates = mNavigator->selectedDates(); 663 DateList dates = mNavigator->selectedDates();
665 664
666 return dates.first(); 665 return dates.first();
667} 666}
668 667
669QDate CalendarView::endDate() 668QDate CalendarView::endDate()
670{ 669{
671 DateList dates = mNavigator->selectedDates(); 670 DateList dates = mNavigator->selectedDates();
672 671
673 return dates.last(); 672 return dates.last();
674} 673}
675 674
676 675
677void CalendarView::createPrinter() 676void CalendarView::createPrinter()
678{ 677{
679#ifndef KORG_NOPRINTER 678#ifndef KORG_NOPRINTER
680 if (!mCalPrinter) { 679 if (!mCalPrinter) {
681 mCalPrinter = new CalPrinter(this, mCalendar); 680 mCalPrinter = new CalPrinter(this, mCalendar);
682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
683 } 682 }
684#endif 683#endif
685} 684}
686 685
687void CalendarView::confSync() 686void CalendarView::confSync()
688{ 687{
689 static KOSyncPrefsDialog* sp = 0; 688 static KOSyncPrefsDialog* sp = 0;
690 if ( ! sp ) { 689 if ( ! sp ) {
691 sp = new KOSyncPrefsDialog( this, "syncprefs", true ); 690 sp = new KOSyncPrefsDialog( this, "syncprefs", true );
692 } 691 }
692 sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName );
693 sp->usrReadConfig(); 693 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 695 sp->showMaximized();
696#else 696#else
697 sp->show(); 697 sp->show();
698#endif 698#endif
699 sp->exec(); 699 sp->exec();
700 700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
701} 702}
702 703
703 704
704//KOPrefs::instance()->mWriteBackFile 705//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 706//KOPrefs::instance()->mWriteBackExistingOnly
706 707
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 714
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 716{
716 717
717 //void setZaurusId(int id); 718 //void setZaurusId(int id);
718 // int zaurusId() const; 719 // int zaurusId() const;
719 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
720 // int zaurusUid() const; 721 // int zaurusUid() const;
721 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
722 // int zaurusStat() const; 723 // int zaurusStat() const;
723 // 0 equal 724 // 0 equal
724 // 1 take local 725 // 1 take local
725 // 2 take remote 726 // 2 take remote
726 // 3 cancel 727 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
729 bool remCh, locCh; 730 bool remCh, locCh;
730 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 731 remCh = ( remote->zaurusUid() != local->zaurusUid() );
731 locCh = ( local->lastModified() > mLastCalendarSync ); 732 locCh = ( local->lastModified() > mLastCalendarSync );
732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
733 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
734 //qDebug("both not changed "); 735 //qDebug("both not changed ");
735 lastSync = local->lastModified().addDays(1); 736 lastSync = local->lastModified().addDays(1);
736 } else { 737 } else {
737 if ( locCh ) { 738 if ( locCh ) {
738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
739 lastSync = local->lastModified().addDays( -1 ); 740 lastSync = local->lastModified().addDays( -1 );
740 if ( !remCh ) 741 if ( !remCh )
741 remote->setLastModified( lastSync.addDays( -1 ) ); 742 remote->setLastModified( lastSync.addDays( -1 ) );
742 } else { 743 } else {
743 //qDebug(" not loc changed "); 744 //qDebug(" not loc changed ");
744 lastSync = local->lastModified().addDays( 1 ); 745 lastSync = local->lastModified().addDays( 1 );
745 if ( remCh ) 746 if ( remCh )
746 remote->setLastModified( lastSync.addDays( 1 ) ); 747 remote->setLastModified( lastSync.addDays( 1 ) );
747 748
748 } 749 }
@@ -1518,119 +1519,96 @@ void CalendarView::readSettings()
1518 else mNavigator->selectDates( dateCount ); 1519 else mNavigator->selectDates( dateCount );
1519 // mViewManager->readSettings( config ); 1520 // mViewManager->readSettings( config );
1520 updateConfig(); 1521 updateConfig();
1521 globalFlagBlockAgenda = 2; 1522 globalFlagBlockAgenda = 2;
1522 mViewManager->readSettings( config ); 1523 mViewManager->readSettings( config );
1523#ifdef DESKTOP_VERSION 1524#ifdef DESKTOP_VERSION
1524 config->setGroup("WidgetLayout"); 1525 config->setGroup("WidgetLayout");
1525 QStringList list; 1526 QStringList list;
1526 list = config->readListEntry("MainLayout"); 1527 list = config->readListEntry("MainLayout");
1527 int x,y,w,h; 1528 int x,y,w,h;
1528 if ( ! list.isEmpty() ) { 1529 if ( ! list.isEmpty() ) {
1529 x = list[0].toInt(); 1530 x = list[0].toInt();
1530 y = list[1].toInt(); 1531 y = list[1].toInt();
1531 w = list[2].toInt(); 1532 w = list[2].toInt();
1532 h = list[3].toInt(); 1533 h = list[3].toInt();
1533 topLevelWidget()->setGeometry(x,y,w,h); 1534 topLevelWidget()->setGeometry(x,y,w,h);
1534 1535
1535 } else { 1536 } else {
1536 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1537 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1537 } 1538 }
1538 list = config->readListEntry("EditEventLayout"); 1539 list = config->readListEntry("EditEventLayout");
1539 if ( ! list.isEmpty() ) { 1540 if ( ! list.isEmpty() ) {
1540 x = list[0].toInt(); 1541 x = list[0].toInt();
1541 y = list[1].toInt(); 1542 y = list[1].toInt();
1542 w = list[2].toInt(); 1543 w = list[2].toInt();
1543 h = list[3].toInt(); 1544 h = list[3].toInt();
1544 mEventEditor->setGeometry(x,y,w,h); 1545 mEventEditor->setGeometry(x,y,w,h);
1545 1546
1546 } 1547 }
1547 list = config->readListEntry("EditTodoLayout"); 1548 list = config->readListEntry("EditTodoLayout");
1548 if ( ! list.isEmpty() ) { 1549 if ( ! list.isEmpty() ) {
1549 x = list[0].toInt(); 1550 x = list[0].toInt();
1550 y = list[1].toInt(); 1551 y = list[1].toInt();
1551 w = list[2].toInt(); 1552 w = list[2].toInt();
1552 h = list[3].toInt(); 1553 h = list[3].toInt();
1553 mTodoEditor->setGeometry(x,y,w,h); 1554 mTodoEditor->setGeometry(x,y,w,h);
1554 1555
1555 } 1556 }
1556 list = config->readListEntry("ViewerLayout"); 1557 list = config->readListEntry("ViewerLayout");
1557 if ( ! list.isEmpty() ) { 1558 if ( ! list.isEmpty() ) {
1558 x = list[0].toInt(); 1559 x = list[0].toInt();
1559 y = list[1].toInt(); 1560 y = list[1].toInt();
1560 w = list[2].toInt(); 1561 w = list[2].toInt();
1561 h = list[3].toInt(); 1562 h = list[3].toInt();
1562 getEventViewerDialog()->setGeometry(x,y,w,h); 1563 getEventViewerDialog()->setGeometry(x,y,w,h);
1563 } 1564 }
1564#endif 1565#endif
1565 1566
1566
1567 // pending read sync settings;
1568 mSyncProfileNames.clear();
1569 mSyncProfileNames << "Profile_1";
1570 mSyncProfileNames << "Profile_2";
1571 mSyncProfileNames << "Profile_3";
1572 mSyncProfileNames << "Profile_4";
1573 mSyncProfileNames << "Profile_5";
1574 KSyncProfile* temp = new KSyncProfile ();
1575 temp->setName("Profile_1" );
1576 mSyncProfiles.append( temp );
1577 temp = new KSyncProfile ();
1578 temp->setName("Profile_2" );
1579 mSyncProfiles.append( temp );
1580 temp = new KSyncProfile ();
1581 temp->setName("Profile_3" );
1582 mSyncProfiles.append( temp );
1583 temp = new KSyncProfile ();
1584 temp->setName("Profile_4" );
1585 mSyncProfiles.append( temp );
1586 temp = new KSyncProfile ();
1587 temp->setName("Profile_5" );
1588 mSyncProfiles.append( temp );
1589} 1567}
1590 1568
1591 1569
1592void CalendarView::writeSettings() 1570void CalendarView::writeSettings()
1593{ 1571{
1594 // kdDebug() << "CalendarView::writeSettings" << endl; 1572 // kdDebug() << "CalendarView::writeSettings" << endl;
1595 1573
1596 KConfig *config = KOGlobals::config(); 1574 KConfig *config = KOGlobals::config();
1597 1575
1598#ifndef KORG_NOSPLITTER 1576#ifndef KORG_NOSPLITTER
1599 config->setGroup("KOrganizer Geometry"); 1577 config->setGroup("KOrganizer Geometry");
1600 1578
1601 QValueList<int> list = mPanner->sizes(); 1579 QValueList<int> list = mPanner->sizes();
1602 config->writeEntry("Separator1",list); 1580 config->writeEntry("Separator1",list);
1603 1581
1604 list = mLeftSplitter->sizes(); 1582 list = mLeftSplitter->sizes();
1605 config->writeEntry("Separator2",list); 1583 config->writeEntry("Separator2",list);
1606#endif 1584#endif
1607 1585
1608 mViewManager->writeSettings( config ); 1586 mViewManager->writeSettings( config );
1609 mTodoList->saveLayout(config,QString("Todo Layout")); 1587 mTodoList->saveLayout(config,QString("Todo Layout"));
1610 mDialogManager->writeSettings( config ); 1588 mDialogManager->writeSettings( config );
1611 //KOPrefs::instance()->usrWriteConfig(); 1589 //KOPrefs::instance()->usrWriteConfig();
1612 KOPrefs::instance()->writeConfig(); 1590 KOPrefs::instance()->writeConfig();
1613 1591
1614 writeFilterSettings(config); 1592 writeFilterSettings(config);
1615 1593
1616 config->setGroup( "Views" ); 1594 config->setGroup( "Views" );
1617 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1595 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1618 1596
1619#ifdef DESKTOP_VERSION 1597#ifdef DESKTOP_VERSION
1620 config->setGroup("WidgetLayout"); 1598 config->setGroup("WidgetLayout");
1621 QStringList list ;//= config->readListEntry("MainLayout"); 1599 QStringList list ;//= config->readListEntry("MainLayout");
1622 int x,y,w,h; 1600 int x,y,w,h;
1623 QWidget* wid; 1601 QWidget* wid;
1624 wid = topLevelWidget(); 1602 wid = topLevelWidget();
1625 x = wid->geometry().x(); 1603 x = wid->geometry().x();
1626 y = wid->geometry().y(); 1604 y = wid->geometry().y();
1627 w = wid->width(); 1605 w = wid->width();
1628 h = wid->height(); 1606 h = wid->height();
1629 list.clear(); 1607 list.clear();
1630 list << QString::number( x ); 1608 list << QString::number( x );
1631 list << QString::number( y ); 1609 list << QString::number( y );
1632 list << QString::number( w ); 1610 list << QString::number( w );
1633 list << QString::number( h ); 1611 list << QString::number( h );
1634 config->writeEntry("MainLayout",list ); 1612 config->writeEntry("MainLayout",list );
1635 1613
1636 wid = mEventEditor; 1614 wid = mEventEditor;
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index fda02f7..8aa5e1c 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -437,98 +437,96 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
437 void setSyncName( QString ); 437 void setSyncName( QString );
438 protected slots: 438 protected slots:
439 void timerAlarm(); 439 void timerAlarm();
440 void suspendAlarm(); 440 void suspendAlarm();
441 void beamDone( Ir *ir ); 441 void beamDone( Ir *ir );
442 /** Select a view or adapt the current view to display the specified dates. */ 442 /** Select a view or adapt the current view to display the specified dates. */
443 void showDates( const KCal::DateList & ); 443 void showDates( const KCal::DateList & );
444 void selectWeekNum ( int ); 444 void selectWeekNum ( int );
445 445
446 public: 446 public:
447 // show a standard warning 447 // show a standard warning
448 // returns KMsgBox::yesNoCancel() 448 // returns KMsgBox::yesNoCancel()
449 int msgCalModified(); 449 int msgCalModified();
450 void confSync(); 450 void confSync();
451 void setLoadedFileVersion(QDateTime); 451 void setLoadedFileVersion(QDateTime);
452 bool checkFileVersion(QString fn); 452 bool checkFileVersion(QString fn);
453 bool checkFileChanged(QString fn); 453 bool checkFileChanged(QString fn);
454 Event* getLastSyncEvent(); 454 Event* getLastSyncEvent();
455 /** Adapt navigation units correpsonding to step size of navigation of the 455 /** Adapt navigation units correpsonding to step size of navigation of the
456 * current view. 456 * current view.
457 */ 457 */
458 void adaptNavigationUnits(); 458 void adaptNavigationUnits();
459 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 459 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
460 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 460 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
461 //Attendee* getYourAttendee(Event *event); 461 //Attendee* getYourAttendee(Event *event);
462 protected: 462 protected:
463 void schedule(Scheduler::Method, Incidence *incidence = 0); 463 void schedule(Scheduler::Method, Incidence *incidence = 0);
464 464
465 // returns KMsgBox::OKCandel() 465 // returns KMsgBox::OKCandel()
466 int msgItemDelete(); 466 int msgItemDelete();
467 void showEventEditor(); 467 void showEventEditor();
468 void showTodoEditor(); 468 void showTodoEditor();
469 void writeLocale(); 469 void writeLocale();
470 Todo *selectedTodo(); 470 Todo *selectedTodo();
471 471
472 private: 472 private:
473 AlarmDialog * mAlarmDialog; 473 AlarmDialog * mAlarmDialog;
474 QString mAlarmNotification; 474 QString mAlarmNotification;
475 QString mSuspendAlarmNotification; 475 QString mSuspendAlarmNotification;
476 QTimer* mSuspendTimer; 476 QTimer* mSuspendTimer;
477 QTimer* mAlarmTimer; 477 QTimer* mAlarmTimer;
478 QTimer* mRecheckAlarmTimer; 478 QTimer* mRecheckAlarmTimer;
479 void computeAlarm( QString ); 479 void computeAlarm( QString );
480 void startAlarm( QString, QString ); 480 void startAlarm( QString, QString );
481 void setSyncEventsReadOnly(); 481 void setSyncEventsReadOnly();
482 482
483 QDateTime loadedFileVersion; 483 QDateTime loadedFileVersion;
484 void checkSharpEvent( Event* lastSync, Incidence* toDelete ); 484 void checkSharpEvent( Event* lastSync, Incidence* toDelete );
485 QPtrList<KSyncProfile> mSyncProfiles;
486 QStringList mSyncProfileNames;
487 void checkZaurusId( int id, bool todo = false ); 485 void checkZaurusId( int id, bool todo = false );
488 int mGlobalSyncMode; 486 int mGlobalSyncMode;
489 QString mCurrentSyncDevice; 487 QString mCurrentSyncDevice;
490 QString mCurrentSyncName; 488 QString mCurrentSyncName;
491 KOBeamPrefs* beamDialog; 489 KOBeamPrefs* beamDialog;
492 void init(); 490 void init();
493 int mDatePickerMode; 491 int mDatePickerMode;
494 bool mFlagEditDescription; 492 bool mFlagEditDescription;
495 QDateTime mLastCalendarSync; 493 QDateTime mLastCalendarSync;
496 void createPrinter(); 494 void createPrinter();
497 495
498 void calendarModified( bool, Calendar * ); 496 void calendarModified( bool, Calendar * );
499 497
500 CalPrinter *mCalPrinter; 498 CalPrinter *mCalPrinter;
501 499
502 QSplitter *mPanner; 500 QSplitter *mPanner;
503 QSplitter *mLeftSplitter; 501 QSplitter *mLeftSplitter;
504 QWidget *mLeftFrame; 502 QWidget *mLeftFrame;
505 QWidgetStack *mRightFrame; 503 QWidgetStack *mRightFrame;
506 504
507 KDatePicker* mDatePicker; 505 KDatePicker* mDatePicker;
508 QVBox* mDateFrame; 506 QVBox* mDateFrame;
509 NavigatorBar *mNavigatorBar; 507 NavigatorBar *mNavigatorBar;
510 508
511 KDateNavigator *mDateNavigator; // widget showing small month view. 509 KDateNavigator *mDateNavigator; // widget showing small month view.
512 510
513 KOFilterView *mFilterView; 511 KOFilterView *mFilterView;
514 512
515 ResourceView *mResourceView; 513 ResourceView *mResourceView;
516 514
517 // calendar object for this viewing instance 515 // calendar object for this viewing instance
518 Calendar *mCalendar; 516 Calendar *mCalendar;
519 517
520 CalendarResourceManager *mResourceManager; 518 CalendarResourceManager *mResourceManager;
521 519
522 FileStorage *mStorage; 520 FileStorage *mStorage;
523 521
524 DateNavigator *mNavigator; 522 DateNavigator *mNavigator;
525 523
526 KOViewManager *mViewManager; 524 KOViewManager *mViewManager;
527 KODialogManager *mDialogManager; 525 KODialogManager *mDialogManager;
528 526
529 // Calendar filters 527 // Calendar filters
530 QPtrList<CalFilter> mFilters; 528 QPtrList<CalFilter> mFilters;
531 529
532 // various housekeeping variables. 530 // various housekeeping variables.
533 bool mModified; // flag indicating if calendar is modified 531 bool mModified; // flag indicating if calendar is modified
534 bool mReadOnly; // flag indicating if calendar is read-only 532 bool mReadOnly; // flag indicating if calendar is read-only
diff --git a/korganizer/kosyncprefsdialog.cpp b/korganizer/kosyncprefsdialog.cpp
index b7e4265..7c838f5 100644
--- a/korganizer/kosyncprefsdialog.cpp
+++ b/korganizer/kosyncprefsdialog.cpp
@@ -1,113 +1,114 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h>
32#include <qtextstream.h> 33#include <qtextstream.h>
33#include <qcombobox.h> 34#include <qcombobox.h>
34#include <qvbox.h> 35#include <qvbox.h>
35#include <qhbox.h> 36#include <qhbox.h>
36#include <qspinbox.h> 37#include <qspinbox.h>
37#include <qdatetime.h> 38#include <qdatetime.h>
38#include <qcheckbox.h> 39#include <qcheckbox.h>
39#include <qradiobutton.h> 40#include <qradiobutton.h>
40#include <qpushbutton.h> 41#include <qpushbutton.h>
41#include <qstrlist.h> 42#include <qstrlist.h>
42#include <qapplication.h> 43#include <qapplication.h>
43 44
44#include <kcolorbutton.h> 45#include <kcolorbutton.h>
45#include <kdebug.h> 46#include <kdebug.h>
46#include <klocale.h> 47#include <klocale.h>
47#include <kglobal.h> 48#include <kglobal.h>
48#include <kfontdialog.h> 49#include <kfontdialog.h>
49#include <kmessagebox.h> 50#include <kmessagebox.h>
50#include <kcolordialog.h> 51#include <kcolordialog.h>
51#include <kiconloader.h> 52#include <kiconloader.h>
52#include <kemailsettings.h> 53#include <kemailsettings.h>
53#include <kstandarddirs.h> 54#include <kstandarddirs.h>
54#include <kfiledialog.h> 55#include <kfiledialog.h>
55#include <kmessagebox.h> 56#include <kmessagebox.h>
56 57
57#include <kurlrequester.h> 58#include <kurlrequester.h>
58#include <klineedit.h> 59#include <klineedit.h>
59#include <libkdepim/ksyncprofile.h> 60#include <libkdepim/ksyncprofile.h>
60 61
61 62
62#include "koprefs.h" 63//#include "koprefs.h"
63 64
64#include "kosyncprefsdialog.h" 65#include "kosyncprefsdialog.h"
65#include "koglobals.h" 66//#include "koglobals.h"
66 67
67 68
68KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 69KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
69 KDialog(parent,name,true) 70 KDialog(parent,name,true)
70{ 71{
71 72
72 setCaption( i18n("Synchronization Preferences")); 73 setCaption( i18n("Synchronization Preferences"));
73 74
74 mSyncProfiles.setAutoDelete( true ); 75 mSyncProfiles.setAutoDelete( true );
75 setupSyncAlgTab(); 76 setupSyncAlgTab();
76} 77}
77 78
78 79
79KOSyncPrefsDialog::~KOSyncPrefsDialog() 80KOSyncPrefsDialog::~KOSyncPrefsDialog()
80{ 81{
81} 82}
82 83
83#include <qlayout.h> 84#include <qlayout.h>
84#include <qscrollview.h> 85#include <qscrollview.h>
85void KOSyncPrefsDialog::setupSyncAlgTab() 86void KOSyncPrefsDialog::setupSyncAlgTab()
86{ 87{
87 QLabel * lab; 88 QLabel * lab;
88 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
89 QVBox * mainbox = new QVBox( this ); 90 QVBox * mainbox = new QVBox( this );
90 QScrollView* sv = new QScrollView( mainbox ); 91 QScrollView* sv = new QScrollView( mainbox );
91 QHBoxLayout * lay = new QHBoxLayout( this ); 92 QHBoxLayout * lay = new QHBoxLayout( this );
92 lay->addWidget( mainbox ); 93 lay->addWidget( mainbox );
93 QHBox * b_box = new QHBox( mainbox ); 94 QHBox * b_box = new QHBox( mainbox );
94 95
95 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
96 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
97 button = new QPushButton( i18n("Cancel"), b_box ); 98 button = new QPushButton( i18n("Cancel"), b_box );
98 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
99 //QBoxLayout * sl = new QVBoxLayout(this ); 100 //QBoxLayout * sl = new QVBoxLayout(this );
100 //sl->addWidget ( sv ); 101 //sl->addWidget ( sv );
101 sv->setResizePolicy ( QScrollView::AutoOneFit ); 102 sv->setResizePolicy ( QScrollView::AutoOneFit );
102 QFrame *topFrame = new QFrame ( sv ); 103 QFrame *topFrame = new QFrame ( sv );
103 sv->addChild( topFrame ); 104 sv->addChild( topFrame );
104 mSetupSyncAlgTab = topFrame; 105 mSetupSyncAlgTab = topFrame;
105 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
106 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
107 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
108 109
109 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
110 int iii = 0; 111 int iii = 0;
111 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
112 //++iii; 113 //++iii;
113 114
@@ -188,97 +189,97 @@ void KOSyncPrefsDialog::setupSyncAlgTab()
188 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
189 190
190 191
191 remoteFileWidget = new QVBox( topFrame); 192 remoteFileWidget = new QVBox( topFrame);
192 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
193 ++iii; 194 ++iii;
194 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
195 mRemotePrecommand = new QLineEdit(remoteFileWidget); 196 mRemotePrecommand = new QLineEdit(remoteFileWidget);
196 197
197 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
198 mLocalTempFile = new QLineEdit(remoteFileWidget); 199 mLocalTempFile = new QLineEdit(remoteFileWidget);
199 200
200 201
201 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
202 mRemotePostcommand = new QLineEdit(remoteFileWidget); 203 mRemotePostcommand = new QLineEdit(remoteFileWidget);
203 204
204 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
205 temphb = new QHBox( remoteFileWidget ); 206 temphb = new QHBox( remoteFileWidget );
206 button = new QPushButton( i18n("ssh/scp"), temphb ); 207 button = new QPushButton( i18n("ssh/scp"), temphb );
207 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
208 button = new QPushButton( i18n("ftp"), temphb ); 209 button = new QPushButton( i18n("ftp"), temphb );
209 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
210 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);
211 212
212 213
213} 214}
214void KOSyncPrefsDialog::slotOK() 215void KOSyncPrefsDialog::slotOK()
215{ 216{
216 if ( mMyMachineName->text() == "undefined" ) { 217 if ( mMyMachineName->text() == "undefined" ) {
217 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"));
218 return; 219 return;
219 } 220 }
220 int i; 221 int i;
221 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 222 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
222 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
223 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"));
224 return; 225 return;
225 } 226 }
226 } 227 }
227 usrWriteConfig(); 228 usrWriteConfig();
228 QDialog::accept(); 229 QDialog::accept();
229} 230}
230void KOSyncPrefsDialog::accept() 231void KOSyncPrefsDialog::accept()
231{ 232{
232 slotOK(); 233 slotOK();
233} 234}
234void KOSyncPrefsDialog::chooseFile() 235void KOSyncPrefsDialog::chooseFile()
235{ 236{
236 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 237 QString fn = QDir::homeDirPath();
237 238
238 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
239 if ( fn == "" ) 240 if ( fn == "" )
240 return; 241 return;
241 mRemoteFile->setText( fn ); 242 mRemoteFile->setText( fn );
242} 243}
243 244
244void KOSyncPrefsDialog::textChanged( const QString & s ) 245void KOSyncPrefsDialog::textChanged( const QString & s )
245{ 246{
246 if ( mProfileBox->count() == 0 ) 247 if ( mProfileBox->count() == 0 )
247 return; 248 return;
248 if ( currentSelection < 3 ) { 249 if ( currentSelection < 3 ) {
249 //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"));
250 mProfileBox->blockSignals( true ); 251 mProfileBox->blockSignals( true );
251 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
252 mProfileBox->blockSignals( false ); 253 mProfileBox->blockSignals( false );
253 return; 254 return;
254 } 255 }
255 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 256 //qDebug("cur i %d ",mProfileBox-> currentItem () );
256 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
257 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
258 prof->setName( s ); 259 prof->setName( s );
259 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 260 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
260} 261}
261void KOSyncPrefsDialog::profileChanged( int item ) 262void KOSyncPrefsDialog::profileChanged( int item )
262{ 263{
263 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item ); 264 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item );
264 KSyncProfile* prof; 265 KSyncProfile* prof;
265 saveProfile(); 266 saveProfile();
266 currentSelection = item; 267 currentSelection = item;
267 prof = mSyncProfiles.at(item) ; 268 prof = mSyncProfiles.at(item) ;
268 mRemotePrecommand->setText(prof->getPreSyncCommand()); 269 mRemotePrecommand->setText(prof->getPreSyncCommand());
269 mRemotePostcommand->setText(prof->getPostSyncCommand()); 270 mRemotePostcommand->setText(prof->getPostSyncCommand());
270 mLocalTempFile->setText(prof->getLocalTempFile()); 271 mLocalTempFile->setText(prof->getLocalTempFile());
271 mRemoteFile->setText(prof->getRemoteFileName()) ; 272 mRemoteFile->setText(prof->getRemoteFileName()) ;
272 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
273 mAskForPreferences->setChecked( prof->getAskForPreferences()); 274 mAskForPreferences->setChecked( prof->getAskForPreferences());
274 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
275 mWriteBackFile->setChecked( prof->getWriteBackFile()); 276 mWriteBackFile->setChecked( prof->getWriteBackFile());
276 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
277 278
278 switch ( prof->getSyncPrefs() ) { 279 switch ( prof->getSyncPrefs() ) {
279 case 0: 280 case 0:
280 loc->setChecked( true); 281 loc->setChecked( true);
281 break; 282 break;
282 case 1: 283 case 1:
283 rem->setChecked( true ); 284 rem->setChecked( true );
284 break; 285 break;
@@ -368,85 +369,100 @@ void KOSyncPrefsDialog::saveProfile()
368} 369}
369 370
370void KOSyncPrefsDialog::insertProfiles() 371void KOSyncPrefsDialog::insertProfiles()
371{ 372{
372 int curItem = mProfileBox->currentItem(); 373 int curItem = mProfileBox->currentItem();
373 mProfileBox->blockSignals( true ); 374 mProfileBox->blockSignals( true );
374 mProfileBox->clear(); 375 mProfileBox->clear();
375 mProfileBox->insertStringList (mSyncProfileNames ); 376 mProfileBox->insertStringList (mSyncProfileNames );
376 int item = mSyncProfileNames.count() -1; 377 int item = mSyncProfileNames.count() -1;
377 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
378 mProfileBox->setCurrentItem( curItem ); 379 mProfileBox->setCurrentItem( curItem );
379 else if ( item >= 0 ) { 380 else if ( item >= 0 ) {
380 mProfileBox->setCurrentItem( item ); 381 mProfileBox->setCurrentItem( item );
381 } 382 }
382 currentSelection = -1; 383 currentSelection = -1;
383 if ( mSyncProfileNames.count() > 0 ) { 384 if ( mSyncProfileNames.count() > 0 ) {
384 //qDebug(" profileChanged( mProfileBox->currentItem() "); 385 //qDebug(" profileChanged( mProfileBox->currentItem() ");
385 profileChanged( mProfileBox->currentItem() ); 386 profileChanged( mProfileBox->currentItem() );
386 currentSelection = mProfileBox->currentItem(); 387 currentSelection = mProfileBox->currentItem();
387 } 388 }
388 mProfileBox->blockSignals( false ); 389 mProfileBox->blockSignals( false );
389} 390}
390 391
391void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 392void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp )
392{ 393{
393 saveProfile(); 394 saveProfile();
394 mSyncProfiles.append( temp ); 395 mSyncProfiles.append( temp );
395 mSyncProfileNames << temp->getName(); 396 mSyncProfileNames << temp->getName();
396 insertProfiles(); 397 insertProfiles();
397 int last = mProfileBox->count() -1; 398 int last = mProfileBox->count() -1;
398 mProfileBox->blockSignals( true ); 399 mProfileBox->blockSignals( true );
399 mProfileBox->setCurrentItem( last ); 400 mProfileBox->setCurrentItem( last );
400 mProfileBox->blockSignals( false ); 401 mProfileBox->blockSignals( false );
401 profileChanged(last); 402 profileChanged(last);
402} 403}
403void KOSyncPrefsDialog::newProfile() 404void KOSyncPrefsDialog::newProfile()
404{ 405{
405 addProfile ( new KSyncProfile () ); 406 addProfile ( new KSyncProfile () );
406} 407}
407 408
408void KOSyncPrefsDialog::cloneProfile() 409void KOSyncPrefsDialog::cloneProfile()
409{ 410{
410 if ( currentSelection >= 0 ) 411 if ( currentSelection >= 0 )
411 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
412 else 413 else
413 newProfile(); 414 newProfile();
414} 415}
415 416
417void KOSyncPrefsDialog::setLocalMachineName ( const QString& name )
418{
419 mMyMachineName->setText( name );
416 420
421}
422QString KOSyncPrefsDialog::getLocalMachineName ( )
423{
424 return mMyMachineName->text();
425}
426
427QStringList KOSyncPrefsDialog::getSyncProfileNames()
428{
429 return mSyncProfileNames;
430}
417void KOSyncPrefsDialog::usrReadConfig() 431void KOSyncPrefsDialog::usrReadConfig()
418{ 432{
419 KConfig *config = KOGlobals::config(); 433 //KConfig *config = KOGlobals::config();
420 config->setGroup("SyncProfiles"); 434 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
421 mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames; 435 config.setGroup("SyncProfiles");
436 mSyncProfileNames =config.readListEntry("SyncProfileNames");
422 int i; 437 int i;
423 KSyncProfile* temp ; 438 KSyncProfile* temp ;
424 mSyncProfiles.clear(); 439 mSyncProfiles.clear();
425 for ( i = 0; i < mSyncProfileNames.count();++i ) { 440 for ( i = 0; i < mSyncProfileNames.count();++i ) {
426 temp = new KSyncProfile (); 441 temp = new KSyncProfile ();
427 temp->setName( mSyncProfileNames[i] ); 442 temp->setName( mSyncProfileNames[i] );
428 temp->readConfig( config ); 443 temp->readConfig( &config );
429 mSyncProfiles.append( temp ); 444 mSyncProfiles.append( temp );
430 } 445 }
431 insertProfiles(); 446 insertProfiles();
432 mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 447 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
433} 448}
434 449
435 450
436void KOSyncPrefsDialog::usrWriteConfig() 451void KOSyncPrefsDialog::usrWriteConfig()
437{ 452{
438 saveProfile(); 453 saveProfile();
439 if ( currentSelection >= 0 ) 454 if ( currentSelection >= 0 )
440 profileChanged(currentSelection); 455 profileChanged(currentSelection);
441 KConfig *config = KOGlobals::config(); 456 //KConfig *config = KOGlobals::config();
442 config->setGroup("SyncProfiles"); 457 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
458 config.setGroup("SyncProfiles");
443 KSyncProfile* prof = mSyncProfiles.first(); 459 KSyncProfile* prof = mSyncProfiles.first();
444 while ( prof ) { 460 while ( prof ) {
445 prof->writeConfig(config); 461 prof->writeConfig(&config);
446 prof = mSyncProfiles.next(); 462 prof = mSyncProfiles.next();
447 } 463 }
448 KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 464 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
449 KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 465 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
450 config->writeEntry("SyncProfileNames",&mSyncProfileNames); 466 config.writeEntry("SyncProfileNames",&mSyncProfileNames);
451} 467}
452 468
diff --git a/korganizer/kosyncprefsdialog.h b/korganizer/kosyncprefsdialog.h
index d2d8c6f..541d18b 100644
--- a/korganizer/kosyncprefsdialog.h
+++ b/korganizer/kosyncprefsdialog.h
@@ -10,96 +10,100 @@
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KOPREFSDIALOG_H 23#ifndef _KOPREFSDIALOG_H
24#define _KOPREFSDIALOG_H 24#define _KOPREFSDIALOG_H
25 25
26//#include <qframe.h> 26//#include <qframe.h>
27//#include <qdict.h> 27//#include <qdict.h>
28#include <qvbox.h> 28#include <qvbox.h>
29#include <qhbox.h> 29#include <qhbox.h>
30//#include <qcolor.h> 30//#include <qcolor.h>
31//#include <qlistview.h> 31//#include <qlistview.h>
32 32
33#include <kdialogbase.h> 33#include <kdialogbase.h>
34 34
35#include <libkdepim/kprefsdialog.h> 35#include <libkdepim/kprefsdialog.h>
36 36
37class KColorButton; 37class KColorButton;
38class QSpinBox;; 38class QSpinBox;;
39class QRadioButton; 39class QRadioButton;
40class QCheckBox; 40class QCheckBox;
41class QSlider; 41class QSlider;
42class KURLRequester; 42class KURLRequester;
43class QComboBox; 43class QComboBox;
44class QLineEdit; 44class QLineEdit;
45class QStringList; 45class QStringList;
46class KSyncProfile; 46class KSyncProfile;
47 47
48/** Dialog to change the korganizer configuration. 48/** Dialog to change the korganizer configuration.
49 */ 49 */
50class KOSyncPrefsDialog : public KDialog 50class KOSyncPrefsDialog : public KDialog
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 public: 53 public:
54 /** Initialize dialog and pages */ 54 /** Initialize dialog and pages */
55 KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); 55 KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
56 ~KOSyncPrefsDialog(); 56 ~KOSyncPrefsDialog();
57 void usrReadConfig(); 57 void usrReadConfig();
58 void setLocalMachineName ( const QString& name );
59 QString getLocalMachineName ( );
60
61 QStringList getSyncProfileNames();
58 62
59 public slots: 63 public slots:
60 protected slots: 64 protected slots:
61 void accept(); 65 void accept();
62 void deleteProfile(); 66 void deleteProfile();
63 void newProfile(); 67 void newProfile();
64 void cloneProfile(); 68 void cloneProfile();
65 void kindChanged(bool); 69 void kindChanged(bool);
66 void fillSSH(); 70 void fillSSH();
67 void fillFTP(); 71 void fillFTP();
68 void textChanged( const QString & ); 72 void textChanged( const QString & );
69 void profileChanged( int ); 73 void profileChanged( int );
70 void chooseFile(); 74 void chooseFile();
71 void slotOK(); 75 void slotOK();
72 76
73 protected: 77 protected:
74 void usrWriteConfig(); 78 void usrWriteConfig();
75 79
76 void setupSyncAlgTab(); 80 void setupSyncAlgTab();
77 81
78 private: 82 private:
79 int currentSelection; 83 int currentSelection;
80 QPtrList<KSyncProfile> mSyncProfiles; 84 QPtrList<KSyncProfile> mSyncProfiles;
81 QStringList mSyncProfileNames; 85 QStringList mSyncProfileNames;
82 QLineEdit * mMyMachineName; 86 QLineEdit * mMyMachineName;
83 QComboBox * mProfileBox; 87 QComboBox * mProfileBox;
84 QRadioButton* mIsLocal; 88 QRadioButton* mIsLocal;
85 QRadioButton* mIsNotLocal; 89 QRadioButton* mIsNotLocal;
86 QCheckBox* mIncludeInRing; 90 QCheckBox* mIncludeInRing;
87 void addProfile ( KSyncProfile* ); 91 void addProfile ( KSyncProfile* );
88 void insertProfiles(); 92 void insertProfiles();
89 void saveProfile(); 93 void saveProfile();
90 QButtonGroup* proGr; 94 QButtonGroup* proGr;
91 95
92 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; 96 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
93 97
94 98
95 QLineEdit * mRemotePostcommand; 99 QLineEdit * mRemotePostcommand;
96 QLineEdit * mRemotePrecommand; 100 QLineEdit * mRemotePrecommand;
97 QLineEdit * mRemoteFile; 101 QLineEdit * mRemoteFile;
98 QLineEdit * mLocalTempFile; 102 QLineEdit * mLocalTempFile;
99 QWidget* mSetupSyncAlgTab; 103 QWidget* mSetupSyncAlgTab;
100 104
101 QVBox* localFileWidget; 105 QVBox* localFileWidget;
102 QVBox* remoteFileWidget; 106 QVBox* remoteFileWidget;
103 QCheckBox* mWriteBackFile; 107 QCheckBox* mWriteBackFile;
104 QCheckBox* mWriteBackExisting; 108 QCheckBox* mWriteBackExisting;
105 QCheckBox* mAskForPreferences; 109 QCheckBox* mAskForPreferences;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index a487f14..589ab2d 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -773,117 +773,116 @@ void MainWindow::initActions()
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 821 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
822 QStringList prof = KOPrefs::instance()->mSyncProfileNames; 822 config.setGroup("SyncProfiles");
823 823 QStringList prof = config.readListEntry("SyncProfileNames");
824
824 if ( prof.count() < 3 ) { 825 if ( prof.count() < 3 ) {
825 KConfig *config = KOGlobals::config();
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->sync(); 837 config.sync();
838 delete temp; 838 delete temp;
839 KOPrefs::instance()->mSyncProfileNames = prof;
840 } 839 }
841 840 KOPrefs::instance()->mSyncProfileNames = prof;
842 int i; 841 int i;
843 for ( i = 0; i < prof.count(); ++i ) { 842 for ( i = 0; i < prof.count(); ++i ) {
844 843
845 syncMenu->insertItem( prof[i], 1000+i ); 844 syncMenu->insertItem( prof[i], 1000+i );
846 if ( i == 2 ) 845 if ( i == 2 )
847 syncMenu->insertSeparator(); 846 syncMenu->insertSeparator();
848 } 847 }
849 QDir app_dir; 848 QDir app_dir;
850 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 849 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
851 syncMenu->setItemEnabled( false , 1000 ); 850 syncMenu->setItemEnabled( false , 1000 );
852 } 851 }
853} 852}
854 853
855int MainWindow::ringSync() 854int MainWindow::ringSync()
856{ 855{
857 int syncedProfiles = 0; 856 int syncedProfiles = 0;
858 int i; 857 int i;
859 QTime timer; 858 QTime timer;
860 KConfig *config = KOGlobals::config(); 859 KConfig *config = KOGlobals::config();
861 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 860 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
862 KSyncProfile* temp = new KSyncProfile (); 861 KSyncProfile* temp = new KSyncProfile ();
863 KOPrefs::instance()->mAskForPreferences = false; 862 KOPrefs::instance()->mAskForPreferences = false;
864 for ( i = 0; i < syncProfileNames.count(); ++i ) { 863 for ( i = 0; i < syncProfileNames.count(); ++i ) {
865 mCurrentSyncProfile = i; 864 mCurrentSyncProfile = i;
866 temp->setName(syncProfileNames[mCurrentSyncProfile]); 865 temp->setName(syncProfileNames[mCurrentSyncProfile]);
867 temp->readConfig(config); 866 temp->readConfig(config);
868 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 867 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
869 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 868 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
870 ++syncedProfiles; 869 ++syncedProfiles;
871 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 870 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
872 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 871 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
873 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 872 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
874 KOPrefs::instance()->mShowSyncSummary = false; 873 KOPrefs::instance()->mShowSyncSummary = false;
875 mView->setSyncDevice(syncProfileNames[i] ); 874 mView->setSyncDevice(syncProfileNames[i] );
876 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 875 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
877 if ( i == 0 ) { 876 if ( i == 0 ) {
878 syncSharp(); 877 syncSharp();
879 } else { 878 } else {
880 if ( temp->getIsLocalFileSync() ) { 879 if ( temp->getIsLocalFileSync() ) {
881 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 880 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
882 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 881 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
883 } else { 882 } else {
884 syncRemote( temp, false ); 883 syncRemote( temp, false );
885 884
886 } 885 }
887 } 886 }
888 timer.start(); 887 timer.start();
889 setCaption(i18n("Multiple sync in progress ... please wait!") ); 888 setCaption(i18n("Multiple sync in progress ... please wait!") );
@@ -1755,97 +1754,97 @@ bool MainWindow::syncWithFile( QString fn , bool quick )
1755 bool loadbup = true; 1754 bool loadbup = true;
1756 if ( !info. exists() ) { 1755 if ( !info. exists() ) {
1757 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1756 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1758 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1757 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1759 mess ); 1758 mess );
1760 return ret; 1759 return ret;
1761 } 1760 }
1762 int result = 0; 1761 int result = 0;
1763 if ( !quick ) { 1762 if ( !quick ) {
1764 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1763 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1765 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1764 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1766 mess, 1765 mess,
1767 i18n("Sync"), i18n("Cancel"), 0, 1766 i18n("Sync"), i18n("Cancel"), 0,
1768 0, 1 ); 1767 0, 1 );
1769 if ( result ) 1768 if ( result )
1770 return false; 1769 return false;
1771 } 1770 }
1772 if ( KOPrefs::instance()->mAskForPreferences ) 1771 if ( KOPrefs::instance()->mAskForPreferences )
1773 mView->edit_sync_options(); 1772 mView->edit_sync_options();
1774 if ( result == 0 ) { 1773 if ( result == 0 ) {
1775 //qDebug("Now sycing ... "); 1774 //qDebug("Now sycing ... ");
1776 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1775 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1777 setCaption( i18n("Synchronization successful") ); 1776 setCaption( i18n("Synchronization successful") );
1778 else 1777 else
1779 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1778 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1780 if ( ! quick ) 1779 if ( ! quick )
1781 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1780 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1782 slotModifiedChanged( true ); 1781 slotModifiedChanged( true );
1783 } 1782 }
1784 return ret; 1783 return ret;
1785} 1784}
1786void MainWindow::quickSyncLocalFile() 1785void MainWindow::quickSyncLocalFile()
1787{ 1786{
1788 //mView->setSyncDevice("local-file" ); 1787 //mView->setSyncDevice("local-file" );
1789 //qDebug("quickSyncLocalFile() "); 1788 //qDebug("quickSyncLocalFile() ");
1790 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1789 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1791 // Event* e = mView->getLastSyncEvent(); 1790 // Event* e = mView->getLastSyncEvent();
1792// e->setReadOnly( false ); 1791// e->setReadOnly( false );
1793// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1792// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1794// e->setReadOnly( true ); 1793// e->setReadOnly( true );
1795 1794
1796 } 1795 }
1797} 1796}
1798 1797
1799void MainWindow::confSync() 1798void MainWindow::confSync()
1800{ 1799{
1801 mView->confSync(); 1800 mView->confSync();
1802 fillSyncMenu(); 1801 fillSyncMenu();
1803 mView->writeSettings(); 1802 //mView->writeSettings();
1804 1803
1805 1804
1806} 1805}
1807void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1806void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1808{ 1807{
1809 QString question; 1808 QString question;
1810 if ( ask ) { 1809 if ( ask ) {
1811 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1810 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1812 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1811 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1813 question, 1812 question,
1814 i18n("Yes"), i18n("No"), 1813 i18n("Yes"), i18n("No"),
1815 0, 0 ) != 0 ) 1814 0, 0 ) != 0 )
1816 return; 1815 return;
1817 } 1816 }
1818 QString command = prof->getPreSyncCommand(); 1817 QString command = prof->getPreSyncCommand();
1819 int fi; 1818 int fi;
1820 if ( (fi = command.find("$PWD$")) > 0 ) { 1819 if ( (fi = command.find("$PWD$")) > 0 ) {
1821 QString pwd = getPassword(); 1820 QString pwd = getPassword();
1822 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1821 command = command.left( fi )+ pwd + command.mid( fi+5 );
1823 1822
1824 } 1823 }
1825 int maxlen = 30; 1824 int maxlen = 30;
1826 if ( QApplication::desktop()->width() > 320 ) 1825 if ( QApplication::desktop()->width() > 320 )
1827 maxlen += 25; 1826 maxlen += 25;
1828 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1827 setCaption ( i18n( "Copy remote file to local machine..." ) );
1829 int fileSize = 0; 1828 int fileSize = 0;
1830 int result = system ( command ); 1829 int result = system ( command );
1831 // 0 : okay 1830 // 0 : okay
1832 // 256: no such file or dir 1831 // 256: no such file or dir
1833 // 1832 //
1834 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1833 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1835 if ( result != 0 ) { 1834 if ( result != 0 ) {
1836 int len = maxlen; 1835 int len = maxlen;
1837 while ( len < command.length() ) { 1836 while ( len < command.length() ) {
1838 command.insert( len , "\n" ); 1837 command.insert( len , "\n" );
1839 len += maxlen +2; 1838 len += maxlen +2;
1840 } 1839 }
1841 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1840 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1842 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1841 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1843 question, 1842 question,
1844 i18n("Okay!")) ; 1843 i18n("Okay!")) ;
1845 setCaption ("KO/Pi"); 1844 setCaption ("KO/Pi");
1846 return; 1845 return;
1847 } 1846 }
1848 setCaption ( i18n( "Copying succeed." ) ); 1847 setCaption ( i18n( "Copying succeed." ) );
1849 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1848 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1850 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1849 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1851// Event* e = mView->getLastSyncEvent(); 1850// Event* e = mView->getLastSyncEvent();