diff --git a/Plugins/org.mitk.gui.qt.xnat/CMakeLists.txt b/Plugins/org.mitk.gui.qt.xnat/CMakeLists.txt index c5be1b1de7..95bffa7abc 100644 --- a/Plugins/org.mitk.gui.qt.xnat/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.xnat/CMakeLists.txt @@ -1,7 +1,8 @@ project(org_mitk_gui_qt_xnat) MACRO_CREATE_MITK_CTK_PLUGIN( + DEPENDS Poco MODULE_DEPENDS MitkXNAT EXPORT_DIRECTIVE XNAT_EXPORT EXPORTED_INCLUDE_SUFFIXES src ) diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.cpp b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.cpp index 854d9b3c8f..cdf7e540eb 100644 --- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.cpp +++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.cpp @@ -1,502 +1,581 @@ /*=================================================================== 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 "QmitkXnatEditor.h" // Qmitk #include "QmitkXnatObjectEditorInput.h" #include "org_mitk_gui_qt_xnatinterface_Activator.h" // CTK XNAT Core #include "ctkXnatObject.h" #include "ctkXnatDataModel.h" -#include "ctkXnatScanFolder.h" #include "ctkXnatFile.h" +#include "ctkXnatResource.h" +#include "ctkXnatScan.h" +#include "ctkXnatScanFolder.h" +#include "ctkXnatAssessor.h" +#include "ctkXnatAssessorFolder.h" +#include "ctkXnatReconstruction.h" +#include "ctkXnatReconstructionFolder.h" // CTK XNAT Widgets #include "ctkXnatListModel.h" // Blueberry #include #include #include // Qt #include #include #include #include #include // MITK #include #include +// Poco +#include + const QString QmitkXnatEditor::EDITOR_ID = "org.mitk.editors.xnat.browser"; QmitkXnatEditor::QmitkXnatEditor() : - m_DownloadPath(berry::Platform::GetPreferencesService()-> - GetSystemPreferences()->Node("/XnatConnection")->Get("Download Path", "")), - m_ListModel(new ctkXnatListModel()), - m_Session(0), - m_DataStorageServiceTracker(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetContext()), - m_SelectionListener(new berry::SelectionChangedAdapter(this, &QmitkXnatEditor::SelectionChanged)) +m_DownloadPath(berry::Platform::GetPreferencesService()-> +GetSystemPreferences()->Node("/XnatConnection")->Get("Download Path", "")), +m_ListModel(new ctkXnatListModel()), +m_Session(0), +m_DataStorageServiceTracker(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetContext()), +m_SelectionListener(new berry::SelectionChangedAdapter(this, &QmitkXnatEditor::SelectionChanged)) { m_DataStorageServiceTracker.open(); - if(m_DownloadPath.isEmpty()) + if (m_DownloadPath.isEmpty()) { QString xnatFolder = "XNAT_DOWNLOADS"; QDir dir(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetContext()->getDataFile("").absoluteFilePath()); dir.mkdir(xnatFolder); dir.setPath(dir.path() + "/" + xnatFolder); m_DownloadPath = dir.path() + "/"; } } QmitkXnatEditor::~QmitkXnatEditor() { delete m_ListModel; berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); s->RemoveSelectionListener(m_SelectionListener.data()); m_DataStorageServiceTracker.close(); } bool QmitkXnatEditor::IsDirty() const { return false; } bool QmitkXnatEditor::IsSaveAsAllowed() const { return false; } void QmitkXnatEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) { this->SetSite(site); berry::QtEditorPart::SetInput(input); this->SetInput(input); } void QmitkXnatEditor::DoSave() { } void QmitkXnatEditor::DoSaveAs() { } void QmitkXnatEditor::SetInput(berry::IEditorInput::Pointer input) { QmitkXnatObjectEditorInput::Pointer oPtr = input.Cast(); - if(oPtr.IsNotNull()) + if (oPtr.IsNotNull()) { berry::QtEditorPart::SetInput(oPtr); this->GetEditorInput().Cast()->GetXnatObject()->fetch(); } } void QmitkXnatEditor::SetFocus() { } -void QmitkXnatEditor::CreateQtPartControl( QWidget *parent ) +void QmitkXnatEditor::CreateQtPartControl(QWidget *parent) { // create GUI widgets from the Qt Designer's .ui file - m_Controls.setupUi( parent ); + m_Controls.setupUi(parent); + m_Controls.buttonDownload->setEnabled(false); + m_Controls.labelDownload->setText("Select a xnat file, resource, scan, or scan folder to download..."); GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener(m_SelectionListener.data()); - connect( m_Controls.treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(OnObjectActivated(const QModelIndex&)) ); + connect(m_Controls.treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(OnObjectActivated(const QModelIndex&))); - connect( m_Controls.buttonDownloadResource, SIGNAL(clicked()), this, SLOT(DownloadResource()) ); - connect( m_Controls.buttonDownloadFile, SIGNAL(clicked()), this, SLOT(DownloadFile()) ); - connect( m_Controls.buttonDataModel, SIGNAL(clicked()), this, SLOT(OnDataModelButtonClicked()) ); - connect( m_Controls.buttonProject, SIGNAL(clicked()), this, SLOT(OnProjectButtonClicked()) ); - connect( m_Controls.buttonSubject, SIGNAL(clicked()), this, SLOT(OnSubjectButtonClicked()) ); - connect( m_Controls.buttonExperiment, SIGNAL(clicked()), this, SLOT(OnExperimentButtonClicked()) ); - connect( m_Controls.buttonKindOfData, SIGNAL(clicked()), this, SLOT(OnKindOfDataButtonClicked()) ); - connect( m_Controls.buttonSession, SIGNAL(clicked()), this, SLOT(OnSessionButtonClicked()) ); - connect( m_Controls.buttonResource, SIGNAL(clicked()), this, SLOT(OnResourceButtonClicked()) ); + connect(m_Controls.buttonDownload, SIGNAL(clicked()), this, SLOT(DownloadResource())); + connect(m_Controls.buttonDataModel, SIGNAL(clicked()), this, SLOT(OnDataModelButtonClicked())); + connect(m_Controls.buttonProject, SIGNAL(clicked()), this, SLOT(OnProjectButtonClicked())); + connect(m_Controls.buttonSubject, SIGNAL(clicked()), this, SLOT(OnSubjectButtonClicked())); + connect(m_Controls.buttonExperiment, SIGNAL(clicked()), this, SLOT(OnExperimentButtonClicked())); + connect(m_Controls.buttonKindOfData, SIGNAL(clicked()), this, SLOT(OnKindOfDataButtonClicked())); + connect(m_Controls.buttonSession, SIGNAL(clicked()), this, SLOT(OnSessionButtonClicked())); + connect(m_Controls.buttonResource, SIGNAL(clicked()), this, SLOT(OnResourceButtonClicked())); + connect(m_Controls.treeView, SIGNAL(clicked(const QModelIndex&)), SLOT(itemSelected(const QModelIndex&))); m_Tracker = new mitk::XnatSessionTracker(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()); - connect( m_Tracker, SIGNAL(AboutToBeClosed(ctkXnatSession*)), this, SLOT(CleanListModel(ctkXnatSession*)) ); - connect( m_Tracker, SIGNAL(Opened(ctkXnatSession*)), this, SLOT(UpdateSession(ctkXnatSession*)) ); + connect(m_Tracker, SIGNAL(AboutToBeClosed(ctkXnatSession*)), this, SLOT(CleanListModel(ctkXnatSession*))); + connect(m_Tracker, SIGNAL(Opened(ctkXnatSession*)), this, SLOT(UpdateSession(ctkXnatSession*))); m_Tracker->Open(); // Makes the breadcrumb feature invisible - for(int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count()-1; i++) + for (int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count() - 1; i++) { QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i); child->widget()->setVisible(false); } - for(int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count()-1; i++) + for (int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count() - 1; i++) { QLayoutItem* child = m_Controls.breadcrumbDescriptionLayout->itemAt(i); child->widget()->setVisible(false); } QmitkXnatObjectEditorInput::Pointer oPtr = GetEditorInput().Cast(); - if(oPtr.IsNotNull()) + if (oPtr.IsNotNull()) { UpdateList(); } else { ctkXnatSession* session; try { session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetService( mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetServiceReference()); } - catch(std::invalid_argument) + catch (std::invalid_argument) { session = 0; } UpdateSession(session); } } void QmitkXnatEditor::UpdateList() { QmitkXnatObjectEditorInput::Pointer xoPtr(GetEditorInput().Cast()); - if( xoPtr.IsNull() ) + if (xoPtr.IsNull()) return; ctkXnatObject* inputObject = xoPtr->GetXnatObject(); - if( inputObject == NULL ) + if (inputObject == NULL) return; m_Controls.treeView->setModel(m_ListModel); - m_ListModel->setRootObject( inputObject ); + m_ListModel->setRootObject(inputObject); m_Controls.treeView->reset(); // recursive method to check parents of the inputObject m_ParentCount = ParentChecker(inputObject); // breadcrumb labels - for(int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count()-1; i++) + for (int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count() - 1; i++) { QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i); child->widget()->setVisible(false); } - for(int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count()-1; i++) + for (int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count() - 1; i++) { QLayoutItem* child = m_Controls.breadcrumbDescriptionLayout->itemAt(i); child->widget()->setVisible(false); } ctkXnatObject* parent = NULL; - for(int i = m_ParentCount*2; i >= 0; i--) + for (int i = m_ParentCount * 2; i >= 0; i--) { - if(i > 12) + if (i > 12) break; m_Controls.breadcrumbDescriptionLayout->itemAt(i)->widget()->setVisible(true); QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i); child->widget()->setVisible(true); - if(i>0) + if (i > 0) { - m_Controls.breadcrumbHorizontalLayout->itemAt(i-1)->widget()->setVisible(true); - m_Controls.breadcrumbDescriptionLayout->itemAt(i-1)->widget()->setVisible(true); + m_Controls.breadcrumbHorizontalLayout->itemAt(i - 1)->widget()->setVisible(true); + m_Controls.breadcrumbDescriptionLayout->itemAt(i - 1)->widget()->setVisible(true); } - if(parent == NULL) + if (parent == NULL) { parent = inputObject; } // create breadcrumb button QPushButton* breadcrumbButton = dynamic_cast(child->widget()); breadcrumbButton->setText(parent->id()); parent = parent->parent(); i--; } m_Controls.buttonDataModel->setText("root"); + m_Controls.buttonDownload->setEnabled(false); + m_Controls.labelDownload->setVisible(true); } void QmitkXnatEditor::SelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, - const berry::ISelection::ConstPointer& selection) + const berry::ISelection::ConstPointer& selection) { // check for null selection if (selection.IsNull()) { return; } // exclude own selection events and check whether this kind of selection can be handled if (sourcepart != this && selection.Cast()) { berry::IStructuredSelection::ConstPointer currentSelection = selection.Cast(); // iterates over the selection for (berry::IStructuredSelection::iterator itr = currentSelection->Begin(); itr != currentSelection->End(); ++itr) { if (berry::SmartPointer objectPointer = itr->Cast()) { // get object of selected ListWidgetElement ctkXnatObject* object = objectPointer->GetQModelIndex().data(Qt::UserRole).value(); // if a file is selected, don't change the input and list view - if ( dynamic_cast(object) == NULL ) + if (dynamic_cast(object) == NULL) { - QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput( object )); - berry::IEditorInput::Pointer editorInput( oPtr ); - if ( !(editorInput == this->GetEditorInput()) ) + QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(object)); + berry::IEditorInput::Pointer editorInput(oPtr); + if (!(editorInput == this->GetEditorInput())) this->SetInput(editorInput); UpdateList(); } } } } } void QmitkXnatEditor::DownloadResource() { if (!m_Controls.treeView->selectionModel()->hasSelection()) return; const QModelIndex index = m_Controls.treeView->selectionModel()->currentIndex(); QVariant variant = m_ListModel->data(index, Qt::UserRole); - if ( variant.isValid() ) + if (variant.isValid()) { - ctkXnatScanFolder* resource = dynamic_cast(variant.value()); - if (resource != NULL) + ctkXnatObject* resource = variant.value(); + if (dynamic_cast(resource) == NULL) { MITK_INFO << "Download started ..."; MITK_INFO << "..."; - QString resourcePath = m_DownloadPath + resource->id() + ".zip"; + QString resourceName = m_ListModel->data(index, Qt::DisplayRole).toString(); + QString resourcePath = m_DownloadPath + resourceName + ".zip"; resource->download(resourcePath); // Testing if the path exists QDir downDir(m_DownloadPath); - if( downDir.exists(resource->id() + ".zip") ) + if (downDir.exists(resourceName + ".zip")) { - MITK_INFO << "Download of " << resource->id().toStdString() << ".zip was completed!"; + MITK_INFO << "Download of " << resourceName.toStdString() << ".zip was completed!"; } else { - MITK_INFO << "Download of " << resource->id().toStdString() << ".zip failed!"; + MITK_INFO << "Download of " << resourceName.toStdString() << ".zip failed!"; } } else { - MITK_INFO << "Selection was not a resource folder!"; + InternalFileDownload(index); } } } -void QmitkXnatEditor::DownloadFile() -{ - if (!m_Controls.treeView->selectionModel()->hasSelection()) - return; - const QModelIndex index = m_Controls.treeView->selectionModel()->currentIndex(); - InternalFileDownload(index); -} - void QmitkXnatEditor::ToHigherLevel() { ctkXnatObject* parent = GetEditorInput().Cast()->GetXnatObject()->parent(); - if( parent == NULL) + if (parent == NULL) { return; } QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(parent)); - berry::IEditorInput::Pointer editorInput( oPtr ); + berry::IEditorInput::Pointer editorInput(oPtr); this->SetInput(editorInput); UpdateList(); } void QmitkXnatEditor::OnObjectActivated(const QModelIndex &index) { if (!index.isValid()) return; ctkXnatObject* child = GetEditorInput().Cast()->GetXnatObject()->children().at(index.row()); - if( child != NULL ) + if (child != NULL) { ctkXnatFile* file = dynamic_cast(child); - if( file != NULL ) + if (file != NULL) { // Download file and put into datamanager InternalFileDownload(index); mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService(); - if(dsService != NULL) + if (dsService != NULL) { QString name = file->property("Name"); + + if (file->property("collection") == "DICOM") + { + ctkXnatObject* grandParent = file->parent()->parent(); + name = grandParent->property("ID") + "-" + grandParent->property("series_description") + "/" + name; + } + mitk::DataNode::Pointer node = mitk::IOUtil::LoadDataNode((m_DownloadPath + name).toStdString()); - if ( ( node.IsNotNull() ) && ( node->GetData() != NULL ) ) + if ((node.IsNotNull()) && (node->GetData() != NULL)) { dsService->GetDataStorage()->GetDataStorage()->Add(node); mitk::BaseData::Pointer basedata = node->GetData(); mitk::RenderingManager::GetInstance()->InitializeViews( - basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true); } } } else { // Updates the root item QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(child)); - berry::IEditorInput::Pointer editorInput( oPtr ); + berry::IEditorInput::Pointer editorInput(oPtr); this->SetInput(editorInput); this->GetEditorInput().Cast()->GetXnatObject()->fetch(); UpdateList(); } } } void QmitkXnatEditor::InternalFileDownload(const QModelIndex& index) { QVariant variant = m_ListModel->data(index, Qt::UserRole); - if ( variant.isValid() ) + if (variant.isValid()) { ctkXnatFile* file = dynamic_cast(variant.value()); if (file != NULL) { - MITK_INFO << "Download started ..."; - MITK_INFO << "..."; - QString name = file->property("Name"); - QString filePath = m_DownloadPath + name; - file->download(filePath); - // Testing if the file exists QDir downDir(m_DownloadPath); - if( downDir.exists(name) ) + if (downDir.exists(file->property("Name"))) { - MITK_INFO << "Download of " << file->id().toStdString() << " was completed!"; + MITK_INFO << "File exists already!"; + return; + } + + if (file->property("collection") == QString("DICOM")) + { + ctkXnatObject* parent = file->parent(); + QList list = parent->children(); + + ctkXnatObject* grandParent = parent->parent(); + QString gpName = grandParent->property("ID") + "-" + grandParent->property("series_description"); + + for (int i = 0; i < list.count(); i++) + { + ctkXnatFile* child = dynamic_cast(list.at(i)); + MITK_INFO << "Download started ..."; + MITK_INFO << "..."; + + if (child == NULL) + { + MITK_INFO << "Download failed! Not a file."; + continue; + } + + QDir downDir(m_DownloadPath); + QString name = child->property("Name"); + QString newDownDir = m_DownloadPath + gpName + "/"; + + if (downDir.mkpath(newDownDir)) + { + QString filePath = newDownDir + name; + child->download(filePath); + } + else + { + MITK_INFO << "Download failed! No subdirectory created."; + } + + // Testing if the file exists + if (downDir.exists(newDownDir + name)) + { + MITK_INFO << "Download of " << child->name().toStdString() << " was completed!"; + } + else + { + MITK_INFO << "Download of " << child->name().toStdString() << " failed!"; + } + } } else { - MITK_INFO << "Download of " << file->id().toStdString() << " failed!"; + MITK_INFO << "Download started ..."; + MITK_INFO << "..."; + QString name = file->property("Name"); + QString filePath = m_DownloadPath + name; + file->download(filePath); + + // Testing if the file exists + QDir downDir(m_DownloadPath); + if (downDir.exists(name)) + { + MITK_INFO << "Download of " << file->name().toStdString() << " was completed!"; + } + else + { + MITK_INFO << "Download of " << file->name().toStdString() << " failed!"; + } } } else { MITK_INFO << "Selection was not a file!"; } } } int QmitkXnatEditor::ParentChecker(ctkXnatObject* child) { int sum; - if( child->parent() == NULL ) + if (child->parent() == NULL) { return 0; } else { sum = 1 + ParentChecker(child->parent()); } return sum; } void QmitkXnatEditor::OnDataModelButtonClicked() { - for(int i = m_ParentCount; i > 0; i--) + for (int i = m_ParentCount; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnProjectButtonClicked() { - for(int i = m_ParentCount-1; i > 0; i--) + for (int i = m_ParentCount - 1; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnSubjectButtonClicked() { - for(int i = m_ParentCount-2; i > 0; i--) + for (int i = m_ParentCount - 2; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnExperimentButtonClicked() { - for(int i = m_ParentCount-3; i > 0; i--) + for (int i = m_ParentCount - 3; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnKindOfDataButtonClicked() { - for(int i = m_ParentCount-4; i > 0; i--) + for (int i = m_ParentCount - 4; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnSessionButtonClicked() { - for(int i = m_ParentCount-5; i > 0; i--) + for (int i = m_ParentCount - 5; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnResourceButtonClicked() { - for(int i = m_ParentCount-6; i > 0; i--) + for (int i = m_ParentCount - 6; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::UpdateSession(ctkXnatSession* session) { GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemoveSelectionListener(m_SelectionListener.data()); - if(session != 0 && session->isOpen()) + if (session != 0 && session->isOpen()) { m_Controls.labelInfo->setText("Current Position:"); m_Controls.labelInfo->setStyleSheet("QLabel { color: black; }"); - m_Controls.buttonDownloadFile->setEnabled(true); - m_Controls.buttonDownloadResource->setEnabled(true); // Fill model and show in the GUI QmitkXnatObjectEditorInput::Pointer xoPtr(new QmitkXnatObjectEditorInput(session->dataModel())); - berry::IEditorInput::Pointer editorInput( xoPtr ); + berry::IEditorInput::Pointer editorInput(xoPtr); this->SetInput(editorInput); this->GetEditorInput().Cast()->GetXnatObject()->fetch(); UpdateList(); } else { m_Controls.labelInfo->setText("Please check the Preferences of the XNAT Connection.\nMaybe they are not ok."); m_Controls.labelInfo->setStyleSheet("QLabel { color: red; }"); - m_Controls.buttonDownloadFile->setEnabled(false); - m_Controls.buttonDownloadResource->setEnabled(false); } GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener(m_SelectionListener.data()); } void QmitkXnatEditor::CleanListModel(ctkXnatSession* session) { - if(session != 0) + if (session != 0) { m_Controls.treeView->setModel(0); m_ListModel->setRootObject(0); m_Controls.treeView->reset(); - m_Controls.buttonDownloadFile->setEnabled(false); - m_Controls.buttonDownloadResource->setEnabled(false); } } + +void QmitkXnatEditor::itemSelected(const QModelIndex &index) +{ + ctkXnatObject* xnatObject = m_ListModel->data(index, Qt::UserRole).value(); + bool downloadable = false; + downloadable |= dynamic_cast(xnatObject) != NULL; + downloadable |= dynamic_cast(xnatObject) != NULL; + downloadable |= dynamic_cast(xnatObject) != NULL; + downloadable |= dynamic_cast(xnatObject) != NULL; + downloadable |= dynamic_cast(xnatObject) != NULL; + downloadable |= dynamic_cast(xnatObject) != NULL; + downloadable |= dynamic_cast(xnatObject) != NULL; + downloadable |= dynamic_cast(xnatObject) != NULL; + m_Controls.buttonDownload->setEnabled(downloadable); + m_Controls.labelDownload->setVisible(!downloadable); +} diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.h b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.h index 1299a47749..b576f07e6a 100644 --- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.h +++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditor.h @@ -1,131 +1,127 @@ /*=================================================================== 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 QMITKXNATEDITOR_h #define QMITKXNATEDITOR_h #include #include #include #include #include #include "ui_QmitkXnatEditorControls.h" #include "ctkXnatListModel.h" #include "ctkXnatSession.h" #include #include "mitkXnatSessionTracker.h" /*! \brief QmitkXnatEditor \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class QmitkXnatEditor : public berry::QtEditorPart, public berry::IReusableEditor { // 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: berryObjectMacro(QmitkXnatEditor) - QmitkXnatEditor(); + QmitkXnatEditor(); ~QmitkXnatEditor(); static const QString EDITOR_ID; void CreateQtPartControl(QWidget *parent); void DoSave(/*IProgressMonitor monitor*/); void DoSaveAs(); void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input); bool IsDirty() const; bool IsSaveAsAllowed() const; void SetInput(berry::IEditorInput::Pointer input); /** \brief Here the root object will be set and the view reset. Additionally the breadcrumbs will set visible. */ void UpdateList(); protected slots: - /** - \brief A resource folder will be downloaded to the chosen download path. - */ - void DownloadResource(); - - /** - \brief A file will be downloaded to the chosen download path. - */ - void DownloadFile(); - - /** - \brief Every time you activate a node in the list, the root item will be updated to a child of the previous parent.\ - In exception of the node is a file. The file will be downloaded and loaded to the DataManager. - */ - void OnObjectActivated(const QModelIndex& index); - - // Breadcrumb button slots - void OnDataModelButtonClicked(); - void OnProjectButtonClicked(); - void OnSubjectButtonClicked(); - void OnExperimentButtonClicked(); - void OnKindOfDataButtonClicked(); - void OnSessionButtonClicked(); - void OnResourceButtonClicked(); - - /// \brief Updates the ctkXnatSession and the user interface - void UpdateSession(ctkXnatSession* session); - void CleanListModel(ctkXnatSession* session); + /** + \brief Any XNAT resource (file or folder) will be downloaded to the chosen download path. + */ + void DownloadResource(); + + /** + \brief Every time you activate a node in the list, the root item will be updated to a child of the previous parent.\ + In exception of the node is a file. The file will be downloaded and loaded to the DataManager. + */ + void OnObjectActivated(const QModelIndex& index); + + // Breadcrumb button slots + void OnDataModelButtonClicked(); + void OnProjectButtonClicked(); + void OnSubjectButtonClicked(); + void OnExperimentButtonClicked(); + void OnKindOfDataButtonClicked(); + void OnSessionButtonClicked(); + void OnResourceButtonClicked(); + + /// \brief Updates the ctkXnatSession and the user interface + void UpdateSession(ctkXnatSession* session); + + void CleanListModel(ctkXnatSession* session); + void itemSelected(const QModelIndex &index); protected: virtual void SetFocus(); Ui::QmitkXnatEditorControls m_Controls; private: int m_ParentCount; QString m_DownloadPath; ctkServiceTracker m_DataStorageServiceTracker; void InternalFileDownload(const QModelIndex& index); int ParentChecker(ctkXnatObject* child); void ToHigherLevel(); ctkXnatListModel* m_ListModel; ctkXnatSession* m_Session; mitk::XnatSessionTracker* m_Tracker; QScopedPointer m_SelectionListener; void SelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, - const berry::ISelection::ConstPointer& selection); + const berry::ISelection::ConstPointer& selection); }; #endif // QMITKXNATEDITOR_h diff --git a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditorControls.ui b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditorControls.ui index 6fbb01a659..7681d055cf 100644 --- a/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditorControls.ui +++ b/Plugins/org.mitk.gui.qt.xnat/src/internal/QmitkXnatEditorControls.ui @@ -1,467 +1,473 @@ QmitkXnatEditorControls 0 0 719 655 0 0 QmitkTemplate xnat_icon.icoxnat_icon.ico Current Position: 0 0 Server 0 0 >> 0 0 Project 0 0 >> 0 0 Subject 0 0 >> 0 0 Experiment 0 0 >> 0 0 Kind of Data 0 0 >> 0 0 Image Session 0 0 >> 0 0 Resource Folder Qt::Horizontal 40 20 6 QLayout::SetDefaultConstraint 0 0 0 Data Model true 0 0 >> 0 0 Qt::LeftToRight Project 0 0 >> 0 0 Subject 0 0 >> 0 0 Experiment 0 0 >> 0 0 Kind of Data 0 0 >> 0 0 Session 0 0 >> 0 0 Resource Qt::Horizontal 40 20 + + + + + + + Qt::Horizontal - QSizePolicy::Minimum + QSizePolicy::Expanding - 250 + 20 20 - - - Download Folder + + + + 0 + 0 + - - - - - Download File + Download