From aba5dff7371949a0ca2d9c165b3cc4882d78a953 2012-02-14 10:34:17 From: sauimone Date: 2012-02-14 10:34:17 Subject: [PATCH] removed barchartseriesbase. functionality is now in model --- diff --git a/example/barchart/main.cpp b/example/barchart/main.cpp index 2a0dbea..68c6034 100644 --- a/example/barchart/main.cpp +++ b/example/barchart/main.cpp @@ -25,11 +25,11 @@ int main(int argc, char *argv[]) QBarSet barSet4; // Create some test data to chart - barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10; - barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0; - barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; - barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; - barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; + barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; + barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2; + barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5; + barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; + barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; series0->addBarSet(barSet0); series0->addBarSet(barSet1); diff --git a/example/percentbarchart/main.cpp b/example/percentbarchart/main.cpp index 02e2080..588e8b8 100644 --- a/example/percentbarchart/main.cpp +++ b/example/percentbarchart/main.cpp @@ -25,11 +25,11 @@ int main(int argc, char *argv[]) QBarSet barSet4; // Create some test data to chart - barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10; - barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0; - barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; - barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; - barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; + barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; + barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2; + barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5; + barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; + barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; series0->addBarSet(barSet0); series0->addBarSet(barSet1); diff --git a/example/stackedbarchart/main.cpp b/example/stackedbarchart/main.cpp index 75107a7..9d30f5f 100644 --- a/example/stackedbarchart/main.cpp +++ b/example/stackedbarchart/main.cpp @@ -25,11 +25,11 @@ int main(int argc, char *argv[]) QBarSet barSet4; // Create some test data to chart - barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10; - barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0; - barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; - barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; - barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; + barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12; + barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0 << 4 << 2; + barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1 << 3 << 5; + barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5 << 2 << 7; + barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10 << 1 << 6; series0->addBarSet(barSet0); series0->addBarSet(barSet1); diff --git a/src/barchart/barchartmodel.cpp b/src/barchart/barchartmodel.cpp index 5b3183a..010274f 100644 --- a/src/barchart/barchartmodel.cpp +++ b/src/barchart/barchartmodel.cpp @@ -133,6 +133,11 @@ qreal BarChartModel::maxCategorySum() return max; } +QString BarChartModel::label(int category) +{ + return mCategory.label(category); +} + #include "moc_barchartmodel_p.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/barchartmodel_p.h b/src/barchart/barchartmodel_p.h index 34bd707..a0498e4 100644 --- a/src/barchart/barchartmodel_p.h +++ b/src/barchart/barchartmodel_p.h @@ -33,6 +33,8 @@ public: qreal categorySum(int column); qreal maxCategorySum(); // returns maximum sum of sets in all categories. + QString label(int category); + signals: void modelUpdated(); diff --git a/src/barchart/barchartseries.cpp b/src/barchart/barchartseries.cpp index 91bcd36..3229856 100644 --- a/src/barchart/barchartseries.cpp +++ b/src/barchart/barchartseries.cpp @@ -1,23 +1,59 @@ #include #include "barchartseries.h" +#include "qbarcategory.h" +#include "qbarset.h" +#include "barchartmodel_p.h" + QTCOMMERCIALCHART_BEGIN_NAMESPACE BarChartSeries::BarChartSeries(QBarCategory &category, QObject *parent) - : BarChartSeriesBase(category, parent) + : QChartSeries(parent) + ,mModel(new BarChartModel(category, this)) { } void BarChartSeries::addBarSet(QBarSet &set) { - BarChartSeriesBase::addBarSet(set); + mModel->addBarSet(set); } void BarChartSeries::removeBarSet(QBarSet &set) { - BarChartSeriesBase::removeBarSet(set); + mModel->removeBarSet(set); +} + +int BarChartSeries::countCategories() +{ + return mModel->countCategories(); +} + +qreal BarChartSeries::min() +{ + return mModel->min(); +} + +qreal BarChartSeries::max() +{ + return mModel->max(); } +qreal BarChartSeries::valueAt(int set, int category) +{ + return mModel->valueAt(set,category); +} + +qreal BarChartSeries::maxCategorySum() +{ + return mModel->maxCategorySum(); +} + +BarChartModel& BarChartSeries::model() +{ + return *mModel; +} + + #include "moc_barchartseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/barchartseries.h b/src/barchart/barchartseries.h index b1dabb2..296f003 100644 --- a/src/barchart/barchartseries.h +++ b/src/barchart/barchartseries.h @@ -3,14 +3,17 @@ #include #include -#include "barchartseriesbase.h" - -class BarGroup; +#include "qchartseries.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE +class QBarCategory; +class QBarSet; +class BarGroup; +class BarChartModel; + // Container for series -class QTCOMMERCIALCHART_EXPORT BarChartSeries : public BarChartSeriesBase +class QTCOMMERCIALCHART_EXPORT BarChartSeries : public QChartSeries { Q_OBJECT public: @@ -22,11 +25,24 @@ public: void addBarSet(QBarSet &set); void removeBarSet(QBarSet &set); + int countCategories(); + qreal min(); + qreal max(); + qreal valueAt(int set, int category); + qreal maxCategorySum(); + + BarChartModel& model(); + +signals: + void changed(int index); + public Q_SLOTS: private: BarGroup* mBarGroup; + BarChartModel* mModel; + }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/barchartseriesbase.cpp b/src/barchart/barchartseriesbase.cpp deleted file mode 100644 index 286c31f..0000000 --- a/src/barchart/barchartseriesbase.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include "barchartseriesbase.h" -#include "bargroup.h" -#include "barchartmodel_p.h" -#include "qbarset.h" -#include "qbarcategory.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -BarChartSeriesBase::BarChartSeriesBase(QBarCategory &category, QObject *parent) - : QChartSeries(parent) - ,mModel(new BarChartModel(category, this)) -{ - mLabels.append(category.items()); -} - -void BarChartSeriesBase::addBarSet(QBarSet &set) -{ - mModel->addBarSet(set); -} - -void BarChartSeriesBase::removeBarSet(QBarSet &set) -{ - mModel->removeBarSet(set); -} - -qreal BarChartSeriesBase::min() -{ - return mModel->min(); -} - -qreal BarChartSeriesBase::max() -{ - return mModel->max(); -} - -int BarChartSeriesBase::countColumns() -{ - return mModel->countCategories(); -} - -qreal BarChartSeriesBase::valueAt(int series, int item) -{ -// qDebug() << "BarChartSeriesBase::valueAt" << series << item; - return mModel->valueAt(series,item); -} - -qreal BarChartSeriesBase::maxColumnSum() -{ -// qDebug() << "BarChartSeriesBase::maxColumnSum" << mModel->maxColumnSum(); - return mModel->maxCategorySum(); -} - -BarChartModel& BarChartSeriesBase::model() -{ - return *mModel; -} - -QString BarChartSeriesBase::label(int item) -{ - if ((item>=0) && (item < mLabels.count())) { - return mLabels.at(item); - } - - return QString(""); -} - -#include "moc_barchartseriesbase.cpp" - -QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/barchartseriesbase.h b/src/barchart/barchartseriesbase.h deleted file mode 100644 index cf15a04..0000000 --- a/src/barchart/barchartseriesbase.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef BARCHARTSERIESBASE_H -#define BARCHARTSERIESBASE_H - -#include -#include -#include "qchartseries.h" -#include "qchartglobal.h" - -QTCOMMERCIALCHART_BEGIN_NAMESPACE - -class BarGroupBase; -class BarChartModel; -class QBarSet; -class QBarCategory; - -// Container for series -class QTCOMMERCIALCHART_EXPORT BarChartSeriesBase : public QChartSeries -{ - Q_OBJECT -protected: -// BarChartSeriesBase(QObject* parent=0); - BarChartSeriesBase(QBarCategory &category, QObject* parent=0); - -public: - // from QChartSeries - virtual QChartSeriesType type() const { return QChartSeries::SeriesTypeInvalid; } - -protected: - // Used by derived series - void addBarSet(QBarSet &set); - void removeBarSet(QBarSet &set); - -public: - // These shouldn't be visible to chart series user. However, ChartDataSet needs to access them, and friends are evil. - qreal min(); - qreal max(); - int countColumns(); // Count items in one series. - qreal valueAt(int series, int item); - qreal maxColumnSum(); - - BarChartModel& model(); - QString label(int item); - -signals: - void changed(int index); - -public Q_SLOTS: - -private: - - BarChartModel* mModel; - QList mLabels; -}; - -QTCOMMERCIALCHART_END_NAMESPACE - -#endif // BARCHARTSERIESBASE_H diff --git a/src/barchart/bargroup.cpp b/src/barchart/bargroup.cpp index 50fd1c4..7fa5586 100644 --- a/src/barchart/bargroup.cpp +++ b/src/barchart/bargroup.cpp @@ -5,8 +5,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -BarGroup::BarGroup(BarChartSeries& series, QGraphicsItem *parent) : - BarGroupBase(series,parent) +BarGroup::BarGroup(BarChartModel& model, QGraphicsItem *parent) : + BarGroupBase(model,parent) { mBarDefaultWidth = 10; } diff --git a/src/barchart/bargroup.h b/src/barchart/bargroup.h index ba982ec..5aeebfc 100644 --- a/src/barchart/bargroup.h +++ b/src/barchart/bargroup.h @@ -12,7 +12,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class BarGroup : public BarGroupBase { public: - explicit BarGroup(BarChartSeries& series, QGraphicsItem *parent = 0); + explicit BarGroup(BarChartModel& model, QGraphicsItem *parent = 0); private: diff --git a/src/barchart/bargroupbase.cpp b/src/barchart/bargroupbase.cpp index c91da66..1feb3b2 100644 --- a/src/barchart/bargroupbase.cpp +++ b/src/barchart/bargroupbase.cpp @@ -2,19 +2,18 @@ #include "bar_p.h" #include "barlabel_p.h" #include "separator_p.h" -#include "barchartseriesbase.h" #include QTCOMMERCIALCHART_BEGIN_NAMESPACE -BarGroupBase::BarGroupBase(BarChartSeriesBase& series, QGraphicsItem *parent) +BarGroupBase::BarGroupBase(BarChartModel& model, QGraphicsItem *parent) : ChartItem(parent) ,mBarDefaultWidth(20) // TODO: remove hard coding, when we have layout code ready ,mLayoutSet(false) ,mLayoutDirty(true) ,mSeparatorsVisible(true) - ,mModel(series.model()) - ,mSeries(series) + ,mModel(model) +// ,mSeries(series) { dataChanged(); } @@ -65,7 +64,7 @@ void BarGroupBase::resetColors() void BarGroupBase::dataChanged() { -// qDebug() << "BarGroupBase::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()) { @@ -79,12 +78,10 @@ void BarGroupBase::dataChanged() childItems().append(bar); } - // TODO: labels from series. This creates just some example labels int count = mModel.countCategories(); // mSeries.countColumns(); for (int i=0; iset(mSeries.label(i)); + label->set(mModel.label(i)); childItems().append(label); } diff --git a/src/barchart/bargroupbase.h b/src/barchart/bargroupbase.h index 2d3e3d1..a337b49 100644 --- a/src/barchart/bargroupbase.h +++ b/src/barchart/bargroupbase.h @@ -2,7 +2,6 @@ #define BARGROUPBASE_H #include "chartitem_p.h" -#include "barchartseriesbase.h" #include "barchartmodel_p.h" #include @@ -13,7 +12,7 @@ class BarGroupBase : public QObject, public ChartItem { Q_OBJECT public: - BarGroupBase(BarChartSeriesBase& series, QGraphicsItem *parent = 0); + BarGroupBase(BarChartModel& model, QGraphicsItem *parent = 0); void setSeparatorsVisible(bool visible = true); public: // From ChartItem @@ -53,7 +52,6 @@ protected: QList mColors; // List of colors for series for now bool mSeparatorsVisible; BarChartModel& mModel; - BarChartSeriesBase& mSeries; }; diff --git a/src/barchart/percentbarchartseries.cpp b/src/barchart/percentbarchartseries.cpp index 16bdf62..666c83f 100644 --- a/src/barchart/percentbarchartseries.cpp +++ b/src/barchart/percentbarchartseries.cpp @@ -3,24 +3,59 @@ #include #include #include "percentbarchartseries.h" +#include "qbarset.h" +#include "qbarcategory.h" +#include "barchartmodel_p.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE -PercentBarChartSeries::PercentBarChartSeries(QBarCategory &category, QObject *parent) : - BarChartSeriesBase(category, parent) +PercentBarChartSeries::PercentBarChartSeries(QBarCategory &category, QObject *parent) + : QChartSeries(parent) + ,mModel(new BarChartModel(category, this)) { } void PercentBarChartSeries::addBarSet(QBarSet &set) { - BarChartSeriesBase::addBarSet(set); + mModel->addBarSet(set); } void PercentBarChartSeries::removeBarSet(QBarSet &set) { - BarChartSeriesBase::removeBarSet(set); + mModel->removeBarSet(set); } +int PercentBarChartSeries::countCategories() +{ + return mModel->countCategories(); +} + +qreal PercentBarChartSeries::min() +{ + return mModel->min(); +} + +qreal PercentBarChartSeries::max() +{ + return mModel->max(); +} + +qreal PercentBarChartSeries::valueAt(int set, int category) +{ + return mModel->valueAt(set,category); +} + +qreal PercentBarChartSeries::maxCategorySum() +{ + return mModel->maxCategorySum(); +} + +BarChartModel& PercentBarChartSeries::model() +{ + return *mModel; +} + + #include "moc_percentbarchartseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/percentbarchartseries.h b/src/barchart/percentbarchartseries.h index b15a2f4..8a17e92 100644 --- a/src/barchart/percentbarchartseries.h +++ b/src/barchart/percentbarchartseries.h @@ -3,13 +3,16 @@ #include #include -#include "barchartseriesbase.h" +#include "qchartseries.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE class PercentBarGroup; +class QBarCategory; +class QBarSet; +class BarChartModel; -class QTCOMMERCIALCHART_EXPORT PercentBarChartSeries : public BarChartSeriesBase +class QTCOMMERCIALCHART_EXPORT PercentBarChartSeries : public QChartSeries { Q_OBJECT public: @@ -21,11 +24,25 @@ public: void addBarSet(QBarSet &set); void removeBarSet(QBarSet &set); + int countCategories(); + qreal min(); + qreal max(); + qreal valueAt(int set, int category); + qreal maxCategorySum(); + + BarChartModel& model(); + +signals: + void changed(int index); + public Q_SLOTS: + private: PercentBarGroup* mPercentBarGroup; + BarChartModel* mModel; + }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/percentbargroup.cpp b/src/barchart/percentbargroup.cpp index b4a3d78..a2bdd04 100644 --- a/src/barchart/percentbargroup.cpp +++ b/src/barchart/percentbargroup.cpp @@ -7,8 +7,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -PercentBarGroup::PercentBarGroup(PercentBarChartSeries& series, QGraphicsItem *parent) : - BarGroupBase(series, parent) +PercentBarGroup::PercentBarGroup(BarChartModel& model, QGraphicsItem *parent) : + BarGroupBase(model, parent) { } diff --git a/src/barchart/percentbargroup.h b/src/barchart/percentbargroup.h index 49fe312..5063f2c 100644 --- a/src/barchart/percentbargroup.h +++ b/src/barchart/percentbargroup.h @@ -12,7 +12,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class PercentBarGroup : public BarGroupBase { public: - PercentBarGroup(PercentBarChartSeries& series, QGraphicsItem *parent = 0); + PercentBarGroup(BarChartModel& model, QGraphicsItem *parent = 0); private: diff --git a/src/barchart/qbarcategory.cpp b/src/barchart/qbarcategory.cpp index 210a1f8..4389922 100644 --- a/src/barchart/qbarcategory.cpp +++ b/src/barchart/qbarcategory.cpp @@ -17,9 +17,9 @@ int QBarCategory::count() return mList.count(); } -QList& QBarCategory::items() +QString QBarCategory::label(int category) { - return mList; + return mList.at(category); } diff --git a/src/barchart/qbarcategory.h b/src/barchart/qbarcategory.h index ae012a0..549ed14 100644 --- a/src/barchart/qbarcategory.h +++ b/src/barchart/qbarcategory.h @@ -5,7 +5,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -class QTCOMMERCIALCHART_EXPORT QBarCategory // : pubclic QObject // TODO: Need for this? +class QTCOMMERCIALCHART_EXPORT QBarCategory // TODO? : pubclic QObject { public: QBarCategory(); @@ -14,7 +14,7 @@ public: // Number of items in category int count(); - QList& items(); + QString label(int category); public: diff --git a/src/barchart/stackedbarchartseries.cpp b/src/barchart/stackedbarchartseries.cpp index 026966f..7233792 100644 --- a/src/barchart/stackedbarchartseries.cpp +++ b/src/barchart/stackedbarchartseries.cpp @@ -1,24 +1,59 @@ #include #include #include "stackedbarchartseries.h" +#include "qbarcategory.h" +#include "qbarset.h" +#include "barchartmodel_p.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE -StackedBarChartSeries::StackedBarChartSeries(QBarCategory &category, QObject *parent) : - BarChartSeriesBase(category, parent) +StackedBarChartSeries::StackedBarChartSeries(QBarCategory &category, QObject *parent) + : QChartSeries(parent) + ,mModel(new BarChartModel(category, this)) { } void StackedBarChartSeries::addBarSet(QBarSet &set) { - BarChartSeriesBase::addBarSet(set); + mModel->addBarSet(set); } void StackedBarChartSeries::removeBarSet(QBarSet &set) { - BarChartSeriesBase::removeBarSet(set); + mModel->removeBarSet(set); } +int StackedBarChartSeries::countCategories() +{ + return mModel->countCategories(); +} + +qreal StackedBarChartSeries::min() +{ + return mModel->min(); +} + +qreal StackedBarChartSeries::max() +{ + return mModel->max(); +} + +qreal StackedBarChartSeries::valueAt(int set, int category) +{ + return mModel->valueAt(set,category); +} + +qreal StackedBarChartSeries::maxCategorySum() +{ + return mModel->maxCategorySum(); +} + +BarChartModel& StackedBarChartSeries::model() +{ + return *mModel; +} + + #include "moc_stackedbarchartseries.cpp" QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/stackedbarchartseries.h b/src/barchart/stackedbarchartseries.h index 773efd9..3344c16 100644 --- a/src/barchart/stackedbarchartseries.h +++ b/src/barchart/stackedbarchartseries.h @@ -3,13 +3,16 @@ #include #include -#include "barchartseriesbase.h" +#include "qchartseries.h" QTCOMMERCIALCHART_BEGIN_NAMESPACE class StackedBarGroup; +class QBarCategory; +class QBarSet; +class BarChartModel; -class QTCOMMERCIALCHART_EXPORT StackedBarChartSeries : public BarChartSeriesBase +class QTCOMMERCIALCHART_EXPORT StackedBarChartSeries : public QChartSeries { Q_OBJECT public: @@ -21,11 +24,23 @@ public: void addBarSet(QBarSet &set); void removeBarSet(QBarSet &set); + int countCategories(); + qreal min(); + qreal max(); + qreal valueAt(int set, int category); + qreal maxCategorySum(); + + BarChartModel& model(); + +signals: + void changed(int index); + public Q_SLOTS: private: StackedBarGroup* mStackedBarGroup; + BarChartModel* mModel; }; QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/barchart/stackedbargroup.cpp b/src/barchart/stackedbargroup.cpp index 7107d7b..b95e529 100644 --- a/src/barchart/stackedbargroup.cpp +++ b/src/barchart/stackedbargroup.cpp @@ -6,8 +6,8 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE -StackedBarGroup::StackedBarGroup(StackedBarChartSeries& series, QGraphicsItem *parent) : - BarGroupBase(series,parent) +StackedBarGroup::StackedBarGroup(BarChartModel& model, QGraphicsItem *parent) : + BarGroupBase(model,parent) { } diff --git a/src/barchart/stackedbargroup.h b/src/barchart/stackedbargroup.h index 2a71810..bd52be2 100644 --- a/src/barchart/stackedbargroup.h +++ b/src/barchart/stackedbargroup.h @@ -10,7 +10,7 @@ QTCOMMERCIALCHART_BEGIN_NAMESPACE class StackedBarGroup : public BarGroupBase { public: - StackedBarGroup(StackedBarChartSeries& series, QGraphicsItem *parent = 0); + StackedBarGroup(BarChartModel& model, QGraphicsItem *parent = 0); private: // From BarGroupBase diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index f011b18..fd2c030 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -54,7 +54,7 @@ void ChartDataSet::addSeries(QChartSeries* series) case QChartSeries::SeriesTypeBar: { BarChartSeries* barSeries = static_cast(series); - qreal x = barSeries->countColumns(); + qreal x = barSeries->countCategories(); qreal y = barSeries->max(); domain.m_minX = qMin(domain.m_minX,x); domain.m_minY = qMin(domain.m_minY,y); @@ -65,8 +65,8 @@ void ChartDataSet::addSeries(QChartSeries* series) case QChartSeries::SeriesTypeStackedBar: { StackedBarChartSeries* stackedBarSeries = static_cast(series); - qreal x = stackedBarSeries->countColumns(); - qreal y = stackedBarSeries->maxColumnSum(); + qreal x = stackedBarSeries->countCategories(); + qreal y = stackedBarSeries->maxCategorySum(); domain.m_minX = qMin(domain.m_minX,x); domain.m_minY = qMin(domain.m_minY,y); domain.m_maxX = qMax(domain.m_maxX,x); @@ -76,7 +76,7 @@ void ChartDataSet::addSeries(QChartSeries* series) case QChartSeries::SeriesTypePercentBar: { PercentBarChartSeries* percentBarSeries = static_cast(series); - qreal x = percentBarSeries->countColumns(); + qreal x = percentBarSeries->countCategories(); domain.m_minX = qMin(domain.m_minX,x); domain.m_minY = 0; domain.m_maxX = qMax(domain.m_maxX,x); diff --git a/src/chartpresenter.cpp b/src/chartpresenter.cpp index b9aaaec..3473050 100644 --- a/src/chartpresenter.cpp +++ b/src/chartpresenter.cpp @@ -91,7 +91,7 @@ void ChartPresenter::handleSeriesAdded(QChartSeries* series) case QChartSeries::SeriesTypeBar: { BarChartSeries* barSeries = static_cast(series); - BarGroup* item = new BarGroup(*barSeries,m_chart); + BarGroup* item = new BarGroup(barSeries->model(),m_chart); m_chartTheme->decorate(item,barSeries,m_chartItems.count()); QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&))); @@ -104,7 +104,7 @@ void ChartPresenter::handleSeriesAdded(QChartSeries* series) case QChartSeries::SeriesTypeStackedBar: { StackedBarChartSeries* stackedBarSeries = static_cast(series); - StackedBarGroup* item = new StackedBarGroup(*stackedBarSeries,m_chart); + StackedBarGroup* item = new StackedBarGroup(stackedBarSeries->model(),m_chart); m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count()); QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&))); @@ -116,7 +116,7 @@ void ChartPresenter::handleSeriesAdded(QChartSeries* series) case QChartSeries::SeriesTypePercentBar: { PercentBarChartSeries* percentBarSeries = static_cast(series); - PercentBarGroup* item = new PercentBarGroup(*percentBarSeries,m_chart); + PercentBarGroup* item = new PercentBarGroup(percentBarSeries->model(),m_chart); m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count()); QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&))); QObject::connect(m_dataset,SIGNAL(domainChanged(const Domain&)),item,SLOT(handleDomainChanged(const Domain&))); diff --git a/src/src.pro b/src/src.pro index f328cc8..938da8f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -17,7 +17,6 @@ SOURCES += barchart/barchartseries.cpp \ barchart/barchartmodel.cpp \ barchart/separator.cpp \ barchart/bargroupbase.cpp \ - barchart/barchartseriesbase.cpp \ barchart/qbarset.cpp \ barchart/qbarcategory.cpp \ linechart/linechartanimationitem.cpp \ @@ -56,7 +55,6 @@ PUBLIC_HEADERS += linechart/qlinechartseries.h \ barchart/stackedbargroup.h \ barchart/percentbarchartseries.h \ barchart/percentbargroup.h \ - barchart/barchartseriesbase.h \ barchart/bargroupbase.h \ barchart/qbarset.h \ barchart/qbarcategory.h \