KMimeType Class Reference
Represent a mime type, like "text/plain", and the data that is associated with it. More...
#include <kmimetype.h>
Inheritance diagram for KMimeType:

Public Types | |
typedef KSharedPtr< KMimeType > | Ptr |
typedef QValueList< Ptr > | List |
Public Member Functions | |
KMimeType (const QString &_fullpath, const QString &_type, const QString &_icon, const QString &_comment, const QStringList &_patterns) | |
KMimeType (const QString &_fullpath) | |
KMimeType (KDesktopFile *config) | |
KMimeType (QDataStream &_str, int offset) | |
virtual QString | icon (const QString &, bool) const |
virtual QString | icon (const KURL &, bool) const |
virtual QPixmap | pixmap (KIcon::Group group, int force_size=0, int state=0, QString *path=0L) const |
virtual QPixmap | pixmap (const KURL &_url, KIcon::Group _group, int _force_size=0, int _state=0, QString *_path=0L) const |
QString | comment () const |
virtual QString | comment (const QString &, bool) const |
virtual QString | comment (const KURL &, bool) const |
const QStringList & | patterns () const |
virtual void | load (QDataStream &qs) |
virtual void | save (QDataStream &qs) |
virtual QVariant | property (const QString &_name) const |
virtual QStringList | propertyNames () const |
QString | parentMimeType () const |
bool | is (const QString &mimeTypeName) const |
Static Public Member Functions | |
QPixmap | pixmapForURL (const KURL &_url, mode_t _mode=0, KIcon::Group _group=KIcon::Desktop, int _force_size=0, int _state=0, QString *_path=0L) |
QString | iconForURL (const KURL &_url, mode_t _mode=0) |
QString | favIconForURL (const KURL &url) |
Ptr | mimeType (const QString &_name) |
Ptr | findByURL (const KURL &_url, mode_t _mode=0, bool _is_local_file=false, bool _fast_mode=false) |
Ptr | findByURL (const KURL &_url, mode_t _mode, bool _is_local_file, bool _fast_mode, bool *accurate) |
Ptr | findByPath (const QString &path, mode_t mode=0, bool fast_mode=false) |
Ptr | findByContent (const QByteArray &data, int *accuracy=0) |
Ptr | findByFileContent (const QString &fileName, int *accuracy=0) |
Format | findFormatByFileContent (const QString &fileName) |
List | allMimeTypes () |
const QString & | defaultMimeType () |
KMimeType::Ptr | defaultMimeTypePtr () |
KMimeType::Ptr | diagnoseFileName (const QString &file, QString &pattern) |
Protected Member Functions | |
void | loadInternal (QDataStream &) |
void | init (KDesktopFile *) |
int | patternsAccuracy () const |
virtual void | virtual_hook (int id, void *data) |
Static Protected Member Functions | |
void | errorMissingMimeType (const QString &_type) |
void | buildDefaultType () |
void | checkEssentialMimeTypes () |
Protected Attributes | |
QStringList | m_lstPatterns |
Static Protected Attributes | |
bool | s_bChecked = false |
Ptr | s_pDefaultType = 0L |
Detailed Description
Represent a mime type, like "text/plain", and the data that is associated with it.The starting point you need is often the static methods.
KMimeType inherits KServiceType because "text/plain" can be used to find services (apps and components) "which can open text/plain".
- See also:
- KServiceType
Definition at line 49 of file kmimetype.h.
Constructor & Destructor Documentation
|
Constructor. You may pass in arguments to create a mimetype with specific properties.
Definition at line 353 of file kmimetype.cpp. References KMimeType(). Referenced by KMimeType(). |
|
Construct a mimetype and take all information from a config file.
Definition at line 360 of file kmimetype.cpp. References endl(), KServiceType::isValid(), kdWarning(), and KMimeType(). |
|
Construct a mimetype and take all information from a desktop file.
Definition at line 369 of file kmimetype.cpp. References endl(), KServiceType::isValid(), kdWarning(), and KMimeType(). |
Member Function Documentation
|
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)
Reimplemented in KFolderType, and KDEDesktopMimeType. Definition at line 102 of file kmimetype.h. |
|
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)
Reimplemented in KFolderType, and KDEDesktopMimeType. Definition at line 112 of file kmimetype.h. |
|
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.
Reimplemented in KDEDesktopMimeType. Definition at line 446 of file kmimetype.cpp. References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), KServiceType::icon(), KGlobal::iconLoader(), QPixmap::isNull(), KIconLoader::loadIcon(), and pixmap(). Referenced by pixmap(), and pixmapForURL(). |
|
Find the pixmap for a given file of this mimetype. Convenience method that uses icon(), but also locates and load the pixmap.
Reimplemented in KDEDesktopMimeType. Definition at line 462 of file kmimetype.cpp. References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), KServiceType::icon(), KGlobal::iconLoader(), KURL::isLocalFile(), QPixmap::isNull(), KIconLoader::loadIcon(), and pixmap(). |
|
Convenience method to find the pixmap for a URL. Call this one when you don't know the mimetype.
Definition at line 478 of file kmimetype.cpp. References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), iconForURL(), KGlobal::iconLoader(), QPixmap::isNull(), KIconLoader::loadIcon(), pixmap(), and pixmapForURL(). Referenced by pixmapForURL(). |
|
The same functionality as pixmapForURL(), but this method returns the name of the icon to load. You'll have to use KIconLoader to load the pixmap for it. The advantage of this method is that you can store the result, and then use it later on for any kind of size.
Definition at line 496 of file kmimetype.cpp. References defaultMimeTypePtr(), favIconForURL(), findByURL(), iconForURL(), QString::isEmpty(), KURL::isLocalFile(), and KURL::protocol(). Referenced by iconForURL(), and pixmapForURL(). |
|
Return the "favicon" (see http://www.favicon.com) for the given Does NOT attempt to download the favicon, it only returns one that is already available. If unavailable, returns QString::null.
Definition at line 513 of file kmimetype.cpp. References DCOPRef::call(), KGlobal::config(), favIconForURL(), KURL::isLocalFile(), DCOPReply::isValid(), KURL::protocol(), KConfigBase::readBoolEntry(), and QString::startsWith(). Referenced by favIconForURL(), and iconForURL(). |
|
Returns the descriptive comment associated with the MIME type.
Reimplemented from KServiceType. Definition at line 204 of file kmimetype.h. Referenced by KDEDesktopMimeType::comment(), and KFolderType::comment(). |
|
Returns the descriptive comment associated with the MIME type. The arguments are unused, but provided so that KMimeType derived classes can use them.
Reimplemented in KFolderType, and KDEDesktopMimeType. Definition at line 213 of file kmimetype.h. |
|
Returns the descriptive comment associated with the MIME type. The arguments are unused, but provided so that KMimeType derived classes can use them.
Reimplemented in KFolderType, and KDEDesktopMimeType. Definition at line 222 of file kmimetype.h. |
|
Retrieve the list of patterns associated with the MIME Type.
Definition at line 229 of file kmimetype.h. |
|
Load the mimetype from a stream.
Reimplemented from KServiceType. Definition at line 406 of file kmimetype.cpp. References load(). Referenced by load(). |
|
Save the mimetype to a stream.
Reimplemented from KServiceType. Definition at line 418 of file kmimetype.cpp. References save(). Referenced by save(). |
|
Returns the property with the given
Reimplemented from KServiceType. Definition at line 426 of file kmimetype.cpp. References property(). Referenced by parentMimeType(), and property(). |
|
Retrieves a list of all properties associated with this KMimeType.
Reimplemented from KServiceType. Definition at line 434 of file kmimetype.cpp. References KServiceType::propertyNames(). |
|
Retrieve a pointer to the mime type 0L is never returned. Very important: Don't store the result in a KMimeType* !
Definition at line 140 of file kmimetype.cpp. References buildDefaultType(), KSycocaEntry::isType(), and mimeType(). Referenced by checkEssentialMimeTypes(), findByContent(), findByFileContent(), findByURL(), is(), and mimeType(). |
|
Finds a KMimeType with the given This function looks at mode_t first. If that does not help it looks at the extension. This is fine 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 the file will be examined if the URL a local file or "application/octet-stream" is returned otherwise.
Definition at line 164 of file kmimetype.cpp. References checkEssentialMimeTypes(), defaultMimeType(), defaultMimeTypePtr(), QString::endsWith(), KURL::fileName(), findByURL(), KMimeMagic::findFileType(), KURL::hasSubURL(), QString::isEmpty(), KURL::isLocalFile(), QString::isNull(), KMimeMagicResult::isValid(), KMimeMagicResult::mimeType(), mimeType(), KURL::path(), KURL::protocol(), and KMimeMagic::self(). Referenced by findByPath(), findByURL(), and iconForURL(). |
|
Finds a KMimeType with the given This function looks at mode_t first. If that does not help it looks at the extension. This is fine 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 the file will be examined if the URL a local file or "application/octet-stream" is returned otherwise. Equivalent to
Definition at line 296 of file kmimetype.cpp. References findByPath(), findByURL(), and KURL::setPath(). Referenced by findByPath(). |
|
Tries to find out the MIME type of a data chunk by looking for certain magic numbers and characteristic strings in it.
Definition at line 303 of file kmimetype.cpp. References KMimeMagicResult::accuracy(), defaultMimeType(), KMimeMagic::findBufferType(), findByContent(), KMimeMagicResult::isValid(), mimeType(), KMimeMagicResult::mimeType(), and KMimeMagic::self(). Referenced by findByContent(). |
|
Tries to find out the MIME type of a file by looking for certain magic numbers and characteristic strings in it. This function is similar to the previous one. Note that the file name is not used for determining the file type, it is just used for loading the file's contents.
Definition at line 313 of file kmimetype.cpp. References KMimeMagicResult::accuracy(), defaultMimeType(), findByFileContent(), KMimeMagic::findFileType(), KMimeMagicResult::isValid(), mimeType(), KMimeMagicResult::mimeType(), and KMimeMagic::self(). Referenced by findByFileContent(). |
|
Get all the mimetypes. Useful for showing the list of available mimetypes. More memory consuming than the ones above, don't use unless really necessary.
Definition at line 159 of file kmimetype.cpp. Referenced by KApplicationPropsPlugin::KApplicationPropsPlugin(). |
|
Returns the name of the default mimetype. Always application/octet-stream, but this method exists for performance purposes.
Definition at line 1062 of file kmimetype.cpp. Referenced by buildDefaultType(), findByContent(), findByFileContent(), findByURL(), and KFilePropsPlugin::KFilePropsPlugin(). |
|
Returns the default mimetype. Always application/octet-stream. This can be used to check the result of mimeType(name).
Definition at line 88 of file kmimetype.cpp. References buildDefaultType(). Referenced by findByURL(), KService::hasServiceType(), iconForURL(), KService::initialPreferenceForMimeType(), and KDesktopPropsPlugin::KDesktopPropsPlugin(). |
|
If this mimetype inherits from ("is also") another mimetype, return the name of the parent. For instance a text/x-log is a special kind of text/plain, so the definition of text/x-log can say "X-KDE-IsAlso=text/plain". Or an smb-workgroup is a special kind of inode/directory, etc. This mechanism can also be used to rename mimetypes and preserve compat. Note that this notion doesn't map to the servicetype inheritance mechanism, since an application that handles the specific type doesn't necessarily handle the base type. The opposite is true though.
Definition at line 538 of file kmimetype.cpp. References property(), and QVariant::toString(). Referenced by is(). |
|
Do not use name()=="somename" anymore, to check for a given mimetype. For mimetype inheritance to work, use is("somename") instead. Warning, do not use inherits(), that's the servicetype inheritance concept!
Definition at line 544 of file kmimetype.cpp. References is(), QString::isEmpty(), mimeType(), KServiceType::name(), and parentMimeType(). Referenced by is(). |
|
Signal a missing mime type.
Definition at line 133 of file kmimetype.cpp. References errorMissingMimeType(). Referenced by buildDefaultType(), checkEssentialMimeTypes(), and errorMissingMimeType(). |
|
This function makes sure that the default mime type exists.
Definition at line 67 of file kmimetype.cpp. References defaultMimeType(), errorMissingMimeType(), KSycocaEntry::isType(), and KStandardDirs::resourceDirs(). Referenced by checkEssentialMimeTypes(), defaultMimeTypePtr(), and mimeType(). |
|
This function makes sure that vital mime types are installed.
Definition at line 96 of file kmimetype.cpp. References buildDefaultType(), errorMissingMimeType(), mimeType(), and s_bChecked. Referenced by findByURL(). |
Member Data Documentation
|
true if check for vital mime types has been done.
Definition at line 65 of file kmimetype.cpp. Referenced by checkEssentialMimeTypes(). |
The documentation for this class was generated from the following files: