Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Category Revamp #1880

Merged
merged 43 commits into from
Sep 25, 2023
Merged

WIP: Category Revamp #1880

merged 43 commits into from
Sep 25, 2023

Conversation

Silarn
Copy link
Member

@Silarn Silarn commented Sep 19, 2023

Nexus category import
Updated category editor pane
Update / init dialogs when loading a new / old instance
Setting to enable or disable Nexus mappings
Unmapped categories will trigger a dialog asking to ignore, map, or disable mappings
Autoassignable via dropdown / context menu

TODO: Add Nexus category ID to mod info so we don't rely on download info

@Silarn
Copy link
Member Author

Silarn commented Sep 21, 2023

So I'll probably squash these merge commits but I think I'm ready for you to review this. I may put out one more build tomorrow with the recent changes. But I think this is in a pretty good state at this point. At least for a first version.

Silarn and others added 26 commits September 21, 2023 16:30
* No longer cause an error when deleting a category that's being used
* Add a dialog when installing a mod with no Nexus mapping (if not disabled)
* Allow disabling Nexus category mapping in Settings (Nexus tab)
* Add context option to remove nexus mappings in the category editor
* Some clang style fixes
- We will check the mod info first then fall back to the download file
- Add category field in the info dialog nexus tab
- Bypasses issue where hidden downloads are not accessible
- getCategoryID no longer necessary
- Merge or replace strategies
- Nexus mappings are optional
- If mappings are applied, remapping is optional
Copy link
Member

@Holt59 Holt59 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me from a code point-of-view, I'd have to test it but I'm not sure I'll have time, except for:

  • I don't see why instance() returns a pointer now (reference before). This makes a lot of changes for not much in this PR since the function always return a non-null value (and the return is never checked anyway).
  • I don't like the plugin container added to the category dialog because it means passing a big object (in term of features) to a deep dialog. I feel like setting the container should not be needed.
  • I think the version.rc file is broken, maybe due to clang format.

src/version.rc Outdated

VS_VERSION_INFO VERSIONINFO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right.

void CategoriesDialog::nexusRefresh_clicked()
{
NexusInterface& nexus = NexusInterface::instance();
nexus.setPluginContainer(m_PluginContainer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what this does here and this is the only place where the plugin container is used in the dialog, so this single line mean the plugin container needs to be pass all the way down here for not much.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to avoid having to take multiple steps to route the signal to the Nexus API and get useable data back to the Dialog.

But I've done so now anyway.

}

CategoryFactory& CategoryFactory::instance()
CategoryFactory* CategoryFactory::instance()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not return a pointer since this can never be null.

}

void CategoryFactory::reset()
{
m_Categories.clear();
m_NexusMap.clear();
m_IDMap.clear();
// 28 =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove the comments since the value are not hardcoded anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling these were somehow left behind after a rebase at some point.

src/categories.h Outdated
: m_SortValue(sortValue), m_ID(id), m_Name(name), m_HasChildren(false),
m_NexusIDs(nexusIDs), m_ParentID(parentID)
m_ParentID(parentID), m_NexusCats(nexusCats)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nexusCats should be moved here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming you are wanting to simply replace the old 'nexusIDs' but I moved this because it matched the order of the data in the CategoryDialog table.

Therefore I'm not sure I agree with simply replacing the old parameter, as this did have a reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I was simply saying that this should be m_NexusCats(std::move(nexusCats)) since you are taking nexusCats by value, but that's a very minor thing. ;)

@@ -1321,6 +1321,21 @@ QString DownloadManager::getFileName(int index) const
return m_ActiveDownloads.at(index)->m_FileName;
}

int DownloadManager::getDownloadIndex(QString filename) const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like this should not be in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I added these because I thought I needed them to get the category ID from the download during the install but I was able to pull it with the post-install nexus API call instead. So this function is not needed.

* @param filename the filename of the download
* @return the index of the file
*/
int getDownloadIndex(QString filename) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -424,7 +425,7 @@ void FilterList::checkCriteria()

void FilterList::editCategories()
{
CategoriesDialog dialog(qApp->activeWindow());
CategoriesDialog dialog(&m_core.pluginContainer(), qApp->activeWindow());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment, I feel like we should not need to pass the plugin container.

src/filterlist.h Outdated
@@ -9,6 +9,7 @@ namespace Ui
class MainWindow;
};
class CategoryFactory;
class PluginContainer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not commit this since this main conflict with other PRs.

@Silarn
Copy link
Member Author

Silarn commented Sep 23, 2023

I started working on this so long ago that I'm not entirely sure why I decided some things were necessary at the time. I'll have to dig into this more later since I'm low on time, but I can probably restructure the nexus call to trigger from the mainwindow or core. That should probably cascade to allow most of these issues to be resolved.

- Remove plugins class
- Route signals to run Nexus API call from MainWindow
- Pass Dialog instance to route response data
- Revert CategoryFactory::instance to return reference
I think VS did this when I tried to use the GUI
@Silarn Silarn requested a review from Holt59 September 24, 2023 02:25
Copy link
Member

@Holt59 Holt59 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some minor comments, most of which are cleaning of old for loop style, otherwise looks good to me.

// 28 =
// 43 = Savegames (makes no sense to install them through MO)
// 45 = Videos and trailers
// 87 = Miscelanous
addCategory(0, "None", std::vector<NexusCategory>(), 0);
}

void CategoryFactory::setParents()
{
for (std::vector<Category>::iterator iter = m_Categories.begin();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be changed to a C++11 for-loop.

addCategory(0, "None", std::vector<NexusCategory>(), 0);
}

void CategoryFactory::setParents()
{
for (std::vector<Category>::iterator iter = m_Categories.begin();
iter != m_Categories.end(); ++iter) {
iter->m_HasChildren = false;
iter->setHasChildren(false);
}

for (std::vector<Category>::const_iterator categoryIter = m_Categories.begin();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be changed to a C++11 for-loop.

@@ -201,15 +197,15 @@ void CategoryFactory::saveCategories()
categoryFile.resize(0);
for (std::vector<Category>::const_iterator iter = m_Categories.begin();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be changed to a C++11 for-loop.

@@ -225,9 +221,9 @@ void CategoryFactory::saveCategories()
nexusMapFile.resize(0);
for (auto iter = m_NexusMap.begin(); iter != m_NexusMap.end(); ++iter) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be changed to a C++11/17 for-loop.

@@ -274,8 +270,8 @@ void CategoryFactory::addCategory(int id, const QString& name,
int parentID)
{
for (auto nexusCat : nexusCats) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be const auto& nexusCat, otherwise you are making a copy and I don't think that's wanted here.

@@ -285,14 +281,18 @@ void CategoryFactory::addCategory(int id, const QString& name,
void CategoryFactory::setNexusCategories(
std::vector<CategoryFactory::NexusCategory>& nexusCats)
{
m_NexusMap.empty();
for (auto nexusCat : nexusCats) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be const auto& nexusCat, otherwise you are making a copy and I don't think that's wanted here.

@@ -285,14 +281,18 @@ void CategoryFactory::addCategory(int id, const QString& name,
void CategoryFactory::setNexusCategories(
std::vector<CategoryFactory::NexusCategory>& nexusCats)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be taken by const-reference I think.

@@ -211,22 +210,22 @@ void CategoriesDialog::fillTable()

int row = 0;
for (std::vector<CategoryFactory::Category>::const_iterator iter =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to a C++11 for loop and move the ++row, or at least use auto :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason when I change this loop, it's failing to load the Category data causing the Table to be blank when you initialize the dialog.

I'm probably doing something wrong somewhere, but I'm not sure what.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a ++row in this for loop so you need to move it somewhere if you change to a range-loop.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did that. For some reason the element seemed to have uninitialized values when using the C++11 loop. I wasn't able to figure why the data wasn't loading properly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, don't code when it's pushing 4AM. I was putting the ++row at the front of the loop instead of the back.

I'll push the updated version shortly.

@@ -235,17 +234,17 @@ void CategoriesDialog::fillTable()
table->setItem(row, 3, nexusCatItem.take());
}

for (auto nexusCat : categories->m_NexusMap) {
for (auto nexusCat : categories.m_NexusMap) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be const auto&.

@Silarn
Copy link
Member Author

Silarn commented Sep 24, 2023

Understood. I think I can wrap those changes up before I head to bed.

* row increment needs to be before the logic but after the ID check/continue
* avoid running context menu logic on null rows
@Silarn Silarn merged commit 79d457f into master Sep 25, 2023
3 checks passed
@Silarn Silarn deleted the qt6-category branch September 25, 2023 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants