Commit eaf74268 authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by Boudewijn Rempt

Replace foreach with Q_FOREACH

parent 1d00a620
......@@ -87,7 +87,7 @@ void KisBContrastBenchmark::benchmarkFilter()
QVector<QRect> rects = KritaUtils::splitRectIntoPatches(QRect(0, 0, GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT), size);
QBENCHMARK{
foreach(const QRect &rc, rects) {
Q_FOREACH (const QRect &rc, rects) {
filter->process(m_device, rc, kfc);
}
}
......
......@@ -255,7 +255,7 @@ void freeTiles(QVector<Tile> tiles,
const int srcAlignmentShift,
const int dstAlignmentShift)
{
foreach (const Tile &tile, tiles) {
Q_FOREACH (const Tile &tile, tiles) {
free(tile.src - srcAlignmentShift);
free(tile.dst - dstAlignmentShift);
free(tile.mask);
......@@ -410,7 +410,7 @@ void benchmarkCompositeOp(const KoCompositeOp *op,
QTime timer;
timer.start();
foreach (const Tile &tile, tiles) {
Q_FOREACH (const Tile &tile, tiles) {
params.dstRowStart = tile.dst + tileOffset;
params.srcRowStart = tile.src + tileOffset;
params.maskRowStart = haveMask ? tile.mask : 0;
......@@ -724,7 +724,7 @@ void KisCompositionBenchmark::benchmarkMemcpy()
generateTiles(numTiles, 0, 0, ALPHA_UNIT, ALPHA_UNIT, 4);
QBENCHMARK_ONCE {
foreach (const Tile &tile, tiles) {
Q_FOREACH (const Tile &tile, tiles) {
memcpy(tile.dst, tile.src, 4 * numPixels);
}
}
......
......@@ -93,7 +93,7 @@ void KisLevelFilterBenchmark::benchmarkFilter()
QVector<QRect> rects = KritaUtils::splitRectIntoPatches(QRect(0, 0, GMP_IMAGE_WIDTH,GMP_IMAGE_HEIGHT), size);
QBENCHMARK{
foreach(const QRect &rc, rects) {
Q_FOREACH (const QRect &rc, rects) {
filter->process(m_device, rc, kfc);
}
}
......
......@@ -181,7 +181,7 @@ public:
sketchView->setResizeMode( QDeclarativeView::SizeRootObjectToView );
if (sketchView->errors().count() > 0) {
foreach(const QDeclarativeError &error, sketchView->errors()) {
Q_FOREACH (const QDeclarativeError &error, sketchView->errors()) {
dbgKrita << error.toString();
}
}
......@@ -259,7 +259,7 @@ MainWindow::MainWindow(QStringList fileNames, QWidget* parent, Qt::WindowFlags f
cfg.setNewCursorStyle(CURSOR_STYLE_NO_CURSOR);
cfg.setUseOpenGL(true);
foreach(QString fileName, fileNames) {
Q_FOREACH (QString fileName, fileNames) {
DocumentManager::instance()->recentFileManager()->addRecent( QDir::current().absoluteFilePath( fileName ) );
}
......
......@@ -225,7 +225,7 @@ void DesktopViewProxy::documentChanged()
void DesktopViewProxy::updateKeyBindings()
{
//KisView* view = qobject_cast<KisView*>(d->mainWindow->sketchKisView());
foreach(QAction* action, d->desktopWindow->actions()) {
Q_FOREACH (QAction* action, d->desktopWindow->actions()) {
QAction* otherAction = d->desktopWindow->action(action->objectName().toLatin1());
if(otherAction) {
otherAction->setShortcut(action->shortcut());
......
......@@ -265,7 +265,7 @@ void KisPaintOpPreset::toXML(QDomDocument& doc, QDomElement& elt) const
// sanitize the settings
bool hasTexture = m_d->settings->getBool("Texture/Pattern/Enabled");
if (!hasTexture) {
foreach(const QString & key, m_d->settings->getProperties().keys()) {
Q_FOREACH (const QString & key, m_d->settings->getProperties().keys()) {
if (key.startsWith("Texture") && key != "Texture/Pattern/Enabled") {
m_d->settings->removeProperty(key);
}
......@@ -305,7 +305,7 @@ void KisPaintOpPreset::fromXML(const QDomElement& presetElt)
// sanitize the settings
bool hasTexture = settings->getBool("Texture/Pattern/Enabled");
if (!hasTexture) {
foreach(const QString & key, settings->getProperties().keys()) {
Q_FOREACH (const QString & key, settings->getProperties().keys()) {
if (key.startsWith("Texture") && key != "Texture/Pattern/Enabled") {
settings->removeProperty(key);
}
......
......@@ -45,7 +45,7 @@ KisPaintOpRegistry::KisPaintOpRegistry()
KisPaintOpRegistry::~KisPaintOpRegistry()
{
foreach(const QString & id, keys()) {
Q_FOREACH (const QString & id, keys()) {
delete get(id);
}
dbgRegistry << "Deleting KisPaintOpRegistry";
......@@ -58,7 +58,7 @@ void KisPaintOpRegistry::initRegistry()
QStringList toBeRemoved;
foreach(const QString & id, keys()) {
Q_FOREACH (const QString & id, keys()) {
KisPaintOpFactory *factory = get(id);
if (!factory->settings()) {
toBeRemoved << id;
......@@ -66,7 +66,7 @@ void KisPaintOpRegistry::initRegistry()
factory->processAfterLoading();
}
}
foreach(const QString & id, toBeRemoved) {
Q_FOREACH (const QString & id, toBeRemoved) {
remove(id);
}
}
......@@ -165,7 +165,7 @@ QString KisPaintOpRegistry::pixmap(const KoID & id) const
QList<KoID> KisPaintOpRegistry::listKeys() const
{
QList<KoID> answer;
foreach(const QString & key, keys()) {
Q_FOREACH (const QString & key, keys()) {
answer.append(KoID(key, get(key)->name()));
}
......
......@@ -93,7 +93,7 @@ void KisImageLayerRemoveCommandImpl::Private::processClones(KisNodeSP node)
/**
* Initialize the list of reincarnates nodes
*/
foreach(KisCloneLayerWSP _clone, layer->registeredClones()) {
Q_FOREACH (KisCloneLayerWSP _clone, layer->registeredClones()) {
KisCloneLayerSP clone = _clone;
Q_ASSERT(clone);
......@@ -128,7 +128,7 @@ void KisImageLayerRemoveCommandImpl::Private::moveChildren(KisNodeSP src, KisNod
void KisImageLayerRemoveCommandImpl::Private::moveClones(KisLayerSP src, KisLayerSP dst)
{
foreach(KisCloneLayerWSP _clone, src->registeredClones()) {
Q_FOREACH (KisCloneLayerWSP _clone, src->registeredClones()) {
KisCloneLayerSP clone = _clone;
Q_ASSERT(clone);
......
......@@ -57,13 +57,13 @@ void KisNodePropertyListCommand::doUpdate(const KisNodeModel::PropertyList &oldP
bool oldPassThroughValue = false;
bool newPassThroughValue = false;
foreach(const KisNodeModel::Property &prop, oldPropertyList) {
Q_FOREACH (const KisNodeModel::Property &prop, oldPropertyList) {
if (prop.name == i18n("Pass Through")) {
oldPassThroughValue = prop.state.toBool();
}
}
foreach(const KisNodeModel::Property &prop, newPropertyList) {
Q_FOREACH (const KisNodeModel::Property &prop, newPropertyList) {
if (prop.name == i18n("Pass Through")) {
newPassThroughValue = prop.state.toBool();
}
......@@ -83,7 +83,7 @@ void KisNodePropertyListCommand::doUpdate(const KisNodeModel::PropertyList &oldP
void KisNodePropertyListCommand::setNodePropertiesNoUndo(KisNodeSP node, KisImageSP image, PropertyList proplist)
{
bool undo = true;
foreach(const KisNodeModel::Property &prop, proplist) {
Q_FOREACH (const KisNodeModel::Property &prop, proplist) {
if (prop.name == i18n("Visible") && node->visible() != prop.state.toBool()) undo = false;
if (prop.name == i18n("Locked") && node->userLocked() != prop.state.toBool()) undo = false;
if (prop.name == i18n("Active")) {
......
......@@ -43,7 +43,7 @@ KisFilterRegistry::KisFilterRegistry(QObject *parent)
KisFilterRegistry::~KisFilterRegistry()
{
dbgRegistry << "deleting KisFilterRegistry";
foreach(KisFilterSP filter, values()) {
Q_FOREACH (KisFilterSP filter, values()) {
remove(filter->id());
filter.clear();
}
......
......@@ -40,7 +40,7 @@ KisGeneratorRegistry::KisGeneratorRegistry(QObject *parent)
KisGeneratorRegistry::~KisGeneratorRegistry()
{
foreach(KisGeneratorSP generator, values()) {
Q_FOREACH (KisGeneratorSP generator, values()) {
remove(generator->id());
generator.clear();
}
......
......@@ -169,7 +169,7 @@ public:
prepareRegion += needRectOnSource;
}
foreach(const QRect &rect, prepareRegion.rects()) {
Q_FOREACH (const QRect &rect, prepareRegion.rects()) {
walker.collectRects(srcLayer, rect);
merger.startMerge(walker, false);
}
......
......@@ -95,7 +95,7 @@ QList<QString> KisBookmarkedConfigurationManager::configurations() const
QMap< QString, QString > m = cfg->entryMap(configEntryGroup());
QList<QString> keys = m.keys();
QList<QString> configsKey;
foreach(const QString & key, keys) {
Q_FOREACH (const QString & key, keys) {
if (key != KisBookmarkedConfigurationManager::ConfigDefault && key != KisBookmarkedConfigurationManager::ConfigLastUsed) {
configsKey << key;
}
......
......@@ -351,7 +351,7 @@ QImage KisCageTransformWorker::runOnQImage(QPointF *newOffset)
QVector<QPointF> transformedPoints = m_d->calculateTransformedPoints();
QRectF dstBounds;
foreach (const QPointF &pt, transformedPoints) {
Q_FOREACH (const QPointF &pt, transformedPoints) {
KisAlgebra2D::accumulateBounds(pt, &dstBounds);
}
......
......@@ -45,21 +45,21 @@ int KisCompositeProgressProxy::maximum() const
void KisCompositeProgressProxy::setValue(int value)
{
foreach(KoProgressProxy *proxy, m_uniqueProxies) {
Q_FOREACH (KoProgressProxy *proxy, m_uniqueProxies) {
proxy->setValue(value);
}
}
void KisCompositeProgressProxy::setRange(int minimum, int maximum)
{
foreach(KoProgressProxy *proxy, m_uniqueProxies) {
Q_FOREACH (KoProgressProxy *proxy, m_uniqueProxies) {
proxy->setRange(minimum, maximum);
}
}
void KisCompositeProgressProxy::setFormat(const QString &format)
{
foreach(KoProgressProxy *proxy, m_uniqueProxies) {
Q_FOREACH (KoProgressProxy *proxy, m_uniqueProxies) {
proxy->setFormat(format);
}
}
......
......@@ -494,7 +494,7 @@ private:
fftw_free(m_kernelFFT);
}
foreach (fftw_complex *channel, m_channelFFT) {
Q_FOREACH (fftw_complex *channel, m_channelFFT) {
fftw_free(channel);
}
m_channelFFT.clear();
......
......@@ -21,7 +21,7 @@
bool KisCountVisitor::inList(KisNode* node)
{
foreach(const QString& nodeType, m_nodeTypes) {
Q_FOREACH (const QString& nodeType, m_nodeTypes) {
if (node->inherits(nodeType.toLatin1()))
return true;
}
......
......@@ -410,7 +410,7 @@ bool KisCubicCurve::isNull() const
{
const QList<QPointF> &points = d->data->points;
foreach (const QPointF &pt, points) {
Q_FOREACH (const QPointF &pt, points) {
if (!qFuzzyCompare(pt.x(), pt.y())) {
return false;
}
......@@ -436,7 +436,7 @@ QString KisCubicCurve::toString() const
if(d->data->points.count() < 1)
return sCurve;
foreach(const QPointF & pair, d->data->points) {
Q_FOREACH (const QPointF & pair, d->data->points) {
sCurve += QString::number(pair.x());
sCurve += ',';
sCurve += QString::number(pair.y());
......@@ -452,7 +452,7 @@ void KisCubicCurve::fromString(const QString& string)
QList<QPointF> points;
foreach(const QString & pair, data) {
Q_FOREACH (const QString & pair, data) {
if (pair.indexOf(',') > -1) {
QPointF p;
p.rx() = pair.section(',', 0, 0).toDouble();
......
......@@ -144,7 +144,7 @@ void saveValue(QDomElement *parent, const QString &tag, const QVector<T> &array)
e.setAttribute("type", "array");
int i = 0;
foreach (const T &v, array) {
Q_FOREACH (const T &v, array) {
saveValue(&e, QString("item_%1").arg(i++), v);
}
}
......
......@@ -184,7 +184,7 @@ KisFilterStrategyRegistry::KisFilterStrategyRegistry()
KisFilterStrategyRegistry::~KisFilterStrategyRegistry()
{
foreach(const QString &id, keys()) {
Q_FOREACH (const QString &id, keys()) {
delete get(id);
}
dbgRegistry << "deleting KisFilterStrategyRegistry";
......@@ -209,7 +209,7 @@ KisFilterStrategyRegistry* KisFilterStrategyRegistry::instance()
QList<KoID> KisFilterStrategyRegistry::listKeys() const
{
QList<KoID> answer;
foreach (const QString key, keys()) {
Q_FOREACH (const QString key, keys()) {
answer.append(KoID(key, get(key)->name()));
}
......@@ -220,7 +220,7 @@ QString KisFilterStrategyRegistry::formatedDescriptions() const
{
QString formatedDescription("<html><head/><body>");
foreach (const QString key, keys()) {
Q_FOREACH (const QString key, keys()) {
KisFilterStrategy *strategy = get(key);
QString description = strategy->description();
......
......@@ -585,7 +585,7 @@ void KisGradientPainter::precalculateShape()
QList<QPainterPath> splitPaths = KritaUtils::splitDisjointPaths(path);
foreach (const QPainterPath &subpath, splitPaths) {
Q_FOREACH (const QPainterPath &subpath, splitPaths) {
QRect boundingRect = subpath.boundingRect().toAlignedRect();
if (boundingRect.width() < 3 || boundingRect.height() < 3) {
......@@ -706,7 +706,7 @@ bool KisGradientPainter::paintGradient(const QPointF& gradientVectorStart,
const KoColorSpace * colorSpace = dev->colorSpace();
const qint32 pixelSize = colorSpace->pixelSize();
foreach (const Private::ProcessRegion &r, m_d->processRegions) {
Q_FOREACH (const Private::ProcessRegion &r, m_d->processRegions) {
QRect processRect = r.processRect;
QSharedPointer<KisGradientShapeStrategy> shapeStrategy = r.precalculatedShapeStrategy;
......
......@@ -424,7 +424,7 @@ bool getOrthogonalPointApproximation(const QPoint &cellPt,
*srcPoint = indexesOp.getSrcPointForce(cellPt);
*dstPoint = QPointF();
foreach (const Private::PointExtension &ext, extensionPoints) {
Q_FOREACH (const Private::PointExtension &ext, extensionPoints) {
QPointF near = transformedPoints[ext.near];
QPointF far = transformedPoints[ext.far];
......
......@@ -300,7 +300,7 @@ KisNodeModel::PropertyList KisGroupLayer::sectionModelProperties() const
void KisGroupLayer::setSectionModelProperties(const KisNodeModel::PropertyList &properties)
{
foreach (const KisNodeModel::Property &property, properties) {
Q_FOREACH (const KisNodeModel::Property &property, properties) {
if (property.name == i18n("Pass Through")) {
setPassThroughMode(property.state.toBool());
}
......
......@@ -63,7 +63,7 @@ bool KisIdleWatcher::isIdle() const
{
bool idle = true;
foreach(KisImageSP image, m_d->trackedImages) {
Q_FOREACH (KisImageSP image, m_d->trackedImages) {
if (!image) continue;
if (!image->isIdle()) {
......@@ -80,7 +80,7 @@ void KisIdleWatcher::setTrackedImages(const QVector<KisImageSP> &images)
m_d->connectionsStore.clear();
m_d->trackedImages.clear();
foreach (KisImageSP image, images) {
Q_FOREACH (KisImageSP image, images) {
m_d->trackedImages << image;
m_d->connectionsStore.addConnection(image, SIGNAL(sigImageModified()),
this, SLOT(slotImageModified()));
......
......@@ -928,7 +928,7 @@ void KisImage::refreshHiddenArea(KisNodeSP rootNode, const QRect &preparedArea)
QRegion dirtyRegion = realNodeRect;
dirtyRegion -= preparedArea;
foreach(const QRect &rc, dirtyRegion.rects()) {
Q_FOREACH (const QRect &rc, dirtyRegion.rects()) {
refreshGraph(rootNode, rc, realNodeRect);
}
}
......@@ -963,7 +963,7 @@ void KisImage::flatten()
bool checkIsSourceForClone(KisNodeSP src, const QList<KisNodeSP> &nodes)
{
foreach (KisNodeSP node, nodes) {
Q_FOREACH (KisNodeSP node, nodes) {
if (node == src) continue;
KisCloneLayer *clone = dynamic_cast<KisCloneLayer*>(node.data());
......@@ -1004,7 +1004,7 @@ bool checkIsChildOf(KisNodeSP node, const QList<KisNodeSP> &parents)
parent = parent->parent();
}
foreach(KisNodeSP perspectiveParent, parents) {
Q_FOREACH (KisNodeSP perspectiveParent, parents) {
if (nodeParents.contains(perspectiveParent)) {
return true;
}
......@@ -1056,7 +1056,7 @@ void sortMergableNodes(KisNodeSP root, QList<KisNodeSP> &inputNodes, QList<KisNo
void fetchSelectionMasks(QList<KisNodeSP> mergedNodes, QVector<KisSelectionMaskSP> &selectionMasks)
{
foreach (KisNodeSP node, mergedNodes) {
Q_FOREACH (KisNodeSP node, mergedNodes) {
KisLayerSP layer = dynamic_cast<KisLayer*>(node.data());
KisSelectionMaskSP mask;
......@@ -1070,7 +1070,7 @@ void fetchSelectionMasks(QList<KisNodeSP> mergedNodes, QVector<KisSelectionMaskS
void reparentSelectionMasks(KisLayerSP newLayer, const QVector<KisSelectionMaskSP> &selectionMasks)
{
KisImageSP image = newLayer->image();
foreach (KisSelectionMaskSP mask, selectionMasks) {
Q_FOREACH (KisSelectionMaskSP mask, selectionMasks) {
image->undoAdapter()->addCommand(new KisImageLayerMoveCommand(image, mask, newLayer, newLayer->lastChild()));
image->undoAdapter()->addCommand(new KisActivateSelectionMaskCommand(mask, false));
}
......@@ -1082,7 +1082,7 @@ KisNodeSP tryMergeSelectionMasks(KisImageSP image, QList<KisNodeSP> mergedNodes)
QList<KisSelectionMaskSP> selectionMasks;
foreach (KisNodeSP node, mergedNodes) {
Q_FOREACH (KisNodeSP node, mergedNodes) {
KisSelectionMaskSP mask = dynamic_cast<KisSelectionMask*>(node.data());
if (!mask) return 0;
......@@ -1094,7 +1094,7 @@ KisNodeSP tryMergeSelectionMasks(KisImageSP image, QList<KisNodeSP> mergedNodes)
KisSelectionSP selection = new KisSelection();
foreach (KisMaskSP mask, selectionMasks) {
Q_FOREACH (KisMaskSP mask, selectionMasks) {
selection->pixelSelection()->applySelection(
mask->selection()->pixelSelection(), SELECTION_ADD);
}
......@@ -1138,7 +1138,7 @@ KisNodeSP KisImage::mergeMultipleLayers(QList<KisNodeSP> mergedNodes, KisNodeSP
QVector<KisSelectionMaskSP> selectionMasks;
fetchSelectionMasks(mergedNodes, selectionMasks);
foreach (KisNodeSP layer, mergedNodes) {
Q_FOREACH (KisNodeSP layer, mergedNodes) {
refreshHiddenArea(layer, bounds());
}
......@@ -1148,7 +1148,7 @@ KisNodeSP KisImage::mergeMultipleLayers(QList<KisNodeSP> mergedNodes, KisNodeSP
{
KisImageBarrierLocker l(this);
foreach (KisNodeSP layer, mergedNodes) {
Q_FOREACH (KisNodeSP layer, mergedNodes) {
QRect rc = layer->exactBounds() | bounds();
layer->projectionPlane()->apply(&gc, rc);
}
......@@ -1799,7 +1799,7 @@ void KisImage::requestProjectionUpdate(KisNode *node, const QRect& rect)
QRect boundRect = bounds();
KisWrappedRect splitRect(rect, boundRect);
foreach (const QRect &rc, splitRect) {
Q_FOREACH (const QRect &rc, splitRect) {
requestProjectionUpdateImpl(node, rc, boundRect);
}
} else {
......