QGIS API Documentation
3.14.0-Pi (9f7028fd23)
src
gui
editorwidgets
qgsrelationreferencefactory.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsrelationreferencefactory.cpp
3
--------------------------------------
4
Date : 29.5.2013
5
Copyright : (C) 2013 Matthias Kuhn
6
Email : matthias 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 "
qgsproject.h
"
17
#include "
qgsrelationreferencefactory.h
"
18
19
#include "
qgsfeatureiterator.h
"
20
#include "
qgsrelation.h
"
21
#include "
qgsrelationmanager.h
"
22
#include "
qgsrelationreferencewidgetwrapper.h
"
23
#include "
qgsrelationreferenceconfigdlg.h
"
24
#include "
qgsrelationreferencesearchwidgetwrapper.h
"
25
#include "
qgsrelationreferencewidget.h
"
26
#include "
qgslogger.h
"
27
28
QgsRelationReferenceFactory::QgsRelationReferenceFactory
(
const
QString &name,
QgsMapCanvas
*canvas,
QgsMessageBar
*messageBar )
29
:
QgsEditorWidgetFactory
( name )
30
, mCanvas( canvas )
31
, mMessageBar( messageBar )
32
{
33
}
34
35
QgsEditorWidgetWrapper
*
QgsRelationReferenceFactory::create
(
QgsVectorLayer
*vl,
int
fieldIdx, QWidget *editor, QWidget *parent )
const
36
{
37
return
new
QgsRelationReferenceWidgetWrapper
( vl, fieldIdx, editor, mCanvas, mMessageBar, parent );
38
}
39
40
QgsSearchWidgetWrapper
*
QgsRelationReferenceFactory::createSearchWidget
(
QgsVectorLayer
*vl,
int
fieldIdx, QWidget *parent )
const
41
{
42
return
new
QgsRelationReferenceSearchWidgetWrapper
( vl, fieldIdx, mCanvas, parent );
43
}
44
45
QgsEditorConfigWidget
*
QgsRelationReferenceFactory::configWidget
(
QgsVectorLayer
*vl,
int
fieldIdx, QWidget *parent )
const
46
{
47
return
new
QgsRelationReferenceConfigDlg
( vl, fieldIdx, parent );
48
}
49
50
QHash<const char *, int>
QgsRelationReferenceFactory::supportedWidgetTypes
()
51
{
52
QHash<const char *, int> map = QHash<const char *, int>();
53
map.insert( QgsRelationReferenceWidget::staticMetaObject.className(), 10 );
54
return
map;
55
}
56
57
unsigned
int
QgsRelationReferenceFactory::fieldScore
(
const
QgsVectorLayer
*vl,
int
fieldIdx )
const
58
{
59
const
QList<QgsRelation> relations = vl->
referencingRelations
( fieldIdx );
60
return
!relations.isEmpty() ? 21
/*A bit stronger than the range widget*/
: 5;
61
}
QgsEditorConfigWidget
Definition:
qgseditorconfigwidget.h:38
QgsEditorWidgetFactory
Definition:
qgseditorwidgetfactory.h:42
QgsRelationReferenceSearchWidgetWrapper
Definition:
qgsrelationreferencesearchwidgetwrapper.h:39
QgsRelationReferenceConfigDlg
Definition:
qgsrelationreferenceconfigdlg.h:33
qgsfeatureiterator.h
QgsMapCanvas
Definition:
qgsmapcanvas.h:83
QgsSearchWidgetWrapper
Definition:
qgssearchwidgetwrapper.h:85
QgsRelationReferenceFactory::configWidget
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
Definition:
qgsrelationreferencefactory.cpp:45
QgsRelationReferenceFactory::supportedWidgetTypes
QHash< const char *, int > supportedWidgetTypes() override
Returns a list of widget types which this editor widget supports.
Definition:
qgsrelationreferencefactory.cpp:50
QgsRelationReferenceFactory::QgsRelationReferenceFactory
QgsRelationReferenceFactory(const QString &name, QgsMapCanvas *canvas, QgsMessageBar *messageBar)
Definition:
qgsrelationreferencefactory.cpp:28
QgsEditorWidgetWrapper
Definition:
qgseditorwidgetwrapper.h:47
qgsrelationreferencefactory.h
QgsRelationReferenceFactory::create
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
Definition:
qgsrelationreferencefactory.cpp:35
QgsMessageBar
Definition:
qgsmessagebar.h:60
QgsVectorLayer::referencingRelations
QList< QgsRelation > referencingRelations(int idx) const
Returns the layer's relations, where the foreign key is on this layer.
Definition:
qgsvectorlayer.cpp:5158
qgsrelation.h
qgsrelationmanager.h
QgsVectorLayer
Definition:
qgsvectorlayer.h:385
qgsrelationreferencewidgetwrapper.h
QgsRelationReferenceFactory::createSearchWidget
QgsSearchWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
By default a simple QgsFilterLineEdit is returned as search widget.
Definition:
qgsrelationreferencefactory.cpp:40
qgslogger.h
qgsrelationreferencewidget.h
qgsrelationreferenceconfigdlg.h
QgsRelationReferenceFactory::fieldScore
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
Definition:
qgsrelationreferencefactory.cpp:57
qgsproject.h
qgsrelationreferencesearchwidgetwrapper.h
QgsRelationReferenceWidgetWrapper
Definition:
qgsrelationreferencewidgetwrapper.h:43
Generated on Mon Jun 22 2020 05:14:09 for QGIS API Documentation by
1.8.17