Commit 76be8688 authored by twanvl's avatar twanvl

Fix #67: remember the value of FilterCtrls when the control is destroyed, and...

Fix #67: remember the value of FilterCtrls when the control is destroyed, and set it again when the control is recreated
parent a6685d30
...@@ -219,7 +219,13 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { ...@@ -219,7 +219,13 @@ void CardsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
#endif #endif
// Filter/search textbox // Filter/search textbox
tb->AddSeparator(); tb->AddSeparator();
if (!filter) filter = new FilterCtrl(tb, ID_CARD_FILTER, _LABEL_("search cards")); assert(!filter);
if (!filter) {
filter = new FilterCtrl(tb, ID_CARD_FILTER, _LABEL_("search cards"));
// the control should show what the list is still filtered by
filter->setFilter(filter_value);
}
wxLogDebug(L"%p -> %p", filter, tb);
tb->AddControl(filter); tb->AddControl(filter);
tb->Realize(); tb->Realize();
// Menus // Menus
...@@ -236,7 +242,11 @@ void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) { ...@@ -236,7 +242,11 @@ void CardsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
tb->DeleteTool(ID_CARD_ADD); tb->DeleteTool(ID_CARD_ADD);
tb->DeleteTool(ID_CARD_REMOVE); tb->DeleteTool(ID_CARD_REMOVE);
tb->DeleteTool(ID_CARD_ROTATE); tb->DeleteTool(ID_CARD_ROTATE);
tb->DeleteTool(filter->GetId()); filter = nullptr; // remember the value in the filter control, because the card list remains filtered
// the control is destroyed by DeleteTool
filter_value = filter->getFilterString();
tb->DeleteTool(filter->GetId());
filter = nullptr;
// HACK: hardcoded size of rest of toolbar // HACK: hardcoded size of rest of toolbar
tb->DeleteToolByPos(12); // delete separator tb->DeleteToolByPos(12); // delete separator
tb->DeleteToolByPos(12); // delete separator tb->DeleteToolByPos(12); // delete separator
......
...@@ -82,6 +82,7 @@ class CardsPanel : public SetWindowPanel { ...@@ -82,6 +82,7 @@ class CardsPanel : public SetWindowPanel {
TextCtrl* notes; TextCtrl* notes;
HoverButton* collapse_notes; HoverButton* collapse_notes;
FilterCtrl* filter; FilterCtrl* filter;
String filter_value; // value of filter, need separate variable because the control is destroyed
bool notes_below_editor; bool notes_below_editor;
/// Move the notes panel below the editor or below the card list /// Move the notes panel below the editor or below the card list
......
...@@ -135,7 +135,12 @@ void KeywordsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) { ...@@ -135,7 +135,12 @@ void KeywordsPanel::initUI(wxToolBar* tb, wxMenuBar* mb) {
tb->AddTool(ID_KEYWORD_REMOVE, _(""), load_resource_tool_image(_("keyword_del")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("remove keyword"),_HELP_("remove keyword")); tb->AddTool(ID_KEYWORD_REMOVE, _(""), load_resource_tool_image(_("keyword_del")), wxNullBitmap, wxITEM_NORMAL,_TOOLTIP_("remove keyword"),_HELP_("remove keyword"));
// Filter/search textbox // Filter/search textbox
tb->AddSeparator(); tb->AddSeparator();
if (!filter) filter = new FilterCtrl(tb, ID_KEYWORD_FILTER, _LABEL_("search keywords")); assert(!filter);
if (!filter) {
filter = new FilterCtrl(tb, ID_KEYWORD_FILTER, _LABEL_("search keywords"));
// the control should show what the list is still filtered by
filter->setFilter(filter_value);
}
tb->AddControl(filter); tb->AddControl(filter);
tb->Realize(); tb->Realize();
// Menus // Menus
...@@ -146,7 +151,11 @@ void KeywordsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) { ...@@ -146,7 +151,11 @@ void KeywordsPanel::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
// Toolbar // Toolbar
tb->DeleteTool(ID_KEYWORD_ADD); tb->DeleteTool(ID_KEYWORD_ADD);
tb->DeleteTool(ID_KEYWORD_REMOVE); tb->DeleteTool(ID_KEYWORD_REMOVE);
tb->DeleteTool(filter->GetId()); filter = nullptr; // remember the value in the filter control, because the card list remains filtered
// the control is destroyed by DeleteTool
filter_value = filter->getFilterString();
tb->DeleteTool(filter->GetId());
filter = nullptr;
// HACK: hardcoded size of rest of toolbar // HACK: hardcoded size of rest of toolbar
tb->DeleteToolByPos(12); // delete separator tb->DeleteToolByPos(12); // delete separator
// Menus // Menus
......
...@@ -72,6 +72,7 @@ class KeywordsPanel : public SetWindowPanel { ...@@ -72,6 +72,7 @@ class KeywordsPanel : public SetWindowPanel {
wxButton* add_param; wxButton* add_param;
wxButton* ref_param; wxButton* ref_param;
FilterCtrl* filter; FilterCtrl* filter;
String filter_value;
// --------------------------------------------------- : Events // --------------------------------------------------- : Events
void onKeywordSelect(KeywordSelectEvent& ev); void onKeywordSelect(KeywordSelectEvent& ev);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment