1 // Commit: 95814418f9d6adeba365c795462e8afb00138211
2 /****************************************************************************
4 ** Copyright (C) 2011 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 QSGLISTVIEW_P_H
44 #define QSGLISTVIEW_P_H
46 #include "qsgitemview_p.h"
48 #include <private/qdeclarativeguard_p.h>
54 QT_MODULE(Declarative)
57 class QSGListViewPrivate;
58 class Q_AUTOTEST_EXPORT QSGViewSection : public QObject
61 Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged)
62 Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged)
63 Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
64 Q_PROPERTY(int labelPositioning READ labelPositioning WRITE setLabelPositioning NOTIFY labelPositioningChanged)
65 Q_ENUMS(SectionCriteria)
66 Q_ENUMS(LabelPositioning)
68 QSGViewSection(QSGListView *parent=0);
70 QString property() const { return m_property; }
71 void setProperty(const QString &);
73 enum SectionCriteria { FullString, FirstCharacter };
74 SectionCriteria criteria() const { return m_criteria; }
75 void setCriteria(SectionCriteria);
77 QDeclarativeComponent *delegate() const { return m_delegate; }
78 void setDelegate(QDeclarativeComponent *delegate);
80 QString sectionString(const QString &value);
82 enum LabelPositioning { InlineLabels = 0x01, CurrentLabelAtStart = 0x02, NextLabelAtEnd = 0x04 };
83 int labelPositioning() { return m_labelPositioning; }
84 void setLabelPositioning(int pos);
87 void propertyChanged();
88 void criteriaChanged();
89 void delegateChanged();
90 void labelPositioningChanged();
94 SectionCriteria m_criteria;
95 QDeclarativeComponent *m_delegate;
96 int m_labelPositioning;
97 QSGListViewPrivate *m_view;
101 class QSGVisualModel;
102 class QSGListViewAttached;
103 class Q_AUTOTEST_EXPORT QSGListView : public QSGItemView
106 Q_DECLARE_PRIVATE(QSGListView)
108 // XXX deprecate these two properties (only duration should be necessary)
109 Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
110 Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
112 Q_PROPERTY(int highlightResizeDuration READ highlightResizeDuration WRITE setHighlightResizeDuration NOTIFY highlightResizeDurationChanged)
114 Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
115 Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged)
117 Q_PROPERTY(QSGViewSection *section READ sectionCriteria CONSTANT)
118 Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged)
120 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
124 Q_CLASSINFO("DefaultProperty", "data")
127 QSGListView(QSGItem *parent=0);
130 qreal spacing() const;
131 void setSpacing(qreal spacing);
133 enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical };
134 Orientation orientation() const;
135 void setOrientation(Orientation);
137 QSGViewSection *sectionCriteria();
138 QString currentSection() const;
140 virtual void setHighlightFollowsCurrentItem(bool);
142 qreal highlightMoveSpeed() const;
143 void setHighlightMoveSpeed(qreal);
145 qreal highlightResizeSpeed() const;
146 void setHighlightResizeSpeed(qreal);
148 int highlightResizeDuration() const;
149 void setHighlightResizeDuration(int);
151 virtual void setHighlightMoveDuration(int);
153 enum SnapMode { NoSnap, SnapToItem, SnapOneItem };
154 SnapMode snapMode() const;
155 void setSnapMode(SnapMode mode);
157 static QSGListViewAttached *qmlAttachedProperties(QObject *);
160 void incrementCurrentIndex();
161 void decrementCurrentIndex();
164 void spacingChanged();
165 void orientationChanged();
166 void currentSectionChanged();
167 void highlightMoveSpeedChanged();
168 void highlightResizeSpeedChanged();
169 void highlightResizeDurationChanged();
170 void snapModeChanged();
173 virtual void viewportMoved();
174 virtual void keyPressEvent(QKeyEvent *);
175 virtual void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry);
178 void updateSections();
181 class QSGListViewAttached : public QSGItemViewAttached
186 QSGListViewAttached(QObject *parent)
187 : QSGItemViewAttached(parent), m_view(0) {}
188 ~QSGListViewAttached() {}
190 Q_PROPERTY(QSGListView *view READ view NOTIFY viewChanged)
191 QSGListView *view() { return m_view; }
192 void setView(QSGListView *view) {
193 if (view != m_view) {
203 QDeclarativeGuard<QSGListView> m_view;
209 QML_DECLARE_TYPEINFO(QSGListView, QML_HAS_ATTACHED_PROPERTIES)
210 QML_DECLARE_TYPE(QSGListView)
211 QML_DECLARE_TYPE(QSGViewSection)
215 #endif // QSGLISTVIEW_P_H