Skip to content
Permalink
Browse files

Replace deprecated qSort/qStableSort/qGreater/qLess with std:: algs

  • Loading branch information
nyalldawson committed Feb 7, 2017
1 parent 8408777 commit 3ed6f5b72a6b61967eb7aa322430581c45e7b69b
Showing with 99 additions and 99 deletions.
  1. +3 −3 src/analysis/network/qgsvectorlayerdirector.cpp
  2. +2 −2 src/analysis/vector/qgszonalstatistics.cpp
  3. +1 −1 src/app/composer/qgscomposer.cpp
  4. +1 −1 src/app/composer/qgscomposerlegendwidget.cpp
  5. +5 −5 src/app/qgisapp.cpp
  6. +2 −2 src/app/qgsattributeactiondialog.cpp
  7. +1 −1 src/app/qgsbrowserdockwidget.cpp
  8. +2 −2 src/core/composer/qgsatlascomposition.cpp
  9. +1 −1 src/core/composer/qgscomposerattributetablemodelv2.cpp
  10. +2 −2 src/core/composer/qgscomposerattributetablev2.cpp
  11. +1 −1 src/core/composer/qgscomposerhtml.cpp
  12. +1 −1 src/core/composer/qgscomposermapgrid.cpp
  13. +1 −1 src/core/composer/qgscomposermodel.cpp
  14. +2 −2 src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp
  15. +1 −1 src/core/layertree/qgslayertreemodel.cpp
  16. +2 −2 src/core/pal/costcalculator.cpp
  17. +1 −1 src/core/pal/feature.cpp
  18. +1 −1 src/core/pal/problem.cpp
  19. +1 −1 src/core/qgsbrowsermodel.cpp
  20. +1 −1 src/core/qgscolorramp.cpp
  21. +1 −1 src/core/qgsexpressioncontext.cpp
  22. +1 −1 src/core/qgsfeatureiterator.cpp
  23. +1 −1 src/core/qgshistogram.cpp
  24. +1 −1 src/core/qgslabelingengine.cpp
  25. +1 −1 src/core/qgsmaprendererjob.cpp
  26. +2 −2 src/core/qgsstatisticalsummary.cpp
  27. +1 −1 src/core/qgsvectordataprovider.cpp
  28. +1 −1 src/core/qgsvectorlayer.cpp
  29. +2 −2 src/core/qgsvectorlayereditbuffer.cpp
  30. +1 −1 src/core/qgsvectorlayerundocommand.cpp
  31. +1 −1 src/core/raster/qgscolorrampshader.cpp
  32. +4 −4 src/core/symbology-ng/qgscategorizedsymbolrenderer.cpp
  33. +9 −9 src/core/symbology-ng/qgsgraduatedsymbolrenderer.cpp
  34. +2 −2 src/core/symbology-ng/qgsrulebasedrenderer.cpp
  35. +4 −4 src/core/symbology-ng/qgssymbollayerutils.cpp
  36. +1 −1 src/gui/attributetable/qgsattributetablemodel.cpp
  37. +1 −1 src/gui/editorwidgets/qgsrelationreferencewidget.cpp
  38. +2 −2 src/gui/layertree/qgslayertreemapcanvasbridge.cpp
  39. +2 −2 src/gui/qgscolorschemelist.cpp
  40. +4 −4 src/gui/qgsgradientcolorrampdialog.cpp
  41. +2 −2 src/gui/qgshistogramwidget.cpp
  42. +1 −1 src/gui/qgsrasterformatsaveoptionswidget.cpp
  43. +1 −1 src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
  44. +1 −1 src/gui/symbology-ng/qgscategorizedsymbolrendererwidget.cpp
  45. +1 −1 src/plugins/geometry_checker/checks/qgsgeometryduplicatecheck.cpp
  46. +1 −1 src/plugins/grass/qgsgrassmoduleparam.cpp
  47. +1 −1 src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
  48. +3 −3 src/providers/gpx/gpsdata.cpp
  49. +1 −1 src/providers/grass/qgsgrassprovider.cpp
  50. +1 −1 src/providers/memory/qgsmemoryprovider.cpp
  51. +2 −2 src/providers/ogr/qgsogrprovider.cpp
  52. +1 −1 src/providers/postgres/qgspostgresprovider.cpp
  53. +2 −2 src/providers/wms/qgswmsprovider.cpp
  54. +1 −1 src/providers/wms/qgswmtsdimensions.cpp
  55. +4 −4 src/server/services/wms/qgsmediancut.cpp
  56. +2 −2 tests/src/core/testqgsspatialindex.cpp
@@ -233,7 +233,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const

QgsPointCompare pointCompare( builder->topologyTolerance() );

qSort( points.begin(), points.end(), pointCompare );
std::sort( points.begin(), points.end(), pointCompare );
QVector< QgsPoint >::iterator tmp = std::unique( points.begin(), points.end() );
points.resize( tmp - points.begin() );

@@ -243,7 +243,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
for ( i = 0; i < snappedPoints.size() ; ++i )
snappedPoints[ i ] = *( my_binary_search( points.begin(), points.end(), snappedPoints[ i ], pointCompare ) );

qSort( pointLengthMap.begin(), pointLengthMap.end(), TiePointInfoCompare );
std::sort( pointLengthMap.begin(), pointLengthMap.end(), TiePointInfoCompare );

{
// fill attribute list 'la'
@@ -264,7 +264,7 @@ void QgsVectorLayerDirector::makeGraph( QgsGraphBuilderInterface *builder, const
tmpAttr.push_back( *it2 );
}
}
qSort( tmpAttr.begin(), tmpAttr.end() );
std::sort( tmpAttr.begin(), tmpAttr.end() );

int lastAttrId = -1;
for ( it2 = tmpAttr.begin(); it2 != tmpAttr.end(); ++it2 )
@@ -277,7 +277,7 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
changeAttributeMap.insert( meanIndex, QVariant( mean ) );
if ( mStatistics & QgsZonalStatistics::Median )
{
qSort( featureStats.values.begin(), featureStats.values.end() );
std::sort( featureStats.values.begin(), featureStats.values.end() );
int size = featureStats.values.count();
bool even = ( size % 2 ) < 1;
double medianValue;
@@ -311,7 +311,7 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
if ( mStatistics & QgsZonalStatistics::Minority || mStatistics & QgsZonalStatistics::Majority )
{
QList<int> vals = featureStats.valueCount.values();
qSort( vals.begin(), vals.end() );
std::sort( vals.begin(), vals.end() );
if ( mStatistics & QgsZonalStatistics::Minority )
{
float minorityKey = featureStats.valueCount.key( vals.first() );
@@ -3984,7 +3984,7 @@ void QgsComposer::populatePrintComposersMenu()
if ( acts.size() > 1 )
{
// sort actions in case main app's aboutToShow slot has not yet
qSort( acts.begin(), acts.end(), cmpByText_ );
std::sort( acts.begin(), acts.end(), cmpByText_ );
}
mPrintComposersMenu->addActions( acts );
}
@@ -726,7 +726,7 @@ void QgsComposerLegendWidget::on_mRemoveToolButton_clicked()
Q_FOREACH ( QgsLayerTreeLayer* nodeLayer, nodesWithRemoval.keys() )
{
QList<int> toDelete = nodesWithRemoval[nodeLayer];
qSort( toDelete.begin(), toDelete.end(), qGreater<int>() );
std::sort( toDelete.begin(), toDelete.end(), std::greater<int>() );
QList<int> order = QgsMapLayerLegendUtils::legendNodeOrder( nodeLayer );

Q_FOREACH ( int i, toDelete )
@@ -1553,7 +1553,7 @@ void QgisApp::readSettings()
{
projectKeys.append( key.toInt() );
}
qSort( projectKeys );
std::sort( projectKeys.begin(), projectKeys.end() );

Q_FOREACH ( int key, projectKeys )
{
@@ -2108,7 +2108,7 @@ void QgisApp::createToolBars()
}

// sort actions in toolbar menu
qSort( toolbarMenuActions.begin(), toolbarMenuActions.end(), cmpByText_ );
std::sort( toolbarMenuActions.begin(), toolbarMenuActions.end(), cmpByText_ );

mToolbarMenu->addActions( toolbarMenuActions );

@@ -6930,7 +6930,7 @@ void QgisApp::on_mPrintComposersMenu_aboutToShow()
if ( acts.size() > 1 )
{
// sort actions by text
qSort( acts.begin(), acts.end(), cmpByText_ );
std::sort( acts.begin(), acts.end(), cmpByText_ );
}
mPrintComposersMenu->addActions( acts );
}
@@ -12040,7 +12040,7 @@ QMenu* QgisApp::createPopupMenu()
}
}

qSort( panels.begin(), panels.end(), cmpByText_ );
std::sort( panels.begin(), panels.end(), cmpByText_ );
QWidgetAction* panelstitle = new QWidgetAction( menu );
QLabel* plabel = new QLabel( QStringLiteral( "<b>%1</b>" ).arg( tr( "Panels" ) ) );
plabel->setMargin( 3 );
@@ -12058,7 +12058,7 @@ QMenu* QgisApp::createPopupMenu()
tlabel->setAlignment( Qt::AlignHCenter );
toolbarstitle->setDefaultWidget( tlabel );
menu->addAction( toolbarstitle );
qSort( toolbars.begin(), toolbars.end(), cmpByText_ );
std::sort( toolbars.begin(), toolbars.end(), cmpByText_ );
Q_FOREACH ( QAction* a, toolbars )
{
menu->addAction( a );
@@ -134,7 +134,7 @@ void QgsAttributeActionDialog::insertRow( int row, const QgsAction& action )
item = new QTableWidgetItem();
item->setFlags( item->flags() & ~( Qt::ItemIsEditable ) );
QStringList actionScopes = action.actionScopes().toList();
qSort( actionScopes );
std::sort( actionScopes.begin(), actionScopes.end() );
item->setText( actionScopes.join( QStringLiteral( ", " ) ) );
item->setData( Qt::UserRole, QVariant::fromValue<QSet<QString>>( action.actionScopes() ) );
mAttributeActionTable->setItem( row, ActionScopes, item );
@@ -338,7 +338,7 @@ void QgsAttributeActionDialog::itemDoubleClicked( QTableWidgetItem* item )

QTableWidgetItem* item = mAttributeActionTable->item( row, ActionScopes );
QStringList actionScopes = actionProperties.actionScopes().toList();
qSort( actionScopes );
std::sort( actionScopes.begin(), actionScopes.end() );
item->setText( actionScopes.join( QStringLiteral( ", " ) ) );
item->setData( Qt::UserRole, QVariant::fromValue<QSet<QString>>( actionProperties.actionScopes() ) );

@@ -551,7 +551,7 @@ void QgsBrowserDockWidget::addSelectedLayers()

// get a sorted list of selected indexes
QModelIndexList list = mBrowserView->selectionModel()->selectedIndexes();
qSort( list );
std::sort( list.begin(), list.end() );

// If any of the layer items are QGIS we just open and exit the loop
Q_FOREACH ( const QModelIndex& index, list )
@@ -202,7 +202,7 @@ int QgsAtlasComposition::updateFeatures()
if ( !mFeatureKeys.isEmpty() )
{
FieldSorter sorter( mFeatureKeys, mSortAscending );
qSort( mFeatureIds.begin(), mFeatureIds.end(), sorter );
std::sort( mFeatureIds.begin(), mFeatureIds.end(), sorter );
}

emit numberFeaturesChanged( mFeatureIds.size() );
@@ -750,7 +750,7 @@ void QgsAtlasComposition::setPredefinedScales( const QVector<qreal>& scales )
{
mPredefinedScales = scales;
// make sure the list is sorted
qSort( mPredefinedScales.begin(), mPredefinedScales.end() );
std::sort( mPredefinedScales.begin(), mPredefinedScales.end() );
}

QgsGeometry QgsAtlasComposition::currentGeometry( const QgsCoordinateReferenceSystem& crs ) const
@@ -406,7 +406,7 @@ bool QgsComposerAttributeTableColumnModelV2::moveColumnInSortRank( QgsComposerTa
sortedColumns.append( currentColumn );
}
}
qStableSort( sortedColumns.begin(), sortedColumns.end(), columnsBySortRank );
std::stable_sort( sortedColumns.begin(), sortedColumns.end(), columnsBySortRank );
int columnPos = sortedColumns.indexOf( column );

if (( columnPos == 0 && direction == ShiftUp )
@@ -526,7 +526,7 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co
{
c.setSortColumn( sortColumns.at( i ).first );
c.setAscending( sortColumns.at( i ).second );
qStableSort( contents.begin(), contents.end(), c );
std::stable_sort( contents.begin(), contents.end(), c );
}

recalculateTableSize();
@@ -608,7 +608,7 @@ QList<QPair<int, bool> > QgsComposerAttributeTableV2::sortAttributes() const
}

//sort columns by rank
qSort( sortedColumns.begin(), sortedColumns.end(), columnsBySortRank );
std::sort( sortedColumns.begin(), sortedColumns.end(), columnsBySortRank );

//generate list of column index, bool for sort direction (to match 2.0 api)
QList<QPair<int, bool> > attributesBySortRank;
@@ -405,7 +405,7 @@ double QgsComposerHtml::findNearbyPageBreak( double yPos )
}

//sort candidate rows by number of changes ascending, row number descending
qSort( candidates.begin(), candidates.end(), candidateSort );
std::sort( candidates.begin(), candidates.end(), candidateSort );
//first candidate is now the largest row with smallest number of changes

//ok, now take the mid point of the best candidate position
@@ -1974,7 +1974,7 @@ QgsComposerMapGrid::BorderSide QgsComposerMapGrid::borderForLineCoord( QPointF p
distanceToSide << qMakePair( p.y(), QgsComposerMapGrid::Top );
distanceToSide << qMakePair( mComposerMap->rect().height() - p.y(), QgsComposerMapGrid::Bottom );

qSort( distanceToSide.begin(), distanceToSide.end(), sortByDistance );
std::sort( distanceToSide.begin(), distanceToSide.end(), sortByDistance );
return distanceToSide.at( 0 ).second;
}

@@ -351,7 +351,7 @@ bool QgsComposerModel::dropMimeData( const QMimeData *data,
//move dropped items

//first sort them by z-order
qSort( droppedItems.begin(), droppedItems.end(), zOrderDescending );
std::sort( droppedItems.begin(), droppedItems.end(), zOrderDescending );

//calculate position in z order list to drop items at
int destPos = 0;
@@ -137,11 +137,11 @@ QgsValueRelationFieldFormatter::ValueRelationCache QgsValueRelationFieldFormatte

if ( config.value( "OrderByValue" ).toBool() )
{
qSort( cache.begin(), cache.end(), orderByValueLessThan );
std::sort( cache.begin(), cache.end(), orderByValueLessThan );
}
else
{
qSort( cache.begin(), cache.end(), orderByKeyLessThan );
std::sort( cache.begin(), cache.end(), orderByKeyLessThan );
}

return cache;
@@ -1005,7 +1005,7 @@ QMimeData* QgsLayerTreeModel::mimeData( const QModelIndexList& indexes ) const
{
// Sort the indexes. Depending on how the user selected the items, the indexes may be unsorted.
QModelIndexList sortedIndexes = indexes;
qSort( sortedIndexes.begin(), sortedIndexes.end(), qLess<QModelIndex>() );
std::sort( sortedIndexes.begin(), sortedIndexes.end(), std::less<QModelIndex>() );

QList<QgsLayerTreeNode*> nodesFinal = indexes2nodes( sortedIndexes, true );

@@ -109,7 +109,7 @@ void CostCalculator::setPolygonCandidatesCost( int nblp, QList< LabelPosition* >
{
toSort << lPos.at( i );
}
qSort( toSort.begin(), toSort.end(), candidateSortShrink );
std::sort( toSort.begin(), toSort.end(), candidateSortShrink );
for ( int i = 0; i < nblp; ++i )
{
lPos[i] = toSort.at( i );
@@ -181,7 +181,7 @@ int CostCalculator::finalizeCandidatesCosts( Feats* feat, int max_p, RTree <Feat
max_p = feat->lPos.count();
//
// sort candidates list, best label to worst
qSort( feat->lPos.begin(), feat->lPos.end(), candidateSortGrow );
std::sort( feat->lPos.begin(), feat->lPos.end(), candidateSortGrow );

// try to exclude all conflitual labels (good ones have cost < 1 by pruning)
double discrim = 0.0;
@@ -1601,7 +1601,7 @@ int FeaturePart::createCandidates( QList< LabelPosition*>& lPos,
}
}

qSort( lPos.begin(), lPos.end(), CostCalculator::candidateSortGrow );
std::sort( lPos.begin(), lPos.end(), CostCalculator::candidateSortGrow );
return lPos.count();
}

@@ -2277,7 +2277,7 @@ QList<LabelPosition*> * Problem::getSolution( bool returnInactive )
// if features collide, order by size, so smaller ones appear on top
if ( returnInactive )
{
qSort( solList->begin(), solList->end(), compareLabelArea );
std::sort( solList->begin(), solList->end(), compareLabelArea );
}

return solList;
@@ -153,7 +153,7 @@ void QgsBrowserModel::addRootItems()
QList<QgsDataItem *> providerGroup = providerMap.values( key );
if ( providerGroup.size() > 1 )
{
qSort( providerGroup.begin(), providerGroup.end(), cmpByDataItemName_ );
std::sort( providerGroup.begin(), providerGroup.end(), cmpByDataItemName_ );
}

Q_FOREACH ( QgsDataItem * ditem, providerGroup )
@@ -273,7 +273,7 @@ void QgsGradientColorRamp::setStops( const QgsGradientStopsList &stops )
mStops = stops;

//sort stops by offset
qSort( mStops.begin(), mStops.end(), stopLessThan );
std::sort( mStops.begin(), mStops.end(), stopLessThan );
}

void QgsGradientColorRamp::addStopsToGradient( QGradient* gradient, double alpha )
@@ -166,7 +166,7 @@ QStringList QgsExpressionContextScope::filteredVariableNames() const
filtered << variable;
}
QgsExpressionContextVariableCompare cmp( *this );
qSort( filtered.begin(), filtered.end(), cmp );
std::sort( filtered.begin(), filtered.end(), cmp );

return filtered;
}
@@ -165,7 +165,7 @@ void QgsAbstractFeatureIterator::setupOrderBy( const QList<QgsFeatureRequest::Or
mCachedFeatures.append( indexedFeature );
}

qSort( mCachedFeatures.begin(), mCachedFeatures.end(), QgsExpressionSorter( preparedOrderBys ) );
std::sort( mCachedFeatures.begin(), mCachedFeatures.end(), QgsExpressionSorter( preparedOrderBys ) );

mFeatureIterator = mCachedFeatures.constBegin();
mUseCachedFeatures = true;
@@ -31,7 +31,7 @@ QgsHistogram::QgsHistogram()

void QgsHistogram::prepareValues()
{
qSort( mValues.begin(), mValues.end() );
std::sort( mValues.begin(), mValues.end() );

QgsStatisticalSummary s;
s.setStatistics( QgsStatisticalSummary::Max | QgsStatisticalSummary::Min | QgsStatisticalSummary::InterQuartileRange );
@@ -327,7 +327,7 @@ void QgsLabelingEngine::run( QgsRenderContext& context )
painter->setRenderHint( QPainter::Antialiasing );

// sort labels
qSort( labels->begin(), labels->end(), QgsLabelSorter( mMapSettings ) );
std::sort( labels->begin(), labels->end(), QgsLabelSorter( mMapSettings ) );

// draw the labels
QList<pal::LabelPosition*>::iterator it = labels->begin();
@@ -383,7 +383,7 @@ void QgsMapRendererJob::logRenderingTime( const LayerRenderJobs& jobs )
elapsed.insert( job.renderingTime, job.layer ? job.layer->id() : QString() );

QList<int> tt( elapsed.uniqueKeys() );
qSort( tt.begin(), tt.end(), qGreater<int>() );
std::sort( tt.begin(), tt.end(), std::greater<int>() );
Q_FOREACH ( int t, tt )
{
QgsMessageLog::logMessage( tr( "%1 ms: %2" ).arg( t ).arg( QStringList( elapsed.values( t ) ).join( QStringLiteral( ", " ) ) ), tr( "Rendering" ) );
@@ -135,7 +135,7 @@ void QgsStatisticalSummary::finalize()
|| mStatistics & QgsStatisticalSummary::ThirdQuartile
|| mStatistics & QgsStatisticalSummary::InterQuartileRange )
{
qSort( mValues.begin(), mValues.end() );
std::sort( mValues.begin(), mValues.end() );
bool even = ( mCount % 2 ) < 1;
if ( even )
{
@@ -212,7 +212,7 @@ void QgsStatisticalSummary::finalize()
if ( mStatistics & QgsStatisticalSummary::Minority || mStatistics & QgsStatisticalSummary::Majority )
{
QList<int> valueCounts = mValueCount.values();
qSort( valueCounts.begin(), valueCounts.end() );
std::sort( valueCounts.begin(), valueCounts.end() );
if ( mStatistics & QgsStatisticalSummary::Minority )
{
mMinority = mValueCount.key( valueCounts.first() );
@@ -670,7 +670,7 @@ QStringList QgsVectorDataProvider::availableEncodings()
}

// Do case-insensitive sorting of encodings
qSort( sEncodings.begin(), sEncodings.end(), _compareEncodings );
std::sort( sEncodings.begin(), sEncodings.end(), _compareEncodings );

return sEncodings;
}
@@ -2327,7 +2327,7 @@ bool QgsVectorLayer::deleteAttributes( QList<int> attrs )
// Remove multiple occurrences of same attribute
attrs = attrs.toSet().toList();

qSort( attrs.begin(), attrs.end(), qGreater<int>() );
std::sort( attrs.begin(), attrs.end(), std::greater<int>() );

Q_FOREACH ( int attr, attrs )
{
@@ -678,7 +678,7 @@ void QgsVectorLayerEditBuffer::handleAttributeAdded( int index )
// go through renamed attributes and adapt
QList< int > sortedRenamedIndices = mRenamedAttributes.keys();
//sort keys
qSort( sortedRenamedIndices.begin(), sortedRenamedIndices.end(), qGreater< int >() );
std::sort( sortedRenamedIndices.begin(), sortedRenamedIndices.end(), std::greater< int >() );
Q_FOREACH ( int renameIndex, sortedRenamedIndices )
{
if ( renameIndex >= index )
@@ -717,7 +717,7 @@ void QgsVectorLayerEditBuffer::handleAttributeDeleted( int index )
// go through rename attributes and adapt
QList< int > sortedRenamedIndices = mRenamedAttributes.keys();
//sort keys
qSort( sortedRenamedIndices.begin(), sortedRenamedIndices.end() );
std::sort( sortedRenamedIndices.begin(), sortedRenamedIndices.end() );
int last = -1;
mRenamedAttributes.remove( index );
Q_FOREACH ( int renameIndex, sortedRenamedIndices )
@@ -417,7 +417,7 @@ void QgsVectorLayerUndoCommandDeleteAttribute::redo()
if ( mProviderField )
{
mBuffer->mDeletedAttributeIds.append( mOriginIndex );
qSort( mBuffer->mDeletedAttributeIds ); // keep it sorted
std::sort( mBuffer->mDeletedAttributeIds.begin(), mBuffer->mDeletedAttributeIds.end() ); // keep it sorted
}
else
{

0 comments on commit 3ed6f5b

Please sign in to comment.
You can’t perform that action at this time.