mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36:11 +00:00
Implemented No Results Found warning when search result is empty (#2258)
This commit is contained in:
parent
061636d714
commit
e88ad82968
@ -190,11 +190,13 @@ SearchWidget::SearchWidget(MainWindow *main) :
|
|||||||
QShortcut *enter_press = new QShortcut(QKeySequence(Qt::Key_Return), this);
|
QShortcut *enter_press = new QShortcut(QKeySequence(Qt::Key_Return), this);
|
||||||
connect(enter_press, &QShortcut::activated, this, [this]() {
|
connect(enter_press, &QShortcut::activated, this, [this]() {
|
||||||
refreshSearch();
|
refreshSearch();
|
||||||
|
checkSearchResultEmpty();
|
||||||
});
|
});
|
||||||
enter_press->setContext(Qt::WidgetWithChildrenShortcut);
|
enter_press->setContext(Qt::WidgetWithChildrenShortcut);
|
||||||
|
|
||||||
connect(ui->searchButton, &QAbstractButton::clicked, this, [this]() {
|
connect(ui->searchButton, &QAbstractButton::clicked, this, [this]() {
|
||||||
refreshSearch();
|
refreshSearch();
|
||||||
|
checkSearchResultEmpty();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->searchspaceCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(ui->searchspaceCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
@ -265,6 +267,19 @@ void SearchWidget::refreshSearch()
|
|||||||
qhelpers::adjustColumns(ui->searchTreeView, 3, 0);
|
qhelpers::adjustColumns(ui->searchTreeView, 3, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No Results Found information message when search returns empty
|
||||||
|
// Called by &QShortcut::activated and &QAbstractButton::clicked signals
|
||||||
|
void SearchWidget::checkSearchResultEmpty()
|
||||||
|
{
|
||||||
|
if (search.isEmpty()){
|
||||||
|
QString noResultsMessage="<b>";
|
||||||
|
noResultsMessage.append(tr("No results found for:"));
|
||||||
|
noResultsMessage.append("</b><br>");
|
||||||
|
noResultsMessage.append(ui->filterLineEdit->text().toHtmlEscaped());
|
||||||
|
QMessageBox::information(this, tr("No Results Found"), noResultsMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SearchWidget::setScrollMode()
|
void SearchWidget::setScrollMode()
|
||||||
{
|
{
|
||||||
qhelpers::setVerticalScrollMode(ui->searchTreeView);
|
qhelpers::setVerticalScrollMode(ui->searchTreeView);
|
||||||
|
@ -81,6 +81,7 @@ private:
|
|||||||
QList<SearchDescription> search;
|
QList<SearchDescription> search;
|
||||||
|
|
||||||
void refreshSearch();
|
void refreshSearch();
|
||||||
|
void checkSearchResultEmpty();
|
||||||
void setScrollMode();
|
void setScrollMode();
|
||||||
void updatePlaceholderText(int index);
|
void updatePlaceholderText(int index);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user