From 127db7799ed4847b151a35a16cefab6c494128ef Mon Sep 17 00:00:00 2001 From: Silarn Date: Mon, 23 Dec 2019 23:16:36 -0600 Subject: WIP: Category QObj refactor --- src/modlist.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/modlist.cpp') diff --git a/src/modlist.cpp b/src/modlist.cpp index 7a951369..41d679d9 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -232,11 +232,11 @@ QVariant ModList::data(const QModelIndex& modelIndex, int role) const } else { int category = modInfo->primaryCategory(); if (category != -1) { - CategoryFactory& categoryFactory = CategoryFactory::instance(); - if (categoryFactory.categoryExists(category)) { + CategoryFactory* categoryFactory = CategoryFactory::instance(); + if (categoryFactory->categoryExists(category)) { try { - int categoryIdx = categoryFactory.getCategoryIndex(category); - return categoryFactory.getCategoryName(categoryIdx); + int categoryIdx = categoryFactory->getCategoryIndex(category); + return categoryFactory->getCategoryName(categoryIdx); } catch (const std::exception& e) { log::error("failed to retrieve category name: {}", e.what()); return QString(); @@ -285,11 +285,10 @@ QVariant ModList::data(const QModelIndex& modelIndex, int role) const } else if (role == GroupingRole) { if (column == COL_CATEGORY) { QVariantList categoryNames; - std::set categories = modInfo->getCategories(); - CategoryFactory& categoryFactory = CategoryFactory::instance(); + std::set categories = modInfo->getCategories(); + CategoryFactory* categoryFactory = CategoryFactory::instance(); for (auto iter = categories.begin(); iter != categories.end(); ++iter) { - categoryNames.append( - categoryFactory.getCategoryName(categoryFactory.getCategoryIndex(*iter))); + categoryNames.append(categoryFactory->getCategoryName(categoryFactory->getCategoryIndex(*iter))); } if (categoryNames.count() != 0) { return categoryNames; @@ -447,17 +446,14 @@ QVariant ModList::data(const QModelIndex& modelIndex, int role) const const std::set& categories = modInfo->getCategories(); std::wostringstream categoryString; categoryString << ToWString(tr("Categories:
")); - CategoryFactory& categoryFactory = CategoryFactory::instance(); + CategoryFactory* categoryFactory = CategoryFactory::instance(); for (std::set::const_iterator catIter = categories.begin(); catIter != categories.end(); ++catIter) { if (catIter != categories.begin()) { categoryString << " , "; } try { - categoryString << "" - << ToWString(categoryFactory.getCategoryName( - categoryFactory.getCategoryIndex(*catIter))) - << ""; + categoryString << "" << ToWString(categoryFactory->getCategoryName(categoryFactory->getCategoryIndex(*catIter))) << ""; } catch (const std::exception& e) { log::error("failed to generate tooltip: {}", e.what()); return QString(); -- cgit v1.3.1