X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_PriorityTableModel.cxx;h=0b008616eb8ae6a49aee0c150043d076ce3f742e;hb=58bb6b7459bebeeb089c9ed486c4683a8bae7288;hp=c284d7927e94e306a413d6a9b216a4003569e272;hpb=69048e668dcd9f681a48054df3b01a84d7ed773e;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx b/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx index c284d792..0b008616 100644 --- a/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx +++ b/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx @@ -18,7 +18,7 @@ #include "HYDROGUI_PriorityTableModel.h" -#include +#include /** Constructor. @@ -119,8 +119,11 @@ bool HYDROGUI_PriorityTableModel::setData( const QModelIndex & theIndex, const Q } bool aRes = false; - + if ( theRole == Qt::EditRole ) { + bool aRuleChanged = false; + myPrevRules = myRules; + int aColumn = theIndex.column(); if ( aColumn == 0 || aColumn == 2 ) { @@ -135,9 +138,16 @@ bool HYDROGUI_PriorityTableModel::setData( const QModelIndex & theIndex, const Q if ( !anObject.IsNull() ) { HYDROData_CustomRule anEditedRule = myRules[aRow]; + QString anEntryNew = HYDROGUI_DataObject::dataObjectEntry( anObject ); if ( aColumn == 0 ) { + QString anEntryOld = HYDROGUI_DataObject::dataObjectEntry( anEditedRule.Object1 ); + if ( anEntryOld != anEntryNew ) + aRuleChanged = true; anEditedRule.Object1 = anObject; } else { + QString anEntryOld = HYDROGUI_DataObject::dataObjectEntry( anEditedRule.Object2 ); + if ( anEntryOld != anEntryNew ) + aRuleChanged = true; anEditedRule.Object2 = anObject; } @@ -145,14 +155,24 @@ bool HYDROGUI_PriorityTableModel::setData( const QModelIndex & theIndex, const Q myRules[aRow] = anEditedRule; aRes = true; } else { + aRuleChanged = false; emit showError( tr("ALREADY_EXISTS") ); } } } else if ( aColumn == 1 ) { - myRules[aRow].Priority = (HYDROData_PriorityType)theValue.toInt(); + HYDROData_PriorityType aNewPriority = (HYDROData_PriorityType)theValue.toInt(); + if ( myRules[aRow].Priority != aNewPriority ) + aRuleChanged = true; + myRules[aRow].Priority = aNewPriority; } else if ( aColumn == 3 ) { - myRules[aRow].MergeType = (HYDROData_Zone::MergeType)theValue.toInt();; + HYDROData_Zone::MergeType aNewMergeType = (HYDROData_Zone::MergeType)theValue.toInt(); + if ( myRules[aRow].MergeType != aNewMergeType ) + aRuleChanged = true; + myRules[aRow].MergeType = aNewMergeType; } + + if ( aRuleChanged ) + emit ruleChanged(); } return aRes; @@ -179,6 +199,7 @@ int HYDROGUI_PriorityTableModel::columnCount( const QModelIndex &theParent ) con void HYDROGUI_PriorityTableModel::setRules( const HYDROData_ListOfRules& theRules ) { beginResetModel(); + myPrevRules = myRules; myRules = theRules; endResetModel(); } @@ -218,7 +239,7 @@ QVariant HYDROGUI_PriorityTableModel::headerData( int theSection, break; case 3: { - if ( getObjectsKind() != KIND_LAND_COVER ) + if ( getObjectsKind() != KIND_LAND_COVER_MAP ) aData = tr( "BATHYMETRY" ); } break; @@ -238,6 +259,8 @@ void HYDROGUI_PriorityTableModel::setObjects( const QList