summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-06-26 17:43:38 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-06-26 17:43:38 +0000
commit81ce04522899de9d81eba8a0f0420f8b84373425 (patch)
tree466c23569be45d09d2df450bdac4ab196efafb92 /libs
parent11878127f882b154aa726163f52c1de5dcbbc76c (diff)
playlist sort patch from nick_m, improves ordering of playlists in menu. small effect, but nice
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5284 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/playlist.h5
-rw-r--r--libs/ardour/location.cc2
-rw-r--r--libs/ardour/playlist.cc37
3 files changed, 42 insertions, 2 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 232c0c15d4..9e30130d75 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -68,6 +68,8 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f
std::string name() const { return _name; }
void set_name (std::string str);
+
+ int sort_id() { return _sort_id; }
bool frozen() const { return _frozen; }
void set_frozen (bool yn);
@@ -178,6 +180,7 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f
RegionList regions; /* the current list of regions in the playlist */
std::set<boost::shared_ptr<Region> > all_regions; /* all regions ever added to this playlist */
string _name;
+ int _sort_id;
Session& _session;
mutable gint block_notifications;
mutable gint ignore_state_changes;
@@ -221,6 +224,8 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f
void delay_notifications ();
void release_notifications ();
virtual void flush_notifications ();
+
+ void _set_sort_id ();
void notify_region_removed (boost::shared_ptr<Region>);
void notify_region_added (boost::shared_ptr<Region>);
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index 61471ee5b0..103074511c 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -377,7 +377,7 @@ Location::set_state (const XMLNode& node)
*/
_start = atoi (prop->value().c_str());
-
+
if ((prop = node.property ("end")) == 0) {
error << _("XML node for Location has no end information") << endmsg;
return -1;
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 9960074e9a..eae97e19df 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -39,6 +39,8 @@
#include <ardour/playlist_factory.h>
#include <ardour/transient_detector.h>
+#include <boost/lexical_cast.hpp>
+
#include "i18n.h"
using namespace std;
@@ -78,7 +80,7 @@ Playlist::Playlist (Session& sess, string nom, bool hide)
init (hide);
first_set_state = false;
_name = nom;
-
+ _set_sort_id();
}
Playlist::Playlist (Session& sess, const XMLNode& node, bool hide)
@@ -86,6 +88,7 @@ Playlist::Playlist (Session& sess, const XMLNode& node, bool hide)
{
init (hide);
_name = "unnamed"; /* reset by set_state */
+ _set_sort_id();
/* set state called by derived class */
}
@@ -270,6 +273,35 @@ Playlist::~Playlist ()
}
void
+Playlist::_set_sort_id ()
+{
+ /*
+ Playlists are given names like <track name>.<id>
+ or <track name>.<edit group name>.<id> where id
+ is an integer. We extract the id and sort by that.
+ */
+
+ size_t dot_position = _name.find_last_of(".");
+ if (dot_position == string::npos)
+ {
+ _sort_id = 0;
+ }
+ else
+ {
+ string t = _name.substr(dot_position + 1);
+
+ try
+ {
+ _sort_id = boost::lexical_cast<int>(t);
+ }
+ catch (boost::bad_lexical_cast e)
+ {
+ _sort_id = 0;
+ }
+ }
+}
+
+void
Playlist::set_name (string str)
{
/* in a typical situation, a playlist is being used
@@ -293,6 +325,8 @@ Playlist::set_name (string str)
}
_name = name;
+ _set_sort_id();
+
NameChanged(); /* EMIT SIGNAL */
}
@@ -1730,6 +1764,7 @@ Playlist::set_state (const XMLNode& node)
if (prop->name() == X_("name")) {
_name = prop->value();
+ _set_sort_id();
} else if (prop->name() == X_("orig_diskstream_id")) {
_orig_diskstream_id = prop->value ();
} else if (prop->name() == X_("frozen")) {