diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-02 15:17:13 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-09-02 15:17:13 +0000 |
commit | f2a2e9c00281c9bfe5ff7df31cdc8860129b282c (patch) | |
tree | e45988a790da04e1e72e917d2b0f7935526fe8a2 /libs/pbd | |
parent | 6c2728f9815bcdbf1cbd702f271344e295ddb074 (diff) |
limited history depth (no GUI yet); more work on import dialog and semantics
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2361 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/pbd/undo.h | 10 | ||||
-rw-r--r-- | libs/pbd/undo.cc | 16 |
2 files changed, 23 insertions, 3 deletions
diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index 9539d8b41d..3f4a1c5e9d 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -86,8 +86,8 @@ class UndoHistory : public sigc::trackable unsigned long undo_depth() const { return UndoList.size(); } unsigned long redo_depth() const { return RedoList.size(); } - std::string next_undo() const { return (UndoList.empty() ? std::string("") : UndoList.back()->name()); } - std::string next_redo() const { return (RedoList.empty() ? std::string("") : RedoList.back()->name()); } + std::string next_undo() const { return (UndoList.empty() ? std::string() : UndoList.back()->name()); } + std::string next_redo() const { return (RedoList.empty() ? std::string() : RedoList.back()->name()); } void clear (); void clear_undo (); @@ -96,10 +96,14 @@ class UndoHistory : public sigc::trackable XMLNode &get_state(uint32_t depth = 0); void save_state(); - sigc::signal<void> Changed; + void set_depth (uint32_t); + uint32_t get_depth() const { return _depth; } + sigc::signal<void> Changed; + private: bool _clearing; + uint32_t _depth; std::list<UndoTransaction*> UndoList; std::list<UndoTransaction*> RedoList; diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index 4719d0968e..d54c6b0fff 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -148,12 +148,28 @@ XMLNode &UndoTransaction::get_state() UndoHistory::UndoHistory () { _clearing = false; + _depth = 0; +} + +void +UndoHistory::set_depth (uint32_t d) +{ + _depth = d; + + while (_depth > 0 && UndoList.size() > _depth) { + UndoList.pop_front (); + } } void UndoHistory::add (UndoTransaction* const ut) { ut->GoingAway.connect (bind (mem_fun (*this, &UndoHistory::remove), ut)); + + while (_depth > 0 && UndoList.size() > _depth) { + UndoList.pop_front (); + } + UndoList.push_back (ut); /* we are now owners of the transaction */ |