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; }
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()); }
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; }
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; } } }
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; } } }
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; } } }
void PanelTabBar::resizeEvent(QResizeEvent *e) { QTabBar::resizeEvent(e); layoutTabs(); }