author | drw <drw> | 2005-08-09 18:10:46 (UTC) |
---|---|---|
committer | drw <drw> | 2005-08-09 18:10:46 (UTC) |
commit | 2630b8b81ddf6904379eedab4e3c307ee6399863 (patch) (side-by-side diff) | |
tree | f88ea9ff42e77c322136de6dea4c5cb16e3e225e /libopie2 | |
parent | 438e79dd18c8b752f1e7d74a79f3cdf84f8703c8 (diff) | |
download | opie-2630b8b81ddf6904379eedab4e3c307ee6399863.zip opie-2630b8b81ddf6904379eedab4e3c307ee6399863.tar.gz opie-2630b8b81ddf6904379eedab4e3c307ee6399863.tar.bz2 |
Fix for bug #1682 - correct sizing of tab control
-rw-r--r-- | libopie2/opieui/otabwidget.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp index d617a9c..7103884 100644 --- a/libopie2/opieui/otabwidget.cpp +++ b/libopie2/opieui/otabwidget.cpp @@ -92,151 +92,160 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab // Create new tab in tab bar QTab *tab = new QTab(); // Set label (and icon if necessary) if ( m_tabBarStyle == IconTab ) { tab->label = QString::null; tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ); } else tab->label = label; tabid = m_tabBar->addTab( tab ); } else { // Insert entry (with icon if necessary) into drop down list if ( m_tabBarStyle == IconList ) m_tabList->insertItem( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ), label, -1 ); else m_tabList->insertItem( label ); } // Add widget to stack m_widgetStack->addWidget( child, tabid ); m_widgetStack->raiseWidget( child ); m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); // Keep track of tab information OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); m_tabs.append( tabinfo ); + // Force resizing of child controls + resizeEvent( 0x0 ); + // Make newly added tab the current one displayed selectTab( tabinfo ); } void OTabWidget::removePage( QWidget *childwidget ) { if ( childwidget ) { // Find tab information for desired widget OTabInfo *tab = m_tabs.first(); while ( tab && tab->control() != childwidget ) tab = m_tabs.next(); if ( tab && tab->control() == childwidget ) { if ( m_usingTabs ) { // Remove tab from tab bar m_tabBar->setTabEnabled( tab->id(), false ); m_tabBar->removeTab( m_tabBar->tab( tab->id() ) ); } else { // Remove entry from drop down list int i = 0; while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() ) i++; if ( m_tabList->text( i ) == tab->label() ) m_tabList->removeItem( i ); } // Remove widget from stack m_widgetStack->removeWidget( childwidget ); // Get rid of tab information m_tabs.remove( tab ); delete tab; // Reset current tab m_currTab = m_tabs.current(); if ( !m_currTab ) m_widgetStack->setFrameStyle( QFrame::NoFrame ); // Redraw widget setUpLayout(); } + + // Force resizing of child controls + resizeEvent( 0x0 ); } } void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) { // Find tab information for desired widget OTabInfo *currtab = m_tabs.first(); while ( currtab && currtab->control() != widget ) currtab = m_tabs.next(); if ( currtab && currtab->control() == widget ) { QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) ); if ( m_usingTabs ) { // Update tab label and icon (if necessary) QTab *tab = m_tabBar->tab( currtab->id() ); tab->setText( label ); if ( m_tabBarStyle == IconTab ) tab->setIconSet( icon ); } else { // Update entry label and icon (if necessary) int i = 0; while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() ) i++; if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() ) { if ( m_tabBarStyle == IconList ) m_tabList->changeItem( icon, label, i ); else m_tabList->changeItem( label, i ); } } // Update tab information currtab->setLabel( label ); currtab->setIcon( iconset ); + // Force resizing of child controls + resizeEvent( 0x0 ); + // Redraw widget setUpLayout(); } } void OTabWidget::setCurrentTab( QWidget *childwidget ) { OTabInfo *currtab = m_tabs.first(); while ( currtab && currtab->control() != childwidget ) { currtab = m_tabs.next(); } if ( currtab && currtab->control() == childwidget ) { selectTab( currtab ); } } void OTabWidget::setCurrentTab( const QString &tabname ) { OTabInfo *newtab = m_tabs.first(); while ( newtab && newtab->label() != tabname ) { newtab = m_tabs.next(); } if ( newtab && newtab->label() == tabname ) { selectTab( newtab ); } } void OTabWidget::setCurrentTab(int tabindex) |