Example #1
0
void QmitkXnatEditor::UpdateSession(ctkXnatSession* session)
{
  GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemoveSelectionListener(m_SelectionListener.data());

  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 );
    this->SetInput(editorInput);
    this->GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->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());
}
Example #2
0
void QmitkXnatEditor::UpdateList()
{
  QmitkXnatObjectEditorInput::Pointer xoPtr(GetEditorInput().Cast<QmitkXnatObjectEditorInput>());
  if (xoPtr.IsNull())
    return;
  ctkXnatObject* inputObject = xoPtr->GetXnatObject();
  if (inputObject == NULL)
    return;

  m_Controls.treeView->setModel(m_ListModel);
  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++)
  {
    QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i);
    child->widget()->setVisible(false);
  }
  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--)
  {
    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)
    {
      m_Controls.breadcrumbHorizontalLayout->itemAt(i - 1)->widget()->setVisible(true);
      m_Controls.breadcrumbDescriptionLayout->itemAt(i - 1)->widget()->setVisible(true);
    }
    if (parent == NULL)
    {
      parent = inputObject;
    }
    // create breadcrumb button
    QPushButton* breadcrumbButton = dynamic_cast<QPushButton*>(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);
}