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

@ -4,6 +4,7 @@
#include <QFile>
#include <QRegularExpression>
#include <QTextStream>
#include <algorithm>
#if QT_VERSION < 0x050600
// qHash on QRegularExpression was added in 5.6, FIX IT
@ -316,7 +317,7 @@ QVector<QPair<int, int>> InnerDecklistNode::sort(Qt::SortOrder order)
// Sort temporary list
compareFunctor cmp(order);
qSort(tempList.begin(), tempList.end(), cmp);
std::sort(tempList.begin(), tempList.end(), cmp);
// Map old indexes to new indexes and
// copy temporary list to the current one

View file

@ -59,7 +59,11 @@ void Server_CardZone::shuffle(int start, int end)
for (int i = end; i > start; i--) {
int j = rng->rand(start, i);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
cards.swapItemsAt(j, i);
#else
cards.swap(j, i);
#endif
}
playersWithWritePermission.clear();
}

View file

@ -84,6 +84,7 @@
#include "pb/context_undo_draw.pb.h"
#include <QDebug>
#include <algorithm>
Server_Player::Server_Player(Server_Game *_game,
int _playerId,
@ -409,7 +410,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges,
// 0 performs no sorting
// 1 reverses the sorting
MoveCardCompareFunctor cmp(0);
qSort(cardsToMove.begin(), cardsToMove.end(), cmp);
std::sort(cardsToMove.begin(), cardsToMove.end(), cmp);
bool secondHalf = false;
int xIndex = -1;