Skip to content
Permalink
Browse files

[qt6] The return type of size() is long long

Prepare for the return type of size() to be long long
  • Loading branch information
m-kuhn authored and nyalldawson committed Mar 25, 2021
1 parent ebb2c61 commit c205b2705e42547a5846eb16277d89d0209d4bb3
@@ -85,7 +85,7 @@ QList<double> QgsClassificationJenks::calculateBreaks( double &minimum, double &
// is larger. This will produce a more representative sample for very large
// layers, but could end up being computationally intensive...

sample.resize( std::max( mMaximumSize, values.size() / 10 ) );
sample.resize( std::max( mMaximumSize, static_cast<int>( values.size() ) / 10 ) );

QgsDebugMsgLevel( QStringLiteral( "natural breaks (jenks) sample size: %1" ).arg( sample.size() ), 2 );
QgsDebugMsgLevel( QStringLiteral( "values:%1" ).arg( values.size() ), 2 );
@@ -74,13 +74,13 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsFeature &feature, const QgsRen
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.height() ) / ( is.upperValue - is.lowerValue ) );
size.scale( s.barWidth * s.categoryAttributes.size() + spacing * std::max( 0, s.categoryAttributes.size() - 1 ), maxValue * mScaleFactor, Qt::IgnoreAspectRatio );
size.scale( s.barWidth * s.categoryAttributes.size() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 ), maxValue * mScaleFactor, Qt::IgnoreAspectRatio );
break;

case QgsDiagramSettings::Right:
case QgsDiagramSettings::Left:
mScaleFactor = ( ( is.upperSize.width() - is.lowerSize.width() ) / ( is.upperValue - is.lowerValue ) );
size.scale( maxValue * mScaleFactor, s.barWidth * s.categoryAttributes.size() + spacing * std::max( 0, s.categoryAttributes.size() - 1 ), Qt::IgnoreAspectRatio );
size.scale( maxValue * mScaleFactor, s.barWidth * s.categoryAttributes.size() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 ), Qt::IgnoreAspectRatio );
break;
}

@@ -143,13 +143,13 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributes &attributes, const
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
mScaleFactor = maxValue / s.size.height();
size.scale( s.barWidth * s.categoryColors.size() + spacing * std::max( 0, s.categoryAttributes.size() - 1 ), s.size.height(), Qt::IgnoreAspectRatio );
size.scale( s.barWidth * s.categoryColors.size() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 ), s.size.height(), Qt::IgnoreAspectRatio );
break;

case QgsDiagramSettings::Right:
case QgsDiagramSettings::Left:
mScaleFactor = maxValue / s.size.width();
size.scale( s.size.width(), s.barWidth * s.categoryColors.size() + spacing * std::max( 0, s.categoryAttributes.size() - 1 ), Qt::IgnoreAspectRatio );
size.scale( s.size.width(), s.barWidth * s.categoryColors.size() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 ), Qt::IgnoreAspectRatio );
break;
}

@@ -232,11 +232,11 @@ void QgsHistogramDiagram::renderDiagram( const QgsFeature &feature, QgsRenderCon
break;

case QgsDiagramSettings::Right:
p->drawRect( QRectF( baseX, baseY - scaledWidth * values.size() - spacing * std::max( 0, values.size() - 1 ) + currentOffset, length, scaledWidth ) );
p->drawRect( QRectF( baseX, baseY - scaledWidth * values.size() - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) + currentOffset, length, scaledWidth ) );
break;

case QgsDiagramSettings::Left:
p->drawRect( QRectF( baseX + scaledMaxVal, baseY - scaledWidth * values.size() - spacing * std::max( 0, values.size() - 1 ) + currentOffset, 0 - length, scaledWidth ) );
p->drawRect( QRectF( baseX + scaledMaxVal, baseY - scaledWidth * values.size() - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) + currentOffset, 0 - length, scaledWidth ) );
break;
}

@@ -250,22 +250,22 @@ void QgsHistogramDiagram::renderDiagram( const QgsFeature &feature, QgsRenderCon
switch ( s.diagramOrientation )
{
case QgsDiagramSettings::Up:
axisPoints << QPointF( baseX, baseY - scaledMaxVal ) << QPointF( baseX, baseY ) << QPointF( baseX + scaledWidth * values.size() + spacing * std::max( 0, values.size() - 1 ), baseY );
axisPoints << QPointF( baseX, baseY - scaledMaxVal ) << QPointF( baseX, baseY ) << QPointF( baseX + scaledWidth * values.size() + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ), baseY );
break;

case QgsDiagramSettings::Down:
axisPoints << QPointF( baseX, baseY ) << QPointF( baseX, baseY - scaledMaxVal ) << QPointF( baseX + scaledWidth * values.size() + spacing * std::max( 0, values.size() - 1 ), baseY - scaledMaxVal );
axisPoints << QPointF( baseX, baseY ) << QPointF( baseX, baseY - scaledMaxVal ) << QPointF( baseX + scaledWidth * values.size() + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ), baseY - scaledMaxVal );
break;

case QgsDiagramSettings::Right:
axisPoints << QPointF( baseX + scaledMaxVal, baseY - scaledWidth * values.size() - spacing * std::max( 0, values.size() - 1 ) )
<< QPointF( baseX, baseY - scaledWidth * values.size() - spacing * std::max( 0, values.size() - 1 ) )
axisPoints << QPointF( baseX + scaledMaxVal, baseY - scaledWidth * values.size() - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) )
<< QPointF( baseX, baseY - scaledWidth * values.size() - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) )
<< QPointF( baseX, baseY );
break;

case QgsDiagramSettings::Left:
axisPoints << QPointF( baseX, baseY - scaledWidth * values.size() - spacing * std::max( 0, values.size() - 1 ) )
<< QPointF( baseX + scaledMaxVal, baseY - scaledWidth * values.size() - spacing * std::max( 0, values.size() - 1 ) )
axisPoints << QPointF( baseX, baseY - scaledWidth * values.size() - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) )
<< QPointF( baseX + scaledMaxVal, baseY - scaledWidth * values.size() - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) )
<< QPointF( baseX + scaledMaxVal, baseY );
break;
}
@@ -75,15 +75,15 @@ QSizeF QgsStackedBarDiagram::diagramSize( const QgsFeature &feature, const QgsRe
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
{
const double totalBarLength = size.height() + spacing * std::max( 0, s.categoryAttributes.size() - 1 );
const double totalBarLength = size.height() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 );
size = QSizeF( s.barWidth, totalBarLength );
break;
}

case QgsDiagramSettings::Right:
case QgsDiagramSettings::Left:
{
const double totalBarLength = size.width() + spacing * std::max( 0, s.categoryAttributes.size() - 1 );
const double totalBarLength = size.width() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 );
size = QSizeF( totalBarLength, s.barWidth );
break;
}
@@ -140,12 +140,12 @@ QSizeF QgsStackedBarDiagram::diagramSize( const QgsAttributes &attributes, const
{
case QgsDiagramSettings::Up:
case QgsDiagramSettings::Down:
size.scale( s.barWidth, s.size.height() + spacing * std::max( 0, s.categoryAttributes.size() - 1 ), Qt::IgnoreAspectRatio );
size.scale( s.barWidth, s.size.height() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 ), Qt::IgnoreAspectRatio );
break;

case QgsDiagramSettings::Right:
case QgsDiagramSettings::Left:
size.scale( s.size.width() + spacing * std::max( 0, s.categoryAttributes.size() - 1 ), s.barWidth, Qt::IgnoreAspectRatio );
size.scale( s.size.width() + spacing * std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 ), s.barWidth, Qt::IgnoreAspectRatio );
break;
}

@@ -192,7 +192,7 @@ void QgsStackedBarDiagram::renderDiagram( const QgsFeature &feature, QgsRenderCo


const double spacing = c.convertToPainterUnits( s.spacing(), s.spacingUnit(), s.spacingMapUnitScale() );
const double totalSpacing = std::max( 0, s.categoryAttributes.size() - 1 ) * spacing;
const double totalSpacing = std::max( 0, static_cast<int>( s.categoryAttributes.size() ) - 1 ) * spacing;

double scaledMaxVal = 0;
switch ( s.diagramOrientation )
@@ -254,15 +254,15 @@ void QgsStackedBarDiagram::renderDiagram( const QgsFeature &feature, QgsRenderCo
break;

case QgsDiagramSettings::Down:
p->drawRect( QRectF( baseX, baseY + currentOffset - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ), scaledWidth, length ) );
p->drawRect( QRectF( baseX, baseY + currentOffset - scaledMaxVal - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ), scaledWidth, length ) );
break;

case QgsDiagramSettings::Right:
p->drawRect( QRectF( baseX + currentOffset, baseY - scaledWidth, length, scaledWidth ) );
break;

case QgsDiagramSettings::Left:
p->drawRect( QRectF( baseX + scaledMaxVal - currentOffset + spacing * std::max( 0, values.size() - 1 ), baseY - scaledWidth, 0 - length, scaledWidth ) );
p->drawRect( QRectF( baseX + scaledMaxVal - currentOffset + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ), baseY - scaledWidth, 0 - length, scaledWidth ) );
break;
}

@@ -276,27 +276,27 @@ void QgsStackedBarDiagram::renderDiagram( const QgsFeature &feature, QgsRenderCo
switch ( s.diagramOrientation )
{
case QgsDiagramSettings::Up:
axisPoints << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ) )
axisPoints << QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) )
<< QPointF( baseX, baseY - axisOffset )
<< QPointF( baseX + scaledWidth, baseY - axisOffset );
break;

case QgsDiagramSettings::Down:
axisPoints << QPointF( baseX, baseY )
<< QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ) + axisOffset )
<< QPointF( baseX + scaledWidth, baseY - scaledMaxVal - spacing * std::max( 0, values.size() - 1 ) + axisOffset );
<< QPointF( baseX, baseY - scaledMaxVal - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) + axisOffset )
<< QPointF( baseX + scaledWidth, baseY - scaledMaxVal - spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) + axisOffset );
break;

case QgsDiagramSettings::Right:
axisPoints << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, values.size() - 1 ), baseY - scaledWidth )
axisPoints << QPointF( baseX + scaledMaxVal + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ), baseY - scaledWidth )
<< QPointF( baseX + axisOffset, baseY - scaledWidth )
<< QPointF( baseX + axisOffset, baseY );
break;

case QgsDiagramSettings::Left:
axisPoints << QPointF( baseX, baseY - scaledWidth )
<< QPointF( baseX + scaledMaxVal + spacing * std::max( 0, values.size() - 1 ) - axisOffset, baseY - scaledWidth )
<< QPointF( baseX + scaledMaxVal + spacing * std::max( 0, values.size() - 1 ) - axisOffset, baseY );
<< QPointF( baseX + scaledMaxVal + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) - axisOffset, baseY - scaledWidth )
<< QPointF( baseX + scaledMaxVal + spacing * std::max( 0, static_cast<int>( values.size() ) - 1 ) - axisOffset, baseY );
break;
}

@@ -78,6 +78,7 @@ class CORE_EXPORT QgsWkbPtr
inline const QgsWkbPtr &operator>>( double &v ) const { read( v ); return *this; } SIP_SKIP
inline const QgsWkbPtr &operator>>( float &r ) const { double v; read( v ); r = v; return *this; } SIP_SKIP
inline const QgsWkbPtr &operator>>( int &v ) const { read( v ); return *this; } SIP_SKIP
inline const QgsWkbPtr &operator>>( qsizetype &r ) const { int v; read( v ); r = v; return *this; } SIP_SKIP
inline const QgsWkbPtr &operator>>( unsigned int &v ) const { read( v ); return *this; } SIP_SKIP
inline const QgsWkbPtr &operator>>( char &v ) const { read( v ); return *this; } SIP_SKIP
inline const QgsWkbPtr &operator>>( QgsWkbTypes::Type &v ) const { read( v ); return *this; } SIP_SKIP
@@ -88,6 +89,8 @@ class CORE_EXPORT QgsWkbPtr
inline QgsWkbPtr &operator<<( float r ) { double v = r; write( v ); return *this; } SIP_SKIP
//! Writes an int to the pointer
inline QgsWkbPtr &operator<<( int v ) { write( v ); return *this; } SIP_SKIP
//! Writes a size as int to the pointer
inline QgsWkbPtr &operator<<( qsizetype r ) { int v = r; write( v ); return *this; } SIP_SKIP
//! Writes an unsigned int to the pointer
inline QgsWkbPtr &operator<<( unsigned int v ) { write( v ); return *this; } SIP_SKIP
//! Writes a char to the pointer
@@ -151,7 +151,7 @@ void QgsLocator::fetchResults( const QString &string, const QgsLocatorContext &c

QList< QgsLocatorFilter * > activeFilters;
QString searchString = string;
QString prefix = searchString.left( std::max( searchString.indexOf( ' ' ), 0 ) );
QString prefix = searchString.left( std::max( static_cast<int>( searchString.indexOf( ' ' ) ), 0 ) );
if ( !prefix.isEmpty() )
{
for ( QgsLocatorFilter *filter : std::as_const( mFilters ) )
@@ -101,10 +101,10 @@ void QgsFileDownloader::onSslErrors( QNetworkReply *reply, const QList<QSslError
QStringList errorMessages;
errorMessages.reserve( errors.size() + 1 );
errorMessages << QStringLiteral( "SSL Errors: " );
for ( auto end = errors.size(), i = 0; i != end; ++i )
{
errorMessages << errors[i].errorString();
}

for ( const QSslError &error : errors )
errorMessages << error.errorString();

error( errorMessages );
}
}
@@ -113,10 +113,9 @@ void QgsFileDownloader::onSslErrors( QNetworkReply *reply, const QList<QSslError

void QgsFileDownloader::error( const QStringList &errorMessages )
{
for ( auto end = errorMessages.size(), i = 0; i != end; ++i )
{
mErrors << errorMessages[i];
}
for ( const QString &error : errorMessages )
mErrors << error;

if ( mReply )
mReply->abort();
emit downloadError( mErrors );
@@ -1961,7 +1961,7 @@ void QgsTemplatedLineSymbolLayerBase::renderOffsetVertexAlongLine( const QPolygo

int pointIncrement = distance > 0 ? 1 : -1;
QPointF previousPoint = points[vertex];
int startPoint = distance > 0 ? std::min( vertex + 1, points.count() - 1 ) : std::max( vertex - 1, 0 );
int startPoint = distance > 0 ? std::min( vertex + 1, static_cast<int>( points.count() ) - 1 ) : std::max( vertex - 1, 0 );
int endPoint = distance > 0 ? points.count() - 1 : 0;
double distanceLeft = std::fabs( distance );

@@ -1646,7 +1646,7 @@ void QgsTextRenderer::drawTextInternalVertical( QgsRenderContext &context, const
int maxLineLength = 0;
for ( const QString &line : std::as_const( textLines ) )
{
maxLineLength = std::max( maxLineLength, line.length() );
maxLineLength = std::max( maxLineLength, static_cast<int>( line.length() ) );
}
double actualLabelHeight = fontMetrics->ascent() / fontScale + ( fontMetrics->ascent() / fontScale + letterSpacing ) * ( maxLineLength - 1 );
double ascentOffset = fontMetrics->ascent() / fontScale;

0 comments on commit c205b27

Please sign in to comment.