kexi
action.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "action.h"
00022
00023 #include <kdebug.h>
00024
00025 using namespace KoMacro;
00026
00027 namespace KoMacro {
00028
00033 class Action::Private
00034 {
00035 public:
00036
00040 QString name;
00041
00045 QString text;
00046
00050 QString comment;
00051
00056 Variable::Map varmap;
00057
00063 QStringList varnames;
00064
00065 };
00066
00067 }
00068
00069 Action::Action(const QString& name, const QString& text)
00070 : QObject()
00071 , KShared()
00072 , d( new Private() )
00073 {
00074 kdDebug() << "Action::Action() name=" << name << endl;
00075 d->name = name;
00076 setText(text);
00077
00078
00079 KoMacro::Manager::self()->publishAction( KSharedPtr<Action>(this) );
00080 }
00081
00082 Action::~Action()
00083 {
00084
00085
00086
00087 delete d;
00088 }
00089
00090 const QString Action::toString() const
00091 {
00092 return QString("Action:%1").arg(name());
00093 }
00094
00095 const QString Action::name() const
00096 {
00097 return d->name;
00098 }
00099
00100 void Action::setName(const QString& name)
00101 {
00102 d->name = name;
00103 }
00104
00105 const QString Action::text() const
00106 {
00107 return d->text;
00108 }
00109
00110 void Action::setText(const QString& text)
00111 {
00112 d->text = text;
00113 }
00114
00115 const QString Action::comment() const
00116 {
00117 return d->comment;
00118 }
00119
00120 void Action::setComment(const QString& comment)
00121 {
00122 d->comment = comment;
00123 }
00124
00125 bool Action::hasVariable(const QString& name) const
00126 {
00127 return d->varmap.contains(name);
00128 }
00129
00130 KSharedPtr<Variable> Action::variable(const QString& name) const
00131 {
00132 return d->varmap.contains(name) ? d->varmap[name] : KSharedPtr<Variable>(0);
00133 }
00134
00135 Variable::Map Action::variables() const
00136 {
00137 return d->varmap;
00138 }
00139
00140 QStringList Action::variableNames() const
00141 {
00142 return d->varnames;
00143 }
00144
00145 void Action::setVariable(KSharedPtr<Variable> variable)
00146 {
00147 const QString name = variable->name();
00148 if(! d->varmap.contains(name)) {
00149 d->varnames.append(name);
00150 }
00151 d->varmap.replace(name, variable);
00152 }
00153
00154 void Action::setVariable(const QString& name, const QString& text, const QVariant& variant)
00155 {
00156 Variable* variable = new Variable(variant);
00157 variable->setName(name);
00158 variable->setText(text);
00159 setVariable( KSharedPtr<Variable>(variable) );
00160 }
00161
00162 void Action::removeVariable(const QString& name)
00163 {
00164 if(d->varmap.contains(name)) {
00165 d->varmap.remove(name);
00166 d->varnames.remove(name);
00167 }
00168 }
00169
00170 #include "action.moc"
|