39 #include <QWidgetAction>
42 #include "boost/bind.hpp"
50 QGridLayout* gridLayout,
int row) :
51 BaseWidget(parent,
"StringListSelectWidget",
"StringListSelectWidget"),
56 this->setEnabled(mData->getEnabled());
58 mLabel =
new QLabel(
this);
59 mLabel->setText(mData->getDisplayName());
61 mMenu =
new QMenu(
this);
63 mButton->setIcon(QIcon(
":icons/open_icon_library/go-down-4.png"));
64 mButton->setPopupMode(QToolButton::InstantPopup);
65 mButton->setMenu(mMenu);
70 gridLayout->addWidget(mButton, row, 1);
87 mButton->setIcon(icon);
90 void StringListSelectWidget::onCheckToggled(QString nodeType,
bool value)
92 QStringList data = mData->getValue();
95 data.append(nodeType);
97 data.removeAll(nodeType);
99 mData->setValue(data);
104 mLabel->setVisible(on);
107 void StringListSelectWidget::prePaintEvent()
109 this->setEnabled(mData->getEnabled());
110 mLabel->setEnabled(mData->getEnabled());
111 mButton->setEnabled(mData->getEnabled());
113 QStringList value = mData->getValue();
114 QStringList range = mData->getValueRange();
116 if (mCachedRange!=range)
118 mCachedRange = range;
122 for (
int i=0; i<range.size(); ++i)
124 QString uid = range[i];
125 QString name = mData->convertInternal2Display(uid);
126 mCheckBoxes.push_back(
new QCheckBox(name, mMenu));
127 boost::function<void(bool)> func = boost::bind(&StringListSelectWidget::onCheckToggled,
this, uid, _1);
128 connect(mCheckBoxes[i], &QCheckBox::toggled, func);
129 QWidgetAction *checkableAction =
new QWidgetAction(mMenu);
130 checkableAction->setDefaultWidget(mCheckBoxes[i]);
131 mMenu->addAction(checkableAction);
135 for (
int i=0; i<range.size(); ++i)
137 mCheckBoxes[i]->setChecked(value.contains(range[i]));
140 mButton->setToolTip(mData->getHelp());
141 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