mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Make a new global QgsGui singleton
Move QgsEditorWidgetRegistry from being a singleton itself to instead being a member of the QgsGui singleton
This commit is contained in:
parent
280ca31972
commit
4a5c9a7ba3
@ -1011,7 +1011,7 @@ QgsEditFormConfig {#qgis_api_break_3_0_QgsEditFormConfig}
|
||||
|
||||
- Does no longer inherit QObject
|
||||
- widgetType() and widgetConfig() now reflect only the user configured values.
|
||||
QgsEditorWidgetRegistry::instance()->findBest() must be used instead.
|
||||
QgsEditorWidgetRegistry::findBest() must be used instead.
|
||||
- widgetConfig(), setWidgetType(), setWidgetConfig() and removeWidgetConfig() now only take a string as first parameter. Access by index has been removed.
|
||||
- widgetType() has been removed in favor of QgsVectorLayer::editorWidgetSetup()
|
||||
- expression(), setExpression(), expressionDescription() and setExpressionDescription()
|
||||
@ -1213,6 +1213,7 @@ plugins calling this method will need to be updated.
|
||||
QgsEditorWidgetRegistry {#qgis_api_break_3_0_QgsEditorWidgetRegistry}
|
||||
-----------------------
|
||||
|
||||
- The instance() singleton was removed. Use QgsGui::editorWidgetRegistry() instead.
|
||||
- The signature of isFieldSupported() has been changed to return an unsigned
|
||||
integer (how good it supports the given field) and is now const.
|
||||
|
||||
@ -1822,10 +1823,10 @@ QgsRenderChecker {#qgis_api_break_3_0_QgsRenderChecker}
|
||||
setExcludeAttributesWms()
|
||||
- excludeAttributesWFS() and setExcludeAttributesWFS() have been renamed to excludeAttributesWfs() and
|
||||
setExcludeAttributesWfs()
|
||||
- editorWidgetV2() and editorWidgetV2Config() have been removed and QgsEditorWidgetRegistry::instance()->findBest() must be used instead.
|
||||
- editorWidgetV2() and editorWidgetV2Config() have been removed and QgsEditorWidgetRegistry::findBest() must be used instead.
|
||||
- setEditorWidgetV2(), setEditorWidgetV2Config() have been removed and their equivalent in editFormConfig() must be used instead.
|
||||
- setCheckedState() is removed. Use `editFormConfig()->setWidgetConfig()` instead.
|
||||
- valueMap(), valueRelation(), dateFormat(), widgetSize() have been removed. Use QgsEditorWidgetRegistry::instance()->findBest().config() instead.
|
||||
- valueMap(), valueRelation(), dateFormat(), widgetSize() have been removed. Use QgsEditorWidgetRegistry::findBest().config() instead.
|
||||
|
||||
|
||||
QgsRenderContext {#qgis_api_break_3_0_QgsRenderContext}
|
||||
|
@ -21,15 +21,6 @@ class QgsEditorWidgetRegistry : QObject
|
||||
%End
|
||||
public:
|
||||
|
||||
static QgsEditorWidgetRegistry *instance();
|
||||
%Docstring
|
||||
This class is a singleton and has therefore to be accessed with this method instead
|
||||
of a constructor.
|
||||
|
||||
:return: The one and only instance of the editor widget registry
|
||||
:rtype: QgsEditorWidgetRegistry
|
||||
%End
|
||||
|
||||
static void initEditors( QgsMapCanvas *mapCanvas = 0, QgsMessageBar *messageBar = 0 );
|
||||
%Docstring
|
||||
Registers all the default widgets.
|
||||
|
@ -81,6 +81,7 @@
|
||||
%Include qgsfloatingwidget.sip
|
||||
%Include qgsfocuswatcher.sip
|
||||
%Include qgsformannotation.sip
|
||||
%Include qgsgui.sip
|
||||
%Include qgsgeometryrubberband.sip
|
||||
%Include qgsgradientcolorrampdialog.sip
|
||||
%Include qgsgradientstopeditor.sip
|
||||
|
53
python/gui/qgsgui.sip
Normal file
53
python/gui/qgsgui.sip
Normal file
@ -0,0 +1,53 @@
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsgui.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsGui
|
||||
{
|
||||
%Docstring
|
||||
QgsGui is a singleton class containing various registry and other global members
|
||||
related to GUI classes.
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsgui.h"
|
||||
%End
|
||||
public:
|
||||
|
||||
|
||||
|
||||
static QgsGui *instance();
|
||||
%Docstring
|
||||
Returns a pointer to the singleton instance.
|
||||
:rtype: QgsGui
|
||||
%End
|
||||
|
||||
static QgsEditorWidgetRegistry *editorWidgetRegistry();
|
||||
%Docstring
|
||||
Returns the global editor widget registry, used for managing all known edit widget factories.
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsEditorWidgetRegistry
|
||||
%End
|
||||
|
||||
~QgsGui();
|
||||
|
||||
private:
|
||||
QgsGui( const QgsGui &other );
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/gui/qgsgui.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
@ -23,7 +23,7 @@
|
||||
#include "qgseditorwidgetfactory.h"
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgssettings.h"
|
||||
|
||||
#include "qgsgui.h"
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QTextCodec>
|
||||
@ -379,9 +379,9 @@ 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() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, mLayer->fields()[i].name() );
|
||||
if ( setup.type() != QLatin1String( "TextEdit" ) &&
|
||||
QgsEditorWidgetRegistry::instance()->factory( setup.type() ) )
|
||||
QgsGui::editorWidgetRegistry()->factory( setup.type() ) )
|
||||
{
|
||||
foundFieldThatCanBeExportedAsDisplayedValue = true;
|
||||
break;
|
||||
@ -416,11 +416,11 @@ void QgsVectorLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( int idx
|
||||
|
||||
if ( foundFieldThatCanBeExportedAsDisplayedValue )
|
||||
{
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, mLayer->fields()[i].name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, mLayer->fields()[i].name() );
|
||||
QgsEditorWidgetFactory *factory = nullptr;
|
||||
if ( flags == Qt::ItemIsEnabled &&
|
||||
setup.type() != QLatin1String( "TextEdit" ) &&
|
||||
( factory = QgsEditorWidgetRegistry::instance()->factory( setup.type() ) ) )
|
||||
( factory = QgsGui::editorWidgetRegistry()->factory( setup.type() ) ) )
|
||||
{
|
||||
item = new QTableWidgetItem( tr( "Use %1" ).arg( factory->name() ) );
|
||||
item->setFlags( ( selectAllFields ) ? ( Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ) : Qt::ItemIsUserCheckable );
|
||||
|
@ -278,6 +278,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
|
||||
#include "qgsmaprenderertask.h"
|
||||
#include "qgsmapdecoration.h"
|
||||
#include "qgsnewnamedialog.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include "qgssublayersdialog.h"
|
||||
#include "ogr/qgsopenvectorlayerdialog.h"
|
||||
@ -924,7 +925,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
|
||||
mVectorLayerTools = new QgsGuiVectorLayerTools();
|
||||
|
||||
// Init the editor widget types
|
||||
QgsEditorWidgetRegistry::initEditors( mMapCanvas, mInfoBar );
|
||||
QgsGui::editorWidgetRegistry()->initEditors( mMapCanvas, mInfoBar );
|
||||
|
||||
mInternalClipboard = new QgsClipboard; // create clipboard
|
||||
connect( mInternalClipboard, &QgsClipboard::changed, this, &QgisApp::clipboardChanged );
|
||||
@ -6810,7 +6811,7 @@ QVariant QgisAppFieldValueConverter::convert( int idx, const QVariant &value )
|
||||
{
|
||||
return value;
|
||||
}
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, mLayer->fields().field( idx ).name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, mLayer->fields().field( idx ).name() );
|
||||
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
||||
return fieldFormatter->representValue( mLayer, idx, setup.config(), QVariant(), value );
|
||||
}
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "qgsfields.h"
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgsfieldproxymodel.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
QgsExpressionContext QgsAttributeTableDialog::createExpressionContext() const
|
||||
{
|
||||
@ -412,7 +413,7 @@ void QgsAttributeTableDialog::columnBoxInit()
|
||||
if ( idx < 0 )
|
||||
continue;
|
||||
|
||||
if ( QgsEditorWidgetRegistry::instance()->findBest( mLayer, field.name() ).type() != QLatin1String( "Hidden" ) )
|
||||
if ( QgsGui::editorWidgetRegistry()->findBest( mLayer, field.name() ).type() != QLatin1String( "Hidden" ) )
|
||||
{
|
||||
QIcon icon = mLayer->fields().iconForField( idx );
|
||||
QString alias = mLayer->attributeDisplayName( idx );
|
||||
@ -560,8 +561,8 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject *filterAction )
|
||||
int fldIdx = mLayer->fields().lookupField( fieldName );
|
||||
if ( fldIdx < 0 )
|
||||
return;
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, fieldName );
|
||||
mCurrentSearchWidgetWrapper = QgsEditorWidgetRegistry::instance()->
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, fieldName );
|
||||
mCurrentSearchWidgetWrapper = QgsGui::editorWidgetRegistry()->
|
||||
createSearchWidget( setup.type(), mLayer, fldIdx, setup.config(), mFilterContainer, mEditorContext );
|
||||
if ( mCurrentSearchWidgetWrapper->applyDirectly() )
|
||||
{
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "qgsfieldformatter.h"
|
||||
#include "qgseditorwidgetfactory.h"
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QTableWidgetItem>
|
||||
#include <QFile>
|
||||
@ -46,7 +47,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx
|
||||
setupUi( this );
|
||||
setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->fields().at( fieldIdx ).name(), vl->name() ) );
|
||||
|
||||
QMapIterator<QString, QgsEditorWidgetFactory *> it( QgsEditorWidgetRegistry::instance()->factories() );
|
||||
QMapIterator<QString, QgsEditorWidgetFactory *> it( QgsGui::editorWidgetRegistry()->factories() );
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
it.next();
|
||||
@ -160,7 +161,7 @@ void QgsAttributeTypeDialog::setEditorWidgetType( const QString &type )
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsEditorConfigWidget *cfgWdg = QgsEditorWidgetRegistry::instance()->createConfigWidget( type, mLayer, mFieldIdx, this );
|
||||
QgsEditorConfigWidget *cfgWdg = QgsGui::editorWidgetRegistry()->createConfigWidget( type, mLayer, mFieldIdx, this );
|
||||
|
||||
if ( cfgWdg )
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsfieldexpressionwidget.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QWidget>
|
||||
@ -339,7 +340,7 @@ void QgsFieldsProperties::setRow( int row, int idx, const QgsField &field )
|
||||
|
||||
FieldConfig cfg( mLayer, idx );
|
||||
QPushButton *pb = nullptr;
|
||||
pb = new QPushButton( QgsEditorWidgetRegistry::instance()->name( cfg.mEditorWidgetType ) );
|
||||
pb = new QPushButton( QgsGui::editorWidgetRegistry()->name( cfg.mEditorWidgetType ) );
|
||||
cfg.mButton = pb;
|
||||
mFieldsList->setCellWidget( row, AttrEditTypeCol, pb );
|
||||
|
||||
@ -398,7 +399,7 @@ void QgsFieldsProperties::loadRelations()
|
||||
if ( nmrel.fieldPairs().at( 0 ).referencingField() != relation.fieldPairs().at( 0 ).referencingField() )
|
||||
nmCombo->addItem( QStringLiteral( "%1 (%2)" ).arg( nmrel.referencedLayer()->name(), nmrel.fieldPairs().at( 0 ).referencedField() ), nmrel.id() );
|
||||
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, relation.id() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relation.id() );
|
||||
|
||||
const QVariant nmrelcfg = setup.config().value( QStringLiteral( "nm-rel" ) );
|
||||
|
||||
@ -1102,7 +1103,7 @@ QgsFieldsProperties::FieldConfig::FieldConfig( QgsVectorLayer *layer, int idx )
|
||||
mConstraintStrength.insert( QgsFieldConstraints::ConstraintUnique, constraints.constraintStrength( QgsFieldConstraints::ConstraintUnique ) );
|
||||
mConstraintStrength.insert( QgsFieldConstraints::ConstraintExpression, constraints.constraintStrength( QgsFieldConstraints::ConstraintExpression ) );
|
||||
mConstraintDescription = constraints.constraintDescription();
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( layer, layer->fields().field( idx ).name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( layer, layer->fields().field( idx ).name() );
|
||||
mEditorWidgetType = setup.type();
|
||||
mEditorWidgetConfig = setup.config();
|
||||
}
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "qgsfieldformatterregistry.h"
|
||||
#include "qgsfieldformatter.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QLabel>
|
||||
@ -535,7 +536,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
|
||||
if ( i >= fields.count() )
|
||||
break;
|
||||
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( vlayer, fields[i].name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vlayer, fields[i].name() );
|
||||
if ( setup.type() == QLatin1String( "Hidden" ) )
|
||||
{
|
||||
continue;
|
||||
@ -603,7 +604,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
|
||||
continue;
|
||||
|
||||
QString value = fields.at( i ).displayString( attrs.at( i ) );
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( vlayer, fields.at( i ).name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vlayer, fields.at( i ).name() );
|
||||
QString value2 = representValue( vlayer, setup, fields.at( i ).name(), value );
|
||||
|
||||
tblResults->setRowCount( j + 1 );
|
||||
@ -710,7 +711,7 @@ QString QgsIdentifyResultsDialog::representValue( QgsVectorLayer *vlayer, const
|
||||
QVariant cache;
|
||||
QMap<QString, QVariant> &layerCaches = mWidgetCaches[vlayer->id()];
|
||||
|
||||
QgsEditorWidgetFactory *factory = QgsEditorWidgetRegistry::instance()->factory( setup.type() );
|
||||
QgsEditorWidgetFactory *factory = QgsGui::editorWidgetRegistry()->factory( setup.type() );
|
||||
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
||||
|
||||
int idx = vlayer->fields().lookupField( fieldName );
|
||||
@ -1542,7 +1543,7 @@ void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx,
|
||||
|
||||
if ( item->data( 0, Qt::UserRole + 1 ).toInt() == idx )
|
||||
{
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( vlayer, fld.name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vlayer, fld.name() );
|
||||
value = representValue( vlayer, setup, fld.name(), val );
|
||||
|
||||
QgsTreeWidgetItem *treeItem = static_cast< QgsTreeWidgetItem * >( item );
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "qgsstatisticalsummary.h"
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <limits>
|
||||
#include <QComboBox>
|
||||
@ -115,7 +116,7 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
|
||||
mHiddenAttributes.clear();
|
||||
for ( int idx = 0; idx < mFields.count(); ++idx )
|
||||
{
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mVectorLayer, mFields.at( idx ).name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mVectorLayer, mFields.at( idx ).name() );
|
||||
if ( setup.type() == QLatin1String( "Hidden" ) || setup.type() == QLatin1String( "Immutable" ) )
|
||||
{
|
||||
mHiddenAttributes.insert( idx );
|
||||
@ -155,7 +156,7 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
|
||||
QTableWidgetItem *attributeValItem = new QTableWidgetItem( attrs.at( idx ).toString() );
|
||||
attributeValItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
|
||||
mTableWidget->setItem( i + 1, j, attributeValItem );
|
||||
QgsEditorWidgetWrapper *eww = QgsEditorWidgetRegistry::instance()->create( mVectorLayer, idx, nullptr, mTableWidget, context );
|
||||
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( mVectorLayer, idx, nullptr, mTableWidget, context );
|
||||
if ( eww )
|
||||
{
|
||||
eww->setValue( attrs.at( idx ) );
|
||||
|
@ -226,6 +226,7 @@ SET(QGIS_GUI_SRCS
|
||||
qgsgradientcolorrampdialog.cpp
|
||||
qgsgradientstopeditor.cpp
|
||||
qgsgroupwmsdatadialog.cpp
|
||||
qgsgui.cpp
|
||||
qgshighlight.cpp
|
||||
qgshistogramwidget.cpp
|
||||
qgshelp.cpp
|
||||
@ -621,6 +622,7 @@ SET(QGIS_GUI_HDRS
|
||||
qgsdetaileditemdata.h
|
||||
qgsexpressionbuilderdialog.h
|
||||
qgsfiledropedit.h
|
||||
qgsgui.h
|
||||
qgshelp.h
|
||||
qgshighlight.h
|
||||
qgsmapcanvasitem.h
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "qgslogger.h"
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsactionmanager.h"
|
||||
|
||||
#include "qgsgui.h"
|
||||
|
||||
QgsVectorLayer *QgsAttributeTableDelegate::layer( const QAbstractItemModel *model )
|
||||
{
|
||||
@ -67,7 +67,7 @@ QWidget *QgsAttributeTableDelegate::createEditor( QWidget *parent, const QStyleO
|
||||
int fieldIdx = index.model()->data( index, QgsAttributeTableModel::FieldIndexRole ).toInt();
|
||||
|
||||
QgsAttributeEditorContext context( masterModel( index.model() )->editorContext(), QgsAttributeEditorContext::Popup );
|
||||
QgsEditorWidgetWrapper *eww = QgsEditorWidgetRegistry::instance()->create( vl, fieldIdx, nullptr, parent, context );
|
||||
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( vl, fieldIdx, nullptr, parent, context );
|
||||
QWidget *w = eww->widget();
|
||||
|
||||
w->setAutoFillBackground( true );
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgssymbollayerutils.h"
|
||||
#include "qgsfieldformatterregistry.h"
|
||||
|
||||
#include "qgsgui.h"
|
||||
#include <QVariant>
|
||||
|
||||
#include <limits>
|
||||
@ -351,8 +351,8 @@ void QgsAttributeTableModel::loadAttributes()
|
||||
|
||||
for ( int idx = 0; idx < fields.count(); ++idx )
|
||||
{
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( layer(), fields[idx].name() );
|
||||
QgsEditorWidgetFactory *widgetFactory = QgsEditorWidgetRegistry::instance()->factory( setup.type() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( layer(), fields[idx].name() );
|
||||
QgsEditorWidgetFactory *widgetFactory = QgsGui::editorWidgetRegistry()->factory( setup.type() );
|
||||
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
||||
|
||||
if ( widgetFactory )
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsscrollarea.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDialog>
|
||||
@ -148,7 +149,7 @@ void QgsDualView::columnBoxInit()
|
||||
if ( fieldIndex == -1 )
|
||||
continue;
|
||||
|
||||
if ( QgsEditorWidgetRegistry::instance()->findBest( mLayer, field.name() ).type() != QLatin1String( "Hidden" ) )
|
||||
if ( QgsGui::editorWidgetRegistry()->findBest( mLayer, field.name() ).type() != QLatin1String( "Hidden" ) )
|
||||
{
|
||||
QIcon icon = mLayer->fields().iconForField( fieldIndex );
|
||||
QString text = field.name();
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "qgseditorwidgetautoconf.h"
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
/** \ingroup gui
|
||||
* Widget auto conf plugin that guesses what widget type to use in function of what the widgets support.
|
||||
@ -29,7 +30,7 @@ class FromFactoriesPlugin: public QgsEditorWidgetAutoConfPlugin
|
||||
{
|
||||
int bestScore = 0;
|
||||
QString bestType;
|
||||
const QMap<QString, QgsEditorWidgetFactory *> factories = QgsEditorWidgetRegistry::instance()->factories();
|
||||
const QMap<QString, QgsEditorWidgetFactory *> factories = QgsGui::editorWidgetRegistry()->factories();
|
||||
for ( QMap<QString, QgsEditorWidgetFactory *>::const_iterator i = factories.begin(); i != factories.end(); ++i )
|
||||
{
|
||||
const int index = vl->fields().lookupField( fieldName );
|
||||
|
@ -40,32 +40,24 @@
|
||||
#include "qgsvaluemapwidgetfactory.h"
|
||||
#include "qgsvaluerelationwidgetfactory.h"
|
||||
|
||||
|
||||
QgsEditorWidgetRegistry *QgsEditorWidgetRegistry::instance()
|
||||
{
|
||||
static QgsEditorWidgetRegistry sInstance;
|
||||
return &sInstance;
|
||||
}
|
||||
|
||||
void QgsEditorWidgetRegistry::initEditors( QgsMapCanvas *mapCanvas, QgsMessageBar *messageBar )
|
||||
{
|
||||
QgsEditorWidgetRegistry *reg = instance();
|
||||
reg->registerWidget( QStringLiteral( "TextEdit" ), new QgsTextEditWidgetFactory( tr( "Text Edit" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "Classification" ), new QgsClassificationWidgetWrapperFactory( tr( "Classification" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "Range" ), new QgsRangeWidgetFactory( tr( "Range" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "UniqueValues" ), new QgsUniqueValueWidgetFactory( tr( "Unique Values" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "ValueMap" ), new QgsValueMapWidgetFactory( tr( "Value Map" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "Enumeration" ), new QgsEnumerationWidgetFactory( tr( "Enumeration" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "Hidden" ), new QgsHiddenWidgetFactory( tr( "Hidden" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "CheckBox" ), new QgsCheckboxWidgetFactory( tr( "Check Box" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "ValueRelation" ), new QgsValueRelationWidgetFactory( tr( "Value Relation" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "UuidGenerator" ), new QgsUuidWidgetFactory( tr( "Uuid Generator" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "Color" ), new QgsColorWidgetFactory( tr( "Color" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "RelationReference" ), new QgsRelationReferenceFactory( tr( "Relation Reference" ), mapCanvas, messageBar ) );
|
||||
reg->registerWidget( QStringLiteral( "DateTime" ), new QgsDateTimeEditFactory( tr( "Date/Time" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "ExternalResource" ), new QgsExternalResourceWidgetFactory( tr( "Attachment" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "KeyValue" ), new QgsKeyValueWidgetFactory( tr( "Key/Value" ) ) );
|
||||
reg->registerWidget( QStringLiteral( "List" ), new QgsListWidgetFactory( tr( "List" ) ) );
|
||||
registerWidget( QStringLiteral( "TextEdit" ), new QgsTextEditWidgetFactory( tr( "Text Edit" ) ) );
|
||||
registerWidget( QStringLiteral( "Classification" ), new QgsClassificationWidgetWrapperFactory( tr( "Classification" ) ) );
|
||||
registerWidget( QStringLiteral( "Range" ), new QgsRangeWidgetFactory( tr( "Range" ) ) );
|
||||
registerWidget( QStringLiteral( "UniqueValues" ), new QgsUniqueValueWidgetFactory( tr( "Unique Values" ) ) );
|
||||
registerWidget( QStringLiteral( "ValueMap" ), new QgsValueMapWidgetFactory( tr( "Value Map" ) ) );
|
||||
registerWidget( QStringLiteral( "Enumeration" ), new QgsEnumerationWidgetFactory( tr( "Enumeration" ) ) );
|
||||
registerWidget( QStringLiteral( "Hidden" ), new QgsHiddenWidgetFactory( tr( "Hidden" ) ) );
|
||||
registerWidget( QStringLiteral( "CheckBox" ), new QgsCheckboxWidgetFactory( tr( "Check Box" ) ) );
|
||||
registerWidget( QStringLiteral( "ValueRelation" ), new QgsValueRelationWidgetFactory( tr( "Value Relation" ) ) );
|
||||
registerWidget( QStringLiteral( "UuidGenerator" ), new QgsUuidWidgetFactory( tr( "Uuid Generator" ) ) );
|
||||
registerWidget( QStringLiteral( "Color" ), new QgsColorWidgetFactory( tr( "Color" ) ) );
|
||||
registerWidget( QStringLiteral( "RelationReference" ), new QgsRelationReferenceFactory( tr( "Relation Reference" ), mapCanvas, messageBar ) );
|
||||
registerWidget( QStringLiteral( "DateTime" ), new QgsDateTimeEditFactory( tr( "Date/Time" ) ) );
|
||||
registerWidget( QStringLiteral( "ExternalResource" ), new QgsExternalResourceWidgetFactory( tr( "Attachment" ) ) );
|
||||
registerWidget( QStringLiteral( "KeyValue" ), new QgsKeyValueWidgetFactory( tr( "Key/Value" ) ) );
|
||||
registerWidget( QStringLiteral( "List" ), new QgsListWidgetFactory( tr( "List" ) ) );
|
||||
}
|
||||
|
||||
QgsEditorWidgetRegistry::QgsEditorWidgetRegistry()
|
||||
|
@ -36,7 +36,10 @@ class QgsVectorLayer;
|
||||
|
||||
|
||||
/** \ingroup gui
|
||||
* This class manages all known edit widget factories
|
||||
* This class manages all known edit widget factories.
|
||||
*
|
||||
* QgsEditorWidgetRegistry is not usually directly created, but rather accessed through
|
||||
* QgsGui::editorWidgetRegistry().
|
||||
*/
|
||||
class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
|
||||
{
|
||||
@ -45,12 +48,10 @@ class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
|
||||
public:
|
||||
|
||||
/**
|
||||
* This class is a singleton and has therefore to be accessed with this method instead
|
||||
* of a constructor.
|
||||
*
|
||||
* \returns The one and only instance of the editor widget registry
|
||||
* Constructor for QgsEditorWidgetRegistry. QgsEditorWidgetRegistry is not usually directly created, but rather accessed through
|
||||
* QgsGui::editorWidgetRegistry().
|
||||
*/
|
||||
static QgsEditorWidgetRegistry *instance();
|
||||
QgsEditorWidgetRegistry();
|
||||
|
||||
/**
|
||||
* Registers all the default widgets.
|
||||
@ -62,7 +63,7 @@ class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
|
||||
* \since QGIS 2.8
|
||||
* \note Not required for plugins, the QGIS application does that already
|
||||
*/
|
||||
static void initEditors( QgsMapCanvas *mapCanvas = nullptr, QgsMessageBar *messageBar = nullptr );
|
||||
void initEditors( QgsMapCanvas *mapCanvas = nullptr, QgsMessageBar *messageBar = nullptr );
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -180,9 +181,6 @@ class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
|
||||
*/
|
||||
void registerAutoConfPlugin( QgsEditorWidgetAutoConfPlugin *plugin ) { mAutoConf.registerPlugin( plugin ); }
|
||||
|
||||
protected:
|
||||
QgsEditorWidgetRegistry();
|
||||
|
||||
private:
|
||||
QString findSuitableWrapper( QWidget *editor, const QString &defaultWidget );
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "qgstabwidget.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsscrollarea.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
@ -1233,7 +1234,7 @@ void QgsAttributeForm::init()
|
||||
//show attribute alias if available
|
||||
QString fieldName = mLayer->attributeDisplayName( idx );
|
||||
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, field.name() );
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, field.name() );
|
||||
|
||||
if ( widgetSetup.type() == QLatin1String( "Hidden" ) )
|
||||
continue;
|
||||
@ -1242,7 +1243,7 @@ void QgsAttributeForm::init()
|
||||
|
||||
// This will also create the widget
|
||||
QLabel *l = new QLabel( fieldName );
|
||||
QgsEditorWidgetWrapper *eww = QgsEditorWidgetRegistry::instance()->create( widgetSetup.type(), mLayer, idx, widgetSetup.config(), nullptr, this, mContext );
|
||||
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( widgetSetup.type(), mLayer, idx, widgetSetup.config(), nullptr, this, mContext );
|
||||
|
||||
QWidget *w = nullptr;
|
||||
if ( eww )
|
||||
@ -1281,7 +1282,7 @@ void QgsAttributeForm::init()
|
||||
Q_FOREACH ( const QgsRelation &rel, QgsProject::instance()->relationManager()->referencedRelations( mLayer ) )
|
||||
{
|
||||
QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper( mLayer, rel, nullptr, this );
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, rel.id() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( mLayer, rel.id() );
|
||||
rww->setConfig( setup.config() );
|
||||
rww->setContext( mContext );
|
||||
gridLayout->addWidget( rww->widget(), row++, 0, 1, 2 );
|
||||
@ -1534,9 +1535,9 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
|
||||
int fldIdx = vl->fields().lookupField( fieldDef->name() );
|
||||
if ( fldIdx < vl->fields().count() && fldIdx >= 0 )
|
||||
{
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, fieldDef->name() );
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, fieldDef->name() );
|
||||
|
||||
QgsEditorWidgetWrapper *eww = QgsEditorWidgetRegistry::instance()->create( widgetSetup.type(), mLayer, fldIdx, widgetSetup.config(), nullptr, this, mContext );
|
||||
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( widgetSetup.type(), mLayer, fldIdx, widgetSetup.config(), nullptr, this, mContext );
|
||||
QgsAttributeFormEditorWidget *w = new QgsAttributeFormEditorWidget( eww, this );
|
||||
mFormEditorWidgets.insert( fldIdx, w );
|
||||
|
||||
@ -1560,7 +1561,7 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
|
||||
const QgsAttributeEditorRelation *relDef = static_cast<const QgsAttributeEditorRelation *>( widgetDef );
|
||||
|
||||
QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper( mLayer, relDef->relation(), nullptr, this );
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, relDef->relation().id() );
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relDef->relation().id() );
|
||||
rww->setConfig( widgetSetup.config() );
|
||||
rww->setContext( context );
|
||||
newWidgetInfo.widget = rww->widget();
|
||||
@ -1723,7 +1724,7 @@ void QgsAttributeForm::createWrappers()
|
||||
if ( relation.isValid() )
|
||||
{
|
||||
QgsRelationWidgetWrapper *rww = new QgsRelationWidgetWrapper( mLayer, relation, myWidget, this );
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsEditorWidgetRegistry::instance()->findBest( mLayer, relation.id() );
|
||||
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, relation.id() );
|
||||
rww->setConfig( widgetSetup.config() );
|
||||
rww->setContext( mContext );
|
||||
rww->widget(); // Will initialize the widget
|
||||
@ -1738,7 +1739,7 @@ void QgsAttributeForm::createWrappers()
|
||||
{
|
||||
int idx = mLayer->fields().lookupField( field.name() );
|
||||
|
||||
QgsEditorWidgetWrapper *eww = QgsEditorWidgetRegistry::instance()->create( mLayer, idx, myWidget, this, mContext );
|
||||
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( mLayer, idx, myWidget, this, mContext );
|
||||
addWidgetWrapper( eww );
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "qgssearchwidgetwrapper.h"
|
||||
#include "qgsattributeeditorcontext.h"
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgsgui.h"
|
||||
#include <QLayout>
|
||||
#include <QLabel>
|
||||
#include <QStackedWidget>
|
||||
@ -96,14 +97,14 @@ QgsAttributeFormEditorWidget::~QgsAttributeFormEditorWidget()
|
||||
|
||||
void QgsAttributeFormEditorWidget::createSearchWidgetWrappers( const QString &widgetId, int fieldIdx, const QVariantMap &config, const QgsAttributeEditorContext &context )
|
||||
{
|
||||
QgsSearchWidgetWrapper *sww = QgsEditorWidgetRegistry::instance()->createSearchWidget( widgetId, layer(), fieldIdx, config,
|
||||
QgsSearchWidgetWrapper *sww = QgsGui::editorWidgetRegistry()->createSearchWidget( widgetId, layer(), fieldIdx, config,
|
||||
mSearchFrame, context );
|
||||
setSearchWidgetWrapper( sww );
|
||||
if ( sww->supportedFlags() & QgsSearchWidgetWrapper::Between ||
|
||||
sww->supportedFlags() & QgsSearchWidgetWrapper::IsNotBetween )
|
||||
{
|
||||
// create secondary widget for between type searches
|
||||
QgsSearchWidgetWrapper *sww2 = QgsEditorWidgetRegistry::instance()->createSearchWidget( widgetId, layer(), fieldIdx, config,
|
||||
QgsSearchWidgetWrapper *sww2 = QgsGui::editorWidgetRegistry()->createSearchWidget( widgetId, layer(), fieldIdx, config,
|
||||
mSearchFrame, context );
|
||||
mSearchWidgets << sww2;
|
||||
mSearchFrame->layout()->addWidget( sww2->widget() );
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "qgsproject.h"
|
||||
#include "qgsmaptool.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsgui.h"
|
||||
#include <QDomElement>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@ -94,7 +95,7 @@ QWidget *QgsFormAnnotation::createDesignerWidget( const QString &filePath )
|
||||
QWidget *attWidget = widget->findChild<QWidget *>( fields.at( i ).name() );
|
||||
if ( attWidget )
|
||||
{
|
||||
QgsEditorWidgetWrapper *eww = QgsEditorWidgetRegistry::instance()->create( vectorLayer, i, attWidget, widget, context );
|
||||
QgsEditorWidgetWrapper *eww = QgsGui::editorWidgetRegistry()->create( vectorLayer, i, attWidget, widget, context );
|
||||
if ( eww )
|
||||
{
|
||||
eww->setValue( attrs.at( i ) );
|
||||
|
40
src/gui/qgsgui.cpp
Normal file
40
src/gui/qgsgui.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/***************************************************************************
|
||||
qgsgui.cpp
|
||||
----------
|
||||
begin : May 2017
|
||||
copyright : (C) 2017 by Nyall Dawson
|
||||
email : nyall dot dawson at gmail dot com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 "qgsgui.h"
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
|
||||
QgsGui *QgsGui::instance()
|
||||
{
|
||||
static QgsGui *sInstance( new QgsGui() );
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
QgsEditorWidgetRegistry *QgsGui::editorWidgetRegistry()
|
||||
{
|
||||
return instance()->mEditorWidgetRegistry;
|
||||
}
|
||||
|
||||
QgsGui::~QgsGui()
|
||||
{
|
||||
delete mEditorWidgetRegistry;
|
||||
}
|
||||
|
||||
QgsGui::QgsGui()
|
||||
{
|
||||
mEditorWidgetRegistry = new QgsEditorWidgetRegistry();
|
||||
}
|
66
src/gui/qgsgui.h
Normal file
66
src/gui/qgsgui.h
Normal file
@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
qgsgui.h
|
||||
--------
|
||||
begin : May 2017
|
||||
copyright : (C) 2017 by Nyall Dawson
|
||||
email : nyall dot dawson at gmail dot com
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* 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 QGSGUI_H
|
||||
#define QGSGUI_H
|
||||
|
||||
#include "qgis_gui.h"
|
||||
|
||||
class QgsEditorWidgetRegistry;
|
||||
|
||||
/**
|
||||
* \ingroup gui
|
||||
* QgsGui is a singleton class containing various registry and other global members
|
||||
* related to GUI classes.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
class GUI_EXPORT QgsGui
|
||||
{
|
||||
public:
|
||||
|
||||
//! QgsGui cannot be copied
|
||||
QgsGui( const QgsGui &other ) = delete;
|
||||
|
||||
//! QgsGui cannot be copied
|
||||
QgsGui &operator=( const QgsGui &other ) = delete;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the singleton instance.
|
||||
*/
|
||||
static QgsGui *instance();
|
||||
|
||||
/**
|
||||
* Returns the global editor widget registry, used for managing all known edit widget factories.
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
static QgsEditorWidgetRegistry *editorWidgetRegistry();
|
||||
|
||||
~QgsGui();
|
||||
|
||||
private:
|
||||
|
||||
QgsGui();
|
||||
|
||||
QgsEditorWidgetRegistry *mEditorWidgetRegistry = nullptr;
|
||||
|
||||
#ifdef SIP_RUN
|
||||
QgsGui( const QgsGui &other );
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // QGSGUI_H
|
@ -40,6 +40,7 @@
|
||||
#include "qgsfilterresponsedecorator.h"
|
||||
#include "qgsservice.h"
|
||||
#include "qgsserverprojectutils.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QNetworkDiskCache>
|
||||
@ -271,7 +272,7 @@ bool QgsServer::init( )
|
||||
QgsFontUtils::loadStandardTestFonts( QStringList() << QStringLiteral( "Roman" ) << QStringLiteral( "Bold" ) );
|
||||
#endif
|
||||
|
||||
QgsEditorWidgetRegistry::initEditors();
|
||||
QgsGui::editorWidgetRegistry()->initEditors();
|
||||
|
||||
sServerInterface = new QgsServerInterfaceImpl( sCapabilitiesCache, &sServiceRegistry, &sSettings );
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "qgslayertreegroup.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgseditorwidgetsetup.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QFileInfo>
|
||||
@ -272,7 +273,7 @@ QgsMapLayer *QgsServerProjectParser::createLayerFromElement( const QDomElement &
|
||||
if ( layer->type() == QgsMapLayer::VectorLayer )
|
||||
{
|
||||
// see QgsEditorWidgetRegistry::mapLayerAdded()
|
||||
QObject::connect( layer, SIGNAL( readCustomSymbology( const QDomElement &, QString & ) ), QgsEditorWidgetRegistry::instance(), SLOT( readSymbology( const QDomElement &, QString & ) ) );
|
||||
QObject::connect( layer, SIGNAL( readCustomSymbology( const QDomElement &, QString & ) ), QgsGui::editorWidgetRegistry(), SLOT( readSymbology( const QDomElement &, QString & ) ) );
|
||||
}
|
||||
|
||||
QgsReadWriteContext context;
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "qgsmaprendererjobproxy.h"
|
||||
#include "qgswmsserviceexception.h"
|
||||
#include "qgsserverprojectutils.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
@ -2532,7 +2533,7 @@ namespace QgsWms
|
||||
QString QgsRenderer::replaceValueMapAndRelation( QgsVectorLayer *vl, int idx, const QString &attributeVal )
|
||||
{
|
||||
// TODO Could we get rid of QgsEditorWidgetRegistry dependency ?
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( vl, vl->fields().field( idx ).name() );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( vl, vl->fields().field( idx ).name() );
|
||||
QgsFieldFormatter *fieldFormatter = QgsApplication::fieldFormatterRegistry()->fieldFormatter( setup.type() );
|
||||
QString value( fieldFormatter->representValue( vl, idx, setup.config(), QVariant(), attributeVal ) );
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "qgseditorwidgetregistry.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsmapcanvas.h"
|
||||
#include "qgsgui.h"
|
||||
|
||||
/** \ingroup UnitTests
|
||||
* This is a unit test for the save as dialog
|
||||
@ -59,7 +60,7 @@ void TestQgsVectorLayerSaveAsDialog::initTestCase()
|
||||
QgsApplication::init();
|
||||
QgsApplication::initQgis();
|
||||
mQgisApp = new QgisApp();
|
||||
QgsEditorWidgetRegistry::initEditors();
|
||||
QgsGui::editorWidgetRegistry()->initEditors();
|
||||
}
|
||||
|
||||
//runs after all tests
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <qgsvectorlayer.h>
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include <qgsfeature.h>
|
||||
#include "qgsgui.h"
|
||||
|
||||
class TestQgsAttributeForm : public QObject
|
||||
{
|
||||
@ -46,7 +47,7 @@ void TestQgsAttributeForm::initTestCase()
|
||||
{
|
||||
QgsApplication::init();
|
||||
QgsApplication::initQgis();
|
||||
QgsEditorWidgetRegistry::initEditors();
|
||||
QgsGui::editorWidgetRegistry()->initEditors();
|
||||
}
|
||||
|
||||
void TestQgsAttributeForm::cleanupTestCase()
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "qgsvectordataprovider.h"
|
||||
#include <qgsmapcanvas.h>
|
||||
#include <qgsfeature.h>
|
||||
#include "qgsgui.h"
|
||||
|
||||
#include "qgstest.h"
|
||||
|
||||
@ -72,7 +73,7 @@ void TestQgsDualView::initTestCase()
|
||||
QgsApplication::initQgis();
|
||||
QgsApplication::showSettings();
|
||||
|
||||
QgsEditorWidgetRegistry::initEditors();
|
||||
QgsGui::editorWidgetRegistry()->initEditors();
|
||||
|
||||
// Setup a map canvas with a vector layer loaded...
|
||||
QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "qgseditorwidgetautoconf.h"
|
||||
#include "qgsproject.h"
|
||||
#include "qgsrelationmanager.h"
|
||||
|
||||
#include "qgsgui.h"
|
||||
|
||||
class TestQgsEditorWidgetRegistry: public QObject
|
||||
{
|
||||
@ -46,8 +46,8 @@ class TestQgsEditorWidgetRegistry: public QObject
|
||||
{
|
||||
QgsApplication::init();
|
||||
QgsApplication::initQgis();
|
||||
QgsEditorWidgetRegistry::initEditors();
|
||||
QgsEditorWidgetRegistry::instance()->registerAutoConfPlugin( new DummyPlugin() );
|
||||
QgsGui::editorWidgetRegistry()->initEditors();
|
||||
QgsGui::editorWidgetRegistry()->registerAutoConfPlugin( new DummyPlugin() );
|
||||
}
|
||||
|
||||
void cleanupTestCase()
|
||||
@ -97,7 +97,7 @@ class TestQgsEditorWidgetRegistry: public QObject
|
||||
|
||||
vl.setEditorWidgetSetup( 1, QgsEditorWidgetSetup( QStringLiteral( "FooEdit" ), config ) );
|
||||
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( &vl, QStringLiteral( "col1" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( &vl, QStringLiteral( "col1" ) );
|
||||
QCOMPARE( setup.type(), QString( "FooEdit" ) );
|
||||
QCOMPARE( setup.config(), config );
|
||||
}
|
||||
@ -105,7 +105,7 @@ class TestQgsEditorWidgetRegistry: public QObject
|
||||
void wrongFieldName()
|
||||
{
|
||||
const QgsVectorLayer vl( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=col1:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( &vl, QStringLiteral( "col2" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( &vl, QStringLiteral( "col2" ) );
|
||||
// an unknown fields leads to a default setup with a TextEdit
|
||||
QCOMPARE( setup.type(), QString( "TextEdit" ) );
|
||||
QCOMPARE( setup.config().count(), 0 );
|
||||
@ -130,7 +130,7 @@ class TestQgsEditorWidgetRegistry: public QObject
|
||||
QgsProject::instance()->relationManager()->addRelation( relation );
|
||||
|
||||
//check the guessed editor widget type for vl1.fk is RelationReference
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( &vl1, QStringLiteral( "fk" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( &vl1, QStringLiteral( "fk" ) );
|
||||
QCOMPARE( setup.type(), QString( "RelationReference" ) );
|
||||
QCOMPARE( setup.config(), QVariantMap() );
|
||||
}
|
||||
@ -138,7 +138,7 @@ class TestQgsEditorWidgetRegistry: public QObject
|
||||
void typeFromPlugin()
|
||||
{
|
||||
const QgsVectorLayer vl( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=special:string" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( &vl, QStringLiteral( "special" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( &vl, QStringLiteral( "special" ) );
|
||||
QCOMPARE( setup.type(), QString( "Special" ) );
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ class TestQgsEditorWidgetRegistry: public QObject
|
||||
static void checkSimple( const QString &dataType, const QString &widgetType )
|
||||
{
|
||||
const QgsVectorLayer vl( "LineString?crs=epsg:3111&field=pk:int&field=col1:" + dataType, QStringLiteral( "vl" ), QStringLiteral( "memory" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsEditorWidgetRegistry::instance()->findBest( &vl, QStringLiteral( "col1" ) );
|
||||
const QgsEditorWidgetSetup setup = QgsGui::editorWidgetRegistry()->findBest( &vl, QStringLiteral( "col1" ) );
|
||||
QCOMPARE( setup.type(), widgetType );
|
||||
QCOMPARE( setup.config().count(), 0 );
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ from qgis.core import (
|
||||
QgsSettings,
|
||||
QgsTransactionGroup
|
||||
)
|
||||
from qgis.gui import QgsEditorWidgetRegistry
|
||||
from qgis.gui import QgsGui
|
||||
from qgis.PyQt.QtCore import QDate, QTime, QDateTime, QVariant, QDir
|
||||
from qgis.testing import start_app, unittest
|
||||
from utilities import unitTestDataPath
|
||||
@ -55,7 +55,7 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
|
||||
cls.poly_vl = QgsVectorLayer(cls.dbconn + ' sslmode=disable key=\'pk\' srid=4326 type=POLYGON table="qgis_test"."some_poly_data" (geom) sql=', 'test', 'postgres')
|
||||
assert cls.poly_vl.isValid()
|
||||
cls.poly_provider = cls.poly_vl.dataProvider()
|
||||
QgsEditorWidgetRegistry.instance().initEditors()
|
||||
QgsGui.editorWidgetRegistry().initEditors()
|
||||
cls.con = psycopg2.connect(cls.dbconn)
|
||||
|
||||
@classmethod
|
||||
@ -379,13 +379,13 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
|
||||
self.assertEqual(setup1.type(), "FooEdit")
|
||||
self.assertEqual(setup1.config(), {"param1": "value1", "param2": "2"})
|
||||
|
||||
best1 = QgsEditorWidgetRegistry.instance().findBest(vl, "fld1")
|
||||
best1 = QgsGui.editorWidgetRegistry().findBest(vl, "fld1")
|
||||
self.assertEqual(best1.type(), "FooEdit")
|
||||
self.assertEqual(best1.config(), setup1.config())
|
||||
|
||||
self.assertTrue(fields.field("fld2").editorWidgetSetup().isNull())
|
||||
|
||||
best2 = QgsEditorWidgetRegistry.instance().findBest(vl, "fld2")
|
||||
best2 = QgsGui.editorWidgetRegistry().findBest(vl, "fld2")
|
||||
self.assertEqual(best2.type(), "TextEdit")
|
||||
|
||||
def testHstore(self):
|
||||
|
@ -18,7 +18,7 @@ from qgis.gui import (QgsSearchWidgetWrapper,
|
||||
QgsAttributeFormEditorWidget,
|
||||
QgsDefaultSearchWidgetWrapper,
|
||||
QgsAttributeForm,
|
||||
QgsEditorWidgetRegistry
|
||||
QgsGui
|
||||
)
|
||||
from qgis.core import (QgsVectorLayer)
|
||||
from qgis.PyQt.QtWidgets import QWidget, QDateTimeEdit
|
||||
@ -26,7 +26,7 @@ from qgis.PyQt.QtCore import QDateTime, QDate, QTime
|
||||
from qgis.testing import start_app, unittest
|
||||
|
||||
start_app()
|
||||
QgsEditorWidgetRegistry.instance().initEditors()
|
||||
QgsGui.editorWidgetRegistry().initEditors()
|
||||
|
||||
|
||||
class PyQgsAttributeFormEditorWidget(unittest.TestCase):
|
||||
|
@ -14,7 +14,7 @@ __revision__ = '$Format:%H$'
|
||||
|
||||
from qgis.gui import (
|
||||
QgsAttributeTableModel,
|
||||
QgsEditorWidgetRegistry
|
||||
QgsGui
|
||||
)
|
||||
from qgis.core import (
|
||||
QgsFeature,
|
||||
@ -35,7 +35,7 @@ class TestQgsAttributeTableModel(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
QgsEditorWidgetRegistry.initEditors()
|
||||
QgsGui.editorWidgetRegistry().initEditors()
|
||||
|
||||
def setUp(self):
|
||||
self.layer = self.createLayer()
|
||||
|
@ -15,7 +15,7 @@ __revision__ = '$Format:%H$'
|
||||
import qgis # NOQA
|
||||
|
||||
from qgis.core import (QgsProject, QgsFeature, QgsGeometry, QgsPoint, QgsVectorLayer, NULL, QgsField)
|
||||
from qgis.gui import QgsEditorWidgetRegistry
|
||||
from qgis.gui import QgsGui
|
||||
|
||||
from qgis.testing import start_app, unittest
|
||||
from qgis.PyQt.QtCore import QVariant
|
||||
@ -30,7 +30,7 @@ class TestQgsTextEditWidget(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
QgsEditorWidgetRegistry.initEditors()
|
||||
QgsGui.editorWidgetRegistry().initEditors()
|
||||
|
||||
def createLayerWithOnePoint(self):
|
||||
self.layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer",
|
||||
@ -44,7 +44,7 @@ class TestQgsTextEditWidget(unittest.TestCase):
|
||||
return self.layer
|
||||
|
||||
def doAttributeTest(self, idx, expected):
|
||||
reg = QgsEditorWidgetRegistry.instance()
|
||||
reg = QgsGui.editorWidgetRegistry()
|
||||
configWdg = reg.createConfigWidget('TextEdit', self.layer, idx, None)
|
||||
config = configWdg.config()
|
||||
editwidget = reg.create('TextEdit', self.layer, idx, config, None, None)
|
||||
@ -76,7 +76,7 @@ class TestQgsTextEditWidget(unittest.TestCase):
|
||||
layer.updateFields()
|
||||
QgsProject.instance().addMapLayer(layer)
|
||||
|
||||
reg = QgsEditorWidgetRegistry.instance()
|
||||
reg = QgsGui.editorWidgetRegistry()
|
||||
config = {'IsMultiline': 'True'}
|
||||
|
||||
# first test for field without character limit
|
||||
@ -98,7 +98,7 @@ class TestQgsTextEditWidget(unittest.TestCase):
|
||||
layer = QgsVectorLayer("none?field=number:integer", "layer", "memory")
|
||||
assert layer.isValid()
|
||||
QgsProject.instance().addMapLayer(layer)
|
||||
reg = QgsEditorWidgetRegistry.instance()
|
||||
reg = QgsGui.editorWidgetRegistry()
|
||||
configWdg = reg.createConfigWidget('ValueMap', layer, 0, None)
|
||||
|
||||
config = {'map': {'two': '2', 'twoandhalf': '2.5', 'NULL text': 'NULL',
|
||||
|
@ -15,7 +15,7 @@ __revision__ = '$Format:%H$'
|
||||
import qgis # NOQA
|
||||
|
||||
from qgis.core import QgsFeature, QgsGeometry, QgsPoint, QgsVectorLayer, NULL
|
||||
from qgis.gui import QgsEditorWidgetRegistry
|
||||
from qgis.gui import QgsGui
|
||||
from qgis.testing import start_app, unittest
|
||||
|
||||
start_app()
|
||||
@ -25,7 +25,7 @@ class TestQgsRangeWidget(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
QgsEditorWidgetRegistry.initEditors()
|
||||
QgsGui.editorWidgetRegistry().initEditors()
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
@ -42,7 +42,7 @@ class TestQgsRangeWidget(unittest.TestCase):
|
||||
"""
|
||||
create a range widget
|
||||
"""
|
||||
reg = QgsEditorWidgetRegistry.instance()
|
||||
reg = QgsGui.editorWidgetRegistry()
|
||||
configWdg = reg.createConfigWidget('Range', self.layer, 1, None)
|
||||
config = configWdg.config()
|
||||
|
||||
|
@ -27,7 +27,7 @@ from qgis.core import (
|
||||
)
|
||||
|
||||
from qgis.gui import (
|
||||
QgsEditorWidgetRegistry,
|
||||
QgsGui,
|
||||
QgsRelationWidgetWrapper,
|
||||
QgsAttributeEditorContext
|
||||
)
|
||||
@ -47,7 +47,7 @@ class TestQgsRelationEditWidget(unittest.TestCase):
|
||||
Setup the involved layers and relations for a n:m relation
|
||||
:return:
|
||||
"""
|
||||
QgsEditorWidgetRegistry.initEditors()
|
||||
QgsGui.editorWidgetRegistry().initEditors()
|
||||
cls.dbconn = 'service=\'qgis_test\''
|
||||
if 'QGIS_PGTEST_DB' in os.environ:
|
||||
cls.dbconn = os.environ['QGIS_PGTEST_DB']
|
||||
|
Loading…
x
Reference in New Issue
Block a user