X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FQtx%2FQtxWorkstack.cxx;h=9de0de4c71648c325151c48f0b81eabb0a731fa8;hb=75e47574c7b9e08f69d35391de2a126684e275fb;hp=6607e2f1e07ef0e7aa8c3232113389837f6039f4;hpb=e07448c48ea5b2127e34fc7b8c3427d01c7ce17b;p=modules%2Fgui.git diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 6607e2f1e..9de0de4c7 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -528,16 +528,16 @@ QtxWorkstackArea::QtxWorkstackArea( QWidget* parent ) base->setMargin( frameWidth() ); base->setSpacing( 0 ); - QWidget* top = new QWidget( this ); - base->addWidget( top ); + myTop = new QWidget( this ); + base->addWidget( myTop ); - QHBoxLayout* tl = new QHBoxLayout( top ); + QHBoxLayout* tl = new QHBoxLayout( myTop ); tl->setMargin( 0 ); - myBar = new QtxWorkstackTabBar( top ); + myBar = new QtxWorkstackTabBar( myTop ); tl->addWidget( myBar, 1 ); - CloseButton* close = new CloseButton( top ); + CloseButton* close = new CloseButton( myTop ); close->setIcon( style()->standardIcon( QStyle::SP_TitleBarCloseButton ) ); myClose = close; tl->addWidget( myClose ); @@ -902,6 +902,16 @@ bool QtxWorkstackArea::restoreState( QDataStream& stream, QMapsetVisible(visible); + myBar->setVisible(visible); +} + + /*! \brief Get rectangle to be drawn when highlighting drop area. \return area drop rectangle @@ -953,6 +963,11 @@ void QtxWorkstackArea::customEvent( QEvent* e ) { case ActivateWidget: myBar->updateActiveState(); + // IMN 27/03/2015: This workaround caused by the bug INT PAL 0052623: OCC view blinking when + // using polyline sketcher which is reproduced on Unix systems with qt-4.8.4. + myStack->setUpdatesEnabled( false ); + updateCurrent(); + myStack->setUpdatesEnabled( true ); emit activated( activeWidget() ); break; case FocusWidget: @@ -1104,7 +1119,7 @@ void QtxWorkstackArea::onChildCaptionChanged( QtxWorkstackChild* c ) */ void QtxWorkstackArea::updateCurrent() { - QWidget* cur = child( widget( myBar->tabId( myBar->currentIndex() ) ) ); + QWidget* cur = child( myBar->tabId( myBar->currentIndex() ) ); if ( cur ) myStack->setCurrentWidget( cur ); } @@ -1794,6 +1809,16 @@ QWidget* QtxWorkstack::activeWindow() const return myWin; } +/*! + \brief Set active widget + \param wid widget to activate +*/ +void QtxWorkstack::setActiveWindow( QWidget* wid ) +{ + if ( activeArea() ) + activeArea()->setActiveWidget( wid ); +} + /*! \brief Split workstack. @@ -2178,7 +2203,7 @@ int QtxWorkstack::accel( const int id ) const { int res = 0; if ( myActionsMap.contains( id ) ) - res = myActionsMap[id]->shortcut(); + res = myActionsMap[id]->shortcut()[0]; return res; } @@ -2626,7 +2651,7 @@ void QtxWorkstack::insertWidget( QWidget* wid, QWidget* pWid, QWidget* after ) for ( QWidgetList::iterator itr = moveList.begin(); itr != moveList.end(); ++itr ) { (*itr)->setParent( pWid ); - (*itr)->setShown( map.contains( *itr ) ? map[*itr] : false ); + (*itr)->setVisible( map.contains( *itr ) ? map[*itr] : false ); } } @@ -2729,10 +2754,12 @@ void QtxWorkstack::onContextMenuRequested( QWidget* w, QPoint p ) if ( lst.count() > 1 ) { - if ( myActionsMap[SplitVertical]->isEnabled() ) - pm->addAction( myActionsMap[SplitVertical] ); - if ( myActionsMap[SplitHorizontal]->isEnabled() ) - pm->addAction( myActionsMap[SplitHorizontal] ); + if ( !myActionsMap[SplitVertical]->isEnabled() ) + myActionsMap[SplitVertical]->setEnabled(true); + pm->addAction( myActionsMap[SplitVertical] ); + if ( !myActionsMap[SplitHorizontal]->isEnabled() ) + myActionsMap[SplitHorizontal]->setEnabled(true); + pm->addAction( myActionsMap[SplitHorizontal] ); pm->addSeparator(); } @@ -3162,6 +3189,91 @@ bool QtxWorkstack::opaqueResize() const return mySplit->opaqueResize(); } +/*! + \brief Show/hide splitter state and area. + \param wid widget (and parent area) will be shown/hidden + \param parent_list parent splitters list + \param split splitter will be shown/hidden + \param visible splitter +*/ +void QtxWorkstack::splitterVisible(QWidget* wid, QList& parent_list, QSplitter* split, bool visible) +{ + QList recList; + splitters( split, recList, false ); + for ( QList::iterator itr = recList.begin(); itr != recList.end(); ++itr ) { + parent_list.prepend( *itr ); + splitterVisible( wid, parent_list, *itr, visible ); + } + + QList areaList; + areas( split, areaList, false ); + for ( QList::const_iterator it = areaList.begin(); it != areaList.end(); ++it ) { + QtxWorkstackArea* area = *it; + bool isCurrentWidget = false; + + area->showTabBar(visible); + + // 1. Looking for the selected widget at the lowest level among all splitted areas. + QList childList = area->childList(); + for ( QList::iterator itr = childList.begin(); itr != childList.end(); ++itr ) { + QWidget* aCurWid = (*itr)->widget(); + if ( aCurWid == wid ) { + isCurrentWidget = true; + aCurWid->setVisible( true ); + } + else + aCurWid->setVisible( visible ); + } + + // 2. Show/Hide other areas and widgets that don't contain the desired widget + if ( !isCurrentWidget || visible ) + area->setVisible( visible ); + + if ( !isCurrentWidget && !visible ) + continue; + + // 3. Show/hide all parent widgets + QSplitter* pSplit = splitter( area ); + int count = pSplit->count(); + for ( int i = 0; i < count; i++ ) { + if ( pSplit->indexOf( area ) == i && !visible ) + continue; + pSplit->widget(i)->setVisible( visible ); + } + + // 4. Show/hide all parent splitters don't contain the selected widget + if ( visible ) + pSplit->setVisible( true ); + + if ( isCurrentWidget && !visible ) { + for ( QList::iterator itr = parent_list.begin(); itr != parent_list.end() && pSplit != mySplit; ++itr ) { + if ( pSplit == *itr ) + continue; + QList splitList; + splitters( *itr, splitList, false ); + for ( QList::iterator iter = splitList.begin(); iter != splitList.end(); ++iter ) { + if ( pSplit == (*iter) ) { + pSplit = *itr; + continue; + } + (*iter)->setVisible( false ); + } + } + } + } +} + +/*! + \brief Show/hide splitters state and area. + \param wid widget (and parent area) will be shown/hidden + \param visible splitters +*/ +void QtxWorkstack::splittersVisible( QWidget* wid, bool visible ) +{ + QList parent_list; + parent_list.append( mySplit ); + splitterVisible( wid, parent_list, mySplit, visible ); +} /*! \fn void QtxWorkstack::windowActivated( QWidget* w ) @@ -3197,7 +3309,7 @@ QtxWorkstackArea* QtxWorkstack::wgArea( QWidget* wid ) const \param wid_to widget specified the destination area \param before specifies whether the first widget has to be moved before or after the second widget - \return TRUE if operation is completed successfully, FALSE otherwise + \return \c true if operation is completed successfully, \c false otherwise */ bool QtxWorkstack::move( QWidget* wid, QWidget* wid_to, const bool before ) { @@ -3223,6 +3335,7 @@ bool QtxWorkstack::move( QWidget* wid, QWidget* wid_to, const bool before ) idx++; area_src->removeWidget( wid, true ); area_to->insertWidget( wid, idx ); + wid->showMaximized(); return true; } } @@ -3232,7 +3345,7 @@ bool QtxWorkstack::move( QWidget* wid, QWidget* wid_to, const bool before ) /*! \brief Group all windows in one area - \return TRUE if operation is completed successfully, FALSE otherwise + \return \c true if operation is completed successfully, \c false otherwise */ void QtxWorkstack::stack() {