Mixxx
|
00001 #include <QAbstractProxyModel> 00002 #include <QModelIndex> 00003 00004 class TransposeProxyModel : public QAbstractProxyModel{ 00005 public: 00006 TransposeProxyModel(QObject *p = 0) : QAbstractProxyModel(p){} 00007 QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const{ 00008 return index(sourceIndex.column(), sourceIndex.row()); 00009 } 00010 QModelIndex mapToSource ( const QModelIndex & proxyIndex ) const{ 00011 return sourceModel()->index(proxyIndex.column(), proxyIndex.row()); 00012 } 00013 QModelIndex index(int r, int c, const QModelIndex &ind=QModelIndex()) const{ 00014 return createIndex(r,c); 00015 } 00016 QModelIndex parent(const QModelIndex&) const { 00017 return QModelIndex(); 00018 } 00019 int rowCount(const QModelIndex &) const{ 00020 return sourceModel()->columnCount(); 00021 } 00022 int columnCount(const QModelIndex &) const{ 00023 return sourceModel()->rowCount(); 00024 } 00025 QVariant data(const QModelIndex &ind, int role) const { 00026 return sourceModel()->data(mapToSource(ind), role); 00027 } 00028 };