| 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 | } // namespace QTest |
| 66 | |
| 67 | inline char *toString(QSizePolicy::Policy p) |
| 68 | { |
| 69 | return qstrdup(QTest::Internal::toString(p)); |
| 70 | } |
| 71 | |
| 72 | inline char *toString(QSizePolicy::ControlTypes ct) |
| 73 | { |
| 74 | return qstrdup(QTest::Internal::toString(ct).constData()); |
| 75 | } |
| 76 | |
| 77 | inline char *toString(QSizePolicy::ControlType ct) |
| 78 | { |
| 79 | return toString(ct: QSizePolicy::ControlTypes(ct)); |
| 80 | } |
| 81 | |
| 82 | inline char *toString(QSizePolicy sp) |
| 83 | { |
| 84 | return qstrdup(QTest::Internal::toString(sp).constData()); |
| 85 | } |
| 86 | |
| 87 | QT_END_NAMESPACE |
| 88 | |
| 89 | #endif |
| 90 | |
| 91 |
