• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.32 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>
24 class KServiceOffer;
25 
42 class KDECORE_EXPORT KMimeTypeTrader
43 {
44 public:
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 
183 private:
187  KMimeTypeTrader();
188 
189 private:
190  class Private;
191  Private * const d;
192 };
193 
194 #endif /* KMIMETYPETRADER_H */
i18n
QString i18n(const char *text)
Returns a localized version of a string.
Definition: klocalizedstring.h:630
KSharedPtr< KService >
T
#define T
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
QString
QObject
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
KMimeTypeTrader
KDE&#39;s trader for services associated to a given mimetype.
Definition: kmimetypetrader.h:42
kservice.h
KServiceOffer
Holds the user&#39;s preference of a service.
Definition: kserviceoffer.h:38
QList< Ptr >
This file is part of the KDE documentation.
Documentation copyright © 1996-2017 The KDE developers.
Generated on Mon May 15 2017 14:44:53 by doxygen 1.8.13 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.32 API Reference

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