barchartmodel_p.h
63 lines
| 1.6 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? | ||
class BarChartModel : public QObject //, public QAbstractItemModel | ||||
{ | ||||
Q_OBJECT | ||||
public: | ||||
explicit BarChartModel(QObject *parent = 0); | ||||
|
r161 | ~BarChartModel(); | ||
|
r159 | |||
|
r161 | // Adds data to model. returns id. | ||
int addData(QList<qreal> data); | ||||
void removeData(int id); | ||||
|
r159 | |||
|
r161 | int countRows(); // Number of series in model | ||
int countColumns(); // Maximum number of items in series | ||||
|
r159 | int countTotalItems(); // Total items in all series. Includes empty items. | ||
|
r161 | // TODO: qreal these | ||
|
r159 | int max(); // Maximum value of all series | ||
int min(); // Minimum value of all series | ||||
qreal valueAt(int series, int item); | ||||
|
r161 | qreal columnSum(int column); | ||
qreal maxColumnSum(); // returns maximum sum of items in all columns. | ||||
|
r159 | signals: | ||
void modelUpdated(); | ||||
public slots: | ||||
private: | ||||
|
r161 | // Little helper class. | ||
class DataContainer { | ||||
public: | ||||
DataContainer(QList<qreal> data, int id) : mId(id), mData(data) {} | ||||
int countColumns() { return mData.count(); } | ||||
qreal valueAt(int item) { return mData.at(item); } | ||||
int mId; // TODO: Is this needed? | ||||
private: | ||||
QList<qreal> mData; | ||||
}; | ||||
// Owned. N series. each has a list of values. | ||||
QList<DataContainer*> mDataModel; | ||||
int mRunningId; | ||||
int mMaxColumns; // longest series in datamodel | ||||
|
r159 | |||
}; | ||||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // BARCHARTMODEL_H | ||||