1// Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it>
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 QTRANSPOSEPROXYMODEL_H
5#define QTRANSPOSEPROXYMODEL_H
6
7#include <QtCore/qabstractproxymodel.h>
8#include <QtCore/qscopedpointer.h>
9
10QT_REQUIRE_CONFIG(transposeproxymodel);
11
12QT_BEGIN_NAMESPACE
13
14class QTransposeProxyModelPrivate;
15
16class Q_CORE_EXPORT QTransposeProxyModel : public QAbstractProxyModel
17{
18 Q_OBJECT
19 Q_DISABLE_COPY(QTransposeProxyModel)
20 Q_DECLARE_PRIVATE(QTransposeProxyModel)
21public:
22 explicit QTransposeProxyModel(QObject* parent = nullptr);
23 ~QTransposeProxyModel();
24 void setSourceModel(QAbstractItemModel* newSourceModel) override;
25 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
26 int columnCount(const QModelIndex &parent = QModelIndex()) const override;
27 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
28 bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override;
29 bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles) override;
30 QSize span(const QModelIndex &index) const override;
31 QMap<int, QVariant> itemData(const QModelIndex &index) const override;
32 QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
33 QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
34 QModelIndex parent(const QModelIndex &index) const override;
35 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
36 bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
37 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
38 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
39 bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
40 bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
41 bool moveColumns(const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override;
42 void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
43protected:
44 QTransposeProxyModel(QTransposeProxyModelPrivate &, QObject *parent);
45};
46
47QT_END_NAMESPACE
48
49#endif // QTRANSPOSEPROXYMODEL_H
50

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