From 1ac96eb13367560b5a58df5daa6cd8e144a21a91 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 14 Jul 2024 15:27:54 +1200 Subject: [PATCH] move filter consts to each db file --- db_bolt.go | 4 ++++ db_sqlite.go | 1 + main.go | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/db_bolt.go b/db_bolt.go index 7167072..ee67ad0 100644 --- a/db_bolt.go +++ b/db_bolt.go @@ -14,6 +14,10 @@ import ( "go.etcd.io/bbolt/version" ) +const ( + boltFilter = "Bolt database|*.db|All files|*.*" +) + type boltLoadedDatabase struct { displayName string path string diff --git a/db_sqlite.go b/db_sqlite.go index 2f1d851..bf50e50 100644 --- a/db_sqlite.go +++ b/db_sqlite.go @@ -14,6 +14,7 @@ import ( const ( sqliteTablesCaption = "Tables" + sqliteFilter = "SQLite database|*.db;*.db3;*.sqlite;*.sqlite3|All files|*.*" ) type sqliteLoadedDatabase struct { diff --git a/main.go b/main.go index dbfa56d..32f986a 100644 --- a/main.go +++ b/main.go @@ -332,7 +332,7 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) { func (f *TMainForm) OnMnuFileBoltNewClick(sender vcl.IObject) { dlg := vcl.NewSaveDialog(f) dlg.SetTitle("Save database as...") - dlg.SetFilter("Bolt database|*.db|All files|*.*") + dlg.SetFilter(boltFilter) ret := dlg.Execute() // Fake blocking if ret { f.boltAddDatabaseFromFile(dlg.FileName(), false) @@ -342,7 +342,7 @@ func (f *TMainForm) OnMnuFileBoltNewClick(sender vcl.IObject) { func (f *TMainForm) OnMnuFileBoltOpenClick(sender vcl.IObject) { dlg := vcl.NewOpenDialog(f) dlg.SetTitle("Select a database file...") - dlg.SetFilter("Bolt database|*.db|All files|*.*") + dlg.SetFilter(boltFilter) ret := dlg.Execute() // Fake blocking if ret { f.boltAddDatabaseFromFile(dlg.FileName(), false) @@ -352,7 +352,7 @@ func (f *TMainForm) OnMnuFileBoltOpenClick(sender vcl.IObject) { func (f *TMainForm) OnMnuFileBoltOpenReadonlyClick(sender vcl.IObject) { dlg := vcl.NewOpenDialog(f) dlg.SetTitle("Select a database file...") - dlg.SetFilter("Bolt database|*.db|All files|*.*") + dlg.SetFilter(boltFilter) ret := dlg.Execute() // Fake blocking if ret { f.boltAddDatabaseFromFile(dlg.FileName(), true) @@ -364,7 +364,7 @@ func (f *TMainForm) OnMnuFileSqliteOpenClick(sender vcl.IObject) { dlg := vcl.NewOpenDialog(f) dlg.SetTitle("Select a database file...") - dlg.SetFilter("SQLite database|*.db;*.db3;*.sqlite;*.sqlite3|All files|*.*") + dlg.SetFilter(sqliteFilter) ret := dlg.Execute() // Fake blocking if ret { f.sqliteAddDatabaseFromFile(dlg.FileName(), cliDriver)