Fix Qt4 qAsConst
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Syping 2021-03-26 10:59:34 +01:00
parent 44ab5caedf
commit 04603af8ff
7 changed files with 53 additions and 9 deletions

View File

@ -93,6 +93,7 @@ set(GTA5VIEW_SOURCES
set(GTA5VIEW_HEADERS
config.h
wrapper.h
AboutDialog.h
AppEnv.h
CrewDatabase.h

View File

@ -240,8 +240,19 @@ void MapLocationDialog::mouseReleaseEvent(QMouseEvent *ev)
void MapLocationDialog::wheelEvent(QWheelEvent *ev)
{
#if QT_VERSION >= 0x050000
const QPoint numPixels = ev->pixelDelta();
const QPoint numDegrees = ev->angleDelta();
#else
QPoint numDegrees;
if (ev->orientation() == Qt::Horizontal) {
numDegrees.setX(ev->delta());
}
else {
numDegrees.setY(ev->delta());
}
#endif
#if QT_VERSION >= 0x050000
if (!numPixels.isNull()) {
if (numPixels.y() < 0 && zoomPercent != 100) {
zoomPercent = zoomPercent - 10;
@ -251,8 +262,10 @@ void MapLocationDialog::wheelEvent(QWheelEvent *ev)
zoomPercent = zoomPercent + 10;
repaint();
}
return;
}
else if (!numDegrees.isNull()) {
#endif
if (!numDegrees.isNull()) {
if (numDegrees.y() < 0 && zoomPercent != 100) {
zoomPercent = zoomPercent - 10;
repaint();

View File

@ -20,6 +20,7 @@
#include "SnapmaticPicture.h"
#include "SavegameData.h"
#include "CrewDatabase.h"
#include "wrapper.h"
#include <QStringBuilder>
#include <QStringList>
#include <QString>

View File

@ -837,8 +837,7 @@ void RagePhoto::uInt32ToCharLE(quint32 x, char *y)
const QByteArray RagePhoto::stringToUtf16LE(const QString &string)
{
#if QT_VERSION >= 0x060000
QStringEncoder stringEncoder = QStringEncoder(QStringEncoder::Utf16LE);
return stringEncoder(string);
return QStringEncoder(QStringEncoder::Utf16LE)(string);
#else
return QTextCodec::codecForName("UTF-16LE")->fromUnicode(string);
#endif
@ -847,8 +846,7 @@ const QByteArray RagePhoto::stringToUtf16LE(const QString &string)
const QString RagePhoto::utf16LEToString(const QByteArray &data)
{
#if QT_VERSION >= 0x060000
QStringDecoder stringDecoder = QStringDecoder(QStringDecoder::Utf16LE);
return stringDecoder(data);
return QStringDecoder(QStringDecoder::Utf16LE)(data);
#else
return QTextCodec::codecForName("UTF-16LE")->toUnicode(data);
#endif
@ -857,8 +855,7 @@ const QString RagePhoto::utf16LEToString(const QByteArray &data)
const QString RagePhoto::utf16LEToString(const char *data, int size)
{
#if QT_VERSION >= 0x060000
QStringDecoder stringDecoder = QStringDecoder(QStringDecoder::Utf16LE);
return stringDecoder(QByteArray::fromRawData(data, size));
return QStringDecoder(QStringDecoder::Utf16LE)(QByteArray::fromRawData(data, size));
#else
return QTextCodec::codecForName("UTF-16LE")->toUnicode(data, size);
#endif

View File

@ -21,6 +21,7 @@
#include "SnapmaticPicture.h"
#include "PlayerListDialog.h"
#include "StringParser.h"
#include "wrapper.h"
#include "AppEnv.h"
#include "config.h"
#include <QStringBuilder>
@ -405,7 +406,7 @@ void SnapmaticEditor::on_labCrew_linkActivated(const QString &link)
newCrew = newCrew.split(" ").at(0);
if (newCrew.length() > 10)
return;
for (const QChar &crewChar : newCrew) {
for (const QChar &crewChar : qAsConst(newCrew)) {
if (!crewChar.isNumber()) {
return;
}

View File

@ -25,7 +25,8 @@ DEPLOYMENT.display_name = gta5view
TARGET = gta5view
TEMPLATE = app
HEADERS += config.h
HEADERS += config.h \
wrapper.h
PRECOMPILED_HEADER += config.h
SOURCES += main.cpp \

30
wrapper.h Normal file
View File

@ -0,0 +1,30 @@
/*****************************************************************************
* gta5view Grand Theft Auto V Profile Viewer
* Copyright (C) 2021 Syping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef WRAPPER_H
#define WRAPPER_H
#if QT_VERSION < 0x050700
#if __cplusplus > 201703L
#define qAsConst(x) std::as_const(x)
#else
#define qAsConst
#endif
#endif
#endif // WRAPPER_H