diff options
| author | LostDragonist <lost.dragonist@gmail.com> | 2018-12-14 17:26:37 -0600 |
|---|---|---|
| committer | LostDragonist <lost.dragonist@gmail.com> | 2018-12-20 20:57:09 -0600 |
| commit | 70ddfaadbfdf3999eea0fe50f7cdac3675e5f019 (patch) | |
| tree | e2c6117585afa759dcb22e9421bfba3622b24a2b /src/modlistsortproxy.cpp | |
| parent | afdd21440aa761e023f0ed991a75e318ad8298b7 (diff) | |
Expand mod list search edit to work on categories, nexus IDs, and notes
Diffstat (limited to 'src/modlistsortproxy.cpp')
| -rw-r--r-- | src/modlistsortproxy.cpp | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 9adaa511..b5f1ee5c 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -39,10 +39,6 @@ ModListSortProxy::ModListSortProxy(Profile* profile, QObject *parent) , m_FilterActive(false)
, m_FilterMode(FILTER_AND)
{
- m_EnabledColumns.set(ModList::COL_FLAGS);
- m_EnabledColumns.set(ModList::COL_NAME);
- m_EnabledColumns.set(ModList::COL_VERSION);
- m_EnabledColumns.set(ModList::COL_PRIORITY);
setDynamicSortFilter(true); // this seems to work without dynamicsortfilter
// but I don't know why. This should be necessary
}
@@ -340,8 +336,53 @@ bool ModListSortProxy::filterMatchesModOr(ModInfo::Ptr info, bool enabled) const bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const
{
- if (!m_CurrentFilter.isEmpty() &&
- !info->name().contains(m_CurrentFilter, Qt::CaseInsensitive)) {
+ bool display = true;
+ if (!m_CurrentFilter.isEmpty()) {
+ display = false;
+
+ // Search by name
+ if (!display &&
+ m_EnabledColumns[ModList::COL_NAME] &&
+ info->name().contains(m_CurrentFilter, Qt::CaseInsensitive)) {
+ display = true;
+ }
+
+ // Search by notes
+ if (!display &&
+ m_EnabledColumns[ModList::COL_NOTES] &&
+ info->comments().contains(m_CurrentFilter, Qt::CaseInsensitive)) {
+ display = true;
+ }
+
+ // Search by Nexus ID
+ if (!display &&
+ m_EnabledColumns[ModList::COL_MODID]) {
+ bool ok;
+ int filterID = m_CurrentFilter.toInt(&ok);
+ if (ok) {
+ int modID = info->getNexusID();
+ while (modID > 0) {
+ if (modID == filterID) {
+ display = true;
+ break;
+ }
+ modID = (int)(modID / 10);
+ }
+ }
+ }
+
+ // Search by categories
+ if (!display &&
+ m_EnabledColumns[ModList::COL_CATEGORY]) {
+ for (auto category : info->categories()) {
+ if (category.contains(m_CurrentFilter, Qt::CaseInsensitive)) {
+ display = true;
+ break;
+ }
+ }
+ }
+ }
+ if (!display) {
return false;
}
@@ -352,6 +393,11 @@ bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const }
}
+void ModListSortProxy::setColumnVisible(int column, bool visible)
+{
+ m_EnabledColumns[column] = visible;
+}
+
void ModListSortProxy::setFilterMode(ModListSortProxy::FilterMode mode)
{
if (m_FilterMode != mode) {
|
