diff options
| author | Project579 <star579avatar@gmail.com> | 2018-12-29 11:56:42 +0100 |
|---|---|---|
| committer | Project579 <star579avatar@gmail.com> | 2018-12-29 11:56:42 +0100 |
| commit | d6f9e6d900f4a92da6bb252f0f8a223d59819e45 (patch) | |
| tree | 1e39b666e3d52632a471152630d2f07d4e73125d /src/modlistsortproxy.cpp | |
| parent | 4436d376a8d426867f217b03838570a424b09c5f (diff) | |
| parent | eb50d0b44773f17fd8edccd557b7a2135c2cdb76 (diff) | |
Merge branch 'Develop' into archive_conflicts_2
Updating to 2.1.7alpha1
Diffstat (limited to 'src/modlistsortproxy.cpp')
| -rw-r--r-- | src/modlistsortproxy.cpp | 74 |
1 files changed, 68 insertions, 6 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 8cf4bb9c..aaf93f5a 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
}
@@ -218,9 +214,25 @@ bool ModListSortProxy::lessThan(const QModelIndex &left, lt = comp < 0;
}
} break;
+ case ModList::COL_NOTES: {
+ QString leftComments = leftMod->comments();
+ QString rightComments = rightMod->comments();
+ if (leftComments != rightComments) {
+ if (leftComments.isEmpty()) {
+ lt = sortOrder() == Qt::DescendingOrder;
+ } else if (rightComments.isEmpty()) {
+ lt = sortOrder() == Qt::AscendingOrder;
+ } else {
+ lt = leftComments < rightComments;
+ }
+ }
+ } break;
case ModList::COL_PRIORITY: {
// nop, already compared by priority
} break;
+ default: {
+ qWarning() << "Sorting is not defined for column " << left.column();
+ } break;
}
return lt;
}
@@ -345,8 +357,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;
}
@@ -357,6 +414,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) {
|
