• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

kmimetype.h

Go to the documentation of this file.
00001 /*  This file is part of the KDE libraries
00002  *  Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
00003  *                     David Faure   <faure@kde.org>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation;
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #ifndef __kmimetype_h__
00021 #define __kmimetype_h__
00022 
00023 #include <QtCore/QStringList>
00024 #include <QtCore/QList>
00025 
00026 #include <kurl.h>
00027 #include <ksycocatype.h>
00028 #include <kservicetype.h>
00029 
00030 #include <sys/types.h>
00031 #include <sys/stat.h>
00032 
00033 class KMimeTypePrivate;
00034 
00046 class KDECORE_EXPORT KMimeType : public KServiceType
00047 {
00048     Q_DECLARE_PRIVATE( KMimeType )
00049 public:
00050     typedef KSharedPtr<KMimeType> Ptr;
00051     typedef QList<Ptr> List;
00052 
00053     virtual ~KMimeType();
00054 
00064     QString iconName( const KUrl &url = KUrl()) const;
00065 
00076     static QString iconNameForUrl( const KUrl & url, mode_t mode = 0 );
00077 
00087     static QString favIconForUrl( const KUrl& url );
00088 
00096     QString comment( const KUrl& url = KUrl() ) const;
00097 
00103     QStringList patterns() const;
00104 
00105     enum FindByNameOption { DontResolveAlias, ResolveAliases = 1 };
00106 
00121     static Ptr mimeType( const QString& name, FindByNameOption options = DontResolveAlias );
00122 
00157     static Ptr findByUrl( const KUrl& url, mode_t mode = 0,
00158                           bool is_local_file = false, bool fast_mode = false,
00159                           int *accuracy = 0 );
00188     static Ptr findByPath( const QString& path, mode_t mode = 0,
00189                            bool fast_mode = false, int* accuracy = 0 );
00190 
00201     static Ptr findByContent( const QByteArray &data, int *accuracy=0 );
00202 
00218     static Ptr findByNameAndContent( const QString& name, const QByteArray& data,
00219                                      mode_t mode = 0, int *accuracy=0 );
00220 
00234     static Ptr findByFileContent( const QString &fileName, int *accuracy=0 );
00235 
00242     static bool isBinaryData( const QString &fileName );
00243 
00250     static bool isBufferBinaryData( const QByteArray &data );
00251 
00261     static List allMimeTypes();
00262 
00270     static QString defaultMimeType();
00271 
00278     static KMimeType::Ptr defaultMimeTypePtr();
00279 
00281     bool isDefault() const;
00282 
00293     KDE_DEPRECATED QString parentMimeType() const;
00294 
00313     QStringList parentMimeTypes() const;
00314 
00325     QStringList allParentMimeTypes() const;
00326 
00333     bool is( const QString& mimeTypeName ) const;
00334 
00340     static QString extractKnownExtension( const QString &fileName );
00341 
00342 protected:
00343 
00344     friend class KMimeTypeFactory; // for KMimeType(QDataStream&,int)
00345     friend class KBuildMimeTypeFactory; // for KMimeType(QDataStream&,int)
00346     friend class KMimeFileParser; // for addPattern and addMagicRule
00347 
00353     KMimeType( QDataStream& str, int offset );
00354 
00361     KMimeType( const QString& fullpath, const QString& name, const QString& comment );
00362 
00368     KMimeType( KMimeTypePrivate &dd);
00369 
00379     KMimeType( KMimeTypePrivate &dd, const QString& name, const QString& comment );
00380 
00382     void setPatterns(const QStringList& patterns);
00384     void setParentMimeType(const QString& parent);
00386     void internalClearData();
00387 
00388 private:
00389 
00390     void loadInternal( QDataStream& _str);
00391     static void buildDefaultType();
00392     static void checkEssentialMimeTypes();
00393     static KMimeType::Ptr findByUrlHelper( const KUrl& url, mode_t mode,
00394                                            bool is_local_file, QIODevice* device, int* accuracy );
00395 };
00396 
00397 #endif

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal