tasque r35 - in branches/cache: . src



Author: btimothy
Date: Tue Mar 18 01:03:34 2008
New Revision: 35
URL: http://svn.gnome.org/viewvc/tasque?rev=35&view=rev

Log:
* src/TaskTreeView.cs: Change ordering of refiltering.  Also ExpandAll
  () after Refiltering.  Also, depending on the selected category,
  don't show section headers unless it actually has tasks inside it.
* src/LocalCache.cs: When creating a new task and updating an existing
  task, call SetValue () on the parentIter so that any
  TreeModelFilters above will refilter and show the parent item.
* src/AllCategory.cs: Change ContainsTask () to "override"
  Category.cs's implementation.  Before this change,
  AllCategory.ContainsTask() was never being called.
* src/Category.cs: Change ContainsTask() to be virtual so it can be
  overridden appropriately.
* src/TaskWindow.cs: Call TreeView.ExpandAll () after adding a new task
  so that it will show up if the section had never been shown before.
   Also refilter when a new category is selected.

Modified:
   branches/cache/ChangeLog
   branches/cache/src/AllCategory.cs
   branches/cache/src/Category.cs
   branches/cache/src/LocalCache.cs
   branches/cache/src/TaskTreeView.cs
   branches/cache/src/TaskWindow.cs

Modified: branches/cache/src/AllCategory.cs
==============================================================================
--- branches/cache/src/AllCategory.cs	(original)
+++ branches/cache/src/AllCategory.cs	Tue Mar 18 01:03:34 2008
@@ -30,18 +30,19 @@
 			}
 		}
 		
-		public new bool ContainsTask(Task task)
+		public override bool ContainsTask(Task task)
 		{
 			// Filter out tasks based on the user's preferences of which
 			// categories should be displayed in the AllCategory.
 			Category category = task.Category;
-			if (category == null)
+			if (category == null) {
 				return true;
+			}
 			
 			//if (categoriesToHide.Count == 0)
 			//	return true;
 			
-			return (!categoriesToHide.Contains (category.Name));
+			return (categoriesToHide.Contains (category.Name) == false);
 		}
 		
 		private void OnSettingChanged (Preferences preferences, string settingKey)

Modified: branches/cache/src/Category.cs
==============================================================================
--- branches/cache/src/Category.cs	(original)
+++ branches/cache/src/Category.cs	Tue Mar 18 01:03:34 2008
@@ -60,7 +60,7 @@
 		}
 
 		
-		public bool ContainsTask(Task task)
+		public virtual bool ContainsTask(Task task)
 		{
 			if(task.Category is Category)
 				return ((task.Category as Category).ID == id);

Modified: branches/cache/src/LocalCache.cs
==============================================================================
--- branches/cache/src/LocalCache.cs	(original)
+++ branches/cache/src/LocalCache.cs	Tue Mar 18 01:03:34 2008
@@ -123,7 +123,12 @@
 			Gtk.TreeIter iter = taskStore.AppendNode(parentIter);
 			taskStore.SetValue (iter, 0, new TaskModelNode(task));
 			taskIters [task.Id] = iter;		
-
+			
+			// Set the parent iter object so that in case it's not showing
+			// already, the TreeModelFilter will refilter and cause it to appear.
+			object parentObj = taskStore.GetValue (parentIter, 0);
+			taskStore.SetValue (parentIter, 0, parentObj);
+			
 			return task;
 		}
 		
@@ -236,6 +241,10 @@
 					iter = taskStore.AppendNode(parentIter);
 					taskStore.SetValue (iter, 0, new TaskModelNode(task));					
 					taskIters [task.Id] = iter;
+					
+					// Set the values of all the parent objects so any filters
+					// will update themselves
+					UpdateParentIters ();
 				} else {
 					taskStore.SetValue (iter, 0, new TaskModelNode(task));
 				}
@@ -448,6 +457,21 @@
 									   futureRangeStart.Day, 0, 0, 0);
 			futureRangeEnd = DateTime.MaxValue;
 		}
+		
+		void UpdateParentIters ()
+		{
+			Gtk.TreeIter iter;
+			if (taskStore.GetIterFirst (out iter) == false)
+				return;
+			
+			do {
+				TaskModelNode node = taskStore.GetValue (iter, 0) as TaskModelNode;
+				if (node == null)
+					continue;
+				
+				taskStore.SetValue (iter, 0, node);
+			} while (taskStore.IterNext (ref iter) == true);
+		}
 
 		#endregion // Private Methods
 		

Modified: branches/cache/src/TaskTreeView.cs
==============================================================================
--- branches/cache/src/TaskTreeView.cs	(original)
+++ branches/cache/src/TaskTreeView.cs	Tue Mar 18 01:03:34 2008
@@ -53,7 +53,7 @@
 			modelFilter.RowInserted += OnRowInsertedHandler;
 			modelFilter.RowDeleted += OnRowDeletedHandler;
 			
-			//Model = modelFilter
+			Model = modelFilter;
 			
 			Selection.Mode = Gtk.SelectionMode.Single;
 			RulesHint = false;
@@ -422,8 +422,9 @@
 		public void Refilter (Category selectedCategory)
 		{
 			this.filterCategory = selectedCategory;
-			Model = modelFilter;
 			modelFilter.Refilter ();
+			Model = modelFilter;
+			ExpandAll ();
 		}
 		
 		public int GetNumberOfTasks ()
@@ -682,19 +683,76 @@
 			if(node == null)
 				return false;
 				
-			if(node.IsSeparator)
-				return true;
-				
+			if(node.IsSeparator) {
+				return ShouldShowSeparator (node, model, iter);
+			}
+			
 			if (node.Task.State == TaskState.Deleted) {
 				//Logger.Debug ("TaskTreeView.FilterFunc:\n\t{0}\n\t{1}\n\tReturning false", task.Name, task.State);  
 				return false;
 			}
 			
-			if (filterCategory == null)
+			if (filterCategory == null) {
 				return true;
+			}
 				
 			return filterCategory.ContainsTask (node.Task);
 		}
+		
+		/// <summary>
+		/// Evaluate the given parent iter to see if any of its children would
+		/// cause it to be shown.  As soon as one is found, return true.
+		/// </summary>
+		/// <param name="node">
+		/// A <see cref="TaskModelNode"/>
+		/// </param>
+		/// <param name="model">
+		/// A <see cref="Gtk.TreeModel"/>
+		/// </param>
+		/// <param name="iter">
+		/// A <see cref="Gtk.TreeIter"/>
+		/// </param>
+		/// <returns>
+		/// A <see cref="System.Boolean"/>
+		/// </returns>
+		private bool ShouldShowSeparator (TaskModelNode node,
+										  Gtk.TreeModel model,
+										  Gtk.TreeIter iter)
+		{
+			if (node.IsSeparator == false)
+				return false;
+			
+			// Go through all of the children of the separator and check whether
+			// any of them should be showing based on the currently selected
+			// filterCategory.
+			if (model.IterHasChild (iter) == false) {
+				return false;
+			}
+			
+			if (filterCategory == null) {
+				return true;
+			}
+			
+			Gtk.TreeIter childIter;
+			if (model.IterChildren (out childIter, iter) == false)
+				return false;
+			
+			do {
+				TaskModelNode childNode = model.GetValue (childIter, 0) as TaskModelNode;
+				if (childNode == null)
+					continue;
+				
+				Task childTask = childNode.Task;
+				if (childTask.State == TaskState.Deleted)
+					continue;
+				
+				if (filterCategory.ContainsTask (childTask) == true) {
+					return true;
+				}
+			} while (model.IterNext (ref childIter));
+			
+			return false;
+		}
 		#endregion // Private Methods
 		
 		#region EventHandlers

Modified: branches/cache/src/TaskWindow.cs
==============================================================================
--- branches/cache/src/TaskWindow.cs	(original)
+++ branches/cache/src/TaskWindow.cs	Tue Mar 18 01:03:34 2008
@@ -776,6 +776,7 @@
 				addTaskEntry.GrabFocus ();
 			}
 			
+			taskTreeView.ExpandAll ();
 			return task;
 		}
 		#endregion // Private Methods
@@ -948,13 +949,8 @@
 			Category category =
 				categoryComboBox.Model.GetValue (iter, 0) as Category;
 				
-			// 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);
+			// Update the TreeView so it can filter accordingly
+			taskTreeView.Refilter (category);
 			
 			// Save the selected category in preferences
 			Application.Preferences.Set (Preferences.SelectedCategoryKey,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]