[tasque/viewmodel: 42/78] Change grouping of tasks from nested to flat structure



commit 1ecdd8eadff50603f16176c669a93e770559c6b4
Author: Antonius Riha <antoniusriha gmail com>
Date:   Thu Aug 2 23:21:13 2012 +0200

    Change grouping of tasks from nested to flat structure
    
    * TaskGroup.cs: Represents the groups presented to the user.
    * TaskGroupConverter.cs: Contains the logic to do the grouping.
    * DueDateCategory.cs: Dropped, replaced by TaskGroup.cs
    * DueDateConverter.cs: Dropped, replaced by TaskGroupConverter.cs
    * MainWindowModel.cs: Replaced group descriptions "Completed" and
      "DueDate" with a GroupDescription that uses a task object directly
      for grouping by making use of the TaskGroupConverter. Also: Added
      stubs for each group.

 src/libtasqueui/Legacy/MainWindowModel.cs          |   28 +++++++++++--
 .../Legacy/{DueDateCategory.cs => TaskGroup.cs}    |   17 ++++----
 .../{DueDateConverter.cs => TaskGroupConverter.cs} |   41 ++++++++++---------
 src/libtasqueui/libtasqueui.csproj                 |    4 +-
 4 files changed, 56 insertions(+), 34 deletions(-)
---
diff --git a/src/libtasqueui/Legacy/MainWindowModel.cs b/src/libtasqueui/Legacy/MainWindowModel.cs
index 645c617..84769ce 100644
--- a/src/libtasqueui/Legacy/MainWindowModel.cs
+++ b/src/libtasqueui/Legacy/MainWindowModel.cs
@@ -25,6 +25,7 @@
 // THE SOFTWARE.
 using System;
 using CollectionTransforms;
+using System.Collections.ObjectModel;
 
 namespace Tasque.UIModel.Legacy
 {
@@ -44,11 +45,8 @@ namespace Tasque.UIModel.Legacy
 			
 			Tasks = new ListCollectionView<Task> (Backend.Tasks);
 			Tasks.Filter = Filter;
-			Tasks.GroupDescriptions.Add (new PropertyGroupDescription ("IsComplete"));
-			var dueDateDesc = new PropertyGroupDescription("DueDate");
-            dueDateDesc.Converter = new DueDateConverter();
-            Tasks.GroupDescriptions.Add(dueDateDesc);
-			Tasks.CustomSort = new TaskComparer(new TaskCompletionDateComparer());
+			Tasks.GroupDescriptions.Add (new PropertyGroupDescription (null, new TaskGroupConverter ()));
+			Tasks.CustomSort = new TaskComparer (new TaskCompletionDateComparer());
 			
 			topPanel = new MainWindowTopPanelModel (this);
 		}
@@ -98,6 +96,26 @@ namespace Tasque.UIModel.Legacy
 		}
 		
 		public bool ShowCompletedTasks { get { return showCompletedTasks; } }
+
+		public ReadOnlyObservableCollection<Task> OverdueTasks {
+			get { throw new NotImplementedException (); }
+		}
+		
+		public ReadOnlyObservableCollection<Task> TodayTasks {
+			get { throw new NotImplementedException (); }
+		}
+		
+		public ReadOnlyObservableCollection<Task> TomorrowTasks {
+			get { throw new NotImplementedException (); }
+		}
+		
+		public ReadOnlyObservableCollection<Task> FutureTasks {
+			get { throw new NotImplementedException (); }
+		}
+		
+		public ReadOnlyObservableCollection<Task> CompletedTasks {
+			get { throw new NotImplementedException (); }
+		}
 		
 		public UICommand Hide { get { return hide ?? (hide = new UICommand ()); } }
 		
diff --git a/src/libtasqueui/Legacy/DueDateCategory.cs b/src/libtasqueui/Legacy/TaskGroup.cs
similarity index 90%
rename from src/libtasqueui/Legacy/DueDateCategory.cs
rename to src/libtasqueui/Legacy/TaskGroup.cs
index 9fe3784..1e46a0c 100644
--- a/src/libtasqueui/Legacy/DueDateCategory.cs
+++ b/src/libtasqueui/Legacy/TaskGroup.cs
@@ -1,5 +1,5 @@
 // 
-// DueDateCategory.cs
+// TaskGroup.cs
 //  
 // Author:
 //       Antonius Riha <antoniusriha gmail com>
@@ -26,11 +26,12 @@
 
 namespace Tasque.UIModel.Legacy
 {
-    public enum DueDateCategory
-    {
-        Overdue,
-        Today,
-        Tomorrow,
-        Future
-    }
+	public enum TaskGroup
+	{
+		Overdue,
+		Today,
+		Tomorrow,
+		Future,
+		Completed
+	}
 }
diff --git a/src/libtasqueui/Legacy/DueDateConverter.cs b/src/libtasqueui/Legacy/TaskGroupConverter.cs
similarity index 66%
rename from src/libtasqueui/Legacy/DueDateConverter.cs
rename to src/libtasqueui/Legacy/TaskGroupConverter.cs
index a1c439a..1ca7a33 100644
--- a/src/libtasqueui/Legacy/DueDateConverter.cs
+++ b/src/libtasqueui/Legacy/TaskGroupConverter.cs
@@ -1,5 +1,5 @@
 // 
-// DueDateConverter.cs
+// TaskGroupConverter.cs
 //  
 // Author:
 //       Antonius Riha <antoniusriha gmail com>
@@ -29,27 +29,30 @@ using CollectionTransforms;
 
 namespace Tasque.UIModel.Legacy
 {
-    public class DueDateConverter : IValueConverter
-    {
-        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            var today = DateTime.Today;
-            var tomorrow = DateTime.Today.AddDays(1);
-
-            var dueDate = ((DateTime)value).Date;
+	public class TaskGroupConverter : IValueConverter
+	{
+		public object Convert (object value, Type targetType, object parameter, CultureInfo culture)
+		{
+			var task = (Task)value;
+			if (task.IsComplete)
+				return TaskGroup.Completed;
+			
+			var today = DateTime.Today;
+            var tomorrow = DateTime.Today.AddDays (1);
+			var dueDate = task.DueDate.Date;
             if (dueDate < today)
-                return DueDateCategory.Overdue;
+                return TaskGroup.Overdue;
             else if (dueDate == today)
-                return DueDateCategory.Today;
+                return TaskGroup.Today;
             else if (dueDate == tomorrow)
-                return DueDateCategory.Tomorrow;
+                return TaskGroup.Tomorrow;
             else
-                return DueDateCategory.Future;
-        }
+                return TaskGroup.Future;
+		}
 
-        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
-        {
-            throw new NotImplementedException();
-        }
-    }
+		public object ConvertBack (object value, Type targetType, object parameter, CultureInfo culture)
+		{
+			throw new NotImplementedException ();
+		}
+	}
 }
diff --git a/src/libtasqueui/libtasqueui.csproj b/src/libtasqueui/libtasqueui.csproj
index 2aca8b4..f3eee40 100644
--- a/src/libtasqueui/libtasqueui.csproj
+++ b/src/libtasqueui/libtasqueui.csproj
@@ -96,8 +96,6 @@
     <Compile Include="Legacy\NoteDialogModel.cs" />
     <Compile Include="ViewModelBase.cs" />
     <Compile Include="Legacy\TrayModel.cs" />
-    <Compile Include="Legacy\DueDateCategory.cs" />
-    <Compile Include="Legacy\DueDateConverter.cs" />
     <Compile Include="Legacy\TaskComparer.cs" />
     <Compile Include="Legacy\CompletionDateRange.cs" />
     <Compile Include="ITimeAware.cs" />
@@ -117,6 +115,8 @@
     <Compile Include="..\Options.cs">
       <Link>Options.cs</Link>
     </Compile>
+    <Compile Include="Legacy\TaskGroupConverter.cs" />
+    <Compile Include="Legacy\TaskGroup.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>



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