summaryrefslogtreecommitdiff
path: root/client/macrowindow.cc
diff options
context:
space:
mode:
authordeva <deva>2008-06-03 14:45:48 +0000
committerdeva <deva>2008-06-03 14:45:48 +0000
commit0febf6ea9cbd1a6e04e41339fc46d2e6b07da5e7 (patch)
treeda9cee1a15609b8aa2ed556160c5660819621db2 /client/macrowindow.cc
parentbb3fad646f94739a876869464a484c99795bce61 (diff)
LUA rocks
Diffstat (limited to 'client/macrowindow.cc')
-rw-r--r--client/macrowindow.cc58
1 files changed, 47 insertions, 11 deletions
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index 74e8d54..aab9857 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -35,6 +35,8 @@
#include <QDomNode>
#include <QByteArray>
+#include "lua.h"
+
extern QString cpr;
extern QString user;
extern QString host;
@@ -45,12 +47,15 @@ MacroWindow::MacroWindow(QDomDocument *xml_doc)
{
isclosed = false;
+ this->lua = new LUA(this);
+
// Execute the recursive function with documentElement
recurser(xml_doc->documentElement(), NULL);
}
MacroWindow::~MacroWindow()
{
+ delete lua;
}
void MacroWindow::recurser(QDomNode xml_node, QWidget *parent)
@@ -63,31 +68,39 @@ void MacroWindow::recurser(QDomNode xml_node, QWidget *parent)
if(xml_elem.hasAttribute("name")) macro = xml_elem.attribute("name");
if(xml_elem.hasAttribute("version")) version = xml_elem.attribute("version");
+ } else if(xml_elem.tagName() == "luaprograms") {
+ // Nothing to do here
+ } else if(xml_elem.tagName() == "luaprogram") {
+
+ if(xml_elem.hasAttribute("name")) {
+ luaprograms[xml_elem.attribute("name")] = xml_elem.text();
+ }
+
} else if(xml_elem.tagName() == "window") {
- Window *window = new Window(xml_elem);
+ Window *window = new Window(xml_elem, this);
widget = window;
mainwidget = window;
} else if(xml_elem.tagName() == "frame") {
if(xml_elem.hasAttribute("caption")) {
- GroupBox *frame = new GroupBox(xml_elem);
+ GroupBox *frame = new GroupBox(xml_elem, this);
widget = frame;
} else {
- Frame *frame = new Frame(xml_elem);
+ Frame *frame = new Frame(xml_elem, this);
widget = frame;
}
} else if(xml_elem.tagName() == "label") {
- Label *label = new Label(xml_elem);
+ Label *label = new Label(xml_elem, this);
widget = label;
} else if(xml_elem.tagName() == "lineedit") {
- LineEdit *lineedit = new LineEdit(xml_elem);
+ LineEdit *lineedit = new LineEdit(xml_elem, this);
widgets.push_back(lineedit);
widget = lineedit;
} else if(xml_elem.tagName() == "button") {
- PushButton *pushbutton = new PushButton(xml_elem);
+ PushButton *pushbutton = new PushButton(xml_elem, this);
//connect(pushbutton, SIGNAL(act_continue()), main, SLOT(get_macro()));
connect(pushbutton, SIGNAL(act_commit()), this, SLOT(commit()));
connect(pushbutton, SIGNAL(act_reset()), this, SLOT(reset()));
@@ -96,29 +109,29 @@ void MacroWindow::recurser(QDomNode xml_node, QWidget *parent)
widget = pushbutton;
} else if(xml_elem.tagName() == "textedit") {
- TextEdit *textedit = new TextEdit(xml_elem);
+ TextEdit *textedit = new TextEdit(xml_elem, this);
widgets.push_back(textedit);
widget = textedit;
} else if(xml_elem.tagName() == "checkbox") {
- CheckBox *checkbox = new CheckBox(xml_elem);
+ CheckBox *checkbox = new CheckBox(xml_elem, this);
widgets.push_back(checkbox);
widget = checkbox;
} else if(xml_elem.tagName() == "radiobuttons") {
- RadioButtons *radiobuttons = new RadioButtons(xml_elem);
+ RadioButtons *radiobuttons = new RadioButtons(xml_elem, this);
widgets.push_back(radiobuttons);
widget = radiobuttons;
//return; // Don't iterate children
} else if(xml_elem.tagName() == "combobox") {
- ComboBox *combobox = new ComboBox(xml_elem);
+ ComboBox *combobox = new ComboBox(xml_elem, this);
widgets.push_back(combobox);
widget = combobox;
//return; // Don't iterate children
} else if(xml_elem.tagName() == "listbox") {
- ListBox *listbox = new ListBox(xml_elem);
+ ListBox *listbox = new ListBox(xml_elem, this);
widgets.push_back(listbox);
widget = listbox;
//return; // Don't iterate children
@@ -254,3 +267,26 @@ bool MacroWindow::isClosed()
{
return isclosed;
}
+
+QString MacroWindow::getValue(QString name)
+{
+ // Iterate the different entries, and append their results to the commit string
+ QVector< Widget* >::iterator i=widgets.begin();
+ while (i != widgets.end()) {
+ Widget* w = *i;
+ if(name == w->getName()) return w->getValue();
+ i++;
+ }
+ return name + " - No such field!";
+}
+
+void MacroWindow::setValue(QString name, QString value)
+{
+ // Iterate the different entries, and append their results to the commit string
+ QVector< Widget* >::iterator i = widgets.begin();
+ while (i != widgets.end()) {
+ Widget* w = *i;
+ if(name == w->getName()) w->setValue(value);
+ i++;
+ }
+}