[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nepomuk
Subject:    Re: [Nepomuk] Retrieve "linked" artwork file
From:       Sebastian TrĂ¼g <trueg () kde ! org>
Date:       2011-10-17 18:24:54
Message-ID: 4E9C72F6.80706 () kde ! org
[Download RAW message or body]

On 10/17/2011 04:20 PM, daitheflu@free.fr wrote:
> Hi guys,
> 
> Me again. I'd like my application to link some file as an artwork for a Movie Type \
> Resource. The artwork consists in a .png file, stored in some directory (that's not \
> the important point). 
> Here is how I "link" the file to the artwork "property" of the Movie Resource \
> (Python code, but you'll understand) : 
> ***
> 
> # self.artwork is a QPixmap containg the artwork.
> 
> if not self.artwork.isNull():
> # SNIP : saves the cover to `coverpath`.
> # `coverpath` is a KUrl instance.
> 
> # Build a Resource of type NFO:image from the saved picture :
> img = Nepomuk.Resource(coverpath, OntologiesUrls.image())

This reminds me that I have a python tool somewhere which generates
ontology methods for python... have to look for it...

> # "Links" that NFO:image Resource to the NMM:artwork property of my Movie Resource \
> : resource.setProperty(OntologiesUrls.artwork(), Nepomuk.Variant(img))
> 
> ***
> 
> 
> The problem is to get the .png file back. Here is what I tried :
> 
> 
> ***
> 
> # Get the Resource linked by the NMM:artwork property :
> artwork = resource.property(OntologiesUrls.artwork())
> 
> if artwork.isValid():
> imgResource = artwork.toResource()
> res.artwork = PictureLoader.load_pixmap(imgResource.toFile().url())
> 
> ***
> 
> The problem is that `imgResource.toFile().url()` returns an empty KUrl.
> 
> Am I missing something ? What did I misunderstood ? How can I retrieve and load the \
> linked artwork file ?

it looks correct. Maybe use nepomukshell to look at the resources to
make sure. You can use a query like "select * where { ?r nmm:artwork ?v
. }" and then double-click on the resource.

Cheers,
Sebastian
_______________________________________________
Nepomuk mailing list
Nepomuk@kde.org
https://mail.kde.org/mailman/listinfo/nepomuk


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic