##// END OF EJS Templates
Bugfix: chart scrolling effect on OSX
Bugfix: chart scrolling effect on OSX

File last commit:

r663:9af75e8e0281
r665:39ddc1d3b915
Show More
qbarseries.cpp
368 lines | 9.7 KiB | text/x-c | CppLexer
sauimone
Improved bar chart series
r71 #include <QDebug>
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 #include "qbarseries.h"
sauimone
removed barchartseriesbase. functionality is now in model
r172 #include "qbarset.h"
#include "barchartmodel_p.h"
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.
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 QBarSeries represents a series of data shown as bars. One QBarSeries can contain multible
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
sauimone
Updated barchart documentation
r319 \mainclass
sauimone
replaced qbarcategory with qstringlist
r377 \sa QBarSet, QStackedBarSeries, QPercentBarSeries
sauimone
Documentation for bar charts
r313 */
/*!
Michal Klocek
Rename QChartSeries to QSeries
r360 \fn virtual QSeriesType QBarSeries::type() const
sauimone
Documentation for bar charts
r313 \brief Returns type of series.
Michal Klocek
Rename QChartSeries to QSeries
r360 \sa QSeries, QSeriesType
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
sauimone
Documentation for bar charts
r313 /*!
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 \fn void QBarSeries::showToolTip(QPoint pos, QString tip)
sauimone
Updated barchart documentation
r319 \brief \internal \a pos \a tip
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 */
sauimone
replaced qbarcategory with qstringlist
r377 QBarSeries::QBarSeries(QStringList categories, QObject *parent)
Michal Klocek
Rename QChartSeries to QSeries
r360 : QSeries(parent)
sauimone
replaced qbarcategory with qstringlist
r377 ,mModel(new BarChartModel(categories, this))
sauimone
Improved bar chart series
r71 {
Marek Rosa
QBar series: Model related members initializations added to constructor
r528 m_model = NULL;
m_mapCategories = -1;
Jani Honkonen
We have so many stupid warnings that "treat warnings as errors" flag is needed...
r609 m_mapBarBottom = -1;
m_mapBarTop = -1;
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 m_mapOrientation = Qt::Vertical;
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.
Connects the clicked(QString) and rightClicked(QString) signals
of \a set to this series
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 void QBarSeries::addBarSet(QBarSet *set)
sauimone
Barset and barcategory implememtation. Updated test application
r171 {
sauimone
removed barchartseriesbase. functionality is now in model
r172 mModel->addBarSet(set);
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 connect(set,SIGNAL(clicked(QString)),this,SLOT(barsetClicked(QString)));
connect(set,SIGNAL(rightClicked(QString)),this,SLOT(barsetRightClicked(QString)));
Marek Rosa
Barchart updates on BarSet->SetValue now
r655 connect(set, SIGNAL(valueChanged()), this, SLOT(barsetChanged()));
sauimone
Barset and barcategory implememtation. Updated test application
r171 }
sauimone
Documentation for bar charts
r313 /*!
Removes a set of bars from series. Releases ownership of \a set. Doesnt delete \a set.
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 Disconnects the clicked(QString) and rightClicked(QString) signals
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
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425 disconnect(set,SIGNAL(clicked(QString)),this,SLOT(barsetClicked(QString)));
disconnect(set,SIGNAL(rightClicked(QString)),this,SLOT(barsetRightClicked(QString)));
sauimone
removed barchartseriesbase. functionality is now in model
r172 mModel->removeBarSet(set);
}
Marek Rosa
Adding data to BarSet through model added
r662 void QBarSeries::insertBarSet(int i, QBarSet *set)
{
mModel->insertBarSet(i, set);
// emit barsetChanged();
}
void QBarSeries::insertCategory(int i, QString category)
{
mModel->insertCategory(i, category);
}
Marek Rosa
Removing data from BarSeries through model added
r663 void QBarSeries::removeCategory(int i)
{
mModel->removeCategory(i);
}
sauimone
Documentation for bar charts
r313 /*!
Returns number of sets in series.
*/
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 int QBarSeries::barsetCount()
sauimone
Added pen & brush to QBarSet
r214 {
Marek Rosa
Adding data to BarSet through model added
r662 // if(m_model)
// return m_mapBarTop - m_mapBarBottom;
// else
return mModel->barsetCount();
sauimone
Added pen & brush to QBarSet
r214 }
sauimone
exposing countcategories to user from barchartseries
r323 /*!
Returns number of categories in series
*/
sauimone
review fixes. countCategories() -> categoryCount(). countSets -> barsetCount()
r366 int QBarSeries::categoryCount()
sauimone
exposing countcategories to user from barchartseries
r323 {
sauimone
Updated barchart examples and documentation. Also bug fix to barchart model
r387 return mModel->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.
*/
QList<QBarSet*> QBarSeries::barSets()
sauimone
Added pen & brush to QBarSet
r214 {
sauimone
review fix: Removed iterator from barseries. Remove const from brush and pen. Renamed setters for tooltip, floating values and separators
r357 return mModel->barSets();
sauimone
Added pen & brush to QBarSet
r214 }
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 \internal \a index
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 QBarSet* QBarSeries::barsetAt(int index)
sauimone
moved tooltip to presenter
r288 {
return mModel->setAt(index);
}
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal \a category
sauimone
Documentation for bar charts
r313 */
sauimone
right click feature for bar series. Enables drilldown
r412 QString QBarSeries::categoryName(int category)
sauimone
moved tooltip to presenter
r288 {
sauimone
right click feature for bar series. Enables drilldown
r412 return mModel->categoryName(category);
sauimone
moved tooltip to presenter
r288 }
sauimone
Documentation for bar charts
r313 /*!
Enables or disables tooltip depending on parameter \a enabled.
Tooltip shows the name of set, when mouse is hovering on top of bar.
Calling without parameter \a enabled, enables the tooltip
*/
sauimone
review fix: Removed iterator from barseries. Remove const from brush and pen. Renamed setters for tooltip, floating values and separators
r357 void QBarSeries::setToolTipEnabled(bool enabled)
sauimone
barcharts: added legend to model. added signals for hover events (for tooltip). updated examples
r280 {
sauimone
Labels for barchart to axis
r487 // TODO: what if we add sets after call to this function? Those sets won't have tooltip enabled.
sauimone
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code
r296 if (enabled) {
sauimone
Updated barchart examples and documentation. Also bug fix to barchart model
r387 for (int i=0; i<mModel->barsetCount(); i++) {
sauimone
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code
r296 QBarSet *set = mModel->setAt(i);
connect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString)));
}
} else {
sauimone
Updated barchart examples and documentation. Also bug fix to barchart model
r387 for (int i=0; i<mModel->barsetCount(); i++) {
sauimone
enablers for tooltip and floating values, bug fixing, updated examples. tidying up the code
r296 QBarSet *set = mModel->setAt(i);
disconnect(set,SIGNAL(showToolTip(QPoint,QString)),this,SIGNAL(showToolTip(QPoint,QString)));
}
}
sauimone
moved tooltip to presenter
r288 }
sauimone
Better way to enable features to user. Do less, but expose signals to user and allow user to descide what to do.
r425
/*!
\internal \a category
*/
void QBarSeries::barsetClicked(QString category)
{
emit clicked(qobject_cast<QBarSet*>(sender()), category);
}
/*!
\internal \a category
*/
void QBarSeries::barsetRightClicked(QString category)
{
emit rightClicked(qobject_cast<QBarSet*>(sender()), category);
}
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 qreal QBarSeries::min()
sauimone
removed barchartseriesbase. functionality is now in model
r172 {
return mModel->min();
}
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 qreal QBarSeries::max()
sauimone
removed barchartseriesbase. functionality is now in model
r172 {
return mModel->max();
sauimone
Barset and barcategory implememtation. Updated test application
r171 }
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal \a set \a category
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 qreal QBarSeries::valueAt(int set, int category)
sauimone
removed barchartseriesbase. functionality is now in model
r172 {
return mModel->valueAt(set,category);
}
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal \a set \a category
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 qreal QBarSeries::percentageAt(int set, int category)
sauimone
moved tooltip to presenter
r288 {
return mModel->percentageAt(set,category);
}
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal \a category
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 qreal QBarSeries::categorySum(int category)
sauimone
moved tooltip to presenter
r288 {
return mModel->categorySum(category);
}
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 qreal QBarSeries::maxCategorySum()
sauimone
removed barchartseriesbase. functionality is now in model
r172 {
return mModel->maxCategorySum();
}
sauimone
Documentation for bar charts
r313 /*!
sauimone
Updated barchart documentation
r319 \internal
sauimone
Documentation for bar charts
r313 */
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 BarChartModel& QBarSeries::model()
sauimone
removed barchartseriesbase. functionality is now in model
r172 {
return *mModel;
}
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 bool QBarSeries::setModel(QAbstractItemModel* model)
{
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 // 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 = NULL;
return false;
}
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 }
Tero Ahola
Squashed bunch of warnings
r611 // TODO
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 void QBarSeries::setModelMapping(int categories, int bottomBoundry, int topBoundry, Qt::Orientation orientation)
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 {
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 if (m_model == NULL)
return;
m_mapCategories = categories;
m_mapBarBottom = bottomBoundry;
m_mapBarTop = topBoundry;
m_mapOrientation = orientation;
// connect the signals
if (m_mapOrientation == Qt::Vertical)
{
connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
connect(m_model,SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
}
else
{
connect(m_model,SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(modelUpdated(QModelIndex, QModelIndex)));
connect(m_model,SIGNAL(columnsInserted(QModelIndex, int, int)), this, SLOT(modelDataAdded(QModelIndex,int,int)));
connect(m_model, SIGNAL(columnsRemoved(QModelIndex, int, int)), this, SLOT(modelDataRemoved(QModelIndex,int,int)));
}
// create the initial bars
delete mModel;
if (m_mapOrientation == Qt::Vertical)
{
QStringList categories;
Marek Rosa
Fixes to BarSeries model update function
r650 for (int k = 0; k < m_model->rowCount(); k++)
categories << m_model->data(m_model->index(k, m_mapCategories), Qt::DisplayRole).toString();
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 mModel = new BarChartModel(categories, this);
for (int i = m_mapBarBottom; i <= m_mapBarTop; i++)
{
Marek Rosa
Fixes to BarSeries model update function
r650 QBarSet* barSet = new QBarSet(QString("Column: %1").arg(i + 1));
for(int m = 0; m < m_model->rowCount(); m++)
*barSet << m_model->data(m_model->index(m, i), Qt::DisplayRole).toDouble();
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 addBarSet(barSet);
}
}
else
{
QStringList categories;
Marek Rosa
Fixes to BarSeries model update function
r650 for (int k = 0; k < m_model->columnCount(); k++)
categories << m_model->data(m_model->index(m_mapCategories, k), Qt::DisplayRole).toString();
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 mModel = new BarChartModel(categories, this);
for (int i = m_mapBarBottom; i <= m_mapBarTop; i++)
{
Marek Rosa
Fixes to BarSeries model update function
r650 QBarSet* barSet = new QBarSet(QString("Row: %1").arg(i + 1));
for(int m = 0; m < m_model->columnCount(); m++)
*barSet << m_model->data(m_model->index(i, m), Qt::DisplayRole).toDouble();
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 addBarSet(barSet);
}
}
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 }
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 void QBarSeries::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
{
Q_UNUSED(bottomRight)
if (m_mapOrientation == Qt::Vertical)
{
if (topLeft.column() >= m_mapBarBottom && topLeft.column() <= m_mapBarTop)
Marek Rosa
Fixes to BarSeries model update function
r650 barsetAt(topLeft.column() - m_mapBarBottom)->setValue(topLeft.row(), m_model->data(topLeft, Qt::DisplayRole).toDouble());
Marek Rosa
Adding data to BarSet through model added
r662 // else if (topLeft.column() == m_mapCategories)
// slices().at(topLeft.row())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 }
else
{
if (topLeft.row() >= m_mapBarBottom && topLeft.row() <= m_mapBarTop)
Marek Rosa
Fixes to BarSeries model update function
r650 barsetAt(topLeft.row() - m_mapBarBottom)->setValue(topLeft.column(), m_model->data(topLeft, Qt::DisplayRole).toDouble());
Marek Rosa
Adding data to BarSet through model added
r662 // else if (topLeft.row() == m_mapCategories)
// slices().at(topLeft.column())->setLabel(m_model->data(topLeft, Qt::DisplayRole).toString());
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 }
}
Marek Rosa
Adding data to BarSet through model added
r662 void QBarSeries::modelDataAdded(QModelIndex /*parent*/, int start, int /*end*/)
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 {
Marek Rosa
Adding data to BarSet through model added
r662 if (m_mapOrientation == Qt::Vertical)
{
insertCategory(start, QString("Row: %1").arg(start + 1));
for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++)
{
barsetAt(i)->insertValue(start, m_model->data(m_model->index(start, i), Qt::DisplayRole).toDouble());
}
}
else
{
insertCategory(start, QString("Column: %1").arg(start + 1));
for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++)
{
barsetAt(i)->insertValue(start, m_model->data(m_model->index(i, start), Qt::DisplayRole).toDouble());
}
}
emit restructuredBar(1);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 }
Marek Rosa
Removing data from BarSeries through model added
r663 void QBarSeries::modelDataRemoved(QModelIndex /*parent*/, int start, int /*end*/)
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 {
Marek Rosa
Removing data from BarSeries through model added
r663 removeCategory(start);
for (int i = 0; i <= m_mapBarTop - m_mapBarBottom; i++)
{
barsetAt(i)->removeValue(start);
}
emit restructuredBar(1);
Marek Rosa
Added support for data from model to QBarSeries. Various fixes and small modifications to data from model support to other series
r630 }
void QBarSeries::barsetChanged()
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 {
Marek Rosa
Barchart updates on BarSet->SetValue now
r655 emit updatedBars();
Marek Rosa
QXYSeries: model data orientation added. QBarSeries: some model data function placeholders
r527 }
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 #include "moc_qbarseries.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