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
qquickpane.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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#include "qquickpane_p.h"
5#include "qquickpane_p_p.h"
7
8#include <QtCore/qloggingcategory.h>
9
11
12Q_LOGGING_CATEGORY(lcPane, "qt.quick.controls.pane")
13
14
18
102{
103 Q_Q(QQuickPane);
105 q->setAcceptedMouseButtons(Qt::AllButtons);
106#if QT_CONFIG(cursor)
107 q->setCursor(Qt::ArrowCursor);
108#endif
109 connect(q, &QQuickControl::implicitContentWidthChanged, this, &QQuickPanePrivate::updateContentWidth);
110 connect(q, &QQuickControl::implicitContentHeightChanged, this, &QQuickPanePrivate::updateContentHeight);
112}
113
114QList<QQuickItem *> QQuickPanePrivate::contentChildItems() const
115{
116 if (!contentItem)
117 return QList<QQuickItem *>();
118
119 return contentItem->childItems();
120}
121
130
138
146
148{
149 // Do this check before calling the base class implementation, as that clears contentItem.
150 if (item == firstChild)
151 firstChild = nullptr;
152
154}
155
157{
158 Q_Q(QQuickPane);
159
160 QQuickItem *newFirstChild = getFirstChild();
161
162 if (newFirstChild != firstChild) {
163 if (firstChild)
165 if (newFirstChild && newFirstChild != contentItem)
166 addImplicitSizeListener(newFirstChild);
167 firstChild = newFirstChild;
168 }
169
171 emit q->contentChildrenChanged();
172}
173
175{
176 if (!contentItem)
177 return 0;
178
180 if (!qFuzzyIsNull(cw))
181 return cw;
182
183 const auto contentChildren = contentChildItems();
184 if (contentChildren.size() == 1)
185 return contentChildren.first()->implicitWidth();
186
187 return 0;
188}
189
191{
192 // The first child varies depending on how the content item is declared.
193 // If it's declared as a child of the Pane, it will be parented to the
194 // default QQuickContentItem. If it's assigned to the contentItem property
195 // directly, QQuickControl::contentItem will be used.
196 return (qobject_cast<QQuickContentItem *>(contentItem)
198}
199
201{
202 if (!contentItem)
203 return 0;
204
206 if (!qFuzzyIsNull(ch))
207 return ch;
208
209 const auto contentChildren = contentChildItems();
210 if (contentChildren.size() == 1)
211 return contentChildren.first()->implicitHeight();
212
213 return 0;
214}
215
217{
218 Q_Q(QQuickPane);
220 return;
221
222 const qreal oldContentWidth = contentWidth;
224 qCDebug(lcPane) << "contentWidth of" << q << "changed to" << contentWidth;
225 q->contentSizeChange(QSizeF(contentWidth, contentHeight), QSizeF(oldContentWidth, contentHeight));
226 emit q->contentWidthChanged();
227}
228
230{
231 Q_Q(QQuickPane);
233 return;
234
235 const qreal oldContentHeight = contentHeight;
237 qCDebug(lcPane) << "contentHeight of" << q << "changed to" << contentHeight;
238 q->contentSizeChange(QSizeF(contentWidth, contentHeight), QSizeF(contentWidth, oldContentHeight));
239 emit q->contentHeightChanged();
240}
241
242/*
243 A pane needs to be opaque to mouse events, so that events don't get
244 propagated through to controls covered by the pane.
245*/
246bool QQuickPanePrivate::handlePress(const QPointF &point, ulong timestamp)
247{
248 QQuickControlPrivate::handlePress(point, timestamp);
249 return true;
250}
251
253 : QQuickControl(*(new QQuickPanePrivate), parent)
254{
255 Q_D(QQuickPane);
256 d->init();
257}
258
260{
261 Q_D(QQuickPane);
262 d->removeImplicitSizeListener(d->contentItem);
263 d->removeImplicitSizeListener(d->firstChild);
264}
265
267 : QQuickControl(dd, parent)
268{
269 Q_D(QQuickPane);
270 d->init();
271}
272
284{
285 Q_D(const QQuickPane);
286 return d->contentWidth;
287}
288
290{
291 Q_D(QQuickPane);
292 d->hasContentWidth = true;
293 if (qFuzzyCompare(d->contentWidth, width))
294 return;
295
296 const qreal oldWidth = d->contentWidth;
297 d->contentWidth = width;
298 contentSizeChange(QSizeF(width, d->contentHeight), QSizeF(oldWidth, d->contentHeight));
300}
301
303{
304 Q_D(QQuickPane);
305 if (!d->hasContentWidth)
306 return;
307
308 d->hasContentHeight = false;
309 d->updateContentWidth();
310}
311
323{
324 Q_D(const QQuickPane);
325 return d->contentHeight;
326}
327
329{
330 Q_D(QQuickPane);
331 d->hasContentHeight = true;
332 if (qFuzzyCompare(d->contentHeight, height))
333 return;
334
335 const qreal oldHeight = d->contentHeight;
336 d->contentHeight = height;
337 contentSizeChange(QSizeF(d->contentWidth, height), QSizeF(d->contentWidth, oldHeight));
339}
340
342{
343 Q_D(QQuickPane);
344 if (!d->hasContentHeight)
345 return;
346
347 d->hasContentHeight = false;
348 d->updateContentHeight();
349}
350
365QQmlListProperty<QObject> QQuickPanePrivate::contentData()
366{
367 Q_Q(QQuickPane);
368 return QQmlListProperty<QObject>(q->contentItem(), nullptr,
373}
374
388QQmlListProperty<QQuickItem> QQuickPanePrivate::contentChildren()
389{
390 Q_Q(QQuickPane);
391 return QQmlListProperty<QQuickItem>(q->contentItem(), nullptr,
396}
397
399{
400 Q_D(QQuickPane);
402 d->updateImplicitContentSize();
403}
404
406{
407 Q_D(QQuickPane);
408 QQuickControl::contentItemChange(newItem, oldItem);
409 if (oldItem) {
410 d->removeImplicitSizeListener(oldItem);
412 }
413 if (newItem) {
414 d->addImplicitSizeListener(newItem);
416 }
417 d->contentChildrenChange();
418}
419
420void QQuickPane::contentSizeChange(const QSizeF &newSize, const QSizeF &oldSize)
421{
422 Q_UNUSED(newSize);
423 Q_UNUSED(oldSize);
424}
425
426#if QT_CONFIG(accessibility)
427QAccessible::Role QQuickPane::accessibleRole() const
428{
429 return QAccessible::Pane;
430}
431#endif
432
434
435#include "moc_qquickpane_p.cpp"
static constexpr Policy Preferred
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject_p.h:299
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
Definition qobject_p.h:328
\inmodule QtCore\reentrant
Definition qpoint.h:217
void itemImplicitWidthChanged(QQuickItem *item) override
virtual bool handlePress(const QPointF &point, ulong timestamp)
QQuickDeferredPointer< QQuickItem > contentItem
virtual QQuickItem * getContentItem()
void removeImplicitSizeListener(QQuickItem *item, ChangeTypes changes=ImplicitSizeChanges)
void addImplicitSizeListener(QQuickItem *item, ChangeTypes changes=ImplicitSizeChanges)
void itemDestroyed(QQuickItem *item) override
void itemImplicitHeightChanged(QQuickItem *item) override
virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
static void data_clear(QQmlListProperty< QObject > *)
static qsizetype children_count(QQmlListProperty< QQuickItem > *)
static void children_clear(QQmlListProperty< QQuickItem > *)
static qsizetype data_count(QQmlListProperty< QObject > *)
\qmlproperty list<QtObject> QtQuick::Item::data \qmldefault
static QQuickItem * children_at(QQmlListProperty< QQuickItem > *, qsizetype)
static QObject * data_at(QQmlListProperty< QObject > *, qsizetype)
static void children_append(QQmlListProperty< QQuickItem > *, QQuickItem *)
static void data_append(QQmlListProperty< QObject > *, QObject *)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
QList< QQuickItem * > childItems() const
Returns the children of this item.
qreal implicitWidth
Definition qquickitem.h:114
qreal width
This property holds the width of this item.
Definition qquickitem.h:75
void childrenChanged()
qreal implicitHeight
Definition qquickitem.h:115
qreal height
This property holds the height of this item.
Definition qquickitem.h:76
bool handlePress(const QPointF &point, ulong timestamp) override
virtual QQmlListProperty< QObject > contentData()
\qmlproperty list<QtObject> QtQuick.Controls::Pane::contentData \qmldefault
void contentChildrenChange()
void itemImplicitWidthChanged(QQuickItem *item) override
qreal getContentWidth() const override
virtual QQuickItem * getFirstChild() const
void itemDestroyed(QQuickItem *item) override
QQuickItem * getContentItem() override
virtual QList< QQuickItem * > contentChildItems() const
QQuickItem * firstChild
virtual QQmlListProperty< QQuickItem > contentChildren()
\qmlproperty list<Item> QtQuick.Controls::Pane::contentChildren
void itemImplicitHeightChanged(QQuickItem *item) override
qreal getContentHeight() const override
void resetContentHeight()
void setContentWidth(qreal width)
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override
void contentWidthChanged()
QQuickPane(QQuickItem *parent=nullptr)
void resetContentWidth()
void setContentHeight(qreal height)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void contentHeightChanged()
virtual void contentSizeChange(const QSizeF &newSize, const QSizeF &oldSize)
qreal contentHeight
qreal contentWidth
\inmodule QtCore
Definition qsize.h:208
Combined button and popup list for selecting options.
@ AllButtons
Definition qnamespace.h:90
@ ArrowCursor
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLint GLsizei GLsizei height
GLint GLsizei width
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
static const struct TessellationWindingOrderTab cw[]
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define emit
#define Q_UNUSED(x)
unsigned long ulong
Definition qtypes.h:35
double qreal
Definition qtypes.h:187
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QGraphicsItem * item
widget setSizePolicy(policy)