aboutsummaryrefslogtreecommitdiff
path: root/src/qt/qvaluecombobox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/qvaluecombobox.cpp')
-rw-r--r--src/qt/qvaluecombobox.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/qt/qvaluecombobox.cpp b/src/qt/qvaluecombobox.cpp
new file mode 100644
index 0000000000..c0ad8c12e5
--- /dev/null
+++ b/src/qt/qvaluecombobox.cpp
@@ -0,0 +1,27 @@
+#include "qvaluecombobox.h"
+
+QValueComboBox::QValueComboBox(QWidget *parent) :
+ QComboBox(parent), role(Qt::UserRole)
+{
+ connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
+}
+
+int QValueComboBox::value() const
+{
+ return itemData(currentIndex(), role).toInt();
+}
+
+void QValueComboBox::setValue(int value)
+{
+ setCurrentIndex(findData(value, role));
+}
+
+void QValueComboBox::setRole(int role)
+{
+ this->role = role;
+}
+
+void QValueComboBox::handleSelectionChanged(int idx)
+{
+ emit valueChanged();
+}