diff --git a/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp b/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp index b197ce3210..f110e6e786 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp +++ b/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp @@ -1,237 +1,241 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include // Qmitk #include "QmitkDicomExternalDataWidget.h" #include // Qt #include #include #include #include // CTK #include const std::string QmitkDicomExternalDataWidget::Widget_ID = "org.mitk.Widgets.QmitkDicomExternalDataWidget"; QmitkDicomExternalDataWidget::QmitkDicomExternalDataWidget(QWidget *parent) : m_Controls( 0 ) , m_DirectoryName(new QString()) { Initialize(); CreateQtPartControl(this); } QmitkDicomExternalDataWidget::~QmitkDicomExternalDataWidget() { delete m_ImportDialog; delete m_ExternalDatabase; delete m_ExternalModel; delete m_ExternalIndexer; delete m_Controls; delete m_DirectoryName; delete m_ProgressDialogLabel; } void QmitkDicomExternalDataWidget::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::QmitkDicomExternalDataWidgetControls; m_Controls->setupUi( parent ); - + m_Controls->cancelButton->setVisible(false); + m_Controls->viewExternalDataButton->setVisible(false); // m_Controls->ExternalDataTreeView->setSortingEnabled(true); m_Controls->ExternalDataTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); m_Controls->ExternalDataTreeView->setModel(m_ExternalModel); + //connect Buttons + connect(m_Controls->downloadButton, SIGNAL(clicked()),this,SLOT(OnDownloadButtonClicked())); + connect(m_Controls->viewExternalDataButton, SIGNAL(clicked()),this,SLOT(OnViewButtonClicked())); + connect(m_Controls->cancelButton, SIGNAL(clicked()),this,SLOT(OnDownloadButtonClicked())); + //Initialize import widget m_ImportDialog = new ctkFileDialog(); QCheckBox* importCheckbox = new QCheckBox("Copy on import", m_ImportDialog); m_ImportDialog->setBottomWidget(importCheckbox); m_ImportDialog->setFileMode(QFileDialog::Directory); m_ImportDialog->setLabelText(QFileDialog::Accept,"Import"); m_ImportDialog->setWindowTitle("Import DICOM files from directory ..."); m_ImportDialog->setWindowModality(Qt::ApplicationModal); connect(m_ImportDialog, SIGNAL(fileSelected(QString)),this,SLOT(OnFileSelectedAddExternalData(QString))); m_ProgressDialog= new QProgressDialog ("DICOM Import", "Cancel", 0, 100, this,Qt::WindowTitleHint | Qt::WindowSystemMenuHint); // We don't want the m_ProgressDialog dialog to resize itself, so we bypass the label // by creating our own m_ProgressDialogLabel = new QLabel(tr("Initialization...")); m_ProgressDialog->setLabel(m_ProgressDialogLabel); #ifdef Q_WS_MAC // BUG: avoid deadlock of dialogs on mac m_ProgressDialog->setWindowModality(Qt::NonModal); #else m_ProgressDialog->setWindowModality(Qt::ApplicationModal); #endif connect(m_ProgressDialog, SIGNAL(canceled()), m_ExternalIndexer, SLOT(cancel())); connect(m_ExternalIndexer, SIGNAL(indexingFilePath(QString)), m_ProgressDialogLabel, SLOT(setText(QString))); connect(m_ExternalIndexer, SIGNAL(progress(int)), m_ProgressDialog, SLOT(setValue(int))); connect(m_ExternalIndexer, SIGNAL(progress(int)), this, SLOT(OnProgress(int))); } } void QmitkDicomExternalDataWidget::Initialize() { m_ExternalDatabase = new ctkDICOMDatabase(); //m_ExternalDatabase->initializeDatabase(); try{ m_ExternalDatabase->openDatabase(QString(":memory:"),QString( "EXTERNAL-DB")); }catch(std::exception e){ MITK_ERROR <<"Database error: "<< m_ExternalDatabase->lastError().toStdString(); m_ExternalDatabase->closeDatabase(); return; } m_ExternalModel = new ctkDICOMModel(); m_ExternalModel->setDatabase(m_ExternalDatabase->database()); m_ExternalModel->setEndLevel(ctkDICOMModel::SeriesType); m_ExternalIndexer = new ctkDICOMIndexer(); } void QmitkDicomExternalDataWidget::OnFolderCDImport() { m_ImportDialog->show(); m_ImportDialog->raise(); } void QmitkDicomExternalDataWidget::OnFileSelectedAddExternalData(QString directory) { if (QDir(directory).exists()) { m_DirectoryName = new QString(directory); QCheckBox* copyOnImport = qobject_cast(m_ImportDialog->bottomWidget()); if (copyOnImport->isChecked()) { emit SignalAddDicomData(directory); }else{ AddDicomTemporary(directory); emit SignalChangePage(1); } } } void QmitkDicomExternalDataWidget::OnDownloadButtonClicked() { QStringList* filePaths= new QStringList(); GetFileNamesFromIndex(*filePaths); emit SignalAddDicomData(*filePaths); } void QmitkDicomExternalDataWidget::OnViewButtonClicked() { QModelIndex currentIndex = m_Controls->ExternalDataTreeView->currentIndex(); if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { QString seriesUID = m_ExternalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); QString seriesName = m_ExternalModel->data(currentIndex).toString(); QModelIndex studyIndex = m_ExternalModel->parent(currentIndex); QString studyUID = m_ExternalModel->data(studyIndex,ctkDICOMModel::UIDRole).toString(); QString studyName = m_ExternalModel->data(studyIndex).toString(); QModelIndex patientIndex = m_ExternalModel->parent(studyIndex); QString patientName = m_ExternalModel->data(patientIndex).toString(); QStringList eventProperties; eventProperties << patientName << studyUID << studyName << seriesUID << seriesName << *m_DirectoryName; - MITK_INFO << m_DirectoryName->toStdString(); - emit SignalDicomToDataManager(eventProperties); } } void QmitkDicomExternalDataWidget::OnCancelButtonClicked() { m_Watcher.cancel(); m_Watcher.waitForFinished(); } void QmitkDicomExternalDataWidget::GetFileNamesFromIndex(QStringList& filePaths) { QModelIndex currentIndex = m_Controls->ExternalDataTreeView->currentIndex(); QString currentUID = m_ExternalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { filePaths.append(m_ExternalDatabase->filesForSeries(currentUID)); } else if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::StudyType)) { QStringList seriesList; seriesList.append( m_ExternalDatabase->seriesForStudy(currentUID) ); QStringList::Iterator serieIt; for(serieIt=seriesList.begin();serieIt!=seriesList.end();++serieIt) { filePaths.append(m_ExternalDatabase->filesForSeries(*serieIt)); } } else if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::PatientType)) { QStringList studiesList,seriesList; studiesList.append( m_ExternalDatabase->studiesForPatient(currentUID) ); QStringList::Iterator studyIt,serieIt; for(studyIt=studiesList.begin();studyIt!=studiesList.end();++studyIt) { seriesList.append( m_ExternalDatabase->seriesForStudy(*studyIt) ); for(serieIt=seriesList.begin();serieIt!=seriesList.end();++serieIt) { filePaths.append(m_ExternalDatabase->filesForSeries(*serieIt)); } } } } void QmitkDicomExternalDataWidget::AddDicomTemporary(QString directory) { m_ProgressDialog->setMinimumDuration(0); m_ProgressDialog->setValue(0); m_ProgressDialog->show(); m_ExternalIndexer->addDirectory(*m_ExternalDatabase,directory); m_ExternalModel->reset(); } void QmitkDicomExternalDataWidget::OnProgress(int progress) { Q_UNUSED(progress); QApplication::processEvents(); } void QmitkDicomExternalDataWidget::OnSearchParameterChanged() { m_ExternalModel->setDatabase(m_ExternalDatabase->database(),m_Controls->SearchOption_2->parameters()); } diff --git a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp index 0b70dae553..7ed05ee4e6 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp +++ b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp @@ -1,221 +1,220 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Qmitk #include "QmitkDicomLocalStorageWidget.h" #include #include #include // Qt #include #include #include #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 ) { if ( !m_Controls ) { m_Controls = new Ui::QmitkDicomLocalStorageWidgetControls; m_Controls->setupUi( parent ); m_Controls->groupBox->setVisible(false); + m_Controls->CancelButton->setVisible(false); m_Controls->addSortingTagButton_2->setVisible(false); m_Controls->deleteSortingTagButton_2->setVisible(false); 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::StartDicomImport(const QString& dicomData) { if (m_Watcher.isRunning()){ m_Watcher.waitForFinished(); } SetupProgressDialog(); m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(const QString&)) &QmitkDicomLocalStorageWidget::AddDICOMData,dicomData); m_Watcher.setFuture(m_Future); } void QmitkDicomLocalStorageWidget::StartDicomImport(const QStringList& dicomData) { + mitk::ProgressBar::GetInstance()->AddStepsToDo(dicomData.count()); if (m_Watcher.isRunning()) { m_Watcher.waitForFinished(); } - - mitk::ProgressBar::GetInstance()->AddStepsToDo(dicomData.count()); m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(const QStringList&)) &QmitkDicomLocalStorageWidget::AddDICOMData,dicomData); m_Watcher.setFuture(m_Future); } 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::AddDICOMData(const QStringList& patientFiles) { if(m_LocalDatabase->isOpen()) { QStringListIterator fileIterator(patientFiles); while(fileIterator.hasNext()) { m_LocalIndexer->addFile(*m_LocalDatabase,fileIterator.next(),m_LocalDatabase->databaseDirectory()); mitk::ProgressBar::GetInstance()->Progress(); } } m_LocalModel->setDatabase(m_LocalDatabase->database()); emit FinishedImport(patientFiles); } void QmitkDicomLocalStorageWidget::SetupProgressDialog() { m_ProgressDialog = new QProgressDialog("DICOM Import", "Cancel", 0, 100, this,Qt::WindowTitleHint | Qt::WindowSystemMenuHint); m_ProgressDialogLabel = new QLabel(tr("Initialization...")); m_ProgressDialog->setLabel(m_ProgressDialogLabel); #ifdef Q_WS_MAC // BUG: avoid deadlock of dialogs on mac m_ProgressDialog->setWindowModality(Qt::NonModal); #else m_ProgressDialog->setWindowModality(Qt::ApplicationModal); #endif m_ProgressDialog->setMinimumDuration(0); m_ProgressDialog->setValue(0); m_ProgressDialog->show(); connect(m_ProgressDialog, SIGNAL(canceled()), m_LocalIndexer, SLOT(cancel())); connect(m_LocalIndexer, SIGNAL(indexingFilePath(QString)), m_ProgressDialogLabel, SLOT(setText(QString))); connect(m_LocalIndexer, SIGNAL(progress(int)), m_ProgressDialog, SLOT(setValue(int))); connect(m_LocalIndexer, SIGNAL(progress(int)), this, SLOT(OnProgress(int))); } void QmitkDicomLocalStorageWidget::OnProgress(int progress) { Q_UNUSED(progress); QApplication::processEvents(); } 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::OnCancelButtonClicked() { m_Watcher.cancel(); m_Watcher.waitForFinished(); m_LocalDatabase->closeDatabase(); } void QmitkDicomLocalStorageWidget::OnViewButtonClicked() { QModelIndex currentIndex = m_Controls->InternalDataTreeView->currentIndex(); if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { QString seriesUID = m_LocalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); QString seriesName = m_LocalModel->data(currentIndex).toString(); QModelIndex studyIndex = m_LocalModel->parent(currentIndex); QString studyUID = m_LocalModel->data(studyIndex,ctkDICOMModel::UIDRole).toString(); QString studyName = m_LocalModel->data(studyIndex).toString(); QModelIndex patientIndex = m_LocalModel->parent(studyIndex); QString patientName = m_LocalModel->data(patientIndex).toString(); QString filePath; filePath.append(m_LocalDatabase->databaseDirectory()); filePath.append("/dicom/"); filePath.append(studyUID); filePath.append("/"); filePath.append(seriesUID); filePath.append("/"); QStringList eventProperties; eventProperties << patientName << studyUID <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()); } diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp index f38068f801..07de69a223 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp @@ -1,123 +1,116 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkDicomDirectoryListener.h" #include #include - +#include #include QmitkDicomDirectoryListener::QmitkDicomDirectoryListener() : m_FileSystemWatcher(new QFileSystemWatcher()) -, m_FilesToImport(new QStringList()) -, m_ImportingFiles(new QStringList()) { connect(m_FileSystemWatcher,SIGNAL(directoryChanged(const QString&)),this,SLOT(OnDirectoryChanged(const QString&))); } QmitkDicomDirectoryListener::~QmitkDicomDirectoryListener() { - delete m_FilesToImport; - delete m_ImportingFiles; delete m_FileSystemWatcher; } void QmitkDicomDirectoryListener::OnDirectoryChanged(const QString&) { - //m_Mutex.lock(); SetFilesToImport(); - m_ImportingFiles->append(*m_FilesToImport); - emit SignalAddDicomData(*m_FilesToImport); - //m_Mutex.unlock(); + m_ImportingFiles.append(m_FilesToImport); + emit SignalAddDicomData(m_FilesToImport); } void QmitkDicomDirectoryListener::OnDicomImportFinished(const QStringList& finishedFiles) { - //m_Mutex.lock(); RemoveFilesFromDirectoryAndImportingFilesList(finishedFiles); - //m_Mutex.unlock(); } void QmitkDicomDirectoryListener::SetFilesToImport() { - m_FilesToImport->clear(); + m_FilesToImport.clear(); QDir listenerDirectory(m_DicomListenerDirectory); QFileInfoList entries = listenerDirectory.entryInfoList(QDir::Files); if(!entries.isEmpty()) { QFileInfoList::const_iterator file; for(file = entries.constBegin(); file != entries.constEnd(); ++file ) { - if(!m_ImportingFiles->contains((*file).absoluteFilePath())) + if(!m_ImportingFiles.contains((*file).absoluteFilePath())) { - m_FilesToImport->append((*file).absoluteFilePath()); + m_FilesToImport.append((*file).absoluteFilePath()); } } } } void QmitkDicomDirectoryListener::RemoveFilesFromDirectoryAndImportingFilesList(const QStringList& files) { QStringListIterator fileToDeleteIterator(files); while(fileToDeleteIterator.hasNext()) { QFile file(fileToDeleteIterator.next()); - if(m_ImportingFiles->contains(file.fileName())) + if(m_ImportingFiles.contains(file.fileName())) { - m_ImportingFiles->removeOne(file.fileName()); + m_ImportingFiles.removeOne(file.fileName()); file.remove(); } } } void QmitkDicomDirectoryListener::SetDicomListenerDirectory(const QString& directory) { if(isOnlyListenedDirectory(directory)) { QDir listenerDirectory = QDir(directory); CreateListenerDirectory(listenerDirectory); m_DicomListenerDirectory=listenerDirectory.absolutePath(); m_FileSystemWatcher->addPath(m_DicomListenerDirectory); + MITK_INFO << m_DicomListenerDirectory.toStdString(); } } const QString& QmitkDicomDirectoryListener::GetDicomListenerDirectory() { return m_DicomListenerDirectory; } void QmitkDicomDirectoryListener::CreateListenerDirectory(const QDir& directory) { if(!directory.exists()) { directory.mkpath(directory.absolutePath()); } } bool QmitkDicomDirectoryListener::isOnlyListenedDirectory(const QString& directory) { bool isOnlyListenedDirectory = false; if(m_FileSystemWatcher->directories().count()==0||m_FileSystemWatcher->directories().count()==1) { if(!m_FileSystemWatcher->directories().contains(directory)) { isOnlyListenedDirectory = true; } } return isOnlyListenedDirectory; } \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h index b4540abd25..010cda4e90 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h @@ -1,78 +1,78 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkDicomDirectoryListener_h #define QmitkDicomDirectoryListener_h #include #include #include #include #include #include class QmitkDicomDirectoryListener : public QObject { Q_OBJECT public: QmitkDicomDirectoryListener(); virtual ~QmitkDicomDirectoryListener(); /// @brief sets listened directory, note that only one directory can be set. void SetDicomListenerDirectory(const QString&); /// @brief get filepath to the listened directory. const QString& GetDicomListenerDirectory(); signals: /// @brief signal starts the dicom import of the given file (the QStringList will only contain one file here). void SignalAddDicomData(const QStringList&); public slots: /// \brief called when listener directory changes void OnDirectoryChanged(const QString&); /// \brief called when import is finished void OnDicomImportFinished(const QStringList&); protected: /// \brief creates directory if it's not already existing. void CreateListenerDirectory(const QDir& directory); /// \brief checks wheter the given directory is the only directory that is listened. bool isOnlyListenedDirectory(const QString& directory); /// \brief Composes the filename and initializes m_LastRetrievedFile with it void SetFilesToImport(); /// \brief removes files from void RemoveFilesFromDirectoryAndImportingFilesList(const QStringList& files); QFileSystemWatcher* m_FileSystemWatcher; - QStringList* m_FilesToImport; - QStringList* m_ImportingFiles; + QStringList m_FilesToImport; + QStringList m_ImportingFiles; QString m_DicomListenerDirectory; }; #endif // QmitkDicomListener_h \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp index 7f0262123e..b2039387f9 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp @@ -1,249 +1,249 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Blueberry #include #include #include #include #include #include #include #include #include "berryFileEditorInput.h" // Qmitk #include "QmitkDicomEditor.h" #include "mitkPluginActivator.h" #include //#include "mitkProgressBar.h" // Qt #include #include #include #include #include #include #include #include #include #include #include #include #include #include //CTK #include #include #include #include #include const std::string QmitkDicomEditor::EDITOR_ID = "org.mitk.editors.dicomeditor"; QmitkDicomEditor::QmitkDicomEditor() : m_Thread(new QThread()) , m_DicomDirectoryListener(new QmitkDicomDirectoryListener()) , m_StoreSCPLauncher(new QmitkStoreSCPLauncher(&m_Builder)) , m_Publisher(new QmitkDicomDataEventPublisher()) { } QmitkDicomEditor::~QmitkDicomEditor() { m_Thread->quit(); m_Thread->wait(1000); delete m_Handler; delete m_Publisher; delete m_StoreSCPLauncher; delete m_Thread; delete m_DicomDirectoryListener; } void QmitkDicomEditor::CreateQtPartControl(QWidget *parent ) { m_Controls.setupUi( parent ); m_Controls.LocalStorageButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/drive-harddisk_32.png")); m_Controls.FolderButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/folder_32.png")); m_Controls.CDButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/media-optical_32.png")); m_Controls.QueryRetrieveButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/network-workgroup_32.png")); m_Controls.StoreSCPStatusLabel->setTextFormat(Qt::RichText); m_Controls.StoreSCPStatusLabel->setText(""); TestHandler(); SetPluginDirectory(); SetDatabaseDirectory("DatabaseDirectory"); SetListenerDirectory("ListenerDirectory"); StartDicomDirectoryListener(); - m_Controls.m_ctkDICOMQueryRetrieveWidget->useProgressDialog(false); + m_Controls.m_ctkDICOMQueryRetrieveWidget->useProgressDialog(true); connect(m_Controls.externalDataWidget,SIGNAL(SignalAddDicomData(const QString&)),m_Controls.internalDataWidget,SLOT(StartDicomImport(const QString&))); connect(m_Controls.externalDataWidget,SIGNAL(SignalAddDicomData(const QStringList&)),m_Controls.internalDataWidget,SLOT(StartDicomImport(const QStringList&))); connect(m_Controls.externalDataWidget,SIGNAL(SignalDicomToDataManager(const QStringList&)),this,SLOT(OnViewButtonAddToDataManager(const QStringList&))); connect(m_Controls.externalDataWidget,SIGNAL(SignalChangePage(int)), this, SLOT(OnChangePage(int))); connect(m_Controls.internalDataWidget,SIGNAL(FinishedImport(const QString&)),this,SLOT(OnDicomImportFinished(const QString&))); connect(m_Controls.internalDataWidget,SIGNAL(FinishedImport(const QStringList&)),this,SLOT(OnDicomImportFinished(const QStringList&))); connect(m_Controls.internalDataWidget,SIGNAL(SignalDicomToDataManager(const QStringList&)),this,SLOT(OnViewButtonAddToDataManager(const QStringList&))); connect(m_Controls.CDButton, SIGNAL(clicked()), m_Controls.externalDataWidget, SLOT(OnFolderCDImport())); connect(m_Controls.FolderButton, SIGNAL(clicked()), m_Controls.externalDataWidget, SLOT(OnFolderCDImport())); connect(m_Controls.FolderButton, SIGNAL(clicked()), this, SLOT(OnFolderCDImport())); connect(m_Controls.QueryRetrieveButton, SIGNAL(clicked()), this, SLOT(OnQueryRetrieve())); connect(m_Controls.LocalStorageButton, SIGNAL(clicked()), this, SLOT(OnLocalStorage())); //connect(m_Controls.radioButton,SIGNAL(clicked()),this,SLOT(StartStopStoreSCP())); } void QmitkDicomEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) { this->SetSite(site); this->SetInput(input); } void QmitkDicomEditor::SetFocus() { } berry::IPartListener::Events::Types QmitkDicomEditor::GetPartEventTypes() const { return Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void QmitkDicomEditor::OnQueryRetrieve() { OnChangePage(2); QString storagePort = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StoragePort"].toString(); QString storageAET = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StorageAETitle"].toString(); if(!((m_Builder.GetAETitle()->compare(storageAET,Qt::CaseSensitive)==0)&& (m_Builder.GetPort()->compare(storagePort,Qt::CaseSensitive)==0))) { StopStoreSCP(); StartStoreSCP(); } } void QmitkDicomEditor::OnFolderCDImport() { } void QmitkDicomEditor::OnLocalStorage() { OnChangePage(0); } void QmitkDicomEditor::OnChangePage(int page) { try{ m_Controls.stackedWidget->setCurrentIndex(page); }catch(std::exception e){ MITK_ERROR <<"error: "<< e.what(); return; } } void QmitkDicomEditor::OnDicomImportFinished(const QString&) { } void QmitkDicomEditor::OnDicomImportFinished(const QStringList&) { } void QmitkDicomEditor::StartDicomDirectoryListener() { if(!m_Thread->isRunning()) { m_DicomDirectoryListener->SetDicomListenerDirectory(m_ListenerDirectory); connect(m_DicomDirectoryListener,SIGNAL(SignalAddDicomData(const QStringList&)),m_Controls.internalDataWidget,SLOT(StartDicomImport(const QStringList&)),Qt::DirectConnection); connect(m_Controls.internalDataWidget,SIGNAL(FinishedImport(const QStringList&)),m_DicomDirectoryListener,SLOT(OnDicomImportFinished(const QStringList&)),Qt::DirectConnection); m_DicomDirectoryListener->moveToThread(m_Thread); m_Thread->start(); } } void QmitkDicomEditor::TestHandler() { m_Handler = new DicomEventHandler(); m_Handler->SubscribeSlots(); } void QmitkDicomEditor::OnViewButtonAddToDataManager(const QStringList& eventProperties) { ctkDictionary properties; properties["PatientName"] = eventProperties.at(0); properties["StudyUID"] = eventProperties.at(1); properties["StudyName"] = eventProperties.at(2); properties["SeriesUID"] = eventProperties.at(3); properties["SeriesName"] = eventProperties.at(4); properties["Path"] = eventProperties.at(5); m_Publisher->PublishSignals(mitk::PluginActivator::getContext()); m_Publisher->AddSeriesToDataManagerEvent(properties); } void QmitkDicomEditor::StartStoreSCP() { QString storagePort = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StoragePort"].toString(); QString storageAET = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StorageAETitle"].toString(); m_Builder.AddPort(storagePort)->AddAETitle(storageAET)->AddTransferSyntax()->AddOtherNetworkOptions()->AddMode()->AddOutputDirectory(m_ListenerDirectory); m_StoreSCPLauncher = new QmitkStoreSCPLauncher(&m_Builder); connect(m_StoreSCPLauncher, SIGNAL(SignalStatusOfStoreSCP(const QString&)), this, SLOT(OnStoreSCPStatusChanged(const QString&))); m_StoreSCPLauncher->StartStoreSCP(); } void QmitkDicomEditor::OnStoreSCPStatusChanged(const QString& status) { m_Controls.StoreSCPStatusLabel->setText(" "+status); } void QmitkDicomEditor::StopStoreSCP() { delete m_StoreSCPLauncher; } void QmitkDicomEditor::SetPluginDirectory() { m_PluginDirectory = mitk::PluginActivator::getContext()->getDataFile("").absolutePath(); m_PluginDirectory.append("/"); } void QmitkDicomEditor::SetDatabaseDirectory(const QString& databaseDirectory) { m_DatabaseDirectory.clear(); m_DatabaseDirectory.append(m_PluginDirectory); m_DatabaseDirectory.append(databaseDirectory); m_Controls.internalDataWidget->SetDatabaseDirectory(m_DatabaseDirectory); } void QmitkDicomEditor::SetListenerDirectory(const QString& listenerDirectory) { m_ListenerDirectory.clear(); m_ListenerDirectory.append(m_PluginDirectory); m_ListenerDirectory.append(listenerDirectory); }