Use auto to reduce some verbosity.

This commit is contained in:
Jim Evins
2017-12-30 21:41:02 -05:00
parent c7a6ed4917
commit 9a135f8971
34 changed files with 84 additions and 84 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ namespace glabels
{
foreach( ModelObject* object, objects )
{
if ( ModelImageObject* imageObject = dynamic_cast<ModelImageObject*>(object) )
if ( auto* imageObject = dynamic_cast<ModelImageObject*>(object) )
{
TextNode filenameNode = imageObject->filenameNode();
if ( !filenameNode.isField() )
+1 -1
View File
@@ -87,7 +87,7 @@ namespace glabels
Db* Db::instance()
{
static Db* db = new Db();
static auto* db = new Db();
return db;
}
+1 -1
View File
@@ -161,7 +161,7 @@ namespace glabels
bool FrameCd::isSimilarTo( Frame* other ) const
{
if ( FrameCd *otherCd = dynamic_cast<FrameCd*>(other) )
if ( auto *otherCd = dynamic_cast<FrameCd*>(other) )
{
if ( (fabs( mW - otherCd->mW ) <= EPSILON) &&
(fabs( mH - otherCd->mH ) <= EPSILON) &&
+1 -1
View File
@@ -95,7 +95,7 @@ namespace glabels
bool FrameEllipse::isSimilarTo( Frame* other ) const
{
if ( FrameEllipse* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
if ( auto* otherEllipse = dynamic_cast<FrameEllipse*>(other) )
{
if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) &&
(fabs( mH - otherEllipse->mH ) <= EPSILON) )
+1 -1
View File
@@ -114,7 +114,7 @@ namespace glabels
bool FrameRect::isSimilarTo( Frame* other ) const
{
if ( FrameRect *otherRect = dynamic_cast<FrameRect*>(other) )
if ( auto *otherRect = dynamic_cast<FrameRect*>(other) )
{
if ( (fabs( mW - otherRect->mW ) <= EPSILON) &&
(fabs( mH - otherRect->mH ) <= EPSILON) )
+1 -1
View File
@@ -100,7 +100,7 @@ namespace glabels
bool FrameRound::isSimilarTo( Frame* other ) const
{
if ( FrameRound *otherRound = dynamic_cast<FrameRound*>(other) )
if ( auto *otherRound = dynamic_cast<FrameRound*>(other) )
{
if ( fabs( mR - otherRound->mR ) <= EPSILON )
{
+1 -1
View File
@@ -99,7 +99,7 @@ namespace glabels
Layout* Layout::dup() const
{
Layout *other = new Layout( *this );
auto *other = new Layout( *this );
return other;
}
+4 -4
View File
@@ -65,7 +65,7 @@ namespace glabels
///
Model* Model::save() const
{
Model* savedModel = new Model;
auto* savedModel = new Model;
savedModel->restore( this );
return savedModel;
@@ -1344,7 +1344,7 @@ namespace glabels
QByteArray buffer;
XmlLabelCreator::serializeObjects( getSelection(), buffer );
QMimeData *mimeData = new QMimeData;
auto *mimeData = new QMimeData;
mimeData->setData( MIME_TYPE, buffer );
clipboard->setMimeData( mimeData );
@@ -1410,7 +1410,7 @@ namespace glabels
else if ( mimeData->hasImage() )
{
// Create object from clipboard image
ModelImageObject* object = new ModelImageObject();
auto* object = new ModelImageObject();
object->setImage( qvariant_cast<QImage>(mimeData->imageData()) );
object->setSize( object->naturalSize() );
object->setPosition( (w()-object->w())/2.0, (h()-object->h())/2.0 );
@@ -1421,7 +1421,7 @@ namespace glabels
else if ( mimeData->hasText() )
{
// Create object from clipboard text
ModelTextObject* object = new ModelTextObject();
auto* object = new ModelTextObject();
object->setText( mimeData->text() );
object->setSize( object->naturalSize() );
object->setPosition( (w()-object->w())/2.0, (h()-object->h())/2.0 );
+2 -2
View File
@@ -551,10 +551,10 @@ namespace glabels
int b = color.blue();
int a = color.alpha();
QImage* shadow = new QImage( *mImage );
auto* shadow = new QImage( *mImage );
for ( int iy = 0; iy < shadow->height(); iy++ )
{
QRgb* scanLine = (QRgb*)shadow->scanLine( iy );
auto* scanLine = (QRgb*)shadow->scanLine( iy );
for ( int ix = 0; ix < shadow->width(); ix++ )
{
+2 -2
View File
@@ -68,8 +68,8 @@ namespace glabels
/* Simple integer. */
return QString().sprintf( "%.0f", x );
}
int n = (int)( x * denom[i] + 0.5 );
int d = (int)denom[i];
auto n = int( x * denom[i] + 0.5 );
auto d = int( denom[i] );
if ( n > d )
{
return QString::number(n/d) +
+1 -1
View File
@@ -95,7 +95,7 @@ namespace glabels
QString id = XmlUtil::getStringAttr( node, "id", "" );
QString name = XmlUtil::getI18nAttr( node, "name", "" );
Category *category = new Category( id, name );
auto *category = new Category( id, name );
if ( category != nullptr )
{
Db::registerCategory( category );
+6 -6
View File
@@ -132,27 +132,27 @@ namespace glabels
foreach ( ModelObject* object, objects )
{
if ( ModelBoxObject* boxObject = dynamic_cast<ModelBoxObject*>(object) )
if ( auto* boxObject = dynamic_cast<ModelBoxObject*>(object) )
{
createObjectBoxNode( node, boxObject );
}
else if ( ModelEllipseObject* ellipseObject = dynamic_cast<ModelEllipseObject*>(object) )
else if ( auto* ellipseObject = dynamic_cast<ModelEllipseObject*>(object) )
{
createObjectEllipseNode( node, ellipseObject );
}
else if ( ModelLineObject* lineObject = dynamic_cast<ModelLineObject*>(object) )
else if ( auto* lineObject = dynamic_cast<ModelLineObject*>(object) )
{
createObjectLineNode( node, lineObject );
}
else if ( ModelImageObject* imageObject = dynamic_cast<ModelImageObject*>(object) )
else if ( auto* imageObject = dynamic_cast<ModelImageObject*>(object) )
{
createObjectImageNode( node, imageObject );
}
else if ( ModelBarcodeObject* barcodeObject = dynamic_cast<ModelBarcodeObject*>(object) )
else if ( auto* barcodeObject = dynamic_cast<ModelBarcodeObject*>(object) )
{
createObjectBarcodeNode( node, barcodeObject );
}
else if ( ModelTextObject* textObject = dynamic_cast<ModelTextObject*>(object) )
else if ( auto* textObject = dynamic_cast<ModelTextObject*>(object) )
{
createObjectTextNode( node, textObject );
}
+1 -1
View File
@@ -242,7 +242,7 @@ namespace glabels
qWarning() << "TODO: compatability mode.";
}
Model* label = new Model();
auto* label = new Model();
/* Pass 1, extract data nodes to pre-load cache. */
DataCache data;
+1 -1
View File
@@ -100,7 +100,7 @@ namespace glabels
QString pwgSize = XmlUtil::getStringAttr( node, "pwg_size", "" );
Paper *paper = new Paper( id, name, width, height, pwgSize );
auto *paper = new Paper( id, name, width, height, pwgSize );
if ( paper != nullptr )
{
Db::registerPaper( paper );
+9 -9
View File
@@ -125,19 +125,19 @@ namespace glabels
void XmlTemplateCreator::createLabelNode( QDomElement &parent, const Frame* frame )
{
if ( const FrameRect* frameRect = dynamic_cast<const FrameRect*>(frame) )
if ( const auto* frameRect = dynamic_cast<const FrameRect*>(frame) )
{
createLabelRectangleNode( parent, frameRect );
}
else if ( const FrameEllipse* frameEllipse = dynamic_cast<const FrameEllipse*>(frame) )
else if ( const auto* frameEllipse = dynamic_cast<const FrameEllipse*>(frame) )
{
createLabelEllipseNode( parent, frameEllipse );
}
else if ( const FrameRound* frameRound = dynamic_cast<const FrameRound*>(frame) )
else if ( const auto* frameRound = dynamic_cast<const FrameRound*>(frame) )
{
createLabelRoundNode( parent, frameRound );
}
else if ( const FrameCd* frameCd = dynamic_cast<const FrameCd*>(frame) )
else if ( const auto* frameCd = dynamic_cast<const FrameCd*>(frame) )
{
createLabelCdNode( parent, frameCd );
}
@@ -221,23 +221,23 @@ namespace glabels
{
foreach ( Markup* markup, frame->markups() )
{
if ( MarkupMargin* markupMargin = dynamic_cast<MarkupMargin*>(markup) )
if ( auto* markupMargin = dynamic_cast<MarkupMargin*>(markup) )
{
createMarkupMarginNode( node, markupMargin );
}
else if ( MarkupLine* markupLine = dynamic_cast<MarkupLine*>(markup) )
else if ( auto* markupLine = dynamic_cast<MarkupLine*>(markup) )
{
createMarkupLineNode( node, markupLine );
}
else if ( MarkupCircle* markupCircle = dynamic_cast<MarkupCircle*>(markup) )
else if ( auto* markupCircle = dynamic_cast<MarkupCircle*>(markup) )
{
createMarkupCircleNode( node, markupCircle );
}
else if ( MarkupRect* markupRect = dynamic_cast<MarkupRect*>(markup) )
else if ( auto* markupRect = dynamic_cast<MarkupRect*>(markup) )
{
createMarkupRectNode( node, markupRect );
}
else if ( MarkupEllipse* markupEllipse = dynamic_cast<MarkupEllipse*>(markup) )
else if ( auto* markupEllipse = dynamic_cast<MarkupEllipse*>(markup) )
{
createMarkupEllipseNode( node, markupEllipse );
}
+1 -1
View File
@@ -95,7 +95,7 @@ namespace glabels
QString name = XmlUtil::getStringAttr( node, "name", "" );
QString url = XmlUtil::getStringAttr( node, "url", "" );
Vendor *vendor = new Vendor( name, url );
auto *vendor = new Vendor( name, url );
if ( vendor != nullptr )
{
Db::registerVendor( vendor );