summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/otabwidget.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index d617a9c..7103884 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -1,475 +1,484 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.org> 4 Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17 : ..    .:,     . . . without even the implied warranty of 17 : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <opie2/otabwidget.h> 31#include <opie2/otabwidget.h>
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/oresource.h> 34#include <opie2/oresource.h>
35#include <opie2/otabbar.h> 35#include <opie2/otabbar.h>
36 36
37#include <qpe/config.h> 37#include <qpe/config.h>
38 38
39/* QT */ 39/* QT */
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qwidgetstack.h> 41#include <qwidgetstack.h>
42 42
43using namespace Opie::Ui; 43using namespace Opie::Ui;
44 44
45OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) 45OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
46 : QWidget( parent, name ) 46 : QWidget( parent, name )
47 , m_currTab( 0l ) 47 , m_currTab( 0l )
48 , m_tabBarStyle( Global ) 48 , m_tabBarStyle( Global )
49 , m_tabBarPosition( Top ) 49 , m_tabBarPosition( Top )
50 , m_usingTabs( true ) 50 , m_usingTabs( true )
51 , m_tabBar( 0l ) 51 , m_tabBar( 0l )
52 , m_tabList( 0l ) 52 , m_tabList( 0l )
53{ 53{
54 if ( s == Global ) 54 if ( s == Global )
55 { 55 {
56 // Read Opie global settings for style and position 56 // Read Opie global settings for style and position
57 Config config( "qpe" ); 57 Config config( "qpe" );
58 config.setGroup( "Appearance" ); 58 config.setGroup( "Appearance" );
59 59
60 // Style 60 // Style
61 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); 61 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
62 if ( s <= Global || s > IconList) 62 if ( s <= Global || s > IconList)
63 s = IconTab; 63 s = IconTab;
64 64
65 // Position 65 // Position
66 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom 66 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom
67 : p = Top; 67 : p = Top;
68 } 68 }
69 69
70 // Initialize widget stack for tab widgets 70 // Initialize widget stack for tab widgets
71 m_widgetStack = new QWidgetStack( this ); 71 m_widgetStack = new QWidgetStack( this );
72 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 72 m_widgetStack->setFrameStyle( QFrame::NoFrame );
73 m_widgetStack->setLineWidth( style().defaultFrameWidth() ); 73 m_widgetStack->setLineWidth( style().defaultFrameWidth() );
74 74
75 // Set initial selector control style and position 75 // Set initial selector control style and position
76 setTabStyle( s ); 76 setTabStyle( s );
77 setTabPosition( p ); 77 setTabPosition( p );
78} 78}
79 79
80OTabWidget::~OTabWidget() 80OTabWidget::~OTabWidget()
81{ 81{
82 m_tabs.setAutoDelete( true ); 82 m_tabs.setAutoDelete( true );
83 m_tabs.clear(); 83 m_tabs.clear();
84} 84}
85 85
86void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 86void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
87{ 87{
88 int tabid = -1; 88 int tabid = -1;
89 89
90 if ( m_usingTabs ) 90 if ( m_usingTabs )
91 { 91 {
92 // Create new tab in tab bar 92 // Create new tab in tab bar
93 QTab *tab = new QTab(); 93 QTab *tab = new QTab();
94 94
95 // Set label (and icon if necessary) 95 // Set label (and icon if necessary)
96 if ( m_tabBarStyle == IconTab ) 96 if ( m_tabBarStyle == IconTab )
97 { 97 {
98 tab->label = QString::null; 98 tab->label = QString::null;
99 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) ); 99 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
100 } 100 }
101 else 101 else
102 tab->label = label; 102 tab->label = label;
103 103
104 tabid = m_tabBar->addTab( tab ); 104 tabid = m_tabBar->addTab( tab );
105 } 105 }
106 else 106 else
107 { 107 {
108 // Insert entry (with icon if necessary) into drop down list 108 // Insert entry (with icon if necessary) into drop down list
109 if ( m_tabBarStyle == IconList ) 109 if ( m_tabBarStyle == IconList )
110 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ), label, -1 ); 110 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ), label, -1 );
111 else 111 else
112 m_tabList->insertItem( label ); 112 m_tabList->insertItem( label );
113 } 113 }
114 114
115 // Add widget to stack 115 // Add widget to stack
116 m_widgetStack->addWidget( child, tabid ); 116 m_widgetStack->addWidget( child, tabid );
117 m_widgetStack->raiseWidget( child ); 117 m_widgetStack->raiseWidget( child );
118 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); 118 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
119 119
120 // Keep track of tab information 120 // Keep track of tab information
121 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); 121 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
122 m_tabs.append( tabinfo ); 122 m_tabs.append( tabinfo );
123 123
124 // Force resizing of child controls
125 resizeEvent( 0x0 );
126
124 // Make newly added tab the current one displayed 127 // Make newly added tab the current one displayed
125 selectTab( tabinfo ); 128 selectTab( tabinfo );
126} 129}
127 130
128void OTabWidget::removePage( QWidget *childwidget ) 131void OTabWidget::removePage( QWidget *childwidget )
129{ 132{
130 if ( childwidget ) 133 if ( childwidget )
131 { 134 {
132 // Find tab information for desired widget 135 // Find tab information for desired widget
133 OTabInfo *tab = m_tabs.first(); 136 OTabInfo *tab = m_tabs.first();
134 while ( tab && tab->control() != childwidget ) 137 while ( tab && tab->control() != childwidget )
135 tab = m_tabs.next(); 138 tab = m_tabs.next();
136 139
137 if ( tab && tab->control() == childwidget ) 140 if ( tab && tab->control() == childwidget )
138 { 141 {
139 if ( m_usingTabs ) 142 if ( m_usingTabs )
140 { 143 {
141 // Remove tab from tab bar 144 // Remove tab from tab bar
142 m_tabBar->setTabEnabled( tab->id(), false ); 145 m_tabBar->setTabEnabled( tab->id(), false );
143 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) ); 146 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) );
144 } 147 }
145 else 148 else
146 { 149 {
147 // Remove entry from drop down list 150 // Remove entry from drop down list
148 int i = 0; 151 int i = 0;
149 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() ) 152 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() )
150 i++; 153 i++;
151 if ( m_tabList->text( i ) == tab->label() ) 154 if ( m_tabList->text( i ) == tab->label() )
152 m_tabList->removeItem( i ); 155 m_tabList->removeItem( i );
153 } 156 }
154 157
155 // Remove widget from stack 158 // Remove widget from stack
156 m_widgetStack->removeWidget( childwidget ); 159 m_widgetStack->removeWidget( childwidget );
157 160
158 // Get rid of tab information 161 // Get rid of tab information
159 m_tabs.remove( tab ); 162 m_tabs.remove( tab );
160 delete tab; 163 delete tab;
161 164
162 // Reset current tab 165 // Reset current tab
163 m_currTab = m_tabs.current(); 166 m_currTab = m_tabs.current();
164 if ( !m_currTab ) 167 if ( !m_currTab )
165 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 168 m_widgetStack->setFrameStyle( QFrame::NoFrame );
166 169
167 // Redraw widget 170 // Redraw widget
168 setUpLayout(); 171 setUpLayout();
169 } 172 }
173
174 // Force resizing of child controls
175 resizeEvent( 0x0 );
170 } 176 }
171} 177}
172 178
173void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) 179void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
174{ 180{
175 // Find tab information for desired widget 181 // Find tab information for desired widget
176 OTabInfo *currtab = m_tabs.first(); 182 OTabInfo *currtab = m_tabs.first();
177 while ( currtab && currtab->control() != widget ) 183 while ( currtab && currtab->control() != widget )
178 currtab = m_tabs.next(); 184 currtab = m_tabs.next();
179 185
180 if ( currtab && currtab->control() == widget ) 186 if ( currtab && currtab->control() == widget )
181 { 187 {
182 QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) ); 188 QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) );
183 189
184 if ( m_usingTabs ) 190 if ( m_usingTabs )
185 { 191 {
186 // Update tab label and icon (if necessary) 192 // Update tab label and icon (if necessary)
187 QTab *tab = m_tabBar->tab( currtab->id() ); 193 QTab *tab = m_tabBar->tab( currtab->id() );
188 tab->setText( label ); 194 tab->setText( label );
189 if ( m_tabBarStyle == IconTab ) 195 if ( m_tabBarStyle == IconTab )
190 tab->setIconSet( icon ); 196 tab->setIconSet( icon );
191 } 197 }
192 else 198 else
193 { 199 {
194 // Update entry label and icon (if necessary) 200 // Update entry label and icon (if necessary)
195 int i = 0; 201 int i = 0;
196 while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() ) 202 while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() )
197 i++; 203 i++;
198 if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() ) 204 if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() )
199 { 205 {
200 if ( m_tabBarStyle == IconList ) 206 if ( m_tabBarStyle == IconList )
201 m_tabList->changeItem( icon, label, i ); 207 m_tabList->changeItem( icon, label, i );
202 else 208 else
203 m_tabList->changeItem( label, i ); 209 m_tabList->changeItem( label, i );
204 } 210 }
205 } 211 }
206 212
207 // Update tab information 213 // Update tab information
208 currtab->setLabel( label ); 214 currtab->setLabel( label );
209 currtab->setIcon( iconset ); 215 currtab->setIcon( iconset );
210 216
217 // Force resizing of child controls
218 resizeEvent( 0x0 );
219
211 // Redraw widget 220 // Redraw widget
212 setUpLayout(); 221 setUpLayout();
213 } 222 }
214} 223}
215 224
216void OTabWidget::setCurrentTab( QWidget *childwidget ) 225void OTabWidget::setCurrentTab( QWidget *childwidget )
217{ 226{
218 OTabInfo *currtab = m_tabs.first(); 227 OTabInfo *currtab = m_tabs.first();
219 while ( currtab && currtab->control() != childwidget ) 228 while ( currtab && currtab->control() != childwidget )
220 { 229 {
221 currtab = m_tabs.next(); 230 currtab = m_tabs.next();
222 } 231 }
223 if ( currtab && currtab->control() == childwidget ) 232 if ( currtab && currtab->control() == childwidget )
224 { 233 {
225 selectTab( currtab ); 234 selectTab( currtab );
226 } 235 }
227} 236}
228 237
229void OTabWidget::setCurrentTab( const QString &tabname ) 238void OTabWidget::setCurrentTab( const QString &tabname )
230{ 239{
231 OTabInfo *newtab = m_tabs.first(); 240 OTabInfo *newtab = m_tabs.first();
232 while ( newtab && newtab->label() != tabname ) 241 while ( newtab && newtab->label() != tabname )
233 { 242 {
234 newtab = m_tabs.next(); 243 newtab = m_tabs.next();
235 } 244 }
236 if ( newtab && newtab->label() == tabname ) 245 if ( newtab && newtab->label() == tabname )
237 { 246 {
238 selectTab( newtab ); 247 selectTab( newtab );
239 } 248 }
240} 249}
241 250
242void OTabWidget::setCurrentTab(int tabindex) 251void OTabWidget::setCurrentTab(int tabindex)
243{ 252{
244 OTabInfo *newtab = m_tabs.first(); 253 OTabInfo *newtab = m_tabs.first();
245 while ( newtab && newtab->id() != tabindex ) 254 while ( newtab && newtab->id() != tabindex )
246 { 255 {
247 newtab = m_tabs.next(); 256 newtab = m_tabs.next();
248 } 257 }
249 if ( newtab && newtab->id() == tabindex ) 258 if ( newtab && newtab->id() == tabindex )
250 { 259 {
251 selectTab( newtab ); 260 selectTab( newtab );
252 } 261 }
253} 262}
254 263
255 264
256OTabWidget::TabStyle OTabWidget::tabStyle() const 265OTabWidget::TabStyle OTabWidget::tabStyle() const
257{ 266{
258 return m_tabBarStyle; 267 return m_tabBarStyle;
259} 268}
260 269
261void OTabWidget::setTabStyle( TabStyle s ) 270void OTabWidget::setTabStyle( TabStyle s )
262{ 271{
263 // Get out if new and current styles are the same 272 // Get out if new and current styles are the same
264 if ( s == m_tabBarStyle ) 273 if ( s == m_tabBarStyle )
265 return; 274 return;
266 275
267 // Delete current selector control 276 // Delete current selector control
268 if ( m_usingTabs ) 277 if ( m_usingTabs )
269 { 278 {
270 delete m_tabBar; 279 delete m_tabBar;
271 m_tabBar = 0l; 280 m_tabBar = 0l;
272 } 281 }
273 else 282 else
274 { 283 {
275 delete m_tabList; 284 delete m_tabList;
276 m_tabList = 0l; 285 m_tabList = 0l;
277 } 286 }
278 287
279 // Set new style information 288 // Set new style information
280 m_tabBarStyle = s; 289 m_tabBarStyle = s;
281 m_usingTabs = ( m_tabBarStyle == TextTab || m_tabBarStyle == IconTab ); 290 m_usingTabs = ( m_tabBarStyle == TextTab || m_tabBarStyle == IconTab );
282 291
283 // Create new selector control and populate with tab information 292 // Create new selector control and populate with tab information
284 if ( m_usingTabs ) 293 if ( m_usingTabs )
285 { 294 {
286 // Create new tab bar selector 295 // Create new tab bar selector
287 m_tabBar = new OTabBar( this ); 296 m_tabBar = new OTabBar( this );
288 connect( m_tabBar, SIGNAL(selected(int)), this, SLOT(slotTabBarSelected(int)) ); 297 connect( m_tabBar, SIGNAL(selected(int)), this, SLOT(slotTabBarSelected(int)) );
289 298
290 // Add all current tabs to tab bar 299 // Add all current tabs to tab bar
291 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() ) 300 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() )
292 { 301 {
293 // Create new tab in tab bar 302 // Create new tab in tab bar
294 QTab *tab = new QTab(); 303 QTab *tab = new QTab();
295 304
296 // Set label (and icon if necessary) 305 // Set label (and icon if necessary)
297 if ( m_tabBarStyle == IconTab ) 306 if ( m_tabBarStyle == IconTab )
298 { 307 {
299 tab->label = QString::null; 308 tab->label = QString::null;
300 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ) ); 309 tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ) );
301 } 310 }
302 else 311 else
303 tab->label = tabinfo->label(); 312 tab->label = tabinfo->label();
304 313
305 // Add tab and save its Id 314 // Add tab and save its Id
306 int tabid = m_tabBar->addTab( tab ); 315 int tabid = m_tabBar->addTab( tab );
307 tabinfo->setId( tabid ); 316 tabinfo->setId( tabid );
308 } 317 }
309 } 318 }
310 else 319 else
311 { 320 {
312 // Create new drop down list selector 321 // Create new drop down list selector
313 m_tabList = new QComboBox( false, this ); 322 m_tabList = new QComboBox( false, this );
314 connect( m_tabList, SIGNAL(activated(int)), this, SLOT(slotTabListSelected(int)) ); 323 connect( m_tabList, SIGNAL(activated(int)), this, SLOT(slotTabListSelected(int)) );
315 324
316 // Add all current tabs to drop down list 325 // Add all current tabs to drop down list
317 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() ) 326 for ( OTabInfo *tabinfo = m_tabs.first(); tabinfo; tabinfo = m_tabs.next() )
318 { 327 {
319 if ( m_tabBarStyle == IconList ) 328 if ( m_tabBarStyle == IconList )
320 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ), 329 m_tabList->insertItem( Opie::Core::OResource::loadPixmap( tabinfo->icon(), Opie::Core::OResource::SmallIcon ),
321 tabinfo->label() ); 330 tabinfo->label() );
322 else 331 else
323 m_tabList->insertItem( tabinfo->label() ); 332 m_tabList->insertItem( tabinfo->label() );
324 } 333 }
325 } 334 }
326 335
327 // Redraw widget 336 // Redraw widget
328 setUpLayout(); 337 setUpLayout();
329} 338}
330 339
331OTabWidget::TabPosition OTabWidget::tabPosition() const 340OTabWidget::TabPosition OTabWidget::tabPosition() const
332{ 341{
333 return m_tabBarPosition; 342 return m_tabBarPosition;
334} 343}
335 344
336void OTabWidget::setTabPosition( TabPosition p ) 345void OTabWidget::setTabPosition( TabPosition p )
337{ 346{
338 m_tabBarPosition = p; 347 m_tabBarPosition = p;
339 348
340 // If using the tab bar selector, set its shape 349 // If using the tab bar selector, set its shape
341 if ( m_usingTabs ) 350 if ( m_usingTabs )
342 { 351 {
343 ( m_tabBarPosition == Top ) ? m_tabBar->setShape( QTabBar::RoundedAbove ) 352 ( m_tabBarPosition == Top ) ? m_tabBar->setShape( QTabBar::RoundedAbove )
344 : m_tabBar->setShape( QTabBar::RoundedBelow ); 353 : m_tabBar->setShape( QTabBar::RoundedBelow );
345 } 354 }
346 355
347 // Redraw widget 356 // Redraw widget
348 setUpLayout(); 357 setUpLayout();
349} 358}
350 359
351void OTabWidget::slotTabBarSelected( int id ) 360void OTabWidget::slotTabBarSelected( int id )
352{ 361{
353 OTabInfo *newtab = m_tabs.first(); 362 OTabInfo *newtab = m_tabs.first();
354 while ( newtab && newtab->id() != id ) 363 while ( newtab && newtab->id() != id )
355 newtab = m_tabs.next(); 364 newtab = m_tabs.next();
356 365
357 if ( newtab && newtab->id() == id ) 366 if ( newtab && newtab->id() == id )
358 selectTab( newtab ); 367 selectTab( newtab );
359} 368}
360 369
361void OTabWidget::slotTabListSelected( int index ) 370void OTabWidget::slotTabListSelected( int index )
362{ 371{
363 OTabInfo *newtab = m_tabs.at( index ); 372 OTabInfo *newtab = m_tabs.at( index );
364 if ( newtab ) 373 if ( newtab )
365 selectTab( newtab ); 374 selectTab( newtab );
366} 375}
367 376
368void OTabWidget::selectTab( OTabInfo *tab ) 377void OTabWidget::selectTab( OTabInfo *tab )
369{ 378{
370 if ( m_tabBarStyle == IconTab ) 379 if ( m_tabBarStyle == IconTab )
371 { 380 {
372 // Remove text label from currently selected tab 381 // Remove text label from currently selected tab
373 if ( m_currTab ) 382 if ( m_currTab )
374 { 383 {
375 m_tabBar->tab( m_currTab->id() )->setText( QString::null ); 384 m_tabBar->tab( m_currTab->id() )->setText( QString::null );
376 //setUpLayout(); 385 //setUpLayout();
377 } 386 }
378 387
379 // Set text label for newly selected tab 388 // Set text label for newly selected tab
380 m_tabBar->tab( tab->id() )->setText( tab->label() ); 389 m_tabBar->tab( tab->id() )->setText( tab->label() );
381 m_tabBar->setCurrentTab( tab->id() ); 390 m_tabBar->setCurrentTab( tab->id() );
382 391
383 setUpLayout(); 392 setUpLayout();
384 393
385 QSize t; 394 QSize t;
386 395
387 t = m_tabBar->sizeHint(); 396 t = m_tabBar->sizeHint();
388 if ( t.width() > width() ) 397 if ( t.width() > width() )
389 t.setWidth( width() ); 398 t.setWidth( width() );
390 int lw = m_widgetStack->lineWidth(); 399 int lw = m_widgetStack->lineWidth();
391 if ( m_tabBarPosition == Bottom ) 400 if ( m_tabBarPosition == Bottom )
392 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 401 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
393 else 402 else
394 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 403 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
395 } 404 }
396 else if ( m_tabBarStyle == TextTab ) 405 else if ( m_tabBarStyle == TextTab )
397 { 406 {
398 m_tabBar->setCurrentTab( tab->id() ); 407 m_tabBar->setCurrentTab( tab->id() );
399 } 408 }
400 409
401 m_widgetStack->raiseWidget( tab->control() ); 410 m_widgetStack->raiseWidget( tab->control() );
402 411
403 emit currentChanged( tab->control() ); 412 emit currentChanged( tab->control() );
404 413
405 m_currTab = tab; 414 m_currTab = tab;
406} 415}
407 416
408void OTabWidget::setUpLayout() 417void OTabWidget::setUpLayout()
409{ 418{
410 if ( m_usingTabs ) 419 if ( m_usingTabs )
411 { 420 {
412 m_tabBar->update(); 421 m_tabBar->update();
413 m_tabBar->layoutTabs(); 422 m_tabBar->layoutTabs();
414 } 423 }
415} 424}
416 425
417void OTabWidget::resizeEvent( QResizeEvent * ) 426void OTabWidget::resizeEvent( QResizeEvent * )
418{ 427{
419 QSize t; 428 QSize t;
420 429
421 if ( m_usingTabs ) 430 if ( m_usingTabs )
422 { 431 {
423 m_tabBar->layoutTabs(); 432 m_tabBar->layoutTabs();
424 t = m_tabBar->sizeHint(); 433 t = m_tabBar->sizeHint();
425 if ( t.width() > width() ) 434 if ( t.width() > width() )
426 t.setWidth( width() ); 435 t.setWidth( width() );
427 } 436 }
428 else 437 else
429 { 438 {
430 t = m_tabList->sizeHint(); 439 t = m_tabList->sizeHint();
431 t.setWidth( width() ); 440 t.setWidth( width() );
432 } 441 }
433 442
434 int lw = m_widgetStack->lineWidth(); 443 int lw = m_widgetStack->lineWidth();
435 if ( m_tabBarPosition == Bottom ) 444 if ( m_tabBarPosition == Bottom )
436 { 445 {
437 if ( m_usingTabs ) 446 if ( m_usingTabs )
438 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 447 m_tabBar->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
439 else 448 else
440 m_tabList->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); 449 m_tabList->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() );
441 450
442 m_widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); 451 m_widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) );
443 } 452 }
444 else 453 else
445 { 454 {
446 if ( m_usingTabs ) 455 if ( m_usingTabs )
447 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 456 m_tabBar->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
448 else 457 else
449 m_tabList->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); 458 m_tabList->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() );
450 459
451 m_widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); 460 m_widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) );
452 } 461 }
453 462
454 if ( autoMask() ) 463 if ( autoMask() )
455 updateMask(); 464 updateMask();
456} 465}
457 466
458int OTabWidget::currentTab() 467int OTabWidget::currentTab()
459{ 468{
460 if ( m_currTab ) 469 if ( m_currTab )
461 { 470 {
462 return m_currTab->id(); 471 return m_currTab->id();
463 } 472 }
464 return -1; 473 return -1;
465} 474}
466 475
467QWidget* OTabWidget::currentWidget()const 476QWidget* OTabWidget::currentWidget()const
468{ 477{
469 if ( m_currTab ) 478 if ( m_currTab )
470 { 479 {
471 return m_currTab->control(); 480 return m_currTab->control();
472 } 481 }
473 482
474 return 0; 483 return 0;
475} 484}