diff --git a/backend-shared/exportfuncs.cpp b/backend-shared/exportfuncs.cpp index d999d4f36..850d75c81 100644 --- a/backend-shared/exportfuncs.cpp +++ b/backend-shared/exportfuncs.cpp @@ -350,8 +350,8 @@ std::vector getDiveSitesToExport(bool selectedOnly) return res; } -QFuture exportUsingStyleSheet(QString filename, bool doExport, int units, - QString stylesheet, bool anonymize) +QFuture exportUsingStyleSheet(const QString &filename, bool doExport, int units, + const QString &stylesheet, bool anonymize) { return QtConcurrent::run(export_dives_xslt, filename.toUtf8(), doExport, units, stylesheet.toUtf8(), anonymize); } diff --git a/backend-shared/exportfuncs.h b/backend-shared/exportfuncs.h index 716a740e4..f705ae039 100644 --- a/backend-shared/exportfuncs.h +++ b/backend-shared/exportfuncs.h @@ -17,7 +17,7 @@ void exportProfile(QString filename, bool selected_only, ExportCallback &cb); void export_TeX(const char *filename, bool selected_only, bool plain, ExportCallback &cb); void export_depths(const char *filename, bool selected_only); std::vector getDiveSitesToExport(bool selectedOnly); -QFuture exportUsingStyleSheet(QString filename, bool doExport, int units, QString stylesheet, bool anonymize); +QFuture exportUsingStyleSheet(const QString &filename, bool doExport, int units, const QString &stylesheet, bool anonymize); // prepareDivesForUploadDiveLog // prepareDivesForUploadDiveShare diff --git a/commands/command_pictures.cpp b/commands/command_pictures.cpp index 604f7dfea..7230e847c 100644 --- a/commands/command_pictures.cpp +++ b/commands/command_pictures.cpp @@ -113,7 +113,7 @@ static std::vector addPictures(std::vector &dcs, const std::string &m, const std::stri return it - dcs.begin(); } else { dev.deviceId = calculate_string_hash(s.c_str()); - dcs.insert(it, dev); + it = dcs.insert(it, dev); return it - dcs.begin(); } } diff --git a/core/fulltext.cpp b/core/fulltext.cpp index f7d12d200..dccdba0b0 100644 --- a/core/fulltext.cpp +++ b/core/fulltext.cpp @@ -275,7 +275,7 @@ FullTextResult FullText::find(const FullTextQuery &q, StringFilterMode mode) con [&res2] (dive *d) { return std::find(res2.begin(), res2.end(), d) == res2.end(); }), res.end()); } - return { res }; + return { std::move(res) }; } FullTextQuery &FullTextQuery::operator=(const QString &s) diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index c90ac9f5f..decc7e56d 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -42,11 +42,11 @@ void ImageDownloader::saveImage(QNetworkReply *reply) QString filename = reply->request().attribute(QNetworkRequest::User).toString(); if (reply->error() != QNetworkReply::NoError) { - emit failed(filename); + emit failed(std::move(filename)); } else { QByteArray imageData = reply->readAll(); if (imageData.isEmpty()) { - emit failed(filename); + emit failed(std::move(filename)); } else { QString path = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first(); QDir dir(path); @@ -63,7 +63,7 @@ void ImageDownloader::saveImage(QNetworkReply *reply) imageFile.close(); learnPictureFilename(filename, imageFile.fileName()); } - emit loaded(filename); + emit loaded(std::move(filename)); } } @@ -353,7 +353,7 @@ Thumbnailer::Thumbnail Thumbnailer::addUnknownThumbnailToCache(const QString &pi void Thumbnailer::frameExtracted(QString filename, QImage thumbnail, duration_t duration, duration_t offset) { if (thumbnail.isNull()) { - frameExtractionFailed(filename, duration); + frameExtractionFailed(std::move(filename), duration); return; } else { int size = maxThumbnailSize(); diff --git a/core/parse-gpx.cpp b/core/parse-gpx.cpp index 67feae3c5..bf93a3101 100644 --- a/core/parse-gpx.cpp +++ b/core/parse-gpx.cpp @@ -8,7 +8,7 @@ // Find the coordinates at the time specified in coords.start_dive // by searching the gpx file "fileName". Here is a typical trkpt element in GPX: // -53.7 -int getCoordsFromGPXFile(struct dive_coords *coords, QString fileName) +int getCoordsFromGPXFile(struct dive_coords *coords, const QString &fileName) { struct tm tm1; time_t trkpt_time = 0; diff --git a/core/parse-gpx.h b/core/parse-gpx.h index 92be396ec..f3eb6368c 100644 --- a/core/parse-gpx.h +++ b/core/parse-gpx.h @@ -15,6 +15,6 @@ struct dive_coords { // This structure holds important information after int64_t timeZone_offset; // UTC international time zone offset of dive site }; -int getCoordsFromGPXFile(dive_coords *coords, QString fileName); +int getCoordsFromGPXFile(dive_coords *coords, const QString &fileName); #endif diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 77cb577ab..44aa27509 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -777,8 +777,8 @@ int parseDurationToSeconds(const QString &text) seconds = numOnly.right(numOnly.length() - minutes.length() - 1); } } else { - hours = "0"; - minutes = numOnly; + hours = QStringLiteral("0"); + minutes = std::move(numOnly); } secs = lrint(hours.toDouble() * 3600 + minutes.toDouble() * 60 + seconds.toDouble()); return secs; diff --git a/core/videoframeextractor.cpp b/core/videoframeextractor.cpp index 3f695a68c..9cf564afd 100644 --- a/core/videoframeextractor.cpp +++ b/core/videoframeextractor.cpp @@ -112,7 +112,7 @@ void VideoFrameExtractor::processItem(QString originalFilename, QString filename return fail(originalFilename, duration, true); } - emit extracted(originalFilename, img, duration, position); + emit extracted(originalFilename, std::move(img), duration, position); QMutexLocker l(&lock); workingOn.remove(originalFilename); } diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 864cd7afc..328df5c88 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -938,11 +938,12 @@ int DiveListView::lastImageTimeOffset() return offset; } -void DiveListView::updateLastImageTimeOffset(const int offset) +void DiveListView::updateLastImageTimeOffset(timestamp_t offset) { QSettings s; s.beginGroup("MainWindow"); - s.setValue("LastImageTimeOffset", offset); + // Can't create a QVariant from int64_t, for whatever reason. + s.setValue("LastImageTimeOffset", static_cast(offset)); } void DiveListView::mouseDoubleClickEvent(QMouseEvent*) diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index 3d6051035..5e7f854c2 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -73,7 +73,7 @@ private: void restoreExpandedRows(const std::vector &); int lastVisibleColumn(); void selectTrip(dive_trip *trip); - void updateLastImageTimeOffset(int offset); + void updateLastImageTimeOffset(timestamp_t offset); int lastImageTimeOffset(); void addToTrip(int delta); void matchImagesToDives(const QStringList &fileNames); diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp index faab2d6ad..cbfd323a7 100644 --- a/desktop-widgets/divelogimportdialog.cpp +++ b/desktop-widgets/divelogimportdialog.cpp @@ -326,7 +326,7 @@ void ColumnNameResult::setColumnValues(QList columns) endInsertColumns(); beginInsertRows(QModelIndex(), 0, columns.count()-1); - columnValues = columns; + columnValues = std::move(columns); endInsertRows(); } @@ -799,10 +799,11 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) } if (rows > 0) - resultModel->setColumnValues(fileColumns); - for (int i = 0; i < headers.count(); i++) + resultModel->setColumnValues(std::move(fileColumns)); + for (int i = 0; i < headers.count(); i++) { if (!headers.at(i).isEmpty()) resultModel->setData(resultModel->index(0, i),headers.at(i),Qt::EditRole); + } } void DiveLogImportDialog::setup_csv_params(QStringList r, xml_params ¶ms) diff --git a/desktop-widgets/divesiteimportdialog.cpp b/desktop-widgets/divesiteimportdialog.cpp index 2834eaf7e..66f003253 100644 --- a/desktop-widgets/divesiteimportdialog.cpp +++ b/desktop-widgets/divesiteimportdialog.cpp @@ -13,7 +13,7 @@ // Caller keeps ownership of "imported". The contents of "imported" will be consumed on execution of the dialog. // On return, it will be empty. DivesiteImportDialog::DivesiteImportDialog(struct dive_site_table &imported, QString source, QWidget *parent) : QDialog(parent), - importedSource(source) + importedSource(std::move(source)) { QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_W), this); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q), this); diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 7bbe669ff..5a57000d4 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1354,9 +1354,8 @@ void MainWindow::on_actionImportDiveLog_triggered() logFiles.append(fn); } - if (logFiles.size()) { + if (logFiles.size()) importFiles(logFiles); - } if (csvFiles.size()) { DiveLogImportDialog diveLogImport(std::move(csvFiles), this); @@ -1553,9 +1552,8 @@ void MainWindow::hideProgressBar() } } -void MainWindow::divesChanged(const QVector &dives, DiveField field) +void MainWindow::divesChanged(const QVector &dives, DiveField) { - Q_UNUSED(field) for (struct dive *d: dives) { qDebug() << "dive #" << d->number << "changed, cache is" << (dive_cache_is_valid(d) ? "valid" : "invalidated"); // a brute force way to deal with that would of course be to call diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index 466f50c8b..a0a84b66f 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -155,7 +155,7 @@ void TabDiveInformation::updateProfile() ui->diveTimeText->setText(get_dive_duration_string(currentDive->duration.seconds, tr("h"), tr("min"), tr("sec"), " ", currentDive->dc.divemode == FREEDIVE)); - ui->sacText->setText(currentDive->cylinders.nr > 0 && mean[0] && currentDive->dc.divemode != CCR ? SACs : QString()); + ui->sacText->setText(currentDive->cylinders.nr > 0 && mean[0] && currentDive->dc.divemode != CCR ? std::move(SACs) : QString()); if (currentDive->surface_pressure.mbar == 0) { ui->atmPressVal->clear(); // If no atm pressure for dive then clear text box diff --git a/desktop-widgets/tab-widgets/TabDiveNotes.cpp b/desktop-widgets/tab-widgets/TabDiveNotes.cpp index 5c52b632f..f96a76e4a 100644 --- a/desktop-widgets/tab-widgets/TabDiveNotes.cpp +++ b/desktop-widgets/tab-widgets/TabDiveNotes.cpp @@ -404,7 +404,7 @@ void TabDiveNotes::on_notes_editingFinished() return; QString html = ui.notes->toHtml(); - QString notes = isHtml(html) ? html : ui.notes->toPlainText(); + QString notes = isHtml(html) ? std::move(html) : ui.notes->toPlainText(); if (currentTrip) Command::editTripNotes(currentTrip, notes); diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index d3917d96b..f20846f66 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -15,6 +15,7 @@ CylindersModel::CylindersModel(bool planner, QObject *parent) : CleanerTableModel(parent), d(nullptr), + dcNr(-1), inPlanner(planner), numRows(0), tempRow(-1), diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp index 9abd16192..1d6c0f314 100644 --- a/qt-models/divepicturemodel.cpp +++ b/qt-models/divepicturemodel.cpp @@ -281,7 +281,7 @@ void DivePictureModel::updateThumbnail(QString filename, QImage thumbnail, durat addDurationToThumbnail(thumbnail, duration); // If we know the duration paint it on top of the thumbnail pictures[i].length = duration; } - pictures[i].image = thumbnail; + pictures[i].image = std::move(thumbnail); emit dataChanged(createIndex(i, 0), createIndex(i, 1)); } } @@ -295,7 +295,7 @@ void DivePictureModel::pictureOffsetChanged(dive *d, const QString filenameIn, o auto to = std::find_if(from, pictures.end(), [d](const PictureEntry &e) { return e.d != d; }); // Find picture with the given filename - auto oldPos = std::find_if(from, to, [filename](const PictureEntry &e) { return e.filename == filename; }); + auto oldPos = std::find_if(from, to, [&filename](const PictureEntry &e) { return e.filename == filename; }); if (oldPos == to) return; diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 001ad1b6f..69dcac695 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -1312,7 +1312,7 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) disclaimerBegin = disclaimer.left(disclaimerMid); disclaimerEnd = disclaimer.mid(disclaimerMid + 2); } else { - disclaimerBegin = disclaimer; + disclaimerBegin = std::move(disclaimer); } int disclaimerPositionStart = oldnotes.indexOf(disclaimerBegin); if (disclaimerPositionStart >= 0) { diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index e7ded819d..84e95099c 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -1386,7 +1386,7 @@ void DiveTripModelTree::divesSelectedSlot(const QVector &divesIn, dive * QVector indices; indices.reserve(dives.count()); - processByTrip(dives, [this, &indices] (dive_trip *trip, const QVector &divesInTrip) + processByTrip(std::move(dives), [this, &indices] (dive_trip *trip, const QVector &divesInTrip) { divesSelectedTrip(trip, divesInTrip, indices); }); emit divesSelected(indices, diveToIdx(currentDive), currentDC); diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index 8860217e9..1b45a45f0 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -22,14 +22,12 @@ static QString siteMapDisplayName(const char *sitename) const char Separator = '/'; QString fullname(sitename); - if (!qPrefDisplay::map_short_names() ) { + if (!qPrefDisplay::map_short_names() ) return fullname; - } QString name = fullname.section(Separator, -1).trimmed(); - if (name.isEmpty()) { - name = fullname; - } + if (name.isEmpty()) + name = std::move(fullname); return name; } diff --git a/stats/statsaxis.cpp b/stats/statsaxis.cpp index c4cc76ddb..2eaaee4b8 100644 --- a/stats/statsaxis.cpp +++ b/stats/statsaxis.cpp @@ -279,7 +279,7 @@ void ValueAxis::updateLabels() { QLocale loc; auto [minString, maxString] = getFirstLastLabel(); - int numTicks = guessNumTicks({ minString, maxString}); + int numTicks = guessNumTicks({ std::move(minString), std::move(maxString)}); // Use full decimal increments double height = max - min; diff --git a/stats/statsstate.cpp b/stats/statsstate.cpp index c89c0b4ab..34923a310 100644 --- a/stats/statsstate.cpp +++ b/stats/statsstate.cpp @@ -537,8 +537,9 @@ void StatsState::featureChanged(int id, bool state) // Creates the new chart-type from the current chart-type and a list of possible chart types. // If the flag "varChanged" is true, the current chart-type will be changed if the // current chart-type is undesired. -const ChartTypeDesc &newChartType(ChartType type, std::vector> charts, - bool varChanged) +static const ChartTypeDesc &newChartType(ChartType type, + const std::vector> &charts, + bool varChanged) { for (auto [desc, warn]: charts) { // Found it, but if the axis was changed, we change anyway if the chart is "undesired" diff --git a/stats/statsvariables.cpp b/stats/statsvariables.cpp index 9f67bd42c..bc08bfc5e 100644 --- a/stats/statsvariables.cpp +++ b/stats/statsvariables.cpp @@ -329,14 +329,14 @@ QString StatsVariable::nameWithUnit() const { QString s = name(); QString symb = unitSymbol(); - return symb.isEmpty() ? s : QStringLiteral("%1 [%2]").arg(s, symb); + return symb.isEmpty() ? std::move(s) : QStringLiteral("%1 [%2]").arg(s, symb); } QString StatsVariable::nameWithBinnerUnit(const StatsBinner &binner) const { QString s = name(); QString symb = binner.unitSymbol(); - return symb.isEmpty() ? s : QStringLiteral("%1 [%2]").arg(s, symb); + return symb.isEmpty() ? std::move(s) : QStringLiteral("%1 [%2]").arg(s, symb); } const StatsBinner *StatsVariable::getBinner(int idx) const @@ -551,7 +551,7 @@ std::vector> bin_convert(const StatsVariable &variable, const S T v = func(dives); if (is_invalid_value(v) && (res.empty() || !fill_empty)) continue; - res.push_back({ std::move(bin), v }); + res.push_back({ std::move(bin), std::move(v) }); } if (res.empty()) return res; diff --git a/stats/statsview.cpp b/stats/statsview.cpp index cc8064040..550bd8b7d 100644 --- a/stats/statsview.cpp +++ b/stats/statsview.cpp @@ -892,7 +892,7 @@ void StatsView::plotValueChart(const std::vector &dives, if (res.isValid()) { double height = res.get(valueAxisOperation); QString value = QString("%L1").arg(height, 0, 'f', decimals); - std::vector label = std::vector { value }; + std::vector label = std::vector { std::move(value) }; items.push_back({ pos - 0.5, pos + 0.5, height, label, categoryBinner->formatWithUnit(*bin), res }); } @@ -1080,7 +1080,7 @@ HistogramAxis *StatsView::createHistogramAxis(const QString &name, const StatsBi QString label = binner.formatLowerBound(*bin); double lowerBound = binner.lowerBoundToFloat(*bin); bool prefer = binner.preferBin(*bin); - labels.push_back({ label, lowerBound, prefer }); + labels.push_back({ std::move(label), lowerBound, prefer }); } const StatsBin &lastBin = *bins.back().bin; @@ -1129,7 +1129,7 @@ void StatsView::plotHistogramCountChart(const std::vector &dives, double upperBound = categoryBinner->upperBoundToFloat(*bin); std::vector label = makePercentageLabels((int)dives.size(), total, isHorizontal); - items.push_back({ lowerBound, upperBound, std::move(dives), label, + items.push_back({ lowerBound, upperBound, std::move(dives), std::move(label), categoryBinner->formatWithUnit(*bin), total }); }