1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QTEST_WIDGETS_H |
5 | #define QTEST_WIDGETS_H |
6 | |
7 | // enable WIDGETS features |
8 | #ifndef QT_WIDGETS_LIB |
9 | #define QT_WIDGETS_LIB |
10 | #endif |
11 | #if 0 |
12 | #pragma qt_class(QtTestWidgets) |
13 | #endif |
14 | |
15 | #include <QtTest/qtest_gui.h> |
16 | |
17 | #if 0 |
18 | // inform syncqt |
19 | #pragma qt_no_master_include |
20 | #endif |
21 | |
22 | #include <QtWidgets/QSizePolicy> |
23 | #include <QtCore/QMetaEnum> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | namespace QTest |
28 | { |
29 | |
30 | // |
31 | // QSizePolicy & friends: |
32 | // |
33 | |
34 | namespace Internal |
35 | { |
36 | |
37 | inline const char *toString(QSizePolicy::Policy p) |
38 | { |
39 | static const QMetaEnum me = QSizePolicy::staticMetaObject.enumerator(index: QSizePolicy::staticMetaObject.indexOfEnumerator(name: "Policy")); |
40 | return me.valueToKey(value: int(p)); |
41 | } |
42 | |
43 | inline QByteArray toString(QSizePolicy::ControlTypes ct) |
44 | { |
45 | static const QMetaEnum me = QSizePolicy::staticMetaObject.enumerator(index: QSizePolicy::staticMetaObject.indexOfEnumerator(name: "ControlTypes")); |
46 | return me.valueToKeys(value: int(ct.toInt())); |
47 | } |
48 | |
49 | inline QByteArray toString(QSizePolicy sp) |
50 | { |
51 | static const char comma[] = ", "; |
52 | return QByteArray("QSizePolicy(") |
53 | + Internal::toString(p: sp.horizontalPolicy()) + comma |
54 | + Internal::toString(p: sp.verticalPolicy()) + comma |
55 | + QByteArray::number(sp.horizontalStretch()) + comma |
56 | + QByteArray::number(sp.verticalStretch()) + comma |
57 | + Internal::toString(ct: QSizePolicy::ControlTypes(sp.controlType())) + comma |
58 | + "height for width: "+ (sp.hasHeightForWidth() ? "yes": "no") + comma |
59 | + "width for height: "+ (sp.hasWidthForHeight() ? "yes": "no") + comma |
60 | + (sp.retainSizeWhenHidden() ? "": "don't ") + "retain size when hidden" |
61 | + ')'; |
62 | } |
63 | |
64 | } // namespace Internal |
65 | |
66 | inline char *toString(QSizePolicy::Policy p) |
67 | { |
68 | return qstrdup(Internal::toString(p)); |
69 | } |
70 | |
71 | inline char *toString(QSizePolicy::ControlTypes ct) |
72 | { |
73 | return qstrdup(Internal::toString(ct).constData()); |
74 | } |
75 | |
76 | inline char *toString(QSizePolicy::ControlType ct) |
77 | { |
78 | return toString(ct: QSizePolicy::ControlTypes(ct)); |
79 | } |
80 | |
81 | inline char *toString(QSizePolicy sp) |
82 | { |
83 | return qstrdup(Internal::toString(sp).constData()); |
84 | } |
85 | |
86 | } // namespace QTest |
87 | |
88 | QT_END_NAMESPACE |
89 | |
90 | #endif |
91 | |
92 |