From ec296d98eb1d3e313bdc4b48ba19a2f4ddf86035 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Mon, 3 Mar 2025 10:52:39 -0500 Subject: [PATCH] clang format/tidy fixes for rework_layer_text --- .../source/scwx/qt/manager/font_manager.cpp | 4 +- scwx-qt/source/scwx/qt/map/draw_layer.cpp | 43 ++++++++++--------- scwx-qt/source/scwx/qt/map/map_context.hpp | 2 +- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/scwx-qt/source/scwx/qt/manager/font_manager.cpp b/scwx-qt/source/scwx/qt/manager/font_manager.cpp index 4f5ad99f..d92d3bd7 100644 --- a/scwx-qt/source/scwx/qt/manager/font_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/font_manager.cpp @@ -71,7 +71,7 @@ public: const std::vector& GetRawFontData(const std::string& filename); - static bool CheckFontFormat(const FcChar8* format); + static bool CheckFontFormat(const FcChar8* format); static FontRecord MatchFontFile(const std::string& family, const std::vector& styles); @@ -461,7 +461,7 @@ void FontManager::Impl::FinalizeFontconfig() bool FontManager::Impl::CheckFontFormat(const FcChar8* format) { - const std::string stdFormat = reinterpret_cast(format); + const std::string stdFormat = reinterpret_cast(format); return stdFormat == kFcTrueType_ || stdFormat == kFcOpenType_; } diff --git a/scwx-qt/source/scwx/qt/map/draw_layer.cpp b/scwx-qt/source/scwx/qt/map/draw_layer.cpp index 91dace1c..c39b9f4c 100644 --- a/scwx-qt/source/scwx/qt/map/draw_layer.cpp +++ b/scwx-qt/source/scwx/qt/map/draw_layer.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -6,14 +7,11 @@ #include #include +#include #include #include -namespace scwx -{ -namespace qt -{ -namespace map +namespace scwx::qt::map { static const std::string logPrefix_ = "scwx::qt::map::draw_layer"; @@ -23,13 +21,13 @@ class DrawLayerImpl { public: explicit DrawLayerImpl(std::shared_ptr context) : - context_ {context}, - drawList_ {}, - textureAtlas_ {GL_INVALID_INDEX} + context_ {std::move(context)}, drawList_ {} { static size_t currentMapId_ {0u}; imGuiContextName_ = fmt::format("Layer {}", ++currentMapId_); - imGuiContext_ = + // This must be initialized after the last line + // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer) + imGuiContext_ = model::ImGuiContextModel::Instance().CreateContext(imGuiContextName_); // Initialize ImGui Qt backend @@ -51,15 +49,20 @@ public: model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_); } + DrawLayerImpl(const DrawLayerImpl&) = delete; + DrawLayerImpl& operator=(const DrawLayerImpl&) = delete; + DrawLayerImpl(const DrawLayerImpl&&) = delete; + DrawLayerImpl& operator=(const DrawLayerImpl&&) = delete; + std::shared_ptr context_; std::vector> drawList_; - GLuint textureAtlas_; + GLuint textureAtlas_ {GL_INVALID_INDEX}; std::uint64_t textureAtlasBuildCount_ {}; std::string imGuiContextName_; ImGuiContext* imGuiContext_; - bool imGuiRendererInitialized_{}; + bool imGuiRendererInitialized_ {}; }; DrawLayer::DrawLayer(const std::shared_ptr& context) : @@ -171,15 +174,15 @@ bool DrawLayer::RunMousePicking( bool itemPicked = false; // For each draw item in the draw list in reverse - for (auto it = p->drawList_.rbegin(); it != p->drawList_.rend(); ++it) + for (auto& it : std::ranges::reverse_view(p->drawList_)) { // Run mouse picking on each draw item - if ((*it)->RunMousePicking(params, - mouseLocalPos, - mouseGlobalPos, - mouseCoords, - mouseGeoCoords, - eventHandler)) + if (it->RunMousePicking(params, + mouseLocalPos, + mouseGlobalPos, + mouseCoords, + mouseGeoCoords, + eventHandler)) { // If a draw item was picked, don't process additional items itemPicked = true; @@ -195,6 +198,4 @@ void DrawLayer::AddDrawItem(const std::shared_ptr& drawItem) p->drawList_.push_back(drawItem); } -} // namespace map -} // namespace qt -} // namespace scwx +} // namespace scwx::qt::map diff --git a/scwx-qt/source/scwx/qt/map/map_context.hpp b/scwx-qt/source/scwx/qt/map/map_context.hpp index 8e79b028..57640263 100644 --- a/scwx-qt/source/scwx/qt/map/map_context.hpp +++ b/scwx-qt/source/scwx/qt/map/map_context.hpp @@ -50,7 +50,7 @@ public: common::RadarProductGroup radar_product_group() const; std::string radar_product() const; int16_t radar_product_code() const; - QWidget* widget() const; + [[nodiscard]] QWidget* widget() const; void set_map(const std::shared_ptr& map); void set_map_copyrights(const std::string& copyrights);