QCustomPlot: Fix qsizetype warnings

Starting with Qt 5.10 (our earliest supported version),
Qt has a qsizetype (alias of ssize_t) that functions
like size() and indexOf() return. On clang that does not
have the same size as an int, so cast it away in a number
of places.
This commit is contained in:
Gerald Combs 2022-03-26 10:19:00 -07:00 committed by John Thacker
parent 498dc04278
commit b9b16e2f64
2 changed files with 61 additions and 61 deletions

View File

@ -2594,7 +2594,7 @@ void QCPDataSelection::clear()
void QCPDataSelection::simplify() void QCPDataSelection::simplify()
{ {
// remove any empty ranges: // remove any empty ranges:
for (int i=mDataRanges.size()-1; i>=0; --i) for (int i=static_cast<int>(mDataRanges.size())-1; i>=0; --i)
{ {
if (mDataRanges.at(i).isEmpty()) if (mDataRanges.at(i).isEmpty())
mDataRanges.removeAt(i); mDataRanges.removeAt(i);
@ -3075,7 +3075,7 @@ void QCPMarginGroup::clear()
{ {
it.next(); it.next();
const QList<QCPLayoutElement*> elements = it.value(); const QList<QCPLayoutElement*> elements = it.value();
for (int i=elements.size()-1; i>=0; --i) for (int i=static_cast<int>(elements.size())-1; i>=0; --i)
elements.at(i)->setMarginGroup(it.key(), nullptr); // removes itself from mChildren via removeChild elements.at(i)->setMarginGroup(it.key(), nullptr); // removes itself from mChildren via removeChild
} }
} }
@ -3896,7 +3896,7 @@ QVector<int> QCPLayout::getSectionSizes(QVector<int> maxSizes, QVector<int> minS
} }
if (stretchFactors.isEmpty()) if (stretchFactors.isEmpty())
return QVector<int>(); return QVector<int>();
int sectionCount = stretchFactors.size(); int sectionCount = static_cast<int>(stretchFactors.size());
QVector<double> sectionSizes(sectionCount); QVector<double> sectionSizes(sectionCount);
// if provided total size is forced smaller than total minimum size, ignore minimum sizes (squeeze sections): // if provided total size is forced smaller than total minimum size, ignore minimum sizes (squeeze sections):
int minSizeSum = 0; int minSizeSum = 0;
@ -5026,7 +5026,7 @@ void QCPLayoutInset::updateLayout()
/* inherits documentation from base class */ /* inherits documentation from base class */
int QCPLayoutInset::elementCount() const int QCPLayoutInset::elementCount() const
{ {
return mElements.size(); return static_cast<int>(mElements.size());
} }
/* inherits documentation from base class */ /* inherits documentation from base class */
@ -5561,7 +5561,7 @@ void QCPLabelPainterPrivate::setCacheSize(int labelCount)
int QCPLabelPainterPrivate::cacheSize() const int QCPLabelPainterPrivate::cacheSize() const
{ {
return mLabelCache.maxCost(); return static_cast<int>(mLabelCache.maxCost());
} }
void QCPLabelPainterPrivate::drawTickLabel(QCPPainter *painter, const QPointF &tickPos, const QString &text) void QCPLabelPainterPrivate::drawTickLabel(QCPPainter *painter, const QPointF &tickPos, const QString &text)
@ -5844,7 +5844,7 @@ QCPLabelPainterPrivate::LabelData QCPLabelPainterPrivate::getTickLabelData(const
int eLast = -1; // last index of exponent part, rest of text after this will be suffixPart int eLast = -1; // last index of exponent part, rest of text after this will be suffixPart
if (mSubstituteExponent) if (mSubstituteExponent)
{ {
ePos = text.indexOf(QLatin1Char('e')); ePos = static_cast<int>(text.indexOf(QLatin1Char('e')));
if (ePos > 0 && text.at(ePos-1).isDigit()) if (ePos > 0 && text.at(ePos-1).isDigit())
{ {
eLast = ePos; eLast = ePos;
@ -6388,7 +6388,7 @@ void QCPAxisTicker::trimTicks(const QCPRange &range, QVector<double> &ticks, boo
break; break;
} }
} }
for (int i=ticks.size()-1; i >= 0; --i) for (int i=static_cast<int>(ticks.size())-1; i >= 0; --i)
{ {
if (ticks.at(i) <= range.upper) if (ticks.at(i) <= range.upper)
{ {
@ -6401,7 +6401,7 @@ void QCPAxisTicker::trimTicks(const QCPRange &range, QVector<double> &ticks, boo
if (highFound && lowFound) if (highFound && lowFound)
{ {
int trimFront = qMax(0, lowIndex-(keepOneOutlier ? 1 : 0)); int trimFront = qMax(0, lowIndex-(keepOneOutlier ? 1 : 0));
int trimBack = qMax(0, ticks.size()-(keepOneOutlier ? 2 : 1)-highIndex); int trimBack = qMax(0, static_cast<int>(ticks.size())-(keepOneOutlier ? 2 : 1)-highIndex);
if (trimFront > 0 || trimBack > 0) if (trimFront > 0 || trimBack > 0)
ticks = ticks.mid(trimFront, ticks.size()-trimFront-trimBack); ticks = ticks.mid(trimFront, ticks.size()-trimFront-trimBack);
} else // all ticks are either all below or all above the range } else // all ticks are either all below or all above the range
@ -7327,7 +7327,7 @@ void QCPAxisTickerText::addTicks(const QVector<double> &positions, const QVector
{ {
if (positions.size() != labels.size()) if (positions.size() != labels.size())
qDebug() << Q_FUNC_INFO << "passed unequal length vectors for positions and labels:" << positions.size() << labels.size(); qDebug() << Q_FUNC_INFO << "passed unequal length vectors for positions and labels:" << positions.size() << labels.size();
int n = qMin(positions.size(), labels.size()); int n = static_cast<int>(qMin(positions.size(), labels.size()));
for (int i=0; i<n; ++i) for (int i=0; i<n; ++i)
mTicks.insert(positions.at(i), labels.at(i)); mTicks.insert(positions.at(i), labels.at(i));
} }
@ -7963,7 +7963,7 @@ void QCPGrid::drawGridLines(QCPPainter *painter) const
{ {
if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; } if (!mParentAxis) { qDebug() << Q_FUNC_INFO << "invalid parent axis"; return; }
const int tickCount = mParentAxis->mTickVector.size(); const int tickCount = static_cast<int>(mParentAxis->mTickVector.size());
double t; // helper variable, result of coordinate-to-pixel transforms double t; // helper variable, result of coordinate-to-pixel transforms
if (mParentAxis->orientation() == Qt::Horizontal) if (mParentAxis->orientation() == Qt::Horizontal)
{ {
@ -9689,7 +9689,7 @@ void QCPAxis::draw(QCPPainter *painter)
if (mSubTicks) if (mSubTicks)
{ {
const int subTickCount = mSubTickVector.size(); const int subTickCount = static_cast<int>(mSubTickVector.size());
for (int i=0; i<subTickCount; ++i) for (int i=0; i<subTickCount; ++i)
subTickPositions.append(coordToPixel(mSubTickVector.at(i))); subTickPositions.append(coordToPixel(mSubTickVector.at(i)));
} }
@ -10021,7 +10021,7 @@ void QCPAxisPainterPrivate::draw(QCPPainter *painter)
margin += tickLabelPadding; margin += tickLabelPadding;
painter->setFont(tickLabelFont); painter->setFont(tickLabelFont);
painter->setPen(QPen(tickLabelColor)); painter->setPen(QPen(tickLabelColor));
const int maxLabelIndex = qMin(tickPositions.size(), tickLabels.size()); const int maxLabelIndex = static_cast<int>(qMin(tickPositions.size(), tickLabels.size()));
int distanceToAxis = margin; int distanceToAxis = margin;
if (tickLabelSide == QCPAxis::lsInside) if (tickLabelSide == QCPAxis::lsInside)
distanceToAxis = -(qMax(tickLengthIn, subTickLengthIn)+tickLabelPadding); distanceToAxis = -(qMax(tickLengthIn, subTickLengthIn)+tickLabelPadding);
@ -10346,7 +10346,7 @@ QCPAxisPainterPrivate::TickLabelData QCPAxisPainterPrivate::getTickLabelData(con
int eLast = -1; // last index of exponent part, rest of text after this will be suffixPart int eLast = -1; // last index of exponent part, rest of text after this will be suffixPart
if (substituteExponent) if (substituteExponent)
{ {
ePos = text.indexOf(QString(mParentPlot->locale().exponential())); ePos = static_cast<int>(text.indexOf(QString(mParentPlot->locale().exponential())));
if (ePos > 0 && text.at(ePos-1).isDigit()) if (ePos > 0 && text.at(ePos-1).isDigit())
{ {
eLast = ePos; eLast = ePos;
@ -14313,7 +14313,7 @@ bool QCustomPlot::removePlottable(int index)
*/ */
int QCustomPlot::clearPlottables() int QCustomPlot::clearPlottables()
{ {
int c = mPlottables.size(); int c = static_cast<int>(mPlottables.size());
for (int i=c-1; i >= 0; --i) for (int i=c-1; i >= 0; --i)
removePlottable(mPlottables[i]); removePlottable(mPlottables[i]);
return c; return c;
@ -14326,7 +14326,7 @@ int QCustomPlot::clearPlottables()
*/ */
int QCustomPlot::plottableCount() const int QCustomPlot::plottableCount() const
{ {
return mPlottables.size(); return static_cast<int>(mPlottables.size());
} }
/*! /*!
@ -14474,7 +14474,7 @@ bool QCustomPlot::removeGraph(int index)
*/ */
int QCustomPlot::clearGraphs() int QCustomPlot::clearGraphs()
{ {
int c = mGraphs.size(); int c = static_cast<int>(mGraphs.size());
for (int i=c-1; i >= 0; --i) for (int i=c-1; i >= 0; --i)
removeGraph(mGraphs[i]); removeGraph(mGraphs[i]);
return c; return c;
@ -14487,7 +14487,7 @@ int QCustomPlot::clearGraphs()
*/ */
int QCustomPlot::graphCount() const int QCustomPlot::graphCount() const
{ {
return mGraphs.size(); return static_cast<int>(mGraphs.size());
} }
/*! /*!
@ -14590,7 +14590,7 @@ bool QCustomPlot::removeItem(int index)
*/ */
int QCustomPlot::clearItems() int QCustomPlot::clearItems()
{ {
int c = mItems.size(); int c = static_cast<int>(mItems.size());
for (int i=c-1; i >= 0; --i) for (int i=c-1; i >= 0; --i)
removeItem(mItems[i]); removeItem(mItems[i]);
return c; return c;
@ -14603,7 +14603,7 @@ int QCustomPlot::clearItems()
*/ */
int QCustomPlot::itemCount() const int QCustomPlot::itemCount() const
{ {
return mItems.size(); return static_cast<int>(mItems.size());
} }
/*! /*!
@ -14739,7 +14739,7 @@ bool QCustomPlot::setCurrentLayer(QCPLayer *layer)
*/ */
int QCustomPlot::layerCount() const int QCustomPlot::layerCount() const
{ {
return mLayers.size(); return static_cast<int>(mLayers.size());
} }
/*! /*!
@ -14877,7 +14877,7 @@ bool QCustomPlot::moveLayer(QCPLayer *layer, QCPLayer *otherLayer, QCustomPlot::
*/ */
int QCustomPlot::axisRectCount() const int QCustomPlot::axisRectCount() const
{ {
return axisRects().size(); return static_cast<int>(axisRects().size());
} }
/*! /*!
@ -16342,10 +16342,10 @@ QCPLayerable *QCustomPlot::layerableAt(const QPointF &pos, bool onlySelectable,
QList<QCPLayerable*> QCustomPlot::layerableListAt(const QPointF &pos, bool onlySelectable, QList<QVariant> *selectionDetails) const QList<QCPLayerable*> QCustomPlot::layerableListAt(const QPointF &pos, bool onlySelectable, QList<QVariant> *selectionDetails) const
{ {
QList<QCPLayerable*> result; QList<QCPLayerable*> result;
for (int layerIndex=mLayers.size()-1; layerIndex>=0; --layerIndex) for (int layerIndex=static_cast<int>(mLayers.size())-1; layerIndex>=0; --layerIndex)
{ {
const QList<QCPLayerable*> layerables = mLayers.at(layerIndex)->children(); const QList<QCPLayerable*> layerables = mLayers.at(layerIndex)->children();
for (int i=layerables.size()-1; i>=0; --i) for (int i=static_cast<int>(layerables.size())-1; i>=0; --i)
{ {
if (!layerables.at(i)->realVisibility()) if (!layerables.at(i)->realVisibility())
continue; continue;
@ -17606,7 +17606,7 @@ QCPAxisRect::~QCPAxisRect()
*/ */
int QCPAxisRect::axisCount(QCPAxis::AxisType type) const int QCPAxisRect::axisCount(QCPAxis::AxisType type) const
{ {
return mAxes.value(type).size(); return static_cast<int>(mAxes.value(type).size());
} }
/*! /*!
@ -21048,7 +21048,7 @@ void QCPGraph::addData(const QVector<double> &keys, const QVector<double> &value
{ {
if (keys.size() != values.size()) if (keys.size() != values.size())
qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size();
const int n = qMin(keys.size(), values.size()); const int n = static_cast<int>(qMin(keys.size(), values.size()));
QVector<QCPGraphData> tempData(n); QVector<QCPGraphData> tempData(n);
QVector<QCPGraphData>::iterator it = tempData.begin(); QVector<QCPGraphData>::iterator it = tempData.begin();
const QVector<QCPGraphData>::iterator itEnd = tempData.end(); const QVector<QCPGraphData>::iterator itEnd = tempData.end();
@ -21993,7 +21993,7 @@ void QCPGraph::getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin
QVector<QCPDataRange> QCPGraph::getNonNanSegments(const QVector<QPointF> *lineData, Qt::Orientation keyOrientation) const QVector<QCPDataRange> QCPGraph::getNonNanSegments(const QVector<QPointF> *lineData, Qt::Orientation keyOrientation) const
{ {
QVector<QCPDataRange> result; QVector<QCPDataRange> result;
const int n = lineData->size(); const int n = static_cast<int>(lineData->size());
QCPDataRange currentSegment(-1, -1); QCPDataRange currentSegment(-1, -1);
int i = 0; int i = 0;
@ -22284,7 +22284,7 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector<QPointF> *thisData
croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
// set highest point of cropped data to fit exactly key position of last static data point via linear interpolation: // set highest point of cropped data to fit exactly key position of last static data point via linear interpolation:
if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation
const int li = croppedData->size()-1; // last index const int li = static_cast<int>(croppedData->size())-1; // last index
if (!qFuzzyCompare(croppedData->at(li).x(), croppedData->at(li-1).x())) if (!qFuzzyCompare(croppedData->at(li).x(), croppedData->at(li-1).x()))
slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x()); slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x());
else else
@ -22318,7 +22318,7 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector<QPointF> *thisData
croppedData->remove(highBound+1, croppedData->size()-(highBound+1)); croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
// set highest point of cropped data to fit exactly key position of last static data point via linear interpolation: // set highest point of cropped data to fit exactly key position of last static data point via linear interpolation:
if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation if (croppedData->size() < 2) return QPolygonF(); // need at least two points for interpolation
int li = croppedData->size()-1; // last index int li = static_cast<int>(croppedData->size())-1; // last index
if (!qFuzzyCompare(croppedData->at(li).y(), croppedData->at(li-1).y())) // avoid division by zero in step plots if (!qFuzzyCompare(croppedData->at(li).y(), croppedData->at(li-1).y())) // avoid division by zero in step plots
slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y()); slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y());
else else
@ -22328,7 +22328,7 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector<QPointF> *thisData
} }
// return joined: // return joined:
for (int i=otherSegmentData.size()-1; i>=0; --i) // insert reversed, otherwise the polygon will be twisted for (int i=static_cast<int>(otherSegmentData.size())-1; i>=0; --i) // insert reversed, otherwise the polygon will be twisted
thisSegmentData << otherSegmentData.at(i); thisSegmentData << otherSegmentData.at(i);
return QPolygonF(thisSegmentData); return QPolygonF(thisSegmentData);
} }
@ -22343,14 +22343,14 @@ const QPolygonF QCPGraph::getChannelFillPolygon(const QVector<QPointF> *thisData
*/ */
int QCPGraph::findIndexAboveX(const QVector<QPointF> *data, double x) const int QCPGraph::findIndexAboveX(const QVector<QPointF> *data, double x) const
{ {
for (int i=data->size()-1; i>=0; --i) for (int i=static_cast<int>(data->size())-1; i>=0; --i)
{ {
if (data->at(i).x() < x) if (data->at(i).x() < x)
{ {
if (i<data->size()-1) if (i<data->size()-1)
return i+1; return i+1;
else else
return data->size()-1; return static_cast<int>(data->size())-1;
} }
} }
return -1; return -1;
@ -22389,14 +22389,14 @@ int QCPGraph::findIndexBelowX(const QVector<QPointF> *data, double x) const
*/ */
int QCPGraph::findIndexAboveY(const QVector<QPointF> *data, double y) const int QCPGraph::findIndexAboveY(const QVector<QPointF> *data, double y) const
{ {
for (int i=data->size()-1; i>=0; --i) for (int i=static_cast<int>(data->size())-1; i>=0; --i)
{ {
if (data->at(i).y() < y) if (data->at(i).y() < y)
{ {
if (i<data->size()-1) if (i<data->size()-1)
return i+1; return i+1;
else else
return data->size()-1; return static_cast<int>(data->size())-1;
} }
} }
return -1; return -1;
@ -22773,7 +22773,7 @@ void QCPCurve::addData(const QVector<double> &t, const QVector<double> &keys, co
{ {
if (t.size() != keys.size() || t.size() != values.size()) if (t.size() != keys.size() || t.size() != values.size())
qDebug() << Q_FUNC_INFO << "ts, keys and values have different sizes:" << t.size() << keys.size() << values.size(); qDebug() << Q_FUNC_INFO << "ts, keys and values have different sizes:" << t.size() << keys.size() << values.size();
const int n = qMin(qMin(t.size(), keys.size()), values.size()); const int n = static_cast<int>(qMin(qMin(t.size(), keys.size()), values.size()));
QVector<QCPCurveData> tempData(n); QVector<QCPCurveData> tempData(n);
QVector<QCPCurveData>::iterator it = tempData.begin(); QVector<QCPCurveData>::iterator it = tempData.begin();
const QVector<QCPCurveData>::iterator itEnd = tempData.end(); const QVector<QCPCurveData>::iterator itEnd = tempData.end();
@ -22805,7 +22805,7 @@ void QCPCurve::addData(const QVector<double> &keys, const QVector<double> &value
{ {
if (keys.size() != values.size()) if (keys.size() != values.size())
qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size();
const int n = qMin(keys.size(), values.size()); const int n = static_cast<int>(qMin(keys.size(), values.size()));
double tStart; double tStart;
if (!mDataContainer->isEmpty()) if (!mDataContainer->isEmpty())
tStart = (mDataContainer->constEnd()-1)->t + 1.0; tStart = (mDataContainer->constEnd()-1)->t + 1.0;
@ -24197,7 +24197,7 @@ double QCPBarsGroup::keyPixelOffset(const QCPBars *bars, double keyCoord)
// determine key pixel offset of this base bars considering all other base bars in this barsgroup: // determine key pixel offset of this base bars considering all other base bars in this barsgroup:
double result = 0; double result = 0;
int index = baseBars.indexOf(thisBase); int index = static_cast<int>(baseBars.indexOf(thisBase));
if (index >= 0) if (index >= 0)
{ {
if (baseBars.size() % 2 == 1 && index == (baseBars.size()-1)/2) // is center bar (int division on purpose) if (baseBars.size() % 2 == 1 && index == (baseBars.size()-1)/2) // is center bar (int division on purpose)
@ -24210,11 +24210,11 @@ double QCPBarsGroup::keyPixelOffset(const QCPBars *bars, double keyCoord)
int dir = (index <= (baseBars.size()-1)/2) ? -1 : 1; // if bar is to lower keys of center, dir is negative int dir = (index <= (baseBars.size()-1)/2) ? -1 : 1; // if bar is to lower keys of center, dir is negative
if (baseBars.size() % 2 == 0) // even number of bars if (baseBars.size() % 2 == 0) // even number of bars
{ {
startIndex = baseBars.size()/2 + (dir < 0 ? -1 : 0); startIndex = static_cast<int>(baseBars.size())/2 + (dir < 0 ? -1 : 0);
result += getPixelSpacing(baseBars.at(startIndex), keyCoord)*0.5; // half of middle spacing result += getPixelSpacing(baseBars.at(startIndex), keyCoord)*0.5; // half of middle spacing
} else // uneven number of bars } else // uneven number of bars
{ {
startIndex = (baseBars.size()-1)/2+dir; startIndex = (static_cast<int>(baseBars.size())-1)/2+dir;
baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth); baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5; // half of center bar result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5; // half of center bar
result += getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord); // center bar spacing result += getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord); // center bar spacing
@ -24578,7 +24578,7 @@ void QCPBars::addData(const QVector<double> &keys, const QVector<double> &values
{ {
if (keys.size() != values.size()) if (keys.size() != values.size())
qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size();
const int n = qMin(keys.size(), values.size()); const int n = static_cast<int>(qMin(keys.size(), values.size()));
QVector<QCPBarsData> tempData(n); QVector<QCPBarsData> tempData(n);
QVector<QCPBarsData>::iterator it = tempData.begin(); QVector<QCPBarsData>::iterator it = tempData.begin();
const QVector<QCPBarsData>::iterator itEnd = tempData.end(); const QVector<QCPBarsData>::iterator itEnd = tempData.end();
@ -25470,7 +25470,7 @@ void QCPStatisticalBox::addData(const QVector<double> &keys, const QVector<doubl
median.size() != upperQuartile.size() || upperQuartile.size() != maximum.size() || maximum.size() != keys.size()) median.size() != upperQuartile.size() || upperQuartile.size() != maximum.size() || maximum.size() != keys.size())
qDebug() << Q_FUNC_INFO << "keys, minimum, lowerQuartile, median, upperQuartile, maximum have different sizes:" qDebug() << Q_FUNC_INFO << "keys, minimum, lowerQuartile, median, upperQuartile, maximum have different sizes:"
<< keys.size() << minimum.size() << lowerQuartile.size() << median.size() << upperQuartile.size() << maximum.size(); << keys.size() << minimum.size() << lowerQuartile.size() << median.size() << upperQuartile.size() << maximum.size();
const int n = qMin(keys.size(), qMin(minimum.size(), qMin(lowerQuartile.size(), qMin(median.size(), qMin(upperQuartile.size(), maximum.size()))))); const int n = static_cast<int>(qMin(keys.size(), qMin(minimum.size(), qMin(lowerQuartile.size(), qMin(median.size(), qMin(upperQuartile.size(), maximum.size()))))));
QVector<QCPStatisticalBoxData> tempData(n); QVector<QCPStatisticalBoxData> tempData(n);
QVector<QCPStatisticalBoxData>::iterator it = tempData.begin(); QVector<QCPStatisticalBoxData>::iterator it = tempData.begin();
const QVector<QCPStatisticalBoxData>::iterator itEnd = tempData.end(); const QVector<QCPStatisticalBoxData>::iterator itEnd = tempData.end();
@ -27263,7 +27263,7 @@ void QCPFinancial::addData(const QVector<double> &keys, const QVector<double> &o
{ {
if (keys.size() != open.size() || open.size() != high.size() || high.size() != low.size() || low.size() != close.size() || close.size() != keys.size()) if (keys.size() != open.size() || open.size() != high.size() || high.size() != low.size() || low.size() != close.size() || close.size() != keys.size())
qDebug() << Q_FUNC_INFO << "keys, open, high, low, close have different sizes:" << keys.size() << open.size() << high.size() << low.size() << close.size(); qDebug() << Q_FUNC_INFO << "keys, open, high, low, close have different sizes:" << keys.size() << open.size() << high.size() << low.size() << close.size();
const int n = qMin(keys.size(), qMin(open.size(), qMin(high.size(), qMin(low.size(), close.size())))); const int n = static_cast<int>(qMin(keys.size(), qMin(open.size(), qMin(high.size(), qMin(low.size(), close.size())))));
QVector<QCPFinancialData> tempData(n); QVector<QCPFinancialData> tempData(n);
QVector<QCPFinancialData>::iterator it = tempData.begin(); QVector<QCPFinancialData>::iterator it = tempData.begin();
const QVector<QCPFinancialData>::iterator itEnd = tempData.end(); const QVector<QCPFinancialData>::iterator itEnd = tempData.end();
@ -27399,7 +27399,7 @@ QCPRange QCPFinancial::getValueRange(bool &foundRange, QCP::SignDomain inSignDom
QCPFinancialDataContainer QCPFinancial::timeSeriesToOhlc(const QVector<double> &time, const QVector<double> &value, double timeBinSize, double timeBinOffset) QCPFinancialDataContainer QCPFinancial::timeSeriesToOhlc(const QVector<double> &time, const QVector<double> &value, double timeBinSize, double timeBinOffset)
{ {
QCPFinancialDataContainer data; QCPFinancialDataContainer data;
int count = qMin(time.size(), value.size()); int count = static_cast<int>(qMin(time.size(), value.size()));
if (count == 0) if (count == 0)
return QCPFinancialDataContainer(); return QCPFinancialDataContainer();
@ -28140,7 +28140,7 @@ void QCPErrorBars::addData(const QVector<double> &errorMinus, const QVector<doub
{ {
if (errorMinus.size() != errorPlus.size()) if (errorMinus.size() != errorPlus.size())
qDebug() << Q_FUNC_INFO << "minus and plus error vectors have different sizes:" << errorMinus.size() << errorPlus.size(); qDebug() << Q_FUNC_INFO << "minus and plus error vectors have different sizes:" << errorMinus.size() << errorPlus.size();
const int n = qMin(errorMinus.size(), errorPlus.size()); const int n = static_cast<int>(qMin(errorMinus.size(), errorPlus.size()));
mDataContainer->reserve(n); mDataContainer->reserve(n);
for (int i=0; i<n; ++i) for (int i=0; i<n; ++i)
mDataContainer->append(QCPErrorBarsData(errorMinus.at(i), errorPlus.at(i))); mDataContainer->append(QCPErrorBarsData(errorMinus.at(i), errorPlus.at(i)));
@ -28178,7 +28178,7 @@ void QCPErrorBars::addData(double errorMinus, double errorPlus)
/* inherits documentation from base class */ /* inherits documentation from base class */
int QCPErrorBars::dataCount() const int QCPErrorBars::dataCount() const
{ {
return mDataContainer->size(); return static_cast<int>(mDataContainer->size());
} }
/* inherits documentation from base class */ /* inherits documentation from base class */
@ -28295,7 +28295,7 @@ int QCPErrorBars::findBegin(double sortKey, bool expandedRange) const
return 0; return 0;
int beginIndex = mDataPlottable->interface1D()->findBegin(sortKey, expandedRange); int beginIndex = mDataPlottable->interface1D()->findBegin(sortKey, expandedRange);
if (beginIndex >= mDataContainer->size()) if (beginIndex >= mDataContainer->size())
beginIndex = mDataContainer->size()-1; beginIndex = static_cast<int>(mDataContainer->size())-1;
return beginIndex; return beginIndex;
} else } else
qDebug() << Q_FUNC_INFO << "no data plottable set"; qDebug() << Q_FUNC_INFO << "no data plottable set";
@ -28311,7 +28311,7 @@ int QCPErrorBars::findEnd(double sortKey, bool expandedRange) const
return 0; return 0;
int endIndex = mDataPlottable->interface1D()->findEnd(sortKey, expandedRange); int endIndex = mDataPlottable->interface1D()->findEnd(sortKey, expandedRange);
if (endIndex > mDataContainer->size()) if (endIndex > mDataContainer->size())
endIndex = mDataContainer->size(); endIndex = static_cast<int>(mDataContainer->size());
return endIndex; return endIndex;
} else } else
qDebug() << Q_FUNC_INFO << "no data plottable set"; qDebug() << Q_FUNC_INFO << "no data plottable set";
@ -28692,7 +28692,7 @@ void QCPErrorBars::getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterato
// if the sort key isn't the main key, it's not possible to find a contiguous range of visible // if the sort key isn't the main key, it's not possible to find a contiguous range of visible
// data points, so this method then only applies the range restriction and otherwise returns // data points, so this method then only applies the range restriction and otherwise returns
// the full data range. Visibility checks must be done on a per-datapoin-basis during drawing // the full data range. Visibility checks must be done on a per-datapoin-basis during drawing
QCPDataRange dataRange(0, mDataContainer->size()); QCPDataRange dataRange(0, static_cast<int>(mDataContainer->size()));
dataRange = dataRange.bounded(rangeRestriction); dataRange = dataRange.bounded(rangeRestriction);
begin = mDataContainer->constBegin()+dataRange.begin(); begin = mDataContainer->constBegin()+dataRange.begin();
end = mDataContainer->constBegin()+dataRange.end(); end = mDataContainer->constBegin()+dataRange.end();
@ -28700,7 +28700,7 @@ void QCPErrorBars::getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterato
} }
// get visible data range via interface from data plottable, and then restrict to available error data points: // get visible data range via interface from data plottable, and then restrict to available error data points:
const int n = qMin(mDataContainer->size(), mDataPlottable->interface1D()->dataCount()); const int n = static_cast<int>(qMin(mDataContainer->size(), mDataPlottable->interface1D()->dataCount()));
int beginIndex = mDataPlottable->interface1D()->findBegin(keyAxis->range().lower); int beginIndex = mDataPlottable->interface1D()->findBegin(keyAxis->range().lower);
int endIndex = mDataPlottable->interface1D()->findEnd(keyAxis->range().upper); int endIndex = mDataPlottable->interface1D()->findEnd(keyAxis->range().upper);
int i = beginIndex; int i = beginIndex;
@ -28718,7 +28718,7 @@ void QCPErrorBars::getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterato
++i; ++i;
} }
QCPDataRange dataRange(beginIndex, endIndex); QCPDataRange dataRange(beginIndex, endIndex);
dataRange = dataRange.bounded(rangeRestriction.bounded(QCPDataRange(0, mDataContainer->size()))); dataRange = dataRange.bounded(rangeRestriction.bounded(QCPDataRange(0, static_cast<int>(mDataContainer->size()))));
begin = mDataContainer->constBegin()+dataRange.begin(); begin = mDataContainer->constBegin()+dataRange.begin();
end = mDataContainer->constBegin()+dataRange.end(); end = mDataContainer->constBegin()+dataRange.end();
} }
@ -32690,7 +32690,7 @@ QString QCPPolarAxisAngular::numberFormat() const
*/ */
int QCPPolarAxisAngular::radialAxisCount() const int QCPPolarAxisAngular::radialAxisCount() const
{ {
return mRadialAxes.size(); return static_cast<int>(mRadialAxes.size());
} }
/*! /*!
@ -34697,7 +34697,7 @@ void QCPPolarGraph::addData(const QVector<double> &keys, const QVector<double> &
{ {
if (keys.size() != values.size()) if (keys.size() != values.size())
qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size(); qDebug() << Q_FUNC_INFO << "keys and values have different sizes:" << keys.size() << values.size();
const int n = qMin(keys.size(), values.size()); const int n = static_cast<int>(qMin(keys.size(), values.size()));
QVector<QCPGraphData> tempData(n); QVector<QCPGraphData> tempData(n);
QVector<QCPGraphData>::iterator it = tempData.begin(); QVector<QCPGraphData>::iterator it = tempData.begin();
const QVector<QCPGraphData>::iterator itEnd = tempData.end(); const QVector<QCPGraphData>::iterator itEnd = tempData.end();
@ -35259,7 +35259,7 @@ void QCPPolarGraph::drawPolyline(QCPPainter *painter, const QVector<QPointF> &li
{ {
int i = 0; int i = 0;
bool lastIsNan = false; bool lastIsNan = false;
const int lineDataSize = lineData.size(); const int lineDataSize = static_cast<int>(lineData.size());
while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN
++i; ++i;
++i; // because drawing works in 1 point retrospect ++i; // because drawing works in 1 point retrospect
@ -35279,7 +35279,7 @@ void QCPPolarGraph::drawPolyline(QCPPainter *painter, const QVector<QPointF> &li
{ {
int segmentStart = 0; int segmentStart = 0;
int i = 0; int i = 0;
const int lineDataSize = lineData.size(); const int lineDataSize = static_cast<int>(lineData.size());
while (i < lineDataSize) while (i < lineDataSize)
{ {
if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block

View File

@ -1001,7 +1001,7 @@ public:
friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b); friend inline const QCPDataSelection operator-(const QCPDataRange& a, const QCPDataRange& b);
// getters: // getters:
int dataRangeCount() const { return mDataRanges.size(); } int dataRangeCount() const { return static_cast<int>(mDataRanges.size()); }
int dataPointCount() const; int dataPointCount() const;
QCPDataRange dataRange(int index=0) const; QCPDataRange dataRange(int index=0) const;
QList<QCPDataRange> dataRanges() const { return mDataRanges; } QList<QCPDataRange> dataRanges() const { return mDataRanges; }
@ -1405,8 +1405,8 @@ public:
virtual ~QCPLayoutGrid() Q_DECL_OVERRIDE; virtual ~QCPLayoutGrid() Q_DECL_OVERRIDE;
// getters: // getters:
int rowCount() const { return mElements.size(); } int rowCount() const { return static_cast<int>(mElements.size()); }
int columnCount() const { return mElements.size() > 0 ? mElements.first().size() : 0; } int columnCount() const { return mElements.size() > 0 ? static_cast<int>(mElements.first().size()) : 0; }
QList<double> columnStretchFactors() const { return mColumnStretchFactors; } QList<double> columnStretchFactors() const { return mColumnStretchFactors; }
QList<double> rowStretchFactors() const { return mRowStretchFactors; } QList<double> rowStretchFactors() const { return mRowStretchFactors; }
int columnSpacing() const { return mColumnSpacing; } int columnSpacing() const { return mColumnSpacing; }
@ -2615,7 +2615,7 @@ public:
QCPDataContainer(); QCPDataContainer();
// getters: // getters:
int size() const { return mData.size()-mPreallocSize; } int size() const { return static_cast<int>(mData.size()-mPreallocSize); }
bool isEmpty() const { return size() == 0; } bool isEmpty() const { return size() == 0; }
bool autoSqueeze() const { return mAutoSqueeze; } bool autoSqueeze() const { return mAutoSqueeze; }
@ -2906,7 +2906,7 @@ void QCPDataContainer<DataType>::add(const QVector<DataType> &data, bool already
return; return;
} }
const int n = data.size(); const int n = static_cast<int>(data.size());
const int oldSize = size(); const int oldSize = size();
if (alreadySorted && oldSize > 0 && !qcpLessThanSortKey<DataType>(*constBegin(), *(data.constEnd()-1))) // prepend if new data is sorted and keys are all smaller than or equal to existing ones if (alreadySorted && oldSize > 0 && !qcpLessThanSortKey<DataType>(*constBegin(), *(data.constEnd()-1))) // prepend if new data is sorted and keys are all smaller than or equal to existing ones
@ -4703,7 +4703,7 @@ void QCPAbstractPlottable1D<DataType>::drawPolyline(QCPPainter *painter, const Q
{ {
int i = 0; int i = 0;
bool lastIsNan = false; bool lastIsNan = false;
const int lineDataSize = lineData.size(); const int lineDataSize = static_cast<int>(lineData.size());
while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN while (i < lineDataSize && (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()))) // make sure first point is not NaN
++i; ++i;
++i; // because drawing works in 1 point retrospect ++i; // because drawing works in 1 point retrospect
@ -4723,7 +4723,7 @@ void QCPAbstractPlottable1D<DataType>::drawPolyline(QCPPainter *painter, const Q
{ {
int segmentStart = 0; int segmentStart = 0;
int i = 0; int i = 0;
const int lineDataSize = lineData.size(); const int lineDataSize = static_cast<int>(lineData.size());
while (i < lineDataSize) while (i < lineDataSize)
{ {
if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block if (qIsNaN(lineData.at(i).y()) || qIsNaN(lineData.at(i).x()) || qIsInf(lineData.at(i).y())) // NaNs create a gap in the line. Also filter Infs which make drawPolyline block
@ -5744,7 +5744,7 @@ public:
// non-virtual methods: // non-virtual methods:
QList<QCPBars*> bars() const { return mBars; } QList<QCPBars*> bars() const { return mBars; }
QCPBars* bars(int index) const; QCPBars* bars(int index) const;
int size() const { return mBars.size(); } int size() const { return static_cast<int>(mBars.size()); }
bool isEmpty() const { return mBars.isEmpty(); } bool isEmpty() const { return mBars.isEmpty(); }
void clear(); void clear();
bool contains(QCPBars *bars) const { return mBars.contains(bars); } bool contains(QCPBars *bars) const { return mBars.contains(bars); }