comparison data/model/ImageModel.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
157 } 157 }
158 } 158 }
159 159
160 virtual QVariant getData(int row, int column, int role) const 160 virtual QVariant getData(int row, int column, int role) const
161 { 161 {
162 if (column < 2) {
163 return SparseModel<ImagePoint>::getData
164 (row, column, role);
165 }
166
162 PointListIterator i = getPointListIteratorForRow(row); 167 PointListIterator i = getPointListIteratorForRow(row);
163 if (i == m_points.end()) return QVariant(); 168 if (i == m_points.end()) return QVariant();
164 169
165 switch (column) { 170 switch (column) {
166 case 0: {
167 if (role == SortRole) return int(i->frame);
168 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate());
169 return rt.toText().c_str();
170 }
171 case 1: return int(i->frame);
172 case 2: return i->image; 171 case 2: return i->image;
173 case 3: return i->label; 172 case 3: return i->label;
174 default: return QVariant(); 173 default: return QVariant();
175 } 174 }
176 } 175 }
177 176
178 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role) 177 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role)
179 { 178 {
179 if (column < 2) {
180 return SparseModel<ImagePoint>::getSetDataCommand
181 (row, column, value, role);
182 }
183
180 if (role != Qt::EditRole) return false; 184 if (role != Qt::EditRole) return false;
181 PointListIterator i = getPointListIteratorForRow(row); 185 PointListIterator i = getPointListIteratorForRow(row);
182 if (i == m_points.end()) return false; 186 if (i == m_points.end()) return false;
183 EditCommand *command = new EditCommand(this, tr("Edit Data")); 187 EditCommand *command = new EditCommand(this, tr("Edit Data"));
184 188
185 Point point(*i); 189 Point point(*i);
186 command->deletePoint(point); 190 command->deletePoint(point);
187 191
188 switch (column) { 192 switch (column) {
189 case 0: case 1: point.frame = value.toInt(); break;
190 case 2: point.image = value.toString(); break; 193 case 2: point.image = value.toString(); break;
191 case 3: point.label = value.toString(); break; 194 case 3: point.label = value.toString(); break;
192 } 195 }
193 196
194 command->addPoint(point); 197 command->addPoint(point);