Mercurial > hg > svcore
diff data/model/TabularModel.h @ 1643:7a23dfe65d66 single-point
Update NoteModel to use EventSeries. This is incomplete and won't provide enough to update svgui for it yet; must also refactor to avoid duplication of nasty APIs when updating the rest of the models
author | Chris Cannam |
---|---|
date | Wed, 13 Mar 2019 14:50:10 +0000 |
parents | ad5f892c0c4d |
children | 343ef2a866a4 |
line wrap: on
line diff
--- a/data/model/TabularModel.h Wed Mar 13 14:46:54 2019 +0000 +++ b/data/model/TabularModel.h Wed Mar 13 14:50:10 2019 +0000 @@ -19,6 +19,8 @@ #include <QVariant> #include <QString> +#include "base/RealTime.h" + class Command; /** @@ -55,6 +57,22 @@ virtual Command *getSetDataCommand(int /* row */, int /* column */, const QVariant &, int /* role */) { return 0; } virtual Command *getInsertRowCommand(int /* beforeRow */) { return 0; } virtual Command *getRemoveRowCommand(int /* row */) { return 0; } + + QVariant adaptFrameForRole(sv_frame_t frame, + sv_samplerate_t rate, + int role) const { + if (role == SortRole) return int(frame); + RealTime rt = RealTime::frame2RealTime(frame, rate); + if (role == Qt::EditRole) return rt.toString().c_str(); + else return rt.toText().c_str(); + } + + QVariant adaptValueForRole(float value, + QString unit, + int role) const { + if (role == SortRole || role == Qt::EditRole) return value; + else return QString("%1 %2").arg(value).arg(unit); + } }; #endif