mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-25 16:13:54 -07:00
remove dependency on deprecated qt5 libraries for qt6 (#4692)
* remove dependency on deprecated qt5 libraries for qt6 removes the use of qt6-5compat for builds replaces use of QRegExp with QRegularExpression fixes incorrect usage of QRegExp removes use of QTextCodec fixes incorrect usage of QTextCodec sets qtlinguist as a required component for qt6 * fix anchoredPattern not existing in qt 5.11
This commit is contained in:
parent
f619ef23fd
commit
dec2a252fa
18 changed files with 65 additions and 75 deletions
|
|
@ -7,7 +7,7 @@
|
|||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QUrlQuery>
|
||||
|
||||
DeckStatsInterface::DeckStatsInterface(CardDatabase &_cardDatabase, QObject *parent)
|
||||
|
|
@ -20,7 +20,7 @@ DeckStatsInterface::DeckStatsInterface(CardDatabase &_cardDatabase, QObject *par
|
|||
void DeckStatsInterface::queryFinished(QNetworkReply *reply)
|
||||
{
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
QMessageBox::critical(0, tr("Error"), reply->errorString());
|
||||
QMessageBox::critical(nullptr, tr("Error"), reply->errorString());
|
||||
reply->deleteLater();
|
||||
deleteLater();
|
||||
return;
|
||||
|
|
@ -29,14 +29,15 @@ void DeckStatsInterface::queryFinished(QNetworkReply *reply)
|
|||
QString data(reply->readAll());
|
||||
reply->deleteLater();
|
||||
|
||||
QRegExp rx("<meta property=\"og:url\" content=\"([^\"]+)\"");
|
||||
if (-1 == rx.indexIn(data)) {
|
||||
QMessageBox::critical(0, tr("Error"), tr("The reply from the server could not be parsed."));
|
||||
static const QRegularExpression rx("<meta property=\"og:url\" content=\"([^\"]+)\"");
|
||||
auto match = rx.match(data);
|
||||
if (!match.hasMatch()) {
|
||||
QMessageBox::critical(nullptr, tr("Error"), tr("The reply from the server could not be parsed."));
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
QString deckUrl = rx.cap(1);
|
||||
QString deckUrl = match.captured(1);
|
||||
QDesktopServices::openUrl(deckUrl);
|
||||
|
||||
deleteLater();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
#include <QLibraryInfo>
|
||||
#include <QLocale>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QTextCodec>
|
||||
#include <QTextStream>
|
||||
#include <QTranslator>
|
||||
#include <QtPlugin>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QUrlQuery>
|
||||
|
||||
|
|
@ -21,7 +20,7 @@ TappedOutInterface::TappedOutInterface(CardDatabase &_cardDatabase, QObject *par
|
|||
void TappedOutInterface::queryFinished(QNetworkReply *reply)
|
||||
{
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
QMessageBox::critical(0, tr("Error"), reply->errorString());
|
||||
QMessageBox::critical(nullptr, tr("Error"), reply->errorString());
|
||||
reply->deleteLater();
|
||||
deleteLater();
|
||||
return;
|
||||
|
|
@ -42,26 +41,26 @@ void TappedOutInterface::queryFinished(QNetworkReply *reply)
|
|||
* from the html. Css pseudo selector for errors: $("div.alert-danger > ul > li")
|
||||
*/
|
||||
QString data(reply->readAll());
|
||||
QString errorMessage = tr("Unable to analyze the deck.");
|
||||
QStringList errorMessageList = {tr("Unable to analyze the deck.")};
|
||||
|
||||
QRegExp rx("<div class=\"alert alert-danger.*<ul>(.*)</ul>");
|
||||
rx.setMinimal(true);
|
||||
int found = rx.indexIn(data);
|
||||
if (found >= 0) {
|
||||
QString errors = rx.cap(1);
|
||||
QRegExp rx2("<li>(.*)</li>");
|
||||
rx2.setMinimal(true);
|
||||
|
||||
int captures = rx2.captureCount();
|
||||
for (int i = 1; i <= captures; i++) {
|
||||
errorMessage += QString("\n") + rx2.cap(i).remove(QRegularExpression("<[^>]*>")).simplified();
|
||||
static const QRegularExpression rx("<div class=\"alert alert-danger.*?<ul>(.*?)</ul>");
|
||||
auto match = rx.match(data);
|
||||
if (match.hasMatch()) {
|
||||
QString errors = match.captured(1);
|
||||
static const QRegularExpression rx2("<li>(.*?)</li>");
|
||||
static const QRegularExpression rxremove("<[^>]*>");
|
||||
auto matchIterator = rx2.globalMatch(errors);
|
||||
while (matchIterator.hasNext()) {
|
||||
auto match2 = matchIterator.next();
|
||||
errorMessageList.append(match2.captured(1).remove(rxremove).simplified());
|
||||
}
|
||||
}
|
||||
|
||||
QString errorMessage = errorMessageList.join("\n");
|
||||
qDebug() << "Tappedout: bad reply, http status" << httpStatus << "size" << data.size() << "message"
|
||||
<< errorMessage;
|
||||
|
||||
QMessageBox::critical(0, tr("Error"), errorMessage);
|
||||
QMessageBox::critical(nullptr, tr("Error"), errorMessage);
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue