diff options
author | ConfuSomu | 2023-08-02 01:56:58 +0200 |
---|---|---|
committer | ConfuSomu | 2023-08-02 01:56:58 +0200 |
commit | 42434314d65cdc29402c7adcb08c2fa5113f7ca2 (patch) | |
tree | 703e792905b16d02c7137dd8cf7b60ed8d911890 /src/finddialog.h | |
parent | cdd08523b9af7afda906766d22197a066c9264f3 (diff) | |
download | ActorViewer-42434314d65cdc29402c7adcb08c2fa5113f7ca2.tar ActorViewer-42434314d65cdc29402c7adcb08c2fa5113f7ca2.tar.gz ActorViewer-42434314d65cdc29402c7adcb08c2fa5113f7ca2.zip |
Implement find dialog
This dialog consolidates options for searching through textual elements
in lists which simplifies the logic present in the MainWindow class.
Diffstat (limited to 'src/finddialog.h')
-rw-r--r-- | src/finddialog.h | 49 |
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(); +}; |