comparison view/Overview.cpp @ 908:4a578a360011 cxx11

More type fixes
author Chris Cannam
date Tue, 10 Mar 2015 13:22:10 +0000
parents c17719e488c9
children 26da827e8fb5
comparison
equal deleted inserted replaced
907:28d05ae8741c 908:4a578a360011
36 setPlaybackFollow(PlaybackIgnore); 36 setPlaybackFollow(PlaybackIgnore);
37 m_modelTestTime.start(); 37 m_modelTestTime.start();
38 } 38 }
39 39
40 void 40 void
41 Overview::modelChangedWithin(int startFrame, int endFrame) 41 Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame)
42 { 42 {
43 bool zoomChanged = false; 43 bool zoomChanged = false;
44 44
45 int frameCount = getModelsEndFrame() - getModelsStartFrame(); 45 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame();
46 int zoomLevel = frameCount / width(); 46 int zoomLevel = int(frameCount / width());
47 if (zoomLevel < 1) zoomLevel = 1; 47 if (zoomLevel < 1) zoomLevel = 1;
48 zoomLevel = getZoomConstraintBlockSize(zoomLevel, 48 zoomLevel = getZoomConstraintBlockSize(zoomLevel,
49 ZoomConstraint::RoundUp); 49 ZoomConstraint::RoundUp);
50 if (zoomLevel != m_zoomLevel) { 50 if (zoomLevel != m_zoomLevel) {
51 zoomChanged = true; 51 zoomChanged = true;
89 m_views.erase(view); 89 m_views.erase(view);
90 update(); 90 update();
91 } 91 }
92 92
93 void 93 void
94 Overview::globalCentreFrameChanged(int 94 Overview::globalCentreFrameChanged(sv_frame_t
95 #ifdef DEBUG_OVERVIEW 95 #ifdef DEBUG_OVERVIEW
96 f 96 f
97 #endif 97 #endif
98 ) 98 )
99 { 99 {
102 #endif 102 #endif
103 update(); 103 update();
104 } 104 }
105 105
106 void 106 void
107 Overview::viewCentreFrameChanged(View *v, int 107 Overview::viewCentreFrameChanged(View *v, sv_frame_t
108 #ifdef DEBUG_OVERVIEW 108 #ifdef DEBUG_OVERVIEW
109 f 109 f
110 #endif 110 #endif
111 ) 111 )
112 { 112 {
126 update(); 126 update();
127 } 127 }
128 } 128 }
129 129
130 void 130 void
131 Overview::viewManagerPlaybackFrameChanged(int f) 131 Overview::viewManagerPlaybackFrameChanged(sv_frame_t f)
132 { 132 {
133 #ifdef DEBUG_OVERVIEW 133 #ifdef DEBUG_OVERVIEW
134 cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl; 134 cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl;
135 #endif 135 #endif
136 136
151 151
152 #ifdef DEBUG_OVERVIEW 152 #ifdef DEBUG_OVERVIEW
153 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; 153 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl;
154 #endif 154 #endif
155 155
156 int startFrame = getModelsStartFrame(); 156 sv_frame_t startFrame = getModelsStartFrame();
157 int frameCount = getModelsEndFrame() - getModelsStartFrame(); 157 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame();
158 int zoomLevel = frameCount / width(); 158 int zoomLevel = int(frameCount / width());
159 if (zoomLevel < 1) zoomLevel = 1; 159 if (zoomLevel < 1) zoomLevel = 1;
160 zoomLevel = getZoomConstraintBlockSize(zoomLevel, 160 zoomLevel = getZoomConstraintBlockSize(zoomLevel,
161 ZoomConstraint::RoundUp); 161 ZoomConstraint::RoundUp);
162 if (zoomLevel != m_zoomLevel) { 162 if (zoomLevel != m_zoomLevel) {
163 m_zoomLevel = zoomLevel; 163 m_zoomLevel = zoomLevel;
164 emit zoomLevelChanged(m_zoomLevel, m_followZoom); 164 emit zoomLevelChanged(m_zoomLevel, m_followZoom);
165 } 165 }
166 166
167 int centreFrame = startFrame + m_zoomLevel * (width() / 2); 167 sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2);
168 if (centreFrame > (startFrame + getModelsEndFrame())/2) { 168 if (centreFrame > (startFrame + getModelsEndFrame())/2) {
169 centreFrame = (startFrame + getModelsEndFrame())/2; 169 centreFrame = (startFrame + getModelsEndFrame())/2;
170 } 170 }
171 if (centreFrame != m_centreFrame) { 171 if (centreFrame != m_centreFrame) {
172 #ifdef DEBUG_OVERVIEW 172 #ifdef DEBUG_OVERVIEW
194 194
195 paint.setPen(getForeground()); 195 paint.setPen(getForeground());
196 196
197 int y = 0; 197 int y = 0;
198 198
199 int prevx0 = -10; 199 sv_frame_t prevx0 = -10;
200 int prevx1 = -10; 200 sv_frame_t prevx1 = -10;
201 201
202 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { 202 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) {
203 if (!*i) continue; 203 if (!*i) continue;
204 204
205 View *w = (View *)*i; 205 View *w = (View *)*i;
206 206
207 int f0 = w->getFrameForX(0); 207 sv_frame_t f0 = w->getFrameForX(0);
208 int f1 = w->getFrameForX(w->width()); 208 sv_frame_t f1 = w->getFrameForX(w->width());
209 209
210 if (f0 >= 0) { 210 if (f0 >= 0) {
211 int rf0 = w->alignToReference(f0); 211 sv_frame_t rf0 = w->alignToReference(f0);
212 f0 = alignFromReference(rf0); 212 f0 = alignFromReference(rf0);
213 } 213 }
214 if (f1 >= 0) { 214 if (f1 >= 0) {
215 int rf1 = w->alignToReference(f1); 215 sv_frame_t rf1 = w->alignToReference(f1);
216 f1 = alignFromReference(rf1); 216 f1 = alignFromReference(rf1);
217 } 217 }
218 218
219 int x0 = getXForFrame(f0); 219 int x0 = getXForFrame(f0);
220 int x1 = getXForFrame(f1); 220 int x1 = getXForFrame(f1);
235 235
236 void 236 void
237 Overview::mousePressEvent(QMouseEvent *e) 237 Overview::mousePressEvent(QMouseEvent *e)
238 { 238 {
239 m_clickPos = e->pos(); 239 m_clickPos = e->pos();
240 int clickFrame = getFrameForX(m_clickPos.x()); 240 sv_frame_t clickFrame = getFrameForX(m_clickPos.x());
241 if (clickFrame > 0) m_dragCentreFrame = clickFrame; 241 if (clickFrame > 0) m_dragCentreFrame = clickFrame;
242 else m_dragCentreFrame = 0; 242 else m_dragCentreFrame = 0;
243 m_clickedInRange = true; 243 m_clickedInRange = true;
244 244
245 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { 245 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) {
263 Overview::mouseMoveEvent(QMouseEvent *e) 263 Overview::mouseMoveEvent(QMouseEvent *e)
264 { 264 {
265 if (!m_clickedInRange) return; 265 if (!m_clickedInRange) return;
266 266
267 int xoff = int(e->x()) - int(m_clickPos.x()); 267 int xoff = int(e->x()) - int(m_clickPos.x());
268 int frameOff = xoff * m_zoomLevel; 268 sv_frame_t frameOff = xoff * m_zoomLevel;
269 269
270 int newCentreFrame = m_dragCentreFrame; 270 sv_frame_t newCentreFrame = m_dragCentreFrame;
271 if (frameOff > 0) { 271 if (frameOff > 0) {
272 newCentreFrame += frameOff; 272 newCentreFrame += frameOff;
273 } else if (newCentreFrame >= int(-frameOff)) { 273 } else if (newCentreFrame >= -frameOff) {
274 newCentreFrame += frameOff; 274 newCentreFrame += frameOff;
275 } else { 275 } else {
276 newCentreFrame = 0; 276 newCentreFrame = 0;
277 } 277 }
278 278
280 newCentreFrame = getModelsEndFrame(); 280 newCentreFrame = getModelsEndFrame();
281 if (newCentreFrame > 0) --newCentreFrame; 281 if (newCentreFrame > 0) --newCentreFrame;
282 } 282 }
283 283
284 if (std::max(m_centreFrame, newCentreFrame) - 284 if (std::max(m_centreFrame, newCentreFrame) -
285 std::min(m_centreFrame, newCentreFrame) > int(m_zoomLevel)) { 285 std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) {
286 int rf = alignToReference(newCentreFrame); 286 sv_frame_t rf = alignToReference(newCentreFrame);
287 #ifdef DEBUG_OVERVIEW 287 #ifdef DEBUG_OVERVIEW
288 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; 288 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl;
289 #endif 289 #endif
290 if (m_followPlay == PlaybackScrollContinuous || 290 if (m_followPlay == PlaybackScrollContinuous ||
291 m_followPlay == PlaybackScrollPageWithCentre) { 291 m_followPlay == PlaybackScrollPageWithCentre) {
297 } 297 }
298 298
299 void 299 void
300 Overview::mouseDoubleClickEvent(QMouseEvent *e) 300 Overview::mouseDoubleClickEvent(QMouseEvent *e)
301 { 301 {
302 int frame = getFrameForX(e->x()); 302 sv_frame_t frame = getFrameForX(e->x());
303 int rf = 0; 303 sv_frame_t rf = 0;
304 if (frame > 0) rf = alignToReference(frame); 304 if (frame > 0) rf = alignToReference(frame);
305 #ifdef DEBUG_OVERVIEW 305 #ifdef DEBUG_OVERVIEW
306 cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl; 306 cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl;
307 #endif 307 #endif
308 m_clickedInRange = false; // we're not starting a drag with the second click 308 m_clickedInRange = false; // we're not starting a drag with the second click