diff --git a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp index 96c270dec7..03d0f21d57 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp +++ b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp @@ -1,171 +1,157 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ // Qmitk #include "QmitkDicomLocalStorageWidget.h" #include //#include // Qt #include const std::string QmitkDicomLocalStorageWidget::Widget_ID = "org.mitk.Widgets.QmitkDicomLocalStorageWidget"; QmitkDicomLocalStorageWidget::QmitkDicomLocalStorageWidget(QWidget *parent) : m_Controls( 0 ) ,m_LocalIndexer(new ctkDICOMIndexer()) ,m_LocalModel(new ctkDICOMModel()) { CreateQtPartControl(this); } QmitkDicomLocalStorageWidget::~QmitkDicomLocalStorageWidget() { m_LocalDatabase->closeDatabase(); delete m_LocalDatabase; delete m_LocalIndexer; delete m_LocalModel; delete m_Controls; } - void QmitkDicomLocalStorageWidget::CreateQtPartControl( QWidget *parent ) { - // build up qt Widget, unless already done if ( !m_Controls ) { - // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkDicomLocalStorageWidgetControls; m_Controls->setupUi( parent ); - m_Controls->groupBox->setVisible(false); - - //this->SetDatabaseDirectory(QString("./ctkDICOM-Database")); - m_Controls->InternalDataTreeView->setSortingEnabled(true); m_Controls->InternalDataTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); m_Controls->InternalDataTreeView->setModel(m_LocalModel); - - connect(m_Controls->deleteButton,SIGNAL(clicked()),this,SLOT(OnDeleteButtonClicked())); connect(m_Controls->CancelButton, SIGNAL(clicked()), this , SLOT(OnCancelButtonClicked())); connect(m_Controls->viewInternalDataButton, SIGNAL(clicked()), this , SLOT(OnViewButtonClicked())); - connect(m_Controls->SearchOption, SIGNAL(parameterChanged()), this, SLOT(OnSearchParameterChanged())); } } - -void QmitkDicomLocalStorageWidget::SetDatabaseDirectory(QString newDatatbaseDirectory) +void QmitkDicomLocalStorageWidget::StartDicomImport(const QString& dicomData) { - QDir databaseDirecory = QDir(newDatatbaseDirectory); - if(!databaseDirecory.exists()) - { - databaseDirecory.mkpath(databaseDirecory.absolutePath()); + if (m_Watcher.isRunning()){ + m_Watcher.waitForFinished(); } - QString newDatatbaseFile = databaseDirecory.absolutePath() + QString("/ctkDICOM.sql"); - this->SetDatabase(newDatatbaseFile); + m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(const QString&)) &QmitkDicomLocalStorageWidget::AddDICOMData,dicomData); + m_Watcher.setFuture(m_Future); } -void QmitkDicomLocalStorageWidget::SetDatabase(QString databaseFile) +void QmitkDicomLocalStorageWidget::StartDicomImport(const QStringList& dicomData) { - m_LocalDatabase = new ctkDICOMDatabase(databaseFile); - m_LocalModel->setEndLevel(ctkDICOMModel::SeriesType); - m_LocalModel->setDatabase(m_LocalDatabase->database()); + if (m_Watcher.isRunning()) + { + m_Watcher.waitForFinished(); + } + m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(const QStringList&)) &QmitkDicomLocalStorageWidget::AddDICOMData,dicomData); + m_Watcher.setFuture(m_Future); } -void QmitkDicomLocalStorageWidget::OnAddDICOMData(QString& directory) +void QmitkDicomLocalStorageWidget::AddDICOMData(const QString& directory) { if(m_LocalDatabase->isOpen()) { m_LocalIndexer->addDirectory(*m_LocalDatabase,directory,m_LocalDatabase->databaseDirectory()); } m_LocalModel->setDatabase(m_LocalDatabase->database()); emit FinishedImport(directory); } -void QmitkDicomLocalStorageWidget::OnAddDICOMData(QStringList& patientFiles) +void QmitkDicomLocalStorageWidget::AddDICOMData(const QStringList& patientFiles) { if(m_LocalDatabase->isOpen()) { QStringListIterator fileIterator(patientFiles); - while(fileIterator.hasNext()) { m_LocalIndexer->addFile(*m_LocalDatabase,fileIterator.next(),m_LocalDatabase->databaseDirectory()); } } m_LocalModel->setDatabase(m_LocalDatabase->database()); emit FinishedImport(patientFiles); } void QmitkDicomLocalStorageWidget::OnDeleteButtonClicked() { QModelIndex currentIndex = m_Controls->InternalDataTreeView->currentIndex(); QString currentUID = m_LocalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); - if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { m_LocalDatabase->removeSeries(currentUID); } else if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::StudyType)) { m_LocalDatabase->removeStudy(currentUID); } else if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::PatientType)) { m_LocalDatabase->removePatient(currentUID); } m_LocalModel->reset(); } -void QmitkDicomLocalStorageWidget::StartDicomImport(QString& dicomData) -{ - if (m_Watcher.isRunning()){ - m_Watcher.waitForFinished(); - } - m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(QString&)) &QmitkDicomLocalStorageWidget::OnAddDICOMData,dicomData); - m_Watcher.setFuture(m_Future); -} - -void QmitkDicomLocalStorageWidget::StartDicomImport(QStringList& dicomData) -{ - if (m_Watcher.isRunning()) - { - m_Watcher.waitForFinished(); - } - m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(QStringList&)) &QmitkDicomLocalStorageWidget::OnAddDICOMData,dicomData); - m_Watcher.setFuture(m_Future); -} - void QmitkDicomLocalStorageWidget::OnCancelButtonClicked() { m_Watcher.cancel(); m_Watcher.waitForFinished(); m_LocalDatabase->closeDatabase(); - // } //TODO void QmitkDicomLocalStorageWidget::OnViewButtonClicked() { } -void QmitkDicomLocalStorageWidget::OnSearchParameterChanged(){ - +void QmitkDicomLocalStorageWidget::OnSearchParameterChanged() +{ m_LocalModel->setDatabase(m_LocalDatabase->database(),m_Controls->SearchOption->parameters()); +} + +void QmitkDicomLocalStorageWidget::SetDatabaseDirectory(QString newDatatbaseDirectory) +{ + QDir databaseDirecory = QDir(newDatatbaseDirectory); + if(!databaseDirecory.exists()) + { + databaseDirecory.mkpath(databaseDirecory.absolutePath()); + } + QString newDatatbaseFile = databaseDirecory.absolutePath() + QString("/ctkDICOM.sql"); + this->SetDatabase(newDatatbaseFile); +} + +void QmitkDicomLocalStorageWidget::SetDatabase(QString databaseFile) +{ + m_LocalDatabase = new ctkDICOMDatabase(databaseFile); + m_LocalModel->setEndLevel(ctkDICOMModel::SeriesType); + m_LocalModel->setDatabase(m_LocalDatabase->database()); } \ No newline at end of file diff --git a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h index 0dcf6a652c..bec9f06ec3 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h +++ b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h @@ -1,113 +1,113 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef QmitkDicomLocalStorageWidget_h #define QmitkDicomLocalStorageWidget_h // #include #include "ui_QmitkDicomLocalStorageWidgetControls.h" #include "mitkDicomUIExports.h" // include ctk #include #include #include #include //include QT #include #include #include //For running dicom import in background #include #include #include #include /*! \brief QmitkDicomLocalStorageWidget \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup Functionalities */ class MITK_DICOMUI_EXPORT QmitkDicomLocalStorageWidget : public QWidget { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string Widget_ID; QmitkDicomLocalStorageWidget(QWidget *parent); virtual ~QmitkDicomLocalStorageWidget(); virtual void CreateQtPartControl(QWidget *parent); void SetDatabaseDirectory(QString newDatabaseDirectory); signals: - void FinishedImport(QString); - void FinishedImport(QStringList); + void FinishedImport(const QString&); + void FinishedImport(const QStringList&); public slots: /// @brief Called when cancel button was clicked. void OnViewButtonClicked(); /// @brief Called when cancel button was clicked. void OnCancelButtonClicked(); /// @brief Called delete button was clicked. void OnDeleteButtonClicked(); /// @brief Called when adding a dicom directory. Starts a thread adding the directory. - void StartDicomImport(QString& dicomData); + void StartDicomImport(const QString& dicomData); /// @brief Called when adding a list of dicom files. Starts a thread adding the dicom files. - void StartDicomImport(QStringList& dicomData); + void StartDicomImport(const QStringList& dicomData); /// @brief Called when search parameters change. void OnSearchParameterChanged(); protected: // adds dicom files from a directory containing dicom files to the local storage. - void OnAddDICOMData(QString& dicomDirectory); + void AddDICOMData(const QString& dicomDirectory); // adds dicom files from a string list containing the filepath to the local storage. - void OnAddDICOMData(QStringList& dicomFiles); + void AddDICOMData(const QStringList& dicomFiles); void SetDatabase(QString databaseFile); ctkDICOMDatabase* m_LocalDatabase; ctkDICOMModel* m_LocalModel; ctkDICOMIndexer* m_LocalIndexer; Ui::QmitkDicomLocalStorageWidgetControls* m_Controls; QFuture m_Future; QFutureWatcher m_Watcher; }; #endif // _QmitkDicomLocalStorageWidget_H_INCLUDED