mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[processing] Add class ExpressionEnabledWidgetWrapper
This commit is contained in:
parent
482aadc495
commit
dda667023a
@ -32,16 +32,34 @@ import locale
|
||||
import os
|
||||
from functools import cmp_to_key
|
||||
|
||||
from qgis.core import QgsCoordinateReferenceSystem, QgsApplication, QgsWkbTypes, QgsMapLayerProxyModel
|
||||
from qgis.PyQt.QtWidgets import QCheckBox, QComboBox, QLineEdit, QPlainTextEdit, QWidget, QHBoxLayout, QToolButton, QFileDialog
|
||||
from qgis.gui import (QgsFieldExpressionWidget,
|
||||
QgsExpressionLineEdit,
|
||||
QgsProjectionSelectionWidget,
|
||||
QgsGenericProjectionSelector,
|
||||
QgsFieldComboBox,
|
||||
QgsFieldProxyModel,
|
||||
QgsMapLayerComboBox
|
||||
)
|
||||
from qgis.core import (
|
||||
QgsApplication,
|
||||
QgsCoordinateReferenceSystem,
|
||||
QgsExpression,
|
||||
QgsMapLayerProxyModel,
|
||||
QgsWkbTypes,
|
||||
)
|
||||
from qgis.PyQt.QtWidgets import (
|
||||
QCheckBox,
|
||||
QComboBox,
|
||||
QDialog,
|
||||
QFileDialog,
|
||||
QHBoxLayout,
|
||||
QLineEdit,
|
||||
QPlainTextEdit,
|
||||
QToolButton,
|
||||
QWidget,
|
||||
)
|
||||
from qgis.gui import (
|
||||
QgsExpressionLineEdit,
|
||||
QgsExpressionBuilderDialog,
|
||||
QgsFieldComboBox,
|
||||
QgsFieldExpressionWidget,
|
||||
QgsFieldProxyModel,
|
||||
QgsGenericProjectionSelector,
|
||||
QgsMapLayerComboBox,
|
||||
QgsProjectionSelectionWidget,
|
||||
)
|
||||
from qgis.PyQt.QtCore import pyqtSignal, QObject, QVariant, QSettings
|
||||
|
||||
from processing.gui.NumberInputPanel import NumberInputPanel, ModellerNumberInputPanel
|
||||
@ -175,6 +193,36 @@ class WidgetWrapper(QObject):
|
||||
return filename, selected_filter
|
||||
|
||||
|
||||
class ExpressionEnabledWidgetWrapper(WidgetWrapper):
|
||||
|
||||
def createWidget(self, basewidget):
|
||||
expr_button = QToolButton()
|
||||
expr_button.clicked.connect(self.showExpressionsBuilder)
|
||||
expr_button.setText('...')
|
||||
|
||||
layout = QHBoxLayout()
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addWidget(basewidget)
|
||||
layout.addWidget(expr_button)
|
||||
|
||||
widget = QWidget()
|
||||
widget.setLayout(layout)
|
||||
|
||||
return widget
|
||||
|
||||
def showExpressionsBuilder(self):
|
||||
context = self.param.expressionContext()
|
||||
value = self.value()
|
||||
if not isinstance(value, str):
|
||||
value = ''
|
||||
dlg = QgsExpressionBuilderDialog(None, value, self.widget, 'generic', context)
|
||||
dlg.setWindowTitle(self.tr('Expression based input'))
|
||||
if dlg.exec_() == QDialog.Accepted:
|
||||
exp = QgsExpression(dlg.expressionText())
|
||||
if not exp.hasParserError():
|
||||
self.setValue(dlg.expressionText())
|
||||
|
||||
|
||||
class BasicWidgetWrapper(WidgetWrapper):
|
||||
|
||||
def createWidget(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user