comparison layer/ImageLayer.cpp @ 1471:f2525e6cbdf1 by-id

More layer updates
author Chris Cannam
date Mon, 01 Jul 2019 14:17:13 +0100
parents 696e569ff21b
children e540aa5d89cd
comparison
equal deleted inserted replaced
1470:696e569ff21b 1471:f2525e6cbdf1
65 } 65 }
66 66
67 void 67 void
68 ImageLayer::setModel(ModelId modelId) 68 ImageLayer::setModel(ModelId modelId)
69 { 69 {
70 auto newModel = ModelById::getAs<ImageModel>(modelId);
71
72 if (!modelId.isNone() && !newModel) {
73 throw std::logic_error("Not an ImageModel");
74 }
75
70 if (m_model == modelId) return; 76 if (m_model == modelId) return;
71
72 auto model = ModelById::getAs<ImageModel>(modelId);
73 if (!model) throw std::logic_error("Not an ImageModel");
74
75 m_model = modelId; 77 m_model = modelId;
76 78
77 connectSignals(m_model); 79 if (newModel) {
80 connectSignals(m_model);
81 }
78 82
79 emit modelReplaced(); 83 emit modelReplaced();
80 } 84 }
81 85
82 Layer::PropertyList 86 Layer::PropertyList
352 } 356 }
353 357
354 if (likelyWidth > availableWidth) { 358 if (likelyWidth > availableWidth) {
355 likelyWidth = availableWidth; 359 likelyWidth = availableWidth;
356 } 360 }
361
362 // Qt 5.13 deprecates QFontMetrics::width(), but its suggested
363 // replacement (horizontalAdvance) was only added in Qt 5.11
364 // which is too new for us
365 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
357 366
358 int singleWidth = paint.fontMetrics().width(label); 367 int singleWidth = paint.fontMetrics().width(label);
359 if (singleWidth < availableWidth && singleWidth < likelyWidth * 2) { 368 if (singleWidth < availableWidth && singleWidth < likelyWidth * 2) {
360 likelyWidth = singleWidth + 4; 369 likelyWidth = singleWidth + 4;
361 } 370 }