[longomatch] Refresh updates in the project description in the projects manager



commit 45d8390ed3236a21cf9bee9efaa4c8c9b4fc605d
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Dec 1 16:04:04 2014 +0100

    Refresh updates in the project description in the projects manager

 LongoMatch.GUI/Gui/Component/ProjectListWidget.cs |   40 +++++++++++++++------
 LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs  |    1 +
 2 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs 
b/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs
index 79dc084..7c40e40 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectListWidget.cs
@@ -93,7 +93,6 @@ namespace LongoMatch.Gui.Component
                public void Fill (List<ProjectDescription> projects)
                {
                        Pixbuf image, homeShield, awayShield;
-                       string desc;
 
                        swallowSignals = true;
                        this.projects = projects;
@@ -118,16 +117,7 @@ namespace LongoMatch.Gui.Component
                                        awayShield = Misc.LoadIcon ("longomatch-default-shield", 50);
                                }
                                
-                               desc = String.Format ("{0}-{1} ({2}-{3})\n{4}: {5}\n{6}: {7}\n{8}: {9}",
-                                                     pdesc.LocalName, pdesc.VisitorName,
-                                                     pdesc.LocalGoals, pdesc.VisitorGoals,
-                                                     Catalog.GetString ("Date"),
-                                                     pdesc.MatchDate.ToShortDateString(),
-                                                     Catalog.GetString ("Competition"),
-                                                     pdesc.Competition,
-                                                     Catalog.GetString ("Season"),
-                                                     pdesc.Season);
-                               store.AppendValues (desc, image, homeShield, awayShield, pdesc);
+                               store.AppendValues (FormatDesc (pdesc), image, homeShield, awayShield, pdesc);
                        }
                        swallowSignals = false;
                        iconview.SetCursor (new TreePath ("0"), null, false);
@@ -145,11 +135,39 @@ namespace LongoMatch.Gui.Component
                        }
                }
 
+               public void UpdateProject (ProjectDescription description)
+               {
+                       TreeIter first;
+
+                       /* Projects are only update in the treeview mode */
+                       store.GetIterFirst (out first);
+                       while (store.IterIsValid (first)) {
+                               ProjectDescription pd = store.GetValue (first, COL_PROJECT_DESCRIPTION) as 
ProjectDescription;
+                               if (description.ID == pd.ID) {
+                                       store.SetValue (first, COL_DISPLAY_NAME, FormatDesc (description));
+                                       store.SetValue (first, COL_PROJECT_DESCRIPTION, description);
+                                       break;
+                               }
+                               store.IterNext (ref (first));
+                       }
+               }
+               
+
                public void ClearSearch ()
                {
                        filterEntry.Text = "";
                }
 
+               static string FormatDesc (ProjectDescription pdesc)
+               {
+                       string desc = String.Format ("{0}-{1} ({2}-{3})\n{4}: {5}\n{6}: {7}\n{8}: {9}",
+                                                    pdesc.LocalName, pdesc.VisitorName, pdesc.LocalGoals,
+                                                    pdesc.VisitorGoals, Catalog.GetString ("Date"),
+                                                    pdesc.MatchDate.ToShortDateString (), Catalog.GetString 
("Competition"),
+                                                    pdesc.Competition, Catalog.GetString ("Season"), 
pdesc.Season);
+                       return desc;
+               }
+
                ListStore CreateStore ()
                {
                        store = new ListStore (typeof(string), typeof(Gdk.Pixbuf), typeof(Gdk.Pixbuf),
diff --git a/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs 
b/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
index 7bc6724..034beb1 100644
--- a/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/ProjectsManagerPanel.cs
@@ -170,6 +170,7 @@ namespace LongoMatch.Gui.Panel
                {
                        if (loadedProject != null) {
                                DB.UpdateProject (loadedProject);
+                               projectlistwidget1.UpdateProject (loadedProject.Description);
                        }
                }
 


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