PDA

View Full Version : customize a QSortFilterProxyModel with additional columns



winkle99
16th March 2010, 00:53
My final goal is to display generated information in extra columns in a custom QFileDialog. The documentation indicates that by using a custom proxy model I should be able to add columns to the proxy model and have them displayed in the QFileDialog.

My first task was to determine the best place to gather the information and generate my custom data. My initial thought was filterAcceptsRow. I decided to start simple and just have filterAcceptsRow print out the data being displayed in the table. I was surprised to find that this method appears to only operate on folder information.

For this test my QFileDialog I start at a folder that ONLY contains .dpx files (which, incidentally, is what my filter is set to.) I expected that by default every item would pass through here prior to only .dpx files being returned. Can anyone explain what's happening here?


bool TestProxyModel::filterAcceptsRow ( int source_row, const QModelIndex &source_parent ) const
{
qDebug() << "&&&&entered TestProxyModel::filterAcceptsRow --> source_row is " << source_row;
qDebug() << " DisplayRole[ " << source_parent.row() << ", " << source_parent.column() << " ] = " << source_parent.data( Qt::DisplayRole).toString();
qDebug() << " FileNameRole[ " << source_parent.row() << ", " << source_parent.column() << " ] = " << source_parent.data( QFileSystemModel::FileNameRole ).toString();
qDebug() << " FilePathRole[ " << source_parent.row() << ", " << source_parent.column() << " ] = " << source_parent.data( QFileSystemModel::FilePathRole ).toString();

qDebug() << " DisplayRole[ " << source_parent.row() << ", 1 ] = " << source_parent.sibling(source_parent.row(), 1).data( Qt::DisplayRole).toString();
qDebug() << " FileNameRole[ " << source_parent.row() << ", 1 ] = " << source_parent.sibling(source_parent.row(), 1).data( QFileSystemModel::FileNameRole ).toString();
qDebug() << " FilePathRole[ " << source_parent.row() << ", 1 ] = " << source_parent.sibling(source_parent.row(), 1).data( QFileSystemModel::FilePathRole ).toString();

return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent );
}

rturrentine
16th November 2011, 04:17
I know it's been a while but did you ever solve this issue? I need to add columns for custom data as well.