summaryrefslogtreecommitdiff
path: root/libopie2/opieui
Unidiff
Diffstat (limited to 'libopie2/opieui') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/otabbar.cpp50
-rw-r--r--libopie2/opieui/otabbar.h46
-rw-r--r--libopie2/opieui/otabwidget.cpp1
3 files changed, 50 insertions, 47 deletions
diff --git a/libopie2/opieui/otabbar.cpp b/libopie2/opieui/otabbar.cpp
index a62e18b..dc5df42 100644
--- a/libopie2/opieui/otabbar.cpp
+++ b/libopie2/opieui/otabbar.cpp
@@ -1,83 +1,87 @@
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 Dan Williams <williamsdr@acm.org> 4 Copyright (c) 2002 Dan Williams <williamsdr@acm.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 31
32#include <opie2/otabbar.h> 32#include <opie2/otabbar.h>
33 33
34#include <qpe/applnk.h>
35
36#include <stdio.h>
37
34using namespace Opie::Ui; 38using namespace Opie::Ui;
35 39
36OTabBar::OTabBar( QWidget *parent , const char *name ) 40OTabBar::OTabBar( QWidget *parent , const char *name )
37 :QTabBar( parent, name ) 41 :QTabBar( parent, name )
38{} 42{}
39 43
40void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const 44void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const
41{ 45{
42 46
43 QRect r = br; 47 QRect r = br;
44 if ( t->iconset) 48 if ( t->iconset)
45 { 49 {
46 QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 50 QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
47 if ( mode == QIconSet::Normal && has_focus ) 51 if ( mode == QIconSet::Normal && has_focus )
48 { 52 {
49 mode = QIconSet::Active; 53 mode = QIconSet::Active;
50 } 54 }
51 QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode ); 55 QPixmap pixmap = t->iconset->pixmap();
52 int pixw = pixmap.width(); 56 int pixw = pixmap.width();
53 int pixh = pixmap.height(); 57 int pixh = pixmap.height();
54 r.setLeft( r.left() + pixw + 2 ); 58 r.setLeft( r.left() + pixw + 2 );
55 p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap ); 59 p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap );
56 } 60 }
57 61
58 QRect tr = r; 62 QRect tr = r;
59 if ( t->id == currentTab() ) 63 if ( t->id == currentTab() )
60 { 64 {
61 tr.setBottom( tr.bottom() - style().defaultFrameWidth() ); 65 tr.setBottom( tr.bottom() - style().defaultFrameWidth() );
62 } 66 }
63 67
64 if ( t->enabled && isEnabled() ) 68 if ( t->enabled && isEnabled() )
65 { 69 {
66 p->setPen( colorGroup().foreground() ); 70 p->setPen( colorGroup().foreground() );
67 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 71 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
68 } 72 }
69 else if ( style() == MotifStyle ) 73 else if ( style() == MotifStyle )
70 { 74 {
71 p->setPen( palette().disabled().foreground() ); 75 p->setPen( palette().disabled().foreground() );
72 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 76 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
73 } 77 }
74 else 78 else
75 { 79 {
76 p->setPen( colorGroup().light() ); 80 p->setPen( colorGroup().light() );
77 QRect wr = tr; 81 QRect wr = tr;
78 wr.moveBy( 1, 1 ); 82 wr.moveBy( 1, 1 );
79 p->drawText( wr, AlignCenter | ShowPrefix, t->label ); 83 p->drawText( wr, AlignCenter | ShowPrefix, t->label );
80 p->setPen( palette().disabled().foreground() ); 84 p->setPen( palette().disabled().foreground() );
81 p->drawText( tr, AlignCenter | ShowPrefix, t->label ); 85 p->drawText( tr, AlignCenter | ShowPrefix, t->label );
82 } 86 }
83} 87}
diff --git a/libopie2/opieui/otabbar.h b/libopie2/opieui/otabbar.h
index 925ae96..1044bdd 100644
--- a/libopie2/opieui/otabbar.h
+++ b/libopie2/opieui/otabbar.h
@@ -1,86 +1,86 @@
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 Dan Williams <williamsdr@acm.org> 4 Copyright (c) 2002 Dan Williams <williamsdr@acm.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 31
32#ifndef OTABBAR_H 32#ifndef OTABBAR_H
33#define OTABBAR_H 33#define OTABBAR_H
34 34
35/* QT */ 35/* QT */
36#include <qtabbar.h> 36#include <qtabbar.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Ui { 39namespace Ui {
40 40
41/** 41/**
42 * @class OTabBar 42 * @class OTabBar
43 * @brief The OTabBar class is a derivative of QTabBar. 43 * @brief The OTabBar class is a derivative of QTabBar.
44 * 44 *
45 * OTabBar is a derivation of TrollTech's QTabBar which provides 45 * OTabBar is a derivation of TrollTech's QTabBar which provides
46 * a row of tabs for selection. The only difference between this 46 * a row of tabs for selection. The only difference between this
47 * class and QTabBar is that there is no dotted line box around 47 * class and QTabBar is that there is no dotted line box around
48 * the label of the tab with the current focus. 48 * the label of the tab with the current focus.
49 */ 49 */
50class OTabBar : public QTabBar 50class OTabBar : public QTabBar
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 53
54public: 54public:
55 /** 55 /**
56 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 ) 56 * @fn OTabBar( QWidget *parent = 0, const char *name = 0 )
57 * @brief Object constructor. 57 * @brief Object constructor.
58 * 58 *
59 * @param parent Pointer to parent of this control. 59 * @param parent Pointer to parent of this control.
60 * @param name Name of control. 60 * @param name Name of control.
61 * 61 *
62 * Constructs a new OTabBar control with parent and name. 62 * Constructs a new OTabBar control with parent and name.
63 */ 63 */
64 OTabBar( QWidget * = 0, const char * = 0 ); 64 OTabBar( QWidget * = 0, const char * = 0 );
65 65
66protected: 66protected:
67 /** 67 /**
68 * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const 68 * @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const
69 * @brief Internal function to draw a tab's label. 69 * @brief Internal function to draw a tab's label.
70 * 70 *
71 * @param p Pointer to QPainter used for drawing. 71 * @param p Pointer to QPainter used for drawing.
72 * @param br QRect providing region to draw label in. 72 * @param br QRect providing region to draw label in.
73 * @param t Tab to draw label for. 73 * @param t Tab to draw label for.
74 * @param has_focus Boolean value not used, retained for compatibility reasons. 74 * @param has_focus Boolean value not used, retained for compatibility reasons.
75 */ 75 */
76 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const; 76 void paintLabel( QPainter *, const QRect &, QTab *, bool ) const;
77 77
78private: 78private:
79 class Private; 79 class Private;
80 Private *d; 80 Private *d;
81}; 81};
82 82
83} 83}
84} 84}
85 85
86#endif 86#endif
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index 7333f5e..d617a9c 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -1,229 +1,228 @@
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/applnk.h>
38#include <qpe/config.h> 37#include <qpe/config.h>
39 38
40/* QT */ 39/* QT */
41#include <qcombobox.h> 40#include <qcombobox.h>
42#include <qwidgetstack.h> 41#include <qwidgetstack.h>
43 42
44using namespace Opie::Ui; 43using namespace Opie::Ui;
45 44
46OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) 45OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
47 : QWidget( parent, name ) 46 : QWidget( parent, name )
48 , m_currTab( 0l ) 47 , m_currTab( 0l )
49 , m_tabBarStyle( Global ) 48 , m_tabBarStyle( Global )
50 , m_tabBarPosition( Top ) 49 , m_tabBarPosition( Top )
51 , m_usingTabs( true ) 50 , m_usingTabs( true )
52 , m_tabBar( 0l ) 51 , m_tabBar( 0l )
53 , m_tabList( 0l ) 52 , m_tabList( 0l )
54{ 53{
55 if ( s == Global ) 54 if ( s == Global )
56 { 55 {
57 // Read Opie global settings for style and position 56 // Read Opie global settings for style and position
58 Config config( "qpe" ); 57 Config config( "qpe" );
59 config.setGroup( "Appearance" ); 58 config.setGroup( "Appearance" );
60 59
61 // Style 60 // Style
62 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); 61 s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
63 if ( s <= Global || s > IconList) 62 if ( s <= Global || s > IconList)
64 s = IconTab; 63 s = IconTab;
65 64
66 // Position 65 // Position
67 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom 66 ( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom
68 : p = Top; 67 : p = Top;
69 } 68 }
70 69
71 // Initialize widget stack for tab widgets 70 // Initialize widget stack for tab widgets
72 m_widgetStack = new QWidgetStack( this ); 71 m_widgetStack = new QWidgetStack( this );
73 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 72 m_widgetStack->setFrameStyle( QFrame::NoFrame );
74 m_widgetStack->setLineWidth( style().defaultFrameWidth() ); 73 m_widgetStack->setLineWidth( style().defaultFrameWidth() );
75 74
76 // Set initial selector control style and position 75 // Set initial selector control style and position
77 setTabStyle( s ); 76 setTabStyle( s );
78 setTabPosition( p ); 77 setTabPosition( p );
79} 78}
80 79
81OTabWidget::~OTabWidget() 80OTabWidget::~OTabWidget()
82{ 81{
83 m_tabs.setAutoDelete( true ); 82 m_tabs.setAutoDelete( true );
84 m_tabs.clear(); 83 m_tabs.clear();
85} 84}
86 85
87void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) 86void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
88{ 87{
89 int tabid = -1; 88 int tabid = -1;
90 89
91 if ( m_usingTabs ) 90 if ( m_usingTabs )
92 { 91 {
93 // Create new tab in tab bar 92 // Create new tab in tab bar
94 QTab *tab = new QTab(); 93 QTab *tab = new QTab();
95 94
96 // Set label (and icon if necessary) 95 // Set label (and icon if necessary)
97 if ( m_tabBarStyle == IconTab ) 96 if ( m_tabBarStyle == IconTab )
98 { 97 {
99 tab->label = QString::null; 98 tab->label = QString::null;
100 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 ) );
101 } 100 }
102 else 101 else
103 tab->label = label; 102 tab->label = label;
104 103
105 tabid = m_tabBar->addTab( tab ); 104 tabid = m_tabBar->addTab( tab );
106 } 105 }
107 else 106 else
108 { 107 {
109 // Insert entry (with icon if necessary) into drop down list 108 // Insert entry (with icon if necessary) into drop down list
110 if ( m_tabBarStyle == IconList ) 109 if ( m_tabBarStyle == IconList )
111 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 );
112 else 111 else
113 m_tabList->insertItem( label ); 112 m_tabList->insertItem( label );
114 } 113 }
115 114
116 // Add widget to stack 115 // Add widget to stack
117 m_widgetStack->addWidget( child, tabid ); 116 m_widgetStack->addWidget( child, tabid );
118 m_widgetStack->raiseWidget( child ); 117 m_widgetStack->raiseWidget( child );
119 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); 118 m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
120 119
121 // Keep track of tab information 120 // Keep track of tab information
122 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); 121 OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
123 m_tabs.append( tabinfo ); 122 m_tabs.append( tabinfo );
124 123
125 // Make newly added tab the current one displayed 124 // Make newly added tab the current one displayed
126 selectTab( tabinfo ); 125 selectTab( tabinfo );
127} 126}
128 127
129void OTabWidget::removePage( QWidget *childwidget ) 128void OTabWidget::removePage( QWidget *childwidget )
130{ 129{
131 if ( childwidget ) 130 if ( childwidget )
132 { 131 {
133 // Find tab information for desired widget 132 // Find tab information for desired widget
134 OTabInfo *tab = m_tabs.first(); 133 OTabInfo *tab = m_tabs.first();
135 while ( tab && tab->control() != childwidget ) 134 while ( tab && tab->control() != childwidget )
136 tab = m_tabs.next(); 135 tab = m_tabs.next();
137 136
138 if ( tab && tab->control() == childwidget ) 137 if ( tab && tab->control() == childwidget )
139 { 138 {
140 if ( m_usingTabs ) 139 if ( m_usingTabs )
141 { 140 {
142 // Remove tab from tab bar 141 // Remove tab from tab bar
143 m_tabBar->setTabEnabled( tab->id(), false ); 142 m_tabBar->setTabEnabled( tab->id(), false );
144 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) ); 143 m_tabBar->removeTab( m_tabBar->tab( tab->id() ) );
145 } 144 }
146 else 145 else
147 { 146 {
148 // Remove entry from drop down list 147 // Remove entry from drop down list
149 int i = 0; 148 int i = 0;
150 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() ) 149 while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() )
151 i++; 150 i++;
152 if ( m_tabList->text( i ) == tab->label() ) 151 if ( m_tabList->text( i ) == tab->label() )
153 m_tabList->removeItem( i ); 152 m_tabList->removeItem( i );
154 } 153 }
155 154
156 // Remove widget from stack 155 // Remove widget from stack
157 m_widgetStack->removeWidget( childwidget ); 156 m_widgetStack->removeWidget( childwidget );
158 157
159 // Get rid of tab information 158 // Get rid of tab information
160 m_tabs.remove( tab ); 159 m_tabs.remove( tab );
161 delete tab; 160 delete tab;
162 161
163 // Reset current tab 162 // Reset current tab
164 m_currTab = m_tabs.current(); 163 m_currTab = m_tabs.current();
165 if ( !m_currTab ) 164 if ( !m_currTab )
166 m_widgetStack->setFrameStyle( QFrame::NoFrame ); 165 m_widgetStack->setFrameStyle( QFrame::NoFrame );
167 166
168 // Redraw widget 167 // Redraw widget
169 setUpLayout(); 168 setUpLayout();
170 } 169 }
171 } 170 }
172} 171}
173 172
174void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) 173void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
175{ 174{
176 // Find tab information for desired widget 175 // Find tab information for desired widget
177 OTabInfo *currtab = m_tabs.first(); 176 OTabInfo *currtab = m_tabs.first();
178 while ( currtab && currtab->control() != widget ) 177 while ( currtab && currtab->control() != widget )
179 currtab = m_tabs.next(); 178 currtab = m_tabs.next();
180 179
181 if ( currtab && currtab->control() == widget ) 180 if ( currtab && currtab->control() == widget )
182 { 181 {
183 QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) ); 182 QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) );
184 183
185 if ( m_usingTabs ) 184 if ( m_usingTabs )
186 { 185 {
187 // Update tab label and icon (if necessary) 186 // Update tab label and icon (if necessary)
188 QTab *tab = m_tabBar->tab( currtab->id() ); 187 QTab *tab = m_tabBar->tab( currtab->id() );
189 tab->setText( label ); 188 tab->setText( label );
190 if ( m_tabBarStyle == IconTab ) 189 if ( m_tabBarStyle == IconTab )
191 tab->setIconSet( icon ); 190 tab->setIconSet( icon );
192 } 191 }
193 else 192 else
194 { 193 {
195 // Update entry label and icon (if necessary) 194 // Update entry label and icon (if necessary)
196 int i = 0; 195 int i = 0;
197 while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() ) 196 while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() )
198 i++; 197 i++;
199 if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() ) 198 if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() )
200 { 199 {
201 if ( m_tabBarStyle == IconList ) 200 if ( m_tabBarStyle == IconList )
202 m_tabList->changeItem( icon, label, i ); 201 m_tabList->changeItem( icon, label, i );
203 else 202 else
204 m_tabList->changeItem( label, i ); 203 m_tabList->changeItem( label, i );
205 } 204 }
206 } 205 }
207 206
208 // Update tab information 207 // Update tab information
209 currtab->setLabel( label ); 208 currtab->setLabel( label );
210 currtab->setIcon( iconset ); 209 currtab->setIcon( iconset );
211 210
212 // Redraw widget 211 // Redraw widget
213 setUpLayout(); 212 setUpLayout();
214 } 213 }
215} 214}
216 215
217void OTabWidget::setCurrentTab( QWidget *childwidget ) 216void OTabWidget::setCurrentTab( QWidget *childwidget )
218{ 217{
219 OTabInfo *currtab = m_tabs.first(); 218 OTabInfo *currtab = m_tabs.first();
220 while ( currtab && currtab->control() != childwidget ) 219 while ( currtab && currtab->control() != childwidget )
221 { 220 {
222 currtab = m_tabs.next(); 221 currtab = m_tabs.next();
223 } 222 }
224 if ( currtab && currtab->control() == childwidget ) 223 if ( currtab && currtab->control() == childwidget )
225 { 224 {
226 selectTab( currtab ); 225 selectTab( currtab );
227 } 226 }
228} 227}
229 228