summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/otabwidget.cpp78
-rw-r--r--noncore/settings/sysinfo/otabwidget.h13
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
@@ -24,5 +24,4 @@
#include <qcombobox.h>
-#include <qlist.h>
#include <qtabbar.h>
#include <qwidgetstack.h>
@@ -84,4 +83,6 @@ OTabWidget::OTabWidget( QWidget *parent, const char *name = 0x0,
tabBar->setShape( QTabBar::RoundedBelow );
}
+
+ currentTab= 0x0;
}
@@ -109,8 +110,6 @@ 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 )
{
@@ -121,5 +120,4 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
tabList->insertItem( label );
}
- tabList->setCurrentItem( tabList->count()-1 );
// Add child to widget list
@@ -128,7 +126,35 @@ 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 );
+ }
}
@@ -155,9 +181,10 @@ void OTabWidget::setTabPosition( TabPosition p )
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 )
{
selectTab( newtab );
@@ -167,6 +194,6 @@ void OTabWidget::slotTabBarSelected( int id )
void OTabWidget::slotTabListSelected( int index )
{
- TabInfoList::Iterator newtab = tabs.at( index );
- if ( newtab != tabs.end() )
+ TabInfo *newtab = tabs.at( index );
+ if ( newtab )
{
selectTab( newtab );
@@ -182,25 +209,26 @@ QPixmap OTabWidget::loadSmooth( const QString &name )
}
-void OTabWidget::selectTab( TabInfoList::Iterator tab )
+void OTabWidget::selectTab( TabInfo *tab )
{
if ( tabBarStyle == IconTab )
{
- 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() );
if ( t.width() > width() )
@@ -218,6 +246,6 @@ void OTabWidget::setUpLayout( bool onlyCheck )
}
- if ( !onlyCheck )
- update();
+// if ( !onlyCheck )
+// update();
if ( autoMask() )
updateMask();
@@ -233,4 +261,4 @@ QSize OTabWidget::sizeHint() const
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
@@ -22,4 +22,5 @@
#include <qwidget.h>
+#include <qlist.h>
class QComboBox;
@@ -46,5 +47,5 @@ private:
};
-typedef QValueList<TabInfo> TabInfoList;
+typedef QList<TabInfo> TabInfoList;
class OTabWidget : public QWidget
@@ -64,4 +65,6 @@ public:
void addTab( QWidget *, const QString &, const QString & );
+ void setCurrentTab( QWidget * );
+ void setCurrentTab( QString );
QSize sizeHint() const;
@@ -71,6 +74,6 @@ protected:
private:
- TabInfoList tabs;
- TabInfoList::Iterator currentTab;
+ TabInfoList tabs;
+ TabInfo *currentTab;
TabStyle tabBarStyle;
@@ -84,6 +87,6 @@ private:
QPixmap loadSmooth( const QString & );
- void selectTab( TabInfoList::Iterator );
- void setUpLayout( bool );
+ void selectTab( TabInfo * );
+ void setUpLayout();
private slots: