diff --git a/.clang-tidy b/.clang-tidy index 13b8a5bda..07ffd5596 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,10 +3,45 @@ Checks: > -*, - modernize-use-auto, - modernize-use-override, - modernize-return-braced-init-list, + modernize-avoid-bind, + modernize-concat-nested-namespaces, + modernize-deprecated-headers, + modernize-deprecated-ios-base-aliases, modernize-loop-convert, + modernize-macro-to-enum, + modernize-make-shared, + modernize-make-unique, + modernize-min-max-use-initializer-list, + modernize-raw-string-literal, + modernize-redundant-void-arg, + modernize-replace-auto-ptr, + modernize-replace-disallow-copy-and-assign-macro, + modernize-replace-random-shuffle, + modernize-return-braced-init-list, + modernize-shrink-to-fit, + modernize-type-traits, + modernize-unary-static-assert, + modernize-use-auto, + modernize-use-bool-literals, + modernize-use-constraints, + modernize-use-default-member-init, + modernize-use-designated-initializers, + modernize-use-emplace, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-integer-sign-comparison, + modernize-use-noexcept, + modernize-use-nullptr, + modernize-use-override, + modernize-use-ranges, + modernize-use-scoped-lock, + modernize-use-starts-ends-with, + modernize-use-std-format, + modernize-use-std-numbers, + modernize-use-std-print, + modernize-use-transparent-functors, + modernize-use-uncaught-exceptions, + modernize-use-using, CheckOptions: diff --git a/scripts/run_static_analysis.py b/scripts/run_static_analysis.py index 76d11f73e..6d9122844 100644 --- a/scripts/run_static_analysis.py +++ b/scripts/run_static_analysis.py @@ -113,7 +113,7 @@ def run_clazy(build_path: str, changed_source_files: set[str]): '-p', build_path, "-extra-arg", "-Werror", "-extra-arg", "-Wno-unnecessary-virtual-specifier", - '--header-filter', '(config|core|gui|input|misc|plugins|sound|swiftcore|swiftdata|swiftguistandard|swiftlauncher|xswiftbus)/', + '--header-filter', f'{utils.get_swift_source_path()}/src/', *changed_source_files ], text=True, check=True) except CalledProcessError: diff --git a/src/core/context/contextnetworkimpl.cpp b/src/core/context/contextnetworkimpl.cpp index 4fdd059c4..12b0b337a 100644 --- a/src/core/context/contextnetworkimpl.cpp +++ b/src/core/context/contextnetworkimpl.cpp @@ -3,8 +3,6 @@ #include "core/context/contextnetworkimpl.h" -#include - #include #include diff --git a/src/core/context/contextsimulatorproxy.cpp b/src/core/context/contextsimulatorproxy.cpp index 8c69aa3b3..3f9dd1f8f 100644 --- a/src/core/context/contextsimulatorproxy.cpp +++ b/src/core/context/contextsimulatorproxy.cpp @@ -25,7 +25,7 @@ namespace swift::core::context { CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) - : IContextSimulator(mode, runtime), m_dBusInterface(nullptr) + : IContextSimulator(mode, runtime) { this->m_dBusInterface = new swift::misc::CGenericDBusInterface( serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), connection, this); diff --git a/src/core/inputmanager.cpp b/src/core/inputmanager.cpp index f8fed0a3b..a3092af02 100644 --- a/src/core/inputmanager.cpp +++ b/src/core/inputmanager.cpp @@ -3,7 +3,7 @@ #include "core/inputmanager.h" -#include +#include #include diff --git a/src/core/inputmanager.h b/src/core/inputmanager.h index 39f6391a3..25456c248 100644 --- a/src/core/inputmanager.h +++ b/src/core/inputmanager.h @@ -48,9 +48,11 @@ namespace swift::core template int bind(const QString &action, RecvObj *receiver, void (RecvObj::*slotPointer)(bool)) { + // NOLINTBEGIN(modernize-avoid-bind) using namespace std::placeholders; auto function = std::bind(slotPointer, receiver, _1); return bindImpl(action, receiver, function); + // NOLINTEND(modernize-avoid-bind) } //! Register a new hotkey function diff --git a/src/core/simulator.h b/src/core/simulator.h index 20d48f90e..5d6ab99fd 100644 --- a/src/core/simulator.h +++ b/src/core/simulator.h @@ -715,7 +715,7 @@ namespace swift::core protected: //! Default ctor - ISimulatorFactory() {} + ISimulatorFactory() {} // NOLINT(modernize-use-equals-default) }; } // namespace swift::core diff --git a/src/gui/components/atcbuttoncomponent.cpp b/src/gui/components/atcbuttoncomponent.cpp index b737b09c4..8ca9f2389 100644 --- a/src/gui/components/atcbuttoncomponent.cpp +++ b/src/gui/components/atcbuttoncomponent.cpp @@ -3,7 +3,7 @@ #include "atcbuttoncomponent.h" -#include +#include #include #include diff --git a/src/gui/components/rawfsdmessagescomponent.cpp b/src/gui/components/rawfsdmessagescomponent.cpp index 96a668ea8..81fdbe9d4 100644 --- a/src/gui/components/rawfsdmessagescomponent.cpp +++ b/src/gui/components/rawfsdmessagescomponent.cpp @@ -66,7 +66,7 @@ namespace swift::gui::components using namespace std::placeholders; QMetaObject::Connection c = sGui->getIContextNetwork()->connectRawFsdMessageSignal( - this, std::bind(&CRawFsdMessagesComponent::addFsdMessage, this, _1)); + this, [this](auto &&msg) { addFsdMessage(std::forward(msg)); }); if (!c) { ui->pte_RawFsdMessages->appendPlainText(QStringLiteral("Could not connect to raw FSD message.")); diff --git a/src/gui/components/settingstextmessagestyle.cpp b/src/gui/components/settingstextmessagestyle.cpp index 615eb281e..948fa593e 100644 --- a/src/gui/components/settingstextmessagestyle.cpp +++ b/src/gui/components/settingstextmessagestyle.cpp @@ -94,7 +94,7 @@ namespace swift::gui::components void CSettingsTextMessageStyle::replaceTableStyle(const QString &newTableStyle) { QString style = m_style; - thread_local const QRegularExpression re("table\\s*\\{.*\\}"); + thread_local const QRegularExpression re(R"(table\s*\{.*\})"); style.replace(re, newTableStyle); m_style = style; } @@ -112,7 +112,7 @@ namespace swift::gui::components bool CSettingsTextMessageStyle::changeFontSize(bool increase) { QString style = m_style; - thread_local const QRegularExpression re("table\\s*\\{.*:\\s*(\\d{1,2}).*\\}"); + thread_local const QRegularExpression re(R"(table\s*\{.*:\s*(\d{1,2}).*\})"); const QRegularExpressionMatch match = re.match(style); const QStringList matches = match.capturedTexts(); if (matches.size() != 2) { return false; } diff --git a/src/gui/guiutility.h b/src/gui/guiutility.h index 5cb585dfe..95166563a 100644 --- a/src/gui/guiutility.h +++ b/src/gui/guiutility.h @@ -318,7 +318,7 @@ namespace swift::gui private: //! No constructor, use static functions only - CGuiUtility() {} + CGuiUtility() {} // NOLINT(modernize-use-equals-default) static QWidget *s_mainApplicationWidget; }; diff --git a/src/gui/models/textmessagelistmodel.cpp b/src/gui/models/textmessagelistmodel.cpp index 3c4f26661..a944386ab 100644 --- a/src/gui/models/textmessagelistmodel.cpp +++ b/src/gui/models/textmessagelistmodel.cpp @@ -21,7 +21,7 @@ using namespace swift::misc::aviation; namespace swift::gui::models { CTextMessageListModel::CTextMessageListModel(TextMessageMode mode, QObject *parent) - : CListModelTimestampObjects("ModelTextMessageList", parent), m_textMessageMode(NotSet) + : CListModelTimestampObjects("ModelTextMessageList", parent) { this->setTextMessageMode(mode); diff --git a/src/gui/models/userlistmodel.cpp b/src/gui/models/userlistmodel.cpp index 6681d7e98..c10892c2a 100644 --- a/src/gui/models/userlistmodel.cpp +++ b/src/gui/models/userlistmodel.cpp @@ -17,8 +17,7 @@ using namespace swift::misc::aviation; namespace swift::gui::models { - CUserListModel::CUserListModel(UserMode userMode, QObject *parent) - : CListModelBase("ModelUserList", parent), m_userMode(NotSet) + CUserListModel::CUserListModel(UserMode userMode, QObject *parent) : CListModelBase("ModelUserList", parent) { this->setUserMode(userMode); diff --git a/src/misc/aviation/altitude.cpp b/src/misc/aviation/altitude.cpp index 6768ba780..cfde64d8b 100644 --- a/src/misc/aviation/altitude.cpp +++ b/src/misc/aviation/altitude.cpp @@ -374,7 +374,7 @@ namespace swift::misc::aviation const QRegularExpression &CAltitude::fpAltitudeRegExp() { thread_local const QRegularExpression re( - "([Ff][Ll]?\\d{2,3})|([Ss]\\d{2,4})|([Aa]\\d{2,3})|([Mm]\\d{2,4})|(\\d{3,5}(ft|m))"); + R"(([Ff][Ll]?\d{2,3})|([Ss]\d{2,4})|([Aa]\d{2,3})|([Mm]\d{2,4})|(\d{3,5}(ft|m)))"); return re; } diff --git a/src/misc/aviation/callsignobjectlist.h b/src/misc/aviation/callsignobjectlist.h index 4504e80f1..01cafb1b0 100644 --- a/src/misc/aviation/callsignobjectlist.h +++ b/src/misc/aviation/callsignobjectlist.h @@ -258,7 +258,7 @@ namespace swift::misc::aviation protected: //! Constructor - ICallsignObjectList() {} + ICallsignObjectList() {} // NOLINT(modernize-use-equals-default) //! Container const CONTAINER &container() const { return static_cast(*this); } diff --git a/src/misc/aviation/registermetadataaviation.cpp b/src/misc/aviation/registermetadataaviation.cpp index 5a13fb423..51b890cee 100644 --- a/src/misc/aviation/registermetadataaviation.cpp +++ b/src/misc/aviation/registermetadataaviation.cpp @@ -41,54 +41,50 @@ #include "misc/aviation/track.h" #include "misc/aviation/transponder.h" -namespace swift::misc +namespace swift::misc::aviation { - namespace aviation + void registerMetadata() { - void registerMetadata() - { - CAircraftEngine::registerMetadata(); - CAircraftEngineList::registerMetadata(); - CAircraftIcaoCode::registerMetadata(); - CAircraftIcaoCodeList::registerMetadata(); - CAircraftCategory::registerMetadata(); - CAircraftCategoryList::registerMetadata(); - CAircraftLights::registerMetadata(); - CAircraftParts::registerMetadata(); - CAircraftPartsList::registerMetadata(); - CAircraftSituation::registerMetadata(); - CAircraftSituationChange::registerMetadata(); - CAircraftSituationList::registerMetadata(); - CAircraftVelocity::registerMetadata(); - CAirlineIcaoCode::registerMetadata(); - CAirlineIcaoCodeList::registerMetadata(); - CAirportIcaoCode::registerMetadata(); - CAirport::registerMetadata(); - CAirportList::registerMetadata(); - CAltitude::registerMetadata(); - CAtcStation::registerMetadata(); - CAtcStationList::registerMetadata(); - CCallsign::registerMetadata(); - CCallsignSet::registerMetadata(); - CComSystem::registerMetadata(); - CSsrEquipment::registerMetadata(); - CComNavEquipment::registerMetadata(); - CWakeTurbulenceCategory::registerMetadata(); - CFlightPlan::registerMetadata(); - CFlightPlanAircraftInfo::registerMetadata(); - CFlightPlanList::registerMetadata(); - CSimBriefData::registerMetadata(); - CFlightPlanRemarks::registerMetadata(); - CHeading::registerMetadata(); - CInformationMessage::registerMetadata(); - CLivery::registerMetadata(); - CLiveryList::registerMetadata(); - CNavSystem::registerMetadata(); - CSelcal::registerMetadata(); - CTrack::registerMetadata(); - CTransponder::registerMetadata(); - COnGroundInfo::registerMetadata(); - } - } // namespace aviation - -} // namespace swift::misc + CAircraftEngine::registerMetadata(); + CAircraftEngineList::registerMetadata(); + CAircraftIcaoCode::registerMetadata(); + CAircraftIcaoCodeList::registerMetadata(); + CAircraftCategory::registerMetadata(); + CAircraftCategoryList::registerMetadata(); + CAircraftLights::registerMetadata(); + CAircraftParts::registerMetadata(); + CAircraftPartsList::registerMetadata(); + CAircraftSituation::registerMetadata(); + CAircraftSituationChange::registerMetadata(); + CAircraftSituationList::registerMetadata(); + CAircraftVelocity::registerMetadata(); + CAirlineIcaoCode::registerMetadata(); + CAirlineIcaoCodeList::registerMetadata(); + CAirportIcaoCode::registerMetadata(); + CAirport::registerMetadata(); + CAirportList::registerMetadata(); + CAltitude::registerMetadata(); + CAtcStation::registerMetadata(); + CAtcStationList::registerMetadata(); + CCallsign::registerMetadata(); + CCallsignSet::registerMetadata(); + CComSystem::registerMetadata(); + CSsrEquipment::registerMetadata(); + CComNavEquipment::registerMetadata(); + CWakeTurbulenceCategory::registerMetadata(); + CFlightPlan::registerMetadata(); + CFlightPlanAircraftInfo::registerMetadata(); + CFlightPlanList::registerMetadata(); + CSimBriefData::registerMetadata(); + CFlightPlanRemarks::registerMetadata(); + CHeading::registerMetadata(); + CInformationMessage::registerMetadata(); + CLivery::registerMetadata(); + CLiveryList::registerMetadata(); + CNavSystem::registerMetadata(); + CSelcal::registerMetadata(); + CTrack::registerMetadata(); + CTransponder::registerMetadata(); + COnGroundInfo::registerMetadata(); + } +} // namespace swift::misc::aviation \ No newline at end of file diff --git a/src/misc/cputime.cpp b/src/misc/cputime.cpp index 560dfc619..7f61796d8 100644 --- a/src/misc/cputime.cpp +++ b/src/misc/cputime.cpp @@ -8,7 +8,7 @@ #if defined(Q_OS_WIN32) # include #elif defined(Q_OS_UNIX) -# include +# include #endif namespace swift::misc diff --git a/src/misc/db/datastore.h b/src/misc/db/datastore.h index 1fd6c9b1c..d9bad5eba 100644 --- a/src/misc/db/datastore.h +++ b/src/misc/db/datastore.h @@ -132,7 +132,7 @@ namespace swift::misc protected: //! Constructor - IDatastoreObjectWithIntegerKey() {} + IDatastoreObjectWithIntegerKey() {} // NOLINT(modernize-use-equals-default) //! Constructor IDatastoreObjectWithIntegerKey(int key) : m_dbKey(key) {} @@ -224,7 +224,7 @@ namespace swift::misc protected: //! Constructor - IDatastoreObjectWithStringKey() {} + IDatastoreObjectWithStringKey() {} // NOLINT(modernize-use-equals-default) //! Constructor IDatastoreObjectWithStringKey(const QString &key) : m_dbKey(key) {} diff --git a/src/misc/dictionary.h b/src/misc/dictionary.h index 47a3d9573..5e22121e1 100644 --- a/src/misc/dictionary.h +++ b/src/misc/dictionary.h @@ -92,25 +92,25 @@ namespace swift::misc using impl_type = Impl; //! STL compatibility - typedef Key key_type; + using key_type = Key; //! STL compatibility - typedef Value value_type; + using value_type = Value; //! STL compatibility - typedef Value &reference; + using reference = Value &; //! STL compatibility - typedef const Value &const_reference; + using const_reference = Value &; //! STL compatibility - typedef typename Impl::size_type size_type; + using size_type = typename Impl::size_type; //! STL compatibility - typedef typename Impl::iterator iterator; + using iterator = typename Impl::iterator; //! STL compatibility - typedef typename Impl::const_iterator const_iterator; + using const_iterator = typename Impl::const_iterator; //! Return a copy containing only those elements for which the dictionary keys return true for a given //! predicate. diff --git a/src/misc/geo/coordinategeodetic.h b/src/misc/geo/coordinategeodetic.h index 5014e7834..4af8e99b9 100644 --- a/src/misc/geo/coordinategeodetic.h +++ b/src/misc/geo/coordinategeodetic.h @@ -25,7 +25,7 @@ SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::geo, CCoordinateGeodetic) -namespace swift::misc +namespace swift::misc // NOLINT(modernize-concat-nested-namespaces) { namespace geo { diff --git a/src/misc/geo/earthangle.cpp b/src/misc/geo/earthangle.cpp index 18a4de5c3..3a2075029 100644 --- a/src/misc/geo/earthangle.cpp +++ b/src/misc/geo/earthangle.cpp @@ -84,7 +84,7 @@ namespace swift::misc::geo } // http://www.regular-expressions.info/floatingpoint.html - thread_local const QRegularExpression rx("[+-]?\\d+(?:\\.\\d+)?"); + thread_local const QRegularExpression rx(R"([+-]?\d+(?:\.\d+)?)"); int deg = 0; int min = 0; double sec = 0.0; diff --git a/src/misc/geo/geoobjectlist.h b/src/misc/geo/geoobjectlist.h index 719a4430b..0cf44ad22 100644 --- a/src/misc/geo/geoobjectlist.h +++ b/src/misc/geo/geoobjectlist.h @@ -230,7 +230,7 @@ namespace swift::misc::geo protected: //! Constructor - IGeoObjectList() {} + IGeoObjectList() {} // NOLINT(modernize-use-equals-default) //! Container const CONTAINER &container() const { return static_cast(*this); } @@ -296,7 +296,7 @@ namespace swift::misc::geo protected: //! Constructor - IGeoObjectWithRelativePositionList() {} + IGeoObjectWithRelativePositionList() {} // NOLINT(modernize-use-equals-default) }; } // namespace swift::misc::geo diff --git a/src/misc/identifiable.h b/src/misc/identifiable.h index a1d8df043..baa672d8f 100644 --- a/src/misc/identifiable.h +++ b/src/misc/identifiable.h @@ -40,7 +40,7 @@ namespace swift::misc CIdentifiable(QObject *nameProvider); //! Construct without a name - CIdentifiable() {} + CIdentifiable() {} // NOLINT(modernize-use-equals-default) //! Destructor ~CIdentifiable(); diff --git a/src/misc/invoke.h b/src/misc/invoke.h index 87b526e87..ae9dcfbb4 100644 --- a/src/misc/invoke.h +++ b/src/misc/invoke.h @@ -48,7 +48,9 @@ namespace swift::misc::private_ns auto invokeMethod(T *object, F &&func, Ts &&...args) { const auto invoker = [](auto &&...x) { return private_ns::invokeSlot(std::forward(x)...); }; + // NOLINTBEGIN(modernize-avoid-bind) auto method = std::bind(invoker, std::forward(func), object, std::forward(args)...); + // NOLINTEND(modernize-avoid-bind) CPromise promise; QMetaObject::invokeMethod( object, [promise, method = std::move(method)]() mutable { promise.setResultFrom(std::move(method)); }); diff --git a/src/misc/iterator.h b/src/misc/iterator.h index 28a7ffec7..5066e5897 100644 --- a/src/misc/iterator.h +++ b/src/misc/iterator.h @@ -134,8 +134,8 @@ namespace swift::misc::Iterators }; //! The type returned by this iterator's arrow operator, which may be a pointer or a pointer-like wrapper object - using pointer = typename std::conditional, - std::remove_reference_t *, PointerWrapper>::type; + using pointer = std::conditional_t, + std::remove_reference_t *, PointerWrapper>; //! Constructor. TransformIterator(I iterator, F function) : m_iterator(iterator), m_function(function) {} diff --git a/src/misc/mixin/mixinmetatype.h b/src/misc/mixin/mixinmetatype.h index 413832eea..883ff1198 100644 --- a/src/misc/mixin/mixinmetatype.h +++ b/src/misc/mixin/mixinmetatype.h @@ -14,106 +14,103 @@ #include "misc/propertyindexref.h" #include "misc/variant.h" -namespace swift::misc +namespace swift::misc::mixin { - namespace mixin + /*! + * CRTP class template from which a derived class can inherit common methods dealing with the metatype of the + * class. + * + * \see SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE + */ + template + class MetaType { - /*! - * CRTP class template from which a derived class can inherit common methods dealing with the metatype of the - * class. - * - * \see SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE - */ - template - class MetaType - { - public: - //! Register metadata - static void registerMetadata(); + public: + //! Register metadata + static void registerMetadata(); - //! Returns the Qt meta type ID of this object - //! \remark for CVariant this returns the id of CVariant, not of the encapsulated object. - //! valueVariant.userType()` returns metatype of the contained object - int getMetaTypeId() const; + //! Returns the Qt meta type ID of this object + //! \remark for CVariant this returns the id of CVariant, not of the encapsulated object. + //! valueVariant.userType()` returns metatype of the contained object + int getMetaTypeId() const; - //! Class name - QString getClassName() const; + //! Class name + QString getClassName() const; - //! Returns true if this object is an instance of the class with the given meta type ID, or one of its - //! subclasses. - bool isA(int metaTypeId) const; + //! Returns true if this object is an instance of the class with the given meta type ID, or one of its + //! subclasses. + bool isA(int metaTypeId) const; - private: - const Derived *derived() const; - Derived *derived(); + private: + const Derived *derived() const; + Derived *derived(); - template - static bool baseIsA(const Base2 *base, int metaTypeId); - static bool baseIsA(const void *, int); - }; - - template - void MetaType::registerMetadata() - { - private_ns::MetaTypeHelper::maybeRegisterMetaType(); - } - - template - int MetaType::getMetaTypeId() const - { - return private_ns::MetaTypeHelper::maybeGetMetaTypeId(); - } - - template - QString MetaType::getClassName() const - { - return QMetaType(getMetaTypeId()).name(); - } - - template - bool MetaType::isA(int metaTypeId) const - { - if (metaTypeId == QMetaType::UnknownType) { return false; } - if (metaTypeId == getMetaTypeId()) { return true; } - return baseIsA(static_cast *>(derived()), metaTypeId); - } - - template - const Derived *MetaType::derived() const - { - return static_cast(this); - } - - template - Derived *MetaType::derived() - { - return static_cast(this); - } - - template template - bool MetaType::baseIsA(const Base2 *base, int metaTypeId) - { - return base->isA(metaTypeId); - } + static bool baseIsA(const Base2 *base, int metaTypeId); + static bool baseIsA(const void *, int); + }; - template - bool MetaType::baseIsA(const void *, int) - { - return false; - } + template + void MetaType::registerMetadata() + { + private_ns::MetaTypeHelper::maybeRegisterMetaType(); + } - /*! - * When a derived class and a base class both inherit from mixin::MetaType, - * the derived class uses this macro to disambiguate the inherited members. - */ + template + int MetaType::getMetaTypeId() const + { + return private_ns::MetaTypeHelper::maybeGetMetaTypeId(); + } + + template + QString MetaType::getClassName() const + { + return QMetaType(getMetaTypeId()).name(); + } + + template + bool MetaType::isA(int metaTypeId) const + { + if (metaTypeId == QMetaType::UnknownType) { return false; } + if (metaTypeId == getMetaTypeId()) { return true; } + return baseIsA(static_cast *>(derived()), metaTypeId); + } + + template + const Derived *MetaType::derived() const + { + return static_cast(this); + } + + template + Derived *MetaType::derived() + { + return static_cast(this); + } + + template + template + bool MetaType::baseIsA(const Base2 *base, int metaTypeId) + { + return base->isA(metaTypeId); + } + + template + bool MetaType::baseIsA(const void *, int) + { + return false; + } + + /*! + * When a derived class and a base class both inherit from mixin::MetaType, + * the derived class uses this macro to disambiguate the inherited members. + */ #define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED) \ using ::swift::misc::mixin::MetaType::registerMetadata; \ using ::swift::misc::mixin::MetaType::getMetaTypeId; \ using ::swift::misc::mixin::MetaType::getClassName; \ using ::swift::misc::mixin::MetaType::isA; - } // namespace mixin -} // namespace swift::misc +} // namespace swift::misc::mixin #endif // SWIFT_MISC_MIXIN_MIXINMETATYPE_H diff --git a/src/misc/network/clientprovider.cpp b/src/misc/network/clientprovider.cpp index 37d57a783..84c7017e4 100644 --- a/src/misc/network/clientprovider.cpp +++ b/src/misc/network/clientprovider.cpp @@ -124,7 +124,7 @@ namespace swift::misc::network bool CClientProvider::setClientGndCapability(const CCallsign &callsign, bool supportGndFlag) { SWIFT_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "Missing client callsign"); - if (callsign.isEmpty()) { return 0; } + if (callsign.isEmpty()) { return false; } CClient client = this->getClientOrDefaultForCallsign(callsign); diff --git a/src/misc/network/clientprovider.h b/src/misc/network/clientprovider.h index a4a011642..674eb2c32 100644 --- a/src/misc/network/clientprovider.h +++ b/src/misc/network/clientprovider.h @@ -157,7 +157,7 @@ namespace swift::misc protected: //! Default constructor - CClientAware() {} + CClientAware() {} // NOLINT(modernize-use-equals-default) //! Constructor CClientAware(IClientProvider *clientProvider) : IProviderAware(clientProvider) {} diff --git a/src/misc/network/networkutils.h b/src/misc/network/networkutils.h index 3f154f49d..05acf3d5f 100644 --- a/src/misc/network/networkutils.h +++ b/src/misc/network/networkutils.h @@ -138,7 +138,7 @@ namespace swift::misc::network private: //! Hidden constructor - CNetworkUtils() {} + CNetworkUtils() {} // NOLINT(modernize-use-equals-default) }; } // namespace swift::misc::network diff --git a/src/misc/network/registermetadatanetwork.cpp b/src/misc/network/registermetadatanetwork.cpp index 8c86bc72f..42f79de1b 100644 --- a/src/misc/network/registermetadatanetwork.cpp +++ b/src/misc/network/registermetadatanetwork.cpp @@ -31,41 +31,37 @@ #include "misc/network/userlist.h" #include "misc/network/voicecapabilities.h" -namespace swift::misc +namespace swift::misc::network { - namespace network + void registerMetadata() { - void registerMetadata() - { - CAuthenticatedUser::registerMetadata(); - CConnectionStatus::registerMetadata(); - CClient::registerMetadata(); - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - CClientList::registerMetadata(); - CEcosystem::registerMetadata(); - CEcosystemList::registerMetadata(); - CEntityFlags::registerMetadata(); - CFacilityType::registerMetadata(); - CFsdSetup::registerMetadata(); - CLoginMode::registerMetadata(); - CRawFsdMessage::registerMetadata(); - CRawFsdMessageList::registerMetadata(); - CRemoteFile::registerMetadata(); - CRemoteFileList::registerMetadata(); - CRole::registerMetadata(); - CRoleList::registerMetadata(); - CServer::registerMetadata(); - CServerList::registerMetadata(); - CTextMessage::registerMetadata(); - CTextMessageList::registerMetadata(); - CUrl::registerMetadata(); - CUrlLog::registerMetadata(); - CUrlLogList::registerMetadata(); - CUser::registerMetadata(); - CUserList::registerMetadata(); - CVoiceCapabilities::registerMetadata(); - } - } // namespace network - -} // namespace swift::misc + CAuthenticatedUser::registerMetadata(); + CConnectionStatus::registerMetadata(); + CClient::registerMetadata(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + CClientList::registerMetadata(); + CEcosystem::registerMetadata(); + CEcosystemList::registerMetadata(); + CEntityFlags::registerMetadata(); + CFacilityType::registerMetadata(); + CFsdSetup::registerMetadata(); + CLoginMode::registerMetadata(); + CRawFsdMessage::registerMetadata(); + CRawFsdMessageList::registerMetadata(); + CRemoteFile::registerMetadata(); + CRemoteFileList::registerMetadata(); + CRole::registerMetadata(); + CRoleList::registerMetadata(); + CServer::registerMetadata(); + CServerList::registerMetadata(); + CTextMessage::registerMetadata(); + CTextMessageList::registerMetadata(); + CUrl::registerMetadata(); + CUrlLog::registerMetadata(); + CUrlLogList::registerMetadata(); + CUser::registerMetadata(); + CUserList::registerMetadata(); + CVoiceCapabilities::registerMetadata(); + } +} // namespace swift::misc::network \ No newline at end of file diff --git a/src/misc/optional.h b/src/misc/optional.h index 3a3688980..d24195286 100644 --- a/src/misc/optional.h +++ b/src/misc/optional.h @@ -117,8 +117,8 @@ namespace swift::misc } union Data { - Data() {} - ~Data() {} + Data() {} // NOLINT(modernize-use-equals-default) + ~Data() {} // NOLINT(modernize-use-equals-default) char bytes[sizeof(T)]; T object; }; diff --git a/src/misc/pq/measurementunit.h b/src/misc/pq/measurementunit.h index 6ba219eef..41b68070b 100644 --- a/src/misc/pq/measurementunit.h +++ b/src/misc/pq/measurementunit.h @@ -242,9 +242,6 @@ namespace swift::misc::physical_quantities //! Constructor CMeasurementUnit(const Data &data) : m_data(&data) {} - //! Constructor saves the address of its argument, so forbid rvalues - CMeasurementUnit(const Data &&) = delete; - //! Destructor ~CMeasurementUnit() = default; @@ -258,6 +255,9 @@ namespace swift::misc::physical_quantities const Data *m_data = (static_cast(throw std::logic_error("Uninitialized pimpl")), nullptr); public: + //! Constructor saves the address of its argument, so forbid rvalues + CMeasurementUnit(const Data &&) = delete; + //! \copydoc swift::misc::mixin::String::toQString QString convertToQString(bool i18n = false) const { return this->getSymbol(i18n); } diff --git a/src/misc/pq/pqstring.cpp b/src/misc/pq/pqstring.cpp index f5293c59b..1094ec631 100644 --- a/src/misc/pq/pqstring.cpp +++ b/src/misc/pq/pqstring.cpp @@ -35,7 +35,7 @@ namespace swift::misc::physical_quantities // check if (vs.isEmpty()) { return v; } - thread_local const QRegularExpression regex("([-+]?[0-9]*[\\.,]?[0-9]+)\\s*(\\D*)$"); + thread_local const QRegularExpression regex(R"(([-+]?[0-9]*[\.,]?[0-9]+)\s*(\D*)$)"); const auto match = regex.match(value); if (!match.hasMatch()) { return v; } // not a valid number QString unit = match.captured(2).trimmed(); diff --git a/src/misc/propertyindexref.cpp b/src/misc/propertyindexref.cpp index 9f862290c..f6487af97 100644 --- a/src/misc/propertyindexref.cpp +++ b/src/misc/propertyindexref.cpp @@ -11,7 +11,7 @@ namespace swift::misc { - CPropertyIndexRef::CPropertyIndexRef(int index) : m_begin(nullptr), m_sizeOrIndex(index) {} + CPropertyIndexRef::CPropertyIndexRef(int index) : m_sizeOrIndex(index) {} CPropertyIndexRef::CPropertyIndexRef(const QVector &indexes) : m_begin(indexes.data()), m_sizeOrIndex(indexes.size()) diff --git a/src/misc/provider.h b/src/misc/provider.h index 3cf7a9e05..d9b1fda6a 100644 --- a/src/misc/provider.h +++ b/src/misc/provider.h @@ -32,7 +32,7 @@ namespace swift::misc protected: //! Constructor - IProvider() {} + IProvider() {} // NOLINT(modernize-use-equals-default) }; //! Base class of provider aware classes diff --git a/src/misc/range.h b/src/misc/range.h index ddf717a2a..c063af1d7 100644 --- a/src/misc/range.h +++ b/src/misc/range.h @@ -191,16 +191,16 @@ namespace swift::misc public: //! @{ //! STL compatibility - typedef typename std::iterator_traits::value_type value_type; - typedef typename std::iterator_traits::reference reference; - typedef typename std::iterator_traits::difference_type difference_type; - typedef const value_type &const_reference; - typedef value_type key_type; - typedef difference_type size_type; - typedef I iterator; - typedef I const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + using value_type = typename std::iterator_traits::value_type; + using reference = typename std::iterator_traits::reference; + using difference_type = typename std::iterator_traits::difference_type; + using const_reference = const value_type &; + using key_type = value_type; + using size_type = difference_type; + using iterator = I; + using const_iterator = I; + using reverse_iterator = std::reverse_iterator; + using const_reverse_iterator = std::reverse_iterator; //! @} //! Constructor. @@ -225,7 +225,7 @@ namespace swift::misc //! Create a range from reverse iterators. CRange reverse() const { - static_assert(std::is_same_v, ""); + static_assert(std::is_same_v); return { rbegin(), rend() }; } diff --git a/src/misc/sequence.h b/src/misc/sequence.h index cffe1b2b6..de67ce400 100644 --- a/src/misc/sequence.h +++ b/src/misc/sequence.h @@ -86,40 +86,40 @@ namespace swift::misc { public: //! STL compatibility - typedef T key_type; + using key_type = T; //! STL compatilibty - typedef T value_type; + using value_type = T; //! STL compatibility - typedef T &reference; + using reference = T &; //! STL compatibility - typedef const T &const_reference; + using const_reference = const T &; //! STL compatibility - typedef T *pointer; + using pointer = T *; //! STL compatibility - typedef const T *const_pointer; + using const_pointer = const T *; //! STL compatibility - typedef typename QVector::const_iterator const_iterator; + using const_iterator = typename QVector::const_iterator; //! STL compatibility - typedef typename QVector::iterator iterator; + using iterator = typename QVector::iterator; //! STL compatibility - typedef typename QVector::const_reverse_iterator const_reverse_iterator; + using const_reverse_iterator = typename QVector::const_reverse_iterator; //! STL compatibility - typedef typename QVector::reverse_iterator reverse_iterator; + using reverse_iterator = typename QVector::reverse_iterator; //! STL compatibility - typedef ptrdiff_t difference_type; + using difference_type = ptrdiff_t; //! STL compatibility - typedef int size_type; + using size_type = int; //! Default constructor. CSequence() = default; diff --git a/src/misc/simulation/flightgear/flightgearutil.cpp b/src/misc/simulation/flightgear/flightgearutil.cpp index c02d3b54a..600d360bf 100644 --- a/src/misc/simulation/flightgear/flightgearutil.cpp +++ b/src/misc/simulation/flightgear/flightgearutil.cpp @@ -28,7 +28,7 @@ namespace swift::misc::simulation::flightgear if (CBuildConfig::isRunningOnWindowsNtPlatform()) { QSettings flightgearRegistry( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\FlightGear_is1", + R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FlightGear_is1)", QSettings::NativeFormat); flightgearRootDir = flightgearRegistry.value("InstallLocation").toString().trimmed(); } diff --git a/src/misc/simulation/remoteaircraftprovider.h b/src/misc/simulation/remoteaircraftprovider.h index a0b7cffdd..1b86263e4 100644 --- a/src/misc/simulation/remoteaircraftprovider.h +++ b/src/misc/simulation/remoteaircraftprovider.h @@ -689,7 +689,7 @@ namespace swift::misc::simulation protected: //! Default constructor - CRemoteAircraftAware() {} + CRemoteAircraftAware() {} // NOLINT(modernize-use-equals-default) //! Constructor CRemoteAircraftAware(IRemoteAircraftProvider *remoteAircraftProvider) : IProviderAware(remoteAircraftProvider) diff --git a/src/misc/simulation/settings/xswiftbussettingsqtfree.inc b/src/misc/simulation/settings/xswiftbussettingsqtfree.inc index a130e5144..ceb39b5e9 100644 --- a/src/misc/simulation/settings/xswiftbussettingsqtfree.inc +++ b/src/misc/simulation/settings/xswiftbussettingsqtfree.inc @@ -31,218 +31,209 @@ constexpr char swift::misc::simulation::settings::CXSwiftBusSettingsQtFree::Json constexpr char swift::misc::simulation::settings::CXSwiftBusSettingsQtFree::JsonLogRenderPhases[]; //! @endcond -namespace swift::misc +namespace swift::misc::simulation::settings { - namespace simulation + bool CXSwiftBusSettingsQtFree::parseXSwiftBusString(const std::string &json) { - namespace settings + if (json.empty()) { return false; } + + const nlohmann::basic_json parsed = nlohmann::json::parse(json, nullptr, false); + + if (parsed.is_discarded()) { return false; } + + int c = 0; + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonDBusServerAddress) && + parsed[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].is_string()) { - bool CXSwiftBusSettingsQtFree::parseXSwiftBusString(const std::string &json) - { - if (json.empty()) { return false; } + m_dBusServerAddress = parsed[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonMessageBox) && + parsed[CXSwiftBusSettingsQtFree::JsonMessageBox].is_string()) + { + m_msgBox = parsed[CXSwiftBusSettingsQtFree::JsonMessageBox].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonNightTextureMode) && + parsed[CXSwiftBusSettingsQtFree::JsonNightTextureMode].is_string()) + { + m_nightTextureMode = parsed[CXSwiftBusSettingsQtFree::JsonNightTextureMode].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonDrawingLabels) && + parsed[CXSwiftBusSettingsQtFree::JsonDrawingLabels].is_boolean()) + { + m_drawingLabels = parsed[CXSwiftBusSettingsQtFree::JsonDrawingLabels].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonLabelColor) && + parsed[CXSwiftBusSettingsQtFree::JsonLabelColor].is_number_integer()) + { + m_labelColor = parsed[CXSwiftBusSettingsQtFree::JsonLabelColor].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights) && + parsed[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].is_boolean()) + { + m_bundleTaxiLandingLights = parsed[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonTcas) && + parsed[CXSwiftBusSettingsQtFree::JsonTcas].is_boolean()) + { + m_tcasEnabled = parsed[CXSwiftBusSettingsQtFree::JsonTcas].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonTerrainProbe) && + parsed[CXSwiftBusSettingsQtFree::JsonTerrainProbe].is_boolean()) + { + m_terrainProbeEnabled = parsed[CXSwiftBusSettingsQtFree::JsonTerrainProbe].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonLogRenderPhases) && + parsed[CXSwiftBusSettingsQtFree::JsonLogRenderPhases].is_boolean()) + { + m_logRenderPhases = parsed[CXSwiftBusSettingsQtFree::JsonLogRenderPhases].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonMaxPlanes) && + parsed[CXSwiftBusSettingsQtFree::JsonMaxPlanes].is_number_integer()) + { + m_maxPlanes = parsed[CXSwiftBusSettingsQtFree::JsonMaxPlanes].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonMaxDrawDistance) && + parsed[CXSwiftBusSettingsQtFree::JsonMaxDrawDistance].is_number_float()) + { + m_maxDrawDistanceNM = parsed[CXSwiftBusSettingsQtFree::JsonMaxDrawDistance].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM) && + parsed[CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM].is_number_integer()) + { + m_followAircraftDistanceM = parsed[CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM].get(); + c++; + } + if (parsed.contains(CXSwiftBusSettingsQtFree::JsonTimestamp) && + parsed[CXSwiftBusSettingsQtFree::JsonTimestamp].is_number_integer()) + { + m_msSinceEpochQtFree = parsed[CXSwiftBusSettingsQtFree::JsonTimestamp].get(); + c++; + } + this->objectUpdated(); // post processing + return c == 13; + } - const nlohmann::basic_json parsed = nlohmann::json::parse(json, nullptr, false); + std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const + { + nlohmann::json json; - if (parsed.is_discarded()) { return false; } + json[JsonDBusServerAddress] = m_dBusServerAddress; + json[JsonNightTextureMode] = m_nightTextureMode; + json[JsonMessageBox] = m_msgBox; + json[JsonMaxPlanes] = m_maxPlanes; + json[JsonMaxDrawDistance] = m_maxDrawDistanceNM; + json[JsonTimestamp] = m_msSinceEpochQtFree; + json[JsonDrawingLabels] = m_drawingLabels; + json[JsonLabelColor] = m_labelColor; + json[JsonBundleTaxiLandingLights] = m_bundleTaxiLandingLights; + json[JsonFollowAircraftDistanceM] = m_followAircraftDistanceM; + json[JsonLogRenderPhases] = m_logRenderPhases; + json[JsonTcas] = m_tcasEnabled; + json[JsonTerrainProbe] = m_terrainProbeEnabled; - int c = 0; - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonDBusServerAddress) && - parsed[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].is_string()) - { - m_dBusServerAddress = parsed[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonMessageBox) && - parsed[CXSwiftBusSettingsQtFree::JsonMessageBox].is_string()) - { - m_msgBox = parsed[CXSwiftBusSettingsQtFree::JsonMessageBox].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonNightTextureMode) && - parsed[CXSwiftBusSettingsQtFree::JsonNightTextureMode].is_string()) - { - m_nightTextureMode = parsed[CXSwiftBusSettingsQtFree::JsonNightTextureMode].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonDrawingLabels) && - parsed[CXSwiftBusSettingsQtFree::JsonDrawingLabels].is_boolean()) - { - m_drawingLabels = parsed[CXSwiftBusSettingsQtFree::JsonDrawingLabels].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonLabelColor) && - parsed[CXSwiftBusSettingsQtFree::JsonLabelColor].is_number_integer()) - { - m_labelColor = parsed[CXSwiftBusSettingsQtFree::JsonLabelColor].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights) && - parsed[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].is_boolean()) - { - m_bundleTaxiLandingLights = - parsed[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonTcas) && - parsed[CXSwiftBusSettingsQtFree::JsonTcas].is_boolean()) - { - m_tcasEnabled = parsed[CXSwiftBusSettingsQtFree::JsonTcas].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonTerrainProbe) && - parsed[CXSwiftBusSettingsQtFree::JsonTerrainProbe].is_boolean()) - { - m_terrainProbeEnabled = parsed[CXSwiftBusSettingsQtFree::JsonTerrainProbe].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonLogRenderPhases) && - parsed[CXSwiftBusSettingsQtFree::JsonLogRenderPhases].is_boolean()) - { - m_logRenderPhases = parsed[CXSwiftBusSettingsQtFree::JsonLogRenderPhases].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonMaxPlanes) && - parsed[CXSwiftBusSettingsQtFree::JsonMaxPlanes].is_number_integer()) - { - m_maxPlanes = parsed[CXSwiftBusSettingsQtFree::JsonMaxPlanes].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonMaxDrawDistance) && - parsed[CXSwiftBusSettingsQtFree::JsonMaxDrawDistance].is_number_float()) - { - m_maxDrawDistanceNM = parsed[CXSwiftBusSettingsQtFree::JsonMaxDrawDistance].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM) && - parsed[CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM].is_number_integer()) - { - m_followAircraftDistanceM = - parsed[CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM].get(); - c++; - } - if (parsed.contains(CXSwiftBusSettingsQtFree::JsonTimestamp) && - parsed[CXSwiftBusSettingsQtFree::JsonTimestamp].is_number_integer()) - { - m_msSinceEpochQtFree = parsed[CXSwiftBusSettingsQtFree::JsonTimestamp].get(); - c++; - } - this->objectUpdated(); // post processing - return c == 13; - } + return json.dump(2); + } - std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const - { - nlohmann::json json; + std::string CXSwiftBusSettingsQtFree::convertToString() const + { + return "DBusServer: " + m_dBusServerAddress + ", drawLabels: " + qtfreeutils::boolToYesNo(m_drawingLabels) + + ", labelColor: " + std::to_string((m_labelColor >> 16) & 0xff) + ";" + + std::to_string((m_labelColor >> 8) & 0xff) + ";" + std::to_string(m_labelColor & 0xff) + + ", bundle lights: " + qtfreeutils::boolToYesNo(m_bundleTaxiLandingLights) + + ", phases: " + qtfreeutils::boolToYesNo(m_logRenderPhases) + + ", TCAS: " + qtfreeutils::boolToYesNo(m_tcasEnabled) + + ", terr.probe: " + qtfreeutils::boolToYesNo(m_terrainProbeEnabled) + + ", night t.: " + m_nightTextureMode + ", max planes: " + std::to_string(m_maxPlanes) + + ", max distance NM: " + std::to_string(m_maxDrawDistanceNM) + + ", follow dist m: " + std::to_string(m_followAircraftDistanceM) + ", msg.box: " + m_msgBox + + ", ts: " + std::to_string(m_msSinceEpochQtFree); + } - json[JsonDBusServerAddress] = m_dBusServerAddress; - json[JsonNightTextureMode] = m_nightTextureMode; - json[JsonMessageBox] = m_msgBox; - json[JsonMaxPlanes] = m_maxPlanes; - json[JsonMaxDrawDistance] = m_maxDrawDistanceNM; - json[JsonTimestamp] = m_msSinceEpochQtFree; - json[JsonDrawingLabels] = m_drawingLabels; - json[JsonLabelColor] = m_labelColor; - json[JsonBundleTaxiLandingLights] = m_bundleTaxiLandingLights; - json[JsonFollowAircraftDistanceM] = m_followAircraftDistanceM; - json[JsonLogRenderPhases] = m_logRenderPhases; - json[JsonTcas] = m_tcasEnabled; - json[JsonTerrainProbe] = m_terrainProbeEnabled; + int CXSwiftBusSettingsQtFree::update(const CXSwiftBusSettingsQtFree &newValues) + { + int changed = 0; + if (m_dBusServerAddress != newValues.m_dBusServerAddress) + { + m_dBusServerAddress = newValues.m_dBusServerAddress; + changed++; + } + if (m_msgBox != newValues.m_msgBox) + { + m_msgBox = newValues.m_msgBox; + changed++; + } + if (m_drawingLabels != newValues.m_drawingLabels) + { + m_drawingLabels = newValues.m_drawingLabels; + changed++; + } + if (m_labelColor != newValues.m_labelColor) + { + m_labelColor = newValues.m_labelColor; + changed++; + } + if (m_nightTextureMode != newValues.m_nightTextureMode) + { + m_nightTextureMode = newValues.m_nightTextureMode; + changed++; + } + if (m_logRenderPhases != newValues.m_logRenderPhases) + { + m_logRenderPhases = newValues.m_logRenderPhases; + changed++; + } + if (m_tcasEnabled != newValues.m_tcasEnabled) + { + m_tcasEnabled = newValues.m_tcasEnabled; + changed++; + } + if (m_terrainProbeEnabled != newValues.m_terrainProbeEnabled) + { + m_terrainProbeEnabled = newValues.m_terrainProbeEnabled; + changed++; + } + if (m_maxPlanes != newValues.m_maxPlanes) + { + m_maxPlanes = newValues.m_maxPlanes; + changed++; + } + if (m_msSinceEpochQtFree != newValues.m_msSinceEpochQtFree) + { + m_msSinceEpochQtFree = newValues.m_msSinceEpochQtFree; + changed++; + } + if (m_bundleTaxiLandingLights != newValues.m_bundleTaxiLandingLights) + { + m_bundleTaxiLandingLights = newValues.m_bundleTaxiLandingLights; + changed++; + } + if (m_followAircraftDistanceM != newValues.m_followAircraftDistanceM) + { + m_followAircraftDistanceM = newValues.m_followAircraftDistanceM; + changed++; + } + if (!qtfreeutils::isFuzzyEqual(m_maxDrawDistanceNM, newValues.m_maxDrawDistanceNM)) + { + m_maxDrawDistanceNM = newValues.m_maxDrawDistanceNM; + changed++; + } - return json.dump(2); - } + if (changed > 0) { this->objectUpdated(); } // post processing + return changed; + } - std::string CXSwiftBusSettingsQtFree::convertToString() const - { - return "DBusServer: " + m_dBusServerAddress + - ", drawLabels: " + qtfreeutils::boolToYesNo(m_drawingLabels) + - ", labelColor: " + std::to_string((m_labelColor >> 16) & 0xff) + ";" + - std::to_string((m_labelColor >> 8) & 0xff) + ";" + std::to_string(m_labelColor & 0xff) + - ", bundle lights: " + qtfreeutils::boolToYesNo(m_bundleTaxiLandingLights) + - ", phases: " + qtfreeutils::boolToYesNo(m_logRenderPhases) + - ", TCAS: " + qtfreeutils::boolToYesNo(m_tcasEnabled) + - ", terr.probe: " + qtfreeutils::boolToYesNo(m_terrainProbeEnabled) + - ", night t.: " + m_nightTextureMode + ", max planes: " + std::to_string(m_maxPlanes) + - ", max distance NM: " + std::to_string(m_maxDrawDistanceNM) + - ", follow dist m: " + std::to_string(m_followAircraftDistanceM) + ", msg.box: " + m_msgBox + - ", ts: " + std::to_string(m_msSinceEpochQtFree); - } - - int CXSwiftBusSettingsQtFree::update(const CXSwiftBusSettingsQtFree &newValues) - { - int changed = 0; - if (m_dBusServerAddress != newValues.m_dBusServerAddress) - { - m_dBusServerAddress = newValues.m_dBusServerAddress; - changed++; - } - if (m_msgBox != newValues.m_msgBox) - { - m_msgBox = newValues.m_msgBox; - changed++; - } - if (m_drawingLabels != newValues.m_drawingLabels) - { - m_drawingLabels = newValues.m_drawingLabels; - changed++; - } - if (m_labelColor != newValues.m_labelColor) - { - m_labelColor = newValues.m_labelColor; - changed++; - } - if (m_nightTextureMode != newValues.m_nightTextureMode) - { - m_nightTextureMode = newValues.m_nightTextureMode; - changed++; - } - if (m_logRenderPhases != newValues.m_logRenderPhases) - { - m_logRenderPhases = newValues.m_logRenderPhases; - changed++; - } - if (m_tcasEnabled != newValues.m_tcasEnabled) - { - m_tcasEnabled = newValues.m_tcasEnabled; - changed++; - } - if (m_terrainProbeEnabled != newValues.m_terrainProbeEnabled) - { - m_terrainProbeEnabled = newValues.m_terrainProbeEnabled; - changed++; - } - if (m_maxPlanes != newValues.m_maxPlanes) - { - m_maxPlanes = newValues.m_maxPlanes; - changed++; - } - if (m_msSinceEpochQtFree != newValues.m_msSinceEpochQtFree) - { - m_msSinceEpochQtFree = newValues.m_msSinceEpochQtFree; - changed++; - } - if (m_bundleTaxiLandingLights != newValues.m_bundleTaxiLandingLights) - { - m_bundleTaxiLandingLights = newValues.m_bundleTaxiLandingLights; - changed++; - } - if (m_followAircraftDistanceM != newValues.m_followAircraftDistanceM) - { - m_followAircraftDistanceM = newValues.m_followAircraftDistanceM; - changed++; - } - if (!qtfreeutils::isFuzzyEqual(m_maxDrawDistanceNM, newValues.m_maxDrawDistanceNM)) - { - m_maxDrawDistanceNM = newValues.m_maxDrawDistanceNM; - changed++; - } - - if (changed > 0) { this->objectUpdated(); } // post processing - return changed; - } - - } // namespace settings - } // namespace simulation -} // namespace swift::misc +} // namespace swift::misc::simulation::settings #ifdef __GNUC__ # pragma GCC diagnostic pop diff --git a/src/misc/simulation/simulationenvironmentprovider.h b/src/misc/simulation/simulationenvironmentprovider.h index 07b91284e..7e17e1644 100644 --- a/src/misc/simulation/simulationenvironmentprovider.h +++ b/src/misc/simulation/simulationenvironmentprovider.h @@ -404,7 +404,7 @@ namespace swift::misc::simulation protected: //! Default constructor - CSimulationEnvironmentAware() {} + CSimulationEnvironmentAware() {} // NOLINT(modernize-use-equals-default) //! Constructor CSimulationEnvironmentAware(ISimulationEnvironmentProvider *simEnvProvider) : IProviderAware(simEnvProvider) diff --git a/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp b/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp index 5c1bd3616..b946ae292 100644 --- a/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp +++ b/src/misc/simulation/xplane/aircraftmodelloaderxplane.cpp @@ -3,9 +3,8 @@ #include "misc/simulation/xplane/aircraftmodelloaderxplane.h" -#include - #include +#include #include #include @@ -614,9 +613,14 @@ namespace swift::misc::simulation::xplane using command = std::function; using namespace std::placeholders; - const QMap commands { - { "EXPORT_NAME", std::bind(&CAircraftModelLoaderXPlane::parseExportCommand, this, _1, _2, _3, _4) } - }; + const QMap commands { { "EXPORT_NAME", + [this](auto &&tokens, auto &&package, auto &&path, auto &&lineNum) { + return parseExportCommand( + std::forward(tokens), + std::forward(package), + std::forward(path), + std::forward(lineNum)); + } } }; CSLPackage package; int lineNum = 0; @@ -648,18 +652,68 @@ namespace swift::misc::simulation::xplane using namespace std::placeholders; const QMap commands { - { "EXPORT_NAME", std::bind(&CAircraftModelLoaderXPlane::parseDummyCommand, this, _1, _2, _3, _4) }, - { "DEPENDENCY", std::bind(&CAircraftModelLoaderXPlane::parseDependencyCommand, this, _1, _2, _3, _4) }, - { "OBJECT", std::bind(&CAircraftModelLoaderXPlane::parseObjectCommand, this, _1, _2, _3, _4) }, - { "TEXTURE", std::bind(&CAircraftModelLoaderXPlane::parseTextureCommand, this, _1, _2, _3, _4) }, - { "AIRCRAFT", std::bind(&CAircraftModelLoaderXPlane::parseAircraftCommand, this, _1, _2, _3, _4) }, - { "OBJ8_AIRCRAFT", std::bind(&CAircraftModelLoaderXPlane::parseObj8AircraftCommand, this, _1, _2, _3, _4) }, - { "OBJ8", std::bind(&CAircraftModelLoaderXPlane::parseObj8Command, this, _1, _2, _3, _4) }, - { "HASGEAR", std::bind(&CAircraftModelLoaderXPlane::parseHasGearCommand, this, _1, _2, _3, _4) }, - { "ICAO", std::bind(&CAircraftModelLoaderXPlane::parseIcaoCommand, this, _1, _2, _3, _4) }, - { "AIRLINE", std::bind(&CAircraftModelLoaderXPlane::parseAirlineCommand, this, _1, _2, _3, _4) }, - { "LIVERY", std::bind(&CAircraftModelLoaderXPlane::parseLiveryCommand, this, _1, _2, _3, _4) }, - { "VERT_OFFSET", std::bind(&CAircraftModelLoaderXPlane::parseDummyCommand, this, _1, _2, _3, _4) }, + { "EXPORT_NAME", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseDummyCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "DEPENDENCY", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseDependencyCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "OBJECT", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseObjectCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "TEXTURE", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseTextureCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { + "AIRCRAFT", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseAircraftCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + }, + }, + { "OBJ8_AIRCRAFT", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseObj8AircraftCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "OBJ8", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseObj8Command(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "HASGEAR", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseHasGearCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "ICAO", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseIcaoCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "AIRLINE", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseAirlineCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "LIVERY", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseLiveryCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, + { "VERT_OFFSET", + [this](auto &&PH1, auto &&PH2, auto &&PH3, auto &&PH4) { + return parseDummyCommand(std::forward(PH1), std::forward(PH2), + std::forward(PH3), std::forward(PH4)); + } }, }; int lineNum = 0; diff --git a/src/plugins/simulator/flightgear/simulatorflightgear.cpp b/src/plugins/simulator/flightgear/simulatorflightgear.cpp index fc57031a6..1949ebcb3 100644 --- a/src/plugins/simulator/flightgear/simulatorflightgear.cpp +++ b/src/plugins/simulator/flightgear/simulatorflightgear.cpp @@ -3,7 +3,7 @@ #include "simulatorflightgear.h" -#include +#include #include #include @@ -872,7 +872,10 @@ namespace swift::simplugin::flightgear } using namespace std::placeholders; - auto callback = std::bind(&CSimulatorFlightgear::callbackReceivedRequestedElevation, this, _1, _2, false); + auto callback = [this](auto &&plane, auto &&callsign) { + callbackReceivedRequestedElevation(std::forward(plane), + std::forward(callsign), false); + }; // Request m_trafficProxy->getElevationAtPosition(callsign, pos.latitude().value(CAngleUnit::deg()), diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index afc6be625..3972583be 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -3,7 +3,7 @@ #include "simulatorxplane.h" -#include +#include #include #include @@ -267,7 +267,11 @@ namespace swift::simplugin::xplane } using namespace std::placeholders; - auto callback = std::bind(&CSimulatorXPlane::callbackReceivedRequestedElevation, this, _1, _2, _3); + auto callback = [this](auto &&plane, auto &&callsign, auto &&isWater) { + callbackReceivedRequestedElevation(std::forward(plane), + std::forward(callsign), + std::forward(isWater)); + }; // Request m_trafficProxy->getElevationAtPosition(callsign, pos.latitude().value(CAngleUnit::deg()), diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index 505d168fe..cd96c29a5 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -181,7 +181,7 @@ void CSwiftLauncher::clearWindowsRegistry() CGuiApplication::removeAllWindowsSwiftRegistryEntries(); } -CSwiftLauncher::~CSwiftLauncher() {} +CSwiftLauncher::~CSwiftLauncher() = default; QString CSwiftLauncher::getCmdLine() const { return this->toCmdLine(m_executable, m_executableArgs); } diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index 025dc7e3b..6294d3af5 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -66,7 +66,7 @@ public: CSwiftLauncher(bool installerMode, QWidget *parent = nullptr); //! Destructor - virtual ~CSwiftLauncher() override; + ~CSwiftLauncher() override; //! Executable (to be started) const QString &getExecutable() const { return m_executable; }