Commit ef24e63b authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files
parent 2de01f93
......@@ -110,34 +110,21 @@ def initResources():
from eotimeseriesviewer.externals.qps.resources import initQtResources
initQtResources(pathlib.Path(__file__).parent)
def initMapLayerConfigWidgetFactories():
from .externals.qps import \
registerMapLayerConfigWidgetFactories, \
mapLayerConfigWidgetFactories, \
registerMapLayerConfigWidgetFactory
from .labeling import registerLabelShortcutEditorWidget
registerMapLayerConfigWidgetFactories()
for factory in mapLayerConfigWidgetFactories():
qgis.utils.iface.registerMapLayerConfigWidgetFactory(factory)
def initEditorWidgets():
"""
Initialises QgsEditorWidgets
"""
debugLog('initEditorWidgets')
import eotimeseriesviewer.externals.qps as qps
qps.registerEditorWidgets()
def initAll():
"""
Calls all required init routines
:return:
"""
from .externals.qps import registerEditorWidgets, registerMapLayerConfigWidgetFactories
registerEditorWidgets()
registerMapLayerConfigWidgetFactories()
initResources()
initEditorWidgets()
initMapLayerConfigWidgetFactories()
from .labeling import registerLabelShortcutEditorWidget
registerLabelShortcutEditorWidget()
def icon() -> QIcon:
"""
......
......@@ -40,7 +40,7 @@ DIR_UI_FILES = DIR_QPS / 'ui'
DIR_ICONS = DIR_UI_FILES / 'icons'
QPS_RESOURCE_FILE = DIR_QPS / 'qpsresources_rc.py'
MAPLAYER_CONFIGWIDGET_FACTORIES: typing.List[QgsMapLayerConfigWidgetFactory] = list()
MAPLAYER_CONFIGWIDGET_FACTORIES: typing.Dict[str, QgsMapLayerConfigWidgetFactory] = dict()
if Qgis.QGIS_VERSION < MIN_QGIS_VERSION:
warnings.warn(f'Your QGIS ({Qgis.QGIS_VERSION}) is outdated. '
......@@ -57,8 +57,8 @@ def registerMapLayerConfigWidgetFactory(factory: QgsMapLayerConfigWidgetFactory)
"""
global MAPLAYER_CONFIGWIDGET_FACTORIES
assert isinstance(factory, QgsMapLayerConfigWidgetFactory)
if factory not in MAPLAYER_CONFIGWIDGET_FACTORIES:
MAPLAYER_CONFIGWIDGET_FACTORIES.append(factory)
if factory.title() not in MAPLAYER_CONFIGWIDGET_FACTORIES.keys():
MAPLAYER_CONFIGWIDGET_FACTORIES[factory.title()] = factory
qgis.utils.iface.registerMapLayerConfigWidgetFactory(factory)
......@@ -72,17 +72,19 @@ def unregisterMapLayerConfigWidgetFactory(factory: QgsMapLayerConfigWidgetFactor
"""
global MAPLAYER_CONFIGWIDGET_FACTORIES
assert isinstance(factory, QgsMapLayerConfigWidgetFactory)
while factory in MAPLAYER_CONFIGWIDGET_FACTORIES:
MAPLAYER_CONFIGWIDGET_FACTORIES.remove(factory)
if factory.title() in MAPLAYER_CONFIGWIDGET_FACTORIES.keys():
MAPLAYER_CONFIGWIDGET_FACTORIES.pop(factory.title())
qgis.utils.iface.unregisterMapLayerConfigWidgetFactory(factory)
def mapLayerConfigWidgetFactories() -> typing.List[QgsMapLayerConfigWidgetFactory]:
"""
Returns registered QgsMapLayerConfigWidgetFactories
:return: list of QgsMapLayerConfigWidgetFactories
:rtype:
"""
return MAPLAYER_CONFIGWIDGET_FACTORIES[:]
global MAPLAYER_CONFIGWIDGET_FACTORIES
return list(MAPLAYER_CONFIGWIDGET_FACTORIES.values())
def registerEditorWidgets():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment