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

KDECore

  • kdecore
  • services
kmimetyperepository_p.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  * Copyright (C) 2006-2007 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 as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef KMIMETYPEREPOSITORY_H
22 #define KMIMETYPEREPOSITORY_H
23 
24 #include "kmimemagicrule_p.h"
25 #include "kmimeglobsfileparser_p.h"
26 #include "kmimetype.h"
27 #include <QReadWriteLock>
28 
36 class KDECORE_EXPORT KMimeTypeRepository
37 {
38 public:
42  static KMimeTypeRepository * self();
43 
47  KMimeType::Ptr findMimeTypeByName(const QString &_name, KMimeType::FindByNameOption options = KMimeType::DontResolveAlias);
48 
52  QString resolveAlias(const QString& mime);
53 
57  QString canonicalName(const QString& mime);
58 
62  QStringList parents(const QString& mime);
63 
64  enum GlobMatchingFlag {
65  NoFlag = 0,
66  CaseSensitive = 0x1
67  };
68 
73  QStringList patternsForMimetype(const QString& mimeType);
74 
78  void checkEssentialMimeTypes();
79 
80  KMimeType::Ptr defaultMimeTypePtr();
81 
85  bool useFavIcons();
86 
87  int sharedMimeInfoVersion();
88 
92  static bool matchFileName( const QString &filename, const QString &pattern );
93 
94 private: // only for KMimeType and unittests
95  friend class KMimeType;
96  friend class KMimeFileParserTest;
97  friend class KMimeTypeTest;
98 
106  QStringList findFromFileName(const QString &filename, QString *matchingExtension = 0);
107 
116  KMimeType::Ptr findFromContent(QIODevice* device, int* accuracy, QByteArray& beginning);
117 
122  bool checkMimeTypes();
123 
124 private:
125  KMimeTypeRepository();
126  ~KMimeTypeRepository();
127 
128  typedef QHash<QString, QString> AliasesMap;
129  const AliasesMap& aliases();
130 
134  QList<KMimeMagicRule> parseMagicFile(QIODevice* file, const QString& fileName) const;
135 
136  // Read magic files
137  void parseMagic();
138 
139  void parseGlobs();
140 
150  void findFromOtherPatternList(QStringList& matchingMimeTypes,
151  const QString &filename,
152  QString& foundExt,
153  bool highWeight);
154 
155  mutable AliasesMap m_aliases; // alias -> canonicalName
156 
157  typedef QHash<QString, QStringList> ParentsMap;
158  ParentsMap m_parents;
159 
160  typedef QHash<QString, QStringList> PatternsMap;
161  PatternsMap m_patterns;
162 
163  bool m_parentsMapLoaded;
164  bool m_magicFilesParsed;
165  mutable bool m_aliasFilesParsed;
166  bool m_globsFilesParsed;
167  bool m_patternsMapCalculated;
168  bool m_mimeTypesChecked;
169  bool m_useFavIcons;
170  bool m_useFavIconsChecked;
171  int m_sharedMimeInfoVersion;
172  QList<KMimeMagicRule> m_magicRules;
173  KMimeGlobsFileParser::AllGlobs m_globs;
174  KMimeType::Ptr m_defaultMimeType;
175  QReadWriteLock m_mutex;
176 };
177 
178 #endif /* KMIMETYPEREPOSITORY_H */
179 
KSharedPtr< KMimeType >
KMimeType::DontResolveAlias
Definition: kmimetype.h:105
KMimeType::FindByNameOption
FindByNameOption
Definition: kmimetype.h:105
kmimetype.h
kmimemagicrule_p.h
KMimeType
Represent a mime type, like "text/plain", and the data that is associated with it.
Definition: kmimetype.h:46
QString
QHash< QString, QString >
QStringList
KMimeTypeRepository::GlobMatchingFlag
GlobMatchingFlag
Definition: kmimetyperepository_p.h:64
kmimeglobsfileparser_p.h
KMimeTypeRepository
Definition: kmimetyperepository_p.h:36
QIODevice
KMimeGlobsFileParser::AllGlobs
Result of the globs parsing, as data structures ready for efficient mimetype matching.
Definition: kmimeglobsfileparser_p.h:85
QList< KMimeMagicRule >
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jan 18 2020 18:58:50 by doxygen 1.8.15 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