comparison view/View.cpp @ 1481:e540aa5d89cd by-id

Update for removal of (public) getId from Model
author Chris Cannam
date Fri, 05 Jul 2019 15:34:50 +0100
parents 9bf8aa2916e9
children c1cae369979d
comparison
equal deleted inserted replaced
1480:232262e38051 1481:e540aa5d89cd
704 this, SLOT(layerParameterRangesChanged())); 704 this, SLOT(layerParameterRangesChanged()));
705 connect(layer, SIGNAL(layerMeasurementRectsChanged()), 705 connect(layer, SIGNAL(layerMeasurementRectsChanged()),
706 this, SLOT(layerMeasurementRectsChanged())); 706 this, SLOT(layerMeasurementRectsChanged()));
707 connect(layer, SIGNAL(layerNameChanged()), 707 connect(layer, SIGNAL(layerNameChanged()),
708 this, SLOT(layerNameChanged())); 708 this, SLOT(layerNameChanged()));
709 connect(layer, SIGNAL(modelChanged()), 709 connect(layer, SIGNAL(modelChanged(ModelId)),
710 this, SLOT(modelChanged())); 710 this, SLOT(modelChanged(ModelId)));
711 connect(layer, SIGNAL(modelCompletionChanged()), 711 connect(layer, SIGNAL(modelCompletionChanged(ModelId)),
712 this, SLOT(modelCompletionChanged())); 712 this, SLOT(modelCompletionChanged(ModelId)));
713 connect(layer, SIGNAL(modelAlignmentCompletionChanged()), 713 connect(layer, SIGNAL(modelAlignmentCompletionChanged(ModelId)),
714 this, SLOT(modelAlignmentCompletionChanged())); 714 this, SLOT(modelAlignmentCompletionChanged(ModelId)));
715 connect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), 715 connect(layer, SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)),
716 this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); 716 this, SLOT(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)));
717 connect(layer, SIGNAL(modelReplaced()), 717 connect(layer, SIGNAL(modelReplaced()),
718 this, SLOT(modelReplaced())); 718 this, SLOT(modelReplaced()));
719 719
720 update(); 720 update();
721 721
759 this, SLOT(layerParametersChanged())); 759 this, SLOT(layerParametersChanged()));
760 disconnect(layer, SIGNAL(layerParameterRangesChanged()), 760 disconnect(layer, SIGNAL(layerParameterRangesChanged()),
761 this, SLOT(layerParameterRangesChanged())); 761 this, SLOT(layerParameterRangesChanged()));
762 disconnect(layer, SIGNAL(layerNameChanged()), 762 disconnect(layer, SIGNAL(layerNameChanged()),
763 this, SLOT(layerNameChanged())); 763 this, SLOT(layerNameChanged()));
764 disconnect(layer, SIGNAL(modelChanged()), 764 disconnect(layer, SIGNAL(modelChanged(ModelId)),
765 this, SLOT(modelChanged())); 765 this, SLOT(modelChanged(ModelId)));
766 disconnect(layer, SIGNAL(modelCompletionChanged()), 766 disconnect(layer, SIGNAL(modelCompletionChanged(ModelId)),
767 this, SLOT(modelCompletionChanged())); 767 this, SLOT(modelCompletionChanged(ModelId)));
768 disconnect(layer, SIGNAL(modelAlignmentCompletionChanged()), 768 disconnect(layer, SIGNAL(modelAlignmentCompletionChanged(ModelId)),
769 this, SLOT(modelAlignmentCompletionChanged())); 769 this, SLOT(modelAlignmentCompletionChanged(ModelId)));
770 disconnect(layer, SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), 770 disconnect(layer, SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)),
771 this, SLOT(modelChangedWithin(sv_frame_t, sv_frame_t))); 771 this, SLOT(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)));
772 disconnect(layer, SIGNAL(modelReplaced()), 772 disconnect(layer, SIGNAL(modelReplaced()),
773 this, SLOT(modelReplaced())); 773 this, SLOT(modelReplaced()));
774 774
775 update(); 775 update();
776 776
920 m_followPlay = m; 920 m_followPlay = m;
921 emit propertyContainerPropertyChanged(m_propertyContainer); 921 emit propertyContainerPropertyChanged(m_propertyContainer);
922 } 922 }
923 923
924 void 924 void
925 View::modelChanged() 925 View::modelChanged(ModelId modelId)
926 { 926 {
927 #ifdef DEBUG_VIEW_WIDGET_PAINT 927 #ifdef DEBUG_VIEW_WIDGET_PAINT
928 cerr << "View(" << this << ")::modelChanged()" << endl; 928 cerr << "View(" << this << ")::modelChanged()" << endl;
929 #endif 929 #endif
930 930
931 QObject *obj = sender();
932
933 ModelId model;
934 if (Model *modelPtr = qobject_cast<Model *>(obj)) {
935 model = modelPtr->getId();
936 } else if (Layer *layerPtr = qobject_cast<Layer *>(obj)) {
937 model = layerPtr->getModel();
938 } else {
939 return;
940 }
941
942 // If the model that has changed is not used by any of the cached 931 // If the model that has changed is not used by any of the cached
943 // layers, we won't need to recreate the cache 932 // layers, we won't need to recreate the cache
944 933
945 bool recreate = false; 934 bool recreate = false;
946 935
947 bool discard; 936 bool discard;
948 LayerList scrollables = getScrollableBackLayers(false, discard); 937 LayerList scrollables = getScrollableBackLayers(false, discard);
949 for (LayerList::const_iterator i = scrollables.begin(); 938 for (LayerList::const_iterator i = scrollables.begin();
950 i != scrollables.end(); ++i) { 939 i != scrollables.end(); ++i) {
951 if ((*i)->getModel() == model) { 940 if ((*i)->getModel() == modelId) {
952 recreate = true; 941 recreate = true;
953 break; 942 break;
954 } 943 }
955 } 944 }
956 945
958 m_cacheValid = false; 947 m_cacheValid = false;
959 } 948 }
960 949
961 emit layerModelChanged(); 950 emit layerModelChanged();
962 951
963 checkProgress(obj); 952 checkProgress(modelId);
964 953
965 update(); 954 update();
966 } 955 }
967 956
968 void 957 void
969 View::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) 958 View::modelChangedWithin(ModelId modelId,
970 { 959 sv_frame_t startFrame, sv_frame_t endFrame)
971 QObject *obj = sender(); 960 {
972
973 ModelId model;
974 if (Model *modelPtr = qobject_cast<Model *>(obj)) {
975 model = modelPtr->getId();
976 } else if (Layer *layerPtr = qobject_cast<Layer *>(obj)) {
977 model = layerPtr->getModel();
978 } else {
979 return;
980 }
981
982 sv_frame_t myStartFrame = getStartFrame(); 961 sv_frame_t myStartFrame = getStartFrame();
983 sv_frame_t myEndFrame = getEndFrame(); 962 sv_frame_t myEndFrame = getEndFrame();
984 963
985 #ifdef DEBUG_VIEW_WIDGET_PAINT 964 #ifdef DEBUG_VIEW_WIDGET_PAINT
986 cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl; 965 cerr << "View(" << this << ")::modelChangedWithin(" << startFrame << "," << endFrame << ") [me " << myStartFrame << "," << myEndFrame << "]" << endl;
987 #endif 966 #endif
988 967
989 if (myStartFrame > 0 && endFrame < myStartFrame) { 968 if (myStartFrame > 0 && endFrame < myStartFrame) {
990 checkProgress(obj); 969 checkProgress(modelId);
991 return; 970 return;
992 } 971 }
993 if (startFrame > myEndFrame) { 972 if (startFrame > myEndFrame) {
994 checkProgress(obj); 973 checkProgress(modelId);
995 return; 974 return;
996 } 975 }
997 976
998 // If the model that has changed is not used by any of the cached 977 // If the model that has changed is not used by any of the cached
999 // layers, we won't need to recreate the cache 978 // layers, we won't need to recreate the cache
1002 981
1003 bool discard; 982 bool discard;
1004 LayerList scrollables = getScrollableBackLayers(false, discard); 983 LayerList scrollables = getScrollableBackLayers(false, discard);
1005 for (LayerList::const_iterator i = scrollables.begin(); 984 for (LayerList::const_iterator i = scrollables.begin();
1006 i != scrollables.end(); ++i) { 985 i != scrollables.end(); ++i) {
1007 if ((*i)->getModel() == model) { 986 if ((*i)->getModel() == modelId) {
1008 recreate = true; 987 recreate = true;
1009 break; 988 break;
1010 } 989 }
1011 } 990 }
1012 991
1015 } 994 }
1016 995
1017 if (startFrame < myStartFrame) startFrame = myStartFrame; 996 if (startFrame < myStartFrame) startFrame = myStartFrame;
1018 if (endFrame > myEndFrame) endFrame = myEndFrame; 997 if (endFrame > myEndFrame) endFrame = myEndFrame;
1019 998
1020 checkProgress(obj); 999 checkProgress(modelId);
1021 1000
1022 update(); 1001 update();
1023 } 1002 }
1024 1003
1025 void 1004 void
1026 View::modelCompletionChanged() 1005 View::modelCompletionChanged(ModelId modelId)
1027 { 1006 {
1028 // cerr << "View(" << this << ")::modelCompletionChanged()" << endl; 1007 checkProgress(modelId);
1029 1008 }
1030 QObject *obj = sender(); 1009
1031 checkProgress(obj); 1010 void
1032 } 1011 View::modelAlignmentCompletionChanged(ModelId modelId)
1033 1012 {
1034 void 1013 checkProgress(modelId);
1035 View::modelAlignmentCompletionChanged()
1036 {
1037 // cerr << "View(" << this << ")::modelAlignmentCompletionChanged()" << endl;
1038
1039 QObject *obj = sender();
1040 checkProgress(obj);
1041 } 1014 }
1042 1015
1043 void 1016 void
1044 View::modelReplaced() 1017 View::modelReplaced()
1045 { 1018 {
1389 for (auto layer: m_layerStack) { 1362 for (auto layer: m_layerStack) {
1390 1363
1391 if (!layer) continue; 1364 if (!layer) continue;
1392 if (dynamic_cast<TimeRulerLayer *>(layer)) continue; 1365 if (dynamic_cast<TimeRulerLayer *>(layer)) continue;
1393 1366
1394 auto model = ModelById::get(layer->getModel()); 1367 ModelId thisId = layer->getModel();
1368 auto model = ModelById::get(thisId);
1395 if (!model) continue; 1369 if (!model) continue;
1396 1370
1397 anyModel = model->getId(); 1371 anyModel = thisId;
1398 1372
1399 if (!model->getAlignmentReference().isNone()) { 1373 if (!model->getAlignmentReference().isNone()) {
1400 alignedModel = model->getId(); 1374 alignedModel = thisId;
1401 if (layer->isLayerOpaque() || 1375 if (layer->isLayerOpaque() ||
1402 std::dynamic_pointer_cast 1376 std::dynamic_pointer_cast
1403 <RangeSummarisableTimeValueModel>(model)) { 1377 <RangeSummarisableTimeValueModel>(model)) {
1404 goodModel = model->getId(); 1378 goodModel = thisId;
1405 } 1379 }
1406 } 1380 }
1407 } 1381 }
1408 1382
1409 if (!goodModel.isNone()) return goodModel; 1383 if (!goodModel.isNone()) return goodModel;
1760 } 1734 }
1761 } 1735 }
1762 } 1736 }
1763 1737
1764 void 1738 void
1765 View::checkProgress(void *object) 1739 View::checkProgress(ModelId modelId)
1766 { 1740 {
1767 if (!m_showProgress) { 1741 if (!m_showProgress) {
1768 #ifdef DEBUG_PROGRESS_STUFF 1742 #ifdef DEBUG_PROGRESS_STUFF
1769 SVCERR << "View[" << this << "]::checkProgress(" << object << "): " 1743 SVCERR << "View[" << this << "]::checkProgress(" << modelId << "): "
1770 << "m_showProgress is off" << endl; 1744 << "m_showProgress is off" << endl;
1771 #endif 1745 #endif
1772 return; 1746 return;
1773 } 1747 }
1774 1748
1784 i != m_progressBars.end(); ++i) { 1758 i != m_progressBars.end(); ++i) {
1785 1759
1786 QProgressBar *pb = i->second.bar; 1760 QProgressBar *pb = i->second.bar;
1787 QPushButton *cancel = i->second.cancel; 1761 QPushButton *cancel = i->second.cancel;
1788 1762
1789 if (i->first == object) { 1763 if (i->first && i->first->getModel() == modelId) {
1790 1764
1791 found = true; 1765 found = true;
1792 1766
1793 if (i->first->isLayerDormant(this)) { 1767 if (i->first->isLayerDormant(this)) {
1794 // A dormant (invisible) layer can still be busy 1768 // A dormant (invisible) layer can still be busy
1817 1791
1818 if (error != "" && error != m_lastError) { 1792 if (error != "" && error != m_lastError) {
1819 QMessageBox::critical(this, tr("Layer rendering error"), error); 1793 QMessageBox::critical(this, tr("Layer rendering error"), error);
1820 m_lastError = error; 1794 m_lastError = error;
1821 } 1795 }
1822
1823 ModelId modelId = i->first->getModel();
1824 1796
1825 auto model = ModelById::get(modelId); 1797 auto model = ModelById::get(modelId);
1826 auto wfm = std::dynamic_pointer_cast 1798 auto wfm = std::dynamic_pointer_cast
1827 <RangeSummarisableTimeValueModel>(model); 1799 <RangeSummarisableTimeValueModel>(model);
1828 1800