Simplify
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
7c5047b2ac
commit
c343036d3b
@ -36,7 +36,15 @@ VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent)
|
|||||||
search->setPlaceholderText(tr("Search"));
|
search->setPlaceholderText(tr("Search"));
|
||||||
search->setClearButtonEnabled(true);
|
search->setClearButtonEnabled(true);
|
||||||
verticalLayout->addWidget(search);
|
verticalLayout->addWidget(search);
|
||||||
connect(search, &QLineEdit::textEdited, this, &VersionSelectWidget::updateSearch);
|
connect(search, &QLineEdit::textEdited, [this](const QString& value) {
|
||||||
|
m_proxyModel->setSearch(value);
|
||||||
|
if (!value.isEmpty() || !listView->selectionModel()->hasSelection()) {
|
||||||
|
const QModelIndex first = listView->model()->index(0, 0);
|
||||||
|
listView->selectionModel()->setCurrentIndex(first, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
||||||
|
listView->scrollToTop();
|
||||||
|
} else
|
||||||
|
listView->scrollTo(listView->selectionModel()->currentIndex(), QAbstractItemView::PositionAtCenter);
|
||||||
|
});
|
||||||
|
|
||||||
sneakyProgressBar = new QProgressBar(this);
|
sneakyProgressBar = new QProgressBar(this);
|
||||||
sneakyProgressBar->setObjectName(QStringLiteral("sneakyProgressBar"));
|
sneakyProgressBar->setObjectName(QStringLiteral("sneakyProgressBar"));
|
||||||
@ -124,7 +132,6 @@ void VersionSelectWidget::loadList()
|
|||||||
loadTask->start();
|
loadTask->start();
|
||||||
}
|
}
|
||||||
sneakyProgressBar->setHidden(false);
|
sneakyProgressBar->setHidden(false);
|
||||||
search->setHidden(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionSelectWidget::onTaskSucceeded()
|
void VersionSelectWidget::onTaskSucceeded()
|
||||||
@ -134,13 +141,6 @@ void VersionSelectWidget::onTaskSucceeded()
|
|||||||
listView->setEmptyMode(VersionListView::String);
|
listView->setEmptyMode(VersionListView::String);
|
||||||
}
|
}
|
||||||
sneakyProgressBar->setHidden(true);
|
sneakyProgressBar->setHidden(true);
|
||||||
search->setHidden(false);
|
|
||||||
|
|
||||||
if (focusSearch)
|
|
||||||
{
|
|
||||||
search->setFocus();
|
|
||||||
focusSearch = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
preselect();
|
preselect();
|
||||||
loadTask = nullptr;
|
loadTask = nullptr;
|
||||||
@ -174,17 +174,6 @@ void VersionSelectWidget::preselect()
|
|||||||
selectRecommended();
|
selectRecommended();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionSelectWidget::updateSearch(const QString &value) {
|
|
||||||
m_proxyModel->setSearch(value);
|
|
||||||
// if nothing is selected, pick the first result
|
|
||||||
if (!value.isEmpty()) {
|
|
||||||
listView->selectionModel()->setCurrentIndex(
|
|
||||||
listView->model()->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
|
|
||||||
listView->scrollToTop();
|
|
||||||
} else
|
|
||||||
listView->scrollTo(listView->selectionModel()->currentIndex(), QAbstractItemView::PositionAtCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VersionSelectWidget::selectCurrent()
|
void VersionSelectWidget::selectCurrent()
|
||||||
{
|
{
|
||||||
if(m_currentVersion.isEmpty())
|
if(m_currentVersion.isEmpty())
|
||||||
|
@ -89,7 +89,6 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void preselect();
|
void preselect();
|
||||||
void updateSearch(const QString &value);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_currentVersion;
|
QString m_currentVersion;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user