summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo_map_importer.cc
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2008-09-26 08:29:30 +0000
committerSakari Bergen <sakari.bergen@beatwaves.net>2008-09-26 08:29:30 +0000
commit572fa80aa713e723f63e1e1822db614307eea6af (patch)
tree6d8e8ed27d6192790f54482f14e93dda73d3a485 /libs/ardour/tempo_map_importer.cc
parent10d57b266cbec7054399f20f8e8c76cdff7e1592 (diff)
Add Import from session -functionality
git-svn-id: svn://localhost/ardour2/branches/3.0@3805 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/tempo_map_importer.cc')
-rw-r--r--libs/ardour/tempo_map_importer.cc108
1 files changed, 108 insertions, 0 deletions
diff --git a/libs/ardour/tempo_map_importer.cc b/libs/ardour/tempo_map_importer.cc
new file mode 100644
index 0000000000..45f2c90dfa
--- /dev/null
+++ b/libs/ardour/tempo_map_importer.cc
@@ -0,0 +1,108 @@
+/*
+ Copyright (C) 2008 Paul Davis
+ Author: Sakari Bergen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <ardour/tempo_map_importer.h>
+
+#include <sstream>
+
+#include <ardour/session.h>
+#include <pbd/failed_constructor.h>
+#include <pbd/compose.h>
+#include <pbd/error.h>
+
+#include "i18n.h"
+
+using namespace PBD;
+using namespace ARDOUR;
+
+/**** Handler ***/
+TempoMapImportHandler::TempoMapImportHandler (XMLTree const & source, Session & session) :
+ ElementImportHandler (source, session)
+{
+ XMLNode const * root = source.root();
+ XMLNode const * tempo_map;
+
+ if (!(tempo_map = root->child (X_("TempoMap")))) {
+ throw failed_constructor();
+ }
+
+ elements.push_back (ElementPtr ( new TempoMapImporter (source, session, *tempo_map)));
+}
+
+string
+TempoMapImportHandler::get_info () const
+{
+ return _("Tempo map");
+}
+
+/*** TempoMapImporter ***/
+TempoMapImporter::TempoMapImporter (XMLTree const & source, Session & session, XMLNode const & node) :
+ ElementImporter (source, session),
+ xml_tempo_map (node)
+{
+ name = _("Tempo Map");
+}
+
+string
+TempoMapImporter::get_info () const
+{
+ std::ostringstream oss;
+ unsigned int tempos = 0;
+ unsigned int meters = 0;
+ XMLNodeList children = xml_tempo_map.children();
+
+ for (XMLNodeIterator it = children.begin(); it != children.end(); it++) {
+ if ((*it)->name() == "Tempo") {
+ tempos++;
+ } else if ((*it)->name() == "Meters") {
+ meters++;
+ }
+ }
+
+ // return info
+ oss << _("Tempo marks: ") << tempos << _("\nMeter marks: ") << meters;
+
+ return oss.str();
+}
+
+bool
+TempoMapImporter::prepare_move ()
+{
+ // Prompt user for verification
+ bool replace = Prompt (_("This will replace the current tempo map!\nAre you shure you want to do this?"));
+
+ if (replace) {
+ queued = true;
+ }
+
+ return replace;
+}
+
+void
+TempoMapImporter::cancel_move ()
+{
+ queued = false;
+}
+
+void
+TempoMapImporter::move ()
+{
+ session.tempo_map().set_state (xml_tempo_map);
+}