aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tst_qtdotnet/foo.h
blob: 1c8f9fc959540e865668554acf9fcfd46e00e350 (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
/***************************************************************************************************
 Copyright (C) 2023 The Qt Company Ltd.
 SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/

#pragma once

#include <qdotnetinterface.h>
#include <qdotnetobject.h>

#ifdef __GNUC__
#   pragma GCC diagnostic push
#   pragma GCC diagnostic ignored "-Wconversion"
#endif
#include <QObject>
#include <QString>
#ifdef __GNUC__
#   pragma GCC diagnostic pop
#endif

struct FooPrivate;

class IBarTransformation : public QDotNetInterface
{
public:
    static inline const QString &FullyQualifiedTypeName =
        QStringLiteral("FooLib.IBarTransformation, FooLib");

    virtual QString transform(const QString &) = 0;

protected:
    IBarTransformation();
    ~IBarTransformation() override = default;
};

class Foo final : public QObject, public QDotNetObject
{
    Q_OBJECT
    Q_PROPERTY(QString bar READ bar WRITE setBar NOTIFY barChanged)

public:
    Q_DOTNET_OBJECT(Foo, "FooLib.Foo, FooLib");

    Foo();
    Foo(const IBarTransformation &transformation);
    ~Foo() override;

    [[nodiscard]] QString bar() const;
    void setBar(const QString &value);

signals:
    void barChanged();

private:
    FooPrivate *d;
};