2017-11-09 19:34:51 +01:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
|
|
|
|
* Copyright (C) 2011-2015 The Bitcoin Core developers
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2013-11-04 16:20:43 +01:00
|
|
|
|
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
|
|
|
}
|