From 8dadd3a9f18b6d4e8884862658fe8a1d042f631c Mon Sep 17 00:00:00 2001 From: senator Date: Tue, 2 Oct 2007 10:09:37 +0000 Subject: misc minor changes for testing --- client/widgets/checkbox.cc | 14 +++++++++++++- client/widgets/frame.cc | 8 +++++--- client/widgets/frame.h | 4 ++-- client/widgets/label.cc | 16 +++++++++++----- client/widgets/lineedit.cc | 21 +++++++++++++++++---- client/widgets/pushbutton.cc | 17 ++++++++++++++--- client/widgets/pushbutton.h | 5 +++++ client/widgets/textedit.cc | 23 ++++++++++++++++++----- client/widgets/widget.cc | 5 +++++ client/widgets/widget.h | 1 + client/widgets/window.cc | 2 ++ 11 files changed, 93 insertions(+), 23 deletions(-) (limited to 'client') diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc index 1bb1cfe..3c73235 100644 --- a/client/widgets/checkbox.cc +++ b/client/widgets/checkbox.cc @@ -31,6 +31,14 @@ CheckBox::CheckBox(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("caption")) { setText(elem.attribute("caption")); } else { @@ -50,5 +58,9 @@ CheckBox::CheckBox(QDomNode node) QString CheckBox::getValue() { - return "Checkbox"; + if(checkState() == Qt::Unchecked) { + return "false"; + } else if(checkState() == Qt::Checked) { + return "true"; + } } diff --git a/client/widgets/frame.cc b/client/widgets/frame.cc index 508541d..bc72a2a 100644 --- a/client/widgets/frame.cc +++ b/client/widgets/frame.cc @@ -29,16 +29,18 @@ #include Frame::Frame(QDomNode node) - : QGroupBox(), Widget(node) + : QFrame(), Widget(node) { QDomElement elem = node.toElement(); + /* if(elem.hasAttribute("caption")) { setTitle(elem.attribute("caption")); } else { setTitle(elem.attribute("")); } - + */ + /* if(elem.hasAttribute("border")) { if(elem.attribute("border") == "true") { setFlat(false); @@ -48,7 +50,7 @@ Frame::Frame(QDomNode node) } else { setFlat(true); } - + */ if(elem.hasAttribute("layout")) { if(elem.attribute("layout") == "hbox") { QHBoxLayout *layout = new QHBoxLayout(); diff --git a/client/widgets/frame.h b/client/widgets/frame.h index fed9b1f..7753b83 100644 --- a/client/widgets/frame.h +++ b/client/widgets/frame.h @@ -28,10 +28,10 @@ #define __PRACRO_FRAME_H__ #include "widget.h" -#include +#include #include -class Frame : public QGroupBox, public Widget +class Frame : public QFrame, public Widget { public: diff --git a/client/widgets/label.cc b/client/widgets/label.cc index dd658d3..a9a78b4 100644 --- a/client/widgets/label.cc +++ b/client/widgets/label.cc @@ -33,11 +33,12 @@ Label::Label(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")) { - setMinimumWidth(elem.attribute("height").toInt()); + resize(width(), elem.attribute("height").toInt()); } if(elem.hasAttribute("caption")) { @@ -46,17 +47,22 @@ Label::Label(QDomNode node) setText(elem.attribute("")); } - if(elem.hasAttribute("align")) { - if(elem.attribute("align") == "left") { + // Check for horizontal alignment and set it up accordingly + if(elem.hasAttribute("alignment")) { + if(elem.attribute("alignment") == "left") { setAlignment(Qt::AlignLeft); - } else if (elem.attribute("align") == "center") { + } else if (elem.attribute("alignment") == "center") { setAlignment(Qt::AlignHCenter); - } else if (elem.attribute("align") == "right") { + } else if (elem.attribute("alignment") == "right") { setAlignment(Qt::AlignRight); } } else { setAlignment(Qt::AlignLeft); } + + // Always center vertically in the adressed space + setAlignment(Qt::AlignVCenter); + } QString Label::getValue() 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() diff --git a/client/widgets/pushbutton.cc b/client/widgets/pushbutton.cc index 5b424a5..0a01947 100644 --- a/client/widgets/pushbutton.cc +++ b/client/widgets/pushbutton.cc @@ -32,6 +32,14 @@ PushButton::PushButton(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("caption")) { setText(elem.attribute("caption")); } else { @@ -58,15 +66,18 @@ QString PushButton::getValue() void PushButton::commit() { - printf("committing...\n"); + emit act_commit(); + printf("Emit: commit\n"); } void PushButton::reset() { - printf("resetting...\n"); + emit act_reset(); + printf("Emit: reset\n"); } void PushButton::cancel() { - printf("cancelling...\n"); + emit act_cancel(); + printf("Emit: cancel\n"); } diff --git a/client/widgets/pushbutton.h b/client/widgets/pushbutton.h index 87c768d..b4fde52 100644 --- a/client/widgets/pushbutton.h +++ b/client/widgets/pushbutton.h @@ -46,6 +46,11 @@ public slots: void reset(); void cancel(); +signals: + void act_commit(); + void act_reset(); + void act_cancel(); + private: }; diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc index d1bd6e4..9334d8a 100644 --- a/client/widgets/textedit.cc +++ b/client/widgets/textedit.cc @@ -26,15 +26,24 @@ */ #include "textedit.h" #include +#include TextEdit::TextEdit(QDomNode node) : QTextEdit(), Widget(node) { - setAutoFillBackground(true); /* Default is false, which disables background - color manipulation.*/ + //setAutoFillBackground(true); /* Default is false, which disables background + // color manipulation.*/ 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()), this, SLOT(changed())); @@ -53,11 +62,11 @@ void TextEdit::changed() if(rx.exactMatch(QTextEdit::toPlainText())) { // 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); @@ -66,7 +75,11 @@ void TextEdit::changed() bool TextEdit::isValid() { - return valid; + if(rx.exactMatch(QTextEdit::toPlainText())) { + return true; + } else { + return false; + } } QString TextEdit::getValue() diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc index 7b62f36..5e811cb 100644 --- a/client/widgets/widget.cc +++ b/client/widgets/widget.cc @@ -46,3 +46,8 @@ QString Widget::getName() { return widget_name; } + +bool Widget::isValid() +{ + return true; +} diff --git a/client/widgets/widget.h b/client/widgets/widget.h index ab23ebf..09205b0 100644 --- a/client/widgets/widget.h +++ b/client/widgets/widget.h @@ -37,6 +37,7 @@ public: Widget(QDomNode node); virtual ~Widget(){} virtual QString getValue() = 0; + virtual bool isValid(); QString getName(); protected: diff --git a/client/widgets/window.cc b/client/widgets/window.cc index e93edca..8357c30 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -35,10 +35,12 @@ Window::Window(QDomNode node) if(elem.hasAttribute("width")) { setMinimumWidth(elem.attribute("width").toInt()); + resize(elem.attribute("width").toInt(), height()); } if(elem.hasAttribute("height")) { setMinimumHeight(elem.attribute("height").toInt()); + resize(width(), elem.attribute("height").toInt()); } if(elem.hasAttribute("fixed")) { -- cgit v1.2.3