Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qlistview.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QLISTVIEW_H
6#define QLISTVIEW_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtWidgets/qabstractitemview.h>
10
11QT_REQUIRE_CONFIG(listview);
12
13QT_BEGIN_NAMESPACE
14
15class QListViewPrivate;
16
17class Q_WIDGETS_EXPORT QListView : public QAbstractItemView
18{
19 Q_OBJECT
20 Q_PROPERTY(Movement movement READ movement WRITE setMovement)
21 Q_PROPERTY(Flow flow READ flow WRITE setFlow)
22 Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
23 Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
24 Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
25 Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
26 Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
27 Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
28 Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
29 Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
30 Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
31 Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
32 Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
33 Q_PROPERTY(Qt::Alignment itemAlignment READ itemAlignment WRITE setItemAlignment)
34
35public:
36 enum Movement { Static, Free, Snap };
37 Q_ENUM(Movement)
38 enum Flow { LeftToRight, TopToBottom };
39 Q_ENUM(Flow)
40 enum ResizeMode { Fixed, Adjust };
41 Q_ENUM(ResizeMode)
42 enum LayoutMode { SinglePass, Batched };
43 Q_ENUM(LayoutMode)
44 enum ViewMode { ListMode, IconMode };
45 Q_ENUM(ViewMode)
46
47 explicit QListView(QWidget *parent = nullptr);
48 ~QListView();
49
50 void setMovement(Movement movement);
51 Movement movement() const;
52
53 void setFlow(Flow flow);
54 Flow flow() const;
55
56 void setWrapping(bool enable);
57 bool isWrapping() const;
58
59 void setResizeMode(ResizeMode mode);
60 ResizeMode resizeMode() const;
61
62 void setLayoutMode(LayoutMode mode);
63 LayoutMode layoutMode() const;
64
65 void setSpacing(int space);
66 int spacing() const;
67
68 void setBatchSize(int batchSize);
69 int batchSize() const;
70
71 void setGridSize(const QSize &size);
72 QSize gridSize() const;
73
74 void setViewMode(ViewMode mode);
75 ViewMode viewMode() const;
76
77 void clearPropertyFlags();
78
79 bool isRowHidden(int row) const;
80 void setRowHidden(int row, bool hide);
81
82 void setModelColumn(int column);
83 int modelColumn() const;
84
85 void setUniformItemSizes(bool enable);
86 bool uniformItemSizes() const;
87
88 void setWordWrap(bool on);
89 bool wordWrap() const;
90
91 void setSelectionRectVisible(bool show);
92 bool isSelectionRectVisible() const;
93
94 void setItemAlignment(Qt::Alignment alignment);
95 Qt::Alignment itemAlignment() const;
96
97 QRect visualRect(const QModelIndex &index) const override;
98 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
99 QModelIndex indexAt(const QPoint &p) const override;
100
101 void doItemsLayout() override;
102 void reset() override;
103 void setRootIndex(const QModelIndex &index) override;
104
105Q_SIGNALS:
106 void indexesMoved(const QModelIndexList &indexes);
107
108protected:
109 QListView(QListViewPrivate &, QWidget *parent = nullptr);
110
111 bool event(QEvent *e) override;
112
113 void scrollContentsBy(int dx, int dy) override;
114
115 void resizeContents(int width, int height);
116 QSize contentsSize() const;
117
118 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
119 const QList<int> &roles = QList<int>()) override;
120 void rowsInserted(const QModelIndex &parent, int start, int end) override;
121 void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
122
123 void mouseMoveEvent(QMouseEvent *e) override;
124 void mouseReleaseEvent(QMouseEvent *e) override;
125#if QT_CONFIG(wheelevent)
126 void wheelEvent(QWheelEvent *e) override;
127#endif
128
129 void timerEvent(QTimerEvent *e) override;
130 void resizeEvent(QResizeEvent *e) override;
131#if QT_CONFIG(draganddrop)
132 void dragMoveEvent(QDragMoveEvent *e) override;
133 void dragLeaveEvent(QDragLeaveEvent *e) override;
134 void dropEvent(QDropEvent *e) override;
135 void startDrag(Qt::DropActions supportedActions) override;
136#endif // QT_CONFIG(draganddrop)
137
138 void initViewItemOption(QStyleOptionViewItem *option) const override;
139 void paintEvent(QPaintEvent *e) override;
140
141 int horizontalOffset() const override;
142 int verticalOffset() const override;
143 QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
144 QRect rectForIndex(const QModelIndex &index) const;
145 void setPositionForIndex(const QPoint &position, const QModelIndex &index);
146
147 void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
148 QRegion visualRegionForSelection(const QItemSelection &selection) const override;
149 QModelIndexList selectedIndexes() const override;
150
151 void updateGeometries() override;
152
153 bool isIndexHidden(const QModelIndex &index) const override;
154
155 void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
156 void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
157
158 QSize viewportSizeHint() const override;
159
160private:
161 int visualIndex(const QModelIndex &index) const;
162 friend class QCommonListViewBase;
163
164 Q_DECLARE_PRIVATE(QListView)
165 Q_DISABLE_COPY(QListView)
166};
167
168QT_END_NAMESPACE
169
170#endif // QLISTVIEW_H
QFileDialogComboBox(QWidget *parent=nullptr)
QStringList history() const
void setHistory(const QStringList &paths)
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
void showPopup() override
Displays the list of items in the combobox.
void paintEvent(QPaintEvent *) override
\reimp
void keyPressEvent(QKeyEvent *e) override
FIXME: this is a hack to avoid propagating key press events to the dialog and from there to the "Ok" ...
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
QFileDialogLineEdit(QWidget *parent=nullptr)
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
QSize sizeHint() const override
QFileDialogListView(QWidget *parent=nullptr)
void keyPressEvent(QKeyEvent *e) override
void keyPressEvent(QKeyEvent *e) override
QSize sizeHint() const override
QFileDialogTreeView(QWidget *parent)
void setFileDialogPrivate(QFileDialogPrivate *d_pointer)
The QFileDialog class provides a dialog that allows users to select files or directories.
Definition qfiledialog.h:29
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:18
Definition qlist.h:80
\inmodule QtCore
QT_REQUIRE_CONFIG(animation)
static QUrl _qt_get_directory(const QUrl &url, const QFileInfo &local)
static void _qt_init_lastVisited()
QStringList qt_strip_filters(const QStringList &filters)
QStringList qt_make_filter_list(const QString &filter)
static QString fileFromPath(const QString &rootPath, QString path)
static bool isCaseSensitiveFileSystem(const QString &path)
QT_REQUIRE_CONFIG(filedialog)
QFileDialogArgs(const QUrl &url={})