1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QLISTVIEW_H
|
---|
43 | #define QLISTVIEW_H
|
---|
44 |
|
---|
45 | #include <QtGui/qabstractitemview.h>
|
---|
46 |
|
---|
47 | QT_BEGIN_HEADER
|
---|
48 |
|
---|
49 | QT_BEGIN_NAMESPACE
|
---|
50 |
|
---|
51 | QT_MODULE(Gui)
|
---|
52 |
|
---|
53 | #ifndef QT_NO_LISTVIEW
|
---|
54 |
|
---|
55 | class QListViewPrivate;
|
---|
56 |
|
---|
57 | class Q_GUI_EXPORT QListView : public QAbstractItemView
|
---|
58 | {
|
---|
59 | Q_OBJECT
|
---|
60 | Q_ENUMS(Movement Flow ResizeMode LayoutMode ViewMode)
|
---|
61 | Q_PROPERTY(Movement movement READ movement WRITE setMovement)
|
---|
62 | Q_PROPERTY(Flow flow READ flow WRITE setFlow)
|
---|
63 | Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
|
---|
64 | Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
|
---|
65 | Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
|
---|
66 | Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
|
---|
67 | Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
|
---|
68 | Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
|
---|
69 | Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
|
---|
70 | Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
|
---|
71 | Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
|
---|
72 | Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
|
---|
73 | Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
|
---|
74 |
|
---|
75 | public:
|
---|
76 | enum Movement { Static, Free, Snap };
|
---|
77 | enum Flow { LeftToRight, TopToBottom };
|
---|
78 | enum ResizeMode { Fixed, Adjust };
|
---|
79 | enum LayoutMode { SinglePass, Batched };
|
---|
80 | enum ViewMode { ListMode, IconMode };
|
---|
81 |
|
---|
82 | explicit QListView(QWidget *parent = 0);
|
---|
83 | ~QListView();
|
---|
84 |
|
---|
85 | void setMovement(Movement movement);
|
---|
86 | Movement movement() const;
|
---|
87 |
|
---|
88 | void setFlow(Flow flow);
|
---|
89 | Flow flow() const;
|
---|
90 |
|
---|
91 | void setWrapping(bool enable);
|
---|
92 | bool isWrapping() const;
|
---|
93 |
|
---|
94 | void setResizeMode(ResizeMode mode);
|
---|
95 | ResizeMode resizeMode() const;
|
---|
96 |
|
---|
97 | void setLayoutMode(LayoutMode mode);
|
---|
98 | LayoutMode layoutMode() const;
|
---|
99 |
|
---|
100 | void setSpacing(int space);
|
---|
101 | int spacing() const;
|
---|
102 |
|
---|
103 | void setBatchSize(int batchSize);
|
---|
104 | int batchSize() const;
|
---|
105 |
|
---|
106 | void setGridSize(const QSize &size);
|
---|
107 | QSize gridSize() const;
|
---|
108 |
|
---|
109 | void setViewMode(ViewMode mode);
|
---|
110 | ViewMode viewMode() const;
|
---|
111 |
|
---|
112 | void clearPropertyFlags();
|
---|
113 |
|
---|
114 | bool isRowHidden(int row) const;
|
---|
115 | void setRowHidden(int row, bool hide);
|
---|
116 |
|
---|
117 | void setModelColumn(int column);
|
---|
118 | int modelColumn() const;
|
---|
119 |
|
---|
120 | void setUniformItemSizes(bool enable);
|
---|
121 | bool uniformItemSizes() const;
|
---|
122 |
|
---|
123 | void setWordWrap(bool on);
|
---|
124 | bool wordWrap() const;
|
---|
125 |
|
---|
126 | void setSelectionRectVisible(bool show);
|
---|
127 | bool isSelectionRectVisible() const;
|
---|
128 |
|
---|
129 | QRect visualRect(const QModelIndex &index) const;
|
---|
130 | void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
|
---|
131 | QModelIndex indexAt(const QPoint &p) const;
|
---|
132 |
|
---|
133 | void doItemsLayout();
|
---|
134 | void reset();
|
---|
135 | void setRootIndex(const QModelIndex &index);
|
---|
136 |
|
---|
137 | Q_SIGNALS:
|
---|
138 | void indexesMoved(const QModelIndexList &indexes);
|
---|
139 |
|
---|
140 | protected:
|
---|
141 | QListView(QListViewPrivate &, QWidget *parent = 0);
|
---|
142 |
|
---|
143 | bool event(QEvent *e);
|
---|
144 |
|
---|
145 | void scrollContentsBy(int dx, int dy);
|
---|
146 |
|
---|
147 | void resizeContents(int width, int height);
|
---|
148 | QSize contentsSize() const;
|
---|
149 |
|
---|
150 | void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
---|
151 | void rowsInserted(const QModelIndex &parent, int start, int end);
|
---|
152 | void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
---|
153 |
|
---|
154 | void mouseMoveEvent(QMouseEvent *e);
|
---|
155 | void mouseReleaseEvent(QMouseEvent *e);
|
---|
156 |
|
---|
157 | void timerEvent(QTimerEvent *e);
|
---|
158 | void resizeEvent(QResizeEvent *e);
|
---|
159 | #ifndef QT_NO_DRAGANDDROP
|
---|
160 | void dragMoveEvent(QDragMoveEvent *e);
|
---|
161 | void dragLeaveEvent(QDragLeaveEvent *e);
|
---|
162 | void dropEvent(QDropEvent *e);
|
---|
163 | void startDrag(Qt::DropActions supportedActions);
|
---|
164 |
|
---|
165 | void internalDrop(QDropEvent *e);
|
---|
|
---|