6#include <QtCore/qloggingcategory.h>
7#include <QtGui/qpa/qplatformtheme.h>
8#include <QtQml/qqmlinfo.h>
9#include <QtQuick/private/qquickflickable_p.h>
10#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
11#include <QtQuickTemplates2/private/qquicktumbler_p_p.h>
127 return tumbler->d_func();
138 const qreal itemHeight = delegateHeight(
q);
141 childItem->setHeight(itemHeight);
150 const qreal availableWidth =
q->availableWidth();
153 childItem->setWidth(availableWidth);
163 qCDebug(lcTumbler).nospace() <<
"view currentIndex changed to "
165 <<
", but we're ignoring it because one or more of the following conditions are true:"
166 <<
"\n- !view: " << !
view
175 qCDebug(lcTumbler).nospace() <<
"view currentIndex changed to "
177 <<
", our old currentIndex was " << oldCurrentIndex;
180 emit q->currentIndexChanged();
229 QQuickTumblerAttached *attached = qobject_cast<QQuickTumblerAttached *>(qmlAttachedPropertiesObject<QQuickTumbler>(childItem,
false));
274 d->disconnectFromView();
301 d->currentIndexSetDuringModelChange =
false;
306 d->setCurrentIndex(-1);
334 return d->currentIndex;
340 if (
d->modelBeingSet)
341 d->currentIndexSetDuringModelChange =
true;
356 return d->view ?
d->view->property(
"currentItem").value<
QQuickItem*>() :
nullptr;
389 return d->visibleItemCount;
399 d->_q_updateItemHeights();
430 d->setWrap(
wrap,
true);
436 d->explicitWrap =
false;
437 d->setWrapBasedOnCount();
450 return d->view &&
d->view->property(
"moving").toBool();
481 d->warnAboutIncorrectContentItem();
494 d->_q_updateItemHeights();
496 if (newGeometry.
width() != oldGeometry.
width())
497 d->_q_updateItemWidths();
503 qCDebug(lcTumbler) <<
"componentComplete()";
508 qCDebug(lcTumbler) <<
"emitting wrapChanged() to force view to be created";
511 d->setupViewData(
d->contentItem);
521 d->_q_updateItemHeights();
522 d->_q_updateItemWidths();
523 d->_q_onViewCountChanged();
525 qCDebug(lcTumbler) <<
"componentComplete() is done";
535 d->disconnectFromView();
543 d->setupViewData(newItem);
545 d->_q_updateItemHeights();
546 d->_q_updateItemWidths();
620 qmlWarning(
q) <<
"Tumbler: contentItem must contain either a PathView or a ListView";
632 if (actualViewIndex == indexToSet) {
639 if (
q->count() == 0 && actualViewIndex <= 0)
648 else if (isPendingCurrentIndex)
654 qCDebug(lcTumbler) <<
"setting pendingCurrentIndex to" <<
index;
668 qCDebug(lcTumbler).nospace() <<
"setting currentIndex to " << newCurrentIndex
671 if (newCurrentIndex ==
currentIndex || newCurrentIndex < -1)
674 if (!
q->isComponentComplete()) {
676 qCDebug(lcTumbler) <<
"we're not complete; setting pendingCurrentIndex instead";
686 qCDebug(lcTumbler) <<
"a model is being set; setting pendingCurrentIndex instead";
695 if ((
count > 0 && newCurrentIndex == -1) || (newCurrentIndex >=
count)) {
704 bool couldSet =
false;
705 if (
count == 0 && newCurrentIndex == -1) {
722 emit q->currentIndexChanged();
732 qCDebug(lcTumbler).nospace() <<
"setting count to " << newCount
733 <<
", old count was " <<
count;
734 if (newCount ==
count)
742 emit q->countChanged();
755 qCDebug(lcTumbler) <<
"setting wrap to" << shouldWrap <<
"- explicit?" << isExplicit;
760 if (
q->isComponentComplete() && shouldWrap ==
wrap)
777 emit q->wrapChanged();
812 if (
event->isAutoRepeat() || !
d->view)
825 if (
d->pendingCurrentIndex != -1) {
828 d->setCount(
d->view->property(
"count").toInt());
832 d->setPendingCurrentIndex(-1);
839 d->setCurrentIndex(
d->pendingCurrentIndex);
841 if (
d->currentIndex !=
d->pendingCurrentIndex &&
d->currentIndex == -1) {
844 d->setCurrentIndex(0);
847 d->setPendingCurrentIndex(-1);
860 qmlWarning(
q) <<
"Tumbler: attached properties must be accessed through a delegate item that has a parent";
865 if (!indexContextProperty.
isValid()) {
866 qmlWarning(
q) <<
"Tumbler: attempting to access attached property on item without an \"index\" property";
873 while ((parentItem = parentItem->
parentItem())) {
874 if ((
tumbler = qobject_cast<QQuickTumbler*>(parentItem)))
912 const int halfVisibleItems = visibleItems / 2 + (visibleItems <
count ? 1 : 0);
922 qreal currentItemY = 0;
925 currentItemY = currentItem->
y();
927 const qreal topOfCurrentItemInViewport = currentItemY - contentY;
929 const qreal relativePositionToPreferredHighlightBegin = topOfCurrentItemInViewport - preferredHighlightBegin;
931 const qreal distanceFromCurrentItem = currentItemY - itemY;
932 const qreal displacementInPixels = distanceFromCurrentItem - relativePositionToPreferredHighlightBegin;
943 if (newDisplacement != oldDisplacement)
944 emit q->displacementChanged();
953 d->init(delegateItem);
955 qmlWarning(
parent) <<
"Tumbler: attached properties of Tumbler must be accessed through a delegate item";
970 d->calculateDisplacement();
1009 return d->displacement;
1014#include "moc_qquicktumbler_p.cpp"
The QKeyEvent class describes a key event.
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
QVariant property(const char *name) const
Returns the value of the object's name property.
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
The QPalette class contains color groups for each widget state.
The QQmlComponent class encapsulates a QML component definition.
QVariant contextProperty(const QString &) const
Returns the value of the name property for this context as a QVariant.
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override
QQuickDeferredPointer< QQuickItem > contentItem
virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void rightPaddingChanged()
void bottomPaddingChanged()
void leftPaddingChanged()
void removeItemChangeListener(QQuickItemChangeListener *, ChangeTypes types)
void addItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
static QQuickItemPrivate * get(QQuickItem *item)
QList< QQuickItem * > childItems
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
QList< QQuickItem * > childItems() const
Returns the children of this item.
virtual void keyPressEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key press events for an item.
qreal y
Defines the item's y position relative to its parent.
QQuickItem * parentItem() const
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
void setActiveFocusOnTab(bool)
static QPalette palette(Scope scope)
static QFont font(Scope scope)
static QQuickTumblerAttachedPrivate * get(QQuickTumblerAttached *attached)
void calculateDisplacement()
void emitIfDisplacementChanged(qreal oldDisplacement, qreal newDisplacement)
void init(QQuickItem *delegateItem)
QPointer< QQuickTumbler > tumbler
QQuickTumblerAttached(QObject *parent=nullptr)
bool ignoreCurrentIndexChanges
ContentItemType viewContentItemType
QQuickItem * viewContentItem
void _q_onViewOffsetChanged()
bool currentIndexSetDuringModelChange
void warnAboutIncorrectContentItem()
void itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) override
void setCurrentIndex(int newCurrentIndex, PropertyChangeReason changeReason=InternalChange)
void _q_updateItemHeights()
QQuickItem * determineViewType(QQuickItem *contentItem)
void setWrapBasedOnCount()
void itemChildAdded(QQuickItem *, QQuickItem *) override
void _q_updateItemWidths()
void setCount(int newCount)
void _q_onViewCountChanged()
void disconnectFromView()
static QQuickTumblerPrivate * get(QQuickTumbler *tumbler)
void itemChildRemoved(QQuickItem *, QQuickItem *) override
QList< QQuickItem * > viewContentItemChildItems() const
void setPendingCurrentIndex(int index)
void _q_onViewContentYChanged()
void setupViewData(QQuickItem *newControlContentItem)
@ UnsupportedContentItemType
void _q_onViewCurrentIndexChanged()
void calculateDisplacements()
void setWrap(bool shouldWrap, bool isExplicit)
QPalette defaultPalette() const override
static QString propertyChangeReasonToString(PropertyChangeReason changeReason)
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void updatePolish() override
This function should perform any layout as required for this item.
void keyPressEvent(QKeyEvent *event) override
This event handler can be reimplemented in a subclass to receive key press events for an item.
QFont defaultFont() const override
void setCurrentIndex(int currentIndex)
QQuickTumbler(QQuickItem *parent=nullptr)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void visibleItemCountChanged()
void setDelegate(QQmlComponent *delegate)
void setModel(const QVariant &model)
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override
void setVisibleItemCount(int visibleItemCount)
static QQuickTumblerAttached * qmlAttachedProperties(QObject *object)
bool isMoving() const
\qmlproperty bool QtQuick.Controls::Tumbler::moving
\inmodule QtCore\reentrant
constexpr qreal width() const noexcept
Returns the width of the rectangle.
\macro QT_RESTRICTED_CAST_FROM_ASCII
qreal toReal(bool *ok=nullptr) const
Returns the variant as a qreal if the variant has userType() \l QMetaType::Double,...
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
Combined button and popup list for selecting options.
static qreal delegateHeight(const QQuickTumbler *tumbler)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_ARG(Type, data)
GLenum GLenum GLsizei count
GLenum GLuint GLintptr offset
GLdouble GLdouble GLdouble GLdouble q
QQmlContext * qmlContext(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
#define QStringLiteral(str)
QSqlQueryModel * model
[16]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent