18 #include <QWidgetAction> 21 #include "boost/bind.hpp" 29 QGridLayout* gridLayout,
int row) :
30 BaseWidget(parent,
"StringListSelectWidget",
"StringListSelectWidget"),
35 this->setEnabled(mData->getEnabled());
37 mLabel =
new QLabel(
this);
38 mLabel->setText(mData->getDisplayName());
40 mMenu =
new QMenu(
this);
42 mButton->setIcon(QIcon(
":icons/open_icon_library/go-down-4.png"));
43 mButton->setPopupMode(QToolButton::InstantPopup);
44 mButton->setMenu(mMenu);
49 gridLayout->addWidget(mButton, row, 1);
66 mButton->setIcon(icon);
69 void StringListSelectWidget::onCheckToggled(QString nodeType,
bool value)
71 QStringList data = mData->getValue();
74 data.append(nodeType);
76 data.removeAll(nodeType);
78 mData->setValue(data);
83 mLabel->setVisible(on);
86 void StringListSelectWidget::prePaintEvent()
88 this->setEnabled(mData->getEnabled());
89 mLabel->setEnabled(mData->getEnabled());
90 mButton->setEnabled(mData->getEnabled());
92 QStringList value = mData->getValue();
93 QStringList range = mData->getValueRange();
95 if (mCachedRange!=range)
101 for (
int i=0; i<range.size(); ++i)
103 QString uid = range[i];
104 QString name = mData->convertInternal2Display(uid);
105 mCheckBoxes.push_back(
new QCheckBox(name, mMenu));
106 boost::function<void(bool)> func = boost::bind(&StringListSelectWidget::onCheckToggled,
this, uid, _1);
107 connect(mCheckBoxes[i], &QCheckBox::toggled, func);
108 QWidgetAction *checkableAction =
new QWidgetAction(mMenu);
109 checkableAction->setDefaultWidget(mCheckBoxes[i]);
110 mMenu->addAction(checkableAction);
114 for (
int i=0; i<range.size(); ++i)
116 mCheckBoxes[i]->setChecked(value.contains(range[i]));
119 mButton->setToolTip(mData->getHelp());
120 mLabel->setToolTip(mData->getHelp());
void changed()
emit when the underlying data value is changed: The user interface will be updated.
boost::shared_ptr< class StringListProperty > StringListPropertyPtr
Namespace for all CustusX production code.