1 // Commit: ac5c099cc3c5b8c7eec7a49fdeb8a21037230350
2 /****************************************************************************
4 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** No Commercial Usage
12 ** This file contains pre-release code and may not be distributed.
13 ** You may use this file in accordance with the terms and conditions
14 ** contained in the Technology Preview License Agreement accompanying
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
41 ****************************************************************************/
43 #ifndef QSGPATHVIEW_P_H
44 #define QSGPATHVIEW_P_H
48 #include <private/qdeclarativepath_p.h>
54 QT_MODULE(Declarative)
56 class QSGPathViewPrivate;
57 class QSGPathViewAttached;
58 class Q_AUTOTEST_EXPORT QSGPathView : public QSGItem
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(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
67 Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
68 Q_PROPERTY(QSGItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
70 Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
71 Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
72 Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
73 Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
75 Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
76 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
77 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
79 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
80 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
82 Q_PROPERTY(int count READ count NOTIFY countChanged)
83 Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
84 Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
86 Q_ENUMS(HighlightRangeMode)
89 QSGPathView(QSGItem *parent=0);
90 virtual ~QSGPathView();
92 QVariant model() const;
93 void setModel(const QVariant &);
95 QDeclarativePath *path() const;
96 void setPath(QDeclarativePath *);
98 int currentIndex() const;
99 void setCurrentIndex(int idx);
101 qreal offset() const;
102 void setOffset(qreal offset);
104 QDeclarativeComponent *highlight() const;
105 void setHighlight(QDeclarativeComponent *highlight);
106 QSGItem *highlightItem();
108 enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
109 HighlightRangeMode highlightRangeMode() const;
110 void setHighlightRangeMode(HighlightRangeMode mode);
112 qreal preferredHighlightBegin() const;
113 void setPreferredHighlightBegin(qreal);
115 qreal preferredHighlightEnd() const;
116 void setPreferredHighlightEnd(qreal);
118 int highlightMoveDuration() const;
119 void setHighlightMoveDuration(int);
121 qreal dragMargin() const;
122 void setDragMargin(qreal margin);
124 qreal flickDeceleration() const;
125 void setFlickDeceleration(qreal dec);
127 bool isInteractive() const;
128 void setInteractive(bool);
130 bool isMoving() const;
131 bool isFlicking() const;
135 QDeclarativeComponent *delegate() const;
136 void setDelegate(QDeclarativeComponent *);
138 int pathItemCount() const;
139 void setPathItemCount(int);
141 static QSGPathViewAttached *qmlAttachedProperties(QObject *);
144 void incrementCurrentIndex();
145 void decrementCurrentIndex();
148 void currentIndexChanged();
149 void offsetChanged();
153 void preferredHighlightBeginChanged();
154 void preferredHighlightEndChanged();
155 void highlightRangeModeChanged();
156 void dragMarginChanged();
157 void snapPositionChanged();
158 void delegateChanged();
159 void pathItemCountChanged();
160 void flickDecelerationChanged();
161 void interactiveChanged();
162 void movingChanged();
163 void flickingChanged();
164 void highlightChanged();
165 void highlightItemChanged();
166 void highlightMoveDurationChanged();
167 void movementStarted();
168 void movementEnded();
173 virtual void updatePolish();
174 void mousePressEvent(QGraphicsSceneMouseEvent *event);
175 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
176 void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
177 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
178 bool childMouseEventFilter(QSGItem *, QEvent *);
179 void componentComplete();
184 void movementEnding();
185 void itemsInserted(int index, int count);
186 void itemsRemoved(int index, int count);
187 void itemsMoved(int,int,int);
189 void createdItem(int index, QSGItem *item);
190 void destroyingItem(QSGItem *item);
194 friend class QSGPathViewAttached;
195 Q_DISABLE_COPY(QSGPathView)
196 Q_DECLARE_PRIVATE(QSGPathView)
199 class QDeclarativeOpenMetaObject;
200 class QSGPathViewAttached : public QObject
204 Q_PROPERTY(QSGPathView *view READ view CONSTANT)
205 Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
206 Q_PROPERTY(bool onPath READ isOnPath NOTIFY pathChanged)
209 QSGPathViewAttached(QObject *parent);
210 ~QSGPathViewAttached();
212 QSGPathView *view() { return m_view; }
214 bool isCurrentItem() const { return m_isCurrent; }
215 void setIsCurrentItem(bool c) {
216 if (m_isCurrent != c) {
218 emit currentItemChanged();
222 QVariant value(const QByteArray &name) const;
223 void setValue(const QByteArray &name, const QVariant &val);
225 bool isOnPath() const { return m_onPath; }
226 void setOnPath(bool on) {
227 if (on != m_onPath) {
235 void currentItemChanged();
239 friend class QSGPathViewPrivate;
240 friend class QSGPathView;
242 QDeclarativeOpenMetaObject *m_metaobject;
244 bool m_isCurrent : 1;
250 QML_DECLARE_TYPE(QSGPathView)
251 QML_DECLARE_TYPEINFO(QSGPathView, QML_HAS_ATTACHED_PROPERTIES)
254 #endif // QSGPATHVIEW_P_H