diff options
author | senator <senator> | 2007-07-23 07:40:05 +0000 |
---|---|---|
committer | senator <senator> | 2007-07-23 07:40:05 +0000 |
commit | 22de7bf19fb6fcce8d11c0e01afdfafa2a8c00d6 (patch) | |
tree | b841931e88a673e04a26f2709066c018d9df4f68 /client | |
parent | d614b0436f0ce1f060fc80b987ca4209f17c221e (diff) |
porting widgets to use QDomNodes
Diffstat (limited to 'client')
-rw-r--r-- | client/widgets/frame.cc | 5 | ||||
-rw-r--r-- | client/widgets/frame.h | 3 | ||||
-rw-r--r-- | client/widgets/label.cc | 11 | ||||
-rw-r--r-- | client/widgets/label.h | 3 | ||||
-rw-r--r-- | client/widgets/lineedit.cc | 19 | ||||
-rw-r--r-- | client/widgets/lineedit.h | 5 | ||||
-rw-r--r-- | client/widgets/radiobutton.cc | 20 | ||||
-rw-r--r-- | client/widgets/radiobutton.h | 3 |
8 files changed, 45 insertions, 24 deletions
diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc index 285619a..0ea7d25 100644 --- a/client/widgets/frame.cc +++ b/client/widgets/frame.cc @@ -26,9 +26,10 @@ */ #include "frame.h" -Frame::Frame(QWidget *parent, QString caption) : QGroupBox(parent) +Frame::Frame(QDomNode node) : QGroupBox() { - setTitle(caption); + QDomElement elem = node.toElement(); + setTitle(elem.attribute("caption")); } QString Frame::getValue() diff --git a/client/widgets/frame.h b/client/widgets/frame.h index 73bf704..f934269 100644 --- a/client/widgets/frame.h +++ b/client/widgets/frame.h @@ -29,12 +29,13 @@ #include "widget.h" #include <QGroupBox> +#include <QDomNode> class Frame : public Widget, public QGroupBox { public: - Frame(QWidget *parent, QString caption); + Frame(QDomNode node); public slots: QString getValue(); diff --git a/client/widgets/label.cc b/client/widgets/label.cc index 377fd10..b30d1cb 100644 --- a/client/widgets/label.cc +++ b/client/widgets/label.cc @@ -27,15 +27,16 @@ #include "label.h" #include <stdio.h> -Label::Label(QWidget *parent, QString text, QString align) : QLabel(parent) +Label::Label(QDomNode node) : QLabel(NULL) { - setText(text); + QDomElement elem = node.toElement(); + setText(elem.attribute("caption")); - if(align == "left") { + if(elem.attribute("align") == "left") { setAlignment(Qt::AlignLeft); - } else if (align == "center") { + } else if (elem.attribute("align") == "center") { setAlignment(Qt::AlignHCenter); - } else if (align == "right") { + } else if (elem.attribute("align") == "right") { setAlignment(Qt::AlignRight); } } diff --git a/client/widgets/label.h b/client/widgets/label.h index 3138ce1..78376dd 100644 --- a/client/widgets/label.h +++ b/client/widgets/label.h @@ -29,6 +29,7 @@ #include <QWidget> #include <QLabel> +#include <QDomNode> class Label : public QLabel { @@ -36,7 +37,7 @@ class Label : public QLabel Q_OBJECT public: - Label(QWidget *parent, QString text, QString align); + Label(QDomNode node); public slots: diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 0a16947..686791d 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -27,16 +27,17 @@ #include "lineedit.h" #include <stdio.h> -LineEdit::LineEdit(QWidget *parent, QString reg_exp) : QLineEdit(parent) +LineEdit::LineEdit(QDomNode node) : QLineEdit() { - widget_name = "widget_name"; - - rx = QRegExp(reg_exp); - //validator = new QRegExpValidator(rx, this); - //setValidator(validator); - changed(""); - + QDomElement elem = node.toElement(); + rx = QRegExp(elem.attribute("regexp")); connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed(QString))); + + if(elem.hasAttribute("value")) { + setText(elem.attribute("value")); + } else { + setText(""); + } } void LineEdit::changed(QString text) @@ -49,7 +50,7 @@ void LineEdit::changed(QString text) valid = true; } else { // invalid string - palette.setBrush(backgroundRole(), QBrush(QColor(220, 150, 150))); + palette.setBrush(backgroundRole(), QBrush(QColor(230, 200, 200))); valid = false; } setPalette(palette); diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h index 45af6f3..247a562 100644 --- a/client/widgets/lineedit.h +++ b/client/widgets/lineedit.h @@ -30,7 +30,7 @@ #include "widget.h" #include <QLineEdit> #include <QWidget> -#include <QValidator> +#include <QDomNode> class LineEdit : public QLineEdit, public Widget { @@ -38,7 +38,7 @@ class LineEdit : public QLineEdit, public Widget Q_OBJECT public: - LineEdit(QWidget *parent, QString reg_exp = "*"); + LineEdit(QDomNode node); bool isValid(); public slots: @@ -46,7 +46,6 @@ public slots: QString getValue(); private: - QValidator *validator; QRegExp rx; bool valid; diff --git a/client/widgets/radiobutton.cc b/client/widgets/radiobutton.cc index cad1ebf..89f9f4f 100644 --- a/client/widgets/radiobutton.cc +++ b/client/widgets/radiobutton.cc @@ -26,9 +26,25 @@ */ #include "radiobutton.h" -RadioButton::RadioButton(QWidget *parent) : QRadioButton(parent) +RadioButton::RadioButton(QDomNode node) : QRadioButton() { - setText("Radio button"); + QDomElement elem = node.toElement(); + + if(elem.hasAttribute("caption")) { + setText(elem.attribute("caption")); + } else { + setText(""); + } + + if(elem.hasAttribute("value")) { + if(elem.attribute("value") == "true") { + setChecked(true); + } else if(elem.attribute("value") == "false") { + setChecked(false); + } + } else { + setChecked(false); + } } QString RadioButton::getValue() diff --git a/client/widgets/radiobutton.h b/client/widgets/radiobutton.h index 65a87c7..6239c3f 100644 --- a/client/widgets/radiobutton.h +++ b/client/widgets/radiobutton.h @@ -29,12 +29,13 @@ #include "widget.h" #include <QRadioButton> +#include <QDomNode> class RadioButton : public Widget, public QRadioButton { public: - RadioButton(QWidget *parent); + RadioButton(QDomNode); public slots: QString getValue(); |