[chronojump] add/edit window tags can be created
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] add/edit window tags can be created
- Date: Tue, 1 Dec 2020 11:27:50 +0000 (UTC)
commit e3074cf80fdf613ffcf80d3af0268ef570f77e2c
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Dec 1 12:04:09 2020 +0100
add/edit window tags can be created
src/gui/app1/session/tagSessionSelect.cs | 62 +++++++++++++++++++++++++++-----
src/gui/genericWindow.cs | 2 +-
src/tagSession.cs | 9 +++++
3 files changed, 64 insertions(+), 9 deletions(-)
---
diff --git a/src/gui/app1/session/tagSessionSelect.cs b/src/gui/app1/session/tagSessionSelect.cs
index 398131bd..14791e40 100644
--- a/src/gui/app1/session/tagSessionSelect.cs
+++ b/src/gui/app1/session/tagSessionSelect.cs
@@ -110,10 +110,22 @@ public class TagSessionSelect
bigArray = new ArrayList();
ArrayList a1 = new ArrayList();
+ ArrayList a2 = new ArrayList();
+ ArrayList a3 = new ArrayList();
+ ArrayList a4 = new ArrayList();
//0 is the widgget to show; 1 is the editable; 2 id default value
- a1.Add(Constants.GenericWindowShow.TREEVIEW); a1.Add(true); a1.Add("");
+ a1.Add(Constants.GenericWindowShow.ENTRY2); a1.Add(true); a1.Add("");
bigArray.Add(a1);
+
+ a2.Add(Constants.GenericWindowShow.BUTTONMIDDLE); a2.Add(true); a2.Add("");
+ bigArray.Add(a2);
+
+ a3.Add(Constants.GenericWindowShow.LABELBEFORETEXTVIEWTREEVIEW); a3.Add(true); a3.Add("");
+ bigArray.Add(a3);
+
+ a4.Add(Constants.GenericWindowShow.TREEVIEW); a4.Add(true); a4.Add("");
+ bigArray.Add(a4);
}
private void createGenericWindow()
@@ -123,6 +135,11 @@ public class TagSessionSelect
genericWin.SetTreeview(columnsString, true, allTags_listPrint, new ArrayList(),
GenericWindow.EditActions.EDITDELETE, false);
+
+ genericWin.LabelEntry2 = Catalog.GetString("Create new tag");
+ genericWin.SetButtonMiddleLabel(Catalog.GetString("Create"));
+ genericWin.LabelBeforeTextViewTreeView = Catalog.GetString("Select tags for this session");
+
genericWin.ShowEditRow(false);
genericWin.HideEditRowCombo();
genericWin.SetLabelComment(Catalog.GetString("Change name"));
@@ -147,6 +164,7 @@ public class TagSessionSelect
genericWin.Button_accept.Clicked -= new EventHandler(on_tag_session_win_done);
genericWin.Button_accept.Clicked += new EventHandler(on_tag_session_win_done);
+ genericWin.Button_middle.Clicked += new EventHandler(on_tag_session_win_tag_added);
genericWin.Button_row_edit.Clicked += new EventHandler(on_tag_session_win_row_edit);
genericWin.Button_row_edit_apply.Clicked += new
EventHandler(on_tag_session_win_row_edit_apply);
genericWin.Button_row_delete.Clicked += new
EventHandler(on_tag_session_win_row_delete_prequestion);
@@ -155,6 +173,7 @@ public class TagSessionSelect
private void removeCallbacks() {
genericWin.Button_accept.Clicked -= new EventHandler(on_tag_session_win_done);
+ genericWin.Button_middle.Clicked -= new EventHandler(on_tag_session_win_tag_added);
genericWin.Button_row_edit.Clicked -= new EventHandler(on_tag_session_win_row_edit);
genericWin.Button_row_edit_apply.Clicked -= new
EventHandler(on_tag_session_win_row_edit_apply);
genericWin.Button_row_delete.Clicked -= new
EventHandler(on_tag_session_win_row_delete_prequestion);
@@ -167,6 +186,8 @@ public class TagSessionSelect
//get selected/deselected rows
checkboxes = genericWin.GetColumn(1, false);
+ //need to refresh allTags_list because tasks could have been added/deleted
+ allTags_list = SqliteTagSession.Select(false, -1);
//update on database the what has been selected/deselected
//doing it as a transaction: FAST
SqliteSessionTagSession.UpdateTransaction(currentSessionID, allTags_list,
@@ -175,6 +196,32 @@ public class TagSessionSelect
FakeButtonDone.Click();
}
+ private void on_tag_session_win_tag_added (object o, EventArgs args)
+ {
+ string nameNew = genericWin.Entry2Selected;
+ if(TagSession.CheckIfTagNameExists(false, nameNew))
+ {
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ string.Format("Error: a tag named: '{0}' already exists.", nameNew));
+ return;
+ }
+
+ TagSession ts = new TagSession(-1, nameNew, "#000000", "");
+ int uniqueID = ts.InsertSQL(false);
+
+ /*
+ //update treeview
+ genericWin.on_edit_selected_done_update_treeview();
+ */
+ genericWin.Row_add(new string[] { uniqueID.ToString(), "", ts.Name }, false );
+ //aixo no acaba d'anar bé pq el seu checkbox no va després, potser el millor és refer el
treeview, a veure que es fa al delete
+ //i si no el refa, com a mínim que afegeixi la row en ordre alfabètic
+
+//TODO: Add button should only be active when entry2 changed, can check "on_entries_changed"
+
+//TODO: and has to select the new tag, and hide the edit row if visible
+ }
+
private void on_tag_session_win_row_edit (object o, EventArgs args)
{
genericWin.ShowEditRow(true);
@@ -187,7 +234,6 @@ public class TagSessionSelect
//1) select set
int id = genericWin.TreeviewSelectedUniqueID;
- ArrayList tsArray = SqliteTagSession.Select(true, -1);
TagSession ts = (TagSession) SqliteTagSession.Select(true, id)[0];
//2) if changed comment, update SQL, and update treeview
@@ -195,12 +241,12 @@ public class TagSessionSelect
string nameNew = Util.RemoveTildeAndColonAndDot(genericWin.EntryEditRow);
if(nameNew != ts.Name)
{
- foreach(TagSession ts2 in tsArray)
- if(ts2.Name == nameNew)
- {
- new DialogMessage(Constants.MessageTypes.WARNING,
string.Format("Error: a tag named: '{0}' already exists.", nameNew));
- return;
- }
+ if(TagSession.CheckIfTagNameExists(true, nameNew))
+ {
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ string.Format("Error: a tag named: '{0}' already exists.",
nameNew));
+ return;
+ }
ts.Name = nameNew;
Sqlite.Update(true, Constants.TagSessionTable, "name",
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index c9760781..d03d0472 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -854,7 +854,7 @@ public class GenericWindow
if(! Util.FoundInArrayList(nonSensitiveRows,
Convert.ToInt32(args.Path))) {
bool val = (bool) store.GetValue (iter, column);
- //Log.WriteLine (string.Format("toggled {0} with value {1}", args.Path,
!val));
+ LogB.Information (string.Format("toggled {0} with value {1}", args.Path,
!val));
store.SetValue (iter, column, !val);
diff --git a/src/tagSession.cs b/src/tagSession.cs
index 17272a26..3aa3bad3 100644
--- a/src/tagSession.cs
+++ b/src/tagSession.cs
@@ -90,6 +90,15 @@ public class TagSession
return list;
}
+ public static bool CheckIfTagNameExists(bool dbconOpened, string name)
+ {
+ foreach(TagSession ts in SqliteTagSession.Select(dbconOpened, -1))
+ if(ts.Name == name)
+ return true;
+
+ return false;
+ }
+
public static string GetActiveTagNamesOfThisSession(int sessionID)
{
string str = "";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]