[chronojump] Automatic tests can be deleted from DB
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Automatic tests can be deleted from DB
- Date: Mon, 13 Oct 2014 22:32:17 +0000 (UTC)
commit dc1147495e5685bd2212cbf47cc0e0fd50221794
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Oct 14 00:32:00 2014 +0200
Automatic tests can be deleted from DB
glade/chronojump.glade | 58 +++++++++++++++++++++++++++++++++++++++++++++
src/executeAuto.cs | 8 ++++-
src/gui/executeAuto.cs | 35 ++++++++++++++++++++++++--
src/sqlite/executeAuto.cs | 3 +-
src/utilGtk.cs | 10 +++++++
5 files changed, 108 insertions(+), 6 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index add1f5f..c52f687 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -6311,6 +6311,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -7002,6 +7005,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
<child>
@@ -7827,6 +7833,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">2</property>
@@ -8411,6 +8420,9 @@ Second Chronopic to platforms.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="position">4</property>
@@ -18121,6 +18133,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -18613,6 +18628,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -19597,6 +19615,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>
@@ -19638,6 +19659,9 @@ by you</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
@@ -25138,6 +25162,7 @@ comments</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="row_activated" handler="on_load_row_double_clicked"
swapped="no"/>
+ <signal name="button_release_event"
handler="on_treeview_load_button_release_event" swapped="no"/>
</widget>
</child>
</widget>
@@ -28328,6 +28353,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>
@@ -30210,6 +30253,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>
@@ -30761,6 +30807,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>
@@ -33285,6 +33334,9 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -33441,6 +33493,9 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
@@ -33612,6 +33667,9 @@ show elevation as:</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
</child>
</widget>
diff --git a/src/executeAuto.cs b/src/executeAuto.cs
index cb3973d..0cf5133 100644
--- a/src/executeAuto.cs
+++ b/src/executeAuto.cs
@@ -122,6 +122,7 @@ public class ExecuteAuto {
//sequence saved or loaded on SQL
public class ExecuteAutoSQL
{
+ public int uniqueID;
public string name;
private ExecuteAuto.ModeTypes mode;
private string description;
@@ -129,9 +130,10 @@ public class ExecuteAutoSQL
private List<int> serie2IDs;
private List<int> serie3IDs;
- public ExecuteAutoSQL(string name, ExecuteAuto.ModeTypes mode, string description,
+ public ExecuteAutoSQL(int uniqueID, string name, ExecuteAuto.ModeTypes mode, string description,
List<int> serie1IDs, List<int> serie2IDs, List<int> serie3IDs)
{
+ this.uniqueID = uniqueID;
this.name = name;
this.mode = mode;
this.description = description;
@@ -200,7 +202,9 @@ public class ExecuteAutoSQL
return new string [] { name, mode.ToString(), description,
serieIDsToStrName(serie1IDs, jumpTypes),
serieIDsToStrName(serie2IDs, jumpTypes),
- serieIDsToStrName(serie3IDs, jumpTypes) };
+ serieIDsToStrName(serie3IDs, jumpTypes),
+ uniqueID.ToString()
+ };
}
~ExecuteAutoSQL() {}
diff --git a/src/gui/executeAuto.cs b/src/gui/executeAuto.cs
index 2c2320d..779b194 100644
--- a/src/gui/executeAuto.cs
+++ b/src/gui/executeAuto.cs
@@ -177,9 +177,12 @@ public class ExecuteAutoWindow
}
}
+ int store_load_uniqueID_col = 6;
private void createTreeviewLoad() {
- store_load = new TreeStore(typeof (string), typeof (string), typeof(string), //name, mode,
desc
- typeof (string), typeof (string), typeof (string)); //serie1
jumps, serie2 jumps, serie3jumps
+ store_load = new TreeStore(
+ typeof (string), typeof (string), typeof(string), //name, mode, desc
+ typeof (string), typeof (string), typeof (string), //serie1 jumps, serie2
jumps, serie3jumps
+ typeof (string)); //uniqueID (hidden)
treeview_load.Model = store_load;
treeview_load.HeadersVisible=true;
@@ -191,6 +194,7 @@ public class ExecuteAutoWindow
UtilGtk.CreateCols(treeview_load, store_load, "Tests (1)", i++, true);
UtilGtk.CreateCols(treeview_load, store_load, "Tests (2)", i++, true);
UtilGtk.CreateCols(treeview_load, store_load, "Tests (3)", i++, true);
+ UtilGtk.CreateCols(treeview_load, store_load, "uniqueID", store_load_uniqueID_col, false);
treeview_load.Selection.Changed += onLoadSelectionEntry;
}
@@ -228,7 +232,32 @@ public class ExecuteAutoWindow
button_next.Activate();
}
}
+
+ private void on_treeview_load_button_release_event (object o, ButtonReleaseEventArgs args) {
+ Gdk.EventButton e = args.Event;
+ Gtk.TreeView myTv = (Gtk.TreeView) o;
+ if (e.Button == 3) {
+ Menu myMenu = new Menu ();
+ Gtk.MenuItem myItem;
+
+ myItem = new MenuItem (Catalog.GetString("Delete selected"));
+ myItem.Activated += on_delete_selected_row_clicked;
+ myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+ myMenu.Popup();
+ myMenu.ShowAll();
+ }
+ }
+ private void on_delete_selected_row_clicked (object o, EventArgs args) {
+ int uniqueID = UtilGtk.GetSelectedRowUniqueID(
+ treeview_load, store_load, store_load_uniqueID_col);
+
+ if(uniqueID > 0) {
+ Sqlite.Delete(false, Constants.ExecuteAutoTable, uniqueID);
+ store_load = UtilGtk.RemoveRow(treeview_load, store_load);
+ }
+ }
private void initializeShowJustOrder(int rowNumber) {
@@ -370,7 +399,7 @@ public class ExecuteAutoWindow
private void on_button_save_clicked(object o, EventArgs args)
{
- ExecuteAutoSQL eaSQL = new ExecuteAutoSQL(entry_save_name.Text.ToString(), mode,
entry_save_description.Text.ToString(),
+ ExecuteAutoSQL eaSQL = new ExecuteAutoSQL(-1, entry_save_name.Text.ToString(), mode,
entry_save_description.Text.ToString(),
getTrComboInts(treeviewSerie1Array), getTrComboInts(treeviewSerie2Array),
getTrComboInts(treeviewSerie3Array));
bool saved = eaSQL.SaveToSQL();
diff --git a/src/sqlite/executeAuto.cs b/src/sqlite/executeAuto.cs
index a42ac7b..a5a6132 100644
--- a/src/sqlite/executeAuto.cs
+++ b/src/sqlite/executeAuto.cs
@@ -93,8 +93,9 @@ class SqliteExecuteAuto : Sqlite
//ArrayList sequences = new ArrayList();
int i;
while(reader.Read()) {
- i=1; //start at name
+ i=0;
ExecuteAutoSQL eaSQL = new ExecuteAutoSQL(
+ Convert.ToInt32(reader[i++].ToString()), //uniqueID
reader[i++].ToString(), //name
(ExecuteAuto.ModeTypes) Enum.Parse(typeof(ExecuteAuto.ModeTypes),
reader[i++].ToString()), //mode
reader[i++].ToString(), //description
diff --git a/src/utilGtk.cs b/src/utilGtk.cs
index 1154c54..a68e122 100644
--- a/src/utilGtk.cs
+++ b/src/utilGtk.cs
@@ -216,6 +216,16 @@ public class UtilGtk
return (val1-val2);
}
+ public static int GetSelectedRowUniqueID (Gtk.TreeView tv, Gtk.TreeStore store, int uniqueIDcol) {
+ TreeModel model;
+ TreeIter iter1;
+
+ if (tv.Selection.GetSelected (out model, out iter1)) {
+ return Convert.ToInt32(model.GetValue(iter1, uniqueIDcol));
+ }
+ return -1;
+ }
+
public static Gtk.TreeStore RemoveRow (Gtk.TreeView tv, Gtk.TreeStore store) {
TreeModel model;
TreeIter iter1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]