forked from qt-creator/qt-creator
Reinvent deprecated qSort as Utils::sort
Change-Id: I4f6011cc2b6127037249aabc2426a88ad7108ebf Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "cpplocalsymbols.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -330,7 +331,7 @@ void CheckSymbols::run()
|
||||
_potentialFunctions = collectTypes.functions();
|
||||
_potentialStatics = collectTypes.statics();
|
||||
|
||||
qSort(_macroUses.begin(), _macroUses.end(), sortByLinePredicate);
|
||||
Utils::sort(_macroUses, sortByLinePredicate);
|
||||
_doc->clearDiagnosticMessages();
|
||||
|
||||
if (!isCanceled()) {
|
||||
@@ -1415,7 +1416,7 @@ void CheckSymbols::flush()
|
||||
if (_usages.isEmpty())
|
||||
return;
|
||||
|
||||
qSort(_usages.begin(), _usages.end(), sortByLinePredicate);
|
||||
Utils::sort(_usages, sortByLinePredicate);
|
||||
reportResults(_usages);
|
||||
int cap = _usages.capacity();
|
||||
_usages.clear();
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cpptools/cppprojectfile.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <cplusplus/Token.h>
|
||||
@@ -149,7 +150,7 @@ QString Utils::toString(const QList<ProjectFile> &projectFiles)
|
||||
QStringList filesList;
|
||||
foreach (const ProjectFile &projectFile, projectFiles)
|
||||
filesList << QDir::toNativeSeparators(projectFile.path);
|
||||
qSort(filesList);
|
||||
::Utils::sort(filesList);
|
||||
return filesList.join(QLatin1String("\n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "ui_cppcodemodelsettingspage.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
@@ -70,7 +71,7 @@ void CppCodeModelSettingsWidget::applyToWidget(QComboBox *chooser, const QString
|
||||
chooser->clear();
|
||||
|
||||
QStringList names = m_settings->availableModelManagerSupportersByName().keys();
|
||||
qSort(names);
|
||||
Utils::sort(names);
|
||||
foreach (const QString &name, names) {
|
||||
const QString &id = m_settings->availableModelManagerSupportersByName()[name];
|
||||
chooser->addItem(name, id);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <cplusplus/PreprocessorClient.h>
|
||||
#include <cplusplus/PreprocessorEnvironment.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QDir>
|
||||
@@ -51,9 +52,6 @@ using namespace Utils;
|
||||
|
||||
namespace {
|
||||
|
||||
bool includeLineLessThan(const Include &left, const Include &right)
|
||||
{ return left.line() < right.line(); }
|
||||
|
||||
bool includeFileNamelessThen(const Include & left, const Include & right)
|
||||
{ return left.unresolvedFileName() < right.unresolvedFileName(); }
|
||||
|
||||
@@ -293,7 +291,9 @@ QList<IncludeGroup> LineForNewIncludeDirective::getGroupsByIncludeType(
|
||||
QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByNewLines(QList<Document::Include> &includes)
|
||||
{
|
||||
// Sort by line
|
||||
qSort(includes.begin(), includes.end(), includeLineLessThan);
|
||||
Utils::sort(includes, [](const Include &left, const Include &right) {
|
||||
return left.line() < right.line();
|
||||
});
|
||||
|
||||
// Create groups
|
||||
QList<IncludeGroup> result;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <cplusplus/Overview.h>
|
||||
#include <cplusplus/SymbolVisitor.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QDir>
|
||||
@@ -48,12 +49,6 @@ Q_DECLARE_METATYPE(QList<Tests::TestDocument>)
|
||||
|
||||
namespace {
|
||||
|
||||
bool hierarchySorter(const TypeHierarchy &h1, const TypeHierarchy &h2)
|
||||
{
|
||||
Overview oo;
|
||||
return oo.prettyName(h1.symbol()->name()) < oo.prettyName(h2.symbol()->name());
|
||||
}
|
||||
|
||||
QString toString(const TypeHierarchy &hierarchy, int indent = 0)
|
||||
{
|
||||
Symbol *symbol = hierarchy.symbol();
|
||||
@@ -61,7 +56,10 @@ QString toString(const TypeHierarchy &hierarchy, int indent = 0)
|
||||
+ Overview().prettyName(symbol->name()) + QLatin1Char('\n');
|
||||
|
||||
QList<TypeHierarchy> sortedHierarchy = hierarchy.hierarchy();
|
||||
qSort(sortedHierarchy.begin(), sortedHierarchy.end(), hierarchySorter);
|
||||
Overview oo;
|
||||
Utils::sort(sortedHierarchy, [&oo](const TypeHierarchy &h1, const TypeHierarchy &h2) -> bool {
|
||||
return oo.prettyName(h1.symbol()->name()) < oo.prettyName(h2.symbol()->name());
|
||||
});
|
||||
foreach (TypeHierarchy childHierarchy, sortedHierarchy)
|
||||
result += toString(childHierarchy, indent + 2);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user