1 // Commit: 95814418f9d6adeba365c795462e8afb00138211
2 /****************************************************************************
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** All rights reserved.
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 ** This file is part of the QtDeclarative module of the Qt Toolkit.
10 ** $QT_BEGIN_LICENSE:LGPL$
11 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this
15 ** file. Please review the following information to ensure the GNU Lesser
16 ** General Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
23 ** GNU General Public License Usage
24 ** Alternatively, this file may be used under the terms of the GNU General
25 ** Public License version 3.0 as published by the Free Software Foundation
26 ** and appearing in the file LICENSE.GPL included in the packaging of this
27 ** file. Please review the following information to ensure the GNU General
28 ** Public License version 3.0 requirements will be met:
29 ** http://www.gnu.org/copyleft/gpl.html.
32 ** Alternatively, this file may be used in accordance with the terms and
33 ** conditions contained in a signed written agreement between you and Nokia.
41 ****************************************************************************/
43 #ifndef QQUICKLISTVIEW_P_H
44 #define QQUICKLISTVIEW_P_H
46 #include "qquickitemview_p.h"
48 #include <private/qdeclarativeguard_p.h>
55 class QQuickListViewPrivate;
56 class Q_AUTOTEST_EXPORT QQuickViewSection : public QObject
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)
66 QQuickViewSection(QQuickListView *parent=0);
68 QString property() const { return m_property; }
69 void setProperty(const QString &);
71 enum SectionCriteria { FullString, FirstCharacter };
72 SectionCriteria criteria() const { return m_criteria; }
73 void setCriteria(SectionCriteria);
75 QDeclarativeComponent *delegate() const { return m_delegate; }
76 void setDelegate(QDeclarativeComponent *delegate);
78 QString sectionString(const QString &value);
80 enum LabelPositioning { InlineLabels = 0x01, CurrentLabelAtStart = 0x02, NextLabelAtEnd = 0x04 };
81 int labelPositioning() { return m_labelPositioning; }
82 void setLabelPositioning(int pos);
85 void propertyChanged();
86 void criteriaChanged();
87 void delegateChanged();
88 void labelPositioningChanged();
92 SectionCriteria m_criteria;
93 QDeclarativeComponent *m_delegate;
94 int m_labelPositioning;
95 QQuickListViewPrivate *m_view;
99 class QQuickVisualModel;
100 class QQuickListViewAttached;
101 class Q_AUTOTEST_EXPORT QQuickListView : public QQuickItemView
104 Q_DECLARE_PRIVATE(QQuickListView)
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)
110 Q_PROPERTY(int highlightResizeDuration READ highlightResizeDuration WRITE setHighlightResizeDuration NOTIFY highlightResizeDurationChanged)
112 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
113 Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
115 Q_PROPERTY(QQuickViewSection *section READ sectionCriteria CONSTANT)
116 Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
118 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
122 Q_CLASSINFO("DefaultProperty", "data")
125 QQuickListView(QQuickItem *parent=0);
128 qreal spacing() const;
129 void setSpacing(qreal spacing);
131 enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
132 Orientation orientation() const;
133 void setOrientation(Orientation);
135 QQuickViewSection *sectionCriteria();
136 QString currentSection() const;
138 virtual void setHighlightFollowsCurrentItem(bool);
140 qreal highlightMoveSpeed() const;
141 void setHighlightMoveSpeed(qreal);
143 qreal highlightResizeSpeed() const;
144 void setHighlightResizeSpeed(qreal);
146 int highlightResizeDuration() const;
147 void setHighlightResizeDuration(int);
149 virtual void setHighlightMoveDuration(int);
151 enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
152 SnapMode snapMode() const;
153 void setSnapMode(SnapMode mode);
155 static QQuickListViewAttached *qmlAttachedProperties(QObject *);
158 void incrementCurrentIndex();
159 void decrementCurrentIndex();
162 void spacingChanged();
163 void orientationChanged();
164 void currentSectionChanged();
165 void highlightMoveSpeedChanged();
166 void highlightResizeSpeedChanged();
167 void highlightResizeDurationChanged();
168 void snapModeChanged();
171 virtual void viewportMoved();
172 virtual void keyPressEvent(QKeyEvent *);
173 virtual void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry);
176 void updateSections();
179 class QQuickListViewAttached : public QQuickItemViewAttached
184 QQuickListViewAttached(QObject *parent)
185 : QQuickItemViewAttached(parent), m_view(0) {}
186 ~QQuickListViewAttached() {}
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) {
201 QDeclarativeGuard<QQuickListView> m_view;
207 QML_DECLARE_TYPEINFO(QQuickListView, QML_HAS_ATTACHED_PROPERTIES)
208 QML_DECLARE_TYPE(QQuickListView)
209 QML_DECLARE_TYPE(QQuickViewSection)
213 #endif // QQUICKLISTVIEW_P_H