/*! Minimum size hint needed to display an entry \param data Attributes of the legend entry \return Minimum size */ QSize QwtPlotLegendItem::minimumSize( const QwtLegendData &data ) const { QSize size( 2 * d_data->itemMargin, 2 * d_data->itemMargin ); if ( !data.isValid() ) return size; const QwtGraphic graphic = data.icon(); const QwtText text = data.title(); int w = 0; int h = 0; if ( !graphic.isNull() ) { w = graphic.width(); h = graphic.height(); } if ( !text.isEmpty() ) { const QSizeF sz = text.textSize( font() ); w += qCeil( sz.width() ); h = qMax( h, qCeil( sz.height() ) ); } if ( graphic.width() > 0 && !text.isEmpty() ) w += d_data->itemSpacing; size += QSize( w, h ); return size; }
/*! \brief Return all information, that is needed to represent the item on the legend Most items are represented by one entry on the legend showing an icon and a text. QwtLegendData is basically a list of QVariants that makes it possible to overload and reimplement legendData() to return almost any type of information, that is understood by the receiver that acts as the legend. The default implementation returns one entry with the title() of the item and the legendIcon(). \sa title(), legendIcon(), QwtLegend */ QList<QwtLegendData> QwtPolarItem::legendData() const { QwtLegendData data; QwtText label = title(); label.setRenderFlags( label.renderFlags() & Qt::AlignLeft ); QVariant titleValue; qVariantSetValue( titleValue, label ); data.setValue( QwtLegendData::TitleRole, titleValue ); const QwtGraphic graphic = legendIcon( 0, legendIconSize() ); if ( !graphic.isNull() ) { QVariant iconValue; qVariantSetValue( iconValue, graphic ); data.setValue( QwtLegendData::IconRole, iconValue ); } QList<QwtLegendData> list; list += data; return list; }