summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2010-08-19 09:04:47 +0000
committerdeva <deva>2010-08-19 09:04:47 +0000
commit7914500c96ebe2106716a001ca2b93594d3c07a5 (patch)
tree025cf3dcbba673df9dcca9fa5864135a328209c8
parent145bc8467b9f4271ca15654bc4bc6f7a8bc816b6 (diff)
Fixed problems with eventOnChange.
-rw-r--r--client/widgets/altcombobox.cc15
-rw-r--r--client/widgets/checkbox.cc2
-rw-r--r--client/widgets/combobox.cc4
-rw-r--r--client/widgets/datetime.cc2
-rw-r--r--client/widgets/dbwidget.cc2
-rw-r--r--client/widgets/lineedit.cc7
-rw-r--r--client/widgets/multilist.cc6
-rw-r--r--client/widgets/radiobuttons.cc2
-rw-r--r--client/widgets/textedit.cc2
-rw-r--r--client/widgets/widget.cc20
-rw-r--r--client/widgets/widget.h9
11 files changed, 42 insertions, 29 deletions
diff --git a/client/widgets/altcombobox.cc b/client/widgets/altcombobox.cc
index fac2610..6146624 100644
--- a/client/widgets/altcombobox.cc
+++ b/client/widgets/altcombobox.cc
@@ -188,22 +188,25 @@ void AltComboBox::onValueChange(int index)
altvalue.toStdString().c_str());
if(cmb->itemData(index).toString() == altvalue) {
- // altframe->setEnabled(true);
+
altframerepl->setVisible(false);
frame->layout()->removeWidget(altframerepl);
frame->layout()->addWidget(altframe);
altframe->setVisible(true);
+
} else {
- // altframe->setEnabled(false);
+
altframe->setVisible(false);
frame->layout()->removeWidget(altframe);
frame->layout()->addWidget(altframerepl);
altframerepl->setVisible(true);
+
}
- eventOnChange(true);
+ emit eventOnChange(true);
+ innerwidget->runEventOnChange();
}
void AltComboBox::onValueChange(const QString &text)
@@ -214,8 +217,8 @@ void AltComboBox::onValueChange(const QString &text)
void AltComboBox::onChildChange()
{
+ emit eventOnChange(true);
emit wasChanged();
- eventOnChange(true);
}
bool AltComboBox::setKeyboardFocus()
@@ -230,6 +233,8 @@ bool AltComboBox::setKeyboardFocus()
void AltComboBox::setWdgValid(bool valid)
{
+ DEBUG(altcombobox, "Set valid(%s)", valid?"true":"false");
+
QPalette palette;
if(valid) {
@@ -242,5 +247,5 @@ void AltComboBox::setWdgValid(bool valid)
frame->setPalette(palette);
combobox->qwidget()->setPalette(palette);
- if(innerwidget) innerwidget->setWdgValid(valid);
+ // if(innerwidget) innerwidget->setWdgValid(valid);
}
diff --git a/client/widgets/checkbox.cc b/client/widgets/checkbox.cc
index 6448298..5acf694 100644
--- a/client/widgets/checkbox.cc
+++ b/client/widgets/checkbox.cc
@@ -98,8 +98,8 @@ void CheckBox::setValue(QString value, QString source)
void CheckBox::state_change(int)
{
+ emit eventOnChange();
if(changedByUser) emit wasChanged();
- eventOnChange();
}
bool CheckBox::checked()
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index ebc2cb5..5d5543f 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -174,7 +174,7 @@ void ComboBox::setValue(QString value, QString source)
combobox->setCurrentIndex(idx);
ischangingbyuser = true;
} else {
- eventOnChange();
+ emit eventOnChange();
}
// setInitialValue(value);
@@ -192,7 +192,7 @@ bool ComboBox::preValid()
void ComboBox::changed()
{
if(ischangingbyuser) emit wasChanged();
- eventOnChange();
+ emit eventOnChange();
}
bool ComboBox::eventFilter(QObject *obj, QEvent *event)
diff --git a/client/widgets/datetime.cc b/client/widgets/datetime.cc
index 43977e3..f7780e2 100644
--- a/client/widgets/datetime.cc
+++ b/client/widgets/datetime.cc
@@ -102,8 +102,8 @@ DateTime::~DateTime()
void DateTime::changed(const QDateTime &)
{
+ emit eventOnChange();
if(changedByUser) emit wasChanged();
- eventOnChange();
}
QString DateTime::value()
diff --git a/client/widgets/dbwidget.cc b/client/widgets/dbwidget.cc
index 08107b1..1292708 100644
--- a/client/widgets/dbwidget.cc
+++ b/client/widgets/dbwidget.cc
@@ -139,8 +139,8 @@ bool DBWidget::preValid()
void DBWidget::changed()
{
+ emit eventOnChange();
if(changedByUser) emit wasChanged();
- eventOnChange();
}
void DBWidget::update_list(QString prefix)
diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc
index a8ea600..1c379dc 100644
--- a/client/widgets/lineedit.cc
+++ b/client/widgets/lineedit.cc
@@ -33,6 +33,7 @@
#include <QKeyEvent>
#include "common.h"
+#include "debug.h"
LineEdit::LineEdit(QDomNode &node, MacroWindow *macrowindow)
: Widget(node, macrowindow)
@@ -70,13 +71,13 @@ LineEdit::~LineEdit()
void LineEdit::changed()
{
- eventOnChange();
+ emit eventOnChange();
}
void LineEdit::user_changed()
{
+ emit eventOnChange();
emit wasChanged();
- eventOnChange();
}
QString LineEdit::value()
@@ -118,6 +119,8 @@ void LineEdit::changeEvent(QEvent *event)
void LineEdit::setWdgValid(bool valid)
{
+ DEBUG(lineedit, "Set valid(%s)", valid?"true":"false");
+
QPalette palette;
if(valid) {
diff --git a/client/widgets/multilist.cc b/client/widgets/multilist.cc
index 92cdf29..c4ebd60 100644
--- a/client/widgets/multilist.cc
+++ b/client/widgets/multilist.cc
@@ -188,7 +188,7 @@ void MultiList::setValue(QString values, QString source)
idx++;
} while(value != "");
- eventOnChange();
+ emit eventOnChange();
}
void MultiList::remove()
@@ -197,8 +197,8 @@ void MultiList::remove()
if(item && item->isSelected()) {
delete item;
+ emit eventOnChange();
emit wasChanged();
- eventOnChange();
}
}
@@ -211,7 +211,7 @@ void MultiList::add()
innerwidget->setValues();
innerwidget_has_changes = false;
- eventOnChange();
+ emit eventOnChange();
}
}
diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc
index 5d9abb4..f8b036f 100644
--- a/client/widgets/radiobuttons.cc
+++ b/client/widgets/radiobuttons.cc
@@ -152,7 +152,7 @@ bool RadioButtons::setKeyboardFocus()
void RadioButtons::childChanged()
{
- eventOnChange();
+ emit eventOnChange();
emit wasChanged();
}
diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc
index b5d62e5..c597359 100644
--- a/client/widgets/textedit.cc
+++ b/client/widgets/textedit.cc
@@ -66,7 +66,7 @@ TextEdit::~TextEdit()
void TextEdit::changed()
{
- eventOnChange();
+ emit eventOnChange();
}
QString TextEdit::value()
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index cc74553..fba2da0 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -68,6 +68,9 @@ Widget::Widget(QDomNode &node, MacroWindow *macrowindow)
is_valid = true;
+ connect(this, SIGNAL(eventOnChange()),
+ this, SLOT(runEventOnChange()), Qt::QueuedConnection);
+
DEBUG(widget, "Create Widget '%s' of type '%s'\n",
name().toStdString().c_str(),
type().toStdString().c_str());
@@ -132,15 +135,16 @@ void Widget::setValid(bool valid)
{
is_valid = valid;
setWdgValid(valid);
-
+ /*
QVector< Widget* >::iterator i = children.begin();
while(i != children.end()) {
if(*i) (*i)->setValid(valid);
i++;
}
+ */
}
-void Widget::eventOnChange(bool deep)
+void Widget::runEventOnChange(bool deep)
{
if(enabled() && hasOnChangeEvent)
lua->runScript(onChangeEventScript, this, "onChange");
@@ -149,7 +153,7 @@ void Widget::eventOnChange(bool deep)
QVector< Widget* >::iterator i = children.begin();
while(i != children.end()) {
- if(*i) (*i)->eventOnChange(deep);
+ if(*i) (*i)->runEventOnChange(deep);
i++;
}
}
@@ -157,12 +161,12 @@ void Widget::eventOnChange(bool deep)
void Widget::setEnabled(bool enabled)
{
widget->setEnabled(enabled);
- if(enabled) eventOnChange();
+ if(enabled) emit eventOnChange();
else setValid(true); // Force disabled widgets to be valid
QVector< Widget* >::iterator i = children.begin();
while(i != children.end()) {
- if(*i) (*i)->eventOnChange(true);
+ if(*i) (*i)->runEventOnChange(true);
i++;
}
@@ -176,11 +180,11 @@ bool Widget::enabled()
void Widget::setVisible(bool visible)
{
widget->setVisible(visible);
- if(visible) eventOnChange();
+ if(visible) emit eventOnChange();
QVector< Widget* >::iterator i = children.begin();
while(i != children.end()) {
- if(*i) (*i)->eventOnChange(true);
+ if(*i) (*i)->runEventOnChange(true);
i++;
}
}
@@ -264,7 +268,7 @@ void Widget::addChildren(QDomNode &node, QLayout *layout)
void Widget::setValues()
{
if(has_lazy) setValue(lazy_value, lazy_source);
- else eventOnChange(); // Make sure we run validation on the unset widget.
+ else emit eventOnChange(); // Make sure we run validation on the unset widget.
QVector< Widget* >::iterator i = children.begin();
while(i != children.end()) {
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index 99b9479..17480cb 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -81,15 +81,16 @@ public:
signals:
void wasChanged();
-public slots:
- void childWasChanged();
-
-protected:
/*
* LUA scripting events:
*/
void eventOnChange(bool deep = false);
+public slots:
+ void childWasChanged();
+ void runEventOnChange(bool deep = false);
+
+protected:
QWidget *widget;
bool hideChildren;