! \internal Moves this layerable object to \a layer. If \a prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended. Returns true on success, i.e. if \a layer is a valid layer. */
| 1565 | Returns true on success, i.e. if \a layer is a valid layer. |
| 1566 | */ |
| 1567 | bool QCPLayerable::moveToLayer(QCPLayer *layer, bool prepend) |
| 1568 | { |
| 1569 | if (layer && !mParentPlot) |
| 1570 | { |
| 1571 | qDebug() << Q_FUNC_INFO << "no parent QCustomPlot set"; |
| 1572 | return false; |
| 1573 | } |
| 1574 | if (layer && layer->parentPlot() != mParentPlot) |
| 1575 | { |
| 1576 | qDebug() << Q_FUNC_INFO << "layer" << layer->name() << "is not in same QCustomPlot as this layerable"; |
| 1577 | return false; |
| 1578 | } |
| 1579 | |
| 1580 | QCPLayer *oldLayer = mLayer; |
| 1581 | if (mLayer) |
| 1582 | mLayer->removeChild(this); |
| 1583 | mLayer = layer; |
| 1584 | if (mLayer) |
| 1585 | mLayer->addChild(this, prepend); |
| 1586 | if (mLayer != oldLayer) |
| 1587 | emit layerChanged(mLayer); |
| 1588 | return true; |
| 1589 | } |
| 1590 | |
| 1591 | /*! \internal |
| 1592 |
no test coverage detected