diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-25 14:57:09 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-02-25 14:57:09 +0100 |
| commit | 98488e899a750703562d868d734251cfe032e294 (patch) | |
| tree | 9bd60859300f4d14f00e4c28d8f87e6a5396abb4 /src/base_tab/BaseTab.cpp | |
| parent | cbcc455e339a6fec87f16369e450620ef7692a34 (diff) | |
Enable database export
Diffstat (limited to 'src/base_tab/BaseTab.cpp')
| -rw-r--r-- | src/base_tab/BaseTab.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/base_tab/BaseTab.cpp b/src/base_tab/BaseTab.cpp index 9234a47..f7cf48f 100644 --- a/src/base_tab/BaseTab.cpp +++ b/src/base_tab/BaseTab.cpp @@ -15,6 +15,7 @@ BaseTab::BaseTab(wxFrame *parent, std::string base_file) this->Bind(wxEVT_BUTTON, &BaseTab::OnDelete, this, ID_DELETE_BUTTON); this->Bind(wxEVT_BUTTON, &BaseTab::OnSave, this, ID_SAVE_BUTTON); + this->Bind(wxEVT_BUTTON, &BaseTab::OnExport, this, ID_EXPORT_BUTTON); this->Bind(wxEVT_LIST_ITEM_ACTIVATED, &BaseTab::OnOpenGame, this, wxID_ANY); current_base->SetLabel(base_file); LoadFile(); @@ -65,6 +66,23 @@ void BaseTab::OnOpenGame(wxListEvent &event) { void BaseTab::ApplyPreferences() {} +void BaseTab::OnExport(wxCommandEvent &event) { + wxFileDialog openFileDialog(this, _("Export database"), "", "", + "Database files (*.pgn)|*.pgn", + wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + if (openFileDialog.ShowModal() != wxID_CANCEL) { + std::string path = openFileDialog.GetPath().ToStdString(); + wxFileName file(base_file); + wxString ext = file.GetExt().Lower(); + GameBase *base; + if (ext == "pgn") { + base = new PGNGameBase(path); + base->Save(this->base); + delete base; + } + } +} + void BaseTab::LoadFile() { wxFileName file(base_file); wxString ext = file.GetExt().Lower(); |
