A couple small tweaks to SearchLayout to ensure it requeries only when required.

This commit is contained in:
casey 2016-06-12 17:03:56 -07:00
parent 14b516060d
commit be5ef75fad
2 changed files with 11 additions and 5 deletions

View File

@ -88,8 +88,7 @@ void SearchLayout::Layout() {
#define CREATE_CATEGORY(view, type, order) \ #define CREATE_CATEGORY(view, type, order) \
view.reset(new CategoryListView(this->library, type)); \ view.reset(new CategoryListView(this->library, type)); \
this->AddWindow(view); \ this->AddWindow(view); \
view->SetFocusOrder(order); \ view->SetFocusOrder(order);
view->Requery();
void SearchLayout::InitializeWindows() { void SearchLayout::InitializeWindows() {
this->input.reset(new cursespp::TextInput()); this->input.reset(new cursespp::TextInput());
@ -105,22 +104,28 @@ void SearchLayout::InitializeWindows() {
this->Layout(); this->Layout();
} }
void SearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) { void SearchLayout::Requery(const std::string& value) {
this->albums->Requery(value); this->albums->Requery(value);
this->artists->Requery(value); this->artists->Requery(value);
this->genres->Requery(value); this->genres->Requery(value);
} }
void SearchLayout::OnInputChanged(cursespp::TextInput* sender, std::string value) {
this->Requery(value);
}
void SearchLayout::OnVisibilityChanged(bool visible) { void SearchLayout::OnVisibilityChanged(bool visible) {
LayoutBase::OnVisibilityChanged(visible); LayoutBase::OnVisibilityChanged(visible);
if (visible) { if (visible) {
this->SetFocus(this->input);
if (this->input->Length()) { if (this->input->Length()) {
/* clear, which will trigger a requery */ /* clear, which will trigger a requery */
this->input->SetText(""); this->input->SetText("");
} }
else {
this->SetFocus(this->input); this->Requery();
}
} }
else { else {
this->albums->Reset(); this->albums->Reset();

View File

@ -68,6 +68,7 @@ namespace musik {
private: private:
void InitializeWindows(); void InitializeWindows();
void Requery(const std::string& value = "");
void OnInputChanged( void OnInputChanged(
cursespp::TextInput* sender, cursespp::TextInput* sender,