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
qsidebar_p.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 QSIDEBAR_H
6#define QSIDEBAR_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include <qlist.h>
21#include <qlistview.h>
22#include <qstandarditemmodel.h>
23#include <qstyleditemdelegate.h>
24#include <qurl.h>
25
27
28QT_BEGIN_NAMESPACE
29
30class QFileSystemModel;
31
33{
34 public:
35 QSideBarDelegate(QWidget *parent = nullptr) : QStyledItemDelegate(parent) {}
36 void initStyleOption(QStyleOptionViewItem *option,
37 const QModelIndex &index) const override;
38};
39
40class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel
41{
42 Q_OBJECT
43
44public:
45 enum Roles {
46 UrlRole = Qt::UserRole + 1,
47 EnabledRole = Qt::UserRole + 2
48 };
49
50 QUrlModel(QObject *parent = nullptr);
51 ~QUrlModel();
52
53 QStringList mimeTypes() const override;
54 QMimeData *mimeData(const QModelIndexList &indexes) const override;
55#if QT_CONFIG(draganddrop)
56 bool canDrop(QDragEnterEvent *event);
57 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
58#endif
59 Qt::ItemFlags flags(const QModelIndex &index) const override;
60 bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override;
61
62 void setUrls(const QList<QUrl> &list);
63 void addUrls(const QList<QUrl> &urls, int row = -1, bool move = true);
64 QList<QUrl> urls() const;
65 void setFileSystemModel(QFileSystemModel *model);
66 bool showFullPath;
67
68private Q_SLOTS:
69 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
70 void layoutChanged();
71
72private:
73 void setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex);
74 void changed(const QString &path);
75 void addIndexToWatch(const QString &path, const QModelIndex &index);
76 QFileSystemModel *fileSystemModel;
77 struct WatchItem {
78 QModelIndex index;
79 QString path;
80 };
81 friend class QTypeInfo<WatchItem>;
82
83 QList<WatchItem> watching;
84 QList<QUrl> invalidUrls;
85 std::array<QMetaObject::Connection, 3> modelConnections;
86};
87Q_DECLARE_TYPEINFO(QUrlModel::WatchItem, Q_RELOCATABLE_TYPE);
88
89class Q_AUTOTEST_EXPORT QSidebar : public QListView
90{
91 Q_OBJECT
92
93Q_SIGNALS:
94 void goToUrl(const QUrl &url);
95
96public:
97 QSidebar(QWidget *parent = nullptr);
98 void setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls);
99 ~QSidebar();
100
101 QSize sizeHint() const override;
102
103 void setUrls(const QList<QUrl> &list) { urlModel->setUrls(list); }
104 void addUrls(const QList<QUrl> &list, int row) { urlModel->addUrls(list, row); }
105 QList<QUrl> urls() const { return urlModel->urls(); }
106
107 void selectUrl(const QUrl &url);
108
109protected:
110 bool event(QEvent * e) override;
111 void focusInEvent(QFocusEvent *event) override;
112#if QT_CONFIG(draganddrop)
113 void dragEnterEvent(QDragEnterEvent *event) override;
114#endif
115
116private Q_SLOTS:
117 void clicked(const QModelIndex &index);
118#if QT_CONFIG(menu)
119 void showContextMenu(const QPoint &position);
120#endif
121 void removeEntry();
122
123private:
124 QUrlModel *urlModel;
125};
126
127QT_END_NAMESPACE
128
129#endif // QSIDEBAR_H
The QComboBox widget combines a button with a dropdown list.
Definition qcombobox.h:25
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
\inmodule QtWidgets
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:18
Definition qlist.h:80
\inmodule QtCore
QSideBarDelegate(QWidget *parent=nullptr)
Definition qsidebar_p.h:35
The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.
The QToolButton class provides a quick-access button to commands or options, usually used inside a QT...
Definition qtoolbutton.h:21
The QTreeView class provides a default model/view implementation of a tree view.
Definition qtreeview.h:21
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)
QT_REQUIRE_CONFIG(thread)
QT_REQUIRE_CONFIG(treeview)
QFileDialogArgs(const QUrl &url={})