summaryrefslogtreecommitdiff
path: root/client/widgets/combobox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/combobox.cc')
-rw-r--r--client/widgets/combobox.cc54
1 files changed, 44 insertions, 10 deletions
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index 630a449..4db6172 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -77,7 +77,6 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
setEditable(true);
connect(this, SIGNAL(editTextChanged(QString)), this, SLOT(changed()));
- //setEditText(elem.attribute("value"));
break;
case SEARCH:
@@ -90,6 +89,7 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
}
rxs += ")";
rx = QRegExp(rxs);
+ rx.setCaseSensitivity(Qt::CaseInsensitive);
}
{
QCompleter *completer = new QCompleter(itemlist, this);
@@ -100,11 +100,12 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
}
connect(this, SIGNAL(editTextChanged(QString)), this, SLOT(changed()));
- //setEditText(elem.attribute("value"));
break;
}
+ ischangingbyuser = false;
changed();
+ ischangingbyuser = true;
}
QString ComboBox::getValue()
@@ -119,13 +120,20 @@ QString ComboBox::getValue()
return value;
}
-void ComboBox::setValue(QString value)
+void ComboBox::setValue(QString value, QString source)
{
+ if(isUserSource(source)) emit wasChanged();
+
int idx = findData(value);
printf("setValue(\"%s\") - %d\n", value.toStdString().c_str(), idx);
+ ischangingbyuser = false;
setCurrentIndex(idx);
+ ischangingbyuser = true;
+
+ setInitialValue(value);
+
}
bool ComboBox::isValid()
@@ -134,17 +142,12 @@ bool ComboBox::isValid()
if(currentIndex() != -1) return true;
else return false;
}
- return rx.exactMatch(currentText());
+ return rx.exactMatch(currentText()) && luaValidator();
}
void ComboBox::changed()
{
- /*
- if(combotype == SELECT) {
- luaValidator();
- return;
- }
- */
+ if(ischangingbyuser) emit wasChanged();
QPalette palette;
@@ -169,3 +172,34 @@ void ComboBox::disable()
{
setEnabled(false);
}
+
+void ComboBox::connectFrom(const char *signal,
+ const QObject *receiver, const char *method)
+{
+ connect(this, signal, receiver, method);
+}
+
+void ComboBox::connectTo(const QObject *sender, const char *signal,
+ const char *method)
+{
+ connect(sender, signal, this, method);
+}
+
+/*
+bool ComboBox::eventFilter(QObject *, QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress) emit wasChanged();
+ return false;
+}
+*/
+
+bool ComboBox::setKeyboardFocus()
+{
+ setFocus();
+ return true;
+}
+
+void ComboBox::setVisibility(bool visible)
+{
+ setVisible(visible);
+}