Patch: KFileMetaInfo documentation

Brad Hards bradh at frogmouth.net
Sun Sep 18 21:57:36 BST 2005


On Monday 19 September 2005 00:24 am, Sébastien Laoût wrote:
> I wanted to list all metainfos of a file (eg. the author, title... or a PDF
> file...).
> But the class KFileMetaInfo lack some documentation and it took me some
> time to find out how to do that, and know which methods to call.
> Ie. what to choose between groups(), supportedGroups(), preferredGroups(),
> preferredKeys(), supportedKeys()... where the documentation barelly tell us
> that it "Returns a list of all supported groups" or "Returns a list of the
> preferred groups"!
There is a tutorial for this class, on developer.kde.org.

> Some example of usage would not be bad.
> I propose to add this code snippet in the KFileMetaInfo Detailed
> Description:
>
> /** The following example illustrate how to show the list of metainfos
>   * of a file to the user, with translated keys and formated string values:
>   */
> KFileMetaInfo infos = KFileMetaInfo(theUrlOfTheFile);
> // If the file actually have metainfos:
> if (infos.isValid() && !infos.isEmpty())
> {
>     // Get the keys specific to the file MIME type and that the file have:
>     QStringList groups = infos.preferredKeys();
This part is probably wrong. If you want a list of all the keys that the file 
has, you should use supportedKeys().

>     for (QStringList::Iterator it = groups.begin(); it != groups.end();
> ++it) {
>         KFileMetaInfoItem metaInfoItem = infos.item(*it);
>         if (!metaInfoItem.string().isEmpty())
>         {
>             std::cout << metaInfoItem.translatedKey() << ": " <<
>                          metaInfoItem.string() << std::endl;
>         }
>     }
> }
>
> It will hopefully help other developpers to quickly get used to this class.
You might want to update the tutorial as well.

Brad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050919/1ecf6204/attachment.sig>


More information about the kde-core-devel mailing list