Mercurial > hg > svcore
comparison data/model/SparseTimeValueModel.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 | e43368ec5ff0 |
comparison
equal
deleted
inserted
replaced
424:eafef13bb0b3 | 425:f5e8f12d2e58 |
---|---|
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 virtual QVariant getData(int row, int column, int role) const | 123 virtual QVariant getData(int row, int column, int role) const |
124 { | 124 { |
125 if (column < 2) { | |
126 return SparseValueModel<TimeValuePoint>::getData | |
127 (row, column, role); | |
128 } | |
129 | |
125 PointListIterator i = getPointListIteratorForRow(row); | 130 PointListIterator i = getPointListIteratorForRow(row); |
126 if (i == m_points.end()) return QVariant(); | 131 if (i == m_points.end()) return QVariant(); |
127 | 132 |
128 switch (column) { | 133 switch (column) { |
129 case 0: { | |
130 if (role == SortRole) return int(i->frame); | |
131 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); | |
132 return rt.toText().c_str(); | |
133 } | |
134 case 1: return int(i->frame); | |
135 case 2: | 134 case 2: |
136 if (role == Qt::EditRole || role == SortRole) return i->value; | 135 if (role == Qt::EditRole || role == SortRole) return i->value; |
137 else return QString("%1 %2").arg(i->value).arg(getScaleUnits()); | 136 else return QString("%1 %2").arg(i->value).arg(getScaleUnits()); |
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 SparseValueModel<TimeValuePoint>::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.value = value.toDouble(); break; | 158 case 2: point.value = 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); |