summaryrefslogtreecommitdiff
path: root/libs/ardour/location.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/location.cc')
-rw-r--r--libs/ardour/location.cc48
1 files changed, 41 insertions, 7 deletions
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index e09a59d42f..bec87e5dd6 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -28,6 +28,7 @@
#include <pbd/stl_delete.h>
#include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
#include <ardour/location.h>
#include <ardour/session.h>
@@ -35,6 +36,8 @@
#include "i18n.h"
+#define SUFFIX_MAX 32
+
using namespace std;
using namespace ARDOUR;
using namespace sigc;
@@ -217,12 +220,12 @@ Location::set_flag_internal (bool yn, Flags flag)
{
if (yn) {
if (!(_flags & flag)) {
- _flags |= flag;
+ _flags = Flags (_flags | flag);
return true;
}
} else {
if (_flags & flag) {
- _flags &= ~flag;
+ _flags = Flags (_flags & ~flag);
return true;
}
}
@@ -273,8 +276,7 @@ Location::get_state (void)
node->add_property ("start", buf);
snprintf (buf, sizeof (buf), "%u", end());
node->add_property ("end", buf);
- snprintf (buf, sizeof (buf), "%" PRIu32, (uint32_t) _flags);
- node->add_property ("flags", buf);
+ node->add_property ("flags", enum_2_string (_flags));
return *node;
}
@@ -327,14 +329,12 @@ Location::set_state (const XMLNode& node)
_end = atoi (prop->value().c_str());
- _flags = 0;
-
if ((prop = node.property ("flags")) == 0) {
error << _("XML node for Location has no flags information") << endmsg;
return -1;
}
- _flags = Flags (atoi (prop->value().c_str()));
+ _flags = Flags (string_2_enum (prop->value(), _flags));
for (cd_iter = cd_list.begin(); cd_iter != cd_list.end(); ++cd_iter) {
@@ -404,6 +404,40 @@ Locations::set_current (Location *loc, bool want_lock)
}
int
+Locations::next_available_name(string& result,string base)
+{
+ LocationList::iterator i;
+ Location* location;
+ string temp;
+ string::size_type l;
+ int suffix;
+ char buf[32];
+ bool available[SUFFIX_MAX+1];
+
+ result = base;
+ for (int k=1; k<SUFFIX_MAX; k++) {
+ available[k] = true;
+ }
+ l = base.length();
+ for (i = locations.begin(); i != locations.end(); ++i) {
+ location =* i;
+ temp = location->name();
+ if (l && !temp.find(base,0)) {
+ suffix = atoi(temp.substr(l,3));
+ if (suffix) available[suffix] = false;
+ }
+ }
+ for (int k=1; k<=SUFFIX_MAX; k++) {
+ if (available[k]) {
+ snprintf (buf, 31, "%d", k);
+ result += buf;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
Locations::set_current_unlocked (Location *loc)
{
if (find (locations.begin(), locations.end(), loc) == locations.end()) {