Fix warnings

This commit is contained in:
Martchus 2021-03-20 22:39:40 +01:00
parent 6c12f18eaf
commit f75966aadc
15 changed files with 38 additions and 39 deletions

View File

@ -11,7 +11,7 @@ set(META_APP_CATEGORIES "Network;FileTransfer")
set(META_GUI_OPTIONAL false) set(META_GUI_OPTIONAL false)
set(META_VERSION_MAJOR 1) set(META_VERSION_MAJOR 1)
set(META_VERSION_MINOR 1) set(META_VERSION_MINOR 1)
set(META_VERSION_PATCH 3) set(META_VERSION_PATCH 4)
set(META_VERSION_EXACT_SONAME ON) set(META_VERSION_EXACT_SONAME ON)
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)

View File

@ -47,7 +47,7 @@ static int statusCode = 0;
void exitApplication(int statusCode) void exitApplication(int statusCode)
{ {
statusCode = ::Cli::statusCode; ::Cli::statusCode = statusCode;
terminated = true; terminated = true;
} }
@ -825,13 +825,13 @@ QByteArray Application::editConfigViaScript() const
} }
} else if (m_args.jsLines.isPresent()) { } else if (m_args.jsLines.isPresent()) {
// construct script from CLI arguments // construct script from CLI arguments
int requiredSize = 0; auto requiredSize = QString::size_type(0);
for (const auto *line : m_args.jsLines.values()) { for (const auto *const line : m_args.jsLines.values()) {
requiredSize += strlen(line); requiredSize += static_cast<QString::size_type>(std::strlen(line));
requiredSize += 1; requiredSize += 1;
} }
script.reserve(requiredSize); script.reserve(requiredSize);
for (const auto *line : m_args.jsLines.values()) { for (const auto *const line : m_args.jsLines.values()) {
script += line; script += line;
script += '\n'; script += '\n';
} }

View File

@ -18,7 +18,7 @@ namespace Cli {
inline void printProperty(const char *propName, const char *value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3) inline void printProperty(const char *propName, const char *value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
{ {
if (*value) { if (*value) {
std::cout << indentation << propName << CppUtilities::Indentation(30 - strlen(propName)) << value; std::cout << indentation << propName << CppUtilities::Indentation(static_cast<unsigned char>(30 - strlen(propName))) << value;
if (suffix) { if (suffix) {
std::cout << ' ' << suffix; std::cout << ' ' << suffix;
} }

View File

@ -184,7 +184,7 @@ void ApplicationTests::test()
TESTUTILS_ASSERT_EXEC(catArgs); TESTUTILS_ASSERT_EXEC(catArgs);
cout << stdout; cout << stdout;
QJsonParseError error; QJsonParseError error;
const auto doc(QJsonDocument::fromJson(QByteArray(stdout.data(), stdout.size()), &error)); const auto doc(QJsonDocument::fromJson(QByteArray(stdout.data(), static_cast<QByteArray::size_type>(stdout.size())), &error));
CPPUNIT_ASSERT_EQUAL(QJsonParseError::NoError, error.error); CPPUNIT_ASSERT_EQUAL(QJsonParseError::NoError, error.error);
const auto object(doc.object()); const auto object(doc.object());
CPPUNIT_ASSERT(object.value(QLatin1String("options")).isObject()); CPPUNIT_ASSERT(object.value(QLatin1String("options")).isObject());

View File

@ -77,7 +77,7 @@ constexpr SyncthingCompletion &SyncthingCompletion::operator-=(const SyncthingCo
inline void SyncthingCompletion::recomputePercentage() inline void SyncthingCompletion::recomputePercentage()
{ {
percentage = (static_cast<double>(globalBytes - needed.bytes) / globalBytes) * 100.0; percentage = (static_cast<double>(globalBytes - needed.bytes) / static_cast<double>(globalBytes)) * 100.0;
} }
} // namespace Data } // namespace Data

View File

@ -73,8 +73,8 @@ class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject {
Q_PROPERTY(bool recordFileChanges READ recordFileChanges WRITE setRecordFileChanges) Q_PROPERTY(bool recordFileChanges READ recordFileChanges WRITE setRecordFileChanges)
Q_PROPERTY(QString myId READ myId NOTIFY myIdChanged) Q_PROPERTY(QString myId READ myId NOTIFY myIdChanged)
Q_PROPERTY(QString configDir READ configDir NOTIFY configDirChanged) Q_PROPERTY(QString configDir READ configDir NOTIFY configDirChanged)
Q_PROPERTY(int totalIncomingTraffic READ totalIncomingTraffic NOTIFY trafficChanged) Q_PROPERTY(quint64 totalIncomingTraffic READ totalIncomingTraffic NOTIFY trafficChanged)
Q_PROPERTY(int totalOutgoingTraffic READ totalOutgoingTraffic NOTIFY trafficChanged) Q_PROPERTY(quint64 totalOutgoingTraffic READ totalOutgoingTraffic NOTIFY trafficChanged)
Q_PROPERTY(double totalIncomingRate READ totalIncomingRate NOTIFY trafficChanged) Q_PROPERTY(double totalIncomingRate READ totalIncomingRate NOTIFY trafficChanged)
Q_PROPERTY(double totalOutgoingRate READ totalOutgoingRate NOTIFY trafficChanged) Q_PROPERTY(double totalOutgoingRate READ totalOutgoingRate NOTIFY trafficChanged)
Q_PROPERTY(QString lastSyncedFile READ lastSyncedFile) Q_PROPERTY(QString lastSyncedFile READ lastSyncedFile)

View File

@ -580,8 +580,8 @@ void SyncthingConnection::readDirs(const QJsonArray &dirs)
dirItem->path = dirObj.value(QLatin1String("path")).toString(); dirItem->path = dirObj.value(QLatin1String("path")).toString();
dirItem->deviceIds.clear(); dirItem->deviceIds.clear();
dirItem->deviceNames.clear(); dirItem->deviceNames.clear();
for (const QJsonValueRef dev : dirObj.value(QLatin1String("devices")).toArray()) { for (const QJsonValueRef devObj : dirObj.value(QLatin1String("devices")).toArray()) {
const QString devId = dev.toObject().value(QLatin1String("deviceID")).toString(); const QString devId = devObj.toObject().value(QLatin1String("deviceID")).toString();
if (devId.isEmpty() || devId == m_myId) { if (devId.isEmpty() || devId == m_myId) {
continue; continue;
} }
@ -753,10 +753,10 @@ void SyncthingConnection::readConnections()
const bool hasDelta const bool hasDelta
= !m_lastConnectionsUpdate.isNull() && ((transferTime = (DateTime::gmtNow() - m_lastConnectionsUpdate).totalSeconds()) != 0.0); = !m_lastConnectionsUpdate.isNull() && ((transferTime = (DateTime::gmtNow() - m_lastConnectionsUpdate).totalSeconds()) != 0.0);
m_totalIncomingRate = (hasDelta && totalIncomingTraffic != unknownTraffic && m_totalIncomingTraffic != unknownTraffic) m_totalIncomingRate = (hasDelta && totalIncomingTraffic != unknownTraffic && m_totalIncomingTraffic != unknownTraffic)
? (totalIncomingTraffic - m_totalIncomingTraffic) * 0.008 / transferTime ? static_cast<double>(totalIncomingTraffic - m_totalIncomingTraffic) * 0.008 / transferTime
: 0.0; : 0.0;
m_totalOutgoingRate = (hasDelta && totalOutgoingTraffic != unknownTraffic && m_totalOutgoingTraffic != unknownTraffic) m_totalOutgoingRate = (hasDelta && totalOutgoingTraffic != unknownTraffic && m_totalOutgoingTraffic != unknownTraffic)
? (totalOutgoingTraffic - m_totalOutgoingTraffic) * 0.008 / transferTime ? static_cast<double>(totalOutgoingTraffic - m_totalOutgoingTraffic) * 0.008 / transferTime
: 0.0; : 0.0;
emit trafficChanged(m_totalIncomingTraffic = totalIncomingTraffic, m_totalOutgoingTraffic = totalOutgoingTraffic); emit trafficChanged(m_totalIncomingTraffic = totalIncomingTraffic, m_totalOutgoingTraffic = totalOutgoingTraffic);
@ -1990,10 +1990,10 @@ void SyncthingConnection::readLocalFolderCompletion(DateTime eventTime, const QJ
const auto previouslyNeeded(neededStats); const auto previouslyNeeded(neededStats);
const auto previouslyGlobal(globalStats); const auto previouslyGlobal(globalStats);
// read values from event data // read values from event data
globalStats.bytes = jsonValueToInt(eventData.value(QLatin1String("globalBytes")), globalStats.bytes); globalStats.bytes = jsonValueToInt(eventData.value(QLatin1String("globalBytes")), static_cast<double>(globalStats.bytes));
neededStats.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), neededStats.bytes); neededStats.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), static_cast<double>(neededStats.bytes));
neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), neededStats.deletes); neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), static_cast<double>(neededStats.deletes));
neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needItems")), neededStats.files); neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needItems")), static_cast<double>(neededStats.files));
dirInfo.lastStatisticsUpdate = eventTime; dirInfo.lastStatisticsUpdate = eventTime;
dirInfo.completionPercentage = globalStats.bytes ? static_cast<int>((globalStats.bytes - neededStats.bytes) * 100 / globalStats.bytes) : 100; dirInfo.completionPercentage = globalStats.bytes ? static_cast<int>((globalStats.bytes - neededStats.bytes) * 100 / globalStats.bytes) : 100;
emit dirStatusChanged(dirInfo, index); emit dirStatusChanged(dirInfo, index);
@ -2015,9 +2015,9 @@ void SyncthingConnection::readRemoteFolderCompletion(DateTime eventTime, const Q
completion.lastUpdate = eventTime; completion.lastUpdate = eventTime;
completion.percentage = eventData.value(QLatin1String("completion")).toDouble(); completion.percentage = eventData.value(QLatin1String("completion")).toDouble();
completion.globalBytes = jsonValueToInt(eventData.value(QLatin1String("globalBytes"))); completion.globalBytes = jsonValueToInt(eventData.value(QLatin1String("globalBytes")));
needed.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), needed.bytes); needed.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), static_cast<double>(needed.bytes));
needed.items = jsonValueToInt(eventData.value(QLatin1String("needItems")), needed.items); needed.items = jsonValueToInt(eventData.value(QLatin1String("needItems")), static_cast<double>(needed.items));
needed.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), needed.deletes); needed.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), static_cast<double>(needed.deletes));
// update dir info // update dir info
if (dirInfo) { if (dirInfo) {

View File

@ -60,7 +60,7 @@ constexpr LIB_SYNCTHING_CONNECTOR_EXPORT int trQuandity(quint64 quandity)
template <class Objects, class Accessor> LIB_SYNCTHING_CONNECTOR_EXPORT QStringList things(const Objects &objects, Accessor accessor) template <class Objects, class Accessor> LIB_SYNCTHING_CONNECTOR_EXPORT QStringList things(const Objects &objects, Accessor accessor)
{ {
QStringList things; QStringList things;
things.reserve(objects.size()); things.reserve(static_cast<QStringList::size_type>(objects.size()));
for (const auto &object : objects) { for (const auto &object : objects) {
things << accessor(object); things << accessor(object);
} }

View File

@ -248,6 +248,7 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
case 1: case 1:
return devStatusString(dev); return devStatusString(dev);
} }
break;
case Qt::DecorationRole: case Qt::DecorationRole:
switch (index.column()) { switch (index.column()) {
case 0: case 0:

View File

@ -219,7 +219,6 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
case Qt::ForegroundRole: case Qt::ForegroundRole:
switch (index.column()) { switch (index.column()) {
case 1: case 1:
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())];
switch (row) { switch (row) {
case 4: case 4:
if (dir.deviceIds.isEmpty()) { if (dir.deviceIds.isEmpty()) {
@ -242,7 +241,6 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
case Qt::ToolTipRole: case Qt::ToolTipRole:
switch (index.column()) { switch (index.column()) {
case 1: case 1:
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())];
switch (row) { switch (row) {
case 3: case 3:
if (dir.deviceNames.isEmpty()) { if (dir.deviceNames.isEmpty()) {

View File

@ -123,7 +123,7 @@ template <typename SourceType> QPixmap renderSvgImage(const SourceType &source,
#endif #endif
qGuiApp->devicePixelRatio(); qGuiApp->devicePixelRatio();
QSvgRenderer renderer(source); QSvgRenderer renderer(source);
QSize scaledSize(givenSize.width() * scaleFactor, givenSize.height() * scaleFactor); QSize scaledSize(static_cast<int>(givenSize.width() * scaleFactor), static_cast<int>(givenSize.height() * scaleFactor));
QSize renderSize(renderer.defaultSize()); QSize renderSize(renderer.defaultSize());
renderSize.scale(scaledSize.width() - margin, scaledSize.height() - margin, Qt::KeepAspectRatio); renderSize.scale(scaledSize.width() - margin, scaledSize.height() - margin, Qt::KeepAspectRatio);
QRect renderBounds(QPoint(), scaledSize); QRect renderBounds(QPoint(), scaledSize);

View File

@ -582,9 +582,9 @@ void TrayWidget::showRecentChangesContextMenu(const QPoint &position)
} }
const auto copyRole = [this](SyncthingRecentChangesModel::SyncthingRecentChangesModelRole role) { const auto copyRole = [this](SyncthingRecentChangesModel::SyncthingRecentChangesModelRole role) {
return [this, role] { return [this, role] {
const auto *const selectionModel = m_ui->recentChangesTreeView->selectionModel(); const auto *const selectionModelToCopy = m_ui->recentChangesTreeView->selectionModel();
if (selectionModel && selectionModel->selectedRows().size() == 1) { if (selectionModelToCopy && selectionModelToCopy->selectedRows().size() == 1) {
QGuiApplication::clipboard()->setText(m_recentChangesModel.data(selectionModel->selectedRows().at(0), role).toString()); QGuiApplication::clipboard()->setText(m_recentChangesModel.data(selectionModelToCopy->selectedRows().at(0), role).toString());
} }
}; };
}; };

View File

@ -118,9 +118,9 @@ void DirectoryErrorsDialog::removeNonEmptyDirs()
} }
QStringList removedDirs, failedDirs; QStringList removedDirs, failedDirs;
for (const QString &dirPath : m_nonEmptyDirs) { for (const QString &dirPath : m_nonEmptyDirs) {
bool ok = false; auto ok = false;
QDir dir(dirPath); auto dirObj = QDir(dirPath);
if (!dir.exists() || !dir.removeRecursively()) { if (!dirObj.exists() || !dirObj.removeRecursively()) {
// check whether dir has already been removed by removing its parent // check whether dir has already been removed by removing its parent
for (const QString &removedDir : removedDirs) { for (const QString &removedDir : removedDirs) {
if (dirPath.startsWith(removedDir)) { if (dirPath.startsWith(removedDir)) {

View File

@ -120,18 +120,18 @@ void StatusInfo::updateConnectedDevices(const SyncthingConnection &connection)
// get up to 2 device names // get up to 2 device names
const auto deviceCount = trQuandity(connectedDevices.size()); const auto deviceCount = trQuandity(connectedDevices.size());
const auto deviceNames = [&] { const auto deviceNames = [&] {
QStringList deviceNames; QStringList names;
deviceNames.reserve(2); names.reserve(2);
for (const auto *dev : connectedDevices) { for (const auto *dev : connectedDevices) {
if (dev->name.isEmpty()) { if (dev->name.isEmpty()) {
continue; continue;
} }
deviceNames << dev->name; names << dev->name;
if (deviceNames.size() > 2) { if (names.size() > 2) {
break; break;
} }
} }
return deviceNames; return names;
}(); }();
// update status text // update status text

View File

@ -911,9 +911,9 @@ QWidget *LauncherOptionPage::setupWidget()
} }
// hide libsyncthing-controls by default (as the checkbox is unchecked by default) // hide libsyncthing-controls by default (as the checkbox is unchecked by default)
for (auto *const widget : std::initializer_list<QWidget *>{ ui()->configDirLabel, ui()->configDirPathSelection, ui()->dataDirLabel, for (auto *const lstWidget : std::initializer_list<QWidget *>{ ui()->configDirLabel, ui()->configDirPathSelection, ui()->dataDirLabel,
ui()->dataDirPathSelection, ui()->logLevelLabel, ui()->logLevelComboBox }) { ui()->dataDirPathSelection, ui()->logLevelLabel, ui()->logLevelComboBox }) {
widget->setVisible(false); lstWidget->setVisible(false);
} }
// add "restore to defaults" action for Syncthing arguments // add "restore to defaults" action for Syncthing arguments