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
bookmarkmodel.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3#ifndef BOOKMARKMODEL_H
4#define BOOKMARKMODEL_H
5
6#include <QtCore/QAbstractItemModel>
7#include <QtCore/QMap>
8
9#include <QtGui/QIcon>
10
12
13class BookmarkItem;
14class QMimeData;
15class QTreeView;
16
18
20{
22public:
25
26 QByteArray bookmarks() const;
27 void setBookmarks(const QByteArray &bookmarks);
28
29 void setItemsEditable(bool editable);
30 void expandFoldersIfNeeeded(QTreeView *treeView);
31
32 QModelIndex addItem(const QModelIndex &parent, bool isFolder = false);
33 bool removeItem(const QModelIndex &index);
34
35 int rowCount(const QModelIndex &index = QModelIndex()) const override;
36 int columnCount(const QModelIndex &index = QModelIndex()) const override;
37
38 QModelIndex parent(const QModelIndex &index) const override;
39 QModelIndex index(int row, int column, const QModelIndex &index) const override;
40
41 Qt::DropActions supportedDropActions () const override;
42 Qt::ItemFlags flags(const QModelIndex &index) const override;
43
44 QVariant data(const QModelIndex &index, int role) const override;
45 void setData(const QModelIndex &index, const QList<QVariant> &data);
46 bool setData(const QModelIndex &index, const QVariant &value, int role) override;
47 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
48
50 BookmarkItem *itemFromIndex(const QModelIndex &index) const;
51 QList<QPersistentModelIndex> indexListFor(const QString &label) const;
52
53 bool insertRows(int position, int rows, const QModelIndex &parent) override;
54 bool removeRows(int position, int rows, const QModelIndex &parent) override;
55
56 QStringList mimeTypes() const override;
57 QMimeData* mimeData(const QModelIndexList &indexes) const override;
58 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
59 int column, const QModelIndex &parent) override;
60
61private:
62 void setupCache(const QModelIndex &parent);
63 QModelIndexList collectItems(const QModelIndex &parent) const;
64 void collectItems(const QModelIndex &parent, qint32 depth,
65 QDataStream *stream) const;
66
67private:
68 bool m_folder;
69 bool m_editable;
70 QIcon folderIcon;
71 QIcon bookmarkIcon;
72 BookmarkItem *rootItem;
74};
75
76QT_END_NAMESPACE
77
78#endif // BOOKMARKMODEL_H
QList< QPersistentModelIndex > PersistentModelIndexCache
@ UserRoleExpanded
@ UserRoleFolder
@ UserRoleUrl
QList< QVariant > DataVector
QMap< BookmarkItem *, QPersistentModelIndex > ItemModelIndexCache
bool eventFilter(QObject *object, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
~BookmarkDialog() override
Qt::DropActions supportedDropActions() const override
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
Reimplement this function to return the model index in the source model that corresponds to the proxy...
QVariant data(const QModelIndex &index, int role) const override
Returns the data stored under the given role for the item referred to by the index.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Sets the role data for the item at index to value.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
Reimplement this function to return the model index in the proxy model that corresponds to the source...
QModelIndex index(int row, int column, const QModelIndex &parent) const override
Returns the index of the item in the model specified by the given row, column and parent index.
int rowCount(const QModelIndex &index) const override
Returns the number of rows under the given parent.
int columnCount(const QModelIndex &index) const override
Returns the number of columns for the children of the given parent.
QModelIndex parent(const QModelIndex &child) const override
void setSourceModel(QAbstractItemModel *sourceModel) override
Sets the given sourceModel to be processed by the proxy model.
QVariant data(int column) const
BookmarkItem * child(int number) const
bool insertChildren(bool isFolder, int position, int count)
void addChild(BookmarkItem *child)
void setParent(BookmarkItem *parent)
bool setData(int column, const QVariant &value)
bool removeChildren(int position, int count)
int childCount() const
BookmarkItem * parent() const
void setData(const DataVector &data)
BookmarkItem(const DataVector &data, BookmarkItem *parent=nullptr)
int childNumber() const
void dumpTree(int indent) const
void setItemsEditable(bool editable)
QByteArray bookmarks() const
int columnCount(const QModelIndex &index=QModelIndex()) const override
Returns the number of columns for the children of the given parent.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns the item flags for the given index.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Returns the data for the given role and section in the header with the specified orientation.
QModelIndex index(int row, int column, const QModelIndex &index) const override
Returns the index of the item in the model specified by the given row, column and parent index.
~BookmarkModel() override
bool insertRows(int position, int rows, const QModelIndex &parent) override
QModelIndex addItem(const QModelIndex &parent, bool isFolder=false)
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
Handles the data supplied by a drag and drop operation that ended with the given action.
BookmarkItem * itemFromIndex(const QModelIndex &index) const
bool removeItem(const QModelIndex &index)
void setData(const QModelIndex &index, const QList< QVariant > &data)
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Sets the role data for the item at index to value.
QStringList mimeTypes() const override
Returns the list of allowed MIME types.
QModelIndex indexFromItem(BookmarkItem *item) const
void expandFoldersIfNeeeded(QTreeView *treeView)
int rowCount(const QModelIndex &index=QModelIndex()) const override
Returns the number of rows under the given parent.
void setBookmarks(const QByteArray &bookmarks)
QVariant data(const QModelIndex &index, int role) const override
Returns the data stored under the given role for the item referred to by the index.
QList< QPersistentModelIndex > indexListFor(const QString &label) const
QModelIndex parent(const QModelIndex &index) const override
QMimeData * mimeData(const QModelIndexList &indexes) const override
Returns an object that contains serialized items of data corresponding to the list of indexes specifi...
Qt::DropActions supportedDropActions() const override
bool removeRows(int position, int rows, const QModelIndex &parent) override
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
Returns true if the item in the row indicated by the given source_row and source_parent should be inc...
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns for the children of the given parent.
static HelpEngineWrapper & instance()
Combined button and popup list for selecting options.
#define TRACE_OBJ
Definition tracer.h:34