summaryrefslogtreecommitdiff
path: root/client/widgets/widget.h
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/widget.h')
-rw-r--r--client/widgets/widget.h90
1 files changed, 57 insertions, 33 deletions
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index 732dce9..9e493d0 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -30,64 +30,88 @@
#include <QString>
#include <QDomNode>
#include <QRegExp>
+#include <QObject>
+#include <QVector>
-#include "macrowindow.h"
#include "lua.h"
-class Widget {
+class MacroWindow;
+class LUA;
+class Widget;
+class Widget : public QObject {
+Q_OBJECT
public:
Widget(QDomNode &node, MacroWindow *macrowindow);
- virtual ~Widget(){}
+ virtual ~Widget();
- virtual QString getValue() { return ""; }
- virtual void setValue(QString value, QString source = "");
+ QString name();
+ QString type();
+ bool local();
- virtual bool isValid();
- virtual void setValid(bool valid) { valid = valid; }
+ virtual QString value() = 0;
+ virtual void setValue(QString value, QString source) = 0;
- virtual void disable() {}
- virtual void enable() {}
- virtual bool isDisabled() { return false; }
+ bool valid();
+ void setValid(bool valid);
- virtual void setVisibility(bool) {}
- virtual bool getVisibility() { return true; }
-
- QString name();
- QString type();
+ // Implement in subclasses to contribute to the validation.
+ virtual bool preValid() { return true; }
- /**
- * Connect some signal from this object to some slot in some other object.
- */
- virtual void connectFrom(const char *, const QObject *, const char *) {}
+ // Implement in subclasses to change widget according to validation status.
+ virtual void setWdgValid(bool valid) = 0;
- /**
- * Connect some signal from some other object to some slot in this object.
- */
- virtual void connectTo(const QObject *, const char *, const char *) {}
+ virtual void setEnabled(bool enabled);
+ virtual bool enabled();
+
+ virtual void setVisible(bool visible);
+ virtual bool visible();
- virtual bool setKeyboardFocus() { return false; }
+ virtual bool setKeyboardFocus();
void setInitialValue(QString value);
bool hasInitialValue();
virtual void reset();
+ QWidget *qwidget() { return widget; }
+
+ // Set deep to true to find widgets inside altcombobox, multilist and
+ // metawidgets.
+ Widget *findWidget(QString name, bool deep = false);
+ QVector< Widget* > widgetList(bool deep = false);
+ void addChild(Widget *widget);
+
+signals:
+ void wasChanged();
+
+public slots:
+ void childWasChanged();
+
protected:
- QString widget_name;
- QString widget_type;
+ /*
+ * LUA scripting events:
+ */
+ void eventOnChange();
+
+ QWidget *widget;
+ bool hideChildren;
- bool luaValidator();
- bool regexpValidator();
+ void widgetBuilder(QDomNode &xml_node);
+ void addChildren(QDomNode &xml_node);
private:
- QRegExp rx;
+ QVector< Widget* > children;
- bool hasregexpvalidator;
- bool hasluaprogram;
+ bool is_valid;
+ QString widget_name;
+ QString widget_type;
+ bool widget_local;
- QString luaprogram;
LUA *lua;
MacroWindow *macrowindow;
-
+
+ bool hasOnChangeEvent;
+ QString onChangeEventScript;
+
QString initial_value;
bool has_initial_value;