Skip to content

Commit b75f9f3

Browse files
authored
Merge pull request #7801 from signedav/qml-widget
[FEATURE] QML chart and drawings widget
2 parents 2e91c29 + b8b737f commit b75f9f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1086
-228
lines changed

debian/control.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ Architecture: all
7878
Depends:
7979
libjs-jquery,
8080
libjs-leaflet,
81-
${misc:Depends}
81+
${misc:Depends},
82+
qml-module-qtcharts
8283
Description: QGIS - architecture-independent data
8384
QGIS is a Geographic Information System (GIS) which manages, analyzes and
8485
display databases of geographic information.

python/core/auto_generated/qgsattributeeditorelement.sip.in

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ layer.
4747
AeTypeContainer,
4848
AeTypeField,
4949
AeTypeRelation,
50-
AeTypeInvalid
50+
AeTypeInvalid,
51+
AeTypeQmlElement
5152
};
5253

5354
QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = 0 );
@@ -345,6 +346,45 @@ Determines if the "unlink feature" button should be shown
345346

346347
};
347348

349+
class QgsAttributeEditorQmlElement : QgsAttributeEditorElement
350+
{
351+
%Docstring
352+
An attribute editor widget that will represent arbitrary QML code.
353+
354+
.. versionadded:: 3.4
355+
%End
356+
357+
%TypeHeaderCode
358+
#include "qgsattributeeditorelement.h"
359+
%End
360+
public:
361+
362+
QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent );
363+
%Docstring
364+
Creates a new element which can display QML
365+
366+
:param name: The name of the widget
367+
:param parent: The parent (used as container)
368+
%End
369+
370+
virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;
371+
372+
373+
QString qmlCode() const;
374+
%Docstring
375+
The QML code that will be represented within this widget.
376+
377+
.. versionadded:: 3.4
378+
%End
379+
380+
void setQmlCode( const QString &qmlCode );
381+
%Docstring
382+
The QML code that will be represented within this widget.
383+
384+
@param qmlCode
385+
%End
386+
387+
};
348388

349389
/************************************************************************
350390
* This file has been generated automatically from *

python/core/auto_generated/qgsexpressioncontext.sip.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,11 @@ For instance, QGIS version numbers and variables specified through QGIS options.
765765
.. seealso:: :py:func:`setGlobalVariable`
766766
%End
767767

768-
static QgsExpressionContextScope *formScope( const QgsFeature &formFeature = QgsFeature( ) ) /Factory/;
768+
static QgsExpressionContextScope *formScope( const QgsFeature &formFeature = QgsFeature( ), const QString &formMode = QString() ) /Factory/;
769769
%Docstring
770-
Creates a new scope which contains functions and variables from the current attribute form/table feature.
770+
Creates a new scope which contains functions and variables from the current attribute form/table ``feature``.
771771
The variables and values in this scope will reflect the current state of the form/row being edited.
772+
The ``formMode`` (SingleEditMode etc.) is passed as text
772773

773774
.. versionadded:: 3.2
774775
%End
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# The following has been generated automatically from src/gui/qgsattributeeditorcontext.h
2+
QgsAttributeEditorContext.Mode.baseClass = QgsAttributeEditorContext

python/gui/auto_generated/attributetable/qgsdualview.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Is emitted when a filter expression is set using the view.
240240
.. versionadded:: 2.16
241241
%End
242242

243-
void formModeChanged( QgsAttributeForm::Mode mode );
243+
void formModeChanged( QgsAttributeEditorContext::Mode mode );
244244
%Docstring
245245
Emitted when the form changes mode.
246246

python/gui/auto_generated/editorwidgets/core/qgswidgetwrapper.sip.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// so RTTI for casting is available in the whole module.
1515
%ModuleCode
1616
#include "qgsrelationwidgetwrapper.h"
17+
#include "qgsqmlwidgetwrapper.h"
1718
%End
1819

1920
class QgsWidgetWrapper : QObject
@@ -37,6 +38,8 @@ changed status of the widget will be saved.
3738
sipType = sipType_QgsEditorWidgetWrapper;
3839
else if ( qobject_cast<QgsRelationWidgetWrapper *>( sipCpp ) )
3940
sipType = sipType_QgsRelationWidgetWrapper;
41+
else if ( qobject_cast<QgsQmlWidgetWrapper *>( sipCpp ) )
42+
sipType = sipType_QgsQmlWidgetWrapper;
4043
else
4144
sipType = 0;
4245
%End
@@ -162,6 +165,15 @@ that any pending changes should be pushed to the edit buffer or they
162165
might be lost.
163166

164167
.. versionadded:: 3.2
168+
%End
169+
170+
signals:
171+
172+
void contextChanged();
173+
%Docstring
174+
Signal when QgsAttributeEditorContext mContext changed
175+
176+
.. versionadded:: 3.4
165177
%End
166178

167179
protected:
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/editorwidgets/qgsqmlwidgetwrapper.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
class QgsQmlWidgetWrapper : QgsWidgetWrapper
11+
{
12+
%Docstring
13+
Wraps a QQuickWidget to display QML code
14+
15+
.. versionadded:: 3.4
16+
%End
17+
18+
%TypeHeaderCode
19+
#include "qgsqmlwidgetwrapper.h"
20+
%End
21+
public:
22+
23+
QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
24+
%Docstring
25+
Create a qml widget wrapper
26+
27+
:param layer: The layer on which the feature is
28+
:param editor: An editor widget. Can be NULL if one should be autogenerated.
29+
:param parent: A parent widget
30+
%End
31+
32+
virtual bool valid() const;
33+
34+
35+
virtual QWidget *createWidget( QWidget *parent );
36+
37+
38+
virtual void initWidget( QWidget *editor );
39+
40+
41+
void reinitWidget();
42+
%Docstring
43+
Clears the content and makes new initialization
44+
%End
45+
46+
void setQmlCode( const QString &qmlCode );
47+
%Docstring
48+
writes the ``qmlCode`` into a temporary file
49+
%End
50+
51+
public slots:
52+
virtual void setFeature( const QgsFeature &feature );
53+
54+
55+
};
56+
57+
58+
59+
/************************************************************************
60+
* This file has been generated automatically from *
61+
* *
62+
* src/gui/editorwidgets/qgsqmlwidgetwrapper.h *
63+
* *
64+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
65+
************************************************************************/

python/gui/auto_generated/qgsactionmenu.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Change the feature on which actions are performed
7373
as long as the menu is displayed and the action is running.
7474
%End
7575

76-
void setMode( QgsAttributeForm::Mode mode );
76+
void setMode( QgsAttributeEditorContext::Mode mode );
7777
%Docstring
7878
Change the mode of the actions
7979

python/gui/auto_generated/qgsattributedialog.sip.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ Is this dialog editable?
5050
:return: returns true, if this dialog was created in an editable manner.
5151
%End
5252

53-
void setMode( QgsAttributeForm::Mode mode );
53+
void setMode( QgsAttributeEditorContext::Mode mode );
5454
%Docstring
5555
Toggles the form mode.
5656

57-
:param mode: form mode. For example, if set to QgsAttributeForm.AddFeatureMode, the dialog will be editable even with an invalid feature and
57+
:param mode: form mode. For example, if set to QgsAttributeEditorContext.AddFeatureMode, the dialog will be editable even with an invalid feature and
5858
will add a new feature when the form is accepted.
5959
%End
6060

python/gui/auto_generated/qgsattributeeditorcontext.sip.in

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ showing an embedded form due to relations)
2323
#include "qgsattributeeditorcontext.h"
2424
%End
2525
public:
26+
static const QMetaObject staticMetaObject;
27+
28+
public:
29+
30+
enum Mode
31+
{
32+
SingleEditMode,
33+
AddFeatureMode,
34+
MultiEditMode,
35+
SearchMode,
36+
AggregateSearchMode,
37+
IdentifyMode
38+
};
2639

2740
enum RelationMode
2841
{
@@ -198,9 +211,30 @@ Set current ``feature`` for the currently edited form or table row
198211
.. versionadded:: 3.2
199212
%End
200213

214+
Mode attributeFormMode() const;
215+
%Docstring
216+
Returns current attributeFormMode
217+
218+
.. versionadded:: 3.4
219+
%End
220+
221+
void setAttributeFormMode( const Mode &attributeFormMode );
222+
%Docstring
223+
Set ``attributeFormMode`` for the edited form
224+
225+
.. versionadded:: 3.4
226+
%End
227+
228+
QString attributeFormModeString() const;
229+
%Docstring
230+
Returns given ``attributeFormMode`` as string
231+
232+
.. versionadded:: 3.4
233+
%End
201234

202235
};
203236

237+
204238
/************************************************************************
205239
* This file has been generated automatically from *
206240
* *

python/gui/auto_generated/qgsattributeform.sip.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Returns if the form is currently in editable mode.
7171
:return: Editable mode of this form
7272
%End
7373

74-
Mode mode() const;
74+
QgsAttributeEditorContext::Mode mode() const;
7575
%Docstring
7676
Returns the current mode of the form.
7777

@@ -80,7 +80,7 @@ Returns the current mode of the form.
8080
.. versionadded:: 2.16
8181
%End
8282

83-
void setMode( Mode mode );
83+
void setMode( QgsAttributeEditorContext::Mode mode );
8484
%Docstring
8585
Sets the current mode of the form.
8686

@@ -177,7 +177,7 @@ Is emitted when a filter expression is set using the form.
177177
.. versionadded:: 2.16
178178
%End
179179

180-
void modeChanged( QgsAttributeForm::Mode mode );
180+
void modeChanged( QgsAttributeEditorContext::Mode mode );
181181
%Docstring
182182
Emitted when the form changes mode.
183183

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/qgsqmlwidget.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
class QgsQmlWidget
11+
{
12+
%Docstring
13+
*************************************************************************
14+
qgsqmlwidget.h
15+
16+
---------------------
17+
begin : 25.6.2018
18+
copyright : (C) 2018 by Matthias Kuhn
19+
email : matthias@opengis.ch
20+
**************************************************************************
21+
22+
This program is free software; you can redistribute it and/or modify *
23+
it under the terms of the GNU General Public License as published by *
24+
the Free Software Foundation; either version 2 of the License, or *
25+
(at your option) any later version. *
26+
27+
**************************************************************************
28+
%End
29+
30+
%TypeHeaderCode
31+
#include "qgsqmlwidget.h"
32+
%End
33+
public:
34+
QgsQmlWidget();
35+
};
36+
37+
/************************************************************************
38+
* This file has been generated automatically from *
39+
* *
40+
* src/gui/qgsqmlwidget.h *
41+
* *
42+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
43+
************************************************************************/

python/gui/gui_auto.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Include auto-generated SIP files
2-
%Include auto_generated/qgsattributeeditorcontext.sip
32
%Include auto_generated/qgsattributeforminterface.sip
43
%Include auto_generated/qgsdetaileditemdata.sip
54
%Include auto_generated/qgsexpressionbuilderdialog.sip
@@ -212,6 +211,7 @@
212211
%Include auto_generated/qgsvariableeditorwidget.sip
213212
%Include auto_generated/qgsvscrollarea.sip
214213
%Include auto_generated/qgsfiledownloaderdialog.sip
214+
%Include auto_generated/qgsattributeeditorcontext.sip
215215
%Include auto_generated/raster/qgscolorrampshaderwidget.sip
216216
%Include auto_generated/raster/qgsmultibandcolorrendererwidget.sip
217217
%Include auto_generated/raster/qgspalettedrendererwidget.sip
@@ -326,4 +326,5 @@
326326
%Include auto_generated/processing/qgsprocessingtoolboxmodel.sip
327327
%Include auto_generated/processing/qgsprocessingtoolboxtreeview.sip
328328
%Include auto_generated/processing/qgsprocessingwidgetwrapper.sip
329+
%Include auto_generated/editorwidgets/qgsqmlwidgetwrapper.sip
329330
%Include auto_generated/qgsadvanceddigitizingcanvasitem.sip

rpm/qgis.spec.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ BuildRequires: qwt-qt5-devel
107107
# Installation of QCA plugins must be explicit
108108
Requires: qca-qt5-ossl
109109
Requires: gpsbabel
110+
Requires: qt5-qtcharts
110111

111112
# We don't want to provide private Python extension libs
112113
%global __provides_exclude_from ^(%{python3_sitearch}|%{_libdir}/%{name}/plugins)/.*\.so(\.%{version})?$

src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8212,7 +8212,7 @@ void QgisApp::modifyAttributesOfSelectedFeatures()
82128212
context.setAllowCustomUi( false );
82138213

82148214
QgsAttributeDialog *dialog = new QgsAttributeDialog( vl, &f, false, this, true, context );
8215-
dialog->setMode( QgsAttributeForm::MultiEditMode );
8215+
dialog->setMode( QgsAttributeEditorContext::MultiEditMode );
82168216
dialog->exec();
82178217
}
82188218

src/app/qgisappinterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ QgsAttributeDialog *QgisAppInterface::getFeatureForm( QgsVectorLayer *l, QgsFeat
745745
QgsAttributeDialog *dialog = new QgsAttributeDialog( l, &feature, false, qgis, true, context );
746746
if ( !feature.isValid() )
747747
{
748-
dialog->setMode( QgsAttributeForm::AddFeatureMode );
748+
dialog->setMode( QgsAttributeEditorContext::AddFeatureMode );
749749
}
750750
return dialog;
751751
}

0 commit comments

Comments
 (0)