QGIS API Documentation 4.3.0-Master (bf28115e945)
Loading...
Searching...
No Matches
qgsjsoneditwidgetfactory.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsjsoneditwidgetfactory.cpp
3 --------------------------------------
4 Date : 3.5.2021
5 Copyright : (C) 2021 Damiano Lombardi
6 Email : damiano at opengis dot ch
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
19#include "qgsjsoneditwrapper.h"
20
21#include <QString>
22
23using namespace Qt::StringLiterals;
24
28
29QgsEditorWidgetWrapper *QgsJsonEditWidgetFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
30{
31 return new QgsJsonEditWrapper( vl, fieldIdx, editor, parent );
32}
33
35{
36 return new QgsJsonEditConfigDlg( vl, fieldIdx, parent );
37}
38
39unsigned int QgsJsonEditWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
40{
41 const QgsField field = vl->fields().field( fieldIdx );
42 // Handle the json field
43 if ( field.typeName().compare( u"json"_s, Qt::CaseInsensitive ) == 0 || field.typeName().compare( u"jsonb"_s, Qt::CaseInsensitive ) == 0 )
44 {
45 return 15;
46 }
47 return 5;
48}
49
51{
52 return true;
53}
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
QString typeName() const
Gets the field type.
Definition qgsfield.cpp:158
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
A configuration widget for JSON edit widget.
QgsJsonEditWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor for QgsJsonEditWidgetFactory, where name is a human-readable name for the factory and ico...
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
bool isReadOnly() const override
Returns true if this widget is a read-only widget.
Wraps a JSON edit widget.
Represents a vector layer which manages a vector based dataset.