summaryrefslogtreecommitdiff
path: root/client/widgets/textedit.cc
diff options
context:
space:
mode:
authordeva <deva>2008-06-02 13:03:33 +0000
committerdeva <deva>2008-06-02 13:03:33 +0000
commit322a83c48618b2f58e1014daff6f3956af8070ea (patch)
treeaa6124cd9f13ee2308e28d33175dc31eb1d34984 /client/widgets/textedit.cc
parentf9f04013fca46fa256664bbf1f983c966f253400 (diff)
A large number of small changes in widgets, primarily validation oriented.
Diffstat (limited to 'client/widgets/textedit.cc')
-rw-r--r--client/widgets/textedit.cc24
1 files changed, 4 insertions, 20 deletions
diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc
index 28ca010..e217cc6 100644
--- a/client/widgets/textedit.cc
+++ b/client/widgets/textedit.cc
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <QPalette>
-TextEdit::TextEdit(QDomNode node)
+TextEdit::TextEdit(QDomNode &node)
: QTextEdit(), Widget(node)
{
//setAutoFillBackground(true); /* Default is false, which disables background
@@ -37,23 +37,19 @@ TextEdit::TextEdit(QDomNode 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()), this, SLOT(changed()));
- }
+ connect(this, SIGNAL(textChanged()), this, SLOT(changed()));
if(elem.hasAttribute("value")) {
setText(elem.attribute("value"));
} else {
+ setText(" ");
setText("");
}
}
@@ -62,26 +58,14 @@ void TextEdit::changed()
{
QPalette palette;
- if(rx.exactMatch(QTextEdit::toPlainText())) {
+ 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);
- //printf("%s\n", text.toStdString().c_str());
-}
-
-bool TextEdit::isValid()
-{
- if(rx.exactMatch(QTextEdit::toPlainText())) {
- return true;
- } else {
- return false;
- }
}
QString TextEdit::getValue()