From e81beeb5192199b0d55544df559327fd929cd370 2012-03-27 10:53:10 From: Tero Ahola Date: 2012-03-27 10:53:10 Subject: [PATCH] Code review: Fixed simple issues in Bar and Legend --- diff --git a/src/barchart/bar.cpp b/src/barchart/bar.cpp index adb4a89..f5a22f1 100644 --- a/src/barchart/bar.cpp +++ b/src/barchart/bar.cpp @@ -9,11 +9,11 @@ Bar::Bar(QString category, QGraphicsItem *parent) : QGraphicsRectItem(parent), mCategory(category) { - setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton); + setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton); setAcceptHoverEvents(true); } -void Bar::mousePressEvent(QGraphicsSceneMouseEvent* event) +void Bar::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { emit clicked(mCategory); @@ -22,13 +22,14 @@ void Bar::mousePressEvent(QGraphicsSceneMouseEvent* event) } } -void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent* event) +void Bar::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { emit hoverEntered(event->lastScreenPos()); } -void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/) +void Bar::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { + Q_UNUSED(event) emit hoverLeaved(); } diff --git a/src/barchart/bar_p.h b/src/barchart/bar_p.h index 25479e6..c864b88 100644 --- a/src/barchart/bar_p.h +++ b/src/barchart/bar_p.h @@ -11,7 +11,7 @@ class Bar : public QObject, public QGraphicsRectItem { Q_OBJECT public: - Bar(QString category, QGraphicsItem *parent=0); + Bar(QString category, QGraphicsItem *parent = 0); public: void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index 06e4781..5f00f54 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -19,7 +19,7 @@ BarChartItem::BarChartItem(QBarSeries *series, ChartPresenter *presenter) : mLayoutSet(false), mSeries(series) { - connect(series,SIGNAL(showToolTip(QPoint,QString)),this,SLOT(showToolTip(QPoint,QString))); + connect(series, SIGNAL(showToolTip(QPoint,QString)), this, SLOT(showToolTip(QPoint,QString))); connect(series, SIGNAL(updatedBars()), this, SLOT(handleLayoutChanged())); //TODO: connect(series,SIGNAL("position or size has changed"), this, SLOT(handleLayoutChanged())); connect(series, SIGNAL(restructuredBar(int)), this, SLOT(handleModelChanged(int))); @@ -38,9 +38,9 @@ void BarChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti qDebug() << "BarChartItem::paint called without layout set. Aborting."; return; } - foreach(QGraphicsItem* i, childItems()) { + + foreach(QGraphicsItem* i, childItems()) i->paint(painter,option,widget); - } } QRectF BarChartItem::boundingRect() const @@ -52,38 +52,37 @@ void BarChartItem::dataChanged() { // TODO: performance optimizations. Do we really need to delete and create items every time data is changed or can we reuse them? // Delete old bars - foreach (QGraphicsItem* item, childItems()) { + foreach (QGraphicsItem *item, childItems()) delete item; - } mBars.clear(); mFloatingValues.clear(); mLayout.clear(); // Create new graphic items for bars - for (int c=0; ccategoryCount(); c++) { + for (int c = 0; c < mSeries->categoryCount(); c++) { QString category = mSeries->categoryName(c); - for (int s=0; sbarsetCount(); s++) { + for (int s = 0; s < mSeries->barsetCount(); s++) { QBarSet *set = mSeries->barsetAt(s); Bar *bar = new Bar(category,this); childItems().append(bar); mBars.append(bar); - connect(bar,SIGNAL(clicked(QString)),set,SIGNAL(clicked(QString))); - connect(bar,SIGNAL(rightClicked(QString)),set,SIGNAL(rightClicked(QString))); - connect(bar,SIGNAL(hoverEntered(QPoint)),set,SLOT(barHoverEnterEvent(QPoint))); - connect(bar,SIGNAL(hoverLeaved()),set,SLOT(barHoverLeaveEvent())); - mLayout.append(QRectF(0,0,0,0)); + connect(bar, SIGNAL(clicked(QString)), set, SIGNAL(clicked(QString))); + connect(bar, SIGNAL(rightClicked(QString)), set, SIGNAL(rightClicked(QString))); + connect(bar, SIGNAL(hoverEntered(QPoint)), set, SLOT(barHoverEnterEvent(QPoint))); + connect(bar, SIGNAL(hoverLeaved()), set, SLOT(barHoverLeaveEvent())); + mLayout.append(QRectF(0, 0, 0, 0)); } } // Create floating values - for (int category=0; categorycategoryCount(); category++) { - for (int s=0; sbarsetCount(); s++) { + for (int category = 0; category < mSeries->categoryCount(); category++) { + for (int s = 0; s < mSeries->barsetCount(); s++) { QBarSet *set = mSeries->barsetAt(s); BarValue *value = new BarValue(*set, this); childItems().append(value); mFloatingValues.append(value); - connect(set,SIGNAL(toggleFloatingValues()),value,SLOT(toggleVisible())); + connect(set, SIGNAL(toggleFloatingValues()), value, SLOT(toggleVisible())); } } } @@ -105,19 +104,19 @@ QVector BarChartItem::calculateLayout() max = mDomainMaxY; } - qreal scale = (height/max); - qreal categoryWidth = width/categoryCount; + qreal scale = (height / max); + qreal categoryWidth = width / categoryCount; qreal barWidth = categoryWidth / (setCount+1); int itemIndex(0); - for (int category=0; category < categoryCount; category++) { - qreal xPos = categoryWidth * category + barWidth/2; + for (int category = 0; category < categoryCount; category++) { + qreal xPos = categoryWidth * category + barWidth / 2; qreal yPos = height; for (int set = 0; set < setCount; set++) { - qreal barHeight = mSeries->valueAt(set,category) * scale; + qreal barHeight = mSeries->valueAt(set, category) * scale; Bar* bar = mBars.at(itemIndex); - QRectF rect(xPos,yPos-barHeight,barWidth,barHeight); + QRectF rect(xPos, yPos - barHeight, barWidth, barHeight); layout.append(rect); bar->setPen(mSeries->barsetAt(set)->pen()); bar->setBrush(mSeries->barsetAt(set)->brush()); @@ -128,20 +127,20 @@ QVector BarChartItem::calculateLayout() // Position floating values itemIndex = 0; - for (int category=0; category < mSeries->categoryCount(); category++) { + for (int category = 0; category < mSeries->categoryCount(); category++) { qreal xPos = categoryWidth * category + barWidth; qreal yPos = height; for (int set=0; set < mSeries->barsetCount(); set++) { - qreal barHeight = mSeries->valueAt(set,category) * scale; + qreal barHeight = mSeries->valueAt(set, category) * scale; BarValue* value = mFloatingValues.at(itemIndex); QBarSet* barSet = mSeries->barsetAt(set); - value->resize(100,50); // TODO: proper layout for this. - value->setPos(xPos, yPos-barHeight/2); + value->resize(100, 50); // TODO: proper layout for this. + value->setPos(xPos, yPos-barHeight / 2); value->setPen(barSet->floatingValuePen()); if (mSeries->valueAt(set,category) != 0) { - value->setValueString(QString::number(mSeries->valueAt(set,category))); + value->setValueString(QString::number(mSeries->valueAt(set, category))); } else { value->setValueString(QString("")); } @@ -166,9 +165,8 @@ void BarChartItem::setLayout(const QVector &layout) { mLayout = layout; - for (int i=0; isetRect(layout.at(i)); - } update(); } @@ -190,9 +188,9 @@ void BarChartItem::handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal handleLayoutChanged(); } -void BarChartItem::handleGeometryChanged(const QRectF& rect) +void BarChartItem::handleGeometryChanged(const QRectF &rect) { - m_rect=rect; + m_rect = rect; handleLayoutChanged(); mLayoutSet = true; setPos(rect.topLeft()); @@ -209,7 +207,7 @@ void BarChartItem::handleLayoutChanged() void BarChartItem::showToolTip(QPoint pos, QString tip) { // TODO: cool tooltip instead of default - QToolTip::showText(pos,tip); + QToolTip::showText(pos, tip); } #include "moc_barchartitem_p.cpp" diff --git a/src/barchart/barchartitem_p.h b/src/barchart/barchartitem_p.h index 50a8a00..2e61092 100644 --- a/src/barchart/barchartitem_p.h +++ b/src/barchart/barchartitem_p.h @@ -46,7 +46,7 @@ public: public slots: void handleModelChanged(int index); void handleDomainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY); - void handleGeometryChanged(const QRectF& size); + void handleGeometryChanged(const QRectF &size); void handleLayoutChanged(); // Internal slots @@ -65,9 +65,9 @@ protected: QVector mLayout; // Not owned. - QBarSeries* mSeries; - QList mBars; - QList mFloatingValues; + QBarSeries *mSeries; + QList mBars; + QList mFloatingValues; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/barchartmodel.cpp b/src/barchart/barchartmodel.cpp index bdee5da..81cbe8c 100644 --- a/src/barchart/barchartmodel.cpp +++ b/src/barchart/barchartmodel.cpp @@ -71,13 +71,12 @@ qreal BarChartModel::min() // This is slower since they are checked every time, even if data is same since previous call. qreal min = INT_MAX; - for (int i=0; i count(); - for (int j=0; jvalueAt(j); - if (temp < min) { + if (temp < min) min = temp; - } } } return min; @@ -91,13 +90,12 @@ qreal BarChartModel::max() // This is slower since they are checked every time, even if data is same since previous call. qreal max = INT_MIN; - for (int i=0; i count(); - for (int j=0; jvalueAt(j); - if (temp > max) { + if (temp > max) max = temp; - } } } @@ -129,9 +127,8 @@ qreal BarChartModel::percentageAt(int set, int category) qreal value = mDataModel.at(set)->valueAt(category); qreal total = categorySum(category); - if (0 == total) { + if (0 == total) return 100.0; - } return value / total; } @@ -143,9 +140,8 @@ qreal BarChartModel::categorySum(int category) int count = mDataModel.count(); // Count sets for (int set = 0; set < count; set++) { - if (category < mDataModel.at(set)->count()) { + if (category < mDataModel.at(set)->count()) sum += mDataModel.at(set)->valueAt(category); - } } return sum; } @@ -155,11 +151,10 @@ qreal BarChartModel::maxCategorySum() qreal max = INT_MIN; int count = categoryCount(); - for (int col=0; col max) { + if (sum > max) max = sum; - } } return max; } diff --git a/src/barchart/barchartmodel_p.h b/src/barchart/barchartmodel_p.h index 14608fe..ee00b36 100644 --- a/src/barchart/barchartmodel_p.h +++ b/src/barchart/barchartmodel_p.h @@ -26,7 +26,7 @@ public: void insertCategory(int i, QString category); void removeCategory(int i); QBarSet *setAt(int index); - QList barSets(); + QList barSets(); int barsetCount(); // Number of sets in model int categoryCount(); // Number of categories @@ -48,11 +48,9 @@ public slots: private: - QList mDataModel; + QList mDataModel; QStringList mCategory; - int mCurrentSet; - }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/barvalue.cpp b/src/barchart/barvalue.cpp index 198400a..83a48d9 100644 --- a/src/barchart/barvalue.cpp +++ b/src/barchart/barvalue.cpp @@ -54,7 +54,7 @@ void BarValue::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, if (isVisible()) { painter->setPen(mPen); - painter->drawText(boundingRect(),mValueString); + painter->drawText(boundingRect(), mValueString); } } diff --git a/src/barchart/barvalue_p.h b/src/barchart/barvalue_p.h index f4c1844..05d2a8d 100644 --- a/src/barchart/barvalue_p.h +++ b/src/barchart/barvalue_p.h @@ -35,7 +35,7 @@ public Q_SLOTS: private: - QBarSet& mBarSet; + QBarSet &mBarSet; QPen mPen; QString mValueString; diff --git a/src/barchart/percentbarchartitem.cpp b/src/barchart/percentbarchartitem.cpp index e426299..a0ed454 100644 --- a/src/barchart/percentbarchartitem.cpp +++ b/src/barchart/percentbarchartitem.cpp @@ -6,7 +6,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -PercentBarChartItem::PercentBarChartItem(QBarSeries *series, ChartPresenter* presenter) : +PercentBarChartItem::PercentBarChartItem(QBarSeries *series, ChartPresenter *presenter) : BarChartItem(series, presenter) { } @@ -21,11 +21,11 @@ QVector PercentBarChartItem::calculateLayout() qreal categoryCount = mSeries->categoryCount(); qreal barWidth = width / (mSeries->categoryCount() * 2); - qreal xStep = width/categoryCount; - qreal xPos = xStep/2 - barWidth / 2; + qreal xStep = width / categoryCount; + qreal xPos = xStep / 2 - barWidth / 2; int itemIndex(0); - for (int category = 0; category < categoryCount ; category++) { + for (int category = 0; category < categoryCount; category++) { qreal colSum = mSeries->categorySum(category); qreal scale = (height / colSum); qreal yPos = height; @@ -34,7 +34,7 @@ QVector PercentBarChartItem::calculateLayout() Bar* bar = mBars.at(itemIndex); bar->setPen(mSeries->barsetAt(set)->pen()); bar->setBrush(mSeries->barsetAt(set)->brush()); - QRectF rect(xPos, yPos-barHeight,barWidth, barHeight); + QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); layout.append(rect); itemIndex++; yPos -= barHeight; @@ -54,8 +54,8 @@ QVector PercentBarChartItem::calculateLayout() BarValue* value = mFloatingValues.at(itemIndex); QBarSet* barSet = mSeries->barsetAt(set); - value->resize(100,50); // TODO: proper layout for this. - value->setPos(xPos, yPos-barHeight/2); + value->resize(100, 50); // TODO: proper layout for this. + value->setPos(xPos, yPos-barHeight / 2); value->setPen(barSet->floatingValuePen()); if (mSeries->valueAt(set,category) != 0) { diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index 4b98264..2dee67f 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -54,8 +54,8 @@ QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) void QBarSeries::addBarSet(QBarSet *set) { mModel->addBarSet(set); - connect(set,SIGNAL(clicked(QString)),this,SLOT(barsetClicked(QString))); - connect(set,SIGNAL(rightClicked(QString)),this,SLOT(barsetRightClicked(QString))); + connect(set, SIGNAL(clicked(QString)), this, SLOT(barsetClicked(QString))); + connect(set, SIGNAL(rightClicked(QString)), this, SLOT(barsetRightClicked(QString))); connect(set, SIGNAL(valueChanged()), this, SLOT(barsetChanged())); emit updatedBars(); } @@ -67,8 +67,8 @@ void QBarSeries::addBarSet(QBarSet *set) */ void QBarSeries::removeBarSet(QBarSet *set) { - disconnect(set,SIGNAL(clicked(QString)),this,SLOT(barsetClicked(QString))); - disconnect(set,SIGNAL(rightClicked(QString)),this,SLOT(barsetRightClicked(QString))); + disconnect(set, SIGNAL(clicked(QString)), this, SLOT(barsetClicked(QString))); + disconnect(set, SIGNAL(rightClicked(QString)), this, SLOT(barsetRightClicked(QString))); mModel->removeBarSet(set); emit updatedBars(); } @@ -143,12 +143,12 @@ void QBarSeries::setToolTipEnabled(bool enabled) if (enabled) { for (int i=0; ibarsetCount(); i++) { QBarSet *set = mModel->setAt(i); - connect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString))); + connect(set, SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); } } else { for (int i=0; ibarsetCount(); i++) { QBarSet *set = mModel->setAt(i); - disconnect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString))); + disconnect(set, SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); } } } @@ -192,7 +192,7 @@ qreal QBarSeries::max() */ qreal QBarSeries::valueAt(int set, int category) { - return mModel->valueAt(set,category); + return mModel->valueAt(set, category); } /*! @@ -200,7 +200,7 @@ qreal QBarSeries::valueAt(int set, int category) */ qreal QBarSeries::percentageAt(int set, int category) { - return mModel->percentageAt(set,category); + return mModel->percentageAt(set, category); } /*! @@ -227,7 +227,7 @@ BarChartModel& QBarSeries::model() return *mModel; } -bool QBarSeries::setModel(QAbstractItemModel* model) +bool QBarSeries::setModel(QAbstractItemModel *model) { // disconnect signals from old model if(m_model) @@ -259,6 +259,7 @@ void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound { if (m_model == NULL) return; + m_mapCategories = categories; m_mapBarBottom = bottomBoundry; m_mapBarTop = topBoundry; @@ -266,48 +267,46 @@ void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound m_mapOrientation = orientation; // connect the signals - if (m_mapOrientation == Qt::Vertical) - { + if (m_mapOrientation == Qt::Vertical) { m_mapCount = m_model->rowCount() - m_mapFirst; - connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); - connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); - connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); - } - else - { + connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(modelUpdated(QModelIndex, QModelIndex))); + connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), + this, SLOT(modelDataAdded(QModelIndex,int,int))); + connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), + this, SLOT(modelDataRemoved(QModelIndex,int,int))); + } else { m_mapCount = m_model->columnCount() - m_mapFirst; - connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex))); - connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int))); - connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int))); + connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(modelUpdated(QModelIndex, QModelIndex))); + connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), + this, SLOT(modelDataAdded(QModelIndex,int,int))); + connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), + this, SLOT(modelDataRemoved(QModelIndex,int,int))); } // create the initial bars delete mModel; - if (m_mapOrientation == Qt::Vertical) - { + if (m_mapOrientation == Qt::Vertical) { QStringList categories; for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++) categories << m_model->data(m_model->index(k, m_mapCategories), Qt::DisplayRole).toString(); mModel = new BarChartModel(categories, this); - for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) - { + for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) { QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1)); for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble(); addBarSet(barSet); } - } - else - { + } else { QStringList categories; for (int k = m_mapFirst; k < m_mapFirst + m_mapCount; k++) categories << m_model->data(m_model->index(m_mapCategories, k), Qt::DisplayRole).toString(); mModel = new BarChartModel(categories, this); - for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) - { + for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) { QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1)); for(int m = m_mapFirst; m < m_mapFirst + m_mapCount; m++) *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble(); @@ -342,27 +341,25 @@ void QBarSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight) void QBarSeries::modelDataAdded(QModelIndex /*parent*/, int start, int /*end*/) { - if (m_mapOrientation == Qt::Vertical) - { + if (m_mapOrientation == Qt::Vertical) { insertCategory(start - m_mapFirst, QString("Row: %1").arg(start + 1)); - for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) - { + for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) { barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(start, i), Qt::DisplayRole).toDouble()); } - } - else - { + } else { insertCategory(start - m_mapFirst, QString("Column: %1").arg(start + 1)); - for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) - { + for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) { barsetAt(i)->insertValue(start - m_mapFirst, m_model->data(m_model->index(i, start), Qt::DisplayRole).toDouble()); } } emit restructuredBar(1); } -void QBarSeries::modelDataRemoved(QModelIndex /*parent*/, int start, int /*end*/) +void QBarSeries::modelDataRemoved(QModelIndex parent, int start, int end) { + Q_UNUSED(parent) + Q_UNUSED(end) + removeCategory(start - m_mapFirst); for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++) { @@ -380,8 +377,8 @@ QBarCategories QBarSeries::categories() const { QBarCategories categories; int count = mModel->categoryCount(); - for (int i=1; i<=count; i++) { - categories.insert(i, mModel->categoryName(i-1)); + for (int i=1; i <= count; i++) { + categories.insert(i, mModel->categoryName(i - 1)); } return categories; } diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 23d9a3f..945301b 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -17,7 +17,7 @@ class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries { Q_OBJECT public: - QBarSeries(QStringList categories, QObject* parent=0); + QBarSeries(QStringList categories, QObject *parent = 0); virtual QSeriesType type() const { return QSeries::SeriesTypeBar; } @@ -31,9 +31,8 @@ public: QList barSets(); QBarCategories categories() const; - - bool setModel(QAbstractItemModel* model); - QAbstractItemModel* modelExt() {return m_model;} + bool setModel(QAbstractItemModel *model); + QAbstractItemModel *modelExt() { return m_model; } void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical); void setModelMappingShift(int first, int count); @@ -54,8 +53,8 @@ public: signals: //void changed(int index); - void clicked(QBarSet* barset, QString category); // Up to user of api, what to do with these signals - void rightClicked(QBarSet* barset, QString category); + void clicked(QBarSet *barset, QString category); // Up to user of api, what to do with these signals + void rightClicked(QBarSet *barset, QString category); // void updatedBars(); @@ -67,7 +66,7 @@ signals: // <--- TO PIMPL public Q_SLOTS: - void setToolTipEnabled(bool enabled=true); // enables tooltips + void setToolTipEnabled(bool enabled = true); // enables tooltips // TODO: TO PIMPL ---> void barsetClicked(QString category); @@ -82,7 +81,7 @@ private Q_SLOTS: void barsetChanged(); protected: - BarChartModel* mModel; + BarChartModel *mModel; // QAbstractItemModel* m_model; int m_mapCategories; diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index a53cdd3..40d8a7e 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -127,7 +127,7 @@ void QBarSet::setValue(int index, qreal value) qreal QBarSet::total() { qreal total(0); - for (int i=0; i mValues; // TODO: replace with map (category, value) - QMap mMappedValues; + QMap mMappedValues; QPen mPen; QBrush mBrush; QPen mFloatingValuePen; diff --git a/src/barchart/qpercentbarseries.h b/src/barchart/qpercentbarseries.h index b2a6d13..92650fc 100644 --- a/src/barchart/qpercentbarseries.h +++ b/src/barchart/qpercentbarseries.h @@ -10,12 +10,10 @@ class QTCOMMERCIALCHART_EXPORT QPercentBarSeries : public QBarSeries { Q_OBJECT public: - QPercentBarSeries(QStringList categories, QObject* parent=0); - + QPercentBarSeries(QStringList categories, QObject *parent = 0); virtual QSeriesType type() const { return QSeries::SeriesTypePercentBar; } }; QTCOMMERCIALCHART_END_NAMESPACE - #endif // PERCENTBARSERIES_H diff --git a/src/barchart/qstackedbarseries.h b/src/barchart/qstackedbarseries.h index 8a77ea6..ed30187 100644 --- a/src/barchart/qstackedbarseries.h +++ b/src/barchart/qstackedbarseries.h @@ -10,8 +10,7 @@ class QTCOMMERCIALCHART_EXPORT QStackedBarSeries : public QBarSeries { Q_OBJECT public: - QStackedBarSeries(QStringList categories, QObject* parent=0); - + QStackedBarSeries(QStringList categories, QObject *parent = 0); virtual QSeriesType type() const { return QSeries::SeriesTypeStackedBar; } }; diff --git a/src/barchart/stackedbarchartitem.cpp b/src/barchart/stackedbarchartitem.cpp index b4d2ede..952e03b 100644 --- a/src/barchart/stackedbarchartitem.cpp +++ b/src/barchart/stackedbarchartitem.cpp @@ -7,7 +7,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE StackedBarChartItem::StackedBarChartItem(QBarSeries *series, ChartPresenter *presenter) : - BarChartItem(series,presenter) + BarChartItem(series, presenter) { } @@ -15,7 +15,6 @@ StackedBarChartItem::~StackedBarChartItem() { } - QVector StackedBarChartItem::calculateLayout() { QVector layout; @@ -31,9 +30,9 @@ QVector StackedBarChartItem::calculateLayout() qreal width = geometry().width(); qreal scale = (height / mSeries->maxCategorySum()); qreal categotyCount = mSeries->categoryCount(); - qreal barWidth = width / (categotyCount *2); - qreal xStep = width/categotyCount; - qreal xPos = xStep/2 - barWidth/2; + qreal barWidth = width / (categotyCount * 2); + qreal xStep = width / categotyCount; + qreal xPos = xStep / 2 - barWidth / 2; int itemIndex(0); for (int category = 0; category < categotyCount; category++) { @@ -43,7 +42,7 @@ QVector StackedBarChartItem::calculateLayout() Bar* bar = mBars.at(itemIndex); bar->setPen(mSeries->barsetAt(set)->pen()); bar->setBrush(mSeries->barsetAt(set)->brush()); - QRectF rect(xPos,yPos-barHeight,barWidth,barHeight); + QRectF rect(xPos, yPos-barHeight, barWidth, barHeight); layout.append(rect); itemIndex++; yPos -= barHeight; @@ -57,15 +56,15 @@ QVector StackedBarChartItem::calculateLayout() for (int category=0; category < mSeries->categoryCount(); category++) { qreal yPos = height; for (int set=0; set < mSeries->barsetCount(); set++) { - qreal barHeight = mSeries->valueAt(set,category) * scale; + qreal barHeight = mSeries->valueAt(set, category) * scale; BarValue* value = mFloatingValues.at(itemIndex); QBarSet* barSet = mSeries->barsetAt(set); - value->resize(100,50); // TODO: proper layout for this. - value->setPos(xPos, yPos-barHeight/2); + value->resize(100, 50); // TODO: proper layout for this. + value->setPos(xPos, yPos-barHeight / 2); value->setPen(barSet->floatingValuePen()); - if (mSeries->valueAt(set,category) != 0) { + if (mSeries->valueAt(set, category) != 0) { value->setValueString(QString::number(mSeries->valueAt(set,category))); } else { value->setValueString(QString("")); diff --git a/src/qlegend.cpp b/src/qlegend.cpp index f1689ce..d45e6d5 100644 --- a/src/qlegend.cpp +++ b/src/qlegend.cpp @@ -84,10 +84,14 @@ QLegend::QLegend(QGraphicsItem *parent) mScrollButtonUp = new LegendScrollButton(LegendScrollButton::ScrollButtonIdUp, this); mScrollButtonDown = new LegendScrollButton(LegendScrollButton::ScrollButtonIdDown, this); - connect(mScrollButtonLeft,SIGNAL(clicked(QGraphicsSceneMouseEvent*)),this,SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); - connect(mScrollButtonRight,SIGNAL(clicked(QGraphicsSceneMouseEvent*)),this,SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); - connect(mScrollButtonUp,SIGNAL(clicked(QGraphicsSceneMouseEvent*)),this,SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); - connect(mScrollButtonDown,SIGNAL(clicked(QGraphicsSceneMouseEvent*)),this,SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); + connect(mScrollButtonLeft, SIGNAL(clicked(QGraphicsSceneMouseEvent*)), + this, SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); + connect(mScrollButtonRight, SIGNAL(clicked(QGraphicsSceneMouseEvent*)), + this, SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); + connect(mScrollButtonUp, SIGNAL(clicked(QGraphicsSceneMouseEvent*)), + this, SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); + connect(mScrollButtonDown, SIGNAL(clicked(QGraphicsSceneMouseEvent*)), + this, SLOT(handleScrollButtonClicked(QGraphicsSceneMouseEvent*))); setZValue(ChartPresenter::LegendZValue); } @@ -117,9 +121,9 @@ QRectF QLegend::boundingRect() const /*! Sets the \a brush of legend. Brush affects the background of legend. */ -void QLegend::setBrush(const QBrush& brush) +void QLegend::setBrush(const QBrush &brush) { - if(m_brush!=brush){ + if (m_brush != brush) { m_brush = brush; update(); } @@ -136,9 +140,9 @@ QBrush QLegend::brush() const /*! Sets the \a pen of legend. Pen affects the legend borders. */ -void QLegend::setPen(const QPen& pen) +void QLegend::setPen(const QPen &pen) { - if(m_pen!=pen){ + if (m_pen != pen) { m_pen = pen; update(); } @@ -224,7 +228,7 @@ void QLegend::setPos(const QPointF &pos) /*! \internal \a series \a domain Should be called when series is added to chart. */ -void QLegend::handleSeriesAdded(QSeries* series, Domain* domain) +void QLegend::handleSeriesAdded(QSeries *series, Domain *domain) { Q_UNUSED(domain) @@ -236,14 +240,14 @@ void QLegend::handleSeriesAdded(QSeries* series, Domain* domain) /*! \internal \a series Should be called when series is removed from chart. */ -void QLegend::handleSeriesRemoved(QSeries* series) +void QLegend::handleSeriesRemoved(QSeries *series) { disconnectSeries(series); if (series->type() == QSeries::SeriesTypeArea) { // This is special case. Area series has upper and lower series, which each have markers - QAreaSeries* s = static_cast (series); + QAreaSeries* s = static_cast (series); deleteMarkers(s->upperSeries()); deleteMarkers(s->lowerSeries()); } else { @@ -256,17 +260,18 @@ void QLegend::handleSeriesRemoved(QSeries* series) /*! \internal \a slices Should be called when slices are added to pie chart. */ -void QLegend::handleAdded(QList slices) +void QLegend::handleAdded(QList slices) { - QPieSeries* series = static_cast (sender()); + QPieSeries* series = static_cast (sender()); foreach(QPieSlice* s, slices) { - LegendMarker* marker = new LegendMarker(series,s,this); + LegendMarker* marker = new LegendMarker(series, s, this); marker->setName(s->label()); marker->setBrush(s->sliceBrush()); - connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton))); - connect(s,SIGNAL(changed()),marker,SLOT(changed())); - connect(s,SIGNAL(destroyed()),marker,SLOT(deleteLater())); - connect(marker,SIGNAL(destroyed()),this,SLOT(handleMarkerDestroyed())); + connect(marker, SIGNAL(clicked(QPieSlice*,Qt::MouseButton)), + this, SIGNAL(clicked(QPieSlice*,Qt::MouseButton))); + connect(s, SIGNAL(changed()), marker, SLOT(changed())); + connect(s, SIGNAL(destroyed()), marker, SLOT(deleteLater())); + connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); mMarkers.append(marker); childItems().append(marker); } @@ -291,7 +296,7 @@ void QLegend::handleRemoved(QList slices) void QLegend::handleMarkerDestroyed() { // TODO: what if more than one markers are destroyed and we update layout after first one? - LegendMarker* m = static_cast (sender()); + LegendMarker* m = static_cast (sender()); mMarkers.removeOne(m); updateLayout(); } @@ -303,7 +308,7 @@ void QLegend::handleScrollButtonClicked(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event); // Maybe later something happens with right click... - LegendScrollButton* scrollButton = static_cast (sender()); + LegendScrollButton* scrollButton = static_cast (sender()); Q_ASSERT(scrollButton); switch (scrollButton->id()) { @@ -411,7 +416,7 @@ void QLegend::disconnectSeries(QSeries *series) } case QSeries::SeriesTypePie: { QPieSeries *pieSeries = static_cast(series); - disconnect(pieSeries,SIGNAL(added(QList)),this,SLOT(handleAdded(QList))); + disconnect(pieSeries, SIGNAL(added(QList)), this, SLOT(handleAdded(QList))); // disconnect(pieSeries,SIGNAL(removed(QList)),this,SLOT(handleRemoved(QList))); break; } @@ -436,32 +441,32 @@ void QLegend::createMarkers(QSeries *series) switch (series->type()) { case QSeries::SeriesTypeLine: { - QLineSeries* lineSeries = static_cast(series); + QLineSeries *lineSeries = static_cast(series); appendMarkers(lineSeries); break; } case QSeries::SeriesTypeArea: { - QAreaSeries* areaSeries = static_cast(series); + QAreaSeries *areaSeries = static_cast(series); appendMarkers(areaSeries->upperSeries()); if(areaSeries->lowerSeries()) - appendMarkers(areaSeries->lowerSeries()); + appendMarkers(areaSeries->lowerSeries()); break; } case QSeries::SeriesTypeBar: { - QBarSeries* barSeries = static_cast(series); + QBarSeries *barSeries = static_cast(series); appendMarkers(barSeries); break; } case QSeries::SeriesTypeStackedBar: { - QStackedBarSeries* stackedBarSeries = static_cast(series); + QStackedBarSeries *stackedBarSeries = static_cast(series); appendMarkers(stackedBarSeries); break; } case QSeries::SeriesTypePercentBar: { - QPercentBarSeries* percentBarSeries = static_cast(series); + QPercentBarSeries *percentBarSeries = static_cast(series); appendMarkers(percentBarSeries); break; } @@ -479,7 +484,7 @@ void QLegend::createMarkers(QSeries *series) } case QSeries::SeriesTypeSpline: { - QSplineSeries* splineSeries = static_cast(series); + QSplineSeries *splineSeries = static_cast(series); appendMarkers(splineSeries); break; } @@ -499,8 +504,8 @@ void QLegend::appendMarkers(QXYSeries* series) marker->setName(series->name()); marker->setPen(series->pen()); marker->setBrush(series->brush()); - connect(marker,SIGNAL(clicked(QSeries*,Qt::MouseButton)),this,SIGNAL(clicked(QSeries*,Qt::MouseButton))); - connect(marker,SIGNAL(destroyed()),this,SLOT(handleMarkerDestroyed())); + connect(marker, SIGNAL(clicked(QSeries *, Qt::MouseButton)), this, SIGNAL(clicked(QSeries *, Qt::MouseButton))); + connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); mMarkers.append(marker); childItems().append(marker); } @@ -511,13 +516,14 @@ void QLegend::appendMarkers(QXYSeries* series) void QLegend::appendMarkers(QBarSeries *series) { foreach(QBarSet* s, series->barSets()) { - LegendMarker* marker = new LegendMarker(series,s,this); + LegendMarker* marker = new LegendMarker(series, s, this); marker->setName(s->name()); marker->setPen(s->pen()); marker->setBrush(s->brush()); - connect(marker,SIGNAL(clicked(QBarSet*,Qt::MouseButton)),this,SIGNAL(clicked(QBarSet*,Qt::MouseButton))); - connect(s,SIGNAL(valueChanged()),marker,SLOT(changed())); - connect(marker,SIGNAL(destroyed()),this,SLOT(handleMarkerDestroyed())); + connect(marker, SIGNAL(clicked(QBarSet *, Qt::MouseButton)), + this, SIGNAL(clicked(QBarSet *, Qt::MouseButton))); + connect(s, SIGNAL(valueChanged()), marker, SLOT(changed())); + connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); mMarkers.append(marker); childItems().append(marker); } @@ -529,14 +535,15 @@ void QLegend::appendMarkers(QBarSeries *series) void QLegend::appendMarkers(QPieSeries *series) { foreach(QPieSlice* s, series->slices()) { - LegendMarker* marker = new LegendMarker(series,s,this); + LegendMarker* marker = new LegendMarker(series, s, this); marker->setName(s->label()); marker->setPen(s->slicePen()); marker->setBrush(s->sliceBrush()); - connect(marker,SIGNAL(clicked(QPieSlice*,Qt::MouseButton)),this,SIGNAL(clicked(QPieSlice*,Qt::MouseButton))); - connect(s,SIGNAL(changed()),marker,SLOT(changed())); - connect(s,SIGNAL(destroyed()),marker,SLOT(deleteLater())); - connect(marker,SIGNAL(destroyed()),this,SLOT(handleMarkerDestroyed())); + connect(marker, SIGNAL(clicked(QPieSlice *, Qt::MouseButton)), + this, SIGNAL(clicked(QPieSlice *, Qt::MouseButton))); + connect(s, SIGNAL(changed()), marker, SLOT(changed())); + connect(s, SIGNAL(destroyed()), marker, SLOT(deleteLater())); + connect(marker, SIGNAL(destroyed()), this, SLOT(handleMarkerDestroyed())); mMarkers.append(marker); childItems().append(marker); } @@ -576,7 +583,6 @@ void QLegend::updateLayout() // Use max height as scroll button size rescaleScrollButtons(QSize(markerMaxSize.height() ,markerMaxSize.height())); - qreal totalWidth = 0; qreal totalHeight = 0; switch (mPreferredLayout) @@ -596,9 +602,11 @@ void QLegend::updateLayout() if (scrollButtonsVisible()) { mScrollButtonLeft->setVisible(true); mScrollButtonRight->setVisible(true); - totalWidth += (mScrollButtonLeft->boundingRect().width() + mMargin) * 2; // scrollbuttons visible, so add their width to total width + // scrollbuttons visible, so add their width to total width + totalWidth += (mScrollButtonLeft->boundingRect().width() + mMargin) * 2; scrollButtonWidth = mScrollButtonLeft->boundingRect().width() + mMargin; - x += scrollButtonWidth; // start position changes by scrollbutton width + // start position changes by scrollbutton width + x += scrollButtonWidth; } else { mScrollButtonLeft->setVisible(false); mScrollButtonRight->setVisible(false); @@ -606,9 +614,9 @@ void QLegend::updateLayout() mScrollButtonUp->setVisible(false); mScrollButtonDown->setVisible(false); - for (int i=0; isetVisible(false); } else { @@ -618,7 +626,7 @@ void QLegend::updateLayout() } else { // This marker is ok m->setVisible(true); - m->setPos(x,y); + m->setPos(x, y); x += xStep; column++; } @@ -627,7 +635,7 @@ void QLegend::updateLayout() } mScrollButtonLeft->setPos(mPos.x() + mMargin, y); - mScrollButtonRight->setPos(x+mMargin,y); + mScrollButtonRight->setPos(x + mMargin, y); totalWidth += maxColumns * markerMaxSize.width() + mMargin * 2; totalHeight = markerMaxSize.height() + mMargin * 2; @@ -658,9 +666,9 @@ void QLegend::updateLayout() mScrollButtonLeft->setVisible(false); mScrollButtonRight->setVisible(false); - for (int i=0; isetVisible(false); } else { @@ -670,7 +678,7 @@ void QLegend::updateLayout() } else { // This marker is ok m->setVisible(true); - m->setPos(x,y); + m->setPos(x, y); y += yStep; row++; } @@ -702,13 +710,13 @@ void QLegend::updateLayout() void QLegend::rescaleScrollButtons(const QSize &size) { QPolygonF left; - left << QPointF(size.width(),0) << QPointF(0,size.height()/2) << QPointF(size.width(),size.height()); + left << QPointF(size.width(), 0) << QPointF(0, size.height() / 2) << QPointF(size.width(), size.height()); QPolygonF right; - right << QPointF(0,0) << QPointF(size.width(),size.height()/2) << QPointF(0,size.height()); + right << QPointF(0, 0) << QPointF(size.width(), size.height() / 2) << QPointF(0, size.height()); QPolygonF up; - up << QPointF(0,size.height()) << QPointF(size.width()/2,0) << QPointF(size.width(),size.height()); + up << QPointF(0, size.height()) << QPointF(size.width() / 2,0) << QPointF(size.width(), size.height()); QPolygonF down; - down << QPointF(0,0) << QPointF(size.width()/2,size.height()) << QPointF(size.width(),0); + down << QPointF(0, 0) << QPointF(size.width() / 2, size.height()) << QPointF(size.width(), 0); mScrollButtonLeft->setPolygon(left); mScrollButtonRight->setPolygon(right); @@ -723,12 +731,10 @@ QSizeF QLegend::maximumMarkerSize() { QSizeF max(0,0); foreach (LegendMarker* m, mMarkers) { - if (m->boundingRect().width() > max.width()) { + if (m->boundingRect().width() > max.width()) max.setWidth(m->boundingRect().width()); - } - if (m->boundingRect().height() > max.height()) { + if (m->boundingRect().height() > max.height()) max.setHeight(m->boundingRect().height()); - } } return max; } @@ -743,14 +749,13 @@ void QLegend::checkFirstMarkerBounds() // Bounds limited by height. int max; if (scrollButtonsVisible()) { - max = (mMaximumSize.height() - mScrollButtonLeft->boundingRect().height() * 2 - mMargin*4) / maximumMarkerSize().height(); + max = (mMaximumSize.height() - mScrollButtonLeft->boundingRect().height() * 2 - mMargin * 4) / maximumMarkerSize().height(); } else { max = mMaximumSize.height() / maximumMarkerSize().height(); } - if (mFirstMarker > mMarkers.count() - max) { + if (mFirstMarker > mMarkers.count() - max) mFirstMarker = mMarkers.count() - max; - } } else { // Bounds limited by width int max; @@ -760,14 +765,12 @@ void QLegend::checkFirstMarkerBounds() max = mMaximumSize.width() / maximumMarkerSize().width(); } - if (mFirstMarker > mMarkers.count() - max) { + if (mFirstMarker > mMarkers.count() - max) mFirstMarker = mMarkers.count() - max; - } } - if (mFirstMarker < 0) { + if (mFirstMarker < 0) mFirstMarker = 0; - } } /*! @@ -786,4 +789,5 @@ bool QLegend::scrollButtonsVisible() } #include "moc_qlegend.cpp" + QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/qlegend.h b/src/qlegend.h index 56950fa..7d39232 100644 --- a/src/qlegend.h +++ b/src/qlegend.h @@ -25,7 +25,7 @@ public: PreferredLayoutTop, PreferredLayoutBottom, PreferredLayoutLeft, - PreferredLayoutRight, + PreferredLayoutRight }; explicit QLegend(QGraphicsItem *parent = 0); @@ -33,10 +33,10 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); QRectF boundingRect() const; - void setBrush(const QBrush& brush); + void setBrush(const QBrush &brush); QBrush brush() const; - void setPen(const QPen& pen); + void setPen(const QPen &pen); QPen pen() const; void setPreferredLayout(QLegend::PreferredLayout preferred); @@ -51,31 +51,31 @@ public: signals: // for interactions. - void clicked(QSeries* series, Qt::MouseButton button); - void clicked(QBarSet* barset, Qt::MouseButton button); - void clicked(QPieSlice* slice, Qt::MouseButton button); + void clicked(QSeries *series, Qt::MouseButton button); + void clicked(QBarSet *barset, Qt::MouseButton button); + void clicked(QPieSlice *slice, Qt::MouseButton button); public slots: // PIMPL ---> - void handleSeriesAdded(QSeries* series,Domain* domain); - void handleSeriesRemoved(QSeries* series); - void handleAdded(QList slices); - void handleRemoved(QList slices); + void handleSeriesAdded(QSeries *series, Domain *domain); + void handleSeriesRemoved(QSeries *series); + void handleAdded(QList slices); + void handleRemoved(QList slices); void handleMarkerDestroyed(); - void handleScrollButtonClicked(QGraphicsSceneMouseEvent* event); + void handleScrollButtonClicked(QGraphicsSceneMouseEvent *event); // PIMPL <--- private: // PIMPL ---> - void connectSeries(QSeries* series); - void disconnectSeries(QSeries* series); - void createMarkers(QSeries* series); - void appendMarkers(QXYSeries* series); // All line series are derived from QXYSeries, so this works for now - void appendMarkers(QBarSeries* series); - void appendMarkers(QPieSeries* series); - void deleteMarkers(QSeries* series); + void connectSeries(QSeries *series); + void disconnectSeries(QSeries *series); + void createMarkers(QSeries *series); + void appendMarkers(QXYSeries *series); // All line series are derived from QXYSeries, so this works for now + void appendMarkers(QBarSeries *series); + void appendMarkers(QPieSeries *series); + void deleteMarkers(QSeries *series); void updateLayout(); - void rescaleScrollButtons(const QSize& size); + void rescaleScrollButtons(const QSize &size); QSizeF maximumMarkerSize(); void checkFirstMarkerBounds(); bool scrollButtonsVisible(); @@ -85,7 +85,7 @@ private: QSizeF mMinimumSize; QSizeF mMaximumSize; - QList mMarkers; + QList mMarkers; QBrush m_brush; QPen m_pen; @@ -93,10 +93,10 @@ private: int mFirstMarker; - LegendScrollButton* mScrollButtonLeft; - LegendScrollButton* mScrollButtonRight; - LegendScrollButton* mScrollButtonUp; - LegendScrollButton* mScrollButtonDown; + LegendScrollButton *mScrollButtonLeft; + LegendScrollButton *mScrollButtonRight; + LegendScrollButton *mScrollButtonUp; + LegendScrollButton *mScrollButtonDown; qreal mMargin; // <--- PIMPL