comparison data/model/TextModel.h @ 1429:48e9f538e6e9

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 57633d605547
children c01cbe41aeb5
comparison
equal deleted inserted replaced
1428:87ae75da6527 1429:48e9f538e6e9
31 struct TextPoint : public XmlExportable 31 struct TextPoint : public XmlExportable
32 { 32 {
33 public: 33 public:
34 TextPoint(sv_frame_t _frame) : frame(_frame), height(0.0f) { } 34 TextPoint(sv_frame_t _frame) : frame(_frame), height(0.0f) { }
35 TextPoint(sv_frame_t _frame, float _height, QString _label) : 35 TextPoint(sv_frame_t _frame, float _height, QString _label) :
36 frame(_frame), height(_height), label(_label) { } 36 frame(_frame), height(_height), label(_label) { }
37 37
38 int getDimensions() const { return 2; } 38 int getDimensions() const { return 2; }
39 39
40 sv_frame_t frame; 40 sv_frame_t frame;
41 float height; 41 float height;
44 QString getLabel() const { return label; } 44 QString getLabel() const { return label; }
45 45
46 void toXml(QTextStream &stream, QString indent = "", 46 void toXml(QTextStream &stream, QString indent = "",
47 QString extraAttributes = "") const 47 QString extraAttributes = "") const
48 { 48 {
49 stream << QString("%1<point frame=\"%2\" height=\"%3\" label=\"%4\" %5/>\n") 49 stream << QString("%1<point frame=\"%2\" height=\"%3\" label=\"%4\" %5/>\n")
50 .arg(indent).arg(frame).arg(height) 50 .arg(indent).arg(frame).arg(height)
51 .arg(encodeEntities(label)).arg(extraAttributes); 51 .arg(encodeEntities(label)).arg(extraAttributes);
52 } 52 }
53 53
54 QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const 54 QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const
55 { 55 {
59 if (label != "") list << label; 59 if (label != "") list << label;
60 return list.join(delimiter); 60 return list.join(delimiter);
61 } 61 }
62 62
63 struct Comparator { 63 struct Comparator {
64 bool operator()(const TextPoint &p1, 64 bool operator()(const TextPoint &p1,
65 const TextPoint &p2) const { 65 const TextPoint &p2) const {
66 if (p1.frame != p2.frame) return p1.frame < p2.frame; 66 if (p1.frame != p2.frame) return p1.frame < p2.frame;
67 if (p1.height != p2.height) return p1.height < p2.height; 67 if (p1.height != p2.height) return p1.height < p2.height;
68 return p1.label < p2.label; 68 return p1.label < p2.label;
69 } 69 }
70 }; 70 };
71 71
72 struct OrderComparator { 72 struct OrderComparator {
73 bool operator()(const TextPoint &p1, 73 bool operator()(const TextPoint &p1,
74 const TextPoint &p2) const { 74 const TextPoint &p2) const {
75 return p1.frame < p2.frame; 75 return p1.frame < p2.frame;
76 } 76 }
77 }; 77 };
78 }; 78 };
79 79
80 80
81 // Make this a class rather than a typedef so it can be predeclared. 81 // Make this a class rather than a typedef so it can be predeclared.
84 { 84 {
85 Q_OBJECT 85 Q_OBJECT
86 86
87 public: 87 public:
88 TextModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : 88 TextModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) :
89 SparseModel<TextPoint>(sampleRate, resolution, notifyOnAdd) 89 SparseModel<TextPoint>(sampleRate, resolution, notifyOnAdd)
90 { } 90 { }
91 91
92 virtual void toXml(QTextStream &out, 92 virtual void toXml(QTextStream &out,
93 QString indent = "", 93 QString indent = "",
94 QString extraAttributes = "") const 94 QString extraAttributes = "") const
95 { 95 {
96 SparseModel<TextPoint>::toXml 96 SparseModel<TextPoint>::toXml
97 (out, 97 (out,
98 indent, 98 indent,
99 QString("%1 subtype=\"text\"") 99 QString("%1 subtype=\"text\"")
100 .arg(extraAttributes)); 100 .arg(extraAttributes));
101 } 101 }
102 102
103 QString getTypeName() const { return tr("Text"); } 103 QString getTypeName() const { return tr("Text"); }
104 104
105 /** 105 /**