summaryrefslogtreecommitdiffstats
path: root/kexi/plugins/macros/lib/context.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/plugins/macros/lib/context.h
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/plugins/macros/lib/context.h')
-rw-r--r--kexi/plugins/macros/lib/context.h141
1 files changed, 141 insertions, 0 deletions
diff --git a/kexi/plugins/macros/lib/context.h b/kexi/plugins/macros/lib/context.h
new file mode 100644
index 00000000..dd467dad
--- /dev/null
+++ b/kexi/plugins/macros/lib/context.h
@@ -0,0 +1,141 @@
+/***************************************************************************
+ * This file is part of the KDE project
+ * copyright (C) 2005 by Sebastian Sauer (mail@dipe.org)
+ * copyright (C) 2005 by Tobi Krebs (tobi.krebs@gmail.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ ***************************************************************************/
+
+#ifndef KOMACRO_CONTEXT_H
+#define KOMACRO_CONTEXT_H
+
+#include <qobject.h>
+#include <ksharedptr.h>
+
+#include "variable.h"
+
+namespace KoMacro {
+
+ // Forward declaration.
+ class Macro;
+ class MacroItem;
+ class Action;
+ class Exception;
+
+ /**
+ * The context of an execution. If a @a Macro got executed it creates
+ * an instance of this class and passes it around all it's children
+ * as local execution context.
+ */
+ class KOMACRO_EXPORT Context
+ : public QObject
+ , public KShared
+ {
+ Q_OBJECT
+ public:
+
+ /**
+ * Constructor.
+ *
+ * @param macro The @a Macro this @a Context belongs to.
+ */
+ explicit Context(KSharedPtr<Macro> macro);
+
+ /**
+ * Destructor.
+ */
+ ~Context();
+
+ /**
+ * @return true if there exists a variable with name @p name
+ * else false got returned.
+ */
+ bool hasVariable(const QString& name) const;
+
+ /**
+ * @return the @a Variable defined with name @p name or
+ * NULL if there exists no such variable.
+ */
+ KSharedPtr<Variable> variable(const QString& name) const;
+
+ /**
+ * @return a map of all @a Variable instance that are defined
+ * within this context.
+ */
+ Variable::Map variables() const;
+
+ /**
+ * Set the variable @p variable defined with name @p name . If
+ * there exists already a variable with that name replace it.
+ */
+ void setVariable(const QString& name, KSharedPtr<Variable> variable);
+
+ /**
+ * @return the associated macro
+ */
+ KSharedPtr<Macro> macro() const;
+
+ /**
+ * @return the currently selected @a MacroItem instance
+ * or NULL if there is no @a MacroItem selected yet.
+ */
+ KSharedPtr<MacroItem> macroItem() const;
+
+ /**
+ * @return true if the last @a activate() stopped with an
+ * exception else false is returned.
+ */
+ bool hadException() const;
+
+ /**
+ * @return the @a Exception instance that was thrown on
+ * the last call of @a activate() . If there was no
+ * exception NULL is returned.
+ */
+ Exception* exception() const;
+
+ private slots:
+
+ /**
+ * A @a Context does take care of an execution-chain which
+ * should be activated one after another. The @a Context
+ * remembers what @a Action should be executed next and
+ * calling this slot just activates those @a Action .
+ */
+ virtual void activate(QValueList<KSharedPtr <MacroItem> >::ConstIterator it);
+
+ public slots:
+
+ /**
+ * This slot extends the slot above with the passed
+ * @a Context @p context which will be used as
+ * parent context for this context.
+ */
+ virtual void activate(KSharedPtr<Context> context);
+
+ /**
+ * This slot continues execution.
+ */
+ virtual void activateNext();
+
+ private:
+ /// @internal d-pointer class.
+ class Private;
+ /// @internal d-pointer instance.
+ Private* const d;
+ };
+
+}
+
+#endif