summaryrefslogtreecommitdiff
authorzecke <zecke>2004-11-11 22:00:18 (UTC)
committer zecke <zecke>2004-11-11 22:00:18 (UTC)
commitb81a7aeacda23d4407cd88ee017b67ea48344a94 (patch) (unidiff)
treeeda86d8db6cca3608cf12a298765f468bceed030
parentd2d25a3c1e60a34436cd93e5214a35b3edd05c6c (diff)
downloadopie-b81a7aeacda23d4407cd88ee017b67ea48344a94.zip
opie-b81a7aeacda23d4407cd88ee017b67ea48344a94.tar.gz
opie-b81a7aeacda23d4407cd88ee017b67ea48344a94.tar.bz2
Remove owarn to be less verbose
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/osplitter.cpp15
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.cpp1
2 files changed, 0 insertions, 16 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp
index f50e7f0..78e919a 100644
--- a/libopie2/opieui/big-screen/osplitter.cpp
+++ b/libopie2/opieui/big-screen/osplitter.cpp
@@ -1,640 +1,625 @@
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 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <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 "osplitter.h" 29#include "osplitter.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/otabwidget.h> 32#include <opie2/otabwidget.h>
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34 34
35/* QT */ 35/* QT */
36#include <qvaluelist.h> 36#include <qvaluelist.h>
37#include <qvbox.h> 37#include <qvbox.h>
38 38
39using namespace Opie::Ui; 39using namespace Opie::Ui;
40using namespace Opie::Ui::Internal; 40using namespace Opie::Ui::Internal;
41 41
42/** 42/**
43 * 43 *
44 * This is the constructor of OSplitter 44 * This is the constructor of OSplitter
45 * You might want to call setSizeChange to tell 45 * You might want to call setSizeChange to tell
46 * OSplitter to change its layout when a specefic 46 * OSplitter to change its layout when a specefic
47 * mark was crossed. OSplitter sets a default value. 47 * mark was crossed. OSplitter sets a default value.
48 * 48 *
49 * You cann add widget with addWidget to the OSplitter. 49 * You cann add widget with addWidget to the OSplitter.
50 * OSplitter supports also grouping of Splitters where they 50 * OSplitter supports also grouping of Splitters where they
51 * can share one OTabBar in small screen mode. This can be used 51 * can share one OTabBar in small screen mode. This can be used
52 * for email clients like vies but see the example. 52 * for email clients like vies but see the example.
53 * 53 *
54 * @param orient The orientation wether to layout horizontal or vertical 54 * @param orient The orientation wether to layout horizontal or vertical
55 * @param parent The parent of this widget 55 * @param parent The parent of this widget
56 * @param name The name passed on to QObject 56 * @param name The name passed on to QObject
57 * @param fl Additional widgets flags passed to QWidget 57 * @param fl Additional widgets flags passed to QWidget
58 * 58 *
59 * @short single c'tor of the OSplitter 59 * @short single c'tor of the OSplitter
60 */ 60 */
61OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) 61OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl )
62 : QFrame( parent, name, fl ) 62 : QFrame( parent, name, fl )
63{ 63{
64 m_orient = orient; 64 m_orient = orient;
65 m_hbox = 0; 65 m_hbox = 0;
66 m_size_policy = 330; 66 m_size_policy = 330;
67 setFontPropagation( AllChildren ); 67 setFontPropagation( AllChildren );
68 setPalettePropagation( AllChildren ); 68 setPalettePropagation( AllChildren );
69 69
70 /* start by default with the tab widget */ 70 /* start by default with the tab widget */
71 m_tabWidget = 0; 71 m_tabWidget = 0;
72 m_parentTab = 0; 72 m_parentTab = 0;
73 changeTab(); 73 changeTab();
74 74
75} 75}
76 76
77 77
78/** 78/**
79 * Destructor destructs this object and cleans up. All child 79 * Destructor destructs this object and cleans up. All child
80 * widgets will be deleted 80 * widgets will be deleted
81 * @see addWidget 81 * @see addWidget
82 */ 82 */
83OSplitter::~OSplitter() 83OSplitter::~OSplitter()
84{ 84{
85 owarn << "Deleted Splitter" << oendl;
86 m_splitter.setAutoDelete( true ); 85 m_splitter.setAutoDelete( true );
87 m_splitter.clear(); 86 m_splitter.clear();
88 87
89 delete m_hbox; 88 delete m_hbox;
90 delete m_tabWidget; 89 delete m_tabWidget;
91} 90}
92 91
93 92
94/** 93/**
95 * Sets the label for the Splitter. This label will be used 94 * Sets the label for the Splitter. This label will be used
96 * if a parent splitter is arranged as TabWidget but 95 * if a parent splitter is arranged as TabWidget but
97 * this splitter is in fullscreen mode. Then a tab with OSplitter::label() 96 * this splitter is in fullscreen mode. Then a tab with OSplitter::label()
98 * and iconName() gets added. 97 * and iconName() gets added.
99 * 98 *
100 * @param name The name of the Label 99 * @param name The name of the Label
101 */ 100 */
102void OSplitter::setLabel( const QString& name ) 101void OSplitter::setLabel( const QString& name )
103{ 102{
104 m_name = name; 103 m_name = name;
105} 104}
106 105
107/** 106/**
108 * @see setLabel but this is for the icon retrieved by Resource 107 * @see setLabel but this is for the icon retrieved by Resource
109 * 108 *
110 * @param name The name of the icon in example ( "zoom" ) 109 * @param name The name of the icon in example ( "zoom" )
111 */ 110 */
112void OSplitter::setIconName( const QString& name ) 111void OSplitter::setIconName( const QString& name )
113{ 112{
114 m_icon = name; 113 m_icon = name;
115} 114}
116 115
117 116
118/** 117/**
119 * returns the iconName 118 * returns the iconName
120 * @see setIconName 119 * @see setIconName
121 */ 120 */
122QString OSplitter::iconName()const 121QString OSplitter::iconName()const
123{ 122{
124 return m_icon; 123 return m_icon;
125} 124}
126 125
127/** 126/**
128 * returns the label set with setLabel 127 * returns the label set with setLabel
129 * @see setLabel 128 * @see setLabel
130 */ 129 */
131QString OSplitter::label()const 130QString OSplitter::label()const
132{ 131{
133 return m_name; 132 return m_name;
134} 133}
135 134
136/** 135/**
137 * This function sets the size change policy of the splitter. 136 * This function sets the size change policy of the splitter.
138 * If this size marked is crossed the splitter will relayout. 137 * If this size marked is crossed the splitter will relayout.
139 * Note: that depending on the set Orientation it'll either look 138 * Note: that depending on the set Orientation it'll either look
140 * at the width or height. 139 * at the width or height.
141 * Note: If you want to from side to side view to tabbed view you need 140 * Note: If you want to from side to side view to tabbed view you need
142 * to make sure that the size you supply is not smaller than the minimum 141 * to make sure that the size you supply is not smaller than the minimum
143 * size of your added widgets. Note that if you use widgets like QComboBoxes 142 * size of your added widgets. Note that if you use widgets like QComboBoxes
144 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy 143 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy
145 * 144 *
146 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. 145 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter.
147 * @return void 146 * @return void
148 */ 147 */
149void OSplitter::setSizeChange( int width_height ) 148void OSplitter::setSizeChange( int width_height )
150{ 149{
151 m_size_policy = width_height; 150 m_size_policy = width_height;
152 QSize sz(width(), height() ); 151 QSize sz(width(), height() );
153 QResizeEvent ev(sz, sz ); 152 QResizeEvent ev(sz, sz );
154 resizeEvent(&ev); 153 resizeEvent(&ev);
155} 154}
156 155
157/** 156/**
158 * This functions allows to add another OSplitter and to share 157 * This functions allows to add another OSplitter and to share
159 * the OTabBar in small screen mode. The ownerships gets transfered. 158 * the OTabBar in small screen mode. The ownerships gets transfered.
160 * OSplitters are always added after normal widget items 159 * OSplitters are always added after normal widget items
161 */ 160 */
162void OSplitter::addWidget( OSplitter* split ) 161void OSplitter::addWidget( OSplitter* split )
163{ 162{
164 m_splitter.append( split ); 163 m_splitter.append( split );
165 164
166 /* 165 /*
167 * set tab widget 166 * set tab widget
168 */ 167 */
169 if (m_tabWidget ) 168 if (m_tabWidget )
170 setTabWidget( m_parentTab ); 169 setTabWidget( m_parentTab );
171 else 170 else
172 { 171 {
173 OSplitterContainer con; 172 OSplitterContainer con;
174 con.widget =split; 173 con.widget =split;
175 addToBox( con ); 174 addToBox( con );
176 } 175 }
177} 176}
178 177
179/* 178/*
180 * If in a tab it should be removed 179 * If in a tab it should be removed
181 * and if in a hbox the reparent kills it too 180 * and if in a hbox the reparent kills it too
182 */ 181 */
183/** 182/**
184 * This removes the splitter again. You currently need to call this 183 * This removes the splitter again. You currently need to call this
185 * before you delete or otherwise you can get mem corruption 184 * before you delete or otherwise you can get mem corruption
186 * or other weird behaviour. 185 * or other weird behaviour.
187 * Owner ship gets transfered back to you it's current parent 186 * Owner ship gets transfered back to you it's current parent
188 * is 0 187 * is 0
189 */ 188 */
190void OSplitter::removeWidget( OSplitter* split) 189void OSplitter::removeWidget( OSplitter* split)
191{ 190{
192 split->setTabWidget( 0 ); 191 split->setTabWidget( 0 );
193 split->reparent( 0, 0, QPoint(0, 0) ); 192 split->reparent( 0, 0, QPoint(0, 0) );
194} 193}
195 194
196/** 195/**
197 * Adds a widget to the Splitter. The widgets gets inserted 196 * Adds a widget to the Splitter. The widgets gets inserted
198 * at the end of either the Box or TabWidget. 197 * at the end of either the Box or TabWidget.
199 * Ownership gets transfered and the widgets gets reparented. 198 * Ownership gets transfered and the widgets gets reparented.
200 * Note: icon and label is only available on small screensizes 199 * Note: icon and label is only available on small screensizes
201 * if size is smaller than the mark 200 * if size is smaller than the mark
202 * Warning: No null checking of the widget is done. Only on debug 201 * Warning: No null checking of the widget is done. Only on debug
203 * a message will be outputtet 202 * a message will be outputtet
204 * 203 *
205 * @param wid The widget which will be added 204 * @param wid The widget which will be added
206 * @param icon The icon of the possible Tab 205 * @param icon The icon of the possible Tab
207 * @param label The label of the possible Tab 206 * @param label The label of the possible Tab
208 */ 207 */
209void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) 208void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label )
210{ 209{
211#ifdef DEBUG 210#ifdef DEBUG
212 if (!wid ) 211 if (!wid )
213 {
214 owarn << "Widget is not valid!" << oendl;
215 return; 212 return;
216 }
217#endif 213#endif
218 OSplitterContainer cont; 214 OSplitterContainer cont;
219 cont.widget = wid; 215 cont.widget = wid;
220 cont.icon =icon; 216 cont.icon =icon;
221 cont.name = label; 217 cont.name = label;
222 218
223 m_container.append( cont ); 219 m_container.append( cont );
224 220
225 /* 221 /*
226 * 222 *
227 */ 223 */
228 if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) 224 if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) )
229 setTabWidget( m_parentTab ); 225 setTabWidget( m_parentTab );
230 else 226 else
231 { 227 {
232 if (m_hbox ) 228 if (m_hbox )
233 addToBox( cont ); 229 addToBox( cont );
234 else 230 else
235 addToTab( cont ); 231 addToTab( cont );
236 } 232 }
237} 233}
238 234
239 235
240/** 236/**
241 * Removes the widget from the tab widgets if necessary. 237 * Removes the widget from the tab widgets if necessary.
242 * OSplitter drops ownership of this widget and the widget 238 * OSplitter drops ownership of this widget and the widget
243 * will be reparented i tto 0. 239 * will be reparented i tto 0.
244 * The widget will not be deleted. 240 * The widget will not be deleted.
245 * 241 *
246 * @param w The widget to be removed 242 * @param w The widget to be removed
247 */ 243 */
248void OSplitter::removeWidget( QWidget* w) 244void OSplitter::removeWidget( QWidget* w)
249{ 245{
250 ContainerList::Iterator it; 246 ContainerList::Iterator it;
251 for ( it = m_container.begin(); it != m_container.end(); ++it ) 247 for ( it = m_container.begin(); it != m_container.end(); ++it )
252 if ( (*it).widget == w ) 248 if ( (*it).widget == w )
253 break; 249 break;
254 250
255 if (it == m_container.end() ) 251 if (it == m_container.end() )
256 return; 252 return;
257 253
258 254
259 /* only tab needs to be removed.. box recognizes it */ 255 /* only tab needs to be removed.. box recognizes it */
260 if ( !m_hbox ) 256 if ( !m_hbox )
261 removeFromTab( w ); 257 removeFromTab( w );
262 258
263 259
264 /* Find reparent it and remove it from our list */ 260 /* Find reparent it and remove it from our list */
265 261
266 w->reparent( 0, 0, QPoint(0, 0)); 262 w->reparent( 0, 0, QPoint(0, 0));
267 it = m_container.remove( it ); 263 it = m_container.remove( it );
268 264
269} 265}
270 266
271 267
272/** 268/**
273 * This method will give focus to the widget. If in a tabwidget 269 * This method will give focus to the widget. If in a tabwidget
274 * the tabbar will be changed 270 * the tabbar will be changed
275 * 271 *
276 * @param w The widget which will be set the current one 272 * @param w The widget which will be set the current one
277 */ 273 */
278void OSplitter::setCurrentWidget( QWidget* w) 274void OSplitter::setCurrentWidget( QWidget* w)
279{ 275{
280 if (m_tabWidget ) 276 if (m_tabWidget )
281 m_tabWidget->setCurrentTab( w ); 277 m_tabWidget->setCurrentTab( w );
282 // else 278 // else
283 // m_hbox->setFocus( w ); 279 // m_hbox->setFocus( w );
284 280
285} 281}
286 282
287/** 283/**
288 * This is an overloaded member function and only differs in the 284 * This is an overloaded member function and only differs in the
289 * argument it takes. 285 * argument it takes.
290 * Searches list of widgets for label. It'll pick the first label it finds 286 * Searches list of widgets for label. It'll pick the first label it finds
291 * 287 *
292 * @param label Label to look for. First match will be taken 288 * @param label Label to look for. First match will be taken
293 */ 289 */
294void OSplitter::setCurrentWidget( const QString& label ) 290void OSplitter::setCurrentWidget( const QString& label )
295{ 291{
296 ContainerList::Iterator it; 292 ContainerList::Iterator it;
297 for (it = m_container.begin(); it != m_container.end(); ++it ) 293 for (it = m_container.begin(); it != m_container.end(); ++it )
298 { 294 {
299 if ( (*it).name == label ) 295 if ( (*it).name == label )
300 { 296 {
301 setCurrentWidget( (*it).widget ); 297 setCurrentWidget( (*it).widget );
302 break; 298 break;
303 } 299 }
304 } 300 }
305} 301}
306 302
307/** 303/**
308 * This will only work when the TabWidget is active 304 * This will only work when the TabWidget is active
309 * If everything is visible this signal is kindly ignored 305 * If everything is visible this signal is kindly ignored
310 * @see OTabWidget::setCurrentTab(int) 306 * @see OTabWidget::setCurrentTab(int)
311 * 307 *
312 * @param tab The tab to make current 308 * @param tab The tab to make current
313 */ 309 */
314void OSplitter::setCurrentWidget( int tab ) 310void OSplitter::setCurrentWidget( int tab )
315{ 311{
316 if (m_tabWidget ) 312 if (m_tabWidget )
317 m_tabWidget->setCurrentTab( tab ); 313 m_tabWidget->setCurrentTab( tab );
318} 314}
319 315
320/** 316/**
321 * return the currently activated widget if in tab widget mode 317 * return the currently activated widget if in tab widget mode
322 * or null because all widgets are visible 318 * or null because all widgets are visible
323 */ 319 */
324QWidget* OSplitter::currentWidget() const 320QWidget* OSplitter::currentWidget() const
325{ 321{
326 if (m_tabWidget) 322 if (m_tabWidget)
327 return m_tabWidget->currentWidget(); 323 return m_tabWidget->currentWidget();
328 else if (m_parentTab ) 324 else if (m_parentTab )
329 return m_parentTab->currentWidget(); 325 return m_parentTab->currentWidget();
330 326
331 return 0l; 327 return 0l;
332} 328}
333/* wrong */ 329/* wrong */
334#if 0 330#if 0
335/** 331/**
336 * @reimplented for internal reasons 332 * @reimplented for internal reasons
337 * returns the sizeHint of one of its sub widgets 333 * returns the sizeHint of one of its sub widgets
338 */ 334 */
339QSize OSplitter::sizeHint()const 335QSize OSplitter::sizeHint()const
340{ 336{
341 if (m_parentTab ) 337 if (m_parentTab )
342 return QFrame::sizeHint(); 338 return QFrame::sizeHint();
343 339
344 if (m_hbox ) 340 if (m_hbox )
345 return m_hbox->sizeHint(); 341 return m_hbox->sizeHint();
346 else 342 else
347 return m_tabWidget->sizeHint(); 343 return m_tabWidget->sizeHint();
348} 344}
349 345
350QSize OSplitter::minimumSizeHint()const 346QSize OSplitter::minimumSizeHint()const
351{ 347{
352 if (m_parentTab ) 348 if (m_parentTab )
353 return QFrame::minimumSizeHint(); 349 return QFrame::minimumSizeHint();
354 if (m_hbox) 350 if (m_hbox)
355 return m_hbox->sizeHint(); 351 return m_hbox->sizeHint();
356 else 352 else
357 return m_tabWidget->sizeHint(); 353 return m_tabWidget->sizeHint();
358} 354}
359#endif 355#endif
360 356
361/** 357/**
362 * @reimplemented for internal reasons 358 * @reimplemented for internal reasons
363 */ 359 */
364void OSplitter::resizeEvent( QResizeEvent* res ) 360void OSplitter::resizeEvent( QResizeEvent* res )
365{ 361{
366 QFrame::resizeEvent( res ); 362 QFrame::resizeEvent( res );
367 /* 363 /*
368 * 364 *
369 */ 365 */
370 // owarn << "Old size was width = " << res->oldSize().width() << " height = " << res->oldSize().height() << "" << oendl;
371 bool mode = true; 366 bool mode = true;
372 owarn << "New size is width = " << res->size().width() << " height = " << res->size().height() << " " << name() << "" << oendl;
373 if ( res->size().width() > m_size_policy && 367 if ( res->size().width() > m_size_policy &&
374 m_orient == Horizontal ) 368 m_orient == Horizontal )
375 { 369 {
376 changeHBox(); 370 changeHBox();
377 mode = false; 371 mode = false;
378 } 372 }
379 else if ( (res->size().width() <= m_size_policy && 373 else if ( (res->size().width() <= m_size_policy &&
380 m_orient == Horizontal ) || 374 m_orient == Horizontal ) ||
381 (res->size().height() <= m_size_policy && 375 (res->size().height() <= m_size_policy &&
382 m_orient == Vertical ) ) 376 m_orient == Vertical ) )
383 { 377 {
384 changeTab(); 378 changeTab();
385 } 379 }
386 else if ( res->size().height() > m_size_policy && 380 else if ( res->size().height() > m_size_policy &&
387 m_orient == Vertical ) 381 m_orient == Vertical )
388 { 382 {
389 owarn << "Changng to vbox " << name() << "" << oendl;
390 changeVBox(); 383 changeVBox();
391 mode = false; 384 mode = false;
392 } 385 }
393 386
394 emit sizeChanged(mode, m_orient ); 387 emit sizeChanged(mode, m_orient );
395} 388}
396 389
397/* 390/*
398 * Adds a container to a tab either the parent tab 391 * Adds a container to a tab either the parent tab
399 * or our own 392 * or our own
400 */ 393 */
401void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con ) 394void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con )
402{ 395{
403 QWidget *wid = con.widget; 396 QWidget *wid = con.widget;
404 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); 397 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) );
405 if (m_parentTab ) 398 if (m_parentTab )
406 m_parentTab->addTab( wid, con.icon, con.name ); 399 m_parentTab->addTab( wid, con.icon, con.name );
407 else 400 else
408 m_tabWidget->addTab( wid, con.icon, con.name ); 401 m_tabWidget->addTab( wid, con.icon, con.name );
409} 402}
410 403
411 404
412/* 405/*
413 * adds a container to the box 406 * adds a container to the box
414 */ 407 */
415void OSplitter::addToBox( const Opie::Ui::Internal::OSplitterContainer& con ) 408void OSplitter::addToBox( const Opie::Ui::Internal::OSplitterContainer& con )
416{ 409{
417 QWidget* wid = con.widget; 410 QWidget* wid = con.widget;
418 wid->reparent(m_hbox, 0, QPoint(0, 0) ); 411 wid->reparent(m_hbox, 0, QPoint(0, 0) );
419} 412}
420 413
421 414
422/* 415/*
423 * Removes a widget from the tab 416 * Removes a widget from the tab
424 */ 417 */
425void OSplitter::removeFromTab( QWidget* wid ) 418void OSplitter::removeFromTab( QWidget* wid )
426{ 419{
427 if (m_parentTab ) 420 if (m_parentTab )
428 m_parentTab->removePage( wid ); 421 m_parentTab->removePage( wid );
429 else 422 else
430 m_tabWidget->removePage( wid ); 423 m_tabWidget->removePage( wid );
431} 424}
432 425
433/* 426/*
434 * switches over to a OTabWidget layout 427 * switches over to a OTabWidget layout
435 * it is recursive 428 * it is recursive
436 */ 429 */
437void OSplitter::changeTab() 430void OSplitter::changeTab()
438{ 431{
439 /* if we're the owner of the tab widget */ 432 /* if we're the owner of the tab widget */
440 if (m_tabWidget ) 433 if (m_tabWidget )
441 { 434 {
442 raise(); 435 raise();
443 show(); 436 show();
444 m_tabWidget->setGeometry( frameRect() ); 437 m_tabWidget->setGeometry( frameRect() );
445 return; 438 return;
446 } 439 }
447 440
448 owarn << " New Tab Widget " << name() << "" << oendl;
449 /* 441 /*
450 * and add all widgets this will reparent them 442 * and add all widgets this will reparent them
451 * delete m_hbox set it to 0 443 * delete m_hbox set it to 0
452 * 444 *
453 */ 445 */
454 OTabWidget *tab; 446 OTabWidget *tab;
455 if ( m_parentTab ) 447 if ( m_parentTab )
456 { 448 {
457 hide(); 449 hide();
458 tab = m_parentTab; 450 tab = m_parentTab;
459 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ 451 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/
460 if (!m_container.isEmpty() ) 452 if (!m_container.isEmpty() )
461 { 453 {
462 ContainerList::Iterator it = m_container.begin(); 454 ContainerList::Iterator it = m_container.begin();
463 for (; it != m_container.end(); ++it ) 455 for (; it != m_container.end(); ++it )
464 m_parentTab->removePage( (*it).widget ); 456 m_parentTab->removePage( (*it).widget );
465 } 457 }
466 } 458 }
467 else 459 else
468 tab = m_tabWidget = new OTabWidget( this ); 460 tab = m_tabWidget = new OTabWidget( this );
469 461
470 connect(tab, SIGNAL(currentChanged(QWidget*) ), 462 connect(tab, SIGNAL(currentChanged(QWidget*) ),
471 this, SIGNAL(currentChanged(QWidget*) ) ); 463 this, SIGNAL(currentChanged(QWidget*) ) );
472 464
473 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) 465 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
474 { 466 {
475 owarn << "Widget is " << (*it).name << "" << oendl;
476 addToTab( (*it) ); 467 addToTab( (*it) );
477 } 468 }
478 469
479 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) 470 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
480 { 471 {
481 split->reparent(this, 0, QPoint(0, 0) ); 472 split->reparent(this, 0, QPoint(0, 0) );
482 split->setTabWidget( tab ); 473 split->setTabWidget( tab );
483 } 474 }
484 475
485 476
486 delete m_hbox; 477 delete m_hbox;
487 m_hbox = 0; 478 m_hbox = 0;
488 if (!m_tabWidget ) 479 if (!m_tabWidget )
489 return; 480 return;
490 481
491 m_tabWidget->setGeometry( frameRect() ); 482 m_tabWidget->setGeometry( frameRect() );
492 m_tabWidget->show(); 483 m_tabWidget->show();
493 484
494} 485}
495 486
496/* 487/*
497 * changes over to a box 488 * changes over to a box
498 * this is recursive as well 489 * this is recursive as well
499 */ 490 */
500void OSplitter::changeHBox() 491void OSplitter::changeHBox()
501{ 492{
502 if (m_hbox ) 493 if (m_hbox )
503 { 494 {
504 m_hbox->setGeometry( frameRect() ); 495 m_hbox->setGeometry( frameRect() );
505 return; 496 return;
506 } 497 }
507 498
508 owarn << "new HBox " << name() << "" << oendl;
509 m_hbox = new QHBox( this ); 499 m_hbox = new QHBox( this );
510 commonChangeBox(); 500 commonChangeBox();
511} 501}
512 502
513void OSplitter::changeVBox() 503void OSplitter::changeVBox()
514{ 504{
515 if (m_hbox ) 505 if (m_hbox )
516 { 506 {
517 m_hbox->setGeometry( frameRect() ); 507 m_hbox->setGeometry( frameRect() );
518 return; 508 return;
519 } 509 }
520 510
521 owarn << "New VBOX " << name() << "" << oendl;
522 m_hbox = new QVBox( this ); 511 m_hbox = new QVBox( this );
523 512
524 commonChangeBox(); 513 commonChangeBox();
525 514
526} 515}
527 516
528/* 517/*
529 * common box code 518 * common box code
530 * first remove and add children 519 * first remove and add children
531 * the other splitters 520 * the other splitters
532 * it is recursive as well due the call to setTabWidget 521 * it is recursive as well due the call to setTabWidget
533 */ 522 */
534void OSplitter::commonChangeBox() 523void OSplitter::commonChangeBox()
535{ 524{
536 owarn << " Name of Splitters is " << name() << "" << oendl;
537
538 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) 525 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
539 { 526 {
540 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ 527 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */
541 if (m_parentTab ) 528 if (m_parentTab )
542 removeFromTab( (*it).widget ); 529 removeFromTab( (*it).widget );
543 owarn << "Adding to box " << (*it).name << "" << oendl;
544 addToBox( (*it) ); 530 addToBox( (*it) );
545 } 531 }
546 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) 532 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
547 { 533 {
548 /* tell them the world had changed */ 534 /* tell them the world had changed */
549 split->setTabWidget( 0 ); 535 split->setTabWidget( 0 );
550 OSplitterContainer con; 536 OSplitterContainer con;
551 con.widget = split; 537 con.widget = split;
552 // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) 538 // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget)
553 // : static_cast<QWidget*>(split->m_hbox); 539 // : static_cast<QWidget*>(split->m_hbox);
554 addToBox( con ); 540 addToBox( con );
555 } 541 }
556 542
557 543
558 544
559 if (m_parentTab ) 545 if (m_parentTab )
560 m_parentTab->addTab(m_hbox, iconName(), label() ); 546 m_parentTab->addTab(m_hbox, iconName(), label() );
561 else 547 else
562 { 548 {
563 owarn << " setting Box geometry for " << name() << "" << oendl;
564 m_hbox->setGeometry( frameRect() ); 549 m_hbox->setGeometry( frameRect() );
565 m_hbox->show(); 550 m_hbox->show();
566 delete m_tabWidget; 551 delete m_tabWidget;
567 m_tabWidget = 0; 552 m_tabWidget = 0;
568 show(); // also show this widget 553 show(); // also show this widget
569 } 554 }
570} 555}
571 556
572/* 557/*
573 * sets the tabwidget, removes tabs, and relayouts the widget 558 * sets the tabwidget, removes tabs, and relayouts the widget
574 */ 559 */
575void OSplitter::setTabWidget( OTabWidget* wid) 560void OSplitter::setTabWidget( OTabWidget* wid)
576{ 561{
577 /* clean up cause m_parentTab will not be available for us */ 562 /* clean up cause m_parentTab will not be available for us */
578 if ( m_parentTab ) 563 if ( m_parentTab )
579 { 564 {
580 if (m_hbox ) 565 if (m_hbox )
581 m_parentTab->removePage( m_hbox ); 566 m_parentTab->removePage( m_hbox );
582 else if (!m_container.isEmpty() ) 567 else if (!m_container.isEmpty() )
583 { 568 {
584 ContainerList::Iterator it = m_container.begin(); 569 ContainerList::Iterator it = m_container.begin();
585 for ( ; it != m_container.end(); ++it ) 570 for ( ; it != m_container.end(); ++it )
586 m_parentTab->removePage( (*it).widget ); 571 m_parentTab->removePage( (*it).widget );
587 } 572 }
588 } 573 }
589 /* the parent Splitter changed so either make us indepent or dep */ 574 /* the parent Splitter changed so either make us indepent or dep */
590 575
591 m_parentTab = wid; 576 m_parentTab = wid;
592 577
593 QWidget *tab = m_tabWidget; 578 QWidget *tab = m_tabWidget;
594 QWidget *box = m_hbox; 579 QWidget *box = m_hbox;
595 m_hbox = 0; m_tabWidget = 0; 580 m_hbox = 0; m_tabWidget = 0;
596 581
597 if ( layoutMode() ) 582 if ( layoutMode() )
598 changeTab(); 583 changeTab();
599 else if (m_orient == Horizontal ) 584 else if (m_orient == Horizontal )
600 changeHBox(); 585 changeHBox();
601 else 586 else
602 changeVBox(); 587 changeVBox();
603 588
604 /* our own crap is added and children from change* */ 589 /* our own crap is added and children from change* */
605 delete tab; 590 delete tab;
606 delete box; 591 delete box;
607} 592}
608 593
609#if 0 594#if 0
610void OSplitter::reparentAll() 595void OSplitter::reparentAll()
611{ 596{
612 if (m_container.isEmpty() ) 597 if (m_container.isEmpty() )
613 return; 598 return;
614 599
615 ContainerList::Iterator it = m_container.begin(); 600 ContainerList::Iterator it = m_container.begin();
616 for ( ; it != m_container.end(); ++it ) 601 for ( ; it != m_container.end(); ++it )
617 (*it).wid->reparent(0, 0, QPoint(0, 0) ); 602 (*it).wid->reparent(0, 0, QPoint(0, 0) );
618 603
619 604
620} 605}
621#endif 606#endif
622 607
623/** 608/**
624 * @internal 609 * @internal
625 */ 610 */
626bool OSplitter::layoutMode()const 611bool OSplitter::layoutMode()const
627{ 612{
628 if ( size().width() > m_size_policy && 613 if ( size().width() > m_size_policy &&
629 m_orient == Horizontal ) 614 m_orient == Horizontal )
630 { 615 {
631 return false; 616 return false;
632 } 617 }
633 else if ( size().height() > m_size_policy && 618 else if ( size().height() > m_size_policy &&
634 m_orient == Vertical ) 619 m_orient == Vertical )
635 { 620 {
636 return false; 621 return false;
637 } 622 }
638 623
639 return true; 624 return true;
640} 625}
diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp
index 9c9f7ec..b14a643 100644
--- a/libopie2/opieui/big-screen/owidgetstack.cpp
+++ b/libopie2/opieui/big-screen/owidgetstack.cpp
@@ -121,321 +121,320 @@ void OWidgetStack::forceMode( enum Mode mode) {
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* obj, QEvent* e) {
313 owarn << " " << obj->name() << " " << obj->className() << "" << oendl;
314 if ( e->type() == QEvent::Resize ) { 313 if ( e->type() == QEvent::Resize ) {
315 QResizeEvent *res = static_cast<QResizeEvent*>( e ); 314 QResizeEvent *res = static_cast<QResizeEvent*>( e );
316 QSize size = res->size(); 315 QSize size = res->size();
317 if ( size.width() >= mode_size ) 316 if ( size.width() >= mode_size )
318 switchTop(); 317 switchTop();
319 else 318 else
320 switchStack(); 319 switchStack();
321 } 320 }
322 return false; 321 return false;
323} 322}
324 323
325 324
326/** 325/**
327 * @internal_resons 326 * @internal_resons
328 */ 327 */
329void OWidgetStack::resizeEvent( QResizeEvent* ev ) { 328void OWidgetStack::resizeEvent( QResizeEvent* ev ) {
330 QFrame::resizeEvent( ev ); 329 QFrame::resizeEvent( ev );
331 if (m_mode == SmallScreen ) 330 if (m_mode == SmallScreen )
332 m_stack->setGeometry( frameRect() ); 331 m_stack->setGeometry( frameRect() );
333 else 332 else
334 if (m_mWidget ) 333 if (m_mWidget )
335 m_mWidget->setGeometry( frameRect() ); 334 m_mWidget->setGeometry( frameRect() );
336 335
337} 336}
338 337
339/** 338/**
340 * setMainWindow gives the OWidgetStack a hint which 339 * setMainWindow gives the OWidgetStack a hint which
341 * window should always stay inside the stack. 340 * window should always stay inside the stack.
342 * Normally the first added widget is considered to be 341 * Normally the first added widget is considered to be
343 * the mainwindow but you can change this with this 342 * the mainwindow but you can change this with this
344 * function. 343 * function.
345 * If in BigScreen mode the current mainwindow will be reparented 344 * If in BigScreen mode the current mainwindow will be reparented
346 * and hidden. The position will be taken by the new one. 345 * and hidden. The position will be taken by the new one.
347 * If the old MainWindow was hidden the new window will 346 * If the old MainWindow was hidden the new window will
348 * also be hidden. If the window was visible the new mainwindow 347 * also be hidden. If the window was visible the new mainwindow
349 * 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
350 * was no mainwindow it will be hidden as well. 349 * was no mainwindow it will be hidden as well.
351 * 350 *
352 * @param wid The new mainwindow 351 * @param wid The new mainwindow
353 */ 352 */
354void OWidgetStack::setMainWindow( QWidget* wid ) { 353void OWidgetStack::setMainWindow( QWidget* wid ) {
355 if (m_mode == BigScreen ) { 354 if (m_mode == BigScreen ) {
356 bool wasVisible = false; 355 bool wasVisible = false;
357 if (m_mWidget ) { 356 if (m_mWidget ) {
358 wasVisible = !m_mWidget->isHidden(); 357 wasVisible = !m_mWidget->isHidden();
359 /* hidden by default */ 358 /* hidden by default */
360 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) ); 359 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) );
361 } 360 }
362 wid->reparent(this, 0, frameRect().topLeft() ); 361 wid->reparent(this, 0, frameRect().topLeft() );
363 362
364 if (wasVisible) 363 if (wasVisible)
365 wid->show(); 364 wid->show();
366 } 365 }
367 366
368 m_mWidget = wid; 367 m_mWidget = wid;
369} 368}
370 369
371/** 370/**
372 * this is an overloaded member and only differs 371 * this is an overloaded member and only differs
373 * in the type of arguments. 372 * in the type of arguments.
374 * @see setMainWindow(QWidget*) 373 * @see setMainWindow(QWidget*)
375 */ 374 */
376void OWidgetStack::setMainWindow( int id) { 375void OWidgetStack::setMainWindow( int id) {
377 setMainWindow( widget( id ) ); 376 setMainWindow( widget( id ) );
378} 377}
379 378
380 379
381/* 380/*
382 * this function switches to a stack ;) 381 * this function switches to a stack ;)
383 */ 382 */
384void OWidgetStack::switchStack() { 383void OWidgetStack::switchStack() {
385 if (m_stack ) { 384 if (m_stack ) {
386 m_stack->setGeometry( frameRect() ); 385 m_stack->setGeometry( frameRect() );
387 return; 386 return;
388 } 387 }
389 388
390 m_mode = SmallScreen; 389 m_mode = SmallScreen;
391 m_stack = new QWidgetStack(this); 390 m_stack = new QWidgetStack(this);
392 391
393 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), 392 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
394 this, SIGNAL(aboutToShow(QWidget*) ) ); 393 this, SIGNAL(aboutToShow(QWidget*) ) );
395 connect(m_stack, SIGNAL(aboutToShow(int) ), 394 connect(m_stack, SIGNAL(aboutToShow(int) ),
396 this, SIGNAL(aboutToShow(int) ) ); 395 this, SIGNAL(aboutToShow(int) ) );
397 396
398 /* now reparent the widgets... luckily QWidgetSatck does most of the work */ 397 /* now reparent the widgets... luckily QWidgetSatck does most of the work */
399 if (m_list.isEmpty() ) 398 if (m_list.isEmpty() )
400 return; 399 return;
401 400
402 QMap<int, QWidget*>::Iterator it = m_list.begin(); 401 QMap<int, QWidget*>::Iterator it = m_list.begin();
403 for ( ; it != m_list.end(); ++it ) 402 for ( ; it != m_list.end(); ++it )
404 m_stack->addWidget( it.data(), it.key() ); 403 m_stack->addWidget( it.data(), it.key() );
405 404
406 405
407} 406}
408 407
409/* 408/*
410 * we will switch to top level mode 409 * we will switch to top level mode
411 * reparent the list of widgets and then delete the stack 410 * reparent the list of widgets and then delete the stack
412 */ 411 */
413void OWidgetStack::switchTop() { 412void OWidgetStack::switchTop() {
414 m_mode = BigScreen; 413 m_mode = BigScreen;
415 /* this works because it is guaranteed that switchStack was called at least once*/ 414 /* this works because it is guaranteed that switchStack was called at least once*/
416 if (!m_stack && m_mWidget) { 415 if (!m_stack && m_mWidget) {
417 m_mWidget->setGeometry( frameRect() ); 416 m_mWidget->setGeometry( frameRect() );
418 return; 417 return;
419 }else if (!m_stack) 418 }else if (!m_stack)
420 return; 419 return;
421 420
422 if (!m_list.isEmpty() ) { 421 if (!m_list.isEmpty() ) {
423 QMap<int, QWidget*>::Iterator it = m_list.begin(); 422 QMap<int, QWidget*>::Iterator it = m_list.begin();
424 for ( ; it != m_list.end(); ++it ) { 423 for ( ; it != m_list.end(); ++it ) {
425 /* better than reparenting twice */ 424 /* better than reparenting twice */
426 if ( it.data() == m_mWidget ) { 425 if ( it.data() == m_mWidget ) {
427 m_mWidget->reparent(this, 0, frameRect().topLeft() ); 426 m_mWidget->reparent(this, 0, frameRect().topLeft() );
428 m_mWidget->setGeometry( frameRect() ); 427 m_mWidget->setGeometry( frameRect() );
429 m_mWidget->show(); 428 m_mWidget->show();
430 }else 429 }else
431 /* ### FIXME we need to place the widget better */ 430 /* ### FIXME we need to place the widget better */
432 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) ); 431 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) );
433 } 432 }
434 } 433 }
435 434
436 delete m_stack; 435 delete m_stack;
437 m_stack = 0; 436 m_stack = 0;
438} 437}
439 438
440} 439}
441} 440}