diff options
Diffstat (limited to 'src/base_tab/BaseTab.cpp')
| -rw-r--r-- | src/base_tab/BaseTab.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/base_tab/BaseTab.cpp b/src/base_tab/BaseTab.cpp index 8b58ca9..6866da1 100644 --- a/src/base_tab/BaseTab.cpp +++ b/src/base_tab/BaseTab.cpp @@ -1,12 +1,11 @@ #include "BaseTab.hpp" -#include "AppendGameDialog.hpp" #include <wx/filename.h> BaseTab::BaseTab(wxFrame *parent, std::string base_file) : TabBase(parent), TabInfos(TabInfos::BASE), base_file(base_file){ // First open the database - OpenDatabase(base_file); + base=OpenDatabase(base_file); // Games tab games_tab=new BaseGameTab((wxFrame *)notebook,base,this); @@ -45,34 +44,23 @@ void BaseTab::Refresh(){ SetLabel(wxFileName(base->GetFilePath()).GetName()+" [DB]"); // Propagated to MainWindow tab title automatically by wxWidget } -void BaseTab::OpenDatabase(std::string dbpath) { - wxFileName file(dbpath); - wxString ext = file.GetExt().Lower(); - wxLogDebug("Here"); - if (ext == "pgn") { - if(!file.Exists()) - PGNGameBase::CreateDatabaseFile(dbpath); - base.reset(); - base = std::shared_ptr<GameBase>(new PGNGameBase(dbpath)); - } -} - void BaseTab::OnSave(wxCommandEvent &event) { - // Build new games + SHOW_DIALOG_BUSY("Apply all changes. Take a coffee, this process can takes time..."); + // First import games std::vector<std::shared_ptr<Game>> new_games=games_tab->GetEditedGames(); for(auto g: import_tab->GetGameToImport()){ new_games.push_back(g); } - SHOW_DIALOG_BUSY("Apply all changes. Take a coffee, this process can takes time..."); base->Save(games_tab->GetDeletedGameIds(), import_tab->GetDatabaseToImport(), new_games); - + // Close all opened games in this database wxCommandEvent closeLinkedTabEvent(CLOSE_LINKED_TAB, GetId()); closeLinkedTabEvent.SetClientData((TabInfos*)this); ProcessEvent(closeLinkedTabEvent); // Reopen the saved database - OpenDatabase(base_file); + base.reset(); + base=OpenDatabase(base_file); games_tab->Reset(base); manage_tab->Reset(base); import_tab->Reset(base); |
