Gui: [skip ci] implement function to rename parameter group
This commit is contained in:
@@ -882,7 +882,7 @@ void ParameterGrp::RemoveGrp(const char* Name)
|
||||
|
||||
// if this or any of its children is referenced by an observer
|
||||
// it cannot be deleted
|
||||
#if 0
|
||||
#if 1
|
||||
if (!it->second->ShouldRemove()) {
|
||||
it->second->Clear();
|
||||
}
|
||||
@@ -899,7 +899,7 @@ void ParameterGrp::RemoveGrp(const char* Name)
|
||||
|
||||
DOMNode* node = _pGroupNode->removeChild(pcElem);
|
||||
node->release();
|
||||
#if 0
|
||||
#if 1
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -907,6 +907,28 @@ void ParameterGrp::RemoveGrp(const char* Name)
|
||||
Notify(Name);
|
||||
}
|
||||
|
||||
bool ParameterGrp::RenameGrp(const char* OldName, const char* NewName)
|
||||
{
|
||||
auto it = _GroupMap.find(OldName);
|
||||
if (it == _GroupMap.end())
|
||||
return false;
|
||||
auto jt = _GroupMap.find(NewName);
|
||||
if (jt != _GroupMap.end())
|
||||
return false;
|
||||
|
||||
// rename group handle
|
||||
_GroupMap[NewName] = _GroupMap[OldName];
|
||||
_GroupMap.erase(OldName);
|
||||
_GroupMap[NewName]->_cName = NewName;
|
||||
|
||||
// check if Element in group
|
||||
DOMElement *pcElem = FindElement(_pGroupNode, "FCParamGroup", OldName);
|
||||
if (pcElem)
|
||||
pcElem-> setAttribute(XStr("Name").unicodeForm(), XStr(NewName).unicodeForm());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParameterGrp::Clear(void)
|
||||
{
|
||||
std::vector<DOMNode*> vecNodes;
|
||||
|
||||
@@ -132,6 +132,8 @@ public:
|
||||
typedef Base::Reference<ParameterGrp> handle;
|
||||
/// remove a sub group from this group
|
||||
void RemoveGrp(const char* Name);
|
||||
/// rename a sub group from this group
|
||||
bool RenameGrp(const char* OldName, const char* NewName);
|
||||
/// clears everything in this group (all types)
|
||||
void Clear(void);
|
||||
//@}
|
||||
|
||||
@@ -984,10 +984,8 @@ void ParameterGroupItem::setData ( int column, int role, const QVariant & value
|
||||
else
|
||||
{
|
||||
// rename the group by adding a new group, copy the content and remove the old group
|
||||
Base::Reference<ParameterGrp> hOldGrp = item->_hcGrp->GetGroup( oldName.toLatin1() );
|
||||
Base::Reference<ParameterGrp> hNewGrp = item->_hcGrp->GetGroup( newName.toLatin1() );
|
||||
hOldGrp->copyTo( hNewGrp );
|
||||
item->_hcGrp->RemoveGrp( oldName.toLatin1() );
|
||||
if (!item->_hcGrp->RenameGrp(oldName.toLatin1(), newName.toLatin1()))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user