Exemplo n.º 1
0
bool TabWidget::closeTab(int index)
{
    if(index < 0 || m_tab_ids.size() <= (uint)index)
    {
        Q_ASSERT(false);
        return false;
    }

    quint32 id = m_tab_ids[index];
    Tab *tab = dynamic_cast<Tab*>(widget(index));
    if(!tab)
    {
        Q_ASSERT(false);
        return false;
    }

    if(!tab->onTabClose())
        return false;

    if(id & IDMASK_CHILD)
    {
        sWorkTabMgr.removeChildTab((ChildTab*)tab);
    }
    else
    {
        disconnect((WorkTab*)tab, SIGNAL(statusBarMsg(QString,int)), this, SIGNAL(statusBarMsg(QString,int)));
        sWorkTabMgr.removeTab((WorkTab*)tab);
    }

    changeMenu(currentIndex());
    checkEmpty();
    return true;
}
Exemplo n.º 2
0
bool TabWidget::canCloseTabs()
{
    if(m_tab_ids.empty())
        return true;

    for(int i = 0; i < count(); ++i)
    {
        Tab *tab = dynamic_cast<Tab*>(widget(i));
        if(!tab)
            continue;

        if(tab->isChild())
        {
            ChildTab* child = (ChildTab*)tab;
            WorkTab* parent = sWorkTabMgr.getWorkTab(child->getParentId());
            if(child->getWindowId() == parent->getWindowId())
                continue;
        }

        if(!tab->onTabClose())
            return false;
    }
    return true;
}