comparison view/View.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 fe59d97750ba
children 40c6c9344ff6
comparison
equal deleted inserted replaced
805:1d526ba11a24 806:4c8ca536b54f
152 case 2: setPlaybackFollow(PlaybackIgnore); break; 152 case 2: setPlaybackFollow(PlaybackIgnore); break;
153 } 153 }
154 } 154 }
155 } 155 }
156 156
157 size_t 157 int
158 View::getPropertyContainerCount() const 158 View::getPropertyContainerCount() const
159 { 159 {
160 return m_layers.size() + 1; // the 1 is for me 160 return m_layers.size() + 1; // the 1 is for me
161 } 161 }
162 162
163 const PropertyContainer * 163 const PropertyContainer *
164 View::getPropertyContainer(size_t i) const 164 View::getPropertyContainer(int i) const
165 { 165 {
166 return (const PropertyContainer *)(((View *)this)-> 166 return (const PropertyContainer *)(((View *)this)->
167 getPropertyContainer(i)); 167 getPropertyContainer(i));
168 } 168 }
169 169
170 PropertyContainer * 170 PropertyContainer *
171 View::getPropertyContainer(size_t i) 171 View::getPropertyContainer(int i)
172 { 172 {
173 if (i == 0) return m_propertyContainer; 173 if (i == 0) return m_propertyContainer;
174 return m_layers[i-1]; 174 return m_layers[i-1];
175 } 175 }
176 176
289 View::zoomWheelsEnabledChanged() 289 View::zoomWheelsEnabledChanged()
290 { 290 {
291 // subclass might override this 291 // subclass might override this
292 } 292 }
293 293
294 long 294 int
295 View::getStartFrame() const 295 View::getStartFrame() const
296 { 296 {
297 return getFrameForX(0); 297 return getFrameForX(0);
298 } 298 }
299 299
300 size_t 300 int
301 View::getEndFrame() const 301 View::getEndFrame() const
302 { 302 {
303 return getFrameForX(width()) - 1; 303 return getFrameForX(width()) - 1;
304 } 304 }
305 305
306 void 306 void
307 View::setStartFrame(long f) 307 View::setStartFrame(int f)
308 { 308 {
309 setCentreFrame(f + m_zoomLevel * (width() / 2)); 309 setCentreFrame(f + m_zoomLevel * (width() / 2));
310 } 310 }
311 311
312 bool 312 bool
313 View::setCentreFrame(size_t f, bool e) 313 View::setCentreFrame(int f, bool e)
314 { 314 {
315 bool changeVisible = false; 315 bool changeVisible = false;
316 316
317 if (m_centreFrame != f) { 317 if (m_centreFrame != f) {
318 318
331 331
332 changeVisible = true; 332 changeVisible = true;
333 } 333 }
334 334
335 if (e) { 335 if (e) {
336 size_t rf = alignToReference(f); 336 int rf = alignToReference(f);
337 #ifdef DEBUG_VIEW_WIDGET_PAINT 337 #ifdef DEBUG_VIEW_WIDGET_PAINT
338 cerr << "View[" << this << "]::setCentreFrame(" << f 338 cerr << "View[" << this << "]::setCentreFrame(" << f
339 << "): emitting centreFrameChanged(" 339 << "): emitting centreFrameChanged("
340 << rf << ")" << endl; 340 << rf << ")" << endl;
341 #endif 341 #endif
345 345
346 return changeVisible; 346 return changeVisible;
347 } 347 }
348 348
349 int 349 int
350 View::getXForFrame(long frame) const 350 View::getXForFrame(int frame) const
351 { 351 {
352 return (frame - getStartFrame()) / m_zoomLevel; 352 return (frame - getStartFrame()) / m_zoomLevel;
353 } 353 }
354 354
355 long 355 int
356 View::getFrameForX(int x) const 356 View::getFrameForX(int x) const
357 { 357 {
358 long z = (long)m_zoomLevel; 358 int z = m_zoomLevel;
359 long frame = m_centreFrame - (width()/2) * z; 359 int frame = m_centreFrame - (width()/2) * z;
360 360
361 #ifdef DEBUG_VIEW_WIDGET_PAINT 361 #ifdef DEBUG_VIEW_WIDGET_PAINT
362 SVDEBUG << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl; 362 SVDEBUG << "View::getFrameForX(" << x << "): z = " << z << ", m_centreFrame = " << m_centreFrame << ", width() = " << width() << ", frame = " << frame << endl;
363 #endif 363 #endif
364 364
440 #endif 440 #endif
441 return m_zoomLevel; 441 return m_zoomLevel;
442 } 442 }
443 443
444 void 444 void
445 View::setZoomLevel(size_t z) 445 View::setZoomLevel(int z)
446 { 446 {
447 if (z < 1) z = 1; 447 if (z < 1) z = 1;
448 if (m_zoomLevel != int(z)) { 448 if (m_zoomLevel != int(z)) {
449 m_zoomLevel = z; 449 m_zoomLevel = z;
450 emit zoomLevelChanged(z, m_followZoom); 450 emit zoomLevelChanged(z, m_followZoom);
566 this, SLOT(modelChanged())); 566 this, SLOT(modelChanged()));
567 connect(layer, SIGNAL(modelCompletionChanged()), 567 connect(layer, SIGNAL(modelCompletionChanged()),
568 this, SLOT(modelCompletionChanged())); 568 this, SLOT(modelCompletionChanged()));
569 connect(layer, SIGNAL(modelAlignmentCompletionChanged()), 569 connect(layer, SIGNAL(modelAlignmentCompletionChanged()),
570 this, SLOT(modelAlignmentCompletionChanged())); 570 this, SLOT(modelAlignmentCompletionChanged()));
571 connect(layer, SIGNAL(modelChanged(size_t, size_t)), 571 connect(layer, SIGNAL(modelChangedWithin(int, int)),
572 this, SLOT(modelChanged(size_t, size_t))); 572 this, SLOT(modelChangedWithin(int, int)));
573 connect(layer, SIGNAL(modelReplaced()), 573 connect(layer, SIGNAL(modelReplaced()),
574 this, SLOT(modelReplaced())); 574 this, SLOT(modelReplaced()));
575 575
576 update(); 576 update();
577 577
610 this, SLOT(modelChanged())); 610 this, SLOT(modelChanged()));
611 disconnect(layer, SIGNAL(modelCompletionChanged()), 611 disconnect(layer, SIGNAL(modelCompletionChanged()),
612 this, SLOT(modelCompletionChanged())); 612 this, SLOT(modelCompletionChanged()));
613 disconnect(layer, SIGNAL(modelAlignmentCompletionChanged()), 613 disconnect(layer, SIGNAL(modelAlignmentCompletionChanged()),
614 this, SLOT(modelAlignmentCompletionChanged())); 614 this, SLOT(modelAlignmentCompletionChanged()));
615 disconnect(layer, SIGNAL(modelChanged(size_t, size_t)), 615 disconnect(layer, SIGNAL(modelChangedWithin(int, int)),
616 this, SLOT(modelChanged(size_t, size_t))); 616 this, SLOT(modelChangedWithin(int, int)));
617 disconnect(layer, SIGNAL(modelReplaced()), 617 disconnect(layer, SIGNAL(modelReplaced()),
618 this, SLOT(modelReplaced())); 618 this, SLOT(modelReplaced()));
619 619
620 update(); 620 update();
621 621
648 648
649 void 649 void
650 View::setViewManager(ViewManager *manager) 650 View::setViewManager(ViewManager *manager)
651 { 651 {
652 if (m_manager) { 652 if (m_manager) {
653 m_manager->disconnect(this, SLOT(globalCentreFrameChanged(unsigned long))); 653 m_manager->disconnect(this, SLOT(globalCentreFrameChanged(int)));
654 m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, unsigned long))); 654 m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, int)));
655 m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(unsigned long))); 655 m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(int)));
656 m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, unsigned long, bool))); 656 m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool)));
657 m_manager->disconnect(this, SLOT(toolModeChanged())); 657 m_manager->disconnect(this, SLOT(toolModeChanged()));
658 m_manager->disconnect(this, SLOT(selectionChanged())); 658 m_manager->disconnect(this, SLOT(selectionChanged()));
659 m_manager->disconnect(this, SLOT(overlayModeChanged())); 659 m_manager->disconnect(this, SLOT(overlayModeChanged()));
660 m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged())); 660 m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged()));
661 disconnect(m_manager, SLOT(viewCentreFrameChanged(unsigned long, bool, PlaybackFollowMode))); 661 disconnect(m_manager, SLOT(viewCentreFrameChanged(int, bool, PlaybackFollowMode)));
662 disconnect(m_manager, SLOT(zoomLevelChanged(unsigned long, bool))); 662 disconnect(m_manager, SLOT(zoomLevelChanged(int, bool)));
663 } 663 }
664 664
665 m_manager = manager; 665 m_manager = manager;
666 666
667 connect(m_manager, SIGNAL(globalCentreFrameChanged(unsigned long)), 667 connect(m_manager, SIGNAL(globalCentreFrameChanged(int)),
668 this, SLOT(globalCentreFrameChanged(unsigned long))); 668 this, SLOT(globalCentreFrameChanged(int)));
669 connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, unsigned long)), 669 connect(m_manager, SIGNAL(viewCentreFrameChanged(View *, int)),
670 this, SLOT(viewCentreFrameChanged(View *, unsigned long))); 670 this, SLOT(viewCentreFrameChanged(View *, int)));
671 connect(m_manager, SIGNAL(playbackFrameChanged(unsigned long)), 671 connect(m_manager, SIGNAL(playbackFrameChanged(int)),
672 this, SLOT(viewManagerPlaybackFrameChanged(unsigned long))); 672 this, SLOT(viewManagerPlaybackFrameChanged(int)));
673 673
674 connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, unsigned long, bool)), 674 connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)),
675 this, SLOT(viewZoomLevelChanged(View *, unsigned long, bool))); 675 this, SLOT(viewZoomLevelChanged(View *, int, bool)));
676 676
677 connect(m_manager, SIGNAL(toolModeChanged()), 677 connect(m_manager, SIGNAL(toolModeChanged()),
678 this, SLOT(toolModeChanged())); 678 this, SLOT(toolModeChanged()));
679 connect(m_manager, SIGNAL(selectionChanged()), 679 connect(m_manager, SIGNAL(selectionChanged()),
680 this, SLOT(selectionChanged())); 680 this, SLOT(selectionChanged()));
685 connect(m_manager, SIGNAL(showCentreLineChanged()), 685 connect(m_manager, SIGNAL(showCentreLineChanged()),
686 this, SLOT(overlayModeChanged())); 686 this, SLOT(overlayModeChanged()));
687 connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()), 687 connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()),
688 this, SLOT(zoomWheelsEnabledChanged())); 688 this, SLOT(zoomWheelsEnabledChanged()));
689 689
690 connect(this, SIGNAL(centreFrameChanged(unsigned long, bool, 690 connect(this, SIGNAL(centreFrameChanged(int, bool,
691 PlaybackFollowMode)), 691 PlaybackFollowMode)),
692 m_manager, SLOT(viewCentreFrameChanged(unsigned long, bool, 692 m_manager, SLOT(viewCentreFrameChanged(int, bool,
693 PlaybackFollowMode))); 693 PlaybackFollowMode)));
694 694
695 connect(this, SIGNAL(zoomLevelChanged(unsigned long, bool)), 695 connect(this, SIGNAL(zoomLevelChanged(int, bool)),
696 m_manager, SLOT(viewZoomLevelChanged(unsigned long, bool))); 696 m_manager, SLOT(viewZoomLevelChanged(int, bool)));
697 697
698 // setCentreFrame(m_manager->getViewInitialCentreFrame()); 698 // setCentreFrame(m_manager->getViewInitialCentreFrame());
699 699
700 if (m_followPlay == PlaybackScrollPage) { 700 if (m_followPlay == PlaybackScrollPage) {
701 // SVDEBUG << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << endl; 701 // SVDEBUG << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << endl;
714 714
715 toolModeChanged(); 715 toolModeChanged();
716 } 716 }
717 717
718 void 718 void
719 View::setViewManager(ViewManager *vm, long initialCentreFrame) 719 View::setViewManager(ViewManager *vm, int initialCentreFrame)
720 { 720 {
721 setViewManager(vm); 721 setViewManager(vm);
722 setCentreFrame(initialCentreFrame, false); 722 setCentreFrame(initialCentreFrame, false);
723 } 723 }
724 724
828 828
829 update(); 829 update();
830 } 830 }
831 831
832 void 832 void
833 View::modelChanged(size_t startFrame, size_t endFrame) 833 View::modelChangedWithin(int startFrame, int endFrame)
834 { 834 {
835 QObject *obj = sender(); 835 QObject *obj = sender();
836 836
837 long myStartFrame = getStartFrame(); 837 int myStartFrame = getStartFrame();
838 size_t myEndFrame = getEndFrame(); 838 int myEndFrame = getEndFrame();
839 839
840 #ifdef DEBUG_VIEW_WIDGET_PAINT 840 #ifdef DEBUG_VIEW_WIDGET_PAINT
841 cerr << "View(" << this << ")::modelChanged(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; 841 cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl;
842 #endif 842 #endif
843 843
844 if (myStartFrame > 0 && endFrame < size_t(myStartFrame)) { 844 if (myStartFrame > 0 && endFrame < int(myStartFrame)) {
845 checkProgress(obj); 845 checkProgress(obj);
846 return; 846 return;
847 } 847 }
848 if (startFrame > myEndFrame) { 848 if (startFrame > myEndFrame) {
849 checkProgress(obj); 849 checkProgress(obj);
868 if (recreate) { 868 if (recreate) {
869 delete m_cache; 869 delete m_cache;
870 m_cache = 0; 870 m_cache = 0;
871 } 871 }
872 872
873 if (long(startFrame) < myStartFrame) startFrame = myStartFrame; 873 if (startFrame < myStartFrame) startFrame = myStartFrame;
874 if (endFrame > myEndFrame) endFrame = myEndFrame; 874 if (endFrame > myEndFrame) endFrame = myEndFrame;
875 875
876 checkProgress(obj); 876 checkProgress(obj);
877 877
878 update(); 878 update();
946 Layer *layer = dynamic_cast<Layer *>(sender()); 946 Layer *layer = dynamic_cast<Layer *>(sender());
947 if (layer) emit propertyContainerNameChanged(layer); 947 if (layer) emit propertyContainerNameChanged(layer);
948 } 948 }
949 949
950 void 950 void
951 View::globalCentreFrameChanged(unsigned long rf) 951 View::globalCentreFrameChanged(int rf)
952 { 952 {
953 if (m_followPan) { 953 if (m_followPan) {
954 size_t f = alignFromReference(rf); 954 int f = alignFromReference(rf);
955 #ifdef DEBUG_VIEW_WIDGET_PAINT 955 #ifdef DEBUG_VIEW_WIDGET_PAINT
956 cerr << "View[" << this << "]::globalCentreFrameChanged(" << rf 956 cerr << "View[" << this << "]::globalCentreFrameChanged(" << rf
957 << "): setting centre frame to " << f << endl; 957 << "): setting centre frame to " << f << endl;
958 #endif 958 #endif
959 setCentreFrame(f, false); 959 setCentreFrame(f, false);
960 } 960 }
961 } 961 }
962 962
963 void 963 void
964 View::viewCentreFrameChanged(View *, unsigned long ) 964 View::viewCentreFrameChanged(View *, int )
965 { 965 {
966 // We do nothing with this, but a subclass might 966 // We do nothing with this, but a subclass might
967 } 967 }
968 968
969 void 969 void
970 View::viewManagerPlaybackFrameChanged(unsigned long f) 970 View::viewManagerPlaybackFrameChanged(int f)
971 { 971 {
972 if (m_manager) { 972 if (m_manager) {
973 if (sender() != m_manager) return; 973 if (sender() != m_manager) return;
974 } 974 }
975 975
977 977
978 movePlayPointer(f); 978 movePlayPointer(f);
979 } 979 }
980 980
981 void 981 void
982 View::movePlayPointer(unsigned long newFrame) 982 View::movePlayPointer(int newFrame)
983 { 983 {
984 if (m_playPointerFrame == newFrame) return; 984 if (m_playPointerFrame == newFrame) return;
985 bool visibleChange = 985 bool visibleChange =
986 (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame)); 986 (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame));
987 size_t oldPlayPointerFrame = m_playPointerFrame; 987 int oldPlayPointerFrame = m_playPointerFrame;
988 m_playPointerFrame = newFrame; 988 m_playPointerFrame = newFrame;
989 if (!visibleChange) return; 989 if (!visibleChange) return;
990 990
991 bool somethingGoingOn = 991 bool somethingGoingOn =
992 ((QApplication::mouseButtons() != Qt::NoButton) || 992 ((QApplication::mouseButtons() != Qt::NoButton) ||
1003 case PlaybackScrollPage: 1003 case PlaybackScrollPage:
1004 { 1004 {
1005 int xold = getXForFrame(oldPlayPointerFrame); 1005 int xold = getXForFrame(oldPlayPointerFrame);
1006 update(xold - 4, 0, 9, height()); 1006 update(xold - 4, 0, 9, height());
1007 1007
1008 long w = getEndFrame() - getStartFrame(); 1008 int w = getEndFrame() - getStartFrame();
1009 w -= w/5; 1009 w -= w/5;
1010 long sf = (m_playPointerFrame / w) * w - w/8; 1010 int sf = (m_playPointerFrame / w) * w - w/8;
1011 1011
1012 if (m_manager && 1012 if (m_manager &&
1013 m_manager->isPlaying() && 1013 m_manager->isPlaying() &&
1014 m_manager->getPlaySelectionMode()) { 1014 m_manager->getPlaySelectionMode()) {
1015 MultiSelection::SelectionList selections = m_manager->getSelections(); 1015 MultiSelection::SelectionList selections = m_manager->getSelections();
1016 if (!selections.empty()) { 1016 if (!selections.empty()) {
1017 size_t selectionStart = selections.begin()->getStartFrame(); 1017 int selectionStart = selections.begin()->getStartFrame();
1018 if (sf < long(selectionStart) - w / 10) { 1018 if (sf < selectionStart - w / 10) {
1019 sf = long(selectionStart) - w / 10; 1019 sf = selectionStart - w / 10;
1020 } 1020 }
1021 } 1021 }
1022 } 1022 }
1023 1023
1024 #ifdef DEBUG_VIEW_WIDGET_PAINT 1024 #ifdef DEBUG_VIEW_WIDGET_PAINT
1035 cerr << "xnew = " << xnew << ", width = " << width() << endl; 1035 cerr << "xnew = " << xnew << ", width = " << width() << endl;
1036 #endif 1036 #endif
1037 1037
1038 if (xnew < width()/8 || xnew > (width()*7)/8) { 1038 if (xnew < width()/8 || xnew > (width()*7)/8) {
1039 if (!somethingGoingOn) { 1039 if (!somethingGoingOn) {
1040 long offset = getFrameForX(width()/2) - getStartFrame(); 1040 int offset = getFrameForX(width()/2) - getStartFrame();
1041 long newCentre = sf + offset; 1041 int newCentre = sf + offset;
1042 bool changed = setCentreFrame(newCentre, false); 1042 bool changed = setCentreFrame(newCentre, false);
1043 if (changed) { 1043 if (changed) {
1044 xold = getXForFrame(oldPlayPointerFrame); 1044 xold = getXForFrame(oldPlayPointerFrame);
1045 update(xold - 4, 0, 9, height()); 1045 update(xold - 4, 0, 9, height());
1046 } 1046 }
1051 1051
1052 break; 1052 break;
1053 } 1053 }
1054 1054
1055 case PlaybackIgnore: 1055 case PlaybackIgnore:
1056 if (long(m_playPointerFrame) >= getStartFrame() && 1056 if (m_playPointerFrame >= getStartFrame() &&
1057 m_playPointerFrame < getEndFrame()) { 1057 m_playPointerFrame < getEndFrame()) {
1058 update(); 1058 update();
1059 } 1059 }
1060 break; 1060 break;
1061 } 1061 }
1062 } 1062 }
1063 1063
1064 void 1064 void
1065 View::viewZoomLevelChanged(View *p, unsigned long z, bool locked) 1065 View::viewZoomLevelChanged(View *p, int z, bool locked)
1066 { 1066 {
1067 #ifdef DEBUG_VIEW_WIDGET_PAINT 1067 #ifdef DEBUG_VIEW_WIDGET_PAINT
1068 cerr << "View[" << this << "]: viewZoomLevelChanged(" << p << ", " << z << ", " << locked << ")" << endl; 1068 cerr << "View[" << this << "]: viewZoomLevelChanged(" << p << ", " << z << ", " << locked << ")" << endl;
1069 #endif 1069 #endif
1070 if (m_followZoom && p != this && locked) { 1070 if (m_followZoom && p != this && locked) {
1081 m_selectionCached = false; 1081 m_selectionCached = false;
1082 } 1082 }
1083 update(); 1083 update();
1084 } 1084 }
1085 1085
1086 size_t 1086 int
1087 View::getFirstVisibleFrame() const 1087 View::getFirstVisibleFrame() const
1088 { 1088 {
1089 long f0 = getStartFrame(); 1089 int f0 = getStartFrame();
1090 size_t f = getModelsStartFrame(); 1090 int f = getModelsStartFrame();
1091 if (f0 < 0 || f0 < long(f)) return f; 1091 if (f0 < 0 || f0 < f) return f;
1092 return f0; 1092 return f0;
1093 } 1093 }
1094 1094
1095 size_t 1095 int
1096 View::getLastVisibleFrame() const 1096 View::getLastVisibleFrame() const
1097 { 1097 {
1098 size_t f0 = getEndFrame(); 1098 int f0 = getEndFrame();
1099 size_t f = getModelsEndFrame(); 1099 int f = getModelsEndFrame();
1100 if (f0 > f) return f; 1100 if (f0 > f) return f;
1101 return f0; 1101 return f0;
1102 } 1102 }
1103 1103
1104 size_t 1104 int
1105 View::getModelsStartFrame() const 1105 View::getModelsStartFrame() const
1106 { 1106 {
1107 bool first = true; 1107 bool first = true;
1108 size_t startFrame = 0; 1108 int startFrame = 0;
1109 1109
1110 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { 1110 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
1111 1111
1112 if ((*i)->getModel() && (*i)->getModel()->isOK()) { 1112 if ((*i)->getModel() && (*i)->getModel()->isOK()) {
1113 1113
1114 size_t thisStartFrame = (*i)->getModel()->getStartFrame(); 1114 int thisStartFrame = (*i)->getModel()->getStartFrame();
1115 1115
1116 if (first || thisStartFrame < startFrame) { 1116 if (first || thisStartFrame < startFrame) {
1117 startFrame = thisStartFrame; 1117 startFrame = thisStartFrame;
1118 } 1118 }
1119 first = false; 1119 first = false;
1120 } 1120 }
1121 } 1121 }
1122 return startFrame; 1122 return startFrame;
1123 } 1123 }
1124 1124
1125 size_t 1125 int
1126 View::getModelsEndFrame() const 1126 View::getModelsEndFrame() const
1127 { 1127 {
1128 bool first = true; 1128 bool first = true;
1129 size_t endFrame = 0; 1129 int endFrame = 0;
1130 1130
1131 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { 1131 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
1132 1132
1133 if ((*i)->getModel() && (*i)->getModel()->isOK()) { 1133 if ((*i)->getModel() && (*i)->getModel()->isOK()) {
1134 1134
1135 size_t thisEndFrame = (*i)->getModel()->getEndFrame(); 1135 int thisEndFrame = (*i)->getModel()->getEndFrame();
1136 1136
1137 if (first || thisEndFrame > endFrame) { 1137 if (first || thisEndFrame > endFrame) {
1138 endFrame = thisEndFrame; 1138 endFrame = thisEndFrame;
1139 } 1139 }
1140 first = false; 1140 first = false;
1222 if (goodModel) return goodModel; 1222 if (goodModel) return goodModel;
1223 else if (alignedModel) return alignedModel; 1223 else if (alignedModel) return alignedModel;
1224 else return anyModel; 1224 else return anyModel;
1225 } 1225 }
1226 1226
1227 size_t 1227 int
1228 View::alignFromReference(size_t f) const 1228 View::alignFromReference(int f) const
1229 { 1229 {
1230 if (!m_manager->getAlignMode()) return f; 1230 if (!m_manager->getAlignMode()) return f;
1231 Model *aligningModel = getAligningModel(); 1231 Model *aligningModel = getAligningModel();
1232 if (!aligningModel) return f; 1232 if (!aligningModel) return f;
1233 return aligningModel->alignFromReference(f); 1233 return aligningModel->alignFromReference(f);
1234 } 1234 }
1235 1235
1236 size_t 1236 int
1237 View::alignToReference(size_t f) const 1237 View::alignToReference(int f) const
1238 { 1238 {
1239 if (!m_manager->getAlignMode()) return f; 1239 if (!m_manager->getAlignMode()) return f;
1240 Model *aligningModel = getAligningModel(); 1240 Model *aligningModel = getAligningModel();
1241 if (!aligningModel) return f; 1241 if (!aligningModel) return f;
1242 return aligningModel->alignToReference(f); 1242 return aligningModel->alignToReference(f);
1342 } 1342 }
1343 1343
1344 return nonScrollables; 1344 return nonScrollables;
1345 } 1345 }
1346 1346
1347 size_t 1347 int
1348 View::getZoomConstraintBlockSize(size_t blockSize, 1348 View::getZoomConstraintBlockSize(int blockSize,
1349 ZoomConstraint::RoundingDirection dir) 1349 ZoomConstraint::RoundingDirection dir)
1350 const 1350 const
1351 { 1351 {
1352 size_t candidate = blockSize; 1352 int candidate = blockSize;
1353 bool haveCandidate = false; 1353 bool haveCandidate = false;
1354 1354
1355 PowerOfSqrtTwoZoomConstraint defaultZoomConstraint; 1355 PowerOfSqrtTwoZoomConstraint defaultZoomConstraint;
1356 1356
1357 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { 1357 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
1358 1358
1359 const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint(); 1359 const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint();
1360 if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint; 1360 if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint;
1361 1361
1362 size_t thisBlockSize = 1362 int thisBlockSize =
1363 zoomConstraint->getNearestBlockSize(blockSize, dir); 1363 zoomConstraint->getNearestBlockSize(blockSize, dir);
1364 1364
1365 // Go for the block size that's furthest from the one 1365 // Go for the block size that's furthest from the one
1366 // passed in. Most of the time, that's what we want. 1366 // passed in. Most of the time, that's what we want.
1367 if (!haveCandidate || 1367 if (!haveCandidate ||
1414 } 1414 }
1415 1415
1416 void 1416 void
1417 View::scroll(bool right, bool lots, bool e) 1417 View::scroll(bool right, bool lots, bool e)
1418 { 1418 {
1419 long delta; 1419 int delta;
1420 if (lots) { 1420 if (lots) {
1421 delta = (getEndFrame() - getStartFrame()) / 2; 1421 delta = (getEndFrame() - getStartFrame()) / 2;
1422 } else { 1422 } else {
1423 delta = (getEndFrame() - getStartFrame()) / 20; 1423 delta = (getEndFrame() - getStartFrame()) / 20;
1424 } 1424 }
1600 bool layersChanged = false; 1600 bool layersChanged = false;
1601 LayerList scrollables = getScrollableBackLayers(true, layersChanged); 1601 LayerList scrollables = getScrollableBackLayers(true, layersChanged);
1602 LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged); 1602 LayerList nonScrollables = getNonScrollableFrontLayers(true, layersChanged);
1603 bool selectionCacheable = nonScrollables.empty(); 1603 bool selectionCacheable = nonScrollables.empty();
1604 bool haveSelections = m_manager && !m_manager->getSelections().empty(); 1604 bool haveSelections = m_manager && !m_manager->getSelections().empty();
1605 bool selectionDrawn = false;
1606 1605
1607 // If all the non-scrollable layers are non-opaque, then we draw 1606 // If all the non-scrollable layers are non-opaque, then we draw
1608 // the selection rectangle behind them and cache it. If any are 1607 // the selection rectangle behind them and cache it. If any are
1609 // opaque, however, we can't cache. 1608 // opaque, however, we can't cache.
1610 // 1609 //
1672 repaintCache = true; 1671 repaintCache = true;
1673 } 1672 }
1674 1673
1675 } else if (m_cacheCentreFrame != m_centreFrame) { 1674 } else if (m_cacheCentreFrame != m_centreFrame) {
1676 1675
1677 long dx = 1676 int dx =
1678 getXForFrame(m_cacheCentreFrame) - 1677 getXForFrame(m_cacheCentreFrame) -
1679 getXForFrame(m_centreFrame); 1678 getXForFrame(m_centreFrame);
1680 1679
1681 if (dx > -width() && dx < width()) { 1680 if (dx > -width() && dx < width()) {
1682 #ifdef PIXMAP_COPY_TO_SELF 1681 #ifdef PIXMAP_COPY_TO_SELF
1764 } 1763 }
1765 1764
1766 if (haveSelections && selectionCacheable) { 1765 if (haveSelections && selectionCacheable) {
1767 drawSelections(paint); 1766 drawSelections(paint);
1768 m_selectionCached = repaintCache; 1767 m_selectionCached = repaintCache;
1769 selectionDrawn = true;
1770 } 1768 }
1771 1769
1772 paint.end(); 1770 paint.end();
1773 1771
1774 if (repaintCache) { 1772 if (repaintCache) {
1813 paint.end(); 1811 paint.end();
1814 1812
1815 bool showPlayPointer = true; 1813 bool showPlayPointer = true;
1816 if (m_followPlay == PlaybackScrollContinuous) { 1814 if (m_followPlay == PlaybackScrollContinuous) {
1817 showPlayPointer = false; 1815 showPlayPointer = false;
1818 } else if (long(m_playPointerFrame) <= getStartFrame() || 1816 } else if (m_playPointerFrame <= getStartFrame() ||
1819 m_playPointerFrame >= getEndFrame()) { 1817 m_playPointerFrame >= getEndFrame()) {
1820 showPlayPointer = false; 1818 showPlayPointer = false;
1821 } else if (m_manager && !m_manager->isPlaying()) { 1819 } else if (m_manager && !m_manager->isPlaying()) {
1822 if (m_playPointerFrame == getCentreFrame() && 1820 if (m_playPointerFrame == getCentreFrame() &&
1823 m_followPlay != PlaybackIgnore) { 1821 m_followPlay != PlaybackIgnore) {
1874 } 1872 }
1875 1873
1876 int sampleRate = getModelsSampleRate(); 1874 int sampleRate = getModelsSampleRate();
1877 1875
1878 QPoint localPos; 1876 QPoint localPos;
1879 long illuminateFrame = -1; 1877 int illuminateFrame = -1;
1880 bool closeToLeft, closeToRight; 1878 bool closeToLeft, closeToRight;
1881 1879
1882 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) { 1880 if (shouldIlluminateLocalSelection(localPos, closeToLeft, closeToRight)) {
1883 illuminateFrame = getFrameForX(localPos.x()); 1881 illuminateFrame = getFrameForX(localPos.x());
1884 } 1882 }
2230 2228
2231 paint.restore(); 2229 paint.restore();
2232 } 2230 }
2233 2231
2234 bool 2232 bool
2235 View::render(QPainter &paint, int xorigin, size_t f0, size_t f1) 2233 View::render(QPainter &paint, int xorigin, int f0, int f1)
2236 { 2234 {
2237 size_t x0 = f0 / m_zoomLevel; 2235 int x0 = f0 / m_zoomLevel;
2238 size_t x1 = f1 / m_zoomLevel; 2236 int x1 = f1 / m_zoomLevel;
2239 2237
2240 size_t w = x1 - x0; 2238 int w = x1 - x0;
2241 2239
2242 size_t origCentreFrame = m_centreFrame; 2240 int origCentreFrame = m_centreFrame;
2243 2241
2244 bool someLayersIncomplete = false; 2242 bool someLayersIncomplete = false;
2245 2243
2246 for (LayerList::iterator i = m_layers.begin(); 2244 for (LayerList::iterator i = m_layers.begin();
2247 i != m_layers.end(); ++i) { 2245 i != m_layers.end(); ++i) {
2285 } 2283 }
2286 2284
2287 QProgressDialog progress(tr("Rendering image..."), 2285 QProgressDialog progress(tr("Rendering image..."),
2288 tr("Cancel"), 0, w / width(), this); 2286 tr("Cancel"), 0, w / width(), this);
2289 2287
2290 for (size_t x = 0; x < w; x += width()) { 2288 for (int x = 0; x < w; x += width()) {
2291 2289
2292 progress.setValue(x / width()); 2290 progress.setValue(x / width());
2293 qApp->processEvents(); 2291 qApp->processEvents();
2294 if (progress.wasCanceled()) { 2292 if (progress.wasCanceled()) {
2295 m_centreFrame = origCentreFrame; 2293 m_centreFrame = origCentreFrame;
2337 } 2335 }
2338 2336
2339 QImage * 2337 QImage *
2340 View::toNewImage() 2338 View::toNewImage()
2341 { 2339 {
2342 size_t f0 = getModelsStartFrame(); 2340 int f0 = getModelsStartFrame();
2343 size_t f1 = getModelsEndFrame(); 2341 int f1 = getModelsEndFrame();
2344 2342
2345 return toNewImage(f0, f1); 2343 return toNewImage(f0, f1);
2346 } 2344 }
2347 2345
2348 QImage * 2346 QImage *
2349 View::toNewImage(size_t f0, size_t f1) 2347 View::toNewImage(int f0, int f1)
2350 { 2348 {
2351 size_t x0 = f0 / getZoomLevel(); 2349 int x0 = f0 / getZoomLevel();
2352 size_t x1 = f1 / getZoomLevel(); 2350 int x1 = f1 / getZoomLevel();
2353 2351
2354 QImage *image = new QImage(x1 - x0, height(), QImage::Format_RGB32); 2352 QImage *image = new QImage(x1 - x0, height(), QImage::Format_RGB32);
2355 2353
2356 QPainter *paint = new QPainter(image); 2354 QPainter *paint = new QPainter(image);
2357 if (!render(*paint, 0, f0, f1)) { 2355 if (!render(*paint, 0, f0, f1)) {
2365 } 2363 }
2366 2364
2367 QSize 2365 QSize
2368 View::getImageSize() 2366 View::getImageSize()
2369 { 2367 {
2370 size_t f0 = getModelsStartFrame(); 2368 int f0 = getModelsStartFrame();
2371 size_t f1 = getModelsEndFrame(); 2369 int f1 = getModelsEndFrame();
2372 2370
2373 return getImageSize(f0, f1); 2371 return getImageSize(f0, f1);
2374 } 2372 }
2375 2373
2376 QSize 2374 QSize
2377 View::getImageSize(size_t f0, size_t f1) 2375 View::getImageSize(int f0, int f1)
2378 { 2376 {
2379 size_t x0 = f0 / getZoomLevel(); 2377 int x0 = f0 / getZoomLevel();
2380 size_t x1 = f1 / getZoomLevel(); 2378 int x1 = f1 / getZoomLevel();
2381 2379
2382 return QSize(x1 - x0, height()); 2380 return QSize(x1 - x0, height());
2383 } 2381 }
2384 2382
2385 void 2383 void
2401 .arg(m_followZoom) 2399 .arg(m_followZoom)
2402 .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" : 2400 .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" :
2403 m_followPlay == PlaybackScrollPage ? "page" : "ignore") 2401 m_followPlay == PlaybackScrollPage ? "page" : "ignore")
2404 .arg(extraAttributes); 2402 .arg(extraAttributes);
2405 2403
2406 for (size_t i = 0; i < m_layers.size(); ++i) { 2404 for (int i = 0; i < (int)m_layers.size(); ++i) {
2407 bool visible = !m_layers[i]->isLayerDormant(this); 2405 bool visible = !m_layers[i]->isLayerDormant(this);
2408 m_layers[i]->toBriefXml(stream, indent + " ", 2406 m_layers[i]->toBriefXml(stream, indent + " ",
2409 QString("visible=\"%1\"") 2407 QString("visible=\"%1\"")
2410 .arg(visible ? "true" : "false")); 2408 .arg(visible ? "true" : "false"));
2411 } 2409 }