Skip to content
Permalink
Browse files

docs and replacement of qmlexpression

  • Loading branch information
signedav committed Sep 5, 2018
1 parent ae1333d commit 76df5b022d60fee9dc9a9e774531d3de3fc893a3
@@ -358,7 +358,14 @@ An attribute editor widget that will represent arbitrary QML code.
#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/;

@@ -10,21 +10,9 @@
class QgsQmlWidgetWrapper : QgsWidgetWrapper
{
%Docstring
*************************************************************************
qgsqmlwidgetwrapper.h
Wraps a QQuickWidget to display QML code

---------------------
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. *

**************************************************************************
.. versionadded:: 3.4
%End

%TypeHeaderCode
@@ -33,6 +21,13 @@ the Free Software Foundation; either version 2 of the License, or *
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;

@@ -63,23 +58,6 @@ passes the ``feature`` into the context property of the widget

};


class QmlExpression : QObject
{

%TypeHeaderCode
#include "qgsqmlwidgetwrapper.h"
%End
public:
void setExpressionContext( const QgsExpressionContext &context );

QVariant evaluate( const QString &expression ) const;
%Docstring
evaluates the value regarding the /a expression and the context
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
@@ -1141,7 +1141,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
qmlObjectTemplate->addItem( tr( "Rectangle" ) );
qmlObjectTemplate->addItem( tr( "Pie chart" ) );
qmlObjectTemplate->addItem( tr( "Bar chart" ) );
connect( qmlObjectTemplate, QOverload<int>::of( &QComboBox::currentIndexChanged ), qmlCode, [ = ]( int index )
connect( qmlObjectTemplate, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), qmlCode, [ = ]( int index )
{
qmlCode->clear();
switch ( index )
@@ -413,13 +413,21 @@ class CORE_EXPORT QgsAttributeEditorRelation : public QgsAttributeEditorElement
};

/**
* \ingroup core
* An attribute editor widget that will represent arbitrary QML code.
*
* \since QGIS 3.4
*/
class CORE_EXPORT QgsAttributeEditorQmlElement : public QgsAttributeEditorElement
{
public:

/**
* Creates a new element which can display QML
*
* \param name The name of the widget
* \param parent The parent (used as container)
*/
QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent )
: QgsAttributeEditorElement( AeTypeQmlElement, name, parent )
{}
@@ -558,13 +558,13 @@ QgsAttributeEditorElement *QgsEditFormConfig::attributeEditorElementFromDomEleme

newElement = container;
}
else if ( elem.tagName() == QStringLiteral( "attributeEditorField" ) )
else if ( elem.tagName() == QLatin1String( "attributeEditorField" ) )
{
QString name = elem.attribute( QStringLiteral( "name" ) );
int idx = d->mFields.lookupField( name );
newElement = new QgsAttributeEditorField( name, idx, parent );
}
else if ( elem.tagName() == QStringLiteral( "attributeEditorRelation" ) )
else if ( elem.tagName() == QLatin1String( "attributeEditorRelation" ) )
{
// At this time, the relations are not loaded
// So we only grab the id and delegate the rest to onRelationsLoaded()
@@ -573,7 +573,7 @@ QgsAttributeEditorElement *QgsEditFormConfig::attributeEditorElementFromDomEleme
relElement->setShowUnlinkButton( elem.attribute( QStringLiteral( "showUnlinkButton" ), QStringLiteral( "1" ) ).toInt() );
newElement = relElement;
}
else if ( elem.tagName() == QStringLiteral( "attributeEditorQmlElement" ) )
else if ( elem.tagName() == QLatin1String( "attributeEditorQmlElement" ) )
{
QgsAttributeEditorQmlElement *qmlElement = new QgsAttributeEditorQmlElement( elem.attribute( QStringLiteral( "name" ) ), parent );
qmlElement->setQmlCode( elem.text() );
@@ -20,6 +20,26 @@
#include <QQmlContext>
#include <QQmlEngine>

/**
* \ingroup gui
* To pass the QgsExpression functionality and it's context to the context of the QQuickWidget
* \since QGIS 3.4
*/
class GUI_EXPORT QmlExpression : public QObject
{
Q_OBJECT

public:
void setExpressionContext( const QgsExpressionContext &context );

//! evaluates the value regarding the /a expression and the context
Q_INVOKABLE QVariant evaluate( const QString &expression ) const;

private:
QgsExpressionContext mExpressionContext;
};


QgsQmlWidgetWrapper::QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent )
: QgsWidgetWrapper( layer, editor, parent )
{
@@ -21,12 +21,24 @@
#include "qgis_gui.h"
#include <QtQuickWidgets/QQuickWidget>

/**
* \ingroup gui
* Wraps a QQuickWidget to display QML code
* \since QGIS 3.4
*/
class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
{
Q_OBJECT

public:

/**
* 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
*/
QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );

bool valid() const override;
@@ -51,19 +63,4 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
QQuickWidget *mWidget = nullptr;
};


class GUI_EXPORT QmlExpression : public QObject
{
Q_OBJECT

public:
void setExpressionContext( const QgsExpressionContext &context );

//! evaluates the value regarding the /a expression and the context
Q_INVOKABLE QVariant evaluate( const QString &expression ) const;

private:
QgsExpressionContext mExpressionContext;
};

#endif // QGSQMLWIDGETWRAPPER_H

0 comments on commit 76df5b0

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