diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b33889a..28af716 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -8,6 +8,7 @@ #include <QRandomGenerator> #include <QClipboard> #include <QMimeData> +#include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -103,13 +104,15 @@ void MainWindow::on_buttonSearch_clicked() { QString current_search = ui->textInputSearch->text(); + QList<QListWidgetItem*> matches = ui->listWidget->findItems(current_search, Qt::MatchContains); + if (not (*last_search == current_search)) { *last_search = current_search; selected_match = 0; - } else - ++selected_match; + } else if (++selected_match >= matches.size()) selected_match = 0; + + qDebug() << matches.size() << selected_match; - QList<QListWidgetItem*> matches = ui->listWidget->findItems(current_search, Qt::MatchContains); if (not matches.isEmpty()) { ui->listWidget->scrollToItem(matches[selected_match], QAbstractItemView::EnsureVisible); ui->listWidget->setCurrentItem(matches[selected_match]); |