From 9a135f8971c2bc2537f921964f6550b275323b3a Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 30 Dec 2017 21:41:02 -0500 Subject: [PATCH] Use auto to reduce some verbosity. --- backends/barcode/GnuBarcode.cpp | 2 +- backends/merge/Text.cpp | 2 +- glabels/BarcodeMenu.cpp | 4 ++-- glabels/ColorPaletteDialog.cpp | 10 +++++----- glabels/FieldButton.cpp | 4 ++-- glabels/File.cpp | 8 ++++---- glabels/MainWindow.cpp | 6 +++--- glabels/MergeView.cpp | 12 ++++++------ glabels/Preview.cpp | 8 ++++---- glabels/PropertiesView.cpp | 2 +- glabels/SimplePreview.cpp | 8 ++++---- glabels/TemplatePicker.cpp | 6 +++--- glabels/UndoRedoModel.cpp | 6 +++--- glabels/main.cpp | 4 ++-- glbarcode/BarcodeCode39.cpp | 2 +- glbarcode/BarcodeUpcBase.cpp | 2 +- glbarcode/Factory.cpp | 4 ++-- glbarcode/Renderer.cpp | 10 +++++----- model/DataCache.cpp | 2 +- model/Db.cpp | 2 +- model/FrameCd.cpp | 2 +- model/FrameEllipse.cpp | 2 +- model/FrameRect.cpp | 2 +- model/FrameRound.cpp | 2 +- model/Layout.cpp | 2 +- model/Model.cpp | 8 ++++---- model/ModelImageObject.cpp | 4 ++-- model/StrUtil.cpp | 4 ++-- model/XmlCategoryParser.cpp | 2 +- model/XmlLabelCreator.cpp | 12 ++++++------ model/XmlLabelParser.cpp | 2 +- model/XmlPaperParser.cpp | 2 +- model/XmlTemplateCreator.cpp | 18 +++++++++--------- model/XmlVendorParser.cpp | 2 +- 34 files changed, 84 insertions(+), 84 deletions(-) diff --git a/backends/barcode/GnuBarcode.cpp b/backends/barcode/GnuBarcode.cpp index fb57662..6190115 100644 --- a/backends/barcode/GnuBarcode.cpp +++ b/backends/barcode/GnuBarcode.cpp @@ -213,7 +213,7 @@ namespace glabels /* But it can be too small, in this case enlarge and center the area */ if ( bci->width < (int)(barlen * scalef) ) { - int wid = (int)( barlen * scalef + 1); + auto wid = int( barlen * scalef + 1); bci->xoff -= (wid - bci->width)/2 ; bci->width = wid; /* Can't extend too far on the left */ diff --git a/backends/merge/Text.cpp b/backends/merge/Text.cpp index 6ae1d8f..f1aff8a 100644 --- a/backends/merge/Text.cpp +++ b/backends/merge/Text.cpp @@ -119,7 +119,7 @@ namespace glabels QStringList values = parseLine(); if ( !values.isEmpty() ) { - Record* record = new Record(); + auto* record = new Record(); int iField = 0; foreach ( QString value, values ) diff --git a/glabels/BarcodeMenu.cpp b/glabels/BarcodeMenu.cpp index 1f8c597..1929860 100644 --- a/glabels/BarcodeMenu.cpp +++ b/glabels/BarcodeMenu.cpp @@ -39,7 +39,7 @@ namespace glabels { if ( bcStyle.backendId() == "" ) { - BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle ); + auto* bcMenuItem = new BarcodeMenuItem( bcStyle ); connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)), this, SLOT(onMenuItemActivated(const barcode::Style&)) ); @@ -55,7 +55,7 @@ namespace glabels { if ( bcStyle.backendId() == backendId ) { - BarcodeMenuItem* bcMenuItem = new BarcodeMenuItem( bcStyle ); + auto* bcMenuItem = new BarcodeMenuItem( bcStyle ); connect( bcMenuItem, SIGNAL(activated(const barcode::Style&)), this, SLOT(onMenuItemActivated(const barcode::Style&)) ); diff --git a/glabels/ColorPaletteDialog.cpp b/glabels/ColorPaletteDialog.cpp index cab3dae..f9ec10b 100644 --- a/glabels/ColorPaletteDialog.cpp +++ b/glabels/ColorPaletteDialog.cpp @@ -95,11 +95,11 @@ namespace glabels setStyleSheet( ".glabels--ColorPaletteDialog {background: white; border: 1px solid black}" ); setWindowFlags( Qt::Popup | Qt::FramelessWindowHint ); - QVBoxLayout* vLayout = new QVBoxLayout(); + auto* vLayout = new QVBoxLayout(); vLayout->setContentsMargins( 0, 0, 0, 0 ); vLayout->setSpacing( 0 ); - ColorPaletteButtonItem* defaultButton = new ColorPaletteButtonItem( defaultLabel ); + auto* defaultButton = new ColorPaletteButtonItem( defaultLabel ); connect( defaultButton, SIGNAL(activated()), this, SLOT(onDefaultItemActivated()) ); vLayout->addWidget( defaultButton ); @@ -108,7 +108,7 @@ namespace glabels hline1->setLineWidth( 1 ); vLayout->addWidget( hline1 ); - QGridLayout* mainPaletteLayout = new QGridLayout(); + auto* mainPaletteLayout = new QGridLayout(); mainPaletteLayout->setSpacing( 0 ); for ( int iRow = 0; iRow < PALETTE_ROWS; iRow++ ) { @@ -131,7 +131,7 @@ namespace glabels hline2->setLineWidth( 1 ); vLayout->addWidget( hline2 ); - QHBoxLayout* customPaletteLayout = new QHBoxLayout(); + auto* customPaletteLayout = new QHBoxLayout(); customPaletteLayout->setSpacing( 0 ); for ( int iCol = 0; iCol < PALETTE_COLS; iCol++ ) { @@ -167,7 +167,7 @@ namespace glabels vLayout->addWidget( mMergeFieldCombo ); // Item 0 is the ComboBox title, not an item intended for selection. So disable it. - const QStandardItemModel* model = qobject_cast(mMergeFieldCombo->model()); + const auto* model = qobject_cast(mMergeFieldCombo->model()); QStandardItem* item = model->item(0); item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) ); diff --git a/glabels/FieldButton.cpp b/glabels/FieldButton.cpp index 9fe7c5c..f6c25b6 100644 --- a/glabels/FieldButton.cpp +++ b/glabels/FieldButton.cpp @@ -52,7 +52,7 @@ namespace glabels } // Item 0 is the ComboBox title, not an item intended for selection. So disable it. - const QStandardItemModel* itemModel = qobject_cast(model()); + const auto* itemModel = qobject_cast(model()); QStandardItem* item = itemModel->item(0); item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) ); } @@ -65,7 +65,7 @@ namespace glabels addItem( mName ); // Item 0 is the ComboBox title, not an item intended for selection. So disable it. - const QStandardItemModel* itemModel = qobject_cast(model()); + const auto* itemModel = qobject_cast(model()); QStandardItem* item = itemModel->item(0); item->setFlags( item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) ); diff --git a/glabels/File.cpp b/glabels/File.cpp index 00a9855..e7d7edc 100644 --- a/glabels/File.cpp +++ b/glabels/File.cpp @@ -53,7 +53,7 @@ namespace glabels const model::Template* tmplate = dialog.tmplate(); if ( tmplate ) { - model::Model* model = new model::Model(); + auto* model = new model::Model(); model->setTmplate( tmplate ); model->clearModified(); @@ -68,7 +68,7 @@ namespace glabels } else { - MainWindow *newWindow = new MainWindow(); + auto *newWindow = new MainWindow(); newWindow->setModel( model ); newWindow->show(); } @@ -118,7 +118,7 @@ namespace glabels } else { - MainWindow *newWindow = new MainWindow(); + auto *newWindow = new MainWindow(); newWindow->setModel( model ); newWindow->show(); } @@ -237,7 +237,7 @@ namespace glabels { foreach ( QWidget* qwidget, QApplication::topLevelWidgets() ) { - if ( MainWindow* window = qobject_cast(qwidget) ) + if ( auto* window = qobject_cast(qwidget) ) { window->close(); } diff --git a/glabels/MainWindow.cpp b/glabels/MainWindow.cpp index b370cec..f88d634 100644 --- a/glabels/MainWindow.cpp +++ b/glabels/MainWindow.cpp @@ -113,7 +113,7 @@ namespace glabels // Create central widget QWidget *centralWidget = new QWidget(); - QHBoxLayout *hLayout = new QHBoxLayout(); + auto *hLayout = new QHBoxLayout(); hLayout->setContentsMargins( 0, 0, 0, 0 ); hLayout->addWidget( mContents ); hLayout->addWidget( mPages ); @@ -698,12 +698,12 @@ namespace glabels mLabelEditorScrollArea->setWidget( mLabelEditor ); - QVBoxLayout* editorVLayout = new QVBoxLayout; + auto* editorVLayout = new QVBoxLayout; editorVLayout->setContentsMargins( 0, 0, 0, 0 ); editorVLayout->addWidget( editorToolBar ); editorVLayout->addWidget( mLabelEditorScrollArea ); - QHBoxLayout* editorHLayout = new QHBoxLayout; + auto* editorHLayout = new QHBoxLayout; editorHLayout->setContentsMargins( 0, 0, 0, 0 ); editorHLayout->addLayout( editorVLayout ); editorHLayout->addWidget( mObjectEditor ); diff --git a/glabels/MergeView.cpp b/glabels/MergeView.cpp index d01ecc9..fc236b3 100644 --- a/glabels/MergeView.cpp +++ b/glabels/MergeView.cpp @@ -246,7 +246,7 @@ namespace glabels recordsTable->setColumnCount( mKeys.size() + 1 ); // Include extra column // First column = primay Key - QTableWidgetItem* item = new QTableWidgetItem( mPrimaryKey ); + auto* item = new QTableWidgetItem( mPrimaryKey ); item->setFlags( Qt::ItemIsEnabled ); recordsTable->setHorizontalHeaderItem( 0, item ); @@ -256,7 +256,7 @@ namespace glabels { if ( key != mPrimaryKey ) { - QTableWidgetItem* item = new QTableWidgetItem( key ); + auto* item = new QTableWidgetItem( key ); item->setFlags( Qt::ItemIsEnabled ); recordsTable->setHorizontalHeaderItem( iCol, item ); @@ -266,7 +266,7 @@ namespace glabels } // Extra dummy column to fill any extra horizontal space - QTableWidgetItem* fillItem = new QTableWidgetItem(); + auto* fillItem = new QTableWidgetItem(); fillItem->setFlags( Qt::NoItemFlags ); recordsTable->setHorizontalHeaderItem( iCol, fillItem ); recordsTable->horizontalHeader()->setStretchLastSection( true ); @@ -288,7 +288,7 @@ namespace glabels foreach ( merge::Record* record, records ) { // First column for primay field - QTableWidgetItem* item = new QTableWidgetItem(); + auto* item = new QTableWidgetItem(); if ( record->contains( mPrimaryKey ) ) { item->setText( (*record)[mPrimaryKey] ); @@ -306,7 +306,7 @@ namespace glabels { if ( record->contains( key ) ) { - QTableWidgetItem* item = new QTableWidgetItem( (*record)[key] ); + auto* item = new QTableWidgetItem( (*record)[key] ); item->setFlags( Qt::ItemIsEnabled ); recordsTable->setItem( iRow, iCol, item ); recordsTable->resizeColumnToContents( iCol ); @@ -317,7 +317,7 @@ namespace glabels } // Extra dummy column to fill any extra horizontal space - QTableWidgetItem* fillItem = new QTableWidgetItem(); + auto* fillItem = new QTableWidgetItem(); fillItem->setFlags( Qt::NoItemFlags ); recordsTable->setItem( iRow, iCol, fillItem ); diff --git a/glabels/Preview.cpp b/glabels/Preview.cpp index 8d018b8..259732a 100644 --- a/glabels/Preview.cpp +++ b/glabels/Preview.cpp @@ -132,7 +132,7 @@ namespace glabels /// void Preview::drawPaper( const model::Distance& pw, const model::Distance& ph ) { - QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(); + auto *shadowEffect = new QGraphicsDropShadowEffect(); shadowEffect->setColor( shadowColor ); shadowEffect->setOffset( shadowOffsetPixels ); shadowEffect->setBlurRadius( shadowRadiusPixels ); @@ -142,7 +142,7 @@ namespace glabels pen.setCosmetic( true ); pen.setWidthF( paperOutlineWidthPixels ); - QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() ); + auto *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() ); pageItem->setBrush( brush ); pageItem->setPen( pen ); pageItem->setGraphicsEffect( shadowEffect ); @@ -176,7 +176,7 @@ namespace glabels pen.setCosmetic( true ); pen.setWidthF( labelOutlineWidthPixels ); - QGraphicsPathItem *labelOutlineItem = new QGraphicsPathItem( path ); + auto *labelOutlineItem = new QGraphicsPathItem( path ); labelOutlineItem->setBrush( brush ); labelOutlineItem->setPen( pen ); labelOutlineItem->setPos( x.pt(), y.pt() ); @@ -192,7 +192,7 @@ namespace glabels { if ( mRenderer ) { - PreviewOverlayItem* overlayItem = new PreviewOverlayItem( mRenderer ); + auto* overlayItem = new PreviewOverlayItem( mRenderer ); mScene->addItem( overlayItem ); } } diff --git a/glabels/PropertiesView.cpp b/glabels/PropertiesView.cpp index 75680f5..6c4fb1d 100644 --- a/glabels/PropertiesView.cpp +++ b/glabels/PropertiesView.cpp @@ -44,7 +44,7 @@ namespace glabels titleLabel->setText( QString( "%1" ).arg( tr("Properties") ) ); // Hack to get orientationCombo item height to follow icon size plus padding - QStyledItemDelegate* itemDelegate = new QStyledItemDelegate(); + auto* itemDelegate = new QStyledItemDelegate(); orientationCombo->setItemDelegate( itemDelegate ); orientationCombo->setStyleSheet( "* QAbstractItemView::item { padding: 8px; }" ); diff --git a/glabels/SimplePreview.cpp b/glabels/SimplePreview.cpp index 10132f7..79f7765 100644 --- a/glabels/SimplePreview.cpp +++ b/glabels/SimplePreview.cpp @@ -143,7 +143,7 @@ namespace glabels /// void SimplePreview::drawPaper( const model::Distance& pw, const model::Distance& ph ) { - QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(); + auto *shadowEffect = new QGraphicsDropShadowEffect(); shadowEffect->setColor( shadowColor ); shadowEffect->setOffset( shadowOffsetPixels ); shadowEffect->setBlurRadius( shadowRadiusPixels ); @@ -153,7 +153,7 @@ namespace glabels pen.setCosmetic( true ); pen.setWidthF( paperOutlineWidthPixels ); - QGraphicsRectItem *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() ); + auto *pageItem = new QGraphicsRectItem( 0, 0, pw.pt(), ph.pt() ); pageItem->setBrush( brush ); pageItem->setPen( pen ); pageItem->setGraphicsEffect( shadowEffect ); @@ -188,7 +188,7 @@ namespace glabels pen.setCosmetic( true ); pen.setWidthF( labelOutlineWidthPixels ); - QGraphicsPathItem *labelItem = new QGraphicsPathItem( path ); + auto *labelItem = new QGraphicsPathItem( path ); labelItem->setBrush( brush ); labelItem->setPen( pen ); labelItem->setPos( x.pt(), y.pt() ); @@ -227,7 +227,7 @@ namespace glabels path.lineTo( 0, -minWH.pt()*arrowScale ); path.lineTo( minWH.pt()*arrowScale/2, -minWH.pt()*arrowScale/2 ); - QGraphicsPathItem *arrowItem = new QGraphicsPathItem( path ); + auto *arrowItem = new QGraphicsPathItem( path ); arrowItem->setPen( pen ); arrowItem->setPos( (x0+w/2).pt(), (y0+h/2).pt() ); if ( mRotateFlag ) diff --git a/glabels/TemplatePicker.cpp b/glabels/TemplatePicker.cpp index 005bbc5..d7e2a9d 100644 --- a/glabels/TemplatePicker.cpp +++ b/glabels/TemplatePicker.cpp @@ -63,7 +63,7 @@ namespace glabels { foreach ( QListWidgetItem *item, findItems( "*", Qt::MatchWildcard ) ) { - TemplatePickerItem *tItem = dynamic_cast(item); + auto *tItem = dynamic_cast(item); bool nameMask = tItem->tmplate()->name().contains( searchString, Qt::CaseInsensitive ); @@ -107,7 +107,7 @@ namespace glabels { foreach ( QListWidgetItem *item, findItems( "*", Qt::MatchWildcard ) ) { - TemplatePickerItem *tItem = dynamic_cast(item); + auto *tItem = dynamic_cast(item); bool match = false; foreach ( QString name, names ) @@ -144,7 +144,7 @@ namespace glabels } else { - TemplatePickerItem *tItem = dynamic_cast(items.first()); + auto *tItem = dynamic_cast(items.first()); return tItem->tmplate(); } } diff --git a/glabels/UndoRedoModel.cpp b/glabels/UndoRedoModel.cpp index cf8ad4a..eddc910 100644 --- a/glabels/UndoRedoModel.cpp +++ b/glabels/UndoRedoModel.cpp @@ -66,7 +66,7 @@ namespace glabels mRedoStack.clear(); /* Save state onto undo stack. */ - State* stateNow = new State( mModel, description ); + auto* stateNow = new State( mModel, description ); mUndoStack.push( stateNow ); /* Track consecutive checkpoints. */ @@ -84,7 +84,7 @@ namespace glabels void UndoRedoModel::undo() { State* oldState = mUndoStack.pop(); - State* stateNow = new State( mModel, oldState->description ); + auto* stateNow = new State( mModel, oldState->description ); mRedoStack.push( stateNow ); @@ -103,7 +103,7 @@ namespace glabels void UndoRedoModel::redo() { State* oldState = mRedoStack.pop(); - State* stateNow = new State( mModel, oldState->description ); + auto* stateNow = new State( mModel, oldState->description ); mUndoStack.push( stateNow ); diff --git a/glabels/main.cpp b/glabels/main.cpp index 4bdca03..1acdf1c 100644 --- a/glabels/main.cpp +++ b/glabels/main.cpp @@ -104,7 +104,7 @@ int main( int argc, char **argv ) if ( model ) { model->setFileName( filename ); - glabels::MainWindow *newWindow = new glabels::MainWindow(); + auto *newWindow = new glabels::MainWindow(); newWindow->setModel( model ); newWindow->show(); openedFiles = true; @@ -117,7 +117,7 @@ int main( int argc, char **argv ) // if ( !openedFiles ) { - glabels::MainWindow *mainWindow = new glabels::MainWindow(); + auto *mainWindow = new glabels::MainWindow(); mainWindow->show(); } diff --git a/glbarcode/BarcodeCode39.cpp b/glbarcode/BarcodeCode39.cpp index 929af2f..0aef10e 100644 --- a/glbarcode/BarcodeCode39.cpp +++ b/glbarcode/BarcodeCode39.cpp @@ -190,7 +190,7 @@ namespace glbarcode { /* determine width and establish horizontal scale, based on original cooked data */ - double dataSize = double( cookedData.size() ); + auto dataSize = double( cookedData.size() ); double minL; if ( !checksum() ) { diff --git a/glbarcode/BarcodeUpcBase.cpp b/glbarcode/BarcodeUpcBase.cpp index e5da6a4..e2a9952 100644 --- a/glbarcode/BarcodeUpcBase.cpp +++ b/glbarcode/BarcodeUpcBase.cpp @@ -256,7 +256,7 @@ namespace glbarcode /* now traverse the code string and draw each bar */ - int nBarsSpaces = int( codedData.size() - 1 ); /* coded data has dummy "0" on end. */ + auto nBarsSpaces = int( codedData.size() - 1 ); /* coded data has dummy "0" on end. */ double xModules = 0; for ( int i = 0; i < nBarsSpaces; i += 2 ) diff --git a/glbarcode/Factory.cpp b/glbarcode/Factory.cpp index 27b9011..f29f0ab 100644 --- a/glbarcode/Factory.cpp +++ b/glbarcode/Factory.cpp @@ -86,7 +86,7 @@ namespace glbarcode { init(); - BarcodeTypeMap::iterator i = mBarcodeTypeMap.find( typeId ); + auto i = mBarcodeTypeMap.find( typeId ); return ( i != mBarcodeTypeMap.end() ); } @@ -104,7 +104,7 @@ namespace glbarcode { init(); - BarcodeTypeMap::iterator i = mBarcodeTypeMap.find( typeId ); + auto i = mBarcodeTypeMap.find( typeId ); if( i != mBarcodeTypeMap.end() ) { diff --git a/glbarcode/Renderer.cpp b/glbarcode/Renderer.cpp index 8fd10aa..6a5b6d9 100644 --- a/glbarcode/Renderer.cpp +++ b/glbarcode/Renderer.cpp @@ -31,23 +31,23 @@ void glbarcode::Renderer::render( double w, double h, const std::list(*primitive) ) + if ( auto* line = dynamic_cast(*primitive) ) { drawLine( line->x(), line->y(), line->w(), line->h() ); } - else if ( DrawingPrimitiveBox* box = dynamic_cast(*primitive) ) + else if ( auto* box = dynamic_cast(*primitive) ) { drawBox( box->x(), box->y(), box->w(), box->h() ); } - else if ( DrawingPrimitiveText* text = dynamic_cast(*primitive) ) + else if ( auto* text = dynamic_cast(*primitive) ) { drawText( text->x(), text->y(), text->size(), text->text() ); } - else if ( DrawingPrimitiveRing* ring = dynamic_cast(*primitive) ) + else if ( auto* ring = dynamic_cast(*primitive) ) { drawRing( ring->x(), ring->y(), ring->r(), ring->w() ); } - else if ( DrawingPrimitiveHexagon* hex = dynamic_cast(*primitive) ) + else if ( auto* hex = dynamic_cast(*primitive) ) { drawHexagon( hex->x(), hex->y(), hex->h() ); } diff --git a/model/DataCache.cpp b/model/DataCache.cpp index d98797f..b23cfa7 100644 --- a/model/DataCache.cpp +++ b/model/DataCache.cpp @@ -38,7 +38,7 @@ namespace glabels { foreach( ModelObject* object, objects ) { - if ( ModelImageObject* imageObject = dynamic_cast(object) ) + if ( auto* imageObject = dynamic_cast(object) ) { TextNode filenameNode = imageObject->filenameNode(); if ( !filenameNode.isField() ) diff --git a/model/Db.cpp b/model/Db.cpp index 8871074..5321c2a 100644 --- a/model/Db.cpp +++ b/model/Db.cpp @@ -87,7 +87,7 @@ namespace glabels Db* Db::instance() { - static Db* db = new Db(); + static auto* db = new Db(); return db; } diff --git a/model/FrameCd.cpp b/model/FrameCd.cpp index 3f1985f..ed4aad1 100644 --- a/model/FrameCd.cpp +++ b/model/FrameCd.cpp @@ -161,7 +161,7 @@ namespace glabels bool FrameCd::isSimilarTo( Frame* other ) const { - if ( FrameCd *otherCd = dynamic_cast(other) ) + if ( auto *otherCd = dynamic_cast(other) ) { if ( (fabs( mW - otherCd->mW ) <= EPSILON) && (fabs( mH - otherCd->mH ) <= EPSILON) && diff --git a/model/FrameEllipse.cpp b/model/FrameEllipse.cpp index 766afcb..5c27f72 100644 --- a/model/FrameEllipse.cpp +++ b/model/FrameEllipse.cpp @@ -95,7 +95,7 @@ namespace glabels bool FrameEllipse::isSimilarTo( Frame* other ) const { - if ( FrameEllipse* otherEllipse = dynamic_cast(other) ) + if ( auto* otherEllipse = dynamic_cast(other) ) { if ( (fabs( mW - otherEllipse->mW ) <= EPSILON) && (fabs( mH - otherEllipse->mH ) <= EPSILON) ) diff --git a/model/FrameRect.cpp b/model/FrameRect.cpp index 6a8e963..373e289 100644 --- a/model/FrameRect.cpp +++ b/model/FrameRect.cpp @@ -114,7 +114,7 @@ namespace glabels bool FrameRect::isSimilarTo( Frame* other ) const { - if ( FrameRect *otherRect = dynamic_cast(other) ) + if ( auto *otherRect = dynamic_cast(other) ) { if ( (fabs( mW - otherRect->mW ) <= EPSILON) && (fabs( mH - otherRect->mH ) <= EPSILON) ) diff --git a/model/FrameRound.cpp b/model/FrameRound.cpp index fe67822..fe39ecb 100644 --- a/model/FrameRound.cpp +++ b/model/FrameRound.cpp @@ -100,7 +100,7 @@ namespace glabels bool FrameRound::isSimilarTo( Frame* other ) const { - if ( FrameRound *otherRound = dynamic_cast(other) ) + if ( auto *otherRound = dynamic_cast(other) ) { if ( fabs( mR - otherRound->mR ) <= EPSILON ) { diff --git a/model/Layout.cpp b/model/Layout.cpp index af9d4df..dc5069c 100644 --- a/model/Layout.cpp +++ b/model/Layout.cpp @@ -99,7 +99,7 @@ namespace glabels Layout* Layout::dup() const { - Layout *other = new Layout( *this ); + auto *other = new Layout( *this ); return other; } diff --git a/model/Model.cpp b/model/Model.cpp index 5ed7b36..43f305c 100644 --- a/model/Model.cpp +++ b/model/Model.cpp @@ -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(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 ); diff --git a/model/ModelImageObject.cpp b/model/ModelImageObject.cpp index 221e4f5..5848625 100644 --- a/model/ModelImageObject.cpp +++ b/model/ModelImageObject.cpp @@ -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++ ) { diff --git a/model/StrUtil.cpp b/model/StrUtil.cpp index a8c1f41..4c318f7 100644 --- a/model/StrUtil.cpp +++ b/model/StrUtil.cpp @@ -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) + diff --git a/model/XmlCategoryParser.cpp b/model/XmlCategoryParser.cpp index 218ae47..a490a28 100644 --- a/model/XmlCategoryParser.cpp +++ b/model/XmlCategoryParser.cpp @@ -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 ); diff --git a/model/XmlLabelCreator.cpp b/model/XmlLabelCreator.cpp index 91f87c4..f7e2a74 100644 --- a/model/XmlLabelCreator.cpp +++ b/model/XmlLabelCreator.cpp @@ -132,27 +132,27 @@ namespace glabels foreach ( ModelObject* object, objects ) { - if ( ModelBoxObject* boxObject = dynamic_cast(object) ) + if ( auto* boxObject = dynamic_cast(object) ) { createObjectBoxNode( node, boxObject ); } - else if ( ModelEllipseObject* ellipseObject = dynamic_cast(object) ) + else if ( auto* ellipseObject = dynamic_cast(object) ) { createObjectEllipseNode( node, ellipseObject ); } - else if ( ModelLineObject* lineObject = dynamic_cast(object) ) + else if ( auto* lineObject = dynamic_cast(object) ) { createObjectLineNode( node, lineObject ); } - else if ( ModelImageObject* imageObject = dynamic_cast(object) ) + else if ( auto* imageObject = dynamic_cast(object) ) { createObjectImageNode( node, imageObject ); } - else if ( ModelBarcodeObject* barcodeObject = dynamic_cast(object) ) + else if ( auto* barcodeObject = dynamic_cast(object) ) { createObjectBarcodeNode( node, barcodeObject ); } - else if ( ModelTextObject* textObject = dynamic_cast(object) ) + else if ( auto* textObject = dynamic_cast(object) ) { createObjectTextNode( node, textObject ); } diff --git a/model/XmlLabelParser.cpp b/model/XmlLabelParser.cpp index 2717c22..bb34ac4 100644 --- a/model/XmlLabelParser.cpp +++ b/model/XmlLabelParser.cpp @@ -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; diff --git a/model/XmlPaperParser.cpp b/model/XmlPaperParser.cpp index b01e848..b3e1bc6 100644 --- a/model/XmlPaperParser.cpp +++ b/model/XmlPaperParser.cpp @@ -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 ); diff --git a/model/XmlTemplateCreator.cpp b/model/XmlTemplateCreator.cpp index 2661bbf..e4ef1b7 100644 --- a/model/XmlTemplateCreator.cpp +++ b/model/XmlTemplateCreator.cpp @@ -125,19 +125,19 @@ namespace glabels void XmlTemplateCreator::createLabelNode( QDomElement &parent, const Frame* frame ) { - if ( const FrameRect* frameRect = dynamic_cast(frame) ) + if ( const auto* frameRect = dynamic_cast(frame) ) { createLabelRectangleNode( parent, frameRect ); } - else if ( const FrameEllipse* frameEllipse = dynamic_cast(frame) ) + else if ( const auto* frameEllipse = dynamic_cast(frame) ) { createLabelEllipseNode( parent, frameEllipse ); } - else if ( const FrameRound* frameRound = dynamic_cast(frame) ) + else if ( const auto* frameRound = dynamic_cast(frame) ) { createLabelRoundNode( parent, frameRound ); } - else if ( const FrameCd* frameCd = dynamic_cast(frame) ) + else if ( const auto* frameCd = dynamic_cast(frame) ) { createLabelCdNode( parent, frameCd ); } @@ -221,23 +221,23 @@ namespace glabels { foreach ( Markup* markup, frame->markups() ) { - if ( MarkupMargin* markupMargin = dynamic_cast(markup) ) + if ( auto* markupMargin = dynamic_cast(markup) ) { createMarkupMarginNode( node, markupMargin ); } - else if ( MarkupLine* markupLine = dynamic_cast(markup) ) + else if ( auto* markupLine = dynamic_cast(markup) ) { createMarkupLineNode( node, markupLine ); } - else if ( MarkupCircle* markupCircle = dynamic_cast(markup) ) + else if ( auto* markupCircle = dynamic_cast(markup) ) { createMarkupCircleNode( node, markupCircle ); } - else if ( MarkupRect* markupRect = dynamic_cast(markup) ) + else if ( auto* markupRect = dynamic_cast(markup) ) { createMarkupRectNode( node, markupRect ); } - else if ( MarkupEllipse* markupEllipse = dynamic_cast(markup) ) + else if ( auto* markupEllipse = dynamic_cast(markup) ) { createMarkupEllipseNode( node, markupEllipse ); } diff --git a/model/XmlVendorParser.cpp b/model/XmlVendorParser.cpp index b8745f6..1caf7d9 100644 --- a/model/XmlVendorParser.cpp +++ b/model/XmlVendorParser.cpp @@ -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 );