-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacetedfeatureselect_dialog.py
61 lines (46 loc) · 2.13 KB
/
facetedfeatureselect_dialog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
from qgis.PyQt import uic
from qgis.PyQt.QtWidgets import QDialog
from qgis.core import QgsVectorLayer
from .layerselection_widget import LayerSelectionWidget
from .facetedsearch_widget import FacetedSearchWidget
from .featureselection_widget import FeatureSelectionWidget
# This loads your .ui file so that PyQt can populate your plugin with the elements from Qt Designer
FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'facetedfeatureselect_dialog.ui'))
class FacetedFeatureSelectDialog(QDialog, FORM_CLASS):
layerSelection: LayerSelectionWidget
facetContainer: FacetedSearchWidget
featureSelection: FeatureSelectionWidget
def __init__(self, parent=None):
"""Constructor."""
super().__init__(parent)
self.setupUi(self)
self._layer = None
self.layerSelection = LayerSelectionWidget(self)
self.layerSelection.layerChanged.connect(self._setLayer)
self.layerSelection.addFacet.connect(self._addFacet)
self.layerSelection.removeAllFacets.connect(self._removeAllFacets)
self.layout().addWidget(self.layerSelection)
self.facetContainer = FacetedSearchWidget()
self.layout().addWidget(self.facetContainer)
self.facetContainer.resetSearch.connect(self._removeFeatures)
self.facetContainer.populateSearch.connect(self._populateFeatures)
self.featureSelection = FeatureSelectionWidget(self)
self.layout().addWidget(self.featureSelection)
def initSelection(self):
if self._layer is not None:
self.featureSelection.remove_all_from_selection()
def _setLayer(self, layer: QgsVectorLayer = None):
if layer is None:
return
self._layer = layer
self.facetContainer.setLayer(layer)
self.featureSelection.setLayer(layer)
def _removeAllFacets(self):
self.facetContainer.removeAllFacets()
def _addFacet(self, field: str):
self.facetContainer.addFacet(field)
def _populateFeatures(self):
self.featureSelection.populateFeatures()
def _removeFeatures(self):
self.featureSelection.removeFeatures()