File: takenumber.h

package info (click to toggle)
qt6-declarative 6.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 308,920 kB
  • sloc: cpp: 775,911; javascript: 514,247; xml: 10,855; python: 2,806; ansic: 2,253; java: 810; sh: 262; makefile: 41; php: 27
file content (77 lines) | stat: -rw-r--r-- 2,149 bytes parent folder | download | duplicates (2)
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
71
72
73
74
75
76
77
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef TAKENUMBER_H
#define TAKENUMBER_H

#include <QtCore/qobject.h>
#include <QtQml/qqml.h>

struct Numbers
{
    Q_GADGET
    QML_VALUE_TYPE(numbers)
    QML_STRUCTURED_VALUE

    Q_PROPERTY(int i MEMBER m_i)
    Q_PROPERTY(int n MEMBER m_n)
    Q_PROPERTY(qsizetype s MEMBER m_s)
    Q_PROPERTY(qlonglong l MEMBER m_l)
public:
    int m_i = 0;
    int m_n = 0;
    qsizetype m_s = 0;
    qlonglong m_l = 0;

    friend bool operator==(const Numbers &a, const Numbers &b)
    {
        return a.m_i == b.m_i && a.m_n == b.m_n && a.m_s == b.m_s && a.m_l == b.m_l;
    }

    friend bool operator!=(const Numbers &a, const Numbers &b)
    {
        return !(a == b);
    }
};

class TakeNumber : public QObject
{
    Q_OBJECT
    QML_ELEMENT

    Q_PROPERTY(int propertyInt MEMBER propertyInt NOTIFY propertyIntChanged)
    Q_PROPERTY(int propertyNegativeInt MEMBER propertyNegativeInt NOTIFY propertyNegativeIntChanged)
    Q_PROPERTY(qsizetype propertyQSizeType MEMBER propertyQSizeType NOTIFY propertyQSizeTypeChanged)
    Q_PROPERTY(qlonglong propertyQLongLong MEMBER propertyQLongLong NOTIFY propertyQLongLongChanged)
    Q_PROPERTY(Numbers propertyNumbers MEMBER propertyNumbers NOTIFY propertyNumbersChanged)

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

    Q_INVOKABLE void takeInt(int a);
    Q_INVOKABLE void takeNegativeInt(int a);
    Q_INVOKABLE void takeQSizeType(qsizetype a);
    Q_INVOKABLE void takeQLongLong(qlonglong a);
    Q_INVOKABLE void takeNumbers(const Numbers &a);

    int takenInt = 0;
    int takenNegativeInt = 0;
    qsizetype takenQSizeType = 0;
    qlonglong takenQLongLong = 0;
    Numbers takenNumbers;

    int propertyInt = 0;
    int propertyNegativeInt = 0;
    qsizetype propertyQSizeType = 0;
    qsizetype propertyQLongLong = 0;
    Numbers propertyNumbers;

signals:
    void propertyIntChanged();
    void propertyNegativeIntChanged();
    void propertyQSizeTypeChanged();
    void propertyQLongLongChanged();
    void propertyNumbersChanged();
};

#endif // TAKENUMBER_H