Skip to content
Permalink
Browse files

Merge branch 'master' into fix-rpm-2

  • Loading branch information
daniviga committed Mar 26, 2019
2 parents 4857a06 + 4f9d002 commit 8f9e782396eecba295842bb6e9e071923068be84
Showing with 1,003 additions and 107 deletions.
  1. +41 −2 python/core/auto_generated/qgsattributeeditorelement.sip.in
  2. +20 −0 python/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in
  3. +3 −0 python/gui/auto_generated/editorwidgets/core/qgswidgetwrapper.sip.in
  4. +65 −0 python/gui/auto_generated/editorwidgets/qgshtmlwidgetwrapper.sip.in
  5. +1 −0 python/gui/gui_auto.sip
  6. +134 −2 src/app/qgsattributesformproperties.cpp
  7. +11 −1 src/app/qgsattributesformproperties.h
  8. +30 −0 src/core/qgsattributeeditorelement.cpp
  9. +45 −4 src/core/qgsattributeeditorelement.h
  10. +6 −0 src/core/qgseditformconfig.cpp
  11. +57 −11 src/core/symbology/qgspointdisplacementrenderer.cpp
  12. +18 −1 src/core/symbology/qgspointdisplacementrenderer.h
  13. +2 −0 src/gui/CMakeLists.txt
  14. +3 −0 src/gui/editorwidgets/core/qgswidgetwrapper.h
  15. +117 −0 src/gui/editorwidgets/qgshtmlwidgetwrapper.cpp
  16. +97 −0 src/gui/editorwidgets/qgshtmlwidgetwrapper.h
  17. +20 −0 src/gui/qgsattributeform.cpp
  18. +15 −0 src/gui/symbology/qgspointdisplacementrendererwidget.cpp
  19. +1 −0 src/gui/symbology/qgspointdisplacementrendererwidget.h
  20. +4 −0 src/quickgui/attributes/qgsquickattributeformmodelbase.cpp
  21. +68 −45 src/ui/qgspointdisplacementrendererwidgetbase.ui
  22. +245 −41 tests/src/python/test_qgspointdisplacementrenderer.py
  23. BIN ...pected_displacement_cluster_concentric_labels/expected_displacement_cluster_concentric_labels.png
  24. BIN ...d_displacement_cluster_concentric_labels/expected_displacement_cluster_concentric_labels_mask.png
  25. BIN ...cluster_concentric_labels_diff_size/expected_displacement_cluster_concentric_labels_diff_size.png
  26. BIN ...er_concentric_labels_diff_size/expected_displacement_cluster_concentric_labels_diff_size_mask.png
  27. BIN ...ic_labels_diff_size_farther/expected_displacement_cluster_concentric_labels_diff_size_farther.png
  28. BIN ...bels_diff_size_farther/expected_displacement_cluster_concentric_labels_diff_size_farther_mask.png
  29. BIN ..._renderer/expected_displacement_cluster_grid_labels/expected_displacement_cluster_grid_labels.png
  30. BIN ...erer/expected_displacement_cluster_grid_labels/expected_displacement_cluster_grid_labels_mask.png
  31. BIN ...isplacement_cluster_grid_labels_diff_size/expected_displacement_cluster_grid_labels_diff_size.png
  32. BIN ...cement_cluster_grid_labels_diff_size/expected_displacement_cluster_grid_labels_diff_size_mask.png
  33. BIN ...ter_grid_labels_diff_size_farther/expected_displacement_cluster_grid_labels_diff_size_farther.png
  34. BIN ...rid_labels_diff_size_farther/expected_displacement_cluster_grid_labels_diff_size_farther_mask.png
  35. BIN ..._renderer/expected_displacement_cluster_ring_labels/expected_displacement_cluster_ring_labels.png
  36. BIN ...erer/expected_displacement_cluster_ring_labels/expected_displacement_cluster_ring_labels_mask.png
  37. BIN ...isplacement_cluster_ring_labels_diff_size/expected_displacement_cluster_ring_labels_diff_size.png
  38. BIN ...cement_cluster_ring_labels_diff_size/expected_displacement_cluster_ring_labels_diff_size_mask.png
  39. BIN ...ter_ring_labels_diff_size_farther/expected_displacement_cluster_ring_labels_diff_size_farther.png
  40. BIN ...ing_labels_diff_size_farther/expected_displacement_cluster_ring_labels_diff_size_farther_mask.png
@@ -48,7 +48,8 @@ layer.
AeTypeField,
AeTypeRelation,
AeTypeInvalid,
AeTypeQmlElement
AeTypeQmlElement,
AeTypeHtmlElement
};

QgsAttributeEditorElement( AttributeEditorType type, const QString &name, QgsAttributeEditorElement *parent = 0 );
@@ -394,13 +395,51 @@ The QML code that will be represented within this widget.

void setQmlCode( const QString &qmlCode );
%Docstring
Sets the QML code that will be represented within this widget to ``qmlCode``.
%End

};


class QgsAttributeEditorHtmlElement : QgsAttributeEditorElement
{
%Docstring
An attribute editor widget that will represent arbitrary HTML code.

.. versionadded:: 3.10
%End

%TypeHeaderCode
#include "qgsattributeeditorelement.h"
%End
public:

QgsAttributeEditorHtmlElement( const QString &name, QgsAttributeEditorElement *parent );
%Docstring
Creates a new element which can display HTML

:param name: The name of the widget
:param parent: The parent (used as container)
%End

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


QString htmlCode() const;
%Docstring
The QML code that will be represented within this widget.

@param qmlCode
.. versionadded:: 3.4
%End

void setHtmlCode( const QString &htmlCode );
%Docstring
Sets the HTML code that will be represented within this widget to ``htmlCode``.
%End

};


/************************************************************************
* This file has been generated automatically from *
* *
@@ -104,6 +104,26 @@ Sets a factor for increasing the ring size of displacement groups.
Returns the factor for increasing the ring size of displacement groups.

.. seealso:: :py:func:`setCircleRadiusAddition`
%End

void setLabelDistanceFactor( double factor );
%Docstring
Sets a factor for increasing the label distances from the symbol.

:param factor: addition factor

.. seealso:: :py:func:`labelDistanceFactor`

.. versionadded:: 3.8
%End

double labelDistanceFactor() const;
%Docstring
Returns the factor for label distance from the symbol.

.. seealso:: :py:func:`setLabelDistanceFactor`

.. versionadded:: 3.8
%End

Placement placement() const;
@@ -15,6 +15,7 @@
%ModuleCode
#include "qgsrelationwidgetwrapper.h"
#include "qgsqmlwidgetwrapper.h"
#include "qgshtmlwidgetwrapper.h"
%End

class QgsWidgetWrapper : QObject
@@ -40,6 +41,8 @@ changed status of the widget will be saved.
sipType = sipType_QgsRelationWidgetWrapper;
else if ( qobject_cast<QgsQmlWidgetWrapper *>( sipCpp ) )
sipType = sipType_QgsQmlWidgetWrapper;
else if ( qobject_cast<QgsHtmlWidgetWrapper *>( sipCpp ) )
sipType = sipType_QgsHtmlWidgetWrapper;
else
sipType = 0;
%End
@@ -0,0 +1,65 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/editorwidgets/qgshtmlwidgetwrapper.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/


class QgsHtmlWidgetWrapper : QgsWidgetWrapper
{
%Docstring
Wraps a QQuickWidget to display HTML code

.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgshtmlwidgetwrapper.h"
%End
public:

QgsHtmlWidgetWrapper( QgsVectorLayer *layer, QWidget *editor, QWidget *parent );
%Docstring
Create a html widget wrapper

:param layer: The layer on which the feature is
:param editor: An editor widget. Can be ``None`` if one should be autogenerated.
:param parent: A parent widget
%End

virtual bool valid() const;


virtual QWidget *createWidget( QWidget *parent );


virtual void initWidget( QWidget *editor );


void reinitWidget();
%Docstring
Clears the content and makes new initialization
%End

void setHtmlCode( const QString &htmlCode );
%Docstring
Sets the HTML code to ``htmlCode``
%End

public slots:
virtual void setFeature( const QgsFeature &feature );


};



/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/editorwidgets/qgshtmlwidgetwrapper.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -287,6 +287,7 @@
%Include auto_generated/editorwidgets/qgsdatetimesearchwidgetwrapper.sip
%Include auto_generated/editorwidgets/qgsdefaultsearchwidgetwrapper.sip
%Include auto_generated/editorwidgets/qgsdoublespinbox.sip
%Include auto_generated/editorwidgets/qgshtmlwidgetwrapper.sip
%Include auto_generated/editorwidgets/qgsmultiedittoolbutton.sip
%Include auto_generated/editorwidgets/qgsrelationreferencesearchwidgetwrapper.sip
%Include auto_generated/editorwidgets/qgsrelationreferencewidget.sip
@@ -20,8 +20,10 @@
#include "qgisapp.h"
#include "qgsfieldcombobox.h"
#include "qgsqmlwidgetwrapper.h"
#include "qgshtmlwidgetwrapper.h"
#include "qgsapplication.h"
#include "qgscolorbutton.h"
#include "qgscodeeditorhtml.h"

QgsAttributesFormProperties::QgsAttributesFormProperties( QgsVectorLayer *layer, QWidget *parent )
: QWidget( parent )
@@ -140,14 +142,17 @@ void QgsAttributesFormProperties::initAvailableWidgetsTree()
}
catitem->setExpanded( true );

// QML widget
// QML/HTML widget
catItemData = DnDTreeItemData( DnDTreeItemData::Container, QStringLiteral( "Other" ), tr( "Other Widgets" ) );
catitem = mAvailableWidgetsTree->addItem( mAvailableWidgetsTree->invisibleRootItem(), catItemData );

DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::QmlWidget, QStringLiteral( "QmlWidget" ), tr( "QML Widget" ) );
itemData.setShowLabel( true );

mAvailableWidgetsTree->addItem( catitem, itemData );

auto itemDataHtml { DnDTreeItemData( DnDTreeItemData::HtmlWidget, QStringLiteral( "HtmlWidget" ), tr( "HTML Widget" ) ) };
itemDataHtml.setShowLabel( true );
mAvailableWidgetsTree->addItem( catitem, itemDataHtml );
catitem ->setExpanded( true );
}

@@ -479,6 +484,19 @@ QTreeWidgetItem *QgsAttributesFormProperties::loadAttributeEditorTreeItem( QgsAt
newWidget = tree->addItem( parent, itemData );
break;
}

case QgsAttributeEditorElement::AeTypeHtmlElement:
{
const QgsAttributeEditorHtmlElement *htmlElementEditor = static_cast<const QgsAttributeEditorHtmlElement *>( widgetDef );
DnDTreeItemData itemData = DnDTreeItemData( DnDTreeItemData::HtmlWidget, widgetDef->name(), widgetDef->name() );
itemData.setShowLabel( widgetDef->showLabel() );
HtmlElementEditorConfiguration htmlEdConfig;
htmlEdConfig.htmlCode = htmlElementEditor->htmlCode();
itemData.setHtmlElementEditorConfiguration( htmlEdConfig );
newWidget = tree->addItem( parent, itemData );
break;
}

case QgsAttributeEditorElement::AeTypeInvalid:
{
QgsDebugMsg( QStringLiteral( "Not loading invalid attribute editor type..." ) );
@@ -520,6 +538,12 @@ void QgsAttributesFormProperties::onAttributeSelectionChanged()
mAttributeTypeDialog->setVisible( false );
break;
}
case DnDTreeItemData::HtmlWidget:
{
mAttributeRelationEdit->setVisible( false );
mAttributeTypeDialog->setVisible( false );
break;
}

}
}
@@ -620,6 +644,15 @@ QgsAttributeEditorElement *QgsAttributesFormProperties::createAttributeEditorWid
widgetDef = element;
break;
}

case DnDTreeItemData::HtmlWidget:
{
QgsAttributeEditorHtmlElement *element = new QgsAttributeEditorHtmlElement( item->text( 0 ), parent );
element->setHtmlCode( itemData.htmlElementEditorConfiguration().htmlCode );
widgetDef = element;
break;
}

}

widgetDef->setShowLabel( itemData.showLabel() );
@@ -875,6 +908,10 @@ QTreeWidgetItem *DnDTree::addItem( QTreeWidgetItem *parent, QgsAttributesFormPro
case QgsAttributesFormProperties::DnDTreeItemData::QmlWidget:
//no icon for QmlWidget
break;

case QgsAttributesFormProperties::DnDTreeItemData::HtmlWidget:
//no icon for HtmlWidget
break;
}
}
newItem->setData( 0, QgsAttributesFormProperties::DnDTreeRole, data );
@@ -955,6 +992,11 @@ bool DnDTree::dropMimeData( QTreeWidgetItem *parent, int index, const QMimeData
{
onItemDoubleClicked( newItem, 0 );
}

if ( itemElement.type() == QgsAttributesFormProperties::DnDTreeItemData::HtmlWidget )
{
onItemDoubleClicked( newItem, 0 );
}
}
}

@@ -1295,6 +1337,85 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
}
break;

case QgsAttributesFormProperties::DnDTreeItemData::HtmlWidget:
{
QDialog dlg;
dlg.setWindowTitle( tr( "Configure HTML Widget" ) );

QVBoxLayout *mainLayout = new QVBoxLayout();
QHBoxLayout *htmlLayout = new QHBoxLayout();
QVBoxLayout *layout = new QVBoxLayout();
mainLayout->addLayout( htmlLayout );
htmlLayout->addLayout( layout );
dlg.setLayout( mainLayout );
layout->addWidget( baseWidget );

QLineEdit *title = new QLineEdit( itemData.name() );

//htmlCode
QgsCodeEditorHTML *htmlCode = new QgsCodeEditorHTML( );
htmlCode->setSizePolicy( QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding );
htmlCode->setText( itemData.htmlElementEditorConfiguration().htmlCode );

QgsHtmlWidgetWrapper *htmlWrapper = new QgsHtmlWidgetWrapper( mLayer, nullptr, this );
QgsFeature previewFeature;
mLayer->getFeatures().nextFeature( previewFeature );

//update preview on text change
connect( htmlCode, &QgsCodeEditorHTML::textChanged, this, [ = ]
{
htmlWrapper->setHtmlCode( htmlCode->text( ) );
htmlWrapper->reinitWidget();
htmlWrapper->setFeature( previewFeature );
} );

QgsFieldExpressionWidget *expressionWidget = new QgsFieldExpressionWidget;
expressionWidget->setLayer( mLayer );
QToolButton *addExpressionButton = new QToolButton();
addExpressionButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/symbologyAdd.svg" ) ) );

connect( addExpressionButton, &QAbstractButton::clicked, this, [ = ]
{
htmlCode->insertText( QStringLiteral( "<script>document.write(expression.evaluate(\"%1\"));</script>" ).arg( expressionWidget->expression().replace( '"', QLatin1String( "\\\"" ) ) ) );
} );

layout->addWidget( new QLabel( tr( "Title" ) ) );
layout->addWidget( title );
QGroupBox *expressionWidgetBox = new QGroupBox( tr( "HTML Code" ) );
layout->addWidget( expressionWidgetBox );
expressionWidgetBox->setLayout( new QHBoxLayout );
expressionWidgetBox->layout()->addWidget( expressionWidget );
expressionWidgetBox->layout()->addWidget( addExpressionButton );
layout->addWidget( htmlCode );
QScrollArea *htmlPreviewBox = new QScrollArea();
htmlPreviewBox->setLayout( new QGridLayout );
htmlPreviewBox->setMinimumWidth( 400 );
htmlPreviewBox->layout()->addWidget( htmlWrapper->widget() );
//emit to load preview for the first time
emit htmlCode->textChanged();
htmlLayout->addWidget( htmlPreviewBox );

QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );

connect( buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
connect( buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );

mainLayout->addWidget( buttonBox );

if ( dlg.exec() )
{
QgsAttributesFormProperties::HtmlElementEditorConfiguration htmlEdCfg;
htmlEdCfg.htmlCode = htmlCode->text();
itemData.setName( title->text() );
itemData.setHtmlElementEditorConfiguration( htmlEdCfg );
itemData.setShowLabel( showLabelCheckbox->isChecked() );

item->setData( 0, QgsAttributesFormProperties::DnDTreeRole, itemData );
item->setText( 0, title->text() );
}
}
break;

case QgsAttributesFormProperties::DnDTreeItemData::Field:
{
QDialog dlg;
@@ -1407,6 +1528,17 @@ void QgsAttributesFormProperties::DnDTreeItemData::setQmlElementEditorConfigurat
mQmlElementEditorConfiguration = qmlElementEditorConfiguration;
}


QgsAttributesFormProperties::HtmlElementEditorConfiguration QgsAttributesFormProperties::DnDTreeItemData::htmlElementEditorConfiguration() const
{
return mHtmlElementEditorConfiguration;
}

void QgsAttributesFormProperties::DnDTreeItemData::setHtmlElementEditorConfiguration( QgsAttributesFormProperties::HtmlElementEditorConfiguration htmlElementEditorConfiguration )
{
mHtmlElementEditorConfiguration = htmlElementEditorConfiguration;
}

QColor QgsAttributesFormProperties::DnDTreeItemData::backgroundColor() const
{
return mBackgroundColor;

0 comments on commit 8f9e782

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