From 8a2edd02880598709be1d94d295b2b3a25ad9475 2012-02-27 15:45:58 From: sauimone Date: 2012-02-27 15:45:58 Subject: [PATCH] review fixes. countCategories() -> categoryCount(). countSets -> barsetCount() --- diff --git a/src/barchart/barpresenter.cpp b/src/barchart/barpresenter.cpp index 201751c..c85c1a0 100644 --- a/src/barchart/barpresenter.cpp +++ b/src/barchart/barpresenter.cpp @@ -17,7 +17,7 @@ void BarPresenter::layoutChanged() { // Scale bars to new layout // Layout for bars: - if (mSeries->countSets() <= 0) { + if (mSeries->barsetCount() <= 0) { qDebug() << "No sets in model!"; return; } @@ -29,8 +29,8 @@ void BarPresenter::layoutChanged() // TODO: better way to auto-layout? // Use reals for accurancy (we might get some compiler warnings... :) - int categoryCount = mSeries->countCategories(); - int setCount = mSeries->countSets(); + int categoryCount = mSeries->categoryCount(); + int setCount = mSeries->barsetCount(); qreal tW = mWidth; qreal tH = mHeight; @@ -67,10 +67,10 @@ void BarPresenter::layoutChanged() // Position floating values itemIndex = 0; - for (int category=0; category < mSeries->countCategories(); category++) { + for (int category=0; category < mSeries->categoryCount(); category++) { qreal xPos = xStepPerSet * category + ((tW + mBarDefaultWidth*setCount)/(categoryCount*2)); qreal yPos = mHeight; - for (int set=0; set < mSeries->countSets(); set++) { + for (int set=0; set < mSeries->barsetCount(); set++) { qreal barHeight = mSeries->valueAt(set,category) * scale; BarValue* value = mFloatingValues.at(itemIndex); diff --git a/src/barchart/barpresenterbase.cpp b/src/barchart/barpresenterbase.cpp index 5a0cbca..8f2dbeb 100644 --- a/src/barchart/barpresenterbase.cpp +++ b/src/barchart/barpresenterbase.cpp @@ -68,8 +68,8 @@ void BarPresenterBase::dataChanged() mFloatingValues.clear(); // Create new graphic items for bars - for (int c=0; ccountCategories(); c++) { - for (int s=0; scountSets(); s++) { + for (int c=0; ccategoryCount(); c++) { + for (int s=0; sbarsetCount(); s++) { QBarSet *set = mSeries->barsetAt(s); Bar *bar = new Bar(this); childItems().append(bar); @@ -81,7 +81,7 @@ void BarPresenterBase::dataChanged() } // Create labels - int count = mSeries->countCategories(); + int count = mSeries->categoryCount(); for (int i=0; iset(mSeries->label(i)); @@ -90,7 +90,7 @@ void BarPresenterBase::dataChanged() } // Create separators - count = mSeries->countCategories() - 1; // There is one less separator than columns + count = mSeries->categoryCount() - 1; // There is one less separator than columns for (int i=0; isetColor(QColor(255,0,0,255)); // TODO: color for separations from theme @@ -100,8 +100,8 @@ void BarPresenterBase::dataChanged() } // Create floating values - for (int category=0; categorycountCategories(); category++) { - for (int s=0; scountSets(); s++) { + for (int category=0; categorycategoryCount(); category++) { + for (int s=0; sbarsetCount(); s++) { QBarSet *set = mSeries->barsetAt(s); BarValue *value = new BarValue(*set, this); childItems().append(value); diff --git a/src/barchart/percentbarpresenter.cpp b/src/barchart/percentbarpresenter.cpp index dca32ac..38e3b07 100644 --- a/src/barchart/percentbarpresenter.cpp +++ b/src/barchart/percentbarpresenter.cpp @@ -18,7 +18,7 @@ void PercentBarPresenter::layoutChanged() { // Scale bars to new layout // Layout for bars: - if (mSeries->countSets() <= 0) { + if (mSeries->barsetCount() <= 0) { qDebug() << "No sets in model!"; // Nothing to do. return; @@ -31,7 +31,7 @@ void PercentBarPresenter::layoutChanged() // TODO: better way to auto-layout // Use reals for accurancy (we might get some compiler warnings... :) - int count = mSeries->countCategories(); + int count = mSeries->categoryCount(); int itemIndex(0); int labelIndex(0); qreal tW = mWidth; @@ -40,11 +40,11 @@ void PercentBarPresenter::layoutChanged() qreal xPos = ((tW/tC) - mBarDefaultWidth / 2); qreal h = mHeight; - for (int category = 0; category < mSeries->countCategories(); category++) { + for (int category = 0; category < mSeries->categoryCount(); category++) { qreal colSum = mSeries->categorySum(category); qreal scale = (h / colSum); qreal yPos = h; - for (int set=0; set < mSeries->countSets(); set++) { + for (int set=0; set < mSeries->barsetCount(); set++) { qreal barHeight = mSeries->valueAt(set, category) * scale; Bar* bar = mBars.at(itemIndex); @@ -65,7 +65,7 @@ void PercentBarPresenter::layoutChanged() // Position separators xPos = xStep + xStep/2; - for (int s=0; s < mSeries->countCategories() - 1; s++) { + for (int s=0; s < mSeries->categoryCount() - 1; s++) { Separator* sep = mSeparators.at(s); sep->setPos(xPos,0); sep->setSize(QSizeF(1,mHeight)); @@ -75,11 +75,11 @@ void PercentBarPresenter::layoutChanged() // Position floating values itemIndex = 0; xPos = ((tW/tC) - mBarDefaultWidth / 2); - for (int category=0; category < mSeries->countCategories(); category++) { + for (int category=0; category < mSeries->categoryCount(); category++) { qreal yPos = h; qreal colSum = mSeries->categorySum(category); qreal scale = (h / colSum); - for (int set=0; set < mSeries->countSets(); set++) { + for (int set=0; set < mSeries->barsetCount(); set++) { qreal barHeight = mSeries->valueAt(set,category) * scale; BarValue* value = mFloatingValues.at(itemIndex); diff --git a/src/barchart/qbarseries.cpp b/src/barchart/qbarseries.cpp index ee156bc..0f3f5ff 100644 --- a/src/barchart/qbarseries.cpp +++ b/src/barchart/qbarseries.cpp @@ -76,7 +76,7 @@ void QBarSeries::removeBarSet(QBarSet *set) /*! Returns number of sets in series. */ -int QBarSeries::countSets() +int QBarSeries::barsetCount() { return mModel->countSets(); } @@ -84,7 +84,7 @@ int QBarSeries::countSets() /*! Returns number of categories in series */ -int QBarSeries::countCategories() +int QBarSeries::categoryCount() { return mModel->countCategories(); } diff --git a/src/barchart/qbarseries.h b/src/barchart/qbarseries.h index 6bc6a19..305e322 100644 --- a/src/barchart/qbarseries.h +++ b/src/barchart/qbarseries.h @@ -20,8 +20,8 @@ public: void addBarSet(QBarSet *set); // Takes ownership of set void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set - int countSets(); - int countCategories(); + int barsetCount(); + int categoryCount(); QList barSets(); QList legend(); // Returns legend of series (ie. names of all sets in series) diff --git a/src/barchart/stackedbarpresenter.cpp b/src/barchart/stackedbarpresenter.cpp index 4769ff3..2a0c046 100644 --- a/src/barchart/stackedbarpresenter.cpp +++ b/src/barchart/stackedbarpresenter.cpp @@ -17,13 +17,13 @@ void StackedBarPresenter::layoutChanged() { // Scale bars to new layout // Layout for bars: - if (mSeries->countSets() <= 0) { + if (mSeries->barsetCount() <= 0) { qDebug() << "No sets in model!"; // Nothing to do. return; } - if (mSeries->countCategories() == 0) { + if (mSeries->categoryCount() == 0) { qDebug() << "No categories in model!"; // Nothing to do return; @@ -44,13 +44,13 @@ void StackedBarPresenter::layoutChanged() int itemIndex(0); int labelIndex(0); qreal tW = mWidth; - qreal tC = mSeries->countCategories() + 1; + qreal tC = mSeries->categoryCount() + 1; qreal xStep = (tW/tC); qreal xPos = ((tW/tC) - mBarDefaultWidth / 2); - for (int category = 0; category < mSeries->countCategories(); category++) { + for (int category = 0; category < mSeries->categoryCount(); category++) { qreal yPos = h; - for (int set=0; set < mSeries->countSets(); set++) { + for (int set=0; set < mSeries->barsetCount(); set++) { qreal barHeight = mSeries->valueAt(set, category) * scale; Bar* bar = mBars.at(itemIndex); @@ -70,7 +70,7 @@ void StackedBarPresenter::layoutChanged() // Position separators xPos = xStep + xStep/2; - for (int s=0; s < mSeries->countCategories() - 1; s++) { + for (int s=0; s < mSeries->categoryCount() - 1; s++) { Separator* sep = mSeparators.at(s); sep->setPos(xPos,0); sep->setSize(QSizeF(1,mHeight)); @@ -80,9 +80,9 @@ void StackedBarPresenter::layoutChanged() // Position floating values itemIndex = 0; xPos = ((tW/tC) - mBarDefaultWidth / 2); - for (int category=0; category < mSeries->countCategories(); category++) { + for (int category=0; category < mSeries->categoryCount(); category++) { qreal yPos = h; - for (int set=0; set < mSeries->countSets(); set++) { + for (int set=0; set < mSeries->barsetCount(); set++) { qreal barHeight = mSeries->valueAt(set,category) * scale; BarValue* value = mFloatingValues.at(itemIndex); diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index ac0fce5..b145c2b 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -73,7 +73,7 @@ void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) case QSeries::SeriesTypeBar: { qDebug() << "QChartSeries::SeriesTypeBar"; QBarSeries* barSeries = static_cast(series); - qreal x = barSeries->countCategories(); + qreal x = barSeries->categoryCount(); qreal y = barSeries->max(); domain.m_minX = qMin(domain.m_minX,x); domain.m_minY = qMin(domain.m_minY,y); @@ -85,7 +85,7 @@ void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) qDebug() << "QChartSeries::SeriesTypeStackedBar"; QStackedBarSeries* stackedBarSeries = static_cast(series); - qreal x = stackedBarSeries->countCategories(); + qreal x = stackedBarSeries->categoryCount(); qreal y = stackedBarSeries->maxCategorySum(); domain.m_minX = qMin(domain.m_minX,x); domain.m_minY = qMin(domain.m_minY,y); @@ -97,7 +97,7 @@ void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) qDebug() << "QChartSeries::SeriesTypePercentBar"; QPercentBarSeries* percentBarSeries = static_cast(series); - qreal x = percentBarSeries->countCategories(); + qreal x = percentBarSeries->categoryCount(); domain.m_minX = qMin(domain.m_minX,x); domain.m_minY = 0; domain.m_maxX = qMax(domain.m_maxX,x); diff --git a/src/charttheme.cpp b/src/charttheme.cpp index a244a6c..78c3e37 100644 --- a/src/charttheme.cpp +++ b/src/charttheme.cpp @@ -144,7 +144,7 @@ void ChartTheme::decorate(LineChartItem* item, QLineSeries* series,int count) void ChartTheme::decorate(BarPresenter* item, QBarSeries* series,int count) { QList sets = series->barSets(); - for (int i=0; icountSets(); i++) { + for (int i=0; ibarsetCount(); i++) { sets.at(i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count()))); } } @@ -152,7 +152,7 @@ void ChartTheme::decorate(BarPresenter* item, QBarSeries* series,int count) void ChartTheme::decorate(StackedBarPresenter* item, QStackedBarSeries* series,int count) { QList sets = series->barSets(); - for (int i=0; icountSets(); i++) { + for (int i=0; ibarsetCount(); i++) { sets.at(i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count()))); } } @@ -160,7 +160,7 @@ void ChartTheme::decorate(StackedBarPresenter* item, QStackedBarSeries* series,i void ChartTheme::decorate(PercentBarPresenter* item, QPercentBarSeries* series,int count) { QList sets = series->barSets(); - for (int i=0; icountSets(); i++) { + for (int i=0; ibarsetCount(); i++) { sets.at(i)->setBrush(QBrush(m_seriesColor.at(i%m_seriesColor.count()))); } } diff --git a/test/chartwidgettest/mainwidget.cpp b/test/chartwidgettest/mainwidget.cpp index a111900..f0b4c76 100644 --- a/test/chartwidgettest/mainwidget.cpp +++ b/test/chartwidgettest/mainwidget.cpp @@ -271,7 +271,7 @@ void MainWidget::addSeries(QString seriesName, int columnCount, int rowCount, QS series->addBarSet(set); } series->setFloatingValuesEnabled(true); - series->setToolTipEnabled(); + series->setToolTipEnabled(true); series->setSeparatorsEnabled(false); m_chartWidget->addSeries(series); setCurrentSeries(series);