summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
authorzautrix <zautrix>2005-06-07 05:09:23 (UTC)
committer zautrix <zautrix>2005-06-07 05:09:23 (UTC)
commit0bbef196163a267722978e34db2ba3daaee76f88 (patch) (unidiff)
treefac0b701aea6348490c5e9585820070b32b35e29 /korganizer/calendarview.cpp
parent790b8c38e1305b2f5ee4485e59a3ecd01e5b6f75 (diff)
downloadkdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.zip
kdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.tar.gz
kdepimpi-0bbef196163a267722978e34db2ba3daaee76f88.tar.bz2
clear view fixes
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp19
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
@@ -1123,48 +1123,49 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t
1123void CalendarView::checkExternalId( Incidence * inc ) 1123void CalendarView::checkExternalId( Incidence * inc )
1124{ 1124{
1125 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1125 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1126 checkExternSyncEvent( lastSync, inc ); 1126 checkExternSyncEvent( lastSync, inc );
1127 1127
1128} 1128}
1129bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1129bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1130{ 1130{
1131 bool syncOK = true; 1131 bool syncOK = true;
1132 int addedEvent = 0; 1132 int addedEvent = 0;
1133 int addedEventR = 0; 1133 int addedEventR = 0;
1134 int deletedEventR = 0; 1134 int deletedEventR = 0;
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 ");
1159 } 1160 }
1160 } 1161 }
1161 QDateTime modifiedCalendar = mLastCalendarSync; 1162 QDateTime modifiedCalendar = mLastCalendarSync;
1162 eventLSync = getLastSyncEvent(); 1163 eventLSync = getLastSyncEvent();
1163 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1164 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1164 if ( eventR ) { 1165 if ( eventR ) {
1165 eventRSync = (Event*) eventR->clone(); 1166 eventRSync = (Event*) eventR->clone();
1166 remote->deleteEvent(eventR ); 1167 remote->deleteEvent(eventR );
1167 1168
1168 } else { 1169 } else {
1169 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1170 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1170 eventRSync = (Event*)eventLSync->clone(); 1171 eventRSync = (Event*)eventLSync->clone();
@@ -1815,50 +1816,50 @@ bool CalendarView::importQtopia( const QString &categories,
1815void CalendarView::setSyncEventsReadOnly() 1816void CalendarView::setSyncEventsReadOnly()
1816{ 1817{
1817 Event * ev; 1818 Event * ev;
1818 QPtrList<Event> eL = mCalendar->rawEvents(); 1819 QPtrList<Event> eL = mCalendar->rawEvents();
1819 ev = eL.first(); 1820 ev = eL.first();
1820 while ( ev ) { 1821 while ( ev ) {
1821 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1822 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1822 ev->setReadOnly( true ); 1823 ev->setReadOnly( true );
1823 ev = eL.next(); 1824 ev = eL.next();
1824 } 1825 }
1825} 1826}
1826bool CalendarView::openCalendar(QString filename, bool merge) 1827bool 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 );
1853 } 1854 }
1854 globalFlagBlockAgenda = 2; 1855 globalFlagBlockAgenda = 2;
1855 // if ( getLastSyncEvent() ) 1856 // if ( getLastSyncEvent() )
1856 // getLastSyncEvent()->setReadOnly( true ); 1857 // getLastSyncEvent()->setReadOnly( true );
1857 mCalendar->reInitAlarmSettings(); 1858 mCalendar->reInitAlarmSettings();
1858 setSyncEventsReadOnly(); 1859 setSyncEventsReadOnly();
1859 updateUnmanagedViews(); 1860 updateUnmanagedViews();
1860 updateView(); 1861 updateView();
1861 if ( filename != MainWindow::defaultFileName() ) { 1862 if ( filename != MainWindow::defaultFileName() ) {
1862 saveCalendar( MainWindow::defaultFileName() ); 1863 saveCalendar( MainWindow::defaultFileName() );
1863 } else { 1864 } else {
1864 QFileInfo finf ( MainWindow::defaultFileName()); 1865 QFileInfo finf ( MainWindow::defaultFileName());
@@ -1927,81 +1928,83 @@ bool CalendarView::checkFileVersion(QString fn)
1927 if ( !finf.exists() ) 1928 if ( !finf.exists() )
1928 return true; 1929 return true;
1929 QDateTime dt = finf.lastModified (); 1930 QDateTime dt = finf.lastModified ();
1930 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1931 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1931 //qDebug("file on disk version %s",dt.toString().latin1()); 1932 //qDebug("file on disk version %s",dt.toString().latin1());
1932 if ( dt <= loadedFileVersion ) 1933 if ( dt <= loadedFileVersion )
1933 return true; 1934 return true;
1934 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1935 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1935 i18n("KO/Pi Warning"),i18n("Overwrite"), 1936 i18n("KO/Pi Warning"),i18n("Overwrite"),
1936 i18n("Sync+save")); 1937 i18n("Sync+save"));
1937 1938
1938 if ( km == KMessageBox::Cancel ) 1939 if ( km == KMessageBox::Cancel )
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
1956bool CalendarView::saveCalendar( QString filename ) 1958bool 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
1964 1966
1965 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1967 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1966 mStorage->setSaveFormat( new ICalFormat() ); 1968 mStorage->setSaveFormat( new ICalFormat() );
1967 mStorage->setFileName( filename ); 1969 mStorage->setFileName( filename );
1968 bool success; 1970 bool success;
1969 success = mStorage->save(); 1971 success = mStorage->save();
1970 if ( !success ) { 1972 if ( !success ) {
1971 return false; 1973 return false;
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
1980void CalendarView::closeCalendar() 1982void 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
1991void CalendarView::archiveCalendar() 1994void CalendarView::archiveCalendar()
1992{ 1995{
1993 mDialogManager->showArchiveDialog(); 1996 mDialogManager->showArchiveDialog();
1994} 1997}
1995 1998
1996 1999
1997void CalendarView::readSettings() 2000void CalendarView::readSettings()
1998{ 2001{
1999 2002
2000 2003
2001 // mViewManager->showAgendaView(); 2004 // mViewManager->showAgendaView();
2002 QString str; 2005 QString str;
2003 //qDebug("CalendarView::readSettings() "); 2006 //qDebug("CalendarView::readSettings() ");
2004 // read settings from the KConfig, supplying reasonable 2007 // read settings from the KConfig, supplying reasonable
2005 // defaults where none are to be found 2008 // defaults where none are to be found
2006 KConfig *config = KOGlobals::config(); 2009 KConfig *config = KOGlobals::config();
2007#ifndef KORG_NOSPLITTER 2010#ifndef KORG_NOSPLITTER
@@ -2411,48 +2414,59 @@ void CalendarView::changeEventDisplay(Event *which, int action)
2411 // if (which->getTodoStatus()) { 2414 // if (which->getTodoStatus()) {
2412 mTodoList->updateView(); 2415 mTodoList->updateView();
2413 // } 2416 // }
2414 } else { 2417 } else {
2415 mViewManager->currentView()->updateView(); 2418 mViewManager->currentView()->updateView();
2416 } 2419 }
2417} 2420}
2418 2421
2419 2422
2420void CalendarView::updateTodoViews() 2423void CalendarView::updateTodoViews()
2421{ 2424{
2422 mTodoList->updateView(); 2425 mTodoList->updateView();
2423 mViewManager->currentView()->updateView(); 2426 mViewManager->currentView()->updateView();
2424 2427
2425} 2428}
2426 2429
2427 2430
2428void CalendarView::updateView(const QDate &start, const QDate &end) 2431void 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
2438void 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}
2435void CalendarView::updateView() 2449void 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
2445void CalendarView::updateUnmanagedViews() 2459void CalendarView::updateUnmanagedViews()
2446{ 2460{
2447 mDateNavigator->updateDayMatrix(); 2461 mDateNavigator->updateDayMatrix();
2448} 2462}
2449 2463
2450int CalendarView::msgItemDelete(const QString name) 2464int CalendarView::msgItemDelete(const QString name)
2451{ 2465{
2452 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2466 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2453 i18n("This item will be\npermanently deleted."), 2467 i18n("This item will be\npermanently deleted."),
2454 i18n("KO/Pi Confirmation"),i18n("Delete")); 2468 i18n("KO/Pi Confirmation"),i18n("Delete"));
2455} 2469}
2456 2470
2457 2471
2458void CalendarView::edit_cut() 2472void CalendarView::edit_cut()
@@ -3922,48 +3936,49 @@ void CalendarView::filterEdited()
3922{ 3936{
3923 mFilterView->updateFilters(); 3937 mFilterView->updateFilters();
3924 updateFilter(); 3938 updateFilter();
3925 writeSettings(); 3939 writeSettings();
3926} 3940}
3927 3941
3928 3942
3929void CalendarView::takeOverEvent() 3943void CalendarView::takeOverEvent()
3930{ 3944{
3931 Incidence *incidence = currentSelection(); 3945 Incidence *incidence = currentSelection();
3932 3946
3933 if (!incidence) return; 3947 if (!incidence) return;
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
3942void CalendarView::takeOverCalendar() 3956void 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);
3958 } 3973 }
3959 3974
3960 QPtrList<Journal> journals = mCalendar->journals(); 3975 QPtrList<Journal> journals = mCalendar->journals();
3961 for(uint i=0; i<journals.count(); ++i) { 3976 for(uint i=0; i<journals.count(); ++i) {
3962 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3977 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3963 journals.at(i)->recreate(); 3978 journals.at(i)->recreate();
3964 journals.at(i)->setReadOnly(false); 3979 journals.at(i)->setReadOnly(false);
3965 } 3980 }
3966 3981
3967 updateView(); 3982 updateView();
3968} 3983}
3969 3984