comparison data/model/SparseOneDimensionalModel.h @ 424:eafef13bb0b3

* Add more data-editor support to various models
author Chris Cannam
date Thu, 12 Jun 2008 14:33:45 +0000
parents 6a96bff0bd59
children f5e8f12d2e58
comparison
equal deleted inserted replaced
423:6a96bff0bd59 424:eafef13bb0b3
130 } 130 }
131 } 131 }
132 132
133 virtual QVariant getData(int row, int column, int role) const 133 virtual QVariant getData(int row, int column, int role) const
134 { 134 {
135 if (role != Qt::EditRole &&
136 role != Qt::DisplayRole &&
137 role != SortRole) return QVariant();
138 PointListIterator i = getPointListIteratorForRow(row); 135 PointListIterator i = getPointListIteratorForRow(row);
139 if (i == m_points.end()) return QVariant(); 136 if (i == m_points.end()) return QVariant();
140 137
141 switch (column) { 138 switch (column) {
142 case 0: { 139 case 0: {
146 } 143 }
147 case 1: return int(i->frame); 144 case 1: return int(i->frame);
148 case 2: return i->label; 145 case 2: return i->label;
149 default: return QVariant(); 146 default: return QVariant();
150 } 147 }
148 }
149
150 virtual Command *getSetDataCommand(int row, int column, const QVariant &value, int role)
151 {
152 if (role != Qt::EditRole) return false;
153 PointListIterator i = getPointListIteratorForRow(row);
154 if (i == m_points.end()) return false;
155 EditCommand *command = new EditCommand(this, tr("Edit Data"));
156
157 Point point(*i);
158 command->deletePoint(point);
159
160 switch (column) {
161 case 0: case 1: point.frame = value.toInt(); break;
162 case 2: point.label = value.toString(); break;
163 }
164
165 command->addPoint(point);
166 return command->finish();
151 } 167 }
152 168
153 virtual bool isColumnTimeValue(int column) const 169 virtual bool isColumnTimeValue(int column) const
154 { 170 {
155 return (column < 2); 171 return (column < 2);