Hi !

I'm developing a small application and I'd like to take full advantage of the 
kioslaves technology since I discovered them. I'm coding with PyKDE4 and PyQt4.
For now, I'm trying to display a list of movie files. All the files are stored 
in one location and I also have a "covers" directory in the same location to 
store the movies covers.
Until I discovered the kioslaves thing, this location was local only. Now I'd 
like to be able to specify a local OR remote location (like a NFS share). If I 
understand well, kioslaves should allow me to that easily :)

Well, I'm using a KDirModel (+ a KDirSortFilterProxyModel subclass) with a 
custom QListView to display the available movies. It works pretty well. As I 
said before, I'd like to display the covers instead of the default icons. So I 
overwrote the KDirSortFilterProxyModel.data(index, role) function to return the 
cover. I had no problem when files were local : it was simple to build a QIcon 
with the local path of the corresponding cover.

Now that the cover file can be remote, I plan to use this method to load the 
movie cover (not tested yet) :

@staticmethod
def get_cover(movieName):
    """
    """
    res = QIcon("icons:default_movie_cover.png")
    url = KUrl.fromPath(QApplication.instance().config.get('Movies', 
'movies_path'))

    # as you can see, url is a KUrl that can point to a local OR remote path 
(NFS share or whatever)

    url.addPath("covers/{0}.jpg".format(md5Hash(movieName)))

    if KIO.NetAccess.exists(url, True):
        KIO.NetAccess.download(url, tmpFile)
        res = QIcon(tmpFile)
        KIO.NetAccess.removeTempFile(tmpFile)

    return res


Is this a good solution ? I think I'm missing something because I'm still 
downloading the file and, for what I understand, kioslaves should allow me to 
avoid that. Is there a way to load the file and build a QIcon without 
downloading it first ? What about performances if I have hundreds of files and 
load them from a remote source ?

Thank you very much for your help and interest.

-- 
François
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Reply via email to