QGIS API Documentation
3.14.0-Pi (9f7028fd23)
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
z
Variables
Typedefs
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
2
3
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
c
e
f
g
h
k
l
m
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Related Functions
a
c
d
e
f
g
i
l
m
n
o
p
q
r
s
t
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Variables
a
b
c
d
e
f
g
h
i
l
n
o
p
q
r
s
t
u
w
Typedefs
a
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
Enumerator
Macros
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
w
y
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
src
gui
editorwidgets
qgsrelationaggregatesearchwidgetwrapper.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsrelationaggregatesearchwidget.cpp
3
-----------------------------
4
Date : Nov 2017
5
Copyright : (C) 2017 Matthias Kuhn
6
Email : matthias@opengis.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
17
#include "
qgsrelationaggregatesearchwidgetwrapper.h
"
18
#include "
qgsattributeform.h
"
19
#include "
qgsrelationwidgetwrapper.h
"
20
#include "
qgslogger.h
"
21
#include "
qgscollapsiblegroupbox.h
"
22
23
#include <QLabel>
24
#include <QGridLayout>
25
26
QgsRelationAggregateSearchWidgetWrapper::QgsRelationAggregateSearchWidgetWrapper
(
QgsVectorLayer
*vl,
QgsRelationWidgetWrapper
*wrapper, QWidget *parent )
27
:
QgsSearchWidgetWrapper
( vl, -1, parent )
28
, mWrapper( wrapper )
29
{
30
setContext
( mWrapper->
context
() );
31
}
32
33
QString
QgsRelationAggregateSearchWidgetWrapper::expression
()
const
34
{
35
QString aggregateFilter;
36
37
if
( mAttributeForm )
38
aggregateFilter = mAttributeForm->
aggregateFilter
();
39
40
if
( aggregateFilter.isEmpty() )
41
return
QStringLiteral(
"TRUE"
);
42
else
43
return
aggregateFilter;
44
}
45
46
bool
QgsRelationAggregateSearchWidgetWrapper::valid
()
const
47
{
48
return
true
;
49
}
50
51
QWidget *
QgsRelationAggregateSearchWidgetWrapper::createWidget
( QWidget *parent )
52
{
53
QWidget *
widget
;
54
QgsRelation
relation = mWrapper->
relation
();
55
56
QgsCollapsibleGroupBox
*groupBox =
new
QgsCollapsibleGroupBox
( relation.
name
() );
57
58
if
( !relation.
isValid
() )
59
{
60
widget
=
new
QLabel( tr(
"Relation not valid"
) );
61
}
62
else
63
{
64
mContainerWidget =
new
QWidget( parent );
65
widget
= mContainerWidget;
66
widget
->installEventFilter(
this
);
67
}
68
69
groupBox->setLayout(
new
QGridLayout() );
70
groupBox->layout()->addWidget(
widget
);
71
72
return
groupBox;
73
}
74
75
bool
QgsRelationAggregateSearchWidgetWrapper::applyDirectly
()
76
{
77
return
true
;
78
}
79
80
void
QgsRelationAggregateSearchWidgetWrapper::setExpression
(
const
QString &value )
81
{
82
Q_UNUSED( value )
83
QgsDebugMsg
( QStringLiteral(
"Not supported"
) );
84
}
85
86
bool
QgsRelationAggregateSearchWidgetWrapper::eventFilter
( QObject *watched, QEvent *event )
87
{
88
bool
rv = QgsSearchWidgetWrapper::eventFilter( watched, event );
89
if
( event->type() == QEvent::Show && !mAttributeForm )
90
{
91
QgsAttributeEditorContext
subContext =
QgsAttributeEditorContext
(
context
(), mWrapper->
relation
(),
QgsAttributeEditorContext::Multiple
,
QgsAttributeEditorContext::Embed
);
92
mAttributeForm =
new
QgsAttributeForm
( mWrapper->
relation
().
referencingLayer
(),
QgsFeature
(), subContext, mContainerWidget );
93
mAttributeForm->
setMode
(
QgsAttributeEditorContext::AggregateSearchMode
);
94
QGridLayout *glayout =
new
QGridLayout();
95
mContainerWidget->setLayout( glayout );
96
glayout->setMargin( 0 );
97
glayout->addWidget( mAttributeForm );
98
}
99
return
rv;
100
}
qgsattributeform.h
qgscollapsiblegroupbox.h
QgsRelation::name
QString name
Definition:
qgsrelation.h:48
QgsRelationWidgetWrapper
Definition:
qgsrelationwidgetwrapper.h:30
QgsSearchWidgetWrapper
Definition:
qgssearchwidgetwrapper.h:85
QgsRelationAggregateSearchWidgetWrapper::eventFilter
bool eventFilter(QObject *watched, QEvent *event) override
Definition:
qgsrelationaggregatesearchwidgetwrapper.cpp:86
QgsAttributeEditorContext::Embed
@ Embed
A form was embedded as a widget on another form.
Definition:
qgsattributeeditorcontext.h:71
QgsDebugMsg
#define QgsDebugMsg(str)
Definition:
qgslogger.h:38
QgsAttributeForm::aggregateFilter
QString aggregateFilter() const
The aggregate filter is only useful if the form is in AggregateFilter mode.
Definition:
qgsattributeform.cpp:2365
QgsWidgetWrapper::context
const QgsAttributeEditorContext & context() const
Returns information about the context in which this widget is shown.
Definition:
qgswidgetwrapper.cpp:86
QgsCollapsibleGroupBox
Definition:
qgscollapsiblegroupbox.h:178
QgsWidgetWrapper::widget
QWidget * widget()
Access the widget managed by this wrapper.
Definition:
qgswidgetwrapper.cpp:46
QgsRelation::referencingLayer
QgsVectorLayer referencingLayer
Definition:
qgsrelation.h:46
QgsRelationWidgetWrapper::relation
QgsRelation relation() const
The relation for which this wrapper is created.
Definition:
qgsrelationwidgetwrapper.cpp:80
QgsRelationAggregateSearchWidgetWrapper::valid
bool valid() const override
Returns true if the widget has been properly initialized.
Definition:
qgsrelationaggregatesearchwidgetwrapper.cpp:46
QgsRelationAggregateSearchWidgetWrapper::applyDirectly
bool applyDirectly() override
If this is true, then this search widget should take effect directly when its expression changes.
Definition:
qgsrelationaggregatesearchwidgetwrapper.cpp:75
QgsRelationAggregateSearchWidgetWrapper::createWidget
QWidget * createWidget(QWidget *parent) override
This method should create a new widget with the provided parent.
Definition:
qgsrelationaggregatesearchwidgetwrapper.cpp:51
QgsRelationAggregateSearchWidgetWrapper::expression
QString expression() const override
Will be used to access the widget's value.
Definition:
qgsrelationaggregatesearchwidgetwrapper.cpp:33
QgsRelationAggregateSearchWidgetWrapper::QgsRelationAggregateSearchWidgetWrapper
QgsRelationAggregateSearchWidgetWrapper(QgsVectorLayer *layer, QgsRelationWidgetWrapper *wrapper, QWidget *parent SIP_TRANSFERTHIS=nullptr)
Constructor.
Definition:
qgsrelationaggregatesearchwidgetwrapper.cpp:26
QgsAttributeForm::setMode
void setMode(QgsAttributeEditorContext::Mode mode)
Sets the current mode of the form.
Definition:
qgsattributeform.cpp:130
QgsVectorLayer
Definition:
qgsvectorlayer.h:385
QgsRelation::isValid
bool isValid
Definition:
qgsrelation.h:49
qgsrelationaggregatesearchwidgetwrapper.h
QgsRelation
Definition:
qgsrelation.h:41
QgsFeature
Definition:
qgsfeature.h:55
QgsAttributeForm
Definition:
qgsattributeform.h:44
QgsAttributeEditorContext::AggregateSearchMode
@ AggregateSearchMode
Form is in aggregate search mode, show each widget in this mode.
Definition:
qgsattributeeditorcontext.h:54
qgslogger.h
QgsAttributeEditorContext
Definition:
qgsattributeeditorcontext.h:40
qgsrelationwidgetwrapper.h
QgsWidgetWrapper::setContext
void setContext(const QgsAttributeEditorContext &context)
Set the context in which this widget is shown.
Definition:
qgswidgetwrapper.cpp:66
QgsAttributeEditorContext::Multiple
@ Multiple
When showing a list of features (e.g. houses as an embedded form in a district form)
Definition:
qgsattributeeditorcontext.h:65
QgsRelationAggregateSearchWidgetWrapper::setExpression
void setExpression(const QString &value) override
Set the expression which is currently used as filter for this widget.
Definition:
qgsrelationaggregatesearchwidgetwrapper.cpp:80
Generated on Mon Jun 22 2020 05:14:09 for QGIS API Documentation by
1.8.17