Skip to content

Commit 2a9e520

Browse files
committed
Remove deprecated QgsAttributeEditor
1 parent fe65063 commit 2a9e520

8 files changed

+25
-231
lines changed

doc/api_break.dox

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ This page tries to maintain a list with incompatible changes that happened in pr
178178

179179
<ul>
180180
<li>QgsAttributeAction was removed, and replaced by QgsActionManager.</li>
181+
<li>QgsAttributeEditor was removed. Use QgsEditorWidgetRegistry::create() instead.</li>
181182
<li>QgsColorbutton was removed. QgsColorButtonV2 has now been renamed to QgsColorButton. Hence, QgsColorButtonV2 does not exist anymore.</li>
182183
<li>QgsColorDialog was removed, and QgsColorDialogV2 was renamed to QgsColorDialog. Hence, QgsColorButtonV2 does not exist anymore.
183184
All the functionality from the old QgsColorDialog has been moved to the new class.</li>

python/gui/gui.sip

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
%Include qgsadvanceddigitizingdockwidget.sip
2929
%Include qgsannotationitem.sip
3030
%Include qgsattributedialog.sip
31-
%Include qgsattributeeditor.sip
3231
%Include qgsattributeeditorcontext.sip
3332
%Include qgsattributeform.sip
3433
%Include qgsattributeformeditorwidget.sip

python/gui/qgsattributeeditor.sip

-36
This file was deleted.

src/app/qgsmergeattributesdialog.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
#include "qgsmergeattributesdialog.h"
2020
#include "qgisapp.h"
2121
#include "qgsapplication.h"
22+
#include "qgseditorwidgetwrapper.h"
2223
#include "qgsfeatureiterator.h"
2324
#include "qgsfield.h"
2425
#include "qgsmapcanvas.h"
2526
#include "qgsrubberband.h"
2627
#include "qgsvectorlayer.h"
2728
#include "qgsvectordataprovider.h"
28-
#include "qgsattributeeditor.h"
2929
#include "qgsstatisticalsummary.h"
3030
#include "qgseditorwidgetregistry.h"
3131

@@ -142,6 +142,8 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
142142
QStringList verticalHeaderLabels; //the id column is in the
143143
verticalHeaderLabels << tr( "Id" );
144144

145+
QgsAttributeEditorContext context;
146+
145147
for ( int i = 0; i < mFeatureList.size(); ++i )
146148
{
147149
verticalHeaderLabels << FID_TO_STRING( mFeatureList[i].id() );
@@ -155,8 +157,12 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
155157
QTableWidgetItem* attributeValItem = new QTableWidgetItem( attrs.at( idx ).toString() );
156158
attributeValItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
157159
mTableWidget->setItem( i + 1, j, attributeValItem );
158-
QWidget* attributeWidget = QgsAttributeEditor::createAttributeEditor( mTableWidget, nullptr, mVectorLayer, idx, attrs.at( idx ) );
159-
mTableWidget->setCellWidget( i + 1, j, attributeWidget );
160+
QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( mVectorLayer, idx, nullptr, mTableWidget, context );
161+
if ( eww )
162+
{
163+
eww->setValue( attrs.at( idx ) );
164+
}
165+
mTableWidget->setCellWidget( i + 1, j, eww->widget() );
160166
}
161167
}
162168

@@ -329,16 +335,14 @@ QVariant QgsMergeAttributesDialog::featureAttribute( QgsFeatureId featureId, int
329335
for ( i = 0; i < mFeatureList.size() && mFeatureList.at( i ).id() != featureId; i++ )
330336
;
331337

332-
QVariant value;
333-
if ( i < mFeatureList.size() &&
334-
QgsAttributeEditor::retrieveValue( mTableWidget->cellWidget( i + 1, col ), mVectorLayer, fieldIdx, value ) )
338+
if ( i < mFeatureList.size() )
335339
{
336-
return value;
337-
}
338-
else
339-
{
340-
return QVariant( mVectorLayer->fields().at( fieldIdx ).type() );
340+
QgsEditorWidgetWrapper* wrapper = QgsEditorWidgetWrapper::fromWidget( mTableWidget->cellWidget( i + 1, col ) );
341+
if ( wrapper )
342+
return wrapper->value();
341343
}
344+
345+
return QVariant( mVectorLayer->fields().at( fieldIdx ).type() );
342346
}
343347

344348

src/gui/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ SET(QGIS_GUI_SRCS
166166
qgsadvanceddigitizingdockwidget.cpp
167167
qgsannotationitem.cpp
168168
qgsattributedialog.cpp
169-
qgsattributeeditor.cpp
170169
qgsattributeform.cpp
171170
qgsattributeformeditorwidget.cpp
172171
qgsattributeforminterface.cpp
@@ -332,7 +331,6 @@ SET(QGIS_GUI_MOC_HDRS
332331
qgsactionmenu.h
333332
qgsadvanceddigitizingdockwidget.h
334333
qgsattributedialog.h
335-
qgsattributeeditor.h
336334
qgsattributeform.h
337335
qgsattributeformeditorwidget.h
338336
qgsattributetypeloaddialog.h

src/gui/qgsattributeeditor.cpp

-93
This file was deleted.

src/gui/qgsattributeeditor.h

-86
This file was deleted.

src/gui/qgsformannotationitem.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
***************************************************************************/
1717

1818
#include "qgsformannotationitem.h"
19-
#include "qgsattributeeditor.h"
19+
#include "qgsattributeeditorcontext.h"
20+
#include "qgseditorwidgetregistry.h"
21+
#include "qgseditorwidgetwrapper.h"
2022
#include "qgsfeature.h"
2123
#include "qgsfeatureiterator.h"
2224
#include "qgslogger.h"
@@ -89,6 +91,7 @@ QWidget* QgsFormAnnotationItem::createDesignerWidget( const QString& filePath )
8991
file.close();
9092

9193
//get feature and set attribute information
94+
QgsAttributeEditorContext context;
9295
if ( mVectorLayer && mHasAssociatedFeature )
9396
{
9497
QgsFeature f;
@@ -103,7 +106,11 @@ QWidget* QgsFormAnnotationItem::createDesignerWidget( const QString& filePath )
103106
QWidget* attWidget = widget->findChild<QWidget*>( fields.at( i ).name() );
104107
if ( attWidget )
105108
{
106-
QgsAttributeEditor::createAttributeEditor( widget, attWidget, mVectorLayer, i, attrs.at( i ) );
109+
QgsEditorWidgetWrapper* eww = QgsEditorWidgetRegistry::instance()->create( mVectorLayer, i, attWidget, widget, context );
110+
if ( eww )
111+
{
112+
eww->setValue( attrs.at( i ) );
113+
}
107114
}
108115
}
109116
}

0 commit comments

Comments
 (0)