diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-12-27 19:41:33 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-12-27 19:41:33 +0100 |
| commit | cb6fbd18f374773a6cd6ea1db42f6d6ff6147a1e (patch) | |
| tree | 4c3539f63769fc2f62e0e113ac54f0f641091c54 /src/base_tab/BaseImportTab.cpp | |
| parent | 32fdf9272e1a94f8c51274a1758f4feae555341a (diff) | |
Improve database tab
Diffstat (limited to 'src/base_tab/BaseImportTab.cpp')
| -rw-r--r-- | src/base_tab/BaseImportTab.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/base_tab/BaseImportTab.cpp b/src/base_tab/BaseImportTab.cpp index 2daa125..b43cb54 100644 --- a/src/base_tab/BaseImportTab.cpp +++ b/src/base_tab/BaseImportTab.cpp @@ -2,9 +2,22 @@ #include <algorithm> #include "gamebase/GameBase.hpp" +#define NOTIFY_MANAGE_TAB() \ +{ \ + wxCommandEvent e(REFRESH_MANAGE_TAB,GetId()); \ + ProcessEvent(e); \ +} + +wxDECLARE_EVENT(REFRESH_MANAGE_TAB, wxCommandEvent); + BaseImportTab::BaseImportTab(wxFrame *parent, std::shared_ptr<GameBase> db, TabInfos *main_tab): TabBase_TabImport(parent), main_tab(main_tab), base(db) { + // Init counters + import_ndb=0; + import_ngames=0; + import_nselect=0; + glm=std::make_shared<GameListManager>(game_list); RefreshImportLists(); RefreshPendingImports(); @@ -27,17 +40,19 @@ void BaseImportTab::OnImportDatabase(wxCommandEvent &event){ } void BaseImportTab::RefreshPendingImports(){ - int ngames=games_to_import.size(); - int ndb=databases_to_import.size(); - int nbselect=0; + import_ndb=databases_to_import.size(); + import_ngames=games_to_import.size(); + import_nselect=0; for (auto it = selected_games_to_import.begin(); it != selected_games_to_import.end(); it++){ - nbselect+=it->second.size(); + import_nselect+=it->second.size(); } pending_imports->Clear(); - if(ngames+ndb+nbselect>0){ - pending_imports->AppendText(" Pending imports: "+std::to_string(ngames+nbselect)+" games and "+std::to_string(ndb)+" databases"); + if(import_ndb+import_ngames+import_nselect>0){ + pending_imports->AppendText(" Pending imports: "+std::to_string(import_ngames+import_nselect)+" games and "+std::to_string(import_ndb)+" databases"); }else pending_imports->SetHint("No pending imports"); + + NOTIFY_MANAGE_TAB(); } void BaseImportTab::RefreshImportLists(){ @@ -116,6 +131,7 @@ void BaseImportTab::Reset(std::shared_ptr<GameBase> base){ this->selected_games_to_import.clear(); glm->Clear(); RefreshPendingImports(); + NOTIFY_MANAGE_TAB(); } std::vector<std::shared_ptr<Game>> BaseImportTab::GetGameToImport(){ |
