27 if (
value.isValid()) {
29 if (!qvariant_cast<bool>(
value))
48 for (
const auto &conn : std::as_const(modelConnections))
66 if (
index.isValid()) {
84 for (
const auto &
index : indexes) {
85 if (
index.column() == 0)
93#if QT_CONFIG(draganddrop)
100bool QUrlModel::canDrop(QDragEnterEvent *
event)
102 if (!
event->mimeData()->formats().contains(
mimeTypes().constFirst()))
105 const QList<QUrl>
list =
event->mimeData()->urls();
108 if (!fileSystemModel->
isDir(idx))
138 if (
value.userType() == QMetaType::QUrl) {
168 newName = dirIndex.data().toString();
172 if (!dirIndex.isValid()) {
187 if (!newIcon.isNull()) {
190 if (
size.width() < 32) {
196 if (
index.data().toString() != newName)
199 if (oldIcon.cacheKey() != newIcon.cacheKey())
230 if (!cleanUrl.isEmpty())
240 if (!cleanUrl.compare(local, cs)) {
249 if (!fileSystemModel->
isDir(idx))
253 watching.
append({idx, cleanUrl});
265 for (
int i = 0;
i < numRows; ++
i)
275 if (
model == fileSystemModel)
277 if (fileSystemModel !=
nullptr) {
278 for (
const auto &conn : std::as_const(modelConnections))
281 fileSystemModel =
model;
282 if (fileSystemModel !=
nullptr) {
285 this, &QUrlModel::dataChanged),
287 this, &QUrlModel::layoutChanged),
289 this, &QUrlModel::layoutChanged),
302 for (
int i = 0;
i < watching.
size(); ++
i) {
312 changed(watching.
at(
i).path);
320void QUrlModel::layoutChanged()
324 for (
const WatchItem &
item :
std::as_const(watching))
330 if (newIndex.isValid())
363 this, &QSidebar::clicked);
364#if QT_CONFIG(draganddrop)
365 setDragDropMode(QAbstractItemView::DragDrop);
369 connect(
this, &QSidebar::customContextMenuRequested,
370 this, &QSidebar::showContextMenu);
380#if QT_CONFIG(draganddrop)
381void QSidebar::dragEnterEvent(QDragEnterEvent *
event)
383 if (urlModel->canDrop(
event))
384 QListView::dragEnterEvent(
event);
392 return QListView::sizeHint();
398 this, &QSidebar::clicked);
409 this, &QSidebar::clicked);
420 QList<QAction *> actions;
426 actions.append(action);
428 if (actions.size() > 0)
438void QSidebar::removeEntry()
443 const QList<QPersistentModelIndex> persIndexes(idxs.cbegin(), idxs.cend());
446 model()->removeRow(persistent.row());
468 QAbstractScrollArea::focusInEvent(
event);
489#include "moc_qsidebar_p.cpp"
virtual QIcon icon(IconType) const
Returns an icon set for the given type, using the current icon theme.
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Handles the data supplied by a drag and drop operation that ended with the given action.
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.
virtual Q_INVOKABLE int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
void layoutChanged(const QList< QPersistentModelIndex > &parents=QList< QPersistentModelIndex >(), QAbstractItemModel::LayoutChangeHint hint=QAbstractItemModel::NoLayoutChangeHint)
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
void rowsRemoved(const QModelIndex &parent, int first, int last, QPrivateSignal)
This signal is emitted after rows have been removed from the model.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets the item delegate for this view and its model to delegate.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
QSize sizeHintForIndex(const QModelIndex &index) const
Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
QItemSelectionModel * selectionModel() const
Returns the current selection model.
The QAction class provides an abstraction for user commands that can be added to different user inter...
void triggered(bool checked=false)
This signal is emitted when an action is activated by the user; for example, when the user clicks a m...
static QString cleanPath(const QString &path)
Returns path with directory separators normalized (that is, platform-native separators converted to "...
static QString toNativeSeparators(const QString &pathName)
The QFileSystemModel class provides a data model for the local filesystem.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
\reimp
QVariant myComputer(int role=Qt::DisplayRole) const
Returns the data stored under the given role for the item "My Computer".
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
\reimp
QAbstractFileIconProvider * iconProvider() const
Returns the file icon provider for this directory model.
bool isDir(const QModelIndex &index) const
Returns true if the model item index represents a directory; otherwise returns false.
The QFocusEvent class contains event parameters for widget focus events.
The QIcon class provides scalable icons in different modes and states.
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This signal is emitted whenever the current item changes.
QModelIndexList selectedIndexes
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
virtual void clear()
Clears the selection model.
The QKeyEvent class describes a key event.
The QListView class provides a list or icon view onto a model.
bool event(QEvent *e) override
\reimp
void setUniformItemSizes(bool enable)
QModelIndex indexAt(const QPoint &p) const override
\reimp
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
const_reverse_iterator crbegin() const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
const_reverse_iterator crend() const noexcept
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index.
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
constexpr int column() const noexcept
Returns the column this model index refers to.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
The QStandardItemModel class provides a generic model for storing custom data.
void clear()
Removes all items (including header items) from the model and sets the number of rows and columns to ...
QObject * parent() const
Returns a pointer to the parent object.
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
\reimp
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
Qt::ItemFlags flags(const QModelIndex &index) const override
\reimp
int rowCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
QChar * data()
Returns a pointer to the data stored in the QString.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
virtual void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const
Initialize option with the values using the index index.
void setUrls(const QList< QUrl > &list)
void addUrls(const QList< QUrl > &urls, int row=-1, bool move=true)
Add urls list into the list at row.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
\reimp
QMimeData * mimeData(const QModelIndexList &indexes) const override
\reimp
QStringList mimeTypes() const override
\reimp
QList< QUrl > urls() const
Return the complete list of urls in a QList.
void setFileSystemModel(QFileSystemModel *model)
QFileSystemModel to get index's from, clears existing rows.
Qt::ItemFlags flags(const QModelIndex &index) const override
\reimp
QUrlModel(QObject *parent=nullptr)
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
QString scheme() const
Returns the scheme of the URL.
QString toLocalFile() const
Returns the path of this URL formatted as a local file path.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
QUrl toUrl() const
Returns the variant as a QUrl if the variant has userType() \l QMetaType::QUrl; otherwise returns an ...
list append(new Employee("Blackpool", "Stephen"))
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QList< QString > QStringList
Constructs a string list that contains the given string, str.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLuint * paths
GLenum GLenum GLsizei void GLsizei void * column
GLsizei const GLchar *const * path
GLenum GLenum GLsizei void * row
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QSqlQueryModel * model
[16]
QUrl url("example.com")
[constructor-url-reference]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)
bool contains(const AT &t) const noexcept