Mercurial > hg > svcore
comparison data/model/SparseTimeValueModel.h @ 422:4caa28a0a8a2
* sorting arbitrary columns in data editor
author | Chris Cannam |
---|---|
date | Thu, 12 Jun 2008 09:03:00 +0000 |
parents | 397fe91dc8e0 |
children | 6a96bff0bd59 |
comparison
equal
deleted
inserted
replaced
421:397fe91dc8e0 | 422:4caa28a0a8a2 |
---|---|
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 virtual QVariant getData(int row, int column, int role) const | 121 virtual QVariant getData(int row, int column, int role) const |
122 { | 122 { |
123 if (role != Qt::EditRole && role != Qt::DisplayRole) return QVariant(); | 123 if (role != Qt::EditRole && |
124 role != Qt::DisplayRole && | |
125 role != SortRole) return QVariant(); | |
124 PointListIterator i = getPointListIteratorForRow(row); | 126 PointListIterator i = getPointListIteratorForRow(row); |
125 if (i == m_points.end()) return QVariant(); | 127 if (i == m_points.end()) return QVariant(); |
126 | 128 |
127 switch (column) { | 129 switch (column) { |
128 case 0: { | 130 case 0: { |
131 if (role == SortRole) return int(i->frame); | |
129 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); | 132 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); |
130 return rt.toText().c_str(); | 133 return rt.toText().c_str(); |
131 } | 134 } |
132 case 1: return int(i->frame); | 135 case 1: return int(i->frame); |
133 case 2: | 136 case 2: |
134 if (role == Qt::EditRole) return i->value; | 137 if (role == Qt::EditRole || role == SortRole) return i->value; |
135 else return QString("%1 %2").arg(i->value).arg(getScaleUnits()); | 138 else return QString("%1 %2").arg(i->value).arg(getScaleUnits()); |
136 case 3: return i->label; | 139 case 3: return i->label; |
137 default: return QVariant(); | 140 default: return QVariant(); |
138 } | 141 } |
139 } | 142 } |
168 | 171 |
169 virtual bool isColumnTimeValue(int column) const | 172 virtual bool isColumnTimeValue(int column) const |
170 { | 173 { |
171 return (column < 2); | 174 return (column < 2); |
172 } | 175 } |
176 | |
177 virtual SortType getSortType(int column) const | |
178 { | |
179 if (column == 3) return SortAlphabetical; | |
180 return SortNumeric; | |
181 } | |
173 }; | 182 }; |
174 | 183 |
175 | 184 |
176 #endif | 185 #endif |
177 | 186 |