From 912e62e92c9877db8d6f90312e3403ea8d6be2df Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 9 Feb 2023 16:43:00 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=98endl=E2=80=99=20is=20deprecated:=20Use?= =?UTF-8?q?=20Qt::endl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/valentina/core/vapplication.cpp | 4 --- src/libs/qmuparser/qmuparserbase.cpp | 4 --- src/libs/qmuparser/qmuparserdef.h | 10 ++++++ src/libs/vdxf/vdxfengine.h | 1 + src/libs/vmisc/backport/text.h | 44 +++++++++++++++++++++++++ src/libs/vmisc/qxtcsvmodel.cpp | 16 +++------ src/libs/vmisc/vmisc.pri | 1 + src/libs/vmisc/vmisc.qbs | 1 + src/libs/vobj/vobjengine.cpp | 26 +++------------ src/test/ValentinaTest/tst_dxf.cpp | 9 ++--- 10 files changed, 70 insertions(+), 46 deletions(-) create mode 100644 src/libs/vmisc/backport/text.h diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index ed5f50178..0e5d77cda 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -265,11 +265,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con vStdOut().flush(); vStdErr().flush(); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - (*VApplication::VApp()->LogFile()) << debugdate << endl; -#else (*VApplication::VApp()->LogFile()) << debugdate << Qt::endl; -#endif } if (isGuiThread) diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index fc3bdd9e6..e5c4246b0 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -1898,11 +1898,7 @@ void QmuParserBase::StackDump(const QStack &a_stVal, const QStack + ** @date 1 2, 2023 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentina project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2023 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ +#ifndef TEXT_H +#define TEXT_H + +#include +#include + +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +namespace Qt +{ +static auto endl = ::endl; +static auto flush = ::flush; +static auto dec = ::dec; +static auto SkipEmptyParts = QString::SkipEmptyParts; +} +#endif + +#endif // TEXT_H diff --git a/src/libs/vmisc/qxtcsvmodel.cpp b/src/libs/vmisc/qxtcsvmodel.cpp index 720e8e747..b688a7a64 100644 --- a/src/libs/vmisc/qxtcsvmodel.cpp +++ b/src/libs/vmisc/qxtcsvmodel.cpp @@ -45,6 +45,10 @@ #include "../vmisc/diagnostic.h" #endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +#include "backport/text.h" +#endif + class QxtCsvModelPrivate : public QxtPrivate { public: @@ -617,11 +621,7 @@ bool QxtCsvModel::toCSV(QIODevice* dest, QString &error, bool withHeader, QChar } data += qxt_addCsvQuotes(d_ptr.quoteMode, d_ptr.header.at(col)); } -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - stream << data << endl; -#else stream << data << Qt::endl; -#endif } for (row = 0; row < rows; ++row) { @@ -642,17 +642,9 @@ bool QxtCsvModel::toCSV(QIODevice* dest, QString &error, bool withHeader, QChar data += qxt_addCsvQuotes(d_ptr.quoteMode, QString()); } } -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - stream << data << endl; -#else stream << data << Qt::endl; -#endif } -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - stream << flush; -#else stream << Qt::flush; -#endif dest->close(); return true; } diff --git a/src/libs/vmisc/vmisc.pri b/src/libs/vmisc/vmisc.pri index 56429fc5c..2418b6e95 100644 --- a/src/libs/vmisc/vmisc.pri +++ b/src/libs/vmisc/vmisc.pri @@ -82,6 +82,7 @@ HEADERS += \ $$PWD/vmodifierkey.h \ $$PWD/typedef.h \ $$PWD/backport/qscopeguard.h \ + $$PWD/backport/text.h \ $$PWD/dialogs/dialogselectlanguage.h \ $$PWD/fpm/fixed.hpp \ $$PWD/fpm/math.hpp diff --git a/src/libs/vmisc/vmisc.qbs b/src/libs/vmisc/vmisc.qbs index 9fe506e73..a49bb94ec 100644 --- a/src/libs/vmisc/vmisc.qbs +++ b/src/libs/vmisc/vmisc.qbs @@ -106,6 +106,7 @@ VLib { files: [ "qoverload.h", "qscopeguard.h", + "text.h", ] } diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index a34786ad3..4b69bfbe1 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -49,6 +49,10 @@ #include "../vmisc/vmath.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +#include "../vmisc/backport/text.h" +#endif + class QPaintDevice; class QPixmap; class QPoint; @@ -130,13 +134,8 @@ bool VObjEngine::begin(QPaintDevice *pdev) } stream = QSharedPointer(new QTextStream(outputDevice.data())); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - *stream << "# Valentina OBJ File" << endl; - *stream << "# smart-pattern.com.ua/" << endl; -#else *stream << "# Valentina OBJ File" << Qt::endl; *stream << "# smart-pattern.com.ua/" << Qt::endl; -#endif return true; } @@ -176,11 +175,7 @@ void VObjEngine::drawPath(const QPainterPath &path) qint64 sq = Square(polygon); ++planeCount; -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - *stream << "o Plane." << QString("%1").arg(planeCount, 3, 10, QLatin1Char('0')) << endl; -#else *stream << "o Plane." << QString("%1").arg(planeCount, 3, 10, QLatin1Char('0')) << Qt::endl; -#endif quint32 num_points = 0; @@ -236,11 +231,7 @@ void VObjEngine::drawPath(const QPainterPath &path) } delaunay2d_release(res);//Don't forget release data -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - *stream << "s off" << endl; -#else *stream << "s off" << Qt::endl; -#endif } //--------------------------------------------------------------------------------------------------------------------- @@ -255,11 +246,7 @@ void VObjEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawM { *stream << QString(" %1").arg(static_cast(globalPointsCount) - pointCount + i + 1); } -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - *stream << endl; -#else *stream << Qt::endl; -#endif } //--------------------------------------------------------------------------------------------------------------------- @@ -282,13 +269,8 @@ void VObjEngine::drawPoints(const QPointF *points, int pointCount) qreal x = ((points[i].x() - 0)/qFloor(size.width()/2.0)) - 1.0; qreal y = (((points[i].y() - 0)/qFloor(size.width()/2.0)) - 1.0)*-1; -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - *stream << "v" << " " << QString::number(x, 'f', 6 ) << " " << QString::number(y, 'f', 6 ) << " " - << "0.000000" << endl; -#else *stream << "v" << " " << QString::number(x, 'f', 6 ) << " " << QString::number(y, 'f', 6 ) << " " << "0.000000" << Qt::endl; -#endif ++globalPointsCount; } } diff --git a/src/test/ValentinaTest/tst_dxf.cpp b/src/test/ValentinaTest/tst_dxf.cpp index d171c3983..743a5ad68 100644 --- a/src/test/ValentinaTest/tst_dxf.cpp +++ b/src/test/ValentinaTest/tst_dxf.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "tst_dxf.h" +#include #include #include "../vmisc/def.h" @@ -34,6 +35,10 @@ #include "../vdxf/dxfdef.h" #include "../vdxf/libdxfrw/intern/drw_textcodec.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +#include "../vmisc/backport/text.h" +#endif + namespace { //--------------------------------------------------------------------------------------------------------------------- @@ -59,11 +64,7 @@ TST_DXF::TST_DXF(QObject *parent) void TST_DXF::initTestCase() { QTextStream ts(stdout); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - ts << QStringLiteral("Available codecs:\n%2.").arg(AvailableCodecs().join(", "))<< endl; -#else ts << QStringLiteral("Available codecs:\n%2.").arg(AvailableCodecs().join(", "))<< Qt::endl; -#endif } //---------------------------------------------------------------------------------------------------------------------