comparison data/model/SparseOneDimensionalModel.h @ 422:4caa28a0a8a2

* sorting arbitrary columns in data editor
author Chris Cannam
date Thu, 12 Jun 2008 09:03:00 +0000
parents 50a956688baa
children 6a96bff0bd59
comparison
equal deleted inserted replaced
421:397fe91dc8e0 422:4caa28a0a8a2
128 } 128 }
129 } 129 }
130 130
131 virtual QVariant getData(int row, int column, int role) const 131 virtual QVariant getData(int row, int column, int role) const
132 { 132 {
133 if (role != Qt::EditRole && role != Qt::DisplayRole) return QVariant(); 133 if (role != Qt::EditRole &&
134 role != Qt::DisplayRole &&
135 role != SortRole) return QVariant();
134 PointListIterator i = getPointListIteratorForRow(row); 136 PointListIterator i = getPointListIteratorForRow(row);
135 if (i == m_points.end()) return QVariant(); 137 if (i == m_points.end()) return QVariant();
136 138
137 switch (column) { 139 switch (column) {
138 case 0: { 140 case 0: {
141 if (role == SortRole) return int(i->frame);
139 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); 142 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate());
140 return QVariant(rt.toText().c_str()); 143 return QVariant(rt.toText().c_str());
141 } 144 }
142 case 1: return QVariant(int(i->frame)); 145 case 1: return int(i->frame);
143 case 2: return QVariant(i->label); 146 case 2: return i->label;
144 default: return QVariant(); 147 default: return QVariant();
145 } 148 }
146 } 149 }
147 150
148 virtual bool isColumnTimeValue(int column) const 151 virtual bool isColumnTimeValue(int column) const
149 { 152 {
150 return (column < 2); 153 return (column < 2);
151 } 154 }
155
156 virtual SortType getSortType(int column) const
157 {
158 if (column == 2) return SortAlphabetical;
159 return SortNumeric;
160 }
152 }; 161 };
153 162
154 #endif 163 #endif
155 164
156 165