2018-07-26 18:36:45 -04:00
|
|
|
// Copyright (c) 2011-2018 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 12:20:43 -03:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2017-11-09 21:57:53 -03:00
|
|
|
#include <qt/qvaluecombobox.h>
|
2011-07-29 08:36:35 -04:00
|
|
|
|
|
|
|
QValueComboBox::QValueComboBox(QWidget *parent) :
|
|
|
|
QComboBox(parent), role(Qt::UserRole)
|
|
|
|
{
|
2018-06-24 11:18:22 -04:00
|
|
|
connect(this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &QValueComboBox::handleSelectionChanged);
|
2011-07-29 08:36:35 -04:00
|
|
|
}
|
|
|
|
|
2012-05-08 17:03:41 -04:00
|
|
|
QVariant QValueComboBox::value() const
|
2011-07-29 08:36:35 -04:00
|
|
|
{
|
2012-05-08 17:03:41 -04:00
|
|
|
return itemData(currentIndex(), role);
|
2011-07-29 08:36:35 -04:00
|
|
|
}
|
|
|
|
|
2012-05-08 17:03:41 -04:00
|
|
|
void QValueComboBox::setValue(const QVariant &value)
|
2011-07-29 08:36:35 -04:00
|
|
|
{
|
|
|
|
setCurrentIndex(findData(value, role));
|
|
|
|
}
|
|
|
|
|
2016-09-09 08:43:29 -03:00
|
|
|
void QValueComboBox::setRole(int _role)
|
2011-07-29 08:36:35 -04:00
|
|
|
{
|
2016-09-09 08:43:29 -03:00
|
|
|
this->role = _role;
|
2011-07-29 08:36:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::handleSelectionChanged(int idx)
|
|
|
|
{
|
2015-07-14 08:59:05 -03:00
|
|
|
Q_EMIT valueChanged();
|
2011-07-29 08:36:35 -04:00
|
|
|
}
|