summaryrefslogtreecommitdiff
path: root/libopie/otabwidget.cpp
Unidiff
Diffstat (limited to 'libopie/otabwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/otabwidget.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp
index a1fd2c0..05aafd4 100644
--- a/libopie/otabwidget.cpp
+++ b/libopie/otabwidget.cpp
@@ -69,25 +69,25 @@ OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPositi
69 69
70 tabBar = new OTabBar( tabBarStack, "tabbar" ); 70 tabBar = new OTabBar( tabBarStack, "tabbar" );
71 tabBarStack->addWidget( tabBar, 0 ); 71 tabBarStack->addWidget( tabBar, 0 );
72 connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) ); 72 connect( tabBar, SIGNAL( selected( int ) ), this, SLOT( slotTabBarSelected( int ) ) );
73 73
74 tabList = new QComboBox( false, tabBarStack, "tablist" ); 74 tabList = new QComboBox( false, tabBarStack, "tablist" );
75 tabBarStack->addWidget( tabList, 1 ); 75 tabBarStack->addWidget( tabList, 1 );
76 connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) ); 76 connect( tabList, SIGNAL( activated( int ) ), this, SLOT( slotTabListSelected( int ) ) );
77 77
78 setTabStyle( s ); 78 setTabStyle( s );
79 setTabPosition( p ); 79 setTabPosition( p );
80 80
81 currentTab= 0x0; 81 currTab= 0x0;
82} 82}
83 83
84OTabWidget::~OTabWidget() 84OTabWidget::~OTabWidget()
85{ 85{
86} 86}
87 87
88void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 88void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
89{ 89{
90 QPixmap iconset = loadSmooth( icon ); 90 QPixmap iconset = loadSmooth( icon );
91 91
92 QTab *tab = new QTab(); 92 QTab *tab = new QTab();
93 if ( tabBarStyle == IconTab ) 93 if ( tabBarStyle == IconTab )
@@ -138,26 +138,26 @@ void OTabWidget::removePage( QWidget *childwidget )
138 int i = 0; 138 int i = 0;
139 while ( i < tabList->count() && tabList->text( i ) != tab->label() ) 139 while ( i < tabList->count() && tabList->text( i ) != tab->label() )
140 { 140 {
141 i++; 141 i++;
142 } 142 }
143 if ( tabList->text( i ) == tab->label() ) 143 if ( tabList->text( i ) == tab->label() )
144 { 144 {
145 tabList->removeItem( i ); 145 tabList->removeItem( i );
146 } 146 }
147 widgetStack->removeWidget( childwidget ); 147 widgetStack->removeWidget( childwidget );
148 tabs.remove( tab ); 148 tabs.remove( tab );
149 delete tab; 149 delete tab;
150 currentTab = tabs.current(); 150 currTab = tabs.current();
151 if ( !currentTab ) 151 if ( !currTab )
152 { 152 {
153 widgetStack->setFrameStyle( QFrame::NoFrame ); 153 widgetStack->setFrameStyle( QFrame::NoFrame );
154 } 154 }
155 155
156 setUpLayout(); 156 setUpLayout();
157 } 157 }
158 } 158 }
159} 159}
160 160
161void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) 161void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
162{ 162{
163 OTabInfo *currtab = tabs.first(); 163 OTabInfo *currtab = tabs.first();
@@ -241,25 +241,25 @@ OTabWidget::TabStyle OTabWidget::tabStyle() const
241void OTabWidget::setTabStyle( TabStyle s ) 241void OTabWidget::setTabStyle( TabStyle s )
242{ 242{
243 tabBarStyle = s; 243 tabBarStyle = s;
244 if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) 244 if ( tabBarStyle == TextTab || tabBarStyle == IconTab )
245 { 245 {
246 QTab *currtab; 246 QTab *currtab;
247 for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) 247 for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() )
248 { 248 {
249 currtab = tabBar->tab( tabinfo->id() ); 249 currtab = tabBar->tab( tabinfo->id() );
250 if ( tabBarStyle == IconTab ) 250 if ( tabBarStyle == IconTab )
251 { 251 {
252 currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); 252 currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) );
253 if ( tabinfo == currentTab ) 253 if ( tabinfo == currTab )
254 currtab->setText( tabinfo->label() ); 254 currtab->setText( tabinfo->label() );
255 else 255 else
256 currtab->setText( QString::null ); 256 currtab->setText( QString::null );
257 } 257 }
258 else 258 else
259 { 259 {
260 currtab->iconset = 0x0; 260 currtab->iconset = 0x0;
261 currtab->setText( tabinfo->label() ); 261 currtab->setText( tabinfo->label() );
262 } 262 }
263 } 263 }
264 tabBarStack->raiseWidget( tabBar ); 264 tabBarStack->raiseWidget( tabBar );
265 } 265 }
@@ -326,44 +326,44 @@ void OTabWidget::slotTabListSelected( int index )
326QPixmap OTabWidget::loadSmooth( const QString &name ) 326QPixmap OTabWidget::loadSmooth( const QString &name )
327{ 327{
328 QImage image = Resource::loadImage( name ); 328 QImage image = Resource::loadImage( name );
329 QPixmap pixmap; 329 QPixmap pixmap;
330 pixmap.convertFromImage( image.smoothScale( 14, 14 ) ); 330 pixmap.convertFromImage( image.smoothScale( 14, 14 ) );
331 return pixmap; 331 return pixmap;
332} 332}
333 333
334void OTabWidget::selectTab( OTabInfo *tab ) 334void OTabWidget::selectTab( OTabInfo *tab )
335{ 335{
336 if ( tabBarStyle == IconTab ) 336 if ( tabBarStyle == IconTab )
337 { 337 {
338 if ( currentTab ) 338 if ( currTab )
339 { 339 {
340 tabBar->tab( currentTab->id() )->setText( QString::null ); 340 tabBar->tab( currTab->id() )->setText( QString::null );
341 setUpLayout(); 341 setUpLayout();
342 } 342 }
343 tabBar->tab( tab->id() )->setText( tab->label() ); 343 tabBar->tab( tab->id() )->setText( tab->label() );
344 tabBar->setCurrentTab( tab->id() ); 344 tabBar->setCurrentTab( tab->id() );
345 setUpLayout(); 345 setUpLayout();
346 tabBar->update(); 346 tabBar->update();
347 } 347 }
348 else 348 else
349 { 349 {
350 tabBar->setCurrentTab( tab->id() ); 350 tabBar->setCurrentTab( tab->id() );
351 } 351 }
352 352
353 widgetStack->raiseWidget( tab->control() ); 353 widgetStack->raiseWidget( tab->control() );
354 354
355 emit currentChanged( tab->control() ); 355 emit currentChanged( tab->control() );
356 356
357 currentTab = tab; 357 currTab = tab;
358} 358}
359 359
360void OTabWidget::setUpLayout() 360void OTabWidget::setUpLayout()
361{ 361{
362 tabBar->layoutTabs(); 362 tabBar->layoutTabs();
363 QSize t( tabBarStack->sizeHint() ); 363 QSize t( tabBarStack->sizeHint() );
364 if ( tabBarStyle == IconTab ) 364 if ( tabBarStyle == IconTab )
365 { 365 {
366 if ( t.width() > width() ) 366 if ( t.width() > width() )
367 t.setWidth( width() ); 367 t.setWidth( width() );
368 } 368 }
369 else 369 else
@@ -389,21 +389,21 @@ void OTabWidget::setUpLayout()
389QSize OTabWidget::sizeHint() const 389QSize OTabWidget::sizeHint() const
390{ 390{
391 QSize s( widgetStack->sizeHint() ); 391 QSize s( widgetStack->sizeHint() );
392 QSize t( tabBarStack->sizeHint() ); 392 QSize t( tabBarStack->sizeHint() );
393 return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); 393 return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() );
394} 394}
395 395
396void OTabWidget::resizeEvent( QResizeEvent * ) 396void OTabWidget::resizeEvent( QResizeEvent * )
397{ 397{
398 setUpLayout(); 398 setUpLayout();
399} 399}
400 400
401int OTabWidget::getCurrentTab() 401int OTabWidget::currentTab()
402{ 402{
403 if ( currentTab ) 403 if ( currTab )
404 { 404 {
405 return currentTab->id(); 405 return currTab->id();
406 } 406 }
407 return -1; 407 return -1;
408} 408}
409 409