123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- /*=========================================================================
- Library: CTK
- Copyright (c) Kitware Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0.txt
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- =========================================================================*/
- // ctk includes
- #include "ctkDICOMTableManager.h"
- #include "ctkDICOMTableView.h"
- #include "ui_ctkDICOMTableManager.h"
- // Qt includes
- #include <QHBoxLayout>
- #include <QVBoxLayout>
- #include <QSplitter>
- class ctkDICOMTableManagerPrivate : public Ui_ctkDICOMTableManager
- {
- Q_DECLARE_PUBLIC(ctkDICOMTableManager)
- protected:
- ctkDICOMTableManager* const q_ptr;
- public:
- ctkDICOMTableManagerPrivate(ctkDICOMTableManager& obj);
- ~ctkDICOMTableManagerPrivate();
- void init();
- void setCTKDICOMDatabase(ctkDICOMDatabase *db);
- ctkDICOMDatabase* dicomDatabase;
- };
- ctkDICOMTableManagerPrivate::ctkDICOMTableManagerPrivate(ctkDICOMTableManager &obj)
- : q_ptr(&obj)
- {
- }
- ctkDICOMTableManagerPrivate::~ctkDICOMTableManagerPrivate()
- {
- }
- void ctkDICOMTableManagerPrivate::init()
- {
- //setup UI
- Q_Q(ctkDICOMTableManager);
- this->setupUi(q);
- this->patientsTable->setQueryTableName("Patients");
- this->studiesTable->setQueryTableName("Studies");
- this->studiesTable->setQueryForeignKey("PatientsUID");
- this->seriesTable->setQueryTableName("Series");
- this->seriesTable->setQueryForeignKey("StudyInstanceUID");
- // For propagating patient selection changes
- QObject::connect(this->patientsTable, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
- q, SIGNAL(patientsSelectionChanged(const QItemSelection&, const QItemSelection&)));
- QObject::connect(this->patientsTable, SIGNAL(selectionChanged(const QStringList&)),
- q, SIGNAL(patientsSelectionChanged(const QStringList&)));
- // For propagating study selection changes
- QObject::connect(this->studiesTable, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
- q, SIGNAL(studiesSelectionChanged(const QItemSelection&, const QItemSelection&)));
- QObject::connect(this->studiesTable, SIGNAL(selectionChanged(const QStringList&)),
- q, SIGNAL(studiesSelectionChanged(const QStringList&)));
- // For propagating series selection changes
- QObject::connect(this->seriesTable, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
- q, SIGNAL(seriesSelectionChanged(const QItemSelection&, const QItemSelection&)));
- QObject::connect(this->seriesTable, SIGNAL(selectionChanged(const QStringList&)),
- q, SIGNAL(seriesSelectionChanged(const QStringList&)));
- }
- void ctkDICOMTableManagerPrivate::setCTKDICOMDatabase(ctkDICOMDatabase* db)
- {
- this->patientsTable->setCTKDicomDataBase(db);
- this->studiesTable->setCTKDicomDataBase(db);
- this->seriesTable->setCTKDicomDataBase(db);
- dicomDatabase = db;
- }
- //----------------------------------------------------------------------------
- // ctkDICOMTableManager methods
- //----------------------------------------------------------------------------
- ctkDICOMTableManager::ctkDICOMTableManager(QWidget *parent)
- :Superclass(parent)
- , d_ptr(new ctkDICOMTableManagerPrivate(*this))
- {
- Q_D(ctkDICOMTableManager);
- d->init();
- }
- ctkDICOMTableManager::ctkDICOMTableManager(ctkDICOMDatabase *db, QWidget *parent)
- : Superclass(parent)
- , d_ptr(new ctkDICOMTableManagerPrivate(*this))
- {
- Q_D(ctkDICOMTableManager);
- d->init();
- d->setCTKDICOMDatabase(db);
- }
- ctkDICOMTableManager::~ctkDICOMTableManager()
- {
- }
- void ctkDICOMTableManager::setCTKDICOMDatabase(ctkDICOMDatabase* db)
- {
- Q_D(ctkDICOMTableManager);
- d->setCTKDICOMDatabase(db);
- }
- void ctkDICOMTableManager::setTableOrientation(const Qt::Orientation &o)
- {
- Q_D(ctkDICOMTableManager);
- d->tableSplitter->setOrientation(o);
- }
- Qt::Orientation ctkDICOMTableManager::tableOrientation()
- {
- Q_D(ctkDICOMTableManager);
- return d->tableSplitter->orientation();
- }
- void ctkDICOMTableManager::deleteSelectedRows()
- {
- Q_D(ctkDICOMTableManager);
- QStringList seriesUIDS = d->seriesTable->currentSelection();
- if (seriesUIDS.size() != 0)
- {
- QString seriesUID;
- foreach (seriesUID, seriesUIDS)
- {
- d->dicomDatabase->removeSeries(seriesUID);
- }
- return;
- }
- QStringList studiesUIDS = d->studiesTable->currentSelection();
- if (studiesUIDS.size() != 0)
- {
- QString studyUID;
- foreach (studyUID, studiesUIDS)
- {
- d->dicomDatabase->removeStudy(studyUID);
- }
- return;
- }
- QStringList patientsUIDS = d->patientsTable->currentSelection();
- if (patientsUIDS.size() != 0)
- {
- QString patienUID;
- foreach (patienUID, patientsUIDS)
- {
- d->dicomDatabase->removePatient(patienUID);
- }
- return;
- }
- }
|