Deal with recent Qt methods deprecation (#3801)

* Deal with recent Qt methods deprecation

 * Use std::sort, std::less instead of qSort/qLess
 * Use QFontMetrics::horizontalAdvance instead of ::width
 * Use qApp->primaryScreen() instead of QDesktopWidget
 * use lambas instead of QSignalMapper
 * Use QTreeWidgetItem::setForeground instead of ::setTextColor
 * Use QDir::setPath instead of operator=(QString)
 * Use QList::swapItemsAt instead of ::swap

* fix error
This commit is contained in:
ctrlaltca 2019-08-28 02:06:54 +02:00 committed by Zach H
parent f54165025e
commit b6df5a4ac3
17 changed files with 71 additions and 40 deletions

View file

@ -17,6 +17,8 @@
#include <QToolBar>
#include <QTreeView>
#include <algorithm>
#define SORT_RESET -1
WndSets::WndSets(QWidget *parent) : QMainWindow(parent)
@ -338,7 +340,7 @@ void WndSets::actDisableSome()
void WndSets::actUp()
{
QModelIndexList rows = view->selectionModel()->selectedRows();
qSort(rows.begin(), rows.end(), qLess<QModelIndex>());
std::sort(rows.begin(), rows.end(), std::less<QModelIndex>());
QSet<int> newRows;
if (rows.empty())
@ -360,7 +362,8 @@ void WndSets::actUp()
void WndSets::actDown()
{
QModelIndexList rows = view->selectionModel()->selectedRows();
qSort(rows.begin(), rows.end(), qGreater<QModelIndex>());
// QModelIndex only implements operator<, so we can't use std::greater
std::sort(rows.begin(), rows.end(), [](const QModelIndex &a, const QModelIndex &b) { return !(b < a); });
QSet<int> newRows;
if (rows.empty())
@ -382,7 +385,7 @@ void WndSets::actDown()
void WndSets::actTop()
{
QModelIndexList rows = view->selectionModel()->selectedRows();
qSort(rows.begin(), rows.end(), qLess<QModelIndex>());
std::sort(rows.begin(), rows.end(), std::less<QModelIndex>());
QSet<int> newRows;
int newRow = 0;
@ -407,7 +410,8 @@ void WndSets::actTop()
void WndSets::actBottom()
{
QModelIndexList rows = view->selectionModel()->selectedRows();
qSort(rows.begin(), rows.end(), qGreater<QModelIndex>());
// QModelIndex only implements operator<, so we can't use std::greater
std::sort(rows.begin(), rows.end(), [](const QModelIndex &a, const QModelIndex &b) { return !(b < a); });
QSet<int> newRows;
int newRow = model->rowCount() - 1;