22 mViewService(viewService),
23 mPatientModelService(patientModelService)
25 this->setSizePolicy(this->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
26 mStackedLayout =
new QStackedLayout(
this);
27 mStackedLayout->setMargin(0);
32 std::vector<PropertyPtr> converted;
33 std::copy(options.begin(), options.end(), std::back_inserter(converted));
34 this->
setOptions(uid, converted, showAdvanced);
40 if (mStackedLayout->currentWidget() && (uid == mStackedLayout->currentWidget()->objectName()))
51 return mStackedLayout->currentWidget()->objectName();
63 this->populate(mShowAdvanced);
68 if(mOptions.size() == 0)
76 for(std::vector<PropertyPtr>::const_iterator it = mOptions.begin(); it != mOptions.end(); ++it)
78 if(it->get()->getAdvanced())
90 void OptionsWidget::clear()
93 while ((child = mStackedLayout->takeAt(0)) != 0)
96 QWidget* widget = child->widget();
107 QWidget* widget =
new QWidget(
this);
108 widget->setObjectName(mUid);
109 mStackedLayout->addWidget(widget);
110 QGridLayout* layout =
new QGridLayout(widget);
111 layout->setMargin(layout->margin()/2);
113 std::map<QString, QWidget*> groupWidgets;
114 QWidget* otherWidget = NULL;
115 for (
unsigned i = 0; i < mOptions.size(); ++i)
117 if(showAdvanced || (!showAdvanced && !mOptions[i]->getAdvanced()))
119 QWidget* groupWidget = NULL;
120 QGridLayout* groupLayout = NULL;
123 QString groupName = mOptions[i]->getGroup();
124 if(groupName.isEmpty())
126 std::map<QString, QWidget*>::iterator it = groupWidgets.find(groupName);
127 if(it == groupWidgets.end())
129 groupWidget =
new QWidget(widget);
130 groupWidget->setObjectName(groupName);
131 groupLayout =
new QGridLayout(groupWidget);
132 groupLayout->setMargin(groupLayout->margin()/2);
133 QWidget* temp = this->createGroupHeaderWidget(groupName);
134 groupLayout->addWidget(temp,0,0,1,2);
135 layout->addWidget(groupWidget);
136 groupWidgets[groupName] = groupWidget;
137 if(groupName ==
"other")
142 groupWidget = it->second;
143 groupLayout =
dynamic_cast<QGridLayout*
>(groupWidget->layout());
147 int itemsInGroup = groupLayout->count();
151 createDataWidget(mViewService, mPatientModelService, groupWidget, mOptions[i], groupLayout, ++itemsInGroup);
157 if((groupWidgets.size() == 1) && (otherWidget != NULL))
160 mStackedLayout->setCurrentWidget(widget);
163 QWidget* OptionsWidget::createGroupHeaderWidget(QString title)
165 QWidget* retval =
new QWidget(
this);
166 QVBoxLayout* layout =
new QVBoxLayout(retval);
167 layout->setMargin(0);
168 layout->setSpacing(0);
170 QLabel* label =
new QLabel(title);
171 QFont font = label->font();
172 font.setPointSize(8);
173 label->setFont(font);
174 layout->addWidget(label);
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Namespace for all CustusX production code.