[chronojump] session load: sortable date and name. Hidden ID. Date first: sort desc
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] session load: sortable date and name. Hidden ID. Date first: sort desc
- Date: Thu, 26 Jan 2017 14:53:17 +0000 (UTC)
commit 2713ca106918f117c5c10cdc4dbb52d50961caaa
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Jan 26 15:52:17 2017 +0100
session load: sortable date and name. Hidden ID. Date first: sort desc
src/gui/person.cs | 11 -------
src/gui/session.cs | 79 ++++++++++++++++++++++++++++++++++++++++-----------
src/utilDate.cs | 1 -
src/utilGtk.cs | 15 ++++++++++
4 files changed, 77 insertions(+), 29 deletions(-)
---
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 6ec98c6..85b1218 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -148,17 +148,6 @@ public class PersonRecuperateWindow {
}
*/
- /*
- public int birthColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2) {
- DateTime val1;
- DateTime val2;
- val1 = UtilDate.DateAsDateTime(model.GetValue(iter1, firstColumn + 5).ToString());
- val2 = UtilDate.DateAsDateTime(model.GetValue(iter2, firstColumn + 5).ToString());
-
- return DateTime.Compare(val1, val2);
- }
- */
-
private void fillTreeView (Gtk.TreeView tv, TreeStore store, string searchFilterName)
{
int except = currentSession.UniqueID;
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 5639e17..6b352de 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -691,12 +691,15 @@ public class SessionLoadWindow {
//put an icon to window
UtilGtk.IconWindow(session_load);
-
+
createTreeView(treeview_session_load, false, false);
store = getStore(false, false);
treeview_session_load.Model = store;
fillTreeView(treeview_session_load, store, false, false);
+ store.SetSortColumnId(1, Gtk.SortType.Descending); //date
+ store.ChangeSortColumn();
+
button_accept.Sensitive = false;
entry_search_filter.CanFocus = true;
entry_search_filter.IsFocus = true;
@@ -722,7 +725,7 @@ public class SessionLoadWindow {
TreeStore s;
if(showContacts && showEncoder)
s = new TreeStore(
- typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string), //number
(hidden), date, name, place
typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
typeof (string), typeof (string), typeof (string), typeof(string), //jumps
s,r, runs s, i,
typeof (string), typeof (string), typeof (string), //rt, pulses, mc
@@ -731,7 +734,7 @@ public class SessionLoadWindow {
);
else if(showContacts && ! showEncoder)
s = new TreeStore(
- typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string), //number
(hidden), date, name, place
typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
typeof (string), typeof (string), typeof (string), typeof(string), //jumps
s,r, runs s, i,
typeof (string), typeof (string), typeof (string), //rt, pulses, mc
@@ -739,20 +742,35 @@ public class SessionLoadWindow {
);
else if(! showContacts && showEncoder)
s = new TreeStore(
- typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string), //number
(hidden), date, name, place
typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
typeof (string), typeof (string), //encoder s, c
typeof (string) //comments
);
else // ! showContacts && ! showEncoder
s = new TreeStore(
- typeof (string), typeof (string), typeof (string), typeof (string), //number,
name, place, date
+ typeof (string), typeof (string), typeof (string), typeof (string), //number
(hidden), date, name, place
typeof (string), typeof (string), typeof (string), typeof (string),
//persons, sport, spllity, level
typeof (string) //comments
);
+
+ //s.SetSortFunc (0, UtilGtk.IdColumnCompare); //not needed, it's hidden
+ s.SetSortFunc (1, dateColumnCompare);
+ s.ChangeSortColumn();
+
return s;
}
+
+ private static int dateColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2)
+ {
+ DateTime val1;
+ DateTime val2;
+ val1 = UtilDate.FromSql(model.GetValue(iter1, 1).ToString());
+ val2 = UtilDate.FromSql(model.GetValue(iter2, 1).ToString());
+
+ return DateTime.Compare(val1, val2);
+ }
static public SessionLoadWindow Show (Gtk.Window parent, WindowType type)
{
@@ -766,14 +784,29 @@ public class SessionLoadWindow {
return SessionLoadWindowBox;
}
- private void createTreeView (Gtk.TreeView tv, bool showContacts, bool showEncoder) {
+ private void createTreeView (Gtk.TreeView tv, bool showContacts, bool showEncoder)
+ {
tv.HeadersVisible=true;
int count = 0;
+
+ Gtk.TreeViewColumn colID = new Gtk.TreeViewColumn(Catalog.GetString ("Number"), new
CellRendererText(), "text", count);
+ colID.SortColumnId = count ++;
+ colID.SortIndicator = true;
+ colID.Visible = false; //hidden
+ tv.AppendColumn (colID);
+
+ //tv.AppendColumn ( Catalog.GetString ("Date"), new CellRendererText(), "text", count++);
+ Gtk.TreeViewColumn colDate = new Gtk.TreeViewColumn(Catalog.GetString ("Date"), new
CellRendererText(), "text", count);
+ colDate.SortColumnId = count ++;
+ colDate.SortIndicator = true;
+ tv.AppendColumn (colDate);
+
+ Gtk.TreeViewColumn colName = new Gtk.TreeViewColumn(Catalog.GetString ("Name"), new
CellRendererText(), "text", count);
+ colName.SortColumnId = count ++;
+ colName.SortIndicator = true;
+ tv.AppendColumn (colName);
- tv.AppendColumn ( Catalog.GetString ("Number"), new CellRendererText(), "text", count++);
- tv.AppendColumn ( Catalog.GetString ("Name"), new CellRendererText(), "text", count++);
tv.AppendColumn ( Catalog.GetString ("Place"), new CellRendererText(), "text", count++);
- tv.AppendColumn ( Catalog.GetString ("Date"), new CellRendererText(), "text", count++);
tv.AppendColumn ( Catalog.GetString ("Persons"), new CellRendererText(), "text", count++);
tv.AppendColumn ( Catalog.GetString ("Sport"), new CellRendererText(), "text", count++);
tv.AppendColumn ( Catalog.GetString ("Specialty"), new CellRendererText(), "text", count++);
@@ -844,6 +877,10 @@ public class SessionLoadWindow {
fillTreeView(treeview_session_load, store,
checkbutton_show_data_jump_run.Active, checkbutton_show_data_encoder.Active);
+ store.SetSortColumnId(1, Gtk.SortType.Descending); //date
+ store.ChangeSortColumn();
+
+
/*
* after clicking on checkbuttons, treeview row gets unselected
* call onSelectionEntry to see if there's a row selected
@@ -884,9 +921,11 @@ public class SessionLoadWindow {
myLevel = Catalog.GetString(myStringFull[6]);
if(showContacts && showEncoder)
- store.AppendValues (myStringFull[0], myStringFull[1],
- myStringFull[2],
+ store.AppendValues (
+ myStringFull[0], //session num
myStringFull[3], //session date
+ myStringFull[1], //session name
+ myStringFull[2], //session place
myStringFull[8], //number of jumpers x session
mySport, //personsSport
mySpeciallity, //personsSpeciallity
@@ -903,9 +942,11 @@ public class SessionLoadWindow {
myStringFull[7] //description of session
);
else if(showContacts && ! showEncoder)
- store.AppendValues (myStringFull[0], myStringFull[1],
- myStringFull[2],
+ store.AppendValues (
+ myStringFull[0], //session num
myStringFull[3], //session date
+ myStringFull[1], //session name
+ myStringFull[2], //session place
myStringFull[8], //number of jumpers x session
mySport, //personsSport
mySpeciallity, //personsSpeciallity
@@ -920,9 +961,11 @@ public class SessionLoadWindow {
myStringFull[7] //description of session
);
else if(! showContacts && showEncoder)
- store.AppendValues (myStringFull[0], myStringFull[1],
- myStringFull[2],
+ store.AppendValues (
+ myStringFull[0], //session num
myStringFull[3], //session date
+ myStringFull[1], //session name
+ myStringFull[2], //session place
myStringFull[8], //number of jumpers x session
mySport, //personsSport
mySpeciallity, //personsSpeciallity
@@ -932,9 +975,11 @@ public class SessionLoadWindow {
myStringFull[7] //description of session
);
else // ! showContacts && ! showEncoder
- store.AppendValues (myStringFull[0], myStringFull[1],
- myStringFull[2],
+ store.AppendValues (
+ myStringFull[0], //session num
myStringFull[3], //session date
+ myStringFull[1], //session name
+ myStringFull[2], //session place
myStringFull[8], //number of jumpers x session
mySport, //personsSport
mySpeciallity, //personsSpeciallity
diff --git a/src/utilDate.cs b/src/utilDate.cs
index a7a875b..7c6aae3 100644
--- a/src/utilDate.cs
+++ b/src/utilDate.cs
@@ -58,7 +58,6 @@ public class UtilDate
if(date == null || date == "")
return DateTime.Now;
-
/*
maybe date format is before 0.72 (d/m/Y)
this is still here and not in a standalone conversion
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 0680590..0bdb9c2 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -240,6 +240,21 @@ public class UtilGtk
return (val1-val2);
}
+
+ /*
+ * DateColumnCompare depends on the column. Better define this method where is needed.
+ * Search for dateColumnCompare
+ *
+ public static int DateColumnCompare (TreeModel model, TreeIter iter1, TreeIter iter2) {
+ DateTime val1;
+ DateTime val2;
+ val1 = UtilDate.FromSql(model.GetValue(iter1, 3).ToString());
+ val2 = UtilDate.FromSql(model.GetValue(iter2, 3).ToString());
+
+ return DateTime.Compare(val1, val2);
+ }
+ */
+
public static int GetSelectedRowUniqueID (Gtk.TreeView tv, Gtk.TreeStore store, int uniqueIDcol) {
TreeModel model;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]