kexi
macro.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "macro.h"
00021 #include "macroitem.h"
00022 #include "manager.h"
00023 #include "context.h"
00024 #include "variable.h"
00025
00026 #include <qdom.h>
00027 #include <kdebug.h>
00028
00029 using namespace KoMacro;
00030
00031 namespace KoMacro {
00032
00037 class Macro::Private
00038 {
00039 public:
00040
00044 QValueList<KSharedPtr<MacroItem > > itemlist;
00045
00049 QString name;
00050
00051 };
00052
00053 }
00054
00055
00056 Macro::Macro(const QString& name)
00057 : QObject()
00058 , KShared()
00059 , XMLHandler(this)
00060 , d( new Private() )
00061 {
00062 d->name = name;
00063 }
00064
00065
00066 Macro::~Macro()
00067 {
00068
00069 delete d;
00070 }
00071
00072
00073 const QString Macro::name() const
00074 {
00075 return d->name;
00076 }
00077
00078
00079 void Macro::setName(const QString& name)
00080 {
00081 d->name = name;
00082 }
00083
00084
00085 const QString Macro::toString() const
00086 {
00087 return QString("Macro:%1").arg(name());
00088 }
00089
00090
00091 QValueList<KSharedPtr<MacroItem > >& Macro::items() const
00092 {
00093 return d->itemlist;
00094 }
00095
00096
00097 void Macro::addItem(KSharedPtr<MacroItem> item)
00098 {
00099 d->itemlist.append(item);
00100 }
00101
00102 void Macro::clearItems()
00103 {
00104 d->itemlist.clear();
00105 }
00106
00107
00108 KSharedPtr<Context> Macro::execute(QObject* sender)
00109 {
00110 kdDebug() << "Macro::execute(KSharedPtr<Context>)" << endl;
00111
00112
00113 KSharedPtr<Context> c = KSharedPtr<Context>( new Context(this) );
00114 if(sender) {
00115
00116 c->setVariable("[sender]", KSharedPtr<Variable>( new Variable(sender) ));
00117 }
00118
00119
00120
00121 c->activate( c );
00122
00123 return c;
00124 }
00125
00126 #include "macro.moc"
|