-rw-r--r-- | libopie/otabwidget.cpp | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp index bee3f35..99bf067 100644 --- a/libopie/otabwidget.cpp +++ b/libopie/otabwidget.cpp @@ -89,25 +89,25 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab { QPixmap iconset = loadSmooth( icon ); QTab *tab = new QTab(); if ( tabBarStyle == IconTab ) { tab->label = QString::null; } else { tab->label = label; } - if ( tabBarStyle == IconTab || tabBarStyle == IconList) + if ( tabBarStyle == IconTab || tabBarStyle == IconList ) { tab->iconset = new QIconSet( iconset ); } int tabid = tabBar->addTab( tab ); if ( tabBarStyle == IconTab || tabBarStyle == IconList ) { tabList->insertItem( iconset, label, -1 ); } else { tabList->insertItem( label ); @@ -149,34 +149,70 @@ void OTabWidget::removePage( QWidget *childwidget ) delete tab; currentTab = tabs.current(); if ( !currentTab ) { widgetStack->setFrameStyle( QFrame::NoFrame ); } setUpLayout(); } } } +void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) +{ + OTabInfo *currtab = tabs.first(); + while ( currtab && currtab->control() != widget ) + { + currtab = tabs.next(); + } + if ( currtab && currtab->control() == widget ) + { + QTab *tab = tabBar->tab( currtab->id() ); + QPixmap icon( loadSmooth( iconset ) ); + tab->setText( label ); + if ( tabBarStyle == IconTab ) + tab->setIconSet( icon ); + int i = 0; + while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) + { + i++; + } + if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) + { + if ( tabBarStyle == IconTab || tabBarStyle == IconList ) + { + tabList->changeItem( icon, label, i ); + } + else + { + tabList->changeItem( label, i ); + } + } + currtab->setLabel( label ); + currtab->setIcon( iconset ); + } + setUpLayout(); +} + void OTabWidget::setCurrentTab( QWidget *childwidget ) { - OTabInfo *newtab = tabs.first(); - while ( newtab && newtab->control() != childwidget ) + OTabInfo *currtab = tabs.first(); + while ( currtab && currtab->control() != childwidget ) { - newtab = tabs.next(); + currtab = tabs.next(); } - if ( newtab && newtab->control() == childwidget ) + if ( currtab && currtab->control() == childwidget ) { - selectTab( newtab ); + selectTab( currtab ); } } void OTabWidget::setCurrentTab( const QString &tabname ) { OTabInfo *newtab = tabs.first(); while ( newtab && newtab->label() != tabname ) { newtab = tabs.next(); } if ( newtab && newtab->label() == tabname ) { |