Skip to content

Commit

Permalink
More framework
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 17, 2023
1 parent 7fdc804 commit 58e52ed
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
Expand Up @@ -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 );

Expand Down
4 changes: 0 additions & 4 deletions src/core/layout/qgslayoutitemelevationprofile.h
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions src/core/layout/qgslayoutitemregistry.cpp
Expand Up @@ -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 <QPainter>

Expand Down Expand Up @@ -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 ) );
Expand Down
34 changes: 34 additions & 0 deletions src/gui/layout/qgslayoutguiutils.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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() );

}

0 comments on commit 58e52ed

Please sign in to comment.