KMimeType Class Reference
Represent a mime type, like "text/plain". More...
#include <kmimetype.h>
Inheritance diagram for KMimeType:

Public Types | |
typedef KSharedPtr< KMimeType > | Ptr |
typedef QValueList< Ptr > | List |
Public Methods | |
KMimeType (const QString &_fullpath, const QString &_type, const QString &_icon, const QString &_comment, const QStringList &_patterns) | |
Constructor. | |
KMimeType (const QString &_fullpath) | |
Construct a mimetype and take all information from a config file. | |
KMimeType (KDesktopFile *config) | |
Construct a mimetype and take all information from a desktop file. | |
virtual QString | icon (const QString &, bool) const |
Return the filename of the icon associated with the mimetype. | |
virtual QString | icon (const KURL &, bool) const |
This function differs from the above only in that a KURL may be provided instead of a QString for convenience. | |
virtual QPixmap | pixmap (KIcon::Group _group, int _force_size=0, int _state=0, QString *_path=0L) const |
Use this function only if you don't have a special URL for which you search a pixmap. | |
virtual QPixmap | pixmap (const KURL &_url, KIcon::Group _group, int _force_size=0, int _state=0, QString *_path=0L) const |
Find the pixmap for a given file of this mimetype. | |
QString | comment () const |
virtual QString | comment (const QString &, bool) const |
The arguments are unused, but provided so that KMimeType derived classes can use them. | |
virtual QString | comment (const KURL &, bool) const |
This function differs from the above only in that a KURL may be provided instead of a QString for convenience. | |
const QStringList & | patterns () const |
Retrieve the list of patterns associated with the MIME Type. | |
virtual void | load (QDataStream &) |
Load the mimetype from a stream. | |
virtual void | save (QDataStream &) |
Save the mimetype to a stream. | |
virtual QVariant | property (const QString &_name) const |
virtual QStringList | propertyNames () const |
Static Public Methods | |
QPixmap | pixmapForURL (const KURL &_url, mode_t _mode=0, KIcon::Group _group=KIcon::Desktop, int _force_size=0, int _state=0, QString *_path=0L) |
Convenience method to find the pixmap for a URL. | |
QString | iconForURL (const KURL &_url, mode_t _mode=0) |
The same functionality as pixmapForURL, but this method returns the name of the icon to load. | |
QString | favIconForURL (const KURL &url) |
Ptr | mimeType (const QString &_name) |
Retrieve a pointer to the mime type _name or a pointer to the default mime type "application/octet-stream". | |
Ptr | findByURL (const KURL &_url, mode_t _mode=0, bool _is_local_file=false, bool _fast_mode=false) |
This function looks at mode_t first. | |
Ptr | findByPath (const QString &path, mode_t mode=0, bool fast_mode=false) |
Same as findByURL but for local files only - convenience method. | |
Ptr | findByContent (const QByteArray &data, int *accuracy=0) |
Tries to find out the MIME type of a data chunk by looking for certain magic numbers and characteristic strings in it. | |
Ptr | findByFileContent (const QString &fileName, int *accuracy=0) |
Tries to find out the MIME type of a file by looking for certain magic numbers and characteristic strings in it. | |
List | allMimeTypes () |
Get all the mimetypes. | |
const QString & | defaultMimeType () |
Protected Methods | |
void | init (KDesktopFile *) |
virtual void | virtual_hook (int id, void *data) |
Static Protected Methods | |
void | errorMissingMimeType (const QString &_type) |
Signal a missing mime type. | |
void | buildDefaultType () |
This function makes sure that the default mime type exists. | |
void | checkEssentialMimeTypes () |
This function makes sure that vital mime types are installed. | |
Static Protected Attributes | |
bool | s_bChecked = false |
Returns true if check for vital mime types has been done. |
Detailed Description
Represent a mime type, like "text/plain".The starting point you need is often the static methods. See also KServiceType.
Definition at line 43 of file kmimetype.h.
Constructor & Destructor Documentation
|
Constructor. You may pass in arguments to create a mimetype with specific properties. Definition at line 280 of file kmimetype.cpp. Referenced by buildDefaultType(). |
|
Construct a mimetype and take all information from a config file.
Definition at line 287 of file kmimetype.cpp. References KSycocaEntry::isValid(). |
|
Construct a mimetype and take all information from a desktop file.
Definition at line 296 of file kmimetype.cpp. References KSycocaEntry::isValid(). |
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 87 of file kmimetype.h. |
|
This function differs from the above only in that a KURL may be provided instead of a QString for convenience.
Reimplemented in KFolderType, and KDEDesktopMimeType. Definition at line 93 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 361 of file kmimetype.cpp. References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), KIcon::Group, KServiceType::icon(), KGlobal::iconLoader(), QPixmap::isNull(), KIconLoader::loadIcon(), and pixmap(). Referenced by KDEDesktopMimeType::pixmap(), 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 377 of file kmimetype.cpp. References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), KIcon::Group, 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 393 of file kmimetype.cpp. References KIconLoader::addExtraDesktopThemes(), KIconLoader::extraDesktopThemesAdded(), KIcon::Group, iconForURL(), KGlobal::iconLoader(), QPixmap::isNull(), KIconLoader::loadIcon(), and pixmap(). Referenced by KURLComboBox::getPixmap(), KFileDialog::init(), KURLPixmapProvider::pixmapFor(), KIO::RenameDlg::RenameDlg(), and KURLBarItem::setIcon(). |
|
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 411 of file kmimetype.cpp. References defaultMimeType(), favIconForURL(), findByURL(), KProtocolInfo::icon(), QString::isEmpty(), KURL::isLocalFile(), KURL::protocol(), and KGlobal::staticQString(). Referenced by KRecentDocument::add(), KBookmarkGroup::addBookmark(), KURIFilterData::iconName(), KFilePropsPlugin::KFilePropsPlugin(), KURLBarItemDialog::KURLBarItemDialog(), and pixmapForURL(). |
|
Definition at line 428 of file kmimetype.cpp. References KGlobal::config(), KURL::isLocalFile(), KURL::protocol(), and QString::startsWith(). Referenced by iconForURL(). |
|
Reimplemented from KServiceType. Definition at line 164 of file kmimetype.h. Referenced by KDEDesktopMimeType::comment(), and KFolderType::comment(). |
|
The arguments are unused, but provided so that KMimeType derived classes can use them.
Reimplemented in KFolderType, and KDEDesktopMimeType. Definition at line 172 of file kmimetype.h. |
|
This function differs from the above only in that a KURL may be provided instead of a QString for convenience.
Reimplemented in KFolderType, and KDEDesktopMimeType. Definition at line 178 of file kmimetype.h. |
|
Retrieve the list of patterns associated with the MIME Type.
Definition at line 183 of file kmimetype.h. |
|
Load the mimetype from a stream.
Reimplemented from KServiceType. Definition at line 321 of file kmimetype.cpp. References KServiceType::load(). |
|
Save the mimetype to a stream.
Reimplemented from KServiceType. Definition at line 333 of file kmimetype.cpp. References KServiceType::save(). |
|
Retrieve a pointer to the mime type 0L is never returned. Very important: Don't store the result in a KMimeType* !
Definition at line 131 of file kmimetype.cpp. References buildDefaultType(). Referenced by KFileTreeView::addBranch(), checkEssentialMimeTypes(), KFileDialog::currentFilterMimeType(), findByContent(), findByFileContent(), findByURL(), KFileItem::KFileItem(), and KFileItem::pixmap(). |
|
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 KMimeMagic is used if the URL a local file or "application/octet-stream" is returned otherwise.
Definition at line 152 of file kmimetype.cpp. References checkEssentialMimeTypes(), defaultMimeType(), KProtocolInfo::defaultMimetype(), KProtocolInfo::determineMimetypeFromExtension(), QFile::encodeName(), QString::endsWith(), KURL::fileName(), KMimeMagic::findFileType(), QString::fromLatin1(), QString::isEmpty(), KURL::isLocalFile(), QString::isNull(), KMimeMagicResult::isValid(), KMimeMagicResult::mimeType(), mimeType(), KURL::path(), KURL::protocol(), KMimeMagic::self(), and KGlobal::staticQString(). Referenced by KFileItem::determineMimeType(), findByPath(), iconForURL(), KFileItem::init(), KFileMetaInfo::KFileMetaInfo(), KFilePropsPlugin::KFilePropsPlugin(), KImageIO::mimeType(), KFileItem::pixmap(), and KOpenWithDlg::setServiceType(). |
|
Same as findByURL but for local files only - convenience method. Equivalent to KURL u; u.setPath(path); return findByURL( u, mode, true, fast_mode ); Definition at line 253 of file kmimetype.cpp. References findByURL(), and KURL::setPath(). Referenced by KFilterBase::findFilterByFileName(), and KTar::KTar(). |
|
Tries to find out the MIME type of a data chunk by looking for certain magic numbers and characteristic strings in it. Returns application/octet-stream of the type can not be found this way. If accuracy is not a null pointer, *accuracy is set to the accuracy of the match (which is in the range 0..100). Definition at line 260 of file kmimetype.cpp. References KMimeMagicResult::accuracy(), defaultMimeType(), KMimeMagic::findBufferType(), KMimeMagicResult::isValid(), mimeType(), KMimeMagicResult::mimeType(), and KMimeMagic::self(). |
|
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. If accuracy is not a null pointer, *accuracy is set to the accuracy of the match (which is in the range 0..100). Definition at line 270 of file kmimetype.cpp. References KMimeMagicResult::accuracy(), defaultMimeType(), KMimeMagic::findFileType(), KMimeMagicResult::isValid(), mimeType(), KMimeMagicResult::mimeType(), and KMimeMagic::self(). Referenced by KFilePropsPlugin::KFilePropsPlugin(), and KTar::KTar(). |
|
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 147 of file kmimetype.cpp. Referenced by KApplicationPropsPlugin::KApplicationPropsPlugin(). |
|
Definition at line 948 of file kmimetype.cpp. References KGlobal::staticQString(). Referenced by buildDefaultType(), findByContent(), findByFileContent(), findByURL(), iconForURL(), KFileItem::init(), KFilePropsPlugin::KFilePropsPlugin(), and KIO::RenameDlg::RenameDlg(). |
|
Signal a missing mime type.
Definition at line 124 of file kmimetype.cpp. References KMessageBox::sorry(). Referenced by buildDefaultType(), and checkEssentialMimeTypes(). |
|
This function makes sure that the default mime type exists.
Definition at line 65 of file kmimetype.cpp. References defaultMimeType(), errorMissingMimeType(), KMimeType(), and KStandardDirs::resourceDirs(). Referenced by checkEssentialMimeTypes(), and mimeType(). |
|
This function makes sure that vital mime types are installed.
Definition at line 87 of file kmimetype.cpp. References buildDefaultType(), KMessageBox::error(), errorMissingMimeType(), mimeType(), and s_bChecked. Referenced by findByURL(). |
Member Data Documentation
|
Returns
Definition at line 63 of file kmimetype.cpp. Referenced by checkEssentialMimeTypes(). |
The documentation for this class was generated from the following files: