diff options
Diffstat (limited to 'client/widgets/lineedit.cc')
-rw-r--r-- | client/widgets/lineedit.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index d50ec6b..62e1aa8 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -30,9 +30,18 @@ LineEdit::LineEdit(QDomNode node) : QLineEdit() { QDomElement elem = node.toElement(); - widget_name = elem.attribute("name"); - rx = QRegExp(elem.attribute("regexp")); - connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed(QString))); + + if(elem.hasAttribute("name")) { + widget_name = elem.attribute("name"); + } else { + printf("XML ERROR!! Unnamed widget of type: %s\n", + elem.tagName().toStdString().c_str()); + } + + if(elem.hasAttribute("regexp")) { + rx = QRegExp(elem.attribute("regexp")); + connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed(QString))); + } if(elem.hasAttribute("value")) { setText(elem.attribute("value")); @@ -41,11 +50,11 @@ LineEdit::LineEdit(QDomNode node) : QLineEdit() } } -void LineEdit::changed(QString text) +void LineEdit::changed(QString new_text) { QPalette palette; - if(rx.exactMatch(text)) { + if(rx.exactMatch(new_text)) { // valid string palette.setBrush(backgroundRole(), QBrush(QColor(255, 255, 255))); valid = true; @@ -54,7 +63,7 @@ void LineEdit::changed(QString text) palette.setBrush(backgroundRole(), QBrush(QColor(230, 200, 200))); valid = false; } - setPalette(palette); + setPalette(palette); //printf("%s\n", text.toStdString().c_str()); } |