summaryrefslogtreecommitdiff
path: root/client/widgets/radiobuttons.cc
diff options
context:
space:
mode:
authordeva <deva>2010-08-12 10:57:04 +0000
committerdeva <deva>2010-08-12 10:57:04 +0000
commitd9338083192084613e5530b02710b796252d342b (patch)
treee0ec2b36e0de62328e5fd5d3b597f6ee71d1b18f /client/widgets/radiobuttons.cc
parentdbab8458dcce186e7eb7a114a83f759d7db5445a (diff)
New scripting system part2.
Diffstat (limited to 'client/widgets/radiobuttons.cc')
-rw-r--r--client/widgets/radiobuttons.cc102
1 files changed, 37 insertions, 65 deletions
diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc
index e4555ff..7f1bda7 100644
--- a/client/widgets/radiobuttons.cc
+++ b/client/widgets/radiobuttons.cc
@@ -25,18 +25,23 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "radiobuttons.h"
-#include "radiobutton.h"
-#include <QRadioButton>
+
+#include <QEvent>
#include <QHBoxLayout>
#include <QVBoxLayout>
+#include <QFrame>
#include "common.h"
+#include "radiobutton.h"
RadioButtons::RadioButtons(QDomNode &node, MacroWindow *macrowindow)
- : QFrame(), Widget(node, macrowindow)
+ : Widget(node, macrowindow)
{
- setCommonAttributes(this, node);
- setCommonLayout(this, node);
+ frame = new QFrame();
+ widget = frame;
+
+ setCommonAttributes(frame, node);
+ setCommonLayout(frame, node);
QDomNodeList children = node.childNodes();
@@ -46,17 +51,22 @@ RadioButtons::RadioButtons(QDomNode &node, MacroWindow *macrowindow)
RadioButton *radiobutton = new RadioButton(child);
// Create radiobutton from child, insert in this
- layout()->addWidget(radiobutton);
+ frame->layout()->addWidget(radiobutton);
connect(radiobutton, SIGNAL(clicked()), this, SLOT(childChanged()));
radiobutton_list.push_back(radiobutton);
}
- layout()->setContentsMargins(0,0,0,0);
+ frame->layout()->setContentsMargins(0,0,0,0);
}
-bool RadioButtons::setBGColor(bool valid)
+RadioButtons::~RadioButtons()
+{
+ // delete frame;
+}
+
+void RadioButtons::setWdgValid(bool valid)
{
QPalette palette;
@@ -72,35 +82,32 @@ bool RadioButtons::setBGColor(bool valid)
RadioButton *widget = *i;
widget->setPalette(palette);
}
-
- return valid;
}
-bool RadioButtons::isValid()
+bool RadioButtons::preValid()
{
- if(!regexpValidator()) return setBGColor(false);
- if(!luaValidator()) return setBGColor(false);
-
QVector< RadioButton* >::iterator i;
for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) {
- RadioButton *widget = *i;
- if(widget->isChecked()) {
- return setBGColor(true);
+ RadioButton *rbtn = *i;
+ if(rbtn->isChecked()) {
+ return true;
}
}
-
- return setBGColor(false);
+ return false;
}
-QString RadioButtons::getValue()
+QString RadioButtons::value()
{
QVector< RadioButton* >::iterator i;
QString value;
for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) {
- RadioButton *widget = *i;
- if(widget->isChecked()) {
- printf("Radiobutton returned: %s\n", widget->getValue().toStdString().c_str());
- value = widget->getValue();
+ RadioButton *rbtn = *i;
+ if(rbtn->isChecked()) {
+ /*
+ printf("Radiobutton returned: %s\n",
+ rbtn->getValue().toStdString().c_str());
+ */
+ value = rbtn->getValue();
}
}
return value;
@@ -112,29 +119,15 @@ void RadioButtons::setValue(QString value, QString source)
QVector< RadioButton* >::iterator i;
for (i = radiobutton_list.begin(); i != radiobutton_list.end(); ++i) {
- RadioButton *widget = *i;
- if(value == widget->getValue()) {
- widget->setChecked(true);
+ RadioButton *rbtn = *i;
+ if(value == rbtn->getValue()) {
+ rbtn->setChecked(true);
} else {
- widget->setChecked(false);
+ rbtn->setChecked(false);
}
}
setInitialValue(value);
-
- isValid();
-}
-
-void RadioButtons::connectFrom(const char *signal,
- const QObject *receiver, const char *method)
-{
- connect(this, signal, receiver, method);
-}
-
-void RadioButtons::connectTo(const QObject *sender, const char *signal,
- const char *method)
-{
- connect(sender, signal, this, method);
}
bool RadioButtons::setKeyboardFocus()
@@ -157,36 +150,15 @@ bool RadioButtons::setKeyboardFocus()
return false;
}
-void RadioButtons::setVisibility(bool visible)
-{
- setVisible(visible);
-}
-
void RadioButtons::childChanged()
{
- isValid();
-
+ eventOnChange();
emit wasChanged();
}
-void RadioButtons::enable()
-{
- setEnabled(true);
-}
-
-void RadioButtons::disable()
-{
- setEnabled(false);
-}
-
-bool RadioButtons::isDisabled()
-{
- return isEnabled() == false;
-}
-
void RadioButtons::changeEvent(QEvent *event)
{
if(event->type() == QEvent::EnabledChange) {
- setBGColor(isValid() || !isEnabled());
+ // setWdgValid(valid() || !frame->isEnabled());
}
}