1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

New method: ValueTree::copyPropertiesFrom()

This commit is contained in:
jules 2012-07-12 15:55:34 +01:00
parent df729be74a
commit b6965d2fe5
2 changed files with 24 additions and 0 deletions

View file

@ -219,6 +219,16 @@ public:
}
}
void copyPropertiesFrom (const SharedObject& source, UndoManager* const undoManager)
{
for (int i = properties.size(); --i >= 0;)
if (! source.properties.contains (properties.getName (i)))
removeProperty (properties.getName (i), undoManager);
for (int i = 0; i < source.properties.size(); ++i)
setProperty (source.properties.getName(i), source.properties.getValueAt(i), undoManager);
}
ValueTree getChildWithName (const Identifier& typeToMatch) const
{
for (int i = 0; i < children.size(); ++i)
@ -783,6 +793,14 @@ Identifier ValueTree::getPropertyName (const int index) const
: object->properties.getName (index);
}
void ValueTree::copyPropertiesFrom (const ValueTree& source, UndoManager* const undoManager)
{
if (source.object == nullptr)
removeAllProperties (undoManager);
else if (object != nullptr)
object->copyPropertiesFrom (*(source.object), undoManager);
}
//==============================================================================
class ValueTreePropertyValueSource : public Value::ValueSource,
private ValueTree::Listener

View file

@ -204,6 +204,12 @@ public:
*/
Value getPropertyAsValue (const Identifier& name, UndoManager* undoManager);
/** Overwrites all the properties in this tree with the properties of the source tree.
Any properties that already exist will be updated; and new ones will be added, and
any that are not present in the source tree will be removed.
*/
void copyPropertiesFrom (const ValueTree& source, UndoManager* undoManager);
//==============================================================================
/** Returns the number of child nodes belonging to this one.
@see getChild