##// END OF EJS Templates
Make all Q_DISABLE_COPY declarations private....
Make all Q_DISABLE_COPY declarations private. Task-number: QTRD-1945 Change-Id: I5cf04319ae2e4e9da1122be888c3c3e49928c748 Reviewed-by: Titta Heikkala <titta.heikkala@theqtcompany.com>

File last commit:

r2714:929d943d1aab
r2723:c6cc3c566c94
Show More
qlegend.cpp
632 lines | 16.6 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
Michal Klocek
Adds qlegend pimpl...
r950 **
Titta Heikkala
Update copyright year...
r2688 ** Copyright (C) 2014 Digia Plc
Michal Klocek
Adds qlegend pimpl...
r950 ** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
Miikka Heikkinen
Qt Commercial -> Qt Enterprise...
r2574 ** This file is part of the Qt Enterprise Charts Add-on.
Michal Klocek
Adds qlegend pimpl...
r950 **
** $QT_BEGIN_LICENSE$
Miikka Heikkinen
Qt Commercial -> Qt Enterprise...
r2574 ** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
Michal Klocek
Adds qlegend pimpl...
r950 ** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Jani Honkonen
Add license headers
r794
Titta Heikkala
Fix include syntax...
r2714 #include <QtCharts/QLegend>
#include <private/qlegend_p.h>
#include <QtCharts/QAbstractSeries>
#include <private/qabstractseries_p.h>
#include <private/qchart_p.h>
#include <private/legendlayout_p.h>
#include <private/chartpresenter_p.h>
#include <private/abstractchartlayout_p.h>
#include <QtCharts/QLegendMarker>
#include <private/qlegendmarker_p.h>
#include <private/legendmarkeritem_p.h>
#include <private/chartdataset_p.h>
#include <QtGui/QPainter>
#include <QtGui/QPen>
#include <QtWidgets/QGraphicsItemGroup>
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_BEGIN_NAMESPACE
sauimone
First version of legend. Simple markers and serie names. Using drilldown as example for now.
r529
sauimone
legend documentation fix. detaching and attaching the legend
r728 /*!
Tero Ahola
Documentation fixes....
r995 \class QLegend
Titta Heikkala
Fix Charts documentation...
r2639 \inmodule Qt Charts
Miikka Heikkinen
Fix some documentation issues...
r2520 \brief Legend object.
Tero Ahola
Documentation fixes....
r995 \mainclass
sauimone
legend documentation fix. detaching and attaching the legend
r728
Miikka Heikkinen
Documentation updates...
r2494 QLegend is a graphical object for displaying the legend of the chart. Legend state is updated by QChart, when
Tero Ahola
Documentation fixes....
r995 series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and
handle the drawing manually.
User isn't supposed to create or delete legend objects, but can reference it via QChart class.
sauimone
legend documentation fix. detaching and attaching the legend
r728
Tero Ahola
Documentation fixes....
r995 \image examples_percentbarchart_legend.png
sauimone
legend documentation fix. detaching and attaching the legend
r728
Tero Ahola
Documentation fixes....
r995 \sa QChart
*/
Tero Ahola
Adding legend properties
r1452 /*!
Titta Heikkala
Fix Charts documentation...
r2639 \qmltype Legend
\instantiates QLegend
Titta Heikkala
Qt Charts project file structure change...
r2712 \inqmlmodule QtCharts
Tero Ahola
Adding legend properties
r1452
Titta Heikkala
Qt Charts project file structure change...
r2712 \brief Legend is part of Qt Chart QML API.
Legend is a graphical object, whics displays legend of the chart. Legend state is updated by
ChartView, when series have been changed. Legend is used via ChartView class. For example:
\code
ChartView {
legend.visible: true
legend.alignment: Qt.AlignBottom
// Add a few series...
}
\endcode
\image examples_percentbarchart_legend.png
Tero Ahola
Updated Legend/Marker documentation
r2240
Titta Heikkala
Qt Charts project file structure change...
r2712 Please note that there is no QML API available for modifying legend markers, unlike in the Qt
API of Charts. The use case of modifying markers can be implemented for example by creating your
own custom legend. For an example on how to do this,
see \l {qmlcustomlegend}{Qml Custom Example} application.
Tero Ahola
Adding legend properties
r1452 */
/*!
\property QLegend::alignment
\brief The alignment of the legend.
Legend paints on the defined position in the chart. The following alignments are supported:
Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight. If you set more than one flag the result is undefined.
*/
/*!
\qmlproperty Qt.Alignment Legend::alignment
\brief The alignment of the legend.
Legend paints on the defined position in the chart. The following alignments are supported:
Qt.AlignTop, Qt.AlignBottom, Qt.AlignLeft, Qt.AlignRight. If you set more than one flag the result is undefined.
*/
/*!
\property QLegend::backgroundVisible
Whether the legend background is visible or not.
*/
/*!
\qmlproperty bool Legend::backgroundVisible
Whether the legend background is visible or not.
*/
/*!
\property QLegend::color
Tero Ahola
Fixed setting the legend (background) color
r1472 The color of the legend, i.e. the background (brush) color. Note that if you change the color
of the legend, the style of the legend brush is set to Qt::SolidPattern.
Tero Ahola
Adding legend properties
r1452 */
/*!
\qmlproperty color Legend::color
Tero Ahola
Fixed setting the legend (background) color
r1472 The color of the legend, i.e. the background (brush) color.
Tero Ahola
Adding legend properties
r1452 */
/*!
\property QLegend::borderColor
The border color of the legend, i.e. the line color.
*/
/*!
\qmlproperty color Legend::borderColor
The border color of the legend, i.e. the line color.
*/
sauimone
legend documentation fix. detaching and attaching the legend
r728
sauimone
legend font fix
r1522 /*!
\property QLegend::font
Titta Heikkala
Minor fixes to documentation...
r2686 The font of markers used by legend.
sauimone
legend font fix
r1522 */
/*!
Tero Ahola
Fixed documentation bugs in QML ChartView
r2113 \qmlproperty Font Legend::font
Titta Heikkala
Minor fixes to documentation...
r2686 The font of markers used by legend.
sauimone
legend font fix
r1522 */
Tero Ahola
Documented QLegend label properties
r1529 /*!
\property QLegend::labelColor
The color of brush used to draw labels.
*/
/*!
Titta Heikkala
Minor fixes to documentation...
r2686 \qmlproperty color Legend::labelColor
Tero Ahola
Documented QLegend label properties
r1529 The color of brush used to draw labels.
*/
Titta Heikkala
Add possibility to set markers in legend in reverse order...
r2676 /*!
\property QLegend::reverseMarkers
Whether reverse order is used for the markers in legend or not. False by default.
*/
/*!
\qmlproperty bool Legend::reverseMarkers
Whether reverse order is used for the markers in legend or not. False by default.
*/
Tero Ahola
Adding legend properties
r1452 /*!
\fn void QLegend::backgroundVisibleChanged(bool)
The visibility of the legend background changed to \a visible.
*/
/*!
\fn void QLegend::colorChanged(QColor)
The color of the legend background changed to \a color.
*/
/*!
\fn void QLegend::borderColorChanged(QColor)
The border color of the legend background changed to \a color.
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357 */
sauimone
layout fix to legend. Documented legend functions.
r724
sauimone
legend font fix
r1522 /*!
\fn void QLegend::fontChanged(QFont)
The font of markers of the legend changed to \a font.
*/
Tero Ahola
Documented QLegend label properties
r1529 /*!
\fn void QLegend::labelColorChanged(QColor color)
This signal is emitted when the color of brush used to draw labels has changed to \a color.
*/
Titta Heikkala
Minor fixes to documentation...
r2686 /*!
\fn void QLegend::reverseMarkersChanged(bool)
The use of reverse order for the markers in legend is changed to \a reverseMarkers.
*/
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 QLegend::QLegend(QChart *chart): QGraphicsWidget(chart),
d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter, chart, this))
sauimone
minor code review fixes
r762 {
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 setZValue(ChartPresenter::LegendZValue);
Michal Klocek
Refactor qledgend handling...
r855 setFlags(QGraphicsItem::ItemClipsChildrenToShape);
Michal Klocek
Refactors internals...
r2273 QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesAdded(QAbstractSeries*)), d_ptr.data(), SLOT(handleSeriesAdded(QAbstractSeries*)));
Jani Honkonen
src folder: another massive victory for coding style police
r2131 QObject::connect(chart->d_ptr->m_dataset, SIGNAL(seriesRemoved(QAbstractSeries*)), d_ptr.data(), SLOT(handleSeriesRemoved(QAbstractSeries*)));
Michal Klocek
Refactors layout managment...
r1534 setLayout(d_ptr->m_layout);
Michal Klocek
Adds qlegend pimpl...
r950 }
Tero Ahola
No errors anymore when generating docs, wohoo! For now.
r1002 /*!
Destroys the legend object. Legend is always owned by a QChart, so an application should never call this.
*/
Michal Klocek
Adds qlegend pimpl...
r950 QLegend::~QLegend()
{
sauimone
framework for legend
r524 }
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
sauimone
legend doc changes
r1501 \internal
Michal Klocek
Adds qlegend pimpl...
r950 */
sauimone
framework for legend
r524 void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Michal Klocek
Adds qlegend pimpl...
r950 Q_UNUSED(option)
Q_UNUSED(widget)
Michal Klocek
Fix show Event in legend widget
r1963
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (!d_ptr->m_backgroundVisible)
return;
Tero Ahola
Squashed bunch of warnings
r611
sauimone
layout fix to legend. Documented legend functions.
r724 painter->setOpacity(opacity());
Michal Klocek
Adds qlegend pimpl...
r950 painter->setPen(d_ptr->m_pen);
painter->setBrush(d_ptr->m_brush);
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 painter->drawRoundRect(rect(), d_ptr->roundness(rect().width()), d_ptr->roundness(rect().height()));
sauimone
framework for legend
r524 }
Michal Klocek
Refactors layout managment...
r1534
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 Sets the \a brush of legend. Brush affects the background of legend.
*/
Tero Ahola
Code review: Fixed simple issues in Bar and Legend
r737 void QLegend::setBrush(const QBrush &brush)
sauimone
background to legend, theme applies
r540 {
Michal Klocek
Adds qlegend pimpl...
r950 if (d_ptr->m_brush != brush) {
d_ptr->m_brush = brush;
Michal Klocek
Adds force option to chartTheme...
r645 update();
Tero Ahola
Fixed signaling in QLegend
r1543 emit colorChanged(brush.color());
Michal Klocek
Adds force option to chartTheme...
r645 }
}
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 Returns the brush used by legend.
*/
Michal Klocek
Adds force option to chartTheme...
r645 QBrush QLegend::brush() const
{
Michal Klocek
Adds qlegend pimpl...
r950 return d_ptr->m_brush;
Michal Klocek
Adds force option to chartTheme...
r645 }
Tero Ahola
Adding legend properties
r1452 void QLegend::setColor(QColor color)
{
QBrush b = d_ptr->m_brush;
Tero Ahola
Fixed setting the legend (background) color
r1472 if (b.style() != Qt::SolidPattern || b.color() != color) {
b.setStyle(Qt::SolidPattern);
Tero Ahola
Adding legend properties
r1452 b.setColor(color);
setBrush(b);
}
}
QColor QLegend::color()
{
return d_ptr->m_brush.color();
}
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 Sets the \a pen of legend. Pen affects the legend borders.
*/
Tero Ahola
Code review: Fixed simple issues in Bar and Legend
r737 void QLegend::setPen(const QPen &pen)
Michal Klocek
Adds force option to chartTheme...
r645 {
Michal Klocek
Adds qlegend pimpl...
r950 if (d_ptr->m_pen != pen) {
d_ptr->m_pen = pen;
Michal Klocek
Adds force option to chartTheme...
r645 update();
Tero Ahola
Fixed signaling in QLegend
r1543 emit borderColorChanged(pen.color());
Michal Klocek
Adds force option to chartTheme...
r645 }
sauimone
background to legend, theme applies
r540 }
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Titta Heikkala
Minor fixes to documentation...
r2686 Returns the pen used by legend.
Michal Klocek
Adds qlegend pimpl...
r950 */
sauimone
layout fix to legend. Documented legend functions.
r724
Michal Klocek
Adds force option to chartTheme...
r645 QPen QLegend::pen() const
sauimone
background to legend, theme applies
r540 {
Michal Klocek
Adds qlegend pimpl...
r950 return d_ptr->m_pen;
sauimone
background to legend, theme applies
r540 }
Michal Klocek
Refactors layout managment...
r1534 void QLegend::setFont(const QFont &font)
{
Michal Klocek
Refactors internals...
r2273 if (d_ptr->m_font != font) {
Titta Heikkala
Fix legend drawing on font change...
r2652 // Hide items to avoid flickering
d_ptr->items()->setVisible(false);
Michal Klocek
Refactors layout managment...
r1534 d_ptr->m_font = font;
Michal Klocek
Refactors internals...
r2273 foreach (QLegendMarker *marker, d_ptr->markers()) {
marker->setFont(d_ptr->m_font);
}
layout()->invalidate();
emit fontChanged(font);
Michal Klocek
Refactors layout managment...
r1534 }
}
QFont QLegend::font() const
{
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 return d_ptr->m_font;
Michal Klocek
Refactors layout managment...
r1534 }
Tero Ahola
Adding legend properties
r1452 void QLegend::setBorderColor(QColor color)
{
QPen p = d_ptr->m_pen;
if (p.color() != color) {
p.setColor(color);
setPen(p);
}
}
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357
Tero Ahola
Adding legend properties
r1452 QColor QLegend::borderColor()
{
return d_ptr->m_pen.color();
}
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357
Tero Ahola
Documented QLegend label properties
r1529 /*!
Set brush used to draw labels to \a brush.
*/
sauimone
legend theme fix
r1527 void QLegend::setLabelBrush(const QBrush &brush)
{
if (d_ptr->m_labelBrush != brush) {
Michal Klocek
Refactors layout managment...
r1534 d_ptr->m_labelBrush = brush;
sauimone
code inspection round 1 fixes
r2185 foreach (QLegendMarker *marker, d_ptr->markers()) {
Michal Klocek
Refactors layout managment...
r1534 marker->setLabelBrush(d_ptr->m_labelBrush);
Tero Ahola
Legend marker rect color now follows the text color
r1795 // Note: The pen of the marker rectangle could be exposed in the public QLegend API
// instead of mapping it from label brush color
marker->setPen(brush.color());
Michal Klocek
Refactors layout managment...
r1534 }
Tero Ahola
Fixed signaling in QLegend
r1543 emit labelColorChanged(brush.color());
sauimone
legend theme fix
r1527 }
}
Tero Ahola
Documented QLegend label properties
r1529 /*!
Brush used to draw labels.
*/
sauimone
legend theme fix
r1527 QBrush QLegend::labelBrush() const
{
return d_ptr->m_labelBrush;
}
void QLegend::setLabelColor(QColor color)
{
QBrush b = d_ptr->m_labelBrush;
if (b.style() != Qt::SolidPattern || b.color() != color) {
b.setStyle(Qt::SolidPattern);
b.setColor(color);
setLabelBrush(b);
}
}
QColor QLegend::labelColor() const
{
return d_ptr->m_labelBrush.color();
}
Michal Klocek
Refactors layout managment...
r1534
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357 void QLegend::setAlignment(Qt::Alignment alignment)
sauimone
legend layouting change
r616 {
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (d_ptr->m_alignment != alignment) {
Michal Klocek
Adds qlegend pimpl...
r950 d_ptr->m_alignment = alignment;
Michal Klocek
Fix title font resize does not invalidate layout
r2088 layout()->invalidate();
Michal Klocek
Refactor qledgend handling...
r855 }
sauimone
Scrolling logic to legend
r716 }
Tero Ahola
Qml ChartView properties; legend to use Qt alignments
r1357 Qt::Alignment QLegend::alignment() const
sauimone
Scrolling logic to legend
r716 {
Michal Klocek
Adds qlegend pimpl...
r950 return d_ptr->m_alignment;
sauimone
legend layouting change
r616 }
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 Detaches the legend from chart. Chart won't change layout of the legend.
*/
void QLegend::detachFromChart()
sauimone
framework for legend
r524 {
Michal Klocek
Adds qlegend pimpl...
r950 d_ptr->m_attachedToChart = false;
sauimone
fix: legend detaching/attaching now invalidates chart layout
r2392 // layout()->invalidate();
d_ptr->m_chart->layout()->invalidate();
Michal Klocek
Refactors layout managment...
r1534 setParent(0);
sauimone
handleThemeChanged slot to legend.
r586 }
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 Attaches the legend to chart. Chart may change layout of the legend.
*/
void QLegend::attachToChart()
sauimone
handleThemeChanged slot to legend.
r586 {
Michal Klocek
Refactors layout managment...
r1534 d_ptr->m_attachedToChart = true;
sauimone
fix: legend detaching/attaching now invalidates chart layout
r2392 // layout()->invalidate();
d_ptr->m_chart->layout()->invalidate();
Michal Klocek
Refactors layout managment...
r1534 setParent(d_ptr->m_chart);
sauimone
handleThemeChanged slot to legend.
r586 }
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 Returns true, if legend is attached to chart.
*/
bool QLegend::isAttachedToChart()
sauimone
Added handling for pieslice add/remove to legend
r637 {
Michal Klocek
Adds qlegend pimpl...
r950 return d_ptr->m_attachedToChart;
sauimone
Added handling for pieslice add/remove to legend
r637 }
sauimone
legend layout with padding
r799 /*!
Michal Klocek
Adds qlegend pimpl...
r950 Sets the visibility of legend background to \a visible
*/
void QLegend::setBackgroundVisible(bool visible)
sauimone
legend layout with padding
r799 {
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (d_ptr->m_backgroundVisible != visible) {
Tero Ahola
Adding legend properties
r1452 d_ptr->m_backgroundVisible = visible;
Michal Klocek
Adds qlegend pimpl...
r950 update();
Tero Ahola
Adding legend properties
r1452 emit backgroundVisibleChanged(visible);
Michal Klocek
Adds qlegend pimpl...
r950 }
sauimone
legend layout with padding
r799 }
/*!
Michal Klocek
Adds qlegend pimpl...
r950 Returns the visibility of legend background
*/
bool QLegend::isBackgroundVisible() const
sauimone
legend layout with padding
r799 {
Michal Klocek
Adds qlegend pimpl...
r950 return d_ptr->m_backgroundVisible;
sauimone
legend layout with padding
r799 }
sauimone
documentation of legendmarkers
r2216 /*!
Returns the list of markers in legend. The list can be filtered with \a series parameter.
If \a series is given, only markers related to that series are returned.
*/
sauimone
optional series parameter to markers function. code style fixes
r2193 QList<QLegendMarker*> QLegend::markers(QAbstractSeries *series) const
sauimone
first prototry of QLegendMarker API
r2160 {
sauimone
optional series parameter to markers function. code style fixes
r2193 return d_ptr->markers(series);
sauimone
first prototry of QLegendMarker API
r2160 }
Titta Heikkala
Add possibility to set markers in legend in reverse order...
r2676 bool QLegend::reverseMarkers()
{
return d_ptr->m_reverseMarkers;
}
void QLegend::setReverseMarkers(bool reverseMarkers)
{
if (d_ptr->m_reverseMarkers != reverseMarkers) {
d_ptr->m_reverseMarkers = reverseMarkers;
layout()->invalidate();
emit reverseMarkersChanged(reverseMarkers);
}
}
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 \internal \a event see QGraphicsWidget for details
*/
void QLegend::hideEvent(QHideEvent *event)
sauimone
First version of legend. Simple markers and serie names. Using drilldown as example for now.
r529 {
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (isAttachedToChart())
d_ptr->m_presenter->layout()->invalidate();
QGraphicsWidget::hideEvent(event);
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 }
sauimone
layout fix to legend. Documented legend functions.
r724 /*!
Michal Klocek
Adds qlegend pimpl...
r950 \internal \a event see QGraphicsWidget for details
*/
void QLegend::showEvent(QShowEvent *event)
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 {
Titta Heikkala
Fix missing legend...
r2602 if (isAttachedToChart())
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 layout()->invalidate();
QGraphicsWidget::showEvent(event);
//layout activation will show the items
Michal Klocek
Adds qlegend pimpl...
r950 }
Michal Klocek
Refactor qledgend handling...
r855
Michal Klocek
Adds qlegend pimpl...
r950 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Jani Honkonen
more coding style fixes for src-folder...
r2104 QLegendPrivate::QLegendPrivate(ChartPresenter *presenter, QChart *chart, QLegend *q)
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 : q_ptr(q),
m_presenter(presenter),
m_layout(new LegendLayout(q)),
m_chart(chart),
m_items(new QGraphicsItemGroup(q)),
m_alignment(Qt::AlignTop),
m_brush(QBrush()),
m_pen(QPen()),
m_labelBrush(QBrush()),
m_diameter(5),
m_attachedToChart(true),
Titta Heikkala
Add possibility to set markers in legend in reverse order...
r2676 m_backgroundVisible(false),
m_reverseMarkers(false)
Michal Klocek
Adds qlegend pimpl...
r950 {
sauimone
fix to example. Event handling prototyping.
r2169 m_items->setHandlesChildEvents(false);
sauimone
handleThemeChanged slot to legend.
r586 }
Michal Klocek
Adds qlegend pimpl...
r950 QLegendPrivate::~QLegendPrivate()
{
sauimone
First version of legend. Simple markers and serie names. Using drilldown as example for now.
r529
Michal Klocek
Adds qlegend pimpl...
r950 }
sauimone
Kinetic scrolling is back for legend
r2189 void QLegendPrivate::setOffset(const QPointF &offset)
Michal Klocek
Refactor qledgend handling...
r855 {
sauimone
Kinetic scrolling is back for legend
r2189 m_layout->setOffset(offset.x(), offset.y());
Michal Klocek
Refactor qledgend handling...
r855 }
sauimone
Scrolling logic to legend
r716
sauimone
moved legend offset to private side
r1458 QPointF QLegendPrivate::offset() const
{
Michal Klocek
Refactors layout managment...
r1534 return m_layout->offset();
sauimone
legend example to documentation. minor legend fixes
r1300 }
sauimone
added roundness to legend background
r1453 int QLegendPrivate::roundness(qreal size)
{
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 return 100 * m_diameter / int(size);
sauimone
added roundness to legend background
r1453 }
sauimone
optional series parameter to markers function. code style fixes
r2193 QList<QLegendMarker*> QLegendPrivate::markers(QAbstractSeries *series)
{
// Return all markers
if (!series) {
return m_markers;
}
// Create filtered list
QList<QLegendMarker *> markers;
foreach (QLegendMarker *marker, m_markers) {
if (marker->series() == series) {
markers.append(marker);
}
}
return markers;
}
sauimone
no need for add/remove series in legend, since these are handled via slots
r2209 void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series)
sauimone
refactoring
r2167 {
if (m_series.contains(series)) {
sauimone
some cleanup on legend and pie. No need for pie to know too much about legend
r2173 return;
sauimone
refactoring
r2167 }
sauimone
added LegendMarkerItem. Updated new legend example to test clicked of LegendMarker
r2164
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163 QList<QLegendMarker*> newMarkers = series->d_ptr->createLegendMarkers(q_ptr);
sauimone
Better handling for new or removed markers
r2182 decorateMarkers(newMarkers);
addMarkers(newMarkers);
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163
sauimone
cleaning up todos
r2192 QObject::connect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163 QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
Michal Klocek
Adds trivial legend handling for slices when removed or added
r956
sauimone
some cleanup on legend and pie. No need for pie to know too much about legend
r2173 m_series.append(series);
Michal Klocek
Fixes legend markers updates
r2085 m_items->setVisible(false);
Michal Klocek
Fix title font resize does not invalidate layout
r2088 m_layout->invalidate();
sauimone
Scrolling logic to legend
r716 }
sauimone
no need for add/remove series in legend, since these are handled via slots
r2209 void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series)
sauimone
Scrolling logic to legend
r716 {
sauimone
some cleanup on legend and pie. No need for pie to know too much about legend
r2173 if (m_series.contains(series)) {
m_series.removeOne(series);
}
sauimone
removing old commented code. removing domain parameter from handleseriesadded of pimpl. adding QLegend parameter to marker construction
r2171
sauimone
Better handling for new or removed markers
r2182 // Find out, which markers to remove
QList<QLegendMarker *> removed;
sauimone
code inspection round 1 fixes
r2185 foreach (QLegendMarker *m, m_markers) {
sauimone
Better handling for new or removed markers
r2182 if (m->series() == series) {
removed << m;
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163 }
}
sauimone
Better handling for new or removed markers
r2182 removeMarkers(removed);
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163
sauimone
cleaning up todos
r2192 QObject::disconnect(series->d_ptr.data(), SIGNAL(countChanged()), this, SLOT(handleCountChanged()));
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163 QObject::disconnect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged()));
Michal Klocek
Fix title font resize does not invalidate layout
r2088 m_layout->invalidate();
sauimone
some cleanup on legend and pie. No need for pie to know too much about legend
r2173 }
sauimone
fix: series visible now affects legend items also
r1459 void QLegendPrivate::handleSeriesVisibleChanged()
{
Jani Honkonen
more coding style fixes for src-folder...
r2104 QAbstractSeries *series = qobject_cast<QAbstractSeries *> (sender());
Michal Klocek
Fixes legend markers updates
r2085 Q_ASSERT(series);
sauimone
fix: series visible now affects legend items also
r1459
sauimone
optional series parameter to markers function. code style fixes
r2193 foreach (QLegendMarker *marker, m_markers) {
sauimone
Added createLegendMarkers to private series. This will replace old createLegendMarker method. Notice the s in new method name. PIMPL for QLegendMarker. Newlegend example updated a bit
r2163 if (marker->series() == series) {
marker->setVisible(series->isVisible());
}
}
Titta Heikkala
Fix ChartView visibility change drawing...
r2605
if (m_chart->isVisible())
m_layout->invalidate();
sauimone
fix: series visible now affects legend items also
r1459 }
Michal Klocek
Fixes legend markers updates
r2085 void QLegendPrivate::handleCountChanged()
sauimone
legend private implemantation modified.
r2081 {
sauimone
Better handling for new or removed markers
r2182 // Here we handle the changes in marker count.
// Can happen for example when pieslice(s) have been added to or removed from pieseries.
sauimone
some cleanup on legend and pie. No need for pie to know too much about legend
r2173
sauimone
cleaning up todos
r2192 QAbstractSeriesPrivate *series = qobject_cast<QAbstractSeriesPrivate *> (sender());
QList<QLegendMarker *> createdMarkers = series->createLegendMarkers(q_ptr);
sauimone
Better handling for new or removed markers
r2182
// Find out removed markers and created markers
QList<QLegendMarker *> removedMarkers;
sauimone
code inspection round 1 fixes
r2185 foreach (QLegendMarker *oldMarker, m_markers) {
sauimone
Better handling for new or removed markers
r2182 // we have marker, which is related to sender.
sauimone
cleaning up todos
r2192 if (oldMarker->series() == series->q_ptr) {
sauimone
Better handling for new or removed markers
r2182 bool found = false;
foreach(QLegendMarker *newMarker, createdMarkers) {
// New marker considered existing if:
// - d_ptr->relatedObject() is same for both markers.
if (newMarker->d_ptr->relatedObject() == oldMarker->d_ptr->relatedObject()) {
// Delete the new marker, since we already have existing marker, that might be connected on user side.
found = true;
createdMarkers.removeOne(newMarker);
delete newMarker;
}
}
if (!found) {
// No related object found for marker, add to removedMarkers list
removedMarkers << oldMarker;
}
}
}
removeMarkers(removedMarkers);
sauimone
Legend can now handle clicked and do scrolling
r2183 decorateMarkers(createdMarkers);
sauimone
Better handling for new or removed markers
r2182 addMarkers(createdMarkers);
q_ptr->layout()->invalidate();
}
void QLegendPrivate::addMarkers(QList<QLegendMarker *> markers)
{
sauimone
optional series parameter to markers function. code style fixes
r2193 foreach (QLegendMarker *marker, markers) {
sauimone
Better handling for new or removed markers
r2182 m_items->addToGroup(marker->d_ptr.data()->item());
sauimone
code inspection round 1 fixes
r2185 m_markers << marker;
sauimone
better implementation of mouse event handling in legend
r2197 m_markerHash.insert(marker->d_ptr->item(), marker);
sauimone
Better handling for new or removed markers
r2182 }
}
void QLegendPrivate::removeMarkers(QList<QLegendMarker *> markers)
{
foreach (QLegendMarker *marker, markers) {
marker->d_ptr->item()->setVisible(false);
m_items->removeFromGroup(marker->d_ptr->item());
sauimone
code inspection round 1 fixes
r2185 m_markers.removeOne(marker);
sauimone
better implementation of mouse event handling in legend
r2197 m_markerHash.remove(marker->d_ptr->item());
delete marker;
sauimone
Better handling for new or removed markers
r2182 }
}
void QLegendPrivate::decorateMarkers(QList<QLegendMarker *> markers)
{
sauimone
optional series parameter to markers function. code style fixes
r2193 foreach (QLegendMarker *marker, markers) {
sauimone
Better handling for new or removed markers
r2182 marker->setFont(m_font);
marker->setLabelBrush(m_labelBrush);
}
sauimone
legend private implemantation modified.
r2081 }
sauimone
Better handling for new or removed markers
r2182
sauimone
framework for legend
r524 #include "moc_qlegend.cpp"
Michal Klocek
Adds qlegend pimpl...
r950 #include "moc_qlegend_p.cpp"
Tero Ahola
Code review: Fixed simple issues in Bar and Legend
r737
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_END_NAMESPACE