##// END OF EJS Templates
Title and name of QSeries replaced with name
Title and name of QSeries replaced with name

File last commit:

r724:2a4cd4554920
r731:90a16700f8b3
Show More
legendmarker.cpp
176 lines | 3.9 KiB | text/x-c | CppLexer
/ src / legendmarker.cpp
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
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
LegendMarker::LegendMarker(QSeries* series, QGraphicsItem *parent)
: QGraphicsObject(parent)
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 ,mPos(0,0)
,mSize(0,0)
,mBoundingRect(0,0,0,0)
,mMarkerBoundingRect(0,0,0,0)
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 ,mSeries(series)
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 ,mBarset(0)
,mPieslice(0)
,mType(LegendMarkerTypeSeries)
sauimone
fixed bug in legend name drawing
r585 ,mTextItem(new QGraphicsSimpleTextItem(this))
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 {
setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
}
sauimone
Legend can handle removing of series
r576 LegendMarker::LegendMarker(QSeries *series, QBarSet *barset, QGraphicsItem *parent)
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 : QGraphicsObject(parent)
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 ,mPos(0,0)
,mSize(0,0)
,mBoundingRect(0,0,0,0)
,mMarkerBoundingRect(0,0,0,0)
sauimone
Legend can handle removing of series
r576 ,mSeries(series)
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 ,mBarset(barset)
,mPieslice(0)
,mType(LegendMarkerTypeBarset)
sauimone
fixed bug in legend name drawing
r585 ,mTextItem(new QGraphicsSimpleTextItem(this))
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 {
setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
}
sauimone
Legend can handle removing of series
r576 LegendMarker::LegendMarker(QSeries *series, QPieSlice *pieslice, QGraphicsItem *parent)
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 : QGraphicsObject(parent)
sauimone
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 ,mPos(0,0)
,mSize(0,0)
,mBoundingRect(0,0,0,0)
,mMarkerBoundingRect(0,0,0,0)
sauimone
Legend can handle removing of series
r576 ,mSeries(series)
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 ,mBarset(0)
,mPieslice(pieslice)
,mType(LegendMarkerTypePieslice)
sauimone
fixed bug in legend name drawing
r585 ,mTextItem(new QGraphicsSimpleTextItem(this))
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 {
setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
}
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
Adaptive layout to legend. Tries to fit all items inside given maximum size
r626 mPos = QPointF(x,y);
layoutChanged();
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
sauimone
layout fix to legend. Documented legend functions.
r724 void LegendMarker::setPen(const QPen pen)
{
mPen = pen;
}
QPen LegendMarker::pen() const
{
return mPen;
}
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 void LegendMarker::setBrush(const QBrush brush)
{
mBrush = brush;
}
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 QBrush LegendMarker::brush() const
{
return mBrush;
}
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 void LegendMarker::setName(const QString name)
{
sauimone
fixed bug in legend name drawing
r585 mTextItem.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
fixed bug in legend name drawing
r585 return mTextItem.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
{
return mSeries;
}
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
layout fix to legend. Documented legend functions.
r724 painter->setPen(mPen);
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 painter->setBrush(mBrush);
sauimone
fixed bug in legend name drawing
r585 painter->drawRect(mMarkerBoundingRect);
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 }
QRectF LegendMarker::boundingRect() const
{
return mBoundingRect;
}
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;
mSize.setHeight(markerSize.height() + 2 * margin);
mSize.setWidth(mTextItem.boundingRect().width() + markerSize.width() + 3 * margin);
mBoundingRect = QRectF(mPos.x(),mPos.y(),mSize.width(),mSize.height());
mMarkerBoundingRect = QRectF(mPos.x() + margin, mPos.y() + margin, markerSize.width(),markerSize.height());
sauimone
layout fix to legend. Documented legend functions.
r724 mTextItem.setPos(mPos.x() + markerSize.width() + 2 * margin, mPos.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
more intelligent legend. fixed compiler warning in bar.cpp
r565 switch (mType)
{
case LegendMarkerTypeSeries: {
sauimone
combined clicked and rightclicked events of legend to one event with parameter
r567 emit clicked(mSeries,event->button());
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 break;
sauimone
bug fix in legend signals
r569 }
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 case LegendMarkerTypeBarset: {
sauimone
combined clicked and rightclicked events of legend to one event with parameter
r567 emit clicked(mBarset,event->button());
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 break;
sauimone
bug fix in legend signals
r569 }
sauimone
more intelligent legend. fixed compiler warning in bar.cpp
r565 case LegendMarkerTypePieslice: {
sauimone
combined clicked and rightclicked events of legend to one event with parameter
r567 emit clicked(mPieslice,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()
{
switch (mType)
{
case LegendMarkerTypeSeries: {
sauimone
legend layouting change
r616 QXYSeries* s = static_cast<QXYSeries*> (mSeries);
setBrush(s->brush());
setName(s->name());
sauimone
removed handlethemechange for legend. Too complex solution. Legend now listens the changed signals from series
r587 break;
}
case LegendMarkerTypeBarset: {
setBrush(mBarset->brush());
setName(mBarset->name());
break;
}
case LegendMarkerTypePieslice: {
setBrush(mPieslice->sliceBrush());
setName(mPieslice->label());
break;
}
}
}
sauimone
Separated legend marker to private header. Added signals for left and right mouse click
r547 #include "moc_legendmarker_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE