1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKGRIDVIEW_P_H
5#define QQUICKGRIDVIEW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/private/qtquickglobal_p.h>
19
20QT_REQUIRE_CONFIG(quick_gridview);
21
22#include "qquickitemview_p.h"
23
24QT_BEGIN_NAMESPACE
25
26class QQuickGridViewAttached;
27class QQuickGridViewPrivate;
28class Q_QUICK_PRIVATE_EXPORT QQuickGridView : public QQuickItemView
29{
30 Q_OBJECT
31 Q_DECLARE_PRIVATE(QQuickGridView)
32
33 Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged FINAL)
34 Q_PROPERTY(qreal cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged FINAL)
35 Q_PROPERTY(qreal cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged FINAL)
36
37 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL)
38
39 Q_CLASSINFO("DefaultProperty", "data")
40 QML_NAMED_ELEMENT(GridView)
41 QML_ADDED_IN_VERSION(2, 0)
42 QML_ATTACHED(QQuickGridViewAttached)
43
44public:
45 enum Flow {
46 FlowLeftToRight = LeftToRight,
47 FlowTopToBottom = TopToBottom
48 };
49 Q_ENUM(Flow)
50
51 QQuickGridView(QQuickItem *parent=nullptr);
52
53 void setHighlightFollowsCurrentItem(bool) override;
54 void setHighlightMoveDuration(int) override;
55
56 Flow flow() const;
57 void setFlow(Flow);
58
59 qreal cellWidth() const;
60 void setCellWidth(qreal);
61
62 qreal cellHeight() const;
63 void setCellHeight(qreal);
64
65 enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
66 Q_ENUM(SnapMode)
67 SnapMode snapMode() const;
68 void setSnapMode(SnapMode mode);
69
70 static QQuickGridViewAttached *qmlAttachedProperties(QObject *);
71
72public Q_SLOTS:
73 void moveCurrentIndexUp();
74 void moveCurrentIndexDown();
75 void moveCurrentIndexLeft();
76 void moveCurrentIndexRight();
77
78Q_SIGNALS:
79 void cellWidthChanged();
80 void cellHeightChanged();
81 void highlightMoveDurationChanged();
82 void flowChanged();
83 void snapModeChanged();
84
85protected:
86 void viewportMoved(Qt::Orientations) override;
87 void keyPressEvent(QKeyEvent *) override;
88 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
89 void initItem(int index, QObject *item) override;
90};
91
92class QQuickGridViewAttached : public QQuickItemViewAttached
93{
94 Q_OBJECT
95public:
96 QQuickGridViewAttached(QObject *parent)
97 : QQuickItemViewAttached(parent) {}
98 ~QQuickGridViewAttached() {}
99};
100
101
102QT_END_NAMESPACE
103
104QML_DECLARE_TYPE(QQuickGridView)
105
106#endif // QQUICKGRIDVIEW_P_H
107

source code of qtdeclarative/src/quick/items/qquickgridview_p.h