views:

276

answers:

2

Hi,

I am writing an application which requires me to use another file system and file engine handlers and not the qt's default ones. Basically what I want to be able to do is to use qt's file dialog but have an underlying file system handler (for example built using boost file system library) of mine handling all the operations with regards to file and directory operations within that dialog. I have already written a custom file engine which handles some of the operations but I am now stuck with Qt's file system model and the file system watcher engine, as I need to have the signals transmitted for this custom file engine. Seems like I have a daunting task ahead. Am I heading in the right direction?

Is there any other simpler way that I could implement this? Can anyone give me any idea on how to proceed. I was thinking of looking into proxy models but not sure if that would work.

Thanks in advance for any help.

+1  A: 

Proxy model operates with data, that underlying model contains, so, you can't use it to get entirely new model contents.

The obvious way to do such tasks is to investigate, what kind of model QFileDialog has, and then replace the model.

You can, probably, copy the model from QFileDialog, with respect to your new file engine, of course, and then use propxy model in a somewhat strange way: set it (it will connect to underlying model of QFileDialog, you can't access another way) and then use your proxy's setSourceModel() to set your model instead.

Or you simply can get the code of QFileDialog and replace filesystem-awared code with yours. But it smells bad, I think, and I don't know if it legal and what issues you can face due to the licences and so one.

Max
Thanks much for your response Max, I was thinking in the same direction as you have mentioned as getting the QFileDialog code and modify it but that does not seem to be right because of licensing issues etc. Also, as you suggested, proxy models would not provide anything as some of the calls that are made by QDir are called from within QFileSystemModel. In that case the only solution is to write the whole new model and then create a view similar to QFileDialog, which is non trivial at best.
knight
I feel that there should be a simpler solution to this. I may have to provide some of the functionality of Qdir and QFileEnginePrivate into my custom file engine, then hopefully I may still be able to use the same model-view pair for file access through my custom engine. I am not really sure if what I am thinking would work or not, or if it even makes sense.
knight
Maybe you need to reimplement only QFileSystemModel and then connect your model to QFileDialog using proxymodel's setSourceModel() method?
Max
A: 

It used to be possible to do this with QAbstractFileEngine etc. but the changes to QDir in Qt 4.6 broke it somewhat - see Qt bug 10333 for my experiences.

Alphax