mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fallback to generated layout for Select by Value if using a custom
UI form Custom UI forms are not supported with the attribute form search mode, but this way users with custom UI forms can still use the feature
This commit is contained in:
parent
ebf1df5d5e
commit
f1e4c4592b
@ -54,5 +54,19 @@ class QgsAttributeEditorContext
|
||||
*/
|
||||
void setFormMode( FormMode mode );
|
||||
|
||||
/** Returns true if the attribute editor should permit use of custom UI forms.
|
||||
* @see setAllowCustomUi()
|
||||
* @note added in QGIS 2.16
|
||||
*/
|
||||
bool allowCustomUi() const;
|
||||
|
||||
/** Sets whether the attribute editor should permit use of custom UI forms.
|
||||
* @param allow set to true to allow custom UI forms, or false to disable them and use default generated
|
||||
* QGIS forms
|
||||
* @see allowCustomUi()
|
||||
* @note added in QGIS 2.16
|
||||
*/
|
||||
void setAllowCustomUi( bool allow );
|
||||
|
||||
const QgsAttributeEditorContext* parentContext() const;
|
||||
};
|
||||
|
@ -6929,10 +6929,12 @@ void QgisApp::modifyAttributesOfSelectedFeatures()
|
||||
|
||||
//dummy feature
|
||||
QgsFeature f;
|
||||
QgsAttributeDialog* dialog = new QgsAttributeDialog( vl, &f, false, this );
|
||||
QgsAttributeEditorContext context;
|
||||
context.setAllowCustomUi( false );
|
||||
|
||||
QgsAttributeDialog* dialog = new QgsAttributeDialog( vl, &f, false, this, true, context );
|
||||
dialog->setMode( QgsAttributeForm::MultiEditMode );
|
||||
dialog->exec();
|
||||
|
||||
}
|
||||
|
||||
void QgisApp::mergeSelectedFeatures()
|
||||
|
@ -23,6 +23,7 @@ QgsSelectByFormDialog::QgsSelectByFormDialog( QgsVectorLayer* layer, const QgsAt
|
||||
{
|
||||
QgsAttributeEditorContext dlgContext = context;
|
||||
dlgContext.setFormMode( QgsAttributeEditorContext::StandaloneDialog );
|
||||
dlgContext.setAllowCustomUi( false );
|
||||
|
||||
mForm = new QgsAttributeForm( layer, QgsFeature(), dlgContext, this );
|
||||
mForm->setMode( QgsAttributeForm::SearchMode );
|
||||
|
@ -56,6 +56,7 @@ class GUI_EXPORT QgsAttributeEditorContext
|
||||
, mVectorLayerTools( nullptr )
|
||||
, mRelationMode( Undefined )
|
||||
, mFormMode( Embed )
|
||||
, mAllowCustomUi( true )
|
||||
{}
|
||||
|
||||
QgsAttributeEditorContext( const QgsAttributeEditorContext& parentContext, FormMode formMode )
|
||||
@ -65,6 +66,7 @@ class GUI_EXPORT QgsAttributeEditorContext
|
||||
, mDistanceArea( parentContext.mDistanceArea )
|
||||
, mRelationMode( Undefined )
|
||||
, mFormMode( formMode )
|
||||
, mAllowCustomUi( true )
|
||||
{
|
||||
Q_ASSERT( parentContext.vectorLayerTools() );
|
||||
}
|
||||
@ -77,6 +79,7 @@ class GUI_EXPORT QgsAttributeEditorContext
|
||||
, mRelation( relation )
|
||||
, mRelationMode( relationMode )
|
||||
, mFormMode( widgetMode )
|
||||
, mAllowCustomUi( true )
|
||||
{
|
||||
Q_ASSERT( parentContext.vectorLayerTools() );
|
||||
}
|
||||
@ -111,6 +114,20 @@ class GUI_EXPORT QgsAttributeEditorContext
|
||||
*/
|
||||
inline void setFormMode( FormMode mode ) { mFormMode = mode; }
|
||||
|
||||
/** Returns true if the attribute editor should permit use of custom UI forms.
|
||||
* @see setAllowCustomUi()
|
||||
* @note added in QGIS 2.16
|
||||
*/
|
||||
bool allowCustomUi() const { return mAllowCustomUi; }
|
||||
|
||||
/** Sets whether the attribute editor should permit use of custom UI forms.
|
||||
* @param allow set to true to allow custom UI forms, or false to disable them and use default generated
|
||||
* QGIS forms
|
||||
* @see allowCustomUi()
|
||||
* @note added in QGIS 2.16
|
||||
*/
|
||||
void setAllowCustomUi( bool allow ) { mAllowCustomUi = allow; }
|
||||
|
||||
inline const QgsAttributeEditorContext* parentContext() const { return mParentContext; }
|
||||
|
||||
private:
|
||||
@ -121,6 +138,7 @@ class GUI_EXPORT QgsAttributeEditorContext
|
||||
QgsRelation mRelation;
|
||||
RelationMode mRelationMode;
|
||||
FormMode mFormMode;
|
||||
bool mAllowCustomUi;
|
||||
};
|
||||
|
||||
#endif // QGSATTRIBUTEEDITORCONTEXT_H
|
||||
|
@ -1064,7 +1064,8 @@ void QgsAttributeForm::init()
|
||||
setContentsMargins( 0, 0, 0, 0 );
|
||||
|
||||
// Try to load Ui-File for layout
|
||||
if ( mLayer->editFormConfig()->layout() == QgsEditFormConfig::UiFileLayout && !mLayer->editFormConfig()->uiForm().isEmpty() )
|
||||
if ( mContext.allowCustomUi() && mLayer->editFormConfig()->layout() == QgsEditFormConfig::UiFileLayout &&
|
||||
!mLayer->editFormConfig()->uiForm().isEmpty() )
|
||||
{
|
||||
QFile file( mLayer->editFormConfig()->uiForm() );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user