author | zautrix <zautrix> | 2005-11-25 17:41:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-25 17:41:25 (UTC) |
commit | 279e183c0325cd9565605f60af0215bb9bfdc825 (patch) (unidiff) | |
tree | 43ab776cd108874819e7c6e73070a7d989a9078f /korganizer | |
parent | 794a5204686ad9bfc16172b01db35f1f3b7683e5 (diff) | |
download | kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.zip kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.gz kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.bz2 |
sync
-rw-r--r-- | korganizer/calendarview.cpp | 73 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 14 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 |
4 files changed, 78 insertions, 17 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8965d3b..307027a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -321,96 +321,97 @@ class KOCatPrefs : public QDialog | |||
321 | lay->addWidget( format ); | 321 | lay->addWidget( format ); |
322 | format->setExclusive ( true ) ; | 322 | format->setExclusive ( true ) ; |
323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 323 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 324 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
325 | addCatBut->setChecked( true ); | 325 | addCatBut->setChecked( true ); |
326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); | 326 | QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); |
327 | lay->addWidget( ok ); | 327 | lay->addWidget( ok ); |
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mMultiResourceSync = false; | ||
369 | flag_blockConflict = false; | 370 | flag_blockConflict = false; |
370 | flag_blockScrollBar = false; | 371 | flag_blockScrollBar = false; |
371 | flag_checkFileFirsttime = true; | 372 | flag_checkFileFirsttime = true; |
372 | flag_clearallviewsEventDisplay = false; | 373 | flag_clearallviewsEventDisplay = false; |
373 | flag_clearallviewsupdateView = false; | 374 | flag_clearallviewsupdateView = false; |
374 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 375 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
375 | setFocusPolicy (NoFocus ); | 376 | setFocusPolicy (NoFocus ); |
376 | mViewerCallerIsSearchDialog = false; | 377 | mViewerCallerIsSearchDialog = false; |
377 | mBlockShowDates = false; | 378 | mBlockShowDates = false; |
378 | mConflictingEvent = 0; | 379 | mConflictingEvent = 0; |
379 | mDatePickerMode = 0; | 380 | mDatePickerMode = 0; |
380 | mCurrentSyncDevice = ""; | 381 | mCurrentSyncDevice = ""; |
381 | mViewManager = new KOViewManager( this ); | 382 | mViewManager = new KOViewManager( this ); |
382 | mDialogManager = new KODialogManager( this ); | 383 | mDialogManager = new KODialogManager( this ); |
383 | mEventViewerDialog = 0; | 384 | mEventViewerDialog = 0; |
384 | mModified = false; | 385 | mModified = false; |
385 | mReadOnly = false; | 386 | mReadOnly = false; |
386 | mSelectedIncidence = 0; | 387 | mSelectedIncidence = 0; |
387 | mCalPrinter = 0; | 388 | mCalPrinter = 0; |
388 | mFilters.setAutoDelete(true); | 389 | mFilters.setAutoDelete(true); |
389 | 390 | ||
390 | mCalendar->registerObserver( this ); | 391 | mCalendar->registerObserver( this ); |
391 | // TODO: Make sure that view is updated, when calendar is changed. | 392 | // TODO: Make sure that view is updated, when calendar is changed. |
392 | 393 | ||
393 | mStorage = new FileStorage( mCalendar ); | 394 | mStorage = new FileStorage( mCalendar ); |
394 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 395 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
395 | 396 | ||
396 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 397 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
397 | #ifndef KORG_NOSPLITTER | 398 | #ifndef KORG_NOSPLITTER |
398 | // create the main layout frames. | 399 | // create the main layout frames. |
399 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 400 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
400 | topLayout->addWidget(mPanner); | 401 | topLayout->addWidget(mPanner); |
401 | 402 | ||
402 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 403 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
403 | "CalendarView::LeftFrame"); | 404 | "CalendarView::LeftFrame"); |
404 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 405 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
405 | 406 | ||
406 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 407 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
407 | "CalendarView::DateNavigator" ); | 408 | "CalendarView::DateNavigator" ); |
408 | 409 | ||
409 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 410 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
410 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 411 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
411 | mTodoList->setNavigator( mNavigator ); | 412 | mTodoList->setNavigator( mNavigator ); |
412 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 413 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
413 | 414 | ||
414 | #ifdef KORG_NORESOURCEVIEW | 415 | #ifdef KORG_NORESOURCEVIEW |
415 | mResourceView = 0; | 416 | mResourceView = 0; |
416 | #else | 417 | #else |
@@ -1507,96 +1508,97 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
1507 | localIsNew = localMod >= remoteMod; | 1508 | localIsNew = localMod >= remoteMod; |
1508 | if ( localIsNew ) | 1509 | if ( localIsNew ) |
1509 | getEventViewerDialog()->setColorMode( 1 ); | 1510 | getEventViewerDialog()->setColorMode( 1 ); |
1510 | else | 1511 | else |
1511 | getEventViewerDialog()->setColorMode( 2 ); | 1512 | getEventViewerDialog()->setColorMode( 2 ); |
1512 | getEventViewerDialog()->setIncidence(local); | 1513 | getEventViewerDialog()->setIncidence(local); |
1513 | if ( localIsNew ) | 1514 | if ( localIsNew ) |
1514 | getEventViewerDialog()->setColorMode( 2 ); | 1515 | getEventViewerDialog()->setColorMode( 2 ); |
1515 | else | 1516 | else |
1516 | getEventViewerDialog()->setColorMode( 1 ); | 1517 | getEventViewerDialog()->setColorMode( 1 ); |
1517 | getEventViewerDialog()->addIncidence(remote); | 1518 | getEventViewerDialog()->addIncidence(remote); |
1518 | getEventViewerDialog()->setColorMode( 0 ); | 1519 | getEventViewerDialog()->setColorMode( 0 ); |
1519 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1520 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1520 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1521 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1521 | getEventViewerDialog()->showMe(); | 1522 | getEventViewerDialog()->showMe(); |
1522 | result = getEventViewerDialog()->executeS( localIsNew ); | 1523 | result = getEventViewerDialog()->executeS( localIsNew ); |
1523 | return result; | 1524 | return result; |
1524 | 1525 | ||
1525 | break; | 1526 | break; |
1526 | case SYNC_PREF_FORCE_LOCAL: | 1527 | case SYNC_PREF_FORCE_LOCAL: |
1527 | return 1; | 1528 | return 1; |
1528 | break; | 1529 | break; |
1529 | case SYNC_PREF_FORCE_REMOTE: | 1530 | case SYNC_PREF_FORCE_REMOTE: |
1530 | return 2; | 1531 | return 2; |
1531 | break; | 1532 | break; |
1532 | 1533 | ||
1533 | default: | 1534 | default: |
1534 | // SYNC_PREF_TAKE_BOTH not implemented | 1535 | // SYNC_PREF_TAKE_BOTH not implemented |
1535 | break; | 1536 | break; |
1536 | } | 1537 | } |
1537 | return 0; | 1538 | return 0; |
1538 | } | 1539 | } |
1539 | Event* CalendarView::getLastSyncEvent() | 1540 | Event* CalendarView::getLastSyncEvent() |
1540 | { | 1541 | { |
1541 | Event* lse; | 1542 | Event* lse; |
1542 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1543 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1543 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1544 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1544 | if (!lse) { | 1545 | if (!lse) { |
1545 | lse = new Event(); | 1546 | lse = new Event(); |
1546 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1547 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1547 | QString sum = ""; | 1548 | QString sum = ""; |
1548 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1549 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1549 | sum = "E: "; | 1550 | sum = "E: "; |
1550 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1551 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1551 | lse->setDtStart( mLastCalendarSync ); | 1552 | lse->setDtStart( mLastCalendarSync ); |
1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1553 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1553 | lse->setCategories( i18n("SyncEvent") ); | 1554 | lse->setCategories( i18n("SyncEvent") ); |
1554 | lse->setReadOnly( true ); | 1555 | lse->setReadOnly( true ); |
1556 | lse->setCalID( 1 ); | ||
1555 | mCalendar->addEvent( lse ); | 1557 | mCalendar->addEvent( lse ); |
1556 | } | 1558 | } |
1557 | 1559 | ||
1558 | return lse; | 1560 | return lse; |
1559 | 1561 | ||
1560 | } | 1562 | } |
1561 | 1563 | ||
1562 | // we check, if the to delete event has a id for a profile | 1564 | // we check, if the to delete event has a id for a profile |
1563 | // if yes, we set this id in the profile to delete | 1565 | // if yes, we set this id in the profile to delete |
1564 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1566 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1565 | { | 1567 | { |
1566 | if ( lastSync.count() == 0 ) { | 1568 | if ( lastSync.count() == 0 ) { |
1567 | //qDebug(" lastSync.count() == 0"); | 1569 | //qDebug(" lastSync.count() == 0"); |
1568 | return; | 1570 | return; |
1569 | } | 1571 | } |
1570 | if ( toDelete->typeID() == journalID ) | 1572 | if ( toDelete->typeID() == journalID ) |
1571 | return; | 1573 | return; |
1572 | 1574 | ||
1573 | Event* eve = lastSync.first(); | 1575 | Event* eve = lastSync.first(); |
1574 | 1576 | ||
1575 | while ( eve ) { | 1577 | while ( eve ) { |
1576 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1578 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1577 | if ( !id.isEmpty() ) { | 1579 | if ( !id.isEmpty() ) { |
1578 | QString des = eve->description(); | 1580 | QString des = eve->description(); |
1579 | QString pref = "e"; | 1581 | QString pref = "e"; |
1580 | if ( toDelete->typeID() == todoID ) | 1582 | if ( toDelete->typeID() == todoID ) |
1581 | pref = "t"; | 1583 | pref = "t"; |
1582 | des += pref+ id + ","; | 1584 | des += pref+ id + ","; |
1583 | eve->setReadOnly( false ); | 1585 | eve->setReadOnly( false ); |
1584 | eve->setDescription( des ); | 1586 | eve->setDescription( des ); |
1585 | //qDebug("setdes %s ", des.latin1()); | 1587 | //qDebug("setdes %s ", des.latin1()); |
1586 | eve->setReadOnly( true ); | 1588 | eve->setReadOnly( true ); |
1587 | } | 1589 | } |
1588 | eve = lastSync.next(); | 1590 | eve = lastSync.next(); |
1589 | } | 1591 | } |
1590 | 1592 | ||
1591 | } | 1593 | } |
1592 | void CalendarView::checkExternalId( Incidence * inc ) | 1594 | void CalendarView::checkExternalId( Incidence * inc ) |
1593 | { | 1595 | { |
1594 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1596 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1595 | checkExternSyncEvent( lastSync, inc ); | 1597 | checkExternSyncEvent( lastSync, inc ); |
1596 | 1598 | ||
1597 | } | 1599 | } |
1598 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1600 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1599 | { | 1601 | { |
1600 | bool syncOK = true; | 1602 | bool syncOK = true; |
1601 | int addedEvent = 0; | 1603 | int addedEvent = 0; |
1602 | int addedEventR = 0; | 1604 | int addedEventR = 0; |
@@ -1857,106 +1859,111 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1857 | inR = inL->clone(); | 1859 | inR = inL->clone(); |
1858 | inR->setIDStr( ":" ); | 1860 | inR->setIDStr( ":" ); |
1859 | inR->setCalID( 0 );// add to default cal | 1861 | inR->setCalID( 0 );// add to default cal |
1860 | remote->addIncidence( inR ); | 1862 | remote->addIncidence( inR ); |
1861 | } | 1863 | } |
1862 | } | 1864 | } |
1863 | } | 1865 | } |
1864 | } else { | 1866 | } else { |
1865 | ++filteredOUT; | 1867 | ++filteredOUT; |
1866 | } | 1868 | } |
1867 | } | 1869 | } |
1868 | } | 1870 | } |
1869 | inL = el.next(); | 1871 | inL = el.next(); |
1870 | } | 1872 | } |
1871 | int delFut = 0; | 1873 | int delFut = 0; |
1872 | int remRem = 0; | 1874 | int remRem = 0; |
1873 | if ( mSyncManager->mWriteBackInFuture ) { | 1875 | if ( mSyncManager->mWriteBackInFuture ) { |
1874 | er = remote->rawIncidences(); | 1876 | er = remote->rawIncidences(); |
1875 | remRem = er.count(); | 1877 | remRem = er.count(); |
1876 | inR = er.first(); | 1878 | inR = er.first(); |
1877 | QDateTime dt; | 1879 | QDateTime dt; |
1878 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1880 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1879 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1881 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1880 | while ( inR ) { | 1882 | while ( inR ) { |
1881 | if ( inR->typeID() == todoID ) { | 1883 | if ( inR->typeID() == todoID ) { |
1882 | Todo * t = (Todo*)inR; | 1884 | Todo * t = (Todo*)inR; |
1883 | if ( t->hasDueDate() ) | 1885 | if ( t->hasDueDate() ) |
1884 | dt = t->dtDue(); | 1886 | dt = t->dtDue(); |
1885 | else | 1887 | else |
1886 | dt = cur.addSecs( 62 ); | 1888 | dt = cur.addSecs( 62 ); |
1887 | } | 1889 | } |
1888 | else if (inR->typeID() == eventID ) { | 1890 | else if (inR->typeID() == eventID ) { |
1889 | bool ok; | 1891 | bool ok; |
1890 | dt = inR->getNextOccurence( cur, &ok ); | 1892 | dt = inR->getNextOccurence( cur, &ok ); |
1891 | if ( !ok ) | 1893 | if ( !ok ) |
1892 | dt = cur.addSecs( -62 ); | 1894 | dt = cur.addSecs( -62 ); |
1893 | } | 1895 | } |
1894 | else | 1896 | else |
1895 | dt = inR->dtStart(); | 1897 | dt = inR->dtStart(); |
1896 | if ( dt < cur || dt > end ) { | 1898 | if ( dt < cur || dt > end ) { |
1897 | remote->deleteIncidence( inR ); | 1899 | remote->deleteIncidence( inR ); |
1898 | ++delFut; | 1900 | ++delFut; |
1899 | } | 1901 | } |
1900 | inR = er.next(); | 1902 | inR = er.next(); |
1901 | } | 1903 | } |
1902 | } | 1904 | } |
1903 | bar.hide(); | 1905 | bar.hide(); |
1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1906 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1905 | eventLSync->setReadOnly( false ); | 1907 | if ( mMultiResourceSync ) { |
1906 | eventLSync->setDtStart( mLastCalendarSync ); | 1908 | remote->removeSyncInfo( "" ); //all |
1907 | eventRSync->setDtStart( mLastCalendarSync ); | 1909 | |
1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1910 | } else { |
1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1911 | eventLSync->setReadOnly( false ); |
1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1912 | eventLSync->setDtStart( mLastCalendarSync ); |
1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1913 | eventRSync->setDtStart( mLastCalendarSync ); |
1912 | eventLSync->setReadOnly( true ); | 1914 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1915 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | ||
1916 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | ||
1917 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | ||
1918 | eventLSync->setReadOnly( true ); | ||
1919 | } | ||
1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1920 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1921 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... |
1915 | remote->addEvent( eventRSync ); | 1922 | remote->addEvent( eventRSync ); |
1916 | else | 1923 | else |
1917 | delete eventRSync; | 1924 | delete eventRSync; |
1918 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1925 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1919 | QString mes; | 1926 | QString mes; |
1920 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1927 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1921 | QString delmess; | 1928 | QString delmess; |
1922 | if ( delFut ) { | 1929 | if ( delFut ) { |
1923 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1930 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1924 | mes += delmess; | 1931 | mes += delmess; |
1925 | } | 1932 | } |
1926 | mes = i18n("Local calendar changed!\n") +mes; | 1933 | mes = i18n("Local calendar changed!\n") +mes; |
1927 | mCalendar->checkAlarmForIncidence( 0, true ); | 1934 | mCalendar->checkAlarmForIncidence( 0, true ); |
1928 | qDebug( mes ); | 1935 | qDebug( mes ); |
1929 | if ( mSyncManager->mShowSyncSummary ) { | 1936 | if ( mSyncManager->mShowSyncSummary ) { |
1930 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1937 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1931 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1938 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1932 | qDebug("KO: WB cancelled "); | 1939 | qDebug("KO: WB cancelled "); |
1933 | mSyncManager->mWriteBackFile = false; | 1940 | mSyncManager->mWriteBackFile = false; |
1934 | return syncOK; | 1941 | return syncOK; |
1935 | } | 1942 | } |
1936 | } | 1943 | } |
1937 | return syncOK; | 1944 | return syncOK; |
1938 | } | 1945 | } |
1939 | 1946 | ||
1940 | void CalendarView::setSyncDevice( QString s ) | 1947 | void CalendarView::setSyncDevice( QString s ) |
1941 | { | 1948 | { |
1942 | mCurrentSyncDevice= s; | 1949 | mCurrentSyncDevice= s; |
1943 | } | 1950 | } |
1944 | void CalendarView::setSyncName( QString s ) | 1951 | void CalendarView::setSyncName( QString s ) |
1945 | { | 1952 | { |
1946 | mCurrentSyncName= s; | 1953 | mCurrentSyncName= s; |
1947 | } | 1954 | } |
1948 | bool CalendarView::syncCalendar(QString filename, int mode) | 1955 | bool CalendarView::syncCalendar(QString filename, int mode) |
1949 | { | 1956 | { |
1950 | //qDebug("syncCalendar %s ", filename.latin1()); | 1957 | //qDebug("syncCalendar %s ", filename.latin1()); |
1951 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1958 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1952 | CalendarLocal* calendar = new CalendarLocal(); | 1959 | CalendarLocal* calendar = new CalendarLocal(); |
1953 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1960 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1954 | FileStorage* storage = new FileStorage( calendar ); | 1961 | FileStorage* storage = new FileStorage( calendar ); |
1955 | bool syncOK = false; | 1962 | bool syncOK = false; |
1956 | storage->setFileName( filename ); | 1963 | storage->setFileName( filename ); |
1957 | // qDebug("loading ... "); | 1964 | // qDebug("loading ... "); |
1958 | if ( storage->load() ) { | 1965 | if ( storage->load() ) { |
1959 | getEventViewerDialog()->setSyncMode( true ); | 1966 | getEventViewerDialog()->setSyncMode( true ); |
1960 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1967 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1961 | getEventViewerDialog()->setSyncMode( false ); | 1968 | getEventViewerDialog()->setSyncMode( false ); |
1962 | if ( syncOK ) { | 1969 | if ( syncOK ) { |
@@ -2390,219 +2397,263 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
2390 | mTodoList->setDocumentId( filename ); | 2397 | mTodoList->setDocumentId( filename ); |
2391 | } | 2398 | } |
2392 | globalFlagBlockAgenda = 2; | 2399 | globalFlagBlockAgenda = 2; |
2393 | // if ( getLastSyncEvent() ) | 2400 | // if ( getLastSyncEvent() ) |
2394 | // getLastSyncEvent()->setReadOnly( true ); | 2401 | // getLastSyncEvent()->setReadOnly( true ); |
2395 | mCalendar->reInitAlarmSettings(); | 2402 | mCalendar->reInitAlarmSettings(); |
2396 | setSyncEventsReadOnly(); | 2403 | setSyncEventsReadOnly(); |
2397 | //updateUnmanagedViews(); | 2404 | //updateUnmanagedViews(); |
2398 | //updateView(); | 2405 | //updateView(); |
2399 | if ( filename != MainWindow::defaultFileName() ) { | 2406 | if ( filename != MainWindow::defaultFileName() ) { |
2400 | saveCalendar( MainWindow::defaultFileName() ); | 2407 | saveCalendar( MainWindow::defaultFileName() ); |
2401 | } else { | 2408 | } else { |
2402 | QFileInfo finf ( MainWindow::defaultFileName()); | 2409 | QFileInfo finf ( MainWindow::defaultFileName()); |
2403 | if ( finf.exists() ) { | 2410 | if ( finf.exists() ) { |
2404 | setLoadedFileVersion( finf.lastModified () ); | 2411 | setLoadedFileVersion( finf.lastModified () ); |
2405 | } | 2412 | } |
2406 | } | 2413 | } |
2407 | return true; | 2414 | return true; |
2408 | } else { | 2415 | } else { |
2409 | // while failing to load, the calendar object could | 2416 | // while failing to load, the calendar object could |
2410 | // have become partially populated. Clear it out. | 2417 | // have become partially populated. Clear it out. |
2411 | if ( !merge ) { | 2418 | if ( !merge ) { |
2412 | mCalendar->close(); | 2419 | mCalendar->close(); |
2413 | mViewManager->setDocumentId( filename ); | 2420 | mViewManager->setDocumentId( filename ); |
2414 | mDialogManager->setDocumentId( filename ); | 2421 | mDialogManager->setDocumentId( filename ); |
2415 | mTodoList->setDocumentId( filename ); | 2422 | mTodoList->setDocumentId( filename ); |
2416 | } | 2423 | } |
2417 | 2424 | ||
2418 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 2425 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
2419 | 2426 | ||
2420 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 2427 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
2421 | globalFlagBlockAgenda = 2; | 2428 | globalFlagBlockAgenda = 2; |
2422 | mCalendar->reInitAlarmSettings(); | 2429 | mCalendar->reInitAlarmSettings(); |
2423 | setSyncEventsReadOnly(); | 2430 | setSyncEventsReadOnly(); |
2424 | updateUnmanagedViews(); | 2431 | updateUnmanagedViews(); |
2425 | updateView(); | 2432 | updateView(); |
2426 | } | 2433 | } |
2427 | return false; | 2434 | return false; |
2428 | } | 2435 | } |
2429 | void CalendarView::mergeFile( QString fn ) | 2436 | void CalendarView::mergeFile( QString fn ) |
2430 | { | 2437 | { |
2431 | clearAllViews(); | 2438 | clearAllViews(); |
2432 | mCalendar->mergeCalendarFile( fn ); | 2439 | mCalendar->mergeCalendarFile( fn ); |
2433 | mCalendar->reInitAlarmSettings(); | 2440 | mCalendar->reInitAlarmSettings(); |
2434 | setSyncEventsReadOnly(); | 2441 | setSyncEventsReadOnly(); |
2435 | updateUnmanagedViews(); | 2442 | updateUnmanagedViews(); |
2436 | updateView(); | 2443 | updateView(); |
2437 | } | 2444 | } |
2445 | void CalendarView::mergeFileResource( QString fn ,QString resource ) | ||
2446 | { | ||
2447 | |||
2448 | if ( resource == "ALL" ) { | ||
2449 | mergeFile( fn ); | ||
2450 | return; | ||
2451 | } | ||
2452 | |||
2453 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
2454 | if ( !exclusiveResource ) { | ||
2455 | qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); | ||
2456 | return; | ||
2457 | } | ||
2458 | clearAllViews(); | ||
2459 | mCalendar->setCalendarRemove( exclusiveResource ); | ||
2460 | int def = mCalendar->defaultCalendar(); | ||
2461 | mCalendar->setDefaultCalendar(exclusiveResource); | ||
2462 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { | ||
2463 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); | ||
2464 | } | ||
2465 | mCalendar->setDefaultCalendar( def ); | ||
2466 | mCalendar->reInitAlarmSettings(); | ||
2467 | setSyncEventsReadOnly(); | ||
2468 | updateUnmanagedViews(); | ||
2469 | updateView(); | ||
2470 | } | ||
2438 | void CalendarView::showOpenError() | 2471 | void CalendarView::showOpenError() |
2439 | { | 2472 | { |
2440 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2473 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
2441 | } | 2474 | } |
2442 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 2475 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
2443 | { | 2476 | { |
2444 | loadedFileVersion = dt; | 2477 | loadedFileVersion = dt; |
2445 | } | 2478 | } |
2446 | bool CalendarView::checkFileChanged(QString fn) | 2479 | bool CalendarView::checkFileChanged(QString fn) |
2447 | { | 2480 | { |
2448 | QFileInfo finf ( fn ); | 2481 | QFileInfo finf ( fn ); |
2449 | if ( !finf.exists() ) | 2482 | if ( !finf.exists() ) |
2450 | return true; | 2483 | return true; |
2451 | QDateTime dt = finf.lastModified (); | 2484 | QDateTime dt = finf.lastModified (); |
2452 | if ( dt <= loadedFileVersion ) | 2485 | if ( dt <= loadedFileVersion ) |
2453 | return false; | 2486 | return false; |
2454 | return true; | 2487 | return true; |
2455 | 2488 | ||
2456 | } | 2489 | } |
2457 | void CalendarView::watchSavedFile() | 2490 | void CalendarView::watchSavedFile() |
2458 | { | 2491 | { |
2459 | QFileInfo finf ( MainWindow::defaultFileName()); | 2492 | QFileInfo finf ( MainWindow::defaultFileName()); |
2460 | if ( !finf.exists() ) | 2493 | if ( !finf.exists() ) |
2461 | return; | 2494 | return; |
2462 | QDateTime dt = finf.lastModified (); | 2495 | QDateTime dt = finf.lastModified (); |
2463 | if ( dt < loadedFileVersion ) { | 2496 | if ( dt < loadedFileVersion ) { |
2464 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 2497 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
2465 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 2498 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
2466 | return; | 2499 | return; |
2467 | } | 2500 | } |
2468 | loadedFileVersion = dt; | 2501 | loadedFileVersion = dt; |
2469 | } | 2502 | } |
2470 | bool CalendarView::checkAllFileVersions() | 2503 | bool CalendarView::checkAllFileVersions() |
2471 | { | 2504 | { |
2472 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2505 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2473 | KopiCalendarFile * cal = calendars.first(); | 2506 | KopiCalendarFile * cal = calendars.first(); |
2474 | mCalendar->setDefaultCalendar( 1 ); | 2507 | mCalendar->setDefaultCalendar( 1 ); |
2475 | mCalendar->setDefaultCalendarEnabledOnly(); | 2508 | mCalendar->setDefaultCalendarEnabledOnly(); |
2476 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2509 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2477 | if ( !checkFileVersion(MainWindow::defaultFileName())) { | 2510 | if ( !checkFileVersion(MainWindow::defaultFileName())) { |
2478 | restoreCalendarSettings(); | 2511 | restoreCalendarSettings(); |
2479 | return false; | 2512 | return false; |
2480 | } | 2513 | } |
2481 | } | 2514 | } |
2482 | cal = calendars.next(); | 2515 | cal = calendars.next(); |
2483 | QDateTime storeTemp = loadedFileVersion; | 2516 | QDateTime storeTemp = loadedFileVersion; |
2484 | while ( cal ) { | 2517 | while ( cal ) { |
2485 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2518 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2486 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2519 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2487 | mCalendar->setDefaultCalendarEnabledOnly(); | 2520 | mCalendar->setDefaultCalendarEnabledOnly(); |
2488 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); | 2521 | loadedFileVersion = cal->mLoadDt.addSecs( 15 ); |
2489 | if ( !checkFileVersion(cal->mFileName )) { | 2522 | if ( !checkFileVersion(cal->mFileName )) { |
2490 | loadedFileVersion = storeTemp; | 2523 | loadedFileVersion = storeTemp; |
2491 | restoreCalendarSettings(); | 2524 | restoreCalendarSettings(); |
2492 | return false; | 2525 | return false; |
2493 | } | 2526 | } |
2494 | } | 2527 | } |
2495 | cal = calendars.next(); | 2528 | cal = calendars.next(); |
2496 | } | 2529 | } |
2497 | loadedFileVersion = storeTemp; | 2530 | loadedFileVersion = storeTemp; |
2498 | return true; | 2531 | return true; |
2499 | } | 2532 | } |
2500 | bool CalendarView::checkFileVersion(QString fn) | 2533 | bool CalendarView::checkFileVersion(QString fn) |
2501 | { | 2534 | { |
2502 | QFileInfo finf ( fn ); | 2535 | QFileInfo finf ( fn ); |
2503 | if ( !finf.exists() ) | 2536 | if ( !finf.exists() ) |
2504 | return true; | 2537 | return true; |
2505 | QDateTime dt = finf.lastModified (); | 2538 | QDateTime dt = finf.lastModified (); |
2506 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); | 2539 | //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); |
2507 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); | 2540 | //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); |
2508 | if ( dt <= loadedFileVersion ) | 2541 | if ( dt <= loadedFileVersion ) |
2509 | return true; | 2542 | return true; |
2510 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 2543 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
2511 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 2544 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
2512 | i18n("Sync+save")); | 2545 | i18n("Sync+save")); |
2513 | 2546 | ||
2514 | if ( km == KMessageBox::Cancel ) | 2547 | if ( km == KMessageBox::Cancel ) |
2515 | return false; | 2548 | return false; |
2516 | if ( km == KMessageBox::Yes ) | 2549 | if ( km == KMessageBox::Yes ) |
2517 | return true; | 2550 | return true; |
2518 | 2551 | ||
2519 | setSyncDevice("deleteaftersync" ); | 2552 | setSyncDevice("deleteaftersync" ); |
2520 | mSyncManager->mAskForPreferences = true; | 2553 | mSyncManager->mAskForPreferences = true; |
2521 | mSyncManager->mSyncAlgoPrefs = 3; | 2554 | mSyncManager->mSyncAlgoPrefs = 3; |
2522 | mSyncManager->mWriteBackFile = false; | 2555 | mSyncManager->mWriteBackFile = false; |
2523 | mSyncManager->mWriteBackExistingOnly = false; | 2556 | mSyncManager->mWriteBackExistingOnly = false; |
2524 | mSyncManager->mShowSyncSummary = false; | 2557 | mSyncManager->mShowSyncSummary = false; |
2558 | mMultiResourceSync = false; | ||
2525 | syncCalendar( fn, 3 ); | 2559 | syncCalendar( fn, 3 ); |
2526 | Event * e = getLastSyncEvent(); | 2560 | Event * e = getLastSyncEvent(); |
2527 | if ( e ) | 2561 | if ( e ) |
2528 | mCalendar->deleteEvent( e ); | 2562 | mCalendar->deleteEvent( e ); |
2529 | return true; | 2563 | return true; |
2530 | } | 2564 | } |
2531 | bool CalendarView::saveCalendars() | 2565 | bool CalendarView::saveCalendars() |
2532 | { | 2566 | { |
2533 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 2567 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
2534 | KopiCalendarFile * cal = calendars.first(); | 2568 | KopiCalendarFile * cal = calendars.first(); |
2535 | mCalendar->setDefaultCalendar( 1 ); | 2569 | mCalendar->setDefaultCalendar( 1 ); |
2536 | mCalendar->setDefaultCalendarEnabledOnly(); | 2570 | mCalendar->setDefaultCalendarEnabledOnly(); |
2537 | QString saveError; | 2571 | QString saveError; |
2538 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) | 2572 | if ( !saveCalendar( MainWindow::defaultFileName() ) ) |
2539 | saveError = cal->mName +"\n"; | 2573 | saveError = cal->mName +"\n"; |
2540 | cal = calendars.next(); | 2574 | cal = calendars.next(); |
2541 | while ( cal ) { | 2575 | while ( cal ) { |
2542 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { | 2576 | if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { |
2543 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 2577 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
2544 | mCalendar->setDefaultCalendarEnabledOnly(); | 2578 | mCalendar->setDefaultCalendarEnabledOnly(); |
2545 | if ( saveCalendar( cal->mFileName ) ) | 2579 | if ( saveCalendar( cal->mFileName ) ) |
2546 | cal->mLoadDt = QDateTime::currentDateTime(); | 2580 | cal->mLoadDt = QDateTime::currentDateTime(); |
2547 | else | 2581 | else |
2548 | saveError += cal->mName + "\n"; | 2582 | saveError += cal->mName + "\n"; |
2549 | } | 2583 | } |
2550 | cal = calendars.next(); | 2584 | cal = calendars.next(); |
2551 | } | 2585 | } |
2552 | restoreCalendarSettings(); | 2586 | restoreCalendarSettings(); |
2553 | //saveError = "test error"; | 2587 | //saveError = "test error"; |
2554 | if ( !saveError.isEmpty() ) { | 2588 | if ( !saveError.isEmpty() ) { |
2555 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; | 2589 | saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; |
2556 | KMessageBox::error(this, saveError, i18n("Error saving data")); | 2590 | KMessageBox::error(this, saveError, i18n("Error saving data")); |
2557 | return false; | 2591 | return false; |
2558 | } | 2592 | } |
2559 | return true; | 2593 | return true; |
2560 | } | 2594 | } |
2595 | bool CalendarView::saveCalendarResource(QString filename, QString resource) | ||
2596 | { | ||
2597 | if ( resource == "ALL" ) | ||
2598 | return saveCalendar( filename ); | ||
2599 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
2600 | if ( !exclusiveResource ) { | ||
2601 | qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); | ||
2602 | return false; | ||
2603 | } | ||
2604 | mCalendar->setDefaultCalendar( exclusiveResource ); | ||
2605 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2606 | mCalendar->setSyncEventsEnabled(); | ||
2607 | bool res = saveCalendar( filename ); | ||
2608 | restoreCalendarSettings(); | ||
2609 | return res; | ||
2610 | |||
2611 | } | ||
2561 | bool CalendarView::saveCalendar( QString filename ) | 2612 | bool CalendarView::saveCalendar( QString filename ) |
2562 | { | 2613 | { |
2563 | 2614 | ||
2564 | // Store back all unsaved data into calendar object | 2615 | // Store back all unsaved data into calendar object |
2565 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 2616 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
2566 | if ( mViewManager->currentView() ) | 2617 | if ( mViewManager->currentView() ) |
2567 | mViewManager->currentView()->flushView(); | 2618 | mViewManager->currentView()->flushView(); |
2568 | 2619 | ||
2569 | 2620 | ||
2570 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 2621 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
2571 | mStorage->setSaveFormat( new ICalFormat() ); | 2622 | mStorage->setSaveFormat( new ICalFormat() ); |
2572 | mStorage->setFileName( filename ); | 2623 | mStorage->setFileName( filename ); |
2573 | bool success; | 2624 | bool success; |
2574 | success = mStorage->save(); | 2625 | success = mStorage->save(); |
2575 | if ( !success ) { | 2626 | if ( !success ) { |
2576 | return false; | 2627 | return false; |
2577 | } | 2628 | } |
2578 | if ( filename == MainWindow::defaultFileName() ) { | 2629 | if ( filename == MainWindow::defaultFileName() ) { |
2579 | setLoadedFileVersion( lfv ); | 2630 | setLoadedFileVersion( lfv ); |
2580 | watchSavedFile(); | 2631 | watchSavedFile(); |
2581 | } | 2632 | } |
2582 | return true; | 2633 | return true; |
2583 | } | 2634 | } |
2584 | 2635 | ||
2585 | void CalendarView::closeCalendar() | 2636 | void CalendarView::closeCalendar() |
2586 | { | 2637 | { |
2587 | 2638 | ||
2588 | // child windows no longer valid | 2639 | // child windows no longer valid |
2589 | clearAllViews(); | 2640 | clearAllViews(); |
2590 | emit closingDown(); | 2641 | emit closingDown(); |
2591 | 2642 | ||
2592 | mCalendar->close(); | 2643 | mCalendar->close(); |
2593 | setModified(false); | 2644 | setModified(false); |
2594 | updateView(); | 2645 | updateView(); |
2595 | } | 2646 | } |
2596 | 2647 | ||
2597 | void CalendarView::archiveCalendar() | 2648 | void CalendarView::archiveCalendar() |
2598 | { | 2649 | { |
2599 | mDialogManager->showArchiveDialog(); | 2650 | mDialogManager->showArchiveDialog(); |
2600 | } | 2651 | } |
2601 | 2652 | ||
2602 | 2653 | ||
2603 | void CalendarView::readSettings() | 2654 | void CalendarView::readSettings() |
2604 | { | 2655 | { |
2605 | 2656 | ||
2606 | 2657 | ||
2607 | // mViewManager->showAgendaView(); | 2658 | // mViewManager->showAgendaView(); |
2608 | QString str; | 2659 | QString str; |
@@ -4987,97 +5038,101 @@ bool CalendarView::removeCompletedSubTodos( Todo* t ) | |||
4987 | } | 5038 | } |
4988 | if ( deleteTodo ) { | 5039 | if ( deleteTodo ) { |
4989 | if ( t->isCompleted() && !t->doesRecur()) { | 5040 | if ( t->isCompleted() && !t->doesRecur()) { |
4990 | checkExternalId( t ); | 5041 | checkExternalId( t ); |
4991 | mCalendar->deleteTodo( t ); | 5042 | mCalendar->deleteTodo( t ); |
4992 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 5043 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
4993 | } | 5044 | } |
4994 | else | 5045 | else |
4995 | deleteTodo = false; | 5046 | deleteTodo = false; |
4996 | } | 5047 | } |
4997 | return deleteTodo; | 5048 | return deleteTodo; |
4998 | 5049 | ||
4999 | } | 5050 | } |
5000 | void CalendarView::purgeCompleted() | 5051 | void CalendarView::purgeCompleted() |
5001 | { | 5052 | { |
5002 | int result = KMessageBox::warningContinueCancel(this, | 5053 | int result = KMessageBox::warningContinueCancel(this, |
5003 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); | 5054 | i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); |
5004 | 5055 | ||
5005 | if (result == KMessageBox::Continue) { | 5056 | if (result == KMessageBox::Continue) { |
5006 | 5057 | ||
5007 | QPtrList<Todo> todoCal; | 5058 | QPtrList<Todo> todoCal; |
5008 | QPtrList<Todo> rootTodos; | 5059 | QPtrList<Todo> rootTodos; |
5009 | //QPtrList<Incidence> rel; | 5060 | //QPtrList<Incidence> rel; |
5010 | Todo *aTodo; | 5061 | Todo *aTodo; |
5011 | todoCal = calendar()->todos(); | 5062 | todoCal = calendar()->todos(); |
5012 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 5063 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
5013 | if ( !aTodo->relatedTo() ) | 5064 | if ( !aTodo->relatedTo() ) |
5014 | rootTodos.append( aTodo ); | 5065 | rootTodos.append( aTodo ); |
5015 | } | 5066 | } |
5016 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 5067 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
5017 | removeCompletedSubTodos( aTodo ); | 5068 | removeCompletedSubTodos( aTodo ); |
5018 | } | 5069 | } |
5019 | 5070 | ||
5020 | updateView(); | 5071 | updateView(); |
5021 | } | 5072 | } |
5022 | } | 5073 | } |
5023 | 5074 | ||
5024 | void CalendarView::slotCalendarChanged() | 5075 | void CalendarView::slotCalendarChanged() |
5025 | { | 5076 | { |
5026 | ; | 5077 | ; |
5027 | } | 5078 | } |
5028 | 5079 | ||
5029 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 5080 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
5030 | { | 5081 | { |
5031 | //qDebug("CalendarView::keyPressEvent "); | 5082 | //qDebug("CalendarView::keyPressEvent "); |
5032 | e->ignore(); | 5083 | e->ignore(); |
5033 | } | 5084 | } |
5034 | 5085 | ||
5086 | void CalendarView::multiResourceSyncStart( bool start ) | ||
5087 | { | ||
5088 | mMultiResourceSync = start; | ||
5035 | 5089 | ||
5090 | } | ||
5036 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 5091 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5037 | { | 5092 | { |
5038 | 5093 | ||
5039 | if ( manager != mSyncManager) | 5094 | if ( manager != mSyncManager) |
5040 | qDebug("KO: Internal error-1. SyncManager mismatch "); | 5095 | qDebug("KO: Internal error-1. SyncManager mismatch "); |
5041 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 5096 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
5042 | qDebug("KO: SyncKDE request detected!"); | 5097 | qDebug("KO: SyncKDE request detected!"); |
5043 | } | 5098 | } |
5044 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5099 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5045 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5100 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5046 | if ( !resource.isEmpty() ) { | 5101 | if ( !resource.isEmpty() ) { |
5047 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | 5102 | int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); |
5048 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); | 5103 | qDebug( "KO: Sync request for resource: %s", resource.latin1() ); |
5049 | 5104 | ||
5050 | if ( !exclusiveSyncResource ) { | 5105 | if ( !exclusiveSyncResource ) { |
5051 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); | 5106 | qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); |
5052 | return false; | 5107 | return false; |
5053 | } | 5108 | } |
5054 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); | 5109 | mCalendar->setDefaultCalendar( exclusiveSyncResource ); |
5055 | mCalendar->setDefaultCalendarEnabledOnly(); | 5110 | mCalendar->setDefaultCalendarEnabledOnly(); |
5056 | } | 5111 | } |
5057 | bool result = syncCalendar( filename, mode ); | 5112 | bool result = syncCalendar( filename, mode ); |
5058 | if ( !resource.isEmpty() ) | 5113 | if ( !resource.isEmpty() ) |
5059 | restoreCalendarSettings(); | 5114 | restoreCalendarSettings(); |
5060 | return result; | 5115 | return result; |
5061 | } | 5116 | } |
5062 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 5117 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
5063 | { | 5118 | { |
5064 | //mSyncManager = manager; | 5119 | //mSyncManager = manager; |
5065 | if ( manager != mSyncManager) | 5120 | if ( manager != mSyncManager) |
5066 | qDebug("KO: Internal error-2. SyncManager mismatch "); | 5121 | qDebug("KO: Internal error-2. SyncManager mismatch "); |
5067 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 5122 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
5068 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 5123 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
5069 | if ( resource == "sharp" ) | 5124 | if ( resource == "sharp" ) |
5070 | syncExternal( 0 ); | 5125 | syncExternal( 0 ); |
5071 | if ( resource == "phone" ) | 5126 | if ( resource == "phone" ) |
5072 | syncExternal( 1 ); | 5127 | syncExternal( 1 ); |
5073 | // pending setmodified | 5128 | // pending setmodified |
5074 | return true; | 5129 | return true; |
5075 | } | 5130 | } |
5076 | void CalendarView::setSyncManager(KSyncManager* manager) | 5131 | void CalendarView::setSyncManager(KSyncManager* manager) |
5077 | { | 5132 | { |
5078 | mSyncManager = manager; | 5133 | mSyncManager = manager; |
5079 | } | 5134 | } |
5080 | 5135 | ||
5081 | void CalendarView::removeSyncInfo( QString syncProfile) | 5136 | void CalendarView::removeSyncInfo( QString syncProfile) |
5082 | { | 5137 | { |
5083 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 5138 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index f85b6a3..60b1276 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -94,203 +94,206 @@ class MissedAlarmTextBrowser : public QTextBrowser { | |||
94 | ~MissedAlarmTextBrowser(); | 94 | ~MissedAlarmTextBrowser(); |
95 | void setSource(const QString & n); | 95 | void setSource(const QString & n); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | Incidence * getNextInc(QDateTime start ); | 98 | Incidence * getNextInc(QDateTime start ); |
99 | QPtrList<Incidence> mAlarms; | 99 | QPtrList<Incidence> mAlarms; |
100 | signals: | 100 | signals: |
101 | void showIncidence( QString uid); | 101 | void showIncidence( QString uid); |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 105 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
106 | { | 106 | { |
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | public: | 108 | public: |
109 | /** | 109 | /** |
110 | Constructs a new calendar view widget. | 110 | Constructs a new calendar view widget. |
111 | 111 | ||
112 | @param calendar calendar document | 112 | @param calendar calendar document |
113 | @param parent parent window | 113 | @param parent parent window |
114 | @param name Qt internal widget object name | 114 | @param name Qt internal widget object name |
115 | */ | 115 | */ |
116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 116 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
117 | const char *name = 0 ); | 117 | const char *name = 0 ); |
118 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 118 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
119 | const char *name = 0 ); | 119 | const char *name = 0 ); |
120 | virtual ~CalendarView(); | 120 | virtual ~CalendarView(); |
121 | 121 | ||
122 | Calendar *calendar() { return mCalendar; } | 122 | Calendar *calendar() { return mCalendar; } |
123 | 123 | ||
124 | KOViewManager *viewManager(); | 124 | KOViewManager *viewManager(); |
125 | KODialogManager *dialogManager(); | 125 | KODialogManager *dialogManager(); |
126 | 126 | ||
127 | QDate startDate(); | 127 | QDate startDate(); |
128 | QDate endDate(); | 128 | QDate endDate(); |
129 | 129 | ||
130 | QWidgetStack *viewStack(); | 130 | QWidgetStack *viewStack(); |
131 | QWidget *leftFrame(); | 131 | QWidget *leftFrame(); |
132 | 132 | ||
133 | DateNavigator *dateNavigator(); | 133 | DateNavigator *dateNavigator(); |
134 | KDateNavigator *dateNavigatorWidget(); | 134 | KDateNavigator *dateNavigatorWidget(); |
135 | 135 | ||
136 | void addView(KOrg::BaseView *); | 136 | void addView(KOrg::BaseView *); |
137 | void showView(KOrg::BaseView *); | 137 | void showView(KOrg::BaseView *); |
138 | KOEventViewerDialog* getEventViewerDialog(); | 138 | KOEventViewerDialog* getEventViewerDialog(); |
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | void mergeFile( QString fn ); | 141 | void mergeFile( QString fn ); |
142 | void mergeFileResource( QString fn ,QString res); | ||
142 | 143 | ||
143 | signals: | 144 | signals: |
144 | void save (); | 145 | void save (); |
145 | void saveStopTimer (); | 146 | void saveStopTimer (); |
146 | void tempDisableBR(bool); | 147 | void tempDisableBR(bool); |
147 | /** This todo has been modified */ | 148 | /** This todo has been modified */ |
148 | void todoModified(Todo *, int); | 149 | void todoModified(Todo *, int); |
149 | 150 | ||
150 | /** when change is made to options dialog, the topwidget will catch this | 151 | /** when change is made to options dialog, the topwidget will catch this |
151 | * and emit this signal which notifies all widgets which have registered | 152 | * and emit this signal which notifies all widgets which have registered |
152 | * for notification to update their settings. */ | 153 | * for notification to update their settings. */ |
153 | void configChanged(); | 154 | void configChanged(); |
154 | /** emitted when the topwidget is closing down, so that any attached | 155 | /** emitted when the topwidget is closing down, so that any attached |
155 | child windows can also close. */ | 156 | child windows can also close. */ |
156 | void closingDown(); | 157 | void closingDown(); |
157 | /** emitted right before we die */ | 158 | /** emitted right before we die */ |
158 | void closed(QWidget *); | 159 | void closed(QWidget *); |
159 | 160 | ||
160 | /** Emitted when state of modified flag changes */ | 161 | /** Emitted when state of modified flag changes */ |
161 | void modifiedChanged(bool); | 162 | void modifiedChanged(bool); |
162 | void signalmodified(); | 163 | void signalmodified(); |
163 | 164 | ||
164 | /** Emitted when state of read-only flag changes */ | 165 | /** Emitted when state of read-only flag changes */ |
165 | void readOnlyChanged(bool); | 166 | void readOnlyChanged(bool); |
166 | 167 | ||
167 | /** Emitted when the unit of navigation changes */ | 168 | /** Emitted when the unit of navigation changes */ |
168 | void changeNavStringPrev(const QString &); | 169 | void changeNavStringPrev(const QString &); |
169 | void changeNavStringNext(const QString &); | 170 | void changeNavStringNext(const QString &); |
170 | 171 | ||
171 | /** Emitted when state of events selection has changed and user is organizer*/ | 172 | /** Emitted when state of events selection has changed and user is organizer*/ |
172 | void organizerEventsSelected(bool); | 173 | void organizerEventsSelected(bool); |
173 | /** Emitted when state of events selection has changed and user is attendee*/ | 174 | /** Emitted when state of events selection has changed and user is attendee*/ |
174 | void groupEventsSelected(bool); | 175 | void groupEventsSelected(bool); |
175 | /** | 176 | /** |
176 | Emitted when an incidence gets selected. If the selection is cleared the | 177 | Emitted when an incidence gets selected. If the selection is cleared the |
177 | signal is emitted with 0 as argument. | 178 | signal is emitted with 0 as argument. |
178 | */ | 179 | */ |
179 | void incidenceSelected( Incidence * ); | 180 | void incidenceSelected( Incidence * ); |
180 | /** Emitted, when a todoitem is selected or deselected. */ | 181 | /** Emitted, when a todoitem is selected or deselected. */ |
181 | void todoSelected( bool ); | 182 | void todoSelected( bool ); |
182 | 183 | ||
183 | /** | 184 | /** |
184 | Emitted, when clipboard content changes. Parameter indicates if paste | 185 | Emitted, when clipboard content changes. Parameter indicates if paste |
185 | is possible or not. | 186 | is possible or not. |
186 | */ | 187 | */ |
187 | void pasteEnabled(bool); | 188 | void pasteEnabled(bool); |
188 | 189 | ||
189 | /** Emitted, when the number of incoming messages has changed. */ | 190 | /** Emitted, when the number of incoming messages has changed. */ |
190 | void numIncomingChanged(int); | 191 | void numIncomingChanged(int); |
191 | 192 | ||
192 | /** Emitted, when the number of outgoing messages has changed. */ | 193 | /** Emitted, when the number of outgoing messages has changed. */ |
193 | void numOutgoingChanged(int); | 194 | void numOutgoingChanged(int); |
194 | 195 | ||
195 | /** Send status message, which can e.g. be displayed in the status bar. */ | 196 | /** Send status message, which can e.g. be displayed in the status bar. */ |
196 | void statusMessage(const QString &); | 197 | void statusMessage(const QString &); |
197 | 198 | ||
198 | void calendarViewExpanded( bool ); | 199 | void calendarViewExpanded( bool ); |
199 | void updateSearchDialog(); | 200 | void updateSearchDialog(); |
200 | void filtersUpdated(); | 201 | void filtersUpdated(); |
201 | 202 | ||
202 | 203 | ||
203 | public slots: | 204 | public slots: |
205 | void multiResourceSyncStart( bool ); | ||
204 | void displayCalendarInfo( int id ); | 206 | void displayCalendarInfo( int id ); |
205 | void nextConflict( bool all, bool allday ); | 207 | void nextConflict( bool all, bool allday ); |
206 | void conflictAll(); | 208 | void conflictAll(); |
207 | void conflictAllday(); | 209 | void conflictAllday(); |
208 | void conflictNotAll(); | 210 | void conflictNotAll(); |
209 | void setCalReadOnly( int id, bool readO ); | 211 | void setCalReadOnly( int id, bool readO ); |
210 | void checkAlarms(); | 212 | void checkAlarms(); |
211 | void checkFiles(); | 213 | void checkFiles(); |
212 | void slotprintSelInc(); | 214 | void slotprintSelInc(); |
213 | void showNextAlarms(); | 215 | void showNextAlarms(); |
214 | void showOpenError(); | 216 | void showOpenError(); |
215 | void watchSavedFile(); | 217 | void watchSavedFile(); |
216 | void recheckTimerAlarm(); | 218 | void recheckTimerAlarm(); |
217 | void checkNextTimerAlarm(); | 219 | void checkNextTimerAlarm(); |
218 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 220 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
219 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 221 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
220 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 222 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
221 | 223 | ||
222 | /** options dialog made a changed to the configuration. we catch this | 224 | /** options dialog made a changed to the configuration. we catch this |
223 | * and notify all widgets which need to update their configuration. */ | 225 | * and notify all widgets which need to update their configuration. */ |
224 | void updateConfig(); | 226 | void updateConfig(); |
225 | 227 | ||
226 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 228 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
227 | const QStringList& anniversaryList, const QStringList& realNameList, | 229 | const QStringList& anniversaryList, const QStringList& realNameList, |
228 | const QStringList& emailList, const QStringList& assembledNameList, | 230 | const QStringList& emailList, const QStringList& assembledNameList, |
229 | const QStringList& uidList); | 231 | const QStringList& uidList); |
230 | 232 | ||
231 | /** | 233 | /** |
232 | Load calendar from file \a filename. If \a merge is true, load | 234 | Load calendar from file \a filename. If \a merge is true, load |
233 | calendar into existing one, if it is false, clear calendar, before | 235 | calendar into existing one, if it is false, clear calendar, before |
234 | loading. Return true, if calendar could be successfully loaded. | 236 | loading. Return true, if calendar could be successfully loaded. |
235 | */ | 237 | */ |
236 | bool openCalendar(QString filename, bool merge=false); | 238 | bool openCalendar(QString filename, bool merge=false); |
237 | bool loadCalendars(); | 239 | bool loadCalendars(); |
238 | bool saveCalendars(); | 240 | bool saveCalendars(); |
239 | bool restoreCalendarSettings(); | 241 | bool restoreCalendarSettings(); |
240 | bool addCalendar( KopiCalendarFile * ); | 242 | bool addCalendar( KopiCalendarFile * ); |
241 | void addCalendarId( int id ); | 243 | void addCalendarId( int id ); |
242 | bool syncCalendar(QString filename,int mode = 0 ); | 244 | bool syncCalendar(QString filename,int mode = 0 ); |
243 | 245 | ||
244 | /** | 246 | /** |
245 | Save calendar data to file. Return true if calendar could be | 247 | Save calendar data to file. Return true if calendar could be |
246 | successfully saved. | 248 | successfully saved. |
247 | */ | 249 | */ |
248 | bool saveCalendar(QString filename); | 250 | bool saveCalendar(QString filename); |
251 | bool saveCalendarResource(QString filename, QString resource); | ||
249 | 252 | ||
250 | /** | 253 | /** |
251 | Close calendar. Clear calendar data and reset views to display an empty | 254 | Close calendar. Clear calendar data and reset views to display an empty |
252 | calendar. | 255 | calendar. |
253 | */ | 256 | */ |
254 | void closeCalendar(); | 257 | void closeCalendar(); |
255 | 258 | ||
256 | /** Archive old events of calendar */ | 259 | /** Archive old events of calendar */ |
257 | void archiveCalendar(); | 260 | void archiveCalendar(); |
258 | 261 | ||
259 | void showIncidence(); | 262 | void showIncidence(); |
260 | void editIncidence(); | 263 | void editIncidence(); |
261 | void editIncidenceDescription(); | 264 | void editIncidenceDescription(); |
262 | void deleteIncidence(); | 265 | void deleteIncidence(); |
263 | void cloneIncidence(); | 266 | void cloneIncidence(); |
264 | void moveIncidence(); | 267 | void moveIncidence(); |
265 | void beamIncidence(); | 268 | void beamIncidence(); |
266 | void toggleCancelIncidence(); | 269 | void toggleCancelIncidence(); |
267 | 270 | ||
268 | /** create an editeventwin with supplied date/time, and if bool is true, | 271 | /** create an editeventwin with supplied date/time, and if bool is true, |
269 | * make the event take all day. */ | 272 | * make the event take all day. */ |
270 | void newEvent(QDateTime, QDateTime, bool allDay ); | 273 | void newEvent(QDateTime, QDateTime, bool allDay ); |
271 | void newEvent(QDateTime, QDateTime); | 274 | void newEvent(QDateTime, QDateTime); |
272 | void newEvent(QDateTime fh); | 275 | void newEvent(QDateTime fh); |
273 | void newEvent(QDate dt); | 276 | void newEvent(QDate dt); |
274 | /** create new event without having a date hint. Takes current date as | 277 | /** create new event without having a date hint. Takes current date as |
275 | default hint. */ | 278 | default hint. */ |
276 | void newEvent(); | 279 | void newEvent(); |
277 | void newFloatingEvent(); | 280 | void newFloatingEvent(); |
278 | 281 | ||
279 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 282 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
280 | void showIncidence(Incidence *); | 283 | void showIncidence(Incidence *); |
281 | void showIncidence(QString uid); | 284 | void showIncidence(QString uid); |
282 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 285 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
283 | void editIncidence(Incidence *); | 286 | void editIncidence(Incidence *); |
284 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 287 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
285 | void deleteIncidence(Incidence *); | 288 | void deleteIncidence(Incidence *); |
286 | void cloneIncidence(Incidence *); | 289 | void cloneIncidence(Incidence *); |
287 | void cancelIncidence(Incidence *); | 290 | void cancelIncidence(Incidence *); |
288 | /** Create an editor for the supplied event. */ | 291 | /** Create an editor for the supplied event. */ |
289 | void editEvent(Event *); | 292 | void editEvent(Event *); |
290 | /** Delete the supplied event. */ | 293 | /** Delete the supplied event. */ |
291 | void deleteEvent(Event *); | 294 | void deleteEvent(Event *); |
292 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 295 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
293 | found. */ | 296 | found. */ |
294 | bool deleteEvent(const QString &uid); | 297 | bool deleteEvent(const QString &uid); |
295 | /** Create a read-only viewer dialog for the supplied event. */ | 298 | /** Create a read-only viewer dialog for the supplied event. */ |
296 | void showEvent(Event *); | 299 | void showEvent(Event *); |
@@ -494,96 +497,97 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
494 | void beamFilteredCalendar() ; | 497 | void beamFilteredCalendar() ; |
495 | void beamIncidenceList(QPtrList<Incidence>) ; | 498 | void beamIncidenceList(QPtrList<Incidence>) ; |
496 | void manageCategories(); | 499 | void manageCategories(); |
497 | void editCategories(); | 500 | void editCategories(); |
498 | int addCategories(); | 501 | int addCategories(); |
499 | void removeCategories(); | 502 | void removeCategories(); |
500 | void setSyncDevice( QString ); | 503 | void setSyncDevice( QString ); |
501 | void setSyncName( QString ); | 504 | void setSyncName( QString ); |
502 | void showDay( QDate ); | 505 | void showDay( QDate ); |
503 | void undo_delete(); | 506 | void undo_delete(); |
504 | protected slots: | 507 | protected slots: |
505 | void resetFocus(); | 508 | void resetFocus(); |
506 | void scrollBarValue(int); | 509 | void scrollBarValue(int); |
507 | void slotViewerClosed(); | 510 | void slotViewerClosed(); |
508 | void timerAlarm(); | 511 | void timerAlarm(); |
509 | void suspendAlarm(); | 512 | void suspendAlarm(); |
510 | void beamDone( Ir *ir ); | 513 | void beamDone( Ir *ir ); |
511 | /** Select a view or adapt the current view to display the specified dates. */ | 514 | /** Select a view or adapt the current view to display the specified dates. */ |
512 | void showDates( const KCal::DateList & ); | 515 | void showDates( const KCal::DateList & ); |
513 | void selectWeekNum ( int ); | 516 | void selectWeekNum ( int ); |
514 | void checkConflictForEvent(); | 517 | void checkConflictForEvent(); |
515 | 518 | ||
516 | public: | 519 | public: |
517 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); | 520 | void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); |
518 | // show a standard warning | 521 | // show a standard warning |
519 | // returns KMsgBox::yesNoCancel() | 522 | // returns KMsgBox::yesNoCancel() |
520 | int msgCalModified(); | 523 | int msgCalModified(); |
521 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); | 524 | virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); |
522 | 525 | ||
523 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 526 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
524 | virtual void removeSyncInfo( QString syncProfile); | 527 | virtual void removeSyncInfo( QString syncProfile); |
525 | void setSyncManager(KSyncManager* manager); | 528 | void setSyncManager(KSyncManager* manager); |
526 | void setLoadedFileVersion(QDateTime); | 529 | void setLoadedFileVersion(QDateTime); |
527 | bool checkFileVersion(QString fn); | 530 | bool checkFileVersion(QString fn); |
528 | bool checkAllFileVersions(); | 531 | bool checkAllFileVersions(); |
529 | bool checkFileChanged(QString fn); | 532 | bool checkFileChanged(QString fn); |
530 | Event* getLastSyncEvent(); | 533 | Event* getLastSyncEvent(); |
531 | /** Adapt navigation units correpsonding to step size of navigation of the | 534 | /** Adapt navigation units correpsonding to step size of navigation of the |
532 | * current view. | 535 | * current view. |
533 | */ | 536 | */ |
534 | void adaptNavigationUnits(); | 537 | void adaptNavigationUnits(); |
535 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 538 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
536 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 539 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
537 | //Attendee* getYourAttendee(Event *event); | 540 | //Attendee* getYourAttendee(Event *event); |
538 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 541 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
539 | void setScrollBarStep(int val ); | 542 | void setScrollBarStep(int val ); |
540 | 543 | ||
541 | protected: | 544 | protected: |
545 | bool mMultiResourceSync; | ||
542 | Event *mConflictingEvent; | 546 | Event *mConflictingEvent; |
543 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 547 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
544 | 548 | ||
545 | // returns KMsgBox::OKCandel() | 549 | // returns KMsgBox::OKCandel() |
546 | int msgItemDelete(const QString name); | 550 | int msgItemDelete(const QString name); |
547 | void showEventEditor(); | 551 | void showEventEditor(); |
548 | void showTodoEditor(); | 552 | void showTodoEditor(); |
549 | Todo *selectedTodo(); | 553 | Todo *selectedTodo(); |
550 | private: | 554 | private: |
551 | #ifdef DESKTOP_VERSION | 555 | #ifdef DESKTOP_VERSION |
552 | QScrollBar * mDateScrollBar; | 556 | QScrollBar * mDateScrollBar; |
553 | #endif | 557 | #endif |
554 | bool flag_blockConflict; | 558 | bool flag_blockConflict; |
555 | bool flag_blockScrollBar; | 559 | bool flag_blockScrollBar; |
556 | bool flag_checkFileFirsttime; | 560 | bool flag_checkFileFirsttime; |
557 | bool flag_clearallviewsEventDisplay; | 561 | bool flag_clearallviewsEventDisplay; |
558 | bool flag_clearallviewsupdateView; | 562 | bool flag_clearallviewsupdateView; |
559 | QDateTime mNextAlarmDateTime; | 563 | QDateTime mNextAlarmDateTime; |
560 | bool mViewerCallerIsSearchDialog; | 564 | bool mViewerCallerIsSearchDialog; |
561 | bool mBlockShowDates; | 565 | bool mBlockShowDates; |
562 | KSyncManager* mSyncManager; | 566 | KSyncManager* mSyncManager; |
563 | AlarmDialog * mAlarmDialog; | 567 | AlarmDialog * mAlarmDialog; |
564 | QString mAlarmNotification; | 568 | QString mAlarmNotification; |
565 | QString mSuspendAlarmNotification; | 569 | QString mSuspendAlarmNotification; |
566 | QTimer* mSuspendTimer; | 570 | QTimer* mSuspendTimer; |
567 | QTimer* mAlarmTimer; | 571 | QTimer* mAlarmTimer; |
568 | QTimer* mRecheckAlarmTimer; | 572 | QTimer* mRecheckAlarmTimer; |
569 | void computeAlarm( QString ); | 573 | void computeAlarm( QString ); |
570 | void startAlarm( QString, QString ); | 574 | void startAlarm( QString, QString ); |
571 | void setSyncEventsReadOnly(); | 575 | void setSyncEventsReadOnly(); |
572 | 576 | ||
573 | QDateTime loadedFileVersion; | 577 | QDateTime loadedFileVersion; |
574 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 578 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
575 | void checkExternalId( Incidence * inc ); | 579 | void checkExternalId( Incidence * inc ); |
576 | int mGlobalSyncMode; | 580 | int mGlobalSyncMode; |
577 | QString mCurrentSyncDevice; | 581 | QString mCurrentSyncDevice; |
578 | QString mCurrentSyncName; | 582 | QString mCurrentSyncName; |
579 | void init(); | 583 | void init(); |
580 | int mDatePickerMode; | 584 | int mDatePickerMode; |
581 | bool mFlagEditDescription; | 585 | bool mFlagEditDescription; |
582 | QDateTime mLastCalendarSync; | 586 | QDateTime mLastCalendarSync; |
583 | void createPrinter(); | 587 | void createPrinter(); |
584 | 588 | ||
585 | void calendarModified( bool, Calendar * ); | 589 | void calendarModified( bool, Calendar * ); |
586 | 590 | ||
587 | CalPrinter *mCalPrinter; | 591 | CalPrinter *mCalPrinter; |
588 | 592 | ||
589 | QSplitter *mPanner; | 593 | QSplitter *mPanner; |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 66bb19b..69ccde1 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -329,98 +329,100 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : | |||
329 | if( !QFile::exists( defaultFileName() ) ) { | 329 | if( !QFile::exists( defaultFileName() ) ) { |
330 | QFileInfo finfo ( defaultFileName() ); | 330 | QFileInfo finfo ( defaultFileName() ); |
331 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 331 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
332 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 332 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
333 | finfo.setFile( oldFile ); | 333 | finfo.setFile( oldFile ); |
334 | if (finfo.exists() ) { | 334 | if (finfo.exists() ) { |
335 | KMessageBox::information( this, message); | 335 | KMessageBox::information( this, message); |
336 | mView->openCalendar( oldFile ); | 336 | mView->openCalendar( oldFile ); |
337 | qApp->processEvents(); | 337 | qApp->processEvents(); |
338 | } else { | 338 | } else { |
339 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 339 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
340 | finfo.setFile( oldFile ); | 340 | finfo.setFile( oldFile ); |
341 | if (finfo.exists() ) { | 341 | if (finfo.exists() ) { |
342 | KMessageBox::information( this, message); | 342 | KMessageBox::information( this, message); |
343 | mView->openCalendar( oldFile ); | 343 | mView->openCalendar( oldFile ); |
344 | qApp->processEvents(); | 344 | qApp->processEvents(); |
345 | } | 345 | } |
346 | } | 346 | } |
347 | mView->saveCalendar( defaultFileName() ); | 347 | mView->saveCalendar( defaultFileName() ); |
348 | newFile = true; | 348 | newFile = true; |
349 | } | 349 | } |
350 | 350 | ||
351 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); | 351 | //QTime neededSaveTime = QDateTime::currentDateTime().time(); |
352 | //mView->loadCalendars(); | 352 | //mView->loadCalendars(); |
353 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 353 | //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
354 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 354 | //qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
355 | 355 | ||
356 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { | 356 | if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { |
357 | KOPrefs::instance()->setAllDefaults(); | 357 | KOPrefs::instance()->setAllDefaults(); |
358 | } | 358 | } |
359 | 359 | ||
360 | 360 | ||
361 | connect( mView, SIGNAL( tempDisableBR(bool) ), | 361 | connect( mView, SIGNAL( tempDisableBR(bool) ), |
362 | SLOT( disableBR(bool) ) ); | 362 | SLOT( disableBR(bool) ) ); |
363 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 363 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
364 | setCentralWidget( mView ); | 364 | setCentralWidget( mView ); |
365 | globalFlagBlockStartup = 0; | 365 | globalFlagBlockStartup = 0; |
366 | //mView->show(); | 366 | //mView->show(); |
367 | //delete splash; | 367 | //delete splash; |
368 | if ( newFile ) | 368 | if ( newFile ) |
369 | mView->updateConfig(); | 369 | mView->updateConfig(); |
370 | // qApp->processEvents(); | 370 | // qApp->processEvents(); |
371 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 371 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
372 | //fillSyncMenu(); | 372 | //fillSyncMenu(); |
373 | 373 | ||
374 | 374 | ||
375 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 375 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
376 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 376 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
377 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 377 | connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); |
378 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 378 | connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) ); |
379 | connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) ); | ||
380 | |||
379 | mSyncManager->setDefaultFileName( sentSyncFile()); | 381 | mSyncManager->setDefaultFileName( sentSyncFile()); |
380 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 382 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
381 | mSyncManager->fillSyncMenu(); | 383 | mSyncManager->fillSyncMenu(); |
382 | 384 | ||
383 | 385 | ||
384 | 386 | ||
385 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 387 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
386 | if ( showWarning ) { | 388 | if ( showWarning ) { |
387 | KMessageBox::information( this, | 389 | KMessageBox::information( this, |
388 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 390 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
389 | //qApp->processEvents(); | 391 | //qApp->processEvents(); |
390 | mView->dialogManager()->showSyncOptions(); | 392 | mView->dialogManager()->showSyncOptions(); |
391 | } | 393 | } |
392 | 394 | ||
393 | //US listen for result adressed from Ka/Pi | 395 | //US listen for result adressed from Ka/Pi |
394 | 396 | ||
395 | #ifndef DESKTOP_VERSION | 397 | #ifndef DESKTOP_VERSION |
396 | infrared = 0; | 398 | infrared = 0; |
397 | #endif | 399 | #endif |
398 | updateFilterToolbar(); | 400 | updateFilterToolbar(); |
399 | updateWeek( mView->startDate() ); | 401 | updateWeek( mView->startDate() ); |
400 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), | 402 | connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), |
401 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); | 403 | SLOT( updateWeekNum( const KCal::DateList & ) ) ); |
402 | mBRdisabled = false; | 404 | mBRdisabled = false; |
403 | //toggleBeamReceive(); | 405 | //toggleBeamReceive(); |
404 | 406 | ||
405 | setCaption(i18n("Loading calendar files ... please wait" )); | 407 | setCaption(i18n("Loading calendar files ... please wait" )); |
406 | mSaveDelay = 0; | 408 | mSaveDelay = 0; |
407 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); | 409 | QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); |
408 | } | 410 | } |
409 | MainWindow::~MainWindow() | 411 | MainWindow::~MainWindow() |
410 | { | 412 | { |
411 | //qDebug("MainWindow::~MainWindow() "); | 413 | //qDebug("MainWindow::~MainWindow() "); |
412 | //save toolbar location | 414 | //save toolbar location |
413 | delete mCalendar; | 415 | delete mCalendar; |
414 | delete mSyncManager; | 416 | delete mSyncManager; |
415 | #ifndef DESKTOP_VERSION | 417 | #ifndef DESKTOP_VERSION |
416 | if ( infrared ) | 418 | if ( infrared ) |
417 | delete infrared; | 419 | delete infrared; |
418 | #endif | 420 | #endif |
419 | 421 | ||
420 | 422 | ||
421 | } | 423 | } |
422 | 424 | ||
423 | void MainWindow::loadDataAfterStart() | 425 | void MainWindow::loadDataAfterStart() |
424 | { | 426 | { |
425 | qDebug("KO: Start loading files..." ); | 427 | qDebug("KO: Start loading files..." ); |
426 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 428 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
@@ -2659,120 +2661,120 @@ void MainWindow::exportCalendar( bool iCalFormat ) | |||
2659 | if ( fn == "" ) | 2661 | if ( fn == "" ) |
2660 | return; | 2662 | return; |
2661 | QFileInfo info; | 2663 | QFileInfo info; |
2662 | info.setFile( fn ); | 2664 | info.setFile( fn ); |
2663 | QString mes; | 2665 | QString mes; |
2664 | bool createbup = true; | 2666 | bool createbup = true; |
2665 | if ( info. exists() ) { | 2667 | if ( info. exists() ) { |
2666 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2668 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
2667 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2669 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
2668 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2670 | i18n("Overwrite!"), i18n("Cancel"), 0, |
2669 | 0, 1 ); | 2671 | 0, 1 ); |
2670 | if ( result != 0 ) { | 2672 | if ( result != 0 ) { |
2671 | createbup = false; | 2673 | createbup = false; |
2672 | } | 2674 | } |
2673 | } | 2675 | } |
2674 | if ( createbup ) { | 2676 | if ( createbup ) { |
2675 | bool success = false; | 2677 | bool success = false; |
2676 | if ( iCalFormat ) | 2678 | if ( iCalFormat ) |
2677 | success = mView->exportICalendar( fn ); | 2679 | success = mView->exportICalendar( fn ); |
2678 | else | 2680 | else |
2679 | success = mView->exportVCalendar( fn ); | 2681 | success = mView->exportVCalendar( fn ); |
2680 | if ( success ) { | 2682 | if ( success ) { |
2681 | if ( fn.length() > 20 ) | 2683 | if ( fn.length() > 20 ) |
2682 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2684 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2683 | else | 2685 | else |
2684 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2686 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2685 | setCaption(mes); | 2687 | setCaption(mes); |
2686 | } | 2688 | } |
2687 | } | 2689 | } |
2688 | 2690 | ||
2689 | } | 2691 | } |
2690 | void MainWindow::exportICalendar() | 2692 | void MainWindow::exportICalendar() |
2691 | { | 2693 | { |
2692 | exportCalendar( true ); | 2694 | exportCalendar( true ); |
2693 | } | 2695 | } |
2694 | void MainWindow::exportVCalendar() | 2696 | void MainWindow::exportVCalendar() |
2695 | { | 2697 | { |
2696 | exportCalendar( false ); | 2698 | exportCalendar( false ); |
2697 | } | 2699 | } |
2698 | QString MainWindow::sentSyncFile() | 2700 | QString MainWindow::sentSyncFile() |
2699 | { | 2701 | { |
2700 | #ifdef DESKTOP_VERSION | 2702 | #ifdef DESKTOP_VERSION |
2701 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); | 2703 | return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); |
2702 | #else | 2704 | #else |
2703 | return QString( "/tmp/copysynccal.ics" ); | 2705 | return QString( "/tmp/copysynccal.ics" ); |
2704 | #endif | 2706 | #endif |
2705 | } | 2707 | } |
2706 | 2708 | ||
2707 | void MainWindow::syncFileRequest() | 2709 | void MainWindow::syncFileRequest(const QString& resource) |
2708 | { | 2710 | { |
2709 | while ( mSyncManager->blockSave() ) { | 2711 | while ( mSyncManager->blockSave() ) { |
2710 | qApp->processEvents(); | 2712 | qApp->processEvents(); |
2711 | } | 2713 | } |
2712 | mSyncManager->setBlockSave(true); | 2714 | mSyncManager->setBlockSave(true); |
2713 | 2715 | ||
2714 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2716 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2715 | mSyncManager->slotSyncMenu( 999 ); | 2717 | mSyncManager->slotSyncMenu( 999 ); |
2716 | } | 2718 | } |
2717 | 2719 | ||
2718 | setCaption(i18n("Saving Data to temp file ..." )); | 2720 | setCaption(i18n("Saving Data to temp file ..." )); |
2719 | mView->saveCalendar( sentSyncFile() ); | 2721 | mView->saveCalendarResource( sentSyncFile(), resource ); |
2720 | setCaption(i18n("Data saved to temp file!" )); | 2722 | setCaption(i18n("Data saved to temp file!" )); |
2721 | mSyncManager->setBlockSave( false ); | 2723 | mSyncManager->setBlockSave( false ); |
2722 | 2724 | ||
2723 | } | 2725 | } |
2724 | void MainWindow::getFile( bool success ) | 2726 | void MainWindow::getFile( bool success ,const QString& resource) |
2725 | { | 2727 | { |
2726 | if ( ! success ) { | 2728 | if ( ! success ) { |
2727 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2729 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2728 | return; | 2730 | return; |
2729 | } | 2731 | } |
2730 | mView->mergeFile( sentSyncFile() ); | 2732 | mView->mergeFileResource( sentSyncFile(), resource); |
2731 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2733 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2732 | mSyncManager->slotSyncMenu( 999 ); | 2734 | mSyncManager->slotSyncMenu( 999 ); |
2733 | } | 2735 | } |
2734 | setCaption( i18n("Pi-Sync successful!") ); | 2736 | setCaption( i18n("Pi-Sync successful!") ); |
2735 | } | 2737 | } |
2736 | void MainWindow::printListView() | 2738 | void MainWindow::printListView() |
2737 | { | 2739 | { |
2738 | 2740 | ||
2739 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); | 2741 | QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); |
2740 | 2742 | ||
2741 | KMessageBox::information( this, message); | 2743 | KMessageBox::information( this, message); |
2742 | } | 2744 | } |
2743 | void MainWindow::printSel( ) | 2745 | void MainWindow::printSel( ) |
2744 | { | 2746 | { |
2745 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2747 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2746 | } | 2748 | } |
2747 | 2749 | ||
2748 | void MainWindow::printCal() | 2750 | void MainWindow::printCal() |
2749 | { | 2751 | { |
2750 | mView->print();//mCp->showDialog(); | 2752 | mView->print();//mCp->showDialog(); |
2751 | } | 2753 | } |
2752 | 2754 | ||
2753 | 2755 | ||
2754 | #include "libkdepim/kdatepicker.h" | 2756 | #include "libkdepim/kdatepicker.h" |
2755 | #include <kdatetbl.h> | 2757 | #include <kdatetbl.h> |
2756 | 2758 | ||
2757 | void MainWindow::weekAction() | 2759 | void MainWindow::weekAction() |
2758 | { | 2760 | { |
2759 | int month; | 2761 | int month; |
2760 | KPopupFrame* popup = new KPopupFrame(this); | 2762 | KPopupFrame* popup = new KPopupFrame(this); |
2761 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); | 2763 | KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); |
2762 | // ----- | 2764 | // ----- |
2763 | picker->resize(picker->sizeHint()); | 2765 | picker->resize(picker->sizeHint()); |
2764 | popup->setMainWidget(picker); | 2766 | popup->setMainWidget(picker); |
2765 | picker->setFocus(); | 2767 | picker->setFocus(); |
2766 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 2768 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
2767 | int x = 0; | 2769 | int x = 0; |
2768 | int y = iconToolBar->height(); | 2770 | int y = iconToolBar->height(); |
2769 | int dX = 0; | 2771 | int dX = 0; |
2770 | int dY = 0; | 2772 | int dY = 0; |
2771 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 2773 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
2772 | if ( iconToolBar->y() > height()/2 ) { | 2774 | if ( iconToolBar->y() > height()/2 ) { |
2773 | dY = picker->sizeHint().height()+8; | 2775 | dY = picker->sizeHint().height()+8; |
2774 | y = 0; | 2776 | y = 0; |
2775 | } | 2777 | } |
2776 | } else { | 2778 | } else { |
2777 | if ( iconToolBar->x() > width()/2 ) { // right side | 2779 | if ( iconToolBar->x() > width()/2 ) { // right side |
2778 | x=0; | 2780 | x=0; |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index d8018b6..a533d8b 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -65,98 +65,98 @@ class MainWindow : public QMainWindow | |||
65 | void features(); | 65 | void features(); |
66 | void synchowto(); | 66 | void synchowto(); |
67 | void storagehowto(); | 67 | void storagehowto(); |
68 | void timetrackinghowto(); | 68 | void timetrackinghowto(); |
69 | void kdesynchowto(); | 69 | void kdesynchowto(); |
70 | void multisynchowto(); | 70 | void multisynchowto(); |
71 | void whatsNew(); | 71 | void whatsNew(); |
72 | void keyBindings(); | 72 | void keyBindings(); |
73 | void aboutAutoSaving();; | 73 | void aboutAutoSaving();; |
74 | void aboutKnownBugs(); | 74 | void aboutKnownBugs(); |
75 | 75 | ||
76 | void processIncidenceSelection( Incidence * ); | 76 | void processIncidenceSelection( Incidence * ); |
77 | 77 | ||
78 | void importQtopia(); | 78 | void importQtopia(); |
79 | void importBday(); | 79 | void importBday(); |
80 | void importOL(); | 80 | void importOL(); |
81 | void importIcal(); | 81 | void importIcal(); |
82 | void importFile( QString, bool ); | 82 | void importFile( QString, bool ); |
83 | void quickImportIcal(); | 83 | void quickImportIcal(); |
84 | 84 | ||
85 | void slotModifiedChanged( bool ); | 85 | void slotModifiedChanged( bool ); |
86 | 86 | ||
87 | void save(); | 87 | void save(); |
88 | void backupAllFiles(); | 88 | void backupAllFiles(); |
89 | void saveStopTimer(); | 89 | void saveStopTimer(); |
90 | void configureToolBar( int ); | 90 | void configureToolBar( int ); |
91 | void printSel(); | 91 | void printSel(); |
92 | void printCal(); | 92 | void printCal(); |
93 | void printListView(); | 93 | void printListView(); |
94 | void saveCalendar(); | 94 | void saveCalendar(); |
95 | void loadCalendar(); | 95 | void loadCalendar(); |
96 | void exportVCalendar(); | 96 | void exportVCalendar(); |
97 | void exportICalendar(); | 97 | void exportICalendar(); |
98 | void exportCalendar( bool ); | 98 | void exportCalendar( bool ); |
99 | void fillFilterMenu(); | 99 | void fillFilterMenu(); |
100 | void fillFilterMenuTB(); | 100 | void fillFilterMenuTB(); |
101 | void selectFilter( int ); | 101 | void selectFilter( int ); |
102 | void fillFilterMenuPopup(); | 102 | void fillFilterMenuPopup(); |
103 | void selectFilterPopup( int ); | 103 | void selectFilterPopup( int ); |
104 | void exportToPhone( int ); | 104 | void exportToPhone( int ); |
105 | void toggleBeamReceive(); | 105 | void toggleBeamReceive(); |
106 | void disableBR(bool); | 106 | void disableBR(bool); |
107 | signals: | 107 | signals: |
108 | void selectWeek ( int ); | 108 | void selectWeek ( int ); |
109 | private slots: | 109 | private slots: |
110 | void slotResetFocus(); | 110 | void slotResetFocus(); |
111 | void slotResetFocusLoop(); | 111 | void slotResetFocusLoop(); |
112 | void showConfigureAgenda(); | 112 | void showConfigureAgenda(); |
113 | void getFile( bool ); | 113 | void getFile( bool ,const QString &); |
114 | void syncFileRequest(); | 114 | void syncFileRequest(const QString &); |
115 | 115 | ||
116 | protected: | 116 | protected: |
117 | int mFocusLoop; | 117 | int mFocusLoop; |
118 | void hideEvent ( QHideEvent * ); | 118 | void hideEvent ( QHideEvent * ); |
119 | QString sentSyncFile(); | 119 | QString sentSyncFile(); |
120 | void displayText( QString, QString); | 120 | void displayText( QString, QString); |
121 | void enableIncidenceActions( bool ); | 121 | void enableIncidenceActions( bool ); |
122 | bool askForQuitOnSaveError(); | 122 | bool askForQuitOnSaveError(); |
123 | 123 | ||
124 | private: | 124 | private: |
125 | bool mAutoSaveDisabled; | 125 | bool mAutoSaveDisabled; |
126 | bool checkAutosave(); | 126 | bool checkAutosave(); |
127 | QCString mCStringMess; | 127 | QCString mCStringMess; |
128 | QByteArray mByteData; | 128 | QByteArray mByteData; |
129 | 129 | ||
130 | //void setMenuBar( QMenuBar * ); | 130 | //void setMenuBar( QMenuBar * ); |
131 | bool mBRdisabled; | 131 | bool mBRdisabled; |
132 | #ifndef DESKTOP_VERSION | 132 | #ifndef DESKTOP_VERSION |
133 | QCopChannel* infrared; | 133 | QCopChannel* infrared; |
134 | #endif | 134 | #endif |
135 | QAction* brAction; | 135 | QAction* brAction; |
136 | KSyncManager* mSyncManager; | 136 | KSyncManager* mSyncManager; |
137 | bool mClosed; | 137 | bool mClosed; |
138 | void saveOnClose(); | 138 | void saveOnClose(); |
139 | bool mFlagKeyPressed; | 139 | bool mFlagKeyPressed; |
140 | bool mBlockAtStartup; | 140 | bool mBlockAtStartup; |
141 | KMenuBar *menuBar1; | 141 | KMenuBar *menuBar1; |
142 | QPEToolBar *iconToolBar; | 142 | QPEToolBar *iconToolBar; |
143 | QPEToolBar *viewToolBar; | 143 | QPEToolBar *viewToolBar; |
144 | QPEToolBar *navigatorToolBar; | 144 | QPEToolBar *navigatorToolBar; |
145 | QPEToolBar *filterToolBar; | 145 | QPEToolBar *filterToolBar; |
146 | KMenuBar *filterMenubar; | 146 | KMenuBar *filterMenubar; |
147 | QPopupMenu * filterPopupMenu; | 147 | QPopupMenu * filterPopupMenu; |
148 | QPopupMenu * mCurrentItemMenu; | 148 | QPopupMenu * mCurrentItemMenu; |
149 | void initActions(); | 149 | void initActions(); |
150 | void setDefaultPreferences(); | 150 | void setDefaultPreferences(); |
151 | void resizeEvent( QResizeEvent* e); | 151 | void resizeEvent( QResizeEvent* e); |
152 | void keyPressEvent ( QKeyEvent * ) ; | 152 | void keyPressEvent ( QKeyEvent * ) ; |
153 | void keyReleaseEvent ( QKeyEvent * ) ; | 153 | void keyReleaseEvent ( QKeyEvent * ) ; |
154 | QPopupMenu *configureToolBarMenu; | 154 | QPopupMenu *configureToolBarMenu; |
155 | QPopupMenu *selectFilterMenu; | 155 | QPopupMenu *selectFilterMenu; |
156 | QPopupMenu *selectFilterMenuTB; | 156 | QPopupMenu *selectFilterMenuTB; |
157 | QPopupMenu *configureAgendaMenu, *syncMenu; | 157 | QPopupMenu *configureAgendaMenu, *syncMenu; |
158 | CalendarLocal *mCalendar; | 158 | CalendarLocal *mCalendar; |
159 | CalendarView *mView; | 159 | CalendarView *mView; |
160 | QAction *mNewSubTodoAction; | 160 | QAction *mNewSubTodoAction; |
161 | QAction *mWeekAction; | 161 | QAction *mWeekAction; |
162 | QFont mWeekFont; | 162 | QFont mWeekFont; |