Skip to content
Permalink
Browse files

Revert "Merge pull request #3338 from pvalsecc/editor_widgets_selection"

This reverts commit bbafbf4, reversing
changes made to 13ac043.
  • Loading branch information
m-kuhn committed Aug 29, 2016
1 parent b144823 commit a529b448e774afae7f5bbfe2facad417d7902fd8
Showing with 234 additions and 909 deletions.
  1. +0 −17 doc/api_break.dox
  2. +39 −9 python/core/qgseditformconfig.sip
  3. +0 −45 python/core/qgsfield.sip
  4. +0 −41 python/gui/editorwidgets/core/qgseditorwidgetautoconf.sip
  5. +4 −10 python/gui/editorwidgets/core/qgseditorwidgetfactory.sip
  6. +0 −19 python/gui/editorwidgets/core/qgseditorwidgetregistry.sip
  7. +0 −1 python/gui/gui.sip
  8. +4 −6 src/app/ogr/qgsvectorlayersaveasdialog.cpp
  9. +3 −3 src/app/qgisapp.cpp
  10. +4 −3 src/app/qgsattributetabledialog.cpp
  11. +4 −5 src/app/qgsfieldsproperties.cpp
  12. +9 −11 src/app/qgsidentifyresultsdialog.cpp
  13. +1 −2 src/app/qgsidentifyresultsdialog.h
  14. +3 −4 src/app/qgsmergeattributesdialog.cpp
  15. +41 −28 src/core/qgseditformconfig.cpp
  16. +24 −13 src/core/qgseditformconfig.h
  17. +0 −10 src/core/qgsfield.cpp
  18. +0 −50 src/core/qgsfield.h
  19. +0 −2 src/core/qgsfield_p.h
  20. +1 −1 src/core/qgsvectorlayerundocommand.cpp
  21. +0 −1 src/gui/CMakeLists.txt
  22. +3 −1 src/gui/attributetable/qgsattributetabledelegate.cpp
  23. +4 −4 src/gui/attributetable/qgsattributetablemodel.cpp
  24. +1 −2 src/gui/attributetable/qgsdualview.cpp
  25. +0 −112 src/gui/editorwidgets/core/qgseditorwidgetautoconf.cpp
  26. +0 −88 src/gui/editorwidgets/core/qgseditorwidgetautoconf.h
  27. +2 −2 src/gui/editorwidgets/core/qgseditorwidgetfactory.cpp
  28. +6 −12 src/gui/editorwidgets/core/qgseditorwidgetfactory.h
  29. +4 −26 src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp
  30. +0 −37 src/gui/editorwidgets/core/qgseditorwidgetregistry.h
  31. +0 −6 src/gui/editorwidgets/qgscheckboxwidgetfactory.cpp
  32. +0 −1 src/gui/editorwidgets/qgscheckboxwidgetfactory.h
  33. +0 −14 src/gui/editorwidgets/qgscolorwidgetfactory.cpp
  34. +0 −1 src/gui/editorwidgets/qgscolorwidgetfactory.h
  35. +0 −15 src/gui/editorwidgets/qgsdatetimeeditfactory.cpp
  36. +0 −1 src/gui/editorwidgets/qgsdatetimeeditfactory.h
  37. +3 −3 src/gui/editorwidgets/qgsenumerationwidgetfactory.cpp
  38. +2 −1 src/gui/editorwidgets/qgsenumerationwidgetfactory.h
  39. +3 −3 src/gui/editorwidgets/qgsexternalresourcewidgetfactory.cpp
  40. +3 −1 src/gui/editorwidgets/qgsexternalresourcewidgetfactory.h
  41. +11 −2 src/gui/editorwidgets/qgsrangewidgetfactory.cpp
  42. +1 −1 src/gui/editorwidgets/qgsrangewidgetfactory.h
  43. +0 −7 src/gui/editorwidgets/qgstexteditwidgetfactory.cpp
  44. +2 −1 src/gui/editorwidgets/qgstexteditwidgetfactory.h
  45. +0 −6 src/gui/editorwidgets/qgsuuidwidgetfactory.cpp
  46. +0 −1 src/gui/editorwidgets/qgsuuidwidgetfactory.h
  47. +4 −1 src/gui/qgsattributeeditor.cpp
  48. +18 −15 src/gui/qgsattributeform.cpp
  49. +1 −0 src/providers/postgres/CMakeLists.txt
  50. +0 −2 src/providers/postgres/qgspostgresconn.cpp
  51. +22 −68 src/providers/postgres/qgspostgresprovider.cpp
  52. +0 −4 src/providers/postgres/qgspostgresprovider.h
  53. +3 −4 src/server/qgsserverprojectparser.cpp
  54. +4 −4 src/server/qgswmsserver.cpp
  55. +0 −13 tests/src/core/testqgsfield.cpp
  56. +0 −1 tests/src/gui/CMakeLists.txt
  57. +0 −1 tests/src/gui/testqgsattributeform.cpp
  58. +0 −119 tests/src/gui/testqgseditorwidgetregistry.cpp
  59. +0 −23 tests/src/python/test_provider_postgres.py
  60. +0 −1 tests/testdata/provider/testdata_pg.sh
  61. +0 −24 tests/testdata/provider/testdata_pg.sql
@@ -507,8 +507,6 @@ place of a null pointer.</li>

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

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

\subsection qgis_api_break_3_0_QgsEditorWidgetRegistry QgsEditorWidgetRegistry

<ul>
<li>The signature of isFieldSupported() has been changed to return an unsigned (how good it supports the given field)
and to const-correct it.</li>
</ul>

\subsection qgis_api_break_3_0_QgsGroupWMSDataDialog QgsGroupWMSDataDialog

<ul>
@@ -855,14 +846,6 @@ plugins calling this method will need to be updated.</li>

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

\subsection qgis_api_break_3_0_QgsRenderContext QgsRenderContext
@@ -142,6 +142,15 @@ class QgsEditFormConfig
*/
void setWidgetType( int fieldIdx, const QString& widgetType );

/**
* Get the id for the editor widget used to represent the field at the given index
*
* @param fieldIdx The index of the field
*
* @return The id for the editor widget or a NULL string if not applicable
*/
QString widgetType( int fieldIdx ) const;

/**
* Get the id for the editor widget used to represent the field at the given index
*
@@ -168,14 +177,40 @@ class QgsEditFormConfig
*/
void setWidgetConfig( int attrIdx, const QgsEditorWidgetConfig& config );

/**
* Set the editor widget config for a widget.
*
* Example:
* \code{.py}
* layer.setWidgetConfig( 'relation_id', { 'nm-rel': 'other_relation' } )
* \endcode
*
* @param widgetName The name of the widget or field to configure
* @param config The config to set for this field
*
* @see setWidgetType() for a list of widgets and choose the widget to see the available options.
*
* @note not available in python bindings
*/
// void setWidgetConfig( const QString& widgetName, const QgsEditorWidgetConfig& config );

/**
* Get the configuration for the editor widget used to represent the field at the given index
*
* @param fieldIdx The index of the field
*
* @return The configuration for the editor widget or an empty config if the field does not exist
*/
QgsEditorWidgetConfig widgetConfig( int fieldIdx ) const;

/**
* Get the configuration for the editor widget used to represent the field with the given name
*
* @param fieldName The name of the field.
* @param widgetName The name of the widget. This can be a field name or the name of an additional widget.
*
* @return The configuration for the editor widget or an empty config if the field does not exist
*/
QgsEditorWidgetConfig widgetConfig( const QString& fieldName ) const;
QgsEditorWidgetConfig widgetConfig( const QString& widgetName ) const;

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

/**
* This returns true if the field is manually set to read only or if the field
@@ -337,9 +372,4 @@ class QgsEditFormConfig
* Deserialize drag and drop designer elements.
*/
QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QgsAttributeEditorElement* parent );

/**
* Parse the XML for the config of one editor widget.
*/
static QgsEditorWidgetConfig parseEditorWidgetConfig( const QDomElement& cfgElem );
};
@@ -1,35 +1,3 @@
/** \ingroup core
* Holder for the widget type and its configuration for a field.
*/
class QgsEditorWidgetSetup
{
%TypeHeaderCode
#include <qgsfield.h>
%End
public:
/**
* Constructor
*/
QgsEditorWidgetSetup( const QString& type, const QgsEditorWidgetConfig& config );
QgsEditorWidgetSetup();

/**
* @return the widget type to use
*/
QString type() const;

/**
* @return the widget configuration to used
*/
QgsEditorWidgetConfig config() const;

/**
* @return true if there is no widget configured.
*/
bool isNull() const;
};


/** \class QgsField
* \ingroup core
* Encapsulate a field in an attribute table or data source.
@@ -211,19 +179,6 @@ class QgsField
//! Allows direct construction of QVariants from fields.
operator QVariant() const;

/**
* Set the editor widget setup for the field.
*
* @param v The value to set
*/
void setEditorWidgetSetup( const QgsEditorWidgetSetup& v );

/**
* Get the editor widget setup for the field.
*
* @return the value
*/
const QgsEditorWidgetSetup& editorWidgetSetup() const;
}; // class QgsField


This file was deleted.

@@ -170,23 +170,17 @@ class QgsEditorWidgetFactory
*/
virtual QgsEditorWidgetConfig readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );

private:
/**
* This method allows disabling this editor widget type for a certain field.
* By default, it returns 5 for every fields.
* By default, it returns true for all fields.
* Reimplement this if you only support certain fields.
*
* Typical return values are:
* * 0: not supported
* * 5: maybe support (for example, Datetime support strings depending on their content)
* * 10: basic support (this is what returns TextEdit for example, since it supports everything in a crude way)
* * 20: specialised support
*
* @param vl
* @param fieldIdx
* @return 0 if the field is not supported or a bigger number if it can (the widget with the biggest number will be
* taken by default). The default implementation returns 5..
* @return True if the field is supported.
*
* @see supportsField( QgsVectorLayer* vl, fieldIdx )
*/
virtual unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const;
virtual bool isFieldSupported( QgsVectorLayer* vl, int fieldIdx );
};
@@ -13,7 +13,6 @@
* *
***************************************************************************/


/**
* This class manages all known edit widget factories
*/
@@ -44,17 +43,6 @@ class QgsEditorWidgetRegistry : QObject
*/
static void initEditors( QgsMapCanvas* mapCanvas = 0, QgsMessageBar* messageBar = 0 );

/**
* Find the best editor widget and its configuration for a given field.
*
* @param vl The vector layer for which this widget will be created
* @param fieldIdx The field index on the specified layer for which this widget will be created
*
* @return The id of the widget type to use and its config
*/
QgsEditorWidgetSetup findBest( const QgsVectorLayer* vl, const QString& fieldName ) const;


/**
* Create an attribute editor widget wrapper of a given type for a given field.
* The editor may be NULL if you want the widget wrapper to create a default widget.
@@ -128,11 +116,4 @@ class QgsEditorWidgetRegistry : QObject
* @return true, if successful, false, if the widgetId is already in use or widgetFactory is NULL
*/
bool registerWidget( const QString& widgetId, QgsEditorWidgetFactory* widgetFactory /Transfer/ );

/**
* Register a new auto-conf plugin.
*
* @param plugin The plugin (ownership is transfered)
*/
void registerAutoConfPlugin( QgsEditorWidgetAutoConfPlugin* plugin );
};
@@ -258,7 +258,6 @@
%Include effects/qgspainteffectwidget.sip

%Include editorwidgets/core/qgseditorconfigwidget.sip
%Include editorwidgets/core/qgseditorwidgetautoconf.sip
%Include editorwidgets/core/qgseditorwidgetfactory.sip
%Include editorwidgets/core/qgseditorwidgetregistry.sip
%Include editorwidgets/core/qgseditorwidgetwrapper.sip
@@ -249,9 +249,8 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
bool foundFieldThatCanBeExportedAsDisplayedValue = false;
for ( int i = 0; i < mLayer->fields().size(); ++i )
{
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, mLayer->fields()[i].name() );
if ( setup.type() != "TextEdit" &&
QgsEditorWidgetRegistry::instance()->factory( setup.type() ) )
if ( mLayer->editFormConfig().widgetType( i ) != "TextEdit" &&
QgsEditorWidgetRegistry::instance()->factory( mLayer->editFormConfig().widgetType( i ) ) )
{
foundFieldThatCanBeExportedAsDisplayedValue = true;
break;
@@ -286,11 +285,10 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx

if ( foundFieldThatCanBeExportedAsDisplayedValue )
{
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, mLayer->fields()[i].name() );
QgsEditorWidgetFactory *factory = nullptr;
if ( flags == Qt::ItemIsEnabled &&
setup.type() != "TextEdit" &&
( factory = QgsEditorWidgetRegistry::instance()->factory( setup.type() ) ) )
mLayer->editFormConfig().widgetType( i ) != "TextEdit" &&
( factory = QgsEditorWidgetRegistry::instance()->factory( mLayer->editFormConfig().widgetType( i ) ) ) )
{
item = new QTableWidgetItem( tr( "Use %1" ).arg( factory->name() ) );
item->setFlags(( selectAllFields ) ? ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ) : Qt::ItemIsUserCheckable );
@@ -6149,11 +6149,11 @@ QVariant QgisAppFieldValueConverter::convert( int idx, const QVariant& value )
{
return value;
}
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, mLayer->fields().field( idx ).name() );
QgsEditorWidgetFactory *factory = QgsEditorWidgetRegistry::instance()->factory( setup.type() );
QgsEditorWidgetFactory *factory = QgsEditorWidgetRegistry::instance()->factory( mLayer->editFormConfig().widgetType( idx ) );
if ( factory )
{
return QVariant( factory->representValue( mLayer, idx, setup.config(), QVariant(), value ) );
QgsEditorWidgetConfig cfg( mLayer->editFormConfig().widgetConfig( idx ) );
return QVariant( factory->representValue( mLayer, idx, cfg, QVariant(), value ) );
}
return value;
}
@@ -391,7 +391,7 @@ void QgsAttributeTableDialog::columnBoxInit()
if ( idx < 0 )
continue;

if ( QgsEditorWidgetRegistry::instance()->findBest( mLayer, field.name() ).type() != "Hidden" )
if ( mLayer->editFormConfig().widgetType( idx ) != "Hidden" )
{
QIcon icon = mLayer->fields().iconForField( idx );
QString alias = mLayer->attributeDisplayName( idx );
@@ -527,9 +527,10 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
int fldIdx = mLayer->fieldNameIndex( fieldName );
if ( fldIdx < 0 )
return;
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, fieldName );
const QString widgetType = mLayer->editFormConfig().widgetType( fldIdx );
const QgsEditorWidgetConfig widgetConfig = mLayer->editFormConfig().widgetConfig( fldIdx );
mCurrentSearchWidgetWrapper = QgsEditorWidgetRegistry::instance()->
createSearchWidget( setup.type(), mLayer, fldIdx, setup.config(), mFilterContainer, mEditorContext );
createSearchWidget( widgetType, mLayer, fldIdx, widgetConfig, mFilterContainer, mEditorContext );
if ( mCurrentSearchWidgetWrapper->applyDirectly() )
{
connect( mCurrentSearchWidgetWrapper, SIGNAL( expressionChanged( QString ) ), SLOT( filterQueryChanged( QString ) ) );
@@ -392,9 +392,9 @@ void QgsFieldsProperties::loadRelations()
if ( nmrel.fieldPairs().at( 0 ).referencingField() != relation.fieldPairs().at( 0 ).referencingField() )
nmCombo->addItem( QString( "%1 (%2)" ).arg( nmrel.referencedLayer()->name(), nmrel.fieldPairs().at( 0 ).referencedField() ), nmrel.id() );

const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, relation.id() );
QgsEditorWidgetConfig cfg = mLayer->editFormConfig().widgetConfig( relation.id() );

const QVariant nmrelcfg = setup.config().value( "nm-rel" );
QVariant nmrelcfg = cfg.value( "nm-rel" );

int idx = nmCombo->findData( nmrelcfg.toString() );

@@ -1028,9 +1028,8 @@ QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer* layer, int idx )
mNotNull = layer->editFormConfig().notNull( idx );
mConstraint = layer->editFormConfig().expression( idx );
mConstraintDescription = layer->editFormConfig().expressionDescription( idx );
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( layer, layer->fields().field( idx ).name() );
mEditorWidgetType = setup.type();
mEditorWidgetConfig = setup.config();
mEditorWidgetType = layer->editFormConfig().widgetType( idx );
mEditorWidgetConfig = layer->editFormConfig().widgetConfig( idx );
}

/*

0 comments on commit a529b44

Please sign in to comment.
You can’t perform that action at this time.