ctkDICOMTableManager.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // ctk includes
  15. #include "ctkDICOMTableManager.h"
  16. #include "ctkDICOMTableView.h"
  17. #include "ui_ctkDICOMTableManager.h"
  18. // Qt includes
  19. #include <QHBoxLayout>
  20. #include <QVBoxLayout>
  21. #include <QSplitter>
  22. class ctkDICOMTableManagerPrivate : public Ui_ctkDICOMTableManager
  23. {
  24. Q_DECLARE_PUBLIC(ctkDICOMTableManager)
  25. protected:
  26. ctkDICOMTableManager* const q_ptr;
  27. public:
  28. ctkDICOMTableManagerPrivate(ctkDICOMTableManager& obj);
  29. ~ctkDICOMTableManagerPrivate();
  30. void init();
  31. void setCTKDICOMDatabase(ctkDICOMDatabase *db);
  32. ctkDICOMDatabase* dicomDatabase;
  33. };
  34. ctkDICOMTableManagerPrivate::ctkDICOMTableManagerPrivate(ctkDICOMTableManager &obj)
  35. : q_ptr(&obj)
  36. {
  37. }
  38. ctkDICOMTableManagerPrivate::~ctkDICOMTableManagerPrivate()
  39. {
  40. }
  41. void ctkDICOMTableManagerPrivate::init()
  42. {
  43. //setup UI
  44. Q_Q(ctkDICOMTableManager);
  45. this->setupUi(q);
  46. this->patientsTable->setQueryTableName("Patients");
  47. this->studiesTable->setQueryTableName("Studies");
  48. this->studiesTable->setQueryForeignKey("PatientsUID");
  49. this->seriesTable->setQueryTableName("Series");
  50. this->seriesTable->setQueryForeignKey("StudyInstanceUID");
  51. // For propagating patient selection changes
  52. QObject::connect(this->patientsTable, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
  53. q, SIGNAL(patientsSelectionChanged(const QItemSelection&, const QItemSelection&)));
  54. QObject::connect(this->patientsTable, SIGNAL(selectionChanged(const QStringList&)),
  55. q, SIGNAL(patientsSelectionChanged(const QStringList&)));
  56. // For propagating study selection changes
  57. QObject::connect(this->studiesTable, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
  58. q, SIGNAL(studiesSelectionChanged(const QItemSelection&, const QItemSelection&)));
  59. QObject::connect(this->studiesTable, SIGNAL(selectionChanged(const QStringList&)),
  60. q, SIGNAL(studiesSelectionChanged(const QStringList&)));
  61. // For propagating series selection changes
  62. QObject::connect(this->seriesTable, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
  63. q, SIGNAL(seriesSelectionChanged(const QItemSelection&, const QItemSelection&)));
  64. QObject::connect(this->seriesTable, SIGNAL(selectionChanged(const QStringList&)),
  65. q, SIGNAL(seriesSelectionChanged(const QStringList&)));
  66. }
  67. void ctkDICOMTableManagerPrivate::setCTKDICOMDatabase(ctkDICOMDatabase* db)
  68. {
  69. this->patientsTable->setCTKDicomDataBase(db);
  70. this->studiesTable->setCTKDicomDataBase(db);
  71. this->seriesTable->setCTKDicomDataBase(db);
  72. dicomDatabase = db;
  73. }
  74. //----------------------------------------------------------------------------
  75. // ctkDICOMTableManager methods
  76. //----------------------------------------------------------------------------
  77. ctkDICOMTableManager::ctkDICOMTableManager(QWidget *parent)
  78. :Superclass(parent)
  79. , d_ptr(new ctkDICOMTableManagerPrivate(*this))
  80. {
  81. Q_D(ctkDICOMTableManager);
  82. d->init();
  83. }
  84. ctkDICOMTableManager::ctkDICOMTableManager(ctkDICOMDatabase *db, QWidget *parent)
  85. : Superclass(parent)
  86. , d_ptr(new ctkDICOMTableManagerPrivate(*this))
  87. {
  88. Q_D(ctkDICOMTableManager);
  89. d->init();
  90. d->setCTKDICOMDatabase(db);
  91. }
  92. ctkDICOMTableManager::~ctkDICOMTableManager()
  93. {
  94. }
  95. void ctkDICOMTableManager::setCTKDICOMDatabase(ctkDICOMDatabase* db)
  96. {
  97. Q_D(ctkDICOMTableManager);
  98. d->setCTKDICOMDatabase(db);
  99. }
  100. void ctkDICOMTableManager::setTableOrientation(const Qt::Orientation &o)
  101. {
  102. Q_D(ctkDICOMTableManager);
  103. d->tableSplitter->setOrientation(o);
  104. }
  105. Qt::Orientation ctkDICOMTableManager::tableOrientation()
  106. {
  107. Q_D(ctkDICOMTableManager);
  108. return d->tableSplitter->orientation();
  109. }
  110. void ctkDICOMTableManager::deleteSelectedRows()
  111. {
  112. Q_D(ctkDICOMTableManager);
  113. QStringList seriesUIDS = d->seriesTable->currentSelection();
  114. if (seriesUIDS.size() != 0)
  115. {
  116. QString seriesUID;
  117. foreach (seriesUID, seriesUIDS)
  118. {
  119. d->dicomDatabase->removeSeries(seriesUID);
  120. }
  121. return;
  122. }
  123. QStringList studiesUIDS = d->studiesTable->currentSelection();
  124. if (studiesUIDS.size() != 0)
  125. {
  126. QString studyUID;
  127. foreach (studyUID, studiesUIDS)
  128. {
  129. d->dicomDatabase->removeStudy(studyUID);
  130. }
  131. return;
  132. }
  133. QStringList patientsUIDS = d->patientsTable->currentSelection();
  134. if (patientsUIDS.size() != 0)
  135. {
  136. QString patienUID;
  137. foreach (patienUID, patientsUIDS)
  138. {
  139. d->dicomDatabase->removePatient(patienUID);
  140. }
  141. return;
  142. }
  143. }