Skip to content

Commit

Permalink
Port away from Q_FOREACH, add -DQT_NO_URL_CAST_FROM_STRING
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaure-kdab committed Jul 9, 2024
1 parent b2293fa commit 0e49957
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)

include(KDCompilerFlags)

add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY)
add_definitions(-DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DUSE_EXCEPTIONS -DQT_FATAL_ASSERT)
if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
Expand Down
2 changes: 1 addition & 1 deletion src/KDReports/KDReportsCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ KDReports::Cell::CellFormatFunc KDReports::Cell::cellFormatFunction() const

void KDReports::Cell::build(ReportBuilder &builder) const
{
foreach (const KDReports::ElementData &ed, d->m_elements) {
for (const KDReports::ElementData &ed : std::as_const(d->m_elements)) {
switch (ed.m_type) {
case KDReports::ElementData::Inline:
builder.addInlineElement(*ed.m_element);
Expand Down
2 changes: 1 addition & 1 deletion src/KDReports/KDReportsFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void KDReports::Frame::build(ReportBuilder &builder) const
ReportBuilder contentsBuilder(builder.currentDocumentData(), contentsCursor, builder.report());
contentsBuilder.copyStateFrom(builder);

foreach (const KDReports::ElementData &ed, d->m_elements) {
for (const KDReports::ElementData &ed : std::as_const(d->m_elements)) {
switch (ed.m_type) {
case KDReports::ElementData::Inline:
contentsBuilder.addInlineElement(*ed.m_element);
Expand Down
2 changes: 1 addition & 1 deletion src/KDReports/KDReportsPreviewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void KDReports::PreviewWidgetPrivate::handleMouseRelease(QPoint pos)
const QPoint unscaledPos = pos / m_zoomFactor;
const QString link = m_report->anchorAt(pageList->currentRow(), unscaledPos);
if (!link.isEmpty()) {
Q_EMIT q->linkActivated(link);
Q_EMIT q->linkActivated(QUrl(link));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/KDReports/KDReportsTextDocumentData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void KDReports::TextDocumentData::scaleFontsBy(qreal factor)

// Also adjust the padding in the cells so that it remains proportional,
// and the column constraints.
Q_FOREACH (QTextTable *table, m_tables) {
for (QTextTable *table : std::as_const(m_tables)) {
QTextTableFormat format = table->format();
format.setCellPadding(format.cellPadding() * factor);

Expand Down Expand Up @@ -388,7 +388,7 @@ void KDReports::TextDocumentData::regenerateOneTable(const KDReports::AutoTableE

void KDReports::TextDocumentData::saveResourcesToFiles()
{
Q_FOREACH (const QString &name, m_resourceNames) {
for (const QString &name : std::as_const(m_resourceNames)) {
const QVariant v = m_document.resource(QTextDocument::ImageResource, QUrl(name));
QPixmap pix = v.value<QPixmap>();
if (!pix.isNull()) {
Expand Down
5 changes: 2 additions & 3 deletions unittests/TextDocument/TextDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ private slots:
QTextTable *thirdTable = c.insertTable(1, 1);
thirdTable->firstCursorPosition().insertText("in table");
c.insertText("Foo");
QList<QTextTable *> origTables;
origTables << firstTable << secondTable << thirdTable;
const QList<QTextTable *> origTables = { firstTable, secondTable, thirdTable };

// A generic and slow solution is
// curs.currentTable() && !tablesFound.contains(curs.currentTable())
Expand Down Expand Up @@ -240,7 +239,7 @@ private slots:
QVERIFY(curs.currentTable());

// generic loop, works. This approach is in TextDocument::breakTables now.
Q_FOREACH (QTextTable *origTable, origTables) {
for (QTextTable *origTable : origTables) {
QTextCursor curs(clonedDoc);
curs.setPosition(origTable->firstCursorPosition().position());
tablesByPos.append(curs.currentTable());
Expand Down

0 comments on commit 0e49957

Please sign in to comment.