X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_MeshDlg.cxx;h=09218ef3d1bfb9cf9f4a9e3a52da09ce6c99739b;hp=4973a5d1ebe264ae5894f53b262e7bed94c6ee21;hb=dd0d39d752a4d5ba58ed2e417651093764bb8d09;hpb=251f8c052dd12dd29922210dc901b295fe999a0e diff --git a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx index 4973a5d1e..09218ef3d 100644 --- a/src/SMESHGUI/SMESHGUI_MeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 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 @@ -30,6 +30,7 @@ // SALOME GUI includes #include #include +#include // Qt includes #include @@ -163,19 +164,33 @@ SMESHGUI_MeshTab::~SMESHGUI_MeshTab() * \param [in] txt - item text * \param [in] type - HypType * \param [in] index - index of item in a list of items + * \param [in] isGroup - is the item a group title */ //================================================================================ -void SMESHGUI_MeshTab::addItem( const QString& txt, const int type, const int index ) +void SMESHGUI_MeshTab::addItem( const QString& txt, + const int type, + const int index, + const bool isGroup ) { + const char* prefix = " "; if ( type <= AddHyp ) { - myHypCombo[ type ]->addItem( txt, QVariant( index )); - myHypCombo[ type ]->setMaxVisibleItems( qMax( 10, myHypCombo[ type ]->count() ) ); + if ( isGroup ) + { + int idx = myHypCombo[ type ]->count(); + myHypCombo[ type ]->addItem( txt.mid( 6 ), QVariant( index )); + myHypCombo[ type ]->setItemData( idx, "separator", Qt::AccessibleDescriptionRole ); + } + else + { + myHypCombo[ type ]->addItem( prefix + txt, QVariant( index )); + } + //myHypCombo[ type ]->setMaxVisibleItems( qMax( 10, myHypCombo[ type ]->count() ) ); } else { - QListWidgetItem* item = new QListWidgetItem( txt, myAddHypList ); + QListWidgetItem* item = new QListWidgetItem( prefix + txt, myAddHypList ); item->setData( Qt::UserRole, QVariant( index )); } } @@ -222,7 +237,7 @@ void SMESHGUI_MeshTab::setAvailableHyps( const int theId, const QStringList& the { addItem( tr( "NONE"), Algo, 0 ); for ( int i = 0, nbHyp = theHyps.count(); i < nbHyp; ++i ) - addItem( theHyps[i], Algo, i+1 ); + addItem( theHyps[i], Algo, i+1, theHyps[i].startsWith( "GROUP:" )); myHypCombo[ Algo ]->setCurrentIndex( 0 ); } } @@ -338,17 +353,24 @@ void SMESHGUI_MeshTab::setCurrentHyp( const int theId, const int theIndex ) } else // more than one additional hyp assigned { - // move a hyp from myHypCombo[ AddHyp ] to myAddHypList - for ( int i = 1, nb = myHypCombo[ AddHyp ]->count(); i < nb; ++i ) + if ( theIndex > 0 ) { - int curIndex = myHypCombo[ AddHyp ]->itemData( i ).toInt(); - if ( theIndex == curIndex ) + // move a hyp from myHypCombo[ AddHyp ] to myAddHypList + for ( int i = 1, nb = myHypCombo[ AddHyp ]->count(); i < nb; ++i ) { - addItem( myHypCombo[ AddHyp ]->itemText( i ), theId, theIndex ); - myHypCombo[ AddHyp ]->removeItem( i ); - break; + int curIndex = myHypCombo[ AddHyp ]->itemData( i ).toInt(); + if ( theIndex == curIndex ) + { + addItem( myHypCombo[ AddHyp ]->itemText( i ), theId, theIndex ); + myHypCombo[ AddHyp ]->removeItem( i ); + break; + } } } + else + { + myAddHypList->clear(); + } } } @@ -393,15 +415,25 @@ void SMESHGUI_MeshTab::onCreateHyp() { bool isMainHyp = ( sender() == myCreateHypBtn[ MainHyp ]); - QMenu aPopup( this ); + QtxMenu aPopup( this ); QStringList aHypNames = isMainHyp ? myAvailableHypTypes[ MainHyp ] : myAvailableHypTypes[ AddHyp ]; QList actions; for ( int i = 0, n = aHypNames.count(); i < n; i++ ) - actions.append( aPopup.addAction( aHypNames[ i ] ) ); - + { + QAction* a = 0; + if ( aHypNames[ i ].startsWith( "GROUP:" )) + { + aPopup.appendGroupTitle( aHypNames[ i ].mid( 6 )); + } + else + { + a = aPopup.addAction( aHypNames[ i ] ); + } + actions.append( a ); + } QAction* a = aPopup.exec( QCursor::pos() ); if ( a ) emit createHyp( isMainHyp ? MainHyp : AddHyp, actions.indexOf( a ) ); @@ -437,7 +469,18 @@ void SMESHGUI_MeshTab::onEditHyp() //================================================================================ void SMESHGUI_MeshTab::onHyp( int theIndex ) { - const QObject* aSender = sender(); + QObject* aSender = sender(); + + if ( QComboBox* cb = qobject_cast< QComboBox* >( aSender )) + { + // don't allow selecting a group title + if ( cb->itemData( theIndex, Qt::AccessibleDescriptionRole ) == "separator" ) + { + cb->setCurrentIndex( theIndex+1 ); + return; + } + } + if ( aSender == myHypCombo[ Algo ] ) { emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top @@ -617,12 +660,32 @@ SMESHGUI_MeshDlg::SMESHGUI_MeshDlg( const bool theToCreate, const bool theIsMesh objectWg( Mesh, Btn )->hide(); objectWg( Geom, Btn )->hide(); } + setTitile( theToCreate, theIsMesh ); } SMESHGUI_MeshDlg::~SMESHGUI_MeshDlg() { } +//================================================================================ +/*! + * \brief Set dialog title + */ +//================================================================================ + +void SMESHGUI_MeshDlg::setTitile( const bool theToCreate, const bool theIsMesh ) +{ + if ( theToCreate ) + { + setWindowTitle( tr( theIsMesh ? "CREATE_MESH" : "CREATE_SUBMESH" )); + } + else + { + setWindowTitle( tr( theIsMesh ? "EDIT_MESH" : "EDIT_SUBMESH") ); + } + +} + //================================================================================ /*! * \brief Gets tab with given id