2015-12-13 17:58:29 +01:00
|
|
|
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2011-07-29 14:36:35 +02:00
|
|
|
#include "qvaluecombobox.h"
|
|
|
|
|
|
|
|
QValueComboBox::QValueComboBox(QWidget *parent) :
|
|
|
|
QComboBox(parent), role(Qt::UserRole)
|
|
|
|
{
|
|
|
|
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
|
|
|
|
}
|
|
|
|
|
2012-05-08 23:03:41 +02:00
|
|
|
QVariant QValueComboBox::value() const
|
2011-07-29 14:36:35 +02:00
|
|
|
{
|
2012-05-08 23:03:41 +02:00
|
|
|
return itemData(currentIndex(), role);
|
2011-07-29 14:36:35 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 23:03:41 +02:00
|
|
|
void QValueComboBox::setValue(const QVariant &value)
|
2011-07-29 14:36:35 +02:00
|
|
|
{
|
|
|
|
setCurrentIndex(findData(value, role));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::setRole(int role)
|
|
|
|
{
|
|
|
|
this->role = role;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::handleSelectionChanged(int idx)
|
|
|
|
{
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT valueChanged();
|
2011-07-29 14:36:35 +02:00
|
|
|
}
|