diff options
author | deva <deva> | 2010-08-12 10:57:04 +0000 |
---|---|---|
committer | deva <deva> | 2010-08-12 10:57:04 +0000 |
commit | d9338083192084613e5530b02710b796252d342b (patch) | |
tree | e0ec2b36e0de62328e5fd5d3b597f6ee71d1b18f /client/widgets/metawidget.cc | |
parent | dbab8458dcce186e7eb7a114a83f759d7db5445a (diff) |
New scripting system part2.
Diffstat (limited to 'client/widgets/metawidget.cc')
-rw-r--r-- | client/widgets/metawidget.cc | 85 |
1 files changed, 39 insertions, 46 deletions
diff --git a/client/widgets/metawidget.cc b/client/widgets/metawidget.cc index 5933212..9634c76 100644 --- a/client/widgets/metawidget.cc +++ b/client/widgets/metawidget.cc @@ -28,19 +28,24 @@ #include <QHBoxLayout> #include <QVBoxLayout> +#include <QFrame> #include "messagebox.h" - #include "widgetbuilder.h" #include "formatparser.h" - +#include "macrowindow.h" #include "common.h" MetaWidget::MetaWidget(QDomNode &node, MacroWindow *macrowindow) - : QFrame(), Widget(node, macrowindow) + : Widget(node, macrowindow) { - setCommonAttributes(this, node); - setCommonLayout(this, node); + frame = new QFrame(); + widget = frame; + + setCommonAttributes(frame, node); + setCommonLayout(frame, node); + + hideChildren = true; QDomElement elem = node.toElement(); storechildren = elem.attribute("storechildren", "false") == "true"; @@ -49,10 +54,8 @@ MetaWidget::MetaWidget(QDomNode &node, MacroWindow *macrowindow) QDomNodeList children = node.childNodes(); for (int i=0; i<children.count();i++) { QDomNode child = children.at(i); - widgets += widgetBuilder(child, this, macrowindow, false); + widgetBuilder(child); } - if(storechildren) macrowindow->addWidgets(widgets); - else macrowindow->addAuxWidgets(widgets); // Setup format string if(elem.hasAttribute("formatlanguage")) { @@ -73,23 +76,30 @@ MetaWidget::MetaWidget(QDomNode &node, MacroWindow *macrowindow) } } + addChildren(node); + // Connect all children wasChanged signal, to catch changes. QVector< Widget* >::iterator i = widgets.begin(); while (i != widgets.end()) { Widget* w = *i; - w->connectFrom(SIGNAL(wasChanged()), this, SLOT(changed())); + connect(w, SIGNAL(wasChanged()), this, SLOT(changed())); i++; } } +MetaWidget::~MetaWidget() +{ + // delete frame; +} + void MetaWidget::changed() { emit wasChanged(); } -QString MetaWidget::getValue() +QString MetaWidget::value() { - return format_parser(format, widgets, formatlanguage); + return format_parser(format, this, formatlanguage); } void MetaWidget::setValue(QString, QString) @@ -97,52 +107,25 @@ void MetaWidget::setValue(QString, QString) // Nothing reasonable we can do here. } -void MetaWidget::enable() -{ - setEnabled(true); -} - -void MetaWidget::disable() -{ - setEnabled(false); -} - -bool MetaWidget::isDisabled() -{ - return isEnabled() == false; -} - -bool MetaWidget::isValid() +bool MetaWidget::preValid() { // If children are stored they will validate themselves. if(!storechildren) { QVector< Widget* >::iterator i = widgets.begin(); while (i != widgets.end()) { Widget* w = *i; - if(w->isValid() == false) { + if(w->enabled() && !w->local() && !w->valid()) { MessageBox::critical(NULL, "Fejl", - "Et af inputfelterne (" + w->name() - + ") er ikke udfyldt korrekt, prøv igen.\n" - , MessageBox::Ok); + "Et af inputfelterne (" + w->name() + + ") er ikke udfyldt korrekt, prøv igen.\n", + MessageBox::Ok); return false; } i++; } } - return regexpValidator() && luaValidator(); -} - -void MetaWidget::connectFrom(const char *signal, - const QObject *receiver, const char *method) -{ - connect(this, signal, receiver, method); -} - -void MetaWidget::connectTo(const QObject *sender, const char *signal, - const char *method) -{ - connect(sender, signal, this, method); + return true; } bool MetaWidget::setKeyboardFocus() @@ -169,7 +152,17 @@ void MetaWidget::reset() } } -void MetaWidget::setVisibility(bool visible) +void MetaWidget::setWdgValid(bool valid) { - setVisible(visible); + QPalette palette; + + if(valid) { + // valid string + palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); + } else { + // invalid string + palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); + } + + frame->setPalette(palette); } |