Commit 670e5434 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Remove use of deprecated Qt algorithms



Change-Id: Ib35cffa2d5762874feea9b1d4df7f569c0e5f496
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent d4b3789d
......@@ -27,6 +27,8 @@
#include <QDebug>
#include <algorithm>
namespace QmlDesigner {
ChildrenChangedCommand::ChildrenChangedCommand()
......@@ -58,8 +60,8 @@ QVector<InformationContainer> ChildrenChangedCommand::informations() const
void ChildrenChangedCommand::sort()
{
qSort(m_childrenVector);
qSort(m_informationVector);
std::sort(m_childrenVector.begin(), m_childrenVector.end());
std::sort(m_informationVector.begin(), m_informationVector.end());
}
QDataStream &operator<<(QDataStream &out, const ChildrenChangedCommand &command)
......
......@@ -28,6 +28,8 @@
#include <QDataStream>
#include <QDebug>
#include <algorithm>
namespace QmlDesigner {
ComponentCompletedCommand::ComponentCompletedCommand()
......@@ -46,7 +48,7 @@ QVector<qint32> ComponentCompletedCommand::instances() const
void ComponentCompletedCommand::sort()
{
qSort(m_instanceVector);
std::sort(m_instanceVector.begin(), m_instanceVector.end());
}
QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command)
......
......@@ -30,6 +30,8 @@
#include "propertyvaluecontainer.h"
#include <algorithm>
namespace QmlDesigner {
InformationChangedCommand::InformationChangedCommand()
......@@ -48,7 +50,7 @@ QVector<InformationContainer> InformationChangedCommand::informations() const
void InformationChangedCommand::sort()
{
qSort(m_informationVector);
std::sort(m_informationVector.begin(), m_informationVector.end());
}
QDataStream &operator<<(QDataStream &out, const InformationChangedCommand &command)
......
......@@ -29,6 +29,8 @@
#include <QVarLengthArray>
#include <algorithm>
namespace QmlDesigner {
PixmapChangedCommand::PixmapChangedCommand()
......@@ -47,7 +49,7 @@ QVector<ImageContainer> PixmapChangedCommand::images() const
void PixmapChangedCommand::sort()
{
qSort(m_imageVector);
std::sort(m_imageVector.begin(), m_imageVector.end());
}
QDataStream &operator<<(QDataStream &out, const PixmapChangedCommand &command)
......
......@@ -27,6 +27,8 @@
#include <QDebug>
#include <algorithm>
namespace QmlDesigner {
StatePreviewImageChangedCommand::StatePreviewImageChangedCommand()
......@@ -45,7 +47,7 @@ QVector<ImageContainer> StatePreviewImageChangedCommand::previews()const
void StatePreviewImageChangedCommand::sort()
{
qSort(m_previewVector);
std::sort(m_previewVector.begin(), m_previewVector.end());
}
QDataStream &operator<<(QDataStream &out, const StatePreviewImageChangedCommand &command)
......
......@@ -28,6 +28,8 @@
#include <QDataStream>
#include <QDebug>
#include <algorithm>
namespace QmlDesigner {
TokenCommand::TokenCommand()
......@@ -59,7 +61,7 @@ QVector<qint32> TokenCommand::instances() const
void TokenCommand::sort()
{
qSort(m_instanceIdVector);
std::sort(m_instanceIdVector.begin(), m_instanceIdVector.end());
}
QDataStream &operator<<(QDataStream &out, const TokenCommand &command)
......
......@@ -31,6 +31,8 @@
#include <cstring>
#include <algorithm>
namespace QmlDesigner {
// using cache as a container which deletes sharedmemory pointers at process exit
......@@ -68,7 +70,7 @@ void ValuesChangedCommand::removeSharedMemorys(const QVector<qint32> &keyNumberV
void ValuesChangedCommand::sort()
{
qSort(m_valueChangeVector);
std::sort(m_valueChangeVector.begin(), m_valueChangeVector.end());
}
static const QLatin1String valueKeyTemplateString("Values-%1");
......
......@@ -275,11 +275,6 @@ using namespace ExtensionSystem::Internal;
static Internal::PluginManagerPrivate *d = 0;
static PluginManager *m_instance = 0;
static bool lessThanByPluginName(const PluginSpec *one, const PluginSpec *two)
{
return one->name() < two->name();
}
/*!
Gets the unique plugin manager instance.
*/
......@@ -588,7 +583,7 @@ static QStringList subList(const QStringList &in, const QString &key)
QStringList rc;
// Find keyword and copy arguments until end or next keyword
const QStringList::const_iterator inEnd = in.constEnd();
QStringList::const_iterator it = qFind(in.constBegin(), inEnd, key);
QStringList::const_iterator it = std::find(in.constBegin(), inEnd, key);
if (it != inEnd) {
const QChar nextIndicator = QLatin1Char(':');
for (++it; it != inEnd && !it->startsWith(nextIndicator); ++it)
......@@ -1468,7 +1463,7 @@ void PluginManagerPrivate::readPluginPaths()
}
resolveDependencies();
// ensure deterministic plugin load order by sorting
qSort(pluginSpecs.begin(), pluginSpecs.end(), lessThanByPluginName);
Utils::sort(pluginSpecs, &PluginSpec::name);
emit q->pluginsChanged();
}
......
......@@ -37,6 +37,8 @@
#include "qmt/diagram/dannotation.h"
#include "qmt/infrastructure/qmtassert.h"
#include <utils/algorithm.h>
#include <QSet>
#include <QDebug>
......@@ -292,7 +294,7 @@ const Style *DefaultStyleEngine::applyObjectStyle(const Style *baseStyle, const
int depth = 0;
if (!depths.isEmpty()) {
QList<int> keys = depths.keys();
qSort(keys);
Utils::sort(keys);
foreach (int d, keys) {
DepthProperties properties = depths.value(d);
if (properties.m_elementType == elementType
......
......@@ -34,6 +34,7 @@
#include "qmljsviewercontext.h"
#include <cplusplus/cppmodelmanagerbase.h>
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>
#include <utils/runextensions.h>
......@@ -439,9 +440,9 @@ void ModelManagerInterface::iterateQrcFiles(ProjectExplorer::Project *project,
} else {
pInfos = projectInfos();
if (resources == ActiveQrcResources) // make the result predictable
qSort(pInfos.begin(), pInfos.end(), &pInfoLessThanActive);
Utils::sort(pInfos, &pInfoLessThanActive);
else
qSort(pInfos.begin(), pInfos.end(), &pInfoLessThanAll);
Utils::sort(pInfos, &pInfoLessThanAll);
}
QSet<QString> pathsChecked;
......
......@@ -25,6 +25,8 @@
#include <qmljs/qmljsscanner.h>
#include <algorithm>
using namespace QmlJS;
namespace {
......@@ -410,10 +412,7 @@ int Scanner::state() const
bool Scanner::isKeyword(const QString &text) const
{
if (qBinaryFind(begin(js_keywords), end(js_keywords), text) != end(js_keywords))
return true;
return false;
return std::binary_search(begin(js_keywords), end(js_keywords), text);
}
QStringList Scanner::keywords()
......
......@@ -32,6 +32,8 @@
#include <QResizeEvent>
#include <QPainter>
#include <algorithm>
namespace Utils {
static const int ArrowBorderSize = 12;
......@@ -292,10 +294,8 @@ void CrumblePath::sortChildren(Qt::SortOrder order)
QTC_ASSERT(childList, return);
QList<QAction *> actions = childList->actions();
if (order == Qt::AscendingOrder)
qStableSort(actions.begin(), actions.end(), lessThan);
else
qStableSort(actions.begin(), actions.end(), greaterThan);
std::stable_sort(actions.begin(), actions.end(),
order == Qt::AscendingOrder ? lessThan : greaterThan);
childList->clear();
childList->addActions(actions);
......
......@@ -23,6 +23,7 @@
**
****************************************************************************/
#include "algorithm.h"
#include "environment.h"
#include <QDir>
......@@ -55,14 +56,9 @@ Q_GLOBAL_STATIC(SystemEnvironment, staticSystemEnvironment)
namespace Utils {
static bool sortEnvironmentItem(const EnvironmentItem &a, const EnvironmentItem &b)
{
return a.name < b.name;
}
void EnvironmentItem::sort(QList<EnvironmentItem> *list)
{
qSort(list->begin(), list->end(), &sortEnvironmentItem);
Utils::sort(*list, &EnvironmentItem::name);
}
QList<EnvironmentItem> EnvironmentItem::fromStringList(const QStringList &list)
......
......@@ -25,6 +25,7 @@
#include "fancymainwindow.h"
#include "algorithm.h"
#include "qtcassert.h"
#include <QAbstractButton>
......@@ -505,13 +506,6 @@ bool FancyMainWindow::autoHideTitleBars() const
return d->m_autoHideTitleBars.isChecked();
}
static bool actionLessThan(const QAction *action1, const QAction *action2)
{
QTC_ASSERT(action1, return true);
QTC_ASSERT(action2, return false);
return action1->text().toLower() < action2->text().toLower();
}
void FancyMainWindow::addDockActionsToMenu(QMenu *menu)
{
QList<QAction *> actions;
......@@ -523,7 +517,11 @@ void FancyMainWindow::addDockActionsToMenu(QMenu *menu)
actions.append(dockwidgets.at(i)->toggleViewAction());
}
}
qSort(actions.begin(), actions.end(), actionLessThan);
Utils::sort(actions, [](const QAction *action1, const QAction *action2) {
QTC_ASSERT(action1, return true);
QTC_ASSERT(action2, return false);
return action1->text().toLower() < action2->text().toLower();
});
foreach (QAction *action, actions)
menu->addAction(action);
menu->addAction(&d->m_menuSeparator1);
......
......@@ -409,16 +409,16 @@ void AndroidConfig::updateAvailableSdkPlatforms() const
} else if (line.startsWith(QLatin1String("---")) || line.startsWith(QLatin1String("==="))) {
if (platform.apiLevel == -1)
continue;
auto it = qLowerBound(m_availableSdkPlatforms.begin(), m_availableSdkPlatforms.end(),
platform, sortSdkPlatformByApiLevel);
auto it = std::lower_bound(m_availableSdkPlatforms.begin(), m_availableSdkPlatforms.end(),
platform, sortSdkPlatformByApiLevel);
m_availableSdkPlatforms.insert(it, platform);
platform = SdkPlatform();
}
}
if (platform.apiLevel != -1) {
auto it = qLowerBound(m_availableSdkPlatforms.begin(), m_availableSdkPlatforms.end(),
platform, sortSdkPlatformByApiLevel);
auto it = std::lower_bound(m_availableSdkPlatforms.begin(), m_availableSdkPlatforms.end(),
platform, sortSdkPlatformByApiLevel);
m_availableSdkPlatforms.insert(it, platform);
}
......
......@@ -67,6 +67,7 @@
#include <QCheckBox>
#include <QScrollArea>
#include <algorithm>
#include <limits>
using namespace ProjectExplorer;
......@@ -1337,7 +1338,8 @@ const QStringList &PermissionsModel::permissions()
QModelIndex PermissionsModel::addPermission(const QString &permission)
{
const int idx = qLowerBound(m_permissions, permission) - m_permissions.constBegin();
auto it = std::lower_bound(m_permissions.constBegin(), m_permissions.constEnd(), permission);
const int idx = it - m_permissions.constBegin();
beginInsertRows(QModelIndex(), idx, idx);
m_permissions.insert(idx, permission);
endInsertRows();
......@@ -1351,7 +1353,8 @@ bool PermissionsModel::updatePermission(const QModelIndex &index, const QString
if (m_permissions[index.row()] == permission)
return false;
int newIndex = qLowerBound(m_permissions.constBegin(), m_permissions.constEnd(), permission) - m_permissions.constBegin();
auto it = std::lower_bound(m_permissions.constBegin(), m_permissions.constEnd(), permission);
const int newIndex = it - m_permissions.constBegin();
if (newIndex == index.row() || newIndex == index.row() + 1) {
m_permissions[index.row()] = permission;
emit dataChanged(index, index);
......
......@@ -251,7 +251,7 @@ void NewDialog::setWizardFactories(QList<IWizardFactory *> factories,
{
m_defaultLocation = defaultLocation;
m_extraVariables = extraVariables;
qStableSort(factories.begin(), factories.end(), wizardFactoryLessThan);
std::stable_sort(factories.begin(), factories.end(), wizardFactoryLessThan);
m_model->clear();
QStandardItem *parentItem = m_model->invisibleRootItem();
......
......@@ -70,7 +70,7 @@ bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2)
static inline QList<IOptionsPage*> sortedOptionsPages()
{
QList<IOptionsPage*> rc = ExtensionSystem::PluginManager::getObjects<IOptionsPage>();
qStableSort(rc.begin(), rc.end(), optionsPageLessThan);
std::stable_sort(rc.begin(), rc.end(), optionsPageLessThan);
return rc;
}
......@@ -222,7 +222,7 @@ void CategoryModel::ensurePages(Category *category)
category->pages += createdPages;
category->providerPagesCreated = true;
qStableSort(category->pages.begin(), category->pages.end(), optionsPageLessThan);
std::stable_sort(category->pages.begin(), category->pages.end(), optionsPageLessThan);
}
}
......
......@@ -91,7 +91,7 @@ static bool lessThanByText(SearchResultTreeItem *a, const QString &b)
int SearchResultTreeItem::insertionIndex(const QString &text, SearchResultTreeItem **existingItem) const
{
QList<SearchResultTreeItem *>::const_iterator insertionPosition =
qLowerBound(m_children.begin(), m_children.end(), text, lessThanByText);
std::lower_bound(m_children.begin(), m_children.end(), text, lessThanByText);
if (existingItem) {
if (insertionPosition != m_children.end() && (*insertionPosition)->item.text == text)
(*existingItem) = (*insertionPosition);
......
......@@ -390,7 +390,7 @@ QList<QModelIndex> SearchResultTreeModel::addResults(const QList<SearchResultIte
{
QSet<SearchResultTreeItem *> pathNodes;
QList<SearchResultItem> sortedItems = items;
qStableSort(sortedItems.begin(), sortedItems.end(), lessThanByPath);
std::stable_sort(sortedItems.begin(), sortedItems.end(), lessThanByPath);
QList<SearchResultItem> itemSet;
foreach (const SearchResultItem &item, sortedItems) {
m_editorFontIsUsed |= item.useTextEditorFont;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment