[chronojump] TagSession work correctly on add session
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] TagSession work correctly on add session
- Date: Fri, 4 Dec 2020 15:37:42 +0000 (UTC)
commit 0538028760b54d7555e07107c80575623996a461
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Dec 4 16:35:05 2020 +0100
TagSession work correctly on add session
src/gui/app1/session/addEdit.cs | 15 ++++++++--
src/gui/app1/session/tagSessionSelect.cs | 50 ++++++++++++++++++++++++++++----
2 files changed, 58 insertions(+), 7 deletions(-)
---
diff --git a/src/gui/app1/session/addEdit.cs b/src/gui/app1/session/addEdit.cs
index 3e588dd8..551554af 100644
--- a/src/gui/app1/session/addEdit.cs
+++ b/src/gui/app1/session/addEdit.cs
@@ -545,7 +545,10 @@ public partial class ChronoJumpWindow
tagSessionSelect = new TagSessionSelect();
- tagSessionSelect.PassVariables(currentSession.UniqueID, preferences.askDeletion);
+ if(app1sae_addSession)
+ tagSessionSelect.PassVariables(true, -1, preferences.askDeletion);
+ else
+ tagSessionSelect.PassVariables(false, currentSession.UniqueID,
preferences.askDeletion);
tagSessionSelect.FakeButtonDone.Clicked -= new EventHandler(on_select_tags_clicked_done);
tagSessionSelect.FakeButtonDone.Clicked += new EventHandler(on_select_tags_clicked_done);
@@ -557,7 +560,11 @@ public partial class ChronoJumpWindow
private void on_select_tags_clicked_done (object o, EventArgs args)
{
tagSessionSelect.FakeButtonDone.Clicked -= new EventHandler(on_select_tags_clicked_done);
- app1sae_label_tags_selected.Text =
TagSession.GetActiveTagNamesOfThisSession(currentSession.UniqueID);
+
+ if(app1sae_addSession)
+ app1sae_label_tags_selected.Text = tagSessionSelect.TagsListStringForAddSession;
+ else
+ app1sae_label_tags_selected.Text =
TagSession.GetActiveTagNamesOfThisSession(currentSession.UniqueID);
}
void app1sae_on_button_change_date_clicked (object o, EventArgs args)
@@ -685,6 +692,10 @@ public partial class ChronoJumpWindow
LogB.Information("app1sae_on_button_accept_clicked B");
notebook_supSetOldPage();
LogB.Information("app1sae_on_button_accept_clicked C");
+
+ //tags have not been added yet because there was no sessionID
+ tagSessionSelect.SQLUpdateTransaction(currentSession.UniqueID);
+ LogB.Information("app1sae_on_button_accept_clicked C2");
} else
{
LogB.Information("app1sae_on_button_accept_clicked D");
diff --git a/src/gui/app1/session/tagSessionSelect.cs b/src/gui/app1/session/tagSessionSelect.cs
index 9ce43844..1c3ae4c9 100644
--- a/src/gui/app1/session/tagSessionSelect.cs
+++ b/src/gui/app1/session/tagSessionSelect.cs
@@ -31,6 +31,7 @@ using Mono.Unix;
public class TagSessionSelect
{
//passed variables
+ private bool addSession;
private int currentSessionID;
private bool askDeletion;
@@ -41,11 +42,13 @@ public class TagSessionSelect
private string [] columnsString;
private ArrayList bigArray;
private string [] checkboxes;
+ private string tagsListStringForAddSession;
public Gtk.Button FakeButtonDone;
- public void PassVariables(int currentSessionID, bool askDeletion)
+ public void PassVariables(bool addSession, int currentSessionID, bool askDeletion)
{
+ this.addSession = addSession;
this.currentSessionID = currentSessionID;
this.askDeletion = askDeletion;
@@ -81,7 +84,11 @@ public class TagSessionSelect
private void getData()
{
allTags_list = SqliteTagSession.Select(false, -1);
- tagsActiveThisSession_list = SqliteSessionTagSession.SelectTagsOfASession(false,
currentSessionID);
+
+ if(addSession)
+ tagsActiveThisSession_list = new List<TagSession>();
+ else
+ tagsActiveThisSession_list = SqliteSessionTagSession.SelectTagsOfASession(false,
currentSessionID);
}
private void createBigArray()
@@ -184,6 +191,7 @@ public class TagSessionSelect
private void on_tag_session_win_done (object o, EventArgs args)
{
+ LogB.Information("on_tag_session_win_done");
removeCallbacks();
//get selected/deselected rows
@@ -191,12 +199,39 @@ public class TagSessionSelect
//need to refresh allTags_list because tasks could have been added/deleted
allTags_list = SqliteTagSession.Select(false, -1);
+
+ if(addSession) {
+ int count = 0;
+ string sep = "";
+ tagsListStringForAddSession = "";
+ foreach(TagSession tag in allTags_list)
+ {
+ //LogB.Information("TagSession: " + tag.ToString() + "; checkboxes[count]: "
+ checkboxes[count]);
+ if(checkboxes[count] == "active")
+ {
+ tagsListStringForAddSession += sep + tag.Name;
+ sep = ", ";
+ }
+ count ++;
+ }
+ } else
+ SQLUpdateTransaction(currentSessionID);
+
+ FakeButtonDone.Click();
+ }
+
+ /*
+ this is called on edit session just on close genericWin
+ and on add, when session is added (and there is a sessionID)
+ */
+ public void SQLUpdateTransaction(int sID)
+ {
+ LogB.Information("SQLUpdateTransaction sID: " + sID.ToString());
+
//update on database the what has been selected/deselected
//doing it as a transaction: FAST
- SqliteSessionTagSession.UpdateTransaction(currentSessionID, allTags_list,
+ SqliteSessionTagSession.UpdateTransaction(sID, allTags_list,
tagsActiveThisSession_list, checkboxes);
-
- FakeButtonDone.Click();
}
private void on_tag_session_win_tag_added (object o, EventArgs args)
@@ -282,4 +317,9 @@ public class TagSessionSelect
genericWin.Delete_row_accepted();
}
+
+ public string TagsListStringForAddSession
+ {
+ get { return tagsListStringForAddSession; }
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]