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#ifndef QQUICKTUMBLER_P_P_H
5#define QQUICKTUMBLER_P_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 <QtQuickTemplates2/private/qquickcontrol_p_p.h>
19#include <QtQuickTemplates2/private/qquicktumbler_p.h>
20
21#include <QtCore/qpointer.h>
22
23QT_BEGIN_NAMESPACE
24
25class Q_QUICKTEMPLATES2_EXPORT QQuickTumblerPrivate : public QQuickControlPrivate
26{
27 Q_DECLARE_PUBLIC(QQuickTumbler)
28
29public:
30 enum ContentItemType {
31 NoContentItem,
32 UnsupportedContentItemType,
33 PathViewContentItem,
34 ListViewContentItem
35 };
36
37 QQuickItem *determineViewType(QQuickItem *contentItem);
38 void resetViewData();
39 QList<QQuickItem *> viewContentItemChildItems() const;
40
41 static QQuickTumblerPrivate *get(QQuickTumbler *tumbler);
42
43 QPalette defaultPalette() const override;
44
45 QVariant model;
46 QQmlComponent *delegate = nullptr;
47 int visibleItemCount = 5;
48 bool wrap = true;
49 bool explicitWrap = false;
50 bool modelBeingSet = false;
51 bool currentIndexSetDuringModelChange = false;
52 QQuickItem *view = nullptr;
53 QQuickItem *viewContentItem = nullptr;
54 ContentItemType viewContentItemType = UnsupportedContentItemType;
55 union {
56 qreal viewOffset; // PathView
57 qreal viewContentY; // ListView
58 };
59 int currentIndex = -1;
60 int pendingCurrentIndex = -1;
61 bool ignoreCurrentIndexChanges = false;
62 int count = 0;
63 bool ignoreSignals = false;
64
65 void _q_updateItemHeights();
66 void _q_updateItemWidths();
67 void _q_onViewCurrentIndexChanged();
68 void _q_onViewCountChanged();
69 void _q_onViewOffsetChanged();
70 void _q_onViewContentYChanged();
71
72 void calculateDisplacements();
73
74 void disconnectFromView();
75 void setupViewData(QQuickItem *newControlContentItem);
76 void warnAboutIncorrectContentItem();
77 void syncCurrentIndex();
78 void setPendingCurrentIndex(int index);
79
80 enum PropertyChangeReason {
81 UserChange,
82 InternalChange
83 };
84
85 static QString propertyChangeReasonToString(PropertyChangeReason changeReason);
86
87 void setCurrentIndex(int newCurrentIndex, PropertyChangeReason changeReason = InternalChange);
88 void setCount(int newCount);
89 void setWrapBasedOnCount();
90 void setWrap(bool shouldWrap, bool isExplicit);
91 void beginSetModel();
92 void endSetModel();
93
94 void itemChildAdded(QQuickItem *, QQuickItem *) override;
95 void itemChildRemoved(QQuickItem *, QQuickItem *) override;
96 void itemGeometryChanged(QQuickItem *, QQuickGeometryChange , const QRectF &) override;
97};
98
99class QQuickTumblerAttachedPrivate : public QObjectPrivate
100{
101 Q_DECLARE_PUBLIC(QQuickTumblerAttached)
102
103public:
104 static QQuickTumblerAttachedPrivate *get(QQuickTumblerAttached *attached)
105 {
106 return attached->d_func();
107 }
108
109 void init(QQuickItem *delegateItem);
110
111 void calculateDisplacement();
112 void emitIfDisplacementChanged(qreal oldDisplacement, qreal newDisplacement);
113
114 // The Tumbler that contains the delegate. Required to calculated the displacement.
115 QPointer<QQuickTumbler> tumbler;
116 // The index of the delegate. Used to calculate the displacement.
117 int index = -1;
118 // The displacement for our delegate.
119 qreal displacement = 0;
120};
121
122QT_END_NAMESPACE
123
124#endif // QQUICKTUMBLER_P_P_H
125

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtdeclarative/src/quicktemplates/qquicktumbler_p_p.h