-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
167 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
*************************************************************************** | ||
wrappers_map_theme.py - Map theme widget wrappers | ||
--------------------- | ||
Date : August 2017 | ||
Copyright : (C) 2017 by OPENGIS.ch | ||
Email : mario@opengis.ch | ||
*************************************************************************** | ||
* * | ||
* 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.core import (QgsSettings, | ||
QgsProcessingParameterNumber, | ||
QgsProcessingParameterFile, | ||
QgsProcessingParameterField, | ||
QgsProcessingParameterExpression, | ||
QgsProcessingOutputString, | ||
QgsProcessingParameterString, | ||
QgsMapThemeCollection, | ||
QgsProject | ||
) | ||
|
||
from qgis.PyQt.QtWidgets import QComboBox | ||
from qgis.PyQt.QtCore import pyqtSignal | ||
|
||
from processing.gui.wrappers import ( | ||
BasicWidgetWrapper | ||
) | ||
from processing.tools.postgis import GeoDB | ||
|
||
|
||
class MapThemeWrapper(BasicWidgetWrapper): | ||
""" | ||
WidgetWrapper for ParameterString that create and manage a combobox widget | ||
with existing postgis connections. | ||
""" | ||
|
||
def createWidget(self): | ||
self._combo = QComboBox() | ||
for item in self.items(): | ||
self._combo.addItem(item, item) | ||
self._combo.currentIndexChanged.connect(lambda: | ||
self.widgetValueHasChanged.emit(self)) | ||
return self._combo | ||
|
||
def items(self): | ||
items = QgsProject.instance().mapThemeCollection().mapThemes() | ||
#if self.dialogType == DIALOG_MODELER: | ||
# strings = self.dialog.getAvailableValuesOfType( | ||
# [QgsProcessingParameterString, QgsProcessingParameterNumber, | ||
# QgsProcessingParameterFile, | ||
# QgsProcessingParameterField, | ||
# QgsProcessingParameterExpression], QgsProcessingOutputString) | ||
# items = items + [(self.dialog.resolveValueDescription(s), | ||
# s) for s in strings] | ||
# | ||
return items | ||
|
||
def setValue(self, value): | ||
self.setComboValue(value, self._combo) | ||
|
||
def value(self): | ||
return self.comboValue(combobox=self._combo) |