From e911e9581a90b089a56872342210e6b942ab67f3 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 14 May 2007 12:58:22 +0000 Subject: [PATCH] Porting to Qt4 --- src/SUIT/SUIT_Desktop.cxx | 79 +++++++++++++++++++++++---------------- src/SUIT/SUIT_Desktop.h | 18 +++++---- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/src/SUIT/SUIT_Desktop.cxx b/src/SUIT/SUIT_Desktop.cxx index 8b2c63202..11bb07b53 100755 --- a/src/SUIT/SUIT_Desktop.cxx +++ b/src/SUIT/SUIT_Desktop.cxx @@ -18,13 +18,15 @@ // #include "SUIT_Desktop.h" -#include "SUIT_Tools.h" #include "SUIT_ViewWindow.h" -#include +//#include #include #include +#include +#include + /*!\class SUIT_Desktop * Provide desktop management:\n * \li menu manager @@ -32,6 +34,17 @@ * \li windows */ +class SUIT_Desktop::ReparentEvent : public QEvent +{ +public: + ReparentEvent( Type t, QObject* obj ) : QEvent( t ), myObj( obj ) {}; + + QObject* object() const { return myObj; } + +private: + QObject* myObj; +}; + /*! Constructor. */ @@ -40,7 +53,7 @@ SUIT_Desktop::SUIT_Desktop() { myMenuMgr = new QtxActionMenuMgr( this ); myToolMgr = new QtxActionToolMgr( this ); - myLogoMgr = new QtxLogoMgr( menuBar() ); + myLogoMgr = 0;//new QtxLogoMgr( menuBar() ); } /*! @@ -66,6 +79,8 @@ bool SUIT_Desktop::event( QEvent* e ) case QEvent::WindowDeactivate: emit deactivated(); break; + default: + break; } return QMainWindow::event( e ); @@ -85,18 +100,29 @@ void SUIT_Desktop::closeEvent( QCloseEvent* e ) */ void SUIT_Desktop::childEvent( QChildEvent* e ) { - if ( e->type() == QEvent::ChildInserted && parentArea() && - e->child()->isWidgetType() && e->child()->inherits( "SUIT_ViewWindow" ) ) - { - QWidget* wid = (QWidget*)e->child(); - bool vis = wid->isVisibleTo( wid->parentWidget() ); - wid->reparent( parentArea(), QPoint( 0, 0 ), vis ); - wid->setShown( vis ); - } + if ( e->type() == QEvent::ChildAdded && e->child()->isWidgetType() ) + QApplication::postEvent( this, new QChildEvent( QEvent::Type( Reparent ), e->child() ) ); else QtxMainWindow::childEvent( e ); } +void SUIT_Desktop::customEvent( QEvent* e ) +{ + if ( (int)e->type() != Reparent ) + return; + + QChildEvent* re = (QChildEvent*)e; + if ( re->child()->inherits( "SUIT_ViewWindow" ) ) + { + QWidget* wid = (QWidget*)re->child(); + bool invis = wid->testAttribute( Qt::WA_WState_ExplicitShowHide ) && + wid->testAttribute( Qt::WA_WState_Hidden ); + + addWindow( wid ); + wid->setShown( !invis ); + } +} + /*! Gets menu manager. */ @@ -118,48 +144,35 @@ QtxActionToolMgr* SUIT_Desktop::toolMgr() const */ int SUIT_Desktop::logoCount() const { + return 0; +/* if ( !myLogoMgr ) return 0; else return myLogoMgr->count(); -} - -/*! - Adds new logo to the menu bar area. - Obsolete. Not should be used. - Use SUIT_Desktop::logoInsert(); */ -void SUIT_Desktop::addLogo( const QString& id, const QPixmap& pix ) -{ - logoInsert( id, pix ); -} - -/*! - Removes a logo. - Obsolete. Not should be used. - Use SUIT_Desktop::logoRemove(); -*/ -void SUIT_Desktop::removeLogo( const QString& id ) -{ - logoRemove( id ); } /*! Adds new logo to the menu bar area */ -void SUIT_Desktop::logoInsert( const QString& logoID, const QPixmap& logo, const int idx ) +void SUIT_Desktop::logoInsert( const QString& /*logoID*/, const QPixmap& /*logo*/, const int /*idx*/ ) { +/* if ( myLogoMgr ) myLogoMgr->insert( logoID, logo, idx ); +*/ } /*! Removes a logo */ -void SUIT_Desktop::logoRemove( const QString& logoID ) +void SUIT_Desktop::logoRemove( const QString& /*logoID*/ ) { +/* if ( myLogoMgr ) myLogoMgr->remove( logoID ); +*/ } /*! @@ -167,8 +180,10 @@ void SUIT_Desktop::logoRemove( const QString& logoID ) */ void SUIT_Desktop::logoClear() { +/* if ( myLogoMgr ) myLogoMgr->clear(); +*/ } /*! diff --git a/src/SUIT/SUIT_Desktop.h b/src/SUIT/SUIT_Desktop.h index e3acceb62..ba3b057e6 100755 --- a/src/SUIT/SUIT_Desktop.h +++ b/src/SUIT/SUIT_Desktop.h @@ -21,11 +21,11 @@ #include "SUIT.h" -#include -#include +#include +#include + #include -class QPopupMenu; class QtxLogoMgr; class SUIT_ViewWindow; class QtxActionMenuMgr; @@ -40,6 +40,10 @@ class SUIT_EXPORT SUIT_Desktop : public QtxMainWindow { Q_OBJECT + class ReparentEvent; + + enum { Reparent = QEvent::User }; + public: SUIT_Desktop(); virtual ~SUIT_Desktop(); @@ -48,10 +52,7 @@ public: QtxActionToolMgr* toolMgr() const; virtual SUIT_ViewWindow* activeWindow() const = 0; - virtual QPtrList windows() const = 0; - - void addLogo( const QString&, const QPixmap& ); // Not should be used. Will be removed. - void removeLogo( const QString& ); // Not should be used. Will be removed. + virtual QList windows() const = 0; int logoCount() const; @@ -71,10 +72,11 @@ signals: protected: virtual bool event( QEvent* ); + virtual void customEvent( QEvent* ); virtual void closeEvent( QCloseEvent* ); virtual void childEvent( QChildEvent* ); - virtual QWidget* parentArea() const = 0; + virtual void addWindow( QWidget* ) = 0; private: QtxActionMenuMgr* myMenuMgr; -- 2.39.2