QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
editorwidgets
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
16
#include "
qgsjsoneditwidgetfactory.h
"
17
18
#include "
qgsjsoneditconfigdlg.h
"
19
#include "
qgsjsoneditwrapper.h
"
20
21
#include <QString>
22
23
using namespace
Qt::StringLiterals;
24
25
QgsJsonEditWidgetFactory::QgsJsonEditWidgetFactory
(
const
QString &
name
,
const
QIcon &
icon
)
26
:
QgsEditorWidgetFactory
(
name
,
icon
)
27
{}
28
29
QgsEditorWidgetWrapper
*
QgsJsonEditWidgetFactory::create
(
QgsVectorLayer
*vl,
int
fieldIdx, QWidget *editor, QWidget *parent )
const
30
{
31
return
new
QgsJsonEditWrapper
( vl, fieldIdx, editor, parent );
32
}
33
34
QgsEditorConfigWidget
*
QgsJsonEditWidgetFactory::configWidget
(
QgsVectorLayer
*vl,
int
fieldIdx, QWidget *parent )
const
35
{
36
return
new
QgsJsonEditConfigDlg
( vl, fieldIdx, parent );
37
}
38
39
unsigned
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
50
bool
QgsJsonEditWidgetFactory::isReadOnly
()
const
51
{
52
return
true
;
53
}
QgsEditorConfigWidget
Base class for widgets which configure editor widget types.
Definition
qgseditorconfigwidget.h:41
QgsEditorWidgetFactory::QgsEditorWidgetFactory
QgsEditorWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor.
Definition
qgseditorwidgetfactory.cpp:27
QgsEditorWidgetFactory::icon
QIcon icon() const
Returns the icon of this widget type.
Definition
qgseditorwidgetfactory.cpp:46
QgsEditorWidgetFactory::name
QString name() const
Returns the human readable identifier name of this widget type.
Definition
qgseditorwidgetfactory.cpp:41
QgsEditorWidgetWrapper
Manages an editor widget.
Definition
qgseditorwidgetwrapper.h:50
QgsField
Encapsulate a field in an attribute table or data source.
Definition
qgsfield.h:56
QgsField::typeName
QString typeName() const
Gets the field type.
Definition
qgsfield.cpp:158
QgsFields::field
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
Definition
qgsfields.cpp:214
QgsJsonEditConfigDlg
A configuration widget for JSON edit widget.
Definition
qgsjsoneditconfigdlg.h:34
QgsJsonEditWidgetFactory::QgsJsonEditWidgetFactory
QgsJsonEditWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor for QgsJsonEditWidgetFactory, where name is a human-readable name for the factory and ico...
Definition
qgsjsoneditwidgetfactory.cpp:25
QgsJsonEditWidgetFactory::configWidget
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
Definition
qgsjsoneditwidgetfactory.cpp:34
QgsJsonEditWidgetFactory::fieldScore
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
Definition
qgsjsoneditwidgetfactory.cpp:39
QgsJsonEditWidgetFactory::create
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
Definition
qgsjsoneditwidgetfactory.cpp:29
QgsJsonEditWidgetFactory::isReadOnly
bool isReadOnly() const override
Returns true if this widget is a read-only widget.
Definition
qgsjsoneditwidgetfactory.cpp:50
QgsJsonEditWrapper
Wraps a JSON edit widget.
Definition
qgsjsoneditwrapper.h:40
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
QgsVectorLayer::fields
QgsFields fields
Definition
qgsvectorlayer.h:422
qgsjsoneditconfigdlg.h
qgsjsoneditwidgetfactory.h
qgsjsoneditwrapper.h
Generated on
for QGIS API Documentation by
1.17.0