• Skip to content
  • Skip to link menu
KDE 4.1 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 
00172     template <class T>
00173     static T *createInstanceFromQuery(const QString &serviceType,
00174             QWidget *parentWidget, QObject *parent, const QString &constraint = QString(), 
00175             const QVariantList &args = QVariantList(), QString *error = 0)
00176     {
00177         const KService::List offers = self()->query(serviceType, constraint);
00178         Q_FOREACH (const KService::Ptr &ptr, offers) {
00179             T *component = ptr->template createInstance<T>(parentWidget, parent, args, error);
00180             if (component) {
00181                 if (error)
00182                     error->clear();
00183                 return component;
00184             }
00185         }
00186         if (error) 
00187             *error = i18n("No service matching the requirements was found");
00188         return 0;
00189     }
00190 
00191     template <class T>
00192     static KDE_DEPRECATED T *createInstanceFromQuery(const QString &serviceType, const QString &constraint,
00193             QObject *parent, const QStringList &args, int *error = 0)
00194     {
00195         const KService::List offers = KServiceTypeTrader::self()->query(serviceType, constraint);
00196         if (offers.isEmpty()) {
00197             if (error) {
00198                 *error = KLibLoader::ErrNoServiceFound;
00199             }
00200             return 0;
00201         }
00202 
00203         return KService::createInstance<T>(offers.begin(), offers.end(), parent, args, error);
00204     }
00205 
00206 
00210     static void applyConstraints( KService::List& lst,
00211                                   const QString& constraint );
00212 
00213 private:
00217     KServiceTypeTrader();
00218 
00219     // dissalow copy ctor and assignment operator
00220     KServiceTypeTrader( const KServiceTypeTrader& other );
00221     KServiceTypeTrader& operator=( const KServiceTypeTrader& rhs );
00222 
00223     class Private;
00224     Private * const d;
00225 };
00226 
00227 #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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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