diff options
author | Luca Beldi <v.ronin@yahoo.it> | 2018-11-05 12:17:31 +0000 |
---|---|---|
committer | Luca Beldi <v.ronin@yahoo.it> | 2018-11-05 23:53:01 +0000 |
commit | 6963efb396f7f206afb2f3f9655f26b0c21b6a05 (patch) | |
tree | ade6488a327178ba6db90d1e897bb777f5bd8d01 /src/corelib/itemmodels/qtransposeproxymodel_p.h | |
parent | e9bebc12812b5c50346952cd9128bdd08ddd0b9d (diff) |
New proxy model: QTransposeProxyModel
Implemented a new proxy model to transpose the source model.
Rows will become columns and vice-versa.
Both flat and tree models supported.
[ChangeLog][QtCore] New class QTransposeProxyModel to
swap rows and columns of the source model.
Change-Id: I902963c6b81aa0f63b5ad2bddca538f28b565084
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels/qtransposeproxymodel_p.h')
-rw-r--r-- | src/corelib/itemmodels/qtransposeproxymodel_p.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/corelib/itemmodels/qtransposeproxymodel_p.h b/src/corelib/itemmodels/qtransposeproxymodel_p.h new file mode 100644 index 0000000000..240fc4ccae --- /dev/null +++ b/src/corelib/itemmodels/qtransposeproxymodel_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTRANSPOSEPROXYMODEL_P_H +#define QTRANSPOSEPROXYMODEL_P_H + +#include "qtransposeproxymodel.h" +#include <private/qabstractproxymodel_p.h> + +QT_BEGIN_NAMESPACE + +class QTransposeProxyModelPrivate : public QAbstractProxyModelPrivate +{ + Q_DECLARE_PUBLIC(QTransposeProxyModel) + Q_DISABLE_COPY(QTransposeProxyModelPrivate) +private: + QTransposeProxyModelPrivate() = default; + QVector<QMetaObject::Connection> sourceConnections; + QVector<QPersistentModelIndex> layoutChangePersistentIndexes; + QModelIndexList layoutChangeProxyIndexes; + QModelIndex uncheckedMapToSource(const QModelIndex &proxyIndex) const; + QModelIndex uncheckedMapFromSource(const QModelIndex &sourceIndex) const; + void onLayoutChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint); + void onLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &parents, QAbstractItemModel::LayoutChangeHint hint); + void onDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles); + void onHeaderDataChanged(Qt::Orientation orientation, int first, int last); + void onColumnsAboutToBeInserted(const QModelIndex &parent, int first, int last); + void onColumnsAboutToBeRemoved(const QModelIndex &parent, int first, int last); + void onColumnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn); + void onRowsAboutToBeInserted(const QModelIndex &parent, int first, int last); + void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last); + void onRowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow); +}; + +QT_END_NAMESPACE + +#endif //QTRANSPOSEPROXYMODEL_P_H |