Plasma
service.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PLASMA_SERVICE_H
00021 #define PLASMA_SERVICE_H
00022
00023 #include <QtCore/QMap>
00024 #include <QtCore/QObject>
00025 #include <QtCore/QVariant>
00026
00027 #include <kconfiggroup.h>
00028
00029 #include <plasma/plasma_export.h>
00030
00031 class QGraphicsWidget;
00032 class QIODevice;
00033 class QWidget;
00034
00035 namespace Plasma
00036 {
00037
00038 class ServiceJob;
00039 class ServicePrivate;
00040
00075 class PLASMA_EXPORT Service : public QObject
00076 {
00077 Q_OBJECT
00078 public:
00082 ~Service();
00083
00092 static Service *load(const QString &name, QObject *parent = 0);
00093
00100 Q_INVOKABLE void setDestination(const QString &destination);
00101
00105 Q_INVOKABLE QString destination() const;
00106
00110 Q_INVOKABLE QStringList operationNames() const;
00111
00118 Q_INVOKABLE KConfigGroup operationDescription(const QString &operationName);
00119
00127 Q_INVOKABLE ServiceJob *startOperationCall(const KConfigGroup &description, QObject *parent = 0);
00128
00135 Q_INVOKABLE bool isOperationEnabled(const QString &operation) const;
00136
00140 Q_INVOKABLE QString name() const;
00141
00152 Q_INVOKABLE void associateWidget(QWidget *widget, const QString &operation);
00153
00162 Q_INVOKABLE void disassociateWidget(QWidget *widget);
00163
00174 Q_INVOKABLE void associateWidget(QGraphicsWidget *widget, const QString &operation);
00175
00184 Q_INVOKABLE void disassociateWidget(QGraphicsWidget *widget);
00185
00186 Q_SIGNALS:
00190 void finished(Plasma::ServiceJob *job);
00191
00197 void operationsChanged();
00198
00199 protected:
00205 explicit Service(QObject *parent = 0);
00206
00210 Service(QObject *parent, const QVariantList &args);
00211
00219 virtual ServiceJob *createJob(const QString &operation,
00220 QMap<QString, QVariant> ¶meters) = 0;
00221
00228 virtual void registerOperationsScheme();
00229
00234 void setOperationsScheme(QIODevice *xml);
00235
00242 void setName(const QString &name);
00243
00250 void setOperationEnabled(const QString &operation, bool enable);
00251
00252 private:
00253 Q_PRIVATE_SLOT(d, void jobFinished(KJob *))
00254 Q_PRIVATE_SLOT(d, void associatedWidgetDestroyed(QObject *))
00255 Q_PRIVATE_SLOT(d, void associatedGraphicsWidgetDestroyed(QObject *))
00256
00257 ServicePrivate * const d;
00258
00259 friend class ServicePrivate;
00260 };
00261
00262 }
00263
00267 #define K_EXPORT_PLASMA_SERVICE(libname, classname) \
00268 K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
00269 K_EXPORT_PLUGIN(factory("plasma_service_" #libname)) \
00270 K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
00271
00272 #endif // multiple inclusion guard
00273