1 // Commit: ac5c099cc3c5b8c7eec7a49fdeb8a21037230350
2 /****************************************************************************
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
41 ****************************************************************************/
43 #ifndef QQUICKPATHVIEW_P_H
44 #define QQUICKPATHVIEW_P_H
46 #include "qquickitem.h"
48 #include <private/qdeclarativepath_p.h>
54 class QDeclarativeChangeSet;
56 class QQuickPathViewPrivate;
57 class QQuickPathViewAttached;
58 class Q_AUTOTEST_EXPORT QQuickPathView : public QQuickItem
62 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
63 Q_PROPERTY(QDeclarativePath *path READ path WRITE setPath NOTIFY pathChanged)
64 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
65 Q_PROPERTY(QQuickItem *currentItem READ currentItem NOTIFY currentItemChanged)
66 Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
68 Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
69 Q_PROPERTY(QQuickItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
71 Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
72 Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
73 Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
74 Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
76 Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
77 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
78 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
80 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
81 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
83 Q_PROPERTY(int count READ count NOTIFY countChanged)
84 Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
85 Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
87 Q_ENUMS(HighlightRangeMode)
90 QQuickPathView(QQuickItem *parent=0);
91 virtual ~QQuickPathView();
93 QVariant model() const;
94 void setModel(const QVariant &);
96 QDeclarativePath *path() const;
97 void setPath(QDeclarativePath *);
99 int currentIndex() const;
100 void setCurrentIndex(int idx);
102 QQuickItem *currentItem() const;
104 qreal offset() const;
105 void setOffset(qreal offset);
107 QDeclarativeComponent *highlight() const;
108 void setHighlight(QDeclarativeComponent *highlight);
109 QQuickItem *highlightItem();
111 enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
112 HighlightRangeMode highlightRangeMode() const;
113 void setHighlightRangeMode(HighlightRangeMode mode);
115 qreal preferredHighlightBegin() const;
116 void setPreferredHighlightBegin(qreal);
118 qreal preferredHighlightEnd() const;
119 void setPreferredHighlightEnd(qreal);
121 int highlightMoveDuration() const;
122 void setHighlightMoveDuration(int);
124 qreal dragMargin() const;
125 void setDragMargin(qreal margin);
127 qreal flickDeceleration() const;
128 void setFlickDeceleration(qreal dec);
130 bool isInteractive() const;
131 void setInteractive(bool);
133 bool isMoving() const;
134 bool isFlicking() const;
138 QDeclarativeComponent *delegate() const;
139 void setDelegate(QDeclarativeComponent *);
141 int pathItemCount() const;
142 void setPathItemCount(int);
144 static QQuickPathViewAttached *qmlAttachedProperties(QObject *);
147 void incrementCurrentIndex();
148 void decrementCurrentIndex();
151 void currentIndexChanged();
152 void currentItemChanged();
153 void offsetChanged();
157 void preferredHighlightBeginChanged();
158 void preferredHighlightEndChanged();
159 void highlightRangeModeChanged();
160 void dragMarginChanged();
161 void snapPositionChanged();
162 void delegateChanged();
163 void pathItemCountChanged();
164 void flickDecelerationChanged();
165 void interactiveChanged();
166 void movingChanged();
167 void flickingChanged();
168 void highlightChanged();
169 void highlightItemChanged();
170 void highlightMoveDurationChanged();
171 void movementStarted();
172 void movementEnded();
177 virtual void updatePolish();
178 void mousePressEvent(QMouseEvent *event);
179 void mouseMoveEvent(QMouseEvent *event);
180 void mouseReleaseEvent(QMouseEvent *);
181 bool sendMouseEvent(QMouseEvent *event);
182 bool childMouseEventFilter(QQuickItem *, QEvent *);
183 void mouseUngrabEvent();
184 void componentComplete();
189 void movementEnding();
190 void modelUpdated(const QDeclarativeChangeSet &changeSet, bool reset);
191 void createdItem(int index, QQuickItem *item);
192 void initItem(int index, QQuickItem *item);
193 void destroyingItem(QQuickItem *item);
197 friend class QQuickPathViewAttached;
198 Q_DISABLE_COPY(QQuickPathView)
199 Q_DECLARE_PRIVATE(QQuickPathView)
202 class QDeclarativeOpenMetaObject;
203 class QQuickPathViewAttached : public QObject
207 Q_PROPERTY(QQuickPathView *view READ view CONSTANT)
208 Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
209 Q_PROPERTY(bool onPath READ isOnPath NOTIFY pathChanged)
212 QQuickPathViewAttached(QObject *parent);
213 ~QQuickPathViewAttached();
215 QQuickPathView *view() { return m_view; }
217 bool isCurrentItem() const { return m_isCurrent; }
218 void setIsCurrentItem(bool c) {
219 if (m_isCurrent != c) {
221 emit currentItemChanged();
225 QVariant value(const QByteArray &name) const;
226 void setValue(const QByteArray &name, const QVariant &val);
228 bool isOnPath() const { return m_onPath; }
229 void setOnPath(bool on) {
230 if (on != m_onPath) {
238 void currentItemChanged();
242 friend class QQuickPathViewPrivate;
243 friend class QQuickPathView;
244 QQuickPathView *m_view;
245 QDeclarativeOpenMetaObject *m_metaobject;
247 bool m_isCurrent : 1;
253 QML_DECLARE_TYPE(QQuickPathView)
254 QML_DECLARE_TYPEINFO(QQuickPathView, QML_HAS_ATTACHED_PROPERTIES)
257 #endif // QQUICKPATHVIEW_P_H