Skip to content

Commit

Permalink
More warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 20, 2015
1 parent ec35dbe commit 2cacc6a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFa
QTransform t;
t.translate( shift.x() + offsetX, shift.y() + offsetY );

if ( rotation != 0 )
if ( !qgsDoubleNear( rotation, 0.0 ) )
t.rotate( rotation );

double halfWidth = symbolWidth / 2.0;
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgspointdisplacementrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ QgsFeatureRendererV2* QgsPointDisplacementRenderer::create( QDomElement& symbolo
labelFont.fromString( symbologyElem.attribute( "labelFont", "" ) );
}
r->setLabelFont( labelFont );
r->setPlacement(( Placement )symbologyElem.attribute( "placement", "0" ).toInt() );
r->setPlacement( static_cast< Placement >( symbologyElem.attribute( "placement", "0" ).toInt() ) );
r->setCircleWidth( symbologyElem.attribute( "circleWidth", "0.4" ).toDouble() );
r->setCircleColor( QgsSymbolLayerV2Utils::decodeColor( symbologyElem.attribute( "circleColor", "" ) ) );
r->setLabelColor( QgsSymbolLayerV2Utils::decodeColor( symbologyElem.attribute( "labelColor", "" ) ) );
Expand Down Expand Up @@ -398,7 +398,7 @@ QDomElement QgsPointDisplacementRenderer::save( QDomDocument& doc )
rendererElement.setAttribute( "circleColor", QgsSymbolLayerV2Utils::encodeColor( mCircleColor ) );
rendererElement.setAttribute( "labelColor", QgsSymbolLayerV2Utils::encodeColor( mLabelColor ) );
rendererElement.setAttribute( "circleRadiusAddition", QString::number( mCircleRadiusAddition ) );
rendererElement.setAttribute( "placement", ( int )mPlacement );
rendererElement.setAttribute( "placement", static_cast< int >( mPlacement ) );
rendererElement.setAttribute( "maxLabelScaleDenominator", QString::number( mMaxLabelScaleDenominator ) );
rendererElement.setAttribute( "tolerance", QString::number( mTolerance ) );
rendererElement.setAttribute( "toleranceUnit", QgsSymbolLayerV2Utils::encodeOutputUnit( mToleranceUnit ) );
Expand Down
36 changes: 18 additions & 18 deletions src/core/symbology-ng/qgsstylev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ bool QgsStyleV2::load( const QString& filename )
while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QDomDocument doc;
QString symbol_name = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, SymbolName ) );
QString xmlstring = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, SymbolXML ) );
QString symbol_name = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, SymbolName ) ) );
QString xmlstring = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, SymbolXML ) ) );
if ( !doc.setContent( xmlstring ) )
{
QgsDebugMsg( "Cannot open symbol " + symbol_name );
Expand All @@ -336,8 +336,8 @@ bool QgsStyleV2::load( const QString& filename )
while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QDomDocument doc;
QString ramp_name = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, ColorrampName ) );
QString xmlstring = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, ColorrampXML ) );
QString ramp_name = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, ColorrampName ) ) );
QString xmlstring = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, ColorrampXML ) ) );
if ( !doc.setContent( xmlstring ) )
{
QgsDebugMsg( "Cannot open symbol " + ramp_name );
Expand Down Expand Up @@ -469,7 +469,7 @@ QStringList QgsStyleV2::groupNames()
int nError = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, nullptr );
while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
groupNames << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, SymgroupName ) );
groupNames << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, SymgroupName ) ) );
}
sqlite3_finalize( ppStmt );
return groupNames;
Expand Down Expand Up @@ -513,7 +513,7 @@ QgsSymbolGroupMap QgsStyleV2::childGroupNames( const QString& parent )
nError = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt, nullptr );
while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QString group = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, SymgroupName ) );
QString group = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, SymgroupName ) ) );
groupNames.insert( sqlite3_column_int( ppStmt, SymgroupId ), group );
}

Expand Down Expand Up @@ -551,7 +551,7 @@ QStringList QgsStyleV2::symbolsOfGroup( StyleEntity type, int groupid )
QStringList symbols;
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
symbols << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
symbols << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, 0 ) ) );
}

sqlite3_finalize( ppStmt );
Expand Down Expand Up @@ -599,7 +599,7 @@ QStringList QgsStyleV2::symbolsWithTag( StyleEntity type, int tagid )
int sErr = sqlite3_prepare_v2( mCurrentDB, query, -1, &ppStmt2, nullptr );
while ( sErr == SQLITE_OK && sqlite3_step( ppStmt2 ) == SQLITE_ROW )
{
symbols << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt2, 0 ) );
symbols << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt2, 0 ) ) );
}
sqlite3_finalize( ppStmt2 );
}
Expand All @@ -622,7 +622,7 @@ int QgsStyleV2::addGroup( const QString& groupName, int parentid )

sqlite3_finalize( ppStmt );

return ( int )sqlite3_last_insert_rowid( mCurrentDB );
return static_cast< int >( sqlite3_last_insert_rowid( mCurrentDB ) );
}

int QgsStyleV2::addTag( const QString& tagname )
Expand All @@ -637,7 +637,7 @@ int QgsStyleV2::addTag( const QString& tagname )
( void )sqlite3_step( ppStmt );
sqlite3_finalize( ppStmt );

return ( int )sqlite3_last_insert_rowid( mCurrentDB );
return static_cast< int >( sqlite3_last_insert_rowid( mCurrentDB ) );
}

void QgsStyleV2::rename( StyleEntity type, int id, const QString& newName )
Expand Down Expand Up @@ -777,7 +777,7 @@ QStringList QgsStyleV2::findSymbols( StyleEntity type, const QString& qword )
QStringList symbols;
while ( nErr == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
symbols << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
symbols << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, 0 ) ) );
}

sqlite3_finalize( ppStmt );
Expand Down Expand Up @@ -919,7 +919,7 @@ QStringList QgsStyleV2::tagsOfSymbol( StyleEntity type, const QString& symbol )
int pErr = sqlite3_prepare_v2( mCurrentDB, subquery, -1, &ppStmt2, nullptr );
if ( pErr == SQLITE_OK && sqlite3_step( ppStmt2 ) == SQLITE_ROW )
{
tagList << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt2, 0 ) );
tagList << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt2, 0 ) ) );
}
sqlite3_finalize( ppStmt2 );
}
Expand Down Expand Up @@ -1003,7 +1003,7 @@ int QgsStyleV2::addSmartgroup( const QString& name, const QString& op, const Qgs

if ( runEmptyQuery( query ) )
{
return ( int )sqlite3_last_insert_rowid( mCurrentDB );
return static_cast< int >( sqlite3_last_insert_rowid( mCurrentDB ) );
}
else
{
Expand All @@ -1029,7 +1029,7 @@ QgsSymbolGroupMap QgsStyleV2::smartgroupsListMap()
QgsSymbolGroupMap groupNames;
while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QString group = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, SmartgroupName ) );
QString group = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, SmartgroupName ) ) );
groupNames.insert( sqlite3_column_int( ppStmt, SmartgroupId ), group );
}

Expand All @@ -1055,7 +1055,7 @@ QStringList QgsStyleV2::smartgroupNames()
QStringList groups;
while ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
groups << QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
groups << QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, 0 ) ) );
}

sqlite3_finalize( ppStmt );
Expand All @@ -1079,7 +1079,7 @@ QStringList QgsStyleV2::symbolsOfSmartgroup( StyleEntity type, int id )
else
{
QDomDocument doc;
QString xmlstr = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
QString xmlstr = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, 0 ) ) );
if ( !doc.setContent( xmlstr ) )
{
QgsDebugMsg( QString( "Cannot open smartgroup id: %1" ).arg( id ) );
Expand Down Expand Up @@ -1194,7 +1194,7 @@ QgsSmartConditionMap QgsStyleV2::smartgroup( int id )
if ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QDomDocument doc;
QString xmlstr = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
QString xmlstr = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, 0 ) ) );
if ( !doc.setContent( xmlstr ) )
{
QgsDebugMsg( QString( "Cannot open smartgroup id: %1" ).arg( id ) );
Expand Down Expand Up @@ -1236,7 +1236,7 @@ QString QgsStyleV2::smartgroupOperator( int id )
if ( nError == SQLITE_OK && sqlite3_step( ppStmt ) == SQLITE_ROW )
{
QDomDocument doc;
QString xmlstr = QString::fromUtf8(( const char * ) sqlite3_column_text( ppStmt, 0 ) );
QString xmlstr = QString::fromUtf8( reinterpret_cast< const char * >( sqlite3_column_text( ppStmt, 0 ) ) );
if ( !doc.setContent( xmlstr ) )
{
QgsDebugMsg( QString( "Cannot open smartgroup id: %1" ).arg( id ) );
Expand Down
17 changes: 9 additions & 8 deletions src/core/symbology-ng/qgssvgcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ QgsSvgCacheEntry::~QgsSvgCacheEntry()

bool QgsSvgCacheEntry::operator==( const QgsSvgCacheEntry& other ) const
{
return other.file == file && other.size == size && other.outlineWidth == outlineWidth && other.widthScaleFactor == widthScaleFactor
&& other.rasterScaleFactor == rasterScaleFactor && other.fill == fill && other.outline == outline;
return other.file == file && qgsDoubleNear( other.size, size ) && qgsDoubleNear( other.outlineWidth, outlineWidth ) && qgsDoubleNear( other.widthScaleFactor, widthScaleFactor )
&& qgsDoubleNear( other.rasterScaleFactor, rasterScaleFactor ) && other.fill == fill && other.outline == outline;
}

int QgsSvgCacheEntry::dataSize() const
Expand Down Expand Up @@ -136,7 +136,7 @@ const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const Q
}
long cachedDataSize = 0;
cachedDataSize += currentEntry->svgContent.size();
cachedDataSize += ( int )( currentEntry->size * currentEntry->size * hwRatio * 32 );
cachedDataSize += static_cast< int >( currentEntry->size * currentEntry->size * hwRatio * 32 );
if ( cachedDataSize > mMaximumSize / 2 )
{
fitsInCache = false;
Expand Down Expand Up @@ -337,7 +337,7 @@ double QgsSvgCache::calcSizeScaleFactor( QgsSvgCacheEntry* entry, const QDomElem
QString viewBox;

//bad size
if ( !entry || entry->size == 0 )
if ( !entry || qgsDoubleNear( entry->size, 0.0 ) )
return 1.0;

//find svg viewbox attribute
Expand Down Expand Up @@ -511,13 +511,13 @@ void QgsSvgCache::cacheImage( QgsSvgCacheEntry* entry )
hwRatio = r.viewBoxF().height() / r.viewBoxF().width();
}
double wSize = entry->size;
int wImgSize = ( int )wSize;
int wImgSize = static_cast< int >( wSize );
if ( wImgSize < 1 )
{
wImgSize = 1;
}
double hSize = wSize * hwRatio;
int hImgSize = ( int )hSize;
int hImgSize = static_cast< int >( hSize );
if ( hImgSize < 1 )
{
hImgSize = 1;
Expand All @@ -527,7 +527,7 @@ void QgsSvgCache::cacheImage( QgsSvgCacheEntry* entry )
image->fill( 0 ); // transparent background

QPainter p( image );
if ( r.viewBoxF().width() == r.viewBoxF().height() )
if ( qgsDoubleNear( r.viewBoxF().width(), r.viewBoxF().height() ) )
{
r.render( &p );
}
Expand Down Expand Up @@ -588,7 +588,8 @@ QgsSvgCacheEntry* QgsSvgCache::cacheEntry( const QString& file, double size, con
{
QgsSvgCacheEntry* cacheEntry = *entryIt;
if ( qgsDoubleNear( cacheEntry->size, size ) && cacheEntry->fill == fill && cacheEntry->outline == outline &&
cacheEntry->outlineWidth == outlineWidth && cacheEntry->widthScaleFactor == widthScaleFactor && cacheEntry->rasterScaleFactor == rasterScaleFactor )
qgsDoubleNear( cacheEntry->outlineWidth, outlineWidth ) && qgsDoubleNear( cacheEntry->widthScaleFactor, widthScaleFactor )
&& qgsDoubleNear( cacheEntry->rasterScaleFactor, rasterScaleFactor ) )
{
currentEntry = cacheEntry;
break;
Expand Down
6 changes: 3 additions & 3 deletions src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ QgsSymbolLayerV2* QgsVectorFieldSymbolLayer::create( const QgsStringMap& propert
}
if ( properties.contains( "vector_field_type" ) )
{
symbolLayer->setVectorFieldType(( VectorFieldType )( properties["vector_field_type"].toInt() ) );
symbolLayer->setVectorFieldType( static_cast< VectorFieldType >( properties["vector_field_type"].toInt() ) );
}
if ( properties.contains( "angle_orientation" ) )
{
symbolLayer->setAngleOrientation(( AngleOrientation )( properties["angle_orientation"].toInt() ) );
symbolLayer->setAngleOrientation( static_cast< AngleOrientation >( properties["angle_orientation"].toInt() ) );
}
if ( properties.contains( "angle_units" ) )
{
symbolLayer->setAngleUnits(( AngleUnits )( properties["angle_units"].toInt() ) );
symbolLayer->setAngleUnits( static_cast< AngleUnits >( properties["angle_units"].toInt() ) );
}
if ( properties.contains( "size" ) )
{
Expand Down

0 comments on commit 2cacc6a

Please sign in to comment.