summaryrefslogtreecommitdiff
path: root/client/widgets/lineedit.cc
diff options
context:
space:
mode:
authorsenator <senator>2007-07-26 13:10:25 +0000
committersenator <senator>2007-07-26 13:10:25 +0000
commite1bbdd89f09966a240e8a7b8007dc44895e0febd (patch)
tree0e990d7a9df1d7c2fc53aaee0bc52990a6607b60 /client/widgets/lineedit.cc
parentce667bf4b2f3de7aab677ac7e7f23bc72d3db80f (diff)
added error check for unnamed widgets
Diffstat (limited to 'client/widgets/lineedit.cc')
-rw-r--r--client/widgets/lineedit.cc21
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());
}