Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qabstractproxymodel.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 QABSTRACTPROXYMODEL_H
5#define QABSTRACTPROXYMODEL_H
6
7#include <QtCore/qabstractitemmodel.h>
8
9QT_REQUIRE_CONFIG(proxymodel);
10
12
14class QItemSelection;
15
16class Q_CORE_EXPORT QAbstractProxyModel : public QAbstractItemModel
17{
19 Q_PROPERTY(QAbstractItemModel *sourceModel READ sourceModel WRITE setSourceModel
20 NOTIFY sourceModelChanged BINDABLE bindableSourceModel)
21
22public:
23 explicit QAbstractProxyModel(QObject *parent = nullptr);
25
26 virtual void setSourceModel(QAbstractItemModel *sourceModel);
27 QAbstractItemModel *sourceModel() const;
28 QBindable<QAbstractItemModel *> bindableSourceModel();
29
30 Q_INVOKABLE virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const = 0;
31 Q_INVOKABLE virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const = 0;
32
33 Q_INVOKABLE virtual QItemSelection mapSelectionToSource(const QItemSelection &selection) const;
34 Q_INVOKABLE virtual QItemSelection mapSelectionFromSource(const QItemSelection &selection) const;
35
36 bool submit() override;
37 void revert() override;
38
39 QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override;
40 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
41 QMap<int, QVariant> itemData(const QModelIndex &index) const override;
42 Qt::ItemFlags flags(const QModelIndex &index) const override;
43
44 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
45 bool setItemData(const QModelIndex& index, const QMap<int, QVariant> &roles) override;
46 bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
47 bool clearItemData(const QModelIndex &index) override;
48
49 QModelIndex buddy(const QModelIndex &index) const override;
50 bool canFetchMore(const QModelIndex &parent) const override;
51 void fetchMore(const QModelIndex &parent) override;
52 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
53 QSize span(const QModelIndex &index) const override;
54 bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
55 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
56
57 QMimeData* mimeData(const QModelIndexList &indexes) const override;
58 bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
59 int row, int column, const QModelIndex &parent) const override;
60 bool dropMimeData(const QMimeData *data, Qt::DropAction action,
61 int row, int column, const QModelIndex &parent) override;
62 QStringList mimeTypes() const override;
63 Qt::DropActions supportedDragActions() const override;
64 Qt::DropActions supportedDropActions() const override;
65 QHash<int, QByteArray> roleNames() const override;
66
68 void sourceModelChanged(QPrivateSignal);
69
70protected:
71 QModelIndex createSourceIndex(int row, int col, void *internalPtr) const;
73
74private:
75 Q_DECLARE_PRIVATE(QAbstractProxyModel)
76 Q_DISABLE_COPY(QAbstractProxyModel)
77 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelDestroyed())
78 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelRowsAboutToBeInserted(QModelIndex, int, int))
79 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelRowsInserted(QModelIndex, int, int))
80 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelRowsRemoved(QModelIndex, int, int))
81 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelColumnsAboutToBeInserted(QModelIndex, int, int))
82 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelColumnsInserted(QModelIndex, int, int))
83 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelColumnsRemoved(QModelIndex, int, int))
84};
85
87
88#endif // QABSTRACTPROXYMODEL_H
virtual Qt::DropActions supportedDropActions() const
virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
Returns {true} if a model can accept a drop of the data.
virtual Q_INVOKABLE QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Returns the data for the given role and section in the header with the specified orientation.
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.
virtual Q_INVOKABLE bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns {true} if parent has any children; otherwise returns {false}.
virtual Q_INVOKABLE void fetchMore(const QModelIndex &parent)
Fetches any available data for the items with the parent specified by the parent index.
virtual bool clearItemData(const QModelIndex &index)
virtual QModelIndex buddy(const QModelIndex &index) const
Returns a model index for the buddy of the item represented by index.
virtual Q_INVOKABLE bool canFetchMore(const QModelIndex &parent) const
Returns {true} if there is more data available for parent; otherwise returns {false}.
virtual void revert()
Lets the model know that it should discard cached information.
virtual Q_INVOKABLE bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Sets the role data for the item at index to value.
virtual Q_INVOKABLE QModelIndex sibling(int row, int column, const QModelIndex &idx) const
Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no...
virtual QHash< int, QByteArray > roleNames() const
virtual QMap< int, QVariant > itemData(const QModelIndex &index) const
Returns a map with values for all predefined roles in the model for the item at the given index.
virtual bool setItemData(const QModelIndex &index, const QMap< int, QVariant > &roles)
Sets the role data for the item at index to the associated value in roles, for every Qt::ItemDataRole...
virtual Qt::DropActions supportedDragActions() const
Returns the actions supported by the data in this model.
virtual QStringList mimeTypes() const
Returns the list of allowed MIME types.
friend class QAbstractProxyModel
virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
Sets the data for the given role and section in the header with the specified orientation to the valu...
virtual bool submit()
Lets the model know that it should submit cached information to permanent storage.
The QAbstractProxyModel class provides a base class for proxy item models that can do sorting,...
virtual Q_INVOKABLE QModelIndex mapToSource(const QModelIndex &proxyIndex) const =0
Reimplement this function to return the model index in the source model that corresponds to the proxy...
virtual Q_INVOKABLE QModelIndex mapFromSource(const QModelIndex &sourceIndex) const =0
Reimplement this function to return the model index in the proxy model that corresponds to the source...
void sourceModelChanged(QPrivateSignal)
\inmodule QtCore
Definition qproperty.h:809
\inmodule QtCore
Definition qhash.h:818
\inmodule QtCore
Definition qmap.h:186
\inmodule QtCore
Definition qmimedata.h:16
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\inmodule QtCore
Definition qvariant.h:64
Combined button and popup list for selecting options.
Orientation
Definition qnamespace.h:97
@ EditRole
@ DisplayRole
SortOrder
Definition qnamespace.h:120
@ AscendingOrder
Definition qnamespace.h:121
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
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void GLsizei void void * span
GLfixed GLfixed GLint GLint order
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_PRIVATE_SLOT(d, signature)
#define Q_SIGNALS
QMimeData * mimeData
QItemSelection * selection
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent