qbarchartseries.cpp
128 lines
| 2.6 KiB
| text/x-c
|
CppLexer
sauimone
|
r71 | #include <QDebug> | ||
sauimone
|
r216 | #include "qbarchartseries.h" | ||
sauimone
|
r172 | #include "qbarcategory.h" | ||
#include "qbarset.h" | ||||
#include "barchartmodel_p.h" | ||||
sauimone
|
r126 | |||
sauimone
|
r56 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
sauimone
|
r216 | QBarChartSeries::QBarChartSeries(QBarCategory *category, QObject *parent) | ||
sauimone
|
r172 | : QChartSeries(parent) | ||
,mModel(new BarChartModel(category, this)) | ||||
sauimone
|
r71 | { | ||
} | ||||
sauimone
|
r216 | void QBarChartSeries::addBarSet(QBarSet *set) | ||
sauimone
|
r171 | { | ||
sauimone
|
r172 | mModel->addBarSet(set); | ||
sauimone
|
r171 | } | ||
sauimone
|
r216 | void QBarChartSeries::removeBarSet(QBarSet *set) | ||
sauimone
|
r171 | { | ||
sauimone
|
r172 | mModel->removeBarSet(set); | ||
} | ||||
sauimone
|
r216 | int QBarChartSeries::countSets() | ||
sauimone
|
r214 | { | ||
return mModel->countSets(); | ||||
} | ||||
sauimone
|
r216 | QBarSet* QBarChartSeries::nextSet(bool getFirst) | ||
sauimone
|
r214 | { | ||
return mModel->nextSet(getFirst); | ||||
} | ||||
sauimone
|
r288 | QBarSet* QBarChartSeries::setAt(int index) | ||
{ | ||||
return mModel->setAt(index); | ||||
} | ||||
sauimone
|
r280 | QList<QString> QBarChartSeries::legend() | ||
{ | ||||
return mModel->legend(); | ||||
} | ||||
sauimone
|
r288 | QString QBarChartSeries::label(int category) | ||
{ | ||||
return mModel->label(category); | ||||
} | ||||
sauimone
|
r280 | void QBarChartSeries::enableFloatingValues(bool enabled) | ||
{ | ||||
sauimone
|
r296 | if (enabled) { | ||
for (int i=0; i<mModel->countSets(); i++) { | ||||
QBarSet *set = mModel->setAt(i); | ||||
connect(set,SIGNAL(clicked()),set,SIGNAL(toggleFloatingValues())); | ||||
} | ||||
} else { | ||||
for (int i=0; i<mModel->countSets(); i++) { | ||||
QBarSet *set = mModel->setAt(i); | ||||
disconnect(set,SIGNAL(clicked()),set,SIGNAL(toggleFloatingValues())); | ||||
} | ||||
} | ||||
sauimone
|
r280 | } | ||
sauimone
|
r288 | void QBarChartSeries::enableToolTip(bool enabled) | ||
sauimone
|
r280 | { | ||
sauimone
|
r296 | if (enabled) { | ||
for (int i=0; i<mModel->countSets(); i++) { | ||||
QBarSet *set = mModel->setAt(i); | ||||
connect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString))); | ||||
} | ||||
} else { | ||||
for (int i=0; i<mModel->countSets(); i++) { | ||||
QBarSet *set = mModel->setAt(i); | ||||
disconnect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString))); | ||||
} | ||||
} | ||||
sauimone
|
r288 | } | ||
void QBarChartSeries::enableSeparators(bool enabled) | ||||
{ | ||||
emit separatorsEnabled(enabled); | ||||
sauimone
|
r280 | } | ||
sauimone
|
r216 | int QBarChartSeries::countCategories() | ||
sauimone
|
r172 | { | ||
return mModel->countCategories(); | ||||
} | ||||
sauimone
|
r216 | qreal QBarChartSeries::min() | ||
sauimone
|
r172 | { | ||
return mModel->min(); | ||||
} | ||||
sauimone
|
r216 | qreal QBarChartSeries::max() | ||
sauimone
|
r172 | { | ||
return mModel->max(); | ||||
sauimone
|
r171 | } | ||
sauimone
|
r216 | qreal QBarChartSeries::valueAt(int set, int category) | ||
sauimone
|
r172 | { | ||
return mModel->valueAt(set,category); | ||||
} | ||||
sauimone
|
r288 | qreal QBarChartSeries::percentageAt(int set, int category) | ||
{ | ||||
return mModel->percentageAt(set,category); | ||||
} | ||||
qreal QBarChartSeries::categorySum(int category) | ||||
{ | ||||
return mModel->categorySum(category); | ||||
} | ||||
sauimone
|
r216 | qreal QBarChartSeries::maxCategorySum() | ||
sauimone
|
r172 | { | ||
return mModel->maxCategorySum(); | ||||
} | ||||
sauimone
|
r216 | BarChartModel& QBarChartSeries::model() | ||
sauimone
|
r172 | { | ||
return *mModel; | ||||
} | ||||
sauimone
|
r216 | #include "moc_qbarchartseries.cpp" | ||
sauimone
|
r71 | |||
sauimone
|
r56 | QTCOMMERCIALCHART_END_NAMESPACE | ||