[tasque/viewmodel: 13/78] WiP
- From: Antonius Riha <antoniusri src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tasque/viewmodel: 13/78] WiP
- Date: Wed, 29 Aug 2012 18:35:45 +0000 (UTC)
commit 0f7836f5efa7f2410ccfc662b341f28155474a56
Author: Antonius Riha <antoniusriha gmail com>
Date: Thu Jul 26 01:26:16 2012 +0200
WiP
src/ObservableTransformCollections | 2 +-
src/libtasqueui/Legacy/DueDateCategory.cs | 36 ++++++++++++++++++
src/libtasqueui/Legacy/DueDateConverter.cs | 55 ++++++++++++++++++++++++++++
src/libtasqueui/Legacy/MainWindowModel.cs | 9 ++++-
src/libtasqueui/Legacy/TaskComparer.cs | 53 +++++++++++++++++++++++++++
src/libtasqueui/libtasqueui.csproj | 11 ++++--
6 files changed, 159 insertions(+), 7 deletions(-)
---
diff --git a/src/ObservableTransformCollections b/src/ObservableTransformCollections
index a7bf241..2b9190c 160000
--- a/src/ObservableTransformCollections
+++ b/src/ObservableTransformCollections
@@ -1 +1 @@
-Subproject commit a7bf2411f73deee7e5374f48563b019ccb544c6f
+Subproject commit 2b9190c75ed72be059e6ba3d35a17b008417be81
diff --git a/src/libtasqueui/Legacy/DueDateCategory.cs b/src/libtasqueui/Legacy/DueDateCategory.cs
new file mode 100644
index 0000000..9fe3784
--- /dev/null
+++ b/src/libtasqueui/Legacy/DueDateCategory.cs
@@ -0,0 +1,36 @@
+//
+// DueDateCategory.cs
+//
+// Author:
+// Antonius Riha <antoniusriha gmail com>
+//
+// Copyright (c) 2012 Antonius Riha
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+namespace Tasque.UIModel.Legacy
+{
+ public enum DueDateCategory
+ {
+ Overdue,
+ Today,
+ Tomorrow,
+ Future
+ }
+}
diff --git a/src/libtasqueui/Legacy/DueDateConverter.cs b/src/libtasqueui/Legacy/DueDateConverter.cs
new file mode 100644
index 0000000..a1c439a
--- /dev/null
+++ b/src/libtasqueui/Legacy/DueDateConverter.cs
@@ -0,0 +1,55 @@
+//
+// DueDateConverter.cs
+//
+// Author:
+// Antonius Riha <antoniusriha gmail com>
+//
+// Copyright (c) 2012 Antonius Riha
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Globalization;
+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;
+ if (dueDate < today)
+ return DueDateCategory.Overdue;
+ else if (dueDate == today)
+ return DueDateCategory.Today;
+ else if (dueDate == tomorrow)
+ return DueDateCategory.Tomorrow;
+ else
+ return DueDateCategory.Future;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/libtasqueui/Legacy/MainWindowModel.cs b/src/libtasqueui/Legacy/MainWindowModel.cs
index 9e6dfd6..ce6b225 100644
--- a/src/libtasqueui/Legacy/MainWindowModel.cs
+++ b/src/libtasqueui/Legacy/MainWindowModel.cs
@@ -35,8 +35,13 @@ namespace Tasque.UIModel.Legacy
this.preferences = preferences;
preferences.PropertyChanged += HandlePreferencesPropertyChanged;
- tasks = new CollectionView<Task> (backend.Tasks);
+ tasks = new ListCollectionView<Task> (backend.Tasks);
SetFilter ();
+ 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());
}
void HandlePreferencesPropertyChanged (object sender, PropertyChangedEventArgs e)
@@ -57,6 +62,6 @@ namespace Tasque.UIModel.Legacy
}
Preferences preferences;
- CollectionView<Task> tasks;
+ ListCollectionView<Task> tasks;
}
}
diff --git a/src/libtasqueui/Legacy/TaskComparer.cs b/src/libtasqueui/Legacy/TaskComparer.cs
new file mode 100644
index 0000000..1d860af
--- /dev/null
+++ b/src/libtasqueui/Legacy/TaskComparer.cs
@@ -0,0 +1,53 @@
+//
+// TaskComparer.cs
+//
+// Author:
+// Antonius Riha <antoniusriha gmail com>
+//
+// Copyright (c) 2012 Antonius Riha
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Collections.Generic;
+
+namespace Tasque.UIModel.Legacy
+{
+ public class TaskComparer : Comparer<Task>
+ {
+ public TaskComparer(TaskCompletionDateComparer completedComparer)
+ {
+ this.completedComparer = completedComparer;
+ }
+
+ public override int Compare(Task x, Task y)
+ {
+ var result = x.IsComplete.CompareTo(y.IsComplete);
+
+ if (result != 0)
+ return -result;
+
+ if (x.IsComplete)
+ return -completedComparer.Compare(x, y);
+ else
+ return x.CompareTo(y);
+ }
+
+ TaskCompletionDateComparer completedComparer;
+ }
+}
diff --git a/src/libtasqueui/libtasqueui.csproj b/src/libtasqueui/libtasqueui.csproj
index d5cf8ae..f8ad60a 100644
--- a/src/libtasqueui/libtasqueui.csproj
+++ b/src/libtasqueui/libtasqueui.csproj
@@ -149,6 +149,9 @@
<Compile Include="TaskGroupModelFactory.cs" />
<Compile Include="Legacy\TrayModel.cs" />
<Compile Include="Preferences.cs" />
+ <Compile Include="Legacy\DueDateCategory.cs" />
+ <Compile Include="Legacy\DueDateConverter.cs" />
+ <Compile Include="Legacy\TaskComparer.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@ -156,13 +159,13 @@
<Folder Include="Legacy\" />
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\ObservableTransformCollections\CollectionView\CollectionView.csproj">
- <Project>{A5AAD70F-F4E8-4CAE-A000-01C2D0A10B92}</Project>
- <Name>CollectionView</Name>
- </ProjectReference>
<ProjectReference Include="..\libtasque\libtasque.csproj">
<Project>{784C9AA8-2B28-400B-8CC4-DCDC48CA37F0}</Project>
<Name>libtasque</Name>
</ProjectReference>
+ <ProjectReference Include="..\ObservableTransformCollections\CollectionView\CollectionView.csproj">
+ <Project>{A5AAD70F-F4E8-4CAE-A000-01C2D0A10B92}</Project>
+ <Name>CollectionView</Name>
+ </ProjectReference>
</ItemGroup>
</Project>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]