Replaced all Qt foreach loops with modern C++ range-based loops. (#277)
This commit is contained in:
@@ -556,7 +556,7 @@ namespace glabels
|
|||||||
|
|
||||||
const Style& Backends::style( const QString& backendId, const QString& StyleId )
|
const Style& Backends::style( const QString& backendId, const QString& StyleId )
|
||||||
{
|
{
|
||||||
foreach ( const Style& bcStyle, mStyleList )
|
for ( const Style& bcStyle : mStyleList )
|
||||||
{
|
{
|
||||||
if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) )
|
if ( (bcStyle.backendId() == backendId) && (bcStyle.id() == StyleId) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
BarcodeMenu::BarcodeMenu()
|
BarcodeMenu::BarcodeMenu()
|
||||||
{
|
{
|
||||||
foreach ( const barcode::Style& bcStyle, barcode::Backends::styleList() )
|
for ( const barcode::Style& bcStyle : barcode::Backends::styleList() )
|
||||||
{
|
{
|
||||||
if ( bcStyle.backendId() == "" )
|
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 ) );
|
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 )
|
if ( bcStyle.backendId() == backendId )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ namespace glabels
|
|||||||
QList<QColor> colorList = mColorHistory->getColors();
|
QList<QColor> colorList = mColorHistory->getColors();
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
foreach ( QColor color, colorList )
|
for ( QColor color : colorList )
|
||||||
{
|
{
|
||||||
mHistoryItem[id]->setColor( id, color, nameList[id] );
|
mHistoryItem[id]->setColor( id, color, nameList[id] );
|
||||||
mHistoryItem[id]->setEnabled( true );
|
mHistoryItem[id]->setEnabled( true );
|
||||||
|
|||||||
+1
-1
@@ -289,7 +289,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void File::exit()
|
void File::exit()
|
||||||
{
|
{
|
||||||
foreach ( QWidget* qwidget, QApplication::topLevelWidgets() )
|
for ( QWidget* qwidget : QApplication::topLevelWidgets() )
|
||||||
{
|
{
|
||||||
if ( auto* window = qobject_cast<MainWindow*>(qwidget) )
|
if ( auto* window = qobject_cast<MainWindow*>(qwidget) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1283,7 +1283,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
foreach ( model::ModelObject* object, mModel->objectList() )
|
for ( model::ModelObject* object : mModel->objectList() )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace glabels
|
|||||||
similarProductsNullBox->hide();
|
similarProductsNullBox->hide();
|
||||||
|
|
||||||
QString similarListString;
|
QString similarListString;
|
||||||
foreach ( QString name, list )
|
for ( QString name : list )
|
||||||
{
|
{
|
||||||
similarListString += name + "\n";
|
similarListString += name + "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
mCategoryIdList.clear();
|
mCategoryIdList.clear();
|
||||||
|
|
||||||
foreach( QCheckBox* check, mCheckList )
|
for ( QCheckBox* check : mCheckList )
|
||||||
{
|
{
|
||||||
if ( check->isChecked() )
|
if ( check->isChecked() )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ namespace glabels
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
categoryMask = false;
|
categoryMask = false;
|
||||||
foreach ( QString id, categoryIds )
|
for ( QString id : categoryIds )
|
||||||
{
|
{
|
||||||
categoryMask = categoryMask || tItem->tmplate().hasCategory( id );
|
categoryMask = categoryMask || tItem->tmplate().hasCategory( id );
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ namespace glabels
|
|||||||
if ( auto* tItem = dynamic_cast<TemplatePickerItem *>( mModel->item( i, 0 ) ) )
|
if ( auto* tItem = dynamic_cast<TemplatePickerItem *>( mModel->item( i, 0 ) ) )
|
||||||
{
|
{
|
||||||
bool match = false;
|
bool match = false;
|
||||||
foreach ( QString name, names )
|
for ( QString name : names )
|
||||||
{
|
{
|
||||||
if ( tItem->tmplate().name() == name )
|
if ( tItem->tmplate().name() == name )
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -112,7 +112,7 @@ int main( int argc, char **argv )
|
|||||||
// Open each file in its own main window
|
// Open each file in its own main window
|
||||||
//
|
//
|
||||||
bool openedFiles = false;
|
bool openedFiles = false;
|
||||||
foreach ( QString filename, parser.positionalArguments() )
|
for ( QString filename : parser.positionalArguments() )
|
||||||
{
|
{
|
||||||
glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
|
glabels::model::Model *model = glabels::model::XmlLabelParser::readFile( filename );
|
||||||
if ( model )
|
if ( model )
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ namespace glabels
|
|||||||
|
|
||||||
DataCache::DataCache( const QList<ModelObject*>& objects )
|
DataCache::DataCache( const QList<ModelObject*>& objects )
|
||||||
{
|
{
|
||||||
foreach( ModelObject* object, objects )
|
for ( ModelObject* object : objects )
|
||||||
{
|
{
|
||||||
if ( auto* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
if ( auto* imageObject = dynamic_cast<ModelImageObject*>(object) )
|
||||||
{
|
{
|
||||||
|
|||||||
+53
-56
@@ -95,10 +95,7 @@ namespace glabels
|
|||||||
void Model::restore( const Model *savedModel )
|
void Model::restore( const Model *savedModel )
|
||||||
{
|
{
|
||||||
// Clear current object list
|
// Clear current object list
|
||||||
foreach ( ModelObject* object, mObjectList )
|
qDeleteAll( mObjectList );
|
||||||
{
|
|
||||||
delete object;
|
|
||||||
}
|
|
||||||
mObjectList.clear();
|
mObjectList.clear();
|
||||||
|
|
||||||
// Now copy state
|
// Now copy state
|
||||||
@@ -108,7 +105,7 @@ namespace glabels
|
|||||||
mTmplate = savedModel->mTmplate;
|
mTmplate = savedModel->mTmplate;
|
||||||
mRotate = savedModel->mRotate;
|
mRotate = savedModel->mRotate;
|
||||||
|
|
||||||
foreach ( ModelObject* savedObject, savedModel->mObjectList )
|
for ( ModelObject* savedObject : savedModel->mObjectList )
|
||||||
{
|
{
|
||||||
ModelObject* object = savedObject->clone();
|
ModelObject* object = savedObject->clone();
|
||||||
|
|
||||||
@@ -474,7 +471,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
static Handle nullHandle;
|
static Handle nullHandle;
|
||||||
|
|
||||||
foreach( ModelObject* object, mObjectList )
|
for( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
auto& handle = object->handleAt( scale, x, y );
|
auto& handle = object->handleAt( scale, x, y );
|
||||||
if ( !handle.isNull() )
|
if ( !handle.isNull() )
|
||||||
@@ -566,7 +563,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::selectAll()
|
void Model::selectAll()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
object->select();
|
object->select();
|
||||||
}
|
}
|
||||||
@@ -580,7 +577,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::unselectAll()
|
void Model::unselectAll()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
object->unselect();
|
object->unselect();
|
||||||
}
|
}
|
||||||
@@ -599,7 +596,7 @@ namespace glabels
|
|||||||
Distance rX2 = max( region.x1(), region.x2() );
|
Distance rX2 = max( region.x1(), region.x2() );
|
||||||
Distance rY2 = max( region.y1(), region.y2() );
|
Distance rY2 = max( region.y1(), region.y2() );
|
||||||
|
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
Region objectExtent = object->getExtent();
|
Region objectExtent = object->getExtent();
|
||||||
|
|
||||||
@@ -621,7 +618,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
bool Model::isSelectionEmpty()
|
bool Model::isSelectionEmpty()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -640,7 +637,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
int nSelected = 0;
|
int nSelected = 0;
|
||||||
|
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -663,7 +660,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
QList<ModelObject*> selectedList;
|
QList<ModelObject*> selectedList;
|
||||||
|
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -680,7 +677,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
ModelObject* Model::getFirstSelectedObject()
|
ModelObject* Model::getFirstSelectedObject()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -697,7 +694,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
bool Model::canSelectionText()
|
bool Model::canSelectionText()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() && object->canText() )
|
if ( object->isSelected() && object->canText() )
|
||||||
{
|
{
|
||||||
@@ -714,7 +711,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
bool Model::canSelectionFill()
|
bool Model::canSelectionFill()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() && object->canFill() )
|
if ( object->isSelected() && object->canFill() )
|
||||||
{
|
{
|
||||||
@@ -731,7 +728,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
bool Model::canSelectionLineColor()
|
bool Model::canSelectionLineColor()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() && object->canLineColor() )
|
if ( object->isSelected() && object->canLineColor() )
|
||||||
{
|
{
|
||||||
@@ -748,7 +745,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
bool Model::canSelectionLineWidth()
|
bool Model::canSelectionLineWidth()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() && object->canLineWidth() )
|
if ( object->isSelected() && object->canLineWidth() )
|
||||||
{
|
{
|
||||||
@@ -767,7 +764,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
QList<ModelObject*> selectedList = getSelection();
|
QList<ModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
deleteObject( object );
|
deleteObject( object );
|
||||||
}
|
}
|
||||||
@@ -786,13 +783,13 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
QList<ModelObject*> selectedList = getSelection();
|
QList<ModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
mObjectList.removeOne( object );
|
mObjectList.removeOne( object );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to end of list, representing top most object.
|
// Move to end of list, representing top most object.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
mObjectList.push_back( object );
|
mObjectList.push_back( object );
|
||||||
}
|
}
|
||||||
@@ -810,13 +807,13 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
QList<ModelObject*> selectedList = getSelection();
|
QList<ModelObject*> selectedList = getSelection();
|
||||||
|
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
mObjectList.removeOne( object );
|
mObjectList.removeOne( object );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to front of list, representing bottom most object.
|
// Move to front of list, representing bottom most object.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
mObjectList.push_front( object );
|
mObjectList.push_front( object );
|
||||||
}
|
}
|
||||||
@@ -832,7 +829,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::rotateSelection( double thetaDegs )
|
void Model::rotateSelection( double thetaDegs )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -869,7 +866,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::flipSelectionHoriz()
|
void Model::flipSelectionHoriz()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -888,7 +885,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::flipSelectionVert()
|
void Model::flipSelectionVert()
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -916,14 +913,14 @@ namespace glabels
|
|||||||
|
|
||||||
// Find left-most edge.
|
// Find left-most edge.
|
||||||
Distance x1_min = 7200; // Start with a very large value: 7200pts = 100in
|
Distance x1_min = 7200; // Start with a very large value: 7200pts = 100in
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
if ( r.x1() < x1_min ) x1_min = r.x1();
|
if ( r.x1() < x1_min ) x1_min = r.x1();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now adjust the object positions to line up the left edges at left-most edge.
|
// Now adjust the object positions to line up the left edges at left-most edge.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dx = x1_min - r.x1();
|
Distance dx = x1_min - r.x1();
|
||||||
@@ -950,14 +947,14 @@ namespace glabels
|
|||||||
|
|
||||||
// Find right-most edge.
|
// Find right-most edge.
|
||||||
Distance x1_max = -7200; // Start with a very large negative value: 7200pts = 100in
|
Distance x1_max = -7200; // Start with a very large negative value: 7200pts = 100in
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
if ( r.x1() > x1_max ) x1_max = r.x1();
|
if ( r.x1() > x1_max ) x1_max = r.x1();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now adjust the object positions to line up the right edges at right-most edge.
|
// Now adjust the object positions to line up the right edges at right-most edge.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dx = x1_max - r.x1();
|
Distance dx = x1_max - r.x1();
|
||||||
@@ -985,7 +982,7 @@ namespace glabels
|
|||||||
// Find average center of objects.
|
// Find average center of objects.
|
||||||
Distance xsum = 0;
|
Distance xsum = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
xsum += (r.x1() + r.x2()) / 2.0;
|
xsum += (r.x1() + r.x2()) / 2.0;
|
||||||
@@ -996,7 +993,7 @@ namespace glabels
|
|||||||
// Find object closest to average center of objects.
|
// Find object closest to average center of objects.
|
||||||
Distance xcenter = 7200; // Start with very large value.
|
Distance xcenter = 7200; // Start with very large value.
|
||||||
Distance dxmin = fabs( xavg - xcenter );
|
Distance dxmin = fabs( xavg - xcenter );
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dx = fabs( xavg - (r.x1() + r.x2())/2.0 );
|
Distance dx = fabs( xavg - (r.x1() + r.x2())/2.0 );
|
||||||
@@ -1008,7 +1005,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now adjust the object positions to line up with the center of this object.
|
// Now adjust the object positions to line up with the center of this object.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dx = xcenter - (r.x1() + r.x2())/2.0;
|
Distance dx = xcenter - (r.x1() + r.x2())/2.0;
|
||||||
@@ -1035,14 +1032,14 @@ namespace glabels
|
|||||||
|
|
||||||
// Find top-most edge.
|
// Find top-most edge.
|
||||||
Distance y1_min = 7200; // Start with a very large value: 7200pts = 100in
|
Distance y1_min = 7200; // Start with a very large value: 7200pts = 100in
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
if ( r.y1() < y1_min ) y1_min = r.y1();
|
if ( r.y1() < y1_min ) y1_min = r.y1();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now adjust the object positions to line up the top edges at top-most edge.
|
// Now adjust the object positions to line up the top edges at top-most edge.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dy = y1_min - r.y1();
|
Distance dy = y1_min - r.y1();
|
||||||
@@ -1069,14 +1066,14 @@ namespace glabels
|
|||||||
|
|
||||||
// Find bottom-most edge.
|
// Find bottom-most edge.
|
||||||
Distance y1_max = -7200; // Start with a very large negative value: 7200pts = 100in
|
Distance y1_max = -7200; // Start with a very large negative value: 7200pts = 100in
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
if ( r.y1() > y1_max ) y1_max = r.y1();
|
if ( r.y1() > y1_max ) y1_max = r.y1();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now adjust the object positions to line up the bottom edges at bottom-most edge.
|
// Now adjust the object positions to line up the bottom edges at bottom-most edge.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dy = y1_max - r.y1();
|
Distance dy = y1_max - r.y1();
|
||||||
@@ -1104,7 +1101,7 @@ namespace glabels
|
|||||||
// Find average center of objects.
|
// Find average center of objects.
|
||||||
Distance ysum = 0;
|
Distance ysum = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
ysum += (r.y1() + r.y2()) / 2.0;
|
ysum += (r.y1() + r.y2()) / 2.0;
|
||||||
@@ -1115,7 +1112,7 @@ namespace glabels
|
|||||||
// Find object closest to average center of objects.
|
// Find object closest to average center of objects.
|
||||||
Distance ycenter = 7200; // Start with very large value.
|
Distance ycenter = 7200; // Start with very large value.
|
||||||
Distance dymin = fabs( yavg - ycenter );
|
Distance dymin = fabs( yavg - ycenter );
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dy = fabs( yavg - (r.y1() + r.y2())/2.0 );
|
Distance dy = fabs( yavg - (r.y1() + r.y2())/2.0 );
|
||||||
@@ -1127,7 +1124,7 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now adjust the object positions to line up with the center of this object.
|
// Now adjust the object positions to line up with the center of this object.
|
||||||
foreach ( ModelObject* object, selectedList )
|
for ( ModelObject* object : selectedList )
|
||||||
{
|
{
|
||||||
Region r = object->getExtent();
|
Region r = object->getExtent();
|
||||||
Distance dy = ycenter - (r.y1() + r.y2())/2.0;
|
Distance dy = ycenter - (r.y1() + r.y2())/2.0;
|
||||||
@@ -1147,7 +1144,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
Distance xLabelCenter = w() / 2.0;
|
Distance xLabelCenter = w() / 2.0;
|
||||||
|
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1172,7 +1169,7 @@ namespace glabels
|
|||||||
Distance xLabelCenter = w() / 2.0;
|
Distance xLabelCenter = w() / 2.0;
|
||||||
Distance yLabelCenter = h() / 2.0;
|
Distance yLabelCenter = h() / 2.0;
|
||||||
|
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1198,7 +1195,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
Distance yLabelCenter = h() / 2.0;
|
Distance yLabelCenter = h() / 2.0;
|
||||||
|
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1220,7 +1217,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::moveSelection( Distance dx, Distance dy )
|
void Model::moveSelection( Distance dx, Distance dy )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1239,7 +1236,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionFontFamily( const QString &fontFamily )
|
void Model::setSelectionFontFamily( const QString &fontFamily )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1258,7 +1255,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionFontSize( double fontSize )
|
void Model::setSelectionFontSize( double fontSize )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1277,7 +1274,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionFontWeight( QFont::Weight fontWeight )
|
void Model::setSelectionFontWeight( QFont::Weight fontWeight )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1296,7 +1293,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionFontItalicFlag( bool fontItalicFlag )
|
void Model::setSelectionFontItalicFlag( bool fontItalicFlag )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1315,7 +1312,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionTextHAlign( Qt::Alignment textHAlign )
|
void Model::setSelectionTextHAlign( Qt::Alignment textHAlign )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1334,7 +1331,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionTextVAlign( Qt::Alignment textVAlign )
|
void Model::setSelectionTextVAlign( Qt::Alignment textVAlign )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1353,7 +1350,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionTextLineSpacing( double textLineSpacing )
|
void Model::setSelectionTextLineSpacing( double textLineSpacing )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1372,7 +1369,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionTextColorNode( ColorNode textColorNode )
|
void Model::setSelectionTextColorNode( ColorNode textColorNode )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1391,7 +1388,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionLineWidth( Distance lineWidth )
|
void Model::setSelectionLineWidth( Distance lineWidth )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1410,7 +1407,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionLineColorNode( ColorNode lineColorNode )
|
void Model::setSelectionLineColorNode( ColorNode lineColorNode )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1429,7 +1426,7 @@ namespace glabels
|
|||||||
///
|
///
|
||||||
void Model::setSelectionFillColorNode( ColorNode fillColorNode )
|
void Model::setSelectionFillColorNode( ColorNode fillColorNode )
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
if ( object->isSelected() )
|
if ( object->isSelected() )
|
||||||
{
|
{
|
||||||
@@ -1523,7 +1520,7 @@ namespace glabels
|
|||||||
QList <ModelObject*> objects = XmlLabelParser::deserializeObjects( buffer, this );
|
QList <ModelObject*> objects = XmlLabelParser::deserializeObjects( buffer, this );
|
||||||
|
|
||||||
unselectAll();
|
unselectAll();
|
||||||
foreach ( ModelObject* object, objects )
|
for ( ModelObject* object : objects )
|
||||||
{
|
{
|
||||||
object->setPositionRelative( p.x(), p.y() );
|
object->setPositionRelative( p.x(), p.y() );
|
||||||
addObject( object );
|
addObject( object );
|
||||||
@@ -1613,7 +1610,7 @@ namespace glabels
|
|||||||
const merge::Record& record,
|
const merge::Record& record,
|
||||||
const Variables& variablesInstance ) const
|
const Variables& variablesInstance ) const
|
||||||
{
|
{
|
||||||
foreach ( ModelObject* object, mObjectList )
|
for ( ModelObject* object : mObjectList )
|
||||||
{
|
{
|
||||||
object->draw( painter, inEditor, record, variablesInstance );
|
object->draw( painter, inEditor, record, variablesInstance );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -672,7 +672,7 @@ namespace glabels
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
QPainterPath hoverPath; // new empty hover path
|
QPainterPath hoverPath; // new empty hover path
|
||||||
foreach ( QTextLayout* layout, mEditorLayouts )
|
for ( QTextLayout* layout : mEditorLayouts )
|
||||||
{
|
{
|
||||||
for ( int j = 0; j < layout->lineCount(); j++ )
|
for ( int j = 0; j < layout->lineCount(); j++ )
|
||||||
{
|
{
|
||||||
@@ -708,7 +708,7 @@ namespace glabels
|
|||||||
painter->setPen( QPen( color ) );
|
painter->setPen( QPen( color ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( QTextLayout* layout, mEditorLayouts )
|
for ( QTextLayout* layout : mEditorLayouts )
|
||||||
{
|
{
|
||||||
layout->draw( painter, QPointF( 0, 0 ) );
|
layout->draw( painter, QPointF( 0, 0 ) );
|
||||||
}
|
}
|
||||||
@@ -790,7 +790,7 @@ namespace glabels
|
|||||||
y = marginPts;
|
y = marginPts;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
foreach ( QTextLayout* layout, layouts )
|
for ( QTextLayout* layout : layouts )
|
||||||
{
|
{
|
||||||
for ( int j = 0; j < layout->lineCount(); j++ )
|
for ( int j = 0; j < layout->lineCount(); j++ )
|
||||||
{
|
{
|
||||||
@@ -802,7 +802,7 @@ namespace glabels
|
|||||||
|
|
||||||
// Draw layouts
|
// Draw layouts
|
||||||
painter->setPen( QPen( color ) );
|
painter->setPen( QPen( color ) );
|
||||||
foreach ( QTextLayout* layout, layouts )
|
for ( QTextLayout* layout : layouts )
|
||||||
{
|
{
|
||||||
layout->draw( painter, QPointF( 0, 0 ) );
|
layout->draw( painter, QPointF( 0, 0 ) );
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -75,7 +75,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
foreach ( const Token& token, mTokens )
|
for ( const Token& token : mTokens )
|
||||||
{
|
{
|
||||||
if ( token.isField )
|
if ( token.isField )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ namespace glabels
|
|||||||
XmlUtil::setStringAttr( node, "id", "0" );
|
XmlUtil::setStringAttr( node, "id", "0" );
|
||||||
XmlUtil::setBoolAttr( node, "rotate", rotate );
|
XmlUtil::setBoolAttr( node, "rotate", rotate );
|
||||||
|
|
||||||
foreach ( ModelObject* object, objects )
|
for ( ModelObject* object : objects )
|
||||||
{
|
{
|
||||||
if ( auto* boxObject = dynamic_cast<ModelBoxObject*>(object) )
|
if ( auto* boxObject = dynamic_cast<ModelBoxObject*>(object) )
|
||||||
{
|
{
|
||||||
@@ -560,13 +560,13 @@ namespace glabels
|
|||||||
|
|
||||||
DataCache data( objects );
|
DataCache data( objects );
|
||||||
|
|
||||||
foreach ( QString name, data.imageNames() )
|
for ( QString name : data.imageNames() )
|
||||||
{
|
{
|
||||||
QString fn = FileUtil::makeRelativeIfInDir( model->dir(), name );
|
QString fn = FileUtil::makeRelativeIfInDir( model->dir(), name );
|
||||||
createPngFileNode( node, fn, data.getImage( name ) );
|
createPngFileNode( node, fn, data.getImage( name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( QString name, data.svgNames() )
|
for ( QString name : data.svgNames() )
|
||||||
{
|
{
|
||||||
QString fn = FileUtil::makeRelativeIfInDir( model->dir(), name );
|
QString fn = FileUtil::makeRelativeIfInDir( model->dir(), name );
|
||||||
createSvgFileNode( node, fn, data.getSvg( name ) );
|
createSvgFileNode( node, fn, data.getSvg( name ) );
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
model->setRotate( parseRotateAttr( child.toElement() ) );
|
model->setRotate( parseRotateAttr( child.toElement() ) );
|
||||||
auto list = parseObjectsNode( child.toElement(), model, data );
|
auto list = parseObjectsNode( child.toElement(), model, data );
|
||||||
foreach ( ModelObject* object, list )
|
for ( ModelObject* object : list )
|
||||||
{
|
{
|
||||||
model->addObject( object );
|
model->addObject( object );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
label->setRotate( parseRotateAttr( childElement ) );
|
label->setRotate( parseRotateAttr( childElement ) );
|
||||||
QList<ModelObject*> list = parseObjectsNode( childElement, data );
|
QList<ModelObject*> list = parseObjectsNode( childElement, data );
|
||||||
foreach ( ModelObject* object, list )
|
for ( ModelObject* object : list )
|
||||||
{
|
{
|
||||||
label->addObject( object );
|
label->addObject( object );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ int main( int argc, char *argv[] )
|
|||||||
QStringList filenameList = app.arguments();
|
QStringList filenameList = app.arguments();
|
||||||
filenameList.removeFirst(); // Remove 0th argument, which is the command name
|
filenameList.removeFirst(); // Remove 0th argument, which is the command name
|
||||||
|
|
||||||
foreach ( QString filename, filenameList )
|
for ( QString filename : filenameList )
|
||||||
{
|
{
|
||||||
parseFile( filename );
|
parseFile( filename );
|
||||||
}
|
}
|
||||||
@@ -95,13 +95,13 @@ int main( int argc, char *argv[] )
|
|||||||
out << "// Automatically generated with " << app.arguments().at(0) << Qt::endl;
|
out << "// Automatically generated with " << app.arguments().at(0) << Qt::endl;
|
||||||
out << "//" << Qt::endl;
|
out << "//" << Qt::endl;
|
||||||
out << "// Sources:" << Qt::endl;
|
out << "// Sources:" << Qt::endl;
|
||||||
foreach ( QString filename, filenameList )
|
for ( QString filename : filenameList )
|
||||||
{
|
{
|
||||||
out << "// " << filename << Qt::endl;
|
out << "// " << filename << Qt::endl;
|
||||||
}
|
}
|
||||||
out << "//" << Qt::endl;
|
out << "//" << Qt::endl;
|
||||||
|
|
||||||
foreach ( QString string, stringList )
|
for ( QString string : stringList )
|
||||||
{
|
{
|
||||||
out << "QT_TRANSLATE_NOOP( \"XmlStrings\", \"" << string << "\" );" << Qt::endl;
|
out << "QT_TRANSLATE_NOOP( \"XmlStrings\", \"" << string << "\" );" << Qt::endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user