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.cpp52
1 files changed, 34 insertions, 18 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 65750af..426e8f9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -640,90 +640,105 @@ void CalendarView::init()
this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
#endif
mDateNavigator->setCalendar( mCalendar );
}
CalendarView::~CalendarView()
{
// kdDebug() << "~CalendarView()" << endl;
//qDebug("CalendarView::~CalendarView() ");
delete mDialogManager;
delete mViewManager;
delete mStorage;
delete mDateFrame ;
delete mEventViewerDialog;
//kdDebug() << "~CalendarView() done" << endl;
}
void CalendarView::nextConflict( bool all, bool allday )
{
QPtrList<Event> testlist = mCalendar->events();
Event * test = testlist.first();
while ( test ) {
test->setTagged( false );
+ test = testlist.next();
}
QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0));
QDateTime conflict;
QDateTime retVal;
bool found = false;
Event * cE = 0;
+ Event * cE2 = 0;
QPtrList<Event> testlist2 = testlist;
+ test = testlist.first();
+ bool skip = false;
while ( test ) {
- Event * test2 = testlist2.first();
- while ( test2 ) {
- if ( !test2->isTagged() ) {
- if ( test->isOverlapping ( test2, &retVal, true ) ) {
- if ( ! found ) {
- if ( retVal >= startDT ) {
- conflict = retVal;
- cE = test;
- found = true;
- }
- } else {
- if ( retVal >= startDT && retVal < conflict ) {
- conflict = retVal;
- cE = test;
+ skip = false;
+ if ( !all ) skip = ( allday != test->doesFloat() );
+ if ( !skip ) {
+ Event * test2 = testlist2.first();
+ while ( test2 ) {
+ skip = false;
+ if ( !all ) skip = ( allday != test2->doesFloat() );
+ if ( !skip ) {
+ if ( !test2->isTagged() ) {
+ if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
+ //qDebug("overlap ");
+ if ( ! found ) {
+ if ( retVal >= startDT ) {
+ conflict = retVal;
+ cE = test;
+ cE2 = test2;
+ found = true;
+ }
+ } else {
+ if ( retVal >= startDT && retVal < conflict ) {
+ conflict = retVal;
+ cE = test;
+ cE2 = test2;
+ }
+ }
}
}
}
+ test2 = testlist2.next();
}
- test2 = testlist2.next();
}
test->setTagged( true );
test = testlist.next();
}
if ( found ) {
if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
mViewManager->showDayView();
mNavigator->slotDaySelect( conflict.date() );
int hour = conflict.time().hour();
mViewManager->agendaView()->setStartHour( hour );
- topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
+ topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
return;
}
- topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
+ topLevelWidget()->setCaption( i18n("No conflict found") );
qDebug("No conflict found ");
return;
#if 0
QDate end = start.addDays( 365*2);
while ( start < end ) {
QPtrList<Event> eventList = calendar()->events( start );
Event * ev = eventList.first();
QPtrList<Event> test = eventList;
while ( ev ) {
//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 )
@@ -2773,51 +2788,52 @@ void CalendarView::changeEventDisplay(Event *which, int action)
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;
}
QPtrList<Event> testlist = mCalendar->events();
Event * test = testlist.first();
QDateTime conflict;
QDateTime retVal;
bool found = false;
Event * cE = 0;
+ QDateTime current = QDateTime::currentDateTime();
while ( test ) {
if ( !test->doesFloat() ) {
- if ( mConflictingEvent->isOverlapping ( test, &retVal, true ) ) {
+ if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
if ( ! found ) {
conflict = retVal;
cE = test;
} else {
if ( retVal < conflict ) {
conflict = retVal;
cE = test;
}
}
found = true;
}
}
test = testlist.next();
}
if ( found ) {
QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
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();