mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
Yay, more QML!
This commit is contained in:
parent
35898f9f0e
commit
f41aaa79cb
@ -348,6 +348,11 @@ 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"
|
||||
@ -355,8 +360,22 @@ class QgsAttributeEditorQmlElement : QgsAttributeEditorElement
|
||||
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,6 +412,11 @@ 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:
|
||||
@ -419,7 +424,20 @@ class CORE_EXPORT QgsAttributeEditorQmlElement : public QgsAttributeEditorElemen
|
||||
: 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 );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user