aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/NyaaSi.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-08-03 15:06:57 +0200
committerdec05eba <dec05eba@protonmail.com>2021-08-05 05:50:23 +0200
commit6c85194c3b1baef0eaa011c4f1b8e48e11860f45 (patch)
tree61f3eb4304091fd2203519702a4f4daf184c5a59 /src/plugins/NyaaSi.cpp
parentcbc6997c0a5659239d2cd971f2fa77eeda53550b (diff)
Make body items private, add accessor functions
This allows body to automatically update dirty state (and other states). Correctly format newlines in codeblocks in matrix.
Diffstat (limited to 'src/plugins/NyaaSi.cpp')
-rw-r--r--src/plugins/NyaaSi.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp
index ccf027d..8e55e62 100644
--- a/src/plugins/NyaaSi.cpp
+++ b/src/plugins/NyaaSi.cpp
@@ -134,12 +134,12 @@ namespace QuickMedia {
return body_item;
}
- static void sort_page_create_body_items(BodyItems &body_items, NyaaSiSortType sort_type) {
+ static void sort_page_create_body_items(Body *body, NyaaSiSortType sort_type) {
for(size_t i = 0; i < sort_type_names.size(); ++i) {
std::string prefix = " ";
if((NyaaSiSortType)i == sort_type)
prefix = "* ";
- body_items.push_back(create_sort_body_item(prefix + sort_type_names[i], (NyaaSiSortType)i));
+ body->append_item(create_sort_body_item(prefix + sort_type_names[i], (NyaaSiSortType)i));
}
}
@@ -294,12 +294,12 @@ namespace QuickMedia {
auto search_page = std::make_unique<NyaaSiSearchPage>(program, strip(title), url, std::move(domain));
NyaaSiSearchPage *search_page_p = search_page.get();
auto body = create_body();
- body->items = std::move(result_items);
+ body->set_items(std::move(result_items));
result_tabs.push_back(Tab{std::move(body), std::move(search_page), create_search_bar("Search...", 500)});
auto sort_order_page_body = create_body();
Body *sort_order_page_body_p = sort_order_page_body.get();
- sort_page_create_body_items(sort_order_page_body->items, NyaaSiSortType::UPLOAD_DATE_DESC);
+ sort_page_create_body_items(sort_order_page_body_p, NyaaSiSortType::UPLOAD_DATE_DESC);
result_tabs.push_back(Tab{std::move(sort_order_page_body), std::make_unique<NyaaSiSortOrderPage>(program, sort_order_page_body_p, search_page_p), nullptr});
return PluginResult::OK;
}
@@ -486,7 +486,7 @@ namespace QuickMedia {
return PluginResult::ERR;
auto body = create_body();
- body->items = std::move(result_items);
+ body->set_items(std::move(result_items));
result_tabs.push_back(Tab{std::move(body), std::make_unique<NyaaSiTorrentPage>(program), nullptr});
return PluginResult::OK;
}
@@ -499,8 +499,8 @@ namespace QuickMedia {
PluginResult NyaaSiSortOrderPage::submit(const std::string&, const std::string&, std::vector<Tab>&) {
const NyaaSiSortType sort_type = (NyaaSiSortType)(size_t)submit_body_item->userdata;
- body->items.clear();
- sort_page_create_body_items(body->items, sort_type);
+ body->clear_items();
+ sort_page_create_body_items(body, sort_type);
search_page->set_sort_type(sort_type);
search_page->needs_refresh = true;
return PluginResult::OK;