diff --git a/UI/ui_combobox.cpp b/UI/ui_combobox.cpp index bb1f686..125aa74 100644 --- a/UI/ui_combobox.cpp +++ b/UI/ui_combobox.cpp @@ -16,7 +16,7 @@ void UI_combobox::set_selected(size_t selected) { if (selected == m_selected) return; - m_selected = selected; + m_selected = std::move(selected); emit ui_changed(); emit changed(selected_text()); } @@ -38,7 +38,7 @@ size_t UI_combobox::selected() const return m_selected; } -std::string UI_combobox::selected_text() const +std::string UI_combobox::selected_text() const & { return m_options[m_selected]; } diff --git a/UI/ui_combobox.hpp b/UI/ui_combobox.hpp index 57fec59..f2c39f6 100644 --- a/UI/ui_combobox.hpp +++ b/UI/ui_combobox.hpp @@ -52,7 +52,7 @@ class UI_combobox : public UI_item * * @return std::string The text of the selected option */ - std::string selected_text() const; + std::string selected_text() const &; /** * @brief Deserialize the combobox from JSON diff --git a/UI/ui_dial.cpp b/UI/ui_dial.cpp index 6a9f732..8b2660e 100644 --- a/UI/ui_dial.cpp +++ b/UI/ui_dial.cpp @@ -52,7 +52,7 @@ double UI_dial::max() const return m_max; } -std::string UI_dial::unit() const +std::string UI_dial::unit() const & { return m_unit; } diff --git a/UI/ui_dial.hpp b/UI/ui_dial.hpp index 1f4d691..2f9c36c 100644 --- a/UI/ui_dial.hpp +++ b/UI/ui_dial.hpp @@ -96,7 +96,7 @@ class UI_dial : public UI_item * * @return std::string The unit of the dial */ - std::string unit() const; + std::string unit() const &; /** * @brief Deserialize the dial from JSON diff --git a/UI/ui_item.cpp b/UI/ui_item.cpp index 09fb754..33b9457 100644 --- a/UI/ui_item.cpp +++ b/UI/ui_item.cpp @@ -12,7 +12,7 @@ UI_item::UI_item(std::string type, QObject *parent) { } -std::string UI_item::type() const +std::string UI_item::type() const & { return m_type; } @@ -30,7 +30,7 @@ void UI_item::set_text(std::string text) { if (this->m_text != text) { - this->m_text = text; + this->m_text = std::move(text); emit ui_changed(); } } @@ -41,7 +41,7 @@ void UI_item::append_text(std::string text) emit ui_changed(); } -std::string UI_item::text() const +std::string UI_item::text() const & { return m_text; } @@ -50,12 +50,12 @@ void UI_item::set_fg_color(Color fg_color) { if (this->m_fg_color != fg_color) { - this->m_fg_color = fg_color; + this->m_fg_color = std::move(fg_color); emit ui_changed(); } } -Color UI_item::fg_color() const +Color UI_item::fg_color() const & { return m_fg_color; } @@ -64,12 +64,12 @@ void UI_item::set_bg_color(Color bg_color) { if (this->m_bg_color != bg_color) { - this->m_bg_color = bg_color; + this->m_bg_color = std::move(bg_color); emit ui_changed(); } } -Color UI_item::bg_color() const +Color UI_item::bg_color() const & { return m_bg_color; } @@ -78,7 +78,7 @@ void UI_item::set_enabled(bool enabled) { if (this->m_enabled != enabled) { - this->m_enabled = enabled; + this->m_enabled = std::move(enabled); emit ui_changed(); } } @@ -92,7 +92,7 @@ void UI_item::set_visible(bool visible) { if (this->m_visible != visible) { - this->m_visible = visible; + this->m_visible = std::move(visible); emit ui_changed(); } } diff --git a/UI/ui_item.hpp b/UI/ui_item.hpp index e6edf42..9bd5edc 100644 --- a/UI/ui_item.hpp +++ b/UI/ui_item.hpp @@ -41,7 +41,7 @@ class UI_item : public QObject * * @return std::string The type of the UI item */ - std::string type() const; + std::string type() const &; /** * @brief Check if the JSON object is of the correct type * @@ -68,7 +68,7 @@ class UI_item : public QObject * * @return std::string The text of the UI item */ - std::string text() const; + std::string text() const &; /** * @brief Set the foreground color of the UI item @@ -81,7 +81,7 @@ class UI_item : public QObject * * @return Color The foreground color of the UI item */ - Color fg_color() const; + Color fg_color() const &; /** * @brief Set the background color of the UI item @@ -94,7 +94,7 @@ class UI_item : public QObject * * @return Color The background color of the UI item */ - Color bg_color() const; + Color bg_color() const &; /** * @brief Enable or disable the UI item diff --git a/UI/ui_plot.cpp b/UI/ui_plot.cpp index 9a56895..1b69115 100644 --- a/UI/ui_plot.cpp +++ b/UI/ui_plot.cpp @@ -12,24 +12,24 @@ UI_plot::UI_plot(std::string text, std::string x_label, std::string y_label, QOb void UI_plot::set_x_label(std::string name) { - m_x_label = name; + m_x_label = std::move(name); emit ui_changed(); } -std::string UI_plot::x_label() const +std::string UI_plot::x_label() const & { return m_x_label; } void UI_plot::set_y_label(std::string name) { - m_y_label = name; + m_y_label = std::move(name); emit ui_changed(); } -std::string UI_plot::y_label() const +std::string UI_plot::y_label() const & { return m_y_label; } @@ -50,12 +50,12 @@ void UI_plot::add_value(double x, double y) emit ui_changed(); } -const std::vector &UI_plot::x_vals() const +const std::vector &UI_plot::x_vals() const & { return m_x_vals; } -const std::vector &UI_plot::y_vals() const +const std::vector &UI_plot::y_vals() const & { return m_y_vals; } diff --git a/UI/ui_plot.hpp b/UI/ui_plot.hpp index 249897d..9996ee7 100644 --- a/UI/ui_plot.hpp +++ b/UI/ui_plot.hpp @@ -37,7 +37,7 @@ class UI_plot : public UI_item * * @return std::string The x-axis label */ - std::string x_label() const; + std::string x_label() const &; /** * @brief Set the label for the y-axis @@ -50,7 +50,7 @@ class UI_plot : public UI_item * * @return std::string The y-axis label */ - std::string y_label() const; + std::string y_label() const &; /** * @brief Add a value to the plot @@ -71,14 +71,14 @@ class UI_plot : public UI_item * * @return a list of x values and a list of y values */ - const std::vector &x_vals() const; + const std::vector &x_vals() const &; /** * @brief Get the y values of the plot * This is only for testing purposes * * @return a list of y values */ - const std::vector &y_vals() const; + const std::vector &y_vals() const &; /** * @brief Clear all values from the plot * diff --git a/UI/ui_status_bar.cpp b/UI/ui_status_bar.cpp index 0926517..4e02038 100644 --- a/UI/ui_status_bar.cpp +++ b/UI/ui_status_bar.cpp @@ -7,19 +7,19 @@ UI_status_bar::UI_status_bar(QObject *parent) : UI_item(UI_STATUS_BAR_TYPE, pare UI_status_bar::UI_status_bar(std::string message, QObject *parent) : UI_item(UI_STATUS_BAR_TYPE, parent), m_timeout(0) { - m_text = message; + m_text = std::move(message); setup_item(true, false, false); } void UI_status_bar::show_message(std::string message, size_t timeout) { // This should work because the message gets only send once when it changes - m_text = message; + m_text = std::move(message); m_timeout = timeout; emit ui_changed(); } -std::string UI_status_bar::message() const +std::string UI_status_bar::message() const & { return m_text; } diff --git a/UI/ui_status_bar.hpp b/UI/ui_status_bar.hpp index 10a66c8..f79aed1 100644 --- a/UI/ui_status_bar.hpp +++ b/UI/ui_status_bar.hpp @@ -36,7 +36,7 @@ class UI_status_bar : public UI_item * * @return std::string The current message */ - std::string message() const; + std::string message() const &; /** * @brief Get the timeout for the current message * diff --git a/UI/ui_table.cpp b/UI/ui_table.cpp index d78cc05..3c431a4 100644 --- a/UI/ui_table.cpp +++ b/UI/ui_table.cpp @@ -90,7 +90,7 @@ void UI_table::set_column_label(size_t index, std::string label) emit ui_changed(); } -std::string UI_table::column_label(size_t index) const +std::string UI_table::column_label(size_t index) const & { if (m_column_count <= index) { @@ -113,12 +113,12 @@ void UI_table::insert_item(size_t row, size_t column, std::string text) size_t index = row * m_column_count + column; - m_table.at(index) = text; + m_table.at(index) = std::move(text); emit ui_changed(); } -std::string UI_table::item(size_t row, size_t column) const +std::string UI_table::item(size_t row, size_t column) const & { if (m_column_count <= column || m_row_count <= row) { diff --git a/UI/ui_table.hpp b/UI/ui_table.hpp index be22468..15bb96c 100644 --- a/UI/ui_table.hpp +++ b/UI/ui_table.hpp @@ -90,7 +90,7 @@ class UI_table : public UI_item * @param index The index of the column * @return std::string The label of the column */ - std::string column_label(size_t index) const; + std::string column_label(size_t index) const &; /** * @brief Insert an item into the table at the specified row and column @@ -107,7 +107,7 @@ class UI_table : public UI_item * @param column The column of the item * @return std::string The text of the item */ - std::string item(size_t row, size_t column) const; + std::string item(size_t row, size_t column) const &; /** * @brief empty_item This function clears the item diff --git a/UI/ui_textbox.cpp b/UI/ui_textbox.cpp index 3a3350c..1e9abae 100644 --- a/UI/ui_textbox.cpp +++ b/UI/ui_textbox.cpp @@ -13,18 +13,18 @@ void UI_textbox::set_text(std::string text) { if (text == m_text) return; - m_text = text; + m_text = std::move(text); emit ui_changed(); emit changed(m_text); } void UI_textbox::set_hint(std::string hint) { - m_hint = hint; + m_hint = std::move(hint); emit ui_changed(); } -std::string UI_textbox::hint() const +std::string UI_textbox::hint() const & { return m_hint; } diff --git a/UI/ui_textbox.hpp b/UI/ui_textbox.hpp index 49b888c..449e5f2 100644 --- a/UI/ui_textbox.hpp +++ b/UI/ui_textbox.hpp @@ -46,7 +46,7 @@ class UI_textbox : public UI_item * * @return std::string The hint text */ - std::string hint() const; + std::string hint() const &; /** * @brief Deserialize the textbox from JSON