-rw-r--r-- | korganizer/calendarview.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 608b73b..e13d0be 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1135,24 +1135,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1135 | int deletedEventL = 0; | 1135 | int deletedEventL = 0; |
1136 | int changedLocal = 0; | 1136 | int changedLocal = 0; |
1137 | int changedRemote = 0; | 1137 | int changedRemote = 0; |
1138 | int filteredIN = 0; | 1138 | int filteredIN = 0; |
1139 | int filteredOUT = 0; | 1139 | int filteredOUT = 0; |
1140 | //QPtrList<Event> el = local->rawEvents(); | 1140 | //QPtrList<Event> el = local->rawEvents(); |
1141 | Event* eventR; | 1141 | Event* eventR; |
1142 | QString uid; | 1142 | QString uid; |
1143 | int take; | 1143 | int take; |
1144 | Event* eventL; | 1144 | Event* eventL; |
1145 | Event* eventRSync; | 1145 | Event* eventRSync; |
1146 | Event* eventLSync; | 1146 | Event* eventLSync; |
1147 | clearAllViews(); | ||
1147 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1148 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1148 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1149 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1149 | bool fullDateRange = false; | 1150 | bool fullDateRange = false; |
1150 | local->resetTempSyncStat(); | 1151 | local->resetTempSyncStat(); |
1151 | mLastCalendarSync = QDateTime::currentDateTime(); | 1152 | mLastCalendarSync = QDateTime::currentDateTime(); |
1152 | if ( mSyncManager->syncWithDesktop() ) { | 1153 | if ( mSyncManager->syncWithDesktop() ) { |
1153 | remote->resetPilotStat(1); | 1154 | remote->resetPilotStat(1); |
1154 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1155 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1155 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1156 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1156 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1157 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1157 | } else { | 1158 | } else { |
1158 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1159 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
@@ -1827,26 +1828,26 @@ bool CalendarView::openCalendar(QString filename, bool merge) | |||
1827 | { | 1828 | { |
1828 | 1829 | ||
1829 | if (filename.isEmpty()) { | 1830 | if (filename.isEmpty()) { |
1830 | return false; | 1831 | return false; |
1831 | } | 1832 | } |
1832 | 1833 | ||
1833 | if (!QFile::exists(filename)) { | 1834 | if (!QFile::exists(filename)) { |
1834 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1835 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1835 | return false; | 1836 | return false; |
1836 | } | 1837 | } |
1837 | 1838 | ||
1838 | globalFlagBlockAgenda = 1; | 1839 | globalFlagBlockAgenda = 1; |
1840 | clearAllViews(); | ||
1839 | if (!merge) { | 1841 | if (!merge) { |
1840 | mTodoList->clearList(); | ||
1841 | mViewManager->setDocumentId( filename ); | 1842 | mViewManager->setDocumentId( filename ); |
1842 | mCalendar->close(); | 1843 | mCalendar->close(); |
1843 | } | 1844 | } |
1844 | mStorage->setFileName( filename ); | 1845 | mStorage->setFileName( filename ); |
1845 | 1846 | ||
1846 | if ( mStorage->load() ) { | 1847 | if ( mStorage->load() ) { |
1847 | if ( merge ) ;//setModified( true ); | 1848 | if ( merge ) ;//setModified( true ); |
1848 | else { | 1849 | else { |
1849 | //setModified( true ); | 1850 | //setModified( true ); |
1850 | mViewManager->setDocumentId( filename ); | 1851 | mViewManager->setDocumentId( filename ); |
1851 | mDialogManager->setDocumentId( filename ); | 1852 | mDialogManager->setDocumentId( filename ); |
1852 | mTodoList->setDocumentId( filename ); | 1853 | mTodoList->setDocumentId( filename ); |
@@ -1939,25 +1940,26 @@ bool CalendarView::checkFileVersion(QString fn) | |||
1939 | return false; | 1940 | return false; |
1940 | if ( km == KMessageBox::Yes ) | 1941 | if ( km == KMessageBox::Yes ) |
1941 | return true; | 1942 | return true; |
1942 | 1943 | ||
1943 | setSyncDevice("deleteaftersync" ); | 1944 | setSyncDevice("deleteaftersync" ); |
1944 | mSyncManager->mAskForPreferences = true; | 1945 | mSyncManager->mAskForPreferences = true; |
1945 | mSyncManager->mSyncAlgoPrefs = 3; | 1946 | mSyncManager->mSyncAlgoPrefs = 3; |
1946 | mSyncManager->mWriteBackFile = false; | 1947 | mSyncManager->mWriteBackFile = false; |
1947 | mSyncManager->mWriteBackExistingOnly = false; | 1948 | mSyncManager->mWriteBackExistingOnly = false; |
1948 | mSyncManager->mShowSyncSummary = false; | 1949 | mSyncManager->mShowSyncSummary = false; |
1949 | syncCalendar( fn, 3 ); | 1950 | syncCalendar( fn, 3 ); |
1950 | Event * e = getLastSyncEvent(); | 1951 | Event * e = getLastSyncEvent(); |
1951 | mCalendar->deleteEvent ( e ); | 1952 | if ( e ) |
1953 | deleteEvent ( e ); | ||
1952 | updateView(); | 1954 | updateView(); |
1953 | return true; | 1955 | return true; |
1954 | } | 1956 | } |
1955 | 1957 | ||
1956 | bool CalendarView::saveCalendar( QString filename ) | 1958 | bool CalendarView::saveCalendar( QString filename ) |
1957 | { | 1959 | { |
1958 | 1960 | ||
1959 | // Store back all unsaved data into calendar object | 1961 | // Store back all unsaved data into calendar object |
1960 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1962 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1961 | if ( mViewManager->currentView() ) | 1963 | if ( mViewManager->currentView() ) |
1962 | mViewManager->currentView()->flushView(); | 1964 | mViewManager->currentView()->flushView(); |
1963 | 1965 | ||
@@ -1972,24 +1974,25 @@ bool CalendarView::saveCalendar( QString filename ) | |||
1972 | } | 1974 | } |
1973 | if ( filename == MainWindow::defaultFileName() ) { | 1975 | if ( filename == MainWindow::defaultFileName() ) { |
1974 | setLoadedFileVersion( lfv ); | 1976 | setLoadedFileVersion( lfv ); |
1975 | watchSavedFile(); | 1977 | watchSavedFile(); |
1976 | } | 1978 | } |
1977 | return true; | 1979 | return true; |
1978 | } | 1980 | } |
1979 | 1981 | ||
1980 | void CalendarView::closeCalendar() | 1982 | void CalendarView::closeCalendar() |
1981 | { | 1983 | { |
1982 | 1984 | ||
1983 | // child windows no longer valid | 1985 | // child windows no longer valid |
1986 | clearAllViews(); | ||
1984 | emit closingDown(); | 1987 | emit closingDown(); |
1985 | 1988 | ||
1986 | mCalendar->close(); | 1989 | mCalendar->close(); |
1987 | setModified(false); | 1990 | setModified(false); |
1988 | updateView(); | 1991 | updateView(); |
1989 | } | 1992 | } |
1990 | 1993 | ||
1991 | void CalendarView::archiveCalendar() | 1994 | void CalendarView::archiveCalendar() |
1992 | { | 1995 | { |
1993 | mDialogManager->showArchiveDialog(); | 1996 | mDialogManager->showArchiveDialog(); |
1994 | } | 1997 | } |
1995 | 1998 | ||
@@ -2423,24 +2426,35 @@ void CalendarView::updateTodoViews() | |||
2423 | mViewManager->currentView()->updateView(); | 2426 | mViewManager->currentView()->updateView(); |
2424 | 2427 | ||
2425 | } | 2428 | } |
2426 | 2429 | ||
2427 | 2430 | ||
2428 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2431 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2429 | { | 2432 | { |
2430 | mTodoList->updateView(); | 2433 | mTodoList->updateView(); |
2431 | mViewManager->updateView(start, end); | 2434 | mViewManager->updateView(start, end); |
2432 | //mDateNavigator->updateView(); | 2435 | //mDateNavigator->updateView(); |
2433 | } | 2436 | } |
2434 | 2437 | ||
2438 | void CalendarView::clearAllViews() | ||
2439 | { | ||
2440 | mTodoList->clearList(); | ||
2441 | mViewManager->clearAllViews(); | ||
2442 | SearchDialog * sd = mDialogManager->getSearchDialog(); | ||
2443 | if ( sd ) { | ||
2444 | KOListView* kol = sd->listview(); | ||
2445 | if ( kol ) | ||
2446 | kol->clearList(); | ||
2447 | } | ||
2448 | } | ||
2435 | void CalendarView::updateView() | 2449 | void CalendarView::updateView() |
2436 | { | 2450 | { |
2437 | DateList tmpList = mNavigator->selectedDates(); | 2451 | DateList tmpList = mNavigator->selectedDates(); |
2438 | 2452 | ||
2439 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2453 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2440 | mTodoList->updateView(); | 2454 | mTodoList->updateView(); |
2441 | // We assume that the navigator only selects consecutive days. | 2455 | // We assume that the navigator only selects consecutive days. |
2442 | updateView( tmpList.first(), tmpList.last() ); | 2456 | updateView( tmpList.first(), tmpList.last() ); |
2443 | } | 2457 | } |
2444 | 2458 | ||
2445 | void CalendarView::updateUnmanagedViews() | 2459 | void CalendarView::updateUnmanagedViews() |
2446 | { | 2460 | { |
@@ -3934,24 +3948,25 @@ void CalendarView::takeOverEvent() | |||
3934 | 3948 | ||
3935 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3949 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3936 | incidence->recreate(); | 3950 | incidence->recreate(); |
3937 | incidence->setReadOnly(false); | 3951 | incidence->setReadOnly(false); |
3938 | 3952 | ||
3939 | updateView(); | 3953 | updateView(); |
3940 | } | 3954 | } |
3941 | 3955 | ||
3942 | void CalendarView::takeOverCalendar() | 3956 | void CalendarView::takeOverCalendar() |
3943 | { | 3957 | { |
3944 | // TODO: Create Calendar::allIncidences() function and use it here | 3958 | // TODO: Create Calendar::allIncidences() function and use it here |
3945 | 3959 | ||
3960 | clearAllViews(); | ||
3946 | QPtrList<Event> events = mCalendar->events(); | 3961 | QPtrList<Event> events = mCalendar->events(); |
3947 | for(uint i=0; i<events.count(); ++i) { | 3962 | for(uint i=0; i<events.count(); ++i) { |
3948 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3963 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3949 | events.at(i)->recreate(); | 3964 | events.at(i)->recreate(); |
3950 | events.at(i)->setReadOnly(false); | 3965 | events.at(i)->setReadOnly(false); |
3951 | } | 3966 | } |
3952 | 3967 | ||
3953 | QPtrList<Todo> todos = mCalendar->todos(); | 3968 | QPtrList<Todo> todos = mCalendar->todos(); |
3954 | for(uint i=0; i<todos.count(); ++i) { | 3969 | for(uint i=0; i<todos.count(); ++i) { |
3955 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3970 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3956 | todos.at(i)->recreate(); | 3971 | todos.at(i)->recreate(); |
3957 | todos.at(i)->setReadOnly(false); | 3972 | todos.at(i)->setReadOnly(false); |