summaryrefslogtreecommitdiff
path: root/client/widgets/combobox.h
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/combobox.h')
-rw-r--r--client/widgets/combobox.h47
1 files changed, 44 insertions, 3 deletions
diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h
index 92a0e39..bf61b1a 100644
--- a/client/widgets/combobox.h
+++ b/client/widgets/combobox.h
@@ -32,11 +32,19 @@
#include "widget.h"
+#ifdef LUA_CLASS
+#undef LUA_CLASS
+#endif
+#define LUA_CLASS "ComboBox"
+
/***
* ComboBox Widget
* @tag combobox
+ * @screenshot Example
+ * <combobox name="ex" layout="vbox" value="item" type="select">
+ * <item caption="Item" value="item"/>
+ * </combobox>
* @extends widget
- * @screenshot
* The ComboBox is used to make a selection from a list of items.
* The ComboBox contains <code>&lt;item&gt;</code> tags each describing
* an entry in the selection list.
@@ -67,6 +75,8 @@ public:
ComboBox(QDomNode &node, MacroWindow *macrowindow);
~ComboBox();
+ virtual QString luaclass() { return LUA_CLASS; }
+
QString value();
void setValue(QString value, QString source = "");
@@ -78,7 +88,7 @@ public:
void setWdgValid(bool valid);
void clear();
- void addItem(QString item);
+ void addItem(QString item, QString value);
public slots:
void changed();
@@ -89,17 +99,48 @@ protected:
void changeEvent(QEvent *event);
private:
+ void updateSearchList();
+
QRegExp rx;
types_t combotype;
bool ischangingbyuser;
QComboBox *combobox;
bool ignoreChangeEvents;
+
+ QStringList itemlist;
};
+/***
+ * @method nil clear()
+ * This method removes all items from the combobox.
+ */
int cmb_clear(lua_State *L);
+
+/***
+ * @method nil addItem(string caption, string value)
+ * This method adds an item to the selectionlist of the combobox.
+ * @param caption The item text to be added. It will be added both as the value
+ * and caption of the item.
+ * @param value The item value. This value is optional. If left out, the
+ * caption will be used as the item value.
+ */
int cmb_add_item(lua_State *L);
+
+/***
+ * @method string lineEditValue()
+ * This method is used to get the value from the combobox lineedit (in case it
+ * is in edit mode).
+ * @return a string containing the current value of the combobox lineedit.
+ */
int cmb_le_value(lua_State *L);
+
+/***
+ * @method nil setLineEditValue(string text)
+ * This method is used to set the value of the combobox lineedit (in case it
+ * is in edit mode).
+ * @param text The text string to be set.
+ */
int cmb_le_set_value(lua_State *L);
#define CMBBOX_METHS \
@@ -113,7 +154,7 @@ const struct luaL_Reg cmbbox_meths[] =
inline void register_combobox(lua_State *L)
{
- luaL_newmetatable(L, "ComboBox");
+ luaL_newmetatable(L, LUA_CLASS);
lua_pushliteral(L, "__index");
lua_pushvalue(L, -2);
lua_rawset(L, -3);