qbarseries.h
97 lines
| 2.9 KiB
| text/x-c
|
CLexer
sauimone
|
r338 | #ifndef BARSERIES_H | ||
#define BARSERIES_H | ||||
sauimone
|
r56 | |||
Jani Honkonen
|
r697 | #include <qseries.h> | ||
sauimone
|
r377 | #include <QStringList> | ||
sauimone
|
r74 | |||
sauimone
|
r56 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | ||
Michal Klocek
|
r703 | typedef QStringList QBarCategories; | ||
Michal Klocek
|
r701 | |||
sauimone
|
r172 | class QBarSet; | ||
class BarChartModel; | ||||
sauimone
|
r412 | class BarCategory; | ||
sauimone
|
r172 | |||
sauimone
|
r56 | // Container for series | ||
Michal Klocek
|
r360 | class QTCOMMERCIALCHART_EXPORT QBarSeries : public QSeries | ||
sauimone
|
r56 | { | ||
sauimone
|
r71 | Q_OBJECT | ||
sauimone
|
r56 | public: | ||
Tero Ahola
|
r737 | QBarSeries(QStringList categories, QObject *parent = 0); | ||
sauimone
|
r56 | |||
Michal Klocek
|
r360 | virtual QSeriesType type() const { return QSeries::SeriesTypeBar; } | ||
sauimone
|
r56 | |||
sauimone
|
r280 | void addBarSet(QBarSet *set); // Takes ownership of set | ||
void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | ||||
Marek Rosa
|
r662 | void insertBarSet(int i, QBarSet *set); | ||
void insertCategory(int i, QString category); | ||||
Marek Rosa
|
r663 | void removeCategory(int i); | ||
sauimone
|
r366 | int barsetCount(); | ||
int categoryCount(); | ||||
sauimone
|
r357 | QList<QBarSet*> barSets(); | ||
Michal Klocek
|
r703 | QBarCategories categories() const; | ||
Tero Ahola
|
r737 | bool setModel(QAbstractItemModel *model); | ||
QAbstractItemModel *modelExt() { return m_model; } | ||||
Marek Rosa
|
r630 | void setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation = Qt::Vertical); | ||
Marek Rosa
|
r734 | void setModelMappingShift(int first, int count); | ||
Marek Rosa
|
r527 | |||
sauimone
|
r288 | public: | ||
sauimone
|
r173 | // TODO: Functions below this are not part of api and will be moved | ||
sauimone
|
r296 | // to private implementation, when we start using it | ||
// TODO: TO PIMPL ---> | ||||
sauimone
|
r412 | QBarSet* barsetAt(int index); | ||
QString categoryName(int category); | ||||
sauimone
|
r172 | qreal min(); | ||
qreal max(); | ||||
qreal valueAt(int set, int category); | ||||
sauimone
|
r288 | qreal percentageAt(int set, int category); | ||
qreal categorySum(int category); | ||||
sauimone
|
r172 | qreal maxCategorySum(); | ||
BarChartModel& model(); | ||||
sauimone
|
r296 | // <--- TO PIMPL | ||
sauimone
|
r172 | |||
signals: | ||||
sauimone
|
r425 | //void changed(int index); | ||
Tero Ahola
|
r737 | void clicked(QBarSet *barset, QString category); // Up to user of api, what to do with these signals | ||
void rightClicked(QBarSet *barset, QString category); | ||||
sauimone
|
r172 | |||
Marek Rosa
|
r655 | // | ||
void updatedBars(); | ||||
Marek Rosa
|
r662 | void restructuredBar(int); | ||
Marek Rosa
|
r655 | |||
sauimone
|
r288 | // TODO: internal signals, these to private implementation. | ||
sauimone
|
r296 | // TODO: TO PIMPL ---> | ||
sauimone
|
r288 | void showToolTip(QPoint pos, QString tip); | ||
sauimone
|
r296 | // <--- TO PIMPL | ||
public Q_SLOTS: | ||||
Tero Ahola
|
r737 | void setToolTipEnabled(bool enabled = true); // enables tooltips | ||
sauimone
|
r171 | |||
sauimone
|
r425 | // TODO: TO PIMPL ---> | ||
void barsetClicked(QString category); | ||||
void barsetRightClicked(QString category); | ||||
// <--- TO PIMPL | ||||
Marek Rosa
|
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(); | ||||
sauimone
|
r281 | protected: | ||
sauimone
|
r766 | BarChartModel *m_internalModel; // TODO: this may change... current "2 models" situation doesn't look good. | ||
Marek Rosa
|
r527 | |||
sauimone
|
r763 | QAbstractItemModel* m_model; | ||
Marek Rosa
|
r527 | int m_mapCategories; | ||
int m_mapBarBottom; | ||||
int m_mapBarTop; | ||||
Marek Rosa
|
r734 | int m_mapFirst; | ||
int m_mapCount; | ||||
Marek Rosa
|
r630 | Qt::Orientation m_mapOrientation; | ||
sauimone
|
r56 | }; | ||
QTCOMMERCIALCHART_END_NAMESPACE | ||||
sauimone
|
r338 | #endif // BARSERIES_H | ||