void ViewManager::detachActiveView() { // find the currently active view and remove it from its container ViewContainer* container = _viewSplitter->activeContainer(); TerminalDisplay* activeView = dynamic_cast<TerminalDisplay*>(container->activeView()); if (!activeView) return; emit viewDetached(_sessionMap[activeView]); _sessionMap.remove(activeView); // remove the view from this window container->removeView(activeView); activeView->deleteLater(); // if the container from which the view was removed is now empty then it can be deleted, // unless it is the only container in the window, in which case it is left empty // so that there is always an active container if ( _viewSplitter->containers().count() > 1 && container->views().count() == 0 ) { removeContainer(container); } }
void ViewManager::switchToView(int index) { Q_ASSERT(index >= 0); ViewContainer* container = _viewSplitter->activeContainer(); Q_ASSERT(container); QList<QWidget*> containerViews = container->views(); if (index >= containerViews.count()) return; container->setActiveView(containerViews.at(index)); }