PDA

View Full Version : QDirModel and FTP



last2kn0
16th April 2008, 21:52
I am planning on creating an FTP program to view an ftp location as if was a local filesystem. Much like when you create a network place in windows or use the FISH kioslave in KDE.

I would like the files and directories to have their respective type icons. I have noticed programs like Filezilla are able to do so but I have not been able to come across a solution for Qt.

Is there a way to use the QDirModel with remote filesystems? Or is there some other way to accomplish this?

jacek
16th April 2008, 22:37
Take a look at QAbstractFileEngineHandler and QAbstractFileEngine, although I'm not sure how efficient it will be with QDirModel.

last2kn0
17th April 2008, 03:46
Is there some way to at least just get the icon from the file extension?

last2kn0
17th April 2008, 22:24
Ok I found a way of accomplishing this but I do not know if its the best way.
Currently when I ftp.ls(), I make a temporary file with the name of the returned QUrlInfo. Then I send that to QFileIconProvider to get the icon.
I read here (http://msdn2.microsoft.com/en-us/magazine/cc301425.aspx) that SHGetFileInfo has a called SHGFI_USEFILEATTRIBUTES that allows one to send a fake file to get the info you want. This would then allow me to just create a QFileInfo with QUrlInfo::name instead of creating an actual file.

Now this does not work because Qt's implementation of the QFileIconProviderPrivate::getWinIcon does not use SHGFI_USEFILEATTRIBUTES and a few other parts of the implementation.
Should I make a tasktracker to add this so that one does not have to have a real file in order to get the file icon (such as when you just have the ext)?

I'm not quite sure now if this will work on a mac. I don't know how their icon retrieval works yet. I will try this on my mac when I go home at the end of may.

last2kn0
17th April 2008, 23:27
Another question I have is how do I get this to work in Linux? I noticed that QFileIconProvider is only implemented for Windows and Mac. How can you retrieve the icon for linux?

jacek
19th April 2008, 01:02
How can you retrieve the icon for linux?
I'm afraid that there might not be any standard way for Linux systems. AFAIK KDE checks the file contents to detect file type and looks at the extension only as the last resort, so the trick with a virtual file won't work.