barchartmodel_p.h
62 lines
| 1.4 KiB
| text/x-c
|
CLexer
sauimone
|
r159 | #ifndef BARCHARTMODEL_H | ||
#define BARCHARTMODEL_H | ||||
#include <QObject> | ||||
sauimone
|
r377 | #include <QStringList> | ||
sauimone
|
r161 | #include "qchartglobal.h" | ||
sauimone
|
r380 | #include <qseries.h> | ||
sauimone
|
r159 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r161 | // Model for bar chart. Internal class. | ||
sauimone
|
r159 | // TODO: Implement as QAbstractItemModel? | ||
sauimone
|
r169 | class QBarSet; | ||
sauimone
|
r412 | class BarCategory; | ||
sauimone
|
r169 | |||
sauimone
|
r159 | class BarChartModel : public QObject //, public QAbstractItemModel | ||
{ | ||||
Q_OBJECT | ||||
public: | ||||
sauimone
|
r377 | explicit BarChartModel(QStringList categories, QObject *parent = 0); | ||
sauimone
|
r159 | |||
sauimone
|
r377 | QStringList category(); | ||
sauimone
|
r173 | void addBarSet(QBarSet *set); | ||
void removeBarSet(QBarSet *set); | ||||
sauimone
|
r273 | QBarSet *setAt(int index); | ||
sauimone
|
r357 | QList<QBarSet*> barSets(); | ||
sauimone
|
r380 | QList<QSeries::Legend> legend(); | ||
sauimone
|
r169 | |||
sauimone
|
r387 | int barsetCount(); // Number of sets in model | ||
int categoryCount(); // Number of categories | ||||
sauimone
|
r159 | |||
sauimone
|
r171 | qreal max(); // Maximum value of all sets | ||
qreal min(); // Minimum value of all sets | ||||
qreal valueAt(int set, int category); | ||||
sauimone
|
r263 | qreal percentageAt(int set, int category); | ||
sauimone
|
r159 | |||
sauimone
|
r263 | qreal categorySum(int category); | ||
sauimone
|
r171 | qreal maxCategorySum(); // returns maximum sum of sets in all categories. | ||
sauimone
|
r161 | |||
sauimone
|
r412 | QString categoryName(int category); | ||
BarCategory* categoryObject(int category); | ||||
sauimone
|
r172 | |||
sauimone
|
r159 | signals: | ||
void modelUpdated(); | ||||
public slots: | ||||
private: | ||||
sauimone
|
r171 | QList<QBarSet*> mDataModel; | ||
sauimone
|
r377 | QStringList mCategory; | ||
sauimone
|
r412 | QList<BarCategory*> mCategoryObjects; | ||
sauimone
|
r159 | |||
sauimone
|
r214 | int mCurrentSet; | ||
sauimone
|
r159 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // BARCHARTMODEL_H | ||||