##// END OF EJS Templates
Improves build configuration...
Improves build configuration * adds local_build config option * adds developer_build config option * reanmes config files * removes debug stuff * fixes headers issues

File last commit:

r995:d52b7de4b911
r996:ce5f1c868418
Show More
qbarseries.cpp
456 lines | 12.7 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
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
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 #include "qbarseries.h"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "qbarseries_p.h"
sauimone
removed barchartseriesbase. functionality is now in model
r172 #include "qbarset.h"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "qbarset_p.h"
sauimone
removed barchartseriesbase. functionality is now in model
r172 #include "barchartmodel_p.h"
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 #include "domain_p.h"
Michal Klocek
Adds qlegend pimpl...
r950 #include "legendmarker_p.h"
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 #include "chartdataset_p.h"
#include "charttheme_p.h"
#include "chartanimator_p.h"
Michal Klocek
Adds big fat pimpl to series classes...
r938
Marek Rosa
Fixed: QAbstractItemModel could be forward declaration
r862 #include <QAbstractItemModel>
Marek Rosa
BarSeries - renamed internal model getter to modelInternal. Some smaller changes to other files to have in headers forward declarations for model related members instead of include
r877 #include <QModelIndex>
sauimone
refactored barcharts. layout to derived classess other funtionality to base class
r126
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 QTCOMMERCIALCHART_BEGIN_NAMESPACE
sauimone
Documentation for bar charts
r313 /*!
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 \class QBarSeries
sauimone
Documentation for bar charts
r313 \brief part of QtCommercial chart API.
Tero Ahola
Documentation fixes....
r995 \mainclass
sauimone
Documentation for bar charts
r313
Michal Klocek
Krazy reported errors...
r974 QBarSeries represents a series of data shown as bars. One QBarSeries can contain multiple
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 QBarSet data sets. QBarSeries groups the data from sets to categories, which are defined
sauimone
replaced qbarcategory with qstringlist
r377 by QStringList.
sauimone
Documentation for bar charts
r313
Tero Ahola
Documentation fixes....
r995 See the \l {BarChart Example} {bar chart example} to learn how to create a simple bar chart.
\image examples_barchart.png
sauimone
Updated barchart documentation
r319
sauimone
replaced qbarcategory with qstringlist
r377 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
sauimone
Documentation for bar charts
r313 */
/*!
Tero Ahola
Updated documentation, warnings from legend and area left
r973 \fn void QBarSeries::clicked(QBarSet *barset, QString category, Qt::MouseButtons button)
The signal is emitted if the user clicks with a mouse \a button on top of QBarSet \a barset of category \a category
contained by the series.
*/
/*!
\fn void QBarSeries::selected()
The signal is emitted if the user selects/deselects the series. The logic for storing selections should be
implemented by the user of QBarSeries API.
sauimone
Documentation for bar charts
r313 */
sauimone
barchart: doc update for hover signals
r980 /*!
\fn void QBarSeries::hovered(QBarSet* barset, bool status)
The signal is emitted if mouse is hovered on top of series.
Parameter \a barset is the pointer of barset, where hover happened.
Parameter \a status is true, if mouse entered on top of series, false if mouse left from top of series.
*/
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart examples and documentation. Also bug fix to barchart model
r387 Constructs empty QBarSeries. Parameter \a categories defines the categories for chart.
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 QBarSeries is QObject which is a child of a \a parent.
sauimone
Documentation for bar charts
r313 */
Tero Ahola
Updated documentation, warnings from legend and area left
r973 QBarSeries::QBarSeries(QBarCategories categories, QObject *parent) :
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QAbstractSeries(*new QBarSeriesPrivate(categories, this),parent)
Michal Klocek
Adds big fat pimpl to series classes...
r938 {
}
sauimone
barchart: doc update for hover signals
r980 /*!
Destructs barseries and owned barsets.
*/
QBarSeries::~QBarSeries()
{
// NOTE: d_ptr destroyed by QObject
}
Tero Ahola
Updated documentation, warnings from legend and area left
r973 /*!
\internal
*/
QBarSeries::QBarSeries(QBarSeriesPrivate &d, QObject *parent) :
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QAbstractSeries(d,parent)
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 {
}
sauimone
barchart: doc update for hover signals
r980 /*!
Returns the type of series. Derived classes override this.
*/
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QAbstractSeries::QSeriesType QBarSeries::type() const
sauimone
Improved bar chart series
r71 {
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 return QAbstractSeries::SeriesTypeBar;
sauimone
Improved bar chart series
r71 }
sauimone
Documentation for bar charts
r313 /*!
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 Adds a set of bars to series. Takes ownership of \a set.
sauimone
combined clicked and rightclicked signals in barchart
r812 Connects the clicked(QString, Qt::MouseButtons) signal
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 of \a set to this series
sauimone
Documentation for bar charts
r313 */
sauimone
const to getters, renamed addBarset to appendBarset
r776 void QBarSeries::appendBarSet(QBarSet *set)
sauimone
Barset and barcategory implememtation. Updated test application
r171 {
sauimone
barchart pimpl part 1
r934 Q_D(QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938 d->m_internalModel->appendBarSet(set);
QObject::connect(set->d_ptr.data(), SIGNAL(valueChanged()), d, SLOT(barsetChanged()));
emit d->restructuredBars();
sauimone
Barset and barcategory implememtation. Updated test application
r171 }
sauimone
Documentation for bar charts
r313 /*!
Michal Klocek
Krazy reported errors...
r974 Removes a set of bars from series. Releases ownership of \a set. Doesn't delete \a set.
sauimone
combined clicked and rightclicked signals in barchart
r812 Disconnects the clicked(QString, Qt::MouseButtons) signal
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 of \a set from this series
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 void QBarSeries::removeBarSet(QBarSet *set)
sauimone
Barset and barcategory implememtation. Updated test application
r171 {
sauimone
barchart pimpl part 1
r934 Q_D(QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938 d->m_internalModel->removeBarSet(set);
emit d->restructuredBars();
sauimone
percent barchart layout fix. signal fix
r850 }
/*!
Adds a list of barsets to series. Takes ownership of \a sets.
Connects the clicked(QString, Qt::MouseButtons) signals
of \a sets to this series
*/
void QBarSeries::appendBarSets(QList<QBarSet* > sets)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSeries);
sauimone
percent barchart layout fix. signal fix
r850 foreach (QBarSet* barset, sets) {
Michal Klocek
Adds big fat pimpl to series classes...
r938 d->m_internalModel->appendBarSet(barset);
QObject::connect(barset, SIGNAL(valueChanged()), this, SLOT(barsetChanged()));
sauimone
percent barchart layout fix. signal fix
r850 }
Michal Klocek
Adds big fat pimpl to series classes...
r938 emit d->restructuredBars();
sauimone
percent barchart layout fix. signal fix
r850 }
/*!
Michal Klocek
Krazy reported errors...
r974 Removes a list of barsets from series. Releases ownership of \a sets. Doesn't delete \a sets.
sauimone
percent barchart layout fix. signal fix
r850 Disconnects the clicked(QString, Qt::MouseButtons) signal
of \a sets from this series
*/
void QBarSeries::removeBarSets(QList<QBarSet* > sets)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938
sauimone
percent barchart layout fix. signal fix
r850 foreach (QBarSet* barset, sets) {
Michal Klocek
Adds big fat pimpl to series classes...
r938 d->m_internalModel->removeBarSet(barset);
sauimone
percent barchart layout fix. signal fix
r850 }
Michal Klocek
Adds big fat pimpl to series classes...
r938 emit d->restructuredBars();
sauimone
removed barchartseriesbase. functionality is now in model
r172 }
Marek Rosa
Updated spline chart example documentation and added some more docs to barseries
r901 /*!
Inserts new \a set on the \a i position.
The barset that is currently at this postion is moved to postion i + 1
*/
Marek Rosa
Adding data to BarSet through model added
r662 void QBarSeries::insertBarSet(int i, QBarSet *set)
{
sauimone
barchart pimpl part 1
r934 Q_D(QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938 d->m_internalModel->insertBarSet(i, set);
emit d->barsetChanged();
Marek Rosa
Adding data to BarSet through model added
r662 }
sauimone
Documentation for bar charts
r313 /*!
Returns number of sets in series.
*/
sauimone
const to getters, renamed addBarset to appendBarset
r776 int QBarSeries::barsetCount() const
sauimone
Added pen & brush to QBarSet
r214 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938 return d->m_internalModel->barsetCount();
sauimone
Added pen & brush to QBarSet
r214 }
sauimone
exposing countcategories to user from barchartseries
r323 /*!
Returns number of categories in series
*/
sauimone
const to getters, renamed addBarset to appendBarset
r776 int QBarSeries::categoryCount() const
sauimone
exposing countcategories to user from barchartseries
r323 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938 return d->m_internalModel->categoryCount();
sauimone
exposing countcategories to user from barchartseries
r323 }
sauimone
Documentation for bar charts
r313 /*!
sauimone
review fix: Removed iterator from barseries. Remove const from brush and pen. Renamed setters for tooltip, floating values and separators
r357 Returns a list of sets in series. Keeps ownership of sets.
*/
sauimone
const to getters, renamed addBarset to appendBarset
r776 QList<QBarSet*> QBarSeries::barSets() const
sauimone
Added pen & brush to QBarSet
r214 {
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938 return d->m_internalModel->barSets();
sauimone
Added pen & brush to QBarSet
r214 }
Marek Rosa
Removed few commeneted out lines and documented few funtions
r879 /*!
\fn bool QBarSeries::setModel(QAbstractItemModel *model)
Sets the \a model to be used as a data source
*/
Tero Ahola
Code review: Fixed simple issues in Bar and Legend
r737 bool QBarSeries::setModel(QAbstractItemModel *model)
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 {
sauimone
barchart pimpl part 1
r934 Q_D(QBarSeries);
return d->setModel(model);
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 }
Marek Rosa
Added documentation for model related funtions
r900 /*!
\fn bool QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation)
Sets column/row specified by \a categories to be used as a list of bar series categories.
Parameter \a bottomBoundry indicates the column/row where the first bar set is located in the model.
Parameter \a topBoundry indicates the column/row where the last bar set is located in the model.
All the columns/rows inbetween those two values are also used as data for bar sets.
Michal Klocek
Krazy reported errors...
r974 The \a orientation parameter specifies whether the data is in columns or in rows.
Marek Rosa
Added documentation for model related funtions
r900 */
sauimone
barchart pimpl part 1
r934 void QBarSeries::setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation)
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 {
sauimone
barchart pimpl part 1
r934 Q_D(QBarSeries);
d->setModelMapping(categories,bottomBoundary,topBoundary,orientation);
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 }
Tero Ahola
Updated documentation, warnings from legend and area left
r973 /*!
Returns the bar categories of the series.
*/
Michal Klocek
Adds BarCategories typedef
r703 QBarCategories QBarSeries::categories() const
{
sauimone
barchart pimpl part 1
r934 Q_D(const QBarSeries);
Michal Klocek
Adds big fat pimpl to series classes...
r938
Michal Klocek
Adds BarCategories typedef
r703 QBarCategories categories;
Michal Klocek
Adds big fat pimpl to series classes...
r938 int count = d->m_internalModel->categoryCount();
Tero Ahola
Code review: Fixed simple issues in Bar and Legend
r737 for (int i=1; i <= count; i++) {
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 categories.insert(i, d->m_internalModel->categoryName(i - 1));
Michal Klocek
Adds BarCategories typedef
r703 }
return categories;
Michal Klocek
Adds big fat pimpl to series classes...
r938
Michal Klocek
Adds BarCategories typedef
r703 }
sauimone
fixed clipping in barcharts
r839 /*!
Sets the visibility of labels in series to \a visible
*/
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 void QBarSeries::setLabelsVisible(bool visible)
sauimone
values visibility handling changed in barchart
r813 {
foreach (QBarSet* s, barSets()) {
sauimone
renamed barchart floating values with labels to be consistent with piechart
r820 s->setLabelsVisible(visible);
sauimone
values visibility handling changed in barchart
r813 }
}
Michal Klocek
Adds big fat pimpl to series classes...
r938 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Tero Ahola
Renamed QSeries to QAbstractSeries
r988 QBarSeriesPrivate::QBarSeriesPrivate(QBarCategories categories, QBarSeries *q) :
QAbstractSeriesPrivate(q),
Michal Klocek
Adds big fat pimpl to series classes...
r938 m_internalModel(new BarChartModel(categories,this)),
m_model(0),
m_mapCategories(-1),
m_mapBarBottom(-1),
m_mapBarTop(-1),
m_mapOrientation(Qt::Vertical)
{
}
QBarSet* QBarSeriesPrivate::barsetAt(int index)
{
return m_internalModel->barsetAt(index);
}
QString QBarSeriesPrivate::categoryName(int category)
{
return m_internalModel->categoryName(category);
}
qreal QBarSeriesPrivate::min()
{
return m_internalModel->min();
}
qreal QBarSeriesPrivate::max()
{
return m_internalModel->max();
}
qreal QBarSeriesPrivate::valueAt(int set, int category)
{
return m_internalModel->valueAt(set, category);
}
qreal QBarSeriesPrivate::percentageAt(int set, int category)
{
return m_internalModel->percentageAt(set, category);
}
qreal QBarSeriesPrivate::categorySum(int category)
{
return m_internalModel->categorySum(category);
}
qreal QBarSeriesPrivate::absoluteCategorySum(int category)
{
return m_internalModel->absoluteCategorySum(category);
}
qreal QBarSeriesPrivate::maxCategorySum()
{
return m_internalModel->maxCategorySum();
}
BarChartModel& QBarSeriesPrivate::modelInternal()
{
return *m_internalModel;
}
bool QBarSeriesPrivate::setModel(QAbstractItemModel *model)
{
// disconnect signals from old model
if(m_model)
{
disconnect(m_model, 0, this, 0);
m_mapCategories = -1;
m_mapBarBottom = -1;
m_mapBarTop = -1;
m_mapOrientation = Qt::Vertical;
}
// set new model
if(model)
{
m_model = model;
return true;
}
else
{
m_model = 0;
return false;
}
}
void QBarSeriesPrivate::setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation)
{
Q_Q(QBarSeries);
Marek Rosa
Removed gdpbarchart from demos docs
r947 if (m_model == 0)
Michal Klocek
Adds big fat pimpl to series classes...
r938 return;
m_mapCategories = categories;
m_mapBarBottom = bottomBoundry;
m_mapBarTop = topBoundry;
m_mapOrientation = orientation;
// connect the signals
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(modelUpdated(QModelIndex,QModelIndex)));
Michal Klocek
Adds big fat pimpl to series classes...
r938
// create the initial bars
delete m_internalModel;
if (m_mapOrientation == Qt::Vertical) {
QStringList categories;
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 for (int k = 0; k < m_model->rowCount(); k++)
Michal Klocek
Adds big fat pimpl to series classes...
r938 categories << m_model->data(m_model->index(k, m_mapCategories), Qt::DisplayRole).toString();
m_internalModel = new BarChartModel(categories, this);
for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) {
QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1));
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 for(int m = 0; m < m_model->rowCount(); m++)
Michal Klocek
Adds big fat pimpl to series classes...
r938 *barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble();
q->appendBarSet(barSet);
}
} else {
QStringList categories;
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 for (int k = 0; k < m_model->columnCount(); k++)
Michal Klocek
Adds big fat pimpl to series classes...
r938 categories << m_model->data(m_model->index(m_mapCategories, k), Qt::DisplayRole).toString();
m_internalModel = new BarChartModel(categories, this);
for (int i = m_mapBarBottom; i <= m_mapBarTop; i++) {
QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1));
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 for(int m = 0; m < m_model->columnCount(); m++)
Michal Klocek
Adds big fat pimpl to series classes...
r938 *barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble();
q->appendBarSet(barSet);
}
}
}
void QBarSeriesPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
{
Q_UNUSED(bottomRight)
if (m_mapOrientation == Qt::Vertical)
{
// model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 if (topLeft.column() >= m_mapBarBottom && topLeft.column() <= m_mapBarTop)
sauimone
barset: unified insert/set/remove methods
r993 barsetAt(topLeft.column() - m_mapBarBottom)->replace(topLeft.row(), m_model->data(topLeft, Qt::DisplayRole).toDouble());
Michal Klocek
Adds big fat pimpl to series classes...
r938 }
else
{
// model update is relevant to BarSeries if the change was made to the part of the model that was mapped to BarSeries
Marek Rosa
Removed all the unfinished model functionality from XYSeries and BarSeries
r990 if (topLeft.row() >= m_mapBarBottom && topLeft.row() <= m_mapBarTop)
sauimone
barset: unified insert/set/remove methods
r993 barsetAt(topLeft.row() - m_mapBarBottom)->replace(topLeft.column(), m_model->data(topLeft, Qt::DisplayRole).toDouble());
Michal Klocek
Adds big fat pimpl to series classes...
r938 }
}
void QBarSeriesPrivate::barsetChanged()
{
emit updatedBars();
}
sauimone
values visibility handling changed in barchart
r813
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 void QBarSeriesPrivate::scaleDomain(Domain& domain)
{
qreal minX(domain.minX());
qreal minY(domain.minY());
qreal maxX(domain.maxX());
qreal maxY(domain.maxY());
int tickXCount(domain.tickXCount());
int tickYCount(domain.tickYCount());
sauimone
barchart PIMPL part 2. Cleaning up leftovers in public api
r962 qreal x = m_internalModel->categoryCount();
qreal y = max();
Michal Klocek
Refactor to use qseries private for implmentation interface...
r943 minX = qMin(minX, x);
minY = qMin(minY, y);
maxX = qMax(maxX, x);
maxY = qMax(maxY, y);
tickXCount = x+1;
domain.setRangeX(minX,maxX,tickXCount);
domain.setRangeY(minY,maxY,tickYCount);
}
Chart* QBarSeriesPrivate::createGraphics(ChartPresenter* presenter)
{
Q_Q(QBarSeries);
BarChartItem* bar = new BarChartItem(q,presenter);
if(presenter->animationOptions().testFlag(QChart::SeriesAnimations)) {
presenter->animator()->addAnimation(bar);
}
presenter->chartTheme()->decorate(q, presenter->dataSet()->seriesIndex(q));
return bar;
}
Michal Klocek
Adds qlegend pimpl...
r950 QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend)
{
Q_Q(QBarSeries);
QList<LegendMarker*> markers;
foreach(QBarSet* set, q->barSets()) {
BarLegendMarker* marker = new BarLegendMarker(q,set,legend);
markers << marker;
}
return markers;
}
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 #include "moc_qbarseries.cpp"
Michal Klocek
Adds big fat pimpl to series classes...
r938 #include "moc_qbarseries_p.cpp"
sauimone
Improved bar chart series
r71
sauimone
Integrating bar chart. Cleaned up old implementation. TODO: show this in test application. how?
r56 QTCOMMERCIALCHART_END_NAMESPACE