barchartmodel_p.h
60 lines
| 1.4 KiB
| text/x-c
|
CLexer
|
r159 | #ifndef BARCHARTMODEL_H | ||
#define BARCHARTMODEL_H | ||||
#include <QObject> | ||||
|
r161 | #include "qchartglobal.h" | ||
|
r159 | |||
QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||||
|
r161 | // Model for bar chart. Internal class. | ||
|
r159 | // TODO: Implement as QAbstractItemModel? | ||
|
r169 | class QBarSet; | ||
class QBarCategory; | ||||
|
r159 | class BarChartModel : public QObject //, public QAbstractItemModel | ||
{ | ||||
Q_OBJECT | ||||
public: | ||||
|
r173 | explicit BarChartModel(QBarCategory *category, QObject *parent = 0); | ||
~BarChartModel(); | ||||
|
r159 | |||
|
r171 | QBarCategory& category(); | ||
|
r173 | void addBarSet(QBarSet *set); | ||
void removeBarSet(QBarSet *set); | ||||
|
r273 | QBarSet *setAt(int index); | ||
|
r357 | QList<QBarSet*> barSets(); | ||
|
r280 | QList<QString> legend(); | ||
|
r169 | |||
|
r171 | int countSets(); // Number of sets in model | ||
int countCategories(); // Number of categories | ||||
int countTotalItems(); // Total items in all sets. Includes empty items. | ||||
|
r159 | |||
|
r171 | qreal max(); // Maximum value of all sets | ||
qreal min(); // Minimum value of all sets | ||||
qreal valueAt(int set, int category); | ||||
|
r263 | qreal percentageAt(int set, int category); | ||
|
r159 | |||
|
r263 | qreal categorySum(int category); | ||
|
r171 | qreal maxCategorySum(); // returns maximum sum of sets in all categories. | ||
|
r161 | |||
|
r172 | QString label(int category); | ||
|
r159 | signals: | ||
void modelUpdated(); | ||||
public slots: | ||||
private: | ||||
|
r171 | QList<QBarSet*> mDataModel; | ||
|
r173 | QBarCategory* mCategory; // Owned | ||
|
r159 | |||
|
r214 | int mCurrentSet; | ||
|
r159 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // BARCHARTMODEL_H | ||||