Skip to content

Commit

Permalink
Remove QgsEditorWidgetConfig
Browse files Browse the repository at this point in the history
This is replaced with a QVariantMap. It was never really more than this in the
past and with the switch to QgsConfigurationProperties, there is really no
longer any reason to assume that this will change.
  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent ab0dccf commit 9fd0802
Show file tree
Hide file tree
Showing 92 changed files with 213 additions and 294 deletions.
1 change: 0 additions & 1 deletion python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
%Include qgsdbfilterproxymodel.sip
%Include qgsdistancearea.sip
%Include qgseditformconfig.sip
%Include qgseditorwidgetconfig.sip
%Include qgseditorwidgetsetup.sip
%Include qgserror.sip
%Include qgsexpression.sip
Expand Down
2 changes: 1 addition & 1 deletion python/core/fieldkit/qgskeyvaluefieldkit.sip
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class QgsKeyValueFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgskeyvaluefieldkit"
#include "qgskeyvaluefieldkit.h"
%End
public:
QgsKeyValueFieldKit();
Expand Down
24 changes: 3 additions & 21 deletions python/core/fieldkit/qgsrelationreferencefieldkit.sip
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
/***************************************************************************
qgsrelationreferencefieldkit.sip - QgsRelationReferenceFieldKit

---------------------
begin : 3.12.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

class QgsRelationReferenceFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgsrelationreferencefieldkit"
#include "qgsrelationreferencefieldkit.h"
%End
public:
QgsRelationReferenceFieldKit();

QString id() const;

virtual QString representValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const override;

virtual QVariant sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap&config, const QVariant& cache, const QVariant& value ) const override;
virtual QString representValue( QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
virtual QVariant sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap&config, const QVariant& cache, const QVariant& value ) const;
};
6 changes: 3 additions & 3 deletions python/core/fieldkit/qgsvaluerelationfieldkit.sip
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class QgsValueRelationFieldKit : QgsFieldKit
{
%TypeHeaderCode
#include "qgsvaluerelationfieldkit"
#include "qgsvaluerelationfieldkit.h"
%End

public:
Expand All @@ -30,7 +30,7 @@ class QgsValueRelationFieldKit : QgsFieldKit
QString value;
};

typedef QVector < ValueRelationItem > ValueRelationCache;
typedef QVector < QgsValueRelationFieldKit::ValueRelationItem > ValueRelationCache;

QgsValueRelationFieldKit();

Expand All @@ -41,5 +41,5 @@ class QgsValueRelationFieldKit : QgsFieldKit

QVariant createCache( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const;

static ValueRelationCache createCache( const QVariantMap& config );
static QgsValueRelationFieldKit::ValueRelationCache createCache( const QVariantMap& config );
};
4 changes: 2 additions & 2 deletions python/core/qgseditformconfig.sip
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class QgsEditFormConfig
*
* @note not available in python bindings
*/
void setWidgetConfig( const QString& fieldName, const QgsEditorWidgetConfig& config );
void setWidgetConfig( const QString& fieldName, const QVariantMap& config );

/**
* Get the configuration for the editor widget used to represent the field with the given name
Expand All @@ -175,7 +175,7 @@ class QgsEditFormConfig
*
* @return The configuration for the editor widget or an empty config if the field does not exist
*/
QgsEditorWidgetConfig widgetConfig( const QString& fieldName ) const;
QVariantMap widgetConfig( const QString& fieldName ) const;

/**
* Remove the configuration for the editor widget used to represent the field with the given name
Expand Down
14 changes: 0 additions & 14 deletions python/core/qgseditorwidgetconfig.sip

This file was deleted.

4 changes: 2 additions & 2 deletions python/core/qgseditorwidgetsetup.sip
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class QgsEditorWidgetSetup
/**
* Constructor
*/
QgsEditorWidgetSetup( const QString& type, const QgsEditorWidgetConfig& config );
QgsEditorWidgetSetup( const QString& type, const QVariantMap& config );
QgsEditorWidgetSetup();

/**
Expand All @@ -21,7 +21,7 @@ class QgsEditorWidgetSetup
/**
* @return the widget configuration to used
*/
QgsEditorWidgetConfig config() const;
QVariantMap config() const;

/**
* @return true if there is no widget configured.
Expand Down
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/core/qgseditorconfigwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class QgsEditorConfigWidget : QWidget
*/
QgsVectorLayer* layer();

virtual QgsEditorWidgetConfig config() = 0;
virtual void setConfig( const QgsEditorWidgetConfig& config ) = 0;
virtual QVariantMap config() = 0;
virtual void setConfig( const QVariantMap& config ) = 0;

signals:

Expand Down
14 changes: 7 additions & 7 deletions python/gui/editorwidgets/core/qgseditorwidgetfactory.sip
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ class QgsEditorWidgetFactory
virtual QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const = 0 /Factory/;

/**
* Read the config from an XML file and map it to a proper {@link QgsEditorWidgetConfig}.
* Read the config from an XML file and map it to a proper {@link QVariantMap}.
*
* @param configElement The configuration element from the project file
* @param layer The layer for which this configuration applies
* @param fieldIdx The field on the layer for which this configuration applies
*
* @return A configuration object. This will be passed to your widget wrapper later on
*/
QgsEditorWidgetConfig readEditorConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );
QVariantMap readEditorConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );

/**
* Serialize your configuration and save it in a xml doc.
Expand All @@ -87,7 +87,7 @@ class QgsEditorWidgetFactory
* @param layer The layer for which this configuration applies
* @param fieldIdx The field on the layer for which this configuration applies
*/
virtual void writeConfig( const QgsEditorWidgetConfig& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx );
virtual void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx );

/**
* Check if this editor widget type supports a certain field.
Expand All @@ -111,15 +111,15 @@ class QgsEditorWidgetFactory
//virtual QHash<const char*, int> supportedWidgetTypes();

/**
* Read the config from an XML file and map it to a proper {@link QgsEditorWidgetConfig}.
* Read the config from an XML file and map it to a proper {@link QVariantMap}.
*
* @param configElement The configuration element from the project file
* @param layer The layer for which this configuration applies
* @param fieldIdx The field on the layer for which this configuration applies
*
* @return A configuration object. This will be passed to your widget wrapper later on
*/
virtual QgsEditorWidgetConfig readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );
virtual QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );

/**
* This method allows disabling this editor widget type for a certain field.
Expand All @@ -146,10 +146,10 @@ class QgsEditorWidgetFactory
/**
* Copy the given config element to a XML attribute.
*/
static void config2xml( const QgsEditorWidgetConfig& config, QDomElement& configElement, const QString& fieldName );
static void config2xml( const QVariantMap& config, QDomElement& configElement, const QString& fieldName );

/**
* Copy the given XML attribute to the configuration element.
*/
static void xml2config( const QDomElement& configElement, QgsEditorWidgetConfig& config, const QString& fieldName );
static void xml2config( const QDomElement& configElement, QVariantMap& config, const QString& fieldName );
};
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/core/qgseditorwidgetregistry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ class QgsEditorWidgetRegistry : QObject
QgsEditorWidgetWrapper* create( const QString& widgetId,
QgsVectorLayer* vl,
int fieldIdx,
const QgsEditorWidgetConfig& config,
const QVariantMap& config,
QWidget* editor,
QWidget* parent /TransferThis/,
const QgsAttributeEditorContext& context = QgsAttributeEditorContext() ) /Factory/;

QgsSearchWidgetWrapper* createSearchWidget( const QString& widgetId,
QgsVectorLayer* vl,
int fieldIdx,
const QgsEditorWidgetConfig& config,
const QVariantMap& config,
QWidget* parent /TransferThis/,
const QgsAttributeEditorContext& context = QgsAttributeEditorContext() ) /Factory/;

Expand Down
4 changes: 2 additions & 2 deletions python/gui/editorwidgets/core/qgswidgetwrapper.sip
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class QgsWidgetWrapper : QObject
*
* @param config The config for this wrapper
*/
void setConfig( const QgsEditorWidgetConfig& config );
void setConfig( const QVariantMap& config );

/**
* Set the context in which this widget is shown
Expand All @@ -93,7 +93,7 @@ class QgsWidgetWrapper : QObject
*
* @return The configuration
*/
QgsEditorWidgetConfig config() const;
QVariantMap config() const;

/**
* Returns information about the context in which this widget is shown
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsattributeformeditorwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class QgsAttributeFormEditorWidget : QWidget
* @param context editor context (not available in python bindings)
*/
void createSearchWidgetWrappers( const QString& widgetId, int fieldIdx,
const QgsEditorWidgetConfig& config,
const QVariantMap& config,
const QgsAttributeEditorContext &context = QgsAttributeEditorContext() );

/** Sets the current mode for the widget. The widget will adapt its state and visible widgets to
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const QString QgsAttributeTypeDialog::editorWidgetText()
}
}

const QgsEditorWidgetConfig QgsAttributeTypeDialog::editorWidgetConfig()
const QVariantMap QgsAttributeTypeDialog::editorWidgetConfig()
{
QListWidgetItem* item = selectionListWidget->currentItem();
if ( item )
Expand All @@ -139,7 +139,7 @@ const QgsEditorWidgetConfig QgsAttributeTypeDialog::editorWidgetConfig()
}
}

return QgsEditorWidgetConfig();
return QVariantMap();
}

void QgsAttributeTypeDialog::setWidgetType( const QString& type )
Expand Down Expand Up @@ -181,7 +181,7 @@ void QgsAttributeTypeDialog::setWidgetType( const QString& type )
defaultExpressionChanged();
}

void QgsAttributeTypeDialog::setWidgetConfig( const QgsEditorWidgetConfig& config )
void QgsAttributeTypeDialog::setWidgetConfig( const QVariantMap& config )
{
mWidgetConfig = config;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgsattributetypedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut

void setWidgetType( const QString& type );

const QgsEditorWidgetConfig editorWidgetConfig();
const QVariantMap editorWidgetConfig();

void setWidgetConfig( const QgsEditorWidgetConfig& config );
void setWidgetConfig( const QVariantMap& config );

/**
* Setter for checkbox to label on top
Expand Down Expand Up @@ -176,7 +176,7 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
QgsVectorLayer *mLayer;
int mFieldIdx;

QgsEditorWidgetConfig mWidgetConfig;
QVariantMap mWidgetConfig;

//! Cached configuration dialog (lazy loaded)
QMap< QString, QgsEditorConfigWidget* > mEditorConfigWidgets;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ void QgsFieldsProperties::apply()
// relations
for ( int i = 0; i < mRelationsList->rowCount(); ++i )
{
QgsEditorWidgetConfig cfg;
QVariantMap cfg;

QComboBox* cb = qobject_cast<QComboBox*>( mRelationsList->cellWidget( i, RelNmCol ) );
QVariant otherRelation = cb->currentData();
Expand Down
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ SET(QGIS_CORE_HDRS
qgsdiagramrenderer.h
qgsdistancearea.h
qgseditformconfig.h
qgseditorwidgetconfig.h
qgseditorwidgetsetup.h
qgsfeaturefilterprovider.h
qgserror.h
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgseditformconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ QString QgsEditFormConfig::widgetType( const QString& fieldName ) const
return d->mEditorWidgetTypes.value( fieldName );
}

QgsEditorWidgetConfig QgsEditFormConfig::widgetConfig( const QString& fieldName ) const
QVariantMap QgsEditFormConfig::widgetConfig( const QString& fieldName ) const
{
return d->mWidgetConfigs.value( fieldName );
}
Expand Down Expand Up @@ -74,7 +74,7 @@ void QgsEditFormConfig::setWidgetType( const QString& widgetName, const QString&
d->mEditorWidgetTypes[widgetName] = widgetType;
}

void QgsEditFormConfig::setWidgetConfig( const QString& widgetName, const QgsEditorWidgetConfig& config )
void QgsEditFormConfig::setWidgetConfig( const QString& widgetName, const QVariantMap& config )
{
d.detach();
d->mWidgetConfigs[widgetName] = config;
Expand Down Expand Up @@ -429,7 +429,7 @@ void QgsEditFormConfig::writeXml( QDomNode& node ) const

QDomElement widgetsElem = doc.createElement( QStringLiteral( "widgets" ) );

QMap<QString, QgsEditorWidgetConfig >::ConstIterator configIt( d->mWidgetConfigs.constBegin() );
QMap<QString, QVariantMap >::ConstIterator configIt( d->mWidgetConfigs.constBegin() );

while ( configIt != d->mWidgetConfigs.constEnd() )
{
Expand All @@ -442,7 +442,7 @@ void QgsEditFormConfig::writeXml( QDomNode& node ) const
QDomElement configElem = doc.createElement( QStringLiteral( "config" ) );
widgetElem.appendChild( configElem );

QgsEditorWidgetConfig::ConstIterator cfgIt( configIt.value().constBegin() );
QVariantMap::ConstIterator cfgIt( configIt.value().constBegin() );

while ( cfgIt != configIt.value().constEnd() )
{
Expand Down
5 changes: 2 additions & 3 deletions src/core/qgseditformconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <QDomElement>
#include <QDomDocument>

#include "qgseditorwidgetconfig.h"
#include "qgsattributeeditorelement.h"

class QgsRelationManager;
Expand Down Expand Up @@ -200,7 +199,7 @@ class CORE_EXPORT QgsEditFormConfig
*
* @note not available in python bindings
*/
void setWidgetConfig( const QString& fieldName, const QgsEditorWidgetConfig& config );
void setWidgetConfig( const QString& fieldName, const QVariantMap& config );

/**
* Get the configuration for the editor widget used to represent the field with the given name
Expand All @@ -210,7 +209,7 @@ class CORE_EXPORT QgsEditFormConfig
*
* @return The configuration for the editor widget or an empty config if the field does not exist
*/
QgsEditorWidgetConfig widgetConfig( const QString& fieldName ) const;
QVariantMap widgetConfig( const QString& fieldName ) const;

/**
* Remove the configuration for the editor widget used to represent the field with the given name
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgseditformconfig_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class QgsEditFormConfigPrivate : public QSharedData
QMap< QString, bool> mLabelOnTop;

QMap<QString, QString> mEditorWidgetTypes;
QMap<QString, QgsEditorWidgetConfig > mWidgetConfigs;
QMap<QString, QVariantMap > mWidgetConfigs;

//! Defines the default layout to use for the attribute editor (Drag and drop, UI File, Generated)
QgsEditFormConfig::EditorLayout mEditorLayout;
Expand Down
Loading

0 comments on commit 9fd0802

Please sign in to comment.