1 // Commit: 95814418f9d6adeba365c795462e8afb00138211
2 /****************************************************************************
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
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.
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.
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.
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.
41 ****************************************************************************/
43 #ifndef QQUICKGRIDVIEW_P_H
44 #define QQUICKGRIDVIEW_P_H
46 #include "qquickitemview_p.h"
48 #include <private/qdeclarativeguard_p.h>
54 class QQuickVisualModel;
55 class QQuickGridViewAttached;
56 class QQuickGridViewPrivate;
57 class Q_AUTOTEST_EXPORT QQuickGridView : public QQuickItemView
60 Q_DECLARE_PRIVATE(QQuickGridView)
62 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
63 Q_PROPERTY(qreal cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
64 Q_PROPERTY(qreal cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
66 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
70 Q_CLASSINFO("DefaultProperty", "data")
73 QQuickGridView(QQuickItem *parent=0);
76 virtual void setHighlightFollowsCurrentItem(bool);
77 virtual void setHighlightMoveDuration(int);
79 enum Flow { LeftToRight, TopToBottom };
83 qreal cellWidth() const;
84 void setCellWidth(qreal);
86 qreal cellHeight() const;
87 void setCellHeight(qreal);
89 enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
90 SnapMode snapMode() const;
91 void setSnapMode(SnapMode mode);
93 static QQuickGridViewAttached *qmlAttachedProperties(QObject *);
96 void moveCurrentIndexUp();
97 void moveCurrentIndexDown();
98 void moveCurrentIndexLeft();
99 void moveCurrentIndexRight();
102 void cellWidthChanged();
103 void cellHeightChanged();
104 void highlightMoveDurationChanged();
106 void snapModeChanged();
109 virtual void viewportMoved();
110 virtual void keyPressEvent(QKeyEvent *);
113 class QQuickGridViewAttached : public QQuickItemViewAttached
117 QQuickGridViewAttached(QObject *parent)
118 : QQuickItemViewAttached(parent), m_view(0) {}
119 ~QQuickGridViewAttached() {}
121 Q_PROPERTY(QQuickGridView *view READ view NOTIFY viewChanged)
122 QQuickGridView *view() { return m_view; }
123 void setView(QQuickGridView *view) {
124 if (view != m_view) {
134 QDeclarativeGuard<QQuickGridView> m_view;
140 QML_DECLARE_TYPE(QQuickGridView)
141 QML_DECLARE_TYPEINFO(QQuickGridView, QML_HAS_ATTACHED_PROPERTIES)
145 #endif // QQUICKGRIDVIEW_P_H