2014-12-17 01:47:57 +00:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
2014-12-13 04:09:33 +00:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 15:20:43 +00:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2011-07-29 12:36:35 +00: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 21:03:41 +00:00
|
|
|
QVariant QValueComboBox::value() const
|
2011-07-29 12:36:35 +00:00
|
|
|
{
|
2012-05-08 21:03:41 +00:00
|
|
|
return itemData(currentIndex(), role);
|
2011-07-29 12:36:35 +00:00
|
|
|
}
|
|
|
|
|
2012-05-08 21:03:41 +00:00
|
|
|
void QValueComboBox::setValue(const QVariant &value)
|
2011-07-29 12:36:35 +00:00
|
|
|
{
|
|
|
|
setCurrentIndex(findData(value, role));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::setRole(int role)
|
|
|
|
{
|
|
|
|
this->role = role;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::handleSelectionChanged(int idx)
|
|
|
|
{
|
2015-07-14 11:59:05 +00:00
|
|
|
Q_EMIT valueChanged();
|
2011-07-29 12:36:35 +00:00
|
|
|
}
|