##// END OF EJS Templates
Fix label visibility for category axis...
Fix label visibility for category axis Hide the labels in category axis that would be drawn on top of other labels. Task-number: QTRD-2525 Change-Id: Ic66a6b501821bbb14636229096d86d38301cf8b6 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>

File last commit:

r2639:2ce3423968b5
r2651:99ad874661ac
Show More
qlegendmarker.cpp
294 lines | 6.7 KiB | text/x-c | CppLexer
/ src / legend / qlegendmarker.cpp
sauimone
first prototry of QLegendMarker API
r2160 /****************************************************************************
**
Miikka Heikkinen
Fixed the copyright year 2012 -> 2013
r2432 ** Copyright (C) 2013 Digia Plc
sauimone
first prototry of QLegendMarker API
r2160 ** 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.
sauimone
first prototry of QLegendMarker API
r2160 **
** $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
sauimone
first prototry of QLegendMarker API
r2160 ** 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$
**
****************************************************************************/
#include "qlegendmarker.h"
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 #include "qlegendmarker_p.h"
sauimone
added LegendMarkerItem. Updated new legend example to test clicked of LegendMarker
r2164 #include "legendmarkeritem_p.h"
sauimone
removing old commented code. removing domain parameter from handleseriesadded of pimpl. adding QLegend parameter to marker construction
r2171 #include "qlegend.h"
sauimone
fix to QTRD-1674: layout is not calculated correctly after the change in the text of legend marker
r2194 #include "qlegend_p.h"
#include "legendlayout_p.h"
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 #include <QFontMetrics>
sauimone
fix to example. Event handling prototyping.
r2169 #include <QGraphicsSceneEvent>
sauimone
Better handling for new or removed markers
r2182 #include <QAbstractSeries>
sauimone
first prototry of QLegendMarker API
r2160
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174
sauimone
documentation of legendmarkers
r2216 /*!
\class QLegendMarker
Titta Heikkala
Fix Charts documentation...
r2639 \inmodule Qt Charts
Miikka Heikkinen
Fix some documentation issues...
r2520 \brief LegendMarker object.
sauimone
documentation of legendmarkers
r2216 \mainclass
sauimone
legendmarker doc update
r2217 QLegendMarker is abstract object that can be used to access markers inside QLegend. Legend marker consists of two
items: The colored box, which reflects the color of series and label, which is the name of series (or label of slice/barset
in case of pie or bar series)
The QLegendMarker is always related to one series.
sauimone
documentation of legendmarkers
r2216
sauimone
legendmarker doc update
r2217 \image examples_percentbarchart_legend.png
sauimone
documentation of legendmarkers
r2216
\sa QLegend
*/
/*!
\enum QLegendMarker::LegendMarkerType
The type of the legendmarker object.
\value LegendMarkerTypeArea
\value LegendMarkerTypeBar
\value LegendMarkerTypePie
\value LegendMarkerTypeXY
Mika Salmela
A new box-and-whiskers series type added to charts....
r2548 \value LegendMarkerTypeBoxPlot
sauimone
documentation of legendmarkers
r2216 */
/*!
\fn virtual LegendMarkerType QLegendMarker::type() = 0;
Returns the type of legendmarker. Type depends of the related series. LegendMarkerTypeXY is used for all QXYSeries derived
classes.
*/
/*!
\fn virtual QAbstractSeries* QLegendMarker::series() = 0;
Returns pointer to series, which is related to this marker. Marker is always related to some series.
*/
/*!
\fn void QLegendMarker::clicked();
This signal is emitted, when marker is clicked with mouse.
*/
/*!
\fn void QLegendMarker::hovered(bool status);
This signal is emitted, when mouse is hovered over marker. \a status is true, when mouse enters the marker
and false when it leaves the marker.
*/
Tero Ahola
Fixed several documentation issues
r2265 /*!
\fn void QLegendMarker::labelChanged()
This signal is emitted when the label of the legend marker has changed.
*/
/*!
\fn void QLegendMarker::labelBrushChanged()
This signal is emitted when the label brush of the legend marker has changed.
*/
/*!
\fn void QLegendMarker::fontChanged()
This signal is emitted when the (label) font of the legend marker has changed.
*/
/*!
\fn void QLegendMarker::penChanged()
This signal is emitted when the pen of the legend marker has changed.
*/
/*!
\fn void QLegendMarker::brushChanged()
This signal is emitted when the brush of the legend marker has changed.
*/
/*!
\fn void QLegendMarker::visibleChanged()
This signal is emitted when the visibility of the legend marker has changed.
*/
sauimone
signals for properties in legendmarker
r2225 /*!
\property QLegendMarker::label
Label of the marker. This is the text that is shown in legend.
*/
sauimone
legend markers doc update
r2226 /*!
\property QLegendMarker::labelBrush
Brush of the label
*/
/*!
\property QLegendMarker::font
Font of the label
*/
/*!
\property QLegendMarker::pen
Pen of the marker. This is the outline of the colored square.
*/
/*!
\property QLegendMarker::brush
Brush of the marker. This is the inside of the colored square.
*/
/*!
\property QLegendMarker::visible
Visibility of the legend marker. Affects label and the colored square.
*/
sauimone
documentation of legendmarkers
r2216 /*!
Tero Ahola
Fixed several documentation issues
r2265 \internal
sauimone
documentation of legendmarkers
r2216 */
sauimone
refactoring
r2167 QLegendMarker::QLegendMarker(QLegendMarkerPrivate &d, QObject *parent) :
QObject(parent),
d_ptr(&d)
{
sauimone
Better handling for new or removed markers
r2182 d_ptr->m_item->setVisible(d_ptr->series()->isVisible());
sauimone
refactoring
r2167 }
sauimone
first prototry of QLegendMarker API
r2160
sauimone
documentation of legendmarkers
r2216 /*!
Destructor of marker
*/
sauimone
first prototry of QLegendMarker API
r2160 QLegendMarker::~QLegendMarker()
{
}
sauimone
documentation of legendmarkers
r2216 /*!
Returns the label of the marker.
*/
sauimone
first prototry of QLegendMarker API
r2160 QString QLegendMarker::label() const
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 return d_ptr->m_item->label();
sauimone
first prototry of QLegendMarker API
r2160 }
sauimone
documentation of legendmarkers
r2216 /*!
Sets the \a label of marker. Note that changing name of series will also change label of its marker.
*/
sauimone
first prototry of QLegendMarker API
r2160 void QLegendMarker::setLabel(const QString &label)
{
Mika Salmela
Fix for not overriding user settings for legend markers....
r2429 if (label.isEmpty()) {
d_ptr->m_customLabel = false;
} else {
d_ptr->m_customLabel = true;
d_ptr->m_item->setLabel(label);
}
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
documentation of legendmarkers
r2216 /*!
Returns the brush which is used to draw label.
*/
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 QBrush QLegendMarker::labelBrush() const
{
sauimone
fix to qlegendmarker labelBrush
r2195 return d_ptr->m_item->labelBrush();
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
documentation of legendmarkers
r2216 /*!
Sets the \a brush of label
*/
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 void QLegendMarker::setLabelBrush(const QBrush &brush)
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 d_ptr->m_item->setLabelBrush(brush);
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
documentation of legendmarkers
r2216 /*!
Retuns the font of label
*/
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 QFont QLegendMarker::font() const
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 return d_ptr->m_item->font();
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
documentation of legendmarkers
r2216 /*!
Sets the \a font of label
*/
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 void QLegendMarker::setFont(const QFont &font)
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 d_ptr->m_item->setFont(font);
sauimone
first prototry of QLegendMarker API
r2160 }
sauimone
documentation of legendmarkers
r2216 /*!
Returns the pen of marker item
*/
sauimone
first prototry of QLegendMarker API
r2160 QPen QLegendMarker::pen() const
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 return d_ptr->m_item->pen();
sauimone
first prototry of QLegendMarker API
r2160 }
sauimone
documentation of legendmarkers
r2216 /*!
Sets the \a pen of marker item
*/
sauimone
first prototry of QLegendMarker API
r2160 void QLegendMarker::setPen(const QPen &pen)
{
Mika Salmela
Fix for not overriding user settings for legend markers....
r2429 if (pen == QPen(Qt::NoPen)) {
d_ptr->m_customPen = false;
} else {
d_ptr->m_customPen = true;
d_ptr->m_item->setPen(pen);
}
sauimone
first prototry of QLegendMarker API
r2160 }
sauimone
documentation of legendmarkers
r2216 /*!
Returns the brush of marker item
*/
sauimone
first prototry of QLegendMarker API
r2160 QBrush QLegendMarker::brush() const
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 return d_ptr->m_item->brush();
sauimone
first prototry of QLegendMarker API
r2160 }
sauimone
documentation of legendmarkers
r2216 /*!
Sets the \a brush of marker item. Note that changing color of the series also changes this.
*/
sauimone
first prototry of QLegendMarker API
r2160 void QLegendMarker::setBrush(const QBrush &brush)
{
Mika Salmela
Fix for not overriding user settings for legend markers....
r2429 if (brush == QBrush(Qt::NoBrush)) {
d_ptr->m_customBrush = false;
} else {
d_ptr->m_customBrush = true;
d_ptr->m_item->setBrush(brush);
}
sauimone
first prototry of QLegendMarker API
r2160 }
sauimone
documentation of legendmarkers
r2216 /*!
Returns visibility of the marker
*/
sauimone
first prototry of QLegendMarker API
r2160 bool QLegendMarker::isVisible() const
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 return d_ptr->m_item->isVisible();
sauimone
first prototry of QLegendMarker API
r2160 }
sauimone
documentation of legendmarkers
r2216 /*!
Sets markers visibility to \a visible
*/
sauimone
first prototry of QLegendMarker API
r2160 void QLegendMarker::setVisible(bool visible)
{
sauimone
tidying up legend marker code. Added QBarLegendMarker
r2174 d_ptr->m_item->setVisible(visible);
sauimone
first prototry of QLegendMarker API
r2160 }
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
removing old commented code. removing domain parameter from handleseriesadded of pimpl. adding QLegend parameter to marker construction
r2171 QLegendMarkerPrivate::QLegendMarkerPrivate(QLegendMarker *q, QLegend *legend) :
sauimone
fixed warnings in legendmarker
r2202 m_legend(legend),
Mika Salmela
Fix for not overriding user settings for legend markers....
r2429 m_customLabel(false),
m_customBrush(false),
m_customPen(false),
sauimone
fixed warnings in legendmarker
r2202 q_ptr(q)
sauimone
refactoring
r2167 {
m_item = new LegendMarkerItem(this);
}
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
QPieLegenmarkerPrivate added
r2166 QLegendMarkerPrivate::~QLegendMarkerPrivate()
{
sauimone
fix: wrong delete order in legendmarkeritem and legendmarker private
r2381 delete m_item;
sauimone
QPieLegenmarkerPrivate added
r2166 }
sauimone
fix to QTRD-1674: layout is not calculated correctly after the change in the text of legend marker
r2194 void QLegendMarkerPrivate::invalidateLegend()
{
m_legend->d_ptr->m_layout->invalidate();
}
sauimone
first prototry of QLegendMarker API
r2160 #include "moc_qlegendmarker.cpp"
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 #include "moc_qlegendmarker_p.cpp"
sauimone
first prototry of QLegendMarker API
r2160
QTCOMMERCIALCHART_END_NAMESPACE