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.cpp80
1 files changed, 73 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bc1c0c7..9a114d0 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -653,8 +653,74 @@ CalendarView::~CalendarView()
delete mDateFrame ;
delete mEventViewerDialog;
//kdDebug() << "~CalendarView() done" << endl;
}
+void CalendarView::nextConflict( bool all, bool allday )
+{
+ QDate start = mNavigator->selectedDates().first().addDays(1);
+ 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 )
+ 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 ) {
+ 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();
+ }
+ ev = eventList.next();
+ }
+ start = start.addDays( 1 );
+ }
+ topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
+ qDebug("No conflict found ");
+}
+
+void CalendarView::conflictAll()
+{
+ nextConflict ( true, true );
+}
+void CalendarView::conflictAllday()
+{
+ nextConflict ( false, true );
+}
+void CalendarView::conflictNotAll()
+{
+ nextConflict ( false, false );
+}
+
void CalendarView::setCalReadOnly( int id, bool readO )
{
if ( readO ) {
emit save();
@@ -3161,9 +3227,9 @@ void CalendarView::cloneIncidence(Incidence * orgInc )
Todo* t = (Todo*) newInc;
bool cloneSub = false;
if ( orgInc->relations().count() ) {
int result = KMessageBox::warningYesNoCancel(this,
- i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
+ i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ),
i18n("Todo has subtodos"),
i18n("Yes"),
i18n("No"));
@@ -3499,9 +3565,9 @@ void CalendarView::deleteTodo(Todo *todo)
KNotifyClient::beep();
return;
}
if (KOPrefs::instance()->mConfirm) {
- QString text = todo->summary().left(20);
+ QString text = KGlobal::formatMessage ( todo->summary(),0 );
if (!todo->relations().isEmpty()) {
text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
}
@@ -3545,9 +3611,9 @@ void CalendarView::deleteJournal(Journal *jour)
des = des.simplifyWhiteSpace ();
des.replace (QRegExp ("\\n"),"" );
des.replace (QRegExp ("\\r"),"" );
}
- switch (msgItemDelete( i18n("Journal:") +"\n"+des.left(20))) {
+ switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) {
case KMessageBox::Continue: // OK
calendar()->deleteJournal(jour);
updateView();
break;
@@ -3571,17 +3637,17 @@ void CalendarView::deleteEvent(Event *anEvent)
int km;
if (!itemDate.isValid()) {
//kdDebug() << "Date Not Valid" << endl;
if (KOPrefs::instance()->mConfirm) {
- km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
+ km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
i18n("KO/Pi Confirmation"),i18n("Delete All"));
if ( km == KMessageBox::Continue )
km = KMessageBox::No; // No = all below
} else
km = KMessageBox::No;
} else {
- km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
+ km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
i18n("KO/Pi Confirmation"),i18n("Current"),
i18n("All"));
@@ -3620,9 +3686,9 @@ void CalendarView::deleteEvent(Event *anEvent)
//#endif
} // switch
} else {
if (KOPrefs::instance()->mConfirm) {
- switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
+ switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
i18n("\nAre you sure you want\nto delete this event?"),
i18n("KO/Pi Confirmation"),i18n("Delete"))) {
case KMessageBox::Continue: // OK
if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
@@ -4579,9 +4645,9 @@ void CalendarView::undo_delete()
KMessageBox::sorry(this,i18n("There is nothing to undo!"),
i18n("KO/Pi"));
return;
}
- if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
+ if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
i18n("\nAre you sure you want\nto restore this?"),
i18n("KO/Pi Confirmation"),i18n("Restore"))) {
mCalendar->undoDeleteIncidence();
updateView();