Fix warnings
This commit is contained in:
parent
6c12f18eaf
commit
f75966aadc
|
@ -11,7 +11,7 @@ set(META_APP_CATEGORIES "Network;FileTransfer")
|
|||
set(META_GUI_OPTIONAL false)
|
||||
set(META_VERSION_MAJOR 1)
|
||||
set(META_VERSION_MINOR 1)
|
||||
set(META_VERSION_PATCH 3)
|
||||
set(META_VERSION_PATCH 4)
|
||||
set(META_VERSION_EXACT_SONAME ON)
|
||||
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ static int statusCode = 0;
|
|||
|
||||
void exitApplication(int statusCode)
|
||||
{
|
||||
statusCode = ::Cli::statusCode;
|
||||
::Cli::statusCode = statusCode;
|
||||
terminated = true;
|
||||
}
|
||||
|
||||
|
@ -825,13 +825,13 @@ QByteArray Application::editConfigViaScript() const
|
|||
}
|
||||
} else if (m_args.jsLines.isPresent()) {
|
||||
// construct script from CLI arguments
|
||||
int requiredSize = 0;
|
||||
for (const auto *line : m_args.jsLines.values()) {
|
||||
requiredSize += strlen(line);
|
||||
auto requiredSize = QString::size_type(0);
|
||||
for (const auto *const line : m_args.jsLines.values()) {
|
||||
requiredSize += static_cast<QString::size_type>(std::strlen(line));
|
||||
requiredSize += 1;
|
||||
}
|
||||
script.reserve(requiredSize);
|
||||
for (const auto *line : m_args.jsLines.values()) {
|
||||
for (const auto *const line : m_args.jsLines.values()) {
|
||||
script += line;
|
||||
script += '\n';
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Cli {
|
|||
inline void printProperty(const char *propName, const char *value, const char *suffix = nullptr, CppUtilities::Indentation indentation = 3)
|
||||
{
|
||||
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) {
|
||||
std::cout << ' ' << suffix;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ void ApplicationTests::test()
|
|||
TESTUTILS_ASSERT_EXEC(catArgs);
|
||||
cout << stdout;
|
||||
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);
|
||||
const auto object(doc.object());
|
||||
CPPUNIT_ASSERT(object.value(QLatin1String("options")).isObject());
|
||||
|
|
|
@ -77,7 +77,7 @@ constexpr SyncthingCompletion &SyncthingCompletion::operator-=(const SyncthingCo
|
|||
|
||||
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
|
||||
|
|
|
@ -73,8 +73,8 @@ class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject {
|
|||
Q_PROPERTY(bool recordFileChanges READ recordFileChanges WRITE setRecordFileChanges)
|
||||
Q_PROPERTY(QString myId READ myId NOTIFY myIdChanged)
|
||||
Q_PROPERTY(QString configDir READ configDir NOTIFY configDirChanged)
|
||||
Q_PROPERTY(int totalIncomingTraffic READ totalIncomingTraffic NOTIFY trafficChanged)
|
||||
Q_PROPERTY(int totalOutgoingTraffic READ totalOutgoingTraffic NOTIFY trafficChanged)
|
||||
Q_PROPERTY(quint64 totalIncomingTraffic READ totalIncomingTraffic NOTIFY trafficChanged)
|
||||
Q_PROPERTY(quint64 totalOutgoingTraffic READ totalOutgoingTraffic NOTIFY trafficChanged)
|
||||
Q_PROPERTY(double totalIncomingRate READ totalIncomingRate NOTIFY trafficChanged)
|
||||
Q_PROPERTY(double totalOutgoingRate READ totalOutgoingRate NOTIFY trafficChanged)
|
||||
Q_PROPERTY(QString lastSyncedFile READ lastSyncedFile)
|
||||
|
|
|
@ -580,8 +580,8 @@ void SyncthingConnection::readDirs(const QJsonArray &dirs)
|
|||
dirItem->path = dirObj.value(QLatin1String("path")).toString();
|
||||
dirItem->deviceIds.clear();
|
||||
dirItem->deviceNames.clear();
|
||||
for (const QJsonValueRef dev : dirObj.value(QLatin1String("devices")).toArray()) {
|
||||
const QString devId = dev.toObject().value(QLatin1String("deviceID")).toString();
|
||||
for (const QJsonValueRef devObj : dirObj.value(QLatin1String("devices")).toArray()) {
|
||||
const QString devId = devObj.toObject().value(QLatin1String("deviceID")).toString();
|
||||
if (devId.isEmpty() || devId == m_myId) {
|
||||
continue;
|
||||
}
|
||||
|
@ -753,10 +753,10 @@ void SyncthingConnection::readConnections()
|
|||
const bool hasDelta
|
||||
= !m_lastConnectionsUpdate.isNull() && ((transferTime = (DateTime::gmtNow() - m_lastConnectionsUpdate).totalSeconds()) != 0.0);
|
||||
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;
|
||||
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;
|
||||
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 previouslyGlobal(globalStats);
|
||||
// read values from event data
|
||||
globalStats.bytes = jsonValueToInt(eventData.value(QLatin1String("globalBytes")), globalStats.bytes);
|
||||
neededStats.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), neededStats.bytes);
|
||||
neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), neededStats.deletes);
|
||||
neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needItems")), neededStats.files);
|
||||
globalStats.bytes = jsonValueToInt(eventData.value(QLatin1String("globalBytes")), static_cast<double>(globalStats.bytes));
|
||||
neededStats.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), static_cast<double>(neededStats.bytes));
|
||||
neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), static_cast<double>(neededStats.deletes));
|
||||
neededStats.deletes = jsonValueToInt(eventData.value(QLatin1String("needItems")), static_cast<double>(neededStats.files));
|
||||
dirInfo.lastStatisticsUpdate = eventTime;
|
||||
dirInfo.completionPercentage = globalStats.bytes ? static_cast<int>((globalStats.bytes - neededStats.bytes) * 100 / globalStats.bytes) : 100;
|
||||
emit dirStatusChanged(dirInfo, index);
|
||||
|
@ -2015,9 +2015,9 @@ void SyncthingConnection::readRemoteFolderCompletion(DateTime eventTime, const Q
|
|||
completion.lastUpdate = eventTime;
|
||||
completion.percentage = eventData.value(QLatin1String("completion")).toDouble();
|
||||
completion.globalBytes = jsonValueToInt(eventData.value(QLatin1String("globalBytes")));
|
||||
needed.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), needed.bytes);
|
||||
needed.items = jsonValueToInt(eventData.value(QLatin1String("needItems")), needed.items);
|
||||
needed.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), needed.deletes);
|
||||
needed.bytes = jsonValueToInt(eventData.value(QLatin1String("needBytes")), static_cast<double>(needed.bytes));
|
||||
needed.items = jsonValueToInt(eventData.value(QLatin1String("needItems")), static_cast<double>(needed.items));
|
||||
needed.deletes = jsonValueToInt(eventData.value(QLatin1String("needDeletes")), static_cast<double>(needed.deletes));
|
||||
|
||||
// update dir info
|
||||
if (dirInfo) {
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
QStringList things;
|
||||
things.reserve(objects.size());
|
||||
things.reserve(static_cast<QStringList::size_type>(objects.size()));
|
||||
for (const auto &object : objects) {
|
||||
things << accessor(object);
|
||||
}
|
||||
|
|
|
@ -248,6 +248,7 @@ QVariant SyncthingDeviceModel::data(const QModelIndex &index, int role) const
|
|||
case 1:
|
||||
return devStatusString(dev);
|
||||
}
|
||||
break;
|
||||
case Qt::DecorationRole:
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
|
|
|
@ -219,7 +219,6 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
case Qt::ForegroundRole:
|
||||
switch (index.column()) {
|
||||
case 1:
|
||||
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())];
|
||||
switch (row) {
|
||||
case 4:
|
||||
if (dir.deviceIds.isEmpty()) {
|
||||
|
@ -242,7 +241,6 @@ QVariant SyncthingDirectoryModel::data(const QModelIndex &index, int role) const
|
|||
case Qt::ToolTipRole:
|
||||
switch (index.column()) {
|
||||
case 1:
|
||||
const SyncthingDir &dir = m_dirs[static_cast<size_t>(index.parent().row())];
|
||||
switch (row) {
|
||||
case 3:
|
||||
if (dir.deviceNames.isEmpty()) {
|
||||
|
|
|
@ -123,7 +123,7 @@ template <typename SourceType> QPixmap renderSvgImage(const SourceType &source,
|
|||
#endif
|
||||
qGuiApp->devicePixelRatio();
|
||||
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());
|
||||
renderSize.scale(scaledSize.width() - margin, scaledSize.height() - margin, Qt::KeepAspectRatio);
|
||||
QRect renderBounds(QPoint(), scaledSize);
|
||||
|
|
|
@ -582,9 +582,9 @@ void TrayWidget::showRecentChangesContextMenu(const QPoint &position)
|
|||
}
|
||||
const auto copyRole = [this](SyncthingRecentChangesModel::SyncthingRecentChangesModelRole role) {
|
||||
return [this, role] {
|
||||
const auto *const selectionModel = m_ui->recentChangesTreeView->selectionModel();
|
||||
if (selectionModel && selectionModel->selectedRows().size() == 1) {
|
||||
QGuiApplication::clipboard()->setText(m_recentChangesModel.data(selectionModel->selectedRows().at(0), role).toString());
|
||||
const auto *const selectionModelToCopy = m_ui->recentChangesTreeView->selectionModel();
|
||||
if (selectionModelToCopy && selectionModelToCopy->selectedRows().size() == 1) {
|
||||
QGuiApplication::clipboard()->setText(m_recentChangesModel.data(selectionModelToCopy->selectedRows().at(0), role).toString());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -118,9 +118,9 @@ void DirectoryErrorsDialog::removeNonEmptyDirs()
|
|||
}
|
||||
QStringList removedDirs, failedDirs;
|
||||
for (const QString &dirPath : m_nonEmptyDirs) {
|
||||
bool ok = false;
|
||||
QDir dir(dirPath);
|
||||
if (!dir.exists() || !dir.removeRecursively()) {
|
||||
auto ok = false;
|
||||
auto dirObj = QDir(dirPath);
|
||||
if (!dirObj.exists() || !dirObj.removeRecursively()) {
|
||||
// check whether dir has already been removed by removing its parent
|
||||
for (const QString &removedDir : removedDirs) {
|
||||
if (dirPath.startsWith(removedDir)) {
|
||||
|
|
|
@ -120,18 +120,18 @@ void StatusInfo::updateConnectedDevices(const SyncthingConnection &connection)
|
|||
// get up to 2 device names
|
||||
const auto deviceCount = trQuandity(connectedDevices.size());
|
||||
const auto deviceNames = [&] {
|
||||
QStringList deviceNames;
|
||||
deviceNames.reserve(2);
|
||||
QStringList names;
|
||||
names.reserve(2);
|
||||
for (const auto *dev : connectedDevices) {
|
||||
if (dev->name.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
deviceNames << dev->name;
|
||||
if (deviceNames.size() > 2) {
|
||||
names << dev->name;
|
||||
if (names.size() > 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return deviceNames;
|
||||
return names;
|
||||
}();
|
||||
|
||||
// update status text
|
||||
|
|
|
@ -911,9 +911,9 @@ QWidget *LauncherOptionPage::setupWidget()
|
|||
}
|
||||
|
||||
// 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 }) {
|
||||
widget->setVisible(false);
|
||||
lstWidget->setVisible(false);
|
||||
}
|
||||
|
||||
// add "restore to defaults" action for Syncthing arguments
|
||||
|
|
Loading…
Reference in New Issue