[chronojump] Session load has a filter name



commit d4ea292cbab451fa6c4011b5399ecaac6c00ad9b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Dec 24 14:01:28 2015 +0100

    Session load has a filter name

 glade/chronojump.glade |  110 ++++++++++++++++++++++++++++++++++++++++++++++-
 src/gui/session.cs     |   42 ++++++++++---------
 src/sqlite/session.cs  |    8 +++-
 3 files changed, 136 insertions(+), 24 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 343e0bf..b7bba28 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -7922,6 +7922,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -9378,6 +9381,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -10475,6 +10481,9 @@ after time</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -22185,6 +22194,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -23181,6 +23193,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -24669,6 +24684,9 @@ by you</property>
               <placeholder/>
             </child>
             <child>
+              <placeholder/>
+            </child>
+            <child>
               <widget class="GtkButton" id="button_video_url">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -25214,6 +25232,9 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -37092,6 +37113,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -39039,6 +39078,18 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -40343,9 +40394,6 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                       <placeholder/>
                                     </child>
                                     <child>
-                                      <placeholder/>
-                                    </child>
-                                    <child>
                                       <widget class="GtkLabel" id="label218">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
@@ -41341,6 +41389,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                     <child>
                                       <placeholder/>
                                     </child>
+                                    <child>
+                                      <placeholder/>
+                                    </child>
                                   </widget>
                                 </child>
                               </widget>
@@ -45109,6 +45160,9 @@ It starts before and arrives there with some speed.</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -45769,6 +45823,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -46444,6 +46501,9 @@ It starts before and arrives there with some speed.</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -52344,6 +52404,7 @@ suitable for agility tests and RSA)</property>
           <widget class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="spacing">10</property>
             <child>
               <widget class="GtkVBox" id="vbox1">
                 <property name="visible">True</property>
@@ -52388,6 +52449,49 @@ suitable for agility tests and RSA)</property>
                 <property name="position">0</property>
               </packing>
             </child>
+            <child>
+              <widget class="GtkVBox" id="vbox2">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="spacing">4</property>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Search filter</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkEntry" id="entry_search_filter">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="invisible_char">●</property>
+                    <property name="invisible_char_set">True</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <property name="primary_icon_sensitive">True</property>
+                    <property name="secondary_icon_sensitive">True</property>
+                    <signal name="changed" handler="on_entry_search_filter_changed" swapped="no"/>
+                  </widget>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
           </widget>
           <packing>
             <property name="expand">False</property>
diff --git a/src/gui/session.cs b/src/gui/session.cs
index beef06d..385c253 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -641,6 +641,7 @@ public class SessionLoadWindow {
        private string selected;
        [Widget] Gtk.TreeView treeview_session_load;
        [Widget] Gtk.Button button_accept;
+       [Widget] Gtk.Entry entry_search_filter;
        [Widget] Gtk.CheckButton checkbutton_show_data_jump_run;
        [Widget] Gtk.CheckButton checkbutton_show_data_encoder;
 
@@ -664,6 +665,8 @@ public class SessionLoadWindow {
                fillTreeView(treeview_session_load, store, false, false);
 
                button_accept.Sensitive = false;
+               entry_search_filter.CanFocus = true;
+               entry_search_filter.IsFocus = true;
 
                treeview_session_load.Selection.Changed += onSelectionEntry;
        }
@@ -742,30 +745,18 @@ public class SessionLoadWindow {
                tv.AppendColumn ( Catalog.GetString ("Comments"), new CellRendererText(), "text", count++);
        }
        
+       protected void on_entry_search_filter_changed (object o, EventArgs args) {
+               recreateTreeView("changed search filter");
+       }
        void on_checkbutton_show_data_jump_run_toggled (object o, EventArgs args) {
-               LogB.Information("jump run " + checkbutton_show_data_jump_run.Active.ToString());
-               recreateTreeView();
-
-               /*
-                * after clicking on this checkbutton, treeview row gets unselected
-                * call onSelectionEntry to see if there's a row selected
-                * and it will sensitive on/off button_accept as needed
-                */
-               onSelectionEntry (treeview_session_load.Selection, new EventArgs ());
+               recreateTreeView("jump run " + checkbutton_show_data_jump_run.Active.ToString());
        }
        void on_checkbutton_show_data_encoder_toggled (object o, EventArgs args) {
-               LogB.Information("encoder " + checkbutton_show_data_encoder.Active.ToString());
-               recreateTreeView();     
-
-               /*
-                * after clicking on this checkbutton, treeview row gets unselected
-                * call onSelectionEntry to see if there's a row selected
-                * and it will sensitive on/off button_accept as needed
-                */
-               onSelectionEntry (treeview_session_load.Selection, new EventArgs ());
+               recreateTreeView("encoder " + checkbutton_show_data_encoder.Active.ToString());
        }
+       void recreateTreeView(string message) {
+               LogB.Information(message);
 
-       void recreateTreeView() {
                UtilGtk.RemoveColumns(treeview_session_load);
                
                createTreeView(treeview_session_load, 
@@ -775,11 +766,22 @@ public class SessionLoadWindow {
                treeview_session_load.Model = store;
                fillTreeView(treeview_session_load, store,
                                checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+               
+               /*
+                * after clicking on checkbuttons, treeview row gets unselected
+                * call onSelectionEntry to see if there's a row selected
+                * and it will sensitive on/off button_accept as needed
+                */
+               onSelectionEntry (treeview_session_load.Selection, new EventArgs ());
        }
 
        private void fillTreeView (Gtk.TreeView tv, TreeStore store, bool showContacts, bool showEncoder) 
        {
-               string [] mySessions = SqliteSession.SelectAllSessions(); //returns a string of values 
separated by ':'
+               string filterName = "";
+               if(entry_search_filter.Text.ToString().Length > 0) 
+                       filterName = entry_search_filter.Text.ToString();
+               
+               string [] mySessions = SqliteSession.SelectAllSessions(filterName); //returns a string of 
values separated by ':'
                foreach (string session in mySessions) {
                        string [] myStringFull = session.Split(new char[] {':'});
                
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 41e5427..a380567 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -219,14 +219,20 @@ class SqliteSession : Sqlite
        }
 
 
-       public static string[] SelectAllSessions() 
+       public static string[] SelectAllSessions(string filterName) 
        {
                Sqlite.Open();
+
+               string filterNameString = "";
+               if(filterName != "")
+                       filterNameString = " AND LOWER(session.name) LIKE LOWER ('%" + filterName  + "%') ";
+
                dbcmd.CommandText = 
                        "SELECT session.*, sport.name, speciallity.name" +
                        " FROM session, sport, speciallity " +
                        " WHERE session.personsSportID == sport.uniqueID " + 
                        " AND session.personsSpeciallityID == speciallity.UniqueID " +
+                       filterNameString + 
                        " ORDER BY session.uniqueID";
                LogB.SQL(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();


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