Bug 227746 - Can't delete task when "Track Active Applications" is checked
Summary: Can't delete task when "Track Active Applications" is checked
Status: RESOLVED FIXED
Alias: None
Product: ktimetracker
Classification: Applications
Component: general (show other bugs)
Version: 4.4.x
Platform: Debian testing Unspecified
: NOR normal
Target Milestone: ---
Assignee: Thorsten Staerk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-19 23:01 UTC by Eckhart Wörner
Modified: 2010-02-24 14:52 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch for debian 4.3.4-1 (1.80 KB, patch)
2010-02-22 23:45 UTC, Stefano
Details
Patch for ktimetrackerutility.cpp (debian 4.3.4-1) (562 bytes, patch)
2010-02-24 14:52 UTC, Stefano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eckhart Wörner 2010-02-19 23:01:19 UTC
Version:            (using KDE 4.4.0)
Installed from:    Debian testing/unstable Packages

This bug has been copied over from
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=569706 and has been verified
to still exist in KDE SC 4.4.0

Hello,

when the "Track Active Applications" option is checked in the clock menu
it is not possible to delete any active task because a task for the
"Deleting Task" window is created and selected; so, when deleting, I can
only delete that given task and not what I want to delete.

Here are the steps to reproduce the bug:

1. Open Kontact

2. Go to Time Tracker

3. Menu File -> New (Ctrl+N)

4. Menu Task -> New Task (Ctrl+T)

5. create the task, name it e.g. "test task" or whatever

6. Menu Clock -> Track Active Applications

7. select the previously created "test task"

8. Menu Task -> Delete (Del)

now you won't be able to delete the task.

The solution is to uncheck the "Track Active Applications", then delete
the task and recheck the "Track Active Applications". Indeed, it would be
useful if this behavior were not present.

I am using ktimetracker inside kontact.

Thanks.
Comment 1 Thorsten Staerk 2010-02-21 16:21:08 UTC
Thanks for this great bug report!
Comment 2 Thorsten Staerk 2010-02-21 16:35:51 UTC
Here is my patch, can you please test it? It is filed against trunk:

Index: /root/svn/kdepim/ktimetracker/taskview.cpp
===================================================================
--- /root/svn/kdepim/ktimetracker/taskview.cpp	(revision 1086027)
+++ /root/svn/kdepim/ktimetracker/taskview.cpp	(working copy)
@@ -1005,40 +1005,30 @@
 
 
 void TaskView::deleteTask( Task* task )
+/* Attention when popping up a window asking for confirmation.
+If you have "Track active applications" on, this window will create a new task and
+make this task running and selected. */
 {
     kDebug(5970) << "Entering function";
     if (task == 0) task = currentItem();
     if (currentItem() == 0)
     {
         KMessageBox::information(0,i18n("No task selected."));
-        return;
     }
-
-    int response = KMessageBox::Continue;
-    if (KTimeTrackerSettings::promptDelete())
+    else
     {
-        response = KMessageBox::warningContinueCancel( 0,
-            i18n( "Are you sure you want to delete the selected"
-            " task(s) and their entire history?\n"
-            "NOTE: all subtasks and their history will also "
-            "be deleted."),
-            i18n( "Deleting Task(s)"), KStandardGuiItem::del());
-    }
-
-    if (response == KMessageBox::Continue)
-    {
-        int i=0;
-        QList<int> delendum;
-        while ( itemAt(i) )
+        int response = KMessageBox::Continue;
+        if (KTimeTrackerSettings::promptDelete())
         {
-            if ( itemAt( i )->isSelected())
-                delendum << i;
-            i++;
+            response = KMessageBox::warningContinueCancel( 0,
+                i18n( "Are you sure you want to delete the selected"
+                " task(s) and their entire history?\n"
+                "NOTE: all subtasks and their history will also "
+                "be deleted."),
+                i18n( "Deleting Task(s)"), KStandardGuiItem::del());
         }
-        for (int n=delendum.size()-1; n>=0; --n)
-            deleteTaskBatch(itemAt(delendum[n]));
+        if (response == KMessageBox::Continue) deleteTaskBatch(task);
     }
-    //d->mStorage->buildTaskView(this);
 }
 
 void TaskView::markTaskAsComplete()
Comment 3 Thorsten Staerk 2010-02-21 17:04:04 UTC
SVN commit 1093863 by tstaerk:

First find out what task to delete, then pop up windows asking the user.
Reason is: When a window pops up and ktimetracker has "Track active
applications" enabled, this window will create a new task, start it and
select it. So we need the right order: First remember what task is
selected - then pop up window asking for confirmation.

At the same time, I removed the code to create several tasks at once as
I can no longer select several task in ktimetracker's QTreeWidget. The
code is a lot clearer so.

BUGS:227746


 M  +13 -23    taskview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1093863
Comment 4 Thorsten Staerk 2010-02-21 17:44:47 UTC
SVN commit 1093870 by tstaerk:

Backporting 1093863

First find out what task to delete, then pop up windows asking the user.
Reason is: When a window pops up and ktimetracker has "Track active
applications" enabled, this window will create a new task, start it and
select it. So we need the right order: First remember what task is
selected - then pop up window asking for confirmation.

At the same time, I removed the code to create several tasks at once as
I can no longer select several task in ktimetracker's QTreeWidget. The
code is a lot clearer so.

CCBUGS:227746



 M  +13 -23    taskview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1093870
Comment 5 Stefano 2010-02-22 23:45:29 UTC
Created attachment 41020 [details]
Patch for debian 4.3.4-1

Hi,

unfortunately, I wasn't able to apply the patch against the debian source 
(4:4.3.4-1). However, I tried to patch the file by hand (see attached file) and 
I successfully compiled it but it didn't solve the problem.

I am not sure whether I may have done something wrong during the patching 
process or the patch is not effective against the bug.

Thanks.
Comment 6 Thorsten Staerk 2010-02-23 02:45:06 UTC
(In reply to comment #5)

Stefano, I have not read your patch line-by-line but I trust it is a trivial change to my patch which would be the way to go. What happens if you apply the patch? No change at all? Then I guess you have not make install'ed. You need to make install because ktimetracker uses a kpart which is a .desktop file and a .so file. Does it work then?
Comment 7 Stefano 2010-02-23 19:33:45 UTC
(In reply to comment #6)

Hello,

here is what I did to recompile ktimetracker (after having applied the patch):

1. $ cd /usr/src/kdepim-4.3.4/
2. $ mkdir build && cd build && cmake ../
3. make ktimetracker

The new executable is /usr/src/kdepim-4.3.4/build/ktimetracker/ktimetracker

I did not install it to avoid possible conflicts with the original debian ktimetracker package, so I ran the executable directly from its path. This is maybe why I did not notice any change in ktimetracker's behavior.

Now I installed ktimetracker ($ cd /usr/src/kdepim-4.3.4/build/ktimetracker/ && sudo checkinstall make install)

ktimetracker does not appear in kontact anymore, but I can launch it from /usr/bin.

The task is now successfully deleted, but the empty task that is created when the confirmation window pops up is still present. It would be great if we could get rid of that empty task too.

Can we ignore tasks - or applications, since we use the "Track Active Applications" option - with empty strings in their name?

I also noticed other "odd" behaviors: the empty task is somehow considered when a new application is launched (so that the time spent is calculated in the empty task); kate and kwrite are not tracked; when I switch tabs in iceweasel/firefox (version 3.5.6) a new Task is created with the tab title as name. Tell me if you need more information about that and whether I have to file another bug or not.

Thank you.
Comment 8 Thorsten Staerk 2010-02-24 07:20:50 UTC
Glad that it works after make install, so I can see it as "fixed for Debian". ktimetracker disappeared from kontact? There should be a possibility in kontact to add kparts, is ktimetracker there?

Here is the patch to track kate and kwrite and to make empty tasks disappear: http://websvn.kde.org/trunk/KDE/kdepim/ktimetracker/ktimetrackerutility.cpp?r1=1075317&r2=1075316&pathrev=1075317
Comment 9 Stefano 2010-02-24 14:52:39 UTC
Created attachment 41060 [details]
Patch for ktimetrackerutility.cpp (debian 4.3.4-1)

Hi,

as before, I had to slightly modify the patch to adapt it to the Debian source (kdepim-4.3.4). However, the compilation stopped with the following error:

/usr/src/kdepim-4.3.4/ktimetracker/ktimetrackerutility.cpp: In function ‘QString getFocusWindow()’:
/usr/src/kdepim-4.3.4/ktimetracker/ktimetrackerutility.cpp:34: error: ‘KWindowSystem’ has not been declared
/usr/src/kdepim-4.3.4/ktimetracker/ktimetrackerutility.cpp:34: error: ‘KWindowSystem’ has not been declared
/usr/src/kdepim-4.3.4/ktimetracker/ktimetrackerutility.cpp:34: error: ‘NET’ has not been declared
make[3]: *** [ktimetracker/CMakeFiles/ktimetracker.dir/ktimetrackerutility.o] Error 1
make[2]: *** [ktimetracker/CMakeFiles/ktimetracker.dir/all] Error 2
make[1]: *** [ktimetracker/CMakeFiles/ktimetracker.dir/rule] Error 2
make: *** [ktimetracker] Error 2

Does it depend on the fact that my sources are "too old"? Any suggestion?

As for the fact that ktimetracker is not present in kontact anymore, would it be possible that it is because I recompiled only ktimetracker and not the whole kdepim suite?

Thank you.