Skip to content

Commit

Permalink
Merge pull request #7801 from signedav/qml-widget
Browse files Browse the repository at this point in the history
[FEATURE] QML chart and drawings widget
  • Loading branch information
m-kuhn committed Sep 14, 2018
2 parents 2e91c29 + b8b737f commit b75f9f3
Show file tree
Hide file tree
Showing 48 changed files with 1,086 additions and 228 deletions.
3 changes: 2 additions & 1 deletion debian/control.in
Expand Up @@ -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.
Expand Down
42 changes: 41 additions & 1 deletion python/core/auto_generated/qgsattributeeditorelement.sip.in
Expand Up @@ -47,7 +47,8 @@ layer.
AeTypeContainer,
AeTypeField,
AeTypeRelation,
AeTypeInvalid
AeTypeInvalid,
AeTypeQmlElement
};

QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = 0 );
Expand Down Expand Up @@ -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 *
Expand Down
5 changes: 3 additions & 2 deletions python/core/auto_generated/qgsexpressioncontext.sip.in
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions python/gui/auto_additions/qgsattributeeditorcontext.py
@@ -0,0 +1,2 @@
# The following has been generated automatically from src/gui/qgsattributeeditorcontext.h
QgsAttributeEditorContext.Mode.baseClass = QgsAttributeEditorContext
Expand Up @@ -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.

Expand Down
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
65 changes: 65 additions & 0 deletions python/gui/auto_generated/editorwidgets/qgsqmlwidgetwrapper.sip.in
@@ -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 *
************************************************************************/
2 changes: 1 addition & 1 deletion python/gui/auto_generated/qgsactionmenu.sip.in
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions python/gui/auto_generated/qgsattributedialog.sip.in
Expand Up @@ -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

Expand Down
34 changes: 34 additions & 0 deletions python/gui/auto_generated/qgsattributeeditorcontext.sip.in
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 *
* *
Expand Down
6 changes: 3 additions & 3 deletions python/gui/auto_generated/qgsattributeform.sip.in
Expand Up @@ -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.

Expand All @@ -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.

Expand Down Expand Up @@ -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.

Expand Down
43 changes: 43 additions & 0 deletions python/gui/auto_generated/qgsqmlwidget.sip.in
@@ -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 *
************************************************************************/
3 changes: 2 additions & 1 deletion python/gui/gui_auto.sip
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions rpm/qgis.spec.template
Expand Up @@ -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})?$
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisappinterface.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit b75f9f3

Please sign in to comment.