connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addObjects() ) );
connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeObjects() ) );
+ connect( myGeomObjects, SIGNAL( orderChanged() ), SLOT( onOrderChanged() ) );
+
return aPage;
}
/**
Set rules.
@param theRules the list of rules
-*/
+ */
void HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules ) const
{
myPriorityWidget->setRules( theRules );
+}
+
+/**
+ Slot called when objects order is changed.
+ */
+void HYDROGUI_CalculationDlg::onOrderChanged()
+{
+ myPriorityWidget->setObjects( getGeometryObjects() );
}
\ No newline at end of file
void onAlreadyExists( QString theName );
void refreshZonesBrowser();
void onDataChanged();
+ void onOrderChanged();
+
/**
* Process items selection: hide/show bathymetry merge type selector.
*/
*/
void HYDROGUI_OrderedListWidget::onMove( int theType )
{
+ bool isMoved = false;
+
QSortFilterProxyModel* aFilterModel = dynamic_cast<QSortFilterProxyModel*>( myList->model() );
if( aFilterModel ) {
HYDROGUI_ListModel* aModel = dynamic_cast<HYDROGUI_ListModel*>( aFilterModel->sourceModel() );
aSelectedSourceIndexes << aFilterModel->mapToSource( anIndex );
}
QList<int> aSelectedIds = aModel->getIds( aSelectedSourceIndexes );
- aModel->move( aSelectedIds, ( HYDROGUI_ListModel::OpType )theType,
- !myIsHiddenObjectsShown );
+ isMoved = aModel->move( aSelectedIds, ( HYDROGUI_ListModel::OpType )theType,
+ !myIsHiddenObjectsShown );
}
}
+
+ if ( isMoved ) {
+ emit orderChanged();
+ }
}
/**
signals:
void selectionChanged();
+ void orderChanged();
private slots:
void onMove( int theType );
}
/**
- Set objects which could be used for rules.
- @param theObjects the list of objects
+ Set objects which could be used for rules definition.
+ @param theObjects the ordered list of objects
*/
void HYDROGUI_PriorityTableModel::setObjects( const QList<Handle(HYDROData_Object)>& theObjects )
{
}
}
- // Try to find new pair of objects
+ // Try to find:
+ // 1. the new pair of objects
+ // 2. the priority type corresponding to the objects order
Handle(HYDROData_Object) anObject1, anObject2;
+ HYDROData_PriorityType aPriorityType = GREATER;
int aNbObjects = myObjects.count();
for ( int anIndex1 = 0; anIndex1 < aNbObjects; anIndex1++ ) {
if ( !aRules.contains( QPair<int, int>( anIndex1, anIndex2 ) ) ) {
anObject1 = myObjects.at( anIndex1 );
anObject2 = myObjects.at( anIndex2 );
+ if ( anIndex1 > anIndex2 ) {
+ aPriorityType = LESS;
+ }
isFound = true;
break;
}
HYDROData_CustomRule aNewRule;
aNewRule.Object1 = anObject1;
aNewRule.Object2 = anObject2;
- aNewRule.Priority = LESS;
+ aNewRule.Priority = aPriorityType;
aNewRule.MergeType = HYDROData_Zone::Merge_ZMIN;
beginResetModel();
}
/**
- Set objects.
+ Set objects which could be used for rules definition.
+ @param theObjects the ordered list of objects
*/
void HYDROGUI_PriorityWidget::setObjects( const QList<Handle(HYDROData_Object)>& theObjects )
{