16 #ifndef _INTERVAL_MODEL_H_ 17 #define _INTERVAL_MODEL_H_ 28 template <
typename Po
intType>
33 bool notifyOnAdd =
true) :
38 float valueMinimum,
float valueMaximum,
39 bool notifyOnAdd =
true) :
41 valueMinimum, valueMaximum,
68 virtual QVariant
getData(
int row,
int column,
int role)
const 82 else return QString(
"%1 %2").arg(i->value).arg
84 case 3:
return int(i->duration);
85 default:
return QVariant();
95 (row, column, value, role);
98 if (role != Qt::EditRole)
return 0;
99 typename I::PointList::const_iterator i
100 = I::getPointListIteratorForRow(row);
101 if (i == I::m_points.end())
return 0;
102 typename I::EditCommand *command =
new typename I::EditCommand
103 (
this, I::tr(
"Edit Data"));
106 command->deletePoint(point);
110 case 2: point.value = value.toDouble();
break;
111 case 3: point.duration = value.toInt();
break;
114 command->addPoint(point);
115 return command->finish();
126 template <
typename Po
intType>
132 if (start > end)
return typename I::PointList();
134 QMutex &
mutex(I::m_mutex);
135 QMutexLocker locker(&
mutex);
137 PointType endPoint(end);
139 typename I::PointListConstIterator endItr = I::m_points.upper_bound(endPoint);
141 if (endItr != I::m_points.end()) ++endItr;
142 if (endItr != I::m_points.end()) ++endItr;
144 typename I::PointList rv;
146 for (
typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) {
148 if (i->frame < start) {
149 if (i->frame +
long(i->duration) >= start) {
152 }
else if (i->frame <= end) {
160 template <
typename Po
intType>
166 QMutex &
mutex(I::m_mutex);
167 QMutexLocker locker(&
mutex);
169 if (I::m_resolution == 0)
return typename I::PointList();
171 long start = (frame / I::m_resolution) * I::m_resolution;
172 long end = start + I::m_resolution;
174 PointType endPoint(end);
176 typename I::PointListConstIterator endItr = I::m_points.upper_bound(endPoint);
178 typename I::PointList rv;
180 for (
typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) {
182 if (i->frame < start) {
183 if (i->frame +
long(i->duration) >= start) {
186 }
else if (i->frame <= end) {
std::multiset< PointType, typename PointType::OrderComparator > PointList
IntervalModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd=true)
virtual QVariant getData(int row, int column, int role) const
virtual QVariant getData(int row, int column, int role) const
TabularModel methods.
virtual Command * getSetDataCommand(int row, int column, const QVariant &value, int role)
Model containing sparse data (points with some properties) of which one of the properties is an arbit...
virtual const PointList & getPoints() const
Get all points.
virtual const SparseModel< PointType >::PointList & getPoints() const
Get all points.
Model containing sparse data (points with some properties) of which the properties include a duration...
IntervalModel(int sampleRate, int resolution, bool notifyOnAdd=true)
virtual Command * getSetDataCommand(int row, int column, const QVariant &value, int role)
virtual bool isColumnTimeValue(int column) const
PointListIterator getPointListIteratorForRow(int row)
Model containing sparse data (points with some properties).