summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore 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
@@ -1135,24 +1135,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
int deletedEventL = 0;
int changedLocal = 0;
int changedRemote = 0;
int filteredIN = 0;
int filteredOUT = 0;
//QPtrList<Event> el = local->rawEvents();
Event* eventR;
QString uid;
int take;
Event* eventL;
Event* eventRSync;
Event* eventLSync;
+ clearAllViews();
QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastCalendarSync = QDateTime::currentDateTime();
if ( mSyncManager->syncWithDesktop() ) {
remote->resetPilotStat(1);
if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
} else {
qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
@@ -1827,26 +1828,26 @@ bool CalendarView::openCalendar(QString filename, bool merge)
{
if (filename.isEmpty()) {
return false;
}
if (!QFile::exists(filename)) {
KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
return false;
}
globalFlagBlockAgenda = 1;
+ clearAllViews();
if (!merge) {
- mTodoList->clearList();
mViewManager->setDocumentId( filename );
mCalendar->close();
}
mStorage->setFileName( filename );
if ( mStorage->load() ) {
if ( merge ) ;//setModified( true );
else {
//setModified( true );
mViewManager->setDocumentId( filename );
mDialogManager->setDocumentId( filename );
mTodoList->setDocumentId( filename );
@@ -1939,25 +1940,26 @@ bool CalendarView::checkFileVersion(QString fn)
return false;
if ( km == KMessageBox::Yes )
return true;
setSyncDevice("deleteaftersync" );
mSyncManager->mAskForPreferences = true;
mSyncManager->mSyncAlgoPrefs = 3;
mSyncManager->mWriteBackFile = false;
mSyncManager->mWriteBackExistingOnly = false;
mSyncManager->mShowSyncSummary = false;
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
- mCalendar->deleteEvent ( e );
+ if ( e )
+ deleteEvent ( e );
updateView();
return true;
}
bool CalendarView::saveCalendar( QString filename )
{
// Store back all unsaved data into calendar object
// qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
if ( mViewManager->currentView() )
mViewManager->currentView()->flushView();
@@ -1972,24 +1974,25 @@ bool CalendarView::saveCalendar( QString filename )
}
if ( filename == MainWindow::defaultFileName() ) {
setLoadedFileVersion( lfv );
watchSavedFile();
}
return true;
}
void CalendarView::closeCalendar()
{
// child windows no longer valid
+ clearAllViews();
emit closingDown();
mCalendar->close();
setModified(false);
updateView();
}
void CalendarView::archiveCalendar()
{
mDialogManager->showArchiveDialog();
}
@@ -2423,24 +2426,35 @@ void CalendarView::updateTodoViews()
mViewManager->currentView()->updateView();
}
void CalendarView::updateView(const QDate &start, const QDate &end)
{
mTodoList->updateView();
mViewManager->updateView(start, end);
//mDateNavigator->updateView();
}
+void CalendarView::clearAllViews()
+{
+ mTodoList->clearList();
+ mViewManager->clearAllViews();
+ SearchDialog * sd = mDialogManager->getSearchDialog();
+ if ( sd ) {
+ KOListView* kol = sd->listview();
+ if ( kol )
+ kol->clearList();
+ }
+}
void CalendarView::updateView()
{
DateList tmpList = mNavigator->selectedDates();
if ( KOPrefs::instance()->mHideNonStartedTodos )
mTodoList->updateView();
// We assume that the navigator only selects consecutive days.
updateView( tmpList.first(), tmpList.last() );
}
void CalendarView::updateUnmanagedViews()
{
@@ -3934,24 +3948,25 @@ void CalendarView::takeOverEvent()
incidence->setOrganizer(KOPrefs::instance()->email());
incidence->recreate();
incidence->setReadOnly(false);
updateView();
}
void CalendarView::takeOverCalendar()
{
// TODO: Create Calendar::allIncidences() function and use it here
+ clearAllViews();
QPtrList<Event> events = mCalendar->events();
for(uint i=0; i<events.count(); ++i) {
events.at(i)->setOrganizer(KOPrefs::instance()->email());
events.at(i)->recreate();
events.at(i)->setReadOnly(false);
}
QPtrList<Todo> todos = mCalendar->todos();
for(uint i=0; i<todos.count(); ++i) {
todos.at(i)->setOrganizer(KOPrefs::instance()->email());
todos.at(i)->recreate();
todos.at(i)->setReadOnly(false);