Skip to content

Commit 76df5b0

Browse files
committedSep 5, 2018
docs and replacement of qmlexpression
1 parent ae1333d commit 76df5b0

File tree

7 files changed

+60
-50
lines changed

7 files changed

+60
-50
lines changed
 

‎python/core/auto_generated/qgsattributeeditorelement.sip.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,14 @@ An attribute editor widget that will represent arbitrary QML code.
358358
#include "qgsattributeeditorelement.h"
359359
%End
360360
public:
361+
361362
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
362369

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

‎python/gui/auto_generated/editorwidgets/qgsqmlwidgetwrapper.sip.in

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,9 @@
1010
class QgsQmlWidgetWrapper : QgsWidgetWrapper
1111
{
1212
%Docstring
13-
*************************************************************************
14-
qgsqmlwidgetwrapper.h
13+
Wraps a QQuickWidget to display QML code
1514

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-
**************************************************************************
15+
.. versionadded:: 3.4
2816
%End
2917

3018
%TypeHeaderCode
@@ -33,6 +21,13 @@ the Free Software Foundation; either version 2 of the License, or *
3321
public:
3422

3523
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
3631

3732
virtual bool valid() const;
3833

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

6459
};
6560

66-
67-
class QmlExpression : QObject
68-
{
69-
70-
%TypeHeaderCode
71-
#include "qgsqmlwidgetwrapper.h"
72-
%End
73-
public:
74-
void setExpressionContext( const QgsExpressionContext &context );
75-
76-
QVariant evaluate( const QString &expression ) const;
77-
%Docstring
78-
evaluates the value regarding the /a expression and the context
79-
%End
80-
81-
};
82-
8361
/************************************************************************
8462
* This file has been generated automatically from *
8563
* *

‎src/app/qgsattributesformproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
11411141
qmlObjectTemplate->addItem( tr( "Rectangle" ) );
11421142
qmlObjectTemplate->addItem( tr( "Pie chart" ) );
11431143
qmlObjectTemplate->addItem( tr( "Bar chart" ) );
1144-
connect( qmlObjectTemplate, QOverload<int>::of( &QComboBox::currentIndexChanged ), qmlCode, [ = ]( int index )
1144+
connect( qmlObjectTemplate, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), qmlCode, [ = ]( int index )
11451145
{
11461146
qmlCode->clear();
11471147
switch ( index )

‎src/core/qgsattributeeditorelement.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,21 @@ class CORE_EXPORT QgsAttributeEditorRelation : public QgsAttributeEditorElement
413413
};
414414

415415
/**
416+
* \ingroup core
416417
* An attribute editor widget that will represent arbitrary QML code.
417418
*
418419
* \since QGIS 3.4
419420
*/
420421
class CORE_EXPORT QgsAttributeEditorQmlElement : public QgsAttributeEditorElement
421422
{
422423
public:
424+
425+
/**
426+
* Creates a new element which can display QML
427+
*
428+
* \param name The name of the widget
429+
* \param parent The parent (used as container)
430+
*/
423431
QgsAttributeEditorQmlElement( const QString &name, QgsAttributeEditorElement *parent )
424432
: QgsAttributeEditorElement( AeTypeQmlElement, name, parent )
425433
{}

‎src/core/qgseditformconfig.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,13 +558,13 @@ QgsAttributeEditorElement *QgsEditFormConfig::attributeEditorElementFromDomEleme
558558

559559
newElement = container;
560560
}
561-
else if ( elem.tagName() == QStringLiteral( "attributeEditorField" ) )
561+
else if ( elem.tagName() == QLatin1String( "attributeEditorField" ) )
562562
{
563563
QString name = elem.attribute( QStringLiteral( "name" ) );
564564
int idx = d->mFields.lookupField( name );
565565
newElement = new QgsAttributeEditorField( name, idx, parent );
566566
}
567-
else if ( elem.tagName() == QStringLiteral( "attributeEditorRelation" ) )
567+
else if ( elem.tagName() == QLatin1String( "attributeEditorRelation" ) )
568568
{
569569
// At this time, the relations are not loaded
570570
// So we only grab the id and delegate the rest to onRelationsLoaded()
@@ -573,7 +573,7 @@ QgsAttributeEditorElement *QgsEditFormConfig::attributeEditorElementFromDomEleme
573573
relElement->setShowUnlinkButton( elem.attribute( QStringLiteral( "showUnlinkButton" ), QStringLiteral( "1" ) ).toInt() );
574574
newElement = relElement;
575575
}
576-
else if ( elem.tagName() == QStringLiteral( "attributeEditorQmlElement" ) )
576+
else if ( elem.tagName() == QLatin1String( "attributeEditorQmlElement" ) )
577577
{
578578
QgsAttributeEditorQmlElement *qmlElement = new QgsAttributeEditorQmlElement( elem.attribute( QStringLiteral( "name" ) ), parent );
579579
qmlElement->setQmlCode( elem.text() );

‎src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@
2020
#include <QQmlContext>
2121
#include <QQmlEngine>
2222

23+
/**
24+
* \ingroup gui
25+
* To pass the QgsExpression functionality and it's context to the context of the QQuickWidget
26+
* \since QGIS 3.4
27+
*/
28+
class GUI_EXPORT QmlExpression : public QObject
29+
{
30+
Q_OBJECT
31+
32+
public:
33+
void setExpressionContext( const QgsExpressionContext &context );
34+
35+
//! evaluates the value regarding the /a expression and the context
36+
Q_INVOKABLE QVariant evaluate( const QString &expression ) const;
37+
38+
private:
39+
QgsExpressionContext mExpressionContext;
40+
};
41+
42+
2343
QgsQmlWidgetWrapper::QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent )
2444
: QgsWidgetWrapper( layer, editor, parent )
2545
{

‎src/gui/editorwidgets/qgsqmlwidgetwrapper.h

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,24 @@
2121
#include "qgis_gui.h"
2222
#include <QtQuickWidgets/QQuickWidget>
2323

24+
/**
25+
* \ingroup gui
26+
* Wraps a QQuickWidget to display QML code
27+
* \since QGIS 3.4
28+
*/
2429
class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
2530
{
2631
Q_OBJECT
2732

2833
public:
2934

35+
/**
36+
* Create a qml widget wrapper
37+
*
38+
* \param layer The layer on which the feature is
39+
* \param editor An editor widget. Can be NULL if one should be autogenerated.
40+
* \param parent A parent widget
41+
*/
3042
QgsQmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
3143

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

54-
55-
class GUI_EXPORT QmlExpression : public QObject
56-
{
57-
Q_OBJECT
58-
59-
public:
60-
void setExpressionContext( const QgsExpressionContext &context );
61-
62-
//! evaluates the value regarding the /a expression and the context
63-
Q_INVOKABLE QVariant evaluate( const QString &expression ) const;
64-
65-
private:
66-
QgsExpressionContext mExpressionContext;
67-
};
68-
6966
#endif // QGSQMLWIDGETWRAPPER_H

0 commit comments

Comments
 (0)
Please sign in to comment.