Salome HOME
projects
/
modules
/
hydro.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial merge of branch 'BR_HYDRO_IMPS_2016' into BR_PORTING_OCCT_7
[modules/hydro.git]
/
src
/
HYDROGUI
/
HYDROGUI_PriorityTableModel.cxx
diff --git
a/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx
b/src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx
index c284d7927e94e306a413d6a9b216a4003569e272..0b008616eb8ae6a49aee0c150043d076ce3f742e 100644
(file)
--- a/
src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx
+++ b/
src/HYDROGUI/HYDROGUI_PriorityTableModel.cxx
@@
-18,7
+18,7
@@
#include "HYDROGUI_PriorityTableModel.h"
#include "HYDROGUI_PriorityTableModel.h"
-#include <HYDRO
Data_LandCover
.h>
+#include <HYDRO
GUI_DataObject
.h>
/**
Constructor.
/**
Constructor.
@@
-119,8
+119,11
@@
bool HYDROGUI_PriorityTableModel::setData( const QModelIndex & theIndex, const Q
}
bool aRes = false;
}
bool aRes = false;
-
+
if ( theRole == Qt::EditRole ) {
if ( theRole == Qt::EditRole ) {
+ bool aRuleChanged = false;
+ myPrevRules = myRules;
+
int aColumn = theIndex.column();
if ( aColumn == 0 || aColumn == 2 ) {
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];
if ( !anObject.IsNull() ) {
HYDROData_CustomRule anEditedRule = myRules[aRow];
+ QString anEntryNew = HYDROGUI_DataObject::dataObjectEntry( anObject );
if ( aColumn == 0 ) {
if ( aColumn == 0 ) {
+ QString anEntryOld = HYDROGUI_DataObject::dataObjectEntry( anEditedRule.Object1 );
+ if ( anEntryOld != anEntryNew )
+ aRuleChanged = true;
anEditedRule.Object1 = anObject;
} else {
anEditedRule.Object1 = anObject;
} else {
+ QString anEntryOld = HYDROGUI_DataObject::dataObjectEntry( anEditedRule.Object2 );
+ if ( anEntryOld != anEntryNew )
+ aRuleChanged = true;
anEditedRule.Object2 = anObject;
}
anEditedRule.Object2 = anObject;
}
@@
-145,14
+155,24
@@
bool HYDROGUI_PriorityTableModel::setData( const QModelIndex & theIndex, const Q
myRules[aRow] = anEditedRule;
aRes = true;
} else {
myRules[aRow] = anEditedRule;
aRes = true;
} else {
+ aRuleChanged = false;
emit showError( tr("ALREADY_EXISTS") );
}
}
} else if ( aColumn == 1 ) {
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 ) {
} 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;
}
return aRes;
@@
-179,6
+199,7
@@
int HYDROGUI_PriorityTableModel::columnCount( const QModelIndex &theParent ) con
void HYDROGUI_PriorityTableModel::setRules( const HYDROData_ListOfRules& theRules )
{
beginResetModel();
void HYDROGUI_PriorityTableModel::setRules( const HYDROData_ListOfRules& theRules )
{
beginResetModel();
+ myPrevRules = myRules;
myRules = theRules;
endResetModel();
}
myRules = theRules;
endResetModel();
}
@@
-218,7
+239,7
@@
QVariant HYDROGUI_PriorityTableModel::headerData( int theSection,
break;
case 3:
{
break;
case 3:
{
- if ( getObjectsKind() != KIND_LAND_COVER )
+ if ( getObjectsKind() != KIND_LAND_COVER
_MAP
)
aData = tr( "BATHYMETRY" );
}
break;
aData = tr( "BATHYMETRY" );
}
break;
@@
-238,6
+259,8
@@
void HYDROGUI_PriorityTableModel::setObjects( const QList<Handle(HYDROData_Entit
{
myObjects = theObjects;
{
myObjects = theObjects;
+ myPrevRules = myRules;
+
beginResetModel();
// Remove rules which use objects which are no longer available
beginResetModel();
// Remove rules which use objects which are no longer available
@@
-317,6
+340,8
@@
bool HYDROGUI_PriorityTableModel::createNewRule()
aNewRule.Priority = aPriorityType;
aNewRule.MergeType = HYDROData_Zone::Merge_ZMIN;
aNewRule.Priority = aPriorityType;
aNewRule.MergeType = HYDROData_Zone::Merge_ZMIN;
+ myPrevRules = myRules;
+
beginResetModel();
myRules << aNewRule;
endResetModel();
beginResetModel();
myRules << aNewRule;
endResetModel();
@@
-351,6
+376,8
@@
bool HYDROGUI_PriorityTableModel::removeRows ( int theRow, int theCount, const Q
aLastRow = myRules.count() - 1;
}
aLastRow = myRules.count() - 1;
}
+ myPrevRules = myRules;
+
beginRemoveRows( theParent, theRow, aLastRow );
// Remove the corresponding rules
beginRemoveRows( theParent, theRow, aLastRow );
// Remove the corresponding rules
@@
-495,6
+522,16
@@
void HYDROGUI_PriorityTableModel::setColumnCount( int theColumnCount )
myColumnCount = theColumnCount;
}
myColumnCount = theColumnCount;
}
+/**
+ Undo last change in the list of priority rules.
+ */
+void HYDROGUI_PriorityTableModel::undoLastChange()
+{
+ beginResetModel();
+ myRules = myPrevRules;
+ endResetModel();
+}
+
/**
Get type of objects for which rules are defined assuming,
that all objects in the list have the same type.
/**
Get type of objects for which rules are defined assuming,
that all objects in the list have the same type.