1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
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.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEPATHVIEW_H
43 #define QDECLARATIVEPATHVIEW_H
45 #include "qdeclarativeitem.h"
46 #include "QtQuick1/private/qdeclarativepath_p.h"
53 class QDeclarative1PathViewPrivate;
54 class QDeclarative1PathViewAttached;
55 class Q_AUTOTEST_EXPORT QDeclarative1PathView : public QDeclarativeItem
59 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
60 Q_PROPERTY(QDeclarative1Path *path READ path WRITE setPath NOTIFY pathChanged)
61 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
62 Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged)
64 Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
65 Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
67 Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged)
68 Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
69 Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged)
70 Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged)
72 Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged)
73 Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
74 Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
76 Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
77 Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
79 Q_PROPERTY(int count READ count NOTIFY countChanged)
80 Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
81 Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged)
83 Q_ENUMS(HighlightRangeMode)
86 QDeclarative1PathView(QDeclarativeItem *parent=0);
87 virtual ~QDeclarative1PathView();
89 QVariant model() const;
90 void setModel(const QVariant &);
92 QDeclarative1Path *path() const;
93 void setPath(QDeclarative1Path *);
95 int currentIndex() const;
96 void setCurrentIndex(int idx);
99 void setOffset(qreal offset);
101 QDeclarativeComponent *highlight() const;
102 void setHighlight(QDeclarativeComponent *highlight);
103 QDeclarativeItem *highlightItem();
105 enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
106 HighlightRangeMode highlightRangeMode() const;
107 void setHighlightRangeMode(HighlightRangeMode mode);
109 qreal preferredHighlightBegin() const;
110 void setPreferredHighlightBegin(qreal);
112 qreal preferredHighlightEnd() const;
113 void setPreferredHighlightEnd(qreal);
115 int highlightMoveDuration() const;
116 void setHighlightMoveDuration(int);
118 qreal dragMargin() const;
119 void setDragMargin(qreal margin);
121 qreal flickDeceleration() const;
122 void setFlickDeceleration(qreal dec);
124 bool isInteractive() const;
125 void setInteractive(bool);
127 bool isMoving() const;
128 bool isFlicking() const;
132 QDeclarativeComponent *delegate() const;
133 void setDelegate(QDeclarativeComponent *);
135 int pathItemCount() const;
136 void setPathItemCount(int);
138 static QDeclarative1PathViewAttached *qmlAttachedProperties(QObject *);
141 void incrementCurrentIndex();
142 void decrementCurrentIndex();
145 void currentIndexChanged();
146 void offsetChanged();
150 void preferredHighlightBeginChanged();
151 void preferredHighlightEndChanged();
152 void highlightRangeModeChanged();
153 void dragMarginChanged();
154 void snapPositionChanged();
155 void delegateChanged();
156 void pathItemCountChanged();
157 void flickDecelerationChanged();
158 void interactiveChanged();
159 void movingChanged();
160 void flickingChanged();
161 void highlightChanged();
162 void highlightItemChanged();
163 void highlightMoveDurationChanged();
164 void movementStarted();
165 void movementEnded();
170 void mousePressEvent(QGraphicsSceneMouseEvent *event);
171 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
172 void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
173 bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
174 bool sceneEventFilter(QGraphicsItem *, QEvent *);
175 bool sceneEvent(QEvent *event);
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