#pragma once #include #include #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(); // Force doing again the search, useful if list_widget items have changed void force_research(); public slots: void set_search_text(const QString &text, bool search_immediately = false); 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 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(bool force = false); void update_status(); void select_match(); bool has_search_changed(); };