aboutsummaryrefslogtreecommitdiffstats
path: root/src/finddialog.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/finddialog.h')
-rw-r--r--src/finddialog.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/finddialog.h b/src/finddialog.h
new file mode 100644
index 0000000..c6907f8
--- /dev/null
+++ b/src/finddialog.h
@@ -0,0 +1,49 @@
+#pragma once
+#include <QDialog>
+#include <QListWidget>
+#include "./ui_finddialog.h"
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class FindDialog; }
+QT_END_NAMESPACE
+
+class FindDialog : public QDialog {
+ Q_OBJECT
+
+public:
+ FindDialog(QWidget *parent = nullptr);
+ ~FindDialog();
+
+public slots:
+ void set_search_text(const QString &text);
+ void set_qlist_widget(QListWidget* widget);
+ inline void run_search();
+
+signals:
+ void item_selected(QListWidgetItem* item);
+ void search_text_changed(const QString &text);
+
+private slots:
+ void on_textInputSearch_textEdited(const QString &text);
+ void on_buttonSearchPrev_clicked();
+ void on_buttonSearchNext_clicked();
+ void on_hSlider_valueChanged(int value);
+ void on_spinBox_valueChanged(int value);
+
+private:
+ Ui::FindDialog* ui;
+
+ QListWidget* list_widget = nullptr;
+ QString* last_search = new QString;
+ QList<QListWidgetItem*> matches;
+ int selected_match = 0;
+ int total_matches = 0;
+
+ // This is used with the spin box to avoid having repeated value changes due to the on_spinBox_valueChanged slot
+ bool value_changed_processed = false;
+
+ void init_search();
+ void update_status();
+ void select_match();
+ bool has_search_changed();
+};