47 QGridLayout* gridLayout,
int row) :
48 BaseWidget(parent,
"LabeledComboBoxWidget",
"LabeledComboBoxWidget")
50 CX_ASSERT(dataInterface->getAllowOnlyValuesInRange()==
true);
52 this->setEnabled(dataInterface->getEnabled());
54 mData = dataInterface;
57 mLabel =
new QLabel(
this);
58 mLabel->setText(mData->getDisplayName());
60 mCombo =
new QComboBox(
this);
61 connect(mCombo, SIGNAL(currentIndexChanged(
int)),
this, SLOT(comboIndexChanged(
int)));
66 gridLayout->addWidget(mCombo, row, 1);
81 void LabeledComboBoxWidget::comboIndexChanged(
int index)
83 mData->setValue(mCombo->itemData(index).toString());
88 mLabel->setVisible(on);
91 void LabeledComboBoxWidget::prePaintEvent()
93 mCombo->blockSignals(
true);
96 this->setEnabled(mData->getEnabled());
97 mLabel->setEnabled(mData->getEnabled());
98 mCombo->setEnabled(mData->getEnabled());
100 QString currentValue = mData->getValue();
101 QStringList range = mData->getValueRange();
102 int currentIndex = -1;
103 for (
int i = 0; i < range.size(); ++i)
105 QIcon icon = this->getIcon(range[i]);
106 mCombo->addItem(icon, mData->convertInternal2Display(range[i]));
107 mCombo->setItemData(i, range[i]);
108 if (range[i] == currentValue)
111 mCombo->setCurrentIndex(currentIndex);
113 mCombo->setToolTip(mData->getHelp());
114 mLabel->setToolTip(mData->getHelp());
115 mCombo->blockSignals(
false);
118 QIcon LabeledComboBoxWidget::getIcon(QString uid)
124 DataPtr data = dataProperty->getData(uid);
127 return data->getIcon();
#define CX_ASSERT(statement)
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr
void changed()
emit when the underlying data value is changed: The user interface will be updated.