28 #include <QCoreApplication> 31 #include <QMessageBox> 33 #include <QModelIndex> 34 #include <QPersistentModelIndex> 35 #include <QProgressDialog> 42 #include <QHBoxLayout> 46 #include "ctkDirectoryButton.h" 47 #include "ctkFileDialog.h" 50 #include "ctkDICOMDatabase.h" 51 #include "ctkDICOMFilterProxyModel.h" 52 #include "ctkDICOMIndexer.h" 58 #include "ctkThumbnailLabel.h" 59 #include "ctkDICOMQueryResultsTabWidget.h" 60 #include "ctkDICOMQueryRetrieveWidget.h" 61 #include "ctkDICOMQueryWidget.h" 73 #include <ctkLogger.h> 74 static ctkLogger logger(
"org.commontk.DICOM.Widgets.DICOMAppWidget");
116 std::map<ctkDICOMModel::IndexType, QStringList>
getSelection()
const;
136 DICOMDatabase = QSharedPointer<ctkDICOMDatabase> (
new ctkDICOMDatabase);
138 DICOMDatabase->setThumbnailGenerator(ThumbnailGenerator.data());
164 QString helpText =
"Open a DICOM file or folder and make it ready for import";
167 ActionImport->setIcon(QIcon(
":/icons/open_icon_library/document-open-7.png"));
172 helpText =
"Remove the selected series";
175 ActionRemove->setIcon(QIcon(
":/icons/open_icon_library/dialog-close.png"));
176 q->connect(
ActionRemove, SIGNAL(triggered()), q, SLOT(onRemoveAction()));
181 helpText =
"Query and Retrieve DICOM studies from a DICOM database";
184 ActionQuery->setIcon(QIcon(
":/icons/message_levels/dialog-information-4.png"));
185 q->connect(
ActionQuery, SIGNAL(triggered()), q, SLOT(openQueryDialog()));
189 QSplitter* splitter =
new QSplitter;
190 splitter->setOrientation(Qt::Vertical);
194 TreeView->setAlternatingRowColors(
true);
197 QWidget* ThumbnailsFullWidget =
new QWidget;
198 splitter->addWidget(ThumbnailsFullWidget);
199 QVBoxLayout* ThumbnailsFullWidgetLayout =
new QVBoxLayout(ThumbnailsFullWidget);
200 ThumbnailsFullWidgetLayout->setMargin(0);
203 ThumbnailsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
212 connect(
ThumbnailWidthSlider, SIGNAL(valueChanged(
int)), q, SLOT(onThumbnailWidthSliderValueChanged(
int)));
221 q->connect(db, SIGNAL(schemaUpdateStarted(
int)), q, SLOT(schemaUpdateStarted(
int)));
222 q->connect(db, SIGNAL(schemaUpdateProgress(
int)), q, SLOT(schemaUpdateProgress(
int)));
223 q->connect(db, SIGNAL(schemaUpdateProgress(QString)), q, SLOT(schemaUpdateProgress(QString)));
224 q->connect(db, SIGNAL(schemaUpdated()), q, SLOT(schemaUpdated()));
266 void DICOMAppWidget::schemaUpdateStarted(
int)
270 void DICOMAppWidget::schemaUpdateProgress(QString val)
273 void DICOMAppWidget::schemaUpdateProgress(
int val)
276 void DICOMAppWidget::schemaUpdated()
283 QModelIndexList selection =
TreeView->selectionModel()->selectedIndexes();
286 foreach(index,selection)
288 if (index.column()!=0)
298 std::map<ctkDICOMModel::IndexType, QStringList> retval;
299 QModelIndexList selection =
TreeView->selectionModel()->selectedIndexes();
302 foreach(index,selection)
304 QModelIndex index0 = index.sibling(index.row(), 0);
309 retval[type].removeDuplicates();
345 connect(&d->Importer, SIGNAL(indexingCompleted()),
346 &d->mDICOMModel, SLOT(reset()));
351 d->TreeView->setSortingEnabled(
true);
352 d->TreeView->setSelectionBehavior(QAbstractItemView::SelectRows);
353 d->TreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
354 d->DICOMProxyModel.setSourceModel(&d->mDICOMModel);
355 d->TreeView->setModel(&d->mDICOMModel);
357 d->ThumbnailsWidget->setThumbnailSize(
358 QSize(d->ThumbnailWidthSlider->value(), d->ThumbnailWidthSlider->value()));
361 connect(d->TreeView, SIGNAL(collapsed(QModelIndex)),
this, SLOT(
onTreeCollapsed(QModelIndex)));
362 connect(d->TreeView, SIGNAL(expanded(QModelIndex)),
this, SLOT(
onTreeExpanded(QModelIndex)));
365 d->ToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
371 connect(d->TreeView->selectionModel(),
372 &QItemSelectionModel::selectionChanged,
375 connect(d->TreeView->selectionModel(),
376 &QItemSelectionModel::currentChanged,
381 connect(d->TreeView, SIGNAL(clicked(QModelIndex)),
this, SLOT(
onModelSelected(QModelIndex)));
399 return d->Importer.displayImportSummary();
406 return d->Importer.setDisplayImportSummary(onOff);
413 return d->Importer.patientsAddedDuringImport();
420 return d->Importer.studiesAddedDuringImport();
427 return d->Importer.seriesAddedDuringImport();
434 return d->Importer.instancesAddedDuringImport();
442 d->showUpdateSchemaDialog();
443 d->DICOMDatabase->updateSchemaIfNeeded();
452 settings.
setValue(
"DatabaseDirectory", directory);
456 d->DICOMDatabase->closeDatabase();
459 QString databaseFileName = directory + QString(
"/ctkDICOM.sql");
462 d->DICOMDatabase->openDatabase( databaseFileName );
464 CX_LOG_CHANNEL_INFO(
"dicom") <<
"Open Database " << databaseFileName.toStdString() <<
", open= " << d->DICOMDatabase->isOpen();
467 catch (std::exception& e)
469 CX_LOG_CHANNEL_ERROR(
"dicom") <<
"Database error: " << qPrintable(d->DICOMDatabase->lastError());
471 d->DICOMDatabase->closeDatabase();
478 d->mDICOMModel.setDatabase(d->DICOMDatabase);
480 d->TreeView->resizeColumnToContents(0);
481 d->Importer.setDatabase(d->DICOMDatabase);
484 d->ThumbnailsWidget->setDatabaseDirectory(directory);
485 d->ThumbnailsWidget->setDatabase(d->DICOMDatabase);
493 return settings.
value(
"DatabaseDirectory").toString();
500 d->DICOMDatabase->setTagsToPrecache(tags);
507 return d->DICOMDatabase->tagsToPrecache();
513 return d->DICOMDatabase.data();
521 d->getQueryRetrieveWidget()->show();
522 d->getQueryRetrieveWidget()->raise();
530 d->mDICOMModel.reset();
554 d->removeSelection();
561 d->mDICOMModel.setDatabase(d->DICOMDatabase);
568 d->mDICOMModel.reset();
575 d->Importer.onImportDirectory(directory);
585 d->ThumbnailsWidget->addThumbnails(next);
592 ctkDICOMModel* model =
const_cast<ctkDICOMModel*
>(qobject_cast<
const ctkDICOMModel*>(index.model()));
596 QModelIndex index0 = index.sibling(index.row(), 0);
598 d->ActionRemove->setEnabled(
605 d->ActionRemove->setEnabled(
false);
613 d->TreeView->resizeColumnToContents(0);
620 d->TreeView->resizeColumnToContents(0);
621 d->TreeView->resizeColumnToContents(1);
628 d->ThumbnailsWidget->setThumbnailSize(QSize(val, val));
634 d->ToolBar->addAction(action);
639 return d_ptr->mAdvancedActions;
#define CX_LOG_CHANNEL_INFO(channel)
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
Settings * settings()
Shortcut for accessing the settings instance.
thumbnail generator class
#define CX_LOG_CHANNEL_ERROR(channel)
Namespace for all CustusX production code.