• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • 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 // TODO KDE5: drop kservicetype inheritance, inherit kshared
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 = ResolveAliases );
00122 
00162     static Ptr findByUrl( const KUrl& url, mode_t mode = 0,
00163                           bool is_local_file = false, bool fast_mode = false,
00164                           int *accuracy = 0 );
00192     static Ptr findByPath( const QString& path, mode_t mode = 0,
00193                            bool fast_mode = false, int* accuracy = 0 );
00194 
00205     static Ptr findByContent( const QByteArray &data, int *accuracy=0 );
00206 
00222     static Ptr findByNameAndContent( const QString& name, const QByteArray& data,
00223                                      mode_t mode = 0, int *accuracy=0 );
00224 
00236     static Ptr findByContent( QIODevice* device, int* accuracy = 0 );
00237 
00256     static Ptr findByNameAndContent( const QString& name, QIODevice* device,
00257                                      mode_t mode = 0, int* accuracy = 0 );
00258 
00272     static Ptr findByFileContent( const QString &fileName, int *accuracy=0 );
00273 
00280     static bool isBinaryData( const QString &fileName );
00281 
00288     static bool isBufferBinaryData( const QByteArray &data );
00289 
00299     static List allMimeTypes();
00300 
00308     static QString defaultMimeType();
00309 
00316     static KMimeType::Ptr defaultMimeTypePtr();
00317 
00319     bool isDefault() const;
00320 
00331 #ifndef KDE_NO_DEPRECATED
00332     KDE_DEPRECATED QString parentMimeType() const;
00333 #endif
00334 
00353     QStringList parentMimeTypes() const;
00354 
00365     QStringList allParentMimeTypes() const;
00366 
00373     bool is( const QString& mimeTypeName ) const;
00374 
00380     QString userSpecifiedIconName() const;
00381 
00393     QString mainExtension() const;
00394 
00400     static QString extractKnownExtension( const QString &fileName );
00401 
00406     static bool matchFileName( const QString &filename, const QString &pattern );
00407 
00418     static int sharedMimeInfoVersion();
00419 
00420 protected:
00421 
00422     friend class KMimeTypeRepository; // for KMimeType(QString,QString,QString)
00423 
00429     KMimeType( QDataStream& str, int offset );
00430 
00437     KMimeType( const QString& fullpath, const QString& name, const QString& comment );
00438 
00444     KMimeType( KMimeTypePrivate &dd);
00445 
00455     KMimeType( KMimeTypePrivate &dd, const QString& name, const QString& comment );
00456 
00457 private:
00458     // Forbidden nowadays in KMimeType
00459     int offset() const;
00460     void save(QDataStream &s);
00461 
00462     void loadInternal( QDataStream& _str);
00463     static void buildDefaultType();
00464     static void checkEssentialMimeTypes();
00465     static KMimeType::Ptr findByUrlHelper( const KUrl& url, mode_t mode,
00466                                            bool is_local_file, QIODevice* device, int* accuracy );
00467 };
00468 
00469 #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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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