diff --git a/doc/api_break.dox b/doc/api_break.dox
index e442bd2cf7c..c642cf89349 100644
--- a/doc/api_break.dox
+++ b/doc/api_break.dox
@@ -178,6 +178,7 @@ This page tries to maintain a list with incompatible changes that happened in pr
- QgsAttributeAction was removed, and replaced by QgsActionManager.
+- QgsAttributeEditor was removed. Use QgsEditorWidgetRegistry::create() instead.
- QgsColorbutton was removed. QgsColorButtonV2 has now been renamed to QgsColorButton. Hence, QgsColorButtonV2 does not exist anymore.
- QgsColorDialog was removed, and QgsColorDialogV2 was renamed to QgsColorDialog. Hence, QgsColorButtonV2 does not exist anymore.
All the functionality from the old QgsColorDialog has been moved to the new class.
diff --git a/python/gui/gui.sip b/python/gui/gui.sip
index 403839f683a..9b83dd12eca 100644
--- a/python/gui/gui.sip
+++ b/python/gui/gui.sip
@@ -28,7 +28,6 @@
%Include qgsadvanceddigitizingdockwidget.sip
%Include qgsannotationitem.sip
%Include qgsattributedialog.sip
-%Include qgsattributeeditor.sip
%Include qgsattributeeditorcontext.sip
%Include qgsattributeform.sip
%Include qgsattributeformeditorwidget.sip
diff --git a/python/gui/qgsattributeeditor.sip b/python/gui/qgsattributeeditor.sip
deleted file mode 100644
index c78678d1e72..00000000000
--- a/python/gui/qgsattributeeditor.sip
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// \brief create attribute widget for editing
-class QgsAttributeEditor : QObject
-{
-%TypeHeaderCode
-#include
-%End
-
- public:
- QgsAttributeEditor( QObject *parent /TransferThis/ );
-
- /**
- * Creates or prepares a attribute editor widget
- * @param parent The parent object
- * @param editor The widget to prepare. Set to null if it should be generated
- * @param vl The vector layer to use as data source
- * @param idx The field index this widget refers to
- * @param value the value to initiate this widget with
- *
- */
- static QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant& value ) /Factory/;
- /**
- * Creates or prepares a attribute editor widget
- * @param parent The parent object
- * @param editor The widget to prepare. Set to null if it should be generated
- * @param vl The vector layer to use as data source
- * @param idx The field index this widget refers to
- * @param value the value to initiate this widget with
- * @param context the context used for the created attribute editor
- *
- */
- static QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant& value, QgsAttributeEditorContext& context ) /Factory/;
-
- static bool retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value );
- static bool setValue( QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value );
-};
diff --git a/src/app/qgsmergeattributesdialog.cpp b/src/app/qgsmergeattributesdialog.cpp
index 4d5476fcfbc..e9f19d395a7 100644
--- a/src/app/qgsmergeattributesdialog.cpp
+++ b/src/app/qgsmergeattributesdialog.cpp
@@ -19,13 +19,13 @@
#include "qgsmergeattributesdialog.h"
#include "qgisapp.h"
#include "qgsapplication.h"
+#include "qgseditorwidgetwrapper.h"
#include "qgsfeatureiterator.h"
#include "qgsfield.h"
#include "qgsmapcanvas.h"
#include "qgsrubberband.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
-#include "qgsattributeeditor.h"
#include "qgsstatisticalsummary.h"
#include "qgseditorwidgetregistry.h"
@@ -142,6 +142,8 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
QStringList verticalHeaderLabels; //the id column is in the
verticalHeaderLabels << tr( "Id" );
+ QgsAttributeEditorContext context;
+
for ( int i = 0; i < mFeatureList.size(); ++i )
{
verticalHeaderLabels << FID_TO_STRING( mFeatureList[i].id() );
@@ -155,8 +157,12 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
QTableWidgetItem* attributeValItem = new QTableWidgetItem( attrs.at( idx ).toString() );
attributeValItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
mTableWidget->setItem( i + 1, j, attributeValItem );
- QWidget* attributeWidget = QgsAttributeEditor::createAttributeEditor( mTableWidget, nullptr, mVectorLayer, idx, attrs.at( idx ) );
- mTableWidget->setCellWidget( i + 1, j, attributeWidget );
+ QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( mVectorLayer, idx, nullptr, mTableWidget, context );
+ if ( eww )
+ {
+ eww->setValue( attrs.at( idx ) );
+ }
+ mTableWidget->setCellWidget( i + 1, j, eww->widget() );
}
}
@@ -329,16 +335,14 @@ QVariant QgsMergeAttributesDialog::featureAttribute( QgsFeatureId featureId, int
for ( i = 0; i < mFeatureList.size() && mFeatureList.at( i ).id() != featureId; i++ )
;
- QVariant value;
- if ( i < mFeatureList.size() &&
- QgsAttributeEditor::retrieveValue( mTableWidget->cellWidget( i + 1, col ), mVectorLayer, fieldIdx, value ) )
+ if ( i < mFeatureList.size() )
{
- return value;
- }
- else
- {
- return QVariant( mVectorLayer->fields().at( fieldIdx ).type() );
+ QgsEditorWidgetWrapper* wrapper = QgsEditorWidgetWrapper::fromWidget( mTableWidget->cellWidget( i + 1, col ) );
+ if ( wrapper )
+ return wrapper->value();
}
+
+ return QVariant( mVectorLayer->fields().at( fieldIdx ).type() );
}
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 55644666f0f..816bb100182 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -166,7 +166,6 @@ SET(QGIS_GUI_SRCS
qgsadvanceddigitizingdockwidget.cpp
qgsannotationitem.cpp
qgsattributedialog.cpp
- qgsattributeeditor.cpp
qgsattributeform.cpp
qgsattributeformeditorwidget.cpp
qgsattributeforminterface.cpp
@@ -332,7 +331,6 @@ SET(QGIS_GUI_MOC_HDRS
qgsactionmenu.h
qgsadvanceddigitizingdockwidget.h
qgsattributedialog.h
- qgsattributeeditor.h
qgsattributeform.h
qgsattributeformeditorwidget.h
qgsattributetypeloaddialog.h
diff --git a/src/gui/qgsattributeeditor.cpp b/src/gui/qgsattributeeditor.cpp
deleted file mode 100644
index c14661d2571..00000000000
--- a/src/gui/qgsattributeeditor.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/***************************************************************************
- qgsattributeeditor.cpp - description
- -------------------
- begin : July 2009
- copyright : (C) 2009 by Jürgen E. Fischer
- email : jef@norbit.de
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-
-
-#include "qgseditorwidgetfactory.h"
-#include "qgseditorwidgetregistry.h"
-#include "qgseditorwidgetwrapper.h"
-
-#include "qgsattributeeditor.h"
-#include "qgsattributeeditorcontext.h"
-#include "qgsvectorlayer.h"
-
-
-QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
-{
- QgsAttributeEditorContext context;
-
- return createAttributeEditor( parent, editor, vl, idx, value, context );
-}
-
-QWidget *QgsAttributeEditor::createAttributeEditor( QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value, QMap &proxyWidgets )
-{
- Q_UNUSED( proxyWidgets )
-
- QgsAttributeEditorContext context;
-
- return createAttributeEditor( parent, editor, vl, idx, value, context );
-}
-
-QWidget* QgsAttributeEditor::createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant& value, QgsAttributeEditorContext& context )
-{
- QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( vl, idx, editor, parent, context );
-
- if ( eww )
- {
- eww->setValue( value );
- return eww->widget();
- }
- else
- {
- return nullptr;
- }
-}
-
-bool QgsAttributeEditor::retrieveValue( QWidget *editor, QgsVectorLayer *vl, int idx, QVariant &value )
-{
- Q_UNUSED( vl )
- Q_UNUSED( idx )
-
- if ( !editor )
- return false;
-
- QgsEditorWidgetWrapper* wrapper = QgsEditorWidgetWrapper::fromWidget( editor );
-
- if ( wrapper )
- {
- value = wrapper->value();
- return true;
- }
- return false;
-}
-
-bool QgsAttributeEditor::setValue( QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value )
-{
- Q_UNUSED( vl )
- Q_UNUSED( idx )
-
- if ( !editor )
- return false;
-
- QgsEditorWidgetWrapper* wrapper = QgsEditorWidgetWrapper::fromWidget( editor );
-
- if ( wrapper )
- {
- wrapper->setValue( value );
- return true;
- }
- return false;
-}
diff --git a/src/gui/qgsattributeeditor.h b/src/gui/qgsattributeeditor.h
deleted file mode 100644
index e360754931a..00000000000
--- a/src/gui/qgsattributeeditor.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/***************************************************************************
- qgsattributeeditor.h - description
- -------------------
- begin : July 2009
- copyright : (C) 2009 by Jürgen E. Fischer
- email : jef@norbit.de
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-#ifndef QGSATTRIBUTEEDITOR_H
-#define QGSATTRIBUTEEDITOR_H
-
-#include
-#include
-#include
-
-class QgsAttributeEditorContext;
-class QgsAttributeEditorElement;
-class QgsDualView;
-class QgsRelationManager;
-class QgsVectorLayer;
-
-/** \ingroup gui
- * \brief create attribute widget for editing
- *
- * @deprecated
- */
-// TODO QGIS 3.0 - remove
-class GUI_EXPORT QgsAttributeEditor : public QObject
-{
- Q_OBJECT
-
- public:
- QgsAttributeEditor( QObject* parent, QgsVectorLayer* vl = nullptr, int idx = -1 )
- : QObject( parent )
- {
- Q_UNUSED( vl )
- Q_UNUSED( idx )
- }
- /**
- * Creates or prepares a attribute editor widget
- * @param parent The parent object
- * @param editor The widget to prepare. Set to null if it should be generated
- * @param vl The vector layer to use as data source
- * @param idx The field index this widget refers to
- * @param value the value to initiate this widget with
- * @param proxyWidgets an array of widgets, which will act as a value proxy if the same field is inserted multiple times
- *
- * @deprecated
- */
- static Q_DECL_DEPRECATED QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant &value, QMap& proxyWidgets );
-
- /**
- * Creates or prepares a attribute editor widget
- * @param parent The parent object
- * @param editor The widget to prepare. Set to null if it should be generated
- * @param vl The vector layer to use as data source
- * @param idx The field index this widget refers to
- * @param value the value to initiate this widget with
- *
- */
- static QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant& value );
- /**
- * Creates or prepares a attribute editor widget
- * @param parent The parent object
- * @param editor The widget to prepare. Set to null if it should be generated
- * @param vl The vector layer to use as data source
- * @param idx The field index this widget refers to
- * @param value the value to initiate this widget with
- * @param context the context used for the created attribute editor
- *
- */
- static QWidget* createAttributeEditor( QWidget* parent, QWidget* editor, QgsVectorLayer* vl, int idx, const QVariant& value, QgsAttributeEditorContext& context );
-
- static bool retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value );
- static bool setValue( QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value );
-};
-
-#endif
diff --git a/src/gui/qgsformannotationitem.cpp b/src/gui/qgsformannotationitem.cpp
index 429811f34ac..70020f03689 100644
--- a/src/gui/qgsformannotationitem.cpp
+++ b/src/gui/qgsformannotationitem.cpp
@@ -16,7 +16,9 @@
***************************************************************************/
#include "qgsformannotationitem.h"
-#include "qgsattributeeditor.h"
+#include "qgsattributeeditorcontext.h"
+#include "qgseditorwidgetregistry.h"
+#include "qgseditorwidgetwrapper.h"
#include "qgsfeature.h"
#include "qgsfeatureiterator.h"
#include "qgslogger.h"
@@ -89,6 +91,7 @@ QWidget* QgsFormAnnotationItem::createDesignerWidget( const QString& filePath )
file.close();
//get feature and set attribute information
+ QgsAttributeEditorContext context;
if ( mVectorLayer && mHasAssociatedFeature )
{
QgsFeature f;
@@ -103,7 +106,11 @@ QWidget* QgsFormAnnotationItem::createDesignerWidget( const QString& filePath )
QWidget* attWidget = widget->findChild( fields.at( i ).name() );
if ( attWidget )
{
- QgsAttributeEditor::createAttributeEditor( widget, attWidget, mVectorLayer, i, attrs.at( i ) );
+ QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( mVectorLayer, i, attWidget, widget, context );
+ if ( eww )
+ {
+ eww->setValue( attrs.at( i ) );
+ }
}
}
}