[tasque/transition: 116/213] Adjustments to new model API



commit ac3e51d9c5eaa7c3b49fc6a3ac3201bac2eeb625
Author: Antonius Riha <antoniusriha gmail com>
Date:   Thu Aug 16 14:02:56 2012 +0200

    Adjustments to new model API

 src/Tasque.Gtk/NoteDialog.cs |    4 ++--
 src/Tasque.Gtk/TaskWindow.cs |   31 ++++++++++++++++---------------
 2 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/Tasque.Gtk/NoteDialog.cs b/src/Tasque.Gtk/NoteDialog.cs
index 39b81f8..6675ae8 100644
--- a/src/Tasque.Gtk/NoteDialog.cs
+++ b/src/Tasque.Gtk/NoteDialog.cs
@@ -60,7 +60,7 @@ namespace Tasque
 			
 			VBox.PackStart (sw, true, true, 0);
 
-			if(task.SupportsMultipleNotes) {
+			if(task.NoteSupport == TaskNoteSupport.Multiple) {
 				addButton = new Gtk.Button(Gtk.Stock.Add);
 				addButton.Show();
 				this.ActionArea.PackStart(addButton);
@@ -116,7 +116,7 @@ namespace Tasque
 		{
 			NoteWidget nWidget = sender as NoteWidget;
 			try {
-				task.DeleteNote(nWidget.Note);
+				task.RemoveNote (nWidget.Note);
 				targetVBox.Remove (nWidget);
 			} catch(Exception e) {
 				Debug.WriteLine("Unable to delete the note");
diff --git a/src/Tasque.Gtk/TaskWindow.cs b/src/Tasque.Gtk/TaskWindow.cs
index c8d6178..9129eaf 100644
--- a/src/Tasque.Gtk/TaskWindow.cs
+++ b/src/Tasque.Gtk/TaskWindow.cs
@@ -38,6 +38,7 @@ using Tasque;
 using CollectionTransforms;
 using System.Collections;
 using System.Diagnostics;
+using System.Linq;
 
 namespace Tasque
 {
@@ -236,7 +237,7 @@ namespace Tasque
 			backend.BackendSyncFinished += OnBackendSyncFinished;
 			// if the backend is already initialized, go ahead... initialize
 			if(backend.Initialized) {
-				OnBackendInitialized();
+				OnBackendInitialized(null, null);
 			}
 			
 			GtkApplication.Instance.Preferences.SettingChanged += OnSettingChanged;
@@ -647,9 +648,7 @@ namespace Tasque
 			// but I never see anything called unknown
 			if(category != null && category.Name != null) {
 				crt.Text =
-					string.Format ("{0} ({1})",
-								   category.Name,
-								   "HERE SHOULD BE THE TASK COUNT");
+					string.Format ("{0} ({1})", category.Name, category.Count);
 			} else
 				crt.Text = "unknown";
 		}
@@ -693,7 +692,7 @@ namespace Tasque
 			}
 		}
 		
-		void RebuildAddTaskMenu (CollectionView<Category> categories)
+		void RebuildAddTaskMenu (IEnumerable<Category> categories)
 		{
 			Menu menu = new Menu ();
 			
@@ -701,7 +700,7 @@ namespace Tasque
 				if (cat is AllCategory)
 					continue;
 				
-				CategoryMenuItem item = new CategoryMenuItem ((Category)cat);
+				var item = new CategoryMenuItem ((Category)cat);
 				item.Activated += OnNewTaskByCategory;
 				item.ShowAll ();
 				menu.Add (item);
@@ -1080,7 +1079,7 @@ namespace Tasque
 					 * is pre-filtered as to not contain the current category and the AllCategory.
 					 */
 					var cvCategories = new CollectionView<Category> (GtkApplication.Instance.Backend.Categories);
-					cvCategories.Filter = c => c != null && !(c is AllCategory) && !c.Equals(clickedTask.Category);
+					cvCategories.Filter = c => c != null && !(c is AllCategory) && !c.Contains (clickedTask);
 
 					// The categories submenu is only created in case we actually provide at least one category.
 					if (cvCategories.Count > 0) {
@@ -1156,19 +1155,19 @@ namespace Tasque
 			dialog.Destroy ();
 		}
 		
-		private void OnBackendInitialized()
+		private void OnBackendInitialized(object sender, EventArgs e)
 		{		
 			backend.BackendInitialized -= OnBackendInitialized;
 			PopulateWindow();
-			OnBackendSyncFinished (); // To update the statusbar
+			OnBackendSyncFinished (null, null); // To update the statusbar
 		}
 		
-		private void OnBackendSyncStarted ()
+		private void OnBackendSyncStarted (object sender, EventArgs e)
 		{
 			TaskWindow.ShowStatus (Catalog.GetString ("Loading tasks..."));
 		}
 		
-		private void OnBackendSyncFinished ()
+		private void OnBackendSyncFinished (object sender, EventArgs e)
 		{
 			Debug.WriteLine("Backend sync finished");
 			if (GtkApplication.Instance.Backend.Configured) {
@@ -1177,7 +1176,7 @@ namespace Tasque
 				status = string.Format (Catalog.GetString ("Tasks loaded: {0}"), now);
 				TaskWindow.lastLoadedTime = now;
 				TaskWindow.ShowStatus (status);
-				RebuildAddTaskMenu ((CollectionView<Category>)GtkApplication.Instance.Backend.Categories);
+				RebuildAddTaskMenu (GtkApplication.Instance.Backend.Categories);
 				addTaskEntry.Sensitive = true;
 				categoryComboBox.Sensitive = true;
 				// Keep insensitive text color
@@ -1203,12 +1202,14 @@ namespace Tasque
 			args.RetVal = false;
 		}
 
-		private void OnChangeCategory(object sender, EventArgs args)
+		private void OnChangeCategory (object sender, EventArgs args)
 		{
 			if (clickedTask == null)
 				return;
-
-			clickedTask.Category = ((CategoryMenuItem)sender).Category;
+			
+			var oldCategory = GtkApplication.Instance.Backend.Categories.Single (c => c.Contains (clickedTask));
+			oldCategory.Remove (clickedTask);
+			(((CategoryMenuItem)sender).Category).Add (clickedTask);
 		}
 		#endregion // Event Handlers
 		



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