barchartmodel_p.h
78 lines
| 2.2 KiB
| text/x-c
|
CLexer
Jani Honkonen
|
r794 | /**************************************************************************** | ||
** | ||||
** Copyright (C) 2012 Digia Plc | ||||
** All rights reserved. | ||||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
sauimone
|
r159 | #ifndef BARCHARTMODEL_H | ||
#define BARCHARTMODEL_H | ||||
#include <QObject> | ||||
sauimone
|
r377 | #include <QStringList> | ||
sauimone
|
r161 | #include "qchartglobal.h" | ||
sauimone
|
r380 | #include <qseries.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
|
r776 | void appendBarSet(QBarSet *set); | ||
sauimone
|
r173 | void removeBarSet(QBarSet *set); | ||
Marek Rosa
|
r662 | void insertBarSet(int i, QBarSet *set); | ||
void insertCategory(int i, QString category); | ||||
Marek Rosa
|
r663 | void removeCategory(int i); | ||
sauimone
|
r776 | QBarSet *barsetAt(int index) const; | ||
QList<QBarSet *> barSets() const; | ||||
sauimone
|
r357 | |||
sauimone
|
r776 | int barsetCount() const; // Number of sets in model | ||
int categoryCount() const; // Number of categories | ||||
sauimone
|
r159 | |||
sauimone
|
r776 | qreal max() const; // Maximum value of all sets | ||
qreal min() const; // Minimum value of all sets | ||||
qreal valueAt(int set, int category) const; | ||||
qreal percentageAt(int set, int category) const; | ||||
sauimone
|
r159 | |||
sauimone
|
r776 | qreal categorySum(int category) const; | ||
sauimone
|
r850 | qreal absoluteCategorySum(int category) const; | ||
sauimone
|
r776 | qreal maxCategorySum() const; // returns maximum sum of sets in all categories. | ||
sauimone
|
r161 | |||
sauimone
|
r412 | QString categoryName(int category); | ||
sauimone
|
r172 | |||
sauimone
|
r775 | Q_SIGNALS: | ||
sauimone
|
r159 | void modelUpdated(); | ||
sauimone
|
r775 | public Q_SLOTS: | ||
sauimone
|
r159 | |||
private: | ||||
sauimone
|
r763 | QList<QBarSet *> m_dataModel; | ||
QStringList m_category; | ||||
sauimone
|
r159 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
#endif // BARCHARTMODEL_H | ||||