Qt 4.8
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 
45 #include <QtGui/qabstractitemview.h>
46 
48 
50 
51 QT_MODULE(Gui)
52 
53 #ifndef QT_NO_LISTVIEW
54 
55 class QListViewPrivate;
56 
58 {
59  Q_OBJECT
61  Movement movement;
62  Flow flow;
63  bool isWrapping;
64  ResizeMode resizeMode;
65  LayoutMode layoutMode;
66  int spacing;
67  QSize gridSize;
68  ViewMode viewMode;
69  int modelColumn;
70  bool uniformItemSizes;
71  int batchSize;
72  bool wordWrap;
73  bool selectionRectVisible;
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 
195 };
196 
197 #endif // QT_NO_LISTVIEW
198 
200 
202 
203 #endif // QLISTVIEW_H
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
This slot is called when rows are about to be removed.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
virtual QStyleOptionViewItem viewOptions() const
Returns a QStyleOptionViewItem structure populated with the view&#39;s palette, font, state...
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
void mouseMoveEvent(QMouseEvent *event)
This function is called with the given event when a mouse move event is sent to the widget...
virtual bool isIndexHidden(const QModelIndex &index) const =0
Returns true if the item referred to by the given index is hidden in the view, otherwise returns fals...
virtual QRect visualRect(const QModelIndex &index) const =0
Returns the rectangle on the viewport occupied by the item at index.
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
virtual void setRootIndex(const QModelIndex &index)
Sets the root item to the item at the given index.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void timerEvent(QTimerEvent *event)
This function is called with the given event when a timer event is sent to the widget.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
virtual void doItemsLayout()
This function is intended to lay out the items in the view.
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
Definition: qevent.h:530
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)=0
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction...
#define Q_SIGNALS
Definition: qobjectdefs.h:72
void dragMoveEvent(QDragMoveEvent *event)
This function is called continuously with the given event during a drag and drop operation over the w...
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
void dropEvent(QDropEvent *event)
This function is called with the given event when a drop event occurs over the widget.
virtual int verticalOffset() const =0
Returns the vertical offset of the view.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void paintEvent(QPaintEvent *)
This event handler can be reimplemented in a subclass to receive paint events (passed in event)...
virtual void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible)=0
Scrolls the view if necessary to ensure that the item at index is visible.
virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
virtual void reset()
Reset the internal state of the view.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
Definition: qevent.h:577
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
virtual int horizontalOffset() const =0
Returns the horizontal offset of the view.
#define Q_OBJECT
Definition: qobjectdefs.h:157
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
This slot is called when the selection is changed.
The QAbstractItemView class provides the basic functionality for item view classes.
The QItemSelection class manages information about selected items in a model.
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Definition: qevent.h:476
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)=0
Applies the selection flags to the items in or touched by the rectangle, rect.
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
The Flow item arranges its children side by side, wrapping as necessary.
void resizeEvent(QResizeEvent *event)
This function is called with the given event when a resize event is sent to the widget.
virtual QModelIndexList selectedIndexes() const
This convenience function returns a list of all selected and non-hidden item indexes in the view...
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QModelIndex class is used to locate data in a data model.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual void scrollContentsBy(int dx, int dy)
This virtual handler is called when the scroll bars are moved by dx, dy, and consequently the viewpor...
quint16 index
void mouseReleaseEvent(QMouseEvent *event)
This function is called with the given event when a mouse button is released, after a mouse press eve...
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
This slot is called when rows are inserted.
virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
This slot is called when items are changed in the model.
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const =0
Returns the region from the viewport of the items in the given selection.
virtual void updateGeometries()
Updates the geometry of the child widgets of the view.
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
CursorAction
This enum describes the different ways to navigate between items,.
The QStyleOptionViewItem class is used to describe the parameters used to draw an item in a view widg...
Definition: qstyleoption.h:539
The QPaintEvent class contains event parameters for paint events.
Definition: qevent.h:298
static const KeyPair *const end
void dragLeaveEvent(QDragLeaveEvent *event)
This function is called when the item being dragged leaves the view.
bool event(QEvent *event)
Reimplemented Function
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
virtual void startDrag(Qt::DropActions supportedActions)
Starts a drag by calling drag->exec() using the given supportedActions.
virtual QModelIndex indexAt(const QPoint &point) const =0
Returns the model index of the item at the viewport coordinates point.