Author: jghali
Date: Mon Apr 30 23:49:50 2018
New Revision: 22506

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22506
Log:
replace a few Qt's foreach by c++11 range-based for()

Modified:
    trunk/Scribus/scribus/pageitem_noteframe.h
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
    trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
    trunk/Scribus/scribus/text/boxes.cpp
    trunk/Scribus/scribus/text/textlayout.cpp
    trunk/Scribus/scribus/text/textlayout.h
    trunk/Scribus/scribus/text/textshaper.cpp

Modified: trunk/Scribus/scribus/pageitem_noteframe.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/pageitem_noteframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.h  (original)
+++ trunk/Scribus/scribus/pageitem_noteframe.h  Mon Apr 30 23:49:50 2018
@@ -39,10 +39,10 @@
 
        PageItem_TextFrame* masterFrame() { return m_masterFrame; }
        void setMaster(PageItem* frame) { m_masterFrame = frame->asTextFrame(); 
}
-       bool isEndNotesFrame() { return m_nstyle->isEndNotes(); }
-       bool isAutoWelded() { return m_nstyle->isAutoWeldNotesFrames(); }
-       bool isAutoHeight() { return m_nstyle->isAutoNotesHeight(); }
-       bool isAutoWidth() { return m_nstyle->isAutoNotesWidth(); }
+       bool isEndNotesFrame() const { return m_nstyle->isEndNotes(); }
+       bool isAutoWelded()  const { return m_nstyle->isAutoWeldNotesFrames(); }
+       bool isAutoHeight()  const { return m_nstyle->isAutoNotesHeight(); }
+       bool isAutoWidth()  const { return m_nstyle->isAutoNotesWidth(); }
 
        //return list of notes in noteframe
        QList<TextNote*> notesList() { return l_notes; }

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp        (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp        Mon Apr 30 23:49:50 2018
@@ -1102,7 +1102,7 @@
                result->setWidth(lineData.width);
                result->setAscent(lineData.ascent);
                result->setDescent(lineData.descent);
-               foreach (const GlyphCluster& run, 
ShapedTextFeed::putInVisualOrder(glyphs,   0, lineData.lastCluster - 
lineData.firstCluster + 1))
+               for (const GlyphCluster& run : 
ShapedTextFeed::putInVisualOrder(glyphs,   0, lineData.lastCluster - 
lineData.firstCluster + 1))
                {
                        addBox(result, run);
 //                     qDebug() << "cluster" << run.firstChar() << ".." << 
run.lastChar() << "@" << run.visualIndex();
@@ -1411,7 +1411,7 @@
                { //if notes are used
                        UndoManager::instance()->setUndoEnabled(false);
                        QList<PageItem_NoteFrame*> delList;
-                       foreach (PageItem_NoteFrame* nF, 
m_notesFramesMap.keys())
+                       for (PageItem_NoteFrame* nF : m_notesFramesMap.keys())
                        {
                                if (nF->notesList().isEmpty() && 
!nF->isAutoNoteFrame())
                                        delList.append(nF);
@@ -1670,7 +1670,8 @@
                                //text height, width, ascent and descent should 
be calculated for whole text provided by ScText in current position
                                //and that may be more than one char (variable 
text for example)
                                double realCharHeight = 0.0, realCharAscent = 
0.0;
-                               foreach (const GlyphLayout& gl, 
current.glyphs[currentIndex].glyphs()) {
+                               const QList<GlyphLayout>& glyphs = 
current.glyphs[currentIndex].glyphs();
+                               for (const GlyphLayout& gl : glyphs) {
                                        GlyphMetrics gm = 
font.glyphBBox(gl.glyph);
                                        realCharHeight = qMax(realCharHeight, 
gm.ascent + gm.descent);
                                        realCharAscent = qMax(realCharAscent, 
gm.ascent);
@@ -1749,7 +1750,8 @@
                                {
                                        double realCharHeight = 0.0;
                                        wide = 0.0; realAsce = 0.0;
-                                       foreach (const GlyphLayout& gl, 
glyphCluster.glyphs()) {
+                                       const QList<GlyphLayout>& glyphs = 
glyphCluster.glyphs();
+                                       for (const GlyphLayout& gl : glyphs) {
                                                GlyphMetrics gm;
                                                gm = font.glyphBBox(gl.glyph, 
charStyle.fontSize() / 10.0);
                                                realCharHeight = 
qMax(realCharHeight, gm.ascent + gm.descent);
@@ -1786,7 +1788,8 @@
                                {
                                        if (itemText.text(a) != 
SpecialChars::OBJECT)
                                        {
-                                               foreach (const GlyphLayout& gl, 
current.glyphs[currentIndex].glyphs())
+                                               const QList<GlyphLayout>& 
glyphs = current.glyphs[currentIndex].glyphs();
+                                               for (const GlyphLayout& gl : 
glyphs)
                                                {
                                                        GlyphMetrics gm = 
font.glyphBBox(gl.glyph, hlcsize10);
                                                        realDesc = 
qMax(realDesc, gm.descent * scaleV - offset);
@@ -1810,7 +1813,8 @@
                                                realAsce = asce * scaleV + 
offset;
                                        else
                                        {
-                                               foreach (const GlyphLayout& gl, 
current.glyphs[currentIndex].glyphs())
+                                               const QList<GlyphLayout>& 
glyphs = current.glyphs[currentIndex].glyphs();
+                                               for (const GlyphLayout& gl : 
glyphs)
                                                        realAsce = 
qMax(realAsce, font.glyphBBox(gl.glyph, hlcsize10).ascent * scaleV + offset);
                                        }
                                }
@@ -2203,7 +2207,8 @@
                        if (DropCmode)
                        {
                                double yoffset = 0.0;
-                               foreach (const GlyphLayout& gl, 
current.glyphs[currentIndex].glyphs())
+                               const QList<GlyphLayout>& glyphs = 
current.glyphs[currentIndex].glyphs();
+                               for (const GlyphLayout& gl : glyphs)
                                        yoffset = qMax(yoffset, 
font.glyphBBox(gl.glyph, chsd / 10.0).descent);
                                current.glyphs[currentIndex].yoffset -= yoffset;
                        }
@@ -5588,7 +5593,7 @@
        int oldItemsCount = m_Doc->Items->count();
 
        QList<PageItem_NoteFrame*> delList;
-       foreach (PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+       for (PageItem_NoteFrame* nF : m_notesFramesMap.keys())
        {
                if (nF->notesList().isEmpty() && !nF->isAutoNoteFrame())
                        delList.append(nF);
@@ -5806,14 +5811,14 @@
 //     QList<PageItem_NoteFrame*> old_endNotesList;
 
 
-//     foreach(PageItem_NoteFrame* nF, notesMap.keys())
+//     for (PageItem_NoteFrame* nF : notesMap.keys())
 //     {
 //             if (nF->isEndNotesFrame())
 //                     curr_endNotesList.append(nF);
 //             else if (!notesMap.value(nF).isEmpty())
 //                     curr_footNotesList.append(nF);
 //     }
-//     foreach(PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+//     for (PageItem_NoteFrame* nF : m_notesFramesMap.keys())
 //     {
 //             if (nF->isEndNotesFrame())
 //                     old_endNotesList.append(nF);
@@ -5821,7 +5826,7 @@
 //                     old_footNotesList.append(nF);
 //     }
 //     //check for endnotes marks change in current frame
-//     foreach (PageItem_NoteFrame* nF, old_endNotesList)
+//     for (PageItem_NoteFrame* nF : old_endNotesList)
 //     {
 //             if (nF->deleteIt)
 //             {
@@ -5835,7 +5840,7 @@
 //             }
 //     }
        //check if some notes frames are not used anymore
-       foreach (PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+       for (PageItem_NoteFrame* nF : m_notesFramesMap.keys())
        {
                if (nF->deleteIt || (nF->isAutoNoteFrame() && 
!notesMap.keys().contains(nF)))
                {
@@ -5857,7 +5862,7 @@
        if (m_notesFramesMap != notesMap)
        {
                docWasChanged = true;
-               foreach (PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+               for (PageItem_NoteFrame* nF : m_notesFramesMap.keys())
                {
                        if (notesMap.contains(nF))
                        {
@@ -5878,7 +5883,7 @@
 
 void PageItem_TextFrame::notesFramesLayout()
 {
-       foreach (PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+       for (PageItem_NoteFrame* nF : m_notesFramesMap.keys())
        {
                if (nF == NULL)
                        continue;
@@ -5932,7 +5937,7 @@
 
 PageItem_NoteFrame *PageItem_TextFrame::itemNoteFrame(NotesStyle *nStyle)
 {
-       foreach (PageItem_NoteFrame* nF, m_notesFramesMap.keys())
+       for (PageItem_NoteFrame* nF : m_notesFramesMap.keys())
                if (nF->notesStyle() == nStyle)
                        return nF;
        return NULL;

Modified: trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp    
(original)
+++ trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp    Mon Apr 
30 23:49:50 2018
@@ -640,7 +640,7 @@
 void SVGExPlug::paintBorder(const TableBorder& border, const QPointF& start, 
const QPointF& end, const QPointF& startOffsetFactors, const QPointF& 
endOffsetFactors, QDomElement &ob)
 {
        QPointF lineStart, lineEnd;
-       foreach (const TableBorderLine& line, border.borderLines())
+       for (const TableBorderLine& line : border.borderLines())
        {
                lineStart.setX(start.x() + line.width() * 
startOffsetFactors.x());
                lineStart.setY(start.y() + line.width() * 
startOffsetFactors.y());
@@ -1162,7 +1162,8 @@
                if (gc.isControlGlyphs())
                        return;
                double current_x = 0.0;
-               foreach (const GlyphLayout& gl, gc.glyphs()) {
+               for (const GlyphLayout& gl : gc.glyphs())
+               {
                        QTransform transform = matrix();
                        transform.translate(x() + gl.xoffset + current_x, y() - 
(fontSize() * gc.scaleV()) + gl.yoffset);
                        transform.scale(gc.scaleH() * fontSize() / 10.0, 
gc.scaleV() * fontSize() / 10.0);
@@ -1182,7 +1183,8 @@
                if (gc.isControlGlyphs())
                        return;
                double current_x = 0.0;
-               foreach (const GlyphLayout& gl, gc.glyphs()) {
+               for (const GlyphLayout& gl : gc.glyphs())
+               {
                        QTransform transform = matrix();
                        transform.translate(x() + gl.xoffset + current_x, y() - 
(fontSize() * gc.scaleV()) + gl.yoffset);
                        transform.scale(gc.scaleH() * fontSize() / 10.0, 
gc.scaleV() * fontSize() / 10.0);

Modified: trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp      
(original)
+++ trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp      Mon Apr 
30 23:49:50 2018
@@ -839,7 +839,7 @@
                QString gcMap = 
QString("(%1:%2)").arg(gc.getText().size()).arg(gc.glyphs().size());
                QString indices;
                double current_x = 0.0;
-               foreach (const GlyphLayout& gl, gc.glyphs()) {
+               for (const GlyphLayout& gl : gc.glyphs()) {
                        indices += QString("%1,%2,%3,%4;").arg(gl.glyph)
                                        .arg(((gl.xadvance + current_x) * 
m_xps->conversionFactor) / size * 100)
                                        .arg((-gl.xoffset * 
m_xps->conversionFactor) / size * 100)
@@ -856,7 +856,7 @@
                if (gc.isControlGlyphs())
                        return;
                double current_x = 0.0;
-               foreach (const GlyphLayout& gl, gc.glyphs()) {
+               for (const GlyphLayout& gl : gc.glyphs()) {
                        FPointArray outline = font().glyphOutline(gl.glyph);
                        if (outline.size() >= 4)
                        {
@@ -1466,7 +1466,7 @@
 void XPSExPlug::paintBorder(const TableBorder& border, const QPointF& start, 
const QPointF& end, const QPointF& startOffsetFactors, const QPointF& 
endOffsetFactors, QDomElement &ob)
 {
        QPointF lineStart, lineEnd;
-       foreach (const TableBorderLine& line, border.borderLines())
+       for (const TableBorderLine& line : border.borderLines())
        {
                lineStart.setX(start.x() + line.width() * 
startOffsetFactors.x());
                lineStart.setY(start.y() + line.width() * 
startOffsetFactors.y());

Modified: trunk/Scribus/scribus/text/boxes.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/text/boxes.cpp
==============================================================================
--- trunk/Scribus/scribus/text/boxes.cpp        (original)
+++ trunk/Scribus/scribus/text/boxes.cpp        Mon Apr 30 23:49:50 2018
@@ -24,7 +24,7 @@
 int GroupBox::pointToPosition(QPointF coord, const StoryText &story) const
 {
        QPointF rel = coord - QPointF(m_x, m_y);
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
        {
                if (box->containsPoint(rel))
                {
@@ -51,7 +51,7 @@
 QLineF GroupBox::positionToPoint(int pos, const StoryText& story) const
 {
        QLineF result;
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
        {
                if (box->containsPos(pos))
                {
@@ -67,7 +67,7 @@
 {
        p->save();
        p->translate(x(), y());
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
        {
                box->render(p);
        }
@@ -78,7 +78,7 @@
 {
        p->save();
        p->translate(x(), y());
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
        {
                box->render(p, ctx);
        }
@@ -89,7 +89,7 @@
 {
        p->save();
        p->translate(x(), y());
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
        {
                box->drawSelection(p, ctx);
        }
@@ -194,7 +194,7 @@
 QLineF LineBox::positionToPoint(int pos, const StoryText& story) const
 {
        QLineF result;
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
        {
                if (box->containsPos(pos))
                {
@@ -218,7 +218,7 @@
        drawBackGround(p);
 
        p->translate(0, ascent());
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
        {
                box->render(p);
        }
@@ -234,7 +234,7 @@
        drawSelection(p, ctx);
 
        p->translate(0, ascent());
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
                box->render(p, ctx);
 
        p->translate(-x(), -y() - ascent());
@@ -242,7 +242,7 @@
 
 void LineBox::drawSelection(ScreenPainter *p, ITextContext *ctx) const
 {
-       foreach (const Box *box, boxes())
+       for (const Box *box : boxes())
                box->drawSelection(p, ctx);
 }
 
@@ -463,7 +463,7 @@
 
 void PathLineBox::update()
 {
-       foreach (Box* box, boxes()) {
+       for (Box* box : boxes()) {
                m_firstChar = qMin(m_firstChar, box->firstChar());
                m_lastChar = qMax(m_lastChar, box->lastChar());
        }

Modified: trunk/Scribus/scribus/text/textlayout.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/text/textlayout.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textlayout.cpp   (original)
+++ trunk/Scribus/scribus/text/textlayout.cpp   Mon Apr 30 23:49:50 2018
@@ -49,7 +49,7 @@
 uint TextLayout::lines() const
 {
        uint count = 0;
-       foreach (const Box *box, m_box->boxes())
+       for (const Box *box : m_box->boxes())
        {
                count += box->boxes().count();
        }
@@ -59,7 +59,7 @@
 const LineBox* TextLayout::line(uint i) const
 {
        uint count = 0;
-       foreach (const Box *box, m_box->boxes())
+       for (const Box *box : m_box->boxes())
        {
                if (i < count + box->boxes().count())
                        return dynamic_cast<const LineBox*>(box->boxes()[i - 
count]);
@@ -111,14 +111,14 @@
                column->removeBox(lineCount - 1);
 }
 
-void TextLayout::render(ScreenPainter *p, ITextContext *ctx)
+void TextLayout::render(ScreenPainter *p, ITextContext *ctx) const
 {
        p->save();
        m_box->render(p, ctx);
        p->restore();
 }
 
-void TextLayout::renderBackground(TextLayoutPainter *p)
+void TextLayout::renderBackground(TextLayoutPainter *p) const
 {
        QString backColor, lastColor;
        double backShade, lastShade = 100;
@@ -127,7 +127,7 @@
        p->save();
        p->translate(m_box->x(), m_box->y());
 
-       foreach (const Box* column, m_box->boxes())
+       for (const Box* column : m_box->boxes())
        {
                const QList<const Box*>& lineBoxes = column->boxes();
                QRectF colBBox = column->bbox();
@@ -182,7 +182,7 @@
        p->restore();
 }
 
-void TextLayout::render(TextLayoutPainter *p)
+void TextLayout::render(TextLayoutPainter *p) const
 {
        p->save();
        m_box->render(p);

Modified: trunk/Scribus/scribus/text/textlayout.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/text/textlayout.h
==============================================================================
--- trunk/Scribus/scribus/text/textlayout.h     (original)
+++ trunk/Scribus/scribus/text/textlayout.h     Mon Apr 30 23:49:50 2018
@@ -49,9 +49,9 @@
        ITextContext*  frame() { return m_frame; }
        const StoryText* story() const { return m_story; }
        void setStory(StoryText* story);
-       void render(ScreenPainter *p, ITextContext *item);
-       void render(TextLayoutPainter *p);
-       void renderBackground(TextLayoutPainter *p);
+       void render(ScreenPainter *p, ITextContext *item) const;
+       void render(TextLayoutPainter *p) const;
+       void renderBackground(TextLayoutPainter *p) const;
        int startOfLine(int pos) const;
        int endOfLine(int pos) const;
        int prevLine(int pos) const;

Modified: trunk/Scribus/scribus/text/textshaper.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22506&path=/trunk/Scribus/scribus/text/textshaper.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textshaper.cpp   (original)
+++ trunk/Scribus/scribus/text/textshaper.cpp   Mon Apr 30 23:49:50 2018
@@ -78,7 +78,7 @@
        QList<TextRun> newRuns;
        ScriptRun scriptrun((const UChar*) m_text.utf16(), m_text.length());
 
-       foreach (TextRun run, runs)
+       for (TextRun run : runs)
        {
                int start = run.start;
                QList<TextRun> subRuns;
@@ -138,7 +138,8 @@
 {
        QList<TextRun> newRuns;
 
-       foreach (TextRun run, runs) {
+       for (TextRun run : runs)
+       {
                int start = run.start;
                QList<TextRun> subRuns;
 
@@ -289,7 +290,8 @@
 
        // Insert implicit spaces in justification between characters
        // in scripts that do not use spaces to seperate words
-       foreach (const TextRun& run, scriptRuns) {
+       for (const TextRun& run : scriptRuns)
+       {
                switch (run.script) {
                // clustered scripts from 
https://drafts.csswg.org/css-text-3/#script-groups
                case USCRIPT_KHMER:
@@ -324,7 +326,8 @@
                }
        }
 
-       foreach (const TextRun& textRun, textRuns) {
+       for (const TextRun& textRun : textRuns)
+       {
                const CharStyle &style = 
m_story.charStyle(m_textMap.value(textRun.start));
 
                const ScFace &scFace = style.font();
@@ -350,14 +353,16 @@
                hb_buffer_set_cluster_level(hbBuffer, 
HB_BUFFER_CLUSTER_LEVEL_MONOTONE_CHARACTERS);
 
                QVector<hb_feature_t> hbFeatures;
-               QList<FeaturesRun> featuresRuns = itemizeFeatures(textRun);
-               foreach (const FeaturesRun& featuresRun, featuresRuns)
+               const QList<FeaturesRun> featuresRuns = 
itemizeFeatures(textRun);
+               for (const FeaturesRun& featuresRun : featuresRuns)
                {
                        const QStringList& features = featuresRun.features;
                        hbFeatures.reserve(features.length());
-                       foreach (const QString& feature, features) {
+                       for (const QString& feature : features)
+                       {
                                hb_feature_t hbFeature;
-                               hb_bool_t ok = 
hb_feature_from_string(feature.toStdString().c_str(), 
feature.toStdString().length(), &hbFeature);
+                               std::string strFeature(feature.toStdString());
+                               hb_bool_t ok = 
hb_feature_from_string(strFeature.c_str(), strFeature.length(), &hbFeature);
                                if (ok)
                                {
                                        hbFeature.start = featuresRun.start;


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to