From 68f72080ef10f1a7362a47cf3bb626bb738290f3 Mon Sep 17 00:00:00 2001 From: Tim Ebbeke Date: Tue, 26 Nov 2024 23:37:37 +0100 Subject: [PATCH] Applied more clang tidy fixes. --- .../nui/frontend/components/dialog.hpp | 9 ++-- nui/include/nui/frontend/components/table.hpp | 2 - .../nui/frontend/dom/basic_element.hpp | 7 +++ nui/include/nui/frontend/dom/dom.hpp | 2 +- nui/include/nui/frontend/dom/element.hpp | 5 +- nui/include/nui/frontend/dom/reference.hpp | 1 - .../elements/detail/fragment_context.hpp | 3 ++ .../frontend/elements/impl/html_element.tpp | 4 +- .../frontend/elements/impl/materialize.hpp | 5 ++ .../filesystem/file_dialog_options.cpp | 53 ++++++++++--------- 10 files changed, 53 insertions(+), 38 deletions(-) diff --git a/nui/include/nui/frontend/components/dialog.hpp b/nui/include/nui/frontend/components/dialog.hpp index fd47b1a6..2bd48ef0 100644 --- a/nui/include/nui/frontend/components/dialog.hpp +++ b/nui/include/nui/frontend/components/dialog.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -33,9 +32,9 @@ namespace Nui::Components struct ConstructionArgs { std::optional className{std::nullopt}; - std::string title{""}; - std::string body{""}; - std::string buttonClassName{""}; + std::string title{}; + std::string body{}; + std::string buttonClassName{}; ButtonConfiguration buttonConfiguration{ButtonConfiguration::Ok}; std::function onButtonClicked = [](Button) {}; }; @@ -45,7 +44,7 @@ namespace Nui::Components * * @param args The intial values for the dialog. */ - DialogController(ConstructionArgs&& args); + explicit DialogController(ConstructionArgs&& args); /** * @brief Shows the dialog as a modal dialog (blocks the UI). diff --git a/nui/include/nui/frontend/components/table.hpp b/nui/include/nui/frontend/components/table.hpp index 6e2c6395..9b38a6b8 100644 --- a/nui/include/nui/frontend/components/table.hpp +++ b/nui/include/nui/frontend/components/table.hpp @@ -10,9 +10,7 @@ #include #include -#include #include -#include #include namespace Nui::Components diff --git a/nui/include/nui/frontend/dom/basic_element.hpp b/nui/include/nui/frontend/dom/basic_element.hpp index 4a11aca2..691068e2 100644 --- a/nui/include/nui/frontend/dom/basic_element.hpp +++ b/nui/include/nui/frontend/dom/basic_element.hpp @@ -17,6 +17,10 @@ namespace Nui::Dom : element_{std::move(val)} {} virtual ~BasicElement() = default; + BasicElement(BasicElement const&) = default; + BasicElement(BasicElement&&) noexcept = default; + BasicElement& operator=(BasicElement const&) = default; + BasicElement& operator=(BasicElement&&) noexcept = default; Nui::val const& val() const { @@ -26,14 +30,17 @@ namespace Nui::Dom { return element_; } + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator Nui::val const&() const { return element_; } + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator Nui::val&() { return element_; } + // NOLINTNEXTLINE(hicpp-explicit-conversions) operator Nui::val&&() && { return std::move(element_); diff --git a/nui/include/nui/frontend/dom/dom.hpp b/nui/include/nui/frontend/dom/dom.hpp index 8e5bf4fb..28246743 100644 --- a/nui/include/nui/frontend/dom/dom.hpp +++ b/nui/include/nui/frontend/dom/dom.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include namespace Nui::Dom { diff --git a/nui/include/nui/frontend/dom/element.hpp b/nui/include/nui/frontend/dom/element.hpp index 15a572e5..c105296c 100644 --- a/nui/include/nui/frontend/dom/element.hpp +++ b/nui/include/nui/frontend/dom/element.hpp @@ -78,7 +78,7 @@ namespace Nui::Dom Element& operator=(Element const&) = delete; Element& operator=(Element&&) = delete; - ~Element() + ~Element() override { clearChildren(); destroy_(element_); @@ -277,8 +277,7 @@ namespace Nui::Dom { if (where >= children_.size()) return appendElement(element); - else - return insert(begin() + static_cast(where), element); + return insert(begin() + static_cast(where), element); } auto& operator[](std::size_t index) diff --git a/nui/include/nui/frontend/dom/reference.hpp b/nui/include/nui/frontend/dom/reference.hpp index a36eab52..e46f460d 100644 --- a/nui/include/nui/frontend/dom/reference.hpp +++ b/nui/include/nui/frontend/dom/reference.hpp @@ -2,7 +2,6 @@ #include -#include #include #include #include diff --git a/nui/include/nui/frontend/elements/detail/fragment_context.hpp b/nui/include/nui/frontend/elements/detail/fragment_context.hpp index 3f210cd4..5a21a46b 100644 --- a/nui/include/nui/frontend/elements/detail/fragment_context.hpp +++ b/nui/include/nui/frontend/elements/detail/fragment_context.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include + namespace Nui::Detail { template diff --git a/nui/include/nui/frontend/elements/impl/html_element.tpp b/nui/include/nui/frontend/elements/impl/html_element.tpp index d072be96..3a949e67 100644 --- a/nui/include/nui/frontend/elements/impl/html_element.tpp +++ b/nui/include/nui/frontend/elements/impl/html_element.tpp @@ -36,6 +36,7 @@ namespace Nui } } +// NOLINTBEGIN #define NUI_MAKE_HTML_ELEMENT_RENAME(NAME, HTML_ACTUAL) \ struct NAME : ::Nui::HtmlElement \ { \ @@ -61,4 +62,5 @@ namespace Nui NUI_MAKE_HTML_ELEMENT_RENAME(NAME, HTML_ACTUAL) \ } -#define NUI_DECLARE_HTML_ELEMENT(NAME) NUI_DECLARE_HTML_ELEMENT_RENAME(NAME, #NAME) \ No newline at end of file +#define NUI_DECLARE_HTML_ELEMENT(NAME) NUI_DECLARE_HTML_ELEMENT_RENAME(NAME, #NAME) +// NOLINTEND \ No newline at end of file diff --git a/nui/include/nui/frontend/elements/impl/materialize.hpp b/nui/include/nui/frontend/elements/impl/materialize.hpp index 8fd19fc9..89bea764 100644 --- a/nui/include/nui/frontend/elements/impl/materialize.hpp +++ b/nui/include/nui/frontend/elements/impl/materialize.hpp @@ -1,3 +1,8 @@ +#include + +#include +#include + namespace Nui { class HtmlElement; diff --git a/nui/src/nui/backend/filesystem/file_dialog_options.cpp b/nui/src/nui/backend/filesystem/file_dialog_options.cpp index 6b556a15..ae7a4dd4 100644 --- a/nui/src/nui/backend/filesystem/file_dialog_options.cpp +++ b/nui/src/nui/backend/filesystem/file_dialog_options.cpp @@ -2,33 +2,36 @@ namespace Nui::FileDialog { - //##################################################################################################################### - template - void to_json_common(nlohmann::json& json, T const& options) + // ##################################################################################################################### + namespace { - if (options.title) - json["title"] = *options.title; - if (options.defaultPath) - json["defaultPath"] = options.defaultPath->string(); - json["filters"] = options.filters; - json["forcePath"] = options.forcePath; - } - //--------------------------------------------------------------------------------------------------------------------- - template - void from_json_common(nlohmann::json const& json, T& options) - { - if (json.contains("title")) - options.title = json["title"].get(); - else - options.title = std::nullopt; + template + void to_json_common(nlohmann::json& json, T const& options) + { + if (options.title) + json["title"] = *options.title; + if (options.defaultPath) + json["defaultPath"] = options.defaultPath->string(); + json["filters"] = options.filters; + json["forcePath"] = options.forcePath; + } + //--------------------------------------------------------------------------------------------------------------------- + template + void from_json_common(nlohmann::json const& json, T& options) + { + if (json.contains("title")) + options.title = json["title"].get(); + else + options.title = std::nullopt; - if (json.contains("defaultPath")) - options.defaultPath = json["defaultPath"].get(); - else - options.defaultPath = std::nullopt; + if (json.contains("defaultPath")) + options.defaultPath = json["defaultPath"].get(); + else + options.defaultPath = std::nullopt; - json.at("filters").get_to(options.filters); - json.at("forcePath").get_to(options.forcePath); + json.at("filters").get_to(options.filters); + json.at("forcePath").get_to(options.forcePath); + } } //--------------------------------------------------------------------------------------------------------------------- void to_json(nlohmann::json& json, OpenDialogOptions const& options) @@ -64,5 +67,5 @@ namespace Nui::FileDialog from_json_common(json, options); options.forceOverwrite = json["forceOverwrite"].get(); } - //##################################################################################################################### + // ##################################################################################################################### } \ No newline at end of file