barchartmodel_p.h
59 lines
| 1.4 KiB
| text/x-c
|
CLexer
sauimone
|
r159 | #ifndef BARCHARTMODEL_H | ||
#define BARCHARTMODEL_H | ||||
#include <QObject> | ||||
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; | ||
class QBarCategory; | ||||
sauimone
|
r159 | class BarChartModel : public QObject //, public QAbstractItemModel | ||
{ | ||||
Q_OBJECT | ||||
public: | ||||
sauimone
|
r173 | explicit BarChartModel(QBarCategory *category, QObject *parent = 0); | ||
~BarChartModel(); | ||||
sauimone
|
r159 | |||
sauimone
|
r171 | QBarCategory& category(); | ||
sauimone
|
r173 | void addBarSet(QBarSet *set); | ||
void removeBarSet(QBarSet *set); | ||||
sauimone
|
r214 | QBarSet* nextSet(bool getFirst); | ||
sauimone
|
r273 | QBarSet *setAt(int index); | ||
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
|
r173 | QBarCategory* mCategory; // Owned | ||
sauimone
|
r159 | |||
sauimone
|
r214 | int mCurrentSet; | ||
sauimone
|
r159 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // BARCHARTMODEL_H | ||||