Mercurial > hg > svcore
diff 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 |
line wrap: on
line diff
--- a/data/model/SparseTimeValueModel.h Wed Jun 11 17:00:04 2008 +0000 +++ b/data/model/SparseTimeValueModel.h Thu Jun 12 09:03:00 2008 +0000 @@ -120,18 +120,21 @@ virtual QVariant getData(int row, int column, int role) const { - if (role != Qt::EditRole && role != Qt::DisplayRole) return QVariant(); + if (role != Qt::EditRole && + role != Qt::DisplayRole && + role != SortRole) return QVariant(); PointListIterator i = getPointListIteratorForRow(row); if (i == m_points.end()) return QVariant(); switch (column) { case 0: { + if (role == SortRole) return int(i->frame); RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); return rt.toText().c_str(); } case 1: return int(i->frame); case 2: - if (role == Qt::EditRole) return i->value; + if (role == Qt::EditRole || role == SortRole) return i->value; else return QString("%1 %2").arg(i->value).arg(getScaleUnits()); case 3: return i->label; default: return QVariant(); @@ -170,6 +173,12 @@ { return (column < 2); } + + virtual SortType getSortType(int column) const + { + if (column == 3) return SortAlphabetical; + return SortNumeric; + } };