Skip to content

Commit

Permalink
qMin/qMax -> std::min/max
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 25, 2017
1 parent 641d78b commit 2d19279
Show file tree
Hide file tree
Showing 151 changed files with 452 additions and 452 deletions.
2 changes: 1 addition & 1 deletion src/analysis/interpolation/DualEdgeTriangulation.cc
Expand Up @@ -387,7 +387,7 @@ int DualEdgeTriangulation::addPoint( QgsPoint *p )
//Take the higher z-Value in case of two equal points
QgsPoint *newPoint = mPointVector[mPointVector.count() - 1];
QgsPoint *existingPoint = mPointVector[mTwiceInsPoint];
existingPoint->setZ( qMax( newPoint->z(), existingPoint->z() ) );
existingPoint->setZ( std::max( newPoint->z(), existingPoint->z() ) );

mPointVector.remove( mPointVector.count() - 1 );
delete newPoint;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/interpolation/MathUtils.cc
Expand Up @@ -253,8 +253,8 @@ bool MathUtils::inCircle( QgsPoint *testp, QgsPoint *p1, QgsPoint *p2, QgsPoint
double px = testp->x();
double py = testp->y();

double xmin = qMin( qMin( ax, px ), qMin( bx, cx ) );
double ymin = qMin( qMin( ay, py ), qMin( by, cy ) );
double xmin = std::min( std::min( ax, px ), std::min( bx, cx ) );
double ymin = std::min( std::min( ay, py ), std::min( by, cy ) );
ax -= xmin;
bx -= xmin;
cx -= xmin;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgshillshadefilter.cpp
Expand Up @@ -49,5 +49,5 @@ float QgsHillshadeFilter::processNineCellWindow( float *x11, float *x21, float *
{
aspect_rad = M_PI + std::atan2( derX, derY );
}
return qMax( 0.0, 255.0 * ( ( std::cos( zenith_rad ) * std::cos( slope_rad ) ) + ( std::sin( zenith_rad ) * std::sin( slope_rad ) * std::cos( azimuth_rad - aspect_rad ) ) ) );
return std::max( 0.0, 255.0 * ( ( std::cos( zenith_rad ) * std::cos( slope_rad ) ) + ( std::sin( zenith_rad ) * std::sin( slope_rad ) * std::cos( azimuth_rad - aspect_rad ) ) ) );
}
4 changes: 2 additions & 2 deletions src/analysis/raster/qgskde.cpp
Expand Up @@ -87,8 +87,8 @@ QgsKernelDensityEstimation::Result QgsKernelDensityEstimation::prepare()
if ( mBounds.isNull() )
return InvalidParameters;

int rows = qMax( std::ceil( mBounds.height() / mPixelSize ) + 1, 1.0 );
int cols = qMax( std::ceil( mBounds.width() / mPixelSize ) + 1, 1.0 );
int rows = std::max( std::ceil( mBounds.height() / mPixelSize ) + 1, 1.0 );
int cols = std::max( std::ceil( mBounds.width() / mPixelSize ) + 1, 1.0 );

if ( !createEmptyLayer( driver, mBounds, rows, cols ) )
return FileCreationError;
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/vector/qgsgeometrysnapper.cpp
Expand Up @@ -233,8 +233,8 @@ const QgsSnapIndex::Cell *QgsSnapIndex::GridRow::getCell( int col ) const

QList<QgsSnapIndex::SnapItem *> QgsSnapIndex::GridRow::getSnapItems( int colStart, int colEnd ) const
{
colStart = qMax( colStart, mColStartIdx );
colEnd = qMin( colEnd, mColStartIdx + mCells.size() - 1 );
colStart = std::max( colStart, mColStartIdx );
colEnd = std::min( colEnd, mColStartIdx + mCells.size() - 1 );

QList<SnapItem *> items;

Expand Down Expand Up @@ -403,8 +403,8 @@ QgsSnapIndex::SnapItem *QgsSnapIndex::getSnapItem( const QgsPoint &pos, double t
int colEnd = std::floor( ( pos.x() + tol - mOrigin.x() ) / mCellSize );
int rowEnd = std::floor( ( pos.y() + tol - mOrigin.y() ) / mCellSize );

rowStart = qMax( rowStart, mRowsStartIdx );
rowEnd = qMin( rowEnd, mRowsStartIdx + mGridRows.size() - 1 );
rowStart = std::max( rowStart, mRowsStartIdx );
rowEnd = std::min( rowEnd, mRowsStartIdx + mGridRows.size() - 1 );

QList<SnapItem *> items;
for ( int row = rowStart; row <= rowEnd; ++row )
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/vector/qgszonalstatistics.h
Expand Up @@ -98,8 +98,8 @@ class ANALYSIS_EXPORT QgsZonalStatistics
sum += value;
++count;
}
min = qMin( min, value );
max = qMax( max, value );
min = std::min( min, value );
max = std::max( max, value );
if ( mStoreValueCounts )
valueCount.insert( value, valueCount.value( value, 0 ) + 1 );
if ( mStoreValues )
Expand Down
2 changes: 1 addition & 1 deletion src/app/nodetool/qgsnodetool.cpp
Expand Up @@ -976,7 +976,7 @@ void QgsNodeTool::deleteNodeEditorSelection()
if ( mSelectedFeature->geometry()->type() == QgsWkbTypes::LineGeometry )
{
// for lines we don't wrap around vertex selection when deleting nodes from end of line
nextVertexToSelect = qMin( nextVertexToSelect, mSelectedFeature->geometry()->geometry()->nCoordinates() - 1 );
nextVertexToSelect = std::min( nextVertexToSelect, mSelectedFeature->geometry()->geometry()->nCoordinates() - 1 );
}

_safeSelectVertex( *mSelectedFeature, nextVertexToSelect );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsaddattrdialog.cpp
Expand Up @@ -86,7 +86,7 @@ void QgsAddAttrDialog::setPrecisionMinMax()
mPrec->setVisible( minPrecType < maxPrecType );
mPrecLabel->setVisible( minPrecType < maxPrecType );
mPrec->setMinimum( minPrecType );
mPrec->setMaximum( qMax( minPrecType, qMin( maxPrecType, mLength->value() ) ) );
mPrec->setMaximum( std::max( minPrecType, std::min( maxPrecType, mLength->value() ) ) );
}

void QgsAddAttrDialog::accept()
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsattributetabledialog.cpp
Expand Up @@ -344,7 +344,7 @@ void QgsAttributeTableDialog::updateTitle()
QWidget *w = mDock ? qobject_cast<QWidget *>( mDock ) : qobject_cast<QWidget *>( this );
w->setWindowTitle( tr( " %1 :: Features Total: %2, Filtered: %3, Selected: %4" )
.arg( mLayer->name() )
.arg( qMax( static_cast< long >( mMainView->featureCount() ), mLayer->featureCount() ) ) // layer count may be estimated, so use larger of the two
.arg( std::max( static_cast< long >( mMainView->featureCount() ), mLayer->featureCount() ) ) // layer count may be estimated, so use larger of the two
.arg( mMainView->filteredFeatureCount() )
.arg( mLayer->selectedFeatureCount() )
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsdiagramproperties.cpp
Expand Up @@ -593,7 +593,7 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
while ( features.nextFeature( *&feature ) )
{
context.setFeature( feature );
maxValue = qMax( maxValue, exp.evaluate( &context ).toFloat() );
maxValue = std::max( maxValue, exp.evaluate( &context ).toFloat() );
}
}
else
Expand Down Expand Up @@ -689,7 +689,7 @@ void QgsDiagramProperties::apply()
bool ok = false;
double val = provider->maximumValue( fld ).toDouble( &ok );
if ( ok )
maxVal = qMax( maxVal, val );
maxVal = std::max( maxVal, val );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfieldcalculator.cpp
Expand Up @@ -481,7 +481,7 @@ void QgsFieldCalculator::setPrecisionMinMax()
int maxPrecType = mOutputFieldTypeComboBox->itemData( idx, Qt::UserRole + 5 ).toInt();
mOutputFieldPrecisionSpinBox->setEnabled( minPrecType < maxPrecType );
mOutputFieldPrecisionSpinBox->setMinimum( minPrecType );
mOutputFieldPrecisionSpinBox->setMaximum( qMax( minPrecType, qMin( maxPrecType, mOutputFieldWidthSpinBox->value() ) ) );
mOutputFieldPrecisionSpinBox->setMaximum( std::max( minPrecType, std::min( maxPrecType, mOutputFieldWidthSpinBox->value() ) ) );
}

void QgsFieldCalculator::showHelp()
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -234,7 +234,7 @@ QSize QgsIdentifyResultsWebView::sizeHint() const
// correct size, see #9377.
int max = widget->size().height() * 0.9;
QgsDebugMsg( QString( "parent widget height = %1 max height = %2" ).arg( widget->size().height() ).arg( max ) );
height = qMin( height, max );
height = std::min( height, max );
}
else
{
Expand All @@ -243,7 +243,7 @@ QSize QgsIdentifyResultsWebView::sizeHint() const

// Always keep some minimum size, e.g. if page is not yet loaded
// or parent has wrong size
height = qMax( height, 100 );
height = std::max( height, 100 );

s = QSize( size().width(), height );
QgsDebugMsg( QString( "size: %1 x %2" ).arg( s.width() ).arg( s.height() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmeasuredialog.cpp
Expand Up @@ -281,7 +281,7 @@ QString QgsMeasureDialog::formatDistance( double distance, bool convertUnits ) c
// special handling for degrees - because we can't use smaller units (eg m->mm), we need to make sure there's
// enough decimal places to show a usable measurement value
int minPlaces = std::round( std::log10( 1.0 / distance ) ) + 1;
decimals = qMax( decimals, minPlaces );
decimals = std::max( decimals, minPlaces );
}
return QgsDistanceArea::formatDistance( distance, decimals, mDistanceUnits, baseUnit );
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -1281,8 +1281,8 @@ void QgsRasterLayerProperties::adjustTransparencyCellWidth( int row, int column
QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( tableTransparency->cellWidget( row, column ) );
if ( !lineEdit ) return;

int width = qMax( lineEdit->fontMetrics().width( lineEdit->text() ) + 10, 100 );
width = qMax( width, tableTransparency->columnWidth( column ) );
int width = std::max( lineEdit->fontMetrics().width( lineEdit->text() ) + 10, 100 );
width = std::max( width, tableTransparency->columnWidth( column ) );

lineEdit->setFixedWidth( width );
}
Expand Down Expand Up @@ -1850,4 +1850,4 @@ void QgsRasterLayerProperties::onCancel()
void QgsRasterLayerProperties::showHelp()
{
QgsHelp::openHelp( QStringLiteral( "working_with_raster/raster_properties.html" ) );
}
}
4 changes: 2 additions & 2 deletions src/app/qgsrulebasedlabelingwidget.cpp
Expand Up @@ -587,8 +587,8 @@ QgsLabelingRulePropsWidget::QgsLabelingRulePropsWidget( QgsRuleBasedLabeling::Ru
{
groupScale->setChecked( true );
// caution: rule uses scale denom, scale widget uses true scales
mScaleRangeWidget->setMaximumScale( qMax( rule->maximumScale(), 0.0 ) );
mScaleRangeWidget->setMinimumScale( qMax( rule->minimumScale(), 0.0 ) );
mScaleRangeWidget->setMaximumScale( std::max( rule->maximumScale(), 0.0 ) );
mScaleRangeWidget->setMinimumScale( std::max( rule->minimumScale(), 0.0 ) );
}
mScaleRangeWidget->setMapCanvas( mMapCanvas );

Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsvariantdelegate.cpp
Expand Up @@ -190,10 +190,10 @@ void QgsVariantDelegate::setModelData( QWidget *editor, QAbstractItemModel *mode
break;
case QVariant::Color:
( void )mColorExp.exactMatch( text );
value = QColor( qMin( mColorExp.cap( 1 ).toInt(), 255 ),
qMin( mColorExp.cap( 2 ).toInt(), 255 ),
qMin( mColorExp.cap( 3 ).toInt(), 255 ),
qMin( mColorExp.cap( 4 ).toInt(), 255 ) );
value = QColor( std::min( mColorExp.cap( 1 ).toInt(), 255 ),
std::min( mColorExp.cap( 2 ).toInt(), 255 ),
std::min( mColorExp.cap( 3 ).toInt(), 255 ),
std::min( mColorExp.cap( 4 ).toInt(), 255 ) );
break;
case QVariant::Date:
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgswelcomepageitemsmodel.cpp
Expand Up @@ -117,7 +117,7 @@ QSize QgsWelcomePageItemDelegate::sizeHint( const QStyleOptionViewItem &option,
index.data( QgsWelcomePageItemsModel::CrsRole ).toString() ) );
doc.setTextWidth( width - ( !icon.isNull() ? icon.width() + 35 : 35 ) );

return QSize( width, qMax( ( double ) doc.size().height() + 10, ( double )icon.height() ) + 20 );
return QSize( width, std::max( ( double ) doc.size().height() + 10, ( double )icon.height() ) + 20 );
}

QgsWelcomePageItemsModel::QgsWelcomePageItemsModel( QObject *parent )
Expand Down
10 changes: 5 additions & 5 deletions src/core/composer/qgscomposerarrow.cpp
Expand Up @@ -380,8 +380,8 @@ double QgsComposerArrow::computeMarkerMargin() const
}
else if ( mMarkerMode == SVGMarker )
{
double maxArrowHeight = qMax( mStartArrowHeadHeight, mStopArrowHeadHeight );
margin = mPen.widthF() / 2 + qMax( mArrowHeadWidth / 2.0, maxArrowHeight / 2.0 );
double maxArrowHeight = std::max( mStartArrowHeadHeight, mStopArrowHeadHeight );
margin = mPen.widthF() / 2 + std::max( mArrowHeadWidth / 2.0, maxArrowHeight / 2.0 );
}
}
else
Expand All @@ -398,8 +398,8 @@ double QgsComposerArrow::computeMarkerMargin() const
{
double startMarkerMargin = std::sqrt( 0.25 * ( mStartArrowHeadHeight * mStartArrowHeadHeight + mArrowHeadWidth * mArrowHeadWidth ) );
double stopMarkerMargin = std::sqrt( 0.25 * ( mStopArrowHeadHeight * mStopArrowHeadHeight + mArrowHeadWidth * mArrowHeadWidth ) );
double markerMargin = qMax( startMarkerMargin, stopMarkerMargin );
margin = qMax( mPen.widthF() / std::sqrt( 2.0 ), markerMargin );
double markerMargin = std::max( startMarkerMargin, stopMarkerMargin );
margin = std::max( mPen.widthF() / std::sqrt( 2.0 ), markerMargin );
}
}
return margin;
Expand All @@ -408,7 +408,7 @@ double QgsComposerArrow::computeMarkerMargin() const
void QgsComposerArrow::adaptItemSceneRect()
{
//rectangle containing start and end point
QRectF rect = QRectF( qMin( mStartPoint.x(), mStopPoint.x() ), qMin( mStartPoint.y(), mStopPoint.y() ),
QRectF rect = QRectF( std::min( mStartPoint.x(), mStopPoint.x() ), std::min( mStartPoint.y(), mStopPoint.y() ),
std::fabs( mStopPoint.x() - mStartPoint.x() ), std::fabs( mStopPoint.y() - mStartPoint.y() ) );
double enlarge = computeMarkerMargin();
rect.adjust( -enlarge, -enlarge, enlarge, enlarge );
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposerattributetablemodelv2.cpp