qbarseries.h
87 lines
| 2.5 KiB
| text/x-c
|
CLexer
|
r338 | #ifndef BARSERIES_H | ||
#define BARSERIES_H | ||||
|
r56 | |||
|
r360 | #include "qseries.h" | ||
|
r377 | #include <QStringList> | ||
|
r74 | |||
|
r56 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
|
r172 | class QBarSet; | ||
class BarChartModel; | ||||
|
r412 | class BarCategory; | ||
|
r172 | |||
|
r56 | // Container for series | ||
|
r360 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries | ||
|
r56 | { | ||
|
r71 | Q_OBJECT | ||
|
r56 | public: | ||
|
r377 | QBarSeries(QStringList categories, QObject* parent=0); | ||
|
r56 | |||
|
r360 | virtual QSeriesType type() const { return QSeries::SeriesTypeBar; } | ||
|
r56 | |||
|
r280 | void addBarSet(QBarSet *set); // Takes ownership of set | ||
void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | ||||
|
r366 | int barsetCount(); | ||
int categoryCount(); | ||||
|
r357 | QList<QBarSet*> barSets(); | ||
|
r280 | |||
|
r527 | bool setModel(QAbstractItemModel* model); | ||
QAbstractItemModel* modelExt() {return m_model;} | ||||
|
r630 | void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical); | ||
|
r527 | |||
|
r288 | public: | ||
|
r173 | // TODO: Functions below this are not part of api and will be moved | ||
|
r296 | // to private implementation, when we start using it | ||
// TODO: TO PIMPL ---> | ||||
|
r412 | QBarSet* barsetAt(int index); | ||
QString categoryName(int category); | ||||
|
r172 | qreal min(); | ||
qreal max(); | ||||
qreal valueAt(int set, int category); | ||||
|
r288 | qreal percentageAt(int set, int category); | ||
qreal categorySum(int category); | ||||
|
r172 | qreal maxCategorySum(); | ||
BarChartModel& model(); | ||||
|
r296 | // <--- TO PIMPL | ||
|
r172 | |||
signals: | ||||
|
r425 | //void changed(int index); | ||
void clicked(QBarSet* barset, QString category); // Up to user of api, what to do with these signals | ||||
void rightClicked(QBarSet* barset, QString category); | ||||
|
r172 | |||
|
r655 | // | ||
void updatedBars(); | ||||
|
r288 | // TODO: internal signals, these to private implementation. | ||
|
r296 | // TODO: TO PIMPL ---> | ||
|
r288 | void showToolTip(QPoint pos, QString tip); | ||
|
r296 | // <--- TO PIMPL | ||
public Q_SLOTS: | ||||
|
r357 | void setToolTipEnabled(bool enabled=true); // enables tooltips | ||
|
r171 | |||
|
r425 | // TODO: TO PIMPL ---> | ||
void barsetClicked(QString category); | ||||
void barsetRightClicked(QString category); | ||||
// <--- TO PIMPL | ||||
|
r630 | private Q_SLOTS: | ||
// slots for updating bars when data in model changes | ||||
void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight); | ||||
void modelDataAdded(QModelIndex parent, int start, int end); | ||||
void modelDataRemoved(QModelIndex parent, int start, int end); | ||||
void barsetChanged(); | ||||
|
r281 | protected: | ||
|
r172 | BarChartModel* mModel; | ||
|
r527 | |||
|
r655 | // QAbstractItemModel* m_model; | ||
|
r527 | int m_mapCategories; | ||
int m_mapBarBottom; | ||||
int m_mapBarTop; | ||||
|
r630 | Qt::Orientation m_mapOrientation; | ||
|
r56 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
|
r338 | #endif // BARSERIES_H | ||