Mercurial > hg > svcore
comparison data/model/SparseOneDimensionalModel.h @ 420:50a956688baa
* reorganise tabular data editor model support
author | Chris Cannam |
---|---|
date | Wed, 11 Jun 2008 16:13:25 +0000 |
parents | 5858cc462d0a |
children | 4caa28a0a8a2 |
comparison
equal
deleted
inserted
replaced
419:64e7bbb255d3 | 420:50a956688baa |
---|---|
93 virtual QString getDefaultPlayPluginConfiguration() const | 93 virtual QString getDefaultPlayPluginConfiguration() const |
94 { | 94 { |
95 return "<plugin program=\"tap\"/>"; | 95 return "<plugin program=\"tap\"/>"; |
96 } | 96 } |
97 | 97 |
98 int getIndexOf(const Point &point) { | 98 int getIndexOf(const Point &point) |
99 { | |
99 // slow | 100 // slow |
100 int i = 0; | 101 int i = 0; |
101 Point::Comparator comparator; | 102 Point::Comparator comparator; |
102 for (PointList::const_iterator j = m_points.begin(); | 103 for (PointList::const_iterator j = m_points.begin(); |
103 j != m_points.end(); ++j, ++i) { | 104 j != m_points.end(); ++j, ++i) { |
105 } | 106 } |
106 return -1; | 107 return -1; |
107 } | 108 } |
108 | 109 |
109 QString getTypeName() const { return tr("Sparse 1-D"); } | 110 QString getTypeName() const { return tr("Sparse 1-D"); } |
111 | |
112 /** | |
113 * TabularModel methods. | |
114 */ | |
115 | |
116 virtual int getColumnCount() const | |
117 { | |
118 return 3; | |
119 } | |
120 | |
121 virtual QString getHeading(int column) const | |
122 { | |
123 switch (column) { | |
124 case 0: return tr("Time"); | |
125 case 1: return tr("Frame"); | |
126 case 2: return tr("Label"); | |
127 default: return tr("Unknown"); | |
128 } | |
129 } | |
130 | |
131 virtual QVariant getData(int row, int column, int role) const | |
132 { | |
133 if (role != Qt::EditRole && role != Qt::DisplayRole) return QVariant(); | |
134 PointListIterator i = getPointListIteratorForRow(row); | |
135 if (i == m_points.end()) return QVariant(); | |
136 | |
137 switch (column) { | |
138 case 0: { | |
139 RealTime rt = RealTime::frame2RealTime(i->frame, getSampleRate()); | |
140 return QVariant(rt.toText().c_str()); | |
141 } | |
142 case 1: return QVariant(int(i->frame)); | |
143 case 2: return QVariant(i->label); | |
144 default: return QVariant(); | |
145 } | |
146 } | |
147 | |
148 virtual bool isColumnTimeValue(int column) const | |
149 { | |
150 return (column < 2); | |
151 } | |
110 }; | 152 }; |
111 | 153 |
112 #endif | 154 #endif |
113 | 155 |
114 | 156 |