Reusable widget that shows and allows modify meshing order. More...
#include <SMESHGUI_MeshOrderDlg.h>

Public Member Functions | |
| SMESHGUI_MeshOrderBox (QWidget *) | |
| Public methods. | |
| ~SMESHGUI_MeshOrderBox () | |
| Destructor. | |
| void | Clear () |
| Clear mesh box. | |
| void | SetMeshes (const ListListName &theMeshNames, const ListListId &theMeshIds) |
| Set mesh (submesh) names and indeces. | |
| bool | IsOrderChanged () const |
| returns status is order changed by user | |
| ListListId | GetMeshIds () const |
| Returns result (ordered by user) mesh names. | |
| ListListName | GetMeshNames () const |
| Returns result (ordered by user) mesh indeces. | |
Private Slots | |
| void | onSelectionChanged () |
| Private slots. | |
| void | onMoveItem () |
| move item according to clicked arrow button | |
Private Member Functions | |
| void | moveItem (const bool theIsUp) |
| Privatemethods. | |
Private Attributes | |
| bool | myIsChanged |
| Private fields. | |
| QToolButton * | myUpBtn |
| QToolButton * | myDownBtn |
| QListWidget * | myMeshNames |
Reusable widget that shows and allows modify meshing order.
Definition at line 48 of file SMESHGUI_MeshOrderDlg.h.
| SMESHGUI_MeshOrderBox::SMESHGUI_MeshOrderBox | ( | QWidget * | theParent | ) |
Public methods.
Constructor.
Definition at line 50 of file SMESHGUI_MeshOrderDlg.cxx.
References MARGIN, myDownBtn, myMeshNames, myUpBtn, onMoveItem(), onSelectionChanged(), and SPACING.
: QGroupBox( theParent ), myIsChanged( false ), myUpBtn(0), myDownBtn(0) { QHBoxLayout* hBoxLayout = new QHBoxLayout(this); hBoxLayout->setMargin( MARGIN ); hBoxLayout->setSpacing( SPACING ); myMeshNames = new QListWidget(this); myMeshNames->setSelectionMode(QAbstractItemView::SingleSelection); myMeshNames->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding )); hBoxLayout->addWidget(myMeshNames); QGroupBox* btnGrp = new QGroupBox(this); hBoxLayout->addWidget(btnGrp); myUpBtn = new QToolButton(btnGrp); myDownBtn = new QToolButton(btnGrp); myUpBtn-> setArrowType( Qt::UpArrow ); myDownBtn->setArrowType( Qt::DownArrow ); QVBoxLayout* vBoxLayout = new QVBoxLayout(btnGrp); vBoxLayout->addSpacerItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); vBoxLayout->addWidget( myUpBtn ); vBoxLayout->addWidget( myDownBtn ); vBoxLayout->addSpacerItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); connect( myUpBtn, SIGNAL( clicked() ), this, SLOT( onMoveItem() ) ); connect( myDownBtn, SIGNAL( clicked() ), this, SLOT( onMoveItem() ) ); connect( myMeshNames, SIGNAL( itemSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); onSelectionChanged(); }
| SMESHGUI_MeshOrderBox::~SMESHGUI_MeshOrderBox | ( | ) |
| void SMESHGUI_MeshOrderBox::Clear | ( | ) |
Clear mesh box.
Clear submesh names and indeces.
Definition at line 129 of file SMESHGUI_MeshOrderDlg.cxx.
References myIsChanged, and myMeshNames.
Referenced by SMESHGUI_MeshOrderMgr.GetMeshOrder(), and SetMeshes().
{
myMeshNames->clear();
myIsChanged = false;
}
| ListListId SMESHGUI_MeshOrderBox::GetMeshIds | ( | ) | const |
Returns result (ordered by user) mesh names.
Definition at line 177 of file SMESHGUI_MeshOrderDlg.cxx.
References checkItem(), and myMeshNames.
Referenced by SMESHGUI_MeshOrderMgr.SetMeshOrder().
{
ListListId aLLIds;
aLLIds.append( QList<int>() );
for ( int i = 0, n = myMeshNames->count(); i < n; i++ )
{
QListWidgetItem* it = myMeshNames->item( i );
if (checkItem( it ))
aLLIds.last().append( it->data( Qt::UserRole ).toInt() );
else // separator before next list of mesh items
aLLIds.append( QList<int>() );
}
return aLLIds;
}
| ListListName SMESHGUI_MeshOrderBox::GetMeshNames | ( | ) | const |
Returns result (ordered by user) mesh indeces.
Definition at line 198 of file SMESHGUI_MeshOrderDlg.cxx.
References checkItem(), and myMeshNames.
{
ListListName aLLNames;
aLLNames.append( QStringList() );
for ( int i = 0, n = myMeshNames->count(); i < n; i++ )
{
QListWidgetItem* it = myMeshNames->item( i );
if (checkItem( it ))
aLLNames.last().append( it->text() );
else // separator before next list of mesh items
aLLNames.append( QStringList() );
}
return aLLNames;
}
| bool SMESHGUI_MeshOrderBox::IsOrderChanged | ( | ) | const |
returns status is order changed by user
Definition at line 284 of file SMESHGUI_MeshOrderDlg.cxx.
References myIsChanged.
Referenced by SMESHGUI_MeshOrderMgr.IsOrderChanged().
{
return myIsChanged;
}
| void SMESHGUI_MeshOrderBox::moveItem | ( | const bool | theIsUp | ) | [private] |
Privatemethods.
move mesh in order up or down
Definition at line 255 of file SMESHGUI_MeshOrderDlg.cxx.
References checkItem(), myIsChanged, and myMeshNames.
Referenced by onMoveItem().
{
// move selected list item up or down
QList<QListWidgetItem *> items = myMeshNames->selectedItems();
if ( items.isEmpty() )
return;
QListWidgetItem * selItem = (*(items.begin()));
if (!checkItem(selItem))
return;
int rowId = myMeshNames->row( selItem );
if ( rowId == -1 )
return;
// move item in list widget
myIsChanged = true;
myMeshNames->takeItem( rowId );
myMeshNames->insertItem(theIsUp ? rowId-1 : rowId+1, selItem );
// restore selection and current status
selItem->setSelected( true );
myMeshNames->setCurrentItem( selItem );
}
| void SMESHGUI_MeshOrderBox::onMoveItem | ( | ) | [private, slot] |
move item according to clicked arrow button
Definition at line 244 of file SMESHGUI_MeshOrderDlg.cxx.
References moveItem(), and myUpBtn.
Referenced by SMESHGUI_MeshOrderBox().
| void SMESHGUI_MeshOrderBox::onSelectionChanged | ( | ) | [private, slot] |
Private slots.
update state of arrow buttons according to selection
Definition at line 219 of file SMESHGUI_MeshOrderDlg.cxx.
References checkItem(), myDownBtn, myMeshNames, and myUpBtn.
Referenced by SMESHGUI_MeshOrderBox().
{
bool isUp = false;
bool isDown = false;
QList<QListWidgetItem *> items = myMeshNames->selectedItems();
if ( !items.isEmpty() )
{
QListWidgetItem* selItem = (*(items.begin()));
if (checkItem(selItem))
{
const int rowId = myMeshNames->row( selItem );
isUp = checkItem( myMeshNames->item( rowId - 1 ) );
isDown = checkItem( myMeshNames->item( rowId + 1 ) );
}
}
myUpBtn-> setEnabled( isUp );
myDownBtn->setEnabled( isDown );
}
| void SMESHGUI_MeshOrderBox::SetMeshes | ( | const ListListName & | theMeshNames, |
| const ListListId & | theMeshIds | ||
| ) |
Set mesh (submesh) names and indeces.
Set submesh names and indeces.
Definition at line 141 of file SMESHGUI_MeshOrderDlg.cxx.
References addMeshItem(), addSeparator(), Clear(), SMESH_test.ids, myMeshNames, and SMESH_reg.names.
Referenced by SMESHGUI_MeshOrderMgr.GetMeshOrder().
{
Clear();
ListListName::const_iterator nLIt = theMeshNames.constBegin();
ListListId::const_iterator idLIt = theMeshIds.constBegin();
for ( ; nLIt != theMeshNames.constEnd(); ++nLIt, ++idLIt )
{
const QStringList& names = (*nLIt);
const QList<int>& ids = (*idLIt);
if ( myMeshNames->count() )
addSeparator( myMeshNames );
QStringList::const_iterator nameIt = names.constBegin();
QList<int>::const_iterator idIt = ids.constBegin();
for ( ; nameIt != names.constEnd(); ++nameIt, ++idIt )
addMeshItem( myMeshNames, *nameIt, *idIt );
}
}
QToolButton* SMESHGUI_MeshOrderBox.myDownBtn [private] |
Definition at line 88 of file SMESHGUI_MeshOrderDlg.h.
Referenced by onSelectionChanged(), and SMESHGUI_MeshOrderBox().
bool SMESHGUI_MeshOrderBox.myIsChanged [private] |
Private fields.
Definition at line 86 of file SMESHGUI_MeshOrderDlg.h.
Referenced by Clear(), IsOrderChanged(), and moveItem().
QListWidget* SMESHGUI_MeshOrderBox.myMeshNames [private] |
Definition at line 89 of file SMESHGUI_MeshOrderDlg.h.
Referenced by Clear(), GetMeshIds(), GetMeshNames(), moveItem(), onSelectionChanged(), SetMeshes(), and SMESHGUI_MeshOrderBox().
QToolButton* SMESHGUI_MeshOrderBox.myUpBtn [private] |
Definition at line 87 of file SMESHGUI_MeshOrderDlg.h.
Referenced by onMoveItem(), onSelectionChanged(), and SMESHGUI_MeshOrderBox().