summaryrefslogtreecommitdiffstats
path: root/examples/serialbus/can/sendframebox.h
blob: 5a6d6d85d4b91ecde5b9efafd95dd9b504de69a5 (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
// Copyright (C) 2017 Andre Hartmann <aha_1980@gmx.de>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef SENDFRAMEBOX_H
#define SENDFRAMEBOX_H

#include <QCanBusFrame>
#include <QGroupBox>
#include <QRegularExpression>
#include <QValidator>

QT_BEGIN_NAMESPACE
namespace Ui {
class SendFrameBox;
}
QT_END_NAMESPACE

class HexIntegerValidator : public QValidator
{
    Q_OBJECT
public:
    explicit HexIntegerValidator(QObject *parent = nullptr);

    QValidator::State validate(QString &input, int &) const;

    void setMaximum(uint maximum);

private:
    uint m_maximum = 0;
};

class HexStringValidator : public QValidator
{
    Q_OBJECT

public:
    explicit HexStringValidator(QObject *parent = nullptr);

    QValidator::State validate(QString &input, int &pos) const;

    void setMaxLength(int maxLength);

private:
    int m_maxLength = 0;
};

class SendFrameBox : public QGroupBox
{
    Q_OBJECT

public:
    explicit SendFrameBox(QWidget *parent = nullptr);
    ~SendFrameBox();

signals:
    void sendFrame(const QCanBusFrame &frame);

private:
    Ui::SendFrameBox *m_ui = nullptr;

    HexIntegerValidator *m_hexIntegerValidator = nullptr;
    HexStringValidator *m_hexStringValidator = nullptr;
};

#endif // SENDFRAMEBOX_H