mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-05 00:05:32 -04:00
layout and expressions
This commit is contained in:
parent
6ac41b42d9
commit
3d8d3ac6c6
@ -1120,6 +1120,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
|||||||
QLineEdit *title = new QLineEdit( itemData.name() );
|
QLineEdit *title = new QLineEdit( itemData.name() );
|
||||||
//qml code
|
//qml code
|
||||||
QPlainTextEdit *qmlCode = new QPlainTextEdit( itemData.qmlElementEditorConfiguration().qmlCode );
|
QPlainTextEdit *qmlCode = new QPlainTextEdit( itemData.qmlElementEditorConfiguration().qmlCode );
|
||||||
|
qmlCode->setMinimumWidth( 400 );
|
||||||
//template to select
|
//template to select
|
||||||
QComboBox *qmlObjectTemplate = new QComboBox();
|
QComboBox *qmlObjectTemplate = new QComboBox();
|
||||||
qmlObjectTemplate->addItem( "Rectangle" );
|
qmlObjectTemplate->addItem( "Rectangle" );
|
||||||
@ -1145,7 +1146,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
|||||||
"import QtCharts 2.0\n"
|
"import QtCharts 2.0\n"
|
||||||
"\n"
|
"\n"
|
||||||
"ChartView {\n"
|
"ChartView {\n"
|
||||||
" width: 600\n"
|
" width: 400\n"
|
||||||
" height: 400\n"
|
" height: 400\n"
|
||||||
"\n"
|
"\n"
|
||||||
" PieSeries {\n"
|
" PieSeries {\n"
|
||||||
@ -1165,11 +1166,21 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
|||||||
//attributes to select
|
//attributes to select
|
||||||
QgsFieldComboBox *attributeFieldCombo = new QgsFieldComboBox();
|
QgsFieldComboBox *attributeFieldCombo = new QgsFieldComboBox();
|
||||||
attributeFieldCombo->setLayer( mLayer );
|
attributeFieldCombo->setLayer( mLayer );
|
||||||
connect( attributeFieldCombo, &QgsFieldComboBox::fieldChanged, qmlCode, [ = ]( QString attributeName )
|
connect( attributeFieldCombo, &QgsFieldComboBox::fieldChanged, this, [ = ]( QString attributeName )
|
||||||
{
|
{
|
||||||
qmlCode->insertPlainText( QStringLiteral( "feature.attribute(\"%1\")" ).arg( attributeName ) );
|
qmlCode->insertPlainText( QStringLiteral( "feature.attribute(\"%1\")" ).arg( attributeName ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
QgsFieldExpressionWidget *expressionWidget = new QgsFieldExpressionWidget;
|
||||||
|
expressionWidget->setLayer( mLayer );
|
||||||
|
expressionWidget->setExpressionDialogTitle( tr( "Expression" ) );
|
||||||
|
|
||||||
|
connect( expressionWidget, static_cast < void ( QgsFieldExpressionWidget::* )( const QString & ) > ( &QgsFieldExpressionWidget::fieldChanged ), this, [ = ]( const QString & expressionText )
|
||||||
|
{
|
||||||
|
qmlCode->insertPlainText( QStringLiteral( "expression(%1)" ).arg( expressionText ) );
|
||||||
|
QgsLogger::warning( QStringLiteral( "Do it..." ) );
|
||||||
|
//expression needs to be added here...
|
||||||
|
} );
|
||||||
|
|
||||||
QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper( mLayer, nullptr, this );
|
QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper( mLayer, nullptr, this );
|
||||||
qmlWrapper->setQmlCode( qmlCode->toPlainText() );
|
qmlWrapper->setQmlCode( qmlCode->toPlainText() );
|
||||||
@ -1179,15 +1190,19 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
|||||||
qmlWrapper->reinitWidget();
|
qmlWrapper->reinitWidget();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
layout->addRow( tr( "Title" ), title );
|
layout->addRow( tr( "Title" ), title );
|
||||||
QGroupBox *qmlCodeBox = new QGroupBox( tr( "QML Code" ) );
|
QGroupBox *qmlCodeBox = new QGroupBox( tr( "QML Code" ) );
|
||||||
qmlCodeBox->setLayout( new QGridLayout );
|
qmlCodeBox->setLayout( new QGridLayout );
|
||||||
qmlCodeBox->layout()->addWidget( qmlObjectTemplate );
|
qmlCodeBox->layout()->addWidget( qmlObjectTemplate );
|
||||||
qmlCodeBox->layout()->addWidget( attributeFieldCombo );
|
qmlCodeBox->layout()->addWidget( attributeFieldCombo );
|
||||||
|
qmlCodeBox->layout()->addWidget( expressionWidget );
|
||||||
qmlCodeBox->layout()->addWidget( qmlCode );
|
qmlCodeBox->layout()->addWidget( qmlCode );
|
||||||
layout->addRow( qmlCodeBox );
|
layout->addRow( qmlCodeBox );
|
||||||
qmlLayout->addWidget( qmlWrapper->widget() );
|
QGroupBox *qmlPreviewBox = new QGroupBox( tr( "Preview") );
|
||||||
|
qmlPreviewBox->setLayout( new QGridLayout );
|
||||||
|
qmlPreviewBox->setMinimumWidth( 400 );
|
||||||
|
qmlPreviewBox->layout()->addWidget(qmlWrapper->widget());
|
||||||
|
qmlLayout->addWidget( qmlPreviewBox );
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
||||||
|
|
||||||
@ -1196,7 +1211,6 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
|||||||
|
|
||||||
mainLayout->addWidget( buttonBox );
|
mainLayout->addWidget( buttonBox );
|
||||||
|
|
||||||
|
|
||||||
if ( dlg.exec() )
|
if ( dlg.exec() )
|
||||||
{
|
{
|
||||||
QgsAttributesFormProperties::QmlElementEditorConfiguration qmlEdCfg;
|
QgsAttributesFormProperties::QmlElementEditorConfiguration qmlEdCfg;
|
||||||
|
@ -51,4 +51,17 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
|
|||||||
QgsFeature mFeature;
|
QgsFeature mFeature;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
class GUI_EXPORT QmlExpression
|
||||||
|
{
|
||||||
|
Q_GADGET
|
||||||
|
|
||||||
|
public:
|
||||||
|
QgsExpressionContext expressionContext();
|
||||||
|
void setExpressionContext( QgsExpressionContext expressionContext );
|
||||||
|
|
||||||
|
Q_INVOKABLE evaluate();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#endif // QGSQMLWIDGETWRAPPER_H
|
#endif // QGSQMLWIDGETWRAPPER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user