43 mVisualizationService(visualizationService),
44 mPatientModelService(patientModelService)
46 this->setSizePolicy(this->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
47 mStackedLayout =
new QStackedLayout(
this);
48 mStackedLayout->setMargin(0);
53 std::vector<PropertyPtr> converted;
54 std::copy(options.begin(), options.end(), std::back_inserter(converted));
55 this->
setOptions(uid, converted, showAdvanced);
61 if (mStackedLayout->currentWidget() && (uid == mStackedLayout->currentWidget()->objectName()))
72 return mStackedLayout->currentWidget()->objectName();
84 this->populate(mShowAdvanced);
92 void OptionsWidget::clear()
95 while ((child = mStackedLayout->takeAt(0)) != 0)
98 QWidget* widget = child->widget();
104 void OptionsWidget::populate(
bool showAdvanced)
108 QWidget* widget =
new QWidget(
this);
109 widget->setObjectName(mUid);
110 mStackedLayout->addWidget(widget);
111 QGridLayout* layout =
new QGridLayout(widget);
112 layout->setMargin(layout->margin()/2);
114 std::map<QString, QWidget*> groupWidgets;
115 QWidget* otherWidget = NULL;
116 for (
unsigned i = 0; i < mOptions.size(); ++i)
118 if(showAdvanced || (!showAdvanced && !mOptions[i]->getAdvanced()))
120 QWidget* groupWidget = NULL;
121 QGridLayout* groupLayout = NULL;
124 QString groupName = mOptions[i]->getGroup();
125 if(groupName.isEmpty())
127 std::map<QString, QWidget*>::iterator it = groupWidgets.find(groupName);
128 if(it == groupWidgets.end())
130 groupWidget =
new QWidget(widget);
131 groupWidget->setObjectName(groupName);
132 groupLayout =
new QGridLayout(groupWidget);
133 groupLayout->setMargin(groupLayout->margin()/2);
134 QWidget* temp = this->createGroupHeaderWidget(groupName);
135 groupLayout->addWidget(temp,0,0,1,2);
136 layout->addWidget(groupWidget);
137 groupWidgets[groupName] = groupWidget;
138 if(groupName ==
"other")
143 groupWidget = it->second;
144 groupLayout = (QGridLayout*) groupWidget->layout();
148 int itemsInGroup = groupLayout->count();
152 createDataWidget(mVisualizationService, mPatientModelService, groupWidget, mOptions[i], groupLayout, ++itemsInGroup);
158 if((groupWidgets.size() == 1) && (otherWidget != NULL))
161 mStackedLayout->setCurrentWidget(widget);
164 QWidget* OptionsWidget::createGroupHeaderWidget(QString title)
166 QWidget* retval =
new QWidget(
this);
167 QVBoxLayout* layout =
new QVBoxLayout(retval);
168 layout->setMargin(0);
169 layout->setSpacing(0);
171 QLabel* label =
new QLabel(title);
172 QFont font = label->font();
173 font.setPointSize(8);
174 label->setFont(font);
175 layout->addWidget(label);
QWidget * createDataWidget(VisualizationServicePtr visualizationService, 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