class KMimeType

Represents a mime type, like "text/plain". More...

Definition#include <kmimetype.h>
InheritsKServiceType
Inherited byKDEDesktopMimeType, KExecMimeType, KFolderType
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Public Static Methods

Protected Static Methods

Protected Members


Detailed Description

Represents a mime type, like "text/plain". The starting point you need is often the static methods. See also KServiceType.

 KMimeType ( const QString & _fullpath, const QString& _type, const QString& _icon, const QString& _comment, const QStringList& _patterns )

Constructor. You may pass in arguments to create a mimetype with specific properties

 KMimeType ( const QString & _fullpath )

Construct a mimetype and take all informations from a config file.

 KMimeType ( KDesktopFile *config )

Construct a mimetype and take all informations from a desktop file.

 KMimeType ( QDataStream& _str, int offset )

The stream must already be positionned at the correct offset

QString  icon ( const QString& , bool )

[const virtual]

Return the filename of the icon associated with the mimetype. The arguments are unused, but provided so that KMimeType derived classes can use them (e.g. KFolderType uses the URL to return one out of 2 icons)

Returns: the path to the icon associated with this MIME type.

Reimplemented from KServiceType

QString  icon ( const KURL& , bool )

[const virtual]

This function differs from the above only in that a KURL may be provided instead of a QString for convenience.

Reimplemented from KServiceType

QPixmap  pixmap ( KIconLoader::Size _size, QString * _path = 0L )

[const virtual]

Use this function only if you don't have a special URL for which you search a pixmap. This function is useful to find out, which icon is usually chosen for a certain mime type. Since no URL is passed, it is impossible to obey icon hints in desktop entries for example.

Parameters:
_sizeSize requested for the pixmap, see KIconLoader
_pathOutput parameter to get the full path. Seldom needed.

QPixmap  pixmap ( const KURL& _url, KIconLoader::Size _size, QString * _path = 0L )

[const virtual]

Find the pixmap for a given file of this mimetype Convenience method that uses icon(), but also locates and load the pixmap

Parameters:
_urlURL for the file
_sizeSize requested for the pixmap, see KIconLoader
_pathOutput parameter to get the full path. Seldom needed.

QPixmap  pixmapForURL ( const KURL & _url, mode_t _mode = 0, KIconLoader::Size _size = KIconLoader::Small, QString * _path = 0L )

[static]

Convenience method to find the pixmap for a URL Call this one when you don't know the mimetype.

QString  comment ( const QString&, bool )

[const virtual]

The arguments are unused, but provided so that KMimeType derived classes can use them.

Returns: the descriptive comment associated with the MIME type, if any.

Reimplemented from KServiceType

QString  comment ( const KURL&, bool )

[const virtual]

This function differs from the above only in that a KURL may be provided instead of a QString for convenience.

Reimplemented from KServiceType

QString  mimeType ()

[const virtual]

Use KServiceType::name instead.

const QStringList&  patterns ()

[const virtual]

Returns: the list of patterns associated to the MIME Type

void  load ( QDataStream&, bool _parentLoaded = false )

[virtual]

Load the mimetype from a stream.

Parameters:
_parentLoadedinternal (set by the constructor)

Reimplemented from KServiceType

void  save ( QDataStream& )

[virtual]

Save the mimetype to a stream

Reimplemented from KServiceType

Ptr  mimeType ( const QString& _name )

[static]

VERY IMPORTANT : don't store the result in a KMimeType * !

Returns: a pointer to the mime type '_name' or a pointer to the default mime type "application/octet-stream". 0L is NEVER returned.

Ptr  findByURL ( const KURL& _url, mode_t _mode = 0, bool _is_local_file = false, bool _fast_mode = false )

[static]

This function looks at mode_t first. If that does not help it looks at the extension. This is ok for FTP, FILE, TAR and friends, but is not for HTTP ( cgi scripts! ). You should use KRun instead, but this function returns immediately while KRun is async. If no extension matches, then KMimeMagic is used if the URL a local file or "application/octet-stream" is returned otherwise.

Parameters:
_urlis the right most URL with a filesystem protocol. It is up to you to find out about that if you have a nested URL. For example "http://localhost/mist.gz#gzip:/decompress" would have to pass the "http://..." URL part, while "file:/tmp/x.tar#tar:/src/test.gz#gzip:/decompress" would have to pass the "tar:/..." part of the URL, since gzip is a filter protocol and not a filesystem protocol.
_fast_modeIf set to true no disk access is allowed to find out the mimetype. The result may be suboptimal, but it is * FAST.

Returns: a pointer to the matching mimetype. 0L is NEVER returned. VERY IMPORTANT : don't store the result in a KMimeType * !

List  allMimeTypes ()

[static]

Get all the mimetypes. Useful for showing the list of available mimetypes. Very memory consuming, don't use unless really necessary.

void  errorMissingMimeType ( const QString& _type )

[protected static]

Signal a missing mime type

void  buildDefaultType ()

[protected static]

This function makes sure that the default mime type exists

void  checkEssentialMimeTypes ()

[protected static]

This function makes sure that vital mime types are installed.

static bool s_bChecked

[protected]

True if check for vital mime types has been done


Generated by: dfaure@faure on Sun Mar 26 14:24:43 2000, using kdoc 2.0a35.