26 QGridLayout* gridLayout,
int row) :
27 BaseWidget(parent,
"LabeledComboBoxWidget",
"LabeledComboBoxWidget")
29 CX_ASSERT(dataInterface->getAllowOnlyValuesInRange()==
true);
31 this->setEnabled(dataInterface->getEnabled());
33 mData = dataInterface;
36 mLabel =
new QLabel(
this);
37 mLabel->setText(mData->getDisplayName());
39 mCombo =
new QComboBox(
this);
40 connect(mCombo, SIGNAL(currentIndexChanged(
int)),
this, SLOT(comboIndexChanged(
int)));
45 gridLayout->addWidget(mCombo, row, 1);
60 void LabeledComboBoxWidget::comboIndexChanged(
int index)
62 mData->setValue(mCombo->itemData(index).toString());
67 mLabel->setVisible(on);
70 void LabeledComboBoxWidget::prePaintEvent()
72 mCombo->blockSignals(
true);
74 this->setEnabled(mData->getEnabled());
75 mLabel->setEnabled(mData->getEnabled());
76 mCombo->setEnabled(mData->getEnabled());
78 QString currentValue = mData->getValue();
79 QStringList range = mData->getValueRange();
80 if (range.size()!=mCombo->count())
83 mCombo->addItems(range);
85 int currentIndex = -1;
86 for (
int i = 0; i < range.size(); ++i)
88 mCombo->setItemIcon(i, this->getIcon(range[i]));
89 mCombo->setItemText(i, mData->convertInternal2Display(range[i]));
90 mCombo->setItemData(i, range[i]);
91 if (range[i] == currentValue)
94 mCombo->setCurrentIndex(currentIndex);
96 mCombo->setToolTip(mData->getHelp());
97 mLabel->setToolTip(mData->getHelp());
98 mCombo->blockSignals(
false);
101 QIcon LabeledComboBoxWidget::getIcon(QString uid)
107 DataPtr data = dataProperty->getData(uid);
110 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.
Namespace for all CustusX production code.