summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2010-08-13 13:53:59 +0000
committerdeva <deva>2010-08-13 13:53:59 +0000
commit836ab03e9bdc442bbe8b414007dae294153a748a (patch)
treeee9035925e006bf5181e3679790708b022b80cad /client
parent843221d0826ed0a53a94e84772f89c482f80776a (diff)
Make validation run deep (or not).
Diffstat (limited to 'client')
-rw-r--r--client/lua.cc6
-rw-r--r--client/macrowindow.cc19
-rw-r--r--client/widgets/widget.cc7
-rw-r--r--client/widgets/widget.h20
4 files changed, 20 insertions, 32 deletions
diff --git a/client/lua.cc b/client/lua.cc
index 062e520..eb9b8a3 100644
--- a/client/lua.cc
+++ b/client/lua.cc
@@ -32,8 +32,8 @@
#include "luawidget.h"
-#define DEBUG(fmt...) printf("LUA (%p)", this); printf(fmt); fflush(stdout)
-//#define DEBUG(ftm...)
+//#define DEBUG(fmt...) printf("LUA (%p)", this); printf(fmt); fflush(stdout)
+#define DEBUG(ftm...)
#define GLOBAL_POINTER "_pracroGlobalLUAObjectPointerThisShouldBeANameThatIsNotAccidentallyOverwritten"
@@ -184,7 +184,7 @@ bool LUA::runScript(QString script, Widget *widget, QString name)
void LUA::error(QString message)
{
- DEBUG("LUA ERROR: %s\n", message.toStdString().c_str());
+ printf("LUA ERROR: %s\n", message.toStdString().c_str());
}
Widget *LUA::getWidget(QString name)
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index 6588416..4513483 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -42,9 +42,8 @@ extern QString user;
extern QString host;
extern quint16 port;
-#define DEBUG(fmt...) printf("MacroWindow (%p)", this); \
- printf(fmt); fflush(stdout)
-//#define DEBUG(ftm...)
+//#define DEBUG(fmt...) printf("MacroWindow (%p)",this);printf(fmt);fflush(stdout)
+#define DEBUG(ftm...)
MacroWindow::MacroWindow(NetCom &n, QDomNode &xml_doc, QString templ,
bool collapsed, bool compact)
@@ -116,21 +115,21 @@ void MacroWindow::initMacro(QDomNode &node)
} else if(elem.tagName() == "widgets") {
if(mainwidget) {
- DEBUG("ERROR!!!!!!\n\tmainwidget already exists!\n");
+ DEBUG("WARNING: mainwidget already exists! Calling clear().\n");
+ clear();
}
Window *window = new Window(elem, this);
connect(window, SIGNAL(wasChanged()), this, SLOT(macroChanged()));
macrotitle = elem.attribute("caption");
- clear();
mainwidget = window;
mainwidget->setValues();
if(waschanged == true) macroChanged();
- return; // No further recursion.
+ return; // No further recursion here.
}
QDomNodeList children = node.childNodes();
@@ -145,7 +144,8 @@ void MacroWindow::initMacro(QDomNode &node)
bool MacroWindow::doCommit()
{
if(mainwidget->valid()) {
- QVector< Widget* > wlist = mainwidget->widgetList();
+ QVector< Widget* > wlist;
+ if(mainwidget) wlist = mainwidget->widgetList();
QDomDocument doc = netcom.send(wlist, templ, macro, version);
QDomNodeList nl = doc.documentElement().childNodes();
@@ -223,7 +223,8 @@ void MacroWindow::expandWrapper()
expand();
// Set keyboard focus on the first focusable widget in the macro.
- QVector< Widget* > widgets = mainwidget->widgetList(true);
+ QVector< Widget* > widgets;
+ if(mainwidget) widgets = mainwidget->widgetList(true);
QVector< Widget* >::iterator i = widgets.begin();
while (i != widgets.end()) {
if(*i) {
@@ -242,7 +243,7 @@ void MacroWindow::collapseWrapper()
if(waschanged) {
switch(MessageBox::warning(NULL,
"Gem ændringerne i makroen?",
- "Du har valgt at ukke makroen " +
+ "Du har valgt at lukke makroen " +
macrotitle + ".\n"
"Ønsker du at gemme inden du lukker?",
MessageBox::Save | MessageBox::Close |
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index e5ec498..1518231 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -62,7 +62,7 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
*/
has_lazy = elem.hasAttribute("name") && elem.hasAttribute("value");
lazy_value = elem.attribute("value", "");
- lazy_source = elem.attribute("prefilled", "pracro");
+ lazy_source = elem.attribute("prefilled", "prefilled");
if((hasOnChangeEvent = elem.hasAttribute("onChange"))) {
onChangeEventScript = elem.attribute("onChange");
@@ -111,12 +111,12 @@ bool Widget::local()
return widget_local;
}
-bool Widget::valid()
+bool Widget::valid(bool deep)
{
if(preValid() == false) return false;
if(is_valid == false) return false;
- if(hideChildren) return true;
+ if(hideChildren && deep == false) return true;
QVector< Widget* >::iterator i = children.begin();
while(i != children.end()) {
@@ -217,6 +217,7 @@ void Widget::addChild(Widget *widget)
}
children.push_back(widget);
connect(widget, SIGNAL(wasChanged()), this, SLOT(childWasChanged()));
+ //widget->setParent(this);
}
void Widget::addChildren(QDomNode &node, QLayout *layout)
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index ef22c18..3315c2e 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -52,7 +52,8 @@ public:
virtual QString value() = 0;
virtual void setValue(QString value, QString source) = 0;
- bool valid();
+ // Set deep to true to validate inner widgets.
+ bool valid(bool deep = false);
void setValid(bool valid);
// Implement in subclasses to contribute to the validation.
@@ -69,16 +70,9 @@ public:
virtual bool setKeyboardFocus();
- /*
- void setInitialValue(QString value);
- bool hasInitialValue();
- virtual void reset();
- */
-
QWidget *qwidget() { return widget; }
- // Set deep to true to find widgets inside altcombobox, multilist and
- // metawidgets.
+ // Set deep to true to search through inner widgets.
Widget *findWidget(QString name, bool deep = false);
QVector< Widget* > widgetList(bool deep = false);
void addChild(Widget *widget);
@@ -120,14 +114,6 @@ private:
bool hasOnChangeEvent;
QString onChangeEventScript;
-
- /*
- QString initial_value;
- QString initial_source;
- bool has_initial_value;
- QString prefilled;
- */
-
};
#endif/*__PRACRO_WIDGET_H__*/