36 #include <QMessageBox> 37 #include <QProgressDialog> 39 #include <QFileDialog> 42 #include "ctkDICOMDatabase.h" 43 #include "ctkDICOMIndexer.h" 52 DICOMIndexer = QSharedPointer<ctkDICOMIndexer> (
new ctkDICOMIndexer);
54 DisplayImportSummary =
true;
55 PatientsAddedDuringImport = 0;
56 StudiesAddedDuringImport = 0;
57 SeriesAddedDuringImport = 0;
58 InstancesAddedDuringImport = 0;
63 delete IndexerProgress;
70 disconnect(DICOMDatabase.data(), SIGNAL(patientAdded(
int,QString,QString,QString)),
this,
71 SLOT(onPatientAdded(
int,QString,QString,QString)));
72 disconnect(DICOMDatabase.data(), SIGNAL(studyAdded(QString)),
this, SLOT(onStudyAdded(QString)));
73 disconnect(DICOMDatabase.data(), SIGNAL(seriesAdded(QString)),
this, SLOT(onSeriesAdded(QString)));
74 disconnect(DICOMDatabase.data(), SIGNAL(instanceAdded(QString)),
this, SLOT(onInstanceAdded(QString)));
77 DICOMDatabase = database;
81 connect(DICOMDatabase.data(), SIGNAL(patientAdded(
int,QString,QString,QString)),
this,
82 SLOT(onPatientAdded(
int,QString,QString,QString)));
83 connect(DICOMDatabase.data(), SIGNAL(studyAdded(QString)),
this, SLOT(onStudyAdded(QString)));
84 connect(DICOMDatabase.data(), SIGNAL(seriesAdded(QString)),
this, SLOT(onSeriesAdded(QString)));
85 connect(DICOMDatabase.data(), SIGNAL(instanceAdded(QString)),
this, SLOT(onInstanceAdded(QString)));
89 void DicomImporter::showIndexerDialog()
91 if (IndexerProgress == 0)
96 IndexerProgress =
new QProgressDialog(
"DICOM Import",
"Cancel", 0, 100, NULL,
97 Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
101 QLabel* progressLabel =
new QLabel(
"Initialization...");
102 IndexerProgress->setLabel(progressLabel);
103 IndexerProgress->setWindowModality(Qt::ApplicationModal);
104 IndexerProgress->setMinimumDuration(0);
105 IndexerProgress->setValue(0);
107 connect(IndexerProgress, SIGNAL(canceled()),
108 DICOMIndexer.data(), SLOT(cancel()));
110 connect(DICOMIndexer.data(), SIGNAL(progress(
int)),
111 IndexerProgress, SLOT(setValue(
int)));
112 connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
113 progressLabel, SLOT(setText(QString)));
114 connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
116 connect(DICOMIndexer.data(), SIGNAL(indexingFilePath(QString)),
117 this, SLOT(onFileIndexed(QString)));
120 connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
121 IndexerProgress, SLOT(close()));
123 connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
126 connect(IndexerProgress, SIGNAL(canceled()),
127 DICOMIndexer.data(), SLOT(cancel()));
128 connect(IndexerProgress, SIGNAL(canceled()),
132 connect(IndexerProgress, SIGNAL(canceled()),
134 connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
137 IndexerProgress->show();
142 return DisplayImportSummary;
147 DisplayImportSummary = onOff;
152 return PatientsAddedDuringImport;
157 return StudiesAddedDuringImport;
162 return SeriesAddedDuringImport;
167 return InstancesAddedDuringImport;
171 void DicomImporter::onFileIndexed(
const QString& filePath)
175 QCoreApplication::instance()->processEvents();
181 void DicomImporter::openImportDialog()
183 QString folder = QFileDialog::getExistingDirectory(NULL,
"Import DICOM files from directory ...",
"", QFileDialog::ShowDirsOnly);
184 if (!folder.isEmpty())
191 void DicomImporter::onPatientAdded(
int databaseID, QString patientID, QString patientName, QString patientBirthDate )
193 Q_UNUSED(databaseID);
195 Q_UNUSED(patientName);
196 Q_UNUSED(patientBirthDate);
197 ++PatientsAddedDuringImport;
201 void DicomImporter::onStudyAdded(QString studyUID)
204 ++StudiesAddedDuringImport;
208 void DicomImporter::onSeriesAdded(QString seriesUID)
211 ++SeriesAddedDuringImport;
215 void DicomImporter::onInstanceAdded(QString instanceUID)
217 Q_UNUSED(instanceUID);
218 ++InstancesAddedDuringImport;
224 if (QDir(directory).exists())
227 PatientsAddedDuringImport = 0;
228 StudiesAddedDuringImport = 0;
229 SeriesAddedDuringImport = 0;
230 InstancesAddedDuringImport = 0;
234 DICOMIndexer->addDirectory(*DICOMDatabase,directory);
237 if (DisplayImportSummary)
239 QString message =
"Directory import completed.\n\n";
240 message += QString(
"%1 New Patients\n").arg(QString::number(PatientsAddedDuringImport));
241 message += QString(
"%1 New Studies\n").arg(QString::number(StudiesAddedDuringImport));
242 message += QString(
"%1 New Series\n").arg(QString::number(SeriesAddedDuringImport));
243 message += QString(
"%1 New Instances\n").arg(QString::number(InstancesAddedDuringImport));
244 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.