1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
42 #ifndef QQUICKGRIDVIEW_P_H
43 #define QQUICKGRIDVIEW_P_H
45 #include "qquickitemview_p.h"
47 #include <private/qqmlguard_p.h>
53 class QQuickVisualModel;
54 class QQuickGridViewAttached;
55 class QQuickGridViewPrivate;
56 class Q_AUTOTEST_EXPORT QQuickGridView : public QQuickItemView
59 Q_DECLARE_PRIVATE(QQuickGridView)
61 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged)
62 Q_PROPERTY(qreal cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged)
63 Q_PROPERTY(qreal cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged)
65 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
69 Q_CLASSINFO("DefaultProperty", "data")
73 FlowLeftToRight = LeftToRight,
74 FlowTopToBottom = TopToBottom
77 QQuickGridView(QQuickItem *parent=0);
80 virtual void setHighlightFollowsCurrentItem(bool);
81 virtual void setHighlightMoveDuration(int);
86 qreal cellWidth() const;
87 void setCellWidth(qreal);
89 qreal cellHeight() const;
90 void setCellHeight(qreal);
92 enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
93 SnapMode snapMode() const;
94 void setSnapMode(SnapMode mode);
96 static QQuickGridViewAttached *qmlAttachedProperties(QObject *);
99 void moveCurrentIndexUp();
100 void moveCurrentIndexDown();
101 void moveCurrentIndexLeft();
102 void moveCurrentIndexRight();
105 void cellWidthChanged();
106 void cellHeightChanged();
107 void highlightMoveDurationChanged();
109 void snapModeChanged();
112 virtual void viewportMoved(Qt::Orientations);
113 virtual void keyPressEvent(QKeyEvent *);
114 virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
115 virtual void initItem(int index, QQuickItem *item);
118 class QQuickGridViewAttached : public QQuickItemViewAttached
122 QQuickGridViewAttached(QObject *parent)
123 : QQuickItemViewAttached(parent), m_view(0) {}
124 ~QQuickGridViewAttached() {}
126 Q_PROPERTY(QQuickGridView *view READ view NOTIFY viewChanged)
127 QQuickGridView *view() { return m_view; }
128 void setView(QQuickGridView *view) {
129 if (view != m_view) {
139 QQmlGuard<QQuickGridView> m_view;
145 QML_DECLARE_TYPE(QQuickGridView)
146 QML_DECLARE_TYPEINFO(QQuickGridView, QML_HAS_ATTACHED_PROPERTIES)
150 #endif // QQUICKGRIDVIEW_P_H