From 9010c97bfb341166f963090935a0694a7ac5e929 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Feb 2019 13:06:23 +0100 Subject: Fix deprecation warning about Qt algorithms in tool xmlpatterns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use std::sort and implement operator< for class QApplicationArgument, fixing: qapplicationargumentparser.cpp:301:7: warning: ‘template class qLess’ is deprecated [-Wdeprecated-declarations] from qapplicationargumentparser.cpp:29: qapplicationargumentparser.cpp: In member function ‘void QApplicationArgumentParserPrivate::displayHelp() const’: qapplicationargumentparser.cpp:337:15: warning: ‘void qSort(Container&) [with Container = QList]’ is deprecated: Use std::sort [-Wdeprecated-declarations] from qapplicationargumentparser.cpp:29: qapplicationargumentparser.cpp:356:19: warning: ‘void qSort(Container&) [with Container = QList]’ is deprecated: Use std::sort [-Wdeprecated-declarations] from qapplicationargumentparser.cpp:29: Change-Id: I63d8dd5a83f3478b2c70b5b288d9ddb3e5ad5a76 Reviewed-by: Mitch Curtis --- tools/xmlpatterns/qapplicationargument.cpp | 5 +++++ tools/xmlpatterns/qapplicationargument_p.h | 1 + tools/xmlpatterns/qapplicationargumentparser.cpp | 23 ++++------------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/tools/xmlpatterns/qapplicationargument.cpp b/tools/xmlpatterns/qapplicationargument.cpp index 92a8e9e..c0b672d 100644 --- a/tools/xmlpatterns/qapplicationargument.cpp +++ b/tools/xmlpatterns/qapplicationargument.cpp @@ -151,6 +151,11 @@ bool QApplicationArgument::operator==(const QApplicationArgument &other) const return name() == other.name(); } +bool QApplicationArgument::operator<(const QApplicationArgument &other) const +{ + return name() < other.name(); +} + /*! \fn qHash(const QApplicationArgument &); \internal diff --git a/tools/xmlpatterns/qapplicationargument_p.h b/tools/xmlpatterns/qapplicationargument_p.h index acdd075..aef216b 100644 --- a/tools/xmlpatterns/qapplicationargument_p.h +++ b/tools/xmlpatterns/qapplicationargument_p.h @@ -57,6 +57,7 @@ public: ~QApplicationArgument(); QApplicationArgument &operator=(const QApplicationArgument &other); bool operator==(const QApplicationArgument &other) const; + bool operator<(const QApplicationArgument &other) const; void setName(const QString &newName); QString name() const; diff --git a/tools/xmlpatterns/qapplicationargumentparser.cpp b/tools/xmlpatterns/qapplicationargumentparser.cpp index f441b93..8aaae31 100644 --- a/tools/xmlpatterns/qapplicationargumentparser.cpp +++ b/tools/xmlpatterns/qapplicationargumentparser.cpp @@ -40,6 +40,8 @@ #include "qapplicationargumentparser_p.h" +#include + QT_BEGIN_NAMESPACE /*! @@ -291,23 +293,6 @@ void QApplicationArgumentParserPrivate::displayVersion() const << endl; } -/*! - \internal - \relates QApplicationArgument - - qLess() functor for QApplicationArgument that considers the name. - */ -template<> -class qLess -{ -public: - inline bool operator()(const QApplicationArgument &o1, - const QApplicationArgument &o2) const - { - return o1.name().compare(o2.name()) < 0; - } -}; - void QApplicationArgumentParserPrivate::displayHelp() const { enum Constants @@ -334,7 +319,7 @@ void QApplicationArgumentParserPrivate::displayHelp() const /* Sort them, such that we get the nameless options at the end, and it * generally looks tidy. */ - qSort(args); + std::sort(args.begin(), args.end()); /* This is the basic approach: * Switches: @@ -353,7 +338,7 @@ void QApplicationArgumentParserPrivate::displayHelp() const int maxWidth = 0; QList nameless(declaredNamelessArguments); - qSort(nameless); + std::sort(nameless.begin(), nameless.end()); /* Note, here the nameless arguments appear last, but are sorted * with themselves. */ -- cgit v1.2.1