‘endl’ is deprecated: Use Qt::endl

This commit is contained in:
Roman Telezhynskyi 2023-02-09 16:43:00 +02:00
parent 980b1b5837
commit 912e62e92c
10 changed files with 70 additions and 46 deletions

View File

@ -265,11 +265,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
vStdOut().flush(); vStdOut().flush();
vStdErr().flush(); vStdErr().flush();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
(*VApplication::VApp()->LogFile()) << debugdate << endl;
#else
(*VApplication::VApp()->LogFile()) << debugdate << Qt::endl; (*VApplication::VApp()->LogFile()) << debugdate << Qt::endl;
#endif
} }
if (isGuiThread) if (isGuiThread)

View File

@ -1898,11 +1898,7 @@ void QmuParserBase::StackDump(const QStack<token_type> &a_stVal, const QStack<to
} }
stOprt.pop(); stOprt.pop();
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
qDebug() << dec;
#else
qDebug() << Qt::dec; qDebug() << Qt::dec;
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -106,6 +106,16 @@ using qmusizetype = qsizetype;
using qmusizetype = int; using qmusizetype = int;
#endif #endif
#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
namespace qmu namespace qmu
{ {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -50,6 +50,7 @@ class DRW_Entity;
class dx_ifaceBlock; class dx_ifaceBlock;
class VLayoutPoint; class VLayoutPoint;
class DRW_Point; class DRW_Point;
class QTextCodec;
class VDxfEngine final : public QPaintEngine class VDxfEngine final : public QPaintEngine
{ {

View File

@ -0,0 +1,44 @@
/************************************************************************
**
** @file text.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://gitlab.com/smart-pattern/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef TEXT_H
#define TEXT_H
#include <QtGlobal>
#include <QString>
#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

View File

@ -45,6 +45,10 @@
#include "../vmisc/diagnostic.h" #include "../vmisc/diagnostic.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 5, 0) #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<QxtCsvModel> class QxtCsvModelPrivate : public QxtPrivate<QxtCsvModel>
{ {
public: 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)); 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; stream << data << Qt::endl;
#endif
} }
for (row = 0; row < rows; ++row) 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()); data += qxt_addCsvQuotes(d_ptr.quoteMode, QString());
} }
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
stream << data << endl;
#else
stream << data << Qt::endl; stream << data << Qt::endl;
#endif
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
stream << flush;
#else
stream << Qt::flush; stream << Qt::flush;
#endif
dest->close(); dest->close();
return true; return true;
} }

View File

@ -82,6 +82,7 @@ HEADERS += \
$$PWD/vmodifierkey.h \ $$PWD/vmodifierkey.h \
$$PWD/typedef.h \ $$PWD/typedef.h \
$$PWD/backport/qscopeguard.h \ $$PWD/backport/qscopeguard.h \
$$PWD/backport/text.h \
$$PWD/dialogs/dialogselectlanguage.h \ $$PWD/dialogs/dialogselectlanguage.h \
$$PWD/fpm/fixed.hpp \ $$PWD/fpm/fixed.hpp \
$$PWD/fpm/math.hpp $$PWD/fpm/math.hpp

View File

@ -106,6 +106,7 @@ VLib {
files: [ files: [
"qoverload.h", "qoverload.h",
"qscopeguard.h", "qscopeguard.h",
"text.h",
] ]
} }

View File

@ -49,6 +49,10 @@
#include "../vmisc/vmath.h" #include "../vmisc/vmath.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include "../vmisc/backport/text.h"
#endif
class QPaintDevice; class QPaintDevice;
class QPixmap; class QPixmap;
class QPoint; class QPoint;
@ -130,13 +134,8 @@ bool VObjEngine::begin(QPaintDevice *pdev)
} }
stream = QSharedPointer<QTextStream>(new QTextStream(outputDevice.data())); stream = QSharedPointer<QTextStream>(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 << "# Valentina OBJ File" << Qt::endl;
*stream << "# smart-pattern.com.ua/" << Qt::endl; *stream << "# smart-pattern.com.ua/" << Qt::endl;
#endif
return true; return true;
} }
@ -176,11 +175,7 @@ void VObjEngine::drawPath(const QPainterPath &path)
qint64 sq = Square(polygon); qint64 sq = Square(polygon);
++planeCount; ++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; *stream << "o Plane." << QString("%1").arg(planeCount, 3, 10, QLatin1Char('0')) << Qt::endl;
#endif
quint32 num_points = 0; quint32 num_points = 0;
@ -236,11 +231,7 @@ void VObjEngine::drawPath(const QPainterPath &path)
} }
delaunay2d_release(res);//Don't forget release data 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; *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<int>(globalPointsCount) - pointCount + i + 1); *stream << QString(" %1").arg(static_cast<int>(globalPointsCount) - pointCount + i + 1);
} }
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
*stream << endl;
#else
*stream << Qt::endl; *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 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; 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 ) << " " *stream << "v" << " " << QString::number(x, 'f', 6 ) << " " << QString::number(y, 'f', 6 ) << " "
<< "0.000000" << Qt::endl; << "0.000000" << Qt::endl;
#endif
++globalPointsCount; ++globalPointsCount;
} }
} }

View File

@ -27,6 +27,7 @@
*************************************************************************/ *************************************************************************/
#include "tst_dxf.h" #include "tst_dxf.h"
#include <QTextCodec>
#include <QtTest> #include <QtTest>
#include "../vmisc/def.h" #include "../vmisc/def.h"
@ -34,6 +35,10 @@
#include "../vdxf/dxfdef.h" #include "../vdxf/dxfdef.h"
#include "../vdxf/libdxfrw/intern/drw_textcodec.h" #include "../vdxf/libdxfrw/intern/drw_textcodec.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include "../vmisc/backport/text.h"
#endif
namespace namespace
{ {
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -59,11 +64,7 @@ TST_DXF::TST_DXF(QObject *parent)
void TST_DXF::initTestCase() void TST_DXF::initTestCase()
{ {
QTextStream ts(stdout); 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; ts << QStringLiteral("Available codecs:\n%2.").arg(AvailableCodecs().join(", "))<< Qt::endl;
#endif
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------