Results 1 to 6 of 6

Thread: QDirModel and FTP

  1. #1
    Join Date
    Oct 2007
    Location
    USA
    Posts
    27
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QDirModel and FTP

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel and FTP

    Take a look at QAbstractFileEngineHandler and QAbstractFileEngine, although I'm not sure how efficient it will be with QDirModel.

  3. #3
    Join Date
    Oct 2007
    Location
    USA
    Posts
    27
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Re: QDirModel and FTP

    Is there some way to at least just get the icon from the file extension?

  4. #4
    Join Date
    Oct 2007
    Location
    USA
    Posts
    27
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDirModel and FTP

    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 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.

  5. #5
    Join Date
    Oct 2007
    Location
    USA
    Posts
    27
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDirModel and FTP

    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?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDirModel and FTP

    Quote Originally Posted by last2kn0 View Post
    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.