summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-11 22:32:31 (UTC)
committer zecke <zecke>2002-10-11 22:32:31 (UTC)
commitffa7f45a2100b7c438a437fce2d3a47608bd36e3 (patch) (unidiff)
treeccfa8b0c7490d2a271ff7f5edc19ae8e14e277f1
parentc8c961b4106f49f544195733cef17af5f15f6bb8 (diff)
downloadopie-ffa7f45a2100b7c438a437fce2d3a47608bd36e3.zip
opie-ffa7f45a2100b7c438a437fce2d3a47608bd36e3.tar.gz
opie-ffa7f45a2100b7c438a437fce2d3a47608bd36e3.tar.bz2
Fix from drw for his widget. This sounds a bit paradox
Remove Page and Inserting one again crashed... This patch fixes this problem
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/otabwidget.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp
index 1f3fbb0..6ef4034 100644
--- a/libopie/otabwidget.cpp
+++ b/libopie/otabwidget.cpp
@@ -85,25 +85,25 @@ OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPositi
85 tabBarStack->raiseWidget( tabBar ); 85 tabBarStack->raiseWidget( tabBar );
86 } 86 }
87 else if ( tabBarStyle == TextList || tabBarStyle == IconList ) 87 else if ( tabBarStyle == TextList || tabBarStyle == IconList )
88 { 88 {
89 tabBarStack->raiseWidget( tabList ); 89 tabBarStack->raiseWidget( tabList );
90 } 90 }
91 91
92 if ( tabBarPosition == Bottom ) 92 if ( tabBarPosition == Bottom )
93 { 93 {
94 tabBar->setShape( QTabBar::RoundedBelow ); 94 tabBar->setShape( QTabBar::RoundedBelow );
95 } 95 }
96 96
97 tabs.setAutoDelete( TRUE ); 97 //tabs.setAutoDelete( TRUE );
98 currentTab= 0x0; 98 currentTab= 0x0;
99} 99}
100 100
101OTabWidget::~OTabWidget() 101OTabWidget::~OTabWidget()
102{ 102{
103} 103}
104 104
105void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 105void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
106{ 106{
107 QPixmap iconset = loadSmooth( icon ); 107 QPixmap iconset = loadSmooth( icon );
108 108
109 QTab * tab = new QTab(); 109 QTab * tab = new QTab();
@@ -131,46 +131,48 @@ void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &lab
131 } 131 }
132 132
133 widgetStack->addWidget( child, tabid ); 133 widgetStack->addWidget( child, tabid );
134 widgetStack->raiseWidget( child ); 134 widgetStack->raiseWidget( child );
135 135
136 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); 136 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
137 tabs.append( tabinfo ); 137 tabs.append( tabinfo );
138 selectTab( tabinfo ); 138 selectTab( tabinfo );
139} 139}
140 140
141void OTabWidget::removePage( QWidget *childwidget ) 141void OTabWidget::removePage( QWidget *childwidget )
142{ 142{
143 if ( childwidget ) 143 if ( childwidget )
144 { 144 {
145 OTabInfo *tab = tabs.first(); 145 OTabInfo *tab = tabs.first();
146 while ( tab && tab->control() != childwidget ) 146 while ( tab && tab->control() != childwidget )
147 { 147 {
148 tab = tabs.next(); 148 tab = tabs.next();
149 } 149 }
150 if ( tab && tab->control() == childwidget ) 150 if ( tab && tab->control() == childwidget )
151 { 151 {
152 tabBar->setTabEnabled( tab->id(), FALSE ); 152 tabBar->setTabEnabled( tab->id(), FALSE );
153 tabBar->removeTab( tabBar->tab( tab->id() ) ); 153 tabBar->removeTab( tabBar->tab( tab->id() ) );
154 int i = 0; 154 int i = 0;
155 while ( i < tabList->count() && tabList->text( i ) != tab->label() ) 155 while ( i < tabList->count() && tabList->text( i ) != tab->label() )
156 { 156 {
157 i++; 157 i++;
158 } 158 }
159 if ( tabList->text( i ) == tab->label() ) 159 if ( tabList->text( i ) == tab->label() )
160 { 160 {
161 tabList->removeItem( i ); 161 tabList->removeItem( i );
162 } 162 }
163 widgetStack->removeWidget( childwidget ); 163 widgetStack->removeWidget( childwidget );
164 tabs.remove( tab ); 164 tabs.remove( tab );
165 delete tab;
166 currentTab = tabs.current();
165 setUpLayout(); 167 setUpLayout();
166 } 168 }
167 } 169 }
168} 170}
169 171
170void OTabWidget::setCurrentTab( QWidget *childwidget ) 172void OTabWidget::setCurrentTab( QWidget *childwidget )
171{ 173{
172 OTabInfo *newtab = tabs.first(); 174 OTabInfo *newtab = tabs.first();
173 while ( newtab && newtab->control() != childwidget ) 175 while ( newtab && newtab->control() != childwidget )
174 { 176 {
175 newtab = tabs.next(); 177 newtab = tabs.next();
176 } 178 }
@@ -240,25 +242,25 @@ QPixmap OTabWidget::loadSmooth( const QString &name )
240 QImage image = Resource::loadImage( name ); 242 QImage image = Resource::loadImage( name );
241 QPixmap pixmap; 243 QPixmap pixmap;
242 pixmap.convertFromImage( image.smoothScale( 16, 16 ) ); 244 pixmap.convertFromImage( image.smoothScale( 16, 16 ) );
243 return pixmap; 245 return pixmap;
244} 246}
245 247
246void OTabWidget::selectTab( OTabInfo *tab ) 248void OTabWidget::selectTab( OTabInfo *tab )
247{ 249{
248 if ( tabBarStyle == IconTab ) 250 if ( tabBarStyle == IconTab )
249 { 251 {
250 if ( currentTab ) 252 if ( currentTab )
251 { 253 {
252 tabBar->tab( currentTab->id() )->setText( QString::null ); 254 tabBar->tab( currentTab->id() )->setText( "" );
253 setUpLayout(); 255 setUpLayout();
254 } 256 }
255 tabBar->tab( tab->id() )->setText( tab->label() ); 257 tabBar->tab( tab->id() )->setText( tab->label() );
256 currentTab = tab; 258 currentTab = tab;
257 } 259 }
258 tabBar->setCurrentTab( tab->id() ); 260 tabBar->setCurrentTab( tab->id() );
259 setUpLayout(); 261 setUpLayout();
260 tabBar->update(); 262 tabBar->update();
261 263
262 widgetStack->raiseWidget( tab->control() ); 264 widgetStack->raiseWidget( tab->control() );
263 265
264 emit currentChanged( tab->control() ); 266 emit currentChanged( tab->control() );