Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmltablemodelcolumn.cpp
Go to the documentation of this file.
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
5
6#include <QtQml/qqmlinfo.h>
7
9
13
48static constexpr QLatin1StringView displayRoleName("display");
49static constexpr QLatin1StringView decorationRoleName("decoration");
50static constexpr QLatin1StringView editRoleName("edit");
51static constexpr QLatin1StringView toolTipRoleName("toolTip");
52static constexpr QLatin1StringView statusTipRoleName("statusTip");
53static constexpr QLatin1StringView whatsThisRoleName("whatsThis");
54
55static constexpr QLatin1StringView fontRoleName("font");
56static constexpr QLatin1StringView textAlignmentRoleName("textAlignment");
57static constexpr QLatin1StringView backgroundRoleName("background");
58static constexpr QLatin1StringView foregroundRoleName("foreground");
59static constexpr QLatin1StringView checkStateRoleName("checkState");
60
61static constexpr QLatin1StringView accessibleTextRoleName("accessibleText");
62static constexpr QLatin1StringView accessibleDescriptionRoleName("accessibleDescription");
63
64static constexpr QLatin1StringView sizeHintRoleName("sizeHint");
65
66
71
75
76#define DEFINE_ROLE_PROPERTIES(getterGetterName, getterSetterName, getterSignal, setterGetterName, setterSetterName, setterSignal, roleName) \
77QJSValue QQmlTableModelColumn::getterGetterName() const \
78{ \
79 return mGetters.value(roleName); \
80} \
81\
82void QQmlTableModelColumn::getterSetterName(const QJSValue &stringOrFunction) \
83{ \
84 if (!stringOrFunction.isString() && !stringOrFunction.isCallable()) { \
85 qmlWarning(this).quote() << "getter for " << roleName << " must be a function"; \
86 return; \
87 } \
88 if (stringOrFunction.strictlyEquals(decoration())) \
89 return; \
90\
91 mGetters[roleName] = stringOrFunction; \
92 emit decorationChanged(); \
93} \
94\
95QJSValue QQmlTableModelColumn::setterGetterName() const \
96{ \
97 return mSetters.value(roleName); \
98} \
99\
100void QQmlTableModelColumn::setterSetterName(const QJSValue &function) \
101{ \
102 if (!function.isCallable()) { \
103 qmlWarning(this).quote() << "setter for " << roleName << " must be a function"; \
104 return; \
105 } \
106\
107 if (function.strictlyEquals(getSetDisplay())) \
108 return; \
109\
110 mSetters[roleName] = function; \
111 emit setDisplayChanged(); \
112}
113
114DEFINE_ROLE_PROPERTIES(display, setDisplay, displayChanged,
115 getSetDisplay, setSetDisplay, setDisplayChanged, displayRoleName)
118DEFINE_ROLE_PROPERTIES(edit, setEdit, editChanged,
119 getSetEdit, setSetEdit, setEditChanged, editRoleName)
122DEFINE_ROLE_PROPERTIES(statusTip, setStatusTip, statusTipChanged,
123 getSetStatusTip, setSetStatusTip, setStatusTipChanged, statusTipRoleName)
126
127DEFINE_ROLE_PROPERTIES(font, setFont, fontChanged,
128 getSetFont, setSetFont, setFontChanged, fontRoleName)
131DEFINE_ROLE_PROPERTIES(background, setBackground, backgroundChanged,
132 getSetBackground, setSetBackground, setBackgroundChanged, backgroundRoleName)
135DEFINE_ROLE_PROPERTIES(checkState, setCheckState, checkStateChanged,
136 getSetCheckState, setSetCheckState, setCheckStateChanged, checkStateRoleName)
137
140DEFINE_ROLE_PROPERTIES(accessibleDescription, setAccessibleDescription, accessibleDescriptionChanged,
141 getSetAccessibleDescription, setSetAccessibleDescription, setAccessibleDescriptionChanged, accessibleDescriptionRoleName)
142
145
146QJSValue QQmlTableModelColumn::getterAtRole(const QString &roleName)
147{
148 auto it = mGetters.find(roleName);
149 if (it == mGetters.end())
150 return QJSValue();
151 return *it;
152}
153
155{
156 auto it = mSetters.find(roleName);
157 if (it == mSetters.end())
158 return QJSValue();
159 return *it;
160}
161
162const QHash<QString, QJSValue> QQmlTableModelColumn::getters() const
163{
164 return mGetters;
165}
166
187
189
190#include "moc_qqmltablemodelcolumn_p.cpp"
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition qhash.h:1291
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
Definition qhash.h:1216
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
\inmodule QtCore
Definition qobject.h:103
QJSValue setterAtRole(const QString &roleName)
static const QHash< int, QString > supportedRoleNames()
QQmlTableModelColumn(QObject *parent=nullptr)
const QHash< QString, QJSValue > getters() const
iterator end()
Definition qset.h:140
iterator find(const T &value)
Definition qset.h:159
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QSet< QString >::iterator it
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
@ AccessibleDescriptionRole
@ AccessibleTextRole
@ WhatsThisRole
@ FontRole
@ TextAlignmentRole
@ ForegroundRole
@ DecorationRole
@ BackgroundRole
@ EditRole
@ CheckStateRole
@ StatusTipRole
@ ToolTipRole
@ DisplayRole
@ SizeHintRole
GLuint GLuint * names
static constexpr QLatin1StringView accessibleDescriptionRoleName("accessibleDescription")
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName setSizeHintChanged
static constexpr QLatin1StringView decorationRoleName("decoration")
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName setSizeHint
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName setForegroundChanged
decorationRoleName toolTipRoleName setSetWhatsThis
decorationRoleName setSetToolTip
decorationRoleName toolTipRoleName getSetWhatsThis
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName sizeHintChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName setSetAccessibleText
static constexpr QLatin1StringView backgroundRoleName("background")
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName setSetSizeHint
decorationRoleName toolTipRoleName setWhatsThisChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName setAccessibleTextChanged
static constexpr QLatin1StringView whatsThisRoleName("whatsThis")
static constexpr QLatin1StringView editRoleName("edit")
decorationRoleName toolTipRoleName whatsThisRoleName setTextAlignmentChanged
decorationRoleName toolTipRoleName whatsThisRoleName setSetTextAlignment
decorationRoleName toolTipChanged
static constexpr QLatin1StringView statusTipRoleName("statusTip")
decorationRoleName toolTipRoleName whatsThisRoleName setTextAlignment
decorationRoleName toolTipRoleName setWhatsThis
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName setForeground
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextChanged
static QT_BEGIN_NAMESPACE constexpr QLatin1StringView displayRoleName("display")
Represents a column in a model.
decorationRoleName getSetToolTip
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName getSetForeground
decorationRoleName toolTipRoleName whatsThisChanged
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentChanged
static constexpr QLatin1StringView checkStateRoleName("checkState")
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName accessibleTextRoleName getSetSizeHint
decorationRoleName setToolTipChanged
static constexpr QLatin1StringView fontRoleName("font")
#define DEFINE_ROLE_PROPERTIES(getterGetterName, getterSetterName, getterSignal, setterGetterName, setterSetterName, setterSignal, roleName)
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName setAccessibleText
static constexpr QLatin1StringView foregroundRoleName("foreground")
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName foregroundRoleName getSetAccessibleText
decorationRoleName toolTipRoleName whatsThisRoleName getSetTextAlignment
static constexpr QLatin1StringView sizeHintRoleName("sizeHint")
decorationRoleName toolTipRoleName whatsThisRoleName textAlignmentRoleName setSetForeground
decorationRoleName setToolTip
static constexpr QLatin1StringView accessibleTextRoleName("accessibleText")
static constexpr QLatin1StringView toolTipRoleName("toolTip")
static constexpr QLatin1StringView textAlignmentRoleName("textAlignment")