Kross
action.h
Go to the documentation of this file.
00001 /*************************************************************************** 00002 * action.h 00003 * This file is part of the KDE project 00004 * copyright (C)2004-2007 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 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()); //BIC may be removed in favour of the next c'tor 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/* = QStringList()*/); 00150 00156 QDomElement toDomElement() const; 00157 00165 QDomElement toDomElement(const QStringList& searchPath/* = QStringList()*/) 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
KDE 4.6 API Reference