Bug report #8212
style manager searching finds non-related elements
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | Arunmozhi P | ||
Category: | Symbology | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | Yes | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 17026 |
Description
When entering specific and short string in the search box, incorrect elements are found.
For example, when selecting the Marker tab and entering the string "ci" one of the found elements is "star2" - see attached screenshot.
Or in the Line tab with string "Ca" there are many elements that are found.
Also, it seems that search is not done when entering a single character. Is this the intended behavior?
Also when hitting return the help dialog pops up, which is rather unexpected - although this is unrelated.
History
#1 Updated by Etienne Tourigny over 11 years ago
- File patch-8212-1.txt added
- Status changed from Open to Feedback
the following patch resolves the issue. Tested and matches item names as well as tags.
Can Arun please review it? I wonder why the query was on the xml field instead of the name field.
diff --git a/src/core/symbology-ng/qgsstylev2.cpp b/src/core/symbology-ng/qgsstylev2.cpp index 459230b..3648229 100644 --- a/src/core/symbology-ng/qgsstylev2.cpp +++ b/src/core/symbology-ng/qgsstylev2.cpp @@ -753,7 +753,7 @@ QStringList QgsStyleV2::findSymbols( StyleEntity type, QString qword ) } QString item = ( type == SymbolEntity ) ? "symbol" : "colorramp"; - char *query = sqlite3_mprintf( "SELECT name FROM %q WHERE xml LIKE '%%%q%%'", + char *query = sqlite3_mprintf( "SELECT name FROM %q WHERE name LIKE '%%%q%%'", item.toUtf8().constData(), qword.toUtf8().constData() ); sqlite3_stmt *ppStmt;
Attaching a patch with debug statements
#2 Updated by Giovanni Manghi over 11 years ago
- Pull Request or Patch supplied changed from No to Yes
Etienne Tourigny wrote:
the following patch resolves the issue. Tested and matches item names as well as tags.
Hi,
better submit the patch on github, otherwise there is the real chance of not being evaluated and committed.
#3 Updated by Arunmozhi P over 11 years ago
I think there is a misunderstanding between *search*ing and *filter*ing here. The query is run over the entire XML definition so that more complicated searches can be done.
One example is if you want to find all perfect red symbols you can enter 255,0,0 and it gets them for you.
I am sorry that it isn't documented anywhere. We will try to get it documented somewhere.
#4 Updated by Etienne Tourigny over 11 years ago
- Target version set to Future Release - High Priority
I understand now why it works this way, but I don't see the real usefulness. It is rather un-intuitive, I was honestly expecting a name-based search.
Also, a basic xml search will return values based on the tags and not their content (although I didn't test that).
Perhaps in 2.1 you could have 2 search options, one traditional (on the name) and another on the xml, or something more complex, like a selector for name/color/etc?
cheers
#5 Updated by Giovanni Manghi over 10 years ago
- Status changed from Feedback to Open
#6 Updated by Nathan Woodrow over 9 years ago
- Status changed from Open to Closed
Fixed in changeset 09675101452bdd1cde8dfdf4c7482164eca0be3b.