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
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
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
\inmodule QtCore
Definition qmimedata.h:16
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
Orientation
Definition qnamespace.h:98
@ EditRole
@ DisplayRole
SortOrder
Definition qnamespace.h:121
@ AscendingOrder
Definition qnamespace.h:122
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
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
model setHeaderData(0, Qt::Horizontal, tr("Name"))
mimeData setData("text/csv", csvData)
QMimeData * mimeData
QItemSelection * selection
[0]