diff --git a/src/axis/qchartaxiscategories.cpp b/src/axis/qchartaxiscategories.cpp index 6785eba..1f7d35b 100644 --- a/src/axis/qchartaxiscategories.cpp +++ b/src/axis/qchartaxiscategories.cpp @@ -13,10 +13,10 @@ QChartAxisCategories::~QChartAxisCategories() // TODO Auto-generated destructor stub } -void QChartAxisCategories::insert(QBarCategory& category) +void QChartAxisCategories::insert(const QBarCategories& categories) { int i=1; - foreach(QString string , category){ + foreach(QString string , categories){ m_map.insert(i,string); i++; } diff --git a/src/axis/qchartaxiscategories.h b/src/axis/qchartaxiscategories.h index 0dff8ae..897e611 100644 --- a/src/axis/qchartaxiscategories.h +++ b/src/axis/qchartaxiscategories.h @@ -14,7 +14,7 @@ private: public: ~QChartAxisCategories(); - void insert(QBarCategory& category); + void insert(const QBarCategories& category); void insert(qreal value,QString label); void remove(qreal value); QString label(qreal value) const; diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index d4948df..9bb99c4 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -33,7 +33,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE Constructs empty QBarSeries. Parameter \a categories defines the categories for chart. QBarSeries is QObject which is a child of a \a parent. */ -QBarSeries::QBarSeries(QStringList categories, QObject *parent) +QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) : QSeries(parent) ,mModel(new BarChartModel(categories, this)) { @@ -365,6 +365,16 @@ void QBarSeries::barsetChanged() emit updatedBars(); } +QBarCategories QBarSeries::categories() const +{ + QBarCategories categories; + int count = mModel->categoryCount(); + for (int i=1; i<=count; i++) { + categories.insert(i, mModel->categoryName(i-1)); + } + return categories; +} + #include "moc_qbarseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 846c450..23e5d96 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -6,7 +6,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -typedef QStringList QBarCategory; +typedef QStringList QBarCategories; class QBarSet; class BarChartModel; @@ -29,6 +29,8 @@ public: int barsetCount(); int categoryCount(); QList barSets(); + QBarCategories categories() const; + bool setModel(QAbstractItemModel* model); QAbstractItemModel* modelExt() {return m_model;} diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index f9b6fda..1ba1dc5 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -240,12 +240,9 @@ void ChartDataSet::calculateDomain(QSeries* series,Domain* domain) void ChartDataSet::setupCategories(QBarSeries* series) { - int count = series->categoryCount(); QChartAxisCategories* categories = axisX()->categories(); categories->clear(); - for (int i=1; i<=count; i++) { - categories->insert(i,series->categoryName(i-1)); - } + categories->insert(series->categories()); } void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size)