blob: 38a58f2809baff7b83ad37a517cdd1e303547c5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#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();
// 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<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(bool force = false);
void update_status();
void select_match();
bool has_search_changed();
};
|