QtGui/qlistview.h Source File

qlistview.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui 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 QLISTVIEW_H
43 #define QLISTVIEW_H
44 
46 
48 
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
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);
156 
157  void timerEvent(QTimerEvent *e);
158  void resizeEvent(QResizeEvent *e);
159 #ifndef QT_NO_DRAGANDDROP
160  void dragMoveEvent(QDragMoveEvent *e);
162  void dropEvent(QDropEvent *e);
163  void startDrag(Qt::DropActions supportedActions);
164 
165  void internalDrop(QDropEvent *e);
166  void internalDrag(Qt::DropActions supportedActions);
167 #endif // QT_NO_DRAGANDDROP
168 
170  void paintEvent(QPaintEvent *e);
171 
172  int horizontalOffset() const;
173  int verticalOffset() const;
174  QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
175  QRect rectForIndex(const QModelIndex &index) const;
176  void setPositionForIndex(const QPoint &position, const QModelIndex &index);
177 
178  void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
179  QRegion visualRegionForSelection(const QItemSelection &selection) const;
181 
182  void updateGeometries();
183 
184  bool isIndexHidden(const QModelIndex &index) const;
185 
186  void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
187  void currentChanged(const QModelIndex &current, const QModelIndex &previous);
188 
189 private:
190  friend class QAccessibleItemView;
191  int visualIndex(const QModelIndex &index) const;
192 
193  Q_DECLARE_PRIVATE(QListView)
194  Q_DISABLE_COPY(QListView)
195 };
196 
197 #endif // QT_NO_LISTVIEW
198 
200 
202 
203 #endif // QLISTVIEW_H
virtual void setRootIndex(const QModelIndex &index)
void timerEvent(QTimerEvent *event)
GLint mode
Definition: GLee.h:4479
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
int int int int * dy
Definition: GLee.h:10535
virtual QStyleOptionViewItem viewOptions() const
#define QT_END_NAMESPACE
Definition: qglobal.h:128
#define Q_PROPERTY(text)
Definition: qobjectdefs.h:80
GLuint start
Definition: GLee.h:872
void mouseReleaseEvent(QMouseEvent *event)
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
virtual void updateGeometries()
virtual void reset()
GLenum GLsizei width
Definition: GLee.h:873
virtual int verticalOffset() const =0
#define Q_SIGNALS
Definition: qobjectdefs.h:72
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void dropEvent(QDropEvent *event)
virtual bool isIndexHidden(const QModelIndex &index) const =0
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
void mouseMoveEvent(QMouseEvent *event)
Definition: qpoint.h:53
void dragMoveEvent(QDragMoveEvent *event)
void dragLeaveEvent(QDragLeaveEvent *event)
GLenum GLenum GLvoid * row
Definition: GLee.h:893
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
virtual void doItemsLayout()
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
virtual QRect visualRect(const QModelIndex &index) const =0
GLenum GLsizei GLsizei height
Definition: GLee.h:883
virtual QModelIndex indexAt(const QPoint &point) const =0
void resizeEvent(QResizeEvent *event)
virtual void startDrag(Qt::DropActions supportedActions)
#define Q_OBJECT
Definition: qobjectdefs.h:157
GLuint GLuint end
Definition: GLee.h:872
Definition: qrect.h:58
virtual int horizontalOffset() const =0
GLfloat GLfloat p
Definition: GLee.h:5416
GLenum GLenum GLvoid GLvoid * column
Definition: GLee.h:893
Definition: qsize.h:53
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous)
int int int * dx
Definition: GLee.h:10535
bool event(QEvent *event)
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const =0
virtual void scrollContentsBy(int dx, int dy)
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
#define QT_END_HEADER
Definition: qglobal.h:142
void paintEvent(QPaintEvent *)
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
GLsizeiptr size
Definition: GLee.h:1561
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)=0
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
GLuint index
Definition: GLee.h:1704
virtual QModelIndexList selectedIndexes() const