summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/otabwidget.cpp78
-rw-r--r--noncore/settings/sysinfo/otabwidget.h11
2 files changed, 60 insertions, 29 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
@@ -22,9 +22,8 @@
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qcombobox.h>
-#include <qlist.h>
#include <qtabbar.h>
#include <qwidgetstack.h>
OTabWidget::OTabWidget( QWidget *parent, const char *name = 0x0,
@@ -82,8 +81,10 @@ OTabWidget::OTabWidget( QWidget *parent, const char *name = 0x0,
if ( tabBarPosition == Bottom )
{
tabBar->setShape( QTabBar::RoundedBelow );
}
+
+ currentTab= 0x0;
}
OTabWidget::~OTabWidget()
{
@@ -107,30 +108,55 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
{
tab->iconset = new QIconSet( iconset );
}
int tabid = tabBar->addTab( tab );
- tabBar->setCurrentTab( tab );
// Add to tabList
-
if ( tabBarStyle == IconTab || tabBarStyle == IconList )
{
tabList->insertItem( iconset, label, -1 );
}
else
{
tabList->insertItem( label );
}
- tabList->setCurrentItem( tabList->count()-1 );
// Add child to widget list
widgetStack->addWidget( child, tabid );
widgetStack->raiseWidget( child );
// Save tab information
- tabs.append( TabInfo( tabid, child, icon, label ) );
+ TabInfo *tabinfo = new TabInfo( tabid, child, icon, label );
+ tabs.append( tabinfo );
+ selectTab( tabinfo );
+
+// setUpLayout();
+}
+
+void OTabWidget::setCurrentTab( QWidget *childwidget )
+{
+ TabInfo *newtab = tabs.first();
+ while ( newtab && newtab->control() != childwidget )
+ {
+ newtab = tabs.next();
+ }
+ if ( newtab && newtab->control() == childwidget )
+ {
+ selectTab( newtab );
+ }
+}
- setUpLayout( FALSE );
+void OTabWidget::setCurrentTab( QString tabname )
+{
+ TabInfo *newtab = tabs.first();
+ while ( newtab && newtab->label() != tabname )
+ {
+ newtab = tabs.next();
+ }
+ if ( newtab && newtab->label() == tabname )
+ {
+ selectTab( newtab );
+ }
}
OTabWidget::TabStyle OTabWidget::tabStyle() const
{
@@ -153,22 +179,23 @@ 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 );
}
}
void OTabWidget::slotTabListSelected( int index )
{
- TabInfoList::Iterator newtab = tabs.at( index );
- if ( newtab != tabs.end() )
+ TabInfo *newtab = tabs.at( index );
+ if ( newtab )
{
selectTab( newtab );
}
}
@@ -180,29 +207,30 @@ QPixmap OTabWidget::loadSmooth( const QString &name )
pixmap.convertFromImage( image.smoothScale( 16, 16 ) );
return pixmap;
}
-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() )
t.setWidth( width() );
int lw = widgetStack->lineWidth();
@@ -216,10 +244,10 @@ void OTabWidget::setUpLayout( bool onlyCheck )
tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX(0, lw-2));
}
- if ( !onlyCheck )
- update();
+// if ( !onlyCheck )
+// update();
if ( autoMask() )
updateMask();
}
@@ -231,6 +259,6 @@ 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
@@ -20,8 +20,9 @@
#ifndef OTABWIDGET_H
#define OTABWIDGET_H
#include <qwidget.h>
+#include <qlist.h>
class QComboBox;
class QPixmap;
class QTabBar;
@@ -44,9 +45,9 @@ private:
QString p;
QString l;
};
-typedef QValueList<TabInfo> TabInfoList;
+typedef QList<TabInfo> TabInfoList;
class OTabWidget : public QWidget
{
Q_OBJECT
@@ -62,17 +63,19 @@ public:
OTabWidget( QWidget *, const char *, TabStyle, TabPosition );
~OTabWidget();
void addTab( QWidget *, const QString &, const QString & );
+ void setCurrentTab( QWidget * );
+ void setCurrentTab( QString );
QSize sizeHint() const;
protected:
void resizeEvent( QResizeEvent * );
private:
TabInfoList tabs;
- TabInfoList::Iterator currentTab;
+ TabInfo *currentTab;
TabStyle tabBarStyle;
TabPosition tabBarPosition;
@@ -82,10 +85,10 @@ private:
QWidgetStack *widgetStack;
QPixmap loadSmooth( const QString & );
- void selectTab( TabInfoList::Iterator );
- void setUpLayout( bool );
+ void selectTab( TabInfo * );
+ void setUpLayout();
private slots:
void slotTabBarSelected( int );
void slotTabListSelected( int );