From: mzn Date: Fri, 24 Oct 2014 11:25:34 +0000 (+0000) Subject: Bug fix. X-Git-Tag: BR_hydro_v_1_0_4~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d69ad8d8963b34cd370d06a183d39cd90c32a9a9;p=modules%2Fhydro.git Bug fix. --- diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx index 08b27e22..2cab4834 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.cxx @@ -681,15 +681,12 @@ void HYDROGUI_CalculationDlg::setMode( int theMode ) } /** - Enable/disable zones drag and drop. - @param theIsEnabled if true - zones drag and drop will be enabled + Enable/disable zones drag'n'drop and renaming. + @param theIsEnabled if true - zones drag'n'drop and renaming will be enabled */ -void HYDROGUI_CalculationDlg::setMoveZonesEnabled( const bool theIsEnabled ) +void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled ) { - //TODO: to be reimplemented - foreach ( QTreeView* aView, myBrowser->findChildren() ) { - aView->setDragEnabled ( theIsEnabled ); - } + myBrowser->setReadOnly( !theIsEnabled ); } /** diff --git a/src/HYDROGUI/HYDROGUI_CalculationDlg.h b/src/HYDROGUI/HYDROGUI_CalculationDlg.h index 59b28e98..f559b07f 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationDlg.h +++ b/src/HYDROGUI/HYDROGUI_CalculationDlg.h @@ -73,7 +73,7 @@ public: void setAvailableGroups( const QStringList& ); - void setMoveZonesEnabled( const bool theIsEnabled ); + void setEditZonesEnabled( const bool theIsEnabled ); HYDROData_ListOfRules getRules() const; void setRules( const HYDROData_ListOfRules& theRules ) const; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index f43261a3..5cac3dc1 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -669,8 +669,8 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) QString aNewCaseName = aPanel->getObjectName(); QString anOldCaseName = myEditedObject->GetName(); - bool anIsToUpdateOb = myIsEdit && anOldCaseName != aNewCaseName; - + bool anIsToUpdateOb = false; + // At first we must to update the case name because of // automatic names generation for regions and zones myEditedObject->SetName( aNewCaseName ); @@ -699,25 +699,32 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) aRule.Object2, aRule.MergeType ); } } - aPanel->setMoveZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL ); + aPanel->setEditZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL ); if ( myEditedObject->IsMustBeUpdated() ) { myShowZones = true; myEditedObject->Update(); - + //aPanel->setEditedObject( myEditedObject ); aPanel->refreshZonesBrowser(); - + + closePreview(); createPreview(); + + anIsToUpdateOb = true; } else { setZonesVisible( true ); } - if ( anIsToUpdateOb ) - module()->getApp()->updateObjectBrowser( false ); + if ( anIsToUpdateOb ) { + SUIT_DataBrowser* anObjBrowser = ((LightApp_Application*)module()->application())->objectBrowser(); + if ( anObjBrowser ) { + anObjBrowser->updateTree( module()->getDataModel()->getDataObject( myEditedObject ), false ); + } + } QApplication::restoreOverrideCursor(); } diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx index d5460b64..86e069df 100644 --- a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx @@ -42,6 +42,7 @@ #include #include +#include class SUIT_DataBrowser; class LightApp_DataObject; @@ -294,3 +295,29 @@ SUIT_DataObject* HYDROGUI_DataBrowser::findObject( const QString& theEntry ) con } return NULL; } + +/*! + \brief Switch read only mode for the Object Browser. + \param theIsReadOnly if true - read only mode will be turned on +*/ +void HYDROGUI_DataBrowser::setReadOnly( const bool theIsReadOnly ) +{ + //TODO: to be reimplemented + + // Enable/disable edit triggers + foreach ( QTreeView* aView, findChildren() ) { + aView->setDragEnabled ( !theIsReadOnly ); + aView->setEditTriggers ( theIsReadOnly ? + QAbstractItemView::NoEditTriggers : + QAbstractItemView::DoubleClicked ); + } + + // Enable/disable rename shortcut + QList aShortcuts = findChildren(); + QShortcut* aShortcut; + foreach( aShortcut, aShortcuts ) { + if ( aShortcut->key() == QKeySequence( shortcutKey( RenameShortcut ) ) ) { + aShortcut->setEnabled( !theIsReadOnly ); + } + } +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.h b/src/HYDROGUI/HYDROGUI_DataBrowser.h index 11856cf6..82620c5b 100644 --- a/src/HYDROGUI/HYDROGUI_DataBrowser.h +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.h @@ -48,6 +48,8 @@ public: */ virtual SUIT_DataObject* findObject( const QString& ) const; + void setReadOnly( const bool theIsReadOnly ); + signals: void dropped( const QList& theList, SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction ); diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 6f1adada..ee3b3fdd 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -453,7 +453,9 @@ void HYDROGUI_DataModel::update( const int theStudyId ) HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Entity)& theModelObject ) { - return NULL; // to do if necessary + HYDROGUI_DataObject* aGuiObj = dynamic_cast( + findObject( HYDROGUI_DataObject::dataObjectEntry( theModelObject ) ) ); + return aGuiObj; } HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject )