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

View File

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