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

KDECore

kmimetypetrader.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2000 Torben Weis <weis@kde.org>
00003    Copyright (C) 2006 David Faure <faure@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KMIMETYPETRADER_H
00021 #define KMIMETYPETRADER_H
00022 
00023 #include <kservice.h>
00024 class KServiceOffer;
00025 
00042 class KDECORE_EXPORT KMimeTypeTrader
00043 {
00044 public:
00045 
00049     ~KMimeTypeTrader();
00050 
00082     KService::List query( const QString& mimeType,
00083                           const QString& genericServiceType = QString::fromLatin1("Application"),
00084                           const QString& constraint = QString() ) const;
00085 
00086 
00097     KService::Ptr preferredService( const QString & mimeType, const QString & genericServiceType = QString::fromLatin1("Application") );
00098 
00120     template <class T>
00121     static T *createPartInstanceFromQuery(const QString &mimeType, QWidget *parentWidget = 0, QObject *parent = 0,
00122                                       const QString &constraint = QString(),
00123                                       const QVariantList &args = QVariantList(),
00124                                       QString *error = 0)
00125     {
00126         const KService::List offers = self()->query(mimeType, QString::fromAscii("KParts/ReadOnlyPart"), constraint);
00127         Q_FOREACH (const KService::Ptr &ptr, offers) {
00128             T *component = ptr->template createInstance<T>(parentWidget, parent, args, error);
00129             if (component) {
00130                 if (error)
00131                     error->clear();
00132                 return component;
00133             }
00134         }
00135         if (error)
00136             *error = i18n("No service matching the requirements was found");
00137         return 0;
00138     }
00139 
00153     template <class T>
00154     static T *createInstanceFromQuery(const QString &mimeType, const QString &serviceType, QObject *parent = 0,
00155                                       const QString &constraint = QString(),
00156                                       const QVariantList &args = QVariantList(),
00157                                       QString *error = 0)
00158     {
00159         const KService::List offers = self()->query(mimeType, serviceType, constraint);
00160         Q_FOREACH (const KService::Ptr &ptr, offers) {
00161             T *component = ptr->template createInstance<T>(parent, args, error);
00162             if (component) {
00163                 if (error)
00164                     error->clear();
00165                 return component;
00166             }
00167         }
00168         if (error)
00169             *error = i18n("No service matching the requirements was found");
00170         return 0;
00171     }
00172 
00181     static KMimeTypeTrader* self();
00182 
00183 private:
00187     KMimeTypeTrader();
00188 
00189 private:
00190     class Private;
00191     Private * const d;
00192 };
00193 
00194 #endif /* KMIMETYPETRADER_H */

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal