bitcoin/src/qt/qvaluecombobox.cpp

32 lines
808 B
C++
Raw Normal View History

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
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/qvaluecombobox.h>
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);
}
QVariant QValueComboBox::value() const
{
return itemData(currentIndex(), role);
}
void QValueComboBox::setValue(const QVariant &value)
{
setCurrentIndex(findData(value, role));
}
2016-09-09 08:43:29 -03:00
void QValueComboBox::setRole(int _role)
{
2016-09-09 08:43:29 -03:00
this->role = _role;
}
void QValueComboBox::handleSelectionChanged(int idx)
{
Q_EMIT valueChanged();
}