summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-07 20:46:00 (UTC)
committer zautrix <zautrix>2005-07-07 20:46:00 (UTC)
commitde5621f2fd3924f27c05459ae555b3bd06c5e584 (patch) (side-by-side diff)
tree589d19415e3c0ff6c08cec375db145242581c143
parent766b53919de14b8faec22db32b6a750acde0b760 (diff)
downloadkdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.zip
kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.gz
kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.bz2
fixxx
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt13
-rw-r--r--korganizer/calendarview.cpp133
-rw-r--r--korganizer/kotodoview.cpp14
-rw-r--r--libkcal/event.cpp115
-rw-r--r--libkcal/event.h2
-rw-r--r--libkcal/incidencebase.cpp8
-rw-r--r--libkcal/incidencebase.h4
7 files changed, 232 insertions, 57 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index b225594..43bc343 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1502,4 +1502,9 @@
{ "Conflict %1 <-> %2","Konflikt %1 <-> %2" },
{ "<p><b>Q</b>: Show next date with conflicting events\n ","<p><b>Q</b>: Zeige nächstes Datum mit Terminen im Konflikt\n " },
+{ "Week view mode uses row layout","Wochenansicht Modus nutzt Reihenlayout" },
+{ "The event\n%1\nconflicts with event\n%2\nat date\n%3.\n","Der Termin\n%1\nist im Konflikt mit Termin\n%2\nam Datum\n%3.\n" },
+{ "KO/Pi Conflict delected","KO/Pi Konflikt erkannt" },
+{ "Show date","Zeige Datum" },
+{ "No problem!","Kein Problem!" },
{ "","" },
{ "","" },
@@ -1511,10 +1516,2 @@
{ "","" },
{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-
-
-
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e766b8f..65750af 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -657,5 +657,61 @@ CalendarView::~CalendarView()
void CalendarView::nextConflict( bool all, bool allday )
{
- QDate start = mNavigator->selectedDates().first().addDays(1);
+
+ QPtrList<Event> testlist = mCalendar->events();
+ Event * test = testlist.first();
+ while ( test ) {
+ test->setTagged( false );
+ }
+ QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0));
+ QDateTime conflict;
+ QDateTime retVal;
+ bool found = false;
+ Event * cE = 0;
+ QPtrList<Event> testlist2 = testlist;
+ 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;
+ }
+ }
+ }
+ }
+ 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 ) ) );
+ return;
+ }
+
+ topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
+ qDebug("No conflict found ");
+ return;
+
+
+
+
+
+#if 0
+
+
QDate end = start.addDays( 365*2);
while ( start < end ) {
@@ -706,4 +762,5 @@ void CalendarView::nextConflict( bool all, bool allday )
topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
qDebug("No conflict found ");
+#endif
}
@@ -2696,6 +2753,4 @@ void CalendarView::changeEventDisplay(Event *which, int action)
// kdDebug() << "CalendarView::changeEventDisplay" << endl;
changeIncidenceDisplay((Incidence *)which, action);
-
-
static bool clearallviews = false;
if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
@@ -2707,10 +2762,6 @@ void CalendarView::changeEventDisplay(Event *which, int action)
}
clearallviews = true;
-
-
-
mDateNavigator->updateView();
//mDialogManager->updateSearchDialog();
-
if (which) {
// If there is an event view visible update the display
@@ -2738,36 +2789,29 @@ void CalendarView::checkConflictForEvent()
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;
+ QPtrList<Event> testlist = mCalendar->events();
+ Event * test = testlist.first();
+ QDateTime conflict;
+ QDateTime retVal;
+ bool found = false;
+ Event * cE = 0;
+ while ( test ) {
+ if ( !test->doesFloat() ) {
+ if ( mConflictingEvent->isOverlapping ( test, &retVal, true ) ) {
+ if ( ! found ) {
+ conflict = retVal;
+ cE = test;
+ } else {
+ if ( retVal < conflict ) {
+ conflict = retVal;
+ cE = test;
}
- 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) ) ;
+ 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,
@@ -2778,19 +2822,12 @@ void CalendarView::checkConflictForEvent()
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();
+ mNavigator->slotDaySelect( conflict.date() );
+ int hour = conflict.time().hour();
mViewManager->agendaView()->setStartHour( hour );
- topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) );
+ topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
return;
}
- }
- t_ev = test.next();
- }
- start = start.addDays( 1 );
- }
- qDebug("No conflict found ");
+ return;
}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 2c017e1..c2ad886 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -403,4 +403,8 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e )
{
qApp->processEvents();
+ if ( !isVisible() ) {
+ e->ignore();
+ return;
+ }
if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
e->ignore();
@@ -1601,4 +1605,8 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
//return;
//qDebug("KOTodoView::keyPressEvent ");
+ if ( !isVisible() ) {
+ e->ignore();
+ return;
+ }
switch ( e->key() ) {
case Qt::Key_Down:
@@ -1608,4 +1616,10 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
case Qt::Key_Q:
+
+
+ if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
+ e->ignore();
+ break;
+ }
toggleQuickTodo();
break;
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 7cd81fa..235ae55 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -172,4 +172,119 @@ void Event::setDuration(int seconds)
Incidence::setDuration(seconds);
}
+bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, bool inFutureOnly )
+{
+ if ( testEvent == this )
+ return false;
+ if ( ! doesRecur() && !testEvent->doesRecur() ) {
+ QDateTime te;
+ if ( testEvent->doesFloat() )
+ te = testEvent->mDtEnd.addDays( 1 );
+ else
+ te = testEvent->mDtEnd;
+ QDateTime e;
+ if ( doesFloat() )
+ e = mDtEnd.addDays( 1 );
+ else
+ e = mDtEnd;
+ if ( mDtStart < te && testEvent->mDtStart < e ) {
+ if ( mDtStart < testEvent->mDtStart )
+ *overlapDT = testEvent->mDtStart;
+ else
+ *overlapDT = mDtStart;
+ if ( inFutureOnly )
+ return (*overlapDT >= QDateTime::currentDateTime() );
+ return true;
+ }
+ return false;
+ }
+ Event *nonRecur = 0;
+ Event *recurEvent = 0;
+ if ( ! doesRecur() ) {
+ nonRecur = this;
+ recurEvent = testEvent;
+ }
+ else if ( !testEvent->doesRecur() ) {
+ nonRecur = testEvent;
+ recurEvent = this;
+ }
+ if ( nonRecur ) {
+ QDateTime enr;
+ if ( nonRecur->doesFloat() )
+ enr = nonRecur->mDtEnd.addDays( 1 );
+ else
+ enr = nonRecur->mDtEnd;
+ if ( enr < recurEvent->mDtStart )
+ return false;
+ if ( inFutureOnly && enr < QDateTime::currentDateTime() )
+ return false;
+ int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd );
+ if ( recurEvent->doesFloat() )
+ recDuration += 86400;
+ bool ok = true;
+ QDateTime recStart = recurEvent->mDtStart.addSecs( -300);;
+ while ( ok ) {
+ recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok );
+ if ( ok ) {
+ if ( recStart > enr )
+ return false;
+ QDateTime recEnd = recStart.addSecs( recDuration );
+ if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) {
+ if ( nonRecur->mDtStart < recStart )
+ *overlapDT = recStart;
+ else
+ *overlapDT = nonRecur->mDtStart;
+ if ( inFutureOnly ) {
+ if ( *overlapDT >= QDateTime::currentDateTime() )
+ return true;
+ } else
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ QDateTime incidenceStart = mDtStart;
+ int duration = mDtStart.secsTo( mDtEnd );
+ if ( doesFloat() )
+ duration += 86400;
+ QDateTime testincidenceStart = testEvent->mDtStart;
+ int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd );
+ if ( testEvent->doesFloat() )
+ testduration += 86400;
+ bool computeThis = false;
+ if ( incidenceStart < testincidenceStart )
+ computeThis = true;
+ bool ok = true;
+ if ( computeThis )
+ incidenceStart = incidenceStart.addSecs( -300 );
+ else
+ testincidenceStart = testincidenceStart.addSecs( -300 );
+ int count = 0;
+ while ( ok ) {
+ ++count;
+ if ( count > 1000 ) break;
+ if ( computeThis )
+ incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok );
+ else
+ testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok );
+ if ( ok ) {
+ if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) {
+ if ( incidenceStart < testincidenceStart )
+ *overlapDT = testincidenceStart;
+ else
+ *overlapDT = incidenceStart;
+ if ( inFutureOnly ) {
+ if ( *overlapDT >= QDateTime::currentDateTime() )
+ return true;
+ } else
+ return true;
+ }
+ computeThis = ( incidenceStart < testincidenceStart );
+ }
+
+ }
+ return false;
+}
QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
{
diff --git a/libkcal/event.h b/libkcal/event.h
index 287d403..80c11c4 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -75,4 +75,6 @@ class Event : public Incidence
bool contains ( Event*);
+ bool isOverlapping ( Event*, QDateTime*, bool inFutureOnly );
+
private:
bool accept(Visitor &v) { return v.visit(this); }
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 96039df..dcead02 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -140,4 +140,12 @@ QDateTime IncidenceBase::getEvenTime( QDateTime dt )
}
+bool IncidenceBase::isTagged() const
+{
+ return mIsTagged;
+}
+void IncidenceBase::setTagged( bool b)
+{
+ mIsTagged = b;
+}
void IncidenceBase::setCalID( int id )
{
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index dc6024a..bccf287 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -148,6 +148,8 @@ class IncidenceBase : public CustomProperties
void setAlarmEnabled( bool );
bool alarmEnabled() const;
-
+ bool isTagged() const;
+ void setTagged( bool );
protected:
+ bool mIsTagged;
QDateTime mDtStart;
bool mReadOnly;