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:
@@ -33,6 +33,7 @@
|
||||
#include "callgrindfunction.h"
|
||||
#include "callgrindcostitem.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QChar>
|
||||
@@ -68,23 +69,13 @@ public:
|
||||
QVector<const Function *> m_functions;
|
||||
};
|
||||
|
||||
struct SortFunctions {
|
||||
SortFunctions(int event)
|
||||
: m_event(event)
|
||||
{
|
||||
}
|
||||
bool operator()(const Function *left, const Function *right)
|
||||
{
|
||||
return left->inclusiveCost(m_event) > right->inclusiveCost(m_event);
|
||||
}
|
||||
int m_event;
|
||||
};
|
||||
|
||||
void DataModel::Private::updateFunctions()
|
||||
{
|
||||
if (m_data) {
|
||||
m_functions = m_data->functions(m_cycleDetection);
|
||||
qSort(m_functions.begin(), m_functions.end(), SortFunctions(m_event));
|
||||
Utils::sort(m_functions, [this](const Function *l, const Function *r) {
|
||||
return l->inclusiveCost(m_event) > r->inclusiveCost(m_event);
|
||||
});
|
||||
} else {
|
||||
m_functions.clear();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -116,11 +117,6 @@ static bool equalSuppression(const Error &error, const Error &suppressed)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sortIndizesReverse(const QModelIndex &l, const QModelIndex &r)
|
||||
{
|
||||
return l.row() > r.row();
|
||||
}
|
||||
|
||||
SuppressionDialog::SuppressionDialog(MemcheckErrorView *view, const QList<Error> &errors)
|
||||
: m_view(view),
|
||||
m_settings(view->settings()),
|
||||
@@ -224,7 +220,9 @@ void SuppressionDialog::accept()
|
||||
m_settings->addSuppressionFiles(QStringList(path));
|
||||
|
||||
QModelIndexList indices = m_view->selectionModel()->selectedRows();
|
||||
qSort(indices.begin(), indices.end(), sortIndizesReverse);
|
||||
Utils::sort(indices, [](const QModelIndex &l, const QModelIndex &r) {
|
||||
return l.row() > r.row();
|
||||
});
|
||||
QAbstractItemModel *model = m_view->model();
|
||||
foreach (const QModelIndex &index, indices) {
|
||||
bool removed = model->removeRow(index.row());
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "ui_valgrindconfigwidget.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -216,11 +217,6 @@ void ValgrindConfigWidget::slotSuppressionsAdded(const QStringList &files)
|
||||
m_model->appendRow(new QStandardItem(file));
|
||||
}
|
||||
|
||||
bool sortReverse(int l, int r)
|
||||
{
|
||||
return l > r;
|
||||
}
|
||||
|
||||
void ValgrindConfigWidget::slotRemoveSuppression()
|
||||
{
|
||||
// remove from end so no rows get invalidated
|
||||
@@ -232,7 +228,7 @@ void ValgrindConfigWidget::slotRemoveSuppression()
|
||||
removed << index.data().toString();
|
||||
}
|
||||
|
||||
qSort(rows.begin(), rows.end(), sortReverse);
|
||||
Utils::sort(rows, std::greater<int>());
|
||||
|
||||
foreach (int row, rows)
|
||||
m_model->removeRow(row);
|
||||
|
||||
Reference in New Issue
Block a user