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 "pbd/failed_constructor.h"
27 #include "pbd/compose.h"
28 #include "pbd/error.h"
34 using namespace ARDOUR
;
37 TempoMapImportHandler::TempoMapImportHandler (XMLTree
const & source
, Session
& session
) :
38 ElementImportHandler (source
, session
)
40 XMLNode
const * root
= source
.root();
41 XMLNode
const * tempo_map
;
43 if (!(tempo_map
= root
->child (X_("TempoMap")))) {
44 throw failed_constructor();
47 elements
.push_back (ElementPtr ( new TempoMapImporter (source
, session
, *tempo_map
)));
51 TempoMapImportHandler::get_info () const
53 return _("Tempo map");
56 /*** TempoMapImporter ***/
57 TempoMapImporter::TempoMapImporter (XMLTree
const & source
, Session
& session
, XMLNode
const & node
) :
58 ElementImporter (source
, session
),
61 name
= _("Tempo Map");
65 TempoMapImporter::get_info () const
67 std::ostringstream oss
;
68 unsigned int tempos
= 0;
69 unsigned int meters
= 0;
70 XMLNodeList children
= xml_tempo_map
.children();
72 for (XMLNodeIterator it
= children
.begin(); it
!= children
.end(); it
++) {
73 if ((*it
)->name() == "Tempo") {
75 } else if ((*it
)->name() == "Meters") {
81 oss
<< _("Tempo marks: ") << tempos
<< _("\nMeter marks: ") << meters
;
87 TempoMapImporter::_prepare_move ()
89 // Prompt user for verification
90 boost::optional
<bool> replace
= Prompt (_("This will replace the current tempo map!\nAre you shure you want to do this?"));
91 return replace
.get_value_or (false);
95 TempoMapImporter::_cancel_move ()
100 TempoMapImporter::_move ()
102 session
.tempo_map().set_state (xml_tempo_map
, Stateful::current_state_version
);