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

KDECore

  • kdecore
  • services
kmimetypetrader.h
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Torben Weis <weis@kde.org>
3 Copyright (C) 2006 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 KMIMETYPETRADER_H
21#define KMIMETYPETRADER_H
22
23#include <kservice.h>
24class KServiceOffer;
25
42class KDECORE_EXPORT KMimeTypeTrader
43{
44public:
45
49 ~KMimeTypeTrader();
50
82 KService::List query( const QString& mimeType,
83 const QString& genericServiceType = QString::fromLatin1("Application"),
84 const QString& constraint = QString() ) const;
85
86
97 KService::Ptr preferredService( const QString & mimeType, const QString & genericServiceType = QString::fromLatin1("Application") );
98
120 template <class T>
121 static T *createPartInstanceFromQuery(const QString &mimeType, QWidget *parentWidget = 0, QObject *parent = 0,
122 const QString &constraint = QString(),
123 const QVariantList &args = QVariantList(),
124 QString *error = 0)
125 {
126 const KService::List offers = self()->query(mimeType, QString::fromLatin1("KParts/ReadOnlyPart"), constraint);
127 Q_FOREACH (const KService::Ptr &ptr, offers) {
128 T *component = ptr->template createInstance<T>(parentWidget, parent, args, error);
129 if (component) {
130 if (error)
131 error->clear();
132 return component;
133 }
134 }
135 if (error)
136 *error = i18n("No service matching the requirements was found");
137 return 0;
138 }
139
153 template <class T>
154 static T *createInstanceFromQuery(const QString &mimeType, const QString &serviceType, QObject *parent = 0,
155 const QString &constraint = QString(),
156 const QVariantList &args = QVariantList(),
157 QString *error = 0)
158 {
159 const KService::List offers = self()->query(mimeType, serviceType, constraint);
160 Q_FOREACH (const KService::Ptr &ptr, offers) {
161 T *component = ptr->template createInstance<T>(parent, args, error);
162 if (component) {
163 if (error)
164 error->clear();
165 return component;
166 }
167 }
168 if (error)
169 *error = i18n("No service matching the requirements was found");
170 return 0;
171 }
172
181 static KMimeTypeTrader* self();
182
183private:
187 KMimeTypeTrader();
188
189private:
190 class Private;
191 Private * const d;
192};
193
194#endif /* KMIMETYPETRADER_H */
KMimeTypeTrader
KDE's trader for services associated to a given mimetype.
Definition: kmimetypetrader.h:43
KMimeTypeTrader::createPartInstanceFromQuery
static T * createPartInstanceFromQuery(const QString &mimeType, QWidget *parentWidget=0, QObject *parent=0, const QString &constraint=QString(), const QVariantList &args=QVariantList(), QString *error=0)
This method creates and returns a part object from the trader query for a given mimeType.
Definition: kmimetypetrader.h:121
KMimeTypeTrader::createInstanceFromQuery
static T * createInstanceFromQuery(const QString &mimeType, const QString &serviceType, QObject *parent=0, const QString &constraint=QString(), const QVariantList &args=QVariantList(), QString *error=0)
This can be used to create a service instance from a mime type query.
Definition: kmimetypetrader.h:154
KServiceOffer
Holds the user's preference of a service.
Definition: kserviceoffer.h:39
KSharedPtr< KService >
QList< Ptr >
QObject
QString
i18n
QString i18n(const char *text)
Returns a localized version of a string.
Definition: klocalizedstring.h:630
kservice.h
T
#define T
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