void QmitkXnatEditor::OnObjectActivated(const QModelIndex &index) { if (!index.isValid()) return; ctkXnatObject* child = GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->children().at(index.row()); if( child != NULL ) { ctkXnatFile* file = dynamic_cast<ctkXnatFile*>(child); if( file != NULL ) { // Download file and put into datamanager InternalFileDownload(index); mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService(); if(dsService != NULL) { mitk::IOUtil::Load((m_DownloadPath + file->id()).toStdString(), *dsService->GetDataStorage()->GetDataStorage()); mitk::RenderingManager::GetInstance()->InitializeViews(); } } else { // Updates the root item QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(child)); berry::IEditorInput::Pointer editorInput( oPtr ); this->SetInput(editorInput); this->GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->fetch(); UpdateList(); } } }
void QmitkXnatEditor::DownloadFile() { if (!m_Controls.treeView->selectionModel()->hasSelection()) return; const QModelIndex index = m_Controls.treeView->selectionModel()->currentIndex(); InternalFileDownload(index); }
void QmitkXnatEditor::DownloadResource() { if (!m_Controls.listView->selectionModel()->hasSelection()) return; const QModelIndex index = m_Controls.listView->selectionModel()->currentIndex(); QVariant variant = m_ListModel->data(index, Qt::UserRole); if (variant.isValid()) { ctkXnatObject* resource = variant.value<ctkXnatObject*>(); if (dynamic_cast<ctkXnatFile*>(resource) == NULL) { MITK_INFO << "Download started ..."; MITK_INFO << "..."; 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(resourceName + ".zip")) { MITK_INFO << "Download of " << resourceName.toStdString() << ".zip was completed!"; } else { MITK_INFO << "Download of " << resourceName.toStdString() << ".zip failed!"; } } else { InternalFileDownload(index); } } }
void QmitkXnatEditor::OnObjectActivated(const QModelIndex &index) { if (!index.isValid()) return; ctkXnatObject* child = GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->children().at(index.row()); if (child != NULL) { ctkXnatFile* file = dynamic_cast<ctkXnatFile*>(child); if (file != NULL) { // Download file and put into datamanager InternalFileDownload(index); mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService(); if (dsService != NULL) { QString name = file->property("Name"); QString filePath = m_DownloadPath + name; if (file->property("collection") == "DICOM") { QDirIterator it(m_DownloadPath, QStringList() << name, QDir::Files, QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); filePath = it.filePath(); } } mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService(); mitk::DataStorage::Pointer dataStorage = dsService->GetDataStorage()->GetDataStorage(); QStringList list; list << filePath; try { QmitkIOUtil::Load(list, *dataStorage); } catch (const mitk::Exception& e) { MITK_INFO << e; return; } mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects( dsService->GetDataStorage()->GetDataStorage()); } } else { // Updates the root item QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(child)); berry::IEditorInput::Pointer editorInput(oPtr); this->SetInput(editorInput); this->GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->fetch(); UpdateList(); } } }