From 2e87c4608a9fb888fd7669756d8cb457ac305f71 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 24 Mar 2008 13:16:38 +0000 Subject: next button now works; listbox isValid check improved; start macro implemented --- client/builder.cc | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'client/builder.cc') diff --git a/client/builder.cc b/client/builder.cc index b30f225..29f58d0 100644 --- a/client/builder.cc +++ b/client/builder.cc @@ -13,6 +13,7 @@ #include "widgets/radiobutton.h" #include "widgets/checkbox.h" #include "widgets/window.h" +#include "macro.h" #include #include #include @@ -20,6 +21,9 @@ #include #include +extern QString cpr; +extern QString user; + Builder::Builder(QDomDocument *xml_doc) : QObject() { @@ -48,6 +52,7 @@ void Builder::recurser(QDomNode xml_node, QWidget *parent) } else if(xml_elem.tagName() == "window") { Window *window = new Window(xml_elem); widget = window; + mainwidget = window; } else if(xml_elem.tagName() == "frame") { if(xml_elem.hasAttribute("caption")) { @@ -73,7 +78,7 @@ void Builder::recurser(QDomNode xml_node, QWidget *parent) 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()), this, SLOT(cont("fisk"))); + connect(pushbutton, SIGNAL(act_continue(QString)), this, SLOT(cont(QString))); widget = pushbutton; } else if(xml_elem.tagName() == "textedit") { @@ -116,7 +121,7 @@ void Builder::recurser(QDomNode xml_node, QWidget *parent) if(widget != NULL) widget->show(); } -void Builder::commit() +bool Builder::doCommit() { // Check for, and count, errors on all entries before comitting int faulty = 0; // 0 initial errors @@ -127,7 +132,7 @@ void Builder::commit() if(!w->isValid()) faulty++; // Regexp check, returns valid if entry passed // All selectable entries return "none" if nothing is selected - if(w->getValue() == "none") faulty++; // Faulty+1 if error detected + //if(w->getValue() == "none") faulty++; // Faulty+1 if error detected i++; } @@ -138,7 +143,7 @@ void Builder::commit() // Build the XML commit QString xml_string; xml_string.append("\n"); - xml_string.append("\n"); + xml_string.append("\n"); xml_string.append(" \n"); @@ -174,9 +179,18 @@ void Builder::commit() //QByteArray ba = macro_commit.getResult(); QString ba = macro_commit.getResult(); printf("Server returned result: %s", ba.toStdString().c_str()); - exit(1); // Probably bad exit. Implemented for test version. + return true; + } else { + return false; + } +} + +void Builder::commit() +{ + if(doCommit()) { + mainwidget->close(); } else { - QMessageBox::critical(NULL, "Fejl", + QMessageBox::critical(NULL, "Fejl", "Makroen er ikke udfyldt korrekt, prøv igen.\n" , QMessageBox::Ok); } @@ -184,7 +198,7 @@ void Builder::commit() void Builder::reset() { -int ret = QMessageBox::warning(NULL, "Reset", + int ret = QMessageBox::warning(NULL, tr("Reset"), tr("Du har valgt at nulstille de indtastede data.\n" "Er du sikker?"), QMessageBox::Yes | QMessageBox::Cancel); @@ -194,21 +208,27 @@ int ret = QMessageBox::warning(NULL, "Reset", void Builder::cancel() { printf("Builder -> cancelling...\n"); - exit(1); // Probably bad exit. Implemented for test version. + mainwidget->close(); } void Builder::cont(QString name) { - /* + QString macro; QVector< Widget* >::iterator i=widgets.begin(); while (i != widgets.end()) { Widget* w = *i; - - if(w->getName() - xml_string.append(" getName() - + "\" value=\"" + w->getValue() + "\"/>\n"); + if(w->getName() == name) { + macro = w->getValue(); + } i++; } - */ - printf("%s : Builder -> continuing...\n", name.toStdString().c_str()); + if(doCommit()) { + new_macro(macro); + mainwidget->close(); + } else { + QMessageBox::critical(NULL, "Fejl", + "Makroen er ikke udfyldt korrekt, prøv igen.\n" + , QMessageBox::Ok); + } + printf("%s : Builder -> continuing...\n", macro.toStdString().c_str()); } -- cgit v1.2.3