From c6c52a8895dd2e4940af7ec08b19904b9dac95b7 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 25 Nov 2017 16:54:37 -0500 Subject: [PATCH] Minor code cleanup. --- CMakeLists.txt | 11 ++++++++++- backends/merge/Merge.h | 2 +- backends/merge/Record.h | 2 +- glabels/UndoRedoModel.h | 2 +- glbarcode/Barcode2dBase.cpp | 1 + glbarcode/BarcodeCode39.cpp | 6 +++--- glbarcode/BarcodeDataMatrix.cpp | 2 +- glbarcode/BarcodeUpcBase.cpp | 4 ++-- model/ColorNode.h | 2 +- model/Region.h | 2 +- model/SubstitutionField.cpp | 6 ++---- 11 files changed, 24 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5641de5..274aa7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,16 @@ find_package (LibZint 2.6 QUIET) find_package (Qt5Test 5.4 QUIET) +#======================================= +# Global compiler options +#======================================= +# +# Uncomment to compile everything with aggressively pedantic options +# (not recommended -- only for testing -- also not portable) +# +#add_compile_options("-Wall" "-Werror" "-Wpedantic") + + #======================================= # Unit Testing #======================================= @@ -67,7 +77,6 @@ if (Qt5Test_FOUND) enable_testing () endif () - #======================================= # Subdirectories #======================================= diff --git a/backends/merge/Merge.h b/backends/merge/Merge.h index 7745a01..f38ba30 100644 --- a/backends/merge/Merge.h +++ b/backends/merge/Merge.h @@ -40,7 +40,7 @@ namespace glabels /// /// Merge Object /// - struct Merge : QObject + class Merge : public QObject { Q_OBJECT diff --git a/backends/merge/Record.h b/backends/merge/Record.h index 425f179..0add7c1 100644 --- a/backends/merge/Record.h +++ b/backends/merge/Record.h @@ -34,7 +34,7 @@ namespace glabels /// /// Merge Record /// - struct Record : public QMap + class Record : public QMap { ///////////////////////////////// diff --git a/glabels/UndoRedoModel.h b/glabels/UndoRedoModel.h index 0a11de7..8d11dab 100644 --- a/glabels/UndoRedoModel.h +++ b/glabels/UndoRedoModel.h @@ -35,7 +35,7 @@ namespace glabels /// /// UndoRedoModel /// - struct UndoRedoModel : QObject + class UndoRedoModel : public QObject { Q_OBJECT diff --git a/glbarcode/Barcode2dBase.cpp b/glbarcode/Barcode2dBase.cpp index 5f1a56f..90f8d3e 100644 --- a/glbarcode/Barcode2dBase.cpp +++ b/glbarcode/Barcode2dBase.cpp @@ -24,6 +24,7 @@ #include "DrawingPrimitives.h" #include +#include using namespace glbarcode::Constants; diff --git a/glbarcode/BarcodeCode39.cpp b/glbarcode/BarcodeCode39.cpp index 39ab554..929af2f 100644 --- a/glbarcode/BarcodeCode39.cpp +++ b/glbarcode/BarcodeCode39.cpp @@ -142,12 +142,12 @@ namespace glbarcode int sum = 0; for ( unsigned int i=0; i < cookedData.size(); i++ ) { - int cValue = alphabet.find( toupper( cookedData[i] ) ); + size_t cValue = alphabet.find( toupper( cookedData[i] ) ); code += symbols[cValue]; code += "i"; - sum += cValue; + sum += int(cValue); } if ( checksum() ) @@ -190,7 +190,7 @@ namespace glbarcode { /* determine width and establish horizontal scale, based on original cooked data */ - double dataSize = cookedData.size(); + double dataSize = double( cookedData.size() ); double minL; if ( !checksum() ) { diff --git a/glbarcode/BarcodeDataMatrix.cpp b/glbarcode/BarcodeDataMatrix.cpp index 78e4952..49dc5ee 100644 --- a/glbarcode/BarcodeDataMatrix.cpp +++ b/glbarcode/BarcodeDataMatrix.cpp @@ -294,7 +294,7 @@ namespace } } - return codewords.size(); + return int( codewords.size() ); } diff --git a/glbarcode/BarcodeUpcBase.cpp b/glbarcode/BarcodeUpcBase.cpp index 440ddf8..1b0adfe 100644 --- a/glbarcode/BarcodeUpcBase.cpp +++ b/glbarcode/BarcodeUpcBase.cpp @@ -216,7 +216,7 @@ namespace glbarcode double& h ) { /* determine width and establish horizontal scale */ - int nModules = 7*(cookedData.size()+1) + 11; + int nModules = 7*int(cookedData.size()+1) + 11; double scale; if ( w == 0 ) @@ -256,7 +256,7 @@ namespace glbarcode /* now traverse the code string and draw each bar */ - int nBarsSpaces = codedData.size() - 1; /* coded data has dummy "0" on end. */ + int 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/model/ColorNode.h b/model/ColorNode.h index 07c556b..89b0201 100644 --- a/model/ColorNode.h +++ b/model/ColorNode.h @@ -38,7 +38,7 @@ namespace glabels /// /// Color Node Type /// - struct ColorNode + class ColorNode { ///////////////////////////////// diff --git a/model/Region.h b/model/Region.h index 0622f37..8d0da42 100644 --- a/model/Region.h +++ b/model/Region.h @@ -35,7 +35,7 @@ namespace glabels /// /// Label Region Type /// - struct Region + class Region { ///////////////////////////////// diff --git a/model/SubstitutionField.cpp b/model/SubstitutionField.cpp index 4dab782..178b73e 100644 --- a/model/SubstitutionField.cpp +++ b/model/SubstitutionField.cpp @@ -29,13 +29,13 @@ namespace glabels { SubstitutionField::SubstitutionField() - : mNewLine(false), mFormatType(0) + : mFormatType(0), mNewLine(false) { } SubstitutionField::SubstitutionField( const QString& string ) - : mNewLine(false), mFormatType(0) + : mFormatType(0), mNewLine(false) { QStringRef s(&string); parse( s, *this ); @@ -197,8 +197,6 @@ namespace glabels bool SubstitutionField::parseFormatModifier( QStringRef& s, SubstitutionField& field ) { - bool success = false; - field.mFormat = "%"; parseFormatFlags( s, field );