author | zautrix <zautrix> | 2005-04-10 09:27:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-10 09:27:53 (UTC) |
commit | eda44f28d633f852caebd21a1e375f3e8e91a5cb (patch) (side-by-side diff) | |
tree | c7b380b9c742420c6d84b61700f05b72cd6b1d75 | |
parent | 79b12b680f6a0653bcff84c8ef83b23803246b7d (diff) | |
download | kdepimpi-eda44f28d633f852caebd21a1e375f3e8e91a5cb.zip kdepimpi-eda44f28d633f852caebd21a1e375f3e8e91a5cb.tar.gz kdepimpi-eda44f28d633f852caebd21a1e375f3e8e91a5cb.tar.bz2 |
fixxx
-rw-r--r-- | libkcal/todo.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7906046..19a7ffd 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -28,106 +28,108 @@ #include "icalformat.h" #include "todo.h" using namespace KCal; Todo::Todo(): Incidence() { // mStatus = TENTATIVE; mHasDueDate = false; setHasStartDate( false ); mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; mPercentComplete = 0; mRunning = false; mRunSaveTimer = 0; } Todo::Todo(const Todo &t) : Incidence(t) { mDtDue = t.mDtDue; mHasDueDate = t.mHasDueDate; mCompleted = t.mCompleted; mHasCompletedDate = t.mHasCompletedDate; mPercentComplete = t.mPercentComplete; mRunning = false; mRunSaveTimer = 0; } Todo::~Todo() { setRunning( false ); - qDebug("Todo::~Todo() "); + //qDebug("Todo::~Todo() "); } void Todo::setRunning( bool run ) { if ( run == mRunning ) return; if ( !mRunSaveTimer ) { mRunSaveTimer = new QTimer ( this ); connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); } mRunning = run; if ( mRunning ) { mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min mRunStart = QDateTime::currentDateTime(); } else { mRunSaveTimer->stop(); saveRunningInfoToFile(); } } void Todo::saveRunningInfoToFile() { qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); QString dir = KGlobalSettings::timeTrackerDir(); qDebug("%s ", dir.latin1()); - QString file = "%1%2%3-%4%5%6-%7%8%9-"; - int runtime = mRunStart.secsTo( QDateTime::currentDateTime() ); - runtime = (runtime / 60) +1; - int h = runtime / 60; - int m = runtime % 60; - int d = h / 24; - h = h % 24; - file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ).arg( d,3 ).arg( h,2 ).arg( m,2 ); + QString file = "%1%2%3-%4%5%6-"; + file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); file.replace ( QRegExp (" "), "0" ); - file = dir +"/" +file + uid()+".ics"; + file += uid(); qDebug("File %s ",file.latin1() ); CalendarLocal cal; cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); - cal.addIncidence( clone() ); + Todo * to = (Todo*) clone(); + to->setFloats( false ); + to->setDtStart( mRunStart ); + to->setHasStartDate( true ); + to->setDtDue( QDateTime::currentDateTime() ); + to->setHasDueDate( true ); + to->setUid( file ); + cal.addIncidence( to ); ICalFormat format; + file = dir +"/" +file +".ics"; format.save( &cal, file ); } int Todo::runTime() { if ( !mRunning ) return 0; return mRunStart.secsTo( QDateTime::currentDateTime() ); } bool Todo::hasRunningSub() { if ( mRunning ) return true; Incidence *aTodo; for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { if ( ((Todo*)aTodo)->hasRunningSub() ) return true; } return false; } Incidence *Todo::clone() { return new Todo(*this); } bool Todo::contains ( Todo* from ) { if ( !from->summary().isEmpty() ) if ( !summary().startsWith( from->summary() )) return false; @@ -210,65 +212,64 @@ bool KCal::operator==( const Todo& t1, const Todo& t2 ) if ( t1.isCompleted() ) { if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { if ( t1.hasCompletedDate() ) { if ( t1.completed() != t2.completed() ) return false; } } else return false; } return true; } void Todo::setDtDue(const QDateTime &dtDue) { //int diffsecs = mDtDue.secsTo(dtDue); /*if (mReadOnly) return; const QPtrList<Alarm>& alarms = alarms(); for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { if (alarm->enabled()) { alarm->setTime(alarm->time().addSecs(diffsecs)); } }*/ mDtDue = getEvenTime(dtDue); //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; /*const QPtrList<Alarm>& alarms = alarms(); for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) alarm->setAlarmStart(mDtDue);*/ - updated(); } QDateTime Todo::dtDue() const { return mDtDue; } QString Todo::dtDueTimeStr() const { return KGlobal::locale()->formatTime(mDtDue.time()); } QString Todo::dtDueDateStr(bool shortfmt) const { return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); } QString Todo::dtDueStr(bool shortfmt) const { if ( doesFloat() ) return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); } // retval 0 : no found // 1 : due for date found // 2 : overdue for date found int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) { int retval = 0; if ( isCompleted() ) return 0; |