From 94430883ad31aa545a3b6ee7e3e866f27f535e49 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 29 May 2020 18:04:31 +0200 Subject: [PATCH] Use Qt::endl with Qt 5.14 and higher --- src/playlistparsers/asxiniparser.cpp | 10 ++++++++-- src/playlistparsers/plsparser.cpp | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/playlistparsers/asxiniparser.cpp b/src/playlistparsers/asxiniparser.cpp index 880d1f64d..57f48e8e1 100644 --- a/src/playlistparsers/asxiniparser.cpp +++ b/src/playlistparsers/asxiniparser.cpp @@ -31,6 +31,12 @@ class CollectionBackendInterface; +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +# define qt_endl Qt::endl +#else +# define qt_endl std::endl +#endif + AsxIniParser::AsxIniParser(CollectionBackendInterface *collection, QObject *parent) : ParserBase(collection, parent) {} @@ -65,11 +71,11 @@ SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, con void AsxIniParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, Playlist::Path path_type) const { QTextStream s(device); - s << "[Reference]" << Qt::endl; + s << "[Reference]" << qt_endl; int n = 1; for (const Song &song : songs) { - s << "Ref" << n << "=" << URLOrFilename(song.url(), dir, path_type) << Qt::endl; + s << "Ref" << n << "=" << URLOrFilename(song.url(), dir, path_type) << qt_endl; ++n; } diff --git a/src/playlistparsers/plsparser.cpp b/src/playlistparsers/plsparser.cpp index 2598e9751..286b97deb 100644 --- a/src/playlistparsers/plsparser.cpp +++ b/src/playlistparsers/plsparser.cpp @@ -34,6 +34,12 @@ class CollectionBackendInterface; +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +# define qt_endl Qt::endl +#else +# define qt_endl std::endl +#endif + PLSParser::PLSParser(CollectionBackendInterface *collection, QObject *parent) : ParserBase(collection, parent) {} @@ -81,15 +87,15 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const void PLSParser::Save(const SongList &songs, QIODevice *device, const QDir &dir, Playlist::Path path_type) const { QTextStream s(device); - s << "[playlist]" << Qt::endl; - s << "Version=2" << Qt::endl; - s << "NumberOfEntries=" << songs.count() << Qt::endl; + s << "[playlist]" << qt_endl; + s << "Version=2" << qt_endl; + s << "NumberOfEntries=" << songs.count() << qt_endl; int n = 1; for (const Song &song : songs) { - s << "File" << n << "=" << URLOrFilename(song.url(), dir, path_type) << Qt::endl; - s << "Title" << n << "=" << song.title() << Qt::endl; - s << "Length" << n << "=" << song.length_nanosec() / kNsecPerSec << Qt::endl; + s << "File" << n << "=" << URLOrFilename(song.url(), dir, path_type) << qt_endl; + s << "Title" << n << "=" << song.title() << qt_endl; + s << "Length" << n << "=" << song.length_nanosec() / kNsecPerSec << qt_endl; ++n; }