Skip to content

Commit 24bde35

Browse files
author
Patrick Valsecchi
committedAug 29, 2016
Smarter default edit widgets with plugins to pick them
Now the widgets factories can give a score on how good they could handle a widget. Additionaly, plugins can be added to choose a widget factory in function of an external information. One of them uses a table in PostgresQL to allow specification of the widget type and configuration. I took the opportunity to remove a few deprecated method in relation to this.
1 parent 235204f commit 24bde35

File tree

61 files changed

+909
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+909
-234
lines changed
 

‎doc/api_break.dox

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ place of a null pointer.</li>
492492

493493
<ul>
494494
<li>Does no longer inherit QObject
495+
<li>widgetType() and widgetConfig() now reflect only the user configured values.
496+
QgsEditorWidgetRegistry::instance()->findBest() must be used instead.</li>
495497
</ul>
496498

497499
\subsection qgis_api_break_3_0_QgsExpression QgsExpression
@@ -590,6 +592,13 @@ and the new ramp can be retrieved after executing the dialog by calling ramp().<
590592
plugins calling this method will need to be updated.</li>
591593
</ul>
592594

595+
\subsection qgis_api_break_3_0_QgsEditorWidgetRegistry QgsEditorWidgetRegistry
596+
597+
<ul>
598+
<li>The signature of isFieldSupported() has been changed to return an unsigned (how good it supports the given field)
599+
and to const-correct it.</li>
600+
</ul>
601+
593602
\subsection qgis_api_break_3_0_QgsGroupWMSDataDialog QgsGroupWMSDataDialog
594603

595604
<ul>
@@ -817,6 +826,14 @@ plugins calling this method will need to be updated.</li>
817826

818827
<ul>
819828
<li>setMapRenderer() has been removed. Use setMapSettings() instead.</li>
829+
<li>excludeAttributesWMS() and setExcludeAttributesWMS() have been renamed to excludeAttributesWms() and
830+
setExcludeAttributesWms()</li>
831+
<li>excludeAttributesWFS() and setExcludeAttributesWFS() have been renamed to excludeAttributesWfs() and
832+
setExcludeAttributesWfs()</li>
833+
<li>editorWidgetV2() and editorWidgetV2Config() have been removed and QgsEditorWidgetRegistry::instance()->findBest() must be used instead.</li>
834+
<li>setEditorWidgetV2(), setEditorWidgetV2Config() have been removed and their equivalent in editFormConfig() must be used instead.</li>
835+
<li>setCheckedState() is removed. Use editFormConfig()->setWidgetConfig()` instead.</li>
836+
<li>valueMap(), valueRelation(), dateFormat(), widgetSize() have been removed. Use QgsEditorWidgetRegistry::instance()->findBest().config() instead.</li>
820837
</ul>
821838

822839
\subsection qgis_api_break_3_0_QgsRenderContext QgsRenderContext

‎python/core/qgseditformconfig.sip

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,6 @@ class QgsEditFormConfig
142142
*/
143143
void setWidgetType( int fieldIdx, const QString& widgetType );
144144

145-
/**
146-
* Get the id for the editor widget used to represent the field at the given index
147-
*
148-
* @param fieldIdx The index of the field
149-
*
150-
* @return The id for the editor widget or a NULL string if not applicable
151-
*/
152-
QString widgetType( int fieldIdx ) const;
153-
154145
/**
155146
* Get the id for the editor widget used to represent the field at the given index
156147
*
@@ -177,40 +168,14 @@ class QgsEditFormConfig
177168
*/
178169
void setWidgetConfig( int attrIdx, const QgsEditorWidgetConfig& config );
179170

180-
/**
181-
* Set the editor widget config for a widget.
182-
*
183-
* Example:
184-
* \code{.py}
185-
* layer.setWidgetConfig( 'relation_id', { 'nm-rel': 'other_relation' } )
186-
* \endcode
187-
*
188-
* @param widgetName The name of the widget or field to configure
189-
* @param config The config to set for this field
190-
*
191-
* @see setWidgetType() for a list of widgets and choose the widget to see the available options.
192-
*
193-
* @note not available in python bindings
194-
*/
195-
// void setWidgetConfig( const QString& widgetName, const QgsEditorWidgetConfig& config );
196-
197-
/**
198-
* Get the configuration for the editor widget used to represent the field at the given index
199-
*
200-
* @param fieldIdx The index of the field
201-
*
202-
* @return The configuration for the editor widget or an empty config if the field does not exist
203-
*/
204-
QgsEditorWidgetConfig widgetConfig( int fieldIdx ) const;
205-
206171
/**
207172
* Get the configuration for the editor widget used to represent the field with the given name
208173
*
209-
* @param widgetName The name of the widget. This can be a field name or the name of an additional widget.
174+
* @param fieldName The name of the field.
210175
*
211176
* @return The configuration for the editor widget or an empty config if the field does not exist
212177
*/
213-
QgsEditorWidgetConfig widgetConfig( const QString& widgetName ) const;
178+
QgsEditorWidgetConfig widgetConfig( const QString& fieldName ) const;
214179

215180
/**
216181
* Remove the configuration for the editor widget used to represent the field at the given index
@@ -224,11 +189,11 @@ class QgsEditFormConfig
224189
/**
225190
* Remove the configuration for the editor widget used to represent the field with the given name
226191
*
227-
* @param widgetName The name of the widget. This can be a field name or the name of an additional widget.
192+
* @param fieldName The name of the field.
228193
*
229194
* @return true if successful, false if the field does not exist
230195
*/
231-
bool removeWidgetConfig( const QString& widgetName );
196+
bool removeWidgetConfig( const QString& fieldName );
232197

233198
/**
234199
* This returns true if the field is manually set to read only or if the field
@@ -372,4 +337,9 @@ class QgsEditFormConfig
372337
* Deserialize drag and drop designer elements.
373338
*/
374339
QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement* parent );
340+
341+
/**
342+
* Parse the XML for the config of one editor widget.
343+
*/
344+
static QgsEditorWidgetConfig parseEditorWidgetConfig( const QDomElement& cfgElem );
375345
};

0 commit comments

Comments
 (0)
Please sign in to comment.