<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
<p>On Wednesday 21 February 2007 02:34, Michael J Gruber wrote:</p>
<p>> This would certainly be the more systematic approach. Downside is that</p>
<p>> (I don't know I would have the ability/time implement it and) it takes</p>
<p>> too too. If you want to "do it right" (identifying by</p>
<p>> KMimeType/KMimeMagic) then the file needs to be read, at least the first</p>
<p>> few bytes. With the current approach only the file extension is used, so</p>
<p>> that it's relatively cheap to do it on the fly. Besides, it works for me ;)</p>
<p></p>
<p>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 <span style="font-style:italic">fast</span>."  I suspect it won't make much difference.</p>
<p></p>
<p>As for how to implement it, I think it's pretty straightforward (though I haven't actually tried it :-)).  Something like:</p>
<p></p>
<p>QString filetype = KMimeType::findByPath(info->fileName())->name();</p>
<p></p>
<p>Actually, that would set filetype to something like "image/jpeg", so it would be necessary to grab the part after the '/', so:</p>
<p></p>
<p>KMimeType::findByPath(info->fileName())->name().section('/',1);</p>
<p>Should do it.  I'd test it, but I'm not currently set up to build KPA.</p>
<p>       Shawn.</p>
</body></html>