Replaced all Qt foreach loops with modern C++ range-based loops. (#277)

This commit is contained in:
Jaye Evins
2026-01-05 15:24:00 -05:00
committed by GitHub
parent 45a92eda89
commit 3cd173a37f
17 changed files with 79 additions and 82 deletions
+3 -3
View File
@@ -35,7 +35,7 @@ namespace glabels
///
BarcodeMenu::BarcodeMenu()
{
foreach ( const barcode::Style& bcStyle, barcode::Backends::styleList() )
for ( const barcode::Style& bcStyle : barcode::Backends::styleList() )
{
if ( bcStyle.backendId() == "" )
{
@@ -47,11 +47,11 @@ namespace glabels
}
}
foreach ( const QString& backendId, barcode::Backends::backendList() )
for ( const QString& backendId : barcode::Backends::backendList() )
{
QMenu* subMenu = addMenu( barcode::Backends::backendName( backendId ) );
foreach ( const barcode::Style& bcStyle, barcode::Backends::styleList() )
for ( const barcode::Style& bcStyle : barcode::Backends::styleList() )
{
if ( bcStyle.backendId() == backendId )
{
+1 -1
View File
@@ -288,7 +288,7 @@ namespace glabels
QList<QColor> colorList = mColorHistory->getColors();
int id = 0;
foreach ( QColor color, colorList )
for ( QColor color : colorList )
{
mHistoryItem[id]->setColor( id, color, nameList[id] );
mHistoryItem[id]->setEnabled( true );
+1 -1
View File
@@ -289,7 +289,7 @@ namespace glabels
///
void File::exit()
{
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
for ( QWidget* qwidget : QApplication::topLevelWidgets() )
{
if ( auto* window = qobject_cast<MainWindow*>(qwidget) )
{
+1 -1
View File
@@ -1283,7 +1283,7 @@ namespace glabels
{
painter->save();
foreach ( model::ModelObject* object, mModel->objectList() )
for ( model::ModelObject* object : mModel->objectList() )
{
if ( object->isSelected() )
{
+1 -1
View File
@@ -138,7 +138,7 @@ namespace glabels
similarProductsNullBox->hide();
QString similarListString;
foreach ( QString name, list )
for ( QString name : list )
{
similarListString += name + "\n";
}
+1 -1
View File
@@ -298,7 +298,7 @@ namespace glabels
{
mCategoryIdList.clear();
foreach( QCheckBox* check, mCheckList )
for ( QCheckBox* check : mCheckList )
{
if ( check->isChecked() )
{
+2 -2
View File
@@ -211,7 +211,7 @@ namespace glabels
else
{
categoryMask = false;
foreach ( QString id, categoryIds )
for ( QString id : categoryIds )
{
categoryMask = categoryMask || tItem->tmplate().hasCategory( id );
}
@@ -248,7 +248,7 @@ namespace glabels
if ( auto* tItem = dynamic_cast<TemplatePickerItem *>( mModel->item( i, 0 ) ) )
{
bool match = false;
foreach ( QString name, names )
for ( QString name : names )
{
if ( tItem->tmplate().name() == name )
{
+1 -1
View File
@@ -112,7 +112,7 @@ int main( int argc, char **argv )
// Open each file in its own main window
//
bool openedFiles = false;
foreach ( QString filename, parser.positionalArguments() )
for ( QString filename : parser.positionalArguments() )
{
glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
if ( model )