kio Library API Documentation

KFileMetaInfo Class Reference

This is the class for objects that hold meta information about a file. More...

#include <kfilemetainfo.h>

List of all members.

Public Types

enum  What
 This is used to specify what a KFileMetaInfo object should read, so you can specify if you want to read "expensive" items or not. More...


Public Methods

 KFileMetaInfo (const QString &path, const QString &mimeType=QString::null, uint what=Fastest)
 The constructor.

 KFileMetaInfo ()
 Default constructor.

 KFileMetaInfo (const KFileMetaInfo &original)
 Copy constructor.

const KFileMetaInfo & operator= (const KFileMetaInfo &info)
 The assignment operator, so you can do e.g.:.

QStringList groups () const
QStringList editableGroups () const
bool addGroup (const QString &name)
 Try to add the specified group.

bool removeGroup (const QString &name)
 remove the specified group.

bool applyChanges ()
 This method writes all pending changes of the meta info back to the file.

bool contains (const QString &key) const
bool containsGroup (const QString &key) const
bool isValid () const
bool isEmpty () const

Protected Methods

KFilePlugin *const plugin () const


Detailed Description

This is the class for objects that hold meta information about a file.

The information is kept in form of a system of key/value pairs. See also KFileMetaInfoItem. This information is retrieved from the file through a plugin system, and this class is the main interface to it. If you want to write your own plugin, have a look at KFilePlugin. There are basically two different kinds of meta information: Fixed ones that the plugin knows about (e.g. an mp3 id3v1 tag has a well defined fixed list of fields), and variable keys that exist in mimetypes that support their own key/value system (comments in png files are of this type). Almost every file has fixed keys, but some also have variable keys.

The groups and the What enum are not yet supported, but already added to the interface so that adding support doesn't break compatibility.

Definition at line 847 of file kfilemetainfo.h.


Member Enumeration Documentation

enum KFileMetaInfo::What
 

This is used to specify what a KFileMetaInfo object should read, so you can specify if you want to read "expensive" items or not.

  • Fastest do the fastest possible read and omit all items that might need a significantly longer time than the others
  • Everything read everything, even if it might take a while
  • DontCare let the plugin decide what to read
  • TechnicalInfo extract technical details about the file, like e.g. play time, resolution or a compression type
  • ContentInfo read information about the content of the file, like comments or id3 tags
  • ExtendedAttr read filesystem based extended attributes if they are supported for the filesystem
  • Thumbnail only read the file's thumbnail, if it contains one
  • Preferred get at least the preferred items

Definition at line 874 of file kfilemetainfo.h.


Constructor & Destructor Documentation

KFileMetaInfo::KFileMetaInfo const QString   path,
const QString   mimeType = QString::null,
uint    what = Fastest
 

The constructor.

creating a KFileMetaInfo item through this will autoload the plugin belonging to the mimetype and try to get meta information about the specified file.

If no info is available, you'll get an empty (not invalid) object. You can test for it with the isEmpty() method.

Parameters:
path  The file name. This must be the path to a local file.
mimeType  The name of the file's mimetype. If ommited, the mimetype is autodetected
what  one or more of the What enum values. It gives some hint to the plugin what information is desired. The plugin may still return more items.

Definition at line 284 of file kfilemetainfo.cpp.

References KMimeType::findByURL(), QString::isEmpty(), KFileMetaInfo(), plugin(), and KFilePlugin::readInfo().

KFileMetaInfo::KFileMetaInfo  
 

Default constructor.

This will create an invalid object (see isValid().

Definition at line 321 of file kfilemetainfo.cpp.

Referenced by KFileMetaInfo().

KFileMetaInfo::KFileMetaInfo const KFileMetaInfo &    original
 

Copy constructor.

Definition at line 314 of file kfilemetainfo.cpp.


Member Function Documentation

const KFileMetaInfo & KFileMetaInfo::operator= const KFileMetaInfo &    info
 

The assignment operator, so you can do e.g.:.

    KFileMetaInfo info;
    if (something) info = KFileMetaInfo("/the/file");
 

This will create a shared copy of the object. The actual data is automatically deleted if all copies go out of scope

Definition at line 466 of file kfilemetainfo.cpp.

References d.

QStringList KFileMetaInfo::groups  
 

Returns:
all keys groups that the file has.

Definition at line 341 of file kfilemetainfo.cpp.

Referenced by contains(), and containsGroup().

QStringList KFileMetaInfo::editableGroups  
 

Returns:
the list of groups that you can add or remove from the file.

Definition at line 351 of file kfilemetainfo.cpp.

References KFileMimeTypeInfo::GroupInfo::attributes().

bool KFileMetaInfo::addGroup const QString   name
 

Try to add the specified group.

This will only succeed if it is in the list of editableGroups(). Note that all non-variable items that belong to this group are automatically added as empty item.

Definition at line 413 of file kfilemetainfo.cpp.

References KFileMetaInfoGroup::appendItem(), KFileMimeTypeInfo::ItemInfo::attributes(), KFileMimeTypeInfo::GroupInfo::itemInfo(), KFileMimeTypeInfo::ItemInfo::key(), KFileMetaInfoGroup::setAdded(), and KFileMimeTypeInfo::GroupInfo::supportedKeys().

bool KFileMetaInfo::removeGroup const QString   name
 

remove the specified group.

This will only succeed if it is in the list of editableGroups(). Beware that this also removes all the items in that group, so always ask the user before removing it!

Definition at line 449 of file kfilemetainfo.cpp.

bool KFileMetaInfo::applyChanges  
 

This method writes all pending changes of the meta info back to the file.

If any items are marked as removed, they are really removed from the list. The info object as well as all items are updated.

Returns:
true if successful, false if not

Definition at line 494 of file kfilemetainfo.cpp.

References QMapConstIterator::data(), plugin(), and KFilePlugin::writeInfo().

bool KFileMetaInfo::contains const QString   key const
 

Returns:
whether an item for this key exists.

Definition at line 546 of file kfilemetainfo.cpp.

References KFileMetaInfoGroup::contains(), groups(), and KStdAccel::key().

bool KFileMetaInfo::containsGroup const QString   key const
 

Returns:
whether a group with this name exists.

Definition at line 557 of file kfilemetainfo.cpp.

References groups(), and KStdAccel::key().

bool KFileMetaInfo::isValid  
 

Returns:
true if the item is valid, i.e. if actually represents the info about a file, false if the object is uninitialized

Definition at line 479 of file kfilemetainfo.cpp.

Referenced by KFileItem::getToolTipText(), and KFileItem::metaInfo().

bool KFileMetaInfo::isEmpty  
 

Returns:
false if the object contains data, true if it's empty. You'll get an empty object if no plugin for the file could be found.

Definition at line 485 of file kfilemetainfo.cpp.

Referenced by KFileItem::getToolTipText().

KFilePlugin *const KFileMetaInfo::plugin   [protected]
 

Returns:
a pointer to the plugin that belogs to this object's mimetype. It will be auto-loaded if it's currently not loaded

Definition at line 535 of file kfilemetainfo.cpp.

Referenced by applyChanges(), and KFileMetaInfo().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:35 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001