annotate base/XmlExportable.cpp @ 16:cc98d496d52b
* Add command history class, and basic undo/redo menus. No actual commands
to undo/redo yet. Selecting the placeholders sometimes seems to cause
a crash, so this looks a little uncertain so far.
* Add Rename Layer
* Remove models from playback when their layers are removed (and ref counts
hit zero)
* Don't hang around waiting so much when there's work to be done in the audio
buffer fill thread
* Put more sensible names on layers generated from transforms
* Add basic editing to time-value layer like existing editing in time-instants
layer, and make both of them snap to the appropriate resolution during drag
author |
Chris Cannam |
date |
Mon, 30 Jan 2006 17:51:56 +0000 |
parents |
149bb02a41ba |
children |
39ae3dee27b9 |
rev |
line source |
Chris@3
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@3
|
2
|
Chris@3
|
3 /*
|
Chris@3
|
4 A waveform viewer and audio annotation editor.
|
Chris@3
|
5 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@3
|
6
|
Chris@3
|
7 This is experimental software. Not for distribution.
|
Chris@3
|
8 */
|
Chris@3
|
9
|
Chris@3
|
10 #include "XmlExportable.h"
|
Chris@4
|
11 #include <map>
|
Chris@3
|
12
|
Chris@3
|
13 QString
|
Chris@3
|
14 XmlExportable::encodeEntities(QString s)
|
Chris@3
|
15 {
|
Chris@3
|
16 s
|
Chris@3
|
17 .replace("&", "&")
|
Chris@3
|
18 .replace("<", "<")
|
Chris@3
|
19 .replace(">", ">")
|
Chris@3
|
20 .replace("\"", """)
|
Chris@3
|
21 .replace("'", "'");
|
Chris@3
|
22
|
Chris@3
|
23 return s;
|
Chris@3
|
24 }
|
Chris@3
|
25
|
Chris@3
|
26 QString
|
Chris@3
|
27 XmlExportable::encodeColour(QColor c)
|
Chris@3
|
28 {
|
Chris@3
|
29 QString r, g, b;
|
Chris@3
|
30
|
Chris@3
|
31 r.setNum(c.red(), 16);
|
Chris@3
|
32 if (c.red() < 16) r = "0" + r;
|
Chris@3
|
33
|
Chris@3
|
34 g.setNum(c.green(), 16);
|
Chris@3
|
35 if (c.green() < 16) g = "0" + g;
|
Chris@3
|
36
|
Chris@3
|
37 b.setNum(c.blue(), 16);
|
Chris@3
|
38 if (c.blue() < 16) b = "0" + b;
|
Chris@3
|
39
|
Chris@3
|
40 return "#" + r + g + b;
|
Chris@3
|
41 }
|
Chris@3
|
42
|
Chris@4
|
43 int
|
Chris@4
|
44 XmlExportable::getObjectExportId(const void * object)
|
Chris@4
|
45 {
|
Chris@4
|
46 static std::map<const void *, int> idMap;
|
Chris@4
|
47 static int maxId = 0;
|
Chris@4
|
48
|
Chris@4
|
49 if (idMap.find(object) == idMap.end()) {
|
Chris@4
|
50 idMap[object] = maxId++;
|
Chris@4
|
51 }
|
Chris@4
|
52
|
Chris@4
|
53 return idMap[object];
|
Chris@4
|
54 }
|
Chris@4
|
55
|
Chris@4
|
56
|