1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2019 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtQml module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QQMLTABLEMODELCOLUMN_P_H 41 #define QQMLTABLEMODELCOLUMN_P_H 42 43 // 44 // W A R N I N G 45 // ------------- 46 // 47 // This file is not part of the Qt API. It exists purely as an 48 // implementation detail. This header file may change from version to 49 // version without notice, or even be removed. 50 // 51 // We mean it. 52 // 53 54 #include <QtCore/QObject> 55 #include <QtQml/qqml.h> 56 #include <QtQmlModels/private/qtqmlmodelsglobal_p.h> 57 #include <QtQml/qjsvalue.h> 58 59 QT_REQUIRE_CONFIG(qml_table_model); 60 61 QT_BEGIN_NAMESPACE 62 63 class QQmlTableModelColumn : public QObject 64 { 65 Q_OBJECT 66 Q_PROPERTY(QJSValue display READ display WRITE setDisplay NOTIFY displayChanged FINAL) 67 Q_PROPERTY(QJSValue setDisplay READ getSetDisplay WRITE setSetDisplay NOTIFY setDisplayChanged) 68 Q_PROPERTY(QJSValue decoration READ decoration WRITE setDecoration NOTIFY decorationChanged FINAL) 69 Q_PROPERTY(QJSValue setDecoration READ getSetDecoration WRITE setSetDecoration NOTIFY setDecorationChanged FINAL) 70 Q_PROPERTY(QJSValue edit READ edit WRITE setEdit NOTIFY editChanged FINAL) 71 Q_PROPERTY(QJSValue setEdit READ getSetEdit WRITE setSetEdit NOTIFY setEditChanged FINAL) 72 Q_PROPERTY(QJSValue toolTip READ toolTip WRITE setToolTip NOTIFY toolTipChanged FINAL) 73 Q_PROPERTY(QJSValue setToolTip READ getSetToolTip WRITE setSetToolTip NOTIFY setToolTipChanged FINAL) 74 Q_PROPERTY(QJSValue statusTip READ statusTip WRITE setStatusTip NOTIFY statusTipChanged FINAL) 75 Q_PROPERTY(QJSValue setStatusTip READ getSetStatusTip WRITE setSetStatusTip NOTIFY setStatusTipChanged FINAL) 76 Q_PROPERTY(QJSValue whatsThis READ whatsThis WRITE setWhatsThis NOTIFY whatsThisChanged FINAL) 77 Q_PROPERTY(QJSValue setWhatsThis READ getSetWhatsThis WRITE setSetWhatsThis NOTIFY setWhatsThisChanged FINAL) 78 79 Q_PROPERTY(QJSValue font READ font WRITE setFont NOTIFY fontChanged FINAL) 80 Q_PROPERTY(QJSValue setFont READ getSetFont WRITE setSetFont NOTIFY setFontChanged FINAL) 81 Q_PROPERTY(QJSValue textAlignment READ textAlignment WRITE setTextAlignment NOTIFY textAlignmentChanged FINAL) 82 Q_PROPERTY(QJSValue setTextAlignment READ getSetTextAlignment WRITE setSetTextAlignment NOTIFY setTextAlignmentChanged FINAL) 83 Q_PROPERTY(QJSValue background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) 84 Q_PROPERTY(QJSValue setBackground READ getSetBackground WRITE setSetBackground NOTIFY setBackgroundChanged FINAL) 85 Q_PROPERTY(QJSValue foreground READ foreground WRITE setForeground NOTIFY foregroundChanged FINAL) 86 Q_PROPERTY(QJSValue setForeground READ getSetForeground WRITE setSetForeground NOTIFY setForegroundChanged FINAL) 87 Q_PROPERTY(QJSValue checkState READ checkState WRITE setCheckState NOTIFY checkStateChanged FINAL) 88 Q_PROPERTY(QJSValue setCheckState READ getSetCheckState WRITE setSetCheckState NOTIFY setCheckStateChanged FINAL) 89 90 Q_PROPERTY(QJSValue accessibleText READ accessibleText WRITE setAccessibleText NOTIFY accessibleTextChanged FINAL) 91 Q_PROPERTY(QJSValue setAccessibleText READ getSetAccessibleText WRITE setSetAccessibleText NOTIFY setAccessibleTextChanged FINAL) 92 Q_PROPERTY(QJSValue accessibleDescription READ accessibleDescription 93 WRITE setAccessibleDescription NOTIFY accessibleDescriptionChanged FINAL) 94 Q_PROPERTY(QJSValue setAccessibleDescription READ getSetAccessibleDescription 95 WRITE setSetAccessibleDescription NOTIFY setAccessibleDescriptionChanged FINAL) 96 97 Q_PROPERTY(QJSValue sizeHint READ sizeHint WRITE setSizeHint NOTIFY sizeHintChanged FINAL) 98 Q_PROPERTY(QJSValue setSizeHint READ getSetSizeHint WRITE setSetSizeHint NOTIFY setSizeHintChanged FINAL) 99 QML_NAMED_ELEMENT(TableModelColumn) 100 101 public: 102 QQmlTableModelColumn(QObject *parent = nullptr); 103 ~QQmlTableModelColumn() override; 104 105 QJSValue display() const; 106 void setDisplay(const QJSValue &stringOrFunction); 107 QJSValue getSetDisplay() const; 108 void setSetDisplay(const QJSValue &function); 109 110 QJSValue decoration() const; 111 void setDecoration(const QJSValue &stringOrFunction); 112 QJSValue getSetDecoration() const; 113 void setSetDecoration(const QJSValue &function); 114 115 QJSValue edit() const; 116 void setEdit(const QJSValue &stringOrFunction); 117 QJSValue getSetEdit() const; 118 void setSetEdit(const QJSValue &function); 119 120 QJSValue toolTip() const; 121 void setToolTip(const QJSValue &stringOrFunction); 122 QJSValue getSetToolTip() const; 123 void setSetToolTip(const QJSValue &function); 124 125 QJSValue statusTip() const; 126 void setStatusTip(const QJSValue &stringOrFunction); 127 QJSValue getSetStatusTip() const; 128 void setSetStatusTip(const QJSValue &function); 129 130 QJSValue whatsThis() const; 131 void setWhatsThis(const QJSValue &stringOrFunction); 132 QJSValue getSetWhatsThis() const; 133 void setSetWhatsThis(const QJSValue &function); 134 135 QJSValue font() const; 136 void setFont(const QJSValue &stringOrFunction); 137 QJSValue getSetFont() const; 138 void setSetFont(const QJSValue &function); 139 140 QJSValue textAlignment() const; 141 void setTextAlignment(const QJSValue &stringOrFunction); 142 QJSValue getSetTextAlignment() const; 143 void setSetTextAlignment(const QJSValue &function); 144 145 QJSValue background() const; 146 void setBackground(const QJSValue &stringOrFunction); 147 QJSValue getSetBackground() const; 148 void setSetBackground(const QJSValue &function); 149 150 QJSValue foreground() const; 151 void setForeground(const QJSValue &stringOrFunction); 152 QJSValue getSetForeground() const; 153 void setSetForeground(const QJSValue &function); 154 155 QJSValue checkState() const; 156 void setCheckState(const QJSValue &stringOrFunction); 157 QJSValue getSetCheckState() const; 158 void setSetCheckState(const QJSValue &function); 159 160 QJSValue accessibleText() const; 161 void setAccessibleText(const QJSValue &stringOrFunction); 162 QJSValue getSetAccessibleText() const; 163 void setSetAccessibleText(const QJSValue &function); 164 165 QJSValue accessibleDescription() const; 166 void setAccessibleDescription(const QJSValue &stringOrFunction); 167 QJSValue getSetAccessibleDescription() const; 168 void setSetAccessibleDescription(const QJSValue &function); 169 170 QJSValue sizeHint() const; 171 void setSizeHint(const QJSValue &stringOrFunction); 172 QJSValue getSetSizeHint() const; 173 void setSetSizeHint(const QJSValue &function); 174 175 QJSValue getterAtRole(const QString &roleName); 176 QJSValue setterAtRole(const QString &roleName); 177 178 const QHash<QString, QJSValue> getters() const; 179 180 static const QHash<int, QString> supportedRoleNames(); 181 182 Q_SIGNALS: 183 void indexChanged(); 184 void displayChanged(); 185 void setDisplayChanged(); 186 void decorationChanged(); 187 void setDecorationChanged(); 188 void editChanged(); 189 void setEditChanged(); 190 void toolTipChanged(); 191 void setToolTipChanged(); 192 void statusTipChanged(); 193 void setStatusTipChanged(); 194 void whatsThisChanged(); 195 void setWhatsThisChanged(); 196 197 void fontChanged(); 198 void setFontChanged(); 199 void textAlignmentChanged(); 200 void setTextAlignmentChanged(); 201 void backgroundChanged(); 202 void setBackgroundChanged(); 203 void foregroundChanged(); 204 void setForegroundChanged(); 205 void checkStateChanged(); 206 void setCheckStateChanged(); 207 208 void accessibleTextChanged(); 209 void setAccessibleTextChanged(); 210 void accessibleDescriptionChanged(); 211 void setAccessibleDescriptionChanged(); 212 void sizeHintChanged(); 213 void setSizeHintChanged(); 214 215 private: 216 int mIndex = -1; 217 218 // We store these in hashes because QQuickTableModel needs string-based lookup in certain situations. 219 QHash<QString, QJSValue> mGetters; 220 QHash<QString, QJSValue> mSetters; 221 }; 222 223 QT_END_NAMESPACE 224 225 QML_DECLARE_TYPE(QQmlTableModelColumn) 226 227 #endif // QQMLTABLEMODELCOLUMN_P_H 228