summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorsenator <senator>2007-07-25 09:11:31 +0000
committersenator <senator>2007-07-25 09:11:31 +0000
commitce667bf4b2f3de7aab677ac7e7f23bc72d3db80f (patch)
tree760a18ca48e59274553ca6c211c08770f031ad56 /client
parent22de7bf19fb6fcce8d11c0e01afdfafa2a8c00d6 (diff)
migrated all widgets to use QDomNodes; Implemented the getName functionality
Diffstat (limited to 'client')
-rw-r--r--client/widgets/checkbox.cc12
-rw-r--r--client/widgets/checkbox.h3
-rw-r--r--client/widgets/frame.cc1
-rw-r--r--client/widgets/label.cc22
-rw-r--r--client/widgets/label.h4
-rw-r--r--client/widgets/lineedit.cc3
-rw-r--r--client/widgets/pushbutton.cc6
-rw-r--r--client/widgets/pushbutton.h6
-rw-r--r--client/widgets/radiobutton.cc2
-rw-r--r--client/widgets/window.cc19
10 files changed, 60 insertions, 18 deletions
diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc
index ae9f143..33cd9d1 100644
--- a/client/widgets/checkbox.cc
+++ b/client/widgets/checkbox.cc
@@ -26,9 +26,17 @@
*/
#include "checkbox.h"
-CheckBox::CheckBox(QWidget *parent) : QCheckBox(parent)
+CheckBox::CheckBox(QDomNode node) : QCheckBox()
{
- setText("Checkbox");
+ 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") {
+ setChecked(false);
+ }
}
QString CheckBox::getValue()
diff --git a/client/widgets/checkbox.h b/client/widgets/checkbox.h
index df59014..94905f2 100644
--- a/client/widgets/checkbox.h
+++ b/client/widgets/checkbox.h
@@ -28,13 +28,14 @@
#define __PRACRO_CHECKBOX_H__
#include "widget.h"
+#include <QDomNode>
#include <QCheckBox>
class CheckBox : public Widget, public QCheckBox
{
public:
- CheckBox(QWidget *parent);
+ CheckBox(QDomNode node);
public slots:
QString getValue();
diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc
index 0ea7d25..b993f9a 100644
--- a/client/widgets/frame.cc
+++ b/client/widgets/frame.cc
@@ -29,6 +29,7 @@
Frame::Frame(QDomNode node) : QGroupBox()
{
QDomElement elem = node.toElement();
+ widget_name = elem.attribute("name");
setTitle(elem.attribute("caption"));
}
diff --git a/client/widgets/label.cc b/client/widgets/label.cc
index b30d1cb..b6f93b5 100644
--- a/client/widgets/label.cc
+++ b/client/widgets/label.cc
@@ -27,16 +27,24 @@
#include "label.h"
#include <stdio.h>
-Label::Label(QDomNode node) : QLabel(NULL)
+Label::Label(QDomNode node) : QLabel()
{
QDomElement elem = node.toElement();
+ widget_name = elem.attribute("name");
setText(elem.attribute("caption"));
- if(elem.attribute("align") == "left") {
- setAlignment(Qt::AlignLeft);
- } else if (elem.attribute("align") == "center") {
- setAlignment(Qt::AlignHCenter);
- } else if (elem.attribute("align") == "right") {
- setAlignment(Qt::AlignRight);
+ if(elem.hasAttribute("align")) {
+ if(elem.attribute("align") == "left") {
+ setAlignment(Qt::AlignLeft);
+ } else if (elem.attribute("align") == "center") {
+ setAlignment(Qt::AlignHCenter);
+ } else if (elem.attribute("align") == "right") {
+ setAlignment(Qt::AlignRight);
+ }
}
}
+
+QString Label::getValue()
+{
+ return text();
+}
diff --git a/client/widgets/label.h b/client/widgets/label.h
index 78376dd..5393992 100644
--- a/client/widgets/label.h
+++ b/client/widgets/label.h
@@ -27,11 +27,12 @@
#ifndef __PRACRO_LABEL_H__
#define __PRACRO_LABEL_H__
+#include "widget.h"
#include <QWidget>
#include <QLabel>
#include <QDomNode>
-class Label : public QLabel
+class Label : public QLabel, public Widget
{
Q_OBJECT
@@ -40,6 +41,7 @@ public:
Label(QDomNode node);
public slots:
+ QString getValue();
private:
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc
index 686791d..d50ec6b 100644
--- a/client/widgets/lineedit.cc
+++ b/client/widgets/lineedit.cc
@@ -30,6 +30,7 @@
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)));
@@ -54,7 +55,7 @@ void LineEdit::changed(QString text)
valid = false;
}
setPalette(palette);
- printf("%s\n", text.toStdString().c_str());
+ //printf("%s\n", text.toStdString().c_str());
}
bool LineEdit::isValid()
diff --git a/client/widgets/pushbutton.cc b/client/widgets/pushbutton.cc
index 88fcf61..5a1e305 100644
--- a/client/widgets/pushbutton.cc
+++ b/client/widgets/pushbutton.cc
@@ -27,9 +27,11 @@
#include "pushbutton.h"
#include <stdio.h>
-PushButton::PushButton(QWidget *parent, QString caption, QString type) : QPushButton(parent)
+PushButton::PushButton(QDomNode node) : QPushButton()
{
- setText(caption);
+ QDomElement elem = node.toElement();
+ widget_name = elem.attribute("name");
+ setText(elem.attribute("caption"));
//connect(this, SIGNAL(onClicked()), this, SLOT(clicked()));
}
diff --git a/client/widgets/pushbutton.h b/client/widgets/pushbutton.h
index 3fc334f..a64568f 100644
--- a/client/widgets/pushbutton.h
+++ b/client/widgets/pushbutton.h
@@ -30,7 +30,7 @@
#include "widget.h"
#include <QPushButton>
#include <QWidget>
-//#include <QValidator>
+#include <QDomNode>
class PushButton : public QPushButton, public Widget
{
@@ -38,10 +38,10 @@ class PushButton : public QPushButton, public Widget
Q_OBJECT
public:
- PushButton(QWidget *parent, QString caption = "*", QString type = "*");
- QString getValue();
+ PushButton(QDomNode node);
public slots:
+ QString getValue();
private:
diff --git a/client/widgets/radiobutton.cc b/client/widgets/radiobutton.cc
index 89f9f4f..55e3379 100644
--- a/client/widgets/radiobutton.cc
+++ b/client/widgets/radiobutton.cc
@@ -29,7 +29,7 @@
RadioButton::RadioButton(QDomNode node) : QRadioButton()
{
QDomElement elem = node.toElement();
-
+ widget_name = elem.attribute("name");
if(elem.hasAttribute("caption")) {
setText(elem.attribute("caption"));
} else {
diff --git a/client/widgets/window.cc b/client/widgets/window.cc
index 657b62c..95f01a6 100644
--- a/client/widgets/window.cc
+++ b/client/widgets/window.cc
@@ -28,6 +28,25 @@
Window::Window(QDomNode node) : QWidget(NULL)
{
+ QDomElement elem = node.toElement();
+
+ if(elem.hasAttribute("name")) {
+ widget_name = elem.attribute("name");
+ } else {
+ printf("ERROR!! Widget has no name...\n");
+ }
+
+ if(elem.hasAttribute("width")) {
+ setMinimumWidth(elem.attribute("width").toInt());
+ }
+
+ if(elem.hasAttribute("height")) {
+ setMinimumHeight(elem.attribute("height").toInt());
+ }
+
+ if(elem.hasAttribute("caption")) {
+ setWindowTitle(elem.attribute("caption"));
+ }
}
QString Window::getValue()