Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QSIDEBAR_H
5#define QSIDEBAR_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <qlist.h>
20#include <qlistview.h>
21#include <qstandarditemmodel.h>
22#include <qstyleditemdelegate.h>
23#include <qurl.h>
24
26
28
30
32{
33 public:
35 void initStyleOption(QStyleOptionViewItem *option,
36 const QModelIndex &index) const override;
37};
38
40{
42
43public:
44 enum Roles {
45 UrlRole = Qt::UserRole + 1,
46 EnabledRole = Qt::UserRole + 2
47 };
48
49 QUrlModel(QObject *parent = nullptr);
50 ~QUrlModel();
51
52 QStringList mimeTypes() const override;
53 QMimeData *mimeData(const QModelIndexList &indexes) const override;
54#if QT_CONFIG(draganddrop)
55 bool canDrop(QDragEnterEvent *event);
56 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
57#endif
58 Qt::ItemFlags flags(const QModelIndex &index) const override;
59 bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override;
60
61 void setUrls(const QList<QUrl> &list);
62 void addUrls(const QList<QUrl> &urls, int row = -1, bool move = true);
63 QList<QUrl> urls() const;
64 void setFileSystemModel(QFileSystemModel *model);
66
67private Q_SLOTS:
68 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
69 void layoutChanged();
70
71private:
72 void setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex);
73 void changed(const QString &path);
74 void addIndexToWatch(const QString &path, const QModelIndex &index);
75 QFileSystemModel *fileSystemModel;
76 struct WatchItem {
79 };
80 friend class QTypeInfo<WatchItem>;
81
82 QList<WatchItem> watching;
83 QList<QUrl> invalidUrls;
84 std::array<QMetaObject::Connection, 3> modelConnections;
85};
87
89{
91
93 void goToUrl(const QUrl &url);
94
95public:
96 QSidebar(QWidget *parent = nullptr);
97 void setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls);
98 ~QSidebar();
99
100 QSize sizeHint() const override;
101
102 void setUrls(const QList<QUrl> &list) { urlModel->setUrls(list); }
103 void addUrls(const QList<QUrl> &list, int row) { urlModel->addUrls(list, row); }
104 QList<QUrl> urls() const { return urlModel->urls(); }
105
106 void selectUrl(const QUrl &url);
107
108protected:
109 bool event(QEvent * e) override;
110 void focusInEvent(QFocusEvent *event) override;
111#if QT_CONFIG(draganddrop)
112 void dragEnterEvent(QDragEnterEvent *event) override;
113#endif
114
115private Q_SLOTS:
116 void clicked(const QModelIndex &index);
117#if QT_CONFIG(menu)
118 void showContextMenu(const QPoint &position);
119#endif
120 void removeEntry();
121
122private:
123 QUrlModel *urlModel;
124};
125
127
128#endif // QSIDEBAR_H
129
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >())
This signal is emitted whenever the data in an existing item changes.
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
\inmodule QtCore
Definition qcoreevent.h:45
The QFileSystemModel class provides a data model for the local filesystem.
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:17
\inmodule QtCore
Definition qmimedata.h:16
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore\reentrant
Definition qpoint.h:25
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override
Initialize option with the values using the index index.
Definition qsidebar.cpp:22
QSideBarDelegate(QWidget *parent=nullptr)
Definition qsidebar_p.h:34
void goToUrl(const QUrl &url)
QList< QUrl > urls() const
Definition qsidebar_p.h:104
void addUrls(const QList< QUrl > &list, int row)
Definition qsidebar_p.h:103
void setUrls(const QList< QUrl > &list)
Definition qsidebar_p.h:102
\inmodule QtCore
Definition qsize.h:25
The QStandardItemModel class provides a generic model for storing custom data.
QStringList mimeTypes() const override
\reimp
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
\reimp
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
\reimp
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
bool showFullPath
Definition qsidebar_p.h:65
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
Combined button and popup list for selecting options.
@ UserRole
@ EditRole
DropAction
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint index
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLbitfield flags
GLenum GLenum GLsizei void GLsizei void * column
struct _cl_event * event
GLsizei const GLchar *const * path
GLenum GLenum GLsizei void * row
GLuint GLenum option
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
request setUrl(QUrl("http://qt-project.org"))
#define Q_AUTOTEST_EXPORT
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
QSqlQueryModel * model
[16]
QList< int > list
[14]
QUrl url("example.com")
[constructor-url-reference]
QMimeData * mimeData