mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-07-15 08:07:40 +00:00
Improve tab management
This commit is contained in:
parent
d298c59206
commit
1293b59ed5
6 changed files with 31 additions and 30 deletions
|
@ -70,7 +70,7 @@ void BaseGameTab::OnSave(wxCommandEvent &event) {
|
|||
edited_games.end()); // Add edited game (since they are also deleted)
|
||||
base->Save(deleted, new_games_bases, new_games);
|
||||
|
||||
// CLose all opened games in this database
|
||||
// Close all opened games in this database
|
||||
wxCommandEvent closeLinkedTabEvent(CLOSE_LINKED_TAB, GetId());
|
||||
closeLinkedTabEvent.SetClientData(main_tab);
|
||||
ProcessEvent(closeLinkedTabEvent);
|
||||
|
@ -82,17 +82,23 @@ void BaseGameTab::OnSave(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
void BaseGameTab::OnOpenGame(wxListEvent &event) {
|
||||
wxLogDebug("Open!");
|
||||
long id = std::stoi(event.GetItem().GetText().ToStdString());
|
||||
std::shared_ptr<Game> *g = new std::shared_ptr<Game>(base->GetGame(id));
|
||||
if (g != NULL) {
|
||||
edited[id]=*g;
|
||||
deleted.push_back(id);
|
||||
game_list->SetItemBackgroundColour(event.GetIndex(), *wxGREEN);
|
||||
wxCommandEvent openGameEvent(OPEN_GAME_EVENT, GetId());
|
||||
openGameEvent.SetEventObject(this);
|
||||
openGameEvent.SetClientData(g);
|
||||
ProcessEvent(openGameEvent);
|
||||
if(edited.find(id) != edited.end()){
|
||||
// TODO: Focus on the game tab and if close reopen it
|
||||
wxLogDebug("Already opened!");
|
||||
}
|
||||
else {
|
||||
wxLogDebug("Open game");
|
||||
edited[id]=*g;
|
||||
deleted.push_back(id);
|
||||
game_list->SetItemBackgroundColour(event.GetIndex(), *wxGREEN);
|
||||
wxCommandEvent openGameEvent(OPEN_GAME_EVENT, GetId());
|
||||
openGameEvent.SetEventObject(this);
|
||||
openGameEvent.SetClientData(g);
|
||||
ProcessEvent(openGameEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
BaseImportTab::BaseImportTab(wxFrame *parent):
|
||||
TabBase_TabImport(parent)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue