goodbye to MementoCommand for playlists

git-svn-id: svn://localhost/ardour2/branches/3.0@6726 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis
2010-03-04 13:15:04 +00:00
parent c2c224727e
commit 6dde6c5a8f
8 changed files with 108 additions and 57 deletions

View File

@@ -35,6 +35,7 @@
#include "pbd/undo.h"
#include "pbd/stateful.h"
#include "pbd/stateful_owner.h"
#include "pbd/statefuldestructible.h"
#include "pbd/sequence_property.h"
@@ -83,6 +84,7 @@ class RegionListProperty : public PBD::SequenceProperty<std::list<boost::shared_
};
class Playlist : public SessionObject
, public PBD::StatefulOwner
, public boost::enable_shared_from_this<Playlist> {
public:
typedef std::list<boost::shared_ptr<Region> > RegionList;
@@ -97,6 +99,8 @@ class Playlist : public SessionObject
bool set_property (const PBD::PropertyBase&);
void update (const RegionListProperty::ChangeRecord&);
void clear_owned_history ();
void rdiff (std::vector<PBD::StatefulDiffCommand*>&) const;
PBD::PropertyList* property_factory (const XMLNode&) const;

View File

@@ -26,9 +26,9 @@
#include <climits>
#include "pbd/failed_constructor.h"
#include "pbd/stateful_diff_command.h"
#include "pbd/stl_delete.h"
#include "pbd/xml++.h"
#include "pbd/stacktrace.h"
#include "ardour/debug.h"
#include "ardour/playlist.h"
@@ -2025,6 +2025,29 @@ Playlist::set_property (const PropertyBase& prop)
return false;
}
void
Playlist::rdiff (vector<StatefulDiffCommand*>& cmds) const
{
RegionLock rlock (const_cast<Playlist *> (this));
for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
if ((*i)->changed ()) {
StatefulDiffCommand* sdc = new StatefulDiffCommand (*i);
cmds.push_back (sdc);
}
}
}
void
Playlist::clear_owned_history ()
{
RegionLock rlock (this);
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
(*i)->clear_history ();
}
}
void
Playlist::update (const RegionListProperty::ChangeRecord& change)
{

View File

@@ -95,6 +95,7 @@ public:
const gchar*property_name () const { return g_quark_to_string (_property_id); }
PropertyID property_id () const { return _property_id; }
bool changed() const { return _have_old; }
bool operator==(PropertyID pid) const {
return _property_id == pid;

View File

@@ -71,6 +71,8 @@ class Stateful {
void clear_history ();
void diff (PropertyList&, PropertyList&) const;
bool changed() const;
/* create a property list from an XMLNode
*/
virtual PropertyList* property_factory(const XMLNode&) const { return 0; }

View File

@@ -287,5 +287,16 @@ Stateful::resume_property_changes ()
send_change (what_changed);
}
bool
Stateful::changed() const
{
for (OwnedPropertyList::const_iterator i = _properties->begin(); i != _properties->end(); ++i) {
if (i->second->changed()) {
return true;
}
}
return false;
}
} // namespace PBD