[chronojump] Doing 695726. Change person in show curves done
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Doing 695726. Change person in show curves done
- Date: Mon, 1 Apr 2013 17:52:16 +0000 (UTC)
commit a0dcb8db9149b7dab1d655c4d0593cf741a17b2a
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Apr 1 19:51:16 2013 +0200
Doing 695726. Change person in show curves done
glade/chronojump.glade | 52 +++++++++++++++++++++++++++++++++++++++++
src/constants.cs | 2 +-
src/encoder.cs | 31 ++++++++++++++++++++++++
src/gui/encoder.cs | 34 +++++++++++++++++++++++++++
src/gui/genericWindow.cs | 58 +++++++++++++++++++++++++++++++++++++++++++++-
src/util.cs | 11 ++++++++
6 files changed, 186 insertions(+), 2 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index ca3cf3f..98fa147 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -21946,6 +21946,58 @@ comments</property>
<property name="position">8</property>
</packing>
</child>
+ <child>
+ <widget class="GtkHBox" id="hbox_combo_full_line">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <widget class="GtkLabel" id="hbox_combo_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="hbox_combo_button">
+ <property name="label">gtk-apply</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">9</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
diff --git a/src/constants.cs b/src/constants.cs
index b8516ab..3172ac2 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -537,7 +537,7 @@ public class Constants
//heightmetric contains 2 spins
public enum GenericWindowShow {
- ENTRY, ENTRY2, ENTRY3, SPININT, SPINDOUBLE, HEIGHTMETRIC, COMBOALLNONESELECTED, TEXTVIEW,
TREEVIEW
+ ENTRY, ENTRY2, ENTRY3, SPININT, SPINDOUBLE, HEIGHTMETRIC, COMBO, COMBOALLNONESELECTED,
TEXTVIEW, TREEVIEW
}
public const string PrefVersionAvailable = "versionAvailable";
diff --git a/src/encoder.cs b/src/encoder.cs
index 94cef8f..1dc0f37 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -330,6 +330,37 @@ public class EncoderSQL
return str;
}
+ //uniqueID:name
+ public void ChangePerson(string newIDAndName) {
+ int newPersonID = Util.FetchID(newIDAndName);
+ string newPersonName = Util.FetchName(newIDAndName);
+ string newFilename = filename;
+
+ personID = newPersonID;
+
+ /*
+ * this can fail because person name can have an "-"
+ string [] filenameParts = filename.Split(new char[] {'-'});
+ filenameParts[0] = newPersonID.ToString();
+ filenameParts[1] = newPersonName;
+ //the rest will be the same: curveID, timestamp, extension
+ filename = Util.StringArrayToString(filenameParts, "-");
+ */
+
+ int nameStarts = newFilename.IndexOf("-") + 1;
+ int nameEnds = newFilename.IndexOf("-" + uniqueID, nameStarts);
+ newFilename = newFilename.Remove(0, nameEnds);
+ newFilename = newFilename.Insert(0, newPersonID + "-" + newPersonName);
+ Log.WriteLine(newFilename);
+
+ bool success = false;
+ success = Util.FileMove(url, filename, newFilename);
+ if(success)
+ filename = newFilename;
+
+ //SqliteUpdate
+ SqliteEncoder.Update(false, this);
+ }
}
public class EncoderPersonCurvesInDB
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index cf5a660..56e8bf7 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -430,6 +430,7 @@ public partial class ChronoJumpWindow
ArrayList bigArray = new ArrayList();
ArrayList a1 = new ArrayList();
ArrayList a2 = new ArrayList();
+ ArrayList a3 = new ArrayList();
//0 is the widgget to show; 1 is the editable; 2 id default value
a1.Add(Constants.GenericWindowShow.COMBOALLNONESELECTED); a1.Add(true); a1.Add("ALL");
@@ -438,6 +439,9 @@ public partial class ChronoJumpWindow
a2.Add(Constants.GenericWindowShow.TREEVIEW); a2.Add(true); a2.Add("");
bigArray.Add(a2);
+ a3.Add(Constants.GenericWindowShow.COMBO); a3.Add(true); a3.Add("");
+ bigArray.Add(a3);
+
//add exercises to the combo (only the exercises done, and only unique)
ArrayList encoderExercisesNames = new ArrayList();
foreach(EncoderSQL es in data) {
@@ -452,12 +456,25 @@ public partial class ChronoJumpWindow
genericWin.AddOptionsToComboCheckBoxesOptions(encoderExercisesNames);
genericWin.CreateComboCheckBoxes();
genericWin.MarkActiveCurves(checkboxes);
+
+ //find all persons in current session
+ ArrayList personsPre =
SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID);
+ string [] persons = new String[personsPre.Count];
+ count = 0;
+ foreach (Person p in personsPre)
+ persons[count++] = p.UniqueID.ToString() + ":" + p.Name;
+ genericWin.SetComboValues(persons, currentPerson.UniqueID + ":" + currentPerson.Name);
+ genericWin.SetComboLabel(Catalog.GetString("Change the owner of selected curve") +
+ " (" + Catalog.GetString("code") + ":" + Catalog.GetString("name") + ")");
+ genericWin.ShowCombo(false);
+
genericWin.ShowButtonCancel(false);
genericWin.SetButtonAcceptSensitive(true);
genericWin.SetButtonCancelLabel(Catalog.GetString("Close"));
//manage selected, unselected curves
genericWin.Button_accept.Clicked += new EventHandler(on_encoder_show_curves_done);
genericWin.Button_row_edit.Clicked += new EventHandler(on_encoder_show_curves_row_edit);
+ genericWin.Button_row_edit_apply.Clicked += new
EventHandler(on_encoder_show_curves_row_edit_apply);
genericWin.Button_row_delete.Clicked += new EventHandler(on_encoder_show_curves_row_delete);
//used when we don't need to read data,
@@ -507,6 +524,23 @@ public partial class ChronoJumpWindow
protected void on_encoder_show_curves_row_edit (object o, EventArgs args) {
Log.WriteLine("row edit at show curves");
Log.WriteLine(genericWin.TreeviewSelectedUniqueID.ToString());
+ genericWin.ShowCombo(true);
+ }
+
+ protected void on_encoder_show_curves_row_edit_apply (object o, EventArgs args) {
+ Log.WriteLine("row edit apply at show curves");
+ Log.WriteLine("new person: " + genericWin.GetComboSelected);
+
+ int newPersonID = Util.FetchID(genericWin.GetComboSelected);
+ if(newPersonID != currentPerson.UniqueID) {
+ int curveID = genericWin.TreeviewSelectedUniqueID;
+ EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, curveID, 0, 0, "",
false)[0];
+
+ eSQL.ChangePerson(genericWin.GetComboSelected);
+ genericWin.RemoveSelectedRow();
+ }
+
+ genericWin.ShowCombo(false);
}
protected void on_encoder_show_curves_row_delete (object o, EventArgs args) {
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index 325645e..adaf238 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -43,6 +43,14 @@ public class GenericWindow
[Widget] Gtk.SpinButton spin_double;
[Widget] Gtk.Box hbox_height_metric;
+
+ //generic combo
+ [Widget] Gtk.Box hbox_combo_full_line;
+ [Widget] Gtk.Label hbox_combo_label;
+ [Widget] Gtk.Box hbox_combo;
+ [Widget] Gtk.ComboBox combo;
+ [Widget] Gtk.Button hbox_combo_button;
+
[Widget] Gtk.Box hbox_all_none_selected;
[Widget] Gtk.Box hbox_combo_all_none_selected;
[Widget] Gtk.ComboBox combo_all_none_selected;
@@ -144,6 +152,7 @@ public class GenericWindow
hbox_spin_int.Hide();
spin_double.Hide();
hbox_height_metric.Hide();
+ hbox_combo_full_line.Hide();
hbox_all_none_selected.Hide();
hbox_combo_all_none_selected.Hide();
scrolled_window_textview.Hide();
@@ -181,6 +190,12 @@ public class GenericWindow
else if(stuff == Constants.GenericWindowShow.HEIGHTMETRIC) {
hbox_height_metric.Show();
}
+ else if(stuff == Constants.GenericWindowShow.COMBO) {
+ /*
+ hbox_combo.Show();
+ combo.Show();
+ */
+ }
else if(stuff == Constants.GenericWindowShow.COMBOALLNONESELECTED) {
//createComboCheckBoxes();
//combo_all_none_selected.Active =
@@ -210,6 +225,13 @@ public class GenericWindow
spin_double.Show();
else if(stuff == Constants.GenericWindowShow.HEIGHTMETRIC)
hbox_height_metric.Show();
+ else if(stuff == Constants.GenericWindowShow.COMBO) {
+ //do later, we need to create them first
+ /*
+ hbox_combo.Show();
+ combo.Show();
+ */
+ }
else if(stuff == Constants.GenericWindowShow.TEXTVIEW)
scrolled_window_textview.Show();
else //if(stuff == Constants.GenericWindowShow.TREEVIEW)
@@ -231,6 +253,24 @@ public class GenericWindow
spin_int.SetRange(min, max);
}
+ public void SetComboValues(string [] values, string current) {
+ combo = ComboBox.NewText ();
+ UtilGtk.ComboUpdate(combo, values, "");
+
+ hbox_combo.PackStart(combo, true, true, 0);
+ hbox_combo.ShowAll();
+ combo.Sensitive = true;
+
+ combo.Active = UtilGtk.ComboMakeActive(values, current);
+ }
+ public void SetComboLabel(string l) {
+ hbox_combo_label.Text = l;
+ }
+ public void ShowCombo(bool show) {
+ hbox_combo_full_line.Visible = show;
+ }
+
+
protected string [] comboCheckBoxesOptions = {
Catalog.GetString("All"),
Catalog.GetString("None"),
@@ -409,6 +449,8 @@ Log.WriteLine("aaaaaaaaaaaaaaaa2");
SetButtonAcceptSensitive(true);
else
SetButtonAcceptSensitive(false);
+
+ ShowCombo(false);
}
public int TreeviewSelectedRowID() {
@@ -511,6 +553,7 @@ Log.WriteLine((string) store.GetValue (iter, 3));
treeviewContextMenu();
}
}
+ ShowCombo(false);
}
private void treeviewContextMenu() {
@@ -534,6 +577,10 @@ Log.WriteLine((string) store.GetValue (iter, 3));
button_row_edit.Click();
}
+ public void RemoveSelectedRow () {
+ store = UtilGtk.RemoveRow(treeview, store);
+ }
+
private void on_delete_selected_clicked (object o, EventArgs args) {
//remove selected row from treeview
store = UtilGtk.RemoveRow(treeview, store);
@@ -598,11 +645,16 @@ Log.WriteLine((string) store.GetValue (iter, 3));
get { return button_row_edit; }
}
+ public Button Button_row_edit_apply {
+ set { hbox_combo_button = value; }
+ get { return hbox_combo_button; }
+ }
+
public Button Button_row_delete {
set { button_row_delete = value; }
get { return button_row_delete; }
}
-
+
public string EntrySelected {
set { entry.Text = value; }
get { return entry.Text.ToString(); }
@@ -642,6 +694,10 @@ Log.WriteLine((string) store.GetValue (iter, 3));
public string TextviewSelected {
get { return Util.RemoveTab(textview.Buffer.Text); }
}
+
+ public string GetComboSelected {
+ get { return UtilGtk.ComboGetActive(combo); }
+ }
~GenericWindow() {}
diff --git a/src/util.cs b/src/util.cs
index 343356e..4d78943 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1050,6 +1050,17 @@ public class Util
return false;
}
+ public static bool FileMove(string path, string filenameOrigin, string filenameDestination) {
+ try {
+ File.Move(
+ path + Path.DirectorySeparatorChar + filenameOrigin,
+ path + Path.DirectorySeparatorChar + filenameDestination
+ );
+ return true;
+ } catch {}
+ return false;
+ }
+
public static bool FileExists(string fileName){
return File.Exists(fileName);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]