Originally Posted by
wysota
I don't think this would be enough. You would only gain as much that your data would be shifted one column to the left.
But just for the sake of an example:
return sourceModel()->index(proxyIndex.row(), proxyIndex.column()-1, <something has to go here>);
}
return createIndex(sourceIndex.row(), sourceIndex.column()+1, <something has to go here>);
}
QModelIndex Proxy::mapToSource(const QModelIndex &proxyIndex){
if(proxyIndex.column()==0) return QModelIndex();
return sourceModel()->index(proxyIndex.row(), proxyIndex.column()-1, <something has to go here>);
}
QModelIndex Proxy::mapFromSource(const QModelIndex &sourceIndex){
return createIndex(sourceIndex.row(), sourceIndex.column()+1, <something has to go here>);
}
To copy to clipboard, switch view to plain text mode
This also has completely no effect:
#ifndef TABLETOTREEPROXYMODEL_H
#define TABLETOTREEPROXYMODEL_H
//#include <QAbstractProxyModel>
#include <QSortFilterProxyModel>
#include <QModelIndex>
{
public:
{
return sourceModel()->index(proxyIndex.row(), proxyIndex.column()-1, parent(proxyIndex));
}
{
return createIndex(sourceIndex.row(), sourceIndex.column()+1);
}
{
if (!parent.isValid()) return createIndex(row, column);
else return index(parent.row(),parent.column()+1);
return createIndex(row,column);
}
{
return index(child.row(),child.column()-1);
}
};
#endif // TABLETOTREEPROXYMODEL_H
#ifndef TABLETOTREEPROXYMODEL_H
#define TABLETOTREEPROXYMODEL_H
//#include <QAbstractProxyModel>
#include <QSortFilterProxyModel>
#include <QModelIndex>
class TableToTreeProxyModel : public QSortFilterProxyModel
{
public:
TableToTreeProxyModel(QObject * parent = 0) : QSortFilterProxyModel(parent){};
QModelIndex mapToSource(const QModelIndex &proxyIndex)
{
if(proxyIndex.column()==0) return QModelIndex();
return sourceModel()->index(proxyIndex.row(), proxyIndex.column()-1, parent(proxyIndex));
}
QModelIndex mapFromSource(const QModelIndex &sourceIndex)
{
return createIndex(sourceIndex.row(), sourceIndex.column()+1);
}
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex())
{
if (!parent.isValid()) return createIndex(row, column);
else return index(parent.row(),parent.column()+1);
return createIndex(row,column);
}
QModelIndex parent(const QModelIndex &child)
{
if (!child.isValid()) return QModelIndex();
if (child.column()==0) return QModelIndex();
return index(child.row(),child.column()-1);
}
};
#endif // TABLETOTREEPROXYMODEL_H
To copy to clipboard, switch view to plain text mode
Bookmarks