Skip to content
Permalink
Browse files

Merge pull request #7801 from signedav/qml-widget

[FEATURE] QML chart and drawings widget
  • Loading branch information
m-kuhn committed Sep 14, 2018
2 parents 2e91c29 + b8b737f commit b75f9f3b5b4df58a7974c60f629a58f2b1ae42b1
Showing with 1,086 additions and 228 deletions.
  1. +2 −1 debian/control.in
  2. +41 −1 python/core/auto_generated/qgsattributeeditorelement.sip.in
  3. +3 −2 python/core/auto_generated/qgsexpressioncontext.sip.in
  4. +2 −0 python/gui/auto_additions/qgsattributeeditorcontext.py
  5. +1 −1 python/gui/auto_generated/attributetable/qgsdualview.sip.in
  6. +12 −0 python/gui/auto_generated/editorwidgets/core/qgswidgetwrapper.sip.in
  7. +65 −0 python/gui/auto_generated/editorwidgets/qgsqmlwidgetwrapper.sip.in
  8. +1 −1 python/gui/auto_generated/qgsactionmenu.sip.in
  9. +2 −2 python/gui/auto_generated/qgsattributedialog.sip.in
  10. +34 −0 python/gui/auto_generated/qgsattributeeditorcontext.sip.in
  11. +3 −3 python/gui/auto_generated/qgsattributeform.sip.in
  12. +43 −0 python/gui/auto_generated/qgsqmlwidget.sip.in
  13. +2 −1 python/gui/gui_auto.sip
  14. +1 −0 rpm/qgis.spec.template
  15. +1 −1 src/app/qgisapp.cpp
  16. +1 −1 src/app/qgisappinterface.cpp
  17. +323 −99 src/app/qgsattributesformproperties.cpp
  18. +12 −1 src/app/qgsattributesformproperties.h
  19. +2 −2 src/app/qgsattributetabledialog.cpp
  20. +1 −1 src/app/qgsattributetabledialog.h
  21. +3 −3 src/app/qgsfeatureaction.cpp
  22. +1 −1 src/app/qgsmaptoolfillring.cpp
  23. +1 −1 src/app/qgsselectbyformdialog.cpp
  24. +3 −0 src/core/expression/qgsexpression.cpp
  25. +29 −0 src/core/qgsattributeeditorelement.cpp
  26. +43 −1 src/core/qgsattributeeditorelement.h
  27. +11 −3 src/core/qgseditformconfig.cpp
  28. +2 −1 src/core/qgsexpressioncontext.cpp
  29. +3 −2 src/core/qgsexpressioncontext.h
  30. +1 −1 src/core/qgsfeature.h
  31. +22 −1 src/gui/CMakeLists.txt
  32. +3 −3 src/gui/attributetable/qgsdualview.cpp
  33. +1 −1 src/gui/attributetable/qgsdualview.h
  34. +1 −0 src/gui/editorwidgets/core/qgswidgetwrapper.cpp
  35. +12 −0 src/gui/editorwidgets/core/qgswidgetwrapper.h
  36. +121 −0 src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp
  37. +95 −0 src/gui/editorwidgets/qgsqmlwidgetwrapper.h
  38. +1 −1 src/gui/editorwidgets/qgsrelationaggregatesearchwidgetwrapper.cpp
  39. +3 −3 src/gui/qgsactionmenu.cpp
  40. +2 −2 src/gui/qgsactionmenu.h
  41. +2 −2 src/gui/qgsattributedialog.cpp
  42. +2 −2 src/gui/qgsattributedialog.h
  43. +39 −0 src/gui/qgsattributeeditorcontext.h
  44. +113 −68 src/gui/qgsattributeform.cpp
  45. +6 −5 src/gui/qgsattributeform.h
  46. +2 −2 src/gui/qgsidentifymenu.cpp
  47. +4 −0 src/quickgui/attributes/qgsquickattributeformmodelbase.cpp
  48. +8 −8 tests/src/gui/testqgsattributeform.cpp
@@ -78,7 +78,8 @@ Architecture: all
Depends:
libjs-jquery,
libjs-leaflet,
${misc:Depends}
${misc:Depends},
qml-module-qtcharts
Description: QGIS - architecture-independent data
QGIS is a Geographic Information System (GIS) which manages, analyzes and
display databases of geographic information.
@@ -47,7 +47,8 @@ layer.
AeTypeContainer,
AeTypeField,
AeTypeRelation,
AeTypeInvalid
AeTypeInvalid,
AeTypeQmlElement
};

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

};

class QgsAttributeEditorQmlElement : QgsAttributeEditorElement
{
%Docstring
An attribute editor widget that will represent arbitrary QML code.

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgsattributeeditorelement.h"
%End
public:

QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent );
%Docstring
Creates a new element which can display QML

:param name: The name of the widget
:param parent: The parent (used as container)
%End

virtual QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const /Factory/;


QString qmlCode() const;
%Docstring
The QML code that will be represented within this widget.

.. versionadded:: 3.4
%End

void setQmlCode( const QString &qmlCode );
%Docstring
The QML code that will be represented within this widget.

@param qmlCode
%End

};

/************************************************************************
* This file has been generated automatically from *
@@ -765,10 +765,11 @@ For instance, QGIS version numbers and variables specified through QGIS options.
.. seealso:: :py:func:`setGlobalVariable`
%End

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

.. versionadded:: 3.2
%End
@@ -0,0 +1,2 @@
# The following has been generated automatically from src/gui/qgsattributeeditorcontext.h
QgsAttributeEditorContext.Mode.baseClass = QgsAttributeEditorContext
@@ -240,7 +240,7 @@ Is emitted when a filter expression is set using the view.
.. versionadded:: 2.16
%End

void formModeChanged( QgsAttributeForm::Mode mode );
void formModeChanged( QgsAttributeEditorContext::Mode mode );
%Docstring
Emitted when the form changes mode.

@@ -14,6 +14,7 @@
// so RTTI for casting is available in the whole module.
%ModuleCode
#include "qgsrelationwidgetwrapper.h"
#include "qgsqmlwidgetwrapper.h"
%End

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

.. versionadded:: 3.2
%End

signals:

void contextChanged();
%Docstring
Signal when QgsAttributeEditorContext mContext changed

.. versionadded:: 3.4
%End

protected:
@@ -0,0 +1,65 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/editorwidgets/qgsqmlwidgetwrapper.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/


class QgsQmlWidgetWrapper : QgsWidgetWrapper
{
%Docstring
Wraps a QQuickWidget to display QML code

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgsqmlwidgetwrapper.h"
%End
public:

QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
%Docstring
Create a qml widget wrapper

:param layer: The layer on which the feature is
:param editor: An editor widget. Can be NULL if one should be autogenerated.
:param parent: A parent widget
%End

virtual bool valid() const;


virtual QWidget *createWidget( QWidget *parent );


virtual void initWidget( QWidget *editor );


void reinitWidget();
%Docstring
Clears the content and makes new initialization
%End

void setQmlCode( const QString &qmlCode );
%Docstring
writes the ``qmlCode`` into a temporary file
%End

public slots:
virtual void setFeature( const QgsFeature &feature );


};



/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/editorwidgets/qgsqmlwidgetwrapper.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -73,7 +73,7 @@ Change the feature on which actions are performed
as long as the menu is displayed and the action is running.
%End

void setMode( QgsAttributeForm::Mode mode );
void setMode( QgsAttributeEditorContext::Mode mode );
%Docstring
Change the mode of the actions

@@ -50,11 +50,11 @@ Is this dialog editable?
:return: returns true, if this dialog was created in an editable manner.
%End

void setMode( QgsAttributeForm::Mode mode );
void setMode( QgsAttributeEditorContext::Mode mode );
%Docstring
Toggles the form mode.

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

@@ -23,6 +23,19 @@ showing an embedded form due to relations)
#include "qgsattributeeditorcontext.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

enum Mode
{
SingleEditMode,
AddFeatureMode,
MultiEditMode,
SearchMode,
AggregateSearchMode,
IdentifyMode
};

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

Mode attributeFormMode() const;
%Docstring
Returns current attributeFormMode

.. versionadded:: 3.4
%End

void setAttributeFormMode( const Mode &attributeFormMode );
%Docstring
Set ``attributeFormMode`` for the edited form

.. versionadded:: 3.4
%End

QString attributeFormModeString() const;
%Docstring
Returns given ``attributeFormMode`` as string

.. versionadded:: 3.4
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -71,7 +71,7 @@ Returns if the form is currently in editable mode.
:return: Editable mode of this form
%End

Mode mode() const;
QgsAttributeEditorContext::Mode mode() const;
%Docstring
Returns the current mode of the form.

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

void setMode( Mode mode );
void setMode( QgsAttributeEditorContext::Mode mode );
%Docstring
Sets the current mode of the form.

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

void modeChanged( QgsAttributeForm::Mode mode );
void modeChanged( QgsAttributeEditorContext::Mode mode );
%Docstring
Emitted when the form changes mode.

@@ -0,0 +1,43 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsqmlwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/


class QgsQmlWidget
{
%Docstring
*************************************************************************
qgsqmlwidget.h

---------------------
begin : 25.6.2018
copyright : (C) 2018 by Matthias Kuhn
email : matthias@opengis.ch
**************************************************************************

This program is free software; you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or *
(at your option) any later version. *

**************************************************************************
%End

%TypeHeaderCode
#include "qgsqmlwidget.h"
%End
public:
QgsQmlWidget();
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsqmlwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -1,5 +1,4 @@
// Include auto-generated SIP files
%Include auto_generated/qgsattributeeditorcontext.sip
%Include auto_generated/qgsattributeforminterface.sip
%Include auto_generated/qgsdetaileditemdata.sip
%Include auto_generated/qgsexpressionbuilderdialog.sip
@@ -212,6 +211,7 @@
%Include auto_generated/qgsvariableeditorwidget.sip
%Include auto_generated/qgsvscrollarea.sip
%Include auto_generated/qgsfiledownloaderdialog.sip
%Include auto_generated/qgsattributeeditorcontext.sip
%Include auto_generated/raster/qgscolorrampshaderwidget.sip
%Include auto_generated/raster/qgsmultibandcolorrendererwidget.sip
%Include auto_generated/raster/qgspalettedrendererwidget.sip
@@ -326,4 +326,5 @@
%Include auto_generated/processing/qgsprocessingtoolboxmodel.sip
%Include auto_generated/processing/qgsprocessingtoolboxtreeview.sip
%Include auto_generated/processing/qgsprocessingwidgetwrapper.sip
%Include auto_generated/editorwidgets/qgsqmlwidgetwrapper.sip
%Include auto_generated/qgsadvanceddigitizingcanvasitem.sip
@@ -107,6 +107,7 @@ BuildRequires: qwt-qt5-devel
# Installation of QCA plugins must be explicit
Requires: qca-qt5-ossl
Requires: gpsbabel
Requires: qt5-qtcharts

# We don't want to provide private Python extension libs
%global __provides_exclude_from ^(%{python3_sitearch}|%{_libdir}/%{name}/plugins)/.*\.so(\.%{version})?$
@@ -8212,7 +8212,7 @@ void QgisApp::modifyAttributesOfSelectedFeatures()
context.setAllowCustomUi( false );

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

@@ -745,7 +745,7 @@ QgsAttributeDialog *QgisAppInterface::getFeatureForm( QgsVectorLayer *l, QgsFeat
QgsAttributeDialog *dialog = new QgsAttributeDialog( l, &feature, false, qgis, true, context );
if ( !feature.isValid() )
{
dialog->setMode( QgsAttributeForm::AddFeatureMode );
dialog->setMode( QgsAttributeEditorContext::AddFeatureMode );
}
return dialog;
}

0 comments on commit b75f9f3

Please sign in to comment.
You can’t perform that action at this time.