blob: a3d836f7808451119f8328901472cbae781d8133 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
// -*- c-basic-offset: 4 -*-
/*
Rosegarden
A sequencer and musical notation editor.
This program is Copyright 2000-2008
Guillaume Laurent <glaurent@telegraph-road.org>,
Chris Cannam <cannam@all-day-breakfast.com>,
Richard Bown <bownie@bownie.com>
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 <string>
#include <algorithm>
#include "Configuration.h"
#if (__GNUC__ < 3)
#include <strstream>
#define stringstream strstream
#else
#include <sstream>
#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<std::string>
Configuration::getPropertyNames()
{
std::vector<std::string> 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 << "<property name=\""
<< encode(i->first.getName()) << "\" value=\""
<< encode(get<String>(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<PropertyName> getFixedKeys() {
std::vector<PropertyName> 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<Int>(ZoomLevel, 0);
set<String>(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 << "<configuration>" << endl;
config << " <" << ZoomLevel << " type=\"Int\">" << get<Int>(ZoomLevel)
<< "</" << ZoomLevel << ">\n";
config << " <" << TransportMode << " type=\"String\">" << get<String>(TransportMode)
<< "</" << TransportMode << ">\n";
config << "</configuration>" << endl;
#if (__GNUC__ < 3)
config << endl << std::ends;
#else
config << endl;
#endif
return config.str();
}
}
|