barchartmodel_p.h
59 lines
| 1.3 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
|
r159 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
sauimone
|
r161 | // Model for bar chart. Internal class. | ||
sauimone
|
r159 | // TODO: Implement as QAbstractItemModel? | ||
sauimone
|
r169 | class QBarSet; | ||
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
|
r280 | QList<QString> legend(); | ||
sauimone
|
r169 | |||
sauimone
|
r171 | int countSets(); // Number of sets in model | ||
int countCategories(); // Number of categories | ||||
int countTotalItems(); // Total items in all sets. Includes empty items. | ||||
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
|
r172 | QString label(int category); | ||
sauimone
|
r159 | signals: | ||
void modelUpdated(); | ||||
public slots: | ||||
private: | ||||
sauimone
|
r171 | QList<QBarSet*> mDataModel; | ||
sauimone
|
r377 | QStringList mCategory; | ||
sauimone
|
r159 | |||
sauimone
|
r214 | int mCurrentSet; | ||
sauimone
|
r159 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // BARCHARTMODEL_H | ||||