MCPcopy Create free account
hub / github.com/KDE/kdevelop / aboutToRemoveView

Method aboutToRemoveView

kdevplatform/sublime/mainwindow_p.cpp:472–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470}
471
472void MainWindowPrivate::aboutToRemoveView(Sublime::AreaIndex *index, Sublime::View *view)
473{
474 QSplitter *splitter = m_indexSplitters[index];
475 if (!splitter)
476 return;
477
478 qCDebug(SUBLIME) << "index " << index << " root " << area->rootIndex();
479 qCDebug(SUBLIME) << "splitter " << splitter << " container " << splitter->widget(0);
480 qCDebug(SUBLIME) << "structure: " << index->print() << " whole structure: " << area->rootIndex()->print();
481 //find the container for the view and remove the widget
482 auto *container = qobject_cast<Container*>(splitter->widget(0));
483 if (!container) {
484 qCWarning(SUBLIME) << "Splitter does not have a left widget!";
485 return;
486 }
487
488 emit m_mainWindow->aboutToRemoveView( view );
489
490 viewContainers.remove(view);
491
492 const bool wasActive = m_mainWindow->activeView() == view;
493
494 if (auto* const viewWidget = view->widget()) {
495 widgetToView.remove(viewWidget);
496 container->removeWidget(viewWidget);
497 viewWidget->setParent(nullptr);
498 } else {
499 qCWarning(SUBLIME) << "the view" << view->document()->documentSpecifier() << "does not have a widget";
500 }
501
502 if (container->count() > 0) {
503 // container is not empty or this is a root index, so keep the container
504
505 //activate what is visible currently in the container if the removed view was active
506 if (wasActive) {
507 m_mainWindow->setActiveView(container->viewForWidget(container->currentWidget()));
508 return;
509 }
510 }
511 else
512 {
513 // We have just removed the last view from this container. The container is now empty, so destroy it as well.
514
515 // If we have a container, then it should be the only child of
516 // the splitter.
517 Q_ASSERT(splitter->count() == 1);
518
519 // We can be called from signal handler of container
520 // (which is tab widget), so defer deleting it.
521 container->deleteLater();
522 container->setParent(nullptr);
523
524 /* If we're not at the top level, we get to collapse split views. */
525 if (index->parent())
526 {
527 /* The splitter used to have container as the only child, now it's
528 time to get rid of it. Make sure deleting splitter does not
529 delete container -- per above comment, we'll delete it later. */

Callers

nothing calls this directly

Calls 15

rootIndexMethod · 0.80
removeWidgetMethod · 0.80
viewForWidgetMethod · 0.80
secondMethod · 0.80
setOrientationMethod · 0.80
widgetMethod · 0.45
printMethod · 0.45
removeMethod · 0.45
activeViewMethod · 0.45
setParentMethod · 0.45
documentSpecifierMethod · 0.45
documentMethod · 0.45

Tested by

no test coverage detected