Mercurial > hg > svcore
comparison data/model/ImageModel.h @ 1599:ce185d4dd408 bqaudiostream
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 23 Jan 2019 14:43:43 +0000 |
parents | ad5f892c0c4d |
children | a77a7e8c085c |
comparison
equal
deleted
inserted
replaced
1598:d2555df635ec | 1599:ce185d4dd408 |
---|---|
11 published by the Free Software Foundation; either version 2 of the | 11 published by the Free Software Foundation; either version 2 of the |
12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #ifndef _IMAGE_MODEL_H_ | 16 #ifndef SV_IMAGE_MODEL_H |
17 #define _IMAGE_MODEL_H_ | 17 #define SV_IMAGE_MODEL_H |
18 | 18 |
19 #include "SparseModel.h" | 19 #include "SparseModel.h" |
20 #include "base/XmlExportable.h" | 20 #include "base/XmlExportable.h" |
21 #include "base/RealTime.h" | 21 #include "base/RealTime.h" |
22 | 22 |
43 | 43 |
44 QString getLabel() const { return label; } | 44 QString getLabel() const { return label; } |
45 | 45 |
46 void toXml(QTextStream &stream, | 46 void toXml(QTextStream &stream, |
47 QString indent = "", | 47 QString indent = "", |
48 QString extraAttributes = "") const | 48 QString extraAttributes = "") const override |
49 { | 49 { |
50 stream << | 50 stream << |
51 QString("%1<point frame=\"%2\" image=\"%3\" label=\"%4\" %5/>\n") | 51 QString("%1<point frame=\"%2\" image=\"%3\" label=\"%4\" %5/>\n") |
52 .arg(indent).arg(frame) | 52 .arg(indent).arg(frame) |
53 .arg(encodeEntities(image)) | 53 .arg(encodeEntities(image)) |
91 public: | 91 public: |
92 ImageModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : | 92 ImageModel(sv_samplerate_t sampleRate, int resolution, bool notifyOnAdd = true) : |
93 SparseModel<ImagePoint>(sampleRate, resolution, notifyOnAdd) | 93 SparseModel<ImagePoint>(sampleRate, resolution, notifyOnAdd) |
94 { } | 94 { } |
95 | 95 |
96 QString getTypeName() const { return tr("Image"); } | 96 QString getTypeName() const override { return tr("Image"); } |
97 | 97 |
98 virtual void toXml(QTextStream &out, | 98 void toXml(QTextStream &out, |
99 QString indent = "", | 99 QString indent = "", |
100 QString extraAttributes = "") const | 100 QString extraAttributes = "") const override |
101 { | 101 { |
102 SparseModel<ImagePoint>::toXml | 102 SparseModel<ImagePoint>::toXml |
103 (out, | 103 (out, |
104 indent, | 104 indent, |
105 QString("%1 subtype=\"image\"") | 105 QString("%1 subtype=\"image\"") |
119 m_model(model), m_oldPoint(point), m_newPoint(point) { | 119 m_model(model), m_oldPoint(point), m_newPoint(point) { |
120 m_newPoint.image = newImage; | 120 m_newPoint.image = newImage; |
121 m_newPoint.label = newLabel; | 121 m_newPoint.label = newLabel; |
122 } | 122 } |
123 | 123 |
124 virtual QString getName() const { return tr("Edit Image"); } | 124 QString getName() const override { return tr("Edit Image"); } |
125 | 125 |
126 virtual void execute() { | 126 void execute() override { |
127 m_model->deletePoint(m_oldPoint); | 127 m_model->deletePoint(m_oldPoint); |
128 m_model->addPoint(m_newPoint); | 128 m_model->addPoint(m_newPoint); |
129 std::swap(m_oldPoint, m_newPoint); | 129 std::swap(m_oldPoint, m_newPoint); |
130 } | 130 } |
131 | 131 |
132 virtual void unexecute() { execute(); } | 132 void unexecute() override { execute(); } |
133 | 133 |
134 private: | 134 private: |
135 ImageModel *m_model; | 135 ImageModel *m_model; |
136 ImagePoint m_oldPoint; | 136 ImagePoint m_oldPoint; |
137 ImagePoint m_newPoint; | 137 ImagePoint m_newPoint; |
139 | 139 |
140 /** | 140 /** |
141 * TabularModel methods. | 141 * TabularModel methods. |
142 */ | 142 */ |
143 | 143 |
144 virtual int getColumnCount() const | 144 int getColumnCount() const override |
145 { | 145 { |
146 return 4; | 146 return 4; |
147 } | 147 } |
148 | 148 |
149 virtual QString getHeading(int column) const | 149 QString getHeading(int column) const override |
150 { | 150 { |
151 switch (column) { | 151 switch (column) { |
152 case 0: return tr("Time"); | 152 case 0: return tr("Time"); |
153 case 1: return tr("Frame"); | 153 case 1: return tr("Frame"); |
154 case 2: return tr("Image"); | 154 case 2: return tr("Image"); |
155 case 3: return tr("Label"); | 155 case 3: return tr("Label"); |
156 default: return tr("Unknown"); | 156 default: return tr("Unknown"); |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 virtual QVariant getData(int row, int column, int role) const | 160 QVariant getData(int row, int column, int role) const override |
161 { | 161 { |
162 if (column < 2) { | 162 if (column < 2) { |
163 return SparseModel<ImagePoint>::getData | 163 return SparseModel<ImagePoint>::getData |
164 (row, column, role); | 164 (row, column, role); |
165 } | 165 } |
172 case 3: return i->label; | 172 case 3: return i->label; |
173 default: return QVariant(); | 173 default: return QVariant(); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) | 177 Command *getSetDataCommand(int row, int column, const QVariant &value, int role) override |
178 { | 178 { |
179 if (column < 2) { | 179 if (column < 2) { |
180 return SparseModel<ImagePoint>::getSetDataCommand | 180 return SparseModel<ImagePoint>::getSetDataCommand |
181 (row, column, value, role); | 181 (row, column, value, role); |
182 } | 182 } |
196 | 196 |
197 command->addPoint(point); | 197 command->addPoint(point); |
198 return command->finish(); | 198 return command->finish(); |
199 } | 199 } |
200 | 200 |
201 virtual bool isColumnTimeValue(int column) const | 201 bool isColumnTimeValue(int column) const override |
202 { | 202 { |
203 return (column < 2); | 203 return (column < 2); |
204 } | 204 } |
205 | 205 |
206 virtual SortType getSortType(int column) const | 206 SortType getSortType(int column) const override |
207 { | 207 { |
208 if (column > 2) return SortAlphabetical; | 208 if (column > 2) return SortAlphabetical; |
209 return SortNumeric; | 209 return SortNumeric; |
210 } | 210 } |
211 }; | 211 }; |