##// END OF EJS Templates
Updated QML Weather and QML F1 legends pics
Updated QML Weather and QML F1 legends pics

File last commit:

r2151:cdaf9997827b
r2349:023e5d4ef689
Show More
qbarmodelmapper.cpp
561 lines | 17.3 KiB | text/x-c | CppLexer
/ src / barchart / qbarmodelmapper.cpp
Marek Rosa
Added license text to mapper classes
r1355 /****************************************************************************
**
** 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$
**
****************************************************************************/
Marek Rosa
BarSeries Model mapper added
r1170 #include "qbarmodelmapper.h"
Marek Rosa
BarModel mapper refactored.
r1293 #include "qbarmodelmapper_p.h"
sauimone
renamed barseries files to abstractbarseries
r1586 #include "qabstractbarseries.h"
Marek Rosa
BarModel mapper refactored.
r1293 #include "qbarset.h"
Marek Rosa
Added placeholders for mappers documentation
r1331 #include "qchart.h"
Marek Rosa
BarModel mapper refactored.
r1293 #include <QAbstractItemModel>
Marek Rosa
BarSeries Model mapper added
r1170
QTCOMMERCIALCHART_BEGIN_NAMESPACE
QBarModelMapper::QBarModelMapper(QObject *parent) :
QObject(parent),
Marek Rosa
BarModel mapper refactored.
r1293 d_ptr(new QBarModelMapperPrivate(this))
{
}
Jani Honkonen
more coding style fixes for src-folder...
r2104 QAbstractItemModel *QBarModelMapper::model() const
Marek Rosa
BarModel mapper refactored.
r1293 {
Q_D(const QBarModelMapper);
return d->m_model;
}
void QBarModelMapper::setModel(QAbstractItemModel *model)
{
if (model == 0)
return;
Q_D(QBarModelMapper);
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (d->m_model)
Marek Rosa
BarModel mapper refactored.
r1293 disconnect(d->m_model, 0, d, 0);
d->m_model = model;
d->initializeBarFromModel();
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 // connect signals from the model
Marek Rosa
BarModel mapper refactored.
r1293 connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
Marek Rosa
Added support for headerDataChanged() signal from the model to BarModelMapper
r1394 connect(d->m_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)), d, SLOT(modelHeaderDataUpdated(Qt::Orientation,int,int)));
Marek Rosa
BarModel mapper refactored.
r1293 connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int)));
connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
Marek Rosa
Model mappers now connected to series and model destroy signals
r1656 connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed()));
Marek Rosa
BarModel mapper refactored.
r1293 }
Jani Honkonen
more coding style fixes for src-folder...
r2104 QAbstractBarSeries *QBarModelMapper::series() const
Marek Rosa
BarModel mapper refactored.
r1293 {
Q_D(const QBarModelMapper);
return d->m_series;
}
sauimone
QBarSeries to QAbstractBarSeries
r1584 void QBarModelMapper::setSeries(QAbstractBarSeries *series)
Marek Rosa
BarSeries Model mapper added
r1170 {
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(QBarModelMapper);
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (d->m_series)
Marek Rosa
BarModel mapper refactored.
r1293 disconnect(d->m_series, 0, d, 0);
if (series == 0)
return;
d->m_series = series;
d->initializeBarFromModel();
// connect the signals from the series
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 connect(d->m_series, SIGNAL(barsetsAdded(QList<QBarSet*>)), d, SLOT(barSetsAdded(QList<QBarSet*>)));
connect(d->m_series, SIGNAL(barsetsRemoved(QList<QBarSet*>)), d, SLOT(barSetsRemoved(QList<QBarSet*>)));
Marek Rosa
Model mappers now connected to series and model destroy signals
r1656 connect(d->m_series, SIGNAL(destroyed()), d, SLOT(handleSeriesDestroyed()));
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 /*!
Returns which row/column of the model contains the first values of the QBarSets in the series.
The default value is 0.
*/
Marek Rosa
BarSeries Model mapper added
r1170 int QBarModelMapper::first() const
{
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(const QBarModelMapper);
return d->m_first;
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 /*!
Sets which row of the model contains the \a first values of the QBarSets in the series.
The default value is 0.
*/
Marek Rosa
BarSeries Model mapper added
r1170 void QBarModelMapper::setFirst(int first)
{
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(QBarModelMapper);
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 d->m_first = qMax(first, 0);
d->initializeBarFromModel();
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 /*!
sauimone
renamed barseries files to abstractbarseries
r1586 Returns the number of rows/columns of the model that are mapped as the data for QAbstractBarSeries
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 Minimal and default value is: -1 (count limited by the number of rows/columns in the model)
*/
Marek Rosa
BarSeries Model mapper added
r1170 int QBarModelMapper::count() const
{
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(const QBarModelMapper);
return d->m_count;
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 /*!
sauimone
renamed barseries files to abstractbarseries
r1586 Sets the \a count of rows/columns of the model that are mapped as the data for QAbstractBarSeries
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 Minimal and default value is: -1 (count limited by the number of rows/columns in the model)
*/
Marek Rosa
BarSeries Model mapper added
r1170 void QBarModelMapper::setCount(int count)
{
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(QBarModelMapper);
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 d->m_count = qMax(count, -1);
d->initializeBarFromModel();
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
Added documentation for BarModelMapper classes
r1348 /*!
Returns the orientation that is used when QBarModelMapper accesses the model.
This mean whether the consecutive values of the bar set are read from row (Qt::Horizontal)
or from columns (Qt::Vertical)
*/
Marek Rosa
BarSeries Model mapper added
r1170 Qt::Orientation QBarModelMapper::orientation() const
{
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(const QBarModelMapper);
return d->m_orientation;
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
Added documentation for BarModelMapper classes
r1348 /*!
Returns the \a orientation that is used when QBarModelMapper accesses the model.
This mean whether the consecutive values of the pie are read from row (Qt::Horizontal)
or from columns (Qt::Vertical)
*/
Marek Rosa
BarSeries Model mapper added
r1170 void QBarModelMapper::setOrientation(Qt::Orientation orientation)
{
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(QBarModelMapper);
d->m_orientation = orientation;
d->initializeBarFromModel();
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
Added documentation for BarModelMapper classes
r1348 /*!
Returns which section of the model is used as the data source for the first bar set
*/
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 int QBarModelMapper::firstBarSetSection() const
Marek Rosa
BarSeries Model mapper added
r1170 {
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(const QBarModelMapper);
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 return d->m_firstBarSetSection;
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
Added documentation for BarModelMapper classes
r1348 /*!
Sets the model section that is used as the data source for the first bar set
Parameter \a firstBarSetSection specifies the section of the model.
*/
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 void QBarModelMapper::setFirstBarSetSection(int firstBarSetSection)
Marek Rosa
BarSeries Model mapper added
r1170 {
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(QBarModelMapper);
Marek Rosa
Added some tests for BarModelMapper
r1364 d->m_firstBarSetSection = qMax(-1, firstBarSetSection);
Marek Rosa
BarModel mapper refactored.
r1293 d->initializeBarFromModel();
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
Added documentation for BarModelMapper classes
r1348 /*!
Returns which section of the model is used as the data source for the last bar set
*/
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 int QBarModelMapper::lastBarSetSection() const
Marek Rosa
BarSeries Model mapper added
r1170 {
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(const QBarModelMapper);
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 return d->m_lastBarSetSection;
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
Added documentation for BarModelMapper classes
r1348 /*!
Sets the model section that is used as the data source for the last bar set
Parameter \a lastBarSetSection specifies the section of the model.
*/
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 void QBarModelMapper::setLastBarSetSection(int lastBarSetSection)
Marek Rosa
BarSeries Model mapper added
r1170 {
Marek Rosa
BarModel mapper refactored.
r1293 Q_D(QBarModelMapper);
Marek Rosa
Added some tests for BarModelMapper
r1364 d->m_lastBarSetSection = qMax(-1, lastBarSetSection);
Marek Rosa
BarModel mapper refactored.
r1293 d->initializeBarFromModel();
Marek Rosa
BarSeries Model mapper added
r1170 }
Marek Rosa
BarModel mapper refactored.
r1293 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
QBarModelMapperPrivate::QBarModelMapperPrivate(QBarModelMapper *q) :
Marek Rosa
Added QDonutGroup class
r1671 QObject(q),
Marek Rosa
BarModel mapper refactored.
r1293 m_series(0),
m_model(0),
m_first(0),
m_count(-1),
m_orientation(Qt::Vertical),
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 m_firstBarSetSection(-1),
m_lastBarSetSection(-1),
Marek Rosa
BarModel mapper refactored.
r1293 m_seriesSignalsBlock(false),
m_modelSignalsBlock(false),
q_ptr(q)
{
}
void QBarModelMapperPrivate::blockModelSignals(bool block)
{
m_modelSignalsBlock = block;
}
void QBarModelMapperPrivate::blockSeriesSignals(bool block)
{
m_seriesSignalsBlock = block;
}
Jani Honkonen
more coding style fixes for src-folder...
r2104 QBarSet *QBarModelMapperPrivate::barSet(QModelIndex index)
Marek Rosa
BarModelMapper: implemented model updated slots. Some more work needed with categories
r1295 {
if (!index.isValid())
return 0;
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 if (m_orientation == Qt::Vertical && index.column() >= m_firstBarSetSection && index.column() <= m_lastBarSetSection) {
Marek Rosa
Added placeholders for mappers documentation
r1331 if (index.row() >= m_first && (m_count == - 1 || index.row() < m_first + m_count)) {
Marek Rosa
Fixes to BarSeries and BarModelMapper
r1356 return m_series->barSets().at(index.column() - m_firstBarSetSection);
Marek Rosa
Added placeholders for mappers documentation
r1331 }
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 } else if (m_orientation == Qt::Horizontal && index.row() >= m_firstBarSetSection && index.row() <= m_lastBarSetSection) {
Marek Rosa
BarModelMapper: implemented model updated slots. Some more work needed with categories
r1295 if (index.column() >= m_first && (m_count == - 1 || index.column() < m_first + m_count))
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 return m_series->barSets().at(index.row() - m_firstBarSetSection);
Marek Rosa
BarModelMapper: implemented model updated slots. Some more work needed with categories
r1295 }
return 0; // This part of model has not been mapped to any slice
}
Marek Rosa
BarModel mapper refactored.
r1293 QModelIndex QBarModelMapperPrivate::barModelIndex(int barSection, int posInBar)
{
if (m_count != -1 && posInBar >= m_count)
return QModelIndex(); // invalid
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 if (barSection < m_firstBarSetSection || barSection > m_lastBarSetSection)
Marek Rosa
BarModel mapper refactored.
r1293 return QModelIndex(); // invalid
if (m_orientation == Qt::Vertical)
return m_model->index(posInBar + m_first, barSection);
else
return m_model->index(barSection, posInBar + m_first);
}
Marek Rosa
Model mappers now connected to series and model destroy signals
r1656 void QBarModelMapperPrivate::handleSeriesDestroyed()
{
m_series = 0;
}
Marek Rosa
BarModel mapper refactored.
r1293 void QBarModelMapperPrivate::modelUpdated(QModelIndex topLeft, QModelIndex bottomRight)
{
Q_UNUSED(topLeft)
Q_UNUSED(bottomRight)
Marek Rosa
Added Vertical and Horizontal BarModelMappers
r1294
if (m_model == 0 || m_series == 0)
return;
Marek Rosa
BarModel mapper refactored.
r1293 if (m_modelSignalsBlock)
return;
Marek Rosa
BarModelMapper: implemented model updated slots. Some more work needed with categories
r1295 blockSeriesSignals();
QModelIndex index;
for (int row = topLeft.row(); row <= bottomRight.row(); row++) {
for (int column = topLeft.column(); column <= bottomRight.column(); column++) {
index = topLeft.sibling(row, column);
Jani Honkonen
more coding style fixes for src-folder...
r2104 QBarSet *bar = barSet(index);
Marek Rosa
BarModelMapper: implemented model updated slots. Some more work needed with categories
r1295 if (bar) {
if (m_orientation == Qt::Vertical)
bar->replace(row - m_first, m_model->data(index).toReal());
else
bar->replace(column - m_first, m_model->data(index).toReal());
}
}
}
blockSeriesSignals(false);
Marek Rosa
BarModel mapper refactored.
r1293 }
Marek Rosa
Added support for headerDataChanged() signal from the model to BarModelMapper
r1394 void QBarModelMapperPrivate::modelHeaderDataUpdated(Qt::Orientation orientation, int first, int last)
{
if (m_model == 0 || m_series == 0)
return;
if (m_modelSignalsBlock)
return;
blockSeriesSignals();
if (orientation != m_orientation) {
for (int section = first; section <= last; section++) {
if (section >= m_firstBarSetSection && section <= m_lastBarSetSection) {
Jani Honkonen
more coding style fixes for src-folder...
r2104 QBarSet *bar = m_series->barSets().at(section - m_firstBarSetSection);
Marek Rosa
Added support for headerDataChanged() signal from the model to BarModelMapper
r1394 if (bar)
sauimone
changed barset name to label to be consistent with pie series. Series have names, barsets and pieslices have labels
r1429 bar->setLabel(m_model->headerData(section, orientation).toString());
Marek Rosa
Added support for headerDataChanged() signal from the model to BarModelMapper
r1394 }
}
}
blockSeriesSignals(false);
}
Marek Rosa
BarModel mapper refactored.
r1293 void QBarModelMapperPrivate::modelRowsAdded(QModelIndex parent, int start, int end)
{
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 Q_UNUSED(parent)
Marek Rosa
BarModel mapper refactored.
r1293 if (m_modelSignalsBlock)
return;
blockSeriesSignals();
if (m_orientation == Qt::Vertical)
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 insertData(start, end);
Marek Rosa
Removed categories support from BarModelMapper
r1354 else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize
Marek Rosa
BarModel mapper refactored.
r1293 initializeBarFromModel();
blockSeriesSignals(false);
}
void QBarModelMapperPrivate::modelRowsRemoved(QModelIndex parent, int start, int end)
{
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 Q_UNUSED(parent)
Marek Rosa
BarModel mapper refactored.
r1293 if (m_modelSignalsBlock)
return;
blockSeriesSignals();
if (m_orientation == Qt::Vertical)
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 removeData(start, end);
Marek Rosa
Removed categories support from BarModelMapper
r1354 else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize
Marek Rosa
BarModel mapper refactored.
r1293 initializeBarFromModel();
blockSeriesSignals(false);
}
void QBarModelMapperPrivate::modelColumnsAdded(QModelIndex parent, int start, int end)
{
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 Q_UNUSED(parent)
Marek Rosa
BarModel mapper refactored.
r1293 if (m_modelSignalsBlock)
return;
blockSeriesSignals();
if (m_orientation == Qt::Horizontal)
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 insertData(start, end);
Marek Rosa
Removed categories support from BarModelMapper
r1354 else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize
Marek Rosa
BarModel mapper refactored.
r1293 initializeBarFromModel();
blockSeriesSignals(false);
}
void QBarModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end)
{
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 Q_UNUSED(parent)
Marek Rosa
BarModel mapper refactored.
r1293 if (m_modelSignalsBlock)
return;
blockSeriesSignals();
if (m_orientation == Qt::Horizontal)
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 removeData(start, end);
Marek Rosa
Removed categories support from BarModelMapper
r1354 else if (start <= m_firstBarSetSection || start <= m_lastBarSetSection) // if the changes affect the map - reinitialize
Marek Rosa
BarModel mapper refactored.
r1293 initializeBarFromModel();
blockSeriesSignals(false);
}
Marek Rosa
Model mappers now connected to series and model destroy signals
r1656 void QBarModelMapperPrivate::handleModelDestroyed()
{
m_model = 0;
}
Marek Rosa
BarModel mapper refactored.
r1293 void QBarModelMapperPrivate::insertData(int start, int end)
{
Q_UNUSED(end)
Marek Rosa
Removed commented out code and unnecessary lines from model mapper classes
r1379 Q_UNUSED(start)
Q_UNUSED(end)
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 // Currently barchart needs to be fully recalculated when change is made.
// Re-initialize
initializeBarFromModel();
Marek Rosa
BarModel mapper refactored.
r1293 }
void QBarModelMapperPrivate::removeData(int start, int end)
{
Q_UNUSED(end)
Marek Rosa
Removed commented out code and unnecessary lines from model mapper classes
r1379 Q_UNUSED(start)
Q_UNUSED(end)
Marek Rosa
Removed some commented out code in barmodel mapper and replaced one comment with different one
r2151 // Currently barchart needs to be fully recalculated when change is made.
// Re-initialize
initializeBarFromModel();
Marek Rosa
BarModel mapper refactored.
r1293 }
Jani Honkonen
more coding style fixes for src-folder...
r2104 void QBarModelMapperPrivate::barSetsAdded(QList<QBarSet *> sets)
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 {
if (m_seriesSignalsBlock)
return;
if (sets.count() == 0)
return;
int firstIndex = m_series->barSets().indexOf(sets.at(0));
if (firstIndex == -1)
return;
int maxCount = 0;
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 for (int i = 0; i < sets.count(); i++) {
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 if (sets.at(i)->count() > m_count)
maxCount = sets.at(i)->count();
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 }
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435
if (m_count != -1 && m_count < maxCount)
m_count = maxCount;
m_lastBarSetSection += sets.count();
blockModelSignals();
int modelCapacity = m_orientation == Qt::Vertical ? m_model->rowCount() - m_first : m_model->columnCount() - m_first;
if (maxCount > modelCapacity) {
if (m_orientation == Qt::Vertical)
m_model->insertRows(m_model->rowCount(), maxCount - modelCapacity);
else
m_model->insertColumns(m_model->columnCount(), maxCount - modelCapacity);
}
if (m_orientation == Qt::Vertical)
m_model->insertColumns(firstIndex + m_firstBarSetSection, sets.count());
else
m_model->insertRows(firstIndex + m_firstBarSetSection, sets.count());
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 for (int i = firstIndex + m_firstBarSetSection; i < firstIndex + m_firstBarSetSection + sets.count(); i++) {
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 m_model->setHeaderData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, sets.at(i - firstIndex - m_firstBarSetSection)->label());
for (int j = 0; j < sets.at(i - firstIndex - m_firstBarSetSection)->count(); j++)
sauimone
Removed QPointF from QBarSet
r1580 m_model->setData(barModelIndex(i, j), sets.at(i - firstIndex - m_firstBarSetSection)->at(j));
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 }
blockModelSignals(false);
initializeBarFromModel();
}
Jani Honkonen
more coding style fixes for src-folder...
r2104 void QBarModelMapperPrivate::barSetsRemoved(QList<QBarSet *> sets)
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 {
if (m_seriesSignalsBlock)
return;
if (sets.count() == 0)
return;
int firstIndex = m_barSets.indexOf(sets.at(0));
if (firstIndex == -1)
return;
m_lastBarSetSection -= sets.count();
for (int i = firstIndex + sets.count() - 1; i >= firstIndex; i--)
m_barSets.removeAt(i);
blockModelSignals();
if (m_orientation == Qt::Vertical)
m_model->removeColumns(firstIndex + m_firstBarSetSection, sets.count());
else
m_model->removeRows(firstIndex + m_firstBarSetSection, sets.count());
blockModelSignals(false);
initializeBarFromModel();
}
void QBarModelMapperPrivate::valuesAdded(int index, int count)
{
if (m_seriesSignalsBlock)
return;
if (m_count != -1)
m_count += count;
int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender()));
blockModelSignals();
if (m_orientation == Qt::Vertical)
m_model->insertRows(index + m_first, count);
else
m_model->insertColumns(index + m_first, count);
for (int j = index; j < index + count; j++)
sauimone
Removed QPointF from QBarSet
r1580 m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, j), m_barSets.at(barSetIndex)->at(j));
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435
blockModelSignals(false);
initializeBarFromModel();
}
void QBarModelMapperPrivate::valuesRemoved(int index, int count)
{
if (m_seriesSignalsBlock)
return;
if (m_count != -1)
m_count -= count;
blockModelSignals();
if (m_orientation == Qt::Vertical)
m_model->removeRows(index + m_first, count);
else
m_model->removeColumns(index + m_first, count);
blockModelSignals(false);
initializeBarFromModel();
}
void QBarModelMapperPrivate::barLabelChanged()
{
if (m_seriesSignalsBlock)
return;
int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender()));
blockModelSignals();
m_model->setHeaderData(barSetIndex + m_firstBarSetSection, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical, m_barSets.at(barSetIndex)->label());
blockModelSignals(false);
initializeBarFromModel();
}
void QBarModelMapperPrivate::barValueChanged(int index)
{
if (m_seriesSignalsBlock)
return;
int barSetIndex = m_barSets.indexOf(qobject_cast<QBarSet *>(QObject::sender()));
blockModelSignals();
sauimone
Removed QPointF from QBarSet
r1580 m_model->setData(barModelIndex(barSetIndex + m_firstBarSetSection, index), m_barSets.at(barSetIndex)->at(index));
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 blockModelSignals(false);
initializeBarFromModel();
}
Marek Rosa
BarModel mapper refactored.
r1293 void QBarModelMapperPrivate::initializeBarFromModel()
{
if (m_model == 0 || m_series == 0)
return;
blockSeriesSignals();
// clear current content
Marek Rosa
BarModelMapper: implemented model updated slots. Some more work needed with categories
r1295 m_series->clear();
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 m_barSets.clear();
Marek Rosa
BarModel mapper refactored.
r1293
// create the initial bar sets
Marek Rosa
Replaced 'Bar' with 'BarSet' in BarModelMapper functions and member variables
r1312 for (int i = m_firstBarSetSection; i <= m_lastBarSetSection; i++) {
Marek Rosa
BarModel mapper refactored.
r1293 int posInBar = 0;
QModelIndex barIndex = barModelIndex(i, posInBar);
Marek Rosa
Fixes to BarSeries and BarModelMapper
r1356 // check if there is such model index
if (barIndex.isValid()) {
Marek Rosa
Added support for headerDataChanged() signal from the model to BarModelMapper
r1394 QBarSet *barSet = new QBarSet(m_model->headerData(i, m_orientation == Qt::Vertical ? Qt::Horizontal : Qt::Vertical).toString());
Marek Rosa
Fixes to BarSeries and BarModelMapper
r1356 while (barIndex.isValid()) {
barSet->append(m_model->data(barIndex, Qt::DisplayRole).toDouble());
posInBar++;
barIndex = barModelIndex(i, posInBar);
}
Jani Honkonen
Fix Krazy issues
r1935 connect(barSet, SIGNAL(valuesAdded(int,int)), this, SLOT(valuesAdded(int,int)));
connect(barSet, SIGNAL(valuesRemoved(int,int)), this, SLOT(valuesRemoved(int,int)));
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 connect(barSet, SIGNAL(valueChanged(int)), this, SLOT(barValueChanged(int)));
connect(barSet, SIGNAL(labelChanged()), this, SLOT(barLabelChanged()));
Marek Rosa
Fixes to BarSeries and BarModelMapper
r1356 m_series->append(barSet);
Marek Rosa
BarSeries API can now be used when the series is used with BarModelMapper
r1435 m_barSets.append(barSet);
Marek Rosa
Fixes to BarSeries and BarModelMapper
r1356 } else {
break;
Marek Rosa
BarModel mapper refactored.
r1293 }
}
blockSeriesSignals(false);
Marek Rosa
BarSeries Model mapper added
r1170 }
#include "moc_qbarmodelmapper.cpp"
Marek Rosa
BarModel mapper refactored.
r1293 #include "moc_qbarmodelmapper_p.cpp"
Marek Rosa
BarSeries Model mapper added
r1170
QTCOMMERCIALCHART_END_NAMESPACE