}
/**
- 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<QTreeView*>() ) {
- aView->setDragEnabled ( theIsEnabled );
- }
+ myBrowser->setReadOnly( !theIsEnabled );
}
/**
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;
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 );
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();
}
#include <SUIT_DataOwner.h>
#include <QObject>
+#include <QShortcut>
class SUIT_DataBrowser;
class LightApp_DataObject;
}
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<QTreeView*>() ) {
+ aView->setDragEnabled ( !theIsReadOnly );
+ aView->setEditTriggers ( theIsReadOnly ?
+ QAbstractItemView::NoEditTriggers :
+ QAbstractItemView::DoubleClicked );
+ }
+
+ // Enable/disable rename shortcut
+ QList<QShortcut*> aShortcuts = findChildren<QShortcut*>();
+ QShortcut* aShortcut;
+ foreach( aShortcut, aShortcuts ) {
+ if ( aShortcut->key() == QKeySequence( shortcutKey( RenameShortcut ) ) ) {
+ aShortcut->setEnabled( !theIsReadOnly );
+ }
+ }
+}
\ No newline at end of file
*/
virtual SUIT_DataObject* findObject( const QString& ) const;
+ void setReadOnly( const bool theIsReadOnly );
+
signals:
void dropped( const QList<SUIT_DataObject*>& theList,
SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
HYDROGUI_DataObject* HYDROGUI_DataModel::getDataObject( const Handle(HYDROData_Entity)& theModelObject )
{
- return NULL; // to do if necessary
+ HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>(
+ findObject( HYDROGUI_DataObject::dataObjectEntry( theModelObject ) ) );
+ return aGuiObj;
}
HYDROGUI_DataObject* HYDROGUI_DataModel::getReferencedDataObject( HYDROGUI_DataObject* theObject )