##// END OF EJS Templates
Make scatterinteractions compile
Make scatterinteractions compile

File last commit:

r800:32248fc3cb26
r831:d1edc6bf68da
Show More
legendmarker.cpp
214 lines | 5.4 KiB | text/x-c | CppLexer
/ src / legendmarker.cpp
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** 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$
**
****************************************************************************/
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 #include "qchartglobal.h"
#include "legendmarker_p.h"
sauimone
removed handlethemechange for legend. Too complex solution. Legend now listens the changed signals from series
r587 #include <qpieslice.h>
#include <qbarset.h>
sauimone
legend layouting change
r616 #include <qxyseries.h>
sauimone
legend refactoring.
r792 #include <qareaseries.h>
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 #include <QPainter>
#include <QGraphicsSceneEvent>
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 #include <QGraphicsSimpleTextItem>
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
legend fixes
r766 LegendMarker::LegendMarker(QSeries *series, QGraphicsItem *parent) : QGraphicsObject(parent),
sauimone
legend marker pointer fix
r778 m_pos(0,0),
m_size(0,0),
m_boundingRect(0,0,0,0),
m_markerBoundingRect(0,0,0,0),
m_series(series),
m_barset(0),
m_pieslice(0),
m_textItem(new QGraphicsSimpleTextItem(this))
sauimone
legend fixes
r766 {
setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
}
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565
sauimone
legend fixes
r766 LegendMarker::LegendMarker(QSeries *series, QBarSet *barset, QGraphicsItem *parent) : QGraphicsObject(parent),
sauimone
legend marker pointer fix
r778 m_pos(0,0),
m_size(0,0),
m_boundingRect(0,0,0,0),
m_markerBoundingRect(0,0,0,0),
m_series(series),
m_barset(barset),
m_pieslice(0),
m_textItem(new QGraphicsSimpleTextItem(this))
sauimone
legend fixes
r766 {
setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
}
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565
sauimone
legend fixes
r766 LegendMarker::LegendMarker(QSeries *series, QPieSlice *pieslice, QGraphicsItem *parent) : QGraphicsObject(parent),
sauimone
legend marker pointer fix
r778 m_pos(0,0),
m_size(0,0),
m_boundingRect(0,0,0,0),
m_markerBoundingRect(0,0,0,0),
m_series(series),
m_barset(0),
m_pieslice(pieslice),
m_textItem(new QGraphicsSimpleTextItem(this))
sauimone
legend fixes
r766 {
setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
}
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 void LegendMarker::setPos(qreal x, qreal y)
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 {
sauimone
legend marker pointer fix
r778 m_pos = QPointF(x,y);
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 layoutChanged();
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
sauimone
legend fixes
r766 void LegendMarker::setPen(const QPen &pen)
sauimone
layout fix to legend. Documented legend functions.
r724 {
sauimone
legend marker pointer fix
r778 m_pen = pen;
sauimone
layout fix to legend. Documented legend functions.
r724 }
QPen LegendMarker::pen() const
{
sauimone
legend marker pointer fix
r778 return m_pen;
sauimone
layout fix to legend. Documented legend functions.
r724 }
sauimone
legend fixes
r766 void LegendMarker::setBrush(const QBrush &brush)
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 {
sauimone
legend marker pointer fix
r778 m_brush = brush;
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 QBrush LegendMarker::brush() const
{
sauimone
legend marker pointer fix
r778 return m_brush;
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 }
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 void LegendMarker::setName(const QString name)
{
sauimone
legend marker pointer fix
r778 m_textItem->setText(name);
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 layoutChanged();
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
QString LegendMarker::name() const
{
sauimone
legend marker pointer fix
r778 return m_textItem->text();
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
sauimone
Legend can handle removing of series
r576 QSeries* LegendMarker::series() const
{
sauimone
legend marker pointer fix
r778 return m_series;
sauimone
Legend can handle removing of series
r576 }
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 void LegendMarker::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Tero Ahola
Squashed bunch of warnings
r611 Q_UNUSED(option)
Q_UNUSED(widget)
sauimone
legend marker pointer fix
r778 painter->setPen(m_pen);
painter->setBrush(m_brush);
painter->drawRect(m_markerBoundingRect);
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
QRectF LegendMarker::boundingRect() const
{
sauimone
legend marker pointer fix
r778 return m_boundingRect;
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 void LegendMarker::layoutChanged()
{
QSizeF markerSize(10,10);
qreal margin = 2;
sauimone
legend marker pointer fix
r778 m_size.setHeight(markerSize.height() + 2 * margin);
m_size.setWidth(m_textItem->boundingRect().width() + markerSize.width() + 3 * margin);
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626
sauimone
legend marker pointer fix
r778 m_boundingRect = QRectF(m_pos.x(),m_pos.y(),m_size.width(),m_size.height());
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626
sauimone
legend marker pointer fix
r778 m_markerBoundingRect = QRectF(m_pos.x() + margin, m_pos.y() + margin, markerSize.width(),markerSize.height());
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626
sauimone
legend marker pointer fix
r778 m_textItem->setPos(m_pos.x() + markerSize.width() + 2 * margin, m_pos.y() + margin);
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 }
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 void LegendMarker::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
sauimone
legend refactoring.
r792 switch (m_series->type()) {
case QSeries::SeriesTypeLine:
case QSeries::SeriesTypeArea:
case QSeries::SeriesTypeScatter:
case QSeries::SeriesTypeSpline: {
sauimone
legend marker pointer fix
r778 emit clicked(m_series,event->button());
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 break;
sauimone
bug fix in legend signals
r569 }
sauimone
legend refactoring.
r792 case QSeries::SeriesTypeBar:
case QSeries::SeriesTypeStackedBar:
case QSeries::SeriesTypePercentBar: {
sauimone
legend marker pointer fix
r778 emit clicked(m_barset,event->button());
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 break;
sauimone
bug fix in legend signals
r569 }
sauimone
legend refactoring.
r792 case QSeries::SeriesTypePie: {
sauimone
legend marker pointer fix
r778 emit clicked(m_pieslice,event->button());
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 break;
}
default: {
break;
sauimone
bug fix in legend signals
r569 }
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 }
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
sauimone
removed handlethemechange for legend. Too complex solution. Legend now listens the changed signals from series
r587 void LegendMarker::changed()
{
sauimone
solid brush for all legend markers
r800 setPen(Qt::NoPen);
sauimone
legend refactoring.
r792 switch (m_series->type()) {
case QSeries::SeriesTypeArea: {
QAreaSeries* s = static_cast<QAreaSeries*> (m_series);
sauimone
legend layouting change
r616 setBrush(s->brush());
setName(s->name());
sauimone
removed handlethemechange for legend. Too complex solution. Legend now listens the changed signals from series
r587 break;
}
sauimone
legend refactoring.
r792 case QSeries::SeriesTypeLine:
case QSeries::SeriesTypeSpline: {
QXYSeries* s = static_cast<QXYSeries*> (m_series);
sauimone
solid brush for all legend markers
r800 setBrush(QBrush(s->pen().color(),Qt::SolidPattern));
sauimone
legend refactoring.
r792 setName(s->name());
break;
}
sauimone
solid brush for all legend markers
r800 case QSeries::SeriesTypeScatter: {
QXYSeries* s = static_cast<QXYSeries*> (m_series);
setBrush(s->brush());
setName(s->name());
break;
}
sauimone
legend refactoring.
r792 case QSeries::SeriesTypeBar:
case QSeries::SeriesTypeStackedBar:
case QSeries::SeriesTypePercentBar: {
sauimone
legend marker pointer fix
r778 setBrush(m_barset->brush());
setName(m_barset->name());
sauimone
removed handlethemechange for legend. Too complex solution. Legend now listens the changed signals from series
r587 break;
sauimone
legend refactoring.
r792 }
case QSeries::SeriesTypePie: {
sauimone
legend marker pointer fix
r778 setBrush(m_pieslice->brush());
setName(m_pieslice->label());
sauimone
removed handlethemechange for legend. Too complex solution. Legend now listens the changed signals from series
r587 break;
sauimone
legend refactoring.
r792 }
default: {
sauimone
solid brush for all legend markers
r800 setBrush(Qt::NoBrush);
sauimone
legend refactoring.
r792 break;
}
sauimone
removed handlethemechange for legend. Too complex solution. Legend now listens the changed signals from series
r587 }
}
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 #include "moc_legendmarker_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE