mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[FEATURE][needs-docs] Show data defined expected format in expression builder (#6839)
This commit is contained in:
parent
76b956a6a3
commit
53a384cba7
@ -35,6 +35,26 @@ The builder widget that is used by the dialog
|
||||
|
||||
QString expressionText();
|
||||
|
||||
QString expectedOutputFormat();
|
||||
%Docstring
|
||||
The set expected format string. This is pure text format and no expression validation
|
||||
is done against it.
|
||||
|
||||
:return: The expected value format.
|
||||
%End
|
||||
|
||||
void setExpectedOutputFormat( const QString &expected );
|
||||
%Docstring
|
||||
The set expected format string. This is pure text format and no expression validation
|
||||
is done against it.
|
||||
|
||||
:param expected: The expected value format for the expression.
|
||||
|
||||
.. note::
|
||||
|
||||
Only a UI hint and not used for expression validation.
|
||||
%End
|
||||
|
||||
QgsExpressionContext expressionContext() const;
|
||||
%Docstring
|
||||
Returns the expression context for the dialog. The context is used for the expression
|
||||
|
@ -153,6 +153,26 @@ Gets the expression string that has been set in the expression area.
|
||||
Sets the expression string for the widget
|
||||
%End
|
||||
|
||||
QString expectedOutputFormat();
|
||||
%Docstring
|
||||
The set expected format string. This is pure text format and no expression validation
|
||||
is done against it.
|
||||
|
||||
:return: The expected value format.
|
||||
%End
|
||||
|
||||
void setExpectedOutputFormat( const QString &expected );
|
||||
%Docstring
|
||||
The set expected format string. This is pure text format and no expression validation
|
||||
is done against it.
|
||||
|
||||
:param expected: The expected value format for the expression.
|
||||
|
||||
.. note::
|
||||
|
||||
Only a UI hint and not used for expression validation.
|
||||
%End
|
||||
|
||||
QgsExpressionContext expressionContext() const;
|
||||
%Docstring
|
||||
Returns the expression context for the widget. The context is used for the expression
|
||||
|
@ -52,6 +52,16 @@ QString QgsExpressionBuilderDialog::expressionText()
|
||||
return builder->expressionText();
|
||||
}
|
||||
|
||||
QString QgsExpressionBuilderDialog::expectedOutputFormat()
|
||||
{
|
||||
return builder->expectedOutputFormat();
|
||||
}
|
||||
|
||||
void QgsExpressionBuilderDialog::setExpectedOutputFormat( const QString &expected )
|
||||
{
|
||||
builder->setExpectedOutputFormat( expected );
|
||||
}
|
||||
|
||||
QgsExpressionContext QgsExpressionBuilderDialog::expressionContext() const
|
||||
{
|
||||
return builder->expressionContext();
|
||||
|
@ -47,6 +47,21 @@ class GUI_EXPORT QgsExpressionBuilderDialog : public QDialog, private Ui::QgsExp
|
||||
|
||||
QString expressionText();
|
||||
|
||||
/**
|
||||
* The set expected format string. This is pure text format and no expression validation
|
||||
* is done against it.
|
||||
* \returns The expected value format.
|
||||
*/
|
||||
QString expectedOutputFormat();
|
||||
|
||||
/**
|
||||
* The set expected format string. This is pure text format and no expression validation
|
||||
* is done against it.
|
||||
* \param expected The expected value format for the expression.
|
||||
* \note Only a UI hint and not used for expression validation.
|
||||
*/
|
||||
void setExpectedOutputFormat( const QString &expected );
|
||||
|
||||
/**
|
||||
* Returns the expression context for the dialog. The context is used for the expression
|
||||
* preview result and for populating the list of available functions and variables.
|
||||
|
@ -143,6 +143,8 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
|
||||
txtExpressionString->setIndicatorHoverStyle( QgsCodeEditor::DotsIndicator, FUNCTION_MARKER_ID );
|
||||
|
||||
connect( txtExpressionString, &QgsCodeEditorSQL::indicatorClicked, this, &QgsExpressionBuilderWidget::indicatorClicked );
|
||||
|
||||
setExpectedOutputFormat( QString() );
|
||||
}
|
||||
|
||||
|
||||
@ -597,6 +599,17 @@ void QgsExpressionBuilderWidget::setExpressionText( const QString &expression )
|
||||
txtExpressionString->setText( expression );
|
||||
}
|
||||
|
||||
QString QgsExpressionBuilderWidget::expectedOutputFormat()
|
||||
{
|
||||
return lblExpected->text();
|
||||
}
|
||||
|
||||
void QgsExpressionBuilderWidget::setExpectedOutputFormat( const QString &expected )
|
||||
{
|
||||
lblExpected->setText( expected );
|
||||
mExpectedOutputFrame->setVisible( !expected.isNull() );
|
||||
}
|
||||
|
||||
void QgsExpressionBuilderWidget::setExpressionContext( const QgsExpressionContext &context )
|
||||
{
|
||||
mExpressionContext = context;
|
||||
|
@ -173,6 +173,21 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
|
||||
//! Sets the expression string for the widget
|
||||
void setExpressionText( const QString &expression );
|
||||
|
||||
/**
|
||||
* The set expected format string. This is pure text format and no expression validation
|
||||
* is done against it.
|
||||
* \returns The expected value format.
|
||||
*/
|
||||
QString expectedOutputFormat();
|
||||
|
||||
/**
|
||||
* The set expected format string. This is pure text format and no expression validation
|
||||
* is done against it.
|
||||
* \param expected The expected value format for the expression.
|
||||
* \note Only a UI hint and not used for expression validation.
|
||||
*/
|
||||
void setExpectedOutputFormat( const QString &expected );
|
||||
|
||||
/**
|
||||
* Returns the expression context for the widget. The context is used for the expression
|
||||
* preview result and for populating the list of available functions and variables.
|
||||
|
@ -596,6 +596,7 @@ void QgsPropertyOverrideButton::showExpressionDialog()
|
||||
: mProperty.asExpression();
|
||||
|
||||
QgsExpressionBuilderDialog d( const_cast<QgsVectorLayer *>( mVectorLayer ), currentExpression, this, QStringLiteral( "generic" ), context );
|
||||
d.setExpectedOutputFormat( mInputDescription );
|
||||
if ( d.exec() == QDialog::Accepted )
|
||||
{
|
||||
mExpressionString = d.expressionText().trimmed();
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>989</width>
|
||||
<height>520</height>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -99,23 +99,8 @@
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QgsCodeEditorSQL" name="txtExpressionString" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QFrame" name="mOperatorsGroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Maximum">
|
||||
@ -287,59 +272,172 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Output preview is generated <br> using the first feature from the layer.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Output preview: </string>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QgsCodeEditorSQL" name="txtExpressionString" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Output preview is generated <br> using the first feature from the layer.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Output preview: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPreview">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Output preview is generated <br> using the first feature from the layer.</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>123232</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblPreview">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Output preview is generated <br> using the first feature from the layer.</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="mExpectedOutputFrame">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Output preview is generated <br> using the first feature from the layer.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Expected Format:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblExpected">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Output preview is generated <br> using the first feature from the layer.</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>string [r,g,b,a] as int 0-255 or #RRGGBBAA as hex or color as color's name</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user