[chronojump/chronojump-importer] Fixes problem when the importer didn't have any path selected: it was showing the current database s



commit ff21604b99f615447630ccdc4a18e92bd167b59f
Author: Carles Pina i Estany <carles pina cat>
Date:   Tue Sep 13 21:16:53 2016 +0100

    Fixes problem when the importer didn't have any path selected: it was showing the current database 
sessions.

 src/gui/session.cs    |   10 +++++++++-
 src/sqlite/session.cs |   14 +++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 71d5a9e..f6c727c 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -737,6 +737,8 @@ public class SessionLoadWindow {
                if (SessionLoadWindowBox == null) {
                        SessionLoadWindowBox = new SessionLoadWindow (parent, type);
                }
+               SessionLoadWindowBox.recreateTreeView("loaded the dialog");
+
                SessionLoadWindowBox.session_load.Show ();
                
                return SessionLoadWindowBox;
@@ -829,7 +831,13 @@ public class SessionLoadWindow {
                if(entry_search_filter.Text.ToString().Length > 0) 
                        filterName = entry_search_filter.Text.ToString();
 
-               SqliteSessionSwitcher sessionSwitcher = new SqliteSessionSwitcher (file_path_import.Text);
+               SqliteSessionSwitcher.DatabaseType databaseType;
+               if (type == WindowType.LOAD_SESSION) {
+                       databaseType = SqliteSessionSwitcher.DatabaseType.STANDARD;
+               } else {
+                       databaseType = SqliteSessionSwitcher.DatabaseType.SPECIFIC;
+               }
+               SqliteSessionSwitcher sessionSwitcher = new SqliteSessionSwitcher (databaseType, 
file_path_import.Text);
                
                string [] mySessions = sessionSwitcher.SelectAllSessions(filterName); //returns a string of 
values separated by ':'
                foreach (string session in mySessions) {
diff --git a/src/sqlite/session.cs b/src/sqlite/session.cs
index 7bcb5e7..f52b669 100644
--- a/src/sqlite/session.cs
+++ b/src/sqlite/session.cs
@@ -29,14 +29,22 @@ using System.Collections.Generic;
 public class SqliteSessionSwitcher
 {
        private string databasePath;
-       public SqliteSessionSwitcher(string databasePath)
+       private DatabaseType type;
+       public enum DatabaseType
        {
+               STANDARD,
+               SPECIFIC
+       };
+       
+       public SqliteSessionSwitcher(DatabaseType type, string databasePath)
+       {
+               this.type = type;
                this.databasePath = databasePath;
        }
 
        public string[] SelectAllSessions(string filterName)
        {
-               if (string.IsNullOrEmpty (databasePath))
+               if (type == DatabaseType.STANDARD)
                {
                        return SqliteSession.SelectAllSessions (filterName);
                }
@@ -68,7 +76,7 @@ public class SqliteSessionSwitcher
 
        public Session Select(string myUniqueID)
        {
-               if (string.IsNullOrEmpty (databasePath))
+               if (type == DatabaseType.STANDARD)
                {
                        return SqliteSession.Select (myUniqueID);
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]