summaryrefslogtreecommitdiff
authordrw <drw>2002-08-11 22:12:54 (UTC)
committer drw <drw>2002-08-11 22:12:54 (UTC)
commit496ba37b34ef5847865e0e387443d7481b1487f0 (patch) (unidiff)
tree60ec019d7d4539818743b6babd71300e22b1cbeb
parente7af03e8257119824b53a63f581366b6e25f4ae5 (diff)
downloadopie-496ba37b34ef5847865e0e387443d7481b1487f0.zip
opie-496ba37b34ef5847865e0e387443d7481b1487f0.tar.gz
opie-496ba37b34ef5847865e0e387443d7481b1487f0.tar.bz2
OTabWidget updates
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
@@ -25,3 +25,2 @@
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qlist.h>
27#include <qtabbar.h> 26#include <qtabbar.h>
@@ -85,2 +84,4 @@ OTabWidget::OTabWidget( QWidget *parent, const char *name = 0x0,
85 } 84 }
85
86 currentTab= 0x0;
86} 87}
@@ -110,6 +111,4 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
110 int tabid = tabBar->addTab( tab ); 111 int tabid = tabBar->addTab( tab );
111 tabBar->setCurrentTab( tab );
112 112
113 // Add to tabList 113 // Add to tabList
114
115 if ( tabBarStyle == IconTab || tabBarStyle == IconList ) 114 if ( tabBarStyle == IconTab || tabBarStyle == IconList )
@@ -122,3 +121,2 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
122 } 121 }
123 tabList->setCurrentItem( tabList->count()-1 );
124 122
@@ -129,5 +127,33 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
129 // Save tab information 127 // Save tab information
130 tabs.append( TabInfo( tabid, child, icon, label ) ); 128 TabInfo *tabinfo = new TabInfo( tabid, child, icon, label );
129 tabs.append( tabinfo );
130 selectTab( tabinfo );
131
132// setUpLayout();
133}
131 134
132 setUpLayout( FALSE ); 135void OTabWidget::setCurrentTab( QWidget *childwidget )
136{
137 TabInfo *newtab = tabs.first();
138 while ( newtab && newtab->control() != childwidget )
139 {
140 newtab = tabs.next();
141 }
142 if ( newtab && newtab->control() == childwidget )
143 {
144 selectTab( newtab );
145 }
146}
147
148void OTabWidget::setCurrentTab( QString tabname )
149{
150 TabInfo *newtab = tabs.first();
151 while ( newtab && newtab->label() != tabname )
152 {
153 newtab = tabs.next();
154 }
155 if ( newtab && newtab->label() == tabname )
156 {
157 selectTab( newtab );
158 }
133} 159}
@@ -156,7 +182,8 @@ void OTabWidget::slotTabBarSelected( int id )
156{ 182{
157 183 TabInfo *newtab = tabs.first();
158 TabInfoList::Iterator newtab = tabs.begin(); 184 while ( newtab && newtab->id() != id )
159 while ( newtab != tabs.end() && (*newtab).id() != id ) 185 {
160 newtab++; 186 newtab = tabs.next();
161 if ( (*newtab).id() == id ) 187 }
188 if ( newtab && newtab->id() == id )
162 { 189 {
@@ -168,4 +195,4 @@ void OTabWidget::slotTabListSelected( int index )
168{ 195{
169 TabInfoList::Iterator newtab = tabs.at( index ); 196 TabInfo *newtab = tabs.at( index );
170 if ( newtab != tabs.end() ) 197 if ( newtab )
171 { 198 {
@@ -183,3 +210,3 @@ QPixmap OTabWidget::loadSmooth( const QString &name )
183 210
184void OTabWidget::selectTab( TabInfoList::Iterator tab ) 211void OTabWidget::selectTab( TabInfo *tab )
185{ 212{
@@ -187,19 +214,20 @@ void OTabWidget::selectTab( TabInfoList::Iterator tab )
187 { 214 {
188 if ( currentTab != 0x0 ) 215 if ( currentTab )
189 { 216 {
190 tabBar->tab( (*currentTab).id() )->label = QString::null; 217 tabBar->tab( currentTab->id() )->setText( QString::null );
218 setUpLayout();
191 } 219 }
192 tabBar->tab( (*tab).id() )->label = (*tab).label(); 220 tabBar->tab( tab->id() )->setText( tab->label() );
193 currentTab = tab; 221 currentTab = tab;
194 } 222 }
195 tabBar->layoutTabs(); 223 tabBar->setCurrentTab( tab->id() );
224 setUpLayout();
196 tabBar->update(); 225 tabBar->update();
197 226
198 widgetStack->raiseWidget( (*tab).control() ); 227 widgetStack->raiseWidget( tab->control() );
199
200 setUpLayout( FALSE );
201} 228}
202 229
203void OTabWidget::setUpLayout( bool onlyCheck ) 230void OTabWidget::setUpLayout()
204{ 231{
232 tabBar->layoutTabs();
205 QSize t( tabBarStack->sizeHint() ); 233 QSize t( tabBarStack->sizeHint() );
@@ -219,4 +247,4 @@ void OTabWidget::setUpLayout( bool onlyCheck )
219 247
220 if ( !onlyCheck ) 248// if ( !onlyCheck )
221 update(); 249// update();
222 if ( autoMask() ) 250 if ( autoMask() )
@@ -234,3 +262,3 @@ void OTabWidget::resizeEvent( QResizeEvent * )
234{ 262{
235 setUpLayout( FALSE ); 263 setUpLayout();
236} 264}
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 @@
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qlist.h>
24 25
@@ -47,3 +48,3 @@ private:
47 48
48typedef QValueList<TabInfo> TabInfoList; 49typedef QList<TabInfo> TabInfoList;
49 50
@@ -65,2 +66,4 @@ public:
65 void addTab( QWidget *, const QString &, const QString & ); 66 void addTab( QWidget *, const QString &, const QString & );
67 void setCurrentTab( QWidget * );
68 void setCurrentTab( QString );
66 QSize sizeHint() const; 69 QSize sizeHint() const;
@@ -72,4 +75,4 @@ protected:
72private: 75private:
73 TabInfoList tabs; 76 TabInfoList tabs;
74 TabInfoList::Iterator currentTab; 77 TabInfo *currentTab;
75 78
@@ -85,4 +88,4 @@ private:
85 QPixmap loadSmooth( const QString & ); 88 QPixmap loadSmooth( const QString & );
86 void selectTab( TabInfoList::Iterator ); 89 void selectTab( TabInfo * );
87 void setUpLayout( bool ); 90 void setUpLayout();
88 91