#include "PropertyProxyModel.h" /* * Code borrowed from: https://stackoverflow.com/questions/21653253/how-to-change-orientation-of-qt-tableview */ PropertyProxyModel::PropertyProxyModel(QObject *parent) : QIdentityProxyModel(parent) { } QModelIndex PropertyProxyModel::mapToSource(const QModelIndex &proxyIndex) const { if (sourceModel()) { return sourceModel()->index(proxyIndex.column(), proxyIndex.row()); } else { return QModelIndex(); } } QModelIndex PropertyProxyModel::mapFromSource(const QModelIndex &sourceIndex) const { return index(sourceIndex.column(), sourceIndex.row()); } QModelIndex PropertyProxyModel::index(int row, int column, const QModelIndex &) const { return createIndex(row, column, nullptr); } QModelIndex PropertyProxyModel::parent(const QModelIndex &) const { return QModelIndex(); } int PropertyProxyModel::rowCount(const QModelIndex &) const { return sourceModel() ? sourceModel()->columnCount() : 0; } int PropertyProxyModel::columnCount(const QModelIndex &) const { return sourceModel() ? sourceModel()->rowCount() : 0; } QVariant PropertyProxyModel::headerData( int section, Qt::Orientation orientation, int role) const { if (!sourceModel()) { return QVariant(); } Qt::Orientation new_orientation = orientation == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal; return sourceModel()->headerData(section, new_orientation, role); }