| Summary: | Persistent Time Data option | ||
|---|---|---|---|
| Product: | [Applications] ktimetracker | Reporter: | Jason Curl <j.m.curl> |
| Component: | general | Assignee: | Thorsten Staerk <dev> |
| Status: | RESOLVED FIXED | ||
| Severity: | wishlist | ||
| Priority: | NOR | ||
| Version First Reported In: | Git (master) | ||
| Target Milestone: | --- | ||
| Platform: | RedHat Enterprise Linux | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: |
next try
set dtStart when the timer starts, dtEnd when the timer stops set dtStart when the timer starts, dtEnd not before timer stops seems to work now works now |
||
|
Description
Jason Curl
2004-06-28 12:51:06 UTC
Thanks for your report! Currently, I am working on the documentation for the 3.3 release. Once that is out, I'll go over all open bugs and prioritize them. That is a cool idea. I plan to implement it for KDE 4 (that is due on October 23rd, 2007). Here's some pseudo-code how we could accomplish this.
Index: karmstorage.h
===================================================================
--- karmstorage.h (revision 709914)
+++ karmstorage.h (working copy)
@@ -223,12 +223,12 @@
/**
* Log the event that a timer has started for a task.
*
- * For the iCalendar storage, there is no need to log anything for this
- * event. We log an event when the timer is stopped.
+ * Set dtStart to the starttime. So, if karm crashes, it can
+ * ask the user if it may continue timing.
*
* @param task The task the timer was started for.
*/
- void startTimer(const Task* task) { Q_UNUSED(task); }
+ void startTimer(const Task* task);
/**
* Log the event that the timer has stopped for this task.
Index: karmstorage.cpp
===================================================================
--- karmstorage.cpp (revision 709914)
+++ karmstorage.cpp (working copy)
@@ -1049,6 +1049,11 @@
return err;
}
+void KarmStorage::startTimer(const Task* task)
+{
+ task->setDtEnd(QDateTime::currentDateTime());
+}
+
void KarmStorage::stopTimer(const Task* task, QDateTime when)
{
kdDebug(5970) << "Entering KarmStorage::stopTimer" << endl;
near to a solution:
Index: taskview.cpp
===================================================================
--- taskview.cpp (revision 710266)
+++ taskview.cpp (working copy)
@@ -644,10 +644,12 @@
void TaskView::stopTimerFor(Task* task)
{
- if ( task != 0 && d->mActiveTasks.indexOf(task) != -1 ) {
+ if ( task != 0 && d->mActiveTasks.indexOf(task) != -1 )
+ {
d->mActiveTasks.removeAll(task);
task->setRunning(false, d->mStorage);
- if ( d->mActiveTasks.count() == 0 ) {
+ if ( d->mActiveTasks.count() == 0 )
+ {
_idleTimeDetector->stopIdleDetection();
emit timersInactive();
}
@@ -659,7 +661,8 @@
void TaskView::stopCurrentTimer()
{
stopTimerFor( currentItem() );
- if ( d->mFocusTrackingActive && d->mLastTaskWithFocus == currentItem() ) {
+ if ( d->mFocusTrackingActive && d->mLastTaskWithFocus == currentItem() )
+ {
toggleFocusTracking();
}
}
Index: karmstorage.h
===================================================================
--- karmstorage.h (revision 710266)
+++ karmstorage.h (working copy)
@@ -199,7 +199,7 @@
*
* @param task The task the timer was started for.
*/
- void startTimer(const Task* task) { Q_UNUSED(task); }
+ void startTimer(const Task* task, const KDateTime &when=KDateTime::currentLocalDateTime());
/**
* Log the event that the timer has stopped for this task.
Index: karmstorage.cpp
===================================================================
--- karmstorage.cpp (revision 710362)
+++ karmstorage.cpp (working copy)
@@ -873,12 +873,34 @@
return err;
}
+void KarmStorage::startTimer( const Task* task, const KDateTime &when )
+{
+ KCal::Event* e;
+ QDateTime end;
+
+ e = baseEvent(task);
+
+ e->setDtStart(when);
+
+ d->mCalendar->addEvent(e);
+
+ task->taskView()->scheduleSave();
+}
+
void KarmStorage::stopTimer( const Task* task, const QDateTime &when )
{
kDebug(5970) <<"Entering stopTimer when=" << when;
kDebug(5970) <<"task->startTime=" << task->startTime();
- long delta = task->startTime().secsTo(when);
- changeTime(task, delta);
+ KCal::Event::List eventList = d->mCalendar->rawEvents();
+ for(KCal::Event::List::iterator i = eventList.begin();
+ i != eventList.end();
+ ++i)
+ {
+ if ( (*i)->uid() == task->uid() )
+ {
+ if ((*i)->dtEnd().isNull()) (*i)->setDtEnd((KDateTime&) when);
+ };
+ }
}
bool KarmStorage::bookTime(const Task* task,
@@ -924,14 +946,6 @@
d->mCalendar->addEvent(e);
- // This saves the entire iCal file each time, which isn't efficient but
- // ensures no data loss. A faster implementation would be to append events
- // to a file, and then when KArm closes, append the data in this file to the
- // iCal file.
- //
- // Meanwhile, we simply use a timer to delay the full-saving until the GUI
- // has updated, for better user feedback. Feel free to get rid of this
- // if/when implementing the faster saving (DF).
task->taskView()->scheduleSave();
}
Created attachment 21608 [details]
next try
Created attachment 21624 [details]
set dtStart when the timer starts, dtEnd when the timer stops
Created attachment 21629 [details]
set dtStart when the timer starts, dtEnd not before timer stops
discovered hasEndDate(); this is much cleaner than provoking an invalid date.
SVN commit 712828 by tstaerk: Allow saving an ics file that has not yet an end-date. CCBUGS:84152 M +25 -11 karmstorage.cpp M +1 -1 karmstorage.h M +1 -2 mainwindow.cpp M +6 -3 taskview.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=712828 Created attachment 22298 [details]
seems to work now
SVN commit 744312 by tstaerk: Allow saving a task that is running (e.g. has no endtime). CCBUGS:84152 M +5 -4 karmstorage.cpp M +3 -1 mainwindow.cpp M +0 -1 taskview.cpp M +16 -7 timetrackerwidget.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=744312 The problem is that we can never find out if a task has been stopped or not with KDE 4, because of bug 159976 Created attachment 24534 [details]
works now
This works now, but, hey, we have already waited almost 4 years... and I want
to celebrate this bug's fourth birthday, come on, we can spend these few days
also.
SVN commit 801639 by tstaerk: Allow a task to be timed accross a time when ktimetracker is not running. BUGS:84152 M +21 -3 karmstorage.cpp M +10 -0 karmstorage.h M +15 -2 task.cpp M +9 -1 task.h M +19 -3 taskview.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=801639 |