[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kphotoalbum] AnnotationDialog: Changed AnnotationDialog::ListViewTextMatchHider so that the tag nam
From:       Tobias Leupold <tobias.leupold () web ! de>
Date:       2016-03-26 10:43:02
Message-ID: E1ajlgM-00053y-QI () scm ! kde ! org
[Download RAW message or body]

Git commit 950ebb80aca1d64e3e05f87b6357febceeea9d2e by Tobias Leupold.
Committed on 26/03/2016 at 10:42.
Pushed by tleupold into branch 'master'.

Changed AnnotationDialog::ListViewTextMatchHider so that the tag names are matched \
word by word against all parts of the search string.

M  +30   -4    AnnotationDialog/ListViewItemHider.cpp

http://commits.kde.org/kphotoalbum/950ebb80aca1d64e3e05f87b6357febceeea9d2e

diff --git a/AnnotationDialog/ListViewItemHider.cpp \
b/AnnotationDialog/ListViewItemHider.cpp index 2404dbe..665c8a5 100644
--- a/AnnotationDialog/ListViewItemHider.cpp
+++ b/AnnotationDialog/ListViewItemHider.cpp
@@ -86,11 +86,37 @@ bool \
AnnotationDialog::ListViewTextMatchHider::shouldItemBeShown(QTreeWidgetItem  {
         case AnnotationDialog::MatchFromBeginning:
             return item->text(0).toLower().startsWith( m_text.toLower() );
-        case AnnotationDialog::MatchFromWordStart:
-            {
-                QStringList words = item->text(0).toLower().split( \
                QRegExp(QString::fromLatin1("\\W+") ), QString::SkipEmptyParts);
-                return any_of(words,  [this] (const QString& word) { return \
word.startsWith( m_text.toLower()); } ); +        case \
AnnotationDialog::MatchFromWordStart: { +            QStringList itemWords = \
item->text(0).toLower().split(QRegExp(QString::fromUtf8("\\W+")), +                   \
QString::SkipEmptyParts); +            QStringList searchWords = \
m_text.toLower().split(QRegExp(QString::fromUtf8("\\W+")), +                          \
QString::SkipEmptyParts); +
+            int matchesFound = 0;
+            int matchesNeeded = searchWords.size();
+
+            for (int i = 0; i < itemWords.size(); i++) {
+                bool foundMatch = false;
+                for (int j = 0; j < searchWords.size(); j++) {
+                    if (itemWords.at(i).startsWith(searchWords.at(j))) {
+                        searchWords.removeAt(j);
+                        foundMatch = true;
+                        j = matchesNeeded;
+                    }
+                }
+                if (foundMatch) {
+                    foundMatch = false;
+                    matchesFound++;
+
+                    if (matchesFound == matchesNeeded) {
+                        return true;
+                    }
+                }
             }
+
+            return false;
+
+        }
         case AnnotationDialog::MatchAnywhere:
             return item->text(0).toLower().contains( m_text.toLower() );
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic