From: vsr Date: Thu, 2 Aug 2007 13:55:29 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: qt4_porting_delivery_220807~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d8e4d8f3e7772ac608c808f7b19089d16fe93b53;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index b1b050530..0f944c308 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -339,13 +339,18 @@ const QItemSelection OB_Browser::selection() const \brief Select/deselect specified model index. \param index model index to be selected/deselected \param on if \c true, the index will be selected, otherwise - deselected + \param keepSelection if \c true (default) the previous selection is kept, + otherwise it is first cleared */ -void OB_Browser::select( const QModelIndex& index, const bool on ) +void OB_Browser::select( const QModelIndex& index, const bool on, const bool keepSelection ) { if ( myView->selectionModel() ) { - myView->selectionModel()->select( index, on ? - QItemSelectionModel::Select | QItemSelectionModel::Rows : - QItemSelectionModel::Deselect | QItemSelectionModel::Rows ); + QItemSelectionModel::SelectionFlags f = on ? QItemSelectionModel::Select : QItemSelectionModel::Deselect; + f = f | QItemSelectionModel::Rows; + if ( !keepSelection ) + f = f | QItemSelectionModel::Clear; + + myView->selectionModel()->select( index, f ); } } @@ -354,14 +359,18 @@ void OB_Browser::select( const QModelIndex& index, const bool on ) \param indexes model indices to be selected/deselected \param on if \c true, the indices will be selected, otherwise - deselected */ -void OB_Browser::select( const QModelIndexList& indexes, const bool on ) +void OB_Browser::select( const QModelIndexList& indexes, const bool on, const bool keepSelection ) { bool blocked = myView->signalsBlocked(); myView->blockSignals( true ); QModelIndex idx; - foreach( idx, indexes ) - select( idx, on ); + bool first = true; + + foreach( idx, indexes ) { + select( idx, on, first ? keepSelection : true ); + first = false; + } myView->blockSignals( blocked ); emit( selectionChanged() ); diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index 592830ba4..cc4fbe365 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -76,8 +76,8 @@ public: QModelIndexList selectedIndexes() const; const QItemSelection selection() const; - virtual void select( const QModelIndex&, const bool = false ); - virtual void select( const QModelIndexList&, const bool = false ); + virtual void select( const QModelIndex&, const bool, const bool = true ); + virtual void select( const QModelIndexList&, const bool, const bool = true ); bool isOpen( const QModelIndex& ) const; virtual void setOpen( const QModelIndex& theObject, const bool theOpen = true );