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

KDECore

kservicetypetrader.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 #ifndef __kservicetypetrader_h__
00020 #define __kservicetypetrader_h__
00021 
00022 #include "kservice.h"
00023 
00070 class KDECORE_EXPORT KServiceTypeTrader
00071 {
00072 public:
00076     ~KServiceTypeTrader();
00077 
00104     KService::List query( const QString& servicetype,
00105                           const QString& constraint = QString() ) const;
00106 
00113     KService::List defaultOffers( const QString& serviceType,
00114                                   const QString& constraint = QString() ) const;
00121     KService::Ptr preferredService( const QString & serviceType ) const;
00122 
00131     static KServiceTypeTrader* self();
00132 
00152     template <class T>
00153     static T *createInstanceFromQuery(const QString &serviceType,
00154             const QString &constraint = QString(), QObject *parent = 0,
00155             const QVariantList &args = QVariantList(), QString *error = 0)
00156     {
00157         return createInstanceFromQuery<T>(serviceType, 0, parent, constraint, args, error);
00158     }
00159 
00177     template <class T>
00178     static T *createInstanceFromQuery(const QString &serviceType,
00179             QWidget *parentWidget, QObject *parent, const QString &constraint = QString(), 
00180             const QVariantList &args = QVariantList(), QString *error = 0)
00181     {
00182         const KService::List offers = self()->query(serviceType, constraint);
00183         Q_FOREACH (const KService::Ptr &ptr, offers) {
00184             T *component = ptr->template createInstance<T>(parentWidget, parent, args, error);
00185             if (component) {
00186                 if (error)
00187                     error->clear();
00188                 return component;
00189             }
00190         }
00191         if (error) 
00192             *error = i18n("No service matching the requirements was found");
00193         return 0;
00194     }
00195 
00201     template <class T>
00202     static KDE_DEPRECATED T *createInstanceFromQuery(const QString &serviceType, const QString &constraint,
00203             QObject *parent, const QStringList &args, int *error = 0)
00204     {
00205         const KService::List offers = KServiceTypeTrader::self()->query(serviceType, constraint);
00206         if (offers.isEmpty()) {
00207             if (error) {
00208                 *error = KLibLoader::ErrNoServiceFound;
00209             }
00210             return 0;
00211         }
00212 
00213         return KService::createInstance<T>(offers.begin(), offers.end(), parent, args, error);
00214     }
00215 
00216 
00220     static void applyConstraints( KService::List& lst,
00221                                   const QString& constraint );
00222 
00223 private:
00227     KServiceTypeTrader();
00228 
00229     // dissalow copy ctor and assignment operator
00230     KServiceTypeTrader( const KServiceTypeTrader& other );
00231     KServiceTypeTrader& operator=( const KServiceTypeTrader& rhs );
00232 
00233     class Private;
00234     Private * const d;
00235 };
00236 
00237 #endif

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
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
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