Remove special handling of session range in export. Fixes things when the session range is renamed.

This commit is contained in:
Sakari Bergen 2013-05-26 20:25:27 +03:00
parent 13f51112c9
commit 0a364fd991
3 changed files with 28 additions and 30 deletions

View File

@ -120,9 +120,7 @@ ExportTimespanSelector::add_range_to_selection (ARDOUR::Location const * loc)
ExportTimespanPtr span = _session->get_export_handler()->add_timespan();
std::string id;
if (loc == state->session_range.get()) {
id = "session";
} else if (loc == state->selection_range.get()) {
if (loc == state->selection_range.get()) {
id = "selection";
} else {
id = loc->id().to_s();
@ -367,9 +365,7 @@ ExportTimespanSelectorSingle::fill_range_list ()
if (!state) { return; }
std::string id;
if (!range_id.compare (X_("session"))) {
id = state->session_range->id().to_s();
} else if (!range_id.compare (X_("selection"))) {
if (!range_id.compare (X_("selection"))) {
id = state->selection_range->id().to_s();
} else {
id = range_id;
@ -459,9 +455,8 @@ ExportTimespanSelectorMultiple::set_selection_from_state ()
for (tree_it = range_list->children().begin(); tree_it != range_list->children().end(); ++tree_it) {
Location * loc = tree_it->get_value (range_cols.location);
if ((!id.compare ("session") && loc == state->session_range.get()) ||
(!id.compare ("selection") && loc == state->selection_range.get()) ||
(!id.compare (loc->id().to_s()))) {
if ((id == "selection" && loc == state->selection_range.get()) ||
(id == loc->id().to_s())) {
tree_it->set_value (range_cols.selected, true);
}
}

View File

@ -122,16 +122,13 @@ class ExportProfileManager
TimespanListPtr timespans;
TimeFormat time_format;
boost::shared_ptr<Location> session_range;
boost::shared_ptr<Location> selection_range;
boost::shared_ptr<LocationList> ranges;
TimespanState (boost::shared_ptr<Location> session_range,
boost::shared_ptr<Location> selection_range,
TimespanState (boost::shared_ptr<Location> selection_range,
boost::shared_ptr<LocationList> ranges)
: timespans (new TimespanList ())
, time_format (Timecode)
, session_range (session_range)
, selection_range (selection_range)
, ranges (ranges)
{}
@ -157,7 +154,6 @@ class ExportProfileManager
void update_ranges ();
boost::shared_ptr<Location> session_range;
boost::shared_ptr<Location> selection_range;
boost::shared_ptr<LocationList> ranges;

View File

@ -61,7 +61,6 @@ ExportProfileManager::ExportProfileManager (Session & s, ExportType type)
, handler (s.get_export_handler())
, session (s)
, session_range (new Location (s))
, ranges (new LocationList ())
, single_range_mode (false)
@ -385,13 +384,16 @@ ExportProfileManager::init_timespans (XMLNodeList nodes)
}
if (timespans.empty()) {
TimespanStatePtr state (new TimespanState (session_range, selection_range, ranges));
TimespanStatePtr state (new TimespanState (selection_range, ranges));
timespans.push_back (state);
// Add session as default selection
Location * session_range = session.locations()->session_range_location();
if (!session_range) { return false; }
ExportTimespanPtr timespan = handler->add_timespan();
timespan->set_name (session_range->name());
timespan->set_range_id ("session");
timespan->set_range_id (session_range->id().to_s());
timespan->set_range (session_range->start(), session_range->end());
state->timespans->push_back (timespan);
return false;
@ -403,7 +405,7 @@ ExportProfileManager::init_timespans (XMLNodeList nodes)
ExportProfileManager::TimespanStatePtr
ExportProfileManager::deserialize_timespan (XMLNode & root)
{
TimespanStatePtr state (new TimespanState (session_range, selection_range, ranges));
TimespanStatePtr state (new TimespanState (selection_range, ranges));
XMLProperty const * prop;
XMLNodeList spans = root.children ("Range");
@ -413,17 +415,22 @@ ExportProfileManager::deserialize_timespan (XMLNode & root)
if (!prop) { continue; }
string id = prop->value();
Location * location = 0;
for (LocationList::iterator it = ranges->begin(); it != ranges->end(); ++it) {
if ((!id.compare ("session") && *it == session_range.get()) ||
(!id.compare ("selection") && *it == selection_range.get()) ||
(!id.compare ((*it)->id().to_s()))) {
ExportTimespanPtr timespan = handler->add_timespan();
timespan->set_name ((*it)->name());
timespan->set_range_id (id);
timespan->set_range ((*it)->start(), (*it)->end());
state->timespans->push_back (timespan);
if ((id == "selection" && *it == selection_range.get()) ||
(id == (*it)->id().to_s())) {
location = *it;
break;
}
}
if (!location) { continue; }
ExportTimespanPtr timespan = handler->add_timespan();
timespan->set_name (location->name());
timespan->set_range_id (location->id().to_s());
timespan->set_range (location->start(), location->end());
state->timespans->push_back (timespan);
}
if ((prop = root.property ("format"))) {
@ -440,7 +447,6 @@ ExportProfileManager::serialize_timespan (TimespanStatePtr state)
XMLNode * span;
update_ranges ();
for (TimespanList::iterator it = state->timespans->begin(); it != state->timespans->end(); ++it) {
if ((span = root.add_child ("Range"))) {
span->add_property ("id", (*it)->range_id());
@ -463,9 +469,10 @@ ExportProfileManager::update_ranges () {
/* Session */
session_range->set_name (_("Session"));
session_range->set (session.current_start_frame(), session.current_end_frame());
ranges->push_back (session_range.get());
Location * session_range = session.locations()->session_range_location();
if (session_range) {
ranges->push_back (session_range);
}
/* Selection */