mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-22 10:16:39 +00:00
UserTitleTab: remove the need for a title ID map by extending the ListItem class.
Each ListItem element gets its own internal title ID.
This commit is contained in:
parent
b5507b38a6
commit
7a15b4eab8
3 changed files with 18 additions and 18 deletions
|
@ -29,12 +29,21 @@
|
|||
|
||||
namespace nxdt::views
|
||||
{
|
||||
/* Expanded ListItem class to hold a title ID. */
|
||||
class UserTitlesItem: public brls::ListItem
|
||||
{
|
||||
private:
|
||||
u64 title_id = 0;
|
||||
|
||||
public:
|
||||
UserTitlesItem(TitleApplicationMetadata *app_metadata);
|
||||
};
|
||||
|
||||
class UserTitlesTab: public LayeredErrorFrame
|
||||
{
|
||||
private:
|
||||
nxdt::tasks::TitleTask *title_task = nullptr;
|
||||
nxdt::tasks::TitleEvent::Subscription title_task_sub;
|
||||
std::unordered_map<brls::ListItem*, TitleApplicationMetadata*> list_item_metadata;
|
||||
|
||||
void PopulateList(const nxdt::tasks::TitleApplicationMetadataVector* user_app_metadata);
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 053870cd5e2402d180d858ca502fb90db6809279
|
||||
Subproject commit 7de16249a693e187e7249404d41e0da8a5572bf6
|
|
@ -26,6 +26,12 @@ using namespace brls::i18n::literals; /* For _i18n. */
|
|||
|
||||
namespace nxdt::views
|
||||
{
|
||||
UserTitlesItem::UserTitlesItem(TitleApplicationMetadata *app_metadata) : brls::ListItem(std::string(app_metadata->lang_entry.name), "", std::string(app_metadata->lang_entry.author)), \
|
||||
title_id(app_metadata->title_id)
|
||||
{
|
||||
if (app_metadata->icon && app_metadata->icon_size) this->setThumbnail(app_metadata->icon, app_metadata->icon_size);
|
||||
}
|
||||
|
||||
UserTitlesTab::UserTitlesTab(nxdt::tasks::TitleTask *title_task) : LayeredErrorFrame("user_titles_tab/no_titles_available"_i18n), title_task(title_task)
|
||||
{
|
||||
/* Populate list. */
|
||||
|
@ -43,9 +49,6 @@ namespace nxdt::views
|
|||
{
|
||||
/* Unregister task listener. */
|
||||
this->title_task->UnregisterListener(this->title_task_sub);
|
||||
|
||||
/* Clear user application metadata map. */
|
||||
this->list_item_metadata.clear();
|
||||
}
|
||||
|
||||
void UserTitlesTab::PopulateList(const nxdt::tasks::TitleApplicationMetadataVector* user_app_metadata)
|
||||
|
@ -78,23 +81,11 @@ namespace nxdt::views
|
|||
this->list->clear();
|
||||
this->list->invalidate(true);
|
||||
|
||||
/* Clear our private user application map. */
|
||||
this->list_item_metadata.clear();
|
||||
|
||||
/* Immediately return if we have no user application metadata. */
|
||||
if (!user_app_metadata_count) return;
|
||||
|
||||
/* Populate list. */
|
||||
for(TitleApplicationMetadata *cur_app_metadata : *user_app_metadata)
|
||||
{
|
||||
/* Add list item for this application metadata to our list. */
|
||||
brls::ListItem *list_item = new brls::ListItem(std::string(cur_app_metadata->lang_entry.name), "", std::string(cur_app_metadata->lang_entry.author));
|
||||
list_item->setThumbnail(cur_app_metadata->icon, cur_app_metadata->icon_size);
|
||||
this->list->addView(list_item);
|
||||
|
||||
/* Update our private user application metadata map. */
|
||||
this->list_item_metadata.insert(std::make_pair(list_item, cur_app_metadata));
|
||||
}
|
||||
for(TitleApplicationMetadata *cur_app_metadata : *user_app_metadata) this->list->addView(new UserTitlesItem(cur_app_metadata));
|
||||
|
||||
/* Switch to the list. */
|
||||
this->list->invalidate(true);
|
||||
|
|
Loading…
Reference in a new issue