1
0
Fork 0

Fix some integer signed-ness warnings

This commit is contained in:
James Turner 2018-09-06 17:12:12 +02:00
parent 35c5be004f
commit e7f2c1439c
2 changed files with 23 additions and 23 deletions

View file

@ -302,14 +302,14 @@ QUrl QmlAircraftInfo::uri() const
return {};
}
int QmlAircraftInfo::numVariants() const
quint32 QmlAircraftInfo::numVariants() const
{
if (_item) {
// for on-disk, we don't count the primary item
return _item->variants.size() + 1;
return static_cast<quint32>(_item->variants.size() + 1);
} else if (_package) {
// whereas for packaged aircraft we do
return static_cast<int>(_package->variants().size());
return static_cast<quint32>(_package->variants().size());
}
return 0;
@ -519,16 +519,16 @@ QString QmlAircraftInfo::packageId() const
return {};
}
int QmlAircraftInfo::packageSize() const
quint64 QmlAircraftInfo::packageSize() const
{
if (_package) {
return static_cast<int>(_package->fileSizeBytes());
return _package->fileSizeBytes();
}
return 0;
}
int QmlAircraftInfo::downloadedBytes() const
quint64 QmlAircraftInfo::downloadedBytes() const
{
return _downloadBytes;
}
@ -634,7 +634,7 @@ void QmlAircraftInfo::setUri(QUrl u)
// we need to offset the variant index to allow for the different
// indexing schemes here (primary included) and in the cache (primary
// is not counted)
_variant = (vindex >= 0) ? vindex + 1 : 0;
_variant = (vindex >= 0) ? static_cast<quint32>(vindex + 1) : 0U;
} else if (u.scheme() == "package") {
auto ident = u.path().toStdString();
try {
@ -654,12 +654,12 @@ void QmlAircraftInfo::setUri(QUrl u)
emit downloadChanged();
}
void QmlAircraftInfo::setVariant(int variant)
void QmlAircraftInfo::setVariant(quint32 variant)
{
if (!_item && !_package)
return;
if ((variant < 0) || (variant >= numVariants())) {
if (variant >= numVariants()) {
qWarning() << Q_FUNC_INFO << uri() << "variant index out of range:" << variant;
return;
}
@ -725,7 +725,7 @@ PackageRef QmlAircraftInfo::packageRef() const
return _package;
}
void QmlAircraftInfo::setDownloadBytes(int bytes)
void QmlAircraftInfo::setDownloadBytes(quint64 bytes)
{
_downloadBytes = bytes;
emit downloadChanged();
@ -743,7 +743,7 @@ QStringList QmlAircraftInfo::variantNames() const
result.append(v->description);
}
} else if (_package) {
for (int vindex = 0; vindex < _package->variants().size(); ++vindex) {
for (quint32 vindex = 0; vindex < _package->variants().size(); ++vindex) {
if (_package->nameForVariant(vindex).empty()) {
qWarning() << Q_FUNC_INFO << "missing description for variant" << vindex;
}

View file

@ -23,10 +23,10 @@ class QmlAircraftInfo : public QObject
Q_OBJECT
Q_PROPERTY(QUrl uri READ uri WRITE setUri NOTIFY uriChanged)
Q_PROPERTY(int variant READ variant WRITE setVariant NOTIFY variantChanged)
Q_PROPERTY(quint32 variant READ variant WRITE setVariant NOTIFY variantChanged)
Q_PROPERTY(QVariantList previews READ previews NOTIFY infoChanged)
Q_PROPERTY(int numVariants READ numVariants NOTIFY infoChanged)
Q_PROPERTY(quint32 numVariants READ numVariants NOTIFY infoChanged)
Q_PROPERTY(QStringList variantNames READ variantNames NOTIFY infoChanged)
Q_PROPERTY(QString name READ name NOTIFY infoChanged)
@ -37,8 +37,8 @@ class QmlAircraftInfo : public QObject
Q_PROPERTY(QString pathOnDisk READ pathOnDisk NOTIFY infoChanged)
Q_PROPERTY(QString packageId READ packageId NOTIFY infoChanged)
Q_PROPERTY(int packageSize READ packageSize NOTIFY infoChanged)
Q_PROPERTY(int downloadedBytes READ downloadedBytes NOTIFY downloadChanged)
Q_PROPERTY(quint64 packageSize READ packageSize NOTIFY infoChanged)
Q_PROPERTY(quint64 downloadedBytes READ downloadedBytes NOTIFY downloadChanged)
Q_PROPERTY(bool isPackaged READ isPackaged NOTIFY infoChanged)
Q_PROPERTY(QVariant status READ status NOTIFY infoChanged)
@ -65,7 +65,7 @@ public:
QUrl uri() const;
int numVariants() const;
quint32 numVariants() const;
QString name() const;
QString description() const;
@ -82,15 +82,15 @@ public:
QUrl wikipediaUrl() const;
QString packageId() const;
int packageSize() const;
int downloadedBytes() const;
quint64 packageSize() const;
quint64 downloadedBytes() const;
QVariant status() const;
QString minimumFGVersion() const;
static QVariant packageAircraftStatus(simgear::pkg::PackageRef p);
int variant() const
quint32 variant() const
{
return _variant;
}
@ -99,7 +99,7 @@ public:
simgear::pkg::PackageRef packageRef() const;
void setDownloadBytes(int bytes);
void setDownloadBytes(quint64 bytes);
QStringList variantNames() const;
@ -130,13 +130,13 @@ signals:
void uriChanged();
void infoChanged();
void downloadChanged();
void variantChanged(int variant);
void variantChanged(quint32 variant);
public slots:
void setUri(QUrl uri);
void setVariant(int variant);
void setVariant(quint32 variant);
private:
AircraftItemPtr resolveItem() const;
@ -150,7 +150,7 @@ private:
simgear::pkg::PackageRef _package;
AircraftItemPtr _item;
quint32 _variant = 0;
int _downloadBytes = 0;
quint64 _downloadBytes = 0;
QScopedPointer<StatesModel> _statesModel;
/// if the aircraft is locally installed, this is the cached