summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/checkbox.cc25
-rw-r--r--client/widgets/frame.cc9
-rw-r--r--client/widgets/label.cc17
-rw-r--r--client/widgets/lineedit.cc21
-rw-r--r--client/widgets/pushbutton.cc43
-rw-r--r--client/widgets/radiobutton.cc9
-rw-r--r--client/widgets/textedit.cc81
-rw-r--r--client/widgets/window.cc11
8 files changed, 197 insertions, 19 deletions
diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc
index 33cd9d1..c04b104 100644
--- a/client/widgets/checkbox.cc
+++ b/client/widgets/checkbox.cc
@@ -29,12 +29,27 @@
CheckBox::CheckBox(QDomNode node) : QCheckBox()
{
QDomElement elem = node.toElement();
- widget_name = elem.attribute("name");
- setText(elem.attribute("caption"));
- if(elem.attribute("value") == "true") {
- setChecked(true);
- } else if (elem.attribute("value") == "false") {
+ 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("caption")) {
+ setText(elem.attribute("caption"));
+ } else {
+ setText(elem.attribute(""));
+ }
+
+ if(elem.hasAttribute("value")) {
+ if(elem.attribute("value") == "true") {
+ setChecked(true);
+ } else if (elem.attribute("value") == "false") {
+ setChecked(false);
+ }
+ } else {
setChecked(false);
}
}
diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc
index b993f9a..d700b1b 100644
--- a/client/widgets/frame.cc
+++ b/client/widgets/frame.cc
@@ -29,7 +29,14 @@
Frame::Frame(QDomNode node) : QGroupBox()
{
QDomElement elem = node.toElement();
- widget_name = elem.attribute("name");
+
+ if(elem.hasAttribute("name")) {
+ widget_name = elem.attribute("name");
+ } else {
+ printf("XML ERROR!! Unnamed widget of type: %s\n",
+ elem.tagName().toStdString().c_str());
+ }
+
setTitle(elem.attribute("caption"));
}
diff --git a/client/widgets/label.cc b/client/widgets/label.cc
index b6f93b5..b1875e4 100644
--- a/client/widgets/label.cc
+++ b/client/widgets/label.cc
@@ -30,8 +30,19 @@
Label::Label(QDomNode node) : QLabel()
{
QDomElement elem = node.toElement();
- widget_name = elem.attribute("name");
- setText(elem.attribute("caption"));
+
+ 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("caption")) {
+ setText(elem.attribute("caption"));
+ } else {
+ setText(elem.attribute(""));
+ }
if(elem.hasAttribute("align")) {
if(elem.attribute("align") == "left") {
@@ -41,6 +52,8 @@ Label::Label(QDomNode node) : QLabel()
} else if (elem.attribute("align") == "right") {
setAlignment(Qt::AlignRight);
}
+ } else {
+ setAlignment(Qt::AlignLeft);
}
}
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());
}
diff --git a/client/widgets/pushbutton.cc b/client/widgets/pushbutton.cc
index 5a1e305..7c78cfd 100644
--- a/client/widgets/pushbutton.cc
+++ b/client/widgets/pushbutton.cc
@@ -30,12 +30,49 @@
PushButton::PushButton(QDomNode node) : QPushButton()
{
QDomElement elem = node.toElement();
- widget_name = elem.attribute("name");
- setText(elem.attribute("caption"));
- //connect(this, SIGNAL(onClicked()), this, SLOT(clicked()));
+
+ 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("caption")) {
+ setText(elem.attribute("caption"));
+ } else {
+ setText("");
+ }
+
+ if(elem.hasAttribute("action")) {
+ if(elem.attribute("action") == "commit") {
+ connect(this, SIGNAL(clicked()), this, SLOT(commit()));
+ } else if(elem.attribute("action") == "reset") {
+ connect(this, SIGNAL(clicked()), this, SLOT(reset()));
+ } else if(elem.attribute("action") == "cancel") {
+ connect(this, SIGNAL(clicked()), this, SLOT(cancel()));
+ }
+ } else {
+ setEnabled(false);
+ }
}
QString PushButton::getValue()
{
return text();
}
+
+void PushButton::commit()
+{
+ printf("committing...\n");
+}
+
+void PushButton::reset()
+{
+ printf("resetting...\n");
+}
+
+void PushButton::cancel()
+{
+ printf("cancelling...\n");
+}
diff --git a/client/widgets/radiobutton.cc b/client/widgets/radiobutton.cc
index 55e3379..af34de6 100644
--- a/client/widgets/radiobutton.cc
+++ b/client/widgets/radiobutton.cc
@@ -29,7 +29,14 @@
RadioButton::RadioButton(QDomNode node) : QRadioButton()
{
QDomElement elem = node.toElement();
- widget_name = elem.attribute("name");
+
+ 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("caption")) {
setText(elem.attribute("caption"));
} else {
diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc
new file mode 100644
index 0000000..1d1babe
--- /dev/null
+++ b/client/widgets/textedit.cc
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/***************************************************************************
+ * textedit.cc
+ *
+ * Fri Jul 13 12:38:45 CEST 2007
+ * Copyright 2007 Bent Bisballe Nyeng, Lars Bisballe Jensen and Peter Skaarup
+ * deva@aasimon.org, elsenator@gmail.com and piparum@piparum.dk
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "textedit.h"
+#include <stdio.h>
+
+TextEdit::TextEdit(QDomNode node) : QTextEdit()
+{
+ setAutoFillBackground(true); /* Default is false, which disables background
+ color manipulation.*/
+
+ QDomElement elem = node.toElement();
+
+ 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()), this, SLOT(changed()));
+ }
+
+ if(elem.hasAttribute("value")) {
+ setText(elem.attribute("value"));
+ } else {
+ setText("");
+ }
+}
+
+void TextEdit::changed()
+{
+ QPalette palette;
+
+ if(rx.exactMatch(QTextEdit::toPlainText())) {
+ // valid string
+ palette.setBrush(backgroundRole(), QBrush(QColor(255, 255, 255)));
+ valid = true;
+ } else {
+ // invalid string
+ palette.setBrush(backgroundRole(), QBrush(QColor(230, 200, 200)));
+ valid = false;
+ }
+ setPalette(palette);
+ //printf("%s\n", text.toStdString().c_str());
+}
+
+bool TextEdit::isValid()
+{
+ return valid;
+}
+
+QString TextEdit::getValue()
+{
+ return QTextEdit::toPlainText();
+}
diff --git a/client/widgets/window.cc b/client/widgets/window.cc
index 95f01a6..217bf21 100644
--- a/client/widgets/window.cc
+++ b/client/widgets/window.cc
@@ -33,7 +33,8 @@ Window::Window(QDomNode node) : QWidget(NULL)
if(elem.hasAttribute("name")) {
widget_name = elem.attribute("name");
} else {
- printf("ERROR!! Widget has no name...\n");
+ printf("XML ERROR!! Unnamed widget of type: %s\n",
+ elem.tagName().toStdString().c_str());
}
if(elem.hasAttribute("width")) {
@@ -44,8 +45,16 @@ Window::Window(QDomNode node) : QWidget(NULL)
setMinimumHeight(elem.attribute("height").toInt());
}
+ if(elem.hasAttribute("fixed")) {
+ if(elem.attribute("fixed") == "true") {
+ setFixedSize(width(), height());
+ }
+ }
+
if(elem.hasAttribute("caption")) {
setWindowTitle(elem.attribute("caption"));
+ } else {
+ setWindowTitle(elem.attribute(""));
}
}