Mercurial > hg > svcore
comparison data/model/TextModel.h @ 1599:ce185d4dd408 bqaudiostream
Merge from default branch
| author | Chris Cannam | 
|---|---|
| date | Wed, 23 Jan 2019 14:43:43 +0000 | 
| parents | ad5f892c0c4d | 
| children | 353a2d15f213 | 
   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 _TEXT_MODEL_H_ | 16 #ifndef SV_TEXT_MODEL_H | 
| 17 #define _TEXT_MODEL_H_ | 17 #define SV_TEXT_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 | 
| 42 QString label; | 42 QString label; | 
| 43 | 43 | 
| 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 override | 
| 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 } | 
| 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 void toXml(QTextStream &out, | 
| 93 QString indent = "", | 93 QString indent = "", | 
| 94 QString extraAttributes = "") const | 94 QString extraAttributes = "") const override | 
| 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 override { return tr("Text"); } | 
| 104 | 104 | 
| 105 /** | 105 /** | 
| 106 * TabularModel methods. | 106 * TabularModel methods. | 
| 107 */ | 107 */ | 
| 108 | 108 | 
| 109 virtual int getColumnCount() const | 109 int getColumnCount() const override | 
| 110 { | 110 { | 
| 111 return 4; | 111 return 4; | 
| 112 } | 112 } | 
| 113 | 113 | 
| 114 virtual QString getHeading(int column) const | 114 QString getHeading(int column) const override | 
| 115 { | 115 { | 
| 116 switch (column) { | 116 switch (column) { | 
| 117 case 0: return tr("Time"); | 117 case 0: return tr("Time"); | 
| 118 case 1: return tr("Frame"); | 118 case 1: return tr("Frame"); | 
| 119 case 2: return tr("Height"); | 119 case 2: return tr("Height"); | 
| 120 case 3: return tr("Label"); | 120 case 3: return tr("Label"); | 
| 121 default: return tr("Unknown"); | 121 default: return tr("Unknown"); | 
| 122 } | 122 } | 
| 123 } | 123 } | 
| 124 | 124 | 
| 125 virtual QVariant getData(int row, int column, int role) const | 125 QVariant getData(int row, int column, int role) const override | 
| 126 { | 126 { | 
| 127 if (column < 2) { | 127 if (column < 2) { | 
| 128 return SparseModel<TextPoint>::getData | 128 return SparseModel<TextPoint>::getData | 
| 129 (row, column, role); | 129 (row, column, role); | 
| 130 } | 130 } | 
| 137 case 3: return i->label; | 137 case 3: return i->label; | 
| 138 default: return QVariant(); | 138 default: return QVariant(); | 
| 139 } | 139 } | 
| 140 } | 140 } | 
| 141 | 141 | 
| 142 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) | 142 Command *getSetDataCommand(int row, int column, const QVariant &value, int role) override | 
| 143 { | 143 { | 
| 144 if (column < 2) { | 144 if (column < 2) { | 
| 145 return SparseModel<TextPoint>::getSetDataCommand | 145 return SparseModel<TextPoint>::getSetDataCommand | 
| 146 (row, column, value, role); | 146 (row, column, value, role); | 
| 147 } | 147 } | 
| 161 | 161 | 
| 162 command->addPoint(point); | 162 command->addPoint(point); | 
| 163 return command->finish(); | 163 return command->finish(); | 
| 164 } | 164 } | 
| 165 | 165 | 
| 166 virtual bool isColumnTimeValue(int column) const | 166 bool isColumnTimeValue(int column) const override | 
| 167 { | 167 { | 
| 168 return (column < 2); | 168 return (column < 2); | 
| 169 } | 169 } | 
| 170 | 170 | 
| 171 virtual SortType getSortType(int column) const | 171 SortType getSortType(int column) const override | 
| 172 { | 172 { | 
| 173 if (column == 3) return SortAlphabetical; | 173 if (column == 3) return SortAlphabetical; | 
| 174 return SortNumeric; | 174 return SortNumeric; | 
| 175 } | 175 } | 
| 176 | 176 | 
