Mercurial > hg > svcore
comparison data/model/TextModel.h @ 425:f5e8f12d2e58
* Add audio device selection to preferences
* Add (not yet functional) insert, delete, edit buttons to data edit window
* Add proper set methods for time fields in data edit window (using general
sparse model base class)
author | Chris Cannam |
---|---|
date | Fri, 13 Jun 2008 21:09:43 +0000 |
parents | eafef13bb0b3 |
children | d7f3dfe6f9a4 |
comparison
equal
deleted
inserted
replaced
424:eafef13bb0b3 | 425:f5e8f12d2e58 |
---|---|
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 virtual QVariant getData(int row, int column, int role) const | 125 virtual QVariant getData(int row, int column, int role) const |
126 { | 126 { |
127 if (column < 2) { | |
128 return SparseModel<TextPoint>::getData | |
129 (row, column, role); | |
130 } | |
131 | |
127 PointListIterator i = getPointListIteratorForRow(row); | 132 PointListIterator i = getPointListIteratorForRow(row); |
128 if (i == m_points.end()) return QVariant(); | 133 if (i == m_points.end()) return QVariant(); |
129 | 134 |
130 switch (column) { | 135 switch (column) { |
131 case 0: { | |
132 if (role == SortRole) return int(i->frame); | |
133 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); | |
134 return rt.toText().c_str(); | |
135 } | |
136 case 1: return int(i->frame); | |
137 case 2: return i->height; | 136 case 2: return i->height; |
138 case 3: return i->label; | 137 case 3: return i->label; |
139 default: return QVariant(); | 138 default: return QVariant(); |
140 } | 139 } |
141 } | 140 } |
142 | 141 |
143 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) | 142 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) |
144 { | 143 { |
144 if (column < 2) { | |
145 return SparseModel<TextPoint>::getSetDataCommand | |
146 (row, column, value, role); | |
147 } | |
148 | |
145 if (role != Qt::EditRole) return false; | 149 if (role != Qt::EditRole) return false; |
146 PointListIterator i = getPointListIteratorForRow(row); | 150 PointListIterator i = getPointListIteratorForRow(row); |
147 if (i == m_points.end()) return false; | 151 if (i == m_points.end()) return false; |
148 EditCommand *command = new EditCommand(this, tr("Edit Data")); | 152 EditCommand *command = new EditCommand(this, tr("Edit Data")); |
149 | 153 |
150 Point point(*i); | 154 Point point(*i); |
151 command->deletePoint(point); | 155 command->deletePoint(point); |
152 | 156 |
153 switch (column) { | 157 switch (column) { |
154 case 0: case 1: point.frame = value.toInt(); break; | |
155 case 2: point.height = value.toDouble(); break; | 158 case 2: point.height = value.toDouble(); break; |
156 case 3: point.label = value.toString(); break; | 159 case 3: point.label = value.toString(); break; |
157 } | 160 } |
158 | 161 |
159 command->addPoint(point); | 162 command->addPoint(point); |