author | drw <drw> | 2003-02-16 21:54:23 (UTC) |
---|---|---|
committer | drw <drw> | 2003-02-16 21:54:23 (UTC) |
commit | 8ecc375c803dc57b160bd0335891fcaf4f6de1df (patch) (unidiff) | |
tree | a89c1ccc6e3a469bb8fa435dfedce9386333cb72 /libopie | |
parent | e0eb3f016d7f8a1e1e5548ef8aa115fef8999697 (diff) | |
download | opie-8ecc375c803dc57b160bd0335891fcaf4f6de1df.zip opie-8ecc375c803dc57b160bd0335891fcaf4f6de1df.tar.gz opie-8ecc375c803dc57b160bd0335891fcaf4f6de1df.tar.bz2 |
Added changeTab() to OTabWidget to dynamically change tab name and/or icon (stumbled upon request for this in TinyKate todo)
-rw-r--r-- | libopie/otabinfo.h | 16 | ||||
-rw-r--r-- | libopie/otabwidget.cpp | 48 | ||||
-rw-r--r-- | libopie/otabwidget.h | 10 |
3 files changed, 68 insertions, 6 deletions
diff --git a/libopie/otabinfo.h b/libopie/otabinfo.h index 8dbbcc2..6589638 100644 --- a/libopie/otabinfo.h +++ b/libopie/otabinfo.h | |||
@@ -28,89 +28,105 @@ | |||
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OTABINFO_H | 32 | #ifndef OTABINFO_H |
33 | #define OTABINFO_H | 33 | #define OTABINFO_H |
34 | 34 | ||
35 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | 37 | ||
38 | class QWidget; | 38 | class QWidget; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * @class OTabInfo | 41 | * @class OTabInfo |
42 | * @brief The OTabInfo class is used internally by OTabWidget to keep track | 42 | * @brief The OTabInfo class is used internally by OTabWidget to keep track |
43 | * of widgets added to the control. | 43 | * of widgets added to the control. |
44 | * | 44 | * |
45 | * OTabInfo provides the following information about a widget added to an | 45 | * OTabInfo provides the following information about a widget added to an |
46 | * OTabWidget control: | 46 | * OTabWidget control: |
47 | * | 47 | * |
48 | * ID - integer tab bar ID | 48 | * ID - integer tab bar ID |
49 | * Control - QWidget pointer to child widget | 49 | * Control - QWidget pointer to child widget |
50 | * Label - QString text label for OTabWidget selection control | 50 | * Label - QString text label for OTabWidget selection control |
51 | * Icon - QString name of icon file | 51 | * Icon - QString name of icon file |
52 | */ | 52 | */ |
53 | class OTabInfo | 53 | class OTabInfo |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | /** | 56 | /** |
57 | * @fn OTabInfo() | 57 | * @fn OTabInfo() |
58 | * @brief Object constructor. | 58 | * @brief Object constructor. |
59 | * | 59 | * |
60 | * @param parent Pointer to parent of this control. | 60 | * @param parent Pointer to parent of this control. |
61 | * @param name Name of control. | 61 | * @param name Name of control. |
62 | * @param s Style of widget selection control. | 62 | * @param s Style of widget selection control. |
63 | * @param p Position of the widget selection control. | 63 | * @param p Position of the widget selection control. |
64 | */ | 64 | */ |
65 | OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {} | 65 | OTabInfo() : i( -1 ), c( 0 ), p( 0 ), l( QString::null ) {} |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) | 68 | * @fn OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) |
69 | * @brief Object constructor. | 69 | * @brief Object constructor. |
70 | * | 70 | * |
71 | * @param id TabBar identifier for widget. | 71 | * @param id TabBar identifier for widget. |
72 | * @param control QWidget pointer to widget. | 72 | * @param control QWidget pointer to widget. |
73 | * @param icon QString name of icon file. | 73 | * @param icon QString name of icon file. |
74 | * @param label QString text label for OTabWidget selection control. | 74 | * @param label QString text label for OTabWidget selection control. |
75 | */ | 75 | */ |
76 | OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) | 76 | OTabInfo( int id, QWidget *control, const QString &icon, const QString &label ) |
77 | : i( id ), c( control ), p( icon ), l( label ) {} | 77 | : i( id ), c( control ), p( icon ), l( label ) {} |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * @fn id() | 80 | * @fn id() |
81 | * @brief Returns TabBar ID. | 81 | * @brief Returns TabBar ID. |
82 | */ | 82 | */ |
83 | int id() const { return i; } | 83 | int id() const { return i; } |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * @fn label() | 86 | * @fn label() |
87 | * @brief Returns text label for widget. | 87 | * @brief Returns text label for widget. |
88 | */ | 88 | */ |
89 | const QString &label() const { return l; } | 89 | const QString &label() const { return l; } |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * @fn setLabel( const QString &label ) | ||
93 | * @brief Set label for tab. | ||
94 | * | ||
95 | * @param label QString text label for OTabWidget selection control. | ||
96 | */ | ||
97 | void setLabel( const QString &label ) { l = label; } | ||
98 | |||
99 | /** | ||
92 | * @fn control() | 100 | * @fn control() |
93 | * @brief Returns pointer to widget. | 101 | * @brief Returns pointer to widget. |
94 | */ | 102 | */ |
95 | QWidget *control() const { return c; } | 103 | QWidget *control() const { return c; } |
96 | 104 | ||
97 | /** | 105 | /** |
98 | * @fn icon() | 106 | * @fn icon() |
99 | * @brief Returns name of icon file. | 107 | * @brief Returns name of icon file. |
100 | */ | 108 | */ |
101 | const QString &icon() const { return p; } | 109 | const QString &icon() const { return p; } |
102 | 110 | ||
111 | /** | ||
112 | * @fn setIcon( const QString &icon ) | ||
113 | * @brief Set icon for tab. | ||
114 | * | ||
115 | * @param icon QString name of icon file. | ||
116 | */ | ||
117 | void setIcon( const QString &icon ) { p = icon; } | ||
118 | |||
103 | private: | 119 | private: |
104 | int i; | 120 | int i; |
105 | QWidget *c; | 121 | QWidget *c; |
106 | QString p; | 122 | QString p; |
107 | QString l; | 123 | QString l; |
108 | }; | 124 | }; |
109 | 125 | ||
110 | /** | 126 | /** |
111 | * @class OTabInfoList | 127 | * @class OTabInfoList |
112 | * @brief A list of OTabInfo objects used by OTabWidget. | 128 | * @brief A list of OTabInfo objects used by OTabWidget. |
113 | */ | 129 | */ |
114 | typedef QList<OTabInfo> OTabInfoList; | 130 | typedef QList<OTabInfo> OTabInfoList; |
115 | 131 | ||
116 | #endif | 132 | #endif |
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp index bee3f35..99bf067 100644 --- a/libopie/otabwidget.cpp +++ b/libopie/otabwidget.cpp | |||
@@ -37,198 +37,234 @@ | |||
37 | 37 | ||
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qwidgetstack.h> | 39 | #include <qwidgetstack.h> |
40 | 40 | ||
41 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) | 41 | OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p ) |
42 | : QWidget( parent, name ) | 42 | : QWidget( parent, name ) |
43 | { | 43 | { |
44 | if ( s == Global ) | 44 | if ( s == Global ) |
45 | { | 45 | { |
46 | Config config( "qpe" ); | 46 | Config config( "qpe" ); |
47 | config.setGroup( "Appearance" ); | 47 | config.setGroup( "Appearance" ); |
48 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); | 48 | s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab ); |
49 | if ( s <= Global || s > IconList) | 49 | if ( s <= Global || s > IconList) |
50 | { | 50 | { |
51 | s = IconTab; | 51 | s = IconTab; |
52 | } | 52 | } |
53 | QString pos = config.readEntry( "TabPosition", "Top"); | 53 | QString pos = config.readEntry( "TabPosition", "Top"); |
54 | if ( pos == "Bottom" ) | 54 | if ( pos == "Bottom" ) |
55 | { | 55 | { |
56 | p = Bottom; | 56 | p = Bottom; |
57 | } | 57 | } |
58 | else | 58 | else |
59 | { | 59 | { |
60 | p = Top; | 60 | p = Top; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
64 | widgetStack = new QWidgetStack( this, "widgetstack" ); | 64 | widgetStack = new QWidgetStack( this, "widgetstack" ); |
65 | widgetStack->setFrameStyle( QFrame::NoFrame ); | 65 | widgetStack->setFrameStyle( QFrame::NoFrame ); |
66 | widgetStack->setLineWidth( style().defaultFrameWidth() ); | 66 | widgetStack->setLineWidth( style().defaultFrameWidth() ); |
67 | 67 | ||
68 | tabBarStack = new QWidgetStack( this, "tabbarstack" ); | 68 | tabBarStack = new QWidgetStack( this, "tabbarstack" ); |
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 | currentTab= 0x0; |
82 | } | 82 | } |
83 | 83 | ||
84 | OTabWidget::~OTabWidget() | 84 | OTabWidget::~OTabWidget() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label ) | 88 | void 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 ) |
94 | { | 94 | { |
95 | tab->label = QString::null; | 95 | tab->label = QString::null; |
96 | } | 96 | } |
97 | else | 97 | else |
98 | { | 98 | { |
99 | tab->label = label; | 99 | tab->label = label; |
100 | } | 100 | } |
101 | if ( tabBarStyle == IconTab || tabBarStyle == IconList) | 101 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
102 | { | 102 | { |
103 | tab->iconset = new QIconSet( iconset ); | 103 | tab->iconset = new QIconSet( iconset ); |
104 | } | 104 | } |
105 | int tabid = tabBar->addTab( tab ); | 105 | int tabid = tabBar->addTab( tab ); |
106 | 106 | ||
107 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | 107 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) |
108 | { | 108 | { |
109 | tabList->insertItem( iconset, label, -1 ); | 109 | tabList->insertItem( iconset, label, -1 ); |
110 | } | 110 | } |
111 | else | 111 | else |
112 | { | 112 | { |
113 | tabList->insertItem( label ); | 113 | tabList->insertItem( label ); |
114 | } | 114 | } |
115 | 115 | ||
116 | widgetStack->addWidget( child, tabid ); | 116 | widgetStack->addWidget( child, tabid ); |
117 | widgetStack->raiseWidget( child ); | 117 | widgetStack->raiseWidget( child ); |
118 | widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); | 118 | widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); |
119 | 119 | ||
120 | OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); | 120 | OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label ); |
121 | tabs.append( tabinfo ); | 121 | tabs.append( tabinfo ); |
122 | selectTab( tabinfo ); | 122 | selectTab( tabinfo ); |
123 | } | 123 | } |
124 | 124 | ||
125 | void OTabWidget::removePage( QWidget *childwidget ) | 125 | void OTabWidget::removePage( QWidget *childwidget ) |
126 | { | 126 | { |
127 | if ( childwidget ) | 127 | if ( childwidget ) |
128 | { | 128 | { |
129 | OTabInfo *tab = tabs.first(); | 129 | OTabInfo *tab = tabs.first(); |
130 | while ( tab && tab->control() != childwidget ) | 130 | while ( tab && tab->control() != childwidget ) |
131 | { | 131 | { |
132 | tab = tabs.next(); | 132 | tab = tabs.next(); |
133 | } | 133 | } |
134 | if ( tab && tab->control() == childwidget ) | 134 | if ( tab && tab->control() == childwidget ) |
135 | { | 135 | { |
136 | tabBar->setTabEnabled( tab->id(), FALSE ); | 136 | tabBar->setTabEnabled( tab->id(), FALSE ); |
137 | tabBar->removeTab( tabBar->tab( tab->id() ) ); | 137 | tabBar->removeTab( tabBar->tab( tab->id() ) ); |
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 | currentTab = tabs.current(); |
151 | if ( !currentTab ) | 151 | if ( !currentTab ) |
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 | ||
161 | void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label) | ||
162 | { | ||
163 | OTabInfo *currtab = tabs.first(); | ||
164 | while ( currtab && currtab->control() != widget ) | ||
165 | { | ||
166 | currtab = tabs.next(); | ||
167 | } | ||
168 | if ( currtab && currtab->control() == widget ) | ||
169 | { | ||
170 | QTab *tab = tabBar->tab( currtab->id() ); | ||
171 | QPixmap icon( loadSmooth( iconset ) ); | ||
172 | tab->setText( label ); | ||
173 | if ( tabBarStyle == IconTab ) | ||
174 | tab->setIconSet( icon ); | ||
175 | int i = 0; | ||
176 | while ( i < tabList->count() && tabList->text( i ) != currtab->label() ) | ||
177 | { | ||
178 | i++; | ||
179 | } | ||
180 | if ( i < tabList->count() && tabList->text( i ) == currtab->label() ) | ||
181 | { | ||
182 | if ( tabBarStyle == IconTab || tabBarStyle == IconList ) | ||
183 | { | ||
184 | tabList->changeItem( icon, label, i ); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | tabList->changeItem( label, i ); | ||
189 | } | ||
190 | } | ||
191 | currtab->setLabel( label ); | ||
192 | currtab->setIcon( iconset ); | ||
193 | } | ||
194 | setUpLayout(); | ||
195 | } | ||
196 | |||
161 | void OTabWidget::setCurrentTab( QWidget *childwidget ) | 197 | void OTabWidget::setCurrentTab( QWidget *childwidget ) |
162 | { | 198 | { |
163 | OTabInfo *newtab = tabs.first(); | 199 | OTabInfo *currtab = tabs.first(); |
164 | while ( newtab && newtab->control() != childwidget ) | 200 | while ( currtab && currtab->control() != childwidget ) |
165 | { | 201 | { |
166 | newtab = tabs.next(); | 202 | currtab = tabs.next(); |
167 | } | 203 | } |
168 | if ( newtab && newtab->control() == childwidget ) | 204 | if ( currtab && currtab->control() == childwidget ) |
169 | { | 205 | { |
170 | selectTab( newtab ); | 206 | selectTab( currtab ); |
171 | } | 207 | } |
172 | } | 208 | } |
173 | 209 | ||
174 | void OTabWidget::setCurrentTab( const QString &tabname ) | 210 | void OTabWidget::setCurrentTab( const QString &tabname ) |
175 | { | 211 | { |
176 | OTabInfo *newtab = tabs.first(); | 212 | OTabInfo *newtab = tabs.first(); |
177 | while ( newtab && newtab->label() != tabname ) | 213 | while ( newtab && newtab->label() != tabname ) |
178 | { | 214 | { |
179 | newtab = tabs.next(); | 215 | newtab = tabs.next(); |
180 | } | 216 | } |
181 | if ( newtab && newtab->label() == tabname ) | 217 | if ( newtab && newtab->label() == tabname ) |
182 | { | 218 | { |
183 | selectTab( newtab ); | 219 | selectTab( newtab ); |
184 | } | 220 | } |
185 | } | 221 | } |
186 | 222 | ||
187 | void OTabWidget::setCurrentTab(int tabindex) { | 223 | void OTabWidget::setCurrentTab(int tabindex) { |
188 | OTabInfo *newtab = tabs.first(); | 224 | OTabInfo *newtab = tabs.first(); |
189 | while ( newtab && newtab->id() != tabindex ) | 225 | while ( newtab && newtab->id() != tabindex ) |
190 | { | 226 | { |
191 | newtab = tabs.next(); | 227 | newtab = tabs.next(); |
192 | } | 228 | } |
193 | if ( newtab && newtab->id() == tabindex ) | 229 | if ( newtab && newtab->id() == tabindex ) |
194 | { | 230 | { |
195 | selectTab( newtab ); | 231 | selectTab( newtab ); |
196 | } | 232 | } |
197 | } | 233 | } |
198 | 234 | ||
199 | 235 | ||
200 | OTabWidget::TabStyle OTabWidget::tabStyle() const | 236 | OTabWidget::TabStyle OTabWidget::tabStyle() const |
201 | { | 237 | { |
202 | return tabBarStyle; | 238 | return tabBarStyle; |
203 | } | 239 | } |
204 | 240 | ||
205 | void OTabWidget::setTabStyle( TabStyle s ) | 241 | void OTabWidget::setTabStyle( TabStyle s ) |
206 | { | 242 | { |
207 | tabBarStyle = s; | 243 | tabBarStyle = s; |
208 | if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) | 244 | if ( tabBarStyle == TextTab || tabBarStyle == IconTab ) |
209 | { | 245 | { |
210 | QTab *currtab; | 246 | QTab *currtab; |
211 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) | 247 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) |
212 | { | 248 | { |
213 | currtab = tabBar->tab( tabinfo->id() ); | 249 | currtab = tabBar->tab( tabinfo->id() ); |
214 | if ( tabBarStyle == IconTab ) | 250 | if ( tabBarStyle == IconTab ) |
215 | { | 251 | { |
216 | currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); | 252 | currtab->iconset = new QIconSet( loadSmooth( tabinfo->icon() ) ); |
217 | if ( tabinfo == currentTab ) | 253 | if ( tabinfo == currentTab ) |
218 | currtab->setText( tabinfo->label() ); | 254 | currtab->setText( tabinfo->label() ); |
219 | else | 255 | else |
220 | currtab->setText( QString::null ); | 256 | currtab->setText( QString::null ); |
221 | } | 257 | } |
222 | else | 258 | else |
223 | { | 259 | { |
224 | currtab->iconset = 0x0; | 260 | currtab->iconset = 0x0; |
225 | currtab->setText( tabinfo->label() ); | 261 | currtab->setText( tabinfo->label() ); |
226 | } | 262 | } |
227 | } | 263 | } |
228 | tabBarStack->raiseWidget( tabBar ); | 264 | tabBarStack->raiseWidget( tabBar ); |
229 | } | 265 | } |
230 | else if ( tabBarStyle == TextList || tabBarStyle == IconList ) | 266 | else if ( tabBarStyle == TextList || tabBarStyle == IconList ) |
231 | { | 267 | { |
232 | tabList->clear(); | 268 | tabList->clear(); |
233 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) | 269 | for ( OTabInfo *tabinfo = tabs.first(); tabinfo; tabinfo = tabs.next() ) |
234 | { | 270 | { |
diff --git a/libopie/otabwidget.h b/libopie/otabwidget.h index 74d683b..0aa9bb8 100644 --- a/libopie/otabwidget.h +++ b/libopie/otabwidget.h | |||
@@ -65,128 +65,138 @@ public: | |||
65 | 65 | ||
66 | /** | 66 | /** |
67 | * @enum TabStyle | 67 | * @enum TabStyle |
68 | * @brief Defines how the widget selection control is displayed. | 68 | * @brief Defines how the widget selection control is displayed. |
69 | * | 69 | * |
70 | * Valid values: | 70 | * Valid values: |
71 | * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) | 71 | * - Global: use globally selected options (qpe.conf - TabStyle & TabPosition) |
72 | * - TextTab: Tabbed widget selection with text labels | 72 | * - TextTab: Tabbed widget selection with text labels |
73 | * - IconTab: Tabbed widget selection with icon labels, text label for active widget | 73 | * - IconTab: Tabbed widget selection with icon labels, text label for active widget |
74 | * (similar to Opie launcher) | 74 | * (similar to Opie launcher) |
75 | * - TextList: Drop down list widget selection with text labels | 75 | * - TextList: Drop down list widget selection with text labels |
76 | * - IconList: Drop down list widget selection with icon & text labels | 76 | * - IconList: Drop down list widget selection with icon & text labels |
77 | */ | 77 | */ |
78 | enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; | 78 | enum TabStyle { Global, TextTab, IconTab, TextList, IconList }; |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * @enum TabPosition | 81 | * @enum TabPosition |
82 | * @brief Defines where the widget selection control is drawn. | 82 | * @brief Defines where the widget selection control is drawn. |
83 | * | 83 | * |
84 | * Valid values: | 84 | * Valid values: |
85 | * - Top: Widget selection control is drawn above widgets | 85 | * - Top: Widget selection control is drawn above widgets |
86 | * - Bottom: Widget selection control is drawn below widgets | 86 | * - Bottom: Widget selection control is drawn below widgets |
87 | */ | 87 | */ |
88 | enum TabPosition { Top, Bottom }; | 88 | enum TabPosition { Top, Bottom }; |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) | 91 | * @fn OTabWidget( QWidget *parent = 0, const char *name = 0, TabStyle s = Global, TabPosition p = Top ) |
92 | * @brief Object constructor. | 92 | * @brief Object constructor. |
93 | * | 93 | * |
94 | * @param parent Pointer to parent of this control. | 94 | * @param parent Pointer to parent of this control. |
95 | * @param name Name of control. | 95 | * @param name Name of control. |
96 | * @param s Style of widget selection control. | 96 | * @param s Style of widget selection control. |
97 | * @param p Position of the widget selection control. | 97 | * @param p Position of the widget selection control. |
98 | * | 98 | * |
99 | * Constructs a new OTabWidget control with parent and name. The style and position parameters | 99 | * Constructs a new OTabWidget control with parent and name. The style and position parameters |
100 | * determine how the widget selection control will be displayed. | 100 | * determine how the widget selection control will be displayed. |
101 | */ | 101 | */ |
102 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); | 102 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * @fn ~OTabWidget() | 105 | * @fn ~OTabWidget() |
106 | * @brief Object destructor. | 106 | * @brief Object destructor. |
107 | */ | 107 | */ |
108 | ~OTabWidget(); | 108 | ~OTabWidget(); |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) | 111 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) |
112 | * @brief Add new widget to control. | 112 | * @brief Add new widget to control. |
113 | * | 113 | * |
114 | * @param child Widget control. | 114 | * @param child Widget control. |
115 | * @param icon Path to icon. | 115 | * @param icon Path to icon. |
116 | * @param label Text label. | 116 | * @param label Text label. |
117 | */ | 117 | */ |
118 | void addTab( QWidget *, const QString &, const QString & ); | 118 | void addTab( QWidget *, const QString &, const QString & ); |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * @fn removePage( QWidget *widget ) | 121 | * @fn removePage( QWidget *widget ) |
122 | * @brief Remove widget from control. Does not delete widget. | 122 | * @brief Remove widget from control. Does not delete widget. |
123 | * | 123 | * |
124 | * @param widget Widget control to be removed. | 124 | * @param widget Widget control to be removed. |
125 | */ | 125 | */ |
126 | void removePage( QWidget * ); | 126 | void removePage( QWidget * ); |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * @fn changeTab( QWidget *widget, const QIconSet &icon, const QString &label ) | ||
130 | * @brief Change text and/or icon for existing tab | ||
131 | * | ||
132 | * @param child Widget control. | ||
133 | * @param icon Path to icon. | ||
134 | * @param label Text label. | ||
135 | */ | ||
136 | void changeTab( QWidget *, const QString &, const QString & ); | ||
137 | |||
138 | /** | ||
129 | * @fn tabStyle() | 139 | * @fn tabStyle() |
130 | * @brief Returns current widget selection control style. | 140 | * @brief Returns current widget selection control style. |
131 | */ | 141 | */ |
132 | TabStyle tabStyle() const; | 142 | TabStyle tabStyle() const; |
133 | 143 | ||
134 | /** | 144 | /** |
135 | * @fn setTabStyle( TabStyle s ) | 145 | * @fn setTabStyle( TabStyle s ) |
136 | * @brief Set the current widget selection control style. | 146 | * @brief Set the current widget selection control style. |
137 | * | 147 | * |
138 | * @param s New style to be used. | 148 | * @param s New style to be used. |
139 | */ | 149 | */ |
140 | void setTabStyle( TabStyle ); | 150 | void setTabStyle( TabStyle ); |
141 | 151 | ||
142 | /** | 152 | /** |
143 | * @fn tabPosition() | 153 | * @fn tabPosition() |
144 | * @brief Returns current widget selection control position. | 154 | * @brief Returns current widget selection control position. |
145 | */ | 155 | */ |
146 | TabPosition tabPosition() const; | 156 | TabPosition tabPosition() const; |
147 | 157 | ||
148 | /** | 158 | /** |
149 | * @fn setTabPosition( TabPosition p ) | 159 | * @fn setTabPosition( TabPosition p ) |
150 | * @brief Set the current widget selection control position. | 160 | * @brief Set the current widget selection control position. |
151 | * | 161 | * |
152 | * @param p New position of widget selection control. | 162 | * @param p New position of widget selection control. |
153 | */ | 163 | */ |
154 | void setTabPosition( TabPosition ); | 164 | void setTabPosition( TabPosition ); |
155 | 165 | ||
156 | /** | 166 | /** |
157 | * @fn setCurrentTab( QWidget *childwidget ) | 167 | * @fn setCurrentTab( QWidget *childwidget ) |
158 | * @brief Selects and brings to top the desired widget by using widget pointer. | 168 | * @brief Selects and brings to top the desired widget by using widget pointer. |
159 | * | 169 | * |
160 | * @param childwidget Widget to select. | 170 | * @param childwidget Widget to select. |
161 | */ | 171 | */ |
162 | void setCurrentTab( QWidget * ); | 172 | void setCurrentTab( QWidget * ); |
163 | 173 | ||
164 | /** | 174 | /** |
165 | * @fn setCurrentTab( const QString &tabname ) | 175 | * @fn setCurrentTab( const QString &tabname ) |
166 | * @brief Selects and brings to top the desired widget, by using label. | 176 | * @brief Selects and brings to top the desired widget, by using label. |
167 | * | 177 | * |
168 | * @param tabname Text label for widget to select. | 178 | * @param tabname Text label for widget to select. |
169 | */ | 179 | */ |
170 | void setCurrentTab( const QString & ); | 180 | void setCurrentTab( const QString & ); |
171 | 181 | ||
172 | /** | 182 | /** |
173 | * @fn setCurrentTab( int ) | 183 | * @fn setCurrentTab( int ) |
174 | * @brief Selects and brings to top the desired widget, by using id. | 184 | * @brief Selects and brings to top the desired widget, by using id. |
175 | * | 185 | * |
176 | * @param tab id for widget to select. | 186 | * @param tab id for widget to select. |
177 | */ | 187 | */ |
178 | void setCurrentTab(int); | 188 | void setCurrentTab(int); |
179 | 189 | ||
180 | /** | 190 | /** |
181 | * @fn sizeHint() | 191 | * @fn sizeHint() |
182 | * @brief Reimplemented for internal purposes. | 192 | * @brief Reimplemented for internal purposes. |
183 | */ | 193 | */ |
184 | QSize sizeHint() const; | 194 | QSize sizeHint() const; |
185 | 195 | ||
186 | /** | 196 | /** |
187 | * @fn getCurrentTab( ) | 197 | * @fn getCurrentTab( ) |
188 | * @brief returns current tab id. | 198 | * @brief returns current tab id. |
189 | */ | 199 | */ |
190 | int getCurrentTab(); | 200 | int getCurrentTab(); |
191 | 201 | ||
192 | 202 | ||