the mega-properties/SequenceProperty patch. split is broken at present (right hand starts has start-in-source of zero)

git-svn-id: svn://localhost/ardour2/branches/3.0@6718 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-03-02 00:00:00 +00:00
parent 3540594dc5
commit db8b575c30
48 changed files with 1552 additions and 484 deletions

View file

@ -17,7 +17,10 @@
*/
#include <iostream>
#include "pbd/stateful_diff_command.h"
#include "pbd/property_list.h"
#include "i18n.h"
using namespace std;
@ -30,24 +33,35 @@ using namespace PBD;
StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<Stateful> s)
: _object (s)
, _before (new PropertyList)
, _after (new PropertyList)
{
pair<XMLNode *, XMLNode*> const p = s->diff ();
_before = p.first;
_after = p.second;
s->diff (*_before, *_after);
}
StatefulDiffCommand::StatefulDiffCommand (boost::shared_ptr<Stateful> s, XMLNode const & n)
: _object (s)
, _before (0)
, _after (0)
{
_before = new XMLNode (*n.children().front());
_after = new XMLNode (*n.children().back());
}
const XMLNodeList& children (n.children());
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
if ((*i)->name() == X_("Undo")) {
_before = s->property_factory (**i);
} else if ((*i)->name() == X_("Do")) {
_after = s->property_factory (**i);
}
}
assert (_before != 0);
assert (_after != 0);
}
StatefulDiffCommand::~StatefulDiffCommand ()
{
delete _before;
delete _after;
delete _before;
delete _after;
}
void
@ -56,7 +70,10 @@ StatefulDiffCommand::operator() ()
boost::shared_ptr<Stateful> s (_object.lock());
if (s) {
s->set_state (*_after, Stateful::current_state_version);
PropertyChange changed = s->set_properties (*_after);
if (!changed.empty()) {
s->PropertyChanged (changed);
}
}
}
@ -66,7 +83,12 @@ StatefulDiffCommand::undo ()
boost::shared_ptr<Stateful> s (_object.lock());
if (s) {
s->set_state (*_before, Stateful::current_state_version);
std::cerr << "Undoing a stateful diff command\n";
PropertyChange changed = s->set_properties (*_before);
if (!changed.empty()) {
std::cerr << "Sending changed\n";
s->PropertyChanged (changed);
}
}
}
@ -84,8 +106,15 @@ StatefulDiffCommand::get_state ()
node->add_property ("obj-id", s->id().to_s());
node->add_property ("type-name", typeid(*s.get()).name());
node->add_child_copy (*_before);
node->add_child_copy (*_after);
XMLNode* before = new XMLNode (X_("Undo"));
XMLNode* after = new XMLNode (X_("Do"));
_before->add_history_state (before);
_after->add_history_state (after);
node->add_child_nocopy (*before);
node->add_child_nocopy (*after);
return *node;
}