Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkXnatProjectWidget.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 rmatics.
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 "QmitkXnatProjectWidget.h"
18 
19 #include <ctkXnatProject.h>
20 
21 QmitkXnatProjectWidget::QmitkXnatProjectWidget(QWidget *parent) : QWidget(parent)
22 {
23  m_Mode = INFO;
24  Init();
25 }
26 
27 QmitkXnatProjectWidget::QmitkXnatProjectWidget(Mode mode, QWidget *parent) : QWidget(parent), m_Mode(mode)
28 {
29  Init();
30 }
31 
33 {
34 }
35 
36 void QmitkXnatProjectWidget::Init()
37 {
38  // Create GUI widgets from the Qt Designer's .ui file
39  m_Controls.setupUi(this);
40 
41  if (m_Mode == Mode::INFO)
42  {
43  // make not needed row invisible
44  m_Controls.idLabel->setVisible(false);
45  m_Controls.idLineEdit->setVisible(false);
46  m_Controls.mandatoryLabel->setVisible(false);
47  }
48 }
49 
50 void QmitkXnatProjectWidget::SetProject(ctkXnatProject *project)
51 {
52  m_Project = project;
53 
54  // Set the UI labels
55  m_Controls.nameLineEdit->setText(m_Project->property("name"));
56  m_Controls.descriptionLineEdit->setText(m_Project->property("description"));
57  if (!m_Project->property("pi_lastname").isEmpty())
58  {
59  m_Controls.piLineEdit->setText(m_Project->property("pi_lastname") + ", " + m_Project->property("pi_firstname"));
60  }
61 }
62 
63 ctkXnatProject *QmitkXnatProjectWidget::GetProject() const
64 {
65  if (m_Mode == Mode::CREATE)
66  {
67  if (!m_Controls.idLineEdit->text().isEmpty())
68  {
69  m_Project->setProperty("ID", m_Controls.idLineEdit->text());
70  }
71  if (!m_Controls.nameLineEdit->text().isEmpty())
72  {
73  m_Project->setProperty("name", m_Controls.nameLineEdit->text());
74  }
75  if (!m_Controls.descriptionLineEdit->text().isEmpty())
76  {
77  m_Project->setProperty("description", m_Controls.descriptionLineEdit->text());
78  }
79  // pi name needs to be inserted separated
80  }
81  return m_Project;
82 }
QmitkXnatProjectWidget(QWidget *parent=nullptr)
Ui::QmitkXnatProjectWidgetControls m_Controls
void SetProject(ctkXnatProject *project)
ctkXnatProject * GetProject() const