2022-11-30 09:48:21 +00:00
|
|
|
// Copyright (C) 2022 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
#ifndef ENUMPROBLEMS_H
|
|
|
|
#define ENUMPROBLEMS_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2023-06-23 09:50:07 +00:00
|
|
|
#include <QtCore/qflags.h>
|
2022-11-30 09:48:21 +00:00
|
|
|
#include <QtQml/qqml.h>
|
|
|
|
#include <QtQml/qqmlregistration.h>
|
|
|
|
|
|
|
|
class Foo : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Type {
|
|
|
|
Unknown,
|
|
|
|
Fighter,
|
|
|
|
Component
|
|
|
|
};
|
|
|
|
Q_ENUM(Type)
|
|
|
|
|
|
|
|
explicit Foo(Foo::Type type, QObject *parent = nullptr) : QObject(parent), m_type(type) {}
|
|
|
|
|
|
|
|
Type type() const { return m_type; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Type m_type = Type::Unknown;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace FooWrapper {
|
|
|
|
Q_NAMESPACE
|
|
|
|
QML_FOREIGN_NAMESPACE(Foo)
|
|
|
|
QML_NAMED_ELEMENT(Foo)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FooThingWrapper {
|
|
|
|
Q_GADGET
|
|
|
|
QML_FOREIGN(Foo)
|
|
|
|
QML_NAMED_ELEMENT(FooThing)
|
|
|
|
QML_UNCREATABLE("nope")
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class FooFactory : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
QML_ELEMENT
|
2023-03-27 16:01:07 +00:00
|
|
|
Q_PROPERTY(T8 t8 READ t8 CONSTANT FINAL)
|
|
|
|
Q_PROPERTY(T16 t16 READ t16 CONSTANT FINAL)
|
2022-11-30 09:48:21 +00:00
|
|
|
|
|
|
|
public:
|
2023-03-27 16:01:07 +00:00
|
|
|
enum T8: qint8 {
|
|
|
|
A, B, C
|
|
|
|
};
|
|
|
|
Q_ENUM(T8)
|
|
|
|
|
|
|
|
enum T16: qint16 {
|
|
|
|
D = 500, E, F
|
|
|
|
};
|
|
|
|
Q_ENUM(T16)
|
|
|
|
|
|
|
|
T8 t8() const { return C; }
|
|
|
|
T16 t16() const { return E; }
|
|
|
|
|
2022-11-30 09:48:21 +00:00
|
|
|
Q_INVOKABLE Foo* get(Foo::Type type) const { return new Foo(type); }
|
|
|
|
};
|
|
|
|
|
2023-06-23 09:50:07 +00:00
|
|
|
class ControlFlags : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
QML_ELEMENT
|
|
|
|
QML_UNCREATABLE("Flag Container Class")
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum Option {
|
|
|
|
ControlA = 0x1,
|
|
|
|
ControlB = 0x2,
|
|
|
|
Both = ControlA | ControlB
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_FLAGS(Options, Option)
|
|
|
|
Q_FLAG(Option)
|
|
|
|
};
|
|
|
|
|
2022-11-30 09:48:21 +00:00
|
|
|
#endif // ENUMPROBLEMS_H
|