2 Copyright (C) 2008 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "ardour/tempo_map_importer.h"
25 #include "ardour/session.h"
26 #include "ardour/tempo.h"
27 #include "pbd/failed_constructor.h"
33 using namespace ARDOUR;
36 TempoMapImportHandler::TempoMapImportHandler (XMLTree const & source, Session & session) :
37 ElementImportHandler (source, session)
39 XMLNode const * root = source.root();
40 XMLNode const * tempo_map;
42 if (!(tempo_map = root->child (X_("TempoMap")))) {
43 throw failed_constructor();
46 elements.push_back (ElementPtr ( new TempoMapImporter (source, session, *tempo_map)));
50 TempoMapImportHandler::get_info () const
52 return _("Tempo map");
55 /*** TempoMapImporter ***/
56 TempoMapImporter::TempoMapImporter (XMLTree const & source, Session & session, XMLNode const & node) :
57 ElementImporter (source, session),
60 name = _("Tempo Map");
64 TempoMapImporter::get_info () const
66 std::ostringstream oss;
67 unsigned int tempos = 0;
68 unsigned int meters = 0;
69 XMLNodeList children = xml_tempo_map.children();
71 for (XMLNodeIterator it = children.begin(); it != children.end(); it++) {
72 if ((*it)->name() == "Tempo") {
74 } else if ((*it)->name() == "Meters") {
80 oss << _("Tempo marks: ") << tempos << _("\nMeter marks: ") << meters;
86 TempoMapImporter::_prepare_move ()
88 // Prompt user for verification
89 boost::optional<bool> replace = Prompt (_("This will replace the current tempo map!\nAre you sure you want to do this?"));
90 return replace.get_value_or (false);
94 TempoMapImporter::_cancel_move ()
99 TempoMapImporter::_move ()
101 session.tempo_map().set_state (xml_tempo_map, Stateful::current_state_version);