Exemple #1
0
int PanelTabBar::addPanel(ListPanel *panel, bool setCurrent, KrPanel *nextTo)
{
    int insertIndex = -1;

    if(nextTo) {
        for(int i = 0; i < count(); i++) {
            if(getPanel(i) == nextTo) {
                insertIndex = i + 1;
                break;
            }
        }
    }

    int newId;
    if(insertIndex != -1) {
        newId = insertTab(insertIndex, squeeze(DISPLAY(panel->virtualPath())));
    } else
        newId = addTab(squeeze(DISPLAY(panel->virtualPath())));

    QVariant v;
    v.setValue((long long)panel);
    setTabData(newId, v);

    // make sure all tabs lengths are correct
    layoutTabs();

    if (setCurrent)
        setCurrentIndex(newId);

    connect(panel, &ListPanel::pathChanged, [=]() { updateTab(panel); });

    return newId;
}
Exemple #2
0
ListPanel* PanelTabBar::removePanel(int index, ListPanel* &panelToDelete)
{
    panelToDelete = getPanel(index); // old panel to kill later
    disconnect(panelToDelete, 0, this, 0);

    removeTab(index);
    layoutTabs();

    return getPanel(currentIndex());
}
Exemple #3
0
UserWnd *UserTabBar::wnd(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab->wnd()->id() == id)
            return tab->wnd();
    }
    return NULL;
}
Exemple #4
0
void UserTabBar::changeTab(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab->wnd()->id() == id){
            tab->setText(tab->wnd()->getName());
            break;
        }
    }
}
Exemple #5
0
void UserTabBar::removeTab(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab == NULL)
            continue;
        if (tab->wnd()->id() == id){
            QTabBar::removeTab(tab);
            break;
        }
    }
}
Exemple #6
0
void UserTabBar::removeTab(unsigned id)
{
    layoutTabs();
    QList<QTab> *tList = tabList();
    for (QTab *t = tList->first(); t; t = tList->next()){
        UserTab *tab = static_cast<UserTab*>(t);
        if (tab == NULL)
            continue;
        if (tab->wnd()->id() == id){
            QTabBar::removeTab(tab);
            QTimer::singleShot(0, this, SLOT(slotRepaint()));
            break;
        }
    }
}
Exemple #7
0
void PanelTabBar::resizeEvent(QResizeEvent *e)
{
    QTabBar::resizeEvent(e);

    layoutTabs();
}