Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / qquickgridview_p.h
1 // Commit: 95814418f9d6adeba365c795462e8afb00138211
2 /****************************************************************************
3 **
4 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
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.
17 **
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.
21 **
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.
29 **
30 ** Other Usage
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.
33 **
34 **
35 **
36 **
37 **
38 **
39 ** $QT_END_LICENSE$
40 **
41 ****************************************************************************/
42
43 #ifndef QQUICKGRIDVIEW_P_H
44 #define QQUICKGRIDVIEW_P_H
45
46 #include "qquickitemview_p.h"
47
48 #include <private/qdeclarativeguard_p.h>
49
50 QT_BEGIN_HEADER
51
52 QT_BEGIN_NAMESPACE
53
54 class QQuickVisualModel;
55 class QQuickGridViewAttached;
56 class QQuickGridViewPrivate;
57 class Q_AUTOTEST_EXPORT QQuickGridView : public QQuickItemView
58 {
59     Q_OBJECT
60     Q_DECLARE_PRIVATE(QQuickGridView)
61
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)
65
66     Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged)
67
68     Q_ENUMS(SnapMode)
69     Q_ENUMS(Flow)
70     Q_CLASSINFO("DefaultProperty", "data")
71
72 public:
73     QQuickGridView(QQuickItem *parent=0);
74     ~QQuickGridView();
75
76     virtual void setHighlightFollowsCurrentItem(bool);
77     virtual void setHighlightMoveDuration(int);
78
79     enum Flow { LeftToRight, TopToBottom };
80     Flow flow() const;
81     void setFlow(Flow);
82
83     qreal cellWidth() const;
84     void setCellWidth(qreal);
85
86     qreal cellHeight() const;
87     void setCellHeight(qreal);
88
89     enum SnapMode { NoSnap, SnapToRow, SnapOneRow };
90     SnapMode snapMode() const;
91     void setSnapMode(SnapMode mode);
92
93     static QQuickGridViewAttached *qmlAttachedProperties(QObject *);
94
95 public Q_SLOTS:
96     void moveCurrentIndexUp();
97     void moveCurrentIndexDown();
98     void moveCurrentIndexLeft();
99     void moveCurrentIndexRight();
100
101 Q_SIGNALS:
102     void cellWidthChanged();
103     void cellHeightChanged();
104     void highlightMoveDurationChanged();
105     void flowChanged();
106     void snapModeChanged();
107
108 protected:
109     virtual void viewportMoved();
110     virtual void keyPressEvent(QKeyEvent *);
111 };
112
113 class QQuickGridViewAttached : public QQuickItemViewAttached
114 {
115     Q_OBJECT
116 public:
117     QQuickGridViewAttached(QObject *parent)
118         : QQuickItemViewAttached(parent), m_view(0) {}
119     ~QQuickGridViewAttached() {}
120
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) {
125             m_view = view;
126             emit viewChanged();
127         }
128     }
129
130 Q_SIGNALS:
131     void viewChanged();
132
133 public:
134     QDeclarativeGuard<QQuickGridView> m_view;
135 };
136
137
138 QT_END_NAMESPACE
139
140 QML_DECLARE_TYPE(QQuickGridView)
141 QML_DECLARE_TYPEINFO(QQuickGridView, QML_HAS_ATTACHED_PROPERTIES)
142
143 QT_END_HEADER
144
145 #endif // QQUICKGRIDVIEW_P_H