smol fixes

This commit is contained in:
fourtf 2019-09-02 19:00:17 +02:00
parent 125426dbf1
commit eaaa52260e
3 changed files with 21 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -144,12 +144,28 @@ bool SettingsLayout::filterElements(const QString &query)
for (auto &&group : this->groups_) for (auto &&group : this->groups_)
{ {
// if a description in a group matches `query` then show the entire group
bool descriptionMatches{};
for (auto &&widget : group.widgets)
{
if (auto x = dynamic_cast<DescriptionLabel *>(widget.element); x)
{
if (x->text().contains(query, Qt::CaseInsensitive))
{
descriptionMatches = true;
break;
}
}
}
// if group name matches then all should be visible // if group name matches then all should be visible
if (group.name.contains(query, Qt::CaseInsensitive)) if (group.name.contains(query, Qt::CaseInsensitive) ||
descriptionMatches)
{ {
for (auto &&widget : group.widgets) for (auto &&widget : group.widgets)
widget.element->show(); widget.element->show();
group.title->show(); group.title->show();
any = true;
} }
// check if any match // check if any match
else else
@ -173,6 +189,7 @@ bool SettingsLayout::filterElements(const QString &query)
} }
group.title->setVisible(groupAny); group.title->setVisible(groupAny);
any |= groupAny;
} }
} }
@ -207,7 +224,8 @@ bool GeneralPage::filterElements(const QString &query)
{ {
if (this->settingsLayout_) if (this->settingsLayout_)
return this->settingsLayout_->filterElements(query) || return this->settingsLayout_->filterElements(query) ||
this->name_.contains(query) || query.isEmpty(); this->name_.contains(query, Qt::CaseInsensitive) ||
query.isEmpty();
else else
return false; return false;
} }

View file

@ -57,7 +57,7 @@ SettingsPage::SettingsPage(const QString &name, const QString &iconResource)
bool SettingsPage::filterElements(const QString &query) bool SettingsPage::filterElements(const QString &query)
{ {
return filterItemsRec(this, query) || query.isEmpty() || return filterItemsRec(this, query) || query.isEmpty() ||
this->name_.contains(query); this->name_.contains(query, Qt::CaseInsensitive);
} }
const QString &SettingsPage::getName() const QString &SettingsPage::getName()