KD Chart 2
[rev.2.7]
|
Legend defines the interface for the legend drawing class. More...
#include <KDChartLegend.h>
Public Types | |
enum | LegendStyle { MarkersOnly = 0, LinesOnly = 1, MarkersAndLines = 2 } |
Signals | |
void | destroyedLegend (Legend *) |
void | positionChanged (AbstractAreaWidget *) |
void | propertiesChanged () |
Emitted upon change of a property of the Legend or any of its components. More... | |
Public Member Functions | |
void | addDiagram (KDChart::AbstractDiagram *newDiagram) |
Add the given diagram to the legend. More... | |
Qt::Alignment | alignment () const |
Returns the alignment of a non-floating legend. More... | |
void | alignToReferencePoint (const RelativePosition &position) |
BackgroundAttributes | backgroundAttributes () const |
QBrush | brush (uint dataset) const |
const QMap< uint, QBrush > | brushes () const |
virtual Legend * | clone () const |
Creates an exact copy of this legend. More... | |
bool | compare (const AbstractAreaBase *other) const |
Returns true if both areas have the same settings. More... | |
bool | compare (const Legend *other) const |
Returns true if both legends have the same settings. More... | |
ConstDiagramList | constDiagrams () const |
uint | datasetCount () const |
bool | datasetIsHidden (uint dataset) const |
uint | dataSetOffset (KDChart::AbstractDiagram *diagram) |
Returns the offset of the first dataset of diagram . More... | |
KDChart::AbstractDiagram * | diagram () const |
The first diagram of the legend or 0 if there was none added to the legend. More... | |
DiagramList | diagrams () const |
The list of all diagrams associated with the legend. More... | |
const RelativePosition | floatingPosition () const |
Returns the position of a floating legend. More... | |
void | forceRebuild () override |
Call this to trigger an unconditional re-building of the widget's internals. More... | |
FrameAttributes | frameAttributes () const |
void | getFrameLeadings (int &left, int &top, int &right, int &bottom) const |
bool | hasHeightForWidth () const |
int | heightForWidth (int width) const override |
const QList< uint > | hiddenDatasets () const |
Legend (QWidget *parent=0) | |
Legend (KDChart::AbstractDiagram *diagram, QWidget *parent=0) | |
LegendStyle | legendStyle () const |
Qt::Alignment | legendSymbolAlignment () const |
Returns the alignment used while drawing legend symbol(alignment of Legend::LinesOnly) within the legend. More... | |
MarkerAttributes | markerAttributes (uint dataset) const |
const QMap< uint, MarkerAttributes > | markerAttributes () const |
QSize | minimumSizeHint () const override |
void | needSizeHint () override |
Call this to trigger an conditional re-building of the widget's internals. More... | |
Qt::Orientation | orientation () const |
void | paint (QPainter *painter) override |
Overwrite this to paint the inner contents of your widget. More... | |
void | paintAll (QPainter &painter) |
Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically. More... | |
virtual void | paintBackground (QPainter &painter, const QRect &rectangle) |
void | paintEvent (QPaintEvent *event) override |
Draws the background and frame, then calls paint(). More... | |
virtual void | paintFrame (QPainter &painter, const QRect &rectangle) |
virtual void | paintIntoRect (QPainter &painter, const QRect &rect) |
Draws the background and frame, then calls paint(). More... | |
QPen | pen (uint dataset) const |
const QMap< uint, QPen > | pens () const |
Position | position () const |
Returns the position of a non-floating legend. More... | |
const QWidget * | referenceArea () const |
Returns the reference area, that is used for font size of title text, and for font size of the item texts, IF automatic area detection is set. More... | |
void | removeDiagram (KDChart::AbstractDiagram *oldDiagram) |
Removes the diagram from the legend's list of diagrams. More... | |
void | removeDiagrams () |
Removes all diagrams from the legend's list of diagrams. More... | |
void | replaceDiagram (KDChart::AbstractDiagram *newDiagram, KDChart::AbstractDiagram *oldDiagram=0) |
Replaces the old diagram, or appends the new diagram, it there is none yet. More... | |
void | resetTexts () |
Removes all legend texts that might have been set by setText. More... | |
void | resizeEvent (QResizeEvent *event) override |
void | resizeLayout (const QSize &size) override |
void | setAlignment (Qt::Alignment) |
Specify the alignment of a non-floating legend. More... | |
void | setBackgroundAttributes (const BackgroundAttributes &a) |
void | setBrush (uint dataset, const QBrush &brush) |
void | setBrushesFromDiagram (KDChart::AbstractDiagram *diagram) |
void | setColor (uint dataset, const QColor &color) |
Note: there is no color() getter method, since setColor just sets a QBrush with the respective color, so the brush() getter method is sufficient. More... | |
void | setDatasetHidden (uint dataset, bool hidden) |
void | setDefaultColors () |
void | setDiagram (KDChart::AbstractDiagram *newDiagram) |
A convenience method doing the same as replaceDiagram( newDiagram, 0 );. More... | |
void | setFloatingPosition (const RelativePosition &relativePosition) |
Specify the position and alignment of a floating legend. More... | |
void | setFrameAttributes (const FrameAttributes &a) |
void | setHiddenDatasets (const QList< uint > hiddenDatasets) |
Sets a list of datasets that are to be hidden in the legend. More... | |
void | setLegendStyle (LegendStyle style) |
void | setLegendSymbolAlignment (Qt::Alignment) |
Specify the alignment of the legend symbol( alignment of Legend::LinesOnly) within the legend. More... | |
void | setMarkerAttributes (uint dataset, const MarkerAttributes &) |
Note that any sizes specified via setMarkerAttributes are ignored, unless you disable the automatic size calculation, by saying setUseAutomaticMarkerSize( false ) More... | |
void | setOrientation (Qt::Orientation orientation) |
void | setPen (uint dataset, const QPen &pen) |
void | setPosition (Position position) |
Specify the position of a non-floating legend. More... | |
void | setRainbowColors () |
void | setReferenceArea (const QWidget *area) |
Specifies the reference area for font size of title text, and for font size of the item texts, IF automatic area detection is set. More... | |
void | setShowLines (bool legendShowLines) |
void | setSortOrder (Qt::SortOrder order) |
void | setSpacing (uint space) |
void | setSubduedColors (bool ordered=false) |
void | setText (uint dataset, const QString &text) |
void | setTextAlignment (Qt::Alignment) |
Specify the alignment of the text elements within the legend. More... | |
void | setTextAttributes (const TextAttributes &a) |
void | setTitleText (const QString &text) |
void | setTitleTextAttributes (const TextAttributes &a) |
void | setUseAutomaticMarkerSize (bool useAutomaticMarkerSize) |
This option is on by default, it means that Marker sizes in the Legend will be the same as the font height used for their respective label texts. More... | |
void | setVisible (bool visible) override |
bool | showLines () const |
QSize | sizeHint () const override |
Qt::SortOrder | sortOrder () const |
uint | spacing () const |
QString | text (uint dataset) const |
Qt::Alignment | textAlignment () const |
Returns the alignment used while rendering text elements within the legend. More... | |
TextAttributes | textAttributes () const |
const QMap< uint, QString > | texts () const |
QString | titleText () const |
TextAttributes | titleTextAttributes () const |
bool | useAutomaticMarkerSize () const |
~Legend () override | |
Static Public Member Functions | |
static void | paintBackgroundAttributes (QPainter &painter, const QRect &rectangle, const KDChart::BackgroundAttributes &attributes) |
static void | paintFrameAttributes (QPainter &painter, const QRect &rectangle, const KDChart::FrameAttributes &attributes) |
Protected Member Functions | |
QRect | areaGeometry () const override |
QRect | innerRect () const |
void | positionHasChanged () override |
Legend defines the interface for the legend drawing class.
Legend is the class for drawing legends for all kinds of diagrams ("chart types").
Legend is drawn on chart level, not per diagram, but you can have more than one legend per chart, using KDChart::Chart::addLegend().
On the other hand, please note that you MUST call Chart::addLegend to get your legend positioned into the correct place of your chart - if you want to have the legend shown inside of the chart (that's probably true for most cases).
Definition at line 55 of file KDChartLegend.h.
Enumerator | |
---|---|
MarkersOnly | |
LinesOnly | |
MarkersAndLines |
Definition at line 68 of file KDChartLegend.h.
|
explicit |
|
explicit |
Definition at line 88 of file KDChartLegend.cpp.
References d, and setDiagram().
|
override |
Definition at line 96 of file KDChartLegend.cpp.
References d, destroyedLegend(), KDChartEnums::MeasureCalculationModeAbsolute, KDChart::Position::NorthEast, KDChart::TextAttributes::setFont(), KDChart::TextAttributes::setFontSize(), KDChart::AbstractAreaBase::setFrameAttributes(), KDChart::TextAttributes::setMinimalFontSize(), KDChart::FrameAttributes::setPadding(), KDChart::FrameAttributes::setPen(), KDChart::TextAttributes::setPen(), setTextAttributes(), setTitleTextAttributes(), and KDChart::FrameAttributes::setVisible().
void Legend::addDiagram | ( | KDChart::AbstractDiagram * | newDiagram | ) |
Add the given diagram to the legend.
newDiagram | The diagram to add. |
Definition at line 319 of file KDChartLegend.cpp.
References d.
Referenced by replaceDiagram().
Qt::Alignment Legend::alignment | ( | ) | const |
Returns the alignment of a non-floating legend.
Definition at line 474 of file KDChartLegend.cpp.
References d.
Referenced by KDChart::Chart::addLegend(), clone(), compare(), setAlignment(), setLegendSymbolAlignment(), and setTextAlignment().
|
inherited |
Definition at line 81 of file KDChartAbstractAreaBase.cpp.
|
overrideprotectedvirtualinherited |
Implements KDChart::AbstractAreaBase.
Definition at line 179 of file KDChartAbstractAreaWidget.cpp.
Referenced by updateToplevelLayout().
|
inherited |
Definition at line 111 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by KDChart::AbstractAreaBase::compare(), and updateCommonBrush().
QBrush Legend::brush | ( | uint | dataset | ) | const |
Definition at line 633 of file KDChartLegend.cpp.
References d.
Referenced by setBrush(), and updateToplevelLayout().
const QMap< uint, QBrush > Legend::brushes | ( | ) | const |
|
virtual |
Creates an exact copy of this legend.
Definition at line 200 of file KDChartLegend.cpp.
References alignment(), d, KDChart::AbstractAreaBase::frameAttributes(), Legend(), legendStyle(), position(), setAlignment(), KDChart::AbstractAreaBase::setFrameAttributes(), setLegendStyle(), setPosition(), setTextAlignment(), setTextAttributes(), setTitleTextAttributes(), setUseAutomaticMarkerSize(), textAlignment(), textAttributes(), titleTextAttributes(), and useAutomaticMarkerSize().
|
inherited |
Returns true if both areas have the same settings.
Definition at line 71 of file KDChartAbstractAreaBase.cpp.
References KDChart::AbstractAreaBase::backgroundAttributes(), and KDChart::AbstractAreaBase::frameAttributes().
Referenced by compare().
bool Legend::compare | ( | const Legend * | other | ) | const |
Returns true if both legends have the same settings.
Definition at line 215 of file KDChartLegend.cpp.
References alignment(), brushes(), KDChart::AbstractAreaBase::compare(), floatingPosition(), legendStyle(), markerAttributes(), orientation(), pens(), position(), showLines(), spacing(), textAlignment(), textAttributes(), texts(), titleText(), titleTextAttributes(), and useAutomaticMarkerSize().
ConstDiagramList Legend::constDiagrams | ( | ) | const |
Definition at line 310 of file KDChartLegend.cpp.
References d.
uint Legend::datasetCount | ( | ) | const |
Definition at line 266 of file KDChartLegend.cpp.
References d, KDChart::AbstractDiagram::datasetBrushes(), KDChart::AbstractDiagram::datasetLabels(), KDChart::DiagramObserver::diagram(), and diagram().
bool Legend::datasetIsHidden | ( | uint | dataset | ) | const |
uint Legend::dataSetOffset | ( | KDChart::AbstractDiagram * | diagram | ) |
Returns the offset of the first dataset of diagram
.
Definition at line 402 of file KDChartLegend.cpp.
AbstractDiagram * Legend::diagram | ( | ) | const |
The first diagram of the legend or 0 if there was none added to the legend.
Definition at line 293 of file KDChartLegend.cpp.
References d.
Referenced by datasetCount(), dataSetOffset(), paint(), resizeEvent(), and updateToplevelLayout().
DiagramList Legend::diagrams | ( | ) | const |
The list of all diagrams associated with the legend.
Definition at line 301 of file KDChartLegend.cpp.
References d.
Referenced by removeDiagram(), and removeDiagrams().
const RelativePosition Legend::floatingPosition | ( | ) | const |
Returns the position of a floating legend.
Definition at line 516 of file KDChartLegend.cpp.
References d.
Referenced by compare(), and KDChart::Chart::reLayoutFloatingLegends().
|
overridevirtual |
Call this to trigger an unconditional re-building of the widget's internals.
Reimplemented from KDChart::AbstractAreaWidget.
Definition at line 759 of file KDChartLegend.cpp.
Referenced by resizeEvent().
|
inherited |
Definition at line 97 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by clone(), KDChart::AbstractAreaBase::compare(), and updateCommonBrush().
|
inherited |
Definition at line 213 of file KDChartAbstractAreaBase.cpp.
References d.
Referenced by KDChart::AbstractAreaBase::innerRect(), and KDChart::AbstractAreaWidget::paintAll().
bool Legend::hasHeightForWidth | ( | ) | const |
Definition at line 1168 of file KDChartLegend.cpp.
References d.
|
override |
Definition at line 1176 of file KDChartLegend.cpp.
References d, showLines(), and spacing().
const QList< uint > Legend::hiddenDatasets | ( | ) | const |
|
protectedinherited |
Definition at line 225 of file KDChartAbstractAreaBase.cpp.
References KDChart::AbstractAreaBase::areaGeometry(), and KDChart::AbstractAreaBase::getFrameLeadings().
Referenced by KDChart::AbstractArea::paintAll(), and KDChart::TextArea::paintAll().
Legend::LegendStyle Legend::legendStyle | ( | ) | const |
Definition at line 192 of file KDChartLegend.cpp.
References d.
Referenced by clone(), compare(), resizeEvent(), and updateToplevelLayout().
Qt::Alignment Legend::legendSymbolAlignment | ( | ) | const |
Returns the alignment used while drawing legend symbol(alignment of Legend::LinesOnly) within the legend.
Definition at line 502 of file KDChartLegend.cpp.
References d.
MarkerAttributes Legend::markerAttributes | ( | uint | dataset | ) | const |
Definition at line 700 of file KDChartLegend.cpp.
References d.
Referenced by compare(), and resizeEvent().
const QMap< uint, MarkerAttributes > Legend::markerAttributes | ( | ) | const |
Definition at line 711 of file KDChartLegend.cpp.
References d.
Referenced by compare(), setMarkerAttributes(), and updateToplevelLayout().
|
override |
Definition at line 138 of file KDChartLegend.cpp.
References sizeHint().
|
overridevirtual |
Call this to trigger an conditional re-building of the widget's internals.
e.g. AbstractAreaWidget call this, before calling layout()->setGeometry()
Reimplemented from KDChart::AbstractAreaWidget.
Definition at line 156 of file KDChartLegend.cpp.
Referenced by KDChart::Chart::addLegend().
Qt::Orientation Legend::orientation | ( | ) | const |
Definition at line 531 of file KDChartLegend.cpp.
References d.
Referenced by compare(), setOrientation(), and updateToplevelLayout().
|
overridevirtual |
Overwrite this to paint the inner contents of your widget.
Implements KDChart::AbstractAreaWidget.
Definition at line 245 of file KDChartLegend.cpp.
References d, diagram(), and KDChart::AbstractLayoutItem::paint().
|
inherited |
Call paintAll, if you want the background and the frame to be drawn before the normal paint() is invoked automatically.
Definition at line 140 of file KDChartAbstractAreaWidget.cpp.
References KDChart::AbstractAreaBase::getFrameLeadings(), KDChart::AbstractAreaWidget::paint(), KDChart::AbstractAreaBase::paintBackground(), and KDChart::AbstractAreaBase::paintFrame().
Referenced by KDChart::AbstractAreaWidget::paintEvent(), and KDChart::AbstractAreaWidget::paintIntoRect().
|
virtualinherited |
Definition at line 189 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::paintBackgroundAttributes().
Referenced by KDChart::AbstractArea::paintAll(), KDChart::TextArea::paintAll(), and KDChart::AbstractAreaWidget::paintAll().
|
staticinherited |
Definition at line 118 of file KDChartAbstractAreaBase.cpp.
References KDChart::BackgroundAttributes::BackgroundPixmapModeCentered, KDChart::BackgroundAttributes::BackgroundPixmapModeNone, KDChart::BackgroundAttributes::BackgroundPixmapModeScaled, KDChart::BackgroundAttributes::BackgroundPixmapModeStretched, KDChart::BackgroundAttributes::brush(), KDChart::BackgroundAttributes::isVisible(), KDChart::BackgroundAttributes::pixmap(), and KDChart::BackgroundAttributes::pixmapMode().
Referenced by findSharingAxisDiagrams(), and KDChart::AbstractAreaBase::paintBackground().
|
overrideinherited |
Draws the background and frame, then calls paint().
In most cases there is no need to overwrite this method in a derived class, but you would overwrite paint() instead.
Definition at line 95 of file KDChartAbstractAreaWidget.cpp.
References d, and KDChart::AbstractAreaWidget::paintAll().
|
virtualinherited |
Definition at line 205 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::paintFrameAttributes().
Referenced by KDChart::AbstractArea::paintAll(), KDChart::TextArea::paintAll(), and KDChart::AbstractAreaWidget::paintAll().
|
staticinherited |
Definition at line 168 of file KDChartAbstractAreaBase.cpp.
References KDChart::FrameAttributes::cornerRadius(), KDChart::FrameAttributes::isVisible(), KDChart::FrameAttributes::pen(), and KDChart::PrintingParameters::scalePen().
Referenced by findSharingAxisDiagrams(), and KDChart::AbstractAreaBase::paintFrame().
|
virtualinherited |
Draws the background and frame, then calls paint().
In most cases there is no need to overwrite this method in a derived class, but you would overwrite paint() instead.
Definition at line 105 of file KDChartAbstractAreaWidget.cpp.
References d, and KDChart::AbstractAreaWidget::paintAll().
Referenced by findSharingAxisDiagrams().
QPen Legend::pen | ( | uint | dataset | ) | const |
Definition at line 675 of file KDChartLegend.cpp.
References d.
Referenced by setPen(), and updateToplevelLayout().
const QMap< uint, QPen > Legend::pens | ( | ) | const |
Position Legend::position | ( | ) | const |
Returns the position of a non-floating legend.
Definition at line 460 of file KDChartLegend.cpp.
References d.
Referenced by KDChart::Chart::addLegend(), clone(), compare(), KDChart::Chart::reLayoutFloatingLegends(), and setPosition().
|
signalinherited |
Referenced by KDChart::AbstractAreaWidget::positionHasChanged(), and setPosition().
|
overrideprotectedvirtualinherited |
Reimplemented from KDChart::AbstractAreaBase.
Definition at line 184 of file KDChartAbstractAreaWidget.cpp.
References KDChart::AbstractAreaWidget::positionChanged().
|
signal |
Emitted upon change of a property of the Legend or any of its components.
Referenced by setPosition(), and updateToplevelLayout().
const QWidget * Legend::referenceArea | ( | ) | const |
Returns the reference area, that is used for font size of title text, and for font size of the item texts, IF automatic area detection is set.
Definition at line 287 of file KDChartLegend.cpp.
References d.
Referenced by updateToplevelLayout().
void Legend::removeDiagram | ( | KDChart::AbstractDiagram * | oldDiagram | ) |
Removes the diagram from the legend's list of diagrams.
Definition at line 343 of file KDChartLegend.cpp.
References d, KDChart::AbstractDiagram::datasetBrushes(), KDChart::AbstractDiagram::datasetPens(), and diagrams().
Referenced by removeDiagrams(), replaceDiagram(), and setDiagram().
void Legend::removeDiagrams | ( | ) |
Removes all diagrams from the legend's list of diagrams.
Definition at line 371 of file KDChartLegend.cpp.
References d, diagrams(), and removeDiagram().
void Legend::replaceDiagram | ( | KDChart::AbstractDiagram * | newDiagram, |
KDChart::AbstractDiagram * | oldDiagram = 0 |
||
) |
Replaces the old diagram, or appends the new diagram, it there is none yet.
newDiagram | The diagram to be used instead of the old one. If this parameter is zero, the first diagram will just be removed. |
oldDiagram | The diagram to be removed by the new one. This diagram will be deleted automatically. If the parameter is omitted, the very first diagram will be replaced. In case, there was no diagram yet, the new diagram will just be added. |
Definition at line 384 of file KDChartLegend.cpp.
References addDiagram(), d, and removeDiagram().
Referenced by setDiagram().
void Legend::resetTexts | ( | ) |
Removes all legend texts that might have been set by setText.
This resets the Legend to default behaviour: Texts are created automatically.
Definition at line 583 of file KDChartLegend.cpp.
References d.
|
override |
Definition at line 821 of file KDChartLegend.cpp.
References KDChart::AbstractDiagram::datasetBrushes(), datasetIsHidden(), KDChart::AbstractDiagram::datasetLabels(), KDChart::AbstractDiagram::datasetMarkers(), KDChart::AbstractDiagram::datasetPens(), diagram(), forceRebuild(), KDChart::AbstractDiagram::isHidden(), legendStyle(), LinesOnly, markerAttributes(), KDChart::MarkerAttributes::markerSize(), sizeHint(), sortOrder(), and useAutomaticMarkerSize().
|
overridevirtual |
Reimplemented from KDChart::AbstractAreaWidget.
Definition at line 161 of file KDChartLegend.cpp.
References d.
void Legend::setAlignment | ( | Qt::Alignment | alignment | ) |
Specify the alignment of a non-floating legend.
Use setFloatingPosition to set position and alignment if your legend is floating.
Definition at line 465 of file KDChartLegend.cpp.
References alignment(), and d.
Referenced by clone().
|
inherited |
Definition at line 102 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::positionHasChanged().
void Legend::setBrush | ( | uint | dataset, |
const QBrush & | brush | ||
) |
Definition at line 624 of file KDChartLegend.cpp.
Referenced by setDefaultColors(), setRainbowColors(), and setSubduedColors().
void Legend::setBrushesFromDiagram | ( | KDChart::AbstractDiagram * | diagram | ) |
Definition at line 648 of file KDChartLegend.cpp.
References d, and KDChart::AbstractDiagram::datasetBrushes().
void Legend::setColor | ( | uint | dataset, |
const QColor & | color | ||
) |
Note: there is no color() getter method, since setColor just sets a QBrush with the respective color, so the brush() getter method is sufficient.
Definition at line 615 of file KDChartLegend.cpp.
References d.
void Legend::setDatasetHidden | ( | uint | dataset, |
bool | hidden | ||
) |
Definition at line 1242 of file KDChartLegend.cpp.
References d.
void Legend::setDefaultColors | ( | ) |
Definition at line 785 of file KDChartLegend.cpp.
References KDChart::Palette::defaultPalette(), KDChart::Palette::getBrush(), setBrush(), and KDChart::Palette::size().
void Legend::setDiagram | ( | KDChart::AbstractDiagram * | newDiagram | ) |
A convenience method doing the same as replaceDiagram( newDiagram, 0 );.
Replaces the first diagram by the given diagram. If the legend's list of diagram is empty the given diagram is added to the list.
Definition at line 420 of file KDChartLegend.cpp.
References removeDiagram(), and replaceDiagram().
Referenced by KDChart::Widget::addLegend(), Legend(), KDChart::Widget::replaceLegend(), and KDChart::Widget::setType().
void Legend::setFloatingPosition | ( | const RelativePosition & | relativePosition | ) |
Specify the position and alignment of a floating legend.
Use setPosition and setAlignment to set position and alignment if your legend is non-floating.
If your Chart is pointed to by m_chart, your could have the floating legend aligned exactly to the chart's coordinate plane's top-right corner with the following commands:
KDChart::RelativePosition relativePosition; relativePosition.setReferenceArea( m_chart->coordinatePlane() ); relativePosition.setReferencePosition( Position::NorthEast ); relativePosition.setAlignment( Qt::AlignTop | Qt::AlignRight ); relativePosition.setHorizontalPadding( KDChart::Measure( -1.0, KDChartEnums::MeasureCalculationModeAbsolute ) ); relativePosition.setVerticalPadding( KDChart::Measure( 0.0, KDChartEnums::MeasureCalculationModeAbsolute ) ); m_legend->setFloatingPosition( relativePosition );
To have the legend positioned at a fixed point, measured from the QPainter's top left corner, you could use the following code code:
KDChart::RelativePosition relativePosition; relativePosition.setReferencePoints( PositionPoints( QPointF( 0.0, 0.0 ) ) ); relativePosition.setReferencePosition( Position::NorthWest ); relativePosition.setAlignment( Qt::AlignTop | Qt::AlignLeft ); relativePosition.setHorizontalPadding( KDChart::Measure( 4.0, KDChartEnums::MeasureCalculationModeAbsolute ) ); relativePosition.setVerticalPadding( KDChart::Measure( 4.0, KDChartEnums::MeasureCalculationModeAbsolute ) ); m_legend->setFloatingPosition( relativePosition );
Actually that's exactly the code KD Chart is using as default position for any floating legends, so if you just say setPosition( KDChart::Position::Floating ) without calling setFloatingPosition your legend will be positioned at point 4/4.
Definition at line 507 of file KDChartLegend.cpp.
References d, and KDChart::Position::Floating.
|
inherited |
Definition at line 88 of file KDChartAbstractAreaBase.cpp.
References d, and KDChart::AbstractAreaBase::positionHasChanged().
void Legend::setHiddenDatasets | ( | const QList< uint > | hiddenDatasets | ) |
Sets a list of datasets that are to be hidden in the legend.
By passing an empty list, you show all datasets. All datasets are shown by default, which means that hiddenDatasets() returns an empty list.
Definition at line 1232 of file KDChartLegend.cpp.
References d, and hiddenDatasets().
void Legend::setLegendStyle | ( | LegendStyle | style | ) |
void Legend::setLegendSymbolAlignment | ( | Qt::Alignment | alignment | ) |
Specify the alignment of the legend symbol( alignment of Legend::LinesOnly) within the legend.
Definition at line 493 of file KDChartLegend.cpp.
References alignment(), and d.
void Legend::setMarkerAttributes | ( | uint | dataset, |
const MarkerAttributes & | markerAttributes | ||
) |
Note that any sizes specified via setMarkerAttributes are ignored, unless you disable the automatic size calculation, by saying setUseAutomaticMarkerSize( false )
Definition at line 690 of file KDChartLegend.cpp.
References d, and markerAttributes().
void Legend::setOrientation | ( | Qt::Orientation | orientation | ) |
Definition at line 521 of file KDChartLegend.cpp.
References d, and orientation().
void Legend::setPen | ( | uint | dataset, |
const QPen & | pen | ||
) |
Definition at line 665 of file KDChartLegend.cpp.
void Legend::setPosition | ( | Position | position | ) |
Specify the position of a non-floating legend.
Use setFloatingPosition to set position and alignment if your legend is floating.
Definition at line 444 of file KDChartLegend.cpp.
References d, position(), KDChart::AbstractAreaWidget::positionChanged(), and propertiesChanged().
Referenced by KDChart::Widget::addLegend(), and clone().
void Legend::setRainbowColors | ( | ) |
Definition at line 793 of file KDChartLegend.cpp.
References KDChart::Palette::getBrush(), KDChart::Palette::rainbowPalette(), setBrush(), and KDChart::Palette::size().
void Legend::setReferenceArea | ( | const QWidget * | area | ) |
Specifies the reference area for font size of title text, and for font size of the item texts, IF automatic area detection is set.
If no reference area is specified, but automatic area detection is set, then the size of the legend's parent widget will be used.
Definition at line 278 of file KDChartLegend.cpp.
References d.
Referenced by KDChart::Chart::addLegend().
void Legend::setShowLines | ( | bool | legendShowLines | ) |
Definition at line 551 of file KDChartLegend.cpp.
References d.
void Legend::setSortOrder | ( | Qt::SortOrder | order | ) |
Definition at line 536 of file KDChartLegend.cpp.
References d.
void Legend::setSpacing | ( | uint | space | ) |
Definition at line 770 of file KDChartLegend.cpp.
References d.
void Legend::setSubduedColors | ( | bool | ordered = false | ) |
Definition at line 801 of file KDChartLegend.cpp.
References KDChart::Palette::getBrush(), setBrush(), KDChart::Palette::size(), and KDChart::Palette::subduedPalette().
void Legend::setText | ( | uint | dataset, |
const QString & | text | ||
) |
Definition at line 592 of file KDChartLegend.cpp.
void Legend::setTextAlignment | ( | Qt::Alignment | alignment | ) |
Specify the alignment of the text elements within the legend.
Definition at line 479 of file KDChartLegend.cpp.
References alignment(), and d.
Referenced by clone().
void Legend::setTextAttributes | ( | const TextAttributes & | a | ) |
Definition at line 717 of file KDChartLegend.cpp.
References d.
Referenced by KDChart::Chart::addLegend(), clone(), and ~Legend().
void Legend::setTitleText | ( | const QString & | text | ) |
Definition at line 731 of file KDChartLegend.cpp.
void Legend::setTitleTextAttributes | ( | const TextAttributes & | a | ) |
Definition at line 745 of file KDChartLegend.cpp.
References d.
Referenced by KDChart::Chart::addLegend(), clone(), and ~Legend().
void Legend::setUseAutomaticMarkerSize | ( | bool | useAutomaticMarkerSize | ) |
This option is on by default, it means that Marker sizes in the Legend will be the same as the font height used for their respective label texts.
Set this to false, if you want to specify the marker sizes via setMarkerAttributes or if you want the Legend to use the same marker sizes as they are used in the Diagrams.
Definition at line 566 of file KDChartLegend.cpp.
References d, and useAutomaticMarkerSize().
Referenced by clone().
|
override |
Definition at line 430 of file KDChartLegend.cpp.
References sizeHint().
bool Legend::showLines | ( | ) | const |
Definition at line 561 of file KDChartLegend.cpp.
References d.
Referenced by compare(), heightForWidth(), and updateToplevelLayout().
|
override |
Definition at line 145 of file KDChartLegend.cpp.
References d.
Referenced by minimumSizeHint(), KDChart::Chart::reLayoutFloatingLegends(), resizeEvent(), and setVisible().
Qt::SortOrder Legend::sortOrder | ( | ) | const |
uint Legend::spacing | ( | ) | const |
Definition at line 780 of file KDChartLegend.cpp.
References d.
Referenced by compare(), heightForWidth(), and updateToplevelLayout().
QString Legend::text | ( | uint | dataset | ) | const |
Definition at line 601 of file KDChartLegend.cpp.
References d.
Referenced by setText(), setTitleText(), and updateToplevelLayout().
Qt::Alignment Legend::textAlignment | ( | ) | const |
Returns the alignment used while rendering text elements within the legend.
Definition at line 488 of file KDChartLegend.cpp.
References d.
TextAttributes Legend::textAttributes | ( | ) | const |
Definition at line 726 of file KDChartLegend.cpp.
References d.
Referenced by KDChart::Chart::addLegend(), clone(), compare(), and updateToplevelLayout().
const QMap< uint, QString > Legend::texts | ( | ) | const |
QString Legend::titleText | ( | ) | const |
Definition at line 740 of file KDChartLegend.cpp.
References d.
Referenced by compare(), and updateToplevelLayout().
TextAttributes Legend::titleTextAttributes | ( | ) | const |
Definition at line 754 of file KDChartLegend.cpp.
References d.
Referenced by KDChart::Chart::addLegend(), clone(), compare(), and updateToplevelLayout().
bool Legend::useAutomaticMarkerSize | ( | ) | const |
Definition at line 573 of file KDChartLegend.cpp.
References d.
Referenced by clone(), compare(), resizeEvent(), and setUseAutomaticMarkerSize().