43 mViewService(viewService),
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);
89 if(mOptions.size() == 0)
97 for(std::vector<PropertyPtr>::const_iterator it = mOptions.begin(); it != mOptions.end(); ++it)
99 if(it->get()->getAdvanced())
111 void OptionsWidget::clear()
114 while ((child = mStackedLayout->takeAt(0)) != 0)
117 QWidget* widget = child->widget();
123 void OptionsWidget::populate(
bool showAdvanced)
127 QWidget* widget =
new QWidget(
this);
128 widget->setObjectName(mUid);
129 mStackedLayout->addWidget(widget);
130 QGridLayout* layout =
new QGridLayout(widget);
131 layout->setMargin(layout->margin()/2);
133 std::map<QString, QWidget*> groupWidgets;
134 QWidget* otherWidget = NULL;
135 for (
unsigned i = 0; i < mOptions.size(); ++i)
137 if(showAdvanced || (!showAdvanced && !mOptions[i]->getAdvanced()))
139 QWidget* groupWidget = NULL;
140 QGridLayout* groupLayout = NULL;
143 QString groupName = mOptions[i]->getGroup();
144 if(groupName.isEmpty())
146 std::map<QString, QWidget*>::iterator it = groupWidgets.find(groupName);
147 if(it == groupWidgets.end())
149 groupWidget =
new QWidget(widget);
150 groupWidget->setObjectName(groupName);
151 groupLayout =
new QGridLayout(groupWidget);
152 groupLayout->setMargin(groupLayout->margin()/2);
153 QWidget* temp = this->createGroupHeaderWidget(groupName);
154 groupLayout->addWidget(temp,0,0,1,2);
155 layout->addWidget(groupWidget);
156 groupWidgets[groupName] = groupWidget;
157 if(groupName ==
"other")
162 groupWidget = it->second;
163 groupLayout =
dynamic_cast<QGridLayout*
>(groupWidget->layout());
167 int itemsInGroup = groupLayout->count();
171 createDataWidget(mViewService, mPatientModelService, groupWidget, mOptions[i], groupLayout, ++itemsInGroup);
177 if((groupWidgets.size() == 1) && (otherWidget != NULL))
180 mStackedLayout->setCurrentWidget(widget);
183 QWidget* OptionsWidget::createGroupHeaderWidget(QString title)
185 QWidget* retval =
new QWidget(
this);
186 QVBoxLayout* layout =
new QVBoxLayout(retval);
187 layout->setMargin(0);
188 layout->setSpacing(0);
190 QLabel* label =
new QLabel(title);
191 QFont font = label->font();
192 font.setPointSize(8);
193 label->setFont(font);
194 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
cxLogicManager_EXPORT ViewServicePtr viewService()