Qt 6.x
The Qt SDK
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
51 QStringList mimeTypes() const override;
52 QMimeData *mimeData(const QModelIndexList &indexes) const override;
53#if QT_CONFIG(draganddrop)
54 bool canDrop(QDragEnterEvent *event);
55 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
56#endif
57 Qt::ItemFlags flags(const QModelIndex &index) const override;
58 bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override;
59
60 void setUrls(const QList<QUrl> &list);
61 void addUrls(const QList<QUrl> &urls, int row = -1, bool move = true);
62 QList<QUrl> urls() const;
63 void setFileSystemModel(QFileSystemModel *model);
65
66private Q_SLOTS:
67 void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
68 void layoutChanged();
69
70private:
71 void setUrl(const QModelIndex &index, const QUrl &url, const QModelIndex &dirIndex);
72 void changed(const QString &path);
73 void addIndexToWatch(const QString &path, const QModelIndex &index);
74 QFileSystemModel *fileSystemModel;
75 struct WatchItem {
78 };
79 friend class QTypeInfo<WatchItem>;
80
81 QList<WatchItem> watching;
82 QList<QUrl> invalidUrls;
83};
85
87{
89
91 void goToUrl(const QUrl &url);
92
93public:
94 QSidebar(QWidget *parent = nullptr);
95 void setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls);
96 ~QSidebar();
97
98 QSize sizeHint() const override;
99
100 void setUrls(const QList<QUrl> &list) { urlModel->setUrls(list); }
101 void addUrls(const QList<QUrl> &list, int row) { urlModel->addUrls(list, row); }
102 QList<QUrl> urls() const { return urlModel->urls(); }
103
104 void selectUrl(const QUrl &url);
105
106protected:
107 bool event(QEvent * e) override;
108 void focusInEvent(QFocusEvent *event) override;
109#if QT_CONFIG(draganddrop)
110 void dragEnterEvent(QDragEnterEvent *event) override;
111#endif
112
113private Q_SLOTS:
114 void clicked(const QModelIndex &index);
115#if QT_CONFIG(menu)
116 void showContextMenu(const QPoint &position);
117#endif
118 void removeEntry();
119
120private:
121 QUrlModel *urlModel;
122};
123
125
126#endif // QSIDEBAR_H
127
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:469
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:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
\inmodule QtCore\reentrant
Definition qpoint.h:23
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:102
void addUrls(const QList< QUrl > &list, int row)
Definition qsidebar_p.h:101
void setUrls(const QList< QUrl > &list)
Definition qsidebar_p.h:100
\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:127
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
bool showFullPath
Definition qsidebar_p.h:64
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:64
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
double e
Combined button and popup list for selecting options.
@ UserRole
@ EditRole
DropAction
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint index
[2]
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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:145
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:163
QSqlQueryModel * model
[16]
QList< int > list
[14]
QUrl url("example.com")
[constructor-url-reference]
QMimeData * mimeData
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent