[tasque] RTM Backend - fix completion of recurring tasks
- From: Antonius Riha <antoniusri src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tasque] RTM Backend - fix completion of recurring tasks
- Date: Sun, 9 Sep 2012 09:18:42 +0000 (UTC)
commit 0d2cd63b2feb0d6e219b1bf79132fe20244bac46
Author: Alex Hornung <ahornung gmail com>
Date: Mon Aug 15 21:14:52 2011 +0100
RTM Backend - fix completion of recurring tasks
* When a recurring task is completed, the taskseries is automatically
updated with another task, but without removing the initial one.
* Hence change the code to handle the Task element in the XML tree as
a collection and change other code appropriately.
* Now, when one completes a recurring task, the new task for the next
week(s) appears.
RtmNet/Task.cs | 2 +-
src/Backends/Rtm/RtmBackend.cs | 66 ++++++++++++++++++++++-----------------
src/Backends/Rtm/RtmTask.cs | 40 +++++++++++++-----------
3 files changed, 59 insertions(+), 49 deletions(-)
---
diff --git a/RtmNet/Task.cs b/RtmNet/Task.cs
index c027d94..f5a6205 100644
--- a/RtmNet/Task.cs
+++ b/RtmNet/Task.cs
@@ -89,7 +89,7 @@ namespace RtmNet
public string source;
[XmlElement("task", Form=XmlSchemaForm.Unqualified)]
- public Task Task;
+ public Task[] TaskCollection = new Task[0];
/// <remarks/>
[XmlElement("notes", Form=XmlSchemaForm.Unqualified)]
diff --git a/src/Backends/Rtm/RtmBackend.cs b/src/Backends/Rtm/RtmBackend.cs
index 12b4aed..8be781a 100644
--- a/src/Backends/Rtm/RtmBackend.cs
+++ b/src/Backends/Rtm/RtmBackend.cs
@@ -443,21 +443,26 @@ namespace Tasque.Backends.RtmBackend
{
TaskSeries ts = list.TaskSeriesCollection[0];
if(ts != null) {
- RtmTask rtmTask = new RtmTask(ts, this, list.ID);
- lock(taskLock)
+ RtmTask rtmTask = null;
+ foreach(Task task in ts.TaskCollection)
{
- Gtk.Application.Invoke ( delegate {
- if(taskIters.ContainsKey(rtmTask.ID)) {
- Gtk.TreeIter iter = taskIters[rtmTask.ID];
- taskStore.SetValue (iter, 0, rtmTask);
- } else {
- Gtk.TreeIter iter = taskStore.AppendNode();
- taskIters.Add(rtmTask.ID, iter);
- taskStore.SetValue (iter, 0, rtmTask);
- }
- });
+ rtmTask = new RtmTask(ts, task, this, list.ID);
+ lock(taskLock)
+ {
+ Gtk.Application.Invoke ( delegate {
+ if(taskIters.ContainsKey(rtmTask.ID)) {
+ Gtk.TreeIter iter = taskIters[rtmTask.ID];
+ taskStore.SetValue (iter, 0, rtmTask);
+ } else {
+ Gtk.TreeIter iter = taskStore.AppendNode();
+ taskIters.Add(rtmTask.ID, iter);
+ taskStore.SetValue (iter, 0, rtmTask);
+ }
+ });
+ }
}
- return rtmTask;
+ /* Always return the last task received */
+ return rtmTask;
}
return null;
}
@@ -626,23 +631,26 @@ namespace Tasque.Backends.RtmBackend
continue;
foreach(TaskSeries ts in tList.TaskSeriesCollection)
{
- RtmTask rtmTask = new RtmTask(ts, this, list.ID);
-
- lock(taskLock)
+ foreach(Task task in ts.TaskCollection)
{
- Gtk.TreeIter iter;
-
- Gtk.Application.Invoke ( delegate {
- Logger.Debug ("Refreshing task: " + rtmTask.Name);
- if(taskIters.ContainsKey(rtmTask.ID)) {
- iter = taskIters[rtmTask.ID];
- } else {
- iter = taskStore.AppendNode ();
- taskIters.Add(rtmTask.ID, iter);
- }
-
- taskStore.SetValue (iter, 0, rtmTask);
- });
+ RtmTask rtmTask = new RtmTask(ts, task, this, tList.ID);
+
+ lock(taskLock)
+ {
+ Gtk.TreeIter iter;
+
+ Gtk.Application.Invoke ( delegate {
+
+ if(taskIters.ContainsKey(rtmTask.ID)) {
+ iter = taskIters[rtmTask.ID];
+ } else {
+ iter = taskStore.AppendNode ();
+ taskIters.Add(rtmTask.ID, iter);
+ }
+
+ taskStore.SetValue (iter, 0, rtmTask);
+ });
+ }
}
}
}
diff --git a/src/Backends/Rtm/RtmTask.cs b/src/Backends/Rtm/RtmTask.cs
index ff7c3e6..d742660 100644
--- a/src/Backends/Rtm/RtmTask.cs
+++ b/src/Backends/Rtm/RtmTask.cs
@@ -13,8 +13,9 @@ namespace Tasque.Backends.RtmBackend
private TaskState state;
private RtmCategory category;
private List<INote> notes;
-
+
TaskSeries taskSeries;
+ Task task;
/// <summary>
/// Constructor that is created from an RTM Task Series
@@ -22,11 +23,12 @@ namespace Tasque.Backends.RtmBackend
/// <param name="taskSeries">
/// A <see cref="TaskSeries"/>
/// </param>
- public RtmTask(TaskSeries taskSeries, RtmBackend be, string listID)
+ public RtmTask(TaskSeries taskSeries, Task task, RtmBackend be, string listID)
{
this.taskSeries = taskSeries;
this.rtmBackend = be;
this.category = be.GetCategory(listID);
+ this.task = task;
if(CompletionDate == DateTime.MinValue )
state = TaskState.Active;
@@ -48,7 +50,7 @@ namespace Tasque.Backends.RtmBackend
/// </value>
public override string Id
{
- get { return taskSeries.Task.TaskID; }
+ get { return task.TaskID; }
}
/// <value>
@@ -70,9 +72,9 @@ namespace Tasque.Backends.RtmBackend
/// </value>
public override DateTime DueDate
{
- get { return taskSeries.Task.Due; }
+ get { return task.Due; }
set {
- taskSeries.Task.Due = value;
+ task.Due = value;
rtmBackend.UpdateTaskDueDate(this);
}
}
@@ -86,7 +88,7 @@ namespace Tasque.Backends.RtmBackend
get {
// Return the due date in UTC format
string format = "yyyy-MM-ddTHH:mm:ssZ";
- string dateString = taskSeries.Task.Due.ToUniversalTime ().ToString (format);
+ string dateString = task.Due.ToUniversalTime ().ToString (format);
return dateString;
}
}
@@ -97,9 +99,9 @@ namespace Tasque.Backends.RtmBackend
/// </value>
public override DateTime CompletionDate
{
- get { return taskSeries.Task.Completed; }
+ get { return task.Completed; }
set {
- taskSeries.Task.Completed = value;
+ task.Completed = value;
rtmBackend.UpdateTaskCompleteDate(this);
}
}
@@ -118,7 +120,7 @@ namespace Tasque.Backends.RtmBackend
public override TaskPriority Priority
{
get {
- switch (taskSeries.Task.Priority) {
+ switch (task.Priority) {
default:
case "N":
return TaskPriority.None;
@@ -134,16 +136,16 @@ namespace Tasque.Backends.RtmBackend
switch (value) {
default:
case TaskPriority.None:
- taskSeries.Task.Priority = "N";
+ task.Priority = "N";
break;
case TaskPriority.High:
- taskSeries.Task.Priority = "1";
+ task.Priority = "1";
break;
case TaskPriority.Medium:
- taskSeries.Task.Priority = "2";
+ task.Priority = "2";
break;
case TaskPriority.Low:
- taskSeries.Task.Priority = "3";
+ task.Priority = "3";
break;
}
rtmBackend.UpdateTaskPriority(this);
@@ -152,7 +154,7 @@ namespace Tasque.Backends.RtmBackend
public string PriorityString
{
- get { return taskSeries.Task.Priority; }
+ get { return task.Priority; }
}
@@ -220,7 +222,7 @@ namespace Tasque.Backends.RtmBackend
public string TaskTaskID
{
- get { return taskSeries.Task.TaskID; }
+ get { return task.TaskID; }
}
public string ListID
@@ -237,7 +239,7 @@ namespace Tasque.Backends.RtmBackend
{
Logger.Debug("Activating Task: " + Name);
state = TaskState.Active;
- taskSeries.Task.Completed = DateTime.MinValue;
+ task.Completed = DateTime.MinValue;
rtmBackend.UpdateTaskActive(this);
}
@@ -248,7 +250,7 @@ namespace Tasque.Backends.RtmBackend
{
Logger.Debug("Inactivating Task: " + Name);
state = TaskState.Inactive;
- taskSeries.Task.Completed = DateTime.Now;
+ task.Completed = DateTime.Now;
rtmBackend.UpdateTaskInactive(this);
}
@@ -259,8 +261,8 @@ namespace Tasque.Backends.RtmBackend
{
Logger.Debug("Completing Task: " + Name);
state = TaskState.Completed;
- if(taskSeries.Task.Completed == DateTime.MinValue)
- taskSeries.Task.Completed = DateTime.Now;
+ if(task.Completed == DateTime.MinValue)
+ task.Completed = DateTime.Now;
rtmBackend.UpdateTaskCompleted(this);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]