Skip to content

Commit

Permalink
Merge pull request #2598 from SebDieBln/NoSingleStatementLines
Browse files Browse the repository at this point in the history
Make the qgisstyle tool fix multiple statements on a single line
  • Loading branch information
nyalldawson committed Dec 21, 2015
2 parents d31e610 + c28c493 commit a42bfea
Show file tree
Hide file tree
Showing 102 changed files with 1,582 additions and 660 deletions.
1 change: 0 additions & 1 deletion scripts/astyle.sh
Expand Up @@ -63,7 +63,6 @@ astyleit()
--indent-namespaces \ --indent-namespaces \
--indent-switches \ --indent-switches \
--one-line=keep-blocks \ --one-line=keep-blocks \
--one-line=keep-statements \
--max-instatement-indent=40 \ --max-instatement-indent=40 \
--min-conditional-indent=-1 \ --min-conditional-indent=-1 \
--suffix=none \ --suffix=none \
Expand Down
9 changes: 6 additions & 3 deletions src/analysis/interpolation/DualEdgeTriangulation.cc
Expand Up @@ -1527,7 +1527,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )


//set the necessary nexts of leftPolygon(exept the first) //set the necessary nexts of leftPolygon(exept the first)
int actedgel = leftPolygon[1]; int actedgel = leftPolygon[1];
leftiter = leftPolygon.constBegin(); leftiter += 2; leftiter = leftPolygon.constBegin();
leftiter += 2;
for ( ; leftiter != leftPolygon.constEnd(); ++leftiter ) for ( ; leftiter != leftPolygon.constEnd(); ++leftiter )
{ {
mHalfEdge[actedgel]->setNext(( *leftiter ) ); mHalfEdge[actedgel]->setNext(( *leftiter ) );
Expand All @@ -1536,7 +1537,8 @@ int DualEdgeTriangulation::insertForcedSegment( int p1, int p2, bool breakline )


//set all the necessary nexts of rightPolygon //set all the necessary nexts of rightPolygon
int actedger = rightPolygon[1]; int actedger = rightPolygon[1];
rightiter = rightPolygon.constBegin(); rightiter += 2; rightiter = rightPolygon.constBegin();
rightiter += 2;
for ( ; rightiter != rightPolygon.constEnd(); ++rightiter ) for ( ; rightiter != rightPolygon.constEnd(); ++rightiter )
{ {
mHalfEdge[actedger]->setNext(( *rightiter ) ); mHalfEdge[actedger]->setNext(( *rightiter ) );
Expand Down Expand Up @@ -2526,7 +2528,8 @@ void DualEdgeTriangulation::triangulatePolygon( QList<int>* poly, QList<int>* fr
mHalfEdge[( *( --poly->end() ) )]->setNext( inserta ); mHalfEdge[( *( --poly->end() ) )]->setNext( inserta );


QList<int> polya; QList<int> polya;
iterator = poly->constBegin(); iterator += 2; iterator = poly->constBegin();
iterator += 2;
while ( iterator != poly->constEnd() ) while ( iterator != poly->constEnd() )
{ {
polya.append(( *iterator ) ); polya.append(( *iterator ) );
Expand Down
11 changes: 8 additions & 3 deletions src/analysis/raster/qgsrastermatrix.cpp
Expand Up @@ -72,7 +72,9 @@ void QgsRasterMatrix::setData( int cols, int rows, double* data, double nodataVa
double* QgsRasterMatrix::takeData() double* QgsRasterMatrix::takeData()
{ {
double* data = mData; double* data = mData;
mData = nullptr; mColumns = 0; mRows = 0; mData = nullptr;
mColumns = 0;
mRows = 0;
return data; return data;
} }


Expand Down Expand Up @@ -337,7 +339,8 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa


for ( int i = 0; i < nEntries; ++i ) for ( int i = 0; i < nEntries; ++i )
{ {
value1 = mData[i]; value2 = matrix[i]; value1 = mData[i];
value2 = matrix[i];
if ( value1 == mNodataValue || value2 == other.mNodataValue ) if ( value1 == mNodataValue || value2 == other.mNodataValue )
{ {
mData[i] = mNodataValue; mData[i] = mNodataValue;
Expand All @@ -357,7 +360,9 @@ bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMa
int nEntries = other.nColumns() * other.nRows(); int nEntries = other.nColumns() * other.nRows();
double value = mData[0]; double value = mData[0];
delete[] mData; delete[] mData;
mData = new double[nEntries]; mColumns = other.nColumns(); mRows = other.nRows(); mData = new double[nEntries];
mColumns = other.nColumns();
mRows = other.nRows();
mNodataValue = other.nodataValue(); mNodataValue = other.nodataValue();


if ( value == mNodataValue ) if ( value == mNodataValue )
Expand Down
4 changes: 3 additions & 1 deletion src/analysis/raster/qgsrelief.cpp
Expand Up @@ -330,7 +330,9 @@ bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x
} }
else else
{ {
r2 = hillShadeValue315; g2 = hillShadeValue315; b2 = hillShadeValue315; r2 = hillShadeValue315;
g2 = hillShadeValue315;
b2 = hillShadeValue315;
} }


//combine with r,g,b with 70 percentage coverage //combine with r,g,b with 70 percentage coverage
Expand Down
38 changes: 26 additions & 12 deletions src/analysis/vector/qgsgeometryanalyzer.cpp
Expand Up @@ -1303,7 +1303,9 @@ const unsigned char* QgsGeometryAnalyzer::locateBetweenWkbString( const unsigned
} }
} }
} }
prevx = *x; prevy = *y; prevz = *z; prevx = *x;
prevy = *y;
prevz = *z;
} }
return ptr; return ptr;
} }
Expand Down Expand Up @@ -1339,7 +1341,9 @@ const unsigned char* QgsGeometryAnalyzer::locateAlongWkbString( const unsigned c
result.append( pt2 ); result.append( pt2 );
} }
} }
prevx = *x; prevy = *y; prevz = *z; prevx = *x;
prevy = *y;
prevz = *z;
} }
return ptr; return ptr;
} }
Expand Down Expand Up @@ -1385,13 +1389,17 @@ bool QgsGeometryAnalyzer::clipSegmentByRange( double x1, double y1, double m1, d
{ {
if ( reversed ) if ( reversed )
{ {
pt1.setX( x2 ); pt1.setY( y2 ); pt1.setX( x2 );
pt2.setX( x1 ); pt2.setY( y1 ); pt1.setY( y2 );
pt2.setX( x1 );
pt2.setY( y1 );
} }
else else
{ {
pt1.setX( x1 ); pt1.setY( y1 ); pt1.setX( x1 );
pt2.setX( x2 ); pt2.setY( y2 ); pt1.setY( y1 );
pt2.setX( x2 );
pt2.setY( y2 );
} }
secondPointClipped = false; secondPointClipped = false;
return true; return true;
Expand All @@ -1400,7 +1408,8 @@ bool QgsGeometryAnalyzer::clipSegmentByRange( double x1, double y1, double m1, d
//m1 inside and m2 not //m1 inside and m2 not
if ( m1 >= range1 && m1 <= range2 ) if ( m1 >= range1 && m1 <= range2 )
{ {
pt1.setX( x1 ); pt1.setY( y1 ); pt1.setX( x1 );
pt1.setY( y1 );
double dist = ( range2 - m1 ) / ( m2 - m1 ); double dist = ( range2 - m1 ) / ( m2 - m1 );
pt2.setX( x1 + ( x2 - x1 ) * dist ); pt2.setX( x1 + ( x2 - x1 ) * dist );
pt2.setY( y1 + ( y2 - y1 ) * dist ); pt2.setY( y1 + ( y2 - y1 ) * dist );
Expand All @@ -1410,7 +1419,8 @@ bool QgsGeometryAnalyzer::clipSegmentByRange( double x1, double y1, double m1, d
//m2 inside and m1 not //m2 inside and m1 not
if ( m2 >= range1 && m2 <= range2 ) if ( m2 >= range1 && m2 <= range2 )
{ {
pt2.setX( x2 ); pt2.setY( y2 ); pt2.setX( x2 );
pt2.setY( y2 );
double dist = ( m2 - range1 ) / ( m2 - m1 ); double dist = ( m2 - range1 ) / ( m2 - m1 );
pt1.setX( x2 - ( x2 - x1 ) * dist ); pt1.setX( x2 - ( x2 - x1 ) * dist );
pt1.setY( y2 - ( y2 - y1 ) * dist ); pt1.setY( y2 - ( y2 - y1 ) * dist );
Expand Down Expand Up @@ -1468,12 +1478,14 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
if ( reversed ) if ( reversed )
{ {
pt2Ok = true; pt2Ok = true;
pt2.setX( x2 ); pt2.setY( y2 ); pt2.setX( x2 );
pt2.setY( y2 );
} }
else else
{ {
pt1Ok = true; pt1Ok = true;
pt1.setX( x1 ); pt1.setY( y1 ); pt1.setX( x1 );
pt1.setY( y1 );
} }
} }


Expand All @@ -1483,12 +1495,14 @@ void QgsGeometryAnalyzer::locateAlongSegment( double x1, double y1, double m1, d
if ( reversed ) if ( reversed )
{ {
pt1Ok = true; pt1Ok = true;
pt1.setX( x1 ); pt1.setY( y1 ); pt1.setX( x1 );
pt1.setY( y1 );
} }
else else
{ {
pt2Ok = true; pt2Ok = true;
pt2.setX( x2 ); pt2.setY( y2 ); pt2.setX( x2 );
pt2.setY( y2 );
} }
} }


Expand Down
28 changes: 20 additions & 8 deletions src/analysis/vector/qgstransectsample.cpp
Expand Up @@ -235,14 +235,16 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
QgsGeometry* lineClipStratum = lineFarAwayGeom->intersection( strataGeom ); QgsGeometry* lineClipStratum = lineFarAwayGeom->intersection( strataGeom );
if ( !lineClipStratum ) if ( !lineClipStratum )
{ {
delete lineFarAwayGeom; delete lineClipStratum; delete lineFarAwayGeom;
delete lineClipStratum;
continue; continue;
} }


//cancel if distance between sample point and line is too large (line does not start at point //cancel if distance between sample point and line is too large (line does not start at point
if ( lineClipStratum->distance( *samplePoint ) > 0.000001 ) if ( lineClipStratum->distance( *samplePoint ) > 0.000001 )
{ {
delete lineFarAwayGeom; delete lineClipStratum; delete lineFarAwayGeom;
delete lineClipStratum;
continue; continue;
} }


Expand All @@ -262,14 +264,16 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
double transectLength = distanceArea.measureLength( lineClipStratum ); double transectLength = distanceArea.measureLength( lineClipStratum );
if ( transectLength < mMinTransectLength ) if ( transectLength < mMinTransectLength )
{ {
delete lineFarAwayGeom; delete lineClipStratum; delete lineFarAwayGeom;
delete lineClipStratum;
continue; continue;
} }


//search closest existing profile. Cancel if dist < minDist //search closest existing profile. Cancel if dist < minDist
if ( otherTransectWithinDistance( lineClipStratum, minDistanceLayerUnits, minDistance, sIndex, lineFeatureMap, distanceArea ) ) if ( otherTransectWithinDistance( lineClipStratum, minDistanceLayerUnits, minDistance, sIndex, lineFeatureMap, distanceArea ) )
{ {
delete lineFarAwayGeom; delete lineClipStratum; delete lineFarAwayGeom;
delete lineClipStratum;
continue; continue;
} }


Expand Down Expand Up @@ -441,22 +445,30 @@ bool QgsTransectSample::closestSegmentPoints( QgsGeometry& g1, QgsGeometry& g2,


if ( d1 <= d2 && d1 <= d3 && d1 <= d4 ) if ( d1 <= d2 && d1 <= d3 && d1 <= d4 )
{ {
dist = sqrt( d1 ); pt1 = p11; pt2 = minDistPoint1; dist = sqrt( d1 );
pt1 = p11;
pt2 = minDistPoint1;
return true; return true;
} }
else if ( d2 <= d1 && d2 <= d3 && d2 <= d4 ) else if ( d2 <= d1 && d2 <= d3 && d2 <= d4 )
{ {
dist = sqrt( d2 ); pt1 = p12; pt2 = minDistPoint2; dist = sqrt( d2 );
pt1 = p12;
pt2 = minDistPoint2;
return true; return true;
} }
else if ( d3 <= d1 && d3 <= d2 && d3 <= d4 ) else if ( d3 <= d1 && d3 <= d2 && d3 <= d4 )
{ {
dist = sqrt( d3 ); pt1 = p21; pt2 = minDistPoint3; dist = sqrt( d3 );
pt1 = p21;
pt2 = minDistPoint3;
return true; return true;
} }
else else
{ {
dist = sqrt( d4 ); pt1 = p21; pt2 = minDistPoint4; dist = sqrt( d4 );
pt1 = p21;
pt2 = minDistPoint4;
return true; return true;
} }
} }
Expand Down
5 changes: 4 additions & 1 deletion src/analysis/vector/qgszonalstatistics.cpp
Expand Up @@ -392,7 +392,10 @@ int QgsZonalStatistics::cellInfoForBBox( const QgsRectangle& rasterBBox, const Q
QgsRectangle intersectBox = rasterBBox.intersect( &featureBBox ); QgsRectangle intersectBox = rasterBBox.intersect( &featureBBox );
if ( intersectBox.isEmpty() ) if ( intersectBox.isEmpty() )
{ {
nCellsX = 0; nCellsY = 0; offsetX = 0; offsetY = 0; nCellsX = 0;
nCellsY = 0;
offsetX = 0;
offsetY = 0;
return 0; return 0;
} }


Expand Down
6 changes: 4 additions & 2 deletions src/app/composer/qgscomposerpicturewidget.cpp
Expand Up @@ -475,7 +475,8 @@ int QgsComposerPictureWidget::addDirectoryToPreview( const QString& path )
//exclude files that are not svg or image //exclude files that are not svg or image
if ( !fileIsSvg && !fileIsPixel ) if ( !fileIsSvg && !fileIsPixel )
{ {
++counter; continue; ++counter;
continue;
} }


QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget ); QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget );
Expand All @@ -491,7 +492,8 @@ int QgsComposerPictureWidget::addDirectoryToPreview( const QString& path )
QPixmap iconPixmap( filePath ); QPixmap iconPixmap( filePath );
if ( iconPixmap.isNull() ) if ( iconPixmap.isNull() )
{ {
++counter; continue; //unknown file format or other problem ++counter;
continue; //unknown file format or other problem
} }
//set pixmap hardcoded to 30/30, same as icon size for mPreviewListWidget //set pixmap hardcoded to 30/30, same as icon size for mPreviewListWidget
QPixmap scaledPixmap( iconPixmap.scaled( QSize( 30, 30 ), Qt::KeepAspectRatio ) ); QPixmap scaledPixmap( iconPixmap.scaled( QSize( 30, 30 ), Qt::KeepAspectRatio ) );
Expand Down
64 changes: 48 additions & 16 deletions src/app/qgisapp.cpp
Expand Up @@ -1831,11 +1831,21 @@ void QgisApp::createToolBars()
QAction* defSelectAction = mActionSelectFeatures; QAction* defSelectAction = mActionSelectFeatures;
switch ( settings.value( "/UI/selectTool", 0 ).toInt() ) switch ( settings.value( "/UI/selectTool", 0 ).toInt() )
{ {
case 0: defSelectAction = mActionSelectFeatures; break; case 0:
case 1: defSelectAction = mActionSelectFeatures; break; defSelectAction = mActionSelectFeatures;
case 2: defSelectAction = mActionSelectRadius; break; break;
case 3: defSelectAction = mActionSelectPolygon; break; case 1:
case 4: defSelectAction = mActionSelectFreehand; break; defSelectAction = mActionSelectFeatures;
break;
case 2:
defSelectAction = mActionSelectRadius;
break;
case 3:
defSelectAction = mActionSelectPolygon;
break;
case 4:
defSelectAction = mActionSelectFreehand;
break;
} }
bt->setDefaultAction( defSelectAction ); bt->setDefaultAction( defSelectAction );
QAction* selectAction = mAttributesToolBar->insertWidget( mActionDeselectAll, bt ); QAction* selectAction = mAttributesToolBar->insertWidget( mActionDeselectAll, bt );
Expand Down Expand Up @@ -1865,9 +1875,15 @@ void QgisApp::createToolBars()
QAction* defMeasureAction = mActionMeasure; QAction* defMeasureAction = mActionMeasure;
switch ( settings.value( "/UI/measureTool", 0 ).toInt() ) switch ( settings.value( "/UI/measureTool", 0 ).toInt() )
{ {
case 0: defMeasureAction = mActionMeasure; break; case 0:
case 1: defMeasureAction = mActionMeasureArea; break; defMeasureAction = mActionMeasure;
case 2: defMeasureAction = mActionMeasureAngle; break; break;
case 1:
defMeasureAction = mActionMeasureArea;
break;
case 2:
defMeasureAction = mActionMeasureAngle;
break;
} }
bt->setDefaultAction( defMeasureAction ); bt->setDefaultAction( defMeasureAction );
QAction* measureAction = mAttributesToolBar->insertWidget( mActionMapTips, bt ); QAction* measureAction = mAttributesToolBar->insertWidget( mActionMapTips, bt );
Expand All @@ -1887,11 +1903,21 @@ void QgisApp::createToolBars()
QAction* defAnnotationAction = mActionTextAnnotation; QAction* defAnnotationAction = mActionTextAnnotation;
switch ( settings.value( "/UI/annotationTool", 0 ).toInt() ) switch ( settings.value( "/UI/annotationTool", 0 ).toInt() )
{ {
case 0: defAnnotationAction = mActionTextAnnotation; break; case 0:
case 1: defAnnotationAction = mActionFormAnnotation; break; defAnnotationAction = mActionTextAnnotation;
case 2: defAnnotationAction = mActionHtmlAnnotation; break; break;
case 3: defAnnotationAction = mActionSvgAnnotation; break; case 1:
case 4: defAnnotationAction = mActionAnnotation; break; defAnnotationAction = mActionFormAnnotation;
break;
case 2:
defAnnotationAction = mActionHtmlAnnotation;
break;
case 3:
defAnnotationAction = mActionSvgAnnotation;
break;
case 4:
defAnnotationAction = mActionAnnotation;
break;


} }
bt->setDefaultAction( defAnnotationAction ); bt->setDefaultAction( defAnnotationAction );
Expand All @@ -1914,9 +1940,15 @@ void QgisApp::createToolBars()
QAction* defNewLayerAction = mActionNewVectorLayer; QAction* defNewLayerAction = mActionNewVectorLayer;
switch ( settings.value( "/UI/defaultNewLayer", 1 ).toInt() ) switch ( settings.value( "/UI/defaultNewLayer", 1 ).toInt() )
{ {
case 0: defNewLayerAction = mActionNewSpatiaLiteLayer; break; case 0:
case 1: defNewLayerAction = mActionNewVectorLayer; break; defNewLayerAction = mActionNewSpatiaLiteLayer;
case 2: defNewLayerAction = mActionNewMemoryLayer; break; break;
case 1:
defNewLayerAction = mActionNewVectorLayer;
break;
case 2:
defNewLayerAction = mActionNewMemoryLayer;
break;
} }
bt->setDefaultAction( defNewLayerAction ); bt->setDefaultAction( defNewLayerAction );
QAction* newLayerAction = mLayerToolBar->addWidget( bt ); QAction* newLayerAction = mLayerToolBar->addWidget( bt );
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsconfigureshortcutsdialog.cpp
Expand Up @@ -81,7 +81,8 @@ void QgsConfigureShortcutsDialog::populateActions()
QString actionText = actions[i]->text(); QString actionText = actions[i]->text();
actionText.remove( '&' ); // remove the accelerator actionText.remove( '&' ); // remove the accelerator


QStringList lst; lst << actionText << actions[i]->shortcut().toString(); QStringList lst;
lst << actionText << actions[i]->shortcut().toString();
QTreeWidgetItem* item = new QTreeWidgetItem( lst ); QTreeWidgetItem* item = new QTreeWidgetItem( lst );
item->setIcon( 0, actions[i]->icon() ); item->setIcon( 0, actions[i]->icon() );
item->setData( 0, Qt::UserRole, qVariantFromValue(( QObject* )actions[i] ) ); item->setData( 0, Qt::UserRole, qVariantFromValue(( QObject* )actions[i] ) );
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -795,7 +795,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,


tblResults->resizeRowToContents( j ); tblResults->resizeRowToContents( j );


j++; i++; j++;
i++;
} }
//tblResults->resizeColumnToContents( 1 ); //tblResults->resizeColumnToContents( 1 );


Expand Down

0 comments on commit a42bfea

Please sign in to comment.