Skip to content
Permalink
Browse files

Yay, more QML!

  • Loading branch information
m-kuhn authored and signedav committed Sep 5, 2018
1 parent 35898f9 commit f41aaa79cb3b68184356db0ac8ec3ff4482e7dbc
@@ -348,15 +348,34 @@ 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( QgsAttributeEditorElement *parent );

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

};

@@ -491,6 +491,11 @@ void QgsAttributesFormProperties::onAttributeSelectionChanged()
mAttributeTypeDialog->setVisible( false );
break;
}
case DnDTreeItemData::QmlWidget:
{

break;
}

}
}
@@ -572,6 +577,15 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
widgetDef = container;
break;
}

case DnDTreeItemData::QmlWidget:
{
QgsAttributeEditorQmlElement *element = new QgsAttributeEditorQmlElement( parent );
element->setQmlCode( "ABC " );

widgetDef = element;
break;
}
}

widgetDef->setShowLabel( itemData.showLabel() );
@@ -151,6 +151,14 @@ void QgsAttributeEditorRelation::setShowUnlinkButton( bool showUnlinkButton )
mShowUnlinkButton = showUnlinkButton;
}

QgsAttributeEditorElement *QgsAttributeEditorQmlElement::clone( QgsAttributeEditorElement *parent ) const
{
QgsAttributeEditorQmlElement *element = new QgsAttributeEditorQmlElement( parent );
element->setQmlCode( mQmlCode );

return element;
}

QString QgsAttributeEditorQmlElement::qmlCode() const
{
return mQmlCode;
@@ -412,14 +412,32 @@ class CORE_EXPORT QgsAttributeEditorRelation : public QgsAttributeEditorElement
bool mShowUnlinkButton = true;
};

/**
* An attribute editor widget that will represent arbitrary QML code.
*
* \since QGIS 3.4
*/
class CORE_EXPORT QgsAttributeEditorQmlElement : public QgsAttributeEditorElement
{
public:
QgsAttributeEditorQmlElement( QgsAttributeEditorElement *parent )
: QgsAttributeEditorElement( AeTypeQmlElement, "TODO NAME", parent )
{}

QgsAttributeEditorElement *clone( QgsAttributeEditorElement *parent ) const override SIP_FACTORY;

/**
* The QML code that will be represented within this widget.
*
* \since QGIS 3.4
*/
QString qmlCode() const;

/**
* The QML code that will be represented within this widget.
*
* @param qmlCode
*/
void setQmlCode( const QString &qmlCode );

private:
@@ -1775,6 +1775,10 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
const QgsAttributeEditorQmlElement *elementDef = static_cast<const QgsAttributeEditorQmlElement *>( widgetDef );

QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper( mLayer, nullptr, this );
QTemporaryFile *qmlFile = new QTemporaryFile();
qmlFile->write( elementDef->qmlCode().toUtf8() );
qmlFile->setParent( qmlWrapper );

qmlWrapper->setConfig( mLayer->editFormConfig().widgetConfig( "TODO NAME??" ) );
qmlWrapper->setContext( context );

0 comments on commit f41aaa7

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