X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_PriorityWidget.cxx;h=2f84a8229570b92dfa9bd6f83734042a80a5db6f;hb=6ba63abdcb5832a1773cb33cf67d6b34aee4139d;hp=1545f6673c9b16355f2f9705b7c669292ac93e73;hpb=9d657ba909dc1123967fae5790115866b406197c;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx b/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx index 1545f667..2f84a822 100644 --- a/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx +++ b/src/HYDROGUI/HYDROGUI_PriorityWidget.cxx @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 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 -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -158,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 @@ -189,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() ) ); } /** @@ -208,6 +205,7 @@ void HYDROGUI_PriorityWidget::onAddRule() if ( aModel ) { if (aModel->createNewRule()) { updateControls(); + emit ruleChanged(); } } } @@ -223,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(); } } } @@ -243,6 +244,7 @@ void HYDROGUI_PriorityWidget::onClearRules() dynamic_cast( myTable->model() ); if ( aModel && aModel->removeAll() ) { updateControls(); + emit ruleChanged(); } } @@ -250,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() ); @@ -291,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 ); } @@ -320,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(); +}