Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkXnatSubjectWidget.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkXnatSubjectWidget.h"
18 
19 #include <ctkXnatSubject.h>
20 #include <iostream>
21 
22 QmitkXnatSubjectWidget::QmitkXnatSubjectWidget(QWidget *parent) : QWidget(parent)
23 {
24  m_Mode = INFO;
25  Init();
26 }
27 
28 QmitkXnatSubjectWidget::QmitkXnatSubjectWidget(Mode mode, QWidget *parent) : QWidget(parent), m_Mode(mode)
29 {
30  Init();
31 }
32 
34 {
35 }
36 
37 void QmitkXnatSubjectWidget::Init()
38 {
39  // Create GUI widgets from the Qt Designer's .ui file
40  m_Controls.setupUi(this);
41 
42  if (m_Mode == Mode::INFO)
43  {
44  // make not needed row invisible
45  m_Controls.labelLabel->setText("ID:");
46  m_Controls.mandatoryLabel->setVisible(false);
47  }
48 }
49 
50 void QmitkXnatSubjectWidget::SetSubject(ctkXnatSubject *subject)
51 {
52  m_Subject = subject;
53 
54  // Set the UI labels
55  if (m_Subject->parent())
56  {
57  m_Controls.breadcrumbLabel->setText("Project:" + m_Subject->parent()->property("name"));
58  }
59  m_Controls.labelLineEdit->setText(m_Subject->property("label"));
60  m_Controls.birthdateLineEdit->setText(m_Subject->property("dob"));
61  m_Controls.genderLineEdit->setText(m_Subject->property("gender"));
62  m_Controls.handednessLineEdit->setText(m_Subject->property("handedness"));
63  m_Controls.heightLineEdit->setText(m_Subject->property("height"));
64  m_Controls.weightLineEdit->setText(m_Subject->property("weight"));
65 }
66 
67 ctkXnatSubject *QmitkXnatSubjectWidget::GetSubject() const
68 {
69  if (m_Mode == CREATE)
70  {
71  if (!m_Controls.labelLineEdit->text().isEmpty())
72  {
73  m_Subject->setProperty("label", m_Controls.labelLineEdit->text());
74  }
75  if (!m_Controls.birthdateLineEdit->text().isEmpty())
76  {
77  m_Subject->setProperty("dob", m_Controls.birthdateLineEdit->text());
78  }
79  if (!m_Controls.genderLineEdit->text().isEmpty())
80  {
81  m_Subject->setProperty("gender", m_Controls.genderLineEdit->text());
82  }
83  if (!m_Controls.handednessLineEdit->text().isEmpty())
84  {
85  m_Subject->setProperty("handedness", m_Controls.handednessLineEdit->text());
86  }
87  if (!m_Controls.heightLineEdit->text().isEmpty())
88  {
89  m_Subject->setProperty("height", m_Controls.heightLineEdit->text());
90  }
91  if (!m_Controls.weightLineEdit->text().isEmpty())
92  {
93  m_Subject->setProperty("weight", m_Controls.weightLineEdit->text());
94  }
95  }
96 
97  return m_Subject;
98 }
QmitkXnatSubjectWidget(QWidget *parent=nullptr)
Ui::QmitkXnatSubjectWidgetControls m_Controls
ctkXnatSubject * GetSubject() const
void SetSubject(ctkXnatSubject *subject)