48 BaseWidget(parent,
"DataSelectWidget",
"DataSelectWidget"),
50 mViewService(viewService),
51 mPatientModelService(patientModelService)
54 QHBoxLayout* layout =
new QHBoxLayout(
this);
56 layout->setSpacing(0);
61 QIcon(
":/icons/open_icon_library/eye.png.png"),
62 "Toggle show data in view",
"",
63 SLOT(toggleShowData()),
65 mToggleShowAction->setCheckable(
true);
67 toggleShowButton->setDefaultAction(mToggleShowAction);
74 gridLayout->setMargin(0);
75 gridLayout->setSpacing(0);
76 QHBoxLayout* lay =
new QHBoxLayout;
77 lay->addWidget(toggleShowButton);
78 lay->addWidget(mRemoveButton);
79 gridLayout->addLayout(lay, row, 2);
82 layout->addWidget(widget);
83 layout->addWidget(toggleShowButton);
84 layout->addWidget(mRemoveButton);
87 connect(mViewService.get(), SIGNAL(activeViewChanged()),
this, SLOT(viewGroupChangedSlot()));
88 connect(mData.get(), SIGNAL(changed()),
this, SLOT(updateDataVisibility()));
90 this->viewGroupChangedSlot();
95 disconnect(mViewService.get(), SIGNAL(activeViewChanged()),
this, SLOT(viewGroupChangedSlot()));
100 int groupIdx = mViewService->getActiveGroupId();
103 return mViewService->getGroup(groupIdx);
106 void DataSelectWidget::viewGroupChangedSlot()
109 if (mCurrentViewGroupData==group)
112 if (mCurrentViewGroupData)
115 this, &DataSelectWidget::updateDataVisibility);
118 mCurrentViewGroupData = group;
120 if (mCurrentViewGroupData)
123 this, &DataSelectWidget::updateDataVisibility);
126 this->updateDataVisibility();
129 void DataSelectWidget::updateDataVisibility()
131 mToggleShowAction->setEnabled(mData->getData() && (mCurrentViewGroupData!=0));
132 mRemoveButton->setEnabled(mData->getData() ?
true :
false);
134 bool visible =
false;
135 if (mData->getData())
137 std::vector<DataPtr> visibleData;
138 if (mCurrentViewGroupData)
140 visibleData = mCurrentViewGroupData->getData();
142 visible = std::count(visibleData.begin(), visibleData.end(), mData->getData());
144 mToggleShowAction->blockSignals(
true);
145 mToggleShowAction->setChecked(visible);
146 mToggleShowAction->blockSignals(
false);
147 mRemoveButton->
reset();
151 void DataSelectWidget::eraseData()
153 if (!mData->getData())
156 mPatientModelService->removeData(mData->getData()->getUid());
159 void DataSelectWidget::setShowIcon()
161 if (mToggleShowAction->isChecked())
163 mToggleShowAction->setIcon(QIcon(
":/icons/open_icon_library/eye.png.png"));
167 mToggleShowAction->setIcon(QIcon(
":/icons/eye.png"));
171 void DataSelectWidget::toggleShowData()
173 if (!mData->getData())
176 if (mToggleShowAction->isChecked())
178 mCurrentViewGroupData->addData(mData->getData()->getUid());
182 mCurrentViewGroupData->removeData(mData->getData()->getUid());
193 QString tip(
"<html><h4>Permanently delete data.</h4><p>Press button twice to delete.<br>" 194 "Right-click after the first click to cancel.<p></html>");
196 mRemoveAction =
new QAction(
this);
197 mRemoveAction->setToolTip(tip);
198 connect(mRemoveAction, &QAction::triggered,
this, &EraseDataToolButton::requestEraseData);
199 mRemoveAction->setCheckable(
true);
200 this->setDefaultAction(mRemoveAction);
202 this->setRemoveIcon();
207 this->cancelRemovalSlot();
210 void EraseDataToolButton::mousePressEvent(QMouseEvent *e)
212 CXSmallToolButton::mousePressEvent(e);
213 if (e->button() == Qt::RightButton)
214 this->cancelRemovalSlot();
220 void EraseDataToolButton::cancelRemovalSlot()
222 mRemoveAction->blockSignals(
true);
223 mRemoveAction->setChecked(
false);
224 this->setRemoveIcon();
225 mRemoveAction->blockSignals(
false);
228 void EraseDataToolButton::setRemoveIcon()
230 if (mRemoveAction->isChecked())
232 mRemoveAction->setIcon(QIcon(
":/icons/preset_remove.png"));
236 mRemoveAction->setIcon(QIcon(
":/icons/open_icon_library/edit-delete-2.png"));
244 void EraseDataToolButton::requestEraseData()
246 this->setRemoveIcon();
248 if (mRemoveAction->isChecked())
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void dataViewPropertiesChanged(QString uid)
Namespace for all CustusX production code.