|
|
@@ -21,23 +21,14 @@
|
|
|
// std includes
|
|
|
#include <iostream>
|
|
|
|
|
|
-#include <dcmimage.h>
|
|
|
-
|
|
|
// Qt includes
|
|
|
#include <QAction>
|
|
|
#include <QCoreApplication>
|
|
|
#include <QCheckBox>
|
|
|
#include <QDebug>
|
|
|
#include <QMessageBox>
|
|
|
-#include <QMetaType>
|
|
|
-#include <QModelIndex>
|
|
|
-#include <QPersistentModelIndex>
|
|
|
#include <QProgressDialog>
|
|
|
#include <QSettings>
|
|
|
-#include <QSlider>
|
|
|
-#include <QTabBar>
|
|
|
-#include <QTimer>
|
|
|
-#include <QTreeView>
|
|
|
|
|
|
// ctkWidgets includes
|
|
|
#include "ctkDirectoryButton.h"
|
|
|
@@ -45,14 +36,10 @@
|
|
|
|
|
|
// ctkDICOMCore includes
|
|
|
#include "ctkDICOMDatabase.h"
|
|
|
-#include "ctkDICOMFilterProxyModel.h"
|
|
|
#include "ctkDICOMIndexer.h"
|
|
|
-#include "ctkDICOMModel.h"
|
|
|
|
|
|
// ctkDICOMWidgets includes
|
|
|
#include "ctkDICOMBrowser.h"
|
|
|
-#include "ctkDICOMThumbnailGenerator.h"
|
|
|
-#include "ctkThumbnailLabel.h"
|
|
|
#include "ctkDICOMQueryResultsTabWidget.h"
|
|
|
#include "ctkDICOMQueryRetrieveWidget.h"
|
|
|
#include "ctkDICOMQueryWidget.h"
|
|
|
@@ -63,8 +50,6 @@
|
|
|
#include <ctkLogger.h>
|
|
|
static ctkLogger logger("org.commontk.DICOM.Widgets.ctkDICOMBrowser");
|
|
|
|
|
|
-Q_DECLARE_METATYPE(QPersistentModelIndex);
|
|
|
-
|
|
|
//----------------------------------------------------------------------------
|
|
|
class ctkDICOMBrowserPrivate: public Ui_ctkDICOMBrowser
|
|
|
{
|
|
|
@@ -79,9 +64,6 @@ public:
|
|
|
ctkDICOMQueryRetrieveWidget* QueryRetrieveWidget;
|
|
|
|
|
|
QSharedPointer<ctkDICOMDatabase> DICOMDatabase;
|
|
|
- QSharedPointer<ctkDICOMThumbnailGenerator> ThumbnailGenerator;
|
|
|
- ctkDICOMModel DICOMModel;
|
|
|
- ctkDICOMFilterProxyModel DICOMProxyModel;
|
|
|
QSharedPointer<ctkDICOMIndexer> DICOMIndexer;
|
|
|
QProgressDialog *IndexerProgress;
|
|
|
QProgressDialog *UpdateSchemaProgress;
|
|
|
@@ -92,10 +74,6 @@ public:
|
|
|
// used when suspending the ctkDICOMModel
|
|
|
QSqlDatabase EmptyDatabase;
|
|
|
|
|
|
- QTimer* AutoPlayTimer;
|
|
|
-
|
|
|
- bool IsSearchWidgetPopUpMode;
|
|
|
-
|
|
|
// local count variables to keep track of the number of items
|
|
|
// added to the database during an import operation
|
|
|
bool DisplayImportSummary;
|
|
|
@@ -110,8 +88,6 @@ public:
|
|
|
|
|
|
ctkDICOMBrowserPrivate::ctkDICOMBrowserPrivate(ctkDICOMBrowser* parent): q_ptr(parent){
|
|
|
DICOMDatabase = QSharedPointer<ctkDICOMDatabase> (new ctkDICOMDatabase);
|
|
|
- ThumbnailGenerator = QSharedPointer <ctkDICOMThumbnailGenerator> (new ctkDICOMThumbnailGenerator);
|
|
|
- DICOMDatabase->setThumbnailGenerator(ThumbnailGenerator.data());
|
|
|
DICOMIndexer = QSharedPointer<ctkDICOMIndexer> (new ctkDICOMIndexer);
|
|
|
IndexerProgress = 0;
|
|
|
UpdateSchemaProgress = 0;
|
|
|
@@ -154,9 +130,6 @@ void ctkDICOMBrowserPrivate::showUpdateSchemaDialog()
|
|
|
UpdateSchemaProgress->setMinimumDuration(0);
|
|
|
UpdateSchemaProgress->setValue(0);
|
|
|
|
|
|
- //q->connect(UpdateSchemaProgress, SIGNAL(canceled()),
|
|
|
- // DICOMIndexer.data(), SLOT(cancel()));
|
|
|
-
|
|
|
q->connect(DICOMDatabase.data(), SIGNAL(schemaUpdateStarted(int)),
|
|
|
UpdateSchemaProgress, SLOT(setMaximum(int)));
|
|
|
q->connect(DICOMDatabase.data(), SIGNAL(schemaUpdateProgress(int)),
|
|
|
@@ -167,12 +140,6 @@ void ctkDICOMBrowserPrivate::showUpdateSchemaDialog()
|
|
|
// close the dialog
|
|
|
q->connect(DICOMDatabase.data(), SIGNAL(schemaUpdated()),
|
|
|
UpdateSchemaProgress, SLOT(close()));
|
|
|
- // reset the database to show new data
|
|
|
- q->connect(DICOMDatabase.data(), SIGNAL(schemaUpdated()),
|
|
|
- &DICOMModel, SLOT(reset()));
|
|
|
- // reset the database if canceled
|
|
|
- q->connect(UpdateSchemaProgress, SIGNAL(canceled()),
|
|
|
- &DICOMModel, SLOT(reset()));
|
|
|
}
|
|
|
UpdateSchemaProgress->show();
|
|
|
}
|
|
|
@@ -209,14 +176,9 @@ void ctkDICOMBrowserPrivate::showIndexerDialog()
|
|
|
// close the dialog
|
|
|
q->connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
|
|
|
IndexerProgress, SLOT(close()));
|
|
|
- // reset the database to show new data
|
|
|
- q->connect(DICOMIndexer.data(), SIGNAL(indexingComplete()),
|
|
|
- &DICOMModel, SLOT(reset()));
|
|
|
// stop indexing and reset the database if canceled
|
|
|
q->connect(IndexerProgress, SIGNAL(canceled()),
|
|
|
DICOMIndexer.data(), SLOT(cancel()));
|
|
|
- q->connect(IndexerProgress, SIGNAL(canceled()),
|
|
|
- &DICOMModel, SLOT(reset()));
|
|
|
|
|
|
// allow users of this widget to know that the process has finished
|
|
|
q->connect(IndexerProgress, SIGNAL(canceled()),
|
|
|
@@ -238,25 +200,6 @@ ctkDICOMBrowser::ctkDICOMBrowser(QWidget* _parent):Superclass(_parent),
|
|
|
|
|
|
d->setupUi(this);
|
|
|
|
|
|
- this->setSearchWidgetPopUpMode(false);
|
|
|
-
|
|
|
- //Hide image previewer buttons
|
|
|
- d->NextImageButton->hide();
|
|
|
- d->PrevImageButton->hide();
|
|
|
- d->NextSeriesButton->hide();
|
|
|
- d->PrevSeriesButton->hide();
|
|
|
- d->NextStudyButton->hide();
|
|
|
- d->PrevStudyButton->hide();
|
|
|
-
|
|
|
- //Enable sorting in tree view
|
|
|
- d->TreeView->setSortingEnabled(true);
|
|
|
- d->TreeView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
|
- d->DICOMProxyModel.setSourceModel(&d->DICOMModel);
|
|
|
- d->TreeView->setModel(&d->DICOMModel);
|
|
|
-
|
|
|
- d->ThumbnailsWidget->setThumbnailSize(
|
|
|
- QSize(d->ThumbnailWidthSlider->value(), d->ThumbnailWidthSlider->value()));
|
|
|
-
|
|
|
// signals related to tracking inserts
|
|
|
connect(d->DICOMDatabase.data(), SIGNAL(patientAdded(int,QString,QString,QString)), this,
|
|
|
SLOT(onPatientAdded(int,QString,QString,QString)));
|
|
|
@@ -264,9 +207,6 @@ ctkDICOMBrowser::ctkDICOMBrowser(QWidget* _parent):Superclass(_parent),
|
|
|
connect(d->DICOMDatabase.data(), SIGNAL(seriesAdded(QString)), this, SLOT(onSeriesAdded(QString)));
|
|
|
connect(d->DICOMDatabase.data(), SIGNAL(instanceAdded(QString)), this, SLOT(onInstanceAdded(QString)));
|
|
|
|
|
|
- // Treeview signals
|
|
|
- connect(d->TreeView, SIGNAL(collapsed(QModelIndex)), this, SLOT(onTreeCollapsed(QModelIndex)));
|
|
|
- connect(d->TreeView, SIGNAL(expanded(QModelIndex)), this, SLOT(onTreeExpanded(QModelIndex)));
|
|
|
|
|
|
//Set ToolBar button style
|
|
|
d->ToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
|
@@ -287,6 +227,12 @@ ctkDICOMBrowser::ctkDICOMBrowser(QWidget* _parent):Superclass(_parent),
|
|
|
this->setDatabaseDirectory(databaseDirectory);
|
|
|
d->DirectoryButton->setDirectory(databaseDirectory);
|
|
|
|
|
|
+ // TableView signals
|
|
|
+ connect(d->dicomTableManager, SIGNAL(patientsSelectionChanged(const QItemSelection&, const QItemSelection&)),this, SLOT(onModelSelected(const QItemSelection&,const QItemSelection&)));
|
|
|
+ connect(d->dicomTableManager, SIGNAL(studiesSelectionChanged(const QItemSelection&, const QItemSelection&)),this, SLOT(onModelSelected(const QItemSelection&,const QItemSelection&)));
|
|
|
+ connect(d->dicomTableManager, SIGNAL(seriesSelectionChanged(const QItemSelection&, const QItemSelection&)),this, SLOT(onModelSelected(const QItemSelection&,const QItemSelection&)));
|
|
|
+ d->dicomTableManager->setCTKDICOMDatabase(d->DICOMDatabase.data());
|
|
|
+
|
|
|
connect(d->DirectoryButton, SIGNAL(directoryChanged(QString)), this, SLOT(setDatabaseDirectory(QString)));
|
|
|
|
|
|
//Initialize import widget
|
|
|
@@ -299,24 +245,10 @@ ctkDICOMBrowser::ctkDICOMBrowser(QWidget* _parent):Superclass(_parent),
|
|
|
d->ImportDialog->setWindowModality(Qt::ApplicationModal);
|
|
|
|
|
|
//connect signal and slots
|
|
|
- connect(d->TreeView, SIGNAL(clicked(QModelIndex)), d->ThumbnailsWidget, SLOT(addThumbnails(QModelIndex)));
|
|
|
- connect(d->TreeView, SIGNAL(clicked(QModelIndex)), d->ImagePreview, SLOT(onModelSelected(QModelIndex)));
|
|
|
- connect(d->TreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(onModelSelected(QModelIndex)));
|
|
|
-
|
|
|
- connect(d->ThumbnailsWidget, SIGNAL(selected(ctkThumbnailLabel)), this, SLOT(onThumbnailSelected(ctkThumbnailLabel)));
|
|
|
- connect(d->ThumbnailsWidget, SIGNAL(doubleClicked(ctkThumbnailLabel)), this, SLOT(onThumbnailDoubleClicked(ctkThumbnailLabel)));
|
|
|
connect(d->ImportDialog, SIGNAL(fileSelected(QString)),this,SLOT(onImportDirectory(QString)));
|
|
|
|
|
|
connect(d->QueryRetrieveWidget, SIGNAL(canceled()), d->QueryRetrieveWidget, SLOT(hide()) );
|
|
|
connect(d->QueryRetrieveWidget, SIGNAL(canceled()), this, SLOT(onQueryRetrieveFinished()) );
|
|
|
-
|
|
|
- connect(d->ImagePreview, SIGNAL(requestNextImage()), this, SLOT(onNextImage()));
|
|
|
- connect(d->ImagePreview, SIGNAL(requestPreviousImage()), this, SLOT(onPreviousImage()));
|
|
|
- connect(d->ImagePreview, SIGNAL(imageDisplayed(int,int)), this, SLOT(onImagePreviewDisplayed(int,int)));
|
|
|
-
|
|
|
- connect(d->SearchOption, SIGNAL(parameterChanged()), this, SLOT(onSearchParameterChanged()));
|
|
|
-
|
|
|
- connect(d->PlaySlider, SIGNAL(valueChanged(int)), d->ImagePreview, SLOT(displayImage(int)));
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
@@ -414,18 +346,11 @@ void ctkDICOMBrowser::setDatabaseDirectory(const QString& directory)
|
|
|
// update the database schema if needed and provide progress
|
|
|
this->updateDatabaseSchemaIfNeeded();
|
|
|
|
|
|
- d->DICOMModel.setDatabase(d->DICOMDatabase->database());
|
|
|
- d->DICOMModel.setEndLevel(ctkDICOMModel::SeriesType);
|
|
|
- d->TreeView->resizeColumnToContents(0);
|
|
|
-
|
|
|
//pass DICOM database instance to Import widget
|
|
|
- // d->ImportDialog->setDICOMDatabase(d->DICOMDatabase);
|
|
|
d->QueryRetrieveWidget->setRetrieveDatabase(d->DICOMDatabase);
|
|
|
|
|
|
// update the button and let any connected slots know about the change
|
|
|
d->DirectoryButton->setDirectory(directory);
|
|
|
- d->ThumbnailsWidget->setDatabaseDirectory(directory);
|
|
|
- d->ImagePreview->setDatabaseDirectory(directory);
|
|
|
emit databaseDirectoryChanged(directory);
|
|
|
}
|
|
|
|
|
|
@@ -436,12 +361,6 @@ QString ctkDICOMBrowser::databaseDirectory() const
|
|
|
return settings.value("DatabaseDirectory").toString();
|
|
|
}
|
|
|
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-bool ctkDICOMBrowser::searchWidgetPopUpMode(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
- return d->IsSearchWidgetPopUpMode;
|
|
|
-}
|
|
|
-
|
|
|
//------------------------------------------------------------------------------
|
|
|
void ctkDICOMBrowser::setTagsToPrecache( const QStringList tags)
|
|
|
{
|
|
|
@@ -465,32 +384,6 @@ ctkDICOMDatabase* ctkDICOMBrowser::database(){
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::setSearchWidgetPopUpMode(bool flag){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- if(flag)
|
|
|
- {
|
|
|
- d->SearchDockWidget->setTitleBarWidget(0);
|
|
|
- d->SearchPopUpButton->show();
|
|
|
- d->SearchDockWidget->hide();
|
|
|
- d->SearchDockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
|
|
- connect(d->SearchDockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(onSearchWidgetTopLevelChanged(bool)));
|
|
|
- connect(d->SearchPopUpButton, SIGNAL(clicked()), this, SLOT(onSearchPopUpButtonClicked()));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- d->SearchDockWidget->setTitleBarWidget(new QWidget());
|
|
|
- d->SearchPopUpButton->hide();
|
|
|
- d->SearchDockWidget->show();
|
|
|
- d->SearchDockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
- disconnect(d->SearchDockWidget, SIGNAL(topLevelChanged(bool)), this, SLOT(onSearchWidgetTopLevelChanged(bool)));
|
|
|
- disconnect(d->SearchPopUpButton, SIGNAL(clicked()), this, SLOT(onSearchPopUpButtonClicked()));
|
|
|
- }
|
|
|
-
|
|
|
- d->IsSearchWidgetPopUpMode = flag;
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
void ctkDICOMBrowser::onFileIndexed(const QString& filePath)
|
|
|
{
|
|
|
// Update the progress dialog when the file name changes
|
|
|
@@ -529,7 +422,6 @@ void ctkDICOMBrowser::openQueryDialog()
|
|
|
void ctkDICOMBrowser::onQueryRetrieveFinished()
|
|
|
{
|
|
|
Q_D(ctkDICOMBrowser);
|
|
|
- d->DICOMModel.reset();
|
|
|
emit this->queryRetrieveFinished();
|
|
|
}
|
|
|
|
|
|
@@ -537,93 +429,7 @@ void ctkDICOMBrowser::onQueryRetrieveFinished()
|
|
|
void ctkDICOMBrowser::onRemoveAction()
|
|
|
{
|
|
|
Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- //d->QueryRetrieveWidget->show();
|
|
|
- // d->QueryRetrieveWidget->raise();
|
|
|
- std::cout << "on remove" << std::endl;
|
|
|
- QModelIndexList selection = d->TreeView->selectionModel()->selectedIndexes();
|
|
|
- std::cout << selection.size() << std::endl;
|
|
|
- QModelIndex index;
|
|
|
- foreach(index,selection)
|
|
|
- {
|
|
|
- QModelIndex index0 = index.sibling(index.row(), 0);
|
|
|
- if ( d->DICOMModel.data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::SeriesType))
|
|
|
- {
|
|
|
- QString seriesUID = d->DICOMModel.data(index0,ctkDICOMModel::UIDRole).toString();
|
|
|
- d->DICOMDatabase->removeSeries(seriesUID);
|
|
|
- }
|
|
|
- else if ( d->DICOMModel.data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::StudyType))
|
|
|
- {
|
|
|
- QString studyUID = d->DICOMModel.data(index0,ctkDICOMModel::UIDRole).toString();
|
|
|
- d->DICOMDatabase->removeStudy(studyUID);
|
|
|
- }
|
|
|
- else if ( d->DICOMModel.data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::PatientType))
|
|
|
- {
|
|
|
- QString patientUID = d->DICOMModel.data(index0,ctkDICOMModel::UIDRole).toString();
|
|
|
- d->DICOMDatabase->removePatient(patientUID);
|
|
|
- }
|
|
|
- }
|
|
|
- d->DICOMModel.reset();
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::suspendModel()
|
|
|
-{
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- d->DICOMModel.setDatabase(d->EmptyDatabase);
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::resumeModel()
|
|
|
-{
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- d->DICOMModel.setDatabase(d->DICOMDatabase->database());
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::resetModel()
|
|
|
-{
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- d->DICOMModel.reset();
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onThumbnailSelected(const ctkThumbnailLabel& widget)
|
|
|
-{
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex index = widget.property("sourceIndex").value<QPersistentModelIndex>();
|
|
|
- if(index.isValid())
|
|
|
- {
|
|
|
- d->ImagePreview->onModelSelected(index);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onThumbnailDoubleClicked(const ctkThumbnailLabel& widget)
|
|
|
-{
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex index = widget.property("sourceIndex").value<QPersistentModelIndex>();
|
|
|
-
|
|
|
- if(!index.isValid())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(index.model()));
|
|
|
- QModelIndex index0 = index.sibling(index.row(), 0);
|
|
|
-
|
|
|
- if(model && (model->data(index0,ctkDICOMModel::TypeRole) != static_cast<int>(ctkDICOMModel::ImageType)))
|
|
|
- {
|
|
|
- this->onModelSelected(index0);
|
|
|
- d->TreeView->setCurrentIndex(index0);
|
|
|
- d->ThumbnailsWidget->addThumbnails(index0);
|
|
|
- d->ImagePreview->onModelSelected(index0);
|
|
|
- }
|
|
|
+ d->dicomTableManager->deleteSelectedRows();
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
@@ -698,342 +504,8 @@ void ctkDICOMBrowser::onImportDirectory(QString directory)
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onModelSelected(const QModelIndex &index){
|
|
|
-Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(index.model()));
|
|
|
-
|
|
|
- if(model)
|
|
|
- {
|
|
|
- QModelIndex index0 = index.sibling(index.row(), 0);
|
|
|
-
|
|
|
- if ( model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::PatientType) )
|
|
|
- {
|
|
|
- d->NextImageButton->show();
|
|
|
- d->PrevImageButton->show();
|
|
|
- d->NextSeriesButton->show();
|
|
|
- d->PrevSeriesButton->show();
|
|
|
- d->NextStudyButton->show();
|
|
|
- d->PrevStudyButton->show();
|
|
|
- }
|
|
|
- else if ( model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::StudyType) )
|
|
|
- {
|
|
|
- d->NextImageButton->show();
|
|
|
- d->PrevImageButton->show();
|
|
|
- d->NextSeriesButton->show();
|
|
|
- d->PrevSeriesButton->show();
|
|
|
- d->NextStudyButton->hide();
|
|
|
- d->PrevStudyButton->hide();
|
|
|
- }
|
|
|
- else if ( model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::SeriesType) )
|
|
|
- {
|
|
|
- d->NextImageButton->show();
|
|
|
- d->PrevImageButton->show();
|
|
|
- d->NextSeriesButton->hide();
|
|
|
- d->PrevSeriesButton->hide();
|
|
|
- d->NextStudyButton->hide();
|
|
|
- d->PrevStudyButton->hide();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- d->NextImageButton->hide();
|
|
|
- d->PrevImageButton->hide();
|
|
|
- d->NextSeriesButton->hide();
|
|
|
- d->PrevSeriesButton->hide();
|
|
|
- d->NextStudyButton->hide();
|
|
|
- d->PrevStudyButton->hide();
|
|
|
- }
|
|
|
- d->ActionRemove->setEnabled(
|
|
|
- model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::SeriesType) ||
|
|
|
- model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::StudyType) ||
|
|
|
- model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::PatientType) );
|
|
|
- }
|
|
|
-
|
|
|
- else
|
|
|
- {
|
|
|
- d->NextImageButton->hide();
|
|
|
- d->PrevImageButton->hide();
|
|
|
- d->NextSeriesButton->hide();
|
|
|
- d->PrevSeriesButton->hide();
|
|
|
- d->NextStudyButton->hide();
|
|
|
- d->PrevStudyButton->hide();
|
|
|
- d->ActionRemove->setEnabled(false);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onNextImage(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex currentIndex = d->ImagePreview->currentImageIndex();
|
|
|
-
|
|
|
- if(currentIndex.isValid())
|
|
|
- {
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(currentIndex.model()));
|
|
|
-
|
|
|
- if(model)
|
|
|
- {
|
|
|
- QModelIndex seriesIndex = currentIndex.parent();
|
|
|
-
|
|
|
- int imageCount = model->rowCount(seriesIndex);
|
|
|
- int imageID = currentIndex.row();
|
|
|
-
|
|
|
- imageID = (imageID+1)%imageCount;
|
|
|
-
|
|
|
- int max = d->PlaySlider->maximum();
|
|
|
- if(imageID > 0 && imageID < max)
|
|
|
- {
|
|
|
- d->PlaySlider->setValue(imageID);
|
|
|
- }
|
|
|
-
|
|
|
- QModelIndex nextIndex = currentIndex.sibling(imageID, 0);
|
|
|
-
|
|
|
- d->ImagePreview->onModelSelected(nextIndex);
|
|
|
- d->ThumbnailsWidget->selectThumbnailFromIndex(nextIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onPreviousImage(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex currentIndex = d->ImagePreview->currentImageIndex();
|
|
|
-
|
|
|
- if(currentIndex.isValid())
|
|
|
- {
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(currentIndex.model()));
|
|
|
-
|
|
|
- if(model)
|
|
|
- {
|
|
|
- QModelIndex seriesIndex = currentIndex.parent();
|
|
|
-
|
|
|
- int imageCount = model->rowCount(seriesIndex);
|
|
|
- int imageID = currentIndex.row();
|
|
|
-
|
|
|
- imageID--;
|
|
|
- if(imageID < 0) imageID += imageCount;
|
|
|
-
|
|
|
- int max = d->PlaySlider->maximum();
|
|
|
- if(imageID > 0 && imageID < max)
|
|
|
- {
|
|
|
- d->PlaySlider->setValue(imageID);
|
|
|
- }
|
|
|
-
|
|
|
- QModelIndex prevIndex = currentIndex.sibling(imageID, 0);
|
|
|
-
|
|
|
- d->ImagePreview->onModelSelected(prevIndex);
|
|
|
- d->ThumbnailsWidget->selectThumbnailFromIndex(prevIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onNextSeries(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex currentIndex = d->ImagePreview->currentImageIndex();
|
|
|
-
|
|
|
- if(currentIndex.isValid())
|
|
|
- {
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(currentIndex.model()));
|
|
|
-
|
|
|
- if(model)
|
|
|
- {
|
|
|
- QModelIndex seriesIndex = currentIndex.parent();
|
|
|
- QModelIndex studyIndex = seriesIndex.parent();
|
|
|
-
|
|
|
- int seriesCount = model->rowCount(studyIndex);
|
|
|
- int seriesID = seriesIndex.row();
|
|
|
-
|
|
|
- seriesID = (seriesID + 1)%seriesCount;
|
|
|
-
|
|
|
- QModelIndex nextIndex = seriesIndex.sibling(seriesID, 0);
|
|
|
-
|
|
|
- d->ImagePreview->onModelSelected(nextIndex);
|
|
|
- d->ThumbnailsWidget->selectThumbnailFromIndex(nextIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onPreviousSeries(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex currentIndex = d->ImagePreview->currentImageIndex();
|
|
|
-
|
|
|
- if(currentIndex.isValid())
|
|
|
- {
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(currentIndex.model()));
|
|
|
-
|
|
|
- if(model)
|
|
|
- {
|
|
|
- QModelIndex seriesIndex = currentIndex.parent();
|
|
|
- QModelIndex studyIndex = seriesIndex.parent();
|
|
|
-
|
|
|
- int seriesCount = model->rowCount(studyIndex);
|
|
|
- int seriesID = seriesIndex.row();
|
|
|
-
|
|
|
- seriesID--;
|
|
|
- if(seriesID < 0) seriesID += seriesCount;
|
|
|
-
|
|
|
- QModelIndex prevIndex = seriesIndex.sibling(seriesID, 0);
|
|
|
-
|
|
|
- d->ImagePreview->onModelSelected(prevIndex);
|
|
|
- d->ThumbnailsWidget->selectThumbnailFromIndex(prevIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onNextStudy(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex currentIndex = d->ImagePreview->currentImageIndex();
|
|
|
-
|
|
|
- if(currentIndex.isValid())
|
|
|
- {
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(currentIndex.model()));
|
|
|
-
|
|
|
- if(model)
|
|
|
- {
|
|
|
- QModelIndex seriesIndex = currentIndex.parent();
|
|
|
- QModelIndex studyIndex = seriesIndex.parent();
|
|
|
- QModelIndex patientIndex = studyIndex.parent();
|
|
|
-
|
|
|
- int studyCount = model->rowCount(patientIndex);
|
|
|
- int studyID = studyIndex.row();
|
|
|
-
|
|
|
- studyID = (studyID + 1)%studyCount;
|
|
|
-
|
|
|
- QModelIndex nextIndex = studyIndex.sibling(studyID, 0);
|
|
|
-
|
|
|
- d->ImagePreview->onModelSelected(nextIndex);
|
|
|
- d->ThumbnailsWidget->selectThumbnailFromIndex(nextIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onPreviousStudy(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- QModelIndex currentIndex = d->ImagePreview->currentImageIndex();
|
|
|
-
|
|
|
- if(currentIndex.isValid())
|
|
|
- {
|
|
|
- ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(currentIndex.model()));
|
|
|
-
|
|
|
- if(model)
|
|
|
- {
|
|
|
- QModelIndex seriesIndex = currentIndex.parent();
|
|
|
- QModelIndex studyIndex = seriesIndex.parent();
|
|
|
- QModelIndex patientIndex = studyIndex.parent();
|
|
|
-
|
|
|
- int studyCount = model->rowCount(patientIndex);
|
|
|
- int studyID = studyIndex.row();
|
|
|
-
|
|
|
- studyID--;
|
|
|
- if(studyID < 0) studyID += studyCount;
|
|
|
-
|
|
|
- QModelIndex prevIndex = studyIndex.sibling(studyID, 0);
|
|
|
-
|
|
|
- d->ImagePreview->onModelSelected(prevIndex);
|
|
|
- d->ThumbnailsWidget->selectThumbnailFromIndex(prevIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onTreeCollapsed(const QModelIndex &index){
|
|
|
- Q_UNUSED(index);
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
- d->TreeView->resizeColumnToContents(0);
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onTreeExpanded(const QModelIndex &index){
|
|
|
- Q_UNUSED(index);
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
- d->TreeView->resizeColumnToContents(0);
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onAutoPlayCheckboxStateChanged(int state){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- if(state == 0) //OFF
|
|
|
- {
|
|
|
- disconnect(d->AutoPlayTimer, SIGNAL(timeout()), this, SLOT(onAutoPlayTimer()));
|
|
|
- d->AutoPlayTimer->deleteLater();
|
|
|
- }
|
|
|
- else if(state == 2) //ON
|
|
|
- {
|
|
|
- d->AutoPlayTimer = new QTimer(this);
|
|
|
- connect(d->AutoPlayTimer, SIGNAL(timeout()), this, SLOT(onAutoPlayTimer()));
|
|
|
- d->AutoPlayTimer->start(50);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onAutoPlayTimer(){
|
|
|
- this->onNextImage();
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onThumbnailWidthSliderValueChanged(int val){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
- d->ThumbnailsWidget->setThumbnailSize(QSize(val, val));
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onSearchParameterChanged(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
- d->DICOMModel.setDatabase(d->DICOMDatabase->database(), d->SearchOption->parameters());
|
|
|
-
|
|
|
- this->onModelSelected(d->DICOMModel.index(0,0));
|
|
|
- d->ThumbnailsWidget->clearThumbnails();
|
|
|
- d->ThumbnailsWidget->addThumbnails(d->DICOMModel.index(0,0));
|
|
|
- d->ImagePreview->clearImages();
|
|
|
- d->ImagePreview->onModelSelected(d->DICOMModel.index(0,0));
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onImagePreviewDisplayed(int imageID, int count){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- d->PlaySlider->setMinimum(0);
|
|
|
- d->PlaySlider->setMaximum(count-1);
|
|
|
- d->PlaySlider->setValue(imageID);
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onSearchPopUpButtonClicked(){
|
|
|
- Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- if(d->SearchDockWidget->isFloating())
|
|
|
- {
|
|
|
- d->SearchDockWidget->hide();
|
|
|
- d->SearchDockWidget->setFloating(false);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- d->SearchDockWidget->setFloating(true);
|
|
|
- d->SearchDockWidget->adjustSize();
|
|
|
- d->SearchDockWidget->show();
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-//----------------------------------------------------------------------------
|
|
|
-void ctkDICOMBrowser::onSearchWidgetTopLevelChanged(bool topLevel){
|
|
|
+void ctkDICOMBrowser::onModelSelected(const QItemSelection &, const QItemSelection &)
|
|
|
+{
|
|
|
Q_D(ctkDICOMBrowser);
|
|
|
-
|
|
|
- if(topLevel)
|
|
|
- {
|
|
|
- d->SearchDockWidget->show();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- d->SearchDockWidget->hide();
|
|
|
- }
|
|
|
+ d->ActionRemove->setEnabled(true);
|
|
|
}
|