[KPhotoAlbum] Patch: file type as subcategory of media type

Michael J Gruber michaeljgruber+gmane at fastmail.fm
Wed Feb 21 12:42:52 GMT 2007


Shawn Willden venit, vidit, dixit 2007-02-21 12:26:
> On Wednesday 21 February 2007 02:34, Michael J Gruber wrote:
> 
>> This would certainly be the more systematic approach. Downside is that
> 
>> (I don't know I would have the ability/time implement it and) it takes
> 
>> too too. If you want to "do it right" (identifying by
> 
>> KMimeType/KMimeMagic) then the file needs to be read, at least the first
> 
>> few bytes. With the current approach only the file extension is used, so
> 
>> that it's relatively cheap to do it on the fly. Besides, it works for
> me ;)
> 
> You can have it either way, I think. KMimeType::findByPath has a
> "fast_mode" parameter. If set to true, "no disk access is allowed to
> find out the mimetype. The result may be suboptimal, but it is fast." I
> suspect it won't make much difference.
> 
> As for how to implement it, I think it's pretty straightforward (though
> I haven't actually tried it :-)). Something like:
> 
> QString filetype = KMimeType::findByPath(info->fileName())->name();
> 
> Actually, that would set filetype to something like "image/jpeg", so it
> would be necessary to grab the part after the '/', so:
> 
> KMimeType::findByPath(info->fileName())->name().section('/',1);
> 
> Should do it. I'd test it, but I'm not currently set up to build KPA.

Thanks for the hint. I'll have a look at it. It might lump all raw
extensions together, but I'll see. If we use the more exact and
expensive identification then it should be stored as a new attribute in
the xml so that it needs to be done only once. This requires more
coding, of course.

In any case, Jesper has the say on what he'd be willing to integrate.

Michael




More information about the Kphotoalbum mailing list