| 163 | } |
| 164 | |
| 165 | void QmitkForm::UpdateFormHeader() |
| 166 | { |
| 167 | if (m_HasBeenSubmitted || m_Ui->sectionWidget->currentIndex() == -1) |
| 168 | { |
| 169 | m_Ui->formHeaderFrame->hide(); |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | bool showTitle = !m_Form->GetTitle().empty(); |
| 174 | |
| 175 | m_Ui->formTitleLabel->setVisible(showTitle); |
| 176 | |
| 177 | if (showTitle) |
| 178 | m_Ui->formTitleLabel->setText(QString("<h2>%1</h2>").arg(QString::fromStdString(m_Form->GetTitle()))); |
| 179 | |
| 180 | int sectionIndex = m_Ui->sectionWidget->currentIndex(); |
| 181 | bool showDescription = sectionIndex == 0 && !m_Form->GetDescription().empty(); |
| 182 | |
| 183 | m_Ui->formDescriptionLabel->setVisible(showDescription); |
| 184 | |
| 185 | if (showDescription) |
| 186 | m_Ui->formDescriptionLabel->setText(QString::fromStdString(m_Form->GetDescription())); |
| 187 | |
| 188 | bool hasRequiredQuestion = false; |
| 189 | |
| 190 | for (auto question : m_Form->GetSection(sectionIndex).GetQuestions()) |
| 191 | { |
| 192 | if (question->IsRequired()) |
| 193 | { |
| 194 | hasRequiredQuestion = true; |
| 195 | break; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | m_Ui->requiredLabel->setVisible(hasRequiredQuestion); |
| 200 | |
| 201 | m_Ui->formHeaderFrame->setVisible(showTitle || showDescription || hasRequiredQuestion); |
| 202 | } |
| 203 | |
| 204 | void QmitkForm::UpdateSubmittedHeader() |
| 205 | { |
no test coverage detected