Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix open form button not always enabled in relation reference widget (#…
…42144 )
* fix open form button not always enabled in relation reference widget
when the underlying model has more feature than what the model fetches by default (100),
the feature is not fetched yet when the combobox has its index changed
the new signal allows to be aware when the feature is ready to be used
Loading branch information
@@ -154,6 +154,15 @@ If set to 0, no limit is applied when fetching
signals:
void currentFeatureChanged();
%Docstring
Emitted when the current feature in the model has changed
This emitted both when the extra value changes and when the extra value status changes.
It allows being notified when the feature is fetched after the extra value has been set.
.. versionadded:: 3.16.5
%End
void sourceLayerChanged();
%Docstring
The source layer from which features will be fetched.
@@ -221,6 +221,13 @@ Normally the primary key of the layer.
void allowNullChanged();
%Docstring
Determines if a NULL value should be available in the list.
%End
void currentFeatureChanged();
%Docstring
Emitted when the current feature changes
.. versionadded:: 3.16.5
%End
};
@@ -28,6 +28,11 @@ QgsFeaturePickerModelBase::QgsFeaturePickerModelBase( QObject *parent )
mReloadTimer .setInterval ( 100 );
mReloadTimer .setSingleShot ( true );
connect ( &mReloadTimer , &QTimer::timeout, this , &QgsFeaturePickerModelBase::scheduledReload );
// The fact that the feature changed is a combination of the 2 signals:
// If the extra value is set to a feature currently not fetched, it will go through an intermediate step while the extra value does not exist (as it call reloadFeature)
connect ( this , &QgsFeaturePickerModelBase::extraIdentifierValueChanged, this , &QgsFeaturePickerModelBase::currentFeatureChanged );
connect ( this , &QgsFeaturePickerModelBase::extraValueDoesNotExistChanged, this , &QgsFeaturePickerModelBase::currentFeatureChanged );
}
@@ -513,11 +518,13 @@ void QgsFeaturePickerModelBase::setExtraIdentifierValueUnguarded( const QVariant
if ( !isNull )
{
mEntries .prepend ( createEntry ( identifierValue ) );
setExtraValueDoesNotExist ( true );
reloadCurrentFeature ();
}
else
{
mEntries .prepend ( QgsFeatureExpressionValuesGatherer::nullEntry ( mSourceLayer ) );
setExtraValueDoesNotExist ( false );
}
endInsertRows ();
@@ -178,6 +178,14 @@ class CORE_EXPORT QgsFeaturePickerModelBase : public QAbstractItemModel SIP_ABST
signals:
/* *
* Emitted when the current feature in the model has changed
* This emitted both when the extra value changes and when the extra value status changes.
* It allows being notified when the feature is fetched after the extra value has been set.
* \since QGIS 3.16.5
*/
void currentFeatureChanged ();
/* *
* The source layer from which features will be fetched.
*/
@@ -599,7 +599,7 @@ void QgsRelationReferenceWidget::init()
}
// Only connect after iterating, to have only one iterator on the referenced table at once
connect ( mComboBox , qgis::overload< int >:: of ( &QComboBox::currentIndexChanged ) , this , &QgsRelationReferenceWidget::comboReferenceChanged );
connect ( mComboBox , &QgsFeatureListComboBox::currentFeatureChanged , this , &QgsRelationReferenceWidget::comboReferenceChanged );
QApplication::restoreOverrideCursor ();
@@ -723,9 +723,8 @@ void QgsRelationReferenceWidget::mapIdentification()
}
}
void QgsRelationReferenceWidget::comboReferenceChanged ( int index )
void QgsRelationReferenceWidget::comboReferenceChanged ()
{
Q_UNUSED ( index )
mReferencedLayer ->getFeatures ( mComboBox ->currentFeatureRequest () ).nextFeature ( mFeature );
highlightFeature ( mFeature );
updateAttributeEditorFrame ( mFeature );
@@ -287,7 +287,7 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
private slots:
void highlightActionTriggered ( QAction *action );
void deleteHighlight ();
void comboReferenceChanged ( int index );
void comboReferenceChanged ();
void featureIdentified ( const QgsFeature &feature );
void setMapTool ( QgsMapTool *mapTool );
void unsetMapTool ();
@@ -61,6 +61,8 @@ QgsFeatureListComboBox::QgsFeatureListComboBox( QWidget *parent )
connect ( mLineEdit , &QgsFilterLineEdit::textEdited, this , &QgsFeatureListComboBox::onCurrentTextChanged );
connect ( mModel , &QgsFeatureFilterModel::currentFeatureChanged, this , &QgsFeatureListComboBox::currentFeatureChanged );
setToolTip ( tr ( " Just start typing what you are looking for." ) );
}
@@ -234,6 +234,12 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
*/
void allowNullChanged ();
/* *
* Emitted when the current feature changes
* \since QGIS 3.16.5
*/
void currentFeatureChanged ();
private slots:
void onCurrentTextChanged ( const QString &text );
void onFilterUpdateCompleted ();
@@ -253,6 +259,7 @@ class GUI_EXPORT QgsFeatureListComboBox : public QComboBox
bool mIsCurrentlyEdited = false ;
friend class TestQgsFeatureListComboBox ;
friend class TestQgsRelationReferenceWidget ;
};
Toggle all file notes
Toggle all file annotations