summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
authorzautrix <zautrix>2005-07-07 04:18:11 (UTC)
committer zautrix <zautrix>2005-07-07 04:18:11 (UTC)
commitb4d85da57e2d558ec088af6f3b2a34b1854462c0 (patch) (side-by-side diff)
tree0860bfaae1d15aae6cd24861eaa87d0331fb364a /korganizer/calendarview.cpp
parentcb350dbe9151db2ded62942d29d11d6c8b88eabd (diff)
downloadkdepimpi-b4d85da57e2d558ec088af6f3b2a34b1854462c0.zip
kdepimpi-b4d85da57e2d558ec088af6f3b2a34b1854462c0.tar.gz
kdepimpi-b4d85da57e2d558ec088af6f3b2a34b1854462c0.tar.bz2
conflict
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show 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
@@ -645,24 +645,90 @@ void CalendarView::init()
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 )
+{
+ 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();
}
mCalendar->setReadOnly( id, readO );
}
void CalendarView::setScrollBarStep(int val )
{
#ifdef DESKTOP_VERSION
mDateScrollBar->setLineStep ( val );
#endif
@@ -3153,25 +3219,25 @@ void CalendarView::cancelIncidence(Incidence * inc )
updateView();
}
void CalendarView::cloneIncidence(Incidence * orgInc )
{
Incidence * newInc = orgInc->clone();
newInc->recreate();
if ( newInc->typeID() == todoID ) {
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"));
if ( result == KMessageBox::Cancel ) {
delete t;
return;
}
if (result == KMessageBox::Yes) cloneSub = true;
}
showTodoEditor();
mTodoEditor->editTodo( t );
@@ -3491,25 +3557,25 @@ void CalendarView::todo_resub( Todo * parent, Todo * sub )
void CalendarView::todo_unsub(Todo *anTodo )
{
todo_resub( 0, anTodo );
}
void CalendarView::deleteTodo(Todo *todo)
{
if (!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!");
}
switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
case KMessageBox::Continue: // OK
bool deleteT = false;
if (!todo->relations().isEmpty()) {
deleteT = removeCompletedSubTodos( todo );
}
// deleteT == true: todo already deleted in removeCompletedSubTodos
if ( !deleteT ) {
@@ -3537,25 +3603,25 @@ void CalendarView::deleteJournal(Journal *jour)
}
if (KOPrefs::instance()->mConfirm) {
QString des;
if ( !jour->summary().isEmpty() ) {
des = jour->summary();
} else {
des = jour->description().left(30);
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;
} // switch
} else {
calendar()->deleteJournal(jour);;
updateView();
}
emit updateSearchDialog();
}
@@ -3563,33 +3629,33 @@ void CalendarView::deleteEvent(Event *anEvent)
{
if (!anEvent) {
KNotifyClient::beep();
return;
}
if (anEvent->recurrence()->doesRecur()) {
QDate itemDate = mViewManager->currentSelectionDate();
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"));
}
switch(km) {
case KMessageBox::No: // Continue // all
//qDebug("KMessageBox::No ");
if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
schedule(Scheduler::Cancel,anEvent);
@@ -3612,25 +3678,25 @@ void CalendarView::deleteEvent(Event *anEvent)
anEvent->addExDate(itemDate);
int duration = anEvent->recurrence()->duration();
if ( duration > 0 ) {
anEvent->recurrence()->setDuration( duration - 1 );
}
changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
}
break;
//#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)
schedule(Scheduler::Cancel,anEvent);
checkExternalId( anEvent);
mCalendar->deleteEvent(anEvent);
changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
break;
} // switch
} else {
if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
@@ -4571,25 +4637,25 @@ void CalendarView::removeSyncInfo( QString syncProfile)
}
void CalendarView::undo_delete()
{
//qDebug("undo_delete() ");
Incidence* undo = mCalendar->undoIncidence();
if ( !undo ) {
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();
}
}
void CalendarView::slotViewerClosed()
{
QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
}