author | zautrix <zautrix> | 2005-07-07 20:46:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 20:46:00 (UTC) |
commit | de5621f2fd3924f27c05459ae555b3bd06c5e584 (patch) (side-by-side diff) | |
tree | 589d19415e3c0ff6c08cec375db145242581c143 | |
parent | 766b53919de14b8faec22db32b6a750acde0b760 (diff) | |
download | kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.zip kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.gz kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.bz2 |
fixxx
-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 13 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 133 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 14 | ||||
-rw-r--r-- | libkcal/event.cpp | 115 | ||||
-rw-r--r-- | libkcal/event.h | 2 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 4 |
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 @@ -1500,8 +1500,13 @@ { "Events with time","Termine mit Zeit" }, { "No conflict found within the next two years","Kein Konflikt innerhalb der nächsten zwei Jahre gefunden" }, { "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!" }, { "","" }, { "","" }, { "","" }, { "","" }, @@ -1509,12 +1514,4 @@ { "","" }, { "","" }, { "","" }, { "","" }, -{ "","" }, -{ "","" }, -{ "","" }, -{ "","" }, -{ "","" }, - - - diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index e766b8f..65750af 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -655,9 +655,65 @@ CalendarView::~CalendarView() //kdDebug() << "~CalendarView() done" << endl; } 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 ) { QPtrList<Event> eventList = calendar()->events( start ); Event * ev = eventList.first(); @@ -704,8 +760,9 @@ void CalendarView::nextConflict( bool all, bool allday ) start = start.addDays( 1 ); } topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); qDebug("No conflict found "); +#endif } void CalendarView::conflictAll() { @@ -2694,10 +2751,8 @@ void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 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(); @@ -2705,14 +2760,10 @@ void CalendarView::changeEventDisplay(Event *which, int action) } 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 @@ -2736,63 +2787,49 @@ void CalendarView::checkConflictForEvent() 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; + 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, 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(); + 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; } void CalendarView::updateTodoViews() diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 2c017e1..c2ad886 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -401,8 +401,12 @@ void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) void KOTodoListView::keyPressEvent ( QKeyEvent * e ) { qApp->processEvents(); + if ( !isVisible() ) { + e->ignore(); + return; + } if ( e->isAutoRepeat() && !mFlagKeyPressed ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; @@ -1599,15 +1603,25 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e ) { // e->ignore(); //return; //qDebug("KOTodoView::keyPressEvent "); + if ( !isVisible() ) { + e->ignore(); + return; + } switch ( e->key() ) { case Qt::Key_Down: case Qt::Key_Up: QWidget::keyPressEvent ( e ); break; case Qt::Key_Q: + + + if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { + e->ignore(); + break; + } toggleQuickTodo(); break; case Qt::Key_U: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 7cd81fa..235ae55 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp @@ -170,8 +170,123 @@ void Event::setDuration(int seconds) { setHasEndDate(false); 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 { *ok = false; if ( !alarmEnabled() ) diff --git a/libkcal/event.h b/libkcal/event.h index 287d403..80c11c4 100644 --- a/libkcal/event.h +++ b/libkcal/event.h @@ -73,8 +73,10 @@ class Event : public Incidence void setDuration(int seconds); bool contains ( Event*); + bool isOverlapping ( Event*, QDateTime*, bool inFutureOnly ); + private: bool accept(Visitor &v) { return v.visit(this); } QDateTime mDtEnd; diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 96039df..dcead02 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -138,8 +138,16 @@ QDateTime IncidenceBase::getEvenTime( QDateTime dt ) dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); return dt; } +bool IncidenceBase::isTagged() const +{ + return mIsTagged; +} +void IncidenceBase::setTagged( bool b) +{ + mIsTagged = b; +} void IncidenceBase::setCalID( int id ) { if ( mCalID > 0 ) updated(); diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index dc6024a..bccf287 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h @@ -146,10 +146,12 @@ class IncidenceBase : public CustomProperties void setCalEnabled( bool ); bool calEnabled() const; void setAlarmEnabled( bool ); bool alarmEnabled() const; - + bool isTagged() const; + void setTagged( bool ); protected: + bool mIsTagged; QDateTime mDtStart; bool mReadOnly; QDateTime getEvenTime( QDateTime ); |