NOISSUE Search as you type for modpacks.ch

Since we just filter data locally now, this isn't painfully slow -
indeed it's very quick. This also matches other platforms, such as
ATLauncher.
This commit is contained in:
Jamie Mansfield 2021-10-16 23:36:31 +01:00
parent 175132539b
commit 1869dd0de3
No known key found for this signature in database
GPG Key ID: 36F61598F39F67B0
3 changed files with 15 additions and 7 deletions

View File

@ -32,7 +32,8 @@ FtbPage::FtbPage(NewInstanceDialog* dialog, QWidget *parent)
}
ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting());
connect(ui->searchButton, &QPushButton::clicked, this, &FtbPage::triggerSearch);
connect(ui->searchEdit, &QLineEdit::textChanged, this, &FtbPage::triggerSearch);
connect(ui->resetButton, &QPushButton::clicked, this, &FtbPage::resetSearch);
connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FtbPage::onSortingSelectionChanged);
connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FtbPage::onSelectionChanged);
connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FtbPage::onVersionSelectionChanged);
@ -104,6 +105,11 @@ void FtbPage::triggerSearch()
filterModel->setSearchTerm(ui->searchEdit->text());
}
void FtbPage::resetSearch()
{
ui->searchEdit->setText("");
}
void FtbPage::onSortingSelectionChanged(QString data)
{
auto toSet = filterModel->getAvailableSortings().value(data);

View File

@ -65,6 +65,8 @@ private:
private slots:
void triggerSearch();
void resetSearch();
void onSortingSelectionChanged(QString data);
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onVersionSelectionChanged(QString data);

View File

@ -39,9 +39,9 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="searchButton">
<widget class="QPushButton" name="resetButton">
<property name="text">
<string>Search</string>
<string>Reset</string>
</property>
</widget>
</item>
@ -49,15 +49,15 @@
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTreeView" name="packView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="iconSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
@ -76,7 +76,7 @@
</widget>
<tabstops>
<tabstop>searchEdit</tabstop>
<tabstop>searchButton</tabstop>
<tabstop>resetButton</tabstop>
<tabstop>versionSelectionBox</tabstop>
</tabstops>
<resources/>