diff options
Diffstat (limited to 'include/Body.hpp')
-rw-r--r-- | include/Body.hpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/include/Body.hpp b/include/Body.hpp index 4c7044d..86b6984 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -1,5 +1,6 @@ #pragma once +#include "Text.hpp" #include <SFML/Graphics/Font.hpp> #include <SFML/Graphics/Text.hpp> #include <SFML/Graphics/Texture.hpp> @@ -12,18 +13,29 @@ namespace QuickMedia { class BodyItem { public: - BodyItem(std::string _title): visible(true), num_lines(1) { + BodyItem(std::string _title): visible(true), dirty(true) { set_title(std::move(_title)); } + BodyItem(const BodyItem &other) { + title = other.title; + url = other.url; + thumbnail_url = other.thumbnail_url; + attached_content_url = other.attached_content_url; + author = other.author; + visible = other.visible; + dirty = other.dirty; + if(other.title_text) + title_text = std::make_unique<Text>(*other.title_text); + else + title_text = nullptr; + replies = other.replies; + post_number = other.post_number; + } + void set_title(std::string new_title) { title = std::move(new_title); - // TODO: Optimize this - num_lines = 1; - for(char c : title) { - if(c == '\n') - ++num_lines; - } + dirty = true; } std::string title; @@ -32,9 +44,10 @@ namespace QuickMedia { std::string attached_content_url; std::string author; bool visible; + bool dirty; + std::unique_ptr<Text> title_text; // Used by image boards for example. The elements are indices to other body items std::vector<size_t> replies; - int num_lines; std::string post_number; }; |