From: vsr Date: Mon, 14 May 2007 12:11:20 +0000 (+0000) Subject: Porting to Qt4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=01affc5872685e6bff7ec00740aad182372f8095;p=modules%2Fgui.git Porting to Qt4 --- diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index bbe68030d..25e5bd542 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -18,13 +18,14 @@ // #include "SUIT_Application.h" +#include "SUIT_Study.h" #include "SUIT_Session.h" #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" -#include -#include -#include +#include +#include +#include #include #include @@ -38,7 +39,9 @@ SUIT_Application::SUIT_Application() myStudy( 0 ), myDesktop( 0 ), myStatusLabel( 0 ) -{ +{ + if ( SUIT_Session::session() ) + SUIT_Session::session()->insertApplication( this ); } /*! @@ -127,7 +130,7 @@ bool SUIT_Application::useFile( const QString& theFileName ) Opens other study into active Study. If Study is empty - creates it. \param theName - name of study */ -bool SUIT_Application::useStudy( const QString& theName ) +bool SUIT_Application::useStudy( const QString& /*theName*/ ) { return false; } @@ -211,7 +214,7 @@ void SUIT_Application::onInfoClear() */ SUIT_Application* SUIT_Application::startApplication( int argc, char** argv ) const { - return startApplication( name(), argc, argv ); + return startApplication( objectName(), argc, argv ); } /*! @@ -462,7 +465,12 @@ int SUIT_Application::createMenu( const int id, const QString& menu, const int g */ void SUIT_Application::setMenuShown( QAction* a, const bool on ) { - setMenuShown( actionId( a ), on ); + if ( !a || !desktop() ) + return; + + QtxActionMenuMgr* mMgr = desktop()->menuMgr(); + if ( mMgr ) + mMgr->setShown( mMgr->actionId( a ), on ); } /*! @@ -472,8 +480,7 @@ void SUIT_Application::setMenuShown( QAction* a, const bool on ) */ void SUIT_Application::setMenuShown( const int id, const bool on ) { - if ( desktop() && desktop()->menuMgr() ) - desktop()->menuMgr()->setShown( id, on ); + setMenuShown( action( id ), on ); } /*! @@ -483,7 +490,12 @@ void SUIT_Application::setMenuShown( const int id, const bool on ) */ void SUIT_Application::setToolShown( QAction* a, const bool on ) { - setToolShown( actionId( a ), on ); + if ( !a || !desktop() ) + return; + + QtxActionToolMgr* tMgr = desktop()->toolMgr(); + if ( tMgr ) + tMgr->setShown( tMgr->actionId( a ), on ); } /*! @@ -493,8 +505,7 @@ void SUIT_Application::setToolShown( QAction* a, const bool on ) */ void SUIT_Application::setToolShown( const int id, const bool on ) { - if ( desktop() && desktop()->toolMgr() ) - desktop()->toolMgr()->setShown( id, on ); + setToolShown( action( id ), on ); } /*! @@ -538,10 +549,9 @@ QAction* SUIT_Application::action( const int id ) const int SUIT_Application::actionId( const QAction* a ) const { int id = -1; - for ( QMap::ConstIterator it = myActionMap.begin(); - it != myActionMap.end() && id == -1; - ++it ) { - if ( it.data() == a ) + for ( QMap::ConstIterator it = myActionMap.begin(); it != myActionMap.end() && id == -1; ++it ) + { + if ( it.value() == a ) id = it.key(); } return id; @@ -561,7 +571,7 @@ int SUIT_Application::actionId( const QAction* a ) const \param reciever - object that contains slot \param member - slot to be called when action is activated */ -QAction* SUIT_Application::createAction( const int id, const QString& text, const QIconSet& icon, +QAction* SUIT_Application::createAction( const int id, const QString& text, const QIcon& icon, const QString& menu, const QString& tip, const int key, QObject* parent, const bool toggle, QObject* reciever, const char* member ) { @@ -569,7 +579,7 @@ QAction* SUIT_Application::createAction( const int id, const QString& text, cons a->setStatusTip( tip ); if ( reciever && member ) - connect( a, SIGNAL( activated() ), reciever, member ); + connect( a, SIGNAL( triggered( bool ) ), reciever, member ); registerAction( id, a ); diff --git a/src/SUIT/SUIT_Application.h b/src/SUIT/SUIT_Application.h index 0bf48847e..597932673 100755 --- a/src/SUIT/SUIT_Application.h +++ b/src/SUIT/SUIT_Application.h @@ -20,19 +20,20 @@ #define SUIT_APPLICATION_H #include "SUIT.h" -#include "SUIT_Study.h" -#include -#include +#include +#include +class QIcon; class QLabel; class QString; class QAction; -class QIconSet; +class QWidget; + class SUIT_Desktop; -class SUIT_Convertor; class SUIT_ViewModel; class SUIT_ResourceMgr; +class SUIT_Study; #ifdef WIN32 #pragma warning ( disable:4251 ) @@ -95,10 +96,6 @@ public: SUIT_ResourceMgr* resourceMgr() const; - /*! Returns instance of data object Convertor class according to given Viewer. - If convertation is not supported returns 0. */ - virtual SUIT_Convertor* getConvertor(const SUIT_ViewModel* theViewer) { return 0; } - //! Puts the message to the status bar void putInfo ( const QString&, const int = 0 ); @@ -156,7 +153,7 @@ protected: QAction* action( const int ) const; int actionId( const QAction* ) const; int registerAction( const int, QAction* ); - QAction* createAction( const int, const QString&, const QIconSet&, const QString&, + QAction* createAction( const int, const QString&, const QIcon&, const QString&, const QString&, const int, QObject* = 0, const bool = false, QObject* = 0, const char* = 0 ); diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index 1082579fc..186dbe195 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -16,9 +16,8 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "SUIT_DataObject.h" -#include +#include "SUIT_DataObject.h" #include "SUIT_DataObjectKey.h" @@ -28,12 +27,11 @@ SUIT_DataObject::SUIT_DataObject( SUIT_DataObject* p ) : myParent( 0 ), - mySignal( 0 ), - myOpen( false ), - myCheck( false ) +myOpen( false ), +myCheck( false ), +mySignal( 0 ), +myAutoDel( true ) { - myChildren.setAutoDelete( true ); - setParent( p ); } @@ -56,8 +54,14 @@ SUIT_DataObject::~SUIT_DataObject() mySignal->setOwner( 0 ); } - for ( QPtrListIterator it( myChildren ); it.current(); ++it ) - it.current()->myParent = 0; + for ( DataObjectList::iterator it = myChildren.begin(); it != myChildren.end(); ++it ) + (*it)->myParent = 0; + + if ( autoDeleteChildren() ) + { + for ( DataObjectList::iterator itr = myChildren.begin(); itr != myChildren.end(); ++itr ) + delete *itr; + } delete mySignal; } @@ -79,7 +83,7 @@ SUIT_DataObject* SUIT_DataObject::firstChild() const { SUIT_DataObject* child = 0; if ( !myChildren.isEmpty() ) - child = myChildren.getFirst(); + child = myChildren.first(); return child; } @@ -91,7 +95,7 @@ SUIT_DataObject* SUIT_DataObject::lastChild() const { SUIT_DataObject* child = 0; if ( !myChildren.isEmpty() ) - child = myChildren.getLast(); + child = myChildren.last(); return child; } @@ -113,9 +117,9 @@ int SUIT_DataObject::childPos( const SUIT_DataObject* obj ) const int res = -1; int i = 0; - for ( DataObjectListIterator it( myChildren ); it.current() && res == -1; ++it, i++ ) + for ( DataObjectList::const_iterator it = myChildren.begin(); it != myChildren.end() && res == -1; ++it, i++ ) { - if ( it.current() == obj ) + if ( *it == obj ) res = i; } @@ -179,7 +183,7 @@ SUIT_DataObject* SUIT_DataObject::prevBrother() const bool SUIT_DataObject::autoDeleteChildren() const { - return myChildren.autoDelete(); + return myAutoDel; } /*! @@ -188,7 +192,7 @@ bool SUIT_DataObject::autoDeleteChildren() const void SUIT_DataObject::setAutoDeleteChildren( const bool on ) { - myChildren.setAutoDelete( on ); + myAutoDel = on; } /*! @@ -197,11 +201,11 @@ void SUIT_DataObject::setAutoDeleteChildren( const bool on ) void SUIT_DataObject::children( DataObjectList& lst, const bool rec ) const { - for ( DataObjectListIterator it( myChildren ); it.current(); ++it ) + for ( DataObjectList::const_iterator it = myChildren.begin(); it != myChildren.end(); ++it ) { - lst.append( it.current() ); + lst.append( *it ); if ( rec ) - it.current()->children( lst, rec ); + (*it)->children( lst, rec ); } } @@ -231,11 +235,11 @@ void SUIT_DataObject::appendChild( SUIT_DataObject* theObj ) void SUIT_DataObject::insertChild( SUIT_DataObject* theObj, int thePosition ) { - if ( !theObj || myChildren.find( theObj ) != -1 ) + if ( !theObj || myChildren.contains( theObj ) ) return; int pos = thePosition < 0 ? myChildren.count() : thePosition; - myChildren.insert( QMIN( pos, (int)myChildren.count() ), theObj ); + myChildren.insert( qMin( pos, (int)myChildren.count() ), theObj ); theObj->setParent( this ); } @@ -248,13 +252,8 @@ void SUIT_DataObject::removeChild( SUIT_DataObject* theObj ) if ( !theObj ) return; - bool ad = myChildren.autoDelete(); - myChildren.setAutoDelete( false ); - - if ( myChildren.remove( theObj ) ) + if ( myChildren.removeAll( theObj ) ) theObj->setParent( 0 ); - - myChildren.setAutoDelete( ad ); } /*! @@ -297,8 +296,8 @@ void SUIT_DataObject::reparentChildren( const SUIT_DataObject* obj ) DataObjectList lst; obj->children( lst ); - for ( DataObjectListIterator it( lst ); it.current(); ++it ) - it.current()->setParent( this ); + for ( DataObjectList::iterator it = lst.begin(); it != lst.end(); ++it ) + (*it)->setParent( this ); } /*! @@ -495,9 +494,9 @@ SUIT_DataObjectKey* SUIT_DataObject::key() const void SUIT_DataObject::dump( const int indent ) const { QString strIndent = QString().fill( ' ', indent ); // indentation string - printf( "%s%s\n", strIndent.latin1(), name().latin1() ); - for ( DataObjectListIterator it( myChildren ); it.current(); ++it ) // iterate all children - it.current()->dump( indent + 2 ); // dump every child with indent + 2 spaces + printf( "%s%s\n", strIndent.toLatin1().data(), name().toLatin1().data() ); + for ( DataObjectList::const_iterator it = myChildren.begin(); it != myChildren.end(); ++it ) + (*it)->dump( indent + 2 ); } /*! diff --git a/src/SUIT/SUIT_DataObject.h b/src/SUIT/SUIT_DataObject.h index 01f0ffa59..1f479192c 100755 --- a/src/SUIT/SUIT_DataObject.h +++ b/src/SUIT/SUIT_DataObject.h @@ -16,21 +16,21 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #ifndef SUIT_DATAOBJECT_H #define SUIT_DATAOBJECT_H -#include -#include -#include -#include - #include "SUIT.h" +#include +#include +#include +#include + class SUIT_DataObject; class SUIT_DataObjectKey; -typedef QPtrList DataObjectList; -typedef QPtrListIterator DataObjectListIterator; +typedef QList DataObjectList; #ifdef WIN32 #pragma warning( disable:4251 ) @@ -108,10 +108,11 @@ public: void dump( const int indent = 2 ) const; // dump to cout private: + SUIT_DataObject* myParent; bool myOpen; bool myCheck; Signal* mySignal; - SUIT_DataObject* myParent; + bool myAutoDel; DataObjectList myChildren; friend class SUIT_DataObject::Signal;