mirror of https://github.com/qt/qtgraphs.git
Get rid of some clazy warnings in graphs2d/qsgrenderer folder
Fix "c++11 range-loop might detach Qt container" warnings. Change-Id: I6cfcff806ce6f2f27b4e2037106f72065bafbfcd Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io> (cherry picked from commit6b6f6581e2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit6b879d4250) Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
parent
6f80b3bb27
commit
c9dda868e4
|
|
@ -871,7 +871,8 @@ void AxisRenderer::updateBarXAxisLabels(QBarCategoryAxis *axis, const QRectF rec
|
||||||
updateAxisLabelItems(m_xAxisTextItems, categoriesCount, axis->labelDelegate());
|
updateAxisLabelItems(m_xAxisTextItems, categoriesCount, axis->labelDelegate());
|
||||||
|
|
||||||
int textIndex = 0;
|
int textIndex = 0;
|
||||||
for (auto category : axis->categories()) {
|
auto categories = axis->categories();
|
||||||
|
for (const auto &category : std::as_const(categories)) {
|
||||||
auto &textItem = m_xAxisTextItems[textIndex];
|
auto &textItem = m_xAxisTextItems[textIndex];
|
||||||
if (axis->isVisible() && axis->labelsVisible()) {
|
if (axis->isVisible() && axis->labelsVisible()) {
|
||||||
float posX = rect.x() + ((float)textIndex / categoriesCount) * rect.width();
|
float posX = rect.x() + ((float)textIndex / categoriesCount) * rect.width();
|
||||||
|
|
@ -906,7 +907,8 @@ void AxisRenderer::updateBarYAxisLabels(QBarCategoryAxis *axis, const QRectF rec
|
||||||
updateAxisLabelItems(m_yAxisTextItems, categoriesCount, axis->labelDelegate());
|
updateAxisLabelItems(m_yAxisTextItems, categoriesCount, axis->labelDelegate());
|
||||||
|
|
||||||
int textIndex = 0;
|
int textIndex = 0;
|
||||||
for (auto category : axis->categories()) {
|
auto categories = axis->categories();
|
||||||
|
for (const auto &category : std::as_const(categories)) {
|
||||||
auto &textItem = m_yAxisTextItems[textIndex];
|
auto &textItem = m_yAxisTextItems[textIndex];
|
||||||
if (axis->isVisible() && axis->labelsVisible()) {
|
if (axis->isVisible() && axis->labelsVisible()) {
|
||||||
float posX = rect.x();
|
float posX = rect.x();
|
||||||
|
|
|
||||||
|
|
@ -254,10 +254,11 @@ void BarsRenderer::updateValueLabels(QBarSeries *series)
|
||||||
void calculateCategoryTotalValues(QBarSeries *series, QList<float> &totalValues, qsizetype valuesPerSet)
|
void calculateCategoryTotalValues(QBarSeries *series, QList<float> &totalValues, qsizetype valuesPerSet)
|
||||||
{
|
{
|
||||||
totalValues.fill(0, valuesPerSet);
|
totalValues.fill(0, valuesPerSet);
|
||||||
for (auto s : series->barSets()) {
|
auto barsets = series->barSets();
|
||||||
|
for (auto s : std::as_const(barsets)) {
|
||||||
QVariantList v = s->values();
|
QVariantList v = s->values();
|
||||||
int setIndex = 0;
|
int setIndex = 0;
|
||||||
for (auto variantValue : std::as_const(v)) {
|
for (const auto &variantValue : std::as_const(v)) {
|
||||||
if (setIndex < totalValues.size())
|
if (setIndex < totalValues.size())
|
||||||
totalValues[setIndex] += variantValue.toReal();
|
totalValues[setIndex] += variantValue.toReal();
|
||||||
setIndex++;
|
setIndex++;
|
||||||
|
|
@ -303,7 +304,8 @@ void BarsRenderer::updateVerticalBars(QBarSeries *series, qsizetype setCount, qs
|
||||||
int barIndexInSet = 0;
|
int barIndexInSet = 0;
|
||||||
int barSeriesIndex = 0;
|
int barSeriesIndex = 0;
|
||||||
QList<QLegendData> legendDataList;
|
QList<QLegendData> legendDataList;
|
||||||
for (auto s : series->barSets()) {
|
auto barsets = series->barSets();
|
||||||
|
for (auto s : std::as_const(barsets)) {
|
||||||
QVariantList v = s->values();
|
QVariantList v = s->values();
|
||||||
qsizetype valuesCount = v.size();
|
qsizetype valuesCount = v.size();
|
||||||
if (valuesCount == 0)
|
if (valuesCount == 0)
|
||||||
|
|
@ -332,7 +334,7 @@ void BarsRenderer::updateVerticalBars(QBarSeries *series, qsizetype setCount, qs
|
||||||
color.setAlpha(color.alpha() * series->opacity());
|
color.setAlpha(color.alpha() * series->opacity());
|
||||||
borderColor.setAlpha(borderColor.alpha() * series->opacity());
|
borderColor.setAlpha(borderColor.alpha() * series->opacity());
|
||||||
const auto selectedBars = s->selectedBars();
|
const auto selectedBars = s->selectedBars();
|
||||||
for (auto variantValue : std::as_const(v)) {
|
for (const auto &variantValue : std::as_const(v)) {
|
||||||
const float realValue = variantValue.toReal();
|
const float realValue = variantValue.toReal();
|
||||||
float value = (realValue - m_graph->m_axisRenderer->m_axisVerticalMinValue) * series->valuesMultiplier();
|
float value = (realValue - m_graph->m_axisRenderer->m_axisVerticalMinValue) * series->valuesMultiplier();
|
||||||
if (percent) {
|
if (percent) {
|
||||||
|
|
@ -413,7 +415,8 @@ void BarsRenderer::updateHorizontalBars(QBarSeries *series, qsizetype setCount,
|
||||||
int barIndexInSet = 0;
|
int barIndexInSet = 0;
|
||||||
int barSerieIndex = 0;
|
int barSerieIndex = 0;
|
||||||
QList<QLegendData> legendDataList;
|
QList<QLegendData> legendDataList;
|
||||||
for (auto s : series->barSets()) {
|
auto barsets = series->barSets();
|
||||||
|
for (auto s : std::as_const(barsets)) {
|
||||||
QVariantList v = s->values();
|
QVariantList v = s->values();
|
||||||
qsizetype valuesCount = v.size();
|
qsizetype valuesCount = v.size();
|
||||||
if (valuesCount == 0)
|
if (valuesCount == 0)
|
||||||
|
|
@ -441,7 +444,7 @@ void BarsRenderer::updateHorizontalBars(QBarSeries *series, qsizetype setCount,
|
||||||
color.setAlpha(color.alpha() * series->opacity());
|
color.setAlpha(color.alpha() * series->opacity());
|
||||||
borderColor.setAlpha(borderColor.alpha() * series->opacity());
|
borderColor.setAlpha(borderColor.alpha() * series->opacity());
|
||||||
const auto selectedBars = s->selectedBars();
|
const auto selectedBars = s->selectedBars();
|
||||||
for (auto variantValue : std::as_const(v)) {
|
for (const auto &variantValue : std::as_const(v)) {
|
||||||
const float realValue = variantValue.toReal();
|
const float realValue = variantValue.toReal();
|
||||||
float value = (realValue - m_graph->m_axisRenderer->m_axisHorizontalMinValue) * series->valuesMultiplier();
|
float value = (realValue - m_graph->m_axisRenderer->m_axisHorizontalMinValue) * series->valuesMultiplier();
|
||||||
if (percent) {
|
if (percent) {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ void PieRenderer::setSize(QSizeF size)
|
||||||
|
|
||||||
void PieRenderer::handlePolish(QPieSeries *series)
|
void PieRenderer::handlePolish(QPieSeries *series)
|
||||||
{
|
{
|
||||||
for (QPieSlice *slice : series->slices()) {
|
auto slices = series->slices();
|
||||||
|
for (QPieSlice *slice : std::as_const(slices)) {
|
||||||
QPieSlicePrivate *d = slice->d_func();
|
QPieSlicePrivate *d = slice->d_func();
|
||||||
QQuickShapePath *shapePath = d->m_shapePath;
|
QQuickShapePath *shapePath = d->m_shapePath;
|
||||||
QQuickShapePath *labelPath = d->m_labelPath;
|
QQuickShapePath *labelPath = d->m_labelPath;
|
||||||
|
|
@ -100,7 +101,8 @@ void PieRenderer::handlePolish(QPieSeries *series)
|
||||||
qreal sliceAngle = series->startAngle();
|
qreal sliceAngle = series->startAngle();
|
||||||
int sliceIndex = 0;
|
int sliceIndex = 0;
|
||||||
QList<QLegendData> legendDataList;
|
QList<QLegendData> legendDataList;
|
||||||
for (QPieSlice *slice : series->slices()) {
|
auto slicelist = series->slices();
|
||||||
|
for (QPieSlice *slice : std::as_const(slicelist)) {
|
||||||
m_painterPath.clear();
|
m_painterPath.clear();
|
||||||
|
|
||||||
QPieSlicePrivate *d = slice->d_func();
|
QPieSlicePrivate *d = slice->d_func();
|
||||||
|
|
@ -225,7 +227,8 @@ void PieRenderer::afterPolish(QList<QAbstractSeries *> &cleanupSeries)
|
||||||
for (auto series : cleanupSeries) {
|
for (auto series : cleanupSeries) {
|
||||||
auto pieSeries = qobject_cast<QPieSeries *>(series);
|
auto pieSeries = qobject_cast<QPieSeries *>(series);
|
||||||
if (pieSeries) {
|
if (pieSeries) {
|
||||||
for (QPieSlice *slice : pieSeries->slices()) {
|
auto slices = pieSeries->slices();
|
||||||
|
for (QPieSlice *slice : std::as_const(slices)) {
|
||||||
QPieSlicePrivate *d = slice->d_func();
|
QPieSlicePrivate *d = slice->d_func();
|
||||||
auto labelElements = d->m_labelPath->pathElements();
|
auto labelElements = d->m_labelPath->pathElements();
|
||||||
auto shapeElements = d->m_shapePath->pathElements();
|
auto shapeElements = d->m_shapePath->pathElements();
|
||||||
|
|
@ -316,7 +319,7 @@ bool PieRenderer::handleHoverMove(QHoverEvent *event)
|
||||||
|
|
||||||
bool hovering = false;
|
bool hovering = false;
|
||||||
QList<QPieSlice *> list = m_activeSlices.keys();
|
QList<QPieSlice *> list = m_activeSlices.keys();
|
||||||
for (const auto &slice : list) {
|
for (const auto &slice : std::as_const(list)) {
|
||||||
if (!slice->series()->isHoverable())
|
if (!slice->series()->isHoverable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -355,7 +358,7 @@ void PieRenderer::onSingleTapped(QEventPoint eventPoint, Qt::MouseButton button)
|
||||||
Q_UNUSED(button)
|
Q_UNUSED(button)
|
||||||
|
|
||||||
QList<QPieSlice *> list = m_activeSlices.keys();
|
QList<QPieSlice *> list = m_activeSlices.keys();
|
||||||
for (const auto &pieSlice : list) {
|
for (const auto &pieSlice : std::as_const(list)) {
|
||||||
if (!pieSlice->series()->isSelectable())
|
if (!pieSlice->series()->isSelectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -371,7 +374,7 @@ void PieRenderer::onDoubleTapped(QEventPoint eventPoint, Qt::MouseButton button)
|
||||||
Q_UNUSED(button)
|
Q_UNUSED(button)
|
||||||
|
|
||||||
QList<QPieSlice *> list = m_activeSlices.keys();
|
QList<QPieSlice *> list = m_activeSlices.keys();
|
||||||
for (const auto &pieSlice : list) {
|
for (const auto &pieSlice : std::as_const(list)) {
|
||||||
if (!pieSlice->series()->isSelectable())
|
if (!pieSlice->series()->isSelectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -385,7 +388,7 @@ void PieRenderer::onDoubleTapped(QEventPoint eventPoint, Qt::MouseButton button)
|
||||||
void PieRenderer::onPressedChanged()
|
void PieRenderer::onPressedChanged()
|
||||||
{
|
{
|
||||||
QList<QPieSlice *> list = m_activeSlices.keys();
|
QList<QPieSlice *> list = m_activeSlices.keys();
|
||||||
for (const auto &pieSlice : list) {
|
for (const auto &pieSlice : std::as_const(list)) {
|
||||||
if (!pieSlice->series()->isSelectable())
|
if (!pieSlice->series()->isSelectable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ void PointRenderer::handlePolish(QXYSeries *series)
|
||||||
group->shapePath->setPath(painterPath);
|
group->shapePath->setPath(painterPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto m : group->markers)
|
for (auto m : std::as_const(group->markers))
|
||||||
m->deleteLater();
|
m->deleteLater();
|
||||||
|
|
||||||
group->markers.clear();
|
group->markers.clear();
|
||||||
|
|
@ -614,7 +614,7 @@ void PointRenderer::afterPolish(QList<QAbstractSeries *> &cleanupSeries)
|
||||||
if (xySeries && m_groups.contains(xySeries)) {
|
if (xySeries && m_groups.contains(xySeries)) {
|
||||||
auto group = m_groups.value(xySeries);
|
auto group = m_groups.value(xySeries);
|
||||||
|
|
||||||
for (auto marker : group->markers)
|
for (auto marker : std::as_const(group->markers))
|
||||||
marker->deleteLater();
|
marker->deleteLater();
|
||||||
|
|
||||||
if (group->shapePath) {
|
if (group->shapePath) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue