QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsgeometrywidgetfactory.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeometrywidgetfactory.cpp
3 -----------------------
4 Date : February 2023
5 Copyright : (C) 2023 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgsdummyconfigdlg.h"
20#include "qgsvectorlayer.h"
21
22#include <QString>
23
24using namespace Qt::StringLiterals;
25
28 , mMessageBar( messageBar )
29{
30}
31
32QgsEditorWidgetWrapper *QgsGeometryWidgetFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
33{
34 return new QgsGeometryWidgetWrapper( vl, fieldIdx, editor, parent, mMessageBar );
35}
36
38{
39 return new QgsDummyConfigDlg( vl, fieldIdx, parent, QObject::tr( "A widget for interacting with geometry fields." ) );
40}
41
42unsigned int QgsGeometryWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
43{
44 const QgsField field = vl->fields().field( fieldIdx );
45 const QMetaType::Type type = field.type();
46 // Geometry fields only
47 return ( type == QMetaType::Type::User && field.typeName().compare( "geometry"_L1, Qt::CaseInsensitive ) == 0 ) ? 20 : 0;
48}
Configuration widget for dummy widgets.
Base class for widgets which configure editor widget types.
QgsEditorWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor.
QIcon icon() const
Returns the icon of this widget type.
QString name() const
Returns the human readable identifier name of this widget type.
Manages an editor widget.
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:56
QMetaType::Type type
Definition qgsfield.h:63
QString typeName() const
Gets the field type.
Definition qgsfield.cpp:167
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
QgsGeometryWidgetFactory(const QString &name, QgsMessageBar *messageBar, const QIcon &icon=QIcon())
Constructor for QgsGeometryWidgetFactory, where name is a human-readable name for the factory and ico...
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
Widget wrapper for geometry fields.
A bar for displaying non-blocking messages to the user.
Represents a vector layer which manages a vector based dataset.