summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt13
-rw-r--r--korganizer/calendarview.cpp153
-rw-r--r--korganizer/kotodoview.cpp16
-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, 243 insertions, 68 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 @@
1502{ "Conflict %1 <-> %2","Konflikt %1 <-> %2" }, 1502{ "Conflict %1 <-> %2","Konflikt %1 <-> %2" },
1503{ "<p><b>Q</b>: Show next date with conflicting events\n ","<p><b>Q</b>: Zeige nächstes Datum mit Terminen im Konflikt\n " }, 1503{ "<p><b>Q</b>: Show next date with conflicting events\n ","<p><b>Q</b>: Zeige nächstes Datum mit Terminen im Konflikt\n " },
1504{ "Week view mode uses row layout","Wochenansicht Modus nutzt Reihenlayout" },
1505{ "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" },
1506{ "KO/Pi Conflict delected","KO/Pi Konflikt erkannt" },
1507{ "Show date","Zeige Datum" },
1508{ "No problem!","Kein Problem!" },
1504{ "","" }, 1509{ "","" },
1505{ "","" }, 1510{ "","" },
@@ -1511,10 +1516,2 @@
1511{ "","" }, 1516{ "","" },
1512{ "","" }, 1517{ "","" },
1513{ "","" },
1514{ "","" },
1515{ "","" },
1516{ "","" },
1517{ "","" },
1518
1519
1520
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()
657void CalendarView::nextConflict( bool all, bool allday ) 657void CalendarView::nextConflict( bool all, bool allday )
658{ 658{
659 QDate start = mNavigator->selectedDates().first().addDays(1); 659
660 QPtrList<Event> testlist = mCalendar->events();
661 Event * test = testlist.first();
662 while ( test ) {
663 test->setTagged( false );
664 }
665 QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0));
666 QDateTime conflict;
667 QDateTime retVal;
668 bool found = false;
669 Event * cE = 0;
670 QPtrList<Event> testlist2 = testlist;
671 while ( test ) {
672 Event * test2 = testlist2.first();
673 while ( test2 ) {
674 if ( !test2->isTagged() ) {
675 if ( test->isOverlapping ( test2, &retVal, true ) ) {
676 if ( ! found ) {
677 if ( retVal >= startDT ) {
678 conflict = retVal;
679 cE = test;
680 found = true;
681 }
682 } else {
683 if ( retVal >= startDT && retVal < conflict ) {
684 conflict = retVal;
685 cE = test;
686 }
687 }
688 }
689 }
690 test2 = testlist2.next();
691 }
692 test->setTagged( true );
693 test = testlist.next();
694 }
695 if ( found ) {
696 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
697 mViewManager->showDayView();
698 mNavigator->slotDaySelect( conflict.date() );
699 int hour = conflict.time().hour();
700 mViewManager->agendaView()->setStartHour( hour );
701 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
702 return;
703 }
704
705 topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
706 qDebug("No conflict found ");
707 return;
708
709
710
711
712
713#if 0
714
715
660 QDate end = start.addDays( 365*2); 716 QDate end = start.addDays( 365*2);
661 while ( start < end ) { 717 while ( start < end ) {
@@ -706,4 +762,5 @@ void CalendarView::nextConflict( bool all, bool allday )
706 topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); 762 topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
707 qDebug("No conflict found "); 763 qDebug("No conflict found ");
764#endif
708} 765}
709 766
@@ -2696,6 +2753,4 @@ void CalendarView::changeEventDisplay(Event *which, int action)
2696 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2753 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2697 changeIncidenceDisplay((Incidence *)which, action); 2754 changeIncidenceDisplay((Incidence *)which, action);
2698
2699
2700 static bool clearallviews = false; 2755 static bool clearallviews = false;
2701 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2756 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
@@ -2707,10 +2762,6 @@ void CalendarView::changeEventDisplay(Event *which, int action)
2707 } 2762 }
2708 clearallviews = true; 2763 clearallviews = true;
2709
2710
2711
2712 mDateNavigator->updateView(); 2764 mDateNavigator->updateView();
2713 //mDialogManager->updateSearchDialog(); 2765 //mDialogManager->updateSearchDialog();
2714
2715 if (which) { 2766 if (which) {
2716 // If there is an event view visible update the display 2767 // If there is an event view visible update the display
@@ -2738,60 +2789,46 @@ void CalendarView::checkConflictForEvent()
2738 return; 2789 return;
2739 } 2790 }
2740 bool all = false; 2791 QPtrList<Event> testlist = mCalendar->events();
2741 bool allday = false; 2792 Event * test = testlist.first();
2742 Event * ev = mConflictingEvent; 2793 QDateTime conflict;
2743 mConflictingEvent = 0; 2794 QDateTime retVal;
2744 QDate start = ev->dtStart().date(); 2795 bool found = false;
2745 QDate end = ev->dtEnd().date().addDays(1); 2796 Event * cE = 0;
2746 while ( start < end ) { 2797 while ( test ) {
2747 QPtrList<Event> test = calendar()->events( start ); 2798 if ( !test->doesFloat() ) {
2748 //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); 2799 if ( mConflictingEvent->isOverlapping ( test, &retVal, true ) ) {
2749 Event * t_ev = test.first(); 2800 if ( ! found ) {
2750 QDateTime es = ev->dtStart(); 2801 conflict = retVal;
2751 QDateTime ee = ev->dtEnd(); 2802 cE = test;
2752 if ( ev->doesFloat() ) 2803 } else {
2753 ee = ee.addDays( 1 ); 2804 if ( retVal < conflict ) {
2754 if ( ! all ) { 2805 conflict = retVal;
2755 if ( ev->doesFloat() != allday ) 2806 cE = test;
2756 t_ev = 0; 2807 }
2757 }
2758 while ( t_ev ) {
2759 bool skip = false;
2760 if ( ! all ) {
2761 if ( t_ev->doesFloat() != allday )
2762 skip = true;
2763 }
2764 if ( !skip && ev != t_ev ) {
2765 QDateTime ets = t_ev->dtStart();
2766 QDateTime ete = t_ev->dtEnd();
2767 if ( t_ev->doesFloat() )
2768 ete = ete.addDays( 1 );
2769 //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() );
2770 if ( es < ete && ets < ee ) {
2771 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) ) ;
2772 qApp->processEvents();
2773 int km = KMessageBox::warningContinueCancel(this,mess,
2774 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2775 if ( km != KMessageBox::Continue )
2776 return;
2777
2778 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2779 mViewManager->showDayView();
2780 mNavigator->slotDaySelect( start );
2781 int hour = es.time().hour();
2782 if ( ets > es )
2783 hour = ets.time().hour();
2784 mViewManager->agendaView()->setStartHour( hour );
2785 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) );
2786 return;
2787 } 2808 }
2809 found = true;
2788 } 2810 }
2789 t_ev = test.next();
2790 } 2811 }
2791 start = start.addDays( 1 ); 2812 test = testlist.next();
2792 } 2813 }
2793 qDebug("No conflict found "); 2814 if ( found ) {
2794 2815 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()) ) ;
2816 qApp->processEvents();
2817 int km = KMessageBox::warningContinueCancel(this,mess,
2818 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2819 if ( km != KMessageBox::Continue )
2820 return;
2795 2821
2822 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2823 mViewManager->showDayView();
2824 mNavigator->slotDaySelect( conflict.date() );
2825 int hour = conflict.time().hour();
2826 mViewManager->agendaView()->setStartHour( hour );
2827 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
2828 return;
2829 }
2830
2831 return;
2832
2796} 2833}
2797 2834
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 )
403{ 403{
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( !isVisible() ) {
406 e->ignore();
407 return;
408 }
405 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
406 e->ignore(); 410 e->ignore();
@@ -1600,5 +1604,9 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
1600 // e->ignore(); 1604 // e->ignore();
1601 //return; 1605 //return;
1602 //qDebug("KOTodoView::keyPressEvent "); 1606 //qDebug("KOTodoView::keyPressEvent ");
1607 if ( !isVisible() ) {
1608 e->ignore();
1609 return;
1610 }
1603 switch ( e->key() ) { 1611 switch ( e->key() ) {
1604 case Qt::Key_Down: 1612 case Qt::Key_Down:
@@ -1608,4 +1616,10 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
1608 1616
1609 case Qt::Key_Q: 1617 case Qt::Key_Q:
1618
1619
1620 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
1621 e->ignore();
1622 break;
1623 }
1610 toggleQuickTodo(); 1624 toggleQuickTodo();
1611 break; 1625 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)
172 Incidence::setDuration(seconds); 172 Incidence::setDuration(seconds);
173} 173}
174bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, bool inFutureOnly )
175{
176 if ( testEvent == this )
177 return false;
178 if ( ! doesRecur() && !testEvent->doesRecur() ) {
179 QDateTime te;
180 if ( testEvent->doesFloat() )
181 te = testEvent->mDtEnd.addDays( 1 );
182 else
183 te = testEvent->mDtEnd;
184 QDateTime e;
185 if ( doesFloat() )
186 e = mDtEnd.addDays( 1 );
187 else
188 e = mDtEnd;
189 if ( mDtStart < te && testEvent->mDtStart < e ) {
190 if ( mDtStart < testEvent->mDtStart )
191 *overlapDT = testEvent->mDtStart;
192 else
193 *overlapDT = mDtStart;
194 if ( inFutureOnly )
195 return (*overlapDT >= QDateTime::currentDateTime() );
196 return true;
197 }
198 return false;
199 }
200 Event *nonRecur = 0;
201 Event *recurEvent = 0;
202 if ( ! doesRecur() ) {
203 nonRecur = this;
204 recurEvent = testEvent;
205 }
206 else if ( !testEvent->doesRecur() ) {
207 nonRecur = testEvent;
208 recurEvent = this;
209 }
210 if ( nonRecur ) {
211 QDateTime enr;
212 if ( nonRecur->doesFloat() )
213 enr = nonRecur->mDtEnd.addDays( 1 );
214 else
215 enr = nonRecur->mDtEnd;
216 if ( enr < recurEvent->mDtStart )
217 return false;
218 if ( inFutureOnly && enr < QDateTime::currentDateTime() )
219 return false;
220 int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd );
221 if ( recurEvent->doesFloat() )
222 recDuration += 86400;
223 bool ok = true;
224 QDateTime recStart = recurEvent->mDtStart.addSecs( -300);;
225 while ( ok ) {
226 recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok );
227 if ( ok ) {
228 if ( recStart > enr )
229 return false;
230 QDateTime recEnd = recStart.addSecs( recDuration );
231 if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) {
232 if ( nonRecur->mDtStart < recStart )
233 *overlapDT = recStart;
234 else
235 *overlapDT = nonRecur->mDtStart;
236 if ( inFutureOnly ) {
237 if ( *overlapDT >= QDateTime::currentDateTime() )
238 return true;
239 } else
240 return true;
241 }
242 }
243 }
244 return false;
245 }
246
247 QDateTime incidenceStart = mDtStart;
248 int duration = mDtStart.secsTo( mDtEnd );
249 if ( doesFloat() )
250 duration += 86400;
251 QDateTime testincidenceStart = testEvent->mDtStart;
252 int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd );
253 if ( testEvent->doesFloat() )
254 testduration += 86400;
255 bool computeThis = false;
256 if ( incidenceStart < testincidenceStart )
257 computeThis = true;
258 bool ok = true;
259 if ( computeThis )
260 incidenceStart = incidenceStart.addSecs( -300 );
261 else
262 testincidenceStart = testincidenceStart.addSecs( -300 );
263 int count = 0;
264 while ( ok ) {
265 ++count;
266 if ( count > 1000 ) break;
267 if ( computeThis )
268 incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok );
269 else
270 testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok );
271 if ( ok ) {
272 if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) {
273 if ( incidenceStart < testincidenceStart )
274 *overlapDT = testincidenceStart;
275 else
276 *overlapDT = incidenceStart;
277 if ( inFutureOnly ) {
278 if ( *overlapDT >= QDateTime::currentDateTime() )
279 return true;
280 } else
281 return true;
282 }
283 computeThis = ( incidenceStart < testincidenceStart );
284 }
285
286 }
287 return false;
288}
174QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 289QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
175{ 290{
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
75 bool contains ( Event*); 75 bool contains ( Event*);
76 76
77 bool isOverlapping ( Event*, QDateTime*, bool inFutureOnly );
78
77 private: 79 private:
78 bool accept(Visitor &v) { return v.visit(this); } 80 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 )
140} 140}
141 141
142bool IncidenceBase::isTagged() const
143{
144 return mIsTagged;
145}
146void IncidenceBase::setTagged( bool b)
147{
148 mIsTagged = b;
149}
142void IncidenceBase::setCalID( int id ) 150void IncidenceBase::setCalID( int id )
143{ 151{
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
148 void setAlarmEnabled( bool ); 148 void setAlarmEnabled( bool );
149 bool alarmEnabled() const; 149 bool alarmEnabled() const;
150 150 bool isTagged() const;
151 void setTagged( bool );
151 protected: 152 protected:
153 bool mIsTagged;
152 QDateTime mDtStart; 154 QDateTime mDtStart;
153 bool mReadOnly; 155 bool mReadOnly;