diff options
Diffstat (limited to 'commands')
-rw-r--r-- | commands/command_base.h | 11 | ||||
-rw-r--r-- | commands/command_divelist.cpp | 2 | ||||
-rw-r--r-- | commands/command_edit.cpp | 13 |
3 files changed, 14 insertions, 12 deletions
diff --git a/commands/command_base.h b/commands/command_base.h index d805610e5..8c905d09a 100644 --- a/commands/command_base.h +++ b/commands/command_base.h @@ -139,6 +139,17 @@ // v.clear(v); // Reset the vector to zero length. If the elements weren't release()d, // // the pointed-to dives are freed with free_dive() +// Qt is making their containers a lot harder to integrate with std::vector +template<typename T> +QVector<T> stdToQt(const std::vector<T> &v) +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + return QVector<T>(v.begin(), v.end()); +#else + return QVector<T>::fromStdVector(v); +#endif +} + // We put everything in a namespace, so that we can shorten names without polluting the global namespace namespace Command { diff --git a/commands/command_divelist.cpp b/commands/command_divelist.cpp index c5322f709..0917f71e5 100644 --- a/commands/command_divelist.cpp +++ b/commands/command_divelist.cpp @@ -659,7 +659,7 @@ void ShiftTime::redoit() sort_dive_table(&trip->dives); // Keep the trip-table in order // Send signals - QVector<dive *> dives = QVector<dive *>::fromStdVector(diveList); + QVector<dive *> dives = stdToQt<dive *>(diveList); emit diveListNotifier.divesTimeChanged(timeChanged, dives); emit diveListNotifier.divesChanged(dives, DiveField::DATETIME); diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp index ae97594e4..96678996c 100644 --- a/commands/command_edit.cpp +++ b/commands/command_edit.cpp @@ -155,12 +155,7 @@ void EditBase<T>::undo() // Send signals. DiveField id = fieldId(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - emit diveListNotifier.divesChanged(QVector<dive *>(dives.begin(), dives.end()), id); -#else - emit diveListNotifier.divesChanged(QVector<dive *>::fromStdVector(dives), id); -#endif - + emit diveListNotifier.divesChanged(stdToQt<dive *>(dives), id); setSelection(selectedDives, current); } @@ -551,11 +546,7 @@ void EditTagsBase::undo() // Send signals. DiveField id = fieldId(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - emit diveListNotifier.divesChanged(QVector<dive *>(dives.begin(), dives.end()), id); -#else - emit diveListNotifier.divesChanged(QVector<dive *>::fromStdVector(dives), id); -#endif + emit diveListNotifier.divesChanged(stdToQt<dive *>(dives), id); setSelection(selectedDives, current); } |