X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_PriorityWidget.cxx;h=2f84a8229570b92dfa9bd6f83734042a80a5db6f;hb=445cca2de7e4814cdc8d6cb7727b5bf2e3170220;hp=f4c9fb7ea9f73e9d8b2095a54039254a79cc336a;hpb=b2b21a9b49f0df8f53c3a1bcb459a4ec081a84ec;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx b/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx index f4c9fb7e..2f84a822 100644 --- a/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx +++ b/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx @@ -154,12 +154,12 @@ HYDROGUI_PriorityWidget::HYDROGUI_PriorityWidget( QWidget* theParent ) // Set resize mode myTable->horizontalHeader()->setStretchLastSection( false); - myTable->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch ); - myTable->horizontalHeader()->setResizeMode( 1, QHeaderView::ResizeToContents ); - myTable->horizontalHeader()->setResizeMode( 2, QHeaderView::Stretch ); - myTable->horizontalHeader()->setResizeMode( 3, QHeaderView::ResizeToContents ); + myTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch ); + myTable->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::ResizeToContents ); + myTable->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::Stretch ); + myTable->horizontalHeader()->setSectionResizeMode( 3, QHeaderView::ResizeToContents ); - myTable->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ); + myTable->verticalHeader()->setSectionResizeMode( QHeaderView::ResizeToContents ); // Layout // buttons @@ -185,6 +185,7 @@ HYDROGUI_PriorityWidget::HYDROGUI_PriorityWidget( QWidget* theParent ) this, SLOT( onSelectionChanged() ) ); connect( aModel, SIGNAL( showError( const QString& ) ), this, SLOT( onShowError( const QString& ) ) ); + connect( aModel, SIGNAL( ruleChanged() ), this, SIGNAL( ruleChanged() ) ); } /** @@ -204,6 +205,7 @@ void HYDROGUI_PriorityWidget::onAddRule() if ( aModel ) { if (aModel->createNewRule()) { updateControls(); + emit ruleChanged(); } } } @@ -219,13 +221,16 @@ void HYDROGUI_PriorityWidget::onRemoveRule() if (aModel) { QList aRows; - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes(); foreach ( const QModelIndex& anIndex, aSelectedIndexes ) { - aRows << anIndex.row(); + int aRowIndex = anIndex.row(); + if ( !aRows.contains( aRowIndex ) ) + aRows << aRowIndex; } if ( aModel->removeRows( aRows ) ) { updateControls(); + emit ruleChanged(); } } } @@ -239,6 +244,7 @@ void HYDROGUI_PriorityWidget::onClearRules() dynamic_cast( myTable->model() ); if ( aModel && aModel->removeAll() ) { updateControls(); + emit ruleChanged(); } } @@ -246,7 +252,7 @@ void HYDROGUI_PriorityWidget::onClearRules() Set objects which could be used for rules definition. @param theObjects the ordered list of objects */ -void HYDROGUI_PriorityWidget::setObjects( const QList& theObjects ) +void HYDROGUI_PriorityWidget::setObjects( const QList& theObjects ) { HYDROGUI_PriorityTableModel* aModel = dynamic_cast( myTable->model() ); @@ -287,12 +293,21 @@ void HYDROGUI_PriorityWidget::setRules( const HYDROData_ListOfRules& theRules ) } } +/** + Get table view. + @return the table view + */ +QTableView* HYDROGUI_PriorityWidget::getTable() const +{ + return myTable; +} + /** Slot called on table selection change. */ void HYDROGUI_PriorityWidget::onSelectionChanged() { - QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedRows(); + QModelIndexList aSelectedIndexes = myTable->selectionModel()->selectedIndexes(); myRemove->setEnabled( aSelectedIndexes.count() > 0 ); } @@ -316,4 +331,15 @@ void HYDROGUI_PriorityWidget::updateControls() */ void HYDROGUI_PriorityWidget::onShowError( const QString& theMsg ) { SUIT_MessageBox::warning( this, tr( "INCORRECT_INPUT" ), theMsg ); -} \ No newline at end of file +} + +/** + Undo last change in priority rules table. + */ +void HYDROGUI_PriorityWidget::undoLastChange() +{ + HYDROGUI_PriorityTableModel* aModel = + dynamic_cast( myTable->model() ); + if ( aModel ) + aModel->undoLastChange(); +}