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

KIO

  • sources
  • kde-4.14
  • kdelibs
  • kio
  • kio
kimageio.cpp
Go to the documentation of this file.
1 
8 #include "kimageio.h"
9 
10 #include "kmimetype.h"
11 #include <kservicetypetrader.h>
12 #include <klocale.h>
13 #include <kdebug.h>
14 
15 QString
16 KImageIO::pattern(Mode mode)
17 {
18  QStringList patterns;
19  QString allPatterns;
20  QString separator("|");
21 
22  const KService::List services = KServiceTypeTrader::self()->query("QImageIOPlugins");
23  foreach(const KService::Ptr &service, services)
24  {
25  if ( (service->property("X-KDE-Read").toBool() && mode == Reading) ||
26  (service->property("X-KDE-Write").toBool() && mode == Writing ) ) {
27 
28  QString mimeType = service->property("X-KDE-MimeType").toString();
29  if ( mimeType.isEmpty() ) continue;
30  KMimeType::Ptr mime = KMimeType::mimeType( mimeType );
31  if (!mime) {
32  kWarning() << service->entryPath() << " specifies unknown mimetype " << mimeType;
33  } else {
34  QString pattern = mime->patterns().join(" ");
35  patterns.append( pattern + separator + mime->comment() );
36  if (!allPatterns.isEmpty() )
37  allPatterns += ' ';
38  allPatterns += pattern;
39  }
40  }
41  }
42 
43  allPatterns = allPatterns + separator + i18n("All Pictures");
44  patterns.sort();
45  patterns.prepend(allPatterns);
46 
47  QString pattern = patterns.join(QLatin1String("\n"));
48  return pattern;
49 }
50 
51 QStringList KImageIO::typeForMime(const QString& mimeType)
52 {
53  if ( mimeType.isEmpty() )
54  return QStringList();
55 
56  const KService::List services = KServiceTypeTrader::self()->query("QImageIOPlugins");
57  foreach(const KService::Ptr &service, services) {
58  if ( mimeType == service->property("X-KDE-MimeType").toString() )
59  return ( service->property("X-KDE-ImageFormat").toStringList() );
60  }
61  return QStringList();
62 }
63 
64 QStringList KImageIO::mimeTypes( Mode mode )
65 {
66  QStringList mimeList, allFormats;
67 
68  const KService::List services = KServiceTypeTrader::self()->query("QImageIOPlugins");
69  foreach(const KService::Ptr &service, services) {
70  if ( (service->property("X-KDE-Read").toBool() && mode == Reading) ||
71  (service->property("X-KDE-Write").toBool() && mode == Writing ) ) {
72 
73  const QString mime = service->property("X-KDE-MimeType").toString();
74  if ( !mime.isEmpty() )
75  mimeList.append( mime );
76  }
77  }
78 
79  return mimeList;
80 }
81 
82 QStringList KImageIO::types( Mode mode )
83 {
84  QStringList imagetypes;
85  const KService::List services = KServiceTypeTrader::self()->query("QImageIOPlugins");
86  foreach(const KService::Ptr &service, services) {
87  if ( (service->property("X-KDE-Read").toBool() && mode == Reading) ||
88  (service->property("X-KDE-Write").toBool() && mode == Writing ) ) {
89 
90  imagetypes += service->property("X-KDE-ImageFormat").toStringList();
91  }
92  }
93  return imagetypes;
94 }
95 
96 bool KImageIO::isSupported( const QString& mimeType, Mode mode )
97 {
98  if (mimeType.isEmpty() )
99  return false;
100 
101  const KService::List services = KServiceTypeTrader::self()->query("QImageIOPlugins");
102  foreach(const KService::Ptr &service, services) {
103  if ( mimeType == service->property("X-KDE-MimeType").toString() ) {
104 
105  if ( (service->property("X-KDE-Read").toBool() && mode == Reading) ||
106  (service->property("X-KDE-Write").toBool() && mode == Writing ) ) {
107 
108  return true;
109  } else {
110  return false;
111  }
112  }
113  }
114  return false;
115 }
i18n
QString i18n(const char *text)
KSharedPtr< KService >
kdebug.h
kmimetype.h
KImageIO::Writing
Definition: kimageio.h:53
KServiceTypeTrader::self
static KServiceTypeTrader * self()
KService::property
QVariant property(const QString &_name, QVariant::Type t) const
KImageIO::Mode
Mode
Possible image file access modes.
Definition: kimageio.h:53
KImageIO::isSupported
bool isSupported(const QString &mimeType, Mode mode=Writing)
Test to see whether a MIME type is supported to reading/writing.
Definition: kimageio.cpp:96
KImageIO::typeForMime
QStringList typeForMime(const QString &mimeType)
Returns the type of a MIME type.
Definition: kimageio.cpp:51
QStringList::join
QString join(const QString &separator) const
klocale.h
kservicetypetrader.h
QList::append
void append(const T &value)
KImageIO::pattern
QString pattern(Mode mode=Reading)
Returns a list of patterns of all KImageIO supported formats.
Definition: kimageio.cpp:16
QString::isEmpty
bool isEmpty() const
kimageio.h
QString
QList
QStringList
KImageIO::mimeTypes
QStringList mimeTypes(Mode mode=Writing)
Returns a list of MIME types for all KImageIO supported formats.
Definition: kimageio.cpp:64
KImageIO::Reading
Definition: kimageio.h:53
KImageIO::types
QStringList types(Mode mode=Writing)
Returns a list of all KImageIO supported formats.
Definition: kimageio.cpp:82
KServiceTypeTrader::query
KService::List query(const QString &servicetype, const QString &constraint=QString()) const
QVariant::toStringList
QStringList toStringList() const
QLatin1String
QVariant::toBool
bool toBool() const
kWarning
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QStringList::sort
void sort()
QList::prepend
void prepend(const T &value)
QVariant::toString
QString toString() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

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

kdelibs API Reference

Skip menu "kdelibs 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

Search



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