/*!
SLOT: called on window activating
*/
-void QtxWorkstack::onWindowActivated( QWidget* wid )
+void QtxWorkstack::onWindowActivated( QWidget* )
{
const QObject* obj = sender();
if ( !obj->inherits( "QtxWorkstackArea" ) )
/*!
Handler of custom events
*/
-void QtxWorkstack::customEvent( QEvent* e )
+void QtxWorkstack::customEvent( QEvent* )
{
updateState();
}
case RemoveWidget:
removeWidget( we->widget() );
break;
+ default:
+ break;
}
}
updateCurrent();
+ myBar->updateActiveState();
+
myBar->setUpdatesEnabled( updBar );
myStack->setUpdatesEnabled( updStk );
if ( updBar )
{
setDrawBase( true );
setElideMode( Qt::ElideNone );
+
+ connect( this, SIGNAL( currentChanged( int ) ), this, SLOT( onCurrentChanged( int ) ) );
}
/*!
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;
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();
}
/*!
QtxWorkstackDrag::QtxWorkstackDrag( QtxWorkstack* ws, QtxWorkstackChild* child )
: QObject( 0 ),
myWS( ws ),
+myChild( child ),
myTab( -1 ),
myArea( 0 ),
-myChild( child ),
myTabRect( 0 ),
myAreaRect( 0 )
{
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* );
private:
int myId;
+ bool myActive;
};
class QtxWorkstackDrag : public QObject
#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.
*/
/*!
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 );
}
/*!
{
if ( selectionMgr() )
selectionMgr()->removeSelector( this );
+
+ if ( myDestroyer && myDestroyer->selector() == this )
+ {
+ myDestroyer->setSelector( 0 );
+ delete myDestroyer;
+ }
}
/*!
(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();
SUIT_SelectionMgr* mySelMgr;
bool myEnabled;
bool myAutoBlock;
+ Destroyer* myDestroyer;
};
#endif