• Skip to content
  • Skip to link menu
KDE 4.1 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 
00120     static Ptr mimeType( const QString& name, FindByNameOption options = DontResolveAlias );
00121 
00156     static Ptr findByUrl( const KUrl& url, mode_t mode = 0,
00157                           bool is_local_file = false, bool fast_mode = false,
00158                           int *accuracy = 0 );
00187     static Ptr findByPath( const QString& path, mode_t mode = 0,
00188                            bool fast_mode = false, int* accuracy = 0 );
00189 
00200     static Ptr findByContent( const QByteArray &data, int *accuracy=0 );
00201 
00217     static Ptr findByNameAndContent( const QString& name, const QByteArray& data,
00218                                      mode_t mode = 0, int *accuracy=0 );
00219 
00233     static Ptr findByFileContent( const QString &fileName, int *accuracy=0 );
00234 
00241     static bool isBinaryData( const QString &fileName );
00242 
00249     static bool isBufferBinaryData( const QByteArray &data );
00250 
00260     static List allMimeTypes();
00261 
00269     static QString defaultMimeType();
00270 
00277     static KMimeType::Ptr defaultMimeTypePtr();
00278 
00280     bool isDefault() const;
00281 
00292     KDE_DEPRECATED QString parentMimeType() const;
00293 
00312     QStringList parentMimeTypes() const;
00313 
00324     QStringList allParentMimeTypes() const;
00325 
00332     bool is( const QString& mimeTypeName ) const;
00333 
00339     static QString extractKnownExtension( const QString &fileName );
00340 
00341 protected:
00342 
00343     friend class KMimeTypeFactory; // for KMimeType(QDataStream&,int)
00344     friend class KBuildMimeTypeFactory; // for KMimeType(QDataStream&,int)
00345     friend class KMimeFileParser; // for addPattern and addMagicRule
00346 
00352     KMimeType( QDataStream& str, int offset );
00353 
00360     KMimeType( const QString& fullpath, const QString& name, const QString& comment );
00361 
00367     KMimeType( KMimeTypePrivate &dd);
00368 
00375     KMimeType( KMimeTypePrivate &dd, const QString& name, const QString& comment );
00376 
00378     void setPatterns(const QStringList& patterns);
00380     void setParentMimeType(const QString& parent);
00382     void internalClearData();
00383 
00384 private:
00385 
00386     void loadInternal( QDataStream& _str);
00387     static void buildDefaultType();
00388     static void checkEssentialMimeTypes();
00389     static KMimeType::Ptr findByUrlHelper( const KUrl& url, mode_t mode,
00390                                            bool is_local_file, QIODevice* device, int* accuracy );
00391 };
00392 
00393 #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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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