Exemplo n.º 1
0
void UIContext::onRemoveDocument(doc::Document* doc)
{
  if (doc == m_lastSelectedDoc)
    m_lastSelectedDoc = nullptr;

  // We don't destroy views in batch mode.
  if (isUIAvailable()) {
    Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
    DocumentViews docViews;

    // Collect all views related to the document.
    for (WorkspaceView* view : *workspace) {
      if (DocumentView* docView = dynamic_cast<DocumentView*>(view)) {
        if (docView->getDocument() == doc) {
          docViews.push_back(docView);
        }
      }
    }

    for (DocumentView* docView : docViews) {
      workspace->removeView(docView);
      delete docView;
    }
  }
}
Exemplo n.º 2
0
void UIContext::onRemoveDocument(doc::Document* doc)
{
  if (doc == m_lastSelectedDoc)
    m_lastSelectedDoc = nullptr;

  // We don't destroy views in batch mode.
  if (isUIAvailable()) {
    Workspace* workspace = App::instance()->workspace();

    for (DocumentView* docView : getAllDocumentViews(doc)) {
      workspace->removeView(docView);
      delete docView;
    }
  }
}
Exemplo n.º 3
0
  void onExecute(Context* context)
  {
    Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();

    if (workspace->getActiveView() == NULL)
      return;

    if (DocumentView* docView =
          dynamic_cast<DocumentView*>(workspace->getActiveView())) {
      Document* document = docView->getDocument();
      if (static_cast<UIContext*>(context)->countViewsOf(document) == 1) {
        // If we have only one view for this document, close the file.
        close_active_document(context);
        return;
      }
    }

    // Close the active view.
    WorkspaceView* view = workspace->getActiveView();
    workspace->removeView(view);
    delete view;
  }
Exemplo n.º 4
0
void UIContext::onRemoveDocument(doc::Document* doc)
{
  Context::onRemoveDocument(doc);

  Workspace* workspace = App::instance()->getMainWindow()->getWorkspace();
  DocumentViews docViews;

  // Collect all views related to the document.
  for (Workspace::iterator it=workspace->begin(); it != workspace->end(); ++it) {
    WorkspaceView* view = *it;
    if (DocumentView* docView = dynamic_cast<DocumentView*>(view)) {
      if (docView->getDocument() == doc) {
        docViews.push_back(docView);
      }
    }
  }

  for (DocumentViews::iterator it=docViews.begin(); it != docViews.end(); ++it) {
    DocumentView* docView = *it;
    workspace->removeView(docView);
    delete docView;
  }
}