QGridLayout* aLayout = new QGridLayout( aPage );
- myBrowser = new HYDROGUI_DataBrowser( module(), 0, aPage );
+ myBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
myBrowser->setAutoOpenLevel( 3 );
aLayout->setMargin( 5 );
aLayout->setSpacing( 5 );
aPage->setLayout( aLayout );
+ connect( myBrowser, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
myEditedObject = theCase;
myValidator->setEditedObject( theCase );
- HYDROGUI_DataObject* anobj = new HYDROGUI_DataObject( 0, NULL, "" );
- myBrowser->setRoot(anobj);
+ // Build the calculation case subtree
+ module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject );
- module()->getDataModel()->buildCaseTree( anobj, myEditedObject );
myBrowser->updateTree();
myBrowser->openLevels();
myBrowser->adjustColumnsWidth();
+ myBrowser->setAutoUpdate( true );
+ myBrowser->setUpdateModified( true );
+
}
HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
void HYDROGUI_CalculationDlg::refreshZonesBrowser()
{
- myBrowser->updateTree();
+ SUIT_DataObject* aRoot = myBrowser->root();
+ module()->getDataModel()->updateObjectTree( myEditedObject );
+ module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
+ myBrowser->updateTree( aRoot );
+}
+
+void HYDROGUI_CalculationDlg::onDataChanged()
+{
+ SUIT_DataObject* aRoot = myBrowser->root();
+ module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
+ myBrowser->updateTree( aRoot );
}
\ No newline at end of file
void onEmptyName();
void onAlreadyExists( QString theName );
void refreshZonesBrowser();
+ void onDataChanged();
/**
* Process items selection: hide/show bathymetry merge type selector.
*/
#include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h>
+#include <SUIT_DataBrowser.h>
#include <QApplication>
+#include <QKeySequence>
+#include <QShortcut>
HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit )
: HYDROGUI_Operation( theModule ),
if ( !aPanel )
return;
+ SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser();
+ QList<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
+ QShortcut* aShortcut;
+ foreach( aShortcut, aShortcuts )
+ {
+ if ( aShortcut->key() ==
+ QKeySequence(((LightApp_Application*)module()->application())->objectBrowser()->shortcutKey(
+ SUIT_DataBrowser::RenameShortcut ) ) )
+ {
+ aShortcut->setEnabled( false );
+ }
+ }
+
+
aPanel->reset();
QStringList aList;
QStringList anEntryList;
// Abort transaction
abortDocOperation();
HYDROGUI_Operation::abortOperation();
+ module()->getApp()->updateObjectBrowser();
}
void HYDROGUI_CalculationOp::commitOperation()
connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onSplitZones() ) );
connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
- connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
+ //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ) );
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
if ( aPanel )
{
- aPanel->setEditedObject(myEditedObject);
+ aPanel->refreshZonesBrowser();
}
createPreview();
}
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
if ( aPanel )
{
- aPanel->setEditedObject(myEditedObject);
+ aPanel->refreshZonesBrowser();
}
createPreview();
}
myShowZones = true;
myEditedObject->Update();
- aPanel->setEditedObject( myEditedObject );
+ //aPanel->setEditedObject( myEditedObject );
+ aPanel->refreshZonesBrowser();
createPreview();
}
void HYDROGUI_CalculationOp::closePreview()
{
+ SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser();
+ QList<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
+ QShortcut* aShortcut;
+ foreach( aShortcut, aShortcuts )
+ {
+ if ( aShortcut->key() ==
+ QKeySequence( ((LightApp_Application*)module()->application())->objectBrowser()->shortcutKey(
+ SUIT_DataBrowser::RenameShortcut ) ) )
+ {
+ aShortcut->setEnabled( true );
+ }
+ }
+
+
if( myPreviewViewManager )
{
disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
void setZonesVisible( bool theIsVisible );
void getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
QStringList& theNames, QStringList& theEntries ) const;
+
/**
* Ask user to confirm splitting zones recalculation.
* \return true if confirmed
{
SUIT_ResourceMgr* resMgr = theModule->getApp()->resourceMgr();
+ if ( ( !theRoot ) && theModule )
+ {
+ // Initialize the root with the module data model
+ setRoot( new CAM_ModuleObject( theModule->dataModel(), NULL ) );
+ }
+
setSortMenuEnabled( true );
setAutoUpdate( true );
+ setUpdateModified( true );
if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
QString RefObjCol = tr( "REF_OBJECT_COLUMN" );
QString BathymetryCol = tr( "BATHYMETRY_COLUMN" );
+
SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( model() );
//RKV: treeModel->setSearcher( theModule->getApp() );
treeModel->setSearcher( this ); //RKV
connect( proxyModel,
SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
+
+ //// Connect signal emitted after editing for updating after objects renaming
+ SUIT_TreeModel* aMiniModel = dynamic_cast<SUIT_TreeModel*>( proxyModel->sourceModel() );
+ if ( aMiniModel )
+ {
+ connect( aMiniModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ),
+ SIGNAL( dataChanged() ) );
+ }
+
+ // Do updating also in the module's main object browser.
+ if ( theModule )
+ {
+ SUIT_DataBrowser* aModulBrowser = theModule->getApp()->objectBrowser();
+ if ( aModulBrowser )
+ {
+ SUIT_ProxyModel* aPModel = dynamic_cast<SUIT_ProxyModel*>(aModulBrowser->model());
+ if ( aPModel )
+ {
+ SUIT_TreeModel* aModel = dynamic_cast<SUIT_TreeModel*>(aPModel->sourceModel());
+ //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ),
+ // aPModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) );
+ //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ),
+ // aModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) );
+ connect( proxyModel, SIGNAL( modelUpdated() ), aModel, SIGNAL( modelUpdated() ) );
+ }
+ }
+ }
}
// temporary commented
signals:
void dropped( const QList<SUIT_DataObject*>& theList,
SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
+ void dataChanged();
private:
HYDROGUI_Module* myModule;
LightApp_DataObject* HYDROGUI_DataModel::buildObject( SUIT_DataObject* theParent,
HYDROGUI_DataObject* theObject,
const QString& theParentEntry,
- const bool theIsBuildTree )
+ const bool theIsBuildTree,
+ const bool theIsInOperation )
{
if ( theIsBuildTree )
{
- buildObjectTree( theParent, theObject, theParentEntry );
+ buildObjectTree( theParent, theObject, theParentEntry, theIsInOperation );
}
return theObject;
}
LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject* theParent,
Handle(HYDROData_Zone) theModelObject,
const QString& theParentEntry,
- const bool theIsBuildTree )
+ const bool theIsBuildTree,
+ const bool theIsInOperation )
{
- return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+ return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation ),
+ theParentEntry, theIsBuildTree, theIsInOperation );
}
LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject* theParent,
Handle(HYDROData_Region) theModelObject,
const QString& theParentEntry,
- const bool theIsBuildTree )
+ const bool theIsBuildTree,
+ const bool theIsInOperation )
{
- return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry ), theParentEntry, theIsBuildTree );
+ return buildObject( theParent, new HYDROGUI_Region( theParent, theModelObject, theParentEntry, theIsInOperation ),
+ theParentEntry, theIsBuildTree, theIsInOperation );
}
LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* theParent,
void HYDROGUI_DataModel::buildObjectTree( SUIT_DataObject* theParent,
SUIT_DataObject* theObject,
- const QString& theParentEntry )
+ const QString& theParentEntry,
+ const bool theIsInOperation )
{
HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>( theObject );
if ( !aGuiObj )
Handle(HYDROData_Region) aCaseRegion =
Handle(HYDROData_Region)::DownCast( anIter.Value() );
if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
- createRegion( aCaseRegionsSect, aCaseRegion, "", true );
+ createRegion( aCaseRegionsSect, aCaseRegion, "", true, theIsInOperation );
}
}
else if ( anObjectKind == KIND_REGION )
Handle(HYDROData_Zone) aRegionZone =
Handle(HYDROData_Zone)::DownCast( anIter.Value() );
if( !aRegionZone.IsNull() && !aRegionZone->IsRemoved() )
- createZone( aGuiObj, aRegionZone, "", true );
+ createZone( aGuiObj, aRegionZone, "", true, theIsInOperation );
}
}
else if ( anObjectKind == KIND_PROFILE )
{
if ( !theCase.IsNull() )
{
- new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "" );
+ if ( theParent )
+ {
+ // Remove previous objects tree
+ DataObjectList aList;
+ theParent->children( aList );
+ QListIterator<SUIT_DataObject*> anIter( aList );
+ while( anIter.hasNext() )
+ removeChild( theParent, anIter.next() );
+ }
+
+ new HYDROGUI_DropTargetObject( theParent, tr( "NEW_REGION" ), "", true );
HYDROData_SequenceOfObjects aCaseRegions = theCase->GetRegions();
HYDROData_SequenceOfObjects::Iterator anIter( aCaseRegions );
Handle(HYDROData_Region) aCaseRegion =
Handle(HYDROData_Region)::DownCast( anIter.Value() );
if( !aCaseRegion.IsNull() && !aCaseRegion->IsRemoved() )
- createRegion( theParent, aCaseRegion, "", true );
+ createRegion( theParent, aCaseRegion, "", true, true );
+ }
+ }
+}
+
+void HYDROGUI_DataModel::updateObjectTree( Handle(HYDROData_Entity)& theObj )
+{
+ if ( !theObj.IsNull() )
+ {
+ HYDROGUI_DataObject* aGuiObj = dynamic_cast<HYDROGUI_DataObject*>(
+ findObject( HYDROGUI_DataObject::dataObjectEntry( theObj ) ) );
+ if ( aGuiObj )
+ {
+ // Remove previous objects tree
+ DataObjectList aList;
+ aGuiObj->children( aList );
+ QListIterator<SUIT_DataObject*> anIter( aList );
+ while( anIter.hasNext() )
+ removeChild( aGuiObj, anIter.next() );
+
+ // Rebuild the subtree
+ QString aParentEntry;
+ HYDROGUI_DataObject* aParent = dynamic_cast<HYDROGUI_DataObject*>( aGuiObj->parent() );
+ if ( aParent )
+ {
+ aParentEntry = aParent->entry();
+ }
+ buildObjectTree( aParent, aGuiObj, aParentEntry, aGuiObj->isInOperation() );
+ }
+ else
+ {
+ // workaround for the bug in SalomeApp_Study::findObjectByEntry - it can't find LightApp_DataObjects
+ HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
+ if( aModule )
+ {
+ aModule->getApp()->updateObjectBrowser();
+ }
}
}
}
bool rename( Handle(HYDROData_Entity) theEntity, const QString& theName );
/**
- * Creates the GUI data object according to the model object.
- * \param theParent a created object will be appended as a child of this object
- * \param theModelObject model object
- * \param theParentEntry entry of parent object
+ * Creates the Calculation Case subtree for usage within an operation dialog.
+ * \param theParent a created object will be appended as a child of this GUI object
+ * \param theCase the calculation case model object
*/
void buildCaseTree( SUIT_DataObject* theParent,
Handle(HYDROData_CalculationCase) theCase );
+ /**
+ * Updates the object subtree.
+ * \param theObj the data model entity
+ */
+ void updateObjectTree( Handle(HYDROData_Entity)& theObj );
+
/**
* Update the sequence of the objects to be copied
*/
* \param theObject the GUI object
* \param theParentEntry the entry of parent object
* \param theIsBuildTree if true then build the subtree of the GUI object
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
*/
LightApp_DataObject* buildObject( SUIT_DataObject* theParent,
HYDROGUI_DataObject* theObject,
const QString& theParentEntry,
- const bool theIsBuildTree );
+ const bool theIsBuildTree,
+ const bool theIsInOperation = false );
+ /**
+ * Build object tree if the flag theIsBuildTree is true.
+ * \param theParent a created object will be appended as a child of this GUI object
+ * \param theModelObject the data model zone object
+ * \param theParentEntry the entry of parent object
+ * \param theIsBuildTree if true then build the subtree of the GUI object
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
+ */
LightApp_DataObject* createZone( SUIT_DataObject* theParent,
Handle(HYDROData_Zone) theModelObject,
const QString& theParentEntry,
- const bool theIsBuildTree );
+ const bool theIsBuildTree ,
+ const bool theIsInOperation = false );
+ /**
+ * Build object tree if the flag theIsBuildTree is true.
+ * \param theParent a created object will be appended as a child of this GUI object
+ * \param theModelObject the data model region object
+ * \param theParentEntry the entry of parent object
+ * \param theIsBuildTree if true then build the subtree of the GUI object
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
+ */
LightApp_DataObject* createRegion( SUIT_DataObject* theParent,
Handle(HYDROData_Region) theModelObject,
const QString& theParentEntry,
- const bool theIsBuildTree );
+ const bool theIsBuildTree ,
+ const bool theIsInOperation = false );
/**
- * Build tree of model object.
+ * Build tree of a model object.
* \param theParent a created object will be appended as a child of this object
* \param theObject gui object for which the tree will be build
* \param theParentEntry entry of parent object
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
*/
void buildObjectTree( SUIT_DataObject* theParent,
SUIT_DataObject* theObject,
- const QString& theParentEntry = QString() );
+ const QString& theParentEntry = QString(),
+ const bool theIsInOperation = false );
/**
* Removes data object from the tree.
#include <SUIT_DataObject.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_Operation.h>
+#include <CAM_Module.h>
+#include <CAM_Application.h>
+#include <SUIT_Study.h>
#include <QPixmap>
HYDROGUI_DataObject::HYDROGUI_DataObject( SUIT_DataObject* theParent,
Handle(HYDROData_Entity) theData,
- const QString& theParentEntry )
+ const QString& theParentEntry,
+ const bool theIsInOperation )
: CAM_DataObject( theParent ),
LightApp_DataObject( theParent ),
myData( theData ),
myParentEntry( theParentEntry ),
- myIsValid( true )
+ myIsValid( true ),
+ myIsInOperation( theIsInOperation )
{
}
return myIsValid;
}
+bool HYDROGUI_DataObject::renameAllowed( const int theColumnId ) const
+{
+ bool aRes = false;
+ if ( theColumnId == NameId && module())
+ {
+ SUIT_Operation* anOp = module()->application()->activeStudy()->activeOperation();
+ if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
+ {
+ aRes = isInOperation();
+ }
+ else
+ {
+ aRes = !anOp;
+ }
+ }
+ else
+ {
+ aRes = LightApp_DataObject::renameAllowed( theColumnId );
+ }
+ return aRes;
+}
+
+
+
HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent,
const QString& theName,
- const QString& theParentEntry )
+ const QString& theParentEntry,
+ const bool theIsInOperation )
: CAM_DataObject( theParent ),
LightApp_DataObject( theParent ),
myName( theName ),
- myParentEntry( theParentEntry )
+ myParentEntry( theParentEntry ),
+ myIsInOperation( theIsInOperation )
{
}
HYDROGUI_DropTargetObject::HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
const QString& theName,
- const QString& theParentEntry )
-: HYDROGUI_NamedObject( theParent, theName, theParentEntry ), CAM_DataObject( theParent )
+ const QString& theParentEntry,
+ const bool theIsInOperation )
+: HYDROGUI_NamedObject( theParent, theName, theParentEntry, theIsInOperation ),
+ CAM_DataObject( theParent )
{
}
BathymetryId //!< Bathymetry column
};
+ //! Role
+ enum {
+ IsInOperationRole = Qtx::AppropriateRole + 100 //!< Filter value role
+ };
+
/**
* Constructor.
* \param theParent parent data object
* \param theData reference to the corresponding object from data structure
* \param theParentEntry entry of the parent data object (for reference objects)
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
*/
- HYDROGUI_DataObject( SUIT_DataObject* theParent,
+ HYDROGUI_DataObject( SUIT_DataObject* theParent,
Handle(HYDROData_Entity) theData,
- const QString& theParentEntry );
+ const QString& theParentEntry,
+ const bool theIsInOperation = false );
/**
* Returns the unique object identifier string.
*/
virtual QPixmap icon( const int = NameId ) const;
+ /**
+ * Returns true if renaming is allowed for the object.
+ */
+ virtual bool renameAllowed( const int = NameId ) const;
+
/**
* Returns the model data object.
*/
/**
* Returns the validity flag: is object valid or not
- * \returns false if object is not valid
+ * \return false if object is not valid
*/
bool isValid() const;
+ /**
+ * Returns the usage within active operation flag:
+ * is the object is used in the local tree of an active operation dialog or not.
+ * \return false if the object is used in the main object browser tree
+ */
+ bool isInOperation() const { return myIsInOperation; }
+
protected:
Handle(HYDROData_Entity) myData; ///< object from data model
QString myParentEntry;
bool myIsValid; ///< indicates if the object is valid
+ bool myIsInOperation; ///< indicates if the object is used within an active operation
QPixmap myIcon;
};
* Constructor.
* \param theParent parent data object
* \param theName displayed name
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
*/
HYDROGUI_NamedObject( SUIT_DataObject* theParent,
- const QString& theName,
- const QString& theParentEntry );
+ const QString& theName,
+ const QString& theParentEntry,
+ const bool theIsInOperation = false );
/**
* Returns the unique object identifier string.
*/
virtual QPixmap icon( const int = NameId ) const;
+ /**
+ * Returns the usage within active operation flag:
+ * is the object is used in the local tree of an active operation dialog or not.
+ * \return false if the object is used in the main object browser tree
+ */
+ bool isInOperation() const { return myIsInOperation; }
+
private:
QString myName; ///< name in the OB
QString myParentEntry;
QPixmap myIcon;
+ bool myIsInOperation; ///< indicates if the object is used within an active operation
};
/**
* Constructor.
* \param theParent parent data object
* \param theName displayed name
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
*/
HYDROGUI_DropTargetObject( SUIT_DataObject* theParent,
- const QString& theName,
- const QString& theParentEntry );
+ const QString& theName,
+ const QString& theParentEntry,
+ const bool theIsInOperation = false );
bool isDropAccepted() const { return true; }
};
bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
{
Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
- bool aRes = !anEntity.IsNull();
- if ( aRes )
+ bool aRes = false;
+ if ( !anEntity.IsNull() )
{
HYDROGUI_DataModel* aModel = getDataModel();
if( aModel )
{
// check that there are no other objects with the same name in the document
Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
- aRes = anObject.IsNull();
- if ( aRes )
+ if ( anObject.IsNull() )
{
- aRes = aModel->rename( anEntity, theName );
+ SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
+ if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
+ {
+ anEntity->SetName( theName );
+ aRes = true;
+ }
+ else
+ {
+ aRes = aModel->rename( anEntity, theName );
+ }
}
else
{
HYDROGUI_Region::HYDROGUI_Region( SUIT_DataObject* theParent,
Handle(HYDROData_Region) theData,
- const QString& theParentEntry )
-: HYDROGUI_DataObject( theParent, theData, theParentEntry ), CAM_DataObject( theParent )
+ const QString& theParentEntry,
+ const bool theIsInOperation )
+: HYDROGUI_DataObject( theParent, theData, theParentEntry, theIsInOperation ), CAM_DataObject( theParent )
{
}
* \param theParent parent data object
* \param theData reference to the corresponding object from data structure
* \param theParentEntry entry of the parent data object (for reference objects)
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
*/
- HYDROGUI_Region( SUIT_DataObject* theParent,
+ HYDROGUI_Region( SUIT_DataObject* theParent,
Handle(HYDROData_Region) theData,
- const QString& theParentEntry );
+ const QString& theParentEntry,
+ const bool theIsInOperation = false );
bool isDropAccepted() const { return true; }
HYDROGUI_Zone::HYDROGUI_Zone( SUIT_DataObject* theParent,
Handle(HYDROData_Zone) theData,
- const QString& theParentEntry )
-: HYDROGUI_DataObject( theParent, theData, theParentEntry ), CAM_DataObject( theParent )
+ const QString& theParentEntry,
+ const bool theIsInOperation )
+: HYDROGUI_DataObject( theParent, theData, theParentEntry, theIsInOperation ), CAM_DataObject( theParent )
{
}
}
}
}
+
+/*!
+ \brief Check if this object is can't be renamed in place
+
+ \param id column id
+ \return \c true if the item can be renamed by the user in place (e.g. in the Object browser)
+*/
+bool HYDROGUI_Zone::renameAllowed( const int id ) const
+{
+ if ( id == NameId && isInOperation() )
+ {
+ return true;
+ }
+ return HYDROGUI_DataObject::renameAllowed( id );
+}
+
+///*!
+// \brief Set name of this object.
+//
+// \return \c true if rename operation finished successfully, \c false otherwise.
+//*/
+//bool HYDROGUI_Zone::setName(const QString& theName)
+//{
+// if ( isInOperation() )
+// {
+// bool aRes = false;
+// if ( !theName.isEmpty() )
+// {
+// Handle(HYDROData_Entity) anEntity = modelObject();
+// CAM_Module* aModule = module();
+// if( anEntity->GetName() != theName && aModule )
+// {
+// // check that there are no other objects with the same name in the document
+// Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( aModule, theName );
+// if ( anObject.IsNull() )
+// {
+// anEntity->SetName( theName );
+// aRes = true;
+// }
+// else
+// {
+// // Inform the user that the name is already used
+// QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
+// QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
+// SUIT_MessageBox::critical( getApp()->desktop(), aTitle, aMessage );
+// }
+// }
+// }
+// }
+// else
+// {
+// aRes = HYDROGUI_DataObject::setName( theName );
+// }
+// return aRes;
+//}
* \param theParent parent data object
* \param theData reference to the corresponding object from data structure
* \param theParentEntry entry of the parent data object (for reference objects)
+ * \param theIsInOperation if true then the tree is used for a browser within an operation, it is false by default
*/
- HYDROGUI_Zone( SUIT_DataObject* theParent,
- Handle(HYDROData_Zone) theData,
- const QString& theParentEntry );
+ HYDROGUI_Zone( SUIT_DataObject* theParent,
+ Handle(HYDROData_Zone) theData,
+ const QString& theParentEntry,
+ const bool theIsInOperation = false );
/**
* Returns the text for the specified column.
*/
bool isDraggable() const { return true; }
+ bool renameAllowed( const int = NameId ) const;
+ //bool setName( const QString& );
+
/**
* Returns true if it is a zone which needs merge of bathymetries.
*/