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
@@ -1492,29 +1492,26 @@
{ "Configure Calendar Files...","Konfiguriere Kalenderdateien..." },
{ "You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>.","Sie können <b>mehr als eine</b> Kalenderdatei in KO/Pi darstellen und benutzen. Eine Kalenderdatei wird <b>Resource</b> genannt. Um einen Kalender hinzuzufügen oder die Kalendereinstellungen zu ändern benutzen Sie bitte das Menu: <b>Ansicht -> Resourcenansicht umschalten</b>." },
{ "Hide Completed","Verstecke erledigte Todos" },
{ "Show not Running","Zeige nicht Laufende" },
{ "Click to add new Todo","Klick für neues Todo!" },
{ "Show next conflict for","Zeige nächsten Konflikt für" },
{ "All events","Alle Termine" },
{ "Allday events","Ganztagestermine" },
{ "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!" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-{ "","" },
-
-
-
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e766b8f..65750af 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -647,25 +647,81 @@ 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);
+
+ 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();
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 );
@@ -696,24 +752,25 @@ void CalendarView::nextConflict( bool all, bool allday )
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 ");
+#endif
}
void CalendarView::conflictAll()
{
nextConflict ( true, true );
}
void CalendarView::conflictAllday()
{
nextConflict ( false, true );
}
void CalendarView::conflictNotAll()
{
@@ -2686,41 +2743,35 @@ void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
mEventViewerDialog->hide();
}
else
mCalendar->checkAlarmForIncidence( which , false );
}
// most of the changeEventDisplays() right now just call the view's
// total update mode, but they SHOULD be recoded to be more refresh-efficient.
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();
clearallviews = false;
}
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
// if (which->getTodoStatus()) {
mTodoList->updateView();
if ( action != KOGlobals::EVENTDELETED ) {
mConflictingEvent = which ;
QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) );
}
// }
} else {
@@ -2728,79 +2779,65 @@ void CalendarView::changeEventDisplay(Event *which, int action)
}
}
void CalendarView::checkConflictForEvent()
{
if (!KOPrefs::instance()->mConfirm)
return;
if ( ! mConflictingEvent ) return;
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()
{
mTodoList->updateView();
mViewManager->currentView()->updateView();
}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 2c017e1..c2ad886 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -393,24 +393,28 @@ void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
}
void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
{
if ( !e->isAutoRepeat() ) {
mFlagKeyPressed = false;
}
}
void KOTodoListView::keyPressEvent ( QKeyEvent * e )
{
qApp->processEvents();
+ if ( !isVisible() ) {
+ e->ignore();
+ return;
+ }
if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
e->ignore();
// qDebug(" ignore %d",e->isAutoRepeat() );
return;
}
if (! e->isAutoRepeat() )
mFlagKeyPressed = true;
QListViewItem* cn;
if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
cn = currentItem();
if ( cn ) {
KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
@@ -1591,31 +1595,41 @@ void KOTodoView::addQuickTodoPar( Todo * parentTodo)
}
mCalendar->addTodo(todo);
mQuickAdd->setText("");
todoModified (todo, KOGlobals::EVENTADDED );
updateView();
}
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 ) {
mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
unparentTodo();
e->accept();
} else
e->ignore();
break;
case Qt::Key_S:
if ( e->state() == Qt::ControlButton ) {
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 7cd81fa..235ae55 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -162,24 +162,139 @@ void Event::setTransparency(Event::Transparency transparency)
}
Event::Transparency Event::transparency() const
{
return mTransparency;
}
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() )
return QDateTime ();
bool yes;
QDateTime incidenceStart = getNextOccurence( start_dt, &yes );
if ( ! yes || cancelled() ) {
*ok = false;
return QDateTime ();
}
diff --git a/libkcal/event.h b/libkcal/event.h
index 287d403..80c11c4 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -65,24 +65,26 @@ class Event : public Incidence
/** Return true if the event spans multiple days, otherwise return false. */
bool isMultiDay() const;
/** set the event's time transparency level. */
void setTransparency(Transparency transparency);
/** get the event's time transparency level. */
Transparency transparency() const;
void setDuration(int seconds);
bool contains ( Event*);
+ bool isOverlapping ( Event*, QDateTime*, bool inFutureOnly );
+
private:
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtEnd;
bool mHasEndDate;
Transparency mTransparency;
};
bool operator==( const Event&, const Event& );
}
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 96039df..dcead02 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -130,24 +130,32 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
// no need to compare mObserver
}
QDateTime IncidenceBase::getEvenTime( QDateTime dt )
{
QTime t = dt.time();
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();
mCalID = id;
}
int IncidenceBase::calID() const
{
return mCalID;
}
void IncidenceBase::setCalEnabled( bool b )
{
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index dc6024a..bccf287 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -138,26 +138,28 @@ class IncidenceBase : public CustomProperties
QString getCsum( const QString & );
void removeID(const QString &);
void registerObserver( Observer * );
void unRegisterObserver( Observer * );
void updated();
void setCalID( int id );
int calID() const;
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 );
private:
// base components
QString mOrganizer;
QString mUid;
int mCalID;
bool mCalEnabled;
bool mAlarmEnabled;
QDateTime mLastModified;