Skip to content
Permalink
Browse files

Set widget context for QgsProcessingMapLayerComboBox

  • Loading branch information
nyalldawson committed Mar 25, 2020
1 parent 6cf9bee commit 9d0efd3354291be4a7de365cd2af02b73e6814c8
@@ -78,6 +78,13 @@ Sets the ``value`` shown in the widget.
Returns the current value of the widget.

.. seealso:: :py:func:`setValue`
%End

void setWidgetContext( QgsProcessingParameterWidgetContext *context );
%Docstring
Sets the ``context`` in which the widget is shown.

.. versionadded:: 3.14
%End

signals:
@@ -1186,6 +1186,11 @@ def createWidget(self):
widget.setLayout(layout)
return widget

def setWidgetContext(self, context):
if isinstance(self.combo, QgsProcessingMapLayerComboBox):
self.combo.setWidgetContext(context)
super().setWidgetContext(context)

def selectFile(self):
filename, selected_filter = self.getFileName(self.combo.currentText())
if filename:
@@ -329,6 +329,10 @@ QVariant QgsProcessingMapLayerComboBox::value() const
return QVariant();
}

void QgsProcessingMapLayerComboBox::setWidgetContext( QgsProcessingParameterWidgetContext *context )
{
mBrowserModel = context->browserModel();
}

QgsMapLayer *QgsProcessingMapLayerComboBox::compatibleMapLayerFromMimeData( const QMimeData *data, bool &incompatibleLayerSelected ) const
{
@@ -29,6 +29,8 @@ class QgsMapLayerComboBox;
class QToolButton;
class QCheckBox;
class QgsProcessingParameterDefinition;
class QgsBrowserGuiModel;
class QgsProcessingParameterWidgetContext;

///@cond PRIVATE

@@ -92,6 +94,12 @@ class GUI_EXPORT QgsProcessingMapLayerComboBox : public QWidget
*/
QVariant value() const;

/**
* Sets the \a context in which the widget is shown.
* \since QGIS 3.14
*/
void setWidgetContext( QgsProcessingParameterWidgetContext *context );

signals:

/**
@@ -130,6 +138,9 @@ class GUI_EXPORT QgsProcessingMapLayerComboBox : public QWidget
QgsFeatureRequest::InvalidGeometryCheck mGeometryCheck = QgsFeatureRequest::GeometryAbortOnInvalid;
QPointer< QgsMapLayer> mPrevLayer;
int mBlockChangedSignal = 0;

QgsBrowserGuiModel *mBrowserModel = nullptr;

QgsMapLayer *compatibleMapLayerFromMimeData( const QMimeData *data, bool &incompatibleLayerSelected ) const;
QString compatibleUriFromMimeData( const QMimeData *data ) const;
};

0 comments on commit 9d0efd3

Please sign in to comment.
You can’t perform that action at this time.