summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp
index 00194b4..ac46cca 100644
--- a/libopie2/opieui/big-screen/owidgetstack.cpp
+++ b/libopie2/opieui/big-screen/owidgetstack.cpp
@@ -1,440 +1,445 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003,2004,2005 Holger Hans Peter Freyther <zecke@handhelds.org> 3             .=l. Copyright (c) 2003,2004,2005 Holger Hans Peter Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "owidgetstack.h" 29#include "owidgetstack.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34/* QT */ 34/* QT */
35#include <qapplication.h> 35#include <qapplication.h>
36#include <qwidgetstack.h> 36#include <qwidgetstack.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Ui { 39namespace Ui {
40 const int mode_size = 330; 40 const int mode_size = 330;
41 41
42 42
43 43
44/** 44/**
45 * This is the standard widget. For simple usage see the example. Normally this widget 45 * This is the standard widget. For simple usage see the example. Normally this widget
46 * is the central widget of a QMainWindow. 46 * is the central widget of a QMainWindow.
47 * Use removeWidget before you delete a widget yourself. OWidgetStack does not 47 * Use removeWidget before you delete a widget yourself. OWidgetStack does not
48 * yet recognize removal of children. 48 * yet recognize removal of children.
49 * 49 *
50 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion. 50 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion.
51 * Or you use QPEApplication::showMainWidget(). 51 * Or you use QPEApplication::showMainWidget().
52 * @param name Name will be passed on to QObject 52 * @param name Name will be passed on to QObject
53 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags 53 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags
54 */ 54 */
55OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl) 55OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl)
56 : QFrame( parent, name, fl ) 56 : QFrame( parent, name, fl )
57{ 57{
58 m_last = m_mWidget = 0; 58 m_last = m_mWidget = 0;
59 m_forced = false; 59 m_forced = false;
60 60
61 QApplication::desktop()->installEventFilter( this ); 61 QApplication::desktop()->installEventFilter( this );
62 setFontPropagation ( AllChildren ); 62 setFontPropagation ( AllChildren );
63 setPalettePropagation( AllChildren ); 63 setPalettePropagation( AllChildren );
64 64
65 /* sets m_mode and initializes more */ 65 /* sets m_mode and initializes more */
66 /* if you change this call change switchTop as well */ 66 /* if you change this call change switchTop as well */
67 m_stack = 0; 67 m_stack = 0;
68 switchStack(); 68 switchStack();
69} 69}
70 70
71/** 71/**
72 * The destructor. It deletes also all added widgets. 72 * The destructor. It deletes also all added widgets.
73 * 73 *
74 */ 74 */
75OWidgetStack::~OWidgetStack() { 75OWidgetStack::~OWidgetStack() {
76 if (m_mode == BigScreen && !m_list.isEmpty() ) { 76 if (m_mode == BigScreen && !m_list.isEmpty() ) {
77 QMap<int, QWidget*>::Iterator it = m_list.begin(); 77 QMap<int, QWidget*>::Iterator it = m_list.begin();
78 for ( ; it != m_list.end(); ++it ) 78 for ( ; it != m_list.end(); ++it )
79 delete it.data(); 79 delete it.data();
80 } 80 }
81 m_list.clear(); 81 m_list.clear();
82 82
83} 83}
84 84
85/** 85/**
86 * return the mode of the desktop. There are currently two modes. SmallScreen 86 * return the mode of the desktop. There are currently two modes. SmallScreen
87 * with a normal PDA resolution and BigScreen with resolutions greater than 87 * with a normal PDA resolution and BigScreen with resolutions greater than
88 * 330 for width and height. 88 * 330 for width and height.
89 * You can also force the mode this widget is in with forceMode() 89 * You can also force the mode this widget is in with forceMode()
90 * Note that NoForce will be never returned from here 90 * Note that NoForce will be never returned from here
91 */ 91 */
92enum OWidgetStack::Mode OWidgetStack::mode()const { 92enum OWidgetStack::Mode OWidgetStack::mode()const {
93 return m_mode; 93 return m_mode;
94} 94}
95 95
96/** 96/**
97 * You can also force one of the modes and then 97 * You can also force one of the modes and then
98 * this widget stops on listening to size changes. You 98 * this widget stops on listening to size changes. You
99 * can revert to the scanning behaviour by setting mode 99 * can revert to the scanning behaviour by setting mode
100 * to NoForce 100 * to NoForce
101 */ 101 */
102void OWidgetStack::forceMode( enum Mode mode) { 102void OWidgetStack::forceMode( enum Mode mode) {
103 m_forced = mode != NoForce; 103 m_forced = mode != NoForce;
104 104
105 /* we need to see which mode we're in */ 105 /* we need to see which mode we're in */
106 if (!m_forced ) { 106 if (!m_forced ) {
107 if ( QApplication::desktop()->width() >= 107 if ( QApplication::desktop()->width() >=
108 mode_size ) 108 mode_size )
109 mode = BigScreen; 109 mode = BigScreen;
110 else 110 else
111 mode = SmallScreen; 111 mode = SmallScreen;
112 } 112 }
113 switch( mode ) { 113 switch( mode ) {
114 case NoForce: 114 case NoForce:
115 case SmallScreen: 115 case SmallScreen:
116 switchStack(); 116 switchStack();
117 break; 117 break;
118 case BigScreen: 118 case BigScreen:
119 switchTop(); 119 switchTop();
120 break; 120 break;
121 121
122 } 122 }
123 123
124 m_mode = mode; 124 m_mode = mode;
125} 125}
126 126
127/** 127/**
128 * Adds a widget to the stack. The first widget added is considered 128 * Adds a widget to the stack. The first widget added is considered
129 * to be the mainwindow. This is important because if Opie is in 129 * to be the mainwindow. This is important because if Opie is in
130 * BigScreen mode the sizeHint of the MainWindow will be returned. 130 * BigScreen mode the sizeHint of the MainWindow will be returned.
131 * In Small Screen the sizeHint of the QWidgetStack is returned. 131 * In Small Screen the sizeHint of the QWidgetStack is returned.
132 * See QWidgetStack::sizeHint. 132 * See QWidgetStack::sizeHint.
133 * This widget takes ownership of the widget and may even reparent. 133 * This widget takes ownership of the widget and may even reparent.
134 * All windows will be hidden 134 * All windows will be hidden
135 * 135 *
136 * @param wid The QWidget to be added 136 * @param wid The QWidget to be added
137 * @param id An ID for the Widget. If the ID is duplicated the 137 * @param id An ID for the Widget. If the ID is duplicated the
138 last set widget will be related to the id 138 last set widget will be related to the id
139 * 139 *
140 */ 140 */
141void OWidgetStack::addWidget( QWidget* wid, int id) { 141void OWidgetStack::addWidget( QWidget* wid, int id) {
142 if (!wid) 142 if (!wid)
143 return; 143 return;
144 144
145 /* set our main widget */ 145 /* set our main widget */
146 if (!m_mWidget) 146 if (!m_mWidget)
147 m_mWidget = wid; 147 m_mWidget = wid;
148 148
149 m_list.insert( id, wid ); 149 m_list.insert( id, wid );
150 150
151 /** 151 /**
152 * adding does not raise any widget 152 * adding does not raise any widget
153 * But for our mainwidget we prepare 153 * But for our mainwidget we prepare
154 * the right position with the right parent 154 * the right position with the right parent
155 */ 155 */
156 if (m_mode == SmallScreen ) 156 if (m_mode == SmallScreen )
157 m_stack->addWidget( wid,id ); 157 m_stack->addWidget( wid,id );
158 else if ( m_mWidget == wid ) { 158 else if ( m_mWidget == wid ) {
159 wid->reparent(this, 0, contentsRect().topLeft() ); 159 wid->reparent(this, 0, contentsRect().topLeft() );
160 wid->hide(); 160 wid->hide();
161 }else { 161 }else {
162 wid->reparent(0, WType_TopLevel, QPoint(10, 10) ); 162 wid->reparent(0, WType_TopLevel, QPoint(10, 10) );
163 wid->hide(); 163 wid->hide();
164 } 164 }
165} 165}
166 166
167 167
168/** 168/**
169 * Remove the widget from the stack it'll be reparented to 0 169 * Remove the widget from the stack it'll be reparented to 0
170 * and ownership is dropped. You need to delete it. 170 * and ownership is dropped. You need to delete it.
171 * If the removed widget was the mainwindow consider 171 * If the removed widget was the mainwindow consider
172 * to call setMainWindow. 172 * to call setMainWindow.
173 * 173 *
174 * @param wid The QWidget to be removed 174 * @param wid The QWidget to be removed
175 */ 175 */
176void OWidgetStack::removeWidget( QWidget* wid) { 176void OWidgetStack::removeWidget( QWidget* wid) {
177 if (!wid) 177 if (!wid)
178 return; 178 return;
179 179
180 if (m_mode == SmallScreen ) 180 if (m_mode == SmallScreen )
181 m_stack->removeWidget( wid ); 181 m_stack->removeWidget( wid );
182 182
183 183
184 wid->reparent(0, 0, QPoint(0, 0) ); 184 wid->reparent(0, 0, QPoint(0, 0) );
185 m_list.remove( id(wid) ); 185 m_list.remove( id(wid) );
186 186
187 if ( wid == m_mWidget ) 187 if ( wid == m_mWidget )
188 m_mWidget = 0; 188 m_mWidget = 0;
189} 189}
190 190
191#if 0 191#if 0
192/** 192/**
193 * @internal_resons 193 * @internal_resons
194 */ 194 */
195QSizeHint OWidgetStack::sizeHint()const { 195QSizeHint OWidgetStack::sizeHint()const {
196 196
197} 197}
198 198
199/** 199/**
200 * @internal_reasons 200 * @internal_reasons
201 */ 201 */
202QSizeHint OWidgetStack::minimumSizeHint()const { 202QSizeHint OWidgetStack::minimumSizeHint()const {
203 203
204} 204}
205#endif 205#endif
206 206
207/** 207/**
208 * This function tries to find the widget with the id. 208 * This function tries to find the widget with the id.
209 * You supplied a possible id in addWIdget. Note that not 209 * You supplied a possible id in addWIdget. Note that not
210 * QWidget::winId() is used. 210 * QWidget::winId() is used.
211 * 211 *
212 * @param id The id to search for 212 * @param id The id to search for
213 * 213 *
214 * @return The widget or null 214 * @return The widget or null
215 * @see addWidget 215 * @see addWidget
216 */ 216 */
217QWidget* OWidgetStack::widget( int id) const { 217QWidget* OWidgetStack::widget( int id) const {
218 return m_list[id]; 218 return m_list[id];
219} 219}
220 220
221/** 221/**
222 * Tries to find the assigned id for the widget 222 * Tries to find the assigned id for the widget
223 * or returns -1 if no widget could be found 223 * or returns -1 if no widget could be found
224 * @param wid The widget to look for 224 * @param wid The widget to look for
225 */ 225 */
226int OWidgetStack::id( QWidget* wid)const{ 226int OWidgetStack::id( QWidget* wid)const{
227 if (m_list.isEmpty() ) 227 if (m_list.isEmpty() )
228 return -1; 228 return -1;
229 229
230 QMap<int, QWidget*>::ConstIterator it = m_list.begin(); 230 QMap<int, QWidget*>::ConstIterator it = m_list.begin();
231 for ( ; it != m_list.end(); ++it ) 231 for ( ; it != m_list.end(); ++it )
232 if ( it.data() == wid ) 232 if ( it.data() == wid )
233 break; 233 break;
234 234
235 /* if not at the end return the key */ 235 /* if not at the end return the key */
236 return it == m_list.end() ? -1 : it.key(); 236 return it == m_list.end() ? -1 : it.key();
237} 237}
238 238
239 239
240/** 240/**
241 * This function returns the currently visible 241 * This function returns the currently visible
242 * widget. In BigScreen mode the mainwindow 242 * widget. In BigScreen mode the mainwindow
243 * is returned 243 * is returned
244 */ 244 */
245QWidget* OWidgetStack::visibleWidget()const { 245QWidget* OWidgetStack::visibleWidget()const {
246 if (m_mode == SmallScreen ) 246 if (m_mode == SmallScreen )
247 return m_stack->visibleWidget(); 247 return m_stack->visibleWidget();
248 else 248 else
249 return m_mWidget; 249 return m_mWidget;
250 250
251} 251}
252 252
253/** 253/**
254 * This method raises the widget wit the specefic id. 254 * This method raises the widget wit the specefic id.
255 * Note that in BigScreen mode the widget is made visible 255 * Note that in BigScreen mode the widget is made visible
256 * but the other ( previous) visible widget(s) will not 256 * but the other ( previous) visible widget(s) will not
257 * be made invisible. If you need this use hideWidget(). 257 * be made invisible. If you need this use hideWidget().
258 * 258 *
259 * @param id Raise the widget with id 259 * @param id Raise the widget with id
260 */ 260 */
261void OWidgetStack::raiseWidget( int id) { 261void OWidgetStack::raiseWidget( int id) {
262 return raiseWidget( widget( id ) ); 262 return raiseWidget( widget( id ) );
263} 263}
264 264
265/** 265/**
266 * This is an overloaded function and only differs in its parameters. 266 * This is an overloaded function and only differs in its parameters.
267 * @see raiseWidget( int ) 267 * @see raiseWidget( int )
268 */ 268 */
269void OWidgetStack::raiseWidget( QWidget* wid) { 269void OWidgetStack::raiseWidget( QWidget* wid) {
270 m_last = wid; 270 m_last = wid;
271 if (m_mode == SmallScreen ) 271 if (m_mode == SmallScreen )
272 m_stack->raiseWidget( wid ); 272 m_stack->raiseWidget( wid );
273 else { 273 else {
274 int ide; 274 int ide;
275 emit aboutToShow( wid ); 275 emit aboutToShow( wid );
276 /* if someone is connected and the widget is actually available */ 276 /* if someone is connected and the widget is actually available */
277 if ( receivers( SIGNAL(aboutToShow(int) ) ) && 277 if ( receivers( SIGNAL(aboutToShow(int) ) ) &&
278 ( (ide = id( wid ) ) != -1 ) ) 278 ( (ide = id( wid ) ) != -1 ) )
279 emit aboutToShow( ide ); 279 emit aboutToShow( ide );
280 280
281 /* ### FIXME PLACE THE WIDGET right */ 281 /* ### FIXME PLACE THE WIDGET right */
282 wid->show(); 282 wid->show();
283 } 283 }
284} 284}
285 285
286/** 286/**
287 * This will hide the currently visible widget 287 * This will hide the currently visible widget
288 * and raise the widget specified by the parameter. 288 * and raise the widget specified by the parameter.
289 * Note that this method does not use visibleWIdget but remembers 289 * Note that this method does not use visibleWIdget but remembers
290 * the last raisedWidget 290 * the last raisedWidget
291 */ 291 */
292void OWidgetStack::hideWidget( int id) { 292void OWidgetStack::hideWidget( int id) {
293 /* hiding our main widget wouldn't be smart */ 293 /* hiding our main widget wouldn't be smart */
294 if ( m_mode == BigScreen && m_last != m_mWidget ) 294 if ( m_mode == BigScreen && m_last != m_mWidget )
295 m_last->hide(); 295 m_last->hide();
296 raiseWidget( id ); 296 raiseWidget( id );
297} 297}
298 298
299/** 299/**
300 * This is overloaded and only differs in the parameters 300 * This is overloaded and only differs in the parameters
301 * it takes. 301 * it takes.
302 */ 302 */
303void OWidgetStack::hideWidget( QWidget* wid) { 303void OWidgetStack::hideWidget( QWidget* wid) {
304 /* still not smart */ 304 /* still not smart */
305 if ( m_mode == BigScreen && m_last != m_mWidget ) 305 if ( m_mode == BigScreen && m_last != m_mWidget )
306 m_last->hide(); 306 m_last->hide();
307 307
308 raiseWidget( wid ); 308 raiseWidget( wid );
309} 309}
310 310
311 311
312bool OWidgetStack::eventFilter( QObject* obj, QEvent* e) { 312bool OWidgetStack::eventFilter( QObject*, QEvent* e) {
313 if ( e->type() == QEvent::Resize && !m_forced ) { 313 if ( e->type() == QEvent::Resize && !m_forced ) {
314 QResizeEvent *res = static_cast<QResizeEvent*>( e ); 314 QResizeEvent *res = static_cast<QResizeEvent*>( e );
315 QSize size = res->size(); 315 QSize size = res->size();
316 if ( size.width() >= mode_size ) 316 if ( size.width() >= mode_size )
317 switchTop(); 317 switchTop();
318 else 318 else
319 switchStack(); 319 switchStack();
320 } 320 }
321 return false; 321 return false;
322} 322}
323 323
324 324
325/** 325/**
326 * @internal_resons 326 * @internal_resons
327 */ 327 */
328void OWidgetStack::resizeEvent( QResizeEvent* ev ) { 328void OWidgetStack::resizeEvent( QResizeEvent* ev ) {
329 QFrame::resizeEvent( ev ); 329 QFrame::resizeEvent( ev );
330 if (m_mode == SmallScreen ) 330 if (m_mode == SmallScreen )
331 m_stack->setGeometry( frameRect() ); 331 m_stack->setGeometry( frameRect() );
332 else 332 else
333 if (m_mWidget ) 333 if (m_mWidget )
334 m_mWidget->setGeometry( frameRect() ); 334 m_mWidget->setGeometry( frameRect() );
335 335
336} 336}
337 337
338/** 338/**
339 * setMainWindow gives the OWidgetStack a hint which 339 * setMainWindow gives the OWidgetStack a hint which
340 * window should always stay inside the stack. 340 * window should always stay inside the stack.
341 * Normally the first added widget is considered to be 341 * Normally the first added widget is considered to be
342 * the mainwindow but you can change this with this 342 * the mainwindow but you can change this with this
343 * function. 343 * function.
344 * If in BigScreen mode the current mainwindow will be reparented 344 * If in BigScreen mode the current mainwindow will be reparented
345 * and hidden. The position will be taken by the new one. 345 * and hidden. The position will be taken by the new one.
346 * If the old MainWindow was hidden the new window will 346 * If the old MainWindow was hidden the new window will
347 * also be hidden. If the window was visible the new mainwindow 347 * also be hidden. If the window was visible the new mainwindow
348 * will be made visible too and the old one hidden. If there 348 * will be made visible too and the old one hidden. If there
349 * was no mainwindow it will be hidden as well. 349 * was no mainwindow it will be hidden as well.
350 * 350 *
351 * @param wid The new mainwindow 351 * @param wid The new mainwindow
352 */ 352 */
353void OWidgetStack::setMainWindow( QWidget* wid ) { 353void OWidgetStack::setMainWindow( QWidget* wid ) {
354 if (m_mode == BigScreen ) { 354 if (m_mode == BigScreen ) {
355 bool wasVisible = false; 355 bool wasVisible = false;
356 if (m_mWidget ) { 356 if (m_mWidget ) {
357 wasVisible = !m_mWidget->isHidden(); 357 wasVisible = !m_mWidget->isHidden();
358 /* hidden by default */ 358 /* hidden by default */
359 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) ); 359 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) );
360 } 360 }
361 wid->reparent(this, 0, frameRect().topLeft() ); 361 wid->reparent(this, 0, frameRect().topLeft() );
362 362
363 if (wasVisible) 363 if (wasVisible)
364 wid->show(); 364 wid->show();
365 } 365 }
366 366
367 m_mWidget = wid; 367 m_mWidget = wid;
368} 368}
369 369
370/** 370/**
371 * this is an overloaded member and only differs 371 * this is an overloaded member and only differs
372 * in the type of arguments. 372 * in the type of arguments.
373 * @see setMainWindow(QWidget*) 373 * @see setMainWindow(QWidget*)
374 */ 374 */
375void OWidgetStack::setMainWindow( int id) { 375void OWidgetStack::setMainWindow( int id) {
376 setMainWindow( widget( id ) ); 376 setMainWindow( widget( id ) );
377} 377}
378 378
379 379
380/* 380/*
381 * this function switches to a stack ;) 381 * this function switches to a stack ;)
382 */ 382 */
383void OWidgetStack::switchStack() { 383void OWidgetStack::switchStack() {
384 if (m_stack ) { 384 if (m_stack ) {
385 m_stack->setGeometry( frameRect() ); 385 m_stack->setGeometry( frameRect() );
386 return; 386 return;
387 } 387 }
388 388
389 m_mode = SmallScreen; 389 m_mode = SmallScreen;
390 m_stack = new QWidgetStack(this); 390 m_stack = new QWidgetStack(this);
391 m_stack->setGeometry( frameRect() );
392 m_stack->show();
391 393
392 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), 394 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
393 this, SIGNAL(aboutToShow(QWidget*) ) ); 395 this, SIGNAL(aboutToShow(QWidget*) ) );
394 connect(m_stack, SIGNAL(aboutToShow(int) ), 396 connect(m_stack, SIGNAL(aboutToShow(int) ),
395 this, SIGNAL(aboutToShow(int) ) ); 397 this, SIGNAL(aboutToShow(int) ) );
396 398
397 /* now reparent the widgets... luckily QWidgetSatck does most of the work */ 399 /* now reparent the widgets... luckily QWidgetSatck does most of the work */
398 if (m_list.isEmpty() ) 400 if (m_list.isEmpty() )
399 return; 401 return;
400 402
401 QMap<int, QWidget*>::Iterator it = m_list.begin(); 403 QMap<int, QWidget*>::Iterator it = m_list.begin();
402 for ( ; it != m_list.end(); ++it ) 404 for ( ; it != m_list.end(); ++it )
403 m_stack->addWidget( it.data(), it.key() ); 405 m_stack->addWidget( it.data(), it.key() );
404 406
407 if ( m_mWidget )
408 m_stack->raiseWidget( m_mWidget );
409
405 410
406} 411}
407 412
408/* 413/*
409 * we will switch to top level mode 414 * we will switch to top level mode
410 * reparent the list of widgets and then delete the stack 415 * reparent the list of widgets and then delete the stack
411 */ 416 */
412void OWidgetStack::switchTop() { 417void OWidgetStack::switchTop() {
413 m_mode = BigScreen; 418 m_mode = BigScreen;
414 /* this works because it is guaranteed that switchStack was called at least once*/ 419 /* this works because it is guaranteed that switchStack was called at least once*/
415 if (!m_stack && m_mWidget) { 420 if (!m_stack && m_mWidget) {
416 m_mWidget->setGeometry( frameRect() ); 421 m_mWidget->setGeometry( frameRect() );
417 return; 422 return;
418 }else if (!m_stack) 423 }else if (!m_stack)
419 return; 424 return;
420 425
421 if (!m_list.isEmpty() ) { 426 if (!m_list.isEmpty() ) {
422 QMap<int, QWidget*>::Iterator it = m_list.begin(); 427 QMap<int, QWidget*>::Iterator it = m_list.begin();
423 for ( ; it != m_list.end(); ++it ) { 428 for ( ; it != m_list.end(); ++it ) {
424 /* better than reparenting twice */ 429 /* better than reparenting twice */
425 if ( it.data() == m_mWidget ) { 430 if ( it.data() == m_mWidget ) {
426 m_mWidget->reparent(this, 0, frameRect().topLeft() ); 431 m_mWidget->reparent(this, 0, frameRect().topLeft() );
427 m_mWidget->setGeometry( frameRect() ); 432 m_mWidget->setGeometry( frameRect() );
428 m_mWidget->show(); 433 m_mWidget->show();
429 }else 434 }else
430 /* ### FIXME we need to place the widget better */ 435 /* ### FIXME we need to place the widget better */
431 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) ); 436 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) );
432 } 437 }
433 } 438 }
434 439
435 delete m_stack; 440 delete m_stack;
436 m_stack = 0; 441 m_stack = 0;
437} 442}
438 443
439} 444}
440} 445}