| 1 | // Copyright (C) 2019 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 QQMLTABLEMODELCOLUMN_P_H |
| 5 | #define QQMLTABLEMODELCOLUMN_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qqmlmodelsglobal_p.h" |
| 19 | |
| 20 | #include <QtCore/QObject> |
| 21 | #include <QtCore/QHash> |
| 22 | #include <QtQml/qqml.h> |
| 23 | #include <QtQmlModels/private/qtqmlmodelsglobal_p.h> |
| 24 | #include <QtQml/qjsvalue.h> |
| 25 | |
| 26 | QT_REQUIRE_CONFIG(qml_table_model); |
| 27 | |
| 28 | QT_BEGIN_NAMESPACE |
| 29 | |
| 30 | class Q_LABSQMLMODELS_EXPORT QQmlTableModelColumn : public QObject |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | Q_PROPERTY(QJSValue display READ display WRITE setDisplay NOTIFY displayChanged FINAL) |
| 34 | Q_PROPERTY(QJSValue setDisplay READ getSetDisplay WRITE setSetDisplay NOTIFY setDisplayChanged FINAL) |
| 35 | Q_PROPERTY(QJSValue decoration READ decoration WRITE setDecoration NOTIFY decorationChanged FINAL) |
| 36 | Q_PROPERTY(QJSValue setDecoration READ getSetDecoration WRITE setSetDecoration NOTIFY setDecorationChanged FINAL) |
| 37 | Q_PROPERTY(QJSValue edit READ edit WRITE setEdit NOTIFY editChanged FINAL) |
| 38 | Q_PROPERTY(QJSValue setEdit READ getSetEdit WRITE setSetEdit NOTIFY setEditChanged FINAL) |
| 39 | Q_PROPERTY(QJSValue toolTip READ toolTip WRITE setToolTip NOTIFY toolTipChanged FINAL) |
| 40 | Q_PROPERTY(QJSValue setToolTip READ getSetToolTip WRITE setSetToolTip NOTIFY setToolTipChanged FINAL) |
| 41 | Q_PROPERTY(QJSValue statusTip READ statusTip WRITE setStatusTip NOTIFY statusTipChanged FINAL) |
| 42 | Q_PROPERTY(QJSValue setStatusTip READ getSetStatusTip WRITE setSetStatusTip NOTIFY setStatusTipChanged FINAL) |
| 43 | Q_PROPERTY(QJSValue whatsThis READ whatsThis WRITE setWhatsThis NOTIFY whatsThisChanged FINAL) |
| 44 | Q_PROPERTY(QJSValue setWhatsThis READ getSetWhatsThis WRITE setSetWhatsThis NOTIFY setWhatsThisChanged FINAL) |
| 45 | |
| 46 | Q_PROPERTY(QJSValue font READ font WRITE setFont NOTIFY fontChanged FINAL) |
| 47 | Q_PROPERTY(QJSValue setFont READ getSetFont WRITE setSetFont NOTIFY setFontChanged FINAL) |
| 48 | Q_PROPERTY(QJSValue textAlignment READ textAlignment WRITE setTextAlignment NOTIFY textAlignmentChanged FINAL) |
| 49 | Q_PROPERTY(QJSValue setTextAlignment READ getSetTextAlignment WRITE setSetTextAlignment NOTIFY setTextAlignmentChanged FINAL) |
| 50 | Q_PROPERTY(QJSValue background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) |
| 51 | Q_PROPERTY(QJSValue setBackground READ getSetBackground WRITE setSetBackground NOTIFY setBackgroundChanged FINAL) |
| 52 | Q_PROPERTY(QJSValue foreground READ foreground WRITE setForeground NOTIFY foregroundChanged FINAL) |
| 53 | Q_PROPERTY(QJSValue setForeground READ getSetForeground WRITE setSetForeground NOTIFY setForegroundChanged FINAL) |
| 54 | Q_PROPERTY(QJSValue checkState READ checkState WRITE setCheckState NOTIFY checkStateChanged FINAL) |
| 55 | Q_PROPERTY(QJSValue setCheckState READ getSetCheckState WRITE setSetCheckState NOTIFY setCheckStateChanged FINAL) |
| 56 | |
| 57 | Q_PROPERTY(QJSValue accessibleText READ accessibleText WRITE setAccessibleText NOTIFY accessibleTextChanged FINAL) |
| 58 | Q_PROPERTY(QJSValue setAccessibleText READ getSetAccessibleText WRITE setSetAccessibleText NOTIFY setAccessibleTextChanged FINAL) |
| 59 | Q_PROPERTY(QJSValue accessibleDescription READ accessibleDescription |
| 60 | WRITE setAccessibleDescription NOTIFY accessibleDescriptionChanged FINAL) |
| 61 | Q_PROPERTY(QJSValue setAccessibleDescription READ getSetAccessibleDescription |
| 62 | WRITE setSetAccessibleDescription NOTIFY setAccessibleDescriptionChanged FINAL) |
| 63 | |
| 64 | Q_PROPERTY(QJSValue sizeHint READ sizeHint WRITE setSizeHint NOTIFY sizeHintChanged FINAL) |
| 65 | Q_PROPERTY(QJSValue setSizeHint READ getSetSizeHint WRITE setSetSizeHint NOTIFY setSizeHintChanged FINAL) |
| 66 | QML_NAMED_ELEMENT(TableModelColumn) |
| 67 | QML_ADDED_IN_VERSION(1, 0) |
| 68 | |
| 69 | public: |
| 70 | QQmlTableModelColumn(QObject *parent = nullptr); |
| 71 | ~QQmlTableModelColumn() override; |
| 72 | |
| 73 | QJSValue display() const; |
| 74 | void setDisplay(const QJSValue &stringOrFunction); |
| 75 | QJSValue getSetDisplay() const; |
| 76 | void setSetDisplay(const QJSValue &function); |
| 77 | |
| 78 | QJSValue decoration() const; |
| 79 | void setDecoration(const QJSValue &stringOrFunction); |
| 80 | QJSValue getSetDecoration() const; |
| 81 | void setSetDecoration(const QJSValue &function); |
| 82 | |
| 83 | QJSValue edit() const; |
| 84 | void setEdit(const QJSValue &stringOrFunction); |
| 85 | QJSValue getSetEdit() const; |
| 86 | void setSetEdit(const QJSValue &function); |
| 87 | |
| 88 | QJSValue toolTip() const; |
| 89 | void setToolTip(const QJSValue &stringOrFunction); |
| 90 | QJSValue getSetToolTip() const; |
| 91 | void setSetToolTip(const QJSValue &function); |
| 92 | |
| 93 | QJSValue statusTip() const; |
| 94 | void setStatusTip(const QJSValue &stringOrFunction); |
| 95 | QJSValue getSetStatusTip() const; |
| 96 | void setSetStatusTip(const QJSValue &function); |
| 97 | |
| 98 | QJSValue whatsThis() const; |
| 99 | void setWhatsThis(const QJSValue &stringOrFunction); |
| 100 | QJSValue getSetWhatsThis() const; |
| 101 | void setSetWhatsThis(const QJSValue &function); |
| 102 | |
| 103 | QJSValue font() const; |
| 104 | void setFont(const QJSValue &stringOrFunction); |
| 105 | QJSValue getSetFont() const; |
| 106 | void setSetFont(const QJSValue &function); |
| 107 | |
| 108 | QJSValue textAlignment() const; |
| 109 | void setTextAlignment(const QJSValue &stringOrFunction); |
| 110 | QJSValue getSetTextAlignment() const; |
| 111 | void setSetTextAlignment(const QJSValue &function); |
| 112 | |
| 113 | QJSValue background() const; |
| 114 | void setBackground(const QJSValue &stringOrFunction); |
| 115 | QJSValue getSetBackground() const; |
| 116 | void setSetBackground(const QJSValue &function); |
| 117 | |
| 118 | QJSValue foreground() const; |
| 119 | void setForeground(const QJSValue &stringOrFunction); |
| 120 | QJSValue getSetForeground() const; |
| 121 | void setSetForeground(const QJSValue &function); |
| 122 | |
| 123 | QJSValue checkState() const; |
| 124 | void setCheckState(const QJSValue &stringOrFunction); |
| 125 | QJSValue getSetCheckState() const; |
| 126 | void setSetCheckState(const QJSValue &function); |
| 127 | |
| 128 | QJSValue accessibleText() const; |
| 129 | void setAccessibleText(const QJSValue &stringOrFunction); |
| 130 | QJSValue getSetAccessibleText() const; |
| 131 | void setSetAccessibleText(const QJSValue &function); |
| 132 | |
| 133 | QJSValue accessibleDescription() const; |
| 134 | void setAccessibleDescription(const QJSValue &stringOrFunction); |
| 135 | QJSValue getSetAccessibleDescription() const; |
| 136 | void setSetAccessibleDescription(const QJSValue &function); |
| 137 | |
| 138 | QJSValue sizeHint() const; |
| 139 | void setSizeHint(const QJSValue &stringOrFunction); |
| 140 | QJSValue getSetSizeHint() const; |
| 141 | void setSetSizeHint(const QJSValue &function); |
| 142 | |
| 143 | QJSValue getterAtRole(const QString &roleName); |
| 144 | QJSValue setterAtRole(const QString &roleName); |
| 145 | |
| 146 | const QHash<QString, QJSValue> getters() const; |
| 147 | |
| 148 | static const QHash<int, QString> supportedRoleNames(); |
| 149 | |
| 150 | Q_SIGNALS: |
| 151 | void indexChanged(); |
| 152 | void displayChanged(); |
| 153 | void setDisplayChanged(); |
| 154 | void decorationChanged(); |
| 155 | void setDecorationChanged(); |
| 156 | void editChanged(); |
| 157 | void setEditChanged(); |
| 158 | void toolTipChanged(); |
| 159 | void setToolTipChanged(); |
| 160 | void statusTipChanged(); |
| 161 | void setStatusTipChanged(); |
| 162 | void whatsThisChanged(); |
| 163 | void setWhatsThisChanged(); |
| 164 | |
| 165 | void fontChanged(); |
| 166 | void setFontChanged(); |
| 167 | void textAlignmentChanged(); |
| 168 | void setTextAlignmentChanged(); |
| 169 | void backgroundChanged(); |
| 170 | void setBackgroundChanged(); |
| 171 | void foregroundChanged(); |
| 172 | void setForegroundChanged(); |
| 173 | void checkStateChanged(); |
| 174 | void setCheckStateChanged(); |
| 175 | |
| 176 | void accessibleTextChanged(); |
| 177 | void setAccessibleTextChanged(); |
| 178 | void accessibleDescriptionChanged(); |
| 179 | void setAccessibleDescriptionChanged(); |
| 180 | void sizeHintChanged(); |
| 181 | void setSizeHintChanged(); |
| 182 | |
| 183 | private: |
| 184 | // We store these in hashes because QQuickTableModel needs string-based lookup in certain situations. |
| 185 | QHash<QString, QJSValue> mGetters; |
| 186 | QHash<QString, QJSValue> mSetters; |
| 187 | }; |
| 188 | |
| 189 | QT_END_NAMESPACE |
| 190 | |
| 191 | #endif // QQMLTABLEMODELCOLUMN_P_H |
| 192 | |