Skip to content
Permalink
Browse files

Change size()/count() == 0 and count() > 0 to isEmpty() checks

Because:
- easier to read
- follows recommendations by clazy/KDAB
- potentially performance benefits
  • Loading branch information
nyalldawson committed Dec 8, 2015
1 parent 269f709 commit ee720796a3f1ab80ec638bd88be9f7ffe8a0cab0
Showing with 489 additions and 489 deletions.
  1. +4 −4 src/analysis/interpolation/DualEdgeTriangulation.cc
  2. +1 −1 src/analysis/interpolation/NormVecDecorator.cc
  3. +1 −1 src/analysis/raster/qgsrelief.cpp
  4. +3 −3 src/app/composer/qgscomposer.cpp
  5. +1 −1 src/app/composer/qgscomposermanager.cpp
  6. +1 −1 src/app/composer/qgscomposermapwidget.cpp
  7. +1 −1 src/app/legend/qgsapplegendinterface.cpp
  8. +3 −3 src/app/nodetool/qgsmaptoolnodetool.cpp
  9. +1 −1 src/app/ogr/qgsopenvectorlayerdialog.cpp
  10. +25 −25 src/app/qgisapp.cpp
  11. +1 −1 src/app/qgsaddtaborgroup.cpp
  12. +1 −1 src/app/qgsbookmarks.cpp
  13. +1 −1 src/app/qgsbrowserdockwidget.cpp
  14. +1 −1 src/app/qgsconfigureshortcutsdialog.cpp
  15. +1 −1 src/app/qgsdiagramproperties.cpp
  16. +5 −5 src/app/qgsfieldsproperties.cpp
  17. +1 −1 src/app/qgshandlebadlayers.cpp
  18. +4 −4 src/app/qgsidentifyresultsdialog.cpp
  19. +1 −1 src/app/qgsjoindialog.cpp
  20. +1 −1 src/app/qgsmaptoolchangelabelproperties.cpp
  21. +2 −2 src/app/qgsmaptoolcircularstringradius.cpp
  22. +2 −2 src/app/qgsmaptoolfeatureaction.cpp
  23. +2 −2 src/app/qgsnewspatialitelayerdialog.cpp
  24. +1 −1 src/app/qgsoptions.cpp
  25. +6 −6 src/app/qgsprojectproperties.cpp
  26. +1 −1 src/app/qgsrasterlayerproperties.cpp
  27. +1 −1 src/core/auth/qgsauthcertutils.cpp
  28. +5 −5 src/core/composer/qgsatlascomposition.cpp
  29. +4 −4 src/core/composer/qgscomposerarrow.cpp
  30. +2 −2 src/core/composer/qgscomposerattributetable.cpp
  31. +3 −3 src/core/composer/qgscomposeritem.cpp
  32. +1 −1 src/core/composer/qgscomposeritemgroup.cpp
  33. +2 −2 src/core/composer/qgscomposerlabel.cpp
  34. +2 −2 src/core/composer/qgscomposerlegend.cpp
  35. +7 −7 src/core/composer/qgscomposermap.cpp
  36. +2 −2 src/core/composer/qgscomposermapgrid.cpp
  37. +4 −4 src/core/composer/qgscomposermousehandles.cpp
  38. +1 −1 src/core/composer/qgscomposermultiframe.cpp
  39. +1 −1 src/core/composer/qgscomposerpicture.cpp
  40. +5 −5 src/core/composer/qgscomposerscalebar.cpp
  41. +3 −3 src/core/composer/qgscomposershape.cpp
  42. +2 −2 src/core/composer/qgscomposertable.cpp
  43. +1 −1 src/core/composer/qgscomposertablecolumn.cpp
  44. +3 −3 src/core/composer/qgscomposertablev2.cpp
  45. +1 −1 src/core/composer/qgscomposerutils.cpp
  46. +2 −2 src/core/composer/qgscomposition.cpp
  47. +1 −1 src/core/composer/qgslegendmodel.cpp
  48. +1 −1 src/core/composer/qgspaperitem.cpp
  49. +2 −2 src/core/diagram/qgshistogramdiagram.cpp
  50. +1 −1 src/core/dxf/qgsdxfexport.cpp
  51. +2 −2 src/core/dxf/qgsdxfpaintengine.cpp
  52. +3 −3 src/core/geometry/qgscompoundcurvev2.cpp
  53. +2 −2 src/core/geometry/qgsgeos.cpp
  54. +2 −2 src/core/layertree/qgslayertreegroup.cpp
  55. +2 −2 src/core/layertree/qgslayertreemodel.cpp
  56. +1 −1 src/core/layertree/qgslayertreenode.cpp
  57. +3 −3 src/core/pal/feature.cpp
  58. +2 −2 src/core/pal/layer.cpp
  59. +2 −2 src/core/pal/pal.cpp
  60. +1 −1 src/core/pal/pointset.cpp
  61. +10 −10 src/core/pal/problem.cpp
  62. +1 −1 src/core/pal/util.cpp
  63. +3 −3 src/core/qgsapplication.cpp
  64. +1 −1 src/core/qgsclipper.cpp
  65. +4 −4 src/core/qgsdataitem.cpp
  66. +5 −5 src/core/qgsexpression.cpp
  67. +1 −1 src/core/qgsfontutils.cpp
  68. +3 −3 src/core/qgsgml.cpp
  69. +2 −2 src/core/qgsgmlschema.cpp
  70. +3 −3 src/core/qgslegendrenderer.cpp
  71. +1 −1 src/core/qgsmaplayer.cpp
  72. +2 −2 src/core/qgsmaplayerlegend.cpp
  73. +1 −1 src/core/qgsmaplayerregistry.cpp
  74. +1 −1 src/core/qgsmultirenderchecker.cpp
  75. +2 −2 src/core/qgsnetworkaccessmanager.cpp
  76. +1 −1 src/core/qgsnetworkreplyparser.cpp
  77. +9 −9 src/core/qgsogcutils.cpp
  78. +4 −4 src/core/qgsproject.cpp
  79. +1 −1 src/core/qgsprojectfiletransform.cpp
  80. +8 −8 src/core/qgsvectorlayer.cpp
  81. +1 −1 src/core/qgsvectorlayerdiagramprovider.cpp
  82. +2 −2 src/core/qgsvectorlayereditutils.cpp
  83. +1 −1 src/core/qgsvectorlayerfeatureiterator.cpp
  84. +1 −1 src/core/qgsvectorlayerjoinbuffer.cpp
  85. +1 −1 src/core/raster/qgsrasterfilewriter.cpp
  86. +2 −2 src/core/raster/qgsrasterinterface.cpp
  87. +1 −1 src/core/raster/qgsrasterlayer.cpp
  88. +2 −2 src/core/raster/qgsrastertransparency.cpp
  89. +2 −2 src/core/symbology-ng/qgscategorizedsymbolrendererv2.cpp
  90. +4 −4 src/core/symbology-ng/qgscptcityarchive.cpp
  91. +5 −5 src/core/symbology-ng/qgsgraduatedsymbolrendererv2.cpp
  92. +1 −1 src/core/symbology-ng/qgslinesymbollayerv2.cpp
  93. +2 −2 src/core/symbology-ng/qgsrendererv2.cpp
  94. +5 −5 src/core/symbology-ng/qgsrulebasedrendererv2.cpp
  95. +2 −2 src/core/symbology-ng/qgssinglesymbolrendererv2.cpp
  96. +5 −5 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  97. +3 −3 src/core/symbology-ng/qgssymbolv2.cpp
  98. +1 −1 src/gui/attributetable/qgsattributetableview.cpp
  99. +3 −3 src/gui/attributetable/qgsdualview.cpp
  100. +1 −1 src/gui/attributetable/qgsfieldconditionalformatwidget.cpp
  101. +1 −1 src/gui/auth/qgsauthauthoritieseditor.cpp
  102. +1 −1 src/gui/auth/qgsauthconfigidedit.cpp
  103. +2 −2 src/gui/auth/qgsauthimportcertdialog.cpp
  104. +3 −3 src/gui/editorwidgets/qgsdoublespinbox.cpp
  105. +1 −1 src/gui/editorwidgets/qgsenumerationwidgetfactory.cpp
  106. +2 −2 src/gui/editorwidgets/qgsrelationreferencewidget.cpp
  107. +3 −3 src/gui/editorwidgets/qgsspinbox.cpp
  108. +1 −1 src/gui/layertree/qgslayertreemapcanvasbridge.cpp
  109. +1 −1 src/gui/qgsactionmenu.cpp
  110. +1 −1 src/gui/qgsattributedialog.cpp
  111. +1 −1 src/gui/qgsattributeform.cpp
  112. +2 −2 src/gui/qgscolorswatchgrid.cpp
  113. +8 −8 src/gui/qgscomposerview.cpp
  114. +1 −1 src/gui/qgsdatadefinedbutton.cpp
  115. +1 −1 src/gui/qgsexpressionbuilderwidget.cpp
  116. +2 −2 src/gui/qgsfieldvalidator.cpp
  117. +7 −7 src/gui/qgshistogramwidget.cpp
  118. +6 −6 src/gui/qgsidentifymenu.cpp
  119. +1 −1 src/gui/qgsmapcanvas.cpp
  120. +1 −1 src/gui/qgsmaplayermodel.cpp
  121. +1 −1 src/gui/qgsmaptoolcapture.cpp
  122. +4 −4 src/gui/qgsmessagebar.cpp
  123. +1 −1 src/gui/qgsnewnamedialog.cpp
  124. +2 −2 src/gui/qgsnewvectorlayerdialog.cpp
  125. +1 −1 src/gui/qgsowssourceselect.cpp
  126. +6 −6 src/gui/qgsprojectionselector.cpp
  127. +1 −1 src/gui/qgsrasterformatsaveoptionswidget.cpp
  128. +4 −4 src/gui/qgsrubberband.cpp
  129. +1 −1 src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
  130. +6 −6 src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
  131. +1 −1 src/gui/symbology-ng/qgscptcitycolorrampv2dialog.cpp
  132. +1 −1 src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
  133. +4 −4 src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
  134. +1 −1 src/gui/symbology-ng/qgsrendererv2widget.h
  135. +1 −1 src/gui/symbology-ng/qgssmartgroupeditordialog.cpp
  136. +2 −2 src/gui/symbology-ng/qgsstylev2managerdialog.cpp
  137. +2 −2 src/plugins/dxf2shp_converter/builder.cpp
  138. +1 −1 src/plugins/evis/databaseconnection/evisdatabaseconnectiongui.cpp
  139. +2 −2 src/plugins/evis/eventbrowser/evisgenericeventbrowsergui.cpp
  140. +1 −1 src/plugins/evis/evis.cpp
  141. +4 −4 src/plugins/geometry_checker/ui/qgsgeometrycheckerfixsummarydialog.cpp
  142. +1 −1 src/plugins/georeferencer/qgsgcpcanvasitem.cpp
  143. +1 −1 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  144. +2 −2 src/plugins/spatialquery/qgsspatialquery.cpp
  145. +3 −3 src/plugins/spatialquery/qgsspatialquerydialog.cpp
  146. +1 −1 src/plugins/topology/topolTest.cpp
  147. +2 −2 src/providers/delimitedtext/qgsdelimitedtextfile.cpp
  148. +2 −2 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
  149. +2 −2 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  150. +2 −2 src/providers/gdal/qgsgdaldataitems.cpp
  151. +11 −11 src/providers/gdal/qgsgdalprovider.cpp
  152. +2 −2 src/providers/gpx/qgsgpxfeatureiterator.cpp
  153. +1 −1 src/providers/memory/qgsmemoryprovider.cpp
  154. +1 −1 src/providers/mssql/qgsmssqldataitems.cpp
  155. +2 −2 src/providers/mssql/qgsmssqlprovider.cpp
  156. +1 −1 src/providers/mssql/qgsmssqlsourceselect.cpp
  157. +3 −3 src/providers/mssql/qgsmssqltablemodel.cpp
  158. +2 −2 src/providers/ogr/qgsogrprovider.cpp
  159. +1 −1 src/providers/postgres/qgspgsourceselect.cpp
  160. +4 −4 src/providers/postgres/qgspgtablemodel.cpp
  161. +1 −1 src/providers/postgres/qgspostgresdataitems.cpp
  162. +3 −3 src/providers/postgres/qgspostgresprovider.cpp
  163. +2 −2 src/providers/spatialite/qgsspatialiteprovider.cpp
  164. +1 −1 src/providers/spatialite/qgsspatialitetablemodel.cpp
  165. +5 −5 src/providers/wcs/qgswcscapabilities.cpp
  166. +2 −2 src/providers/wcs/qgswcsdataitems.cpp
  167. +2 −2 src/providers/wcs/qgswcsprovider.cpp
  168. +1 −1 src/providers/wcs/qgswcssourceselect.cpp
  169. +1 −1 src/providers/wfs/qgswfssourceselect.cpp
  170. +2 −2 src/providers/wms/qgstilescalewidget.cpp
  171. +4 −4 src/providers/wms/qgswmsdataitems.cpp
  172. +10 −10 src/providers/wms/qgswmsprovider.cpp
  173. +2 −2 src/providers/wms/qgswmssourceselect.cpp
  174. +2 −2 src/server/qgsconfigparserutils.cpp
  175. +1 −1 src/server/qgshttprequesthandler.cpp
  176. +1 −1 src/server/qgsinterpolationlayerbuilder.cpp
  177. +2 −2 src/server/qgsremoteowsbuilder.cpp
  178. +1 −1 src/server/qgsserverprojectparser.cpp
  179. +17 −17 src/server/qgssldconfigparser.cpp
  180. +16 −16 src/server/qgssoaprequesthandler.cpp
  181. +7 −7 src/server/qgswfsserver.cpp
  182. +2 −2 src/server/qgswmsprojectparser.cpp
  183. +3 −3 src/server/qgswmsserver.cpp
  184. +1 −1 tests/src/core/testqgsrulebasedrenderer.cpp
  185. +1 −1 tests/src/core/testqgsvectorlayerjoinbuffer.cpp
  186. +1 −1 tests/src/core/testziplayer.cpp
  187. +4 −4 tests/src/providers/testqgswcspublicservers.cpp
@@ -26,7 +26,7 @@ double leftOfTresh = 0.00000001;
DualEdgeTriangulation::~DualEdgeTriangulation()
{
//remove all the points
if ( mPointVector.count() > 0 )
if ( !mPointVector.isEmpty() )
{
for ( int i = 0; i < mPointVector.count(); i++ )
{
@@ -35,7 +35,7 @@ DualEdgeTriangulation::~DualEdgeTriangulation()
}

//remove all the HalfEdge
if ( mHalfEdge.count() > 0 )
if ( !mHalfEdge.isEmpty() )
{
for ( int i = 0; i < mHalfEdge.count(); i++ )
{
@@ -114,7 +114,7 @@ int DualEdgeTriangulation::addPoint( Point3D* p )
// QgsDebugMsg( QString("inserting point %1,%2//%3//%4").arg(mPointVector.count()).arg(p->getX()).arg(p->getY()).arg(p->getZ()));

//first update the bounding box
if ( mPointVector.count() == 0 )//update bounding box when the first point is inserted
if ( mPointVector.isEmpty() )//update bounding box when the first point is inserted
{
xMin = ( *p ).getX();
yMin = ( *p ).getY();
@@ -743,7 +743,7 @@ void DualEdgeTriangulation::doSwap( unsigned int edge, unsigned int recursiveDee
void DualEdgeTriangulation::draw( QPainter* p, double xlowleft, double ylowleft, double xupright, double yupright, double width, double height ) const
{
//if mPointVector is empty, there is nothing to do
if ( mPointVector.count() == 0 )
if ( mPointVector.isEmpty() )
{
return;
}
@@ -22,7 +22,7 @@
NormVecDecorator::~NormVecDecorator()
{
//remove all the normals
if ( mNormVec->count() > 0 )
if ( !mNormVec->isEmpty() )
{
for ( int i = 0; i < mNormVec->count(); i++ )
{
@@ -701,7 +701,7 @@ void QgsRelief::optimiseClassBreaks( QList<int>& breaks, double* frequencies )
}

double aParam, bParam;
if ( regressionInput.size() > 0 && calculateRegression( regressionInput, aParam, bParam ) )
if ( !regressionInput.isEmpty() && calculateRegression( regressionInput, aParam, bParam ) )
{
a[i] = aParam;
b[i] = bParam;
@@ -1641,7 +1641,7 @@ void QgsComposer::exportCompositionAsPDF( QgsComposer::OutputMode mode )
// else, we need to choose a directory
else
{
if ( atlasMap->filenamePattern().size() == 0 )
if ( atlasMap->filenamePattern().isEmpty() )
{
int res = QMessageBox::warning( 0, tr( "Empty filename pattern" ),
tr( "The filename pattern is empty. A default one will be used." ),
@@ -2127,7 +2127,7 @@ void QgsComposer::exportCompositionAsImage( QgsComposer::OutputMode mode )
else
{
// else, it has an atlas to render, so a directory must first be selected
if ( atlasMap->filenamePattern().size() == 0 )
if ( atlasMap->filenamePattern().isEmpty() )
{
int res = QMessageBox::warning( 0, tr( "Empty filename pattern" ),
tr( "The filename pattern is empty. A default one will be used." ),
@@ -2484,7 +2484,7 @@ void QgsComposer::exportCompositionAsSVG( QgsComposer::OutputMode mode )
else
{
// If we have an Atlas
if ( atlasMap->filenamePattern().size() == 0 )
if ( atlasMap->filenamePattern().isEmpty() )
{
int res = QMessageBox::warning( 0, tr( "Empty filename pattern" ),
tr( "The filename pattern is empty. A default one will be used." ),
@@ -173,7 +173,7 @@ void QgsComposerManager::toggleButtons()

void QgsComposerManager::addTemplates( const QMap<QString, QString>& templates )
{
if ( templates.size() > 0 )
if ( !templates.isEmpty() )
{
mTemplate->insertSeparator( mTemplate->count() );
QMap<QString, QString>::const_iterator templateIt = templates.constBegin();
@@ -1172,7 +1172,7 @@ bool QgsComposerMapWidget::hasPredefinedScales() const
QSettings settings;
QString scalesStr( settings.value( "Map/scales", PROJECT_SCALES ).toString() );
QStringList myScalesList = scalesStr.split( ',' );
return myScalesList.size() > 0 && myScalesList[0] != "";
return !myScalesList.isEmpty() && myScalesList[0] != "";
}
return true;
}
@@ -314,7 +314,7 @@ void QgsAppLegendInterface::onAddedChildren( QgsLayerTreeNode* node, int indexFr
emit itemAdded( mLayerTreeView->layerTreeModel()->node2index( child ) );

// also notify about all children
if ( QgsLayerTree::isGroup( child ) && child->children().count() )
if ( QgsLayerTree::isGroup( child ) && !child->children().isEmpty() )
onAddedChildren( child, 0, child->children().count() - 1 );
}
}
@@ -140,7 +140,7 @@ void QgsMapToolNodeTool::canvasMoveEvent( QgsMapMouseEvent* e )
mSnapper.snapToBackgroundLayers( e->pos(), snapResults, QList<QgsPoint>() << mClosestMapVertex );

QgsPoint curPos = snapPointFromResults( snapResults, e->pos() );
QgsPoint pressPos = snapResults.size() > 0 ? mClosestMapVertex : toMapCoordinates( mPressCoordinates );
QgsPoint pressPos = !snapResults.isEmpty() ? mClosestMapVertex : toMapCoordinates( mPressCoordinates );
double deltaX = curPos.x() - pressPos.x();
double deltaY = curPos.y() - pressPos.y();

@@ -288,7 +288,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QgsMapMouseEvent* e )
if ( !mIsPoint )
mSnapper.snapToCurrentLayer( e->pos(), snapResults, QgsSnapper::SnapToSegment, tol, QList<QgsPoint>(), true );

if ( snapResults.size() > 0 )
if ( !snapResults.isEmpty() )
{
// need to check all if there is a point in the feature
mAnother = snapResults.first().snappedAtGeometry;
@@ -431,7 +431,7 @@ void QgsMapToolNodeTool::canvasReleaseEvent( QgsMapMouseEvent* e )
QgsPoint releaseLayerCoords = toLayerCoordinates( vlayer, snapPointFromResults( snapResults, e->pos() ) );

QgsPoint pressLayerCoords;
if ( snapResults.size() > 0 )
if ( !snapResults.isEmpty() )
{
pressLayerCoords = toLayerCoordinates( vlayer, mClosestMapVertex );

@@ -272,7 +272,7 @@ void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()
if ( radioSrcFile->isChecked() )
{
QStringList selected = openFile();
if ( selected.count() > 0 )
if ( !selected.isEmpty() )
{
inputSrcDataset->setText( selected.join( ";" ) );
buttonBox->button( QDialogButtonBox::Open )->setFocus();
@@ -2749,7 +2749,7 @@ void QgisApp::updateNewLayerInsertionPoint()

void QgisApp::autoSelectAddedLayer( QList<QgsMapLayer*> layers )
{
if ( layers.count() )
if ( !layers.isEmpty() )
{
QgsLayerTreeLayer* nodeLayer = QgsProject::instance()->layerTreeRoot()->findLayer( layers[0]->id() );

@@ -3172,7 +3172,7 @@ bool QgisApp::addVectorLayers( const QStringList &theLayerQStringList, const QSt
delete layer;

}
else if ( sublayers.count() > 0 ) // there is 1 layer of data available
else if ( !sublayers.isEmpty() ) // there is 1 layer of data available
{
//set friendly name for datasources with only one layer
QStringList sublayers = layer->dataProvider()->subLayers();
@@ -3208,7 +3208,7 @@ bool QgisApp::addVectorLayers( const QStringList &theLayerQStringList, const QSt
}

// make sure at least one layer was successfully added
if ( myList.count() == 0 )
if ( myList.isEmpty() )
{
return false;
}
@@ -4016,7 +4016,7 @@ void QgisApp::fileOpenAfterLaunch()
connect( this, SIGNAL( newProject() ), this, SLOT( showMapCanvas() ) );
return;
}
if ( mProjOpen == 1 && mRecentProjects.size() > 0 ) // most recent project
if ( mProjOpen == 1 && !mRecentProjects.isEmpty() ) // most recent project
{
projPath = mRecentProjects.at( 0 ).path;
}
@@ -5503,7 +5503,7 @@ void QgisApp::saveAsVectorFileGeneral( QgsVectorLayer* vlayer, bool symbologyOpt
if ( d.exec() == QDialog::Accepted )
{
QList< int > sdt = d.selectedDatumTransform();
if ( sdt.size() > 0 )
if ( !sdt.isEmpty() )
{
ct->setSourceDatumTransform( sdt.at( 0 ) );
}
@@ -6713,7 +6713,7 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()
}
}

QGis::WkbType wkbType = typeCounts.size() > 0 ? typeCounts.keys().value( 0 ) : QGis::WKBPoint;
QGis::WkbType wkbType = !typeCounts.isEmpty() ? typeCounts.keys().value( 0 ) : QGis::WKBPoint;

QString typeName = QString( QGis::featureType( wkbType ) ).remove( "WKB" );

@@ -6723,11 +6723,11 @@ QgsVectorLayer *QgisApp::pasteToNewMemoryVector()

QString message;

if ( features.size() == 0 )
if ( features.isEmpty() )
{
message = tr( "No features in clipboard." ); // should not happen
}
else if ( typeCounts.size() == 0 )
else if ( typeCounts.isEmpty() )
{
message = tr( "No features with geometry found, point type layer will be created." );
}
@@ -7248,11 +7248,11 @@ void QgisApp::updateLayerModifiedActions()
mActionRollbackEdits->setEnabled( QgsLayerTreeUtils::layersModified( selectedLayerNodes ) );
mActionCancelEdits->setEnabled( QgsLayerTreeUtils::layersEditable( selectedLayerNodes ) );

bool hasEditLayers = ( editableLayers().count() > 0 );
bool hasEditLayers = !editableLayers().isEmpty();
mActionAllEdits->setEnabled( hasEditLayers );
mActionCancelAllEdits->setEnabled( hasEditLayers );

bool hasModifiedLayers = ( editableLayers( true ).count() > 0 );
bool hasModifiedLayers = !editableLayers( true ).isEmpty();
mActionSaveAllEdits->setEnabled( hasModifiedLayers );
mActionRollbackAllEdits->setEnabled( hasModifiedLayers );
}
@@ -8340,7 +8340,7 @@ void QgisApp::embedLayers()
}

mMapCanvas->freeze( false );
if ( groups.size() > 0 || layerIds.size() > 0 )
if ( !groups.isEmpty() || !layerIds.isEmpty() )
{
mMapCanvas->refresh();
}
@@ -8558,7 +8558,7 @@ void QgisApp::removePluginMenu( const QString& name, QAction* action )
{
QMenu* menu = getPluginMenu( name );
menu->removeAction( action );
if ( menu->actions().count() == 0 )
if ( menu->actions().isEmpty() )
{
mPluginMenu->removeAction( menu->menuAction() );
}
@@ -8857,13 +8857,13 @@ void QgisApp::removePluginDatabaseMenu( const QString& name, QAction* action )
{
QMenu* menu = getDatabaseMenu( name );
menu->removeAction( action );
if ( menu->actions().count() == 0 )
if ( menu->actions().isEmpty() )
{
mDatabaseMenu->removeAction( menu->menuAction() );
}

// remove the Database menu from the menuBar if there are no more actions
if ( mDatabaseMenu->actions().count() > 0 )
if ( !mDatabaseMenu->actions().isEmpty() )
return;

QList<QAction*> actions = menuBar()->actions();
@@ -8881,7 +8881,7 @@ void QgisApp::removePluginRasterMenu( const QString& name, QAction* action )
{
QMenu* menu = getRasterMenu( name );
menu->removeAction( action );
if ( menu->actions().count() == 0 )
if ( menu->actions().isEmpty() )
{
mRasterMenu->removeAction( menu->menuAction() );
}
@@ -8899,13 +8899,13 @@ void QgisApp::removePluginVectorMenu( const QString& name, QAction* action )
{
QMenu* menu = getVectorMenu( name );
menu->removeAction( action );
if ( menu->actions().count() == 0 )
if ( menu->actions().isEmpty() )
{
mVectorMenu->removeAction( menu->menuAction() );
}

// remove the Vector menu from the menuBar if there are no more actions
if ( mVectorMenu->actions().count() > 0 )
if ( !mVectorMenu->actions().isEmpty() )
return;

QList<QAction*> actions = menuBar()->actions();
@@ -8923,13 +8923,13 @@ void QgisApp::removePluginWebMenu( const QString& name, QAction* action )
{
QMenu* menu = getWebMenu( name );
menu->removeAction( action );
if ( menu->actions().count() == 0 )
if ( menu->actions().isEmpty() )
{
mWebMenu->removeAction( menu->menuAction() );
}

// remove the Web menu from the menuBar if there are no more actions
if ( mWebMenu->actions().count() > 0 )
if ( !mWebMenu->actions().isEmpty() )
return;

QList<QAction*> actions = menuBar()->actions();
@@ -9345,9 +9345,9 @@ void QgisApp::legendLayerSelectionChanged( void )
{
QList<QgsLayerTreeLayer*> selectedLayers = mLayerTreeView ? mLayerTreeView->selectedLayerNodes() : QList<QgsLayerTreeLayer*>();

mActionDuplicateLayer->setEnabled( selectedLayers.count() > 0 );
mActionSetLayerScaleVisibility->setEnabled( selectedLayers.count() > 0 );
mActionSetLayerCRS->setEnabled( selectedLayers.count() > 0 );
mActionDuplicateLayer->setEnabled( !selectedLayers.isEmpty() );
mActionSetLayerScaleVisibility->setEnabled( !selectedLayers.isEmpty() );
mActionSetLayerCRS->setEnabled( !selectedLayers.isEmpty() );
mActionSetProjectCRSFromLayer->setEnabled( selectedLayers.count() == 1 );

mActionSaveEdits->setEnabled( QgsLayerTreeUtils::layersModified( selectedLayers ) );
@@ -9519,7 +9519,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )

bool isEditable = vlayer->isEditable();
bool layerHasSelection = vlayer->selectedFeatureCount() > 0;
bool layerHasActions = vlayer->actions()->size() + QgsMapLayerActionRegistry::instance()->mapLayerActions( vlayer ).size() > 0;
bool layerHasActions = vlayer->actions()->size() || !QgsMapLayerActionRegistry::instance()->mapLayerActions( vlayer ).isEmpty();

mActionLocalHistogramStretch->setEnabled( false );
mActionFullHistogramStretch->setEnabled( false );
@@ -9782,7 +9782,7 @@ void QgisApp::refreshActionFeatureAction()

QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer );

bool layerHasActions = vlayer->actions()->size() + QgsMapLayerActionRegistry::instance()->mapLayerActions( vlayer ).size() > 0;
bool layerHasActions = vlayer->actions()->size() || !QgsMapLayerActionRegistry::instance()->mapLayerActions( vlayer ).isEmpty();
mActionFeatureAction->setEnabled( layerHasActions );
}

@@ -10041,7 +10041,7 @@ bool QgisApp::addRasterLayers( QStringList const &theFileNameQStringList, bool g
QString msg;

msg = tr( "%1 is not a supported raster data source" ).arg( *myIterator );
if ( errMsg.size() > 0 )
if ( !errMsg.isEmpty() )
msg += '\n' + errMsg;
error.append( QGS_ERROR_MESSAGE( msg, tr( "Raster layer" ) ) );

@@ -33,7 +33,7 @@ QgsAddTabOrGroup::QgsAddTabOrGroup( QgsVectorLayer *lyr, const QList < TabPair >

mTabButton->setChecked( true );
mTabList->setEnabled( false );
if ( mTabs.size() > 0 )
if ( !mTabs.isEmpty() )
{
int i = 0;
Q_FOREACH ( const TabPair& tab, mTabs )
@@ -181,7 +181,7 @@ void QgsBookmarks::deleteClicked()
}
}

if ( rows.size() == 0 )
if ( rows.isEmpty() )
return;

// make sure the user really wants to delete these bookmarks
@@ -421,7 +421,7 @@ void QgsBrowserDockWidget::showContextMenu( const QPoint & pt )
menu->addActions( actions );
}

if ( menu->actions().count() == 0 )
if ( menu->actions().isEmpty() )
{
delete menu;
return;
@@ -412,7 +412,7 @@ void QgsConfigureShortcutsDialog::setCurrentActionShortcut( const QKeySequence&
// reset action of the conflicting other action!
QgsShortcutsManager::instance()->setActionShortcut( otherAction, QString() );
QList<QTreeWidgetItem*> items = treeActions->findItems( otherActionText, Qt::MatchExactly );
if ( items.count() > 0 ) // there should be exactly one
if ( !items.isEmpty() ) // there should be exactly one
items[0]->setText( 1, QString() );
}

@@ -246,7 +246,7 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare

//assume single category or linearly interpolated diagram renderer for now
QList<QgsDiagramSettings> settingList = dr->diagramSettings();
if ( settingList.size() > 0 )
if ( !settingList.isEmpty() )
{
mEnableDiagramsCheckBox->setChecked( settingList.at( 0 ).enabled );
mDiagramTypeFrame->setEnabled( mEnableDiagramsCheckBox->isChecked() );

0 comments on commit ee72079

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