Get rid of dynamic_cast

This commit is contained in:
rexim
2019-05-22 00:33:12 +07:00
parent cbb1ec2d7a
commit aa4e7f13e7
3 changed files with 20 additions and 9 deletions
+4 -7
View File
@@ -1217,12 +1217,9 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
}
else
{
auto imageLayoutElement =
dynamic_cast<const ImageLayoutElement *>(hoverLayoutElement);
if (imageLayoutElement && imageLayoutElement->pixmap()) {
if (auto pixmap = hoverLayoutElement->pixmap()) {
QBuffer buffer;
imageLayoutElement->pixmap()->save(&buffer, "PNG");
pixmap->save(&buffer, "PNG");
// FIXME: Image inside of imageLayoutElement is not always the biggest
// FIXME: Inject image directly into tooltipWidget without base64 bs
@@ -1232,8 +1229,8 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
tooltipWidget->setText(
QString("<img src='data:image/png;base64,%1' /><br/>%2x%3<br/>%4")
.arg(QString(buffer.data().toBase64()))
.arg(imageLayoutElement->pixmap()->width())
.arg(imageLayoutElement->pixmap()->height())
.arg(pixmap->width())
.arg(pixmap->height())
.arg(tooltip));
} else {
tooltipWidget->setText(tooltip);