MCPcopy Create free account
hub / github.com/LUX-Core/lux / removeLayer

Method removeLayer

src/qt/qcustomplot.cpp:14094–14132  ·  view source on GitHub ↗

! Removes the specified \a layer and returns true on success. All layerables (e.g. plottables and items) on the removed layer will be moved to the layer below \a layer. If \a layer is the bottom layer, the layerables are moved to the layer above. In both cases, the total rendering order of all layerables in the QCustomPlot is preserved. If \a layer is the current layer (\ref setCur

Source from the content-addressed store, hash-verified

14092 \see layer, addLayer, moveLayer
14093*/
14094bool QCustomPlot::removeLayer(QCPLayer *layer)
14095{
14096 if (!mLayers.contains(layer))
14097 {
14098 qDebug() << Q_FUNC_INFO << "layer not a layer of this QCustomPlot:" << reinterpret_cast<quintptr>(layer);
14099 return false;
14100 }
14101 if (mLayers.size() < 2)
14102 {
14103 qDebug() << Q_FUNC_INFO << "can't remove last layer";
14104 return false;
14105 }
14106
14107 // append all children of this layer to layer below (if this is lowest layer, prepend to layer above)
14108 int removedIndex = layer->index();
14109 bool isFirstLayer = removedIndex==0;
14110 QCPLayer *targetLayer = isFirstLayer ? mLayers.at(removedIndex+1) : mLayers.at(removedIndex-1);
14111 QList<QCPLayerable*> children = layer->children();
14112 if (isFirstLayer) // prepend in reverse order (so order relative to each other stays the same)
14113 {
14114 for (int i=children.size()-1; i>=0; --i)
14115 children.at(i)->moveToLayer(targetLayer, true);
14116 } else // append normally
14117 {
14118 for (int i=0; i<children.size(); ++i)
14119 children.at(i)->moveToLayer(targetLayer, false);
14120 }
14121 // if removed layer is current layer, change current layer to layer below/above:
14122 if (layer == mCurrentLayer)
14123 setCurrentLayer(targetLayer);
14124 // invalidate the paint buffer that was responsible for this layer:
14125 if (!layer->mPaintBuffer.isNull())
14126 layer->mPaintBuffer.data()->setInvalidated();
14127 // remove layer:
14128 delete layer;
14129 mLayers.removeOne(layer);
14130 updateLayerIndices();
14131 return true;
14132}
14133
14134/*!
14135 Moves the specified \a layer either above or below \a otherLayer. Whether it's placed above or

Callers

nothing calls this directly

Calls 8

moveToLayerMethod · 0.80
setInvalidatedMethod · 0.80
containsMethod · 0.45
sizeMethod · 0.45
indexMethod · 0.45
atMethod · 0.45
isNullMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected