Kross

action.h
1 /***************************************************************************
2  * action.h
3  * This file is part of the KDE project
4  * copyright (C)2004-2007 by Sebastian Sauer ([email protected])
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  ***************************************************************************/
19 
20 #ifndef KROSS_ACTION_H
21 #define KROSS_ACTION_H
22 
23 #include <QVariant>
24 #include <QObject>
25 #include <QDir>
26 #include <QUrl>
27 #include <QAction>
28 #include <QDomAttr>
29 #include <QScriptable>
30 
31 #include "errorinterface.h"
32 #include "childreninterface.h"
33 
34 namespace Kross
35 {
36 
37 class Script;
38 
95 class KROSSCORE_EXPORT Action
96  : public QAction
97  , public QScriptable
98  , public ChildrenInterface
99  , public ErrorInterface
100 {
101  Q_OBJECT
102 
103 public:
104 
114  Action(QObject *parent, const QString &name, const QDir &packagepath = QDir()); //BIC may be removed in favour of the next c'tor
115 
127  Action(QObject *parent, const QUrl &url);
128 
132  virtual ~Action();
133 
140  void fromDomElement(const QDomElement &element);
141 
150  void fromDomElement(const QDomElement &element, const QStringList &searchPath/* = QStringList()*/);
151 
157  QDomElement toDomElement() const;
158 
166  QDomElement toDomElement(const QStringList &searchPath/* = QStringList()*/) const;
167 
177  bool initialize();
178 
185  void finalize();
186 
191  bool isFinalized() const;
192 
204  Script *script() const;
205 
206 public Q_SLOTS:
207 
211  QString name() const;
212 
217  int version() const;
218 
222  QString description() const;
223 
227  void setDescription(const QString &description);
228 
232  QString iconName() const;
233 
237  void setIconName(const QString &iconname);
238 
242  bool isEnabled() const;
243 
247  void setEnabled(bool enabled);
248 
252  QString file() const;
253 
257  bool setFile(const QString &scriptfile);
258 
262  QByteArray code() const;
263 
267  void setCode(const QByteArray &code);
268 
273  QString interpreter() const;
274 
278  void setInterpreter(const QString &interpretername);
279 
284  QString currentPath() const;
285 
290  void addQObject(QObject *obj, const QString &name = QString());
291 
295  QObject *qobject(const QString &name) const;
296 
300  QStringList qobjectNames() const;
301 
307  QVariantMap options() const;
308 
314  QVariant option(const QString &name, const QVariant &defaultvalue = QVariant());
315 
319  bool setOption(const QString &name, const QVariant &value);
320 
324  QStringList functionNames();
325 
332  QVariant callFunction(const QString &name, const QVariantList &args = QVariantList());
333 
350  QVariant evaluate(const QByteArray &code);
351 
352 Q_SIGNALS:
353 
360  void updated();
361 
363  void dataChanged(Action *);
364 
368  void started(Kross::Action *);
369 
373  void finished(Kross::Action *);
374 
378  void finalized(Kross::Action *);
379 
380 private Q_SLOTS:
381 
387  void slotTriggered();
388 
389 private:
391  class Private;
393  Private *const d;
394 };
395 
396 }
397 
398 #endif
399 
Base class for interpreter dependent functionality each script provides.
Definition: core/script.h:44
Interface for error-handling.
Definition: action.cpp:36
Interface for managing Object collections.
The Action class is an abstract container to deal with scripts like a single standalone script file...
Definition: action.h:95
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 5 2020 22:56:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.