-
Notifications
You must be signed in to change notification settings - Fork 165
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
WIP: Category Revamp #1880
Conversation
fdee52b
to
0c094a1
Compare
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. |
* 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
4b459c3
to
d2e48ed
Compare
- Merge or replace strategies - Nexus mappings are optional - If mappings are applied, remapping is optional
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
src/categoriesdialog.cpp
Outdated
void CategoriesDialog::nexusRefresh_clicked() | ||
{ | ||
NexusInterface& nexus = NexusInterface::instance(); | ||
nexus.setPluginContainer(m_PluginContainer); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
} | ||
|
||
CategoryFactory& CategoryFactory::instance() | ||
CategoryFactory* CategoryFactory::instance() |
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
} | ||
|
||
void CategoryFactory::reset() | ||
{ | ||
m_Categories.clear(); | ||
m_NexusMap.clear(); | ||
m_IDMap.clear(); | ||
// 28 = |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. ;)
src/downloadmanager.cpp
Outdated
@@ -1321,6 +1321,21 @@ QString DownloadManager::getFileName(int index) const | |||
return m_ActiveDownloads.at(index)->m_FileName; | |||
} | |||
|
|||
int DownloadManager::getDownloadIndex(QString filename) const |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/downloadmanager.h
Outdated
* @param filename the filename of the download | ||
* @return the index of the file | ||
*/ | ||
int getDownloadIndex(QString filename) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
src/filterlist.cpp
Outdated
@@ -424,7 +425,7 @@ void FilterList::checkCriteria() | |||
|
|||
void FilterList::editCategories() | |||
{ | |||
CategoriesDialog dialog(qApp->activeWindow()); | |||
CategoriesDialog dialog(&m_core.pluginContainer(), qApp->activeWindow()); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
src/organizer_en.ts
Outdated
There was a problem hiding this comment.
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.
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
- Accidentally added to this branch
b7f2c36
to
11522cf
Compare
There was a problem hiding this 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.
src/categories.cpp
Outdated
// 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(); |
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
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(); |
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
@@ -201,15 +197,15 @@ void CategoryFactory::saveCategories() | |||
categoryFile.resize(0); | |||
for (std::vector<Category>::const_iterator iter = m_Categories.begin(); |
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
@@ -225,9 +221,9 @@ void CategoryFactory::saveCategories() | |||
nexusMapFile.resize(0); | |||
for (auto iter = m_NexusMap.begin(); iter != m_NexusMap.end(); ++iter) { |
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
@@ -274,8 +270,8 @@ void CategoryFactory::addCategory(int id, const QString& name, | |||
int parentID) | |||
{ | |||
for (auto nexusCat : nexusCats) { |
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
@@ -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) { |
There was a problem hiding this comment.
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.
src/categories.cpp
Outdated
@@ -285,14 +281,18 @@ void CategoryFactory::addCategory(int id, const QString& name, | |||
void CategoryFactory::setNexusCategories( | |||
std::vector<CategoryFactory::NexusCategory>& nexusCats) |
There was a problem hiding this comment.
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.
src/categoriesdialog.cpp
Outdated
@@ -211,22 +210,22 @@ void CategoriesDialog::fillTable() | |||
|
|||
int row = 0; | |||
for (std::vector<CategoryFactory::Category>::const_iterator iter = |
There was a problem hiding this comment.
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
:)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/categoriesdialog.cpp
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be const auto&
.
Understood. I think I can wrap those changes up before I head to bed. |
c97a15e
to
c30b518
Compare
* row increment needs to be before the logic but after the ID check/continue * avoid running context menu logic on null rows
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