mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-30 17:07:45 +00:00
Improve user experience
This commit is contained in:
parent
4eeb110f80
commit
214d46b8e2
6 changed files with 61 additions and 41 deletions
src/base_tab
|
@ -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!");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
Loading…
Add table
Add a link
Reference in a new issue