##// END OF EJS Templates
updated barchart examples
updated barchart examples

File last commit:

r169:1723c50daa1e
r170:ff886517a70e
Show More
barchartmodel_p.h
69 lines | 1.8 KiB | text/x-c | CLexer
sauimone
model prototyping for bar chart
r159 #ifndef BARCHARTMODEL_H
#define BARCHARTMODEL_H
#include <QObject>
sauimone
model delegate for bar series. updated examples
r161 #include "qchartglobal.h"
sauimone
model prototyping for bar chart
r159
QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
model delegate for bar series. updated examples
r161 // Model for bar chart. Internal class.
sauimone
model prototyping for bar chart
r159 // TODO: Implement as QAbstractItemModel?
sauimone
proof of concept implementation for barset and barcategory
r169 class QBarSet;
class QBarCategory;
sauimone
model prototyping for bar chart
r159 class BarChartModel : public QObject //, public QAbstractItemModel
{
Q_OBJECT
public:
sauimone
proof of concept implementation for barset and barcategory
r169 explicit BarChartModel(QBarCategory &category, QObject *parent = 0);
sauimone
model delegate for bar series. updated examples
r161 ~BarChartModel();
sauimone
proof of concept implementation for barset and barcategory
r169
// TODO: remove these after add and remove QBarSet works.
sauimone
model delegate for bar series. updated examples
r161 int addData(QList<qreal> data);
void removeData(int id);
sauimone
model prototyping for bar chart
r159
sauimone
proof of concept implementation for barset and barcategory
r169 void addBarSet(QBarSet &set);
void removeBarSet(QBarSet &set);
sauimone
model delegate for bar series. updated examples
r161 int countRows(); // Number of series in model
int countColumns(); // Maximum number of items in series
sauimone
model prototyping for bar chart
r159 int countTotalItems(); // Total items in all series. Includes empty items.
sauimone
added labels to series, intergrated with test app. minor hack to test app
r167 qreal max(); // Maximum value of all series
qreal min(); // Minimum value of all series
sauimone
model prototyping for bar chart
r159 qreal valueAt(int series, int item);
sauimone
model delegate for bar series. updated examples
r161 qreal columnSum(int column);
qreal maxColumnSum(); // returns maximum sum of items in all columns.
sauimone
model prototyping for bar chart
r159 signals:
void modelUpdated();
public slots:
private:
sauimone
model delegate for bar series. updated examples
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
sauimone
proof of concept implementation for barset and barcategory
r169 QBarCategory& mCategory;
sauimone
model prototyping for bar chart
r159
};
QTCOMMERCIALCHART_END_NAMESPACE
#endif // BARCHARTMODEL_H