From 145364a8af6a1fec06556221e66d4b724a62fc9a Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 1 Mar 2010 18:37:05 +0000 Subject: Added old abandoned KDE3 version of the RoseGarden MIDI tool git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/rosegarden@1097595 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/base/Configuration.cpp | 232 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 src/base/Configuration.cpp (limited to 'src/base/Configuration.cpp') diff --git a/src/base/Configuration.cpp b/src/base/Configuration.cpp new file mode 100644 index 0000000..a3d836f --- /dev/null +++ b/src/base/Configuration.cpp @@ -0,0 +1,232 @@ +// -*- c-basic-offset: 4 -*- + +/* + Rosegarden + A sequencer and musical notation editor. + + This program is Copyright 2000-2008 + Guillaume Laurent , + Chris Cannam , + Richard Bown + + The moral right of the authors to claim authorship of this work + has been asserted. + + 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. See the file + COPYING included with this distribution for more information. +*/ + + +// Class to hold extraneous bits of configuration which +// don't sit inside the Composition itself - sequencer +// and other general stuff that we want to keep separate. +// +// + +#include +#include + +#include "Configuration.h" + +#if (__GNUC__ < 3) +#include +#define stringstream strstream +#else +#include +#endif + + +namespace Rosegarden +{ + +Configuration::Configuration(const Configuration &conf) : + PropertyMap(), + XmlExportable() +{ + clear(); + + // Copy everything + // + for (const_iterator i = conf.begin(); i != conf.end(); ++i) + insert(PropertyPair(i->first, i->second->clone())); +} + +Configuration::~Configuration() +{ + clear(); +} + + +std::vector +Configuration::getPropertyNames() +{ + std::vector v; + for (const_iterator i = begin(); i != end(); ++i) { + v.push_back(i->first.getName()); + } + std::sort(v.begin(), v.end()); + return v; +} + + +bool +Configuration::has(const PropertyName &name) const +{ + const_iterator i = find(name); + return (i != end()); +} + + +std::string +Configuration::toXmlString() +{ + using std::endl; + std::stringstream config; + + // This simple implementation just assumes everything's a string. + // Override it if you want something fancier (or reimplement it to + // support the whole gamut -- the reader in rosexmlhandler.cpp + // already can) + + for (const_iterator i = begin(); i != end(); ++i) { + config << "first.getName()) << "\" value=\"" + << encode(get(i->first)) << "\"/>" << endl; + } + +#if (__GNUC__ < 3) + config << endl << std::ends; +#else + config << endl; +#endif + + return config.str(); +} + +Configuration& +Configuration::operator=(const Configuration &conf) +{ + clear(); + + // Copy everything + // + for (const_iterator i = conf.begin(); i != conf.end(); ++i) + insert(PropertyPair(i->first, i->second->clone())); + + return (*this); +} + + + +namespace CompositionMetadataKeys +{ + const PropertyName Copyright = "copyright"; + const PropertyName Composer = "composer"; + const PropertyName Title = "title"; + const PropertyName Subtitle = "subtitle"; + const PropertyName Arranger = "arranger"; + // The following are recognized only by LilyPond output + const PropertyName Dedication = "dedication"; + const PropertyName Subsubtitle = "subsubtitle"; + const PropertyName Poet = "poet"; + const PropertyName Meter = "meter"; + const PropertyName Opus = "opus"; + const PropertyName Instrument = "instrument"; + const PropertyName Piece = "piece"; + const PropertyName Tagline = "tagline"; + + // The tab order of the edit fields in HeadersConfigurationPage + // is defined by the creation order of the edit fields. + // The edit fields are created in the order of the keys in getFixedKeys(). + std::vector getFixedKeys() { + std::vector keys; + keys.push_back(Dedication); + keys.push_back(Title); + keys.push_back(Subtitle); + keys.push_back(Subsubtitle); + keys.push_back(Poet); + keys.push_back(Instrument); + keys.push_back(Composer); + keys.push_back(Meter); + keys.push_back(Arranger); + keys.push_back(Piece); + keys.push_back(Opus); + keys.push_back(Copyright); + keys.push_back(Tagline); + + return keys; + } +} + + +// Keep these in lower case +const PropertyName DocumentConfiguration::SequencerOptions = "sequenceroptions"; +const PropertyName DocumentConfiguration::ZoomLevel = "zoomlevel"; +const PropertyName DocumentConfiguration::TransportMode = "transportmode"; + + +DocumentConfiguration::DocumentConfiguration() +{ + set(ZoomLevel, 0); + set(TransportMode, ""); // apparently generates an exception if not initialized +} + +DocumentConfiguration::DocumentConfiguration(const DocumentConfiguration &conf): + Configuration() +{ + for (const_iterator i = conf.begin(); i != conf.end(); ++i) + insert(PropertyPair(i->first, i->second->clone())); +} + +DocumentConfiguration::~DocumentConfiguration() +{ + clear(); +} + + +DocumentConfiguration& +DocumentConfiguration::operator=(const DocumentConfiguration &conf) +{ + clear(); + + for (const_iterator i = conf.begin(); i != conf.end(); ++i) + insert(PropertyPair(i->first, i->second->clone())); + + return *this; +} + + +// Convert to XML string for export +// +std::string +DocumentConfiguration::toXmlString() +{ + using std::endl; + + std::stringstream config; + + config << endl << "" << endl; + + config << " <" << ZoomLevel << " type=\"Int\">" << get(ZoomLevel) + << "\n"; + + config << " <" << TransportMode << " type=\"String\">" << get(TransportMode) + << "\n"; + + config << "" << endl; + +#if (__GNUC__ < 3) + config << endl << std::ends; +#else + config << endl; +#endif + + return config.str(); +} + +} + + -- cgit v1.2.3