summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoeditor.cpp29
-rw-r--r--korganizer/kotodoviewitem.cpp42
-rw-r--r--libkcal/incidence.cpp9
-rw-r--r--libkcal/incidence.h5
-rw-r--r--libkcal/incidencebase.cpp1
-rw-r--r--libkcal/incidencebase.h4
-rw-r--r--libkcal/todo.cpp51
-rw-r--r--libkcal/todo.h2
8 files changed, 133 insertions, 10 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 069dda8..9232e09 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -323,2 +323,4 @@ void KOTodoEditor::checkRecurrence()
}
+ if ( to < from )
+ to = from;
mRecurrence->setDefaults(from,to,!time);
@@ -352,2 +354,29 @@ void KOTodoEditor::writeTodo(Todo *event)
mRecurrence->writeEvent(event);
+ event->setRecurrenceID( event->dtStart().addSecs(-1) );
+ event->setRecurDates();
+#if 0
+ bool ok;
+ QDateTime next = event->getNextOccurence( event->dtStart().addSecs(-1), &ok );
+ if ( ok ) {
+ QDateTime from,to;
+ bool time = mGeneral->mTimeButton->isChecked();
+ if ( time ) {
+ to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ;
+ from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ;
+ } else {
+ to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ;
+ from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
+ }
+ if ( to < from )
+ to = from;
+ int secs = from.secsTo( to );
+ event->setRecurrenceID( next );
+ event->setDtStart( next );
+ event->setDtDue( next.addSecs( secs ) );
+ }
+ else {
+ event->setHasRecurrenceID( false );
+ event->recurrence()->unsetRecurs();
+ }
+#endif
} else
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 0e847c2..70f00c6 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -192,2 +192,10 @@ void KOTodoViewItem::setMyPixmap()
pixSize += size;
+ }
+ if ( mTodo->doesRecur() ) {
+ pixi.resize(size, pixSize+size);
+ pPix.fill( Qt::blue );
+ p.begin( &pixi );
+ p. drawPixmap ( 0, pixSize, pPix);
+ p.end();
+ pixSize += size;
}
@@ -202,3 +210,3 @@ void KOTodoViewItem::stateChange(bool state)
{
- // qDebug("KOTodoViewItem::stateChange ");
+ // qDebug("KOTodoViewItem::stateChange %d ", state);
// do not change setting on startup
@@ -217,3 +225,14 @@ void KOTodoViewItem::stateChange(bool state)
//qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
- mTodo->setCompleted(state);
+ if ( mTodo->doesRecur() ){
+ QDateTime start = mTodo->dtStart();
+ mTodo->setCompleted(state);
+ if ( start != mTodo->dtStart() ) {
+ if ( state && !mTodo->isCompleted() ) {
+ setOn( false );
+ state = false;
+ }
+ }
+ } else
+ mTodo->setCompleted(state);
+
if (state) mTodo->setCompleted(QDateTime::currentDateTime());
@@ -235,2 +254,21 @@ void KOTodoViewItem::stateChange(bool state)
}
+ if (mTodo->hasStartDate()) {
+ QString skeyt = "==";
+ QString skeyd = "==";
+ setText(5, mTodo->dtStartDateStr());
+ QDate d = mTodo->dtStart().date();
+ skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
+
+ if (mTodo->doesFloat()) {
+ setText(6,"");
+ }
+ else {
+ setText(6,mTodo->dtStartTimeStr());
+ QTime t = mTodo->dtStart().time();
+ skeyt.sprintf("%02d%02d",t.hour(),t.minute());
+
+ }
+ setSortKey(5,skeyd);
+ setSortKey(6,skeyt);
+ }
if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index dbc159c..0684af2 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -649 +649,10 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
}
+QDateTime Incidence::dtStart() const
+{
+ if ( doesRecur() ) {
+ if ( type() == "Todo" ) {
+ ((Todo*)this)->checkSetCompletedFalse();
+ }
+ }
+ return mDtStart;
+}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 38d2aaa..0ae9656 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -271,2 +271,3 @@ class Incidence : public IncidenceBase
QDateTime recurrenceID () const;
+ QDateTime dtStart() const;
@@ -276,2 +277,4 @@ protected:
QPtrList<Incidence> mRelations;
+ QDateTime mRecurrenceID;
+ bool mHasRecurrenceID;
private:
@@ -281,4 +284,2 @@ protected:
// base components of jounal, event and todo
- QDateTime mRecurrenceID;
- bool mHasRecurrenceID;
QDateTime mCreated;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 7525a4a..51f2e9d 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -181,2 +181,3 @@ void IncidenceBase::setDtStart(const QDateTime &dtStart)
+
QDateTime IncidenceBase::dtStart() const
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index f9a6558..8624786 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -76,3 +76,3 @@ class IncidenceBase : public CustomProperties
/** returns an event's starting date/time as a QDateTime. */
- QDateTime dtStart() const;
+ virtual QDateTime dtStart() const;
/** returns an event's starting time as a string formatted according to the
@@ -143,2 +143,3 @@ class IncidenceBase : public CustomProperties
protected:
+ QDateTime mDtStart;
bool mReadOnly;
@@ -148,3 +149,2 @@ class IncidenceBase : public CustomProperties
// base components
- QDateTime mDtStart;
QString mOrganizer;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 9c04a7e..1f54c2f 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -313,4 +313,6 @@ bool Todo::isCompleted() const
{
- if (mPercentComplete == 100) return true;
- else return false;
+ if (mPercentComplete == 100) {
+ return true;
+ }
+ else return false;
}
@@ -319,2 +321,6 @@ void Todo::setCompleted(bool completed)
{
+ if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
+ if ( !setRecurDates() )
+ completed = false;
+ }
if (completed) mPercentComplete = 100;
@@ -359,5 +365,29 @@ int Todo::percentComplete() const
}
-
-void Todo::setPercentComplete(int v)
+bool Todo::setRecurDates()
{
+ if ( !mHasRecurrenceID )
+ return true;
+ int secs = mDtStart.secsTo( dtDue() );
+ bool ok;
+ qDebug("--------------------setRecurDates() ");
+ //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
+ QDateTime next = getNextOccurence( mRecurrenceID, &ok );
+ if ( ok ) {
+ mRecurrenceID = next;
+ mDtStart = next;
+ setDtDue( next.addSecs( secs ) );
+ if ( QDateTime::currentDateTime() > next)
+ return false;
+ } else {
+ setHasRecurrenceID( false );
+ recurrence()->unsetRecurs();
+ }
+ return true;
+}
+void Todo::setPercentComplete(int v)
+{
+ if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
+ if ( !setRecurDates() )
+ v = 0;
+ }
mPercentComplete = v;
@@ -414 +444,14 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
+void Todo::checkSetCompletedFalse()
+{
+ if ( !hasRecurrenceID() ) {
+ qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
+ }
+ // qDebug("Todo::checkSetCompletedFalse()");
+ //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
+ if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) {
+ qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
+ setCompleted( false );
+ qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ ");
+ }
+}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 137b252..a22d4b7 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -114,2 +114,4 @@ class Todo : public Incidence
bool contains ( Todo*);
+ void checkSetCompletedFalse();
+ bool setRecurDates();