From e53014bd1799c45f916526697f8f24518875eb3d 2012-03-28 07:55:57 From: Tero Ahola Date: 2012-03-28 07:55:57 Subject: [PATCH] Internal review: fixed minor issues in Area and XySeries --- diff --git a/src/areachart/areachartitem.cpp b/src/areachart/areachartitem.cpp index f8a5545..929cd34 100644 --- a/src/areachart/areachartitem.cpp +++ b/src/areachart/areachartitem.cpp @@ -10,7 +10,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE //TODO: optimize : remove points which are not visible -AreaChartItem::AreaChartItem(QAreaSeries *areaSeries,ChartPresenter *presenter) : ChartItem(presenter), +AreaChartItem::AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter) + : ChartItem(presenter), m_series(areaSeries), m_upper(0), m_lower(0), @@ -18,9 +19,8 @@ AreaChartItem::AreaChartItem(QAreaSeries *areaSeries,ChartPresenter *presenter) { setZValue(ChartPresenter::LineChartZValue); m_upper = new AreaBoundItem(this,m_series->upperSeries()); - if (m_series->lowerSeries()) { + if (m_series->lowerSeries()) m_lower = new AreaBoundItem(this,m_series->lowerSeries()); - } connect(areaSeries,SIGNAL(updated()),this,SLOT(handleUpdated())); connect(this,SIGNAL(clicked(const QPointF&)),areaSeries,SIGNAL(clicked(const QPointF&))); @@ -32,7 +32,7 @@ AreaChartItem::~AreaChartItem() { delete m_upper; delete m_lower; -}; +} QRectF AreaChartItem::boundingRect() const { @@ -60,8 +60,8 @@ void AreaChartItem::updatePath() } path.closeSubpath(); prepareGeometryChange(); - m_path=path; - m_rect=path.boundingRect(); + m_path = path; + m_rect = path.boundingRect(); update(); } @@ -71,7 +71,7 @@ void AreaChartItem::handleUpdated() m_linePen = m_series->pen(); m_brush = m_series->brush(); m_pointPen = m_series->pen(); - m_pointPen.setWidthF(2*m_pointPen.width()); + m_pointPen.setWidthF(2 * m_pointPen.width()); update(); } @@ -91,7 +91,6 @@ void AreaChartItem::handleGeometryChanged(const QRectF &rect) if (m_lower) m_lower->handleGeometryChanged(rect); } -//painter void AreaChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { diff --git a/src/areachart/areachartitem_p.h b/src/areachart/areachartitem_p.h index 3f86311..b9fa66d 100644 --- a/src/areachart/areachartitem_p.h +++ b/src/areachart/areachartitem_p.h @@ -15,7 +15,7 @@ class AreaChartItem : public ChartItem Q_OBJECT public: AreaChartItem(QAreaSeries *areaSeries, ChartPresenter *presenter); - ~ AreaChartItem(); + ~AreaChartItem(); //from QGraphicsItem QRectF boundingRect() const; @@ -56,7 +56,7 @@ class AreaBoundItem : public LineChartItem { public: AreaBoundItem(AreaChartItem *item,QLineSeries *lineSeries) : LineChartItem(lineSeries, 0), m_item(item) {} - ~AreaBoundItem(){} + ~AreaBoundItem() {} void setLayout(QVector &points) { LineChartItem::setLayout(points); @@ -65,7 +65,6 @@ public: private: AreaChartItem* m_item; - }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/areachart/qareaseries.cpp b/src/areachart/qareaseries.cpp index 9aa4ff5..11e990e 100644 --- a/src/areachart/qareaseries.cpp +++ b/src/areachart/qareaseries.cpp @@ -78,12 +78,14 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE upperSeries line and \a lowerSeries line. If no \a lowerSeries is passed to constructor, area is specified by axis x (y=0) instead. When series object is added to QChartView or QChart instance ownerships is transfered. */ -QAreaSeries::QAreaSeries(QLineSeries* upperSeries,QLineSeries* lowerSeries):QSeries(upperSeries), -m_upperSeries(upperSeries), -m_lowerSeries(lowerSeries), -m_pointsVisible(false) +QAreaSeries::QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries) + : QSeries(upperSeries), + m_upperSeries(upperSeries), + m_lowerSeries(lowerSeries), + m_pointsVisible(false) { } + /*! Destroys the object. Series added to QChartView or QChart instances are owned by those, and are deleted when mentioned object are destroyed. @@ -95,7 +97,7 @@ QAreaSeries::~QAreaSeries() /*! Sets \a pen used for drawing area outline. */ -void QAreaSeries::setPen(const QPen& pen) +void QAreaSeries::setPen(const QPen &pen) { if (m_pen != pen) { m_pen = pen; diff --git a/src/xychart/qxyseries.h b/src/xychart/qxyseries.h index 0ba7265..e135883 100644 --- a/src/xychart/qxyseries.h +++ b/src/xychart/qxyseries.h @@ -12,7 +12,7 @@ class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries { Q_OBJECT protected: - QXYSeries(QObject *parent=0); + QXYSeries(QObject *parent = 0); virtual ~QXYSeries(); public: @@ -36,21 +36,21 @@ public: void setPen(const QPen &pen); QPen pen() const {return m_pen;} - void setBrush(const QBrush &pen); + void setBrush(const QBrush &brush); QBrush brush() const {return m_brush;} bool setModel(QAbstractItemModel *model); - QAbstractItemModel* model() {return m_model;} + QAbstractItemModel* model() { return m_model; } virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical); virtual void setModelMappingShift(int first, int count = 0); - private slots: - void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); - void modelDataAboutToBeAdded(QModelIndex parent, int start, int end); - void modelDataAdded(QModelIndex parent, int start, int end); - void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end); - void modelDataRemoved(QModelIndex parent, int start, int end); +private slots: + void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); + void modelDataAboutToBeAdded(QModelIndex parent, int start, int end); + void modelDataAdded(QModelIndex parent, int start, int end); + void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end); + void modelDataRemoved(QModelIndex parent, int start, int end); signals: void clicked(const QPointF &point);