From: stv Date: Wed, 14 Mar 2007 09:45:45 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: For_HDF~20 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=113ac20be0ec90a9d6842b0aac713c8b6000323d;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 2bdc0325b..e1e7cbd18 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -873,7 +873,7 @@ void QtxWorkstack::onDestroyed( QObject* obj ) /*! SLOT: called on window activating */ -void QtxWorkstack::onWindowActivated( QWidget* wid ) +void QtxWorkstack::onWindowActivated( QWidget* ) { const QObject* obj = sender(); if ( !obj->inherits( "QtxWorkstackArea" ) ) @@ -965,7 +965,7 @@ QWidget* QtxWorkstack::addWindow( QWidget* w, Qt::WindowFlags f ) /*! Handler of custom events */ -void QtxWorkstack::customEvent( QEvent* e ) +void QtxWorkstack::customEvent( QEvent* ) { updateState(); } @@ -1865,6 +1865,8 @@ void QtxWorkstackArea::customEvent( QEvent* e ) case RemoveWidget: removeWidget( we->widget() ); break; + default: + break; } } @@ -2150,6 +2152,8 @@ void QtxWorkstackArea::updateState() updateCurrent(); + myBar->updateActiveState(); + myBar->setUpdatesEnabled( updBar ); myStack->setUpdatesEnabled( updStk ); if ( updBar ) @@ -2321,6 +2325,8 @@ myId( -1 ) { setDrawBase( true ); setElideMode( Qt::ElideNone ); + + connect( this, SIGNAL( currentChanged( int ) ), this, SLOT( onCurrentChanged( int ) ) ); } /*! @@ -2346,7 +2352,7 @@ void QtxWorkstackTabBar::setTabId( const int index, const int id ) int QtxWorkstackTabBar::indexOf( const int id ) const { int index = -1; - for ( uint i = 0; i < count() && index < 0; i++ ) + for ( int i = 0; i < (int)count() && index < 0; i++ ) { if ( tabId( i ) == id ) index = i; @@ -2354,29 +2360,38 @@ int QtxWorkstackTabBar::indexOf( const int id ) const return index; } +/*! + Returns 'true' if the tab bar is active +*/ +bool QtxWorkstackTabBar::isActive() const +{ + return myActive; +} + /*! Sets tab bar as active or inactive \param on - new active state */ void QtxWorkstackTabBar::setActive( const bool on ) { - QFont aFont = font(); - aFont.setUnderline( on ); - QPalette aPal = palette(); - if ( !on ) - { - aPal.setColor( QPalette::HighlightedText, aPal.color( QPalette::Foreground ) ); - aPal.setColor( QPalette::Highlight, aPal.color( QPalette::Dark ).light( DARK_COLOR_LIGHT ) ); - setPalette( aPal ); - } - else - { - aPal.setColor( QPalette::HighlightedText, aPal.color( QPalette::HighlightedText ) ); - aPal.setColor( QPalette::Highlight, aPal.color( QPalette::Highlight ) ); - } - setFont( aFont ); + if ( myActive == on ) + return; + + myActive = on; + updateActiveState(); +} + +void QtxWorkstackTabBar::updateActiveState() +{ + QColor bc = palette().color( QPalette::Text ); + QColor ac = isActive() ? palette().color( QPalette::Highlight ) : bc; + for ( int i = 0; i < (int)count(); i++ ) + setTabTextColor( i, currentIndex() == i ? ac : bc ); +} - update(); +void QtxWorkstackTabBar::onCurrentChanged( int ) +{ + updateActiveState(); } /*! @@ -2448,9 +2463,9 @@ void QtxWorkstackTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool QtxWorkstackDrag::QtxWorkstackDrag( QtxWorkstack* ws, QtxWorkstackChild* child ) : QObject( 0 ), myWS( ws ), +myChild( child ), myTab( -1 ), myArea( 0 ), -myChild( child ), myTabRect( 0 ), myAreaRect( 0 ) { diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 1682e0518..7ad6221ea 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -287,16 +287,22 @@ public: QtxWorkstackTabBar( QWidget* = 0 ); virtual ~QtxWorkstackTabBar(); + bool isActive() const; void setActive( const bool ); int tabId( const int ) const; int indexOf( const int ) const; void setTabId( const int, const int ); + void updateActiveState(); + Q_SIGNALS: void dragActiveTab(); void contextMenuRequested( QPoint ); +private Q_SLOTS: + void onCurrentChanged( int ); + protected: virtual void mouseMoveEvent( QMouseEvent* ); virtual void mousePressEvent( QMouseEvent* ); @@ -307,6 +313,7 @@ protected: private: int myId; + bool myActive; }; class QtxWorkstackDrag : public QObject diff --git a/src/SUIT/SUIT_Selector.cxx b/src/SUIT/SUIT_Selector.cxx index 8879f77bc..2afe73c47 100755 --- a/src/SUIT/SUIT_Selector.cxx +++ b/src/SUIT/SUIT_Selector.cxx @@ -20,6 +20,47 @@ #include "SUIT_SelectionMgr.h" +/*!\class SUIT_Selector::Detroyer + Class provide the watching for qobject parent class of the selector. +*/ + +class SUIT_Selector::Destroyer : public QObject +{ +public: + Destroyer( SUIT_Selector*, QObject* = 0 ); + virtual ~Destroyer(); + + SUIT_Selector* selector() const; + void setSelector( SUIT_Selector* ); + +private: + SUIT_Selector* mySelector; +}; + +SUIT_Selector::Destroyer::Destroyer( SUIT_Selector* s, QObject* p ) +: QObject( p ), + mySelector( s ) +{ +} + +SUIT_Selector::Destroyer::~Destroyer() +{ + SUIT_Selector* s = mySelector; + mySelector = 0; + if ( s ) + delete s; +} + +SUIT_Selector* SUIT_Selector::Destroyer::selector() const +{ + return mySelector; +} + +void SUIT_Selector::Destroyer::setSelector( SUIT_Selector* s ) +{ + mySelector = s; +} + /*!\class SUIT_Selector * Class provide selector for data owners. */ @@ -27,15 +68,18 @@ /*! Constructor. */ -SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent ) : -QObject( parent ), -mySelMgr( selMgr ), +SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent ) +: mySelMgr( selMgr ), myBlock( false ), myEnabled( true ), -myAutoBlock( true ) +myAutoBlock( true ), +myDestroyer( 0 ) { if ( selMgr ) selMgr->installSelector( this ); + + if ( parent ) + myDestroyer = new Destroyer( this, parent ); } /*! @@ -45,6 +89,12 @@ SUIT_Selector::~SUIT_Selector() { if ( selectionMgr() ) selectionMgr()->removeSelector( this ); + + if ( myDestroyer && myDestroyer->selector() == this ) + { + myDestroyer->setSelector( 0 ); + delete myDestroyer; + } } /*! diff --git a/src/SUIT/SUIT_Selector.h b/src/SUIT/SUIT_Selector.h index ca2940b6f..954fa449b 100755 --- a/src/SUIT/SUIT_Selector.h +++ b/src/SUIT/SUIT_Selector.h @@ -34,9 +34,11 @@ class SUIT_DataOwnerPtrList; (ObjectBrowser, viewers, etc) Used by selection manager for selection synhronizing */ -class SUIT_EXPORT SUIT_Selector : public QObject + +class SUIT_EXPORT SUIT_Selector { - Q_OBJECT + class Destroyer; + public: SUIT_Selector( SUIT_SelectionMgr*, QObject* = 0 ); virtual ~SUIT_Selector(); @@ -67,6 +69,7 @@ private: SUIT_SelectionMgr* mySelMgr; bool myEnabled; bool myAutoBlock; + Destroyer* myDestroyer; }; #endif