X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Flocation_importer.cc;h=87c304ff9e264238fa9dfa9e29016cdafccf6b5b;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=58a6e72f16e05a37d853f92b470d657c8545cf58;hpb=4e1f451520975868659f4c00d00883f5f1cd5805;p=ardour.git diff --git a/libs/ardour/location_importer.cc b/libs/ardour/location_importer.cc index 58a6e72f16..87c304ff9e 100644 --- a/libs/ardour/location_importer.cc +++ b/libs/ardour/location_importer.cc @@ -18,17 +18,18 @@ */ -#include +#include "ardour/location_importer.h" #include #include -#include -#include -#include +#include "ardour/session.h" +#include "pbd/convert.h" +#include "pbd/failed_constructor.h" -#include "i18n.h" +#include "pbd/i18n.h" +using namespace std; using namespace PBD; using namespace ARDOUR; @@ -38,14 +39,14 @@ LocationImportHandler::LocationImportHandler (XMLTree const & source, Session & { XMLNode const *root = source.root(); XMLNode const * location_node; - + if (!(location_node = root->child ("Locations"))) { throw failed_constructor(); } - + // Construct importable locations XMLNodeList const & locations = location_node->children(); - for (XMLNodeList::const_iterator it = locations.begin(); it != locations.end(); it++) { + for (XMLNodeList::const_iterator it = locations.begin(); it != locations.end(); ++it) { try { elements.push_back (ElementPtr ( new LocationImporter (source, session, *this, **it))); } catch (failed_constructor err) { @@ -61,7 +62,7 @@ LocationImportHandler::get_info () const } /*** LocationImporter ***/ -LocationImporter::LocationImporter (XMLTree const & source, Session & session, LocationImportHandler & handler, XMLNode const & node) : +LocationImporter::LocationImporter (XMLTree const & source, Session & session, LocationImportHandler & handler, XMLNode const & node) : ElementImporter (source, session), handler (handler), xml_location (node), @@ -70,7 +71,7 @@ LocationImporter::LocationImporter (XMLTree const & source, Session & session, L // Parse XML bool name_ok = false; XMLPropertyList props = xml_location.properties(); - + for (XMLPropertyIterator it = props.begin(); it != props.end(); ++it) { string prop = (*it)->name(); if (!prop.compare ("id") || !prop.compare ("flags") || !prop.compare ("locked")) { @@ -86,7 +87,7 @@ LocationImporter::LocationImporter (XMLTree const & source, Session & session, L std::cerr << string_compose (X_("LocationImporter did not recognise XML-property \"%1\""), prop) << endmsg; } } - + if (!name_ok) { error << X_("LocationImporter did not find necessary XML-property \"name\"") << endmsg; throw failed_constructor(); @@ -103,28 +104,28 @@ LocationImporter::~LocationImporter () string LocationImporter::get_info () const { - nframes_t start, end; - SMPTE::Time start_time, end_time; - + framepos_t start, end; + Timecode::Time start_time, end_time; + // Get sample positions std::istringstream iss_start (xml_location.property ("start")->value()); iss_start >> start; std::istringstream iss_end (xml_location.property ("end")->value()); iss_end >> end; - - // Convert to smpte - session.sample_to_smpte (start, start_time, true, false); - session.sample_to_smpte (end, end_time, true, false); - + + // Convert to timecode + session.sample_to_timecode (start, start_time, true, false); + session.sample_to_timecode (end, end_time, true, false); + // return info std::ostringstream oss; if (start == end) { - oss << _("Location: ") << smpte_to_string (start_time); + oss << _("Location: ") << timecode_to_string (start_time); } else { - oss << _("Range\nstart: ") << smpte_to_string (start_time) << - _("\nend: ") << smpte_to_string (end_time); + oss << _("Range\nstart: ") << timecode_to_string (start_time) << + _("\nend: ") << timecode_to_string (end_time); } - + return oss.str(); } @@ -132,44 +133,44 @@ bool LocationImporter::_prepare_move () { try { - Location const original (xml_location); + Location const original (session, xml_location); location = new Location (original); // Updates id } catch (failed_constructor& err) { throw std::runtime_error (X_("Error in session file!")); - return false; + return false; } - + std::pair rename_pair; - + if (location->is_auto_punch()) { - rename_pair = Rename (_("The location is the Punch range. It will be imported as a normal range.\nYou may rename the imported location:"), name); + rename_pair = *Rename (_("The location is the Punch range. It will be imported as a normal range.\nYou may rename the imported location:"), name); if (!rename_pair.first) { return false; } - + name = rename_pair.second; location->set_auto_punch (false, this); location->set_is_range_marker (true, this); } - + if (location->is_auto_loop()) { - rename_pair = Rename (_("The location is a Loop range. It will be imported as a normal range.\nYou may rename the imported location:"), name); + rename_pair = *Rename (_("The location is a Loop range. It will be imported as a normal range.\nYou may rename the imported location:"), name); if (!rename_pair.first) { return false; } - + location->set_auto_loop (false, this); location->set_is_range_marker (true, this); } - + // duplicate name checking Locations::LocationList const & locations(session.locations()->list()); for (Locations::LocationList::const_iterator it = locations.begin(); it != locations.end(); ++it) { if (!((*it)->name().compare (location->name())) || !handler.check_name (location->name())) { - rename_pair = Rename (_("A location with that name already exists.\nYou may rename the imported location:"), name); + rename_pair = *Rename (_("A location with that name already exists.\nYou may rename the imported location:"), name); if (!rename_pair.first) { return false; } name = rename_pair.second; } } - + location->set_name (name); return true; @@ -177,7 +178,7 @@ LocationImporter::_prepare_move () void LocationImporter::_cancel_move () -{ +{ delete location; location = 0; }