Example #1
0
void SplitterOrView::unsplit()
{
    if (!m_splitter)
        return;
    Q_ASSERT(m_splitter->count() == 1);
    SplitterOrView *childSplitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(0));
    QSplitter *oldSplitter = m_splitter;
    m_splitter = 0;

    if (childSplitterOrView->isSplitter()) {
        Q_ASSERT(childSplitterOrView->view() == 0);
        m_splitter = childSplitterOrView->takeSplitter();
        m_layout->addWidget(m_splitter);
        m_layout->setCurrentWidget(m_splitter);
    } else {
        UAVGadgetView *childView = childSplitterOrView->view();
        Q_ASSERT(childView);
        if (m_view) {
            if (IUAVGadget *e = childView->gadget()) {
                childView->removeGadget();
                m_view->setGadget(e);
            }
            m_uavGadgetManager->emptyView(childView);
        } else {
            m_view = childSplitterOrView->takeView();
            m_layout->addWidget(m_view);
        }
        m_layout->setCurrentWidget(m_view);
    }
    delete oldSplitter;
    m_uavGadgetManager->setCurrentGadget(findFirstView()->gadget());
}