2010-03-17 10:47:56 -05:00
|
|
|
#ifndef __INT_COMBO_BOX
|
|
|
|
#define __INT_COMBO_BOX
|
|
|
|
|
2010-03-12 23:46:24 -06:00
|
|
|
#include <QComboBox>
|
|
|
|
|
|
|
|
class IntComboBox : public QComboBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IntComboBox(QWidget *parent = 0)
|
|
|
|
: QComboBox(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void addItem(int value, const QString &text)
|
|
|
|
{
|
|
|
|
QComboBox::addItem(QString("%1 - %2").arg(value).arg(text), value);
|
|
|
|
}
|
|
|
|
int currentValue()
|
|
|
|
{
|
|
|
|
bool isOk;
|
|
|
|
int index = findText(currentText());
|
|
|
|
if (index >= 0)
|
|
|
|
return itemData(index).toInt();
|
|
|
|
else
|
|
|
|
return currentText().toInt(&isOk, 0);
|
|
|
|
}
|
|
|
|
void setValue(int value)
|
|
|
|
{
|
|
|
|
int index = findData(value);
|
|
|
|
if (index >= 0)
|
|
|
|
setCurrentIndex(index);
|
|
|
|
else
|
|
|
|
setEditText(QString().setNum(value));
|
|
|
|
}
|
|
|
|
};
|
2010-03-17 10:47:56 -05:00
|
|
|
|
|
|
|
#endif
|