• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 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
15QString
16KImageIO::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
51QStringList 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
64QStringList 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
82QStringList 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
96bool 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}
KMimeType::mimeType
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
KServiceTypeTrader::self
static KServiceTypeTrader * self()
KServiceTypeTrader::query
KService::List query(const QString &servicetype, const QString &constraint=QString()) const
KSharedPtr< KService >
QList< Ptr >
kWarning
#define kWarning
kdebug.h
kimageio.h
klocale.h
i18n
QString i18n(const char *text)
kmimetype.h
kservicetypetrader.h
KImageIO::mimeTypes
QStringList mimeTypes(Mode mode=Writing)
Returns a list of MIME types for all KImageIO supported formats.
Definition: kimageio.cpp:64
KImageIO::typeForMime
QStringList typeForMime(const QString &mimeType)
Returns the type of a MIME type.
Definition: kimageio.cpp:51
KImageIO::types
QStringList types(Mode mode=Writing)
Returns a list of all KImageIO supported formats.
Definition: kimageio.cpp:82
KImageIO::pattern
QString pattern(Mode mode=Reading)
Returns a list of patterns of all KImageIO supported formats.
Definition: kimageio.cpp:16
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::Mode
Mode
Possible image file access modes.
Definition: kimageio.h:53
KImageIO::Writing
@ Writing
Definition: kimageio.h:53
KImageIO::Reading
@ Reading
Definition: kimageio.h:53
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.

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.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