mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-21 19:55:20 -05:00
Update qcustomplot component for Qt v5.14 compatibility
This commit is contained in:
parent
399b0caafe
commit
eb7681c7c5
@ -1104,8 +1104,8 @@ void QCPLayer::setMode(QCPLayer::LayerMode mode)
|
|||||||
if (mMode != mode)
|
if (mMode != mode)
|
||||||
{
|
{
|
||||||
mMode = mode;
|
mMode = mode;
|
||||||
if (!mPaintBuffer.isNull())
|
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||||
mPaintBuffer.data()->setInvalidated();
|
paint_buffer->setInvalidated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,16 +1140,15 @@ void QCPLayer::draw(QCPPainter *painter)
|
|||||||
*/
|
*/
|
||||||
void QCPLayer::drawToPaintBuffer()
|
void QCPLayer::drawToPaintBuffer()
|
||||||
{
|
{
|
||||||
if (!mPaintBuffer.isNull())
|
if (auto paint_buffer = mPaintBuffer.toStrongRef()) {
|
||||||
{
|
if (auto painter = paint_buffer->startPainting())
|
||||||
if (QCPPainter *painter = mPaintBuffer.data()->startPainting())
|
|
||||||
{
|
{
|
||||||
if (painter->isActive())
|
if (painter->isActive())
|
||||||
draw(painter);
|
draw(painter);
|
||||||
else
|
else
|
||||||
qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter";
|
qDebug() << Q_FUNC_INFO << "paint buffer returned inactive painter";
|
||||||
delete painter;
|
delete painter;
|
||||||
mPaintBuffer.data()->donePainting();
|
paint_buffer->donePainting();
|
||||||
} else
|
} else
|
||||||
qDebug() << Q_FUNC_INFO << "paint buffer returned zero painter";
|
qDebug() << Q_FUNC_INFO << "paint buffer returned zero painter";
|
||||||
} else
|
} else
|
||||||
@ -1173,11 +1172,11 @@ void QCPLayer::replot()
|
|||||||
{
|
{
|
||||||
if (mMode == lmBuffered && !mParentPlot->hasInvalidatedPaintBuffers())
|
if (mMode == lmBuffered && !mParentPlot->hasInvalidatedPaintBuffers())
|
||||||
{
|
{
|
||||||
if (!mPaintBuffer.isNull())
|
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||||
{
|
{
|
||||||
mPaintBuffer.data()->clear(Qt::transparent);
|
paint_buffer->clear(Qt::transparent);
|
||||||
drawToPaintBuffer();
|
drawToPaintBuffer();
|
||||||
mPaintBuffer.data()->setInvalidated(false);
|
paint_buffer->setInvalidated(false);
|
||||||
mParentPlot->update();
|
mParentPlot->update();
|
||||||
} else
|
} else
|
||||||
qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer";
|
qDebug() << Q_FUNC_INFO << "no valid paint buffer associated with this layer";
|
||||||
@ -1203,8 +1202,8 @@ void QCPLayer::addChild(QCPLayerable *layerable, bool prepend)
|
|||||||
mChildren.prepend(layerable);
|
mChildren.prepend(layerable);
|
||||||
else
|
else
|
||||||
mChildren.append(layerable);
|
mChildren.append(layerable);
|
||||||
if (!mPaintBuffer.isNull())
|
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||||
mPaintBuffer.data()->setInvalidated();
|
paint_buffer->setInvalidated();
|
||||||
} else
|
} else
|
||||||
qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast<quintptr>(layerable);
|
qDebug() << Q_FUNC_INFO << "layerable is already child of this layer" << reinterpret_cast<quintptr>(layerable);
|
||||||
}
|
}
|
||||||
@ -1222,8 +1221,8 @@ void QCPLayer::removeChild(QCPLayerable *layerable)
|
|||||||
{
|
{
|
||||||
if (mChildren.removeOne(layerable))
|
if (mChildren.removeOne(layerable))
|
||||||
{
|
{
|
||||||
if (!mPaintBuffer.isNull())
|
if (auto paint_buffer = mPaintBuffer.toStrongRef())
|
||||||
mPaintBuffer.data()->setInvalidated();
|
paint_buffer->setInvalidated();
|
||||||
} else
|
} else
|
||||||
qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast<quintptr>(layerable);
|
qDebug() << Q_FUNC_INFO << "layerable is not child of this layer" << reinterpret_cast<quintptr>(layerable);
|
||||||
}
|
}
|
||||||
@ -11067,12 +11066,12 @@ QCPItemAnchor::QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentIte
|
|||||||
QCPItemAnchor::~QCPItemAnchor()
|
QCPItemAnchor::~QCPItemAnchor()
|
||||||
{
|
{
|
||||||
// unregister as parent at children:
|
// unregister as parent at children:
|
||||||
foreach (QCPItemPosition *child, mChildrenX.toList())
|
foreach (QCPItemPosition *child, mChildrenX.values())
|
||||||
{
|
{
|
||||||
if (child->parentAnchorX() == this)
|
if (child->parentAnchorX() == this)
|
||||||
child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX
|
child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX
|
||||||
}
|
}
|
||||||
foreach (QCPItemPosition *child, mChildrenY.toList())
|
foreach (QCPItemPosition *child, mChildrenY.values())
|
||||||
{
|
{
|
||||||
if (child->parentAnchorY() == this)
|
if (child->parentAnchorY() == this)
|
||||||
child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY
|
child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY
|
||||||
@ -11245,12 +11244,12 @@ QCPItemPosition::~QCPItemPosition()
|
|||||||
// unregister as parent at children:
|
// unregister as parent at children:
|
||||||
// Note: this is done in ~QCPItemAnchor again, but it's important QCPItemPosition does it itself, because only then
|
// Note: this is done in ~QCPItemAnchor again, but it's important QCPItemPosition does it itself, because only then
|
||||||
// the setParentAnchor(0) call the correct QCPItemPosition::pixelPosition function instead of QCPItemAnchor::pixelPosition
|
// the setParentAnchor(0) call the correct QCPItemPosition::pixelPosition function instead of QCPItemAnchor::pixelPosition
|
||||||
foreach (QCPItemPosition *child, mChildrenX.toList())
|
foreach (QCPItemPosition *child, mChildrenX.values())
|
||||||
{
|
{
|
||||||
if (child->parentAnchorX() == this)
|
if (child->parentAnchorX() == this)
|
||||||
child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX
|
child->setParentAnchorX(0); // this acts back on this anchor and child removes itself from mChildrenX
|
||||||
}
|
}
|
||||||
foreach (QCPItemPosition *child, mChildrenY.toList())
|
foreach (QCPItemPosition *child, mChildrenY.values())
|
||||||
{
|
{
|
||||||
if (child->parentAnchorY() == this)
|
if (child->parentAnchorY() == this)
|
||||||
child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY
|
child->setParentAnchorY(0); // this acts back on this anchor and child removes itself from mChildrenY
|
||||||
@ -13857,8 +13856,8 @@ bool QCustomPlot::removeLayer(QCPLayer *layer)
|
|||||||
if (layer == mCurrentLayer)
|
if (layer == mCurrentLayer)
|
||||||
setCurrentLayer(targetLayer);
|
setCurrentLayer(targetLayer);
|
||||||
// invalidate the paint buffer that was responsible for this layer:
|
// invalidate the paint buffer that was responsible for this layer:
|
||||||
if (!layer->mPaintBuffer.isNull())
|
if (auto paint_buffer = layer->mPaintBuffer.toStrongRef())
|
||||||
layer->mPaintBuffer.data()->setInvalidated();
|
paint_buffer->setInvalidated();
|
||||||
// remove layer:
|
// remove layer:
|
||||||
delete layer;
|
delete layer;
|
||||||
mLayers.removeOne(layer);
|
mLayers.removeOne(layer);
|
||||||
@ -13894,10 +13893,10 @@ bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot::
|
|||||||
mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 0:-1));
|
mLayers.move(layer->index(), otherLayer->index() + (insertMode==limAbove ? 0:-1));
|
||||||
|
|
||||||
// invalidate the paint buffers that are responsible for the layers:
|
// invalidate the paint buffers that are responsible for the layers:
|
||||||
if (!layer->mPaintBuffer.isNull())
|
if (auto paint_buffer = layer->mPaintBuffer.toStrongRef())
|
||||||
layer->mPaintBuffer.data()->setInvalidated();
|
paint_buffer->setInvalidated();
|
||||||
if (!otherLayer->mPaintBuffer.isNull())
|
if (auto paint_buffer = otherLayer->mPaintBuffer.toStrongRef())
|
||||||
otherLayer->mPaintBuffer.data()->setInvalidated();
|
paint_buffer->setInvalidated();
|
||||||
|
|
||||||
updateLayerIndices();
|
updateLayerIndices();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user