PDA

View Full Version : QDirModel (filter files, custom Icon, look)



prashant
4th September 2009, 17:03
Hi,

This is my first post.....:)



QDirModel *model = new QDirModel(this);
model->setReadOnly(true);

model->setSorting(QDir::DirsFirst | QDir::IgnoreCase | QDir::Name);
model->setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);


QTreeView *treeView = new QTreeView;
treeView->setModel(model);
QDir dir("../node");
treeView->setRootIndex(model->index(dir.path()));


The above code is working fine. I need to do three more things. The further directory structure inside ("node") directory consists more directories with (.xml,.bmp,.txt) files.

How do I edit QDirModel so that:

1. It should only shows directories and ".xml" files only.

2. Every ".xml" file has equivalent ".bmp" file in the same directory. For e.g. "tree.xml" & "tree.bmp". By default ".xml" files shows system's icon. I need to show the ".bmp" icon
instead of default icon.

3. I don't need the header with colums (Name, Size, Type etc.)

Regards

Prashant

wysota
6th September 2009, 09:39
Subclass QSortFilterProxyModel, filter out the entries you don't need and reimplement the data() method to return proper icons. Then position your proxy model between the source model and the view.