Skip to content
This repository was archived by the owner on Mar 11, 2026. It is now read-only.

Commit 3d51abf

Browse files
committed
add ability to select multiple features
1 parent 405a469 commit 3d51abf

7 files changed

Lines changed: 83 additions & 15 deletions

File tree

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ deploy:
1010
cp -vf $(UI_FILES) $(PLUGINS)
1111
cp -vf $(EXTRAS) $(PLUGINS)
1212
cp -vfr doc $(PLUGINS)
13-
cp -vf helphead.html $(PLUGINS)/index.html
14-
python -m markdown -x markdown.extensions.headerid readme.md >> $(PLUGINS)/index.html
15-
echo '</body>' >> $(PLUGINS)/index.html
13+
cp -vf helphead.html index.html
14+
python -m markdown -x extra readme.md >> index.html
15+
echo '</body>' >> index.html
16+
cp -vf index.html $(PLUGINS)/index.html
1617

doc/layersearch.jpg

-258 Bytes
Loading

index.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<head>
2+
<style>
3+
body {
4+
font:13.34px helvetica,arial,freesans,clean,sans-serif;
5+
color:black;
6+
line-height:1.4em;
7+
background-color: #F8F8F8;
8+
padding: 0.7em;
9+
}
10+
pre {
11+
margin:1em 0;
12+
font-size:12px;
13+
background-color:#eee;
14+
border:1px solid #ddd;
15+
padding:5px;
16+
line-height:1.5em;
17+
color:#444;
18+
overflow:auto;
19+
-webkit-box-shadow:rgba(0,0,0,0.07) 0 1px 2px inset;
20+
-webkit-border-radius:3px;
21+
-moz-border-radius:3px;border-radius:3px;
22+
}
23+
pre code {
24+
padding:0;
25+
font-size:12px;
26+
background-color:#eee;
27+
border:none;
28+
}
29+
code {
30+
font-size:12px;
31+
background-color:#f8f8ff;
32+
color:#444;
33+
padding:0 .2em;
34+
border:1px solid #dedede;
35+
}
36+
</style>
37+
</head>
38+
<body>
39+
<h1>Search Layers Plugin</h1>
40+
<p>The Search Layers plugin features enhanced textual vector layer searching in QGIS. It provides the ability to search across all layers and all fields.</p>
41+
<p>Search Layers is located in the QGIS Plugins menu under <em>"Plugins-&gt;Search Layers-&gt;Search Layers"</em> or by selecting the tool bar icon. <img alt="Toolbar Icon" src="icon.png" /></p>
42+
<p>The following dialog box is displayed when "Search Layers" is launched.</p>
43+
<p><img alt="Search Layers Dialog" src="doc/layersearch.jpg" /></p>
44+
<p>Under <strong>Search String</strong>, enter the search string. <strong>Search Layers</strong> specifies whether the search will be on <em>&lt;All Layers&gt;</em>, <em>&lt;Selected layers&gt;</em>, or on any of the vector layers in the QGIS project. If a specific layer is selected then <strong>Search Fields</strong> will be enabled and by default <em>&lt;All Fields&gt;</em> will be selected, but any field can be selected from the layer and the search will only search on that layer and field.</p>
45+
<p><strong>Comparison</strong> is the matching criteria and is as follows.</p>
46+
<ul>
47+
<li><strong>=</strong> - This requires an exact match including case.</li>
48+
<li><strong>Contains</strong> - This performs a case independent search in which a match is made if a field contains the search string.</li>
49+
<li><strong>Begins with</strong> - This is a case independent search in which the search finds any field that begins with the search string.</li>
50+
</ul>
51+
<p>Click the <strong>Search</strong> button to begin the search. In the case of a large data set, clicking on <strong>Stop</strong> will halt the process. Note that the plugin stops after finding 1500 matches.</p>
52+
<p>When matches are found and clicked on, the features are highlighted on the map. If <strong>Automatically zoom to selected features</strong> is checked, QGIS also zooms to the selected features. The matches can be examined even before the search process has been completed.</p></body>

metadata.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
name=Search Layers
33
qgisMinimumVersion=3.0
44
description=Enhanced textual searching on all QGIS layers and fields.
5-
version=3.0.1
5+
version=3.0.2
66
author=C Hamilton
77
email=adenaculture@gmail.com
8-
about=The Search Layers plugin features enhanced textual vector layer searching in QGIS. The existing QGIS searching capabilities are limited to a particular layer and a particular column. The difference with this plugin is that it will do a string search across all layers and all fields.
8+
about=The Search Layers plugin features enhanced textual vector layer searching in QGIS. This plugin can search across all layers and all fields.
99
tracker=https://github.com/NationalSecurityAgency/qgis-searchlayers-plugin
1010
repository=https://github.com/NationalSecurityAgency/qgis-searchlayers-plugin
1111
homepage=https://github.com/NationalSecurityAgency/qgis-searchlayers-plugin
@@ -15,5 +15,6 @@ icon=icon.png
1515
experimental=False
1616
deprecated=False
1717
changelog=
18+
3.0.2 - Highlight a range of features, add check box to automatically zoom to selected
1819
3.0.1 - Added Feature Id in the result table.
1920
3.0.0 First release for QGIS 3

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Search Layers Plugin
22

3-
The Search Layers plugin features enhanced textual vector layer searching in QGIS. The existing QGIS searching capabilities are limited to a particular layer and a particular column. The difference with this plugin is that it will do a string search across all layers and all fields.
3+
The Search Layers plugin features enhanced textual vector layer searching in QGIS. It provides the ability to search across all layers and all fields.
44

55
Search Layers is located in the QGIS Plugins menu under *"Plugins->Search Layers->Search Layers"* or by selecting the tool bar icon. ![Toolbar Icon](icon.png)
66

@@ -18,5 +18,5 @@ Under **Search String**, enter the search string. **Search Layers** specifies wh
1818

1919
Click the **Search** button to begin the search. In the case of a large data set, clicking on **Stop** will halt the process. Note that the plugin stops after finding 1500 matches.
2020

21-
When matches are found and clicked on, QGIS zooms to the feature, selects it, and highlights it. The matches can be examined even before the search process has been completed.
21+
When matches are found and clicked on, the features are highlighted on the map. If **Automatically zoom to selected features** is checked, QGIS also zooms to the selected features. The matches can be examined even before the search process has been completed.
2222

searchDialog.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,17 @@ def select_feature(self):
6363
for layer in layers:
6464
if layer.type() == QgsMapLayer.VectorLayer:
6565
layer.removeSelection()
66-
# Find the layer that was selected and select the feature in the layer
67-
selectedRow = self.resultsTable.currentRow()
68-
selectedLayer = self.results[selectedRow][0]
69-
selectedFeature = self.results[selectedRow][1]
70-
selectedLayer.select(selectedFeature.id())
66+
# Find the layers that are selected and select the features in the layer
67+
selectedItems = self.resultsTable.selectedItems()
68+
selectedLayer = None
69+
for item in selectedItems:
70+
selectedRow = item.row()
71+
selectedLayer = self.results[selectedRow][0]
72+
selectedFeature = self.results[selectedRow][1]
73+
selectedLayer.select(selectedFeature.id())
7174
# Zoom to the selected feature
72-
self.canvas.zoomToSelected(selectedLayer)
75+
if selectedLayer and self.autoZoomCheckBox.isChecked():
76+
self.canvas.zoomToSelected(selectedLayer)
7377

7478
def layerSelected(self):
7579
'''The user has made a selection so we need to initialize other
@@ -116,7 +120,7 @@ def runSearch(self):
116120
comparisonMode = self.comparisonComboBox.currentIndex()
117121
self.noSelection = True
118122
try:
119-
sstr = self.findStringEdit.text().strip()
123+
sstr = self.findStringEdit.text()
120124
except:
121125
self.showErrorMessage('Invalid Search String')
122126
return

searchlayers.ui

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>517</width>
10-
<height>440</height>
10+
<height>461</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -69,6 +69,16 @@
6969
</item>
7070
</layout>
7171
</item>
72+
<item>
73+
<widget class="QCheckBox" name="autoZoomCheckBox">
74+
<property name="text">
75+
<string>Automatically zoom to selected features</string>
76+
</property>
77+
<property name="checked">
78+
<bool>false</bool>
79+
</property>
80+
</widget>
81+
</item>
7282
<item>
7383
<widget class="QTableWidget" name="resultsTable"/>
7484
</item>

0 commit comments

Comments
 (0)