Skip to content

Commit

Permalink
Fix more clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 5, 2016
1 parent 614c84f commit 1340afd
Show file tree
Hide file tree
Showing 31 changed files with 179 additions and 218 deletions.
4 changes: 2 additions & 2 deletions src/core/composer/qgsatlascomposition.cpp
Expand Up @@ -756,7 +756,7 @@ void QgsAtlasComposition::readXMLMapSettings( const QDomElement &elem, const QDo

//upgrade pre 2.1 projects
double margin = elem.attribute( "margin", "0.0" ).toDouble();
if ( composerMap && margin != 0 )
if ( composerMap && !qgsDoubleNear( margin, 0.0 ) )
{
composerMap->setAtlasMargin( margin );
}
Expand Down Expand Up @@ -905,7 +905,7 @@ void QgsAtlasComposition::setMargin( float margin )
return;
}

map->setAtlasMargin(( double ) margin );
map->setAtlasMargin( static_cast< double >( margin ) );
}

QgsGeometry QgsAtlasComposition::currentGeometry( const QgsCoordinateReferenceSystem& crs ) const
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerattributetablemodel.cpp
Expand Up @@ -602,7 +602,7 @@ bool QgsComposerTableSortColumnsProxyModel::setData( const QModelIndex& index, c

if ( index.column() == 1 )
{
column->setSortOrder(( Qt::SortOrder )value.toInt() );
column->setSortOrder( static_cast< Qt::SortOrder >( value.toInt() ) );
emit dataChanged( index, index );
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerattributetablemodelv2.cpp
Expand Up @@ -620,7 +620,7 @@ bool QgsComposerTableSortColumnsProxyModelV2::setData( const QModelIndex& index,

if ( index.column() == 1 )
{
column->setSortOrder(( Qt::SortOrder )value.toInt() );
column->setSortOrder( static_cast< Qt::SortOrder >( value.toInt() ) );
emit dataChanged( index, index );
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerattributetablev2.cpp
Expand Up @@ -687,7 +687,7 @@ void QgsComposerAttributeTableV2::setWrapString( const QString &wrapString )
bool QgsComposerAttributeTableV2::writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames ) const
{
QDomElement composerTableElem = doc.createElement( "ComposerAttributeTableV2" );
composerTableElem.setAttribute( "source", QString::number(( int )mSource ) );
composerTableElem.setAttribute( "source", QString::number( static_cast< int >( mSource ) ) );
composerTableElem.setAttribute( "relationId", mRelationId );
composerTableElem.setAttribute( "showUniqueRowsOnly", mShowUniqueRowsOnly );
composerTableElem.setAttribute( "showOnlyVisibleFeatures", mShowOnlyVisibleFeatures );
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposerhtml.cpp
Expand Up @@ -223,7 +223,7 @@ double QgsComposerHtml::maxFrameWidth() const
QList<QgsComposerFrame*>::const_iterator frameIt = mFrameItems.constBegin();
for ( ; frameIt != mFrameItems.constEnd(); ++frameIt )
{
maxWidth = qMax( maxWidth, ( double )(( *frameIt )->boundingRect().width() ) );
maxWidth = qMax( maxWidth, static_cast< double >(( *frameIt )->boundingRect().width() ) );
}

return maxWidth;
Expand Down Expand Up @@ -467,7 +467,7 @@ QString QgsComposerHtml::displayName() const
bool QgsComposerHtml::writeXML( QDomElement& elem, QDomDocument & doc, bool ignoreFrames ) const
{
QDomElement htmlElem = doc.createElement( "ComposerHtml" );
htmlElem.setAttribute( "contentMode", QString::number(( int ) mContentMode ) );
htmlElem.setAttribute( "contentMode", QString::number( static_cast< int >( mContentMode ) ) );
htmlElem.setAttribute( "url", mUrl.toString() );
htmlElem.setAttribute( "html", mHtml );
htmlElem.setAttribute( "evaluateExpressions", mEvaluateExpressions ? "true" : "false" );
Expand Down Expand Up @@ -495,7 +495,7 @@ bool QgsComposerHtml::readXML( const QDomElement& itemElem, const QDomDocument&
}

bool contentModeOK;
mContentMode = ( QgsComposerHtml::ContentMode )itemElem.attribute( "contentMode" ).toInt( &contentModeOK );
mContentMode = static_cast< QgsComposerHtml::ContentMode >( itemElem.attribute( "contentMode" ).toInt( &contentModeOK ) );
if ( !contentModeOK )
{
mContentMode = QgsComposerHtml::Url;
Expand Down
14 changes: 7 additions & 7 deletions src/core/composer/qgscomposeritem.cpp
Expand Up @@ -202,7 +202,7 @@ bool QgsComposerItem::_writeXML( QDomElement& itemElem, QDomDocument& doc ) cons
composerItemElem.setAttribute( "pagey", QString::number( pagepos.y() ) );
composerItemElem.setAttribute( "width", QString::number( rect().width() ) );
composerItemElem.setAttribute( "height", QString::number( rect().height() ) );
composerItemElem.setAttribute( "positionMode", QString::number(( int ) mLastUsedPositionMode ) );
composerItemElem.setAttribute( "positionMode", QString::number( static_cast< int >( mLastUsedPositionMode ) ) );
composerItemElem.setAttribute( "zValue", QString::number( zValue() ) );
composerItemElem.setAttribute( "outlineWidth", QString::number( pen().widthF() ) );
composerItemElem.setAttribute( "frameJoinStyle", QgsSymbolLayerV2Utils::encodePenJoinStyle( mFrameJoinStyle ) );
Expand Down Expand Up @@ -325,7 +325,7 @@ bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument&
pagey = itemElem.attribute( "pagey" ).toDouble( &pageyOk );
width = itemElem.attribute( "width" ).toDouble( &widthOk );
height = itemElem.attribute( "height" ).toDouble( &heightOk );
mLastUsedPositionMode = ( ItemPositionMode )itemElem.attribute( "positionMode" ).toInt( &positionModeOK );
mLastUsedPositionMode = static_cast< ItemPositionMode >( itemElem.attribute( "positionMode" ).toInt( &positionModeOK ) );
if ( !positionModeOK )
{
mLastUsedPositionMode = UpperLeft;
Expand Down Expand Up @@ -391,7 +391,7 @@ bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument&
}

//blend mode
setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) );
setBlendMode( QgsMapRenderer::getCompositionMode( static_cast< QgsMapRenderer::BlendMode >( itemElem.attribute( "blendMode", "0" ).toUInt() ) ) );

//transparency
setTransparency( itemElem.attribute( "transparency", "0" ).toInt() );
Expand Down Expand Up @@ -433,7 +433,7 @@ void QgsComposerItem::setFrameOutlineColor( const QColor &color )
void QgsComposerItem::setFrameOutlineWidth( const double outlineWidth )
{
QPen itemPen = pen();
if ( itemPen.widthF() == outlineWidth )
if ( qgsDoubleNear( itemPen.widthF(), outlineWidth ) )
{
//no change
return;
Expand Down Expand Up @@ -652,7 +652,7 @@ void QgsComposerItem::setItemPosition( double x, double y, double width, double
{
//adjust position to account for frame size

if ( mEvaluatedItemRotation == 0 )
if ( qgsDoubleNear( mEvaluatedItemRotation, 0.0 ) )
{
upperLeftX += estimatedFrameBleed();
upperLeftY += estimatedFrameBleed();
Expand Down Expand Up @@ -1061,7 +1061,7 @@ void QgsComposerItem::setItemRotation( const double r, const bool adjustPosition
{
if ( r >= 360 )
{
mItemRotation = (( int )r ) % 360;
mItemRotation = ( static_cast< int >( r ) ) % 360;
}
else
{
Expand Down Expand Up @@ -1089,7 +1089,7 @@ void QgsComposerItem::refreshRotation( const bool updateItem, const bool adjustP
}
}

if ( rotation == mEvaluatedItemRotation )
if ( qgsDoubleNear( rotation, mEvaluatedItemRotation ) )
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposeritemgroup.cpp
Expand Up @@ -71,14 +71,14 @@ void QgsComposerItemGroup::addItem( QgsComposerItem* item )
//call method of superclass to avoid repositioning of items
QgsComposerItem::setSceneRect( QRectF( item->pos().x(), item->pos().y(), item->rect().width(), item->rect().height() ) );

if ( item->itemRotation() != 0 )
if ( !qgsDoubleNear( item->itemRotation(), 0.0 ) )
{
setItemRotation( item->itemRotation() );
}
}
else
{
if ( item->itemRotation() != itemRotation() )
if ( !qgsDoubleNear( item->itemRotation(), itemRotation() ) )
{
//items have mixed rotation, so reset rotation of group
mBoundingRectangle = mapRectToScene( mBoundingRectangle );
Expand Down
6 changes: 3 additions & 3 deletions src/core/composer/qgscomposerlabel.cpp
Expand Up @@ -448,10 +448,10 @@ bool QgsComposerLabel::readXML( const QDomElement& itemElem, const QDomDocument&
}

//Horizontal alignment
mHAlignment = ( Qt::AlignmentFlag )( itemElem.attribute( "halign" ).toInt() );
mHAlignment = static_cast< Qt::AlignmentFlag >( itemElem.attribute( "halign" ).toInt() );

//Vertical alignment
mVAlignment = ( Qt::AlignmentFlag )( itemElem.attribute( "valign" ).toInt() );
mVAlignment = static_cast< Qt::AlignmentFlag >( itemElem.attribute( "valign" ).toInt() );

//font
QgsFontUtils::setFromXmlChildNode( mFont, itemElem, "LabelFont" );
Expand All @@ -478,7 +478,7 @@ bool QgsComposerLabel::readXML( const QDomElement& itemElem, const QDomDocument&
QDomElement composerItemElem = composerItemList.at( 0 ).toElement();

//rotation
if ( composerItemElem.attribute( "rotation", "0" ).toDouble() != 0 )
if ( !qgsDoubleNear( composerItemElem.attribute( "rotation", "0" ).toDouble(), 0.0 ) )
{
//check for old (pre 2.1) rotation attribute
setItemRotation( composerItemElem.attribute( "rotation", "0" ).toDouble() );
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposerlegend.cpp
Expand Up @@ -322,7 +322,7 @@ bool QgsComposerLegend::writeXML( QDomElement& elem, QDomDocument & doc ) const

//write general properties
composerLegendElem.setAttribute( "title", mSettings.title() );
composerLegendElem.setAttribute( "titleAlignment", QString::number(( int ) mSettings.titleAlignment() ) );
composerLegendElem.setAttribute( "titleAlignment", QString::number( static_cast< int >( mSettings.titleAlignment() ) ) );
composerLegendElem.setAttribute( "columnCount", QString::number( mSettings.columnCount() ) );
composerLegendElem.setAttribute( "splitLayer", QString::number( mSettings.splitLayer() ) );
composerLegendElem.setAttribute( "equalColumnWidth", QString::number( mSettings.equalColumnWidth() ) );
Expand Down Expand Up @@ -421,7 +421,7 @@ bool QgsComposerLegend::readXML( const QDomElement& itemElem, const QDomDocument
mSettings.setTitle( itemElem.attribute( "title" ) );
if ( !itemElem.attribute( "titleAlignment" ).isEmpty() )
{
mSettings.setTitleAlignment(( Qt::AlignmentFlag )itemElem.attribute( "titleAlignment" ).toInt() );
mSettings.setTitleAlignment( static_cast< Qt::AlignmentFlag >( itemElem.attribute( "titleAlignment" ).toInt() ) );
}
int colCount = itemElem.attribute( "columnCount", "1" ).toInt();
if ( colCount < 1 ) colCount = 1;
Expand Down
8 changes: 4 additions & 4 deletions src/core/composer/qgscomposerlegendstyle.cpp
Expand Up @@ -57,10 +57,10 @@ void QgsComposerLegendStyle::writeXML( const QString& name, QDomElement& elem, Q

styleElem.setAttribute( "name", name );

if ( mMarginMap[Top] != 0 ) styleElem.setAttribute( "marginTop", QString::number( mMarginMap[Top] ) );
if ( mMarginMap[Bottom] != 0 ) styleElem.setAttribute( "marginBottom", QString::number( mMarginMap[Bottom] ) );
if ( mMarginMap[Left] != 0 ) styleElem.setAttribute( "marginLeft", QString::number( mMarginMap[Left] ) );
if ( mMarginMap[Right] != 0 ) styleElem.setAttribute( "marginRight", QString::number( mMarginMap[Right] ) );
if ( !qgsDoubleNear( mMarginMap[Top], 0.0 ) ) styleElem.setAttribute( "marginTop", QString::number( mMarginMap[Top] ) );
if ( !qgsDoubleNear( mMarginMap[Bottom], 0.0 ) ) styleElem.setAttribute( "marginBottom", QString::number( mMarginMap[Bottom] ) );
if ( !qgsDoubleNear( mMarginMap[Left], 0.0 ) ) styleElem.setAttribute( "marginLeft", QString::number( mMarginMap[Left] ) );
if ( !qgsDoubleNear( mMarginMap[Right], 0.0 ) ) styleElem.setAttribute( "marginRight", QString::number( mMarginMap[Right] ) );

styleElem.appendChild( QgsFontUtils::toXmlElement( mFont, doc, "styleFont" ) );

Expand Down

0 comments on commit 1340afd

Please sign in to comment.