summaryrefslogtreecommitdiff
path: root/library/qpemenubar.cpp
Side-by-side diff
Diffstat (limited to 'library/qpemenubar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpemenubar.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/library/qpemenubar.cpp b/library/qpemenubar.cpp
index bb3ad8d..f0171ba 100644
--- a/library/qpemenubar.cpp
+++ b/library/qpemenubar.cpp
@@ -1,36 +1,36 @@
/**********************************************************************
-** Copyright (C) 2001 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define INCLUDE_MENUITEM_DEF
#include "qpemenubar.h"
#include <qapplication.h>
#include <qguardedptr.h>
#include <qtimer.h>
class QMenuBarHack : public QMenuBar
{
public:
int activeItem() const { return actItem; }
void goodbye()
{
activateItemAt(-1);
@@ -218,107 +218,108 @@ bool QPEMenuToolFocusManager::eventFilter( QObject *object, QEvent *event )
}
if ( ke->key() == Key_F11 ) {
setActive( !isActive() );
return TRUE;
}
} else if ( event->type() == QEvent::KeyRelease ) {
QKeyEvent *ke = (QKeyEvent *)event;
if ( isActive() ) {
if ( object->inherits( "QButton" ) ) {
// Deactivate when a button is selected
if ( ke->key() == Key_Space )
QTimer::singleShot( 0, this, SLOT(deactivate()) );
}
}
} else if ( event->type() == QEvent::FocusIn ) {
if ( isActive() ) {
// A non-menu/tool widget has been selected - we're deactivated
QWidget *w = (QWidget *)object;
if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) {
inFocus = 0;
}
}
} else if ( event->type() == QEvent::Hide ) {
if ( isActive() ) {
// Deaticvate if a menu/tool has been hidden
QWidget *w = (QWidget *)object;
if ( !w->isPopup() && !list.contains( GuardedWidget( w ) ) ) {
setActive( FALSE );
}
}
} else if ( event->type() == QEvent::ChildInserted ) {
QChildEvent *ce = (QChildEvent *)event;
- if ( ce->child()->inherits( "QMenuBar" ) ) {
- addWidget( (QWidget *)ce->child() );
- ce->child()->installEventFilter( this );
- } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) {
- addWidget( (QWidget *)ce->child() );
+ if ( ce->child()->isWidgetType() ) {
+ if ( ce->child()->inherits( "QMenuBar" ) ) {
+ addWidget( (QWidget *)ce->child() );
+ ce->child()->installEventFilter( this );
+ } else if ( object->inherits( "QToolBar" ) ) {
+ addWidget( (QWidget *)ce->child() );
+ }
}
} else if ( event->type() == QEvent::ChildRemoved ) {
QChildEvent *ce = (QChildEvent *)event;
- if ( ce->child()->inherits( "QMenuBar" ) ) {
- removeWidget( (QWidget *)ce->child() );
- ce->child()->removeEventFilter( this );
- } else if ( object->inherits( "QToolBar" ) && ce->child()->isWidgetType() ) {
- removeWidget( (QWidget *)ce->child() );
+ if ( ce->child()->isWidgetType() ) {
+ if ( ce->child()->inherits( "QMenuBar" ) ) {
+ removeWidget( (QWidget *)ce->child() );
+ ce->child()->removeEventFilter( this );
+ } else if ( object->inherits( "QToolBar" ) ) {
+ removeWidget( (QWidget *)ce->child() );
+ }
}
}
return FALSE;
}
void QPEMenuToolFocusManager::deactivate()
{
setActive( FALSE );
}
/*!
\class QPEMenuBar qpemenubar.h
\brief The QPEMenuBar class is obsolete. Use QMenuBar instead.
\obsolete
This class is obsolete. Use QMenuBar instead.
- \sa QMenuBar
*/
/*!
Constructs a QPEMenuBar just as you would construct
a QMenuBar, passing \a parent and \a name.
*/
QPEMenuBar::QPEMenuBar( QWidget *parent, const char *name )
: QMenuBar( parent, name )
{
}
/*!
\reimp
*/
QPEMenuBar::~QPEMenuBar()
{
}
/*!
\internal
*/
void QPEMenuBar::keyPressEvent( QKeyEvent *e )
{
QMenuBar::keyPressEvent( e );
}
-
-void QPEMenuBar::activateItem( int index )
-{
+/*!
+ \internal
+*/
+void QPEMenuBar::activateItem( int index ) {
activateItemAt( index );
}
-
-void QPEMenuBar::goodbye()
-{
+void QPEMenuBar::goodbye() {
activateItemAt(-1);
- for ( unsigned int i = 0; i < count(); i++ ) {
- QMenuItem *mi = findItem( idAt(i) );
- if ( mi->popup() ) {
+ for ( uint i = 0; i < count(); i++ ) {
+ QMenuItem* mi = findItem( idAt(i) );
+ if (mi->popup() )
mi->popup()->hide();
- }
}
}