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

Shawn Willden shawn-kimdaba at willden.org
Wed Feb 21 11:26:14 GMT 2007


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.
	Shawn.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kphotoalbum/attachments/20070221/4acd513f/attachment.htm>


More information about the Kphotoalbum mailing list