23352: [CEA] Order and naming of meshing algorithms

- Redesign dialog with use of QtxToolButton instead of QComboBox for better managing groups of algorihtms/hypotheses.
This commit is contained in:
vsr 2017-02-07 13:14:51 +03:00
parent b5e94caaa3
commit e8d46310d3
2 changed files with 11 additions and 12 deletions

View File

@ -31,6 +31,7 @@
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h> #include <SUIT_ResourceMgr.h>
#include <QtxMenu.h> #include <QtxMenu.h>
#include <QtxToolButton.h>
// Qt includes // Qt includes
#include <QComboBox> #include <QComboBox>
@ -74,11 +75,11 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
// Algorifm // Algorifm
QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this ); QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this );
myHypCombo[ Algo ] = new QComboBox( this ); myHypCombo[ Algo ] = new QtxToolButton( this );
// Hypothesis // Hypothesis
QLabel* aHypLbl = new QLabel( tr( "HYPOTHESIS" ), this ); QLabel* aHypLbl = new QLabel( tr( "HYPOTHESIS" ), this );
myHypCombo[ MainHyp ] = new QComboBox( this ); myHypCombo[ MainHyp ] = new QtxToolButton( this );
myHypCombo[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); myHypCombo[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
myCreateHypBtn[ MainHyp ] = new QToolButton( this ); myCreateHypBtn[ MainHyp ] = new QToolButton( this );
myCreateHypBtn[ MainHyp ]->setIcon( aCreateIcon ); myCreateHypBtn[ MainHyp ]->setIcon( aCreateIcon );
@ -91,7 +92,7 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
// Add. hypothesis // Add. hypothesis
QLabel* anAddHypLbl = new QLabel( tr( "ADD_HYPOTHESIS" ), this ); QLabel* anAddHypLbl = new QLabel( tr( "ADD_HYPOTHESIS" ), this );
myHypCombo[ AddHyp ] = new QComboBox( this ); myHypCombo[ AddHyp ] = new QtxToolButton( this );
myHypCombo[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); myHypCombo[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
myCreateHypBtn[ AddHyp ] = new QToolButton( this ); myCreateHypBtn[ AddHyp ] = new QToolButton( this );
myCreateHypBtn[ AddHyp ]->setIcon( aCreateIcon ); myCreateHypBtn[ AddHyp ]->setIcon( aCreateIcon );
@ -126,6 +127,7 @@ SMESHGUI_MeshTab::SMESHGUI_MeshTab( QWidget* theParent )
aLay->addWidget( myMoreAddHypBtn, 4, 2 ); aLay->addWidget( myMoreAddHypBtn, 4, 2 );
aLay->addWidget( myEditHypBtn[ MoreAddHyp ], 4, 3 ); aLay->addWidget( myEditHypBtn[ MoreAddHyp ], 4, 3 );
aLay->addWidget( myLessAddHypBtn, 5, 2 ); aLay->addWidget( myLessAddHypBtn, 5, 2 );
aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ), 6, 0 ); aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ), 6, 0 );
// Connect signals and slots // Connect signals and slots
@ -172,24 +174,21 @@ void SMESHGUI_MeshTab::addItem( const QString& txt,
const int index, const int index,
const bool isGroup ) const bool isGroup )
{ {
const char* prefix = " ";
if ( type <= AddHyp ) if ( type <= AddHyp )
{ {
if ( isGroup ) if ( isGroup )
{ {
int idx = myHypCombo[ type ]->count(); myHypCombo[ type ]->addSeparator( txt.mid( 6 ) );
myHypCombo[ type ]->addItem( txt.mid( 6 ), QVariant( index ));
myHypCombo[ type ]->setItemData( idx, "separator", Qt::AccessibleDescriptionRole );
} }
else else
{ {
myHypCombo[ type ]->addItem( prefix + txt, QVariant( index )); myHypCombo[ type ]->addItem( txt, QVariant( index ));
} }
//myHypCombo[ type ]->setMaxVisibleItems( qMax( 10, myHypCombo[ type ]->count() ) ); //myHypCombo[ type ]->setMaxVisibleItems( qMax( 10, myHypCombo[ type ]->count() ) );
} }
else else
{ {
QListWidgetItem* item = new QListWidgetItem( prefix + txt, myAddHypList ); QListWidgetItem* item = new QListWidgetItem( txt, myAddHypList );
item->setData( Qt::UserRole, QVariant( index )); item->setData( Qt::UserRole, QVariant( index ));
} }
} }
@ -405,7 +404,7 @@ void SMESHGUI_MeshTab::onCreateHyp()
QAction* a = 0; QAction* a = 0;
if ( aHypNames[ i ].startsWith( "GROUP:" )) if ( aHypNames[ i ].startsWith( "GROUP:" ))
{ {
aPopup.appendGroupTitle( aHypNames[ i ].mid( 6 )); aPopup.addGroup( aHypNames[ i ].mid( 6 ));
} }
else else
{ {

View File

@ -44,6 +44,7 @@ class QListWidget;
class QMenu; class QMenu;
class QTabWidget; class QTabWidget;
class QToolButton; class QToolButton;
class QtxToolButton;
/*! /*!
* \brief Dialog for mech creation or editing * \brief Dialog for mech creation or editing
@ -155,14 +156,13 @@ private:
QMap<int, QStringList> myAvailableHypTypes; QMap<int, QStringList> myAvailableHypTypes;
QMap<int, QComboBox*> myHypCombo; QMap<int, QtxToolButton*> myHypCombo;
QMap<int, QToolButton*> myCreateHypBtn; QMap<int, QToolButton*> myCreateHypBtn;
QMap<int, QToolButton*> myEditHypBtn; QMap<int, QToolButton*> myEditHypBtn;
QToolButton* myMoreAddHypBtn; QToolButton* myMoreAddHypBtn;
QToolButton* myLessAddHypBtn; QToolButton* myLessAddHypBtn;
QListWidget* myAddHypList; // 2-nd, etc. additional hyps QListWidget* myAddHypList; // 2-nd, etc. additional hyps
}; };
#endif // SMESHGUI_MESHDLG_H #endif // SMESHGUI_MESHDLG_H