author | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
commit | 766b53919de14b8faec22db32b6a750acde0b760 (patch) (side-by-side diff) | |
tree | bb07c0af89b0dddf4257a61e9f5b1cf23c4a282a /korganizer/calendarview.cpp | |
parent | b4d85da57e2d558ec088af6f3b2a34b1854462c0 (diff) | |
download | kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.zip kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.gz kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.bz2 |
fixesss
-rw-r--r-- | korganizer/calendarview.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9a114d0..e766b8f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -2593,262 +2593,332 @@ void CalendarView::writeFilterSettings(KConfig *config) config->writeEntry("Criteria",filter->criteria()); config->writeEntry("CategoryList",filter->categoryList()); filter = mFilters.next(); } config->setGroup("General"); config->writeEntry("CalendarFilters",filterList); config->setGroup("FilterView"); config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); } void CalendarView::goToday() { if ( mViewManager->currentView()->isMonthView() ) mNavigator->selectTodayMonth(); else mNavigator->selectToday(); } void CalendarView::goNext() { mNavigator->selectNext(); } void CalendarView::goPrevious() { mNavigator->selectPrevious(); } void CalendarView::goNextMonth() { mNavigator->selectNextMonth(); } void CalendarView::goPreviousMonth() { mNavigator->selectPreviousMonth(); } void CalendarView::updateConfig() { if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); emit configChanged(); mTodoList->updateConfig(); // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); // To make the "fill window" configurations work //mViewManager->raiseCurrentView(); } void CalendarView::eventChanged(Event *event) { changeEventDisplay(event,KOGlobals::EVENTEDITED); //updateUnmanagedViews(); } void CalendarView::eventAdded(Event *event) { changeEventDisplay(event,KOGlobals::EVENTADDED); } void CalendarView::eventToBeDeleted(Event *) { kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; } void CalendarView::eventDeleted() { changeEventDisplay(0,KOGlobals::EVENTDELETED); } void CalendarView::changeTodoDisplay(Todo *which, int action) { changeIncidenceDisplay((Incidence *)which, action); mDateNavigator->updateView(); //LR //mDialogManager->updateSearchDialog(); if (which) { mViewManager->updateWNview(); //mTodoList->updateView(); } } void CalendarView::changeIncidenceDisplay(Incidence *which, int action) { updateUnmanagedViews(); //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); if ( action == KOGlobals::EVENTDELETED ) { //delete mCalendar->checkAlarmForIncidence( 0, true ); if ( mEventViewerDialog ) mEventViewerDialog->hide(); } else mCalendar->checkAlarmForIncidence( which , false ); } // most of the changeEventDisplays() right now just call the view's // total update mode, but they SHOULD be recoded to be more refresh-efficient. void CalendarView::changeEventDisplay(Event *which, int action) { // kdDebug() << "CalendarView::changeEventDisplay" << endl; changeIncidenceDisplay((Incidence *)which, action); static bool clearallviews = false; if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { if ( clearallviews ) { clearAllViews(); clearallviews = false; } return; } clearallviews = true; mDateNavigator->updateView(); //mDialogManager->updateSearchDialog(); if (which) { // If there is an event view visible update the display mViewManager->currentView()->changeEventDisplay(which,action); // TODO: check, if update needed // if (which->getTodoStatus()) { mTodoList->updateView(); + if ( action != KOGlobals::EVENTDELETED ) { + mConflictingEvent = which ; + QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); + } // } } else { mViewManager->currentView()->updateView(); } } +void CalendarView::checkConflictForEvent() +{ + + if (!KOPrefs::instance()->mConfirm) + return; + if ( ! mConflictingEvent ) return; + if ( mConflictingEvent->doesFloat() ) { + mConflictingEvent = 0; + return; + } + bool all = false; + bool allday = false; + Event * ev = mConflictingEvent; + mConflictingEvent = 0; + QDate start = ev->dtStart().date(); + QDate end = ev->dtEnd().date().addDays(1); + while ( start < end ) { + QPtrList<Event> test = calendar()->events( start ); + //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); + Event * t_ev = test.first(); + QDateTime es = ev->dtStart(); + QDateTime ee = ev->dtEnd(); + if ( ev->doesFloat() ) + ee = ee.addDays( 1 ); + if ( ! all ) { + if ( ev->doesFloat() != allday ) + t_ev = 0; + } + while ( t_ev ) { + bool skip = false; + if ( ! all ) { + if ( t_ev->doesFloat() != allday ) + skip = true; + } + if ( !skip && ev != t_ev ) { + QDateTime ets = t_ev->dtStart(); + QDateTime ete = t_ev->dtEnd(); + if ( t_ev->doesFloat() ) + ete = ete.addDays( 1 ); + //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); + if ( es < ete && ets < ee ) { + QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( ev->summary(),0 ) ).arg( KGlobal::formatMessage ( t_ev->summary(),0 )).arg(KGlobal::locale()->formatDate(start) ) ; + qApp->processEvents(); + int km = KMessageBox::warningContinueCancel(this,mess, + i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); + if ( km != KMessageBox::Continue ) + return; + + if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) + mViewManager->showDayView(); + mNavigator->slotDaySelect( start ); + int hour = es.time().hour(); + if ( ets > es ) + hour = ets.time().hour(); + mViewManager->agendaView()->setStartHour( hour ); + topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); + return; + } + } + t_ev = test.next(); + } + start = start.addDays( 1 ); + } + qDebug("No conflict found "); + +} void CalendarView::updateTodoViews() { mTodoList->updateView(); mViewManager->currentView()->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() { static bool clearallviews = false; if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { if ( clearallviews ) { clearAllViews(); clearallviews = false; } return; } clearallviews = true; 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() { mDateNavigator->updateDayMatrix(); } int CalendarView::msgItemDelete(const QString name) { return KMessageBox::warningContinueCancel(this,name +"\n\n"+ i18n("This item will be\npermanently deleted."), i18n("KO/Pi Confirmation"),i18n("Delete")); } void CalendarView::edit_cut() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.cutIncidence(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } void CalendarView::edit_copy() { Event *anEvent=0; Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); if (mViewManager->currentView()->isEventView()) { if ( incidence && incidence->typeID() == eventID ) { anEvent = static_cast<Event *>(incidence); } } if (!anEvent) { KNotifyClient::beep(); return; } DndFactory factory( mCalendar ); factory.copyIncidence(anEvent); } void CalendarView::edit_paste() { QDate date = mNavigator->selectedDates().first(); DndFactory factory( mCalendar ); Event *pastedEvent = (Event *)factory.pasteIncidence( date ); changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); } void CalendarView::edit_global_options() { QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; emit save(); emit saveStopTimer(); mDialogManager->showGlobalOptionsDialog(); if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { emit saveStopTimer(); if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), i18n("Timezone settings"),i18n("Reload"))) { qDebug("KO: TZ reload cancelled "); mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); return; } qDebug("KO: Timezone change "); loadCalendars(); setModified(true); } else qDebug("KO: No tz change "); } void CalendarView::edit_options() { mDialogManager->showOptionsDialog(); } |