Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / qquicklistview_p.h
1 // Commit: 95814418f9d6adeba365c795462e8afb00138211
2 /****************************************************************************
3 **
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
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.
17 **
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.
21 **
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.
29 **
30 ** Other Usage
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.
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QQUICKLISTVIEW_P_H
44 #define QQUICKLISTVIEW_P_H
45
46 #include "qquickitemview_p.h"
47
48 #include <private/qdeclarativeguard_p.h>
49
50 QT_BEGIN_HEADER
51
52 QT_BEGIN_NAMESPACE
53
54 class QQuickListView;
55 class QQuickListViewPrivate;
56 class Q_AUTOTEST_EXPORT QQuickViewSection : public QObject
57 {
58     Q_OBJECT
59     Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
60     Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged)
61     Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
62     Q_PROPERTY(int labelPositioning READ labelPositioning WRITE setLabelPositioning NOTIFY labelPositioningChanged)
63     Q_ENUMS(SectionCriteria)
64     Q_ENUMS(LabelPositioning)
65 public:
66     QQuickViewSection(QQuickListView *parent=0);
67
68     QString property() const { return m_property; }
69     void setProperty(const QString &);
70
71     enum SectionCriteria { FullString, FirstCharacter };
72     SectionCriteria criteria() const { return m_criteria; }
73     void setCriteria(SectionCriteria);
74
75     QDeclarativeComponent *delegate() const { return m_delegate; }
76     void setDelegate(QDeclarativeComponent *delegate);
77
78     QString sectionString(const QString &value);
79
80     enum LabelPositioning { InlineLabels = 0x01, CurrentLabelAtStart = 0x02, NextLabelAtEnd = 0x04 };
81     int labelPositioning() { return m_labelPositioning; }
82     void setLabelPositioning(int pos);
83
84 Q_SIGNALS:
85     void propertyChanged();
86     void criteriaChanged();
87     void delegateChanged();
88     void labelPositioningChanged();
89
90 private:
91     QString m_property;
92     SectionCriteria m_criteria;
93     QDeclarativeComponent *m_delegate;
94     int m_labelPositioning;
95     QQuickListViewPrivate *m_view;
96 };
97
98
99 class QQuickVisualModel;
100 class QQuickListViewAttached;
101 class Q_AUTOTEST_EXPORT QQuickListView : public QQuickItemView
102 {
103     Q_OBJECT
104     Q_DECLARE_PRIVATE(QQuickListView)
105
106     // XXX deprecate these two properties (only duration should be necessary)
107     Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
108     Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
109
110     Q_PROPERTY(int highlightResizeDuration READ highlightResizeDuration WRITE setHighlightResizeDuration NOTIFY highlightResizeDurationChanged)
111
112     Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
113     Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
114
115     Q_PROPERTY(QQuickViewSection *section READ sectionCriteria CONSTANT)
116     Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
117
118     Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
119
120     Q_ENUMS(Orientation)
121     Q_ENUMS(SnapMode)
122     Q_CLASSINFO("DefaultProperty", "data")
123
124 public:
125     QQuickListView(QQuickItem *parent=0);
126     ~QQuickListView();
127
128     qreal spacing() const;
129     void setSpacing(qreal spacing);
130
131     enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
132     Orientation orientation() const;
133     void setOrientation(Orientation);
134
135     QQuickViewSection *sectionCriteria();
136     QString currentSection() const;
137
138     virtual void setHighlightFollowsCurrentItem(bool);
139
140     qreal highlightMoveSpeed() const;
141     void setHighlightMoveSpeed(qreal);
142
143     qreal highlightResizeSpeed() const;
144     void setHighlightResizeSpeed(qreal);
145
146     int highlightResizeDuration() const;
147     void setHighlightResizeDuration(int);
148
149     virtual void setHighlightMoveDuration(int);
150
151     enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
152     SnapMode snapMode() const;
153     void setSnapMode(SnapMode mode);
154
155     static QQuickListViewAttached *qmlAttachedProperties(QObject *);
156
157 public Q_SLOTS:
158     void incrementCurrentIndex();
159     void decrementCurrentIndex();
160
161 Q_SIGNALS:
162     void spacingChanged();
163     void orientationChanged();
164     void currentSectionChanged();
165     void highlightMoveSpeedChanged();
166     void highlightResizeSpeedChanged();
167     void highlightResizeDurationChanged();
168     void snapModeChanged();
169
170 protected:
171     virtual void viewportMoved();
172     virtual void keyPressEvent(QKeyEvent *);
173     virtual void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry);
174
175 protected Q_SLOTS:
176     void updateSections();
177 };
178
179 class QQuickListViewAttached : public QQuickItemViewAttached
180 {
181     Q_OBJECT
182
183 public:
184     QQuickListViewAttached(QObject *parent)
185         : QQuickItemViewAttached(parent), m_view(0) {}
186     ~QQuickListViewAttached() {}
187
188     Q_PROPERTY(QQuickListView *view READ view NOTIFY viewChanged)
189     QQuickListView *view() { return m_view; }
190     void setView(QQuickListView *view) {
191         if (view != m_view) {
192             m_view = view;
193             emit viewChanged();
194         }
195     }
196
197 Q_SIGNALS:
198     void viewChanged();
199
200 public:
201     QDeclarativeGuard<QQuickListView> m_view;
202 };
203
204
205 QT_END_NAMESPACE
206
207 QML_DECLARE_TYPEINFO(QQuickListView, QML_HAS_ATTACHED_PROPERTIES)
208 QML_DECLARE_TYPE(QQuickListView)
209 QML_DECLARE_TYPE(QQuickViewSection)
210
211 QT_END_HEADER
212
213 #endif // QQUICKLISTVIEW_P_H