summaryrefslogtreecommitdiff
path: root/src/qdoc/cppcodeparser.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-07-11 14:23:28 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-07-12 12:14:43 +0000
commit6ed8a22dd2756557954dc85052870c0894de06ba (patch)
treea49597a789e4f3861a6d52efddd7d3bd7701c917 /src/qdoc/cppcodeparser.cpp
parent9cfa5da0238016c9732f84a3bf3642375382f77c (diff)
downloadqttools-6ed8a22dd2756557954dc85052870c0894de06ba.tar.gz
Eradicate the last Java-style iterators and mark the module free of them
... and of QLinkedList. The change in QDesignerAbstractPropertySheetFactory is straight-forward. The rest are little buggers: - In macdeployqt, the code iterates inside an if. Weird, but portable. - In CppCodeParser, it's still somewhat harmless: just a call to std::remove_if to avoid running into quadratic complexity, even though the original loop had a good idea of iterating backwards, saving at least some copies in the process. Need to take care there that we continue to find the _first_ main.cpp, not the last, so add a check for mainCpp.isEmpty(). - In QtGradientStopsModel, however, needed to work around the absence of QMap::rbegin()/rend(), and it shows why they're missing: QMap's funky op* makes it impossible to just use std::reverse_iterator to do the heavy lifting. Use the recently-added QKeyValueIterator to get an approximation. I say 'approximation', because that one lacks operator->, so we need to use (*it).first, which brings back memories of Qt 2's iterators... Change-Id: I051e64b8d36b04ed2e7cf7695d9b797f08efaccb Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r--src/qdoc/cppcodeparser.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp
index 6d5ec5af0..a4ce5fa2e 100644
--- a/src/qdoc/cppcodeparser.cpp
+++ b/src/qdoc/cppcodeparser.cpp
@@ -39,6 +39,8 @@
#include <qdebug.h>
#include "generator.h"
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
/* qmake ignore Q_OBJECT */
@@ -886,18 +888,20 @@ void CppCodeParser::setExampleFileLists(PageNode *pn)
if (!exampleFiles.isEmpty()) {
// move main.cpp and to the end, if it exists
QString mainCpp;
- QMutableStringListIterator i(exampleFiles);
- i.toBack();
- while (i.hasPrevious()) {
- QString fileName = i.previous();
+
+ const auto isGeneratedOrMainCpp = [&mainCpp](const QString &fileName) {
if (fileName.endsWith("/main.cpp")) {
- mainCpp = fileName;
- i.remove();
+ if (mainCpp.isEmpty())
+ mainCpp = fileName;
+ return true;
}
- else if (fileName.contains("/qrc_") || fileName.contains("/moc_")
- || fileName.contains("/ui_"))
- i.remove();
- }
+ return fileName.contains("/qrc_") || fileName.contains("/moc_") || fileName.contains("/ui_");
+ };
+
+ exampleFiles.erase(std::remove_if(exampleFiles.begin(), exampleFiles.end(),
+ isGeneratedOrMainCpp),
+ exampleFiles.end());
+
if (!mainCpp.isEmpty())
exampleFiles.append(mainCpp);