Remove properties related to highlight speed
[profile/ivi/qtdeclarative.git] / src / quick / items / qquicklistview_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 QtQml 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 QQUICKLISTVIEW_P_H
43 #define QQUICKLISTVIEW_P_H
44
45 #include "qquickitemview_p.h"
46
47 #include <private/qqmlguard_p.h>
48
49 QT_BEGIN_HEADER
50
51 QT_BEGIN_NAMESPACE
52
53 class QQuickListView;
54 class QQuickListViewPrivate;
55 class Q_AUTOTEST_EXPORT QQuickViewSection : public QObject
56 {
57     Q_OBJECT
58     Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
59     Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged)
60     Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
61     Q_PROPERTY(int labelPositioning READ labelPositioning WRITE setLabelPositioning NOTIFY labelPositioningChanged)
62     Q_ENUMS(SectionCriteria)
63     Q_ENUMS(LabelPositioning)
64 public:
65     QQuickViewSection(QQuickListView *parent=0);
66
67     QString property() const { return m_property; }
68     void setProperty(const QString &);
69
70     enum SectionCriteria { FullString, FirstCharacter };
71     SectionCriteria criteria() const { return m_criteria; }
72     void setCriteria(SectionCriteria);
73
74     QQmlComponent *delegate() const { return m_delegate; }
75     void setDelegate(QQmlComponent *delegate);
76
77     QString sectionString(const QString &value);
78
79     enum LabelPositioning { InlineLabels = 0x01, CurrentLabelAtStart = 0x02, NextLabelAtEnd = 0x04 };
80     int labelPositioning() { return m_labelPositioning; }
81     void setLabelPositioning(int pos);
82
83 Q_SIGNALS:
84     void propertyChanged();
85     void criteriaChanged();
86     void delegateChanged();
87     void labelPositioningChanged();
88
89 private:
90     QString m_property;
91     SectionCriteria m_criteria;
92     QQmlComponent *m_delegate;
93     int m_labelPositioning;
94     QQuickListViewPrivate *m_view;
95 };
96
97
98 class QQuickVisualModel;
99 class QQuickListViewAttached;
100 class Q_AUTOTEST_EXPORT QQuickListView : public QQuickItemView
101 {
102     Q_OBJECT
103     Q_DECLARE_PRIVATE(QQuickListView)
104
105     Q_PROPERTY(int highlightResizeDuration READ highlightResizeDuration WRITE setHighlightResizeDuration NOTIFY highlightResizeDurationChanged)
106
107     Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
108     Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
109
110     Q_PROPERTY(QQuickViewSection *section READ sectionCriteria CONSTANT)
111     Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
112
113     Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
114
115     Q_ENUMS(Orientation)
116     Q_ENUMS(SnapMode)
117     Q_CLASSINFO("DefaultProperty", "data")
118
119 public:
120     QQuickListView(QQuickItem *parent=0);
121     ~QQuickListView();
122
123     qreal spacing() const;
124     void setSpacing(qreal spacing);
125
126     enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
127     Orientation orientation() const;
128     void setOrientation(Orientation);
129
130     QQuickViewSection *sectionCriteria();
131     QString currentSection() const;
132
133     virtual void setHighlightFollowsCurrentItem(bool);
134
135     int highlightResizeDuration() const;
136     void setHighlightResizeDuration(int);
137
138     virtual void setHighlightMoveDuration(int);
139
140     enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
141     SnapMode snapMode() const;
142     void setSnapMode(SnapMode mode);
143
144     static QQuickListViewAttached *qmlAttachedProperties(QObject *);
145
146 public Q_SLOTS:
147     void incrementCurrentIndex();
148     void decrementCurrentIndex();
149
150 Q_SIGNALS:
151     void spacingChanged();
152     void orientationChanged();
153     void currentSectionChanged();
154     void highlightResizeDurationChanged();
155     void snapModeChanged();
156
157 protected:
158     virtual void viewportMoved(Qt::Orientations orient);
159     virtual void keyPressEvent(QKeyEvent *);
160     virtual void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry);
161
162 protected Q_SLOTS:
163     void updateSections();
164 };
165
166 class QQuickListViewAttached : public QQuickItemViewAttached
167 {
168     Q_OBJECT
169
170 public:
171     QQuickListViewAttached(QObject *parent)
172         : QQuickItemViewAttached(parent), m_view(0), m_sectionItem(0) {}
173     ~QQuickListViewAttached() {}
174
175     Q_PROPERTY(QQuickListView *view READ view NOTIFY viewChanged)
176     QQuickListView *view() { return m_view; }
177     void setView(QQuickListView *view) {
178         if (view != m_view) {
179             m_view = view;
180             emit viewChanged();
181         }
182     }
183
184 Q_SIGNALS:
185     void viewChanged();
186
187 public:
188     QQmlGuard<QQuickListView> m_view;
189     QQuickItem *m_sectionItem;
190 };
191
192
193 QT_END_NAMESPACE
194
195 QML_DECLARE_TYPEINFO(QQuickListView, QML_HAS_ATTACHED_PROPERTIES)
196 QML_DECLARE_TYPE(QQuickListView)
197 QML_DECLARE_TYPE(QQuickViewSection)
198
199 QT_END_HEADER
200
201 #endif // QQUICKLISTVIEW_P_H