• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • services
kmimetype.h
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 * Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
3 * David Faure <faure@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation;
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 **/
19
20#ifndef __kmimetype_h__
21#define __kmimetype_h__
22
23#include <QtCore/QStringList>
24#include <QtCore/QList>
25
26#include <kurl.h>
27#include <ksycocatype.h>
28#include <kservicetype.h>
29
30#include <sys/types.h>
31#include <sys/stat.h>
32
33class KMimeTypePrivate;
34
46class KDECORE_EXPORT KMimeType : public KServiceType // TODO KDE5: drop kservicetype inheritance, inherit kshared
47{
48 Q_DECLARE_PRIVATE( KMimeType )
49public:
50 typedef KSharedPtr<KMimeType> Ptr;
51 typedef QList<Ptr> List;
52
53 virtual ~KMimeType();
54
64 QString iconName( const KUrl &url = KUrl()) const;
65
76 static QString iconNameForUrl( const KUrl & url, mode_t mode = 0 );
77
87 static QString favIconForUrl( const KUrl& url );
88
96 QString comment( const KUrl& url = KUrl() ) const;
97
103 QStringList patterns() const;
104
105 enum FindByNameOption { DontResolveAlias, ResolveAliases = 1 };
106
121 static Ptr mimeType( const QString& name, FindByNameOption options = ResolveAliases );
122
162 static Ptr findByUrl( const KUrl& url, mode_t mode = 0,
163 bool is_local_file = false, bool fast_mode = false,
164 int *accuracy = 0 );
192 static Ptr findByPath( const QString& path, mode_t mode = 0,
193 bool fast_mode = false, int* accuracy = 0 );
194
205 static Ptr findByContent( const QByteArray &data, int *accuracy=0 );
206
222 static Ptr findByNameAndContent( const QString& name, const QByteArray& data,
223 mode_t mode = 0, int *accuracy=0 );
224
236 static Ptr findByContent( QIODevice* device, int* accuracy = 0 );
237
256 static Ptr findByNameAndContent( const QString& name, QIODevice* device,
257 mode_t mode = 0, int* accuracy = 0 );
258
272 static Ptr findByFileContent( const QString &fileName, int *accuracy=0 );
273
280 static bool isBinaryData( const QString &fileName );
281
288 static bool isBufferBinaryData( const QByteArray &data );
289
299 static List allMimeTypes();
300
308 static QString defaultMimeType();
309
316 static KMimeType::Ptr defaultMimeTypePtr();
317
319 bool isDefault() const;
320
331#ifndef KDE_NO_DEPRECATED
332 KDE_DEPRECATED QString parentMimeType() const;
333#endif
334
353 QStringList parentMimeTypes() const;
354
365 QStringList allParentMimeTypes() const;
366
373 bool is( const QString& mimeTypeName ) const;
374
380 QString userSpecifiedIconName() const;
381
393 QString mainExtension() const;
394
400 static QString extractKnownExtension( const QString &fileName );
401
406 static bool matchFileName( const QString &filename, const QString &pattern );
407
418 static int sharedMimeInfoVersion();
419
420protected:
421
422 friend class KMimeTypeRepository; // for KMimeType(QString,QString,QString)
423
429 KMimeType( QDataStream& str, int offset );
430
437 KMimeType( const QString& fullpath, const QString& name, const QString& comment );
438
444 KMimeType( KMimeTypePrivate &dd);
445
455 KMimeType( KMimeTypePrivate &dd, const QString& name, const QString& comment );
456
457private:
458 // Forbidden nowadays in KMimeType
459 int offset() const;
460 void save(QDataStream &s);
461
462 void loadInternal( QDataStream& _str);
463 static void buildDefaultType();
464 static void checkEssentialMimeTypes();
465 static KMimeType::Ptr findByUrlHelper( const KUrl& url, mode_t mode,
466 bool is_local_file, QIODevice* device, int* accuracy );
467};
468
469#endif
KMimeTypePrivate
Definition: kmimetype_p.h:25
KMimeTypeRepository
Definition: kmimetyperepository_p.h:37
KMimeType
Represent a mime type, like "text/plain", and the data that is associated with it.
Definition: kmimetype.h:47
KMimeType::FindByNameOption
FindByNameOption
Definition: kmimetype.h:105
KMimeType::DontResolveAlias
@ DontResolveAlias
Definition: kmimetype.h:105
KMimeType::Ptr
KSharedPtr< KMimeType > Ptr
Definition: kmimetype.h:50
KMimeType::List
QList< Ptr > List
Definition: kmimetype.h:51
KServiceType
A service type is, well, a type of service, where a service is an application or plugin.
Definition: kservicetype.h:44
KSharedPtr
Can be used to control the lifetime of an object that has derived QSharedData.
Definition: ksharedptr.h:64
KUrl
Represents and parses a URL.
Definition: kurl.h:112
QIODevice
QList
Definition: kaboutdata.h:33
QStringList
QString
kservicetype.h
ksycocatype.h
kurl.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • 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
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal