author | drw <drw> | 2002-08-11 22:12:54 (UTC) |
---|---|---|
committer | drw <drw> | 2002-08-11 22:12:54 (UTC) |
commit | 496ba37b34ef5847865e0e387443d7481b1487f0 (patch) (side-by-side diff) | |
tree | 60ec019d7d4539818743b6babd71300e22b1cbeb | |
parent | e7af03e8257119824b53a63f581366b6e25f4ae5 (diff) | |
download | opie-496ba37b34ef5847865e0e387443d7481b1487f0.zip opie-496ba37b34ef5847865e0e387443d7481b1487f0.tar.gz opie-496ba37b34ef5847865e0e387443d7481b1487f0.tar.bz2 |
OTabWidget updates
-rw-r--r-- | noncore/settings/sysinfo/otabwidget.cpp | 78 | ||||
-rw-r--r-- | noncore/settings/sysinfo/otabwidget.h | 13 |
2 files changed, 61 insertions, 30 deletions
diff --git a/noncore/settings/sysinfo/otabwidget.cpp b/noncore/settings/sysinfo/otabwidget.cpp index 5154196..9fe6c4b 100644 --- a/noncore/settings/sysinfo/otabwidget.cpp +++ b/noncore/settings/sysinfo/otabwidget.cpp @@ -25,3 +25,2 @@ #include <qcombobox.h> -#include <qlist.h> #include <qtabbar.h> @@ -85,2 +84,4 @@ OTabWidget::OTabWidget( QWidget *parent, const char *name = 0x0, } + + currentTab= 0x0; } @@ -110,6 +111,4 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab int tabid = tabBar->addTab( tab ); - tabBar->setCurrentTab( tab ); // Add to tabList - if ( tabBarStyle == IconTab || tabBarStyle == IconList ) @@ -122,3 +121,2 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab } - tabList->setCurrentItem( tabList->count()-1 ); @@ -129,5 +127,33 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab // Save tab information - tabs.append( TabInfo( tabid, child, icon, label ) ); + TabInfo *tabinfo = new TabInfo( tabid, child, icon, label ); + tabs.append( tabinfo ); + selectTab( tabinfo ); + +// setUpLayout(); +} - setUpLayout( FALSE ); +void OTabWidget::setCurrentTab( QWidget *childwidget ) +{ + TabInfo *newtab = tabs.first(); + while ( newtab && newtab->control() != childwidget ) + { + newtab = tabs.next(); + } + if ( newtab && newtab->control() == childwidget ) + { + selectTab( newtab ); + } +} + +void OTabWidget::setCurrentTab( QString tabname ) +{ + TabInfo *newtab = tabs.first(); + while ( newtab && newtab->label() != tabname ) + { + newtab = tabs.next(); + } + if ( newtab && newtab->label() == tabname ) + { + selectTab( newtab ); + } } @@ -156,7 +182,8 @@ void OTabWidget::slotTabBarSelected( int id ) { - - TabInfoList::Iterator newtab = tabs.begin(); - while ( newtab != tabs.end() && (*newtab).id() != id ) - newtab++; - if ( (*newtab).id() == id ) + TabInfo *newtab = tabs.first(); + while ( newtab && newtab->id() != id ) + { + newtab = tabs.next(); + } + if ( newtab && newtab->id() == id ) { @@ -168,4 +195,4 @@ void OTabWidget::slotTabListSelected( int index ) { - TabInfoList::Iterator newtab = tabs.at( index ); - if ( newtab != tabs.end() ) + TabInfo *newtab = tabs.at( index ); + if ( newtab ) { @@ -183,3 +210,3 @@ QPixmap OTabWidget::loadSmooth( const QString &name ) -void OTabWidget::selectTab( TabInfoList::Iterator tab ) +void OTabWidget::selectTab( TabInfo *tab ) { @@ -187,19 +214,20 @@ void OTabWidget::selectTab( TabInfoList::Iterator tab ) { - if ( currentTab != 0x0 ) + if ( currentTab ) { - tabBar->tab( (*currentTab).id() )->label = QString::null; + tabBar->tab( currentTab->id() )->setText( QString::null ); + setUpLayout(); } - tabBar->tab( (*tab).id() )->label = (*tab).label(); + tabBar->tab( tab->id() )->setText( tab->label() ); currentTab = tab; } - tabBar->layoutTabs(); + tabBar->setCurrentTab( tab->id() ); + setUpLayout(); tabBar->update(); - widgetStack->raiseWidget( (*tab).control() ); - - setUpLayout( FALSE ); + widgetStack->raiseWidget( tab->control() ); } -void OTabWidget::setUpLayout( bool onlyCheck ) +void OTabWidget::setUpLayout() { + tabBar->layoutTabs(); QSize t( tabBarStack->sizeHint() ); @@ -219,4 +247,4 @@ void OTabWidget::setUpLayout( bool onlyCheck ) - if ( !onlyCheck ) - update(); +// if ( !onlyCheck ) +// update(); if ( autoMask() ) @@ -234,3 +262,3 @@ void OTabWidget::resizeEvent( QResizeEvent * ) { - setUpLayout( FALSE ); + setUpLayout(); } diff --git a/noncore/settings/sysinfo/otabwidget.h b/noncore/settings/sysinfo/otabwidget.h index 38f4d20..7450d51 100644 --- a/noncore/settings/sysinfo/otabwidget.h +++ b/noncore/settings/sysinfo/otabwidget.h @@ -23,2 +23,3 @@ #include <qwidget.h> +#include <qlist.h> @@ -47,3 +48,3 @@ private: -typedef QValueList<TabInfo> TabInfoList; +typedef QList<TabInfo> TabInfoList; @@ -65,2 +66,4 @@ public: void addTab( QWidget *, const QString &, const QString & ); + void setCurrentTab( QWidget * ); + void setCurrentTab( QString ); QSize sizeHint() const; @@ -72,4 +75,4 @@ protected: private: - TabInfoList tabs; - TabInfoList::Iterator currentTab; + TabInfoList tabs; + TabInfo *currentTab; @@ -85,4 +88,4 @@ private: QPixmap loadSmooth( const QString & ); - void selectTab( TabInfoList::Iterator ); - void setUpLayout( bool ); + void selectTab( TabInfo * ); + void setUpLayout(); |