Kross
action.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 KROSS_ACTION_H
00021 #define KROSS_ACTION_H
00022
00023 #include <QtCore/QVariant>
00024 #include <QtCore/QObject>
00025 #include <QtCore/QDir>
00026 #include <QtCore/QUrl>
00027 #include <QtGui/QAction>
00028 #include <QtXml/QDomAttr>
00029 #include <QtScript/QScriptable>
00030
00031 #include "errorinterface.h"
00032 #include "childreninterface.h"
00033
00034 namespace Kross {
00035
00036 class Script;
00037
00094 class KROSSCORE_EXPORT Action
00095 : public QAction
00096 , public QScriptable
00097 , public ChildrenInterface
00098 , public ErrorInterface
00099 {
00100 Q_OBJECT
00101
00102 public:
00103
00113 Action(QObject* parent, const QString& name, const QDir& packagepath = QDir());
00114
00126 Action(QObject* parent, const QUrl& url);
00127
00131 virtual ~Action();
00132
00139 void fromDomElement(const QDomElement& element);
00140
00149 void fromDomElement(const QDomElement& element, const QStringList& searchPath);
00150
00156 QDomElement toDomElement() const;
00157
00165 QDomElement toDomElement(const QStringList& searchPath) const;
00166
00176 bool initialize();
00177
00184 void finalize();
00185
00190 bool isFinalized() const;
00191
00203 Script* script() const;
00204
00205 public Q_SLOTS:
00206
00210 QString name() const;
00211
00216 int version() const;
00217
00221 QString description() const;
00222
00226 void setDescription(const QString& description);
00227
00231 QString iconName() const;
00232
00236 void setIconName(const QString& iconname);
00237
00241 bool isEnabled() const;
00242
00246 void setEnabled(bool enabled);
00247
00251 QString file() const;
00252
00256 bool setFile(const QString& scriptfile);
00257
00261 QByteArray code() const;
00262
00266 void setCode(const QByteArray& code);
00267
00272 QString interpreter() const;
00273
00277 void setInterpreter(const QString& interpretername);
00278
00283 QString currentPath() const;
00284
00289 void addQObject(QObject* obj, const QString &name = QString());
00290
00294 QObject* qobject(const QString &name) const;
00295
00299 QStringList qobjectNames() const;
00300
00306 QVariantMap options() const;
00307
00313 QVariant option(const QString& name, const QVariant& defaultvalue = QVariant());
00314
00318 bool setOption(const QString& name, const QVariant& value);
00319
00323 QStringList functionNames();
00324
00331 QVariant callFunction(const QString& name, const QVariantList& args = QVariantList());
00332
00349 QVariant evaluate(const QByteArray& code);
00350
00351 Q_SIGNALS:
00352
00359 void updated();
00360
00362 void dataChanged(Action*);
00363
00367 void started(Kross::Action*);
00368
00372 void finished(Kross::Action*);
00373
00377 void finalized(Kross::Action*);
00378
00379 private Q_SLOTS:
00380
00386 void slotTriggered();
00387
00388 private:
00390 class Private;
00392 Private* const d;
00393 };
00394
00395 }
00396
00397 Q_DECLARE_METATYPE(Kross::Action*)
00398
00399 #endif
00400