QFileDialog::setProxyModel()
-
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 ? -
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"). -
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.