comparison view/Overview.cpp @ 806:4c8ca536b54f warnfix_no_size_t

Some more unsigned/long removal
author Chris Cannam
date Tue, 17 Jun 2014 15:36:56 +0100
parents 1a0dfcbffaf1
children 40c6c9344ff6
comparison
equal deleted inserted replaced
805:1d526ba11a24 806:4c8ca536b54f
37 setPlaybackFollow(PlaybackIgnore); 37 setPlaybackFollow(PlaybackIgnore);
38 m_modelTestTime.start(); 38 m_modelTestTime.start();
39 } 39 }
40 40
41 void 41 void
42 Overview::modelChanged(size_t startFrame, size_t endFrame) 42 Overview::modelChangedWithin(int startFrame, int endFrame)
43 { 43 {
44 bool zoomChanged = false; 44 bool zoomChanged = false;
45 45
46 size_t frameCount = getModelsEndFrame() - getModelsStartFrame(); 46 int frameCount = getModelsEndFrame() - getModelsStartFrame();
47 int zoomLevel = frameCount / width(); 47 int zoomLevel = frameCount / width();
48 if (zoomLevel < 1) zoomLevel = 1; 48 if (zoomLevel < 1) zoomLevel = 1;
49 zoomLevel = getZoomConstraintBlockSize(zoomLevel, 49 zoomLevel = getZoomConstraintBlockSize(zoomLevel,
50 ZoomConstraint::RoundUp); 50 ZoomConstraint::RoundUp);
51 if (zoomLevel != m_zoomLevel) { 51 if (zoomLevel != m_zoomLevel) {
65 } else { 65 } else {
66 m_modelTestTime.restart(); 66 m_modelTestTime.restart();
67 } 67 }
68 } 68 }
69 69
70 View::modelChanged(startFrame, endFrame); 70 View::modelChangedWithin(startFrame, endFrame);
71 } 71 }
72 72
73 void 73 void
74 Overview::modelReplaced() 74 Overview::modelReplaced()
75 { 75 {
90 m_views.erase(view); 90 m_views.erase(view);
91 update(); 91 update();
92 } 92 }
93 93
94 void 94 void
95 Overview::globalCentreFrameChanged(unsigned long f) 95 Overview::globalCentreFrameChanged(int
96 #ifdef DEBUG_OVERVIEW
97 f
98 #endif
99 )
96 { 100 {
97 #ifdef DEBUG_OVERVIEW 101 #ifdef DEBUG_OVERVIEW
98 cerr << "Overview::globalCentreFrameChanged: " << f << endl; 102 cerr << "Overview::globalCentreFrameChanged: " << f << endl;
99 #endif 103 #endif
100 update(); 104 update();
101 } 105 }
102 106
103 void 107 void
104 Overview::viewCentreFrameChanged(View *v, unsigned long f) 108 Overview::viewCentreFrameChanged(View *v, int
109 #ifdef DEBUG_OVERVIEW
110 f
111 #endif
112 )
105 { 113 {
106 #ifdef DEBUG_OVERVIEW 114 #ifdef DEBUG_OVERVIEW
107 cerr << "Overview[" << this << "]::viewCentreFrameChanged(" << v << "): " << f << endl; 115 cerr << "Overview[" << this << "]::viewCentreFrameChanged(" << v << "): " << f << endl;
108 #endif 116 #endif
109 if (m_views.find(v) != m_views.end()) { 117 if (m_views.find(v) != m_views.end()) {
110 update(); 118 update();
111 } 119 }
112 } 120 }
113 121
114 void 122 void
115 Overview::viewZoomLevelChanged(View *v, unsigned long, bool) 123 Overview::viewZoomLevelChanged(View *v, int, bool)
116 { 124 {
117 if (v == this) return; 125 if (v == this) return;
118 if (m_views.find(v) != m_views.end()) { 126 if (m_views.find(v) != m_views.end()) {
119 update(); 127 update();
120 } 128 }
121 } 129 }
122 130
123 void 131 void
124 Overview::viewManagerPlaybackFrameChanged(unsigned long f) 132 Overview::viewManagerPlaybackFrameChanged(int f)
125 { 133 {
126 #ifdef DEBUG_OVERVIEW 134 #ifdef DEBUG_OVERVIEW
127 cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl; 135 cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << endl;
128 #endif 136 #endif
129 137
144 152
145 #ifdef DEBUG_OVERVIEW 153 #ifdef DEBUG_OVERVIEW
146 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; 154 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl;
147 #endif 155 #endif
148 156
149 size_t startFrame = getModelsStartFrame(); 157 int startFrame = getModelsStartFrame();
150 size_t frameCount = getModelsEndFrame() - getModelsStartFrame(); 158 int frameCount = getModelsEndFrame() - getModelsStartFrame();
151 int zoomLevel = frameCount / width(); 159 int zoomLevel = frameCount / width();
152 if (zoomLevel < 1) zoomLevel = 1; 160 if (zoomLevel < 1) zoomLevel = 1;
153 zoomLevel = getZoomConstraintBlockSize(zoomLevel, 161 zoomLevel = getZoomConstraintBlockSize(zoomLevel,
154 ZoomConstraint::RoundUp); 162 ZoomConstraint::RoundUp);
155 if (zoomLevel != m_zoomLevel) { 163 if (zoomLevel != m_zoomLevel) {
156 m_zoomLevel = zoomLevel; 164 m_zoomLevel = zoomLevel;
157 emit zoomLevelChanged(m_zoomLevel, m_followZoom); 165 emit zoomLevelChanged(m_zoomLevel, m_followZoom);
158 } 166 }
159 167
160 size_t centreFrame = startFrame + m_zoomLevel * (width() / 2); 168 int centreFrame = startFrame + m_zoomLevel * (width() / 2);
161 if (centreFrame > (startFrame + getModelsEndFrame())/2) { 169 if (centreFrame > (startFrame + getModelsEndFrame())/2) {
162 centreFrame = (startFrame + getModelsEndFrame())/2; 170 centreFrame = (startFrame + getModelsEndFrame())/2;
163 } 171 }
164 if (centreFrame != m_centreFrame) { 172 if (centreFrame != m_centreFrame) {
165 #ifdef DEBUG_OVERVIEW 173 #ifdef DEBUG_OVERVIEW
195 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { 203 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) {
196 if (!*i) continue; 204 if (!*i) continue;
197 205
198 View *w = (View *)*i; 206 View *w = (View *)*i;
199 207
200 long f0 = w->getFrameForX(0); 208 int f0 = w->getFrameForX(0);
201 long f1 = w->getFrameForX(w->width()); 209 int f1 = w->getFrameForX(w->width());
202 210
203 if (f0 >= 0) { 211 if (f0 >= 0) {
204 size_t rf0 = w->alignToReference(f0); 212 int rf0 = w->alignToReference(f0);
205 f0 = alignFromReference(rf0); 213 f0 = alignFromReference(rf0);
206 } 214 }
207 if (f1 >= 0) { 215 if (f1 >= 0) {
208 size_t rf1 = w->alignToReference(f1); 216 int rf1 = w->alignToReference(f1);
209 f1 = alignFromReference(rf1); 217 f1 = alignFromReference(rf1);
210 } 218 }
211 219
212 int x0 = getXForFrame(f0); 220 int x0 = getXForFrame(f0);
213 int x1 = getXForFrame(f1); 221 int x1 = getXForFrame(f1);
228 236
229 void 237 void
230 Overview::mousePressEvent(QMouseEvent *e) 238 Overview::mousePressEvent(QMouseEvent *e)
231 { 239 {
232 m_clickPos = e->pos(); 240 m_clickPos = e->pos();
233 long clickFrame = getFrameForX(m_clickPos.x()); 241 int clickFrame = getFrameForX(m_clickPos.x());
234 if (clickFrame > 0) m_dragCentreFrame = clickFrame; 242 if (clickFrame > 0) m_dragCentreFrame = clickFrame;
235 else m_dragCentreFrame = 0; 243 else m_dragCentreFrame = 0;
236 m_clickedInRange = true; 244 m_clickedInRange = true;
237 245
238 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) { 246 for (ViewSet::iterator i = m_views.begin(); i != m_views.end(); ++i) {
255 void 263 void
256 Overview::mouseMoveEvent(QMouseEvent *e) 264 Overview::mouseMoveEvent(QMouseEvent *e)
257 { 265 {
258 if (!m_clickedInRange) return; 266 if (!m_clickedInRange) return;
259 267
260 long xoff = int(e->x()) - int(m_clickPos.x()); 268 int xoff = int(e->x()) - int(m_clickPos.x());
261 long frameOff = xoff * m_zoomLevel; 269 int frameOff = xoff * m_zoomLevel;
262 270
263 size_t newCentreFrame = m_dragCentreFrame; 271 int newCentreFrame = m_dragCentreFrame;
264 if (frameOff > 0) { 272 if (frameOff > 0) {
265 newCentreFrame += frameOff; 273 newCentreFrame += frameOff;
266 } else if (newCentreFrame >= size_t(-frameOff)) { 274 } else if (newCentreFrame >= int(-frameOff)) {
267 newCentreFrame += frameOff; 275 newCentreFrame += frameOff;
268 } else { 276 } else {
269 newCentreFrame = 0; 277 newCentreFrame = 0;
270 } 278 }
271 279
273 newCentreFrame = getModelsEndFrame(); 281 newCentreFrame = getModelsEndFrame();
274 if (newCentreFrame > 0) --newCentreFrame; 282 if (newCentreFrame > 0) --newCentreFrame;
275 } 283 }
276 284
277 if (std::max(m_centreFrame, newCentreFrame) - 285 if (std::max(m_centreFrame, newCentreFrame) -
278 std::min(m_centreFrame, newCentreFrame) > size_t(m_zoomLevel)) { 286 std::min(m_centreFrame, newCentreFrame) > int(m_zoomLevel)) {
279 size_t rf = alignToReference(newCentreFrame); 287 int rf = alignToReference(newCentreFrame);
280 #ifdef DEBUG_OVERVIEW 288 #ifdef DEBUG_OVERVIEW
281 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; 289 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl;
282 #endif 290 #endif
283 emit centreFrameChanged(rf, true, PlaybackScrollContinuous); 291 emit centreFrameChanged(rf, true, PlaybackScrollContinuous);
284 } 292 }
285 } 293 }
286 294
287 void 295 void
288 Overview::mouseDoubleClickEvent(QMouseEvent *e) 296 Overview::mouseDoubleClickEvent(QMouseEvent *e)
289 { 297 {
290 long frame = getFrameForX(e->x()); 298 int frame = getFrameForX(e->x());
291 size_t rf = 0; 299 int rf = 0;
292 if (frame > 0) rf = alignToReference(frame); 300 if (frame > 0) rf = alignToReference(frame);
293 #ifdef DEBUG_OVERVIEW 301 #ifdef DEBUG_OVERVIEW
294 cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl; 302 cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << endl;
295 #endif 303 #endif
296 m_clickedInRange = false; // we're not starting a drag with the second click 304 m_clickedInRange = false; // we're not starting a drag with the second click