-rw-r--r-- | libopie/otabwidget.cpp | 9 | ||||
-rw-r--r-- | libopie/otabwidget.h | 11 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libopie/otabwidget.cpp b/libopie/otabwidget.cpp index fe2c60f..1b8c085 100644 --- a/libopie/otabwidget.cpp +++ b/libopie/otabwidget.cpp | |||
@@ -363,48 +363,57 @@ void OTabWidget::setUpLayout() | |||
363 | tabBar->layoutTabs(); | 363 | tabBar->layoutTabs(); |
364 | QSize t( tabBarStack->sizeHint() ); | 364 | QSize t( tabBarStack->sizeHint() ); |
365 | if ( tabBarStyle == IconTab ) | 365 | if ( tabBarStyle == IconTab ) |
366 | { | 366 | { |
367 | if ( t.width() > width() ) | 367 | if ( t.width() > width() ) |
368 | t.setWidth( width() ); | 368 | t.setWidth( width() ); |
369 | } | 369 | } |
370 | else | 370 | else |
371 | { | 371 | { |
372 | t.setWidth( width() ); | 372 | t.setWidth( width() ); |
373 | } | 373 | } |
374 | int lw = widgetStack->lineWidth(); | 374 | int lw = widgetStack->lineWidth(); |
375 | if ( tabBarPosition == Bottom ) | 375 | if ( tabBarPosition == Bottom ) |
376 | { | 376 | { |
377 | tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); | 377 | tabBarStack->setGeometry( QMAX(0, lw-2), height() - t.height() - lw, t.width(), t.height() ); |
378 | widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); | 378 | widgetStack->setGeometry( 0, 0, width(), height()-t.height()+QMAX(0, lw-2) ); |
379 | } | 379 | } |
380 | else | 380 | else |
381 | { | 381 | { |
382 | tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); | 382 | tabBarStack->setGeometry( QMAX(0, lw-2), 0, t.width(), t.height() ); |
383 | widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); | 383 | widgetStack->setGeometry( 0, t.height()-lw, width(), height()-t.height()+QMAX( 0, lw-2 ) ); |
384 | } | 384 | } |
385 | 385 | ||
386 | if ( autoMask() ) | 386 | if ( autoMask() ) |
387 | updateMask(); | 387 | updateMask(); |
388 | } | 388 | } |
389 | 389 | ||
390 | QSize OTabWidget::sizeHint() const | 390 | QSize OTabWidget::sizeHint() const |
391 | { | 391 | { |
392 | QSize s( widgetStack->sizeHint() ); | 392 | QSize s( widgetStack->sizeHint() ); |
393 | QSize t( tabBarStack->sizeHint() ); | 393 | QSize t( tabBarStack->sizeHint() ); |
394 | return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); | 394 | return QSize( QMAX( s.width(), t.width() ), s.height() + t.height() ); |
395 | } | 395 | } |
396 | 396 | ||
397 | void OTabWidget::resizeEvent( QResizeEvent * ) | 397 | void OTabWidget::resizeEvent( QResizeEvent * ) |
398 | { | 398 | { |
399 | setUpLayout(); | 399 | setUpLayout(); |
400 | } | 400 | } |
401 | 401 | ||
402 | int OTabWidget::currentTab() | 402 | int OTabWidget::currentTab() |
403 | { | 403 | { |
404 | if ( currTab ) | 404 | if ( currTab ) |
405 | { | 405 | { |
406 | return currTab->id(); | 406 | return currTab->id(); |
407 | } | 407 | } |
408 | return -1; | 408 | return -1; |
409 | } | 409 | } |
410 | 410 | ||
411 | QWidget* OTabWidget::currentWidget()const | ||
412 | { | ||
413 | if ( currTab ) | ||
414 | { | ||
415 | return currTab->control(); | ||
416 | } | ||
417 | |||
418 | return 0; | ||
419 | } | ||
diff --git a/libopie/otabwidget.h b/libopie/otabwidget.h index c140c0b..acb9223 100644 --- a/libopie/otabwidget.h +++ b/libopie/otabwidget.h | |||
@@ -79,172 +79,179 @@ public: | |||
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 | // FIXME WFlags? -zecke | 102 | // FIXME WFlags? -zecke |
103 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); | 103 | OTabWidget( QWidget * = 0, const char * = 0, TabStyle = Global, TabPosition = Top ); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * @fn ~OTabWidget() | 106 | * @fn ~OTabWidget() |
107 | * @brief Object destructor. | 107 | * @brief Object destructor. |
108 | */ | 108 | */ |
109 | ~OTabWidget(); | 109 | ~OTabWidget(); |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) | 112 | * @fn addTab( QWidget *child, const QString &icon, const QString &label ) |
113 | * @brief Add new widget to control. | 113 | * @brief Add new widget to control. |
114 | * | 114 | * |
115 | * @param child Widget control. | 115 | * @param child Widget control. |
116 | * @param icon Path to icon. | 116 | * @param icon Path to icon. |
117 | * @param label Text label. | 117 | * @param label Text label. |
118 | */ | 118 | */ |
119 | void addTab( QWidget *, const QString &, const QString & ); | 119 | void addTab( QWidget *, const QString &, const QString & ); |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * @fn removePage( QWidget *widget ) | 122 | * @fn removePage( QWidget *widget ) |
123 | * @brief Remove widget from control. Does not delete widget. | 123 | * @brief Remove widget from control. Does not delete widget. |
124 | * | 124 | * |
125 | * @param widget Widget control to be removed. | 125 | * @param widget Widget control to be removed. |
126 | */ | 126 | */ |
127 | /* ### Page vs. Tab.. yes the widget is a Page but then is addTab wrong -zecke */ | ||
127 | void removePage( QWidget * ); | 128 | void removePage( QWidget * ); |
128 | 129 | ||
129 | /** | 130 | /** |
130 | * @fn changeTab( QWidget *widget, const QString &icon, const QString &label ) | 131 | * @fn changeTab( QWidget *widget, const QString &icon, const QString &label ) |
131 | * @brief Change text and/or icon for existing tab | 132 | * @brief Change text and/or icon for existing tab |
132 | * | 133 | * |
133 | * @param child Widget control. | 134 | * @param child Widget control. |
134 | * @param icon Path to icon. | 135 | * @param icon Path to icon. |
135 | * @param label Text label. | 136 | * @param label Text label. |
136 | */ | 137 | */ |
137 | void changeTab( QWidget *, const QString &, const QString & ); | 138 | void changeTab( QWidget *, const QString &, const QString & ); |
138 | 139 | ||
139 | /** | 140 | /** |
140 | * @fn tabStyle()const | 141 | * @fn tabStyle()const |
141 | * @brief Returns current widget selection control style. | 142 | * @brief Returns current widget selection control style. |
142 | */ | 143 | */ |
143 | TabStyle tabStyle() const; | 144 | TabStyle tabStyle() const; |
144 | 145 | ||
145 | /** | 146 | /** |
146 | * @fn setTabStyle( TabStyle s ) | 147 | * @fn setTabStyle( TabStyle s ) |
147 | * @brief Set the current widget selection control style. | 148 | * @brief Set the current widget selection control style. |
148 | * | 149 | * |
149 | * @param s New style to be used. | 150 | * @param s New style to be used. |
150 | */ | 151 | */ |
151 | void setTabStyle( TabStyle ); | 152 | void setTabStyle( TabStyle ); |
152 | 153 | ||
153 | /** | 154 | /** |
154 | * @fn tabPosition()const | 155 | * @fn tabPosition()const |
155 | * @brief Returns current widget selection control position. | 156 | * @brief Returns current widget selection control position. |
156 | */ | 157 | */ |
157 | TabPosition tabPosition() const; | 158 | TabPosition tabPosition() const; |
158 | 159 | ||
159 | /** | 160 | /** |
160 | * @fn setTabPosition( TabPosition p ) | 161 | * @fn setTabPosition( TabPosition p ) |
161 | * @brief Set the current widget selection control position. | 162 | * @brief Set the current widget selection control position. |
162 | * | 163 | * |
163 | * @param p New position of widget selection control. | 164 | * @param p New position of widget selection control. |
164 | */ | 165 | */ |
165 | void setTabPosition( TabPosition ); | 166 | void setTabPosition( TabPosition ); |
166 | 167 | ||
167 | /** | 168 | /** |
168 | * @fn setCurrentTab( QWidget *childwidget ) | 169 | * @fn setCurrentTab( QWidget *childwidget ) |
169 | * @brief Selects and brings to top the desired widget by using widget pointer. | 170 | * @brief Selects and brings to top the desired widget by using widget pointer. |
170 | * | 171 | * |
171 | * @param childwidget Widget to select. | 172 | * @param childwidget Widget to select. |
172 | */ | 173 | */ |
173 | void setCurrentTab( QWidget * ); | 174 | void setCurrentTab( QWidget * ); |
174 | 175 | ||
175 | /** | 176 | /** |
176 | * @fn setCurrentTab( const QString &tabname ) | 177 | * @fn setCurrentTab( const QString &tabname ) |
177 | * @brief Selects and brings to top the desired widget, by using label. | 178 | * @brief Selects and brings to top the desired widget, by using label. |
178 | * | 179 | * |
179 | * @param tabname Text label for widget to select. | 180 | * @param tabname Text label for widget to select. |
180 | */ | 181 | */ |
181 | void setCurrentTab( const QString & ); | 182 | void setCurrentTab( const QString & ); |
182 | 183 | ||
183 | /** | 184 | /** |
184 | * @fn setCurrentTab( int ) | 185 | * @fn setCurrentTab( int ) |
185 | * @brief Selects and brings to top the desired widget, by using id. | 186 | * @brief Selects and brings to top the desired widget, by using id. |
186 | * | 187 | * |
187 | * @param tab id for widget to select. | 188 | * @param tab id for widget to select. |
188 | */ | 189 | */ |
189 | void setCurrentTab(int); | 190 | void setCurrentTab(int); |
190 | 191 | ||
191 | /** | 192 | /** |
192 | * @fn sizeHint()const | 193 | * @fn sizeHint()const |
193 | * @brief Reimplemented for internal purposes. | 194 | * @brief Reimplemented for internal purposes. |
194 | */ | 195 | */ |
195 | QSize sizeHint() const; | 196 | QSize sizeHint() const; |
196 | 197 | ||
197 | /** | 198 | /** |
198 | * @fn currentTab( ) | 199 | * @fn currentTab( ) |
199 | * @brief returns current tab id. | 200 | * @brief returns current tab id. |
200 | */ | 201 | */ |
201 | int currentTab(); | 202 | // ### make const |
202 | 203 | int currentTab()/* const */; | |
204 | /** | ||
205 | * @brief returns the current page of the active tab | ||
206 | * | ||
207 | * @since 1.2 | ||
208 | */ | ||
209 | QWidget* currentWidget()const; | ||
203 | 210 | ||
204 | protected: | 211 | protected: |
205 | 212 | ||
206 | /** | 213 | /** |
207 | * @fn resizeEvent( QResizeEvent * ) | 214 | * @fn resizeEvent( QResizeEvent * ) |
208 | * @brief Reimplemented for internal purposes. | 215 | * @brief Reimplemented for internal purposes. |
209 | */ | 216 | */ |
210 | void resizeEvent( QResizeEvent * ); | 217 | void resizeEvent( QResizeEvent * ); |
211 | 218 | ||
212 | private: | 219 | private: |
213 | OTabInfoList tabs; | 220 | OTabInfoList tabs; |
214 | OTabInfo *currTab; | 221 | OTabInfo *currTab; |
215 | 222 | ||
216 | TabStyle tabBarStyle; | 223 | TabStyle tabBarStyle; |
217 | TabPosition tabBarPosition; | 224 | TabPosition tabBarPosition; |
218 | 225 | ||
219 | QWidgetStack *tabBarStack; | 226 | QWidgetStack *tabBarStack; |
220 | OTabBar *tabBar; | 227 | OTabBar *tabBar; |
221 | QComboBox *tabList; | 228 | QComboBox *tabList; |
222 | 229 | ||
223 | QWidgetStack *widgetStack; | 230 | QWidgetStack *widgetStack; |
224 | class Private; | 231 | class Private; |
225 | Private* d; | 232 | Private* d; |
226 | 233 | ||
227 | /** | 234 | /** |
228 | * @fn loadSmooth( const QString &name ) | 235 | * @fn loadSmooth( const QString &name ) |
229 | * @brief Loads icon for widget. | 236 | * @brief Loads icon for widget. |
230 | * | 237 | * |
231 | * @param name Name of icon image file. | 238 | * @param name Name of icon image file. |
232 | */ | 239 | */ |
233 | QPixmap loadSmooth( const QString & ); | 240 | QPixmap loadSmooth( const QString & ); |
234 | 241 | ||
235 | /** | 242 | /** |
236 | * @fn selectTab( OTabInfo *tab ) | 243 | * @fn selectTab( OTabInfo *tab ) |
237 | * @brief Internal function to select desired widget. | 244 | * @brief Internal function to select desired widget. |
238 | * | 245 | * |
239 | * @param tab Pointer to data for widget. | 246 | * @param tab Pointer to data for widget. |
240 | */ | 247 | */ |
241 | void selectTab( OTabInfo * ); | 248 | void selectTab( OTabInfo * ); |
242 | 249 | ||
243 | /** | 250 | /** |
244 | * @fn setUpLayout() | 251 | * @fn setUpLayout() |
245 | * @brief Internal function to adjust layout. | 252 | * @brief Internal function to adjust layout. |
246 | */ | 253 | */ |
247 | void setUpLayout(); | 254 | void setUpLayout(); |
248 | 255 | ||
249 | 256 | ||
250 | signals: | 257 | signals: |