Hello! I use Qt-4.4.3/X11.
I customizing QFileDialog so that it displays additional virtual drive after root drive "/" in MyComputer.
In docs reads "QFileDialog::setProxyModel() sets the model for the views to the given proxyModel. This is useful if you want to modify the underlying model; for example, to add columns, filter data or add drives.".
So I use QFileDialog::setProxyModel() to add drive.
I create proxyModel as descendant of QSortFilterProxyModel. Now my QFileDialog with proxyModel displays virtual disk fine.
But double clicking on it does nothing, because proxyIndex for virtual drive have no sourceIndex in source model.
I need that double clicking on virtual drive handles as usual folder. Any ideas ?
You will have to translate the virtual index to an index of an actually existing file/directory in the filesystem or provide the data for more virtual files yourself.
I reimplement all functions to provide data for my virtual files and folders. But double click handler
QFileDialogPrivate::q enterDirectory() does not ask me for virtual file. It asked source model directly throught mapToSource("here myProxyVirtualIndex").
That would be a bug from my point of view then. If it works on a proxy model, it always must ask the proxy model.
I see this bug also. I not find any samples to use this feature QFileDialog::setProxyModel() to realize extra folders.
By the way, if you add stuff, you should create a complete own proxy model instead of deriving QSortFilterProxyModel (QSFPM). There are many dependencies inside the QSFPM which may lead to problems (as MapToSource delivers some, from the base impl. unexpected values etc.).
Yes, you right. I use QSFPM only temporarily to get working example quickly.
Fortunately, it works, virtual drive dispalys correct. The main problem inside QFileDialog, it
ignore proxy for extra folder.
Workaround is handle double click and use separate view with virtual folder contents, but
I still hope find better decision.