15 #include <QMessageBox> 16 #include <QProgressDialog> 18 #include <QFileDialog> 21 #include "ctkDICOMDatabase.h" 22 #include "ctkDICOMIndexer.h" 31 DICOMIndexer = QSharedPointer<ctkDICOMIndexer> (
new ctkDICOMIndexer);
33 DisplayImportSummary =
true;
34 PatientsAddedDuringImport = 0;
35 StudiesAddedDuringImport = 0;
36 SeriesAddedDuringImport = 0;
37 InstancesAddedDuringImport = 0;
42 delete IndexerProgress;
49 disconnect(DICOMDatabase.data(), SIGNAL(patientAdded(
int,QString,QString,QString)),
this,
50 SLOT(onPatientAdded(
int,QString,QString,QString)));
51 disconnect(DICOMDatabase.data(), SIGNAL(studyAdded(QString)),
this, SLOT(onStudyAdded(QString)));
52 disconnect(DICOMDatabase.data(), SIGNAL(seriesAdded(QString)),
this, SLOT(onSeriesAdded(QString)));
53 disconnect(DICOMDatabase.data(), SIGNAL(instanceAdded(QString)),
this, SLOT(onInstanceAdded(QString)));
56 DICOMDatabase = database;
60 connect(DICOMDatabase.data(), SIGNAL(patientAdded(
int,QString,QString,QString)),
this,
61 SLOT(onPatientAdded(
int,QString,QString,QString)));
62 connect(DICOMDatabase.data(), SIGNAL(studyAdded(QString)),
this, SLOT(onStudyAdded(QString)));
63 connect(DICOMDatabase.data(), SIGNAL(seriesAdded(QString)),
this, SLOT(onSeriesAdded(QString)));
64 connect(DICOMDatabase.data(), SIGNAL(instanceAdded(QString)),
this, SLOT(onInstanceAdded(QString)));
68 void DicomImporter::showIndexerDialog()
70 if (IndexerProgress == 0)
75 IndexerProgress =
new QProgressDialog(
"DICOM Import",
"Cancel", 0, 100, NULL,
76 Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
80 QLabel* progressLabel =
new QLabel(
"Initialization...");
81 IndexerProgress->setLabel(progressLabel);
82 IndexerProgress->setWindowModality(Qt::ApplicationModal);
83 IndexerProgress->setMinimumDuration(0);
84 IndexerProgress->setValue(0);
86 connect(IndexerProgress, SIGNAL(canceled()),
87 DICOMIndexer.data(), SLOT(cancel()));
89 connect(DICOMIndexer.data(), SIGNAL(progress(
int)),
90 IndexerProgress, SLOT(setValue(
int)));
91 connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
92 progressLabel, SLOT(setText(QString)));
93 connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
95 connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
96 this, SLOT(onFileIndexed(QString)));
99 connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
100 IndexerProgress, SLOT(close()));
102 connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
105 connect(IndexerProgress, SIGNAL(canceled()),
106 DICOMIndexer.data(), SLOT(cancel()));
107 connect(IndexerProgress, SIGNAL(canceled()),
111 connect(IndexerProgress, SIGNAL(canceled()),
113 connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
116 IndexerProgress->show();
121 return DisplayImportSummary;
126 DisplayImportSummary = onOff;
131 return PatientsAddedDuringImport;
136 return StudiesAddedDuringImport;
141 return SeriesAddedDuringImport;
146 return InstancesAddedDuringImport;
150 void DicomImporter::onFileIndexed(
const QString& filePath)
154 QCoreApplication::instance()->processEvents();
160 void DicomImporter::openImportDialog()
162 QString folder = QFileDialog::getExistingDirectory(NULL,
"Import DICOM files from directory ...",
"", QFileDialog::ShowDirsOnly);
163 if (!folder.isEmpty())
170 void DicomImporter::onPatientAdded(
int databaseID, QString patientID, QString patientName, QString patientBirthDate )
172 Q_UNUSED(databaseID);
174 Q_UNUSED(patientName);
175 Q_UNUSED(patientBirthDate);
176 ++PatientsAddedDuringImport;
180 void DicomImporter::onStudyAdded(QString studyUID)
183 ++StudiesAddedDuringImport;
187 void DicomImporter::onSeriesAdded(QString seriesUID)
190 ++SeriesAddedDuringImport;
194 void DicomImporter::onInstanceAdded(QString instanceUID)
196 Q_UNUSED(instanceUID);
197 ++InstancesAddedDuringImport;
203 if (QDir(directory).exists())
206 PatientsAddedDuringImport = 0;
207 StudiesAddedDuringImport = 0;
208 SeriesAddedDuringImport = 0;
209 InstancesAddedDuringImport = 0;
213 DICOMIndexer->addDirectory(*DICOMDatabase,directory);
216 if (DisplayImportSummary)
218 QString message =
"Directory import completed.\n\n";
219 message += QString(
"%1 New Patients\n").arg(QString::number(PatientsAddedDuringImport));
220 message += QString(
"%1 New Studies\n").arg(QString::number(StudiesAddedDuringImport));
221 message += QString(
"%1 New Series\n").arg(QString::number(SeriesAddedDuringImport));
222 message += QString(
"%1 New Instances\n").arg(QString::number(InstancesAddedDuringImport));
223 QMessageBox::information(NULL,
"DICOM Directory Import", message);
int seriesAddedDuringImport()
bool displayImportSummary()
int studiesAddedDuringImport()
void setDatabase(QSharedPointer< ctkDICOMDatabase > database)
int patientsAddedDuringImport()
Accessors to status of last directory import operation.
void setDisplayImportSummary(bool)
void reportWarning(QString msg)
DicomImporter(QObject *parent=NULL)
void onImportDirectory(QString directory)
void fileIndexed(QString)
int instancesAddedDuringImport()
Namespace for all CustusX production code.