diff options
| author | LostDragonist <lost.dragonist@gmail.com> | 2019-05-03 21:32:33 -0500 |
|---|---|---|
| committer | LostDragonist <lost.dragonist@gmail.com> | 2019-05-03 21:32:33 -0500 |
| commit | 179a73857125ee604f42b0d5c2d765183c86d2c7 (patch) | |
| tree | b9b3f9d62bd5640de839d150a53ab8ef119dab9c /src/pluginlistsortproxy.cpp | |
| parent | e2b799bd6b5cfd51969fefd1dab5e5b1b7e5f81c (diff) | |
| parent | 907c5468424b48774f5da2a6b5f96f26590987b0 (diff) | |
Merge pull request #695 from ModOrganizer2/Develop
Stage for Release 2.2.0
Diffstat (limited to 'src/pluginlistsortproxy.cpp')
| -rw-r--r-- | src/pluginlistsortproxy.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/pluginlistsortproxy.cpp b/src/pluginlistsortproxy.cpp index e09e64a5..3d13798e 100644 --- a/src/pluginlistsortproxy.cpp +++ b/src/pluginlistsortproxy.cpp @@ -72,8 +72,7 @@ void PluginListSortProxy::updateFilter(const QString &filter) bool PluginListSortProxy::filterAcceptsRow(int row, const QModelIndex&) const
{
- return m_CurrentFilter.isEmpty() ||
- sourceModel()->data(sourceModel()->index(row, 0)).toString().contains(m_CurrentFilter, Qt::CaseInsensitive);
+ return filterMatchesPlugin(sourceModel()->data(sourceModel()->index(row, 0)).toString());
}
@@ -137,3 +136,41 @@ bool PluginListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction act sourceIndex.parent());
}
+
+bool PluginListSortProxy::filterMatchesPlugin(const QString &plugin) const
+{
+ if (!m_CurrentFilter.isEmpty()) {
+
+ bool display = false;
+ QString filterCopy = QString(m_CurrentFilter);
+ filterCopy.replace("||", ";").replace("OR", ";").replace("|", ";");
+ QStringList ORList = filterCopy.split(";", QString::SkipEmptyParts);
+
+ bool segmentGood = true;
+
+ //split in ORSegments that internally use AND logic
+ for (auto& ORSegment : ORList) {
+ QStringList ANDKeywords = ORSegment.split(" ", QString::SkipEmptyParts);
+ segmentGood = true;
+
+ //check each word in the segment for match, each word needs to be matched but it doesn't matter where.
+ for (auto& currentKeyword : ANDKeywords) {
+ if (!plugin.contains(currentKeyword, Qt::CaseInsensitive)) {
+ segmentGood = false;
+ break;
+ }
+ }
+
+ if (segmentGood) {
+ //the last AND loop didn't break so the ORSegments is true so mod matches filter
+ return true;
+ }
+
+ }//for ORList loop
+
+ return false;
+ }
+ else
+ return true;
+}
+
|
