diff --git a/python/core/auto_generated/layout/qgslayoutitemelevationprofile.sip.in b/python/core/auto_generated/layout/qgslayoutitemelevationprofile.sip.in index 6fee8289017..78b73db5af3 100644 --- a/python/core/auto_generated/layout/qgslayoutitemelevationprofile.sip.in +++ b/python/core/auto_generated/layout/qgslayoutitemelevationprofile.sip.in @@ -38,11 +38,6 @@ The caller takes responsibility for deleting the returned object. virtual QIcon icon() const; - public slots: - - virtual void refresh(); - - protected: virtual void draw( QgsLayoutItemRenderContext &context ); diff --git a/src/core/layout/qgslayoutitemelevationprofile.h b/src/core/layout/qgslayoutitemelevationprofile.h index c48b2ab23b5..a0488ae6025 100644 --- a/src/core/layout/qgslayoutitemelevationprofile.h +++ b/src/core/layout/qgslayoutitemelevationprofile.h @@ -46,10 +46,6 @@ class CORE_EXPORT QgsLayoutItemElevationProfile: public QgsLayoutItem int type() const override; QIcon icon() const override; - public slots: - - void refresh() override; - protected: void draw( QgsLayoutItemRenderContext &context ) override; bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override; diff --git a/src/core/layout/qgslayoutitemregistry.cpp b/src/core/layout/qgslayoutitemregistry.cpp index 0b317075edd..2e45cb1847d 100644 --- a/src/core/layout/qgslayoutitemregistry.cpp +++ b/src/core/layout/qgslayoutitemregistry.cpp @@ -31,10 +31,7 @@ #include "qgslayoutitemtexttable.h" #include "qgslayoutframe.h" #include "qgslayoutitemmarker.h" -#include "qgsgloweffect.h" -#include "qgseffectstack.h" -#include "qgsvectorlayer.h" -#include "qgssymbol.h" +#include "qgslayoutitemelevationprofile.h" #include @@ -82,6 +79,8 @@ bool QgsLayoutItemRegistry::populate() addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolygon, QObject::tr( "Polygon" ), QObject::tr( "Polygons" ), QgsLayoutItemPolygon::create ) ); addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolyline, QObject::tr( "Polyline" ), QObject::tr( "Polylines" ), QgsLayoutItemPolyline::create ) ); + addLayoutItemType( new QgsLayoutItemMetadata( LayoutElevationProfile, QObject::tr( "Elevation Profile" ), QObject::tr( "Elevation Profiles" ), QgsLayoutItemElevationProfile::create ) ); + addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutHtml, QObject::tr( "HTML" ), QgsLayoutItemHtml::create ) ); addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutAttributeTable, QObject::tr( "Attribute Table" ), QgsLayoutItemAttributeTable::create ) ); addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutTextTable, QObject::tr( "Text Table" ), QgsLayoutItemTextTable::create ) ); diff --git a/src/gui/layout/qgslayoutguiutils.cpp b/src/gui/layout/qgslayoutguiutils.cpp index a914ee1c4fe..72e85a31c70 100644 --- a/src/gui/layout/qgslayoutguiutils.cpp +++ b/src/gui/layout/qgslayoutguiutils.cpp @@ -32,6 +32,7 @@ #include "qgslayoutpicturewidget.h" #include "qgslayoutitempicture.h" #include "qgslayoutitemlabel.h" +#include "qgslayoutitemelevationprofile.h" #include "qgslayoutlabelwidget.h" #include "qgslayoutitemlegend.h" #include "qgslayoutitemscalebar.h" @@ -518,4 +519,37 @@ void QgsLayoutGuiUtils::registerGuiForKnownItemTypes( QgsMapCanvas *mapCanvas ) return f; } ); registry->addLayoutItemGuiMetadata( manualTableItemMetadata.release() ); + + + // elevation profile item + + auto elevationProfileItemMetadata = std::make_unique< QgsLayoutItemGuiMetadata >( QgsLayoutItemRegistry::LayoutElevationProfile, QObject::tr( "Elevation Profile" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionLabel.svg" ) ), + [ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget * + { + return nullptr; //return new QgsLayoutLabelWidget( qobject_cast< QgsLayoutItemLabel * >( item ) ); + }, createRubberBand ); + elevationProfileItemMetadata->setItemCreationFunction( [ = ]( QgsLayout * layout )->QgsLayoutItem * + { + std::unique_ptr< QgsLayoutItemElevationProfile > profileItem = std::make_unique< QgsLayoutItemElevationProfile >( layout ); + +#if 0 + //set default table fonts from settings + QgsSettings settings; + const QString defaultFontString = settings.value( QStringLiteral( "LayoutDesigner/defaultFont" ), QVariant(), QgsSettings::Gui ).toString(); + if ( !defaultFontString.isEmpty() ) + { + QgsTextFormat format; + QFont f = format.font(); + f.setFamily( defaultFontString ); + format.setFont( f ); + tableMultiFrame->setContentTextFormat( format ); + f.setBold( true ); + format.setFont( f ); + tableMultiFrame->setHeaderTextFormat( format ); + } +#endif + return profileItem.release(); + } ); + registry->addLayoutItemGuiMetadata( elevationProfileItemMetadata.release() ); + }