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();
106 QWidget* widget =
new QWidget(
this);
107 widget->setObjectName(mUid);
108 mStackedLayout->addWidget(widget);
109 QGridLayout* layout =
new QGridLayout(widget);
110 layout->setMargin(layout->margin()/2);
112 std::map<QString, QWidget*> groupWidgets;
113 QWidget* otherWidget = NULL;
114 for (
unsigned i = 0; i < mOptions.size(); ++i)
116 if(showAdvanced || (!showAdvanced && !mOptions[i]->getAdvanced()))
118 QWidget* groupWidget = NULL;
119 QGridLayout* groupLayout = NULL;
122 QString groupName = mOptions[i]->getGroup();
123 if(groupName.isEmpty())
125 std::map<QString, QWidget*>::iterator it = groupWidgets.find(groupName);
126 if(it == groupWidgets.end())
128 groupWidget =
new QWidget(widget);
129 groupWidget->setObjectName(groupName);
130 groupLayout =
new QGridLayout(groupWidget);
131 groupLayout->setMargin(groupLayout->margin()/2);
132 QWidget* temp = this->createGroupHeaderWidget(groupName);
133 groupLayout->addWidget(temp,0,0,1,2);
134 layout->addWidget(groupWidget);
135 groupWidgets[groupName] = groupWidget;
136 if(groupName ==
"other")
141 groupWidget = it->second;
142 groupLayout =
dynamic_cast<QGridLayout*
>(groupWidget->layout());
146 int itemsInGroup = groupLayout->count();
150 createDataWidget(mViewService, mPatientModelService, groupWidget, mOptions[i], groupLayout, ++itemsInGroup);
156 if((groupWidgets.size() == 1) && (otherWidget != NULL))
159 mStackedLayout->setCurrentWidget(widget);
162 QWidget* OptionsWidget::createGroupHeaderWidget(QString title)
164 QWidget* retval =
new QWidget(
this);
165 QVBoxLayout* layout =
new QVBoxLayout(retval);
166 layout->setMargin(0);
167 layout->setSpacing(0);
169 QLabel* label =
new QLabel(title);
170 QFont font = label->font();
171 font.setPointSize(8);
172 label->setFont(font);
173 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.