summaryrefslogtreecommitdiff
path: root/libopie2/opieui/big-screen/owidgetstack.cpp
Unidiff
Diffstat (limited to 'libopie2/opieui/big-screen/owidgetstack.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp
index 57e97e3..a0a6355 100644
--- a/libopie2/opieui/big-screen/owidgetstack.cpp
+++ b/libopie2/opieui/big-screen/owidgetstack.cpp
@@ -1,87 +1,87 @@
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 "owidgetstack.h" 29#include "owidgetstack.h"
30 30
31/* QT */ 31/* QT */
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qwidgetstack.h> 33#include <qwidgetstack.h>
34 34
35namespace { 35namespace Opie {
36namespace Ui {
36 const int mode_size = 330; 37 const int mode_size = 330;
37}
38 38
39using namespace Opie; 39
40 40
41/** 41/**
42 * This is the standard widget. For simple usage see the example. Normally this widget 42 * This is the standard widget. For simple usage see the example. Normally this widget
43 * is the central widget of a QMainWindow. 43 * is the central widget of a QMainWindow.
44 * Use removeWidget before you delete a widget yourself. OWidgetStack does not 44 * Use removeWidget before you delete a widget yourself. OWidgetStack does not
45 * yet recognize removal of children. 45 * yet recognize removal of children.
46 * 46 *
47 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion. 47 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion.
48 * Or you use QPEApplication::showMainWidget(). 48 * Or you use QPEApplication::showMainWidget().
49 * @param name Name will be passed on to QObject 49 * @param name Name will be passed on to QObject
50 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags 50 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags
51 */ 51 */
52OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl) 52OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl)
53 : QFrame( parent, name, fl ) 53 : QFrame( parent, name, fl )
54{ 54{
55 m_last = m_mWidget = 0; 55 m_last = m_mWidget = 0;
56 m_forced = false; 56 m_forced = false;
57 57
58 QApplication::desktop()->installEventFilter( this ); 58 QApplication::desktop()->installEventFilter( this );
59 setFontPropagation ( AllChildren ); 59 setFontPropagation ( AllChildren );
60 setPalettePropagation( AllChildren ); 60 setPalettePropagation( AllChildren );
61 61
62 /* sets m_mode and initializes more */ 62 /* sets m_mode and initializes more */
63 /* if you change this call change switchTop as well */ 63 /* if you change this call change switchTop as well */
64 m_stack = 0; 64 m_stack = 0;
65 switchStack(); 65 switchStack();
66} 66}
67 67
68/** 68/**
69 * The destructor. It deletes also all added widgets. 69 * The destructor. It deletes also all added widgets.
70 * 70 *
71 */ 71 */
72OWidgetStack::~OWidgetStack() { 72OWidgetStack::~OWidgetStack() {
73 if (m_mode == BigScreen && !m_list.isEmpty() ) { 73 if (m_mode == BigScreen && !m_list.isEmpty() ) {
74 QMap<int, QWidget*>::Iterator it = m_list.begin(); 74 QMap<int, QWidget*>::Iterator it = m_list.begin();
75 for ( ; it != m_list.end(); ++it ) 75 for ( ; it != m_list.end(); ++it )
76 delete it.data(); 76 delete it.data();
77 } 77 }
78 m_list.clear(); 78 m_list.clear();
79 79
80} 80}
81 81
82/** 82/**
83 * return the mode of the desktop. There are currently two modes. SmallScreen 83 * return the mode of the desktop. There are currently two modes. SmallScreen
84 * with a normal PDA resolution and BigScreen with resolutions greater than 84 * with a normal PDA resolution and BigScreen with resolutions greater than
85 * 330 for width and height. 85 * 330 for width and height.
86 * You can also force the mode this widget is in with forceMode() 86 * You can also force the mode this widget is in with forceMode()
87 * Note that NoForce will be never returned from here 87 * Note that NoForce will be never returned from here
@@ -388,48 +388,51 @@ void OWidgetStack::switchStack() {
388 m_stack = new QWidgetStack(this); 388 m_stack = new QWidgetStack(this);
389 389
390 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), 390 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
391 this, SIGNAL(aboutToShow(QWidget*) ) ); 391 this, SIGNAL(aboutToShow(QWidget*) ) );
392 connect(m_stack, SIGNAL(aboutToShow(int) ), 392 connect(m_stack, SIGNAL(aboutToShow(int) ),
393 this, SIGNAL(aboutToShow(int) ) ); 393 this, SIGNAL(aboutToShow(int) ) );
394 394
395 /* now reparent the widgets... luckily QWidgetSatck does most of the work */ 395 /* now reparent the widgets... luckily QWidgetSatck does most of the work */
396 if (m_list.isEmpty() ) 396 if (m_list.isEmpty() )
397 return; 397 return;
398 398
399 QMap<int, QWidget*>::Iterator it = m_list.begin(); 399 QMap<int, QWidget*>::Iterator it = m_list.begin();
400 for ( ; it != m_list.end(); ++it ) 400 for ( ; it != m_list.end(); ++it )
401 m_stack->addWidget( it.data(), it.key() ); 401 m_stack->addWidget( it.data(), it.key() );
402 402
403 403
404} 404}
405 405
406/* 406/*
407 * we will switch to top level mode 407 * we will switch to top level mode
408 * reparent the list of widgets and then delete the stack 408 * reparent the list of widgets and then delete the stack
409 */ 409 */
410void OWidgetStack::switchTop() { 410void OWidgetStack::switchTop() {
411 m_mode = BigScreen; 411 m_mode = BigScreen;
412 /* this works because it is guaranteed that switchStack was called at least once*/ 412 /* this works because it is guaranteed that switchStack was called at least once*/
413 if (!m_stack && m_mWidget) { 413 if (!m_stack && m_mWidget) {
414 m_mWidget->setGeometry( frameRect() ); 414 m_mWidget->setGeometry( frameRect() );
415 return; 415 return;
416 }else if (!m_stack) 416 }else if (!m_stack)
417 return; 417 return;
418 418
419 if (!m_list.isEmpty() ) { 419 if (!m_list.isEmpty() ) {
420 QMap<int, QWidget*>::Iterator it = m_list.begin(); 420 QMap<int, QWidget*>::Iterator it = m_list.begin();
421 for ( ; it != m_list.end(); ++it ) { 421 for ( ; it != m_list.end(); ++it ) {
422 /* better than reparenting twice */ 422 /* better than reparenting twice */
423 if ( it.data() == m_mWidget ) { 423 if ( it.data() == m_mWidget ) {
424 m_mWidget->reparent(this, 0, frameRect().topLeft() ); 424 m_mWidget->reparent(this, 0, frameRect().topLeft() );
425 m_mWidget->setGeometry( frameRect() ); 425 m_mWidget->setGeometry( frameRect() );
426 m_mWidget->show(); 426 m_mWidget->show();
427 }else 427 }else
428 /* ### FIXME we need to place the widget better */ 428 /* ### FIXME we need to place the widget better */
429 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) ); 429 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) );
430 } 430 }
431 } 431 }
432 432
433 delete m_stack; 433 delete m_stack;
434 m_stack = 0; 434 m_stack = 0;
435} 435}
436
437}
438} \ No newline at end of file