summaryrefslogtreecommitdiff
path: root/client/widgets/lineedit.cc
diff options
context:
space:
mode:
authorsenator <senator>2007-10-02 10:09:37 +0000
committersenator <senator>2007-10-02 10:09:37 +0000
commit8dadd3a9f18b6d4e8884862658fe8a1d042f631c (patch)
treee28c16aafcfdb9c76cdc34aeb5c9b1cbdd5d9bbe /client/widgets/lineedit.cc
parent9910c8962ab813ab7d9a04609b689e1d9ae038e0 (diff)
misc minor changes for testing
Diffstat (limited to 'client/widgets/lineedit.cc')
-rw-r--r--client/widgets/lineedit.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc
index 6c3264b..cb53571 100644
--- a/client/widgets/lineedit.cc
+++ b/client/widgets/lineedit.cc
@@ -32,6 +32,14 @@ LineEdit::LineEdit(QDomNode node)
{
QDomElement elem = node.toElement();
+ if(elem.hasAttribute("width")) {
+ resize(elem.attribute("width").toInt(), height());
+ }
+
+ if(elem.hasAttribute("height")) {
+ resize(width(), elem.attribute("height").toInt());
+ }
+
if(elem.hasAttribute("regexp")) {
rx = QRegExp(elem.attribute("regexp"));
connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed(QString)));
@@ -40,6 +48,8 @@ LineEdit::LineEdit(QDomNode node)
if(elem.hasAttribute("value")) {
setText(elem.attribute("value"));
} else {
+ // This is a hack to force correct background color according to regexp
+ setText(" ");
setText("");
}
}
@@ -50,20 +60,23 @@ void LineEdit::changed(QString new_text)
if(rx.exactMatch(new_text)) {
// valid string
- palette.setBrush(backgroundRole(), QBrush(QColor(255, 255, 255)));
+ palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255)));
valid = true;
} else {
// invalid string
- palette.setBrush(backgroundRole(), QBrush(QColor(230, 200, 200)));
+ palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200)));
valid = false;
}
setPalette(palette);
- //printf("%s\n", text.toStdString().c_str());
}
bool LineEdit::isValid()
{
- return valid;
+ if(rx.exactMatch(text())) {
+ return true;
+ } else {
+ return false;
+ }
}
QString LineEdit::getValue()