replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
[metze/wireshark/wip.git] / ui / qt / widgets / apply_line_edit.h
1 /* apply_lineedit.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later*/
8
9 #ifndef UI_QT_APPLY_LINE_EDIT_H_
10 #define UI_QT_APPLY_LINE_EDIT_H_
11
12 #include <QLineEdit>
13 #include <QString>
14
15 #include <ui/qt/widgets/stock_icon_tool_button.h>
16
17 class ApplyLineEdit : public QLineEdit
18 {
19     Q_OBJECT
20
21 public:
22     explicit ApplyLineEdit(QString linePlaceholderText, QWidget *parent = 0);
23     ~ApplyLineEdit();
24
25     Q_PROPERTY(QString regex READ regex WRITE setRegEx)
26     Q_PROPERTY(bool emptyAllowed READ emptyAllowed WRITE setEmptyAllowed)
27
28     QString regex();
29     void setRegEx(QString);
30
31     bool emptyAllowed();
32     void setEmptyAllowed(bool);
33
34 signals:
35     void textApplied();
36
37 protected:
38     void resizeEvent(QResizeEvent *);
39
40 private:
41
42     QString regex_;
43     bool emptyAllowed_;
44
45     StockIconToolButton *applyButton;
46
47     bool isValidText(QString &, bool ignoreEmptyCheck = false);
48     void handleValidation(QString newText);
49
50 private slots:
51     void onTextEdited(const QString &);
52     void onTextChanged(const QString &);
53     void onSubmitContent();
54 };
55
56 #endif /* UI_QT_APPLY_LINE_EDIT_H_ */
57
58 /*
59  * Editor modelines
60  *
61  * Local Variables:
62  * c-basic-offset: 4
63  * tab-width: 8
64  * indent-tabs-mode: nil
65  * End:
66  *
67  * ex: set shiftwidth=4 tabstop=8 expandtab:
68  * :indentSize=4:tabSize=8:noTabs=true:
69  */