aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/widgets/apply_line_edit.h
blob: 91e440c59a871fe70a959b218a18ed9ba3d713bc (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* apply_lineedit.h
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef UI_QT_APPLY_LINE_EDIT_H_
#define UI_QT_APPLY_LINE_EDIT_H_

#include <QLineEdit>
#include <QString>

#include <ui/qt/widgets/stock_icon_tool_button.h>

class ApplyLineEdit : public QLineEdit
{
    Q_OBJECT

public:
    explicit ApplyLineEdit(QString linePlaceholderText, QWidget *parent = 0);
    ~ApplyLineEdit();

    Q_PROPERTY(QString regex READ regex WRITE setRegEx)
    Q_PROPERTY(bool emptyAllowed READ emptyAllowed WRITE setEmptyAllowed)

    QString regex();
    void setRegEx(QString);

    bool emptyAllowed();
    void setEmptyAllowed(bool);

signals:
    void textApplied();

protected:
    void resizeEvent(QResizeEvent *);

private:

    QString regex_;
    bool emptyAllowed_;

    StockIconToolButton *apply_button_;

    bool isValidText(QString &, bool ignoreEmptyCheck = false);
    void handleValidation(QString newText);

private slots:
    void onTextEdited(const QString &);
    void onTextChanged(const QString &);
    void onSubmitContent();
};

#endif /* UI_QT_APPLY_LINE_EDIT_H_ */

/*
 * Editor modelines
 *
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */