Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / qtquick1 / graphicsitems / qdeclarativepathview_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDECLARATIVEPATHVIEW_H
43 #define QDECLARATIVEPATHVIEW_H
44
45 #include "qdeclarativeitem.h"
46 #include "QtQuick1/private/qdeclarativepath_p.h"
47
48 QT_BEGIN_HEADER
49
50 QT_BEGIN_NAMESPACE
51
52
53 class QDeclarative1PathViewPrivate;
54 class QDeclarative1PathViewAttached;
55 class Q_AUTOTEST_EXPORT QDeclarative1PathView : public QDeclarativeItem
56 {
57     Q_OBJECT
58
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)
63
64     Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged)
65     Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged)
66
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)
71
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)
75
76     Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
77     Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
78
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)
82
83     Q_ENUMS(HighlightRangeMode)
84
85 public:
86     QDeclarative1PathView(QDeclarativeItem *parent=0);
87     virtual ~QDeclarative1PathView();
88
89     QVariant model() const;
90     void setModel(const QVariant &);
91
92     QDeclarative1Path *path() const;
93     void setPath(QDeclarative1Path *);
94
95     int currentIndex() const;
96     void setCurrentIndex(int idx);
97
98     qreal offset() const;
99     void setOffset(qreal offset);
100
101     QDeclarativeComponent *highlight() const;
102     void setHighlight(QDeclarativeComponent *highlight);
103     QDeclarativeItem *highlightItem();
104
105     enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
106     HighlightRangeMode highlightRangeMode() const;
107     void setHighlightRangeMode(HighlightRangeMode mode);
108
109     qreal preferredHighlightBegin() const;
110     void setPreferredHighlightBegin(qreal);
111
112     qreal preferredHighlightEnd() const;
113     void setPreferredHighlightEnd(qreal);
114
115     int highlightMoveDuration() const;
116     void setHighlightMoveDuration(int);
117
118     qreal dragMargin() const;
119     void setDragMargin(qreal margin);
120
121     qreal flickDeceleration() const;
122     void setFlickDeceleration(qreal dec);
123
124     bool isInteractive() const;
125     void setInteractive(bool);
126
127     bool isMoving() const;
128     bool isFlicking() const;
129
130     int count() const;
131
132     QDeclarativeComponent *delegate() const;
133     void setDelegate(QDeclarativeComponent *);
134
135     int pathItemCount() const;
136     void setPathItemCount(int);
137
138     static QDeclarative1PathViewAttached *qmlAttachedProperties(QObject *);
139
140 public Q_SLOTS:
141     void incrementCurrentIndex();
142     void decrementCurrentIndex();
143
144 Q_SIGNALS:
145     void currentIndexChanged();
146     void offsetChanged();
147     void modelChanged();
148     void countChanged();
149     void pathChanged();
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();
166     void flickStarted();
167     void flickEnded();
168
169 protected:
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();
178
179 private Q_SLOTS:
180     void refill();
181     void ticked();
182     void movementEnding();
183     void itemsInserted(int index, int count);
184     void itemsRemoved(int index, int count);
185     void itemsMoved(int,int,int);
186     void modelReset();
187     void createdItem(int index, QDeclarativeItem *item);
188     void destroyingItem(QDeclarativeItem *item);
189     void pathUpdated();
190
191 private:
192     friend class QDeclarative1PathViewAttached;
193     Q_DISABLE_COPY(QDeclarative1PathView)
194     Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PathView)
195 };
196
197 class QDeclarative1OpenMetaObject;
198 class QDeclarative1PathViewAttached : public QObject
199 {
200     Q_OBJECT
201
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)
205
206 public:
207     QDeclarative1PathViewAttached(QObject *parent);
208     ~QDeclarative1PathViewAttached();
209
210     QDeclarative1PathView *view() { return m_view; }
211
212     bool isCurrentItem() const { return m_isCurrent; }
213     void setIsCurrentItem(bool c) {
214         if (m_isCurrent != c) {
215             m_isCurrent = c;
216             emit currentItemChanged();
217         }
218     }
219
220     QVariant value(const QByteArray &name) const;
221     void setValue(const QByteArray &name, const QVariant &val);
222
223     bool isOnPath() const { return m_onPath; }
224     void setOnPath(bool on) {
225         if (on != m_onPath) {
226             m_onPath = on;
227             emit pathChanged();
228         }
229     }
230     qreal m_percent;
231
232 Q_SIGNALS:
233     void currentItemChanged();
234     void pathChanged();
235
236 private:
237     friend class QDeclarative1PathViewPrivate;
238     friend class QDeclarative1PathView;
239     QDeclarative1PathView *m_view;
240     QDeclarative1OpenMetaObject *m_metaobject;
241     bool m_onPath : 1;
242     bool m_isCurrent : 1;
243 };
244
245
246 QT_END_NAMESPACE
247
248 QML_DECLARE_TYPE(QDeclarative1PathView)
249 QML_DECLARE_TYPEINFO(QDeclarative1PathView, QML_HAS_ATTACHED_PROPERTIES)
250 QT_END_HEADER
251
252 #endif // QDECLARATIVEPATHVIEW_H