Пример #1
0
QVariant DescriptorTreeItem::data(int role)
{
  if (role == Qt::DisplayRole)
  {
    return m_descriptor->GetLabel();
  }
  else if (role == Qt::DecorationRole)
  {
    return m_descriptor->GetImageDescriptor();
  }
  else if (role == Qt::ForegroundRole)
  {
    IWorkbenchPage::Pointer page = this->m_model->GetWorkbenchWindow()->GetActivePage();
    if (page.IsNotNull())
    {
      if (page->FindViewReference(m_descriptor->GetId()).IsNotNull())
      {
        return QBrush(QColor(Qt::gray));
      }
    }
  }
  else if (role == ViewTreeModel::Description)
  {
    return m_descriptor->GetDescription();
  }
  else if (role == ViewTreeModel::Id)
  {
    return m_descriptor->GetId();
  }
  return ViewTreeItem::data(role);
}
Пример #2
0
bool WorkbenchIntroManager::CloseIntro(IIntroPart::Pointer part)
{
  if (!introPart || introPart != part)
  {
    return false;
  }

  IWorkbenchPart::Pointer introView = GetIntroAdapterPart();
  if (introView)
  {
    //assumption is that there is only ever one intro per workbench
    //if we ever support one per window then this will need revisiting
    IWorkbenchPage::Pointer page = introView->GetSite()->GetPage();
    if (IntroIsView())
    {
      IViewReference::Pointer reference = page->FindViewReference(
          IntroConstants::INTRO_VIEW_ID);
      page->HideView(introView.Cast<IViewPart>());
      if (!reference || reference->GetPart(false) == 0)
      {
        introPart = nullptr;
        return true;
      }
      return false;
    }
    else
    {
      QList<IEditorReference::Pointer> references(page->FindEditors(IEditorInput::Pointer(nullptr), IntroConstants::INTRO_EDITOR_ID, IWorkbenchPage::MATCH_ID));
      Q_ASSERT(references.size() < 2);
      if (references.empty())
        return false;

      if (page->CloseEditors(references, false))
      {
        introPart = nullptr;
        return true;
      }
      return false;
    }
  }

  // if there is no part then null our reference
  introPart = nullptr;

  return true;
}