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

KIO

  • 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 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Jul 23 2013 20:37:34 by doxygen 1.8.1.1 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-4.10.5 API Reference

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