Improve user experience

This commit is contained in:
Loic Guegan 2022-12-28 07:21:30 +01:00
parent 4eeb110f80
commit 214d46b8e2
6 changed files with 61 additions and 41 deletions

View file

@ -36,13 +36,18 @@ void BaseGameTab::OnApplyFilter(wxCommandEvent &event){
void BaseGameTab::OnDelete(wxCommandEvent &event) {
for(auto i: glm->GetSelectedItems()){
deleted.push_back(glm->GetItemGameId(i));
glm->MarkItemAsDeleted(i);
game_list->SetItemState(i, 0, wxLIST_STATE_SELECTED); // First deselect
long gameid=glm->GetItemGameId(i);
if(!std::count(deleted.begin(), deleted.end(), gameid)){
deleted.push_back(gameid);
glm->MarkItemAsDeleted(i);
}
}
NOTIFY_MANAGE_TAB();
}
std::shared_ptr<Game> BaseGameTab::OpenGame(long gameid, long item) {
game_list->SetItemState(item, 0, wxLIST_STATE_SELECTED); // First deselect
if(edited.find(gameid) != edited.end()){
// TODO: Focus on the game tab and if close reopen it
wxLogDebug("Already opened!");

View file

@ -77,6 +77,7 @@ void BaseImportTab::OnImportSelection(wxCommandEvent &event){
while ((selected = game_list->GetNextItem(selected, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED)) !=
wxNOT_FOUND) {
game_list->SetItemState(selected, 0, wxLIST_STATE_SELECTED); // First deselect
// Get game id
long game_id=glm->GetItemGameId(selected);
// Select the right db hashmap
@ -112,6 +113,7 @@ void BaseImportTab::OnLoad(wxCommandEvent &event){
selected_base=OpenDatabase(game_tab->GetBase()->GetFilePath());
SHOW_DIALOG_BUSY("Loading database...");
auto &game_list=selected_games_to_import[selected_base->GetFilePath()];
bool baseImported=std::count(databases_to_import.begin(),databases_to_import.end(),selected_base->GetFilePath())>0;
while (selected_base->NextGame()) {
long id=glm->AddGame(
selected_base->GetTag("White"),
@ -120,7 +122,7 @@ void BaseImportTab::OnLoad(wxCommandEvent &event){
selected_base->GetTag("Round"),
selected_base->GetTag("Result"),
selected_base->GetTag("ECO"));
if(game_list.find(id)!=game_list.end()){
if(game_list.find(id)!=game_list.end() || baseImported){
glm->MarkItemAsImported(id);
}
}

View file

@ -11,4 +11,9 @@ std::shared_ptr<GameBase> OpenDatabase(const std::string &dbpath, bool createIfN
return std::shared_ptr<GameBase>(new PGNGameBase(dbpath));
}
return nullptr;
}
std::shared_ptr<Game> OpenGameX(const std::string &dbpath, long id){
std::shared_ptr<GameBase> base=OpenDatabase(dbpath);
return base->GetGame(id);
}

View file

@ -35,4 +35,12 @@ public:
* @param dbpath
* @return std::shared_ptr<GameBase>
*/
std::shared_ptr<GameBase> OpenDatabase(const std::string &dbpath, bool createIfNotExist=true);
std::shared_ptr<GameBase> OpenDatabase(const std::string &dbpath, bool createIfNotExist=true);
/**
* @brief Single game open
*
* @param dbpath
* @param id
* @return std::shared_ptr<Game>
*/
std::shared_ptr<Game> OpenGameX(const std::string &dbpath, long id);