diff options
Diffstat (limited to 'client/widgets/lineedit.cc')
-rw-r--r-- | client/widgets/lineedit.cc | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 83f8d3e..26c2760 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -27,25 +27,20 @@ #include "lineedit.h" #include <stdio.h> -LineEdit::LineEdit(QDomNode node) +LineEdit::LineEdit(QDomNode &node) : QLineEdit(), Widget(node) { QDomElement elem = node.toElement(); if(elem.hasAttribute("width")) { - //resize(elem.attribute("width").toInt(), height()); setMinimumWidth(elem.attribute("width").toInt()); } if(elem.hasAttribute("height")) { - //resize(width(), elem.attribute("height").toInt()); setMinimumHeight(elem.attribute("height").toInt()); } - if(elem.hasAttribute("regexp")) { - rx = QRegExp(elem.attribute("regexp")); - connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed(QString))); - } + connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed())); if(elem.hasAttribute("value")) { setText(elem.attribute("value")); @@ -56,29 +51,19 @@ LineEdit::LineEdit(QDomNode node) } } -void LineEdit::changed(QString new_text) +void LineEdit::changed() { QPalette palette; - if(rx.exactMatch(new_text)) { + if(regexpValidator()) { // valid string palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); - valid = true; } else { // invalid string palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); - valid = false; } - setPalette(palette); -} -bool LineEdit::isValid() -{ - if(rx.exactMatch(text())) { - return true; - } else { - return false; - } + setPalette(palette); } QString LineEdit::getValue() |