47 BaseWidget(parent,
"DataSelectWidget",
"DataSelectWidget"),
49 mVisualizationService(visualizationService),
50 mPatientModelService(patientModelService)
53 QHBoxLayout* layout =
new QHBoxLayout(
this);
55 layout->setSpacing(0);
60 QIcon(
":/icons/open_icon_library/eye.png.png"),
61 "Toggle show data in view",
"",
62 SLOT(toggleShowData()),
64 mToggleShowAction->setCheckable(
true);
66 toggleShowButton->setDefaultAction(mToggleShowAction);
70 "<html><h4>Permanently delete data.</h4><p>Press button twice to delete.<br>"
71 "Right-click after the first click to cancel.<p></html>"
73 SLOT(requestEraseData()),
75 mRemoveAction->setCheckable(
true);
77 connect(removeButton, SIGNAL(rightClick()),
this, SLOT(cancelRemovalSlot()));
78 removeButton->setDefaultAction(mRemoveAction);
82 gridLayout->setMargin(0);
83 gridLayout->setSpacing(0);
84 QHBoxLayout* lay =
new QHBoxLayout;
85 lay->addWidget(toggleShowButton);
86 lay->addWidget(removeButton);
87 gridLayout->addLayout(lay, row, 2);
90 layout->addWidget(widget);
91 layout->addWidget(toggleShowButton);
92 layout->addWidget(removeButton);
95 connect(mVisualizationService.get(), SIGNAL(activeViewChanged()),
this, SLOT(viewGroupChangedSlot()));
96 connect(mData.get(), SIGNAL(changed()),
this, SLOT(updateDataVisibility()));
98 this->setRemoveIcon();
99 this->viewGroupChangedSlot();
104 disconnect(mVisualizationService.get(), SIGNAL(activeViewChanged()),
this, SLOT(viewGroupChangedSlot()));
109 int groupIdx = mVisualizationService->getActiveGroupId();
112 return mVisualizationService->getGroup(groupIdx);
115 void DataSelectWidget::viewGroupChangedSlot()
118 if (mCurrentViewGroup==group)
121 if (mCurrentViewGroup)
124 this, &DataSelectWidget::updateDataVisibility);
127 mCurrentViewGroup = group;
129 if (mCurrentViewGroup)
132 this, &DataSelectWidget::updateDataVisibility);
135 this->updateDataVisibility();
138 void DataSelectWidget::updateDataVisibility()
140 mToggleShowAction->setEnabled(mData->getData() && (mCurrentViewGroup!=0));
141 mRemoveAction->setEnabled(mData->getData() ?
true :
false);
143 bool visible =
false;
144 if (mData->getData())
146 std::vector<DataPtr> visibleData;
147 if (mCurrentViewGroup)
149 visibleData = mCurrentViewGroup->getData();
151 visible = std::count(visibleData.begin(), visibleData.end(), mData->getData());
153 mToggleShowAction->blockSignals(
true);
154 mToggleShowAction->setChecked(visible);
155 mToggleShowAction->blockSignals(
false);
156 this->cancelRemovalSlot();
164 void DataSelectWidget::requestEraseData()
166 this->setRemoveIcon();
168 if (mRemoveAction->isChecked())
172 if (!mData->getData())
175 mPatientModelService->removeData(mData->getData()->getUid());
178 void DataSelectWidget::setRemoveIcon()
180 if (mRemoveAction->isChecked())
182 mRemoveAction->setIcon(QIcon(
":/icons/preset_remove.png"));
186 mRemoveAction->setIcon(QIcon(
":/icons/open_icon_library/edit-delete-2.png"));
190 void DataSelectWidget::setShowIcon()
192 if (mToggleShowAction->isChecked())
194 mToggleShowAction->setIcon(QIcon(
":/icons/open_icon_library/eye.png.png"));
198 mToggleShowAction->setIcon(QIcon(
":/icons/eye.png"));
205 void DataSelectWidget::cancelRemovalSlot()
207 mRemoveAction->blockSignals(
true);
208 mRemoveAction->setChecked(
false);
209 this->setRemoveIcon();
210 mRemoveAction->blockSignals(
false);
213 void DataSelectWidget::toggleShowData()
215 if (!mData->getData())
218 if (mToggleShowAction->isChecked())
220 mCurrentViewGroup->addData(mData->getData()->getUid());
224 mCurrentViewGroup->removeData(mData->getData()->getUid());
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void dataViewPropertiesChanged(QString uid)