Skip to content

Commit

Permalink
Applied more clang tidy fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Nov 26, 2024
1 parent 6bb24c6 commit 68f7208
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 38 deletions.
9 changes: 4 additions & 5 deletions nui/include/nui/frontend/components/dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <nui/frontend/element_renderer.hpp>
#include <nui/frontend/event_system/observed_value.hpp>
#include <nui/frontend/event_system/observed_value.hpp>
#include <nui/frontend/dom/element.hpp>

#include <functional>
Expand Down Expand Up @@ -33,9 +32,9 @@ namespace Nui::Components
struct ConstructionArgs
{
std::optional<std::string> 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<void(Button)> onButtonClicked = [](Button) {};
};
Expand All @@ -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).
Expand Down
2 changes: 0 additions & 2 deletions nui/include/nui/frontend/components/table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include <nui/frontend/element_renderer.hpp>

#include <string>
#include <optional>
#include <functional>
#include <memory>
#include <vector>

namespace Nui::Components
Expand Down
7 changes: 7 additions & 0 deletions nui/include/nui/frontend/dom/basic_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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_);
Expand Down
2 changes: 1 addition & 1 deletion nui/include/nui/frontend/dom/dom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <nui/frontend/elements/impl/html_element.hpp>
#include <nui/frontend/dom/element.hpp>

#include <optional>
#include <memory>

namespace Nui::Dom
{
Expand Down
5 changes: 2 additions & 3 deletions nui/include/nui/frontend/dom/element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace Nui::Dom
Element& operator=(Element const&) = delete;
Element& operator=(Element&&) = delete;

~Element()
~Element() override
{
clearChildren();
destroy_(element_);
Expand Down Expand Up @@ -277,8 +277,7 @@ namespace Nui::Dom
{
if (where >= children_.size())
return appendElement(element);
else
return insert(begin() + static_cast<decltype(children_)::difference_type>(where), element);
return insert(begin() + static_cast<decltype(children_)::difference_type>(where), element);
}

auto& operator[](std::size_t index)
Expand Down
1 change: 0 additions & 1 deletion nui/include/nui/frontend/dom/reference.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <nui/frontend/dom/basic_element.hpp>

#include <concepts>
#include <functional>
#include <memory>
#include <type_traits>
Expand Down
3 changes: 3 additions & 0 deletions nui/include/nui/frontend/elements/detail/fragment_context.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

#include <vector>
#include <memory>

namespace Nui::Detail
{
template <typename ElementT>
Expand Down
4 changes: 3 additions & 1 deletion nui/include/nui/frontend/elements/impl/html_element.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Nui
}
}

// NOLINTBEGIN
#define NUI_MAKE_HTML_ELEMENT_RENAME(NAME, HTML_ACTUAL) \
struct NAME : ::Nui::HtmlElement \
{ \
Expand All @@ -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)
#define NUI_DECLARE_HTML_ELEMENT(NAME) NUI_DECLARE_HTML_ELEMENT_RENAME(NAME, #NAME)
// NOLINTEND
5 changes: 5 additions & 0 deletions nui/include/nui/frontend/elements/impl/materialize.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#include <nui/frontend/val.hpp>

#include <type_traits>
#include <cstddef>

namespace Nui
{
class HtmlElement;
Expand Down
53 changes: 28 additions & 25 deletions nui/src/nui/backend/filesystem/file_dialog_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,36 @@

namespace Nui::FileDialog
{
//#####################################################################################################################
template <typename T>
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 <typename T>
void from_json_common(nlohmann::json const& json, T& options)
{
if (json.contains("title"))
options.title = json["title"].get<std::string>();
else
options.title = std::nullopt;
template <typename T>
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 <typename T>
void from_json_common(nlohmann::json const& json, T& options)
{
if (json.contains("title"))
options.title = json["title"].get<std::string>();
else
options.title = std::nullopt;

if (json.contains("defaultPath"))
options.defaultPath = json["defaultPath"].get<std::string>();
else
options.defaultPath = std::nullopt;
if (json.contains("defaultPath"))
options.defaultPath = json["defaultPath"].get<std::string>();
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)
Expand Down Expand Up @@ -64,5 +67,5 @@ namespace Nui::FileDialog
from_json_common(json, options);
options.forceOverwrite = json["forceOverwrite"].get<bool>();
}
//#####################################################################################################################
// #####################################################################################################################
}

0 comments on commit 68f7208

Please sign in to comment.