summaryrefslogtreecommitdiff
path: root/client/widgets/checkgroupbox.cc
diff options
context:
space:
mode:
authordeva <deva>2011-04-04 09:17:03 +0000
committerdeva <deva>2011-04-04 09:17:03 +0000
commit46683949163047405c55efc42fdd3c79e96cde0d (patch)
treec60229ebf98f96115a8479440011955689909806 /client/widgets/checkgroupbox.cc
parentf86e3fa5d2333116b435cb7fd7bbfeb699483d12 (diff)
Fix journal view scrollbar jumpiness. Fix scroll to view on open of new macro. Added new attribute 'type' to checkgroupbox.
Diffstat (limited to 'client/widgets/checkgroupbox.cc')
-rw-r--r--client/widgets/checkgroupbox.cc89
1 files changed, 67 insertions, 22 deletions
diff --git a/client/widgets/checkgroupbox.cc b/client/widgets/checkgroupbox.cc
index 7204418..07b7632 100644
--- a/client/widgets/checkgroupbox.cc
+++ b/client/widgets/checkgroupbox.cc
@@ -28,29 +28,59 @@
#include "checkgroupbox.h"
#include <QGroupBox>
+#include <QCheckBox>
+
+#include <QHBoxLayout>
#include "common.h"
+#include "debug.h"
CheckGroupBox::CheckGroupBox(QDomNode &node, MacroWindow *macrowindow)
: Widget(node, macrowindow)
{
- //
- // From GroupBox
- //
- groupbox = new QGroupBox();
- groupbox->setCheckable(true);
- widget = groupbox;
+ QDomElement elem = node.toElement();
- setCommonAttributes(groupbox, node);
- setCommonLayout(groupbox, node);
+ type = elem.attribute("type", "framed");
+
+ checkbox = NULL;
+ groupbox = NULL;
- QDomElement elem = node.toElement();
+ if(type == "framed") {
+ groupbox = new QGroupBox();
+ groupbox->setCheckable(true);
+ connect(groupbox, SIGNAL(toggled(bool)), this, SLOT(state_change(bool)));
+ widget = groupbox;
- if(elem.hasAttribute("caption")) {
- groupbox->setTitle(elem.attribute("caption"));
- }
+ if(elem.hasAttribute("caption")) {
+ groupbox->setTitle(elem.attribute("caption"));
+ }
+
+ setCommonAttributes(widget, node);
+ setCommonLayout(widget, node);
- addChildren(node, groupbox->layout());
+ addChildren(node, widget->layout());
+
+ } else if(type == "simple") {
+ widget = new QWidget();
+ QHBoxLayout *l = new QHBoxLayout();
+ widget->setLayout(l);
+ checkbox = new QCheckBox();
+ connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(state_change(bool)));
+ if(elem.hasAttribute("caption")) {
+ checkbox->setText(elem.attribute("caption"));
+ }
+ l->addWidget(checkbox);
+ container = new QWidget();
+ l->addWidget(container);
+
+ setCommonAttributes(widget, node);
+ setCommonLayout(container, node);
+
+ addChildren(node, container->layout());
+
+ } else {
+ ERROR(checkgroupbox, "Illigal value of attribute 'type'\n");
+ }
//
// From CheckBox
@@ -68,8 +98,6 @@ CheckGroupBox::CheckGroupBox(QDomNode &node, MacroWindow *macrowindow)
} else {
falsevalue = "false";
}
-
- connect(groupbox, SIGNAL(toggled(bool)), this, SLOT(state_change(bool)));
}
CheckGroupBox::~CheckGroupBox()
@@ -79,7 +107,8 @@ CheckGroupBox::~CheckGroupBox()
QString CheckGroupBox::value()
{
- if(groupbox->isChecked()) return truevalue;
+ if(groupbox && groupbox->isChecked()) return truevalue;
+ if(checkbox && checkbox->isChecked()) return truevalue;
return falsevalue;
}
@@ -89,28 +118,43 @@ void CheckGroupBox::setValue(QString value, QString source)
changedByUser = false;
- bool old = groupbox->isChecked();
+ bool old = false;
+ if(groupbox) old = groupbox->isChecked();
+ if(checkbox) old = checkbox->isChecked();
if(value == truevalue) {
- groupbox->setChecked(true);
+ if(groupbox) groupbox->setChecked(true);
+ if(checkbox) {
+ checkbox->setChecked(true);
+ container->setEnabled(true);
+ }
} else if(value == falsevalue) {
- groupbox->setChecked(false);
+ if(groupbox) groupbox->setChecked(false);
+ if(checkbox) {
+ checkbox->setChecked(false);
+ container->setEnabled(false);
+ }
} else {
printf("Unknown checkbox value: %s\n", value.toStdString().c_str());
}
// If set operation did not change the value we must invocate the code manually.
- if(old == groupbox->isChecked()) state_change(0);
+ if(groupbox && old == groupbox->isChecked()) state_change(old);
+ if(checkbox && old == checkbox->isChecked()) state_change(old);
// setInitialValue(value);
changedByUser = true;
}
-void CheckGroupBox::state_change(bool)
+void CheckGroupBox::state_change(bool state)
{
emit eventOnChange();
if(changedByUser) emit wasChanged();
+
+ if(checkbox) {
+ container->setEnabled(state);
+ }
}
bool CheckGroupBox::checked()
@@ -135,7 +179,8 @@ void CheckGroupBox::setWdgValid(bool valid)
palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200)));
}
- groupbox->setPalette(palette);
+ if(groupbox) groupbox->setPalette(palette);
+ if(checkbox) checkbox->setPalette(palette);
}
bool CheckGroupBox::setKeyboardFocus()