Just use KFileItem::localPath(). If that is empty then the result is not a local file.
And of course KDirModel provides KFileItems. It is based on them. Just use KDirModel::itemForIndex and always make sure you properly convert indexes in case you are using filter models. Cheers, Sebastian On 06/08/2010 11:04 AM, Alessandro Diaferia wrote: > > > 2010/6/8 Alessandro Sivieri <[email protected] > <mailto:[email protected]>> > > 2010/6/7 Alessandro Diaferia <[email protected] > <mailto:[email protected]>> > > As you may have understood i'm using Nepomuk to show media files > to the user. > One thing i noticed is that when using the KDirModel (and so the > KDirLister) to list the results of a query > it seems that each QModelIndex doesn't have a valid > KDirModel::FileItemRole and therefore no important pieces of > information > like the url of the file (AFAIK KDirModel is KFileItem-centric). > I make use of such role in order to get previews of the files. > > > Well, both in Sembrowser and in Smartsave I am using KDirOperator, > and it works correctly for me, I mean files are shown with correct > name and icon, and they are correctly opened once passed to KRun; I > use Nepomuk::Query::toSearchUrl, to obtain the URL to set the URL to > KDirOperator. > I think I also used KDirModel directly some time ago, but then I > decided that the operator was better. > Can you show us some code? > > > Ok, giving some context: the mediabrowser applet we use in PMC takes > advantage of an AbstractItemView written from scratch (aka not > inheriting from QAbstractItemView). > This means that the QAbstractItemModel passed is handled internally. If > the set model makes use of KDirModel::FileItemRole additional > capabilities are enabled: > this means that not only the name and the icon is drawn but now, through > the given KFileItem, the view has access to the URL of the file and can, > for example, retrieve previews. > Unfortunately I cannot make use of KDirOperator as long as PMC has this > particular structure. My concern now is: is there a way to get the file > url for the particular nepomuk search result? > I might go for Nepomuk::Resource::property(Vocabulary::NIE::url()) i > don't know how to build the resource from the given QModelIndex. > > Hints appreciated :p > > > > -- > Sivieri Alessandro > [email protected] <mailto:[email protected]> > http://www.chimera-bellerofonte.eu/ > http://www.poul.org/ > > > Thank you. > > P.S.: forgot to mention that I'm using Nepomuk::Query::toSearchUrl too, > passing it to the KDirLister->openUrl() method. > > -- > Alessandro Diaferia > KDE Developer > KDE e.V. member > > > > _______________________________________________ > Nepomuk mailing list > [email protected] > https://mail.kde.org/mailman/listinfo/nepomuk _______________________________________________ Nepomuk mailing list [email protected] https://mail.kde.org/mailman/listinfo/nepomuk
