Change copyrights from Nokia to Digia
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickgridview_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QQUICKGRIDVIEW_P_H
43 #define QQUICKGRIDVIEW_P_H
44
45 #include "qquickitemview_p.h"
46
47 #include <private/qqmlguard_p.h>
48
49 QT_BEGIN_HEADER
50
51 QT_BEGIN_NAMESPACE
52
53 class QQuickVisualModel;
54 class QQuickGridViewAttached;
55 class QQuickGridViewPrivate;
56 class Q_AUTOTEST_EXPORT QQuickGridView : public QQuickItemView
57 {
58     Q_OBJECT
59     Q_DECLARE_PRIVATE(QQuickGridView)
60
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)
64
65     Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
66
67     Q_ENUMS(SnapMode)
68     Q_ENUMS(Flow)
69     Q_CLASSINFO("DefaultProperty", "data")
70
71 public:
72     enum Flow {
73         FlowLeftToRight = LeftToRight,
74         FlowTopToBottom = TopToBottom
75     };
76
77     QQuickGridView(QQuickItem *parent=0);
78     ~QQuickGridView();
79
80     virtual void setHighlightFollowsCurrentItem(bool);
81     virtual void setHighlightMoveDuration(int);
82
83     Flow flow() const;
84     void setFlow(Flow);
85
86     qreal cellWidth() const;
87     void setCellWidth(qreal);
88
89     qreal cellHeight() const;
90     void setCellHeight(qreal);
91
92     enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
93     SnapMode snapMode() const;
94     void setSnapMode(SnapMode mode);
95
96     static QQuickGridViewAttached *qmlAttachedProperties(QObject *);
97
98 public Q_SLOTS:
99     void moveCurrentIndexUp();
100     void moveCurrentIndexDown();
101     void moveCurrentIndexLeft();
102     void moveCurrentIndexRight();
103
104 Q_SIGNALS:
105     void cellWidthChanged();
106     void cellHeightChanged();
107     void highlightMoveDurationChanged();
108     void flowChanged();
109     void snapModeChanged();
110
111 protected:
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);
116 };
117
118 class QQuickGridViewAttached : public QQuickItemViewAttached
119 {
120     Q_OBJECT
121 public:
122     QQuickGridViewAttached(QObject *parent)
123         : QQuickItemViewAttached(parent), m_view(0) {}
124     ~QQuickGridViewAttached() {}
125
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) {
130             m_view = view;
131             emit viewChanged();
132         }
133     }
134
135 Q_SIGNALS:
136     void viewChanged();
137
138 public:
139     QQmlGuard<QQuickGridView> m_view;
140 };
141
142
143 QT_END_NAMESPACE
144
145 QML_DECLARE_TYPE(QQuickGridView)
146 QML_DECLARE_TYPEINFO(QQuickGridView, QML_HAS_ATTACHED_PROPERTIES)
147
148 QT_END_HEADER
149
150 #endif // QQUICKGRIDVIEW_P_H