PDA

View Full Version : QFileDialog - remote browsing possible?



KShots
13th November 2009, 21:06
I've been scouring the docs looking for a means of running a QFileDialog locally on a remote filesystem, obtaining its data from a QTcpSocket from an application on the other end that can pump FS data back.

It looks like my best shot would be to re-implement the model that the QFileDialog operates off of with a proxy model on the local side, and run a QFileSystemModel on the remote end, and somehow serialize any requests/responses from the two over the QTcpSocket.

Is this even possible/feasible? Looking at the QAbstractProxyModel, it looks like I'd need to call 'setSourceModel' on yet another model, that would actually do the legwork to query the socket from the remote QFileSystemModel, so it would look like this:

+----------------+ +----------+ +----------+ +----------+ +----------+ +------------------+ +-------------------+ +-----------+
|QFileSystemModel|----|serializer|----|QTcpSocket|----|QTcpSocket|----|serializer|----|QAbstractItemModel|----|QAbstractProxyModel|----|QFileDialog|
+----------------+ +----------+ +----------+ +----------+ +----------+ +------------------+ +-------------------+ +-----------+
Am I totally off-base with this? Is there an easier way?

squidge
13th November 2009, 22:06
Can't you just mount the remote drive as a network share and browse that? It'll do what your trying to do without reimplementing everything.

KShots
13th November 2009, 22:28
Not really... the idea is to set inotify watch points on a remote machine (without a keyboard) with a nice GUI app, which may be running any operating system.

squidge
13th November 2009, 23:06
Ok, now I'm confused. How were you going to do that with QFileDialog ? If your going to browse the directory structure with a QFileDialog, you might as well share the directory structure over the network and browse the network path.

Or is there something I'm not getting here?

Unless of course the QFileDialog was simply to show the directories, and then you could select those directories with your application and it did something with them? But QFileDialog is for selecting files, not directories.

:confused:

KShots
14th November 2009, 04:52
That was the idea - it's just to get a directory (or rather, several directories) from the remote system.

QFileDialog has, among other things, a static function that allows for selecting directories.

The how was in the first post (I'd set the model for the QFileDialog's view and that should take care of it)... but it seemed excessive to me and failed to pass the "sanity" check. On the other hand, if it's doable that way, then it's just short of the "too hard to do" point for me and I'll plod forward with it.

I'm also wondering just how much effort I'm willing to put forward when it can be solved with a simple QLineEdit and a manual entry (no browsing)

squidge
14th November 2009, 12:27
So what you really need if you don't want to allow network shares is a FTP-like connection without the "F" part :D As in, you can browse the directory structure but you can't transfer any files.

It is a fair amount of work and possibly a lot of maintenance for something if people would be quite happy with a QLineEdit box though. I assume you can get a directory listing in other ways (Most OS support exporting the display and allowing remote control or other means), so all you need do is copy and paste the path, but if you need to connect to the server to setup the final configuration, then you might as well add the browsing part as well. I just wouldn't use a QFileDialog, but maybe a QTreeView instead, should be much easier.