2013-11-04 12:20:43 -03:00
|
|
|
// Copyright (c) 2011-2013 The Bitcoin developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2011-07-29 08:36:35 -04: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 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));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::setRole(int role)
|
|
|
|
{
|
|
|
|
this->role = role;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::handleSelectionChanged(int idx)
|
|
|
|
{
|
|
|
|
emit valueChanged();
|
|
|
|
}
|