[chronojump] Updates on changeDB
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Updates on changeDB
- Date: Mon, 13 Jun 2022 16:39:05 +0000 (UTC)
commit 34b77789a3674128c2b148436fa0e859e0d9075d
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Jun 13 18:38:47 2022 +0200
Updates on changeDB
src/config.cs | 19 +++++++++++--------
src/gui/networks.cs | 39 ++++++++++++++++++++++++++-------------
src/sqlite/main.cs | 4 ++--
src/util.cs | 6 +++---
4 files changed, 42 insertions(+), 26 deletions(-)
---
diff --git a/src/config.cs b/src/config.cs
index a8e7949c3..6df36223b 100644
--- a/src/config.cs
+++ b/src/config.cs
@@ -29,7 +29,7 @@ public class Config
public static bool UseSystemColor; //do nothing at all
public static Gdk.Color ColorBackground;
public static bool ColorBackgroundIsDark;
- public static string DataDirStatic = ""; //works even with spaces in name
+ public static string LastDBFullPathStatic = ""; //works even with spaces in name
public enum SessionModeEnum { STANDARD, UNIQUE, MONTHLY }
@@ -61,8 +61,9 @@ public class Config
public bool LowHeight; //devices with less than 500 px vertical, like Odroid Go Super
public bool LowCPU; //workaround to not show realtime graph on force sensor capture (until its
optimized)
public bool GuiTest;
- public bool CanOpenExternalDataDir;
- public string DataDir = ""; //on chronojump-networks admin to replace GetLocalDataDir (), think if
Import has to be disabled
+ public bool CanOpenExternalDB;
+ public string ExternalDBDefaultPath = ""; //on chronojump-networks admin to replace GetLocalDataDir
(), think if Import has to be disabled
+ public string LastDBFullPath = ""; //on chronojump-networks admin to replace GetLocalDataDir (),
think if Import has to be disabled
/*
* unused because the default serverURL chronojump.org is ok:
@@ -149,15 +150,17 @@ public class Config
LowCPU = true;
else if(parts[0] == "GuiTest" && Util.StringToBool(parts[1]))
GuiTest = true;
- else if(parts[0] == "CanOpenExternalDataDir" &&
Util.StringToBool(parts[1]))
- CanOpenExternalDataDir = true;
- else if(parts[0] == "DataDir" && parts[1] != "")
+ else if(parts[0] == "CanOpenExternalDB" &&
Util.StringToBool(parts[1]))
+ CanOpenExternalDB = true;
+ else if(parts[0] == "ExternalDBDefaultPath" && parts[1] != "")
+ ExternalDBDefaultPath = parts[1]; //works even with spaces on
name
+ else if(parts[0] == "LastDBFullPath" && parts[1] != "")
{
- DataDir = parts[1]; //works even with spaces on name
+ LastDBFullPath = parts[1]; //works even with spaces on name
/*
DataDirStatic is assigned later to not be active on
chronojump.cs,
start when gui is started, to not mess with
runningFileName and others
- DataDirStatic = parts[1]; //called from Util.GetLocalDataDir
+ LastDBFullPathStatic = parts[1]; //called from
Util.GetLocalDataDir
*/
}
} while(true);
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 01f7c47a9..6cc453b73 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2004-2021 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2022 Xavier de Blas <xaviblas gmail com>
*/
@@ -284,13 +284,13 @@ public partial class ChronoJumpWindow
SqliteJson.UploadExhibitionTestsPending();
}
- if (configChronojump.CanOpenExternalDataDir)
+ if (configChronojump.CanOpenExternalDB)
{
frame_database.Visible = true;
button_menu_database.Visible = true;
- if (configChronojump.DataDir != "")
- databaseChange ();
+ if (configChronojump.LastDBFullPath != "")
+ databaseChange (false);
}
configDo();
@@ -360,12 +360,16 @@ public partial class ChronoJumpWindow
rfidProcessCancel = true;
}
- private void databaseChange ()
+ // updateConfigFile only if selected a new db by user: on_button_database_change_clicked ()
+ private void databaseChange (bool updateConfigFile)
{
+ //TODO: need to close session first
+
+
Sqlite.DisConnect ();
//called from Util.GetLocalDataDir
- Config.DataDirStatic = configChronojump.DataDir;
+ Config.LastDBFullPathStatic = configChronojump.LastDBFullPath;
Sqlite.SetHome ();
Sqlite.Connect ();
@@ -373,32 +377,41 @@ public partial class ChronoJumpWindow
//this updated if needed:
Sqlite.ConvertToLastChronojumpDBVersion ();
- label_current_database.Text = "<b>" + Util.GetLastPartOfPath (configChronojump.DataDir) +
"</b>";
+ label_current_database.Text = "<b>" + Util.GetLastPartOfPath (
+ configChronojump.LastDBFullPath) + "</b>";
+
label_current_database.UseMarkup = true;
- label_current_database.TooltipText = configChronojump.DataDir;
+ label_current_database.TooltipText = configChronojump.LastDBFullPath;
+
+ /*
+ //TODO
+ if (updateConfigFile)
+ */
}
Gtk.FileChooserDialog database_fc;
private void on_button_database_change_clicked (object o, EventArgs args)
{
- database_fc = new Gtk.FileChooserDialog("Use database:",
+ database_fc = new Gtk.FileChooserDialog("Select folder:",
app1,
FileChooserAction.SelectFolder,
Catalog.GetString("Cancel"),ResponseType.Cancel,
Catalog.GetString("Select"),ResponseType.Accept
);
- //database_fc.SetCurrentFolder(whatever);
+
+ if (configChronojump.ExternalDBDefaultPath != "")
+ database_fc.SetCurrentFolder (configChronojump.ExternalDBDefaultPath);
if (database_fc.Run() == (int)ResponseType.Accept)
{
// 1) update to config file (to be opened again on next boot)
- // 2) reassing configChronojump.DataDir
- configChronojump.DataDir = database_fc.Filename;
+ // 2) reassing configChronojump.LastDBFullPath
+ configChronojump.LastDBFullPath = database_fc.Filename;
// 2) open database
//TODO: think where to put a try/catch, eg if there is no database file, or search
database/chronojump.db before
- databaseChange ();
+ databaseChange (true);
}
database_fc.Hide ();
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index b2839b293..179d4f9ac 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -319,8 +319,8 @@ class Sqlite
}
- //used on Chronojump-Networks admin (if Config.DataDir is != "")
- //Config.DataDirStatic has been changed before
+ //used on Chronojump-Networks admin (if Config.LastDBFullPath is != "")
+ //Config.LastDBFullPathStatic has been changed before
public static void SetHome ()
{
home = Util.GetDatabaseDir ();
diff --git a/src/util.cs b/src/util.cs
index 53b1d2fe0..eaadb1e52 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -969,13 +969,13 @@ public class Util
//this will check if any config path is present
public static string GetLocalDataDir (bool withFinalSeparator)
{
- if (Config.DataDirStatic == "")
+ if (Config.LastDBFullPathStatic == "")
return UtilAll.GetDefaultLocalDataDir (withFinalSeparator); //this can be checked by
Mini
else {
if (withFinalSeparator)
- return Config.DataDirStatic + Path.DirectorySeparatorChar;
+ return Config.LastDBFullPathStatic + Path.DirectorySeparatorChar;
else
- return Config.DataDirStatic;
+ return Config.LastDBFullPathStatic;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]