1// Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
5#ifndef QIDENTITYPROXYMODEL_H
6#define QIDENTITYPROXYMODEL_H
7
8#include <QtCore/qabstractproxymodel.h>
9
10QT_REQUIRE_CONFIG(identityproxymodel);
11
12QT_BEGIN_NAMESPACE
13
14
15class QIdentityProxyModelPrivate;
16
17class Q_CORE_EXPORT QIdentityProxyModel : public QAbstractProxyModel
18{
19 Q_OBJECT
20public:
21 explicit QIdentityProxyModel(QObject* parent = nullptr);
22 ~QIdentityProxyModel();
23
24 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
25 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
26 QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override;
27 QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
28 QModelIndex parent(const QModelIndex& child) const override;
29 using QObject::parent;
30 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
31 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
32 bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
33 QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
34
35 QItemSelection mapSelectionFromSource(const QItemSelection& selection) const override;
36 QItemSelection mapSelectionToSource(const QItemSelection& selection) const override;
37 QModelIndexList match(const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const override;
38 void setSourceModel(QAbstractItemModel* sourceModel) override;
39
40 bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
41 bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
42 bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex()) override;
43 bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override;
44 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
45 bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override;
46
47protected:
48 QIdentityProxyModel(QIdentityProxyModelPrivate &dd, QObject* parent);
49
50private:
51 Q_DECLARE_PRIVATE(QIdentityProxyModel)
52 Q_DISABLE_COPY(QIdentityProxyModel)
53
54 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(QModelIndex,int,int))
55 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(QModelIndex,int,int))
56 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(QModelIndex,int,int))
57 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(QModelIndex,int,int))
58 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
59 Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int))
60
61 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(QModelIndex,int,int))
62 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(QModelIndex,int,int))
63 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int))
64 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(QModelIndex,int,int))
65 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))
66 Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int))
67
68 Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(QModelIndex, QModelIndex, QList<int>))
69 Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int first, int last))
70
71 Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint))
72 Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint))
73 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelAboutToBeReset())
74 Q_PRIVATE_SLOT(d_func(), void _q_sourceModelReset())
75};
76
77QT_END_NAMESPACE
78
79#endif // QIDENTITYPROXYMODEL_H
80
81

source code of qtbase/src/corelib/itemmodels/qidentityproxymodel.h