mirror of
https://github.com/qgis/QGIS.git
synced 2025-06-20 00:03:07 -04:00
Add a hint on widgets for non existent joined features
This commit is contained in:
parent
5253aa80e2
commit
e5eda5f889
@ -156,6 +156,13 @@ class QgsEditorWidgetWrapper : QgsWidgetWrapper
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
virtual void setHint( const QString &hintText );
|
||||
%Docstring
|
||||
Add a hint text on the widget
|
||||
\param hintText The hint text to display
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
void valueChanged( const QVariant &value );
|
||||
|
@ -167,7 +167,7 @@ class QgsAttributeForm : QWidget
|
||||
|
||||
public slots:
|
||||
|
||||
void changeAttribute( const QString &field, const QVariant &value );
|
||||
void changeAttribute( const QString &field, const QVariant &value, const QString &hintText = QString() );
|
||||
%Docstring
|
||||
Call this to change the content of a given attribute. Will update the editor(s) related to this field.
|
||||
|
||||
|
@ -211,3 +211,8 @@ bool QgsEditorWidgetWrapper::isInTable( const QWidget *parent )
|
||||
if ( qobject_cast<const QTableView *>( parent ) ) return true;
|
||||
return isInTable( parent->parentWidget() );
|
||||
}
|
||||
|
||||
void QgsEditorWidgetWrapper::setHint( const QString &hintText )
|
||||
{
|
||||
widget()->setToolTip( hintText );
|
||||
}
|
||||
|
@ -164,6 +164,13 @@ class GUI_EXPORT QgsEditorWidgetWrapper : public QgsWidgetWrapper
|
||||
*/
|
||||
QString constraintFailureReason() const;
|
||||
|
||||
/**
|
||||
* Add a hint text on the widget
|
||||
* \param hintText The hint text to display
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual void setHint( const QString &hintText );
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
|
@ -223,7 +223,7 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
|
||||
emit modeChanged( mMode );
|
||||
}
|
||||
|
||||
void QgsAttributeForm::changeAttribute( const QString &field, const QVariant &value )
|
||||
void QgsAttributeForm::changeAttribute( const QString &field, const QVariant &value, const QString &hintText )
|
||||
{
|
||||
Q_FOREACH ( QgsWidgetWrapper *ww, mWidgets )
|
||||
{
|
||||
@ -231,6 +231,7 @@ void QgsAttributeForm::changeAttribute( const QString &field, const QVariant &va
|
||||
if ( eww && eww->field().name() == field )
|
||||
{
|
||||
eww->setValue( value );
|
||||
eww->setHint( hintText );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1945,6 +1946,7 @@ void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
|
||||
if ( infos.count() == 0 || !currentFormFeature( formFeature ) )
|
||||
return;
|
||||
|
||||
const QString hint = tr( "No feature joined" );
|
||||
Q_FOREACH ( const QgsVectorLayerJoinInfo *info, infos )
|
||||
{
|
||||
if ( !info->isDynamicFormEnabled() )
|
||||
@ -1959,11 +1961,15 @@ void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
|
||||
{
|
||||
QString prefixedName = info->prefixedFieldName( field );
|
||||
QVariant val;
|
||||
QString hintText = hint;
|
||||
|
||||
if ( joinFeature.isValid() )
|
||||
{
|
||||
val = joinFeature.attribute( field );
|
||||
hintText.clear();
|
||||
}
|
||||
|
||||
changeAttribute( prefixedName, val );
|
||||
changeAttribute( prefixedName, val, hintText );
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1972,11 +1978,15 @@ void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
|
||||
{
|
||||
QString prefixedName = info->prefixedFieldName( field );
|
||||
QVariant val;
|
||||
QString hintText = hint;
|
||||
|
||||
if ( joinFeature.isValid() )
|
||||
{
|
||||
val = joinFeature.attribute( field.name() );
|
||||
hintText.clear();
|
||||
}
|
||||
|
||||
changeAttribute( prefixedName, val );
|
||||
changeAttribute( prefixedName, val, hintText );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
|
||||
* \param field The field to change
|
||||
* \param value The new value
|
||||
*/
|
||||
void changeAttribute( const QString &field, const QVariant &value );
|
||||
void changeAttribute( const QString &field, const QVariant &value, const QString &hintText = QString() );
|
||||
|
||||
/**
|
||||
* Update all editors to correspond to a different feature.
|
||||
|
Loading…
x
Reference in New Issue
Block a user