1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
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.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEPATHVIEW_H
43 #define QDECLARATIVEPATHVIEW_H
45 #include "qdeclarativeitem.h"
46 #include "QtQuick1/private/qdeclarativepath_p.h"
52 QT_MODULE(Declarative)
54 class QDeclarative1PathViewPrivate;
55 class QDeclarative1PathViewAttached;
56 class Q_AUTOTEST_EXPORT QDeclarative1PathView : public QDeclarativeItem
60 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
61 Q_PROPERTY(QDeclarative1Path *path READ path WRITE setPath NOTIFY pathChanged)
62 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
63 Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
65 Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
66 Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
68 Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
69 Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
70 Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
71 Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
73 Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
74 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
75 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
77 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
78 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
80 Q_PROPERTY(int count READ count NOTIFY countChanged)
81 Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
82 Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
84 Q_ENUMS(HighlightRangeMode)
87 QDeclarative1PathView(QDeclarativeItem *parent=0);
88 virtual ~QDeclarative1PathView();
90 QVariant model() const;
91 void setModel(const QVariant &);
93 QDeclarative1Path *path() const;
94 void setPath(QDeclarative1Path *);
96 int currentIndex() const;
97 void setCurrentIndex(int idx);
100 void setOffset(qreal offset);
102 QDeclarativeComponent *highlight() const;
103 void setHighlight(QDeclarativeComponent *highlight);
104 QDeclarativeItem *highlightItem();
106 enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
107 HighlightRangeMode highlightRangeMode() const;
108 void setHighlightRangeMode(HighlightRangeMode mode);
110 qreal preferredHighlightBegin() const;
111 void setPreferredHighlightBegin(qreal);
113 qreal preferredHighlightEnd() const;
114 void setPreferredHighlightEnd(qreal);
116 int highlightMoveDuration() const;
117 void setHighlightMoveDuration(int);
119 qreal dragMargin() const;
120 void setDragMargin(qreal margin);
122 qreal flickDeceleration() const;
123 void setFlickDeceleration(qreal dec);
125 bool isInteractive() const;
126 void setInteractive(bool);
128 bool isMoving() const;
129 bool isFlicking() const;
133 QDeclarativeComponent *delegate() const;
134 void setDelegate(QDeclarativeComponent *);
136 int pathItemCount() const;
137 void setPathItemCount(int);
139 static QDeclarative1PathViewAttached *qmlAttachedProperties(QObject *);
142 void incrementCurrentIndex();
143 void decrementCurrentIndex();
146 void currentIndexChanged();
147 void offsetChanged();
151 void preferredHighlightBeginChanged();
152 void preferredHighlightEndChanged();
153 void highlightRangeModeChanged();
154 void dragMarginChanged();
155 void snapPositionChanged();
156 void delegateChanged();
157 void pathItemCountChanged();
158 void flickDecelerationChanged();
159 void interactiveChanged();
160 void movingChanged();
161 void flickingChanged();
162 void highlightChanged();
163 void highlightItemChanged();
164 void highlightMoveDurationChanged();
165 void movementStarted();
166 void movementEnded();
171 void mousePressEvent(QGraphicsSceneMouseEvent *event);
172 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
173 void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
174 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
175 bool sceneEventFilter(QGraphicsItem *, QEvent *);
176 bool event(QEvent *event);
177 void componentComplete();
182 void movementEnding();
183 void itemsInserted(int index, int count);
184 void itemsRemoved(int index, int count);
185 void itemsMoved(int,int,int);
187 void createdItem(int index, QDeclarativeItem *item);
188 void destroyingItem(QDeclarativeItem *item);
192 friend class QDeclarative1PathViewAttached;
193 Q_DISABLE_COPY(QDeclarative1PathView)
194 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PathView)
197 class QDeclarative1OpenMetaObject;
198 class QDeclarative1PathViewAttached : public QObject
202 Q_PROPERTY(QDeclarative1PathView *view READ view CONSTANT)
203 Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged)
204 Q_PROPERTY(bool onPath READ isOnPath NOTIFY pathChanged)
207 QDeclarative1PathViewAttached(QObject *parent);
208 ~QDeclarative1PathViewAttached();
210 QDeclarative1PathView *view() { return m_view; }
212 bool isCurrentItem() const { return m_isCurrent; }
213 void setIsCurrentItem(bool c) {
214 if (m_isCurrent != c) {
216 emit currentItemChanged();
220 QVariant value(const QByteArray &name) const;
221 void setValue(const QByteArray &name, const QVariant &val);
223 bool isOnPath() const { return m_onPath; }
224 void setOnPath(bool on) {
225 if (on != m_onPath) {
233 void currentItemChanged();
237 friend class QDeclarative1PathViewPrivate;
238 friend class QDeclarative1PathView;
239 QDeclarative1PathView *m_view;
240 QDeclarative1OpenMetaObject *m_metaobject;
242 bool m_isCurrent : 1;
248 QML_DECLARE_TYPE(QDeclarative1PathView)
249 QML_DECLARE_TYPEINFO(QDeclarative1PathView, QML_HAS_ATTACHED_PROPERTIES)
252 #endif // QDECLARATIVEPATHVIEW_H