tasque r198 - in branches/new_cache: . src
- From: bgmerrell svn gnome org
- To: svn-commits-list gnome org
- Subject: tasque r198 - in branches/new_cache: . src
- Date: Mon, 29 Dec 2008 22:14:24 +0000 (UTC)
Author: bgmerrell
Date: Mon Dec 29 22:14:24 2008
New Revision: 198
URL: http://svn.gnome.org/viewvc/tasque?rev=198&view=rev
Log:
* src/TaskWindow.cs: manually merge more methods from the old caching branch
* src/RemoteControl.cs: Cast ITask to Task in the TaskWindow.SelectAndEdit call
* src/TaskTreeView.cs,
* src/NoteDialog.cs,
* src/TaskCalendar.cs,
* src/AllCategory.cs,
* src/CompletedTaskGroup.cs,
* src/TaskGroup.cs: Change references from ICategory to Category and ITask to Task
* src/SyncManager.cs: svn add
Added:
branches/new_cache/src/SyncManager.cs
Modified:
branches/new_cache/ChangeLog
branches/new_cache/src/AllCategory.cs
branches/new_cache/src/CompletedTaskGroup.cs
branches/new_cache/src/NoteDialog.cs
branches/new_cache/src/RemoteControl.cs
branches/new_cache/src/TaskCalendar.cs
branches/new_cache/src/TaskGroup.cs
branches/new_cache/src/TaskTreeView.cs
branches/new_cache/src/TaskWindow.cs
Modified: branches/new_cache/src/AllCategory.cs
==============================================================================
--- branches/new_cache/src/AllCategory.cs (original)
+++ branches/new_cache/src/AllCategory.cs Mon Dec 29 22:14:24 2008
@@ -7,7 +7,7 @@
namespace Tasque
{
- public class AllCategory : ICategory
+ public class AllCategory : Category
{
// A "set" of categories specified by the user to show when the "All"
// category is selected in the TaskWindow. If the list is empty, tasks
@@ -28,11 +28,11 @@
get { return Catalog.GetString ("All"); }
}
- public bool ContainsTask(ITask task)
+ public bool ContainsTask(Task task)
{
// Filter out tasks based on the user's preferences of which
// categories should be displayed in the AllCategory.
- ICategory category = task.Category;
+ Category category = task.Category;
if (category == null)
return true;
Modified: branches/new_cache/src/CompletedTaskGroup.cs
==============================================================================
--- branches/new_cache/src/CompletedTaskGroup.cs (original)
+++ branches/new_cache/src/CompletedTaskGroup.cs Mon Dec 29 22:14:24 2008
@@ -21,7 +21,7 @@
public class CompletedTaskGroup : TaskGroup
{
- ICategory selectedCategory;
+ Category selectedCategory;
HScale rangeSlider;
ShowCompletedRange currentRange;
@@ -94,7 +94,7 @@
if (!showCompletedTasks)
return false;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null || task.State != TaskState.Completed)
return false;
@@ -133,9 +133,9 @@
Refilter (selectedCategory);
}
- protected ICategory GetSelectedCategory ()
+ protected Category GetSelectedCategory ()
{
- ICategory foundCategory = null;
+ Category foundCategory = null;
string cat = Application.Preferences.Get (
Preferences.SelectedCategoryKey);
@@ -145,7 +145,7 @@
if (model.GetIterFirst (out iter)) {
do {
- ICategory category = model.GetValue (iter, 0) as ICategory;
+ Category category = model.GetValue (iter, 0) as Category;
if (category.Name.CompareTo (cat) == 0) {
foundCategory = category;
break;
@@ -265,8 +265,8 @@
Gtk.TreeIter a,
Gtk.TreeIter b)
{
- ITask taskA = model.GetValue (a, 0) as ITask;
- ITask taskB = model.GetValue (b, 0) as ITask;
+ Task taskA = model.GetValue (a, 0) as Task;
+ Task taskB = model.GetValue (b, 0) as Task;
if (taskA == null || taskB == null)
return 0;
Modified: branches/new_cache/src/NoteDialog.cs
==============================================================================
--- branches/new_cache/src/NoteDialog.cs (original)
+++ branches/new_cache/src/NoteDialog.cs Mon Dec 29 22:14:24 2008
@@ -9,14 +9,14 @@
{
public class NoteDialog : Gtk.Dialog
{
- private ITask task;
+ private Task task;
Gtk.VBox targetVBox;
Gtk.Button addButton = new Gtk.Button(Gtk.Stock.Add);
Gtk.ScrolledWindow sw = new Gtk.ScrolledWindow ();
#region Constructors
- public NoteDialog (Gtk.Window parentWindow, ITask task)
+ public NoteDialog (Gtk.Window parentWindow, Task task)
: base ()
{
this.ParentWindow = parentWindow.GdkWindow;
@@ -79,7 +79,7 @@
#endregion // Constructors
#region Properties
- public ITask Task
+ public Task Task
{
get { return task; }
}
Modified: branches/new_cache/src/RemoteControl.cs
==============================================================================
--- branches/new_cache/src/RemoteControl.cs (original)
+++ branches/new_cache/src/RemoteControl.cs Mon Dec 29 22:14:24 2008
@@ -139,7 +139,7 @@
}
if (enterEditMode) {
- TaskWindow.SelectAndEdit (task);
+ TaskWindow.SelectAndEdit (task as Task);
}
#if ENABLE_NOTIFY_SHARP
Added: branches/new_cache/src/SyncManager.cs
==============================================================================
--- (empty file)
+++ branches/new_cache/src/SyncManager.cs Mon Dec 29 22:14:24 2008
@@ -0,0 +1,93 @@
+// SyncManager.cs created with MonoDevelop
+// User: calvin at 12:23 PMÂ3/18/2008
+//
+// To change standard headers go to Edit->Preferences->Coding->Standard Headers
+//
+
+using System;
+using System.Threading;
+using System.Collections.Generic;
+
+namespace Tasque
+{
+ public class SyncManager
+ {
+
+ private Thread syncThread;
+ private bool runningSyncThread;
+ private AutoResetEvent runSyncEvent;
+
+
+ public SyncManager()
+ {
+ runSyncEvent = new AutoResetEvent(false);
+
+ runningSyncThread = false;
+ syncThread = new Thread(SyncThreadLoop);
+
+ }
+
+ public void Sync()
+ {
+ runSyncEvent.Set();
+ }
+
+ public void Start()
+ {
+ runningSyncThread = true;
+ syncThread.Start();
+ }
+
+ public void Stop()
+ {
+ runningSyncThread = false;
+ runSyncEvent.Set();
+ syncThread.Abort();
+ }
+
+
+ private void SyncThreadLoop()
+ {
+ while(runningSyncThread) {
+ runSyncEvent.WaitOne();
+
+ if(!runningSyncThread)
+ return;
+
+ runSyncEvent.Reset();
+
+ Logger.Debug("SyncThreadLoop running...");
+
+ if( (Application.Backend != null) &&
+ (Application.Backend.Configured) &&
+ (Application.Backend.Initialized) )
+ {
+ Dictionary<string, ITask> tasks;
+ Dictionary<string, ICategory> categories;
+
+ // Refresh the tasks
+ Application.Backend.Refresh();
+
+ // Read Categories and populate them in the localCache
+ categories = Application.Backend.Categories;
+ Logger.Debug("Populating local cache with categories.");
+ foreach(ICategory cat in categories.Values)
+ {
+ Logger.Debug("Category: {0}", cat.Name);
+ }
+
+ // Read Tasks and populate them into the localCache
+ tasks = Application.Backend.Tasks;
+ Logger.Debug("Populating local cache with tasks.");
+ foreach(ITask task in tasks.Values)
+ {
+ Logger.Debug("Task: {0}", task.Name);
+ }
+ }
+
+ Logger.Debug("SyncThreadLoop done!");
+ }
+ }
+
+ }
+}
Modified: branches/new_cache/src/TaskCalendar.cs
==============================================================================
--- branches/new_cache/src/TaskCalendar.cs (original)
+++ branches/new_cache/src/TaskCalendar.cs Mon Dec 29 22:14:24 2008
@@ -22,11 +22,11 @@
Gtk.Widget parent;
int eventCount;
- private ITask task;
+ private Task task;
private const uint CURRENT_TIME = 0;
- public TaskCalendar(ITask task, Gtk.Widget parent)
+ public TaskCalendar(Task task, Gtk.Widget parent)
{
this.task = task;
@@ -203,4 +203,4 @@
}
}
}
-}
\ No newline at end of file
+}
Modified: branches/new_cache/src/TaskGroup.cs
==============================================================================
--- branches/new_cache/src/TaskGroup.cs (original)
+++ branches/new_cache/src/TaskGroup.cs Mon Dec 29 22:14:24 2008
@@ -199,7 +199,7 @@
#endregion // Public Properties
#region Public Methods
- public void Refilter (ICategory selectedCategory)
+ public void Refilter (Category selectedCategory)
{
filteredTasks.Refilter ();
treeView.Refilter (selectedCategory);
@@ -210,18 +210,18 @@
/// currently shown in this TaskGroup.
/// </summary>
/// <param name="task">
- /// A <see cref="ITask"/>
+ /// A <see cref="Task"/>
/// </param>
/// <param name="iter">
/// A <see cref="Gtk.TreeIter"/>
/// </param>
/// <returns>
/// A <see cref="System.Boolean"/> True if the specified <see
- /// cref="ITask">task</see> is currently shown inside this TaskGroup.
+ /// cref="Task">task</see> is currently shown inside this TaskGroup.
/// Additionally, if true, the <see cref="Gtk.TreeIter">iter</see> will
- /// point to the specified <see cref="ITask">task</see>.
+ /// point to the specified <see cref="Task">task</see>.
/// </returns>
- public bool ContainsTask (ITask task, out Gtk.TreeIter iter)
+ public bool ContainsTask (Task task, out Gtk.TreeIter iter)
{
Gtk.TreeIter tempIter;
Gtk.TreeModel model = treeView.Model;
@@ -233,7 +233,7 @@
// Loop through the model looking for a matching task
do {
- ITask tempTask = model.GetValue (tempIter, 0) as ITask;
+ Task tempTask = model.GetValue (tempIter, 0) as Task;
if (tempTask == task) {
iter = tempIter;
return true;
@@ -258,7 +258,7 @@
int pos = 0;
Gtk.TreeIter tempIter;
Gtk.TreeModel model = treeView.Model;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (!model.GetIterFirst (out tempIter))
return 0;
@@ -266,7 +266,7 @@
// This is ugly, but figure out what position the specified iter is
// at so we can return a value accordingly.
do {
- ITask tempTask = model.GetValue (tempIter, 0) as ITask;
+ Task tempTask = model.GetValue (tempIter, 0) as Task;
if (tempTask == task)
break;
@@ -287,7 +287,7 @@
int pos = 0;
Gtk.TreeIter tempIter;
Gtk.TreeModel model = treeView.Model;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (!model.GetIterFirst (out tempIter))
return 0;
@@ -295,7 +295,7 @@
// This is ugly, but figure out what position the specified iter is
// at so we can return a value accordingly.
do {
- ITask tempTask = model.GetValue (tempIter, 0) as ITask;
+ Task tempTask = model.GetValue (tempIter, 0) as Task;
if (tempTask == task)
break;
@@ -309,7 +309,7 @@
return pos * height + header.Requisition.Height;
}
- public void EnterEditMode (ITask task, Gtk.TreeIter iter)
+ public void EnterEditMode (Task task, Gtk.TreeIter iter)
{
Gtk.TreePath path;
@@ -351,7 +351,7 @@
/// </summary>
protected virtual bool FilterTasks (Gtk.TreeModel model, Gtk.TreeIter iter)
{
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null)
return false;
@@ -377,7 +377,7 @@
return true;
}
- private bool ShowCompletedTask (ITask task)
+ private bool ShowCompletedTask (Task task)
{
if (task.State == TaskState.Completed) {
if (!showCompletedTasks)
@@ -411,7 +411,7 @@
/// </summary>
private void Refilter ()
{
- ICategory cat = GetSelectedCategory ();
+ Category cat = GetSelectedCategory ();
if (cat != null)
Refilter (cat);
}
@@ -422,12 +422,12 @@
/// or something.
/// </summary>
/// <returns>
- /// A <see cref="ICategory"/>
+ /// A <see cref="Category"/>
/// </returns>
- private ICategory GetSelectedCategory ()
+ private Category GetSelectedCategory ()
{
// TODO: Move this code into some function in the backend/somewhere
- // with the signature of GetCategoryForName (string catName):ICategory
+ // with the signature of GetCategoryForName (string catName):Category
string selectedCategoryName =
Application.Preferences.Get (Preferences.SelectedCategoryKey);
@@ -439,7 +439,7 @@
// matching category
if (model.GetIterFirst (out iter)) {
do {
- ICategory cat = model.GetValue (iter, 0) as ICategory;
+ Category cat = model.GetValue (iter, 0) as Category;
if (cat == null)
continue; // Needed for some reason to prevent crashes from some backends
if (cat.Name.CompareTo (selectedCategoryName) == 0) {
@@ -517,7 +517,7 @@
showCompletedTasks = newValue;
- ICategory cat = GetSelectedCategory ();
+ Category cat = GetSelectedCategory ();
if (cat != null)
Refilter (cat);
}
Modified: branches/new_cache/src/TaskTreeView.cs
==============================================================================
--- branches/new_cache/src/TaskTreeView.cs (original)
+++ branches/new_cache/src/TaskTreeView.cs Mon Dec 29 22:14:24 2008
@@ -19,7 +19,7 @@
private static Gdk.Pixbuf[] inactiveAnimPixbufs;
private Gtk.TreeModelFilter modelFilter;
- private ICategory filterCategory;
+ private Category filterCategory;
private static string status;
@@ -253,7 +253,7 @@
Refilter (filterCategory);
}
- public void Refilter (ICategory selectedCategory)
+ public void Refilter (Category selectedCategory)
{
this.filterCategory = selectedCategory;
Model = modelFilter;
@@ -288,7 +288,7 @@
Gtk.TreeIter iter)
{
Gtk.CellRendererToggle crt = cell as Gtk.CellRendererToggle;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null)
crt.Active = false;
else {
@@ -312,7 +312,7 @@
List<String> list = new List<String>();
if(Selection.GetSelected(out m, out iter)) {
- ITask task = Model.GetValue (iter, 0) as ITask;
+ Task task = Model.GetValue (iter, 0) as Task;
if (task != null && task.HasNotes && task.Notes != null) {
foreach (INote note in task.Notes) {
// for the tooltip, truncate any notes longer than 250 characters.
@@ -354,7 +354,7 @@
{
// TODO: Add bold (for high), light (for None), and also colors to priority?
Gtk.CellRendererCombo crc = cell as Gtk.CellRendererCombo;
- ITask task = Model.GetValue (iter, 0) as ITask;
+ Task task = Model.GetValue (iter, 0) as Task;
switch (task.Priority) {
case TaskPriority.Low:
crc.Text = Catalog.GetString ("3");
@@ -377,7 +377,7 @@
{
Gtk.CellRendererText crt = renderer as Gtk.CellRendererText;
crt.Ellipsize = Pango.EllipsizeMode.End;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null) {
crt.Text = string.Empty;
return;
@@ -407,7 +407,7 @@
Gtk.TreeIter iter)
{
Gtk.CellRendererCombo crc = renderer as Gtk.CellRendererCombo;
- ITask task = Model.GetValue (iter, 0) as ITask;
+ Task task = Model.GetValue (iter, 0) as Task;
DateTime date = task.State == TaskState.Completed ?
task.CompletionDate :
task.DueDate;
@@ -428,7 +428,7 @@
Gtk.TreeIter iter)
{
Gtk.CellRendererPixbuf crp = renderer as Gtk.CellRendererPixbuf;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null) {
crp.Pixbuf = null;
return;
@@ -442,7 +442,7 @@
Gtk.TreeIter iter)
{
Gtk.CellRendererPixbuf crp = renderer as Gtk.CellRendererPixbuf;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null)
return;
@@ -519,7 +519,7 @@
Gtk.TreeIter iter)
{
// Filter out deleted tasks
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null) {
Logger.Error ("FilterFunc: task at iter was null");
@@ -547,7 +547,7 @@
if (!Model.GetIter (out iter, path))
return; // Do nothing
- ITask task = Model.GetValue (iter, 0) as ITask;
+ Task task = Model.GetValue (iter, 0) as Task;
if (task == null)
return;
@@ -601,7 +601,7 @@
newPriority = TaskPriority.None;
// Update the priority if it's different
- ITask task = Model.GetValue (iter, 0) as ITask;
+ Task task = Model.GetValue (iter, 0) as Task;
if (task.Priority != newPriority)
task.Priority = newPriority;
}
@@ -613,7 +613,7 @@
if (!Model.GetIter (out iter, path))
return;
- ITask task = Model.GetValue (iter, 0) as ITask;
+ Task task = Model.GetValue (iter, 0) as Task;
if (task == null)
return;
@@ -674,7 +674,7 @@
DateTime newDate = DateTime.MinValue;
DateTime today = DateTime.Now;
- ITask task = Model.GetValue (iter, 0) as ITask;
+ Task task = Model.GetValue (iter, 0) as Task;
if (args.NewText.CompareTo (
today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today") ) == 0)
@@ -747,7 +747,7 @@
}
private TaskTreeView tree;
- private ITask task;
+ private Task task;
private uint delay;
private uint secondsLeft;
protected uint pulseTimeoutId;
@@ -757,7 +757,7 @@
public InactivateTimer (TaskTreeView treeView,
Gtk.TreeIter taskIter,
- ITask taskToComplete,
+ Task taskToComplete,
uint delayInSeconds)
{
tree = treeView;
@@ -777,7 +777,7 @@
timers [task.TimerID] = this;
}
- public static void CancelTimer(ITask task)
+ public static void CancelTimer(Task task)
{
Logger.Debug ("Timeout Canceled for task: " + task.Name);
InactivateTimer timer = null;
Modified: branches/new_cache/src/TaskWindow.cs
==============================================================================
--- branches/new_cache/src/TaskWindow.cs (original)
+++ branches/new_cache/src/TaskWindow.cs Mon Dec 29 22:14:24 2008
@@ -45,7 +45,7 @@
private static int lastYPos;
private static Gdk.Pixbuf noteIcon;
- private IBackend backend;
+ //private IBackend backend;
private ScrolledWindow scrolledWindow;
private Entry addTaskEntry;
@@ -53,17 +53,17 @@
private Gtk.ComboBox categoryComboBox;
private Gtk.VBox targetVBox;
- private TaskGroup overdueGroup;
- private TaskGroup todayGroup;
- private TaskGroup tomorrowGroup;
- private TaskGroup nextSevenDaysGroup;
- private TaskGroup futureGroup;
- private CompletedTaskGroup completedTaskGroup;
+ //private TaskGroup overdueGroup;
+ //private TaskGroup todayGroup;
+ //private TaskGroup tomorrowGroup;
+ //private TaskGroup nextSevenDaysGroup;
+ //private TaskGroup futureGroup;
+ //private CompletedTaskGroup completedTaskGroup;
private EventBox innerEb;
- private List<TaskGroup> taskGroups;
+ //private List<TaskGroup> taskGroups;
- private Dictionary<ITask, NoteDialog> noteDialogs;
+ private Dictionary<Task, NoteDialog> noteDialogs;
private Gtk.Statusbar statusbar;
private uint statusContext;
@@ -73,24 +73,23 @@
private static string lastLoadedTime;
private const uint DWELL_TIME_MS = 8000;
- private ITask clickedTask;
+ private Task clickedTask;
private Gtk.AccelGroup accelGroup;
private GlobalKeybinder globalKeys;
+
+ private TaskTreeView taskTreeView;
static TaskWindow ()
{
noteIcon = Utilities.GetIcon ("note", 16);
}
- public TaskWindow (IBackend aBackend) : base (Gtk.WindowType.Toplevel)
+ public TaskWindow () : base (Gtk.WindowType.Toplevel)
{
- this.backend = aBackend;
- taskGroups = new List<TaskGroup> ();
- noteDialogs = new Dictionary<ITask, NoteDialog> ();
+ noteDialogs = new Dictionary<Task, NoteDialog> ();
InitWindow();
-
- Realized += OnRealized;
+ //Realized += OnRealized;
}
void InitWindow()
@@ -147,7 +146,8 @@
// The new task entry widget
addTaskEntry = new Entry (Catalog.GetString ("New task..."));
- addTaskEntry.Sensitive = false;
+ // TODO: Add some logic to this
+ addTaskEntry.Sensitive = true;
addTaskEntry.Focused += OnAddTaskEntryFocused;
addTaskEntry.Changed += OnAddTaskEntryChanged;
addTaskEntry.Activated += OnAddTaskEntryActivated;
@@ -168,7 +168,7 @@
addTaskButton =
new MenuToolButton (buttonHBox, Catalog.GetString ("_Add Task"));
addTaskButton.UseUnderline = true;
- // Disactivate the button until the backend is initialized
+ // Disactivate the button until some text is put in the entry
addTaskButton.Sensitive = false;
Gtk.Menu addTaskMenu = new Gtk.Menu ();
addTaskButton.Menu = addTaskMenu;
@@ -220,6 +220,9 @@
Shown += OnWindowShown;
DeleteEvent += WindowDeleted;
+
+ // XXX: test
+ Realized += OnRealized;
Application.Preferences.SettingChanged += OnSettingChanged;
}
@@ -239,6 +242,13 @@
rangeEnd = DateTime.Now.AddDays (-1);
rangeEnd = new DateTime (rangeEnd.Year, rangeEnd.Month, rangeEnd.Day,
23, 59, 59);
+
+ //
+ // Group TreeView
+ //
+ taskTreeView = new TaskTreeView (Application.LocalCache.Tasks);
+ taskTreeView.Show ();
+ targetVBox.PackStart (taskTreeView, true, true, 0);
/*
overdueGroup = new TaskGroup (Catalog.GetString ("Overdue"),
@@ -423,8 +433,8 @@
}
taskWindow.Present();
}
- } else if (Application.Backend != null) {
- TaskWindow.taskWindow = new TaskWindow(Application.Backend);
+ } else if (Application.LocalCache != null) {
+ TaskWindow.taskWindow = new TaskWindow ();
if(lastXPos == 0 || lastYPos == 0)
{
lastXPos = Application.Preferences.GetInt("MainWindowLastXPos");
@@ -449,7 +459,7 @@
taskWindow.addTaskEntry.GrabFocus ();
}
- public static void SelectAndEdit (ITask task)
+ public static void SelectAndEdit (Task task)
{
ShowWindow ();
taskWindow.EnterEditMode (task, true);
@@ -517,6 +527,7 @@
TaskWindow.ShowWindow ();
}
+ /*
public void HighlightTask (ITask task)
{
Gtk.TreeIter iter;
@@ -536,7 +547,9 @@
}
}
}
+ */
+ /*
/// <summary>
/// Search through the TaskGroups looking for the specified task and
/// adjust the window so the new task is showing.
@@ -614,6 +627,7 @@
}
}
}
+ */
#endregion // Public Methods
#region Private Methods
@@ -623,7 +637,7 @@
Gtk.TreeIter iter)
{
Gtk.CellRendererText crt = renderer as Gtk.CellRendererText;
- ICategory category = model.GetValue (iter, 0) as ICategory;
+ Category category = model.GetValue (iter, 0) as Category;
// CRG: What? I added this check for null and we don't crash
// but I never see anything called unknown
@@ -636,8 +650,8 @@
crt.Text = "unknown";
}
- // TODO: Move this method into a property of ICategory.TaskCount
- private int GetTaskCountInCategory (ICategory category)
+ // TODO: Move this method into a property of Category.TaskCount
+ private int GetTaskCountInCategory (Category category)
{
// This is disgustingly inefficient, but, oh well
int count = 0;
@@ -649,7 +663,7 @@
return 0;
do {
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null)
continue;
if (task.State != TaskState.Active
@@ -670,13 +684,13 @@
/// created.
/// </summary>
/// <param name="task">
- /// A <see cref="ITask"/>
+ /// A <see cref="Task"/>
/// </param>
/// <param name="adjustScrolledWindow">
/// A <see cref="bool"/> which indicates whether the task should be
/// scrolled to.
/// </param>
- private void EnterEditMode (ITask task, bool adjustScrolledWindow)
+ private void EnterEditMode (Task task, bool adjustScrolledWindow)
{
// Make sure we've waited around for the new task to fully
// be added to the TreeModel before continuing. Some
@@ -686,21 +700,77 @@
while (Gtk.Application.EventsPending ())
Gtk.Application.RunIteration ();
- if (adjustScrolledWindow)
- ScrollToTask (task);
+ //if (adjustScrolledWindow)
+ // ScrollToTask (task);
Gtk.TreeIter iter;
- foreach (TaskGroup taskGroup in taskGroups) {
- if (taskGroup.ContainsTask (task, out iter)) {
- Logger.Debug ("Found new task group: {0}", taskGroup.DisplayName);
-
- // Get the header height
- taskGroup.EnterEditMode (task, iter);
- return;
- }
- }
+ if (GetTaskIter(task, out iter) == false)
+ return;
+
+ Gtk.TreePath path = taskTreeView.Model.GetPath(iter);
+ // TODO: Figure out a way to NOT hard-code the column number
+ Gtk.TreeViewColumn nameColumn = taskTreeView.Columns [0];
+ if (adjustScrolledWindow == true) {
+ taskTreeView.ScrollToCell(path,
+ nameColumn,
+ true,
+ 0.0f,
+ 0.0f);
+ }
+
+ // Enter edit mode
+
+ // Select the row
+ taskTreeView.Selection.SelectIter (iter);
+
+ // Go into edit mode
+ Gtk.CellRendererText nameCellRendererText =
+ nameColumn.CellRenderers [3] as Gtk.CellRendererText;
+
+ taskTreeView.SetCursorOnCell (path, nameColumn, nameCellRendererText, true);
}
+
+ /// <summary>
+ /// This method is necessary because it tracks Gtk.TreeIters specific to
+ /// the TreeModelFilter/Sort returned by LocalCache.Tasks.
+ /// </summary>
+ /// <param name="task">
+ /// A <see cref="Task"/>
+ /// </param>
+ /// <param name="iter">
+ /// A <see cref="Gtk.TreeIter"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
+ private bool GetTaskIter (Task task, out Gtk.TreeIter iter)
+ {
+ Gtk.TreeIter parentIter;
+ iter = Gtk.TreeIter.Zero;
+ if (taskTreeView.Model.GetIterFirst(out parentIter) == false)
+ return false;
+
+ do {
+ if (taskTreeView.Model.IterHasChild(parentIter) == true) {
+ Gtk.TreeIter childIter;
+ if (taskTreeView.Model.IterChildren(out childIter, parentIter) == true) {
+ do {
+ TaskModelNode node = taskTreeView.Model.GetValue(childIter, 0) as TaskModelNode;
+ if (node.IsSeparator == true)
+ continue;
+
+ if (node.Task.Id.CompareTo(task.Id) == 0) {
+ iter = childIter;
+ return true;
+ }
+ } while (taskTreeView.Model.IterNext(ref childIter) == true);
+ }
+ }
+ } while (taskTreeView.Model.IterNext(ref parentIter) == true);
+
+ return false;
+ }
private void RebuildAddTaskMenu (Gtk.TreeModel categoriesModel)
{
@@ -709,8 +779,8 @@
Gtk.TreeIter iter;
if (categoriesModel.GetIterFirst (out iter)) {
do {
- ICategory category =
- categoriesModel.GetValue (iter, 0) as ICategory;
+ Category category =
+ categoriesModel.GetValue (iter, 0) as Category;
if (category is AllCategory)
continue; // Skip this one
@@ -736,7 +806,7 @@
// matching category
if (model.GetIterFirst (out iter)) {
do {
- ICategory cat = model.GetValue (iter, 0) as ICategory;
+ Category cat = model.GetValue (iter, 0) as Category;
if (cat == null)
continue; // Needed for some reason to prevent crashes from some backends
if (cat.Name.CompareTo (categoryName) == 0) {
@@ -753,14 +823,14 @@
// category.
if (model.GetIterFirst (out iter)) {
// Make sure we can actually get a category
- ICategory cat = model.GetValue (iter, 0) as ICategory;
+ Category cat = model.GetValue (iter, 0) as Category;
if (cat != null)
categoryComboBox.SetActiveIter (iter);
}
}
}
- private void ShowTaskNotes (ITask task)
+ private void ShowTaskNotes (Task task)
{
NoteDialog dialog = null;
if (!noteDialogs.ContainsKey (task)) {
@@ -777,9 +847,9 @@
dialog.Present ();
}
- private ITask CreateTask (string taskText, ICategory category)
+ private Task CreateTask (string taskText, Category category)
{
- ITask task = backend.CreateTask (taskText, category);
+ Task task = Application.LocalCache.CreateTask (taskText, category);
if (task == null) {
Logger.Debug ("Error creating a new task!");
@@ -795,6 +865,8 @@
addTaskEntry.GrabFocus ();
}
+ // XXX: test
+ taskTreeView.ExpandAll ();
return task;
}
@@ -867,7 +939,7 @@
OnCategoryChanged (this, EventArgs.Empty);
}
-
+
void OnGrabEntryFocus (object sender, EventArgs args)
{
addTaskEntry.GrabFocus ();
@@ -923,8 +995,8 @@
if (!categoryComboBox.GetActiveIter (out iter))
return;
- ICategory category =
- categoryComboBox.Model.GetValue (iter, 0) as ICategory;
+ Category category =
+ categoryComboBox.Model.GetValue (iter, 0) as Category;
// If enabled, attempt to parse due date information
// out of the entered task text.
@@ -938,19 +1010,20 @@
else
taskName = enteredTaskText;
- ITask task = CreateTask (taskName, category);
+ Task task = CreateTask (taskName, category);
if (task == null)
return; // TODO: Explain error to user!
if (taskDueDate != DateTime.MinValue)
task.DueDate = taskDueDate;
- HighlightTask (task);
+ // XXX: test
+ //HighlightTask (task);
}
void OnNewTaskByCategory (object sender, EventArgs args)
{
- string newTaskText = addTaskEntry.Text.Trim ();
+ /*
if (newTaskText.Length == 0)
return;
@@ -965,8 +1038,8 @@
// the title of the task.
Gtk.TreeIter iter;
if (categoryComboBox.GetActiveIter (out iter)) {
- ICategory selectedCategory =
- categoryComboBox.Model.GetValue (iter, 0) as ICategory;
+ Category selectedCategory =
+ categoryComboBox.Model.GetValue (iter, 0) as Category;
// Check to see if "All" is selected
if (selectedCategory is AllCategory) {
@@ -987,28 +1060,25 @@
ITask task = CreateTask (newTaskText, item.Category);
HighlightTask (task);
+ */
+ Logger.Debug("OnNewTaskByCategory Called");
}
void OnCategoryChanged (object sender, EventArgs args)
{
Gtk.TreeIter iter;
- if (!categoryComboBox.GetActiveIter (out iter))
- return;
-
- ICategory category =
- categoryComboBox.Model.GetValue (iter, 0) as ICategory;
-
- // Update the TaskGroups so they can filter accordingly
- overdueGroup.Refilter (category);
- todayGroup.Refilter (category);
- tomorrowGroup.Refilter (category);
- nextSevenDaysGroup.Refilter (category);
- futureGroup.Refilter (category);
- completedTaskGroup.Refilter (category);
-
- // Save the selected category in preferences
- Application.Preferences.Set (Preferences.SelectedCategoryKey,
- category.Name);
+ if (categoryComboBox.GetActiveIter (out iter) == false)
+ return;
+
+ Category category =
+ categoryComboBox.Model.GetValue (iter, 0) as Category;
+
+ // Update the TreeView so it can filter accordingly
+ taskTreeView.Refilter (category);
+
+ // Save the selected category in preferences
+ Application.Preferences.Set (Preferences.SelectedCategoryKey,
+ category.Name);
}
void OnRowActivated (object sender, Gtk.RowActivatedArgs args)
@@ -1026,7 +1096,7 @@
if (!model.GetIter (out iter, args.Path))
return;
- ITask task = model.GetValue (iter, 0) as ITask;
+ Task task = model.GetValue (iter, 0) as Task;
if (task == null)
return;
@@ -1058,7 +1128,7 @@
if (!model.GetIter (out iter, path))
return;
- clickedTask = model.GetValue (iter, 0) as ITask;
+ clickedTask = model.GetValue (iter, 0) as Task;
if (clickedTask == null)
return;
@@ -1103,7 +1173,7 @@
if (clickedTask == null)
return;
- Application.Backend.DeleteTask(clickedTask);
+ Application.LocalCache.DeleteTask(clickedTask);
status = Catalog.GetString ("Task deleted");
TaskWindow.ShowStatus (status);
@@ -1143,14 +1213,14 @@
#region Private Classes
class CategoryMenuItem : Gtk.MenuItem
{
- private ICategory cat;
+ private Category cat;
- public CategoryMenuItem (ICategory category) : base (category.Name)
+ public CategoryMenuItem (Category category) : base (category.Name)
{
cat = category;
}
- public ICategory Category
+ public Category Category
{
get { return cat; }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]