summaryrefslogtreecommitdiff
path: root/client/macrowindow.cc
diff options
context:
space:
mode:
authordeva <deva>2008-06-18 11:03:34 +0000
committerdeva <deva>2008-06-18 11:03:34 +0000
commit8c3994b02e3a0cf81ead56c8dcfefb67be078328 (patch)
tree7bf98b5b9438e0f64725bfc12a34b98c20583116 /client/macrowindow.cc
parentb681594b7e4f9a5375b555b152d661581c600a96 (diff)
Restructured widget building, completed inital version of MultiList with format string parsing, db commiting and rereading.
Diffstat (limited to 'client/macrowindow.cc')
-rw-r--r--client/macrowindow.cc98
1 files changed, 14 insertions, 84 deletions
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index b799d31..6f52916 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -26,8 +26,8 @@
*/
#include "macrowindow.h"
#include "sendrecieve.h"
-#include "widgets.h"
#include "macro.h"
+#include "widgets/widget.h"
#include <QVBoxLayout>
#include <QMessageBox>
#include <QDomDocument>
@@ -35,6 +35,8 @@
#include <QDomNode>
#include <QByteArray>
+#include "widgets/window.h"
+#include "widgetbuilder.h"
#include "lua.h"
extern QString cpr;
@@ -46,11 +48,13 @@ MacroWindow::MacroWindow(QDomNode &xml_doc)
: QObject()
{
isclosed = false;
+ mainwidget = NULL;
this->lua = new LUA(this);
- // Execute the recursive function with documentElement
- recurser(xml_doc, NULL);
+ initMacro(xml_doc);
+
+ if(mainwidget) mainwidget->show();
}
MacroWindow::~MacroWindow()
@@ -58,10 +62,9 @@ MacroWindow::~MacroWindow()
delete lua;
}
-void MacroWindow::recurser(QDomNode xml_node, QWidget *parent)
+void MacroWindow::initMacro(QDomNode &node)
{
- QWidget *widget = NULL;
- QDomElement xml_elem = xml_node.toElement();
+ QDomElement xml_elem = node.toElement();
if(xml_elem.tagName() == "macro") {
// Assign the macro name and version to QStrings for use when comitting
@@ -78,97 +81,24 @@ void MacroWindow::recurser(QDomNode xml_node, QWidget *parent)
} else if(xml_elem.tagName() == "window") {
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, this);
- widget = frame;
- } else {
- Frame *frame = new Frame(xml_elem, this);
- widget = frame;
- }
+ QDomNodeList children = node.childNodes();
- } else if(xml_elem.tagName() == "label") {
- Label *label = new Label(xml_elem, this);
- widget = label;
-
- } else if(xml_elem.tagName() == "lineedit") {
- 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, 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()));
- connect(pushbutton, SIGNAL(act_cancel()), this, SLOT(cancel()));
- connect(pushbutton, SIGNAL(act_continue(QString)), this, SLOT(cont(QString)));
- widget = pushbutton;
-
- } else if(xml_elem.tagName() == "textedit") {
- 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, this);
- widgets.push_back(checkbox);
- widget = checkbox;
-
- } else if(xml_elem.tagName() == "radiobuttons") {
- 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, this);
- widgets.push_back(combobox);
- widget = combobox;
- //return; // Don't iterate children
-
- } else if(xml_elem.tagName() == "listbox") {
- ListBox *listbox = new ListBox(xml_elem, this);
- widgets.push_back(listbox);
- widget = listbox;
- //return; // Don't iterate children
- } else if(xml_elem.tagName() == "multilist") {
-
- MultiList *multilist = new MultiList(xml_elem, this);
- widgets.push_back(multilist);
- if(parent) parent->layout()->addWidget(multilist);
-
- QDomNodeList children = xml_node.childNodes();
for (int i=0; i<children.count();i++) {
QDomNode child = children.at(i);
- if(child.nodeName() == "input") {
- QDomNodeList children = child.childNodes();
-
- for (int i=0; i<children.count();i++) {
- QDomNode child = children.at(i);
- recurser(child, multilist->inputcontainer);
- }
- break;
- }
+ widgets += widgetBuilder(child, mainwidget, this);
}
-
- multilist->inputcontainer->show();
- multilist->show();
- return; // Don't iterate children
+ return;
}
- QDomNodeList children = xml_node.childNodes();
+ QDomNodeList children = node.childNodes();
for (int i=0; i<children.count();i++) {
QDomNode child = children.at(i);
- recurser(child, widget);
+ initMacro(child);
}
- if(parent != NULL && widget != NULL) parent->layout()->addWidget(widget);
- if(widget != NULL) widget->show();
}
bool MacroWindow::doCommit()