-
Notifications
You must be signed in to change notification settings - Fork 2
/
spatial_filter.py
58 lines (46 loc) · 2.44 KB
/
spatial_filter.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
"""
/***************************************************************************
SpatialFilter
A QGIS plugin
This plugin applies spatial filters to layers for performance and efficiency.
Base was generated by Plugin Builder: http://g-sherman.github.io/Qgis-Plugin-Builder/
-------------------
begin : 2022-10-16
copyright : (C) 2022 Wheregroup GmbH
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
from qgis.PyQt.QtCore import QLocale, QSettings, QTranslator, QCoreApplication
import os.path
class SpatialFilter:
def __init__(self, iface):
self.iface = iface
self.plugin_dir = os.path.dirname(__file__)
locale = QSettings().value('locale/userLocale', QLocale().name())[0:2]
locale_path = os.path.join(self.plugin_dir, 'i18n', f'spatial_filter_{locale}.qm')
if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)
QCoreApplication.installTranslator(self.translator)
def initGui(self):
# we import just now because we need the QCoreApplication translator
# to be installed already (e.g. for the LOCALIZED_PLUGIN_NAME)
from .controller import FilterController
from .helpers import warnAboutQgisBugProjectSaving
from .widgets import FilterToolbar
self.toolbar = FilterToolbar(FilterController(), self.iface.mainWindow())
self.iface.mainWindow().addToolBar(self.toolbar)
warnAboutQgisBugProjectSaving()
def unload(self):
self.toolbar.hideFilterGeom()
self.toolbar.controller.removeFilter()
self.toolbar.controller.disconnectSignals()
self.toolbar.deleteLater()