diff --git a/demos/chartthemes/themewidget.cpp b/demos/chartthemes/themewidget.cpp index 2ad217e..ea8c405 100644 --- a/demos/chartthemes/themewidget.cpp +++ b/demos/chartthemes/themewidget.cpp @@ -211,7 +211,7 @@ QChart* ThemeWidget::createBarChart(int valueCount) const QBarSet *set = new QBarSet("Set" + QString::number(i)); foreach (Data data, m_dataTable[i]) *set << data.first.y(); - series->addBarSet(set); + series->appendBarSet(set); } chart->addSeries(series); } diff --git a/examples/barchart/main.cpp b/examples/barchart/main.cpp index e29c805..b8711bc 100644 --- a/examples/barchart/main.cpp +++ b/examples/barchart/main.cpp @@ -69,11 +69,11 @@ int main(int argc, char *argv[]) //![2] //![3] QBarSeries* series = new QBarSeries(categories); - series->addBarSet(set0); - series->addBarSet(set1); - series->addBarSet(set2); - series->addBarSet(set3); - series->addBarSet(set4); + series->appendBarSet(set0); + series->appendBarSet(set1); + series->appendBarSet(set2); + series->appendBarSet(set3); + series->appendBarSet(set4); //![3] //![4] QChart* chart = new QChart(); diff --git a/examples/percentbarchart/main.cpp b/examples/percentbarchart/main.cpp index b32fce9..ab6b0e5 100644 --- a/examples/percentbarchart/main.cpp +++ b/examples/percentbarchart/main.cpp @@ -69,11 +69,11 @@ int main(int argc, char *argv[]) //![2] //![3] QPercentBarSeries* series = new QPercentBarSeries(categories); - series->addBarSet(set0); - series->addBarSet(set1); - series->addBarSet(set2); - series->addBarSet(set3); - series->addBarSet(set4); + series->appendBarSet(set0); + series->appendBarSet(set1); + series->appendBarSet(set2); + series->appendBarSet(set3); + series->appendBarSet(set4); //![3] //![4] QChart* chart = new QChart(); diff --git a/examples/stackedbarchart/main.cpp b/examples/stackedbarchart/main.cpp index dc1a037..842c205 100644 --- a/examples/stackedbarchart/main.cpp +++ b/examples/stackedbarchart/main.cpp @@ -69,11 +69,11 @@ int main(int argc, char *argv[]) //![2] //![3] QStackedBarSeries* series = new QStackedBarSeries(categories); - series->addBarSet(set0); - series->addBarSet(set1); - series->addBarSet(set2); - series->addBarSet(set3); - series->addBarSet(set4); + series->appendBarSet(set0); + series->appendBarSet(set1); + series->appendBarSet(set2); + series->appendBarSet(set3); + series->appendBarSet(set4); //![3] //![4] QChart* chart = new QChart(); diff --git a/qmlplugin/declarativebarseries.cpp b/qmlplugin/declarativebarseries.cpp index e0147ea..9143025 100644 --- a/qmlplugin/declarativebarseries.cpp +++ b/qmlplugin/declarativebarseries.cpp @@ -36,9 +36,9 @@ void DeclarativeBarSeries::componentComplete() *set1 << 5 << 0 << 0 << 4 << 0 << 7; *set2 << 3 << 5 << 8 << 13 << 8 << 5; - m_series->addBarSet(set0); - m_series->addBarSet(set1); - m_series->addBarSet(set2); + m_series->appendBarSet(set0); + m_series->appendBarSet(set1); + m_series->appendBarSet(set2); chart->addSeries(m_series); } diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index d259cd0..aea8727 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -140,9 +140,9 @@ QVector BarChartItem::calculateLayout() value->setPen(barSet->floatingValuePen()); if (!qFuzzyIsNull(m_series->valueAt(set,category))) { - value->setValueString(QString::number(m_series->valueAt(set, category))); + value->setText(QString::number(m_series->valueAt(set, category))); } else { - value->setValueString(QString("")); + value->setText(QString("")); } itemIndex++; diff --git a/src/barchart/barchartmodel.cpp b/src/barchart/barchartmodel.cpp index c682092..8329f35 100644 --- a/src/barchart/barchartmodel.cpp +++ b/src/barchart/barchartmodel.cpp @@ -16,7 +16,7 @@ QStringList BarChartModel::category() return m_category; } -void BarChartModel::addBarSet(QBarSet *set) +void BarChartModel::appendBarSet(QBarSet *set) { m_dataModel.append(set); } @@ -43,27 +43,27 @@ void BarChartModel::removeCategory(int i) m_category.removeAt(i); } -QBarSet* BarChartModel::setAt(int index) +QBarSet* BarChartModel::barsetAt(int index) const { return m_dataModel.at(index); } -QList BarChartModel::barSets() +QList BarChartModel::barSets() const { return m_dataModel; } -int BarChartModel::barsetCount() +int BarChartModel::barsetCount() const { return m_dataModel.count(); } -int BarChartModel::categoryCount() +int BarChartModel::categoryCount() const { return m_category.count(); } -qreal BarChartModel::min() +qreal BarChartModel::min() const { Q_ASSERT(m_dataModel.count() > 0); // TODO: make min and max members and update them when data changes. @@ -81,7 +81,7 @@ qreal BarChartModel::min() return min; } -qreal BarChartModel::max() +qreal BarChartModel::max() const { Q_ASSERT(m_dataModel.count() > 0); @@ -101,7 +101,7 @@ qreal BarChartModel::max() return max; } -qreal BarChartModel::valueAt(int set, int category) +qreal BarChartModel::valueAt(int set, int category) const { if ((set < 0) || (set >= m_dataModel.count())) { // No set, no value. @@ -114,7 +114,7 @@ qreal BarChartModel::valueAt(int set, int category) return m_dataModel.at(set)->valueAt(category); } -qreal BarChartModel::percentageAt(int set, int category) +qreal BarChartModel::percentageAt(int set, int category) const { if ((set < 0) || (set >= m_dataModel.count())) { // No set, no value. @@ -133,7 +133,7 @@ qreal BarChartModel::percentageAt(int set, int category) } -qreal BarChartModel::categorySum(int category) +qreal BarChartModel::categorySum(int category) const { qreal sum(0); int count = m_dataModel.count(); // Count sets @@ -145,7 +145,7 @@ qreal BarChartModel::categorySum(int category) return sum; } -qreal BarChartModel::maxCategorySum() +qreal BarChartModel::maxCategorySum() const { qreal max = INT_MIN; int count = categoryCount(); diff --git a/src/barchart/barchartmodel_p.h b/src/barchart/barchartmodel_p.h index 2427839..88f8d00 100644 --- a/src/barchart/barchartmodel_p.h +++ b/src/barchart/barchartmodel_p.h @@ -20,24 +20,24 @@ public: explicit BarChartModel(QStringList categories, QObject *parent = 0); QStringList category(); - void addBarSet(QBarSet *set); + void appendBarSet(QBarSet *set); void removeBarSet(QBarSet *set); void insertBarSet(int i, QBarSet *set); void insertCategory(int i, QString category); void removeCategory(int i); - QBarSet *setAt(int index); - QList barSets(); + QBarSet *barsetAt(int index) const; + QList barSets() const; - int barsetCount(); // Number of sets in model - int categoryCount(); // Number of categories + int barsetCount() const; // Number of sets in model + int categoryCount() const; // Number of categories - qreal max(); // Maximum value of all sets - qreal min(); // Minimum value of all sets - qreal valueAt(int set, int category); - qreal percentageAt(int set, int category); + qreal max() const; // Maximum value of all sets + qreal min() const; // Minimum value of all sets + qreal valueAt(int set, int category) const; + qreal percentageAt(int set, int category) const; - qreal categorySum(int category); - qreal maxCategorySum(); // returns maximum sum of sets in all categories. + qreal categorySum(int category) const; + qreal maxCategorySum() const; // returns maximum sum of sets in all categories. QString categoryName(int category); diff --git a/src/barchart/barvalue.cpp b/src/barchart/barvalue.cpp index 23e6c21..859fbac 100644 --- a/src/barchart/barvalue.cpp +++ b/src/barchart/barvalue.cpp @@ -15,17 +15,17 @@ BarValue::BarValue(QBarSet &set, QGraphicsItem *parent) setVisible(false); } -void BarValue::setValueString(QString str) +void BarValue::setText(QString str) { m_valueString = str; } -QString BarValue::valueString() +QString BarValue::text() const { return m_valueString; } -void BarValue::setPen(const QPen pen) +void BarValue::setPen(const QPen &pen) { m_pen = pen; } diff --git a/src/barchart/barvalue_p.h b/src/barchart/barvalue_p.h index 172704d..eadacdd 100644 --- a/src/barchart/barvalue_p.h +++ b/src/barchart/barvalue_p.h @@ -17,10 +17,10 @@ class BarValue : public QGraphicsObject public: BarValue(QBarSet &set, QGraphicsItem *parent = 0); - void setValueString(QString str); - QString valueString(); + void setText(QString str); + QString text() const; - void setPen(const QPen pen); + void setPen(const QPen &pen); QPen pen() const; void resize(qreal w, qreal h); diff --git a/src/barchart/percentbarchartitem.cpp b/src/barchart/percentbarchartitem.cpp index 90b0a64..c6f91c9 100644 --- a/src/barchart/percentbarchartitem.cpp +++ b/src/barchart/percentbarchartitem.cpp @@ -63,9 +63,9 @@ QVector PercentBarChartItem::calculateLayout() QString vString(QString::number(p)); vString.truncate(3); vString.append("%"); - value->setValueString(vString); + value->setText(vString); } else { - value->setValueString(QString("")); + value->setText(QString("")); } itemIndex++; diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index d977987..6ed54da 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -50,9 +50,9 @@ QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) : QSeries(par Connects the clicked(QString) and rightClicked(QString) signals of \a set to this series */ -void QBarSeries::addBarSet(QBarSet *set) +void QBarSeries::appendBarSet(QBarSet *set) { - m_internalModel->addBarSet(set); + m_internalModel->appendBarSet(set); 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())); @@ -91,7 +91,7 @@ void QBarSeries::removeCategory(int i) /*! Returns number of sets in series. */ -int QBarSeries::barsetCount() +int QBarSeries::barsetCount() const { // if(m_model) // return m_mapBarTop - m_mapBarBottom; @@ -102,7 +102,7 @@ int QBarSeries::barsetCount() /*! Returns number of categories in series */ -int QBarSeries::categoryCount() +int QBarSeries::categoryCount() const { return m_internalModel->categoryCount(); } @@ -110,7 +110,7 @@ int QBarSeries::categoryCount() /*! Returns a list of sets in series. Keeps ownership of sets. */ -QList QBarSeries::barSets() +QList QBarSeries::barSets() const { return m_internalModel->barSets(); } @@ -120,7 +120,7 @@ QList QBarSeries::barSets() */ QBarSet* QBarSeries::barsetAt(int index) { - return m_internalModel->setAt(index); + return m_internalModel->barsetAt(index); } /*! @@ -141,12 +141,12 @@ void QBarSeries::setToolTipEnabled(bool enabled) // TODO: what if we add sets after call to this function? Those sets won't have tooltip enabled. if (enabled) { for (int i=0; ibarsetCount(); i++) { - QBarSet *set = m_internalModel->setAt(i); + QBarSet *set = m_internalModel->barsetAt(i); connect(set, SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); } } else { for (int i=0; ibarsetCount(); i++) { - QBarSet *set = m_internalModel->setAt(i); + QBarSet *set = m_internalModel->barsetAt(i); disconnect(set, SIGNAL(showToolTip(QPoint,QString)), this, SIGNAL(showToolTip(QPoint,QString))); } } @@ -297,7 +297,7 @@ void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound 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); + appendBarSet(barSet); } } else { QStringList categories; @@ -309,7 +309,7 @@ void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBound 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(); - addBarSet(barSet); + appendBarSet(barSet); } } } diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index a5aef6d..1570314 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -21,14 +21,14 @@ public: virtual QSeriesType type() const { return QSeries::SeriesTypeBar; } - void addBarSet(QBarSet *set); // Takes ownership of set + void appendBarSet(QBarSet *set); // Takes ownership of set void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set void insertBarSet(int i, QBarSet *set); void insertCategory(int i, QString category); void removeCategory(int i); - int barsetCount(); - int categoryCount(); - QList barSets(); + int barsetCount() const; + int categoryCount() const; + QList barSets() const; QBarCategories categories() const; bool setModel(QAbstractItemModel *model); diff --git a/src/barchart/qbarset.cpp b/src/barchart/qbarset.cpp index e3107aa..f64a6a7 100644 --- a/src/barchart/qbarset.cpp +++ b/src/barchart/qbarset.cpp @@ -71,7 +71,7 @@ void QBarSet::setName(QString name) /*! Returns name of the set. */ -QString QBarSet::name() +QString QBarSet::name() const { return m_name; } @@ -99,7 +99,7 @@ void QBarSet::removeValue(int i) /*! Returns count of values in set. */ -int QBarSet::count() +int QBarSet::count() const { return m_values.count(); } @@ -107,7 +107,7 @@ int QBarSet::count() /*! Returns value of set indexed by \a index */ -qreal QBarSet::valueAt(int index) +qreal QBarSet::valueAt(int index) const { return m_values.at(index); } @@ -124,7 +124,7 @@ void QBarSet::setValue(int index, qreal value) /*! Returns total sum of all values in barset. */ -qreal QBarSet::total() +qreal QBarSet::total() const { qreal total(0); for (int i=0; i < m_values.count(); i++) { diff --git a/src/barchart/qbarset.h b/src/barchart/qbarset.h index 80c2349..08d7f5c 100644 --- a/src/barchart/qbarset.h +++ b/src/barchart/qbarset.h @@ -14,16 +14,16 @@ public: QBarSet(QString name, QObject *parent = 0); void setName(QString name); - QString name(); + QString name() const; QBarSet& operator << (const qreal &value); // appends new value to set void insertValue(int i, qreal value); void removeValue(int i); // TODO: remove indices eventually. Use as internal? - int count(); // count of values in set - qreal valueAt(int index); // for modifying individual values + int count() const; // count of values in set + qreal valueAt(int index) const; // for modifying individual values void setValue(int index, qreal value); // setter for individual value - qreal total(); // total values in the set + qreal total() const; // total values in the set // TODO: //qreal value(QString category); diff --git a/src/barchart/stackedbarchartitem.cpp b/src/barchart/stackedbarchartitem.cpp index da54207..3f262cd 100644 --- a/src/barchart/stackedbarchartitem.cpp +++ b/src/barchart/stackedbarchartitem.cpp @@ -65,9 +65,9 @@ QVector StackedBarChartItem::calculateLayout() value->setPen(barSet->floatingValuePen()); if (!qFuzzyIsNull(m_series->valueAt(set, category))) { - value->setValueString(QString::number(m_series->valueAt(set,category))); + value->setText(QString::number(m_series->valueAt(set,category))); } else { - value->setValueString(QString("")); + value->setText(QString("")); } itemIndex++;