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);
95 this->setEnabled(mData->getEnabled());
96 mLabel->setEnabled(mData->getEnabled());
97 mCombo->setEnabled(mData->getEnabled());
99 QString currentValue = mData->getValue();
100 QStringList range = mData->getValueRange();
101 if (range.size()!=mCombo->count())
104 mCombo->addItems(range);
106 int currentIndex = -1;
107 for (
int i = 0; i < range.size(); ++i)
109 mCombo->setItemIcon(i, this->getIcon(range[i]));
110 mCombo->setItemText(i, mData->convertInternal2Display(range[i]));
111 mCombo->setItemData(i, range[i]);
112 if (range[i] == currentValue)
115 mCombo->setCurrentIndex(currentIndex);
117 mCombo->setToolTip(mData->getHelp());
118 mLabel->setToolTip(mData->getHelp());
119 mCombo->blockSignals(
false);
122 QIcon LabeledComboBoxWidget::getIcon(QString uid)
128 DataPtr data = dataProperty->getData(uid);
131 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.