! \overload Adds this plottable to the specified \a legend. Creates a QCPPlottableLegendItem which is inserted into the legend. Returns true on success, i.e. when the legend exists and a legend item associated with this plottable isn't already in the legend. If the plottable needs a more specialized representation in the legend, you can create a corresponding subclass of \ref QCPPlo
| 11808 | \see removeFromLegend, QCPLegend::addItem |
| 11809 | */ |
| 11810 | bool QCPAbstractPlottable::addToLegend(QCPLegend *legend) |
| 11811 | { |
| 11812 | if (!legend) |
| 11813 | { |
| 11814 | qDebug() << Q_FUNC_INFO << "passed legend is null"; |
| 11815 | return false; |
| 11816 | } |
| 11817 | if (legend->parentPlot() != mParentPlot) |
| 11818 | { |
| 11819 | qDebug() << Q_FUNC_INFO << "passed legend isn't in the same QCustomPlot as this plottable"; |
| 11820 | return false; |
| 11821 | } |
| 11822 | |
| 11823 | if (!legend->hasItemWithPlottable(this)) |
| 11824 | { |
| 11825 | legend->addItem(new QCPPlottableLegendItem(legend, this)); |
| 11826 | return true; |
| 11827 | } else |
| 11828 | return false; |
| 11829 | } |
| 11830 | |
| 11831 | /*! \overload |
| 11832 |
no test coverage detected