mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Remove deprecated QgsAttributeEditor
This commit is contained in:
parent
fe65063c2b
commit
2a9e5206e9
@ -178,6 +178,7 @@ This page tries to maintain a list with incompatible changes that happened in pr
|
||||
|
||||
<ul>
|
||||
<li>QgsAttributeAction was removed, and replaced by QgsActionManager.</li>
|
||||
<li>QgsAttributeEditor was removed. Use QgsEditorWidgetRegistry::create() instead.</li>
|
||||
<li>QgsColorbutton was removed. QgsColorButtonV2 has now been renamed to QgsColorButton. Hence, QgsColorButtonV2 does not exist anymore.</li>
|
||||
<li>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.</li>
|
||||
|
@ -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
|
||||
|
@ -1,36 +0,0 @@
|
||||
|
||||
// \brief create attribute widget for editing
|
||||
class QgsAttributeEditor : QObject
|
||||
{
|
||||
%TypeHeaderCode
|
||||
#include <qgsattributeeditor.h>
|
||||
%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 );
|
||||
};
|
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<int, QWidget*> &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;
|
||||
}
|
@ -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 <QVariant>
|
||||
#include <QMetaType>
|
||||
#include <QGridLayout>
|
||||
|
||||
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<int, QWidget*>& 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
|
@ -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<QWidget*>( 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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user