diff --git a/images/images.qrc b/images/images.qrc index 95370696044..f1db3381797 100755 --- a/images/images.qrc +++ b/images/images.qrc @@ -434,6 +434,19 @@ themes/default/mIconWms.svg themes/default/mIconZip.png themes/default/mIconZoom.svg + themes/default/mLayoutItem.svg + themes/default/mLayoutItemShapeEllipse.svg + themes/default/mLayoutItemShapeRectangle.svg + themes/default/mLayoutItemShapeTriangle.svg + themes/default/mLayoutItemHtml.svg + themes/default/mLayoutItemPicture.svg + themes/default/mLayoutItemLabel.svg + themes/default/mLayoutItemLegend.svg + themes/default/mLayoutItemMap.svg + themes/default/mLayoutItemPolygon.svg + themes/default/mLayoutItemPolyline.svg + themes/default/mLayoutItemScaleBar.svg + themes/default/mLayoutItemTable.svg themes/default/mMessageLog.svg themes/default/mMessageLogRead.svg themes/default/north_arrow.png diff --git a/images/themes/default/mLayoutItem.svg b/images/themes/default/mLayoutItem.svg new file mode 100644 index 00000000000..608f8571b60 --- /dev/null +++ b/images/themes/default/mLayoutItem.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemHtml.svg b/images/themes/default/mLayoutItemHtml.svg new file mode 100644 index 00000000000..129456c2955 --- /dev/null +++ b/images/themes/default/mLayoutItemHtml.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemLabel.svg b/images/themes/default/mLayoutItemLabel.svg new file mode 100644 index 00000000000..ac3451cceee --- /dev/null +++ b/images/themes/default/mLayoutItemLabel.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemLegend.svg b/images/themes/default/mLayoutItemLegend.svg new file mode 100644 index 00000000000..da0ef1a8626 --- /dev/null +++ b/images/themes/default/mLayoutItemLegend.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemMap.svg b/images/themes/default/mLayoutItemMap.svg new file mode 100644 index 00000000000..134cb4b72a7 --- /dev/null +++ b/images/themes/default/mLayoutItemMap.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemPicture.svg b/images/themes/default/mLayoutItemPicture.svg new file mode 100644 index 00000000000..8a762bee151 --- /dev/null +++ b/images/themes/default/mLayoutItemPicture.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemPolygon.svg b/images/themes/default/mLayoutItemPolygon.svg new file mode 100644 index 00000000000..40397de53f8 --- /dev/null +++ b/images/themes/default/mLayoutItemPolygon.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemPolyline.svg b/images/themes/default/mLayoutItemPolyline.svg new file mode 100644 index 00000000000..14950f824c6 --- /dev/null +++ b/images/themes/default/mLayoutItemPolyline.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemScaleBar.svg b/images/themes/default/mLayoutItemScaleBar.svg new file mode 100644 index 00000000000..22e62292a8b --- /dev/null +++ b/images/themes/default/mLayoutItemScaleBar.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemShapeEllipse.svg b/images/themes/default/mLayoutItemShapeEllipse.svg new file mode 100644 index 00000000000..b66d5a870f1 --- /dev/null +++ b/images/themes/default/mLayoutItemShapeEllipse.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemShapeRectangle.svg b/images/themes/default/mLayoutItemShapeRectangle.svg new file mode 100644 index 00000000000..608f8571b60 --- /dev/null +++ b/images/themes/default/mLayoutItemShapeRectangle.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemShapeTriangle.svg b/images/themes/default/mLayoutItemShapeTriangle.svg new file mode 100644 index 00000000000..d3afd19858e --- /dev/null +++ b/images/themes/default/mLayoutItemShapeTriangle.svg @@ -0,0 +1 @@ + diff --git a/images/themes/default/mLayoutItemTable.svg b/images/themes/default/mLayoutItemTable.svg new file mode 100644 index 00000000000..650a543f87d --- /dev/null +++ b/images/themes/default/mLayoutItemTable.svg @@ -0,0 +1 @@ + diff --git a/python/core/layout/qgslayoutframe.sip b/python/core/layout/qgslayoutframe.sip index 244220812d8..5a2de801d50 100644 --- a/python/core/layout/qgslayoutframe.sip +++ b/python/core/layout/qgslayoutframe.sip @@ -35,6 +35,8 @@ Creates a new QgsLayoutFrame belonging to the specified ``layout``. virtual int type() const; + virtual QIcon icon() const; + virtual QString uuid() const; diff --git a/python/core/layout/qgslayoutitem.sip b/python/core/layout/qgslayoutitem.sip index 685255238f9..2d0685eeecb 100644 --- a/python/core/layout/qgslayoutitem.sip +++ b/python/core/layout/qgslayoutitem.sip @@ -262,9 +262,14 @@ tasks. virtual int type() const; %Docstring -Return unique graphics item type identifier. +Returns a unique graphics item type identifier. Plugin based subclasses should return an identifier greater than QgsLayoutItemRegistry.PluginItem. +%End + + virtual QIcon icon() const; +%Docstring +Returns the item's icon. %End virtual QString uuid() const; diff --git a/python/core/layout/qgslayoutitemattributetable.sip b/python/core/layout/qgslayoutitemattributetable.sip index 5c13313ca22..916f6bd7871 100644 --- a/python/core/layout/qgslayoutitemattributetable.sip +++ b/python/core/layout/qgslayoutitemattributetable.sip @@ -39,6 +39,8 @@ Ownership is transferred to the layout. virtual int type() const; + virtual QIcon icon() const; + virtual QString displayName() const; diff --git a/python/core/layout/qgslayoutitemhtml.sip b/python/core/layout/qgslayoutitemhtml.sip index 4dbc91398df..8894a279389 100644 --- a/python/core/layout/qgslayoutitemhtml.sip +++ b/python/core/layout/qgslayoutitemhtml.sip @@ -39,6 +39,8 @@ Ownership is transferred to the layout. virtual int type() const; + virtual QIcon icon() const; + static QgsLayoutItemHtml *create( QgsLayout *layout ) /Factory/; %Docstring diff --git a/python/core/layout/qgslayoutitemlabel.sip b/python/core/layout/qgslayoutitemlabel.sip index de4cb4516a7..bdef9d7073f 100644 --- a/python/core/layout/qgslayoutitemlabel.sip +++ b/python/core/layout/qgslayoutitemlabel.sip @@ -42,6 +42,8 @@ The caller takes responsibility for deleting the returned object. virtual int type() const; + virtual QIcon icon() const; + virtual QString displayName() const; diff --git a/python/core/layout/qgslayoutitemlegend.sip b/python/core/layout/qgslayoutitemlegend.sip index 2425a87a1ee..6fb7da9f315 100644 --- a/python/core/layout/qgslayoutitemlegend.sip +++ b/python/core/layout/qgslayoutitemlegend.sip @@ -65,6 +65,8 @@ The caller takes responsibility for deleting the returned object. virtual int type() const; + virtual QIcon icon() const; + virtual QString displayName() const; diff --git a/python/core/layout/qgslayoutitemmap.sip b/python/core/layout/qgslayoutitemmap.sip index b47b1475f52..3699fbeb5c1 100644 --- a/python/core/layout/qgslayoutitemmap.sip +++ b/python/core/layout/qgslayoutitemmap.sip @@ -39,6 +39,8 @@ Constructor for QgsLayoutItemMap, with the specified parent ``layout``. virtual int type() const; + virtual QIcon icon() const; + void assignFreeId(); %Docstring diff --git a/python/core/layout/qgslayoutitempicture.sip b/python/core/layout/qgslayoutitempicture.sip index 93824c58fe1..cda40cc0be9 100644 --- a/python/core/layout/qgslayoutitempicture.sip +++ b/python/core/layout/qgslayoutitempicture.sip @@ -51,6 +51,8 @@ Constructor for QgsLayoutItemPicture, with the specified parent ``layout``. virtual int type() const; + virtual QIcon icon() const; + static QgsLayoutItemPicture *create( QgsLayout *layout ) /Factory/; %Docstring diff --git a/python/core/layout/qgslayoutitempolygon.sip b/python/core/layout/qgslayoutitempolygon.sip index 3dbb26f1973..827bc6a972e 100644 --- a/python/core/layout/qgslayoutitempolygon.sip +++ b/python/core/layout/qgslayoutitempolygon.sip @@ -43,6 +43,8 @@ The caller takes responsibility for deleting the returned object. virtual int type() const; + virtual QIcon icon() const; + virtual QString displayName() const; diff --git a/python/core/layout/qgslayoutitempolyline.sip b/python/core/layout/qgslayoutitempolyline.sip index 584b88a7946..40a4236a00c 100644 --- a/python/core/layout/qgslayoutitempolyline.sip +++ b/python/core/layout/qgslayoutitempolyline.sip @@ -49,6 +49,8 @@ The caller takes responsibility for deleting the returned object. virtual int type() const; + virtual QIcon icon() const; + virtual QString displayName() const; diff --git a/python/core/layout/qgslayoutitemscalebar.sip b/python/core/layout/qgslayoutitemscalebar.sip index 194444e8680..973cc562e2c 100644 --- a/python/core/layout/qgslayoutitemscalebar.sip +++ b/python/core/layout/qgslayoutitemscalebar.sip @@ -28,6 +28,8 @@ Constructor for QgsLayoutItemScaleBar, with the specified parent ``layout``. virtual int type() const; + virtual QIcon icon() const; + static QgsLayoutItemScaleBar *create( QgsLayout *layout ) /Factory/; %Docstring diff --git a/python/core/layout/qgslayoutitemshape.sip b/python/core/layout/qgslayoutitemshape.sip index a4de50a2da9..94215dab6b1 100644 --- a/python/core/layout/qgslayoutitemshape.sip +++ b/python/core/layout/qgslayoutitemshape.sip @@ -36,6 +36,8 @@ Constructor for QgsLayoutItemShape, with the specified parent ``layout``. virtual int type() const; + virtual QIcon icon() const; + virtual QString displayName() const; diff --git a/python/core/layout/qgslayoutmultiframe.sip b/python/core/layout/qgslayoutmultiframe.sip index 2c1deb546b9..9c3ce3bebad 100644 --- a/python/core/layout/qgslayoutmultiframe.sip +++ b/python/core/layout/qgslayoutmultiframe.sip @@ -73,6 +73,11 @@ Returns the total size of the multiframe's content, in layout units. virtual int type() const = 0; %Docstring Returns unique multiframe type id. +%End + + virtual QIcon icon() const; +%Docstring +Returns the item's icon. %End virtual QSizeF fixedFrameSize( const int frameIndex = -1 ) const; diff --git a/src/core/layout/qgslayoutframe.cpp b/src/core/layout/qgslayoutframe.cpp index 456f4070868..f573fe9740a 100644 --- a/src/core/layout/qgslayoutframe.cpp +++ b/src/core/layout/qgslayoutframe.cpp @@ -110,6 +110,14 @@ int QgsLayoutFrame::type() const return QgsLayoutItemRegistry::LayoutFrame; } +QIcon QgsLayoutFrame::icon() const +{ + if ( mMultiFrame ) + return mMultiFrame->icon(); + else + return QIcon(); +} + QString QgsLayoutFrame::uuid() const { if ( mMultiFrame ) diff --git a/src/core/layout/qgslayoutframe.h b/src/core/layout/qgslayoutframe.h index 46768e46f7f..69bb97334f6 100644 --- a/src/core/layout/qgslayoutframe.h +++ b/src/core/layout/qgslayoutframe.h @@ -46,6 +46,7 @@ class CORE_EXPORT QgsLayoutFrame: public QgsLayoutItem static QgsLayoutFrame *create( QgsLayout *layout ) SIP_FACTORY; int type() const override; + QIcon icon() const override; QString uuid() const override; //Overridden to allow multiframe to set display name diff --git a/src/core/layout/qgslayoutitem.h b/src/core/layout/qgslayoutitem.h index 2067c31e9f1..691622d3df9 100644 --- a/src/core/layout/qgslayoutitem.h +++ b/src/core/layout/qgslayoutitem.h @@ -25,6 +25,7 @@ #include "qgslayoutundocommand.h" #include "qgslayoutmeasurement.h" #include +#include #include class QgsLayout; @@ -292,12 +293,17 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt virtual void cleanup(); /** - * Return unique graphics item type identifier. + * Returns a unique graphics item type identifier. * * Plugin based subclasses should return an identifier greater than QgsLayoutItemRegistry::PluginItem. */ int type() const override; + /** + * Returns the item's icon. + */ + virtual QIcon icon() const { return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItem.svg" ) ); } + /** * Returns the item identification string. This is a unique random string set for the item * upon creation. diff --git a/src/core/layout/qgslayoutitemattributetable.cpp b/src/core/layout/qgslayoutitemattributetable.cpp index 8cacccec891..50281267041 100644 --- a/src/core/layout/qgslayoutitemattributetable.cpp +++ b/src/core/layout/qgslayoutitemattributetable.cpp @@ -95,6 +95,11 @@ int QgsLayoutItemAttributeTable::type() const return QgsLayoutItemRegistry::LayoutAttributeTable; } +QIcon QgsLayoutItemAttributeTable::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemTable.svg" ) ); +} + QgsLayoutItemAttributeTable *QgsLayoutItemAttributeTable::create( QgsLayout *layout ) { return new QgsLayoutItemAttributeTable( layout ); diff --git a/src/core/layout/qgslayoutitemattributetable.h b/src/core/layout/qgslayoutitemattributetable.h index 6bca791886b..f228bf4bbc7 100644 --- a/src/core/layout/qgslayoutitemattributetable.h +++ b/src/core/layout/qgslayoutitemattributetable.h @@ -56,6 +56,7 @@ class CORE_EXPORT QgsLayoutItemAttributeTable: public QgsLayoutTable QgsLayoutItemAttributeTable( QgsLayout *layout SIP_TRANSFERTHIS ); int type() const override; + QIcon icon() const override; QString displayName() const override; /** diff --git a/src/core/layout/qgslayoutitemhtml.cpp b/src/core/layout/qgslayoutitemhtml.cpp index 8ed9887c3d3..52fc0aa432f 100644 --- a/src/core/layout/qgslayoutitemhtml.cpp +++ b/src/core/layout/qgslayoutitemhtml.cpp @@ -81,6 +81,11 @@ int QgsLayoutItemHtml::type() const return QgsLayoutItemRegistry::LayoutHtml; } +QIcon QgsLayoutItemHtml::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemHtml.svg" ) ); +} + QgsLayoutItemHtml *QgsLayoutItemHtml::create( QgsLayout *layout ) { return new QgsLayoutItemHtml( layout ); diff --git a/src/core/layout/qgslayoutitemhtml.h b/src/core/layout/qgslayoutitemhtml.h index 9d0d324b365..dceb0746bb6 100644 --- a/src/core/layout/qgslayoutitemhtml.h +++ b/src/core/layout/qgslayoutitemhtml.h @@ -56,6 +56,7 @@ class CORE_EXPORT QgsLayoutItemHtml: public QgsLayoutMultiFrame ~QgsLayoutItemHtml() override; int type() const override; + QIcon icon() const override; /** * Returns a new QgsLayoutItemHtml for the specified parent \a layout. diff --git a/src/core/layout/qgslayoutitemlabel.cpp b/src/core/layout/qgslayoutitemlabel.cpp index 6ecfcf9fffd..1563f7e1b36 100644 --- a/src/core/layout/qgslayoutitemlabel.cpp +++ b/src/core/layout/qgslayoutitemlabel.cpp @@ -102,6 +102,11 @@ int QgsLayoutItemLabel::type() const return QgsLayoutItemRegistry::LayoutLabel; } +QIcon QgsLayoutItemLabel::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemLabel.svg" ) ); +} + void QgsLayoutItemLabel::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * ) { QPainter *painter = context.painter(); diff --git a/src/core/layout/qgslayoutitemlabel.h b/src/core/layout/qgslayoutitemlabel.h index 46cc3b66c45..6ed0b422e53 100644 --- a/src/core/layout/qgslayoutitemlabel.h +++ b/src/core/layout/qgslayoutitemlabel.h @@ -57,6 +57,7 @@ class CORE_EXPORT QgsLayoutItemLabel: public QgsLayoutItem static QgsLayoutItemLabel *create( QgsLayout *layout ) SIP_FACTORY; int type() const override; + QIcon icon() const override; //Overridden to contain part of label's text QString displayName() const override; diff --git a/src/core/layout/qgslayoutitemlegend.cpp b/src/core/layout/qgslayoutitemlegend.cpp index 5487da8310c..990696fd015 100644 --- a/src/core/layout/qgslayoutitemlegend.cpp +++ b/src/core/layout/qgslayoutitemlegend.cpp @@ -58,6 +58,11 @@ int QgsLayoutItemLegend::type() const return QgsLayoutItemRegistry::LayoutLegend; } +QIcon QgsLayoutItemLegend::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemLegend.svg" ) ); +} + void QgsLayoutItemLegend::paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) { if ( !painter ) diff --git a/src/core/layout/qgslayoutitemlegend.h b/src/core/layout/qgslayoutitemlegend.h index cfdd0b1fa35..86104e0dcf2 100644 --- a/src/core/layout/qgslayoutitemlegend.h +++ b/src/core/layout/qgslayoutitemlegend.h @@ -77,6 +77,7 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem static QgsLayoutItemLegend *create( QgsLayout *layout ) SIP_FACTORY; int type() const override; + QIcon icon() const override; //Overridden to show legend title QString displayName() const override; diff --git a/src/core/layout/qgslayoutitemmap.cpp b/src/core/layout/qgslayoutitemmap.cpp index f2dd99a4f7c..476fc250090 100644 --- a/src/core/layout/qgslayoutitemmap.cpp +++ b/src/core/layout/qgslayoutitemmap.cpp @@ -75,6 +75,11 @@ int QgsLayoutItemMap::type() const return QgsLayoutItemRegistry::LayoutMap; } +QIcon QgsLayoutItemMap::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemMap.svg" ) ); +} + void QgsLayoutItemMap::assignFreeId() { if ( !mLayout ) diff --git a/src/core/layout/qgslayoutitemmap.h b/src/core/layout/qgslayoutitemmap.h index 6ef1012ddb9..c9ab4192659 100644 --- a/src/core/layout/qgslayoutitemmap.h +++ b/src/core/layout/qgslayoutitemmap.h @@ -70,6 +70,7 @@ class CORE_EXPORT QgsLayoutItemMap : public QgsLayoutItem ~QgsLayoutItemMap() override; int type() const override; + QIcon icon() const override; /** * Sets the map id() to a number not yet used in the layout. The existing id() is kept if it is not in use. diff --git a/src/core/layout/qgslayoutitempicture.cpp b/src/core/layout/qgslayoutitempicture.cpp index 3ee42d684d5..4ccb50e8966 100644 --- a/src/core/layout/qgslayoutitempicture.cpp +++ b/src/core/layout/qgslayoutitempicture.cpp @@ -71,6 +71,11 @@ int QgsLayoutItemPicture::type() const return QgsLayoutItemRegistry::LayoutPicture; } +QIcon QgsLayoutItemPicture::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemPicture.svg" ) ); +} + QgsLayoutItemPicture *QgsLayoutItemPicture::create( QgsLayout *layout ) { return new QgsLayoutItemPicture( layout ); diff --git a/src/core/layout/qgslayoutitempicture.h b/src/core/layout/qgslayoutitempicture.h index 22053f905f7..2e8d2c5dcd3 100644 --- a/src/core/layout/qgslayoutitempicture.h +++ b/src/core/layout/qgslayoutitempicture.h @@ -71,6 +71,7 @@ class CORE_EXPORT QgsLayoutItemPicture: public QgsLayoutItem QgsLayoutItemPicture( QgsLayout *layout ); int type() const override; + QIcon icon() const override; /** * Returns a new picture item for the specified \a layout. diff --git a/src/core/layout/qgslayoutitempolygon.cpp b/src/core/layout/qgslayoutitempolygon.cpp index b2f38f1a79d..1aafd0f44dd 100644 --- a/src/core/layout/qgslayoutitempolygon.cpp +++ b/src/core/layout/qgslayoutitempolygon.cpp @@ -47,6 +47,11 @@ int QgsLayoutItemPolygon::type() const return QgsLayoutItemRegistry::LayoutPolygon; } +QIcon QgsLayoutItemPolygon::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemPolygon.svg" ) ); +} + bool QgsLayoutItemPolygon::_addNode( const int indexPoint, QPointF newPoint, const double radius ) diff --git a/src/core/layout/qgslayoutitempolygon.h b/src/core/layout/qgslayoutitempolygon.h index 32ac8064e62..cd1ea6af338 100644 --- a/src/core/layout/qgslayoutitempolygon.h +++ b/src/core/layout/qgslayoutitempolygon.h @@ -52,6 +52,7 @@ class CORE_EXPORT QgsLayoutItemPolygon: public QgsLayoutNodesItem static QgsLayoutItemPolygon *create( QgsLayout *layout ) SIP_FACTORY; int type() const override; + QIcon icon() const override; QString displayName() const override; /** diff --git a/src/core/layout/qgslayoutitempolyline.cpp b/src/core/layout/qgslayoutitempolyline.cpp index fee04c18996..311217859ce 100644 --- a/src/core/layout/qgslayoutitempolyline.cpp +++ b/src/core/layout/qgslayoutitempolyline.cpp @@ -48,6 +48,11 @@ int QgsLayoutItemPolyline::type() const return QgsLayoutItemRegistry::LayoutPolyline; } +QIcon QgsLayoutItemPolyline::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemPolyline.svg" ) ); +} + bool QgsLayoutItemPolyline::_addNode( const int indexPoint, QPointF newPoint, const double radius ) diff --git a/src/core/layout/qgslayoutitempolyline.h b/src/core/layout/qgslayoutitempolyline.h index d16c90b31f6..30315c3a702 100644 --- a/src/core/layout/qgslayoutitempolyline.h +++ b/src/core/layout/qgslayoutitempolyline.h @@ -59,6 +59,7 @@ class CORE_EXPORT QgsLayoutItemPolyline: public QgsLayoutNodesItem static QgsLayoutItemPolyline *create( QgsLayout *layout ) SIP_FACTORY; int type() const override; + QIcon icon() const override; QString displayName() const override; /** diff --git a/src/core/layout/qgslayoutitemscalebar.cpp b/src/core/layout/qgslayoutitemscalebar.cpp index 6e2e07fe58d..18717f6031b 100644 --- a/src/core/layout/qgslayoutitemscalebar.cpp +++ b/src/core/layout/qgslayoutitemscalebar.cpp @@ -52,6 +52,11 @@ int QgsLayoutItemScaleBar::type() const return QgsLayoutItemRegistry::LayoutScaleBar; } +QIcon QgsLayoutItemScaleBar::icon() const +{ + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemScaleBar.svg" ) ); +} + QgsLayoutItemScaleBar *QgsLayoutItemScaleBar::create( QgsLayout *layout ) { return new QgsLayoutItemScaleBar( layout ); diff --git a/src/core/layout/qgslayoutitemscalebar.h b/src/core/layout/qgslayoutitemscalebar.h index f4db3d516ae..3697b089ef2 100644 --- a/src/core/layout/qgslayoutitemscalebar.h +++ b/src/core/layout/qgslayoutitemscalebar.h @@ -44,6 +44,7 @@ class CORE_EXPORT QgsLayoutItemScaleBar: public QgsLayoutItem QgsLayoutItemScaleBar( QgsLayout *layout ); int type() const override; + QIcon icon() const override; /** * Returns a new scale bar item for the specified \a layout. diff --git a/src/core/layout/qgslayoutitemshape.cpp b/src/core/layout/qgslayoutitemshape.cpp index 8ef9f5c0097..0f59aec24fb 100644 --- a/src/core/layout/qgslayoutitemshape.cpp +++ b/src/core/layout/qgslayoutitemshape.cpp @@ -59,6 +59,21 @@ int QgsLayoutItemShape::type() const return QgsLayoutItemRegistry::LayoutShape; } +QIcon QgsLayoutItemShape::icon() const +{ + switch ( mShape ) + { + case Ellipse: + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemShapeEllipse.svg" ) ); + case Rectangle: + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemShapeRectangle.svg" ) ); + case Triangle: + return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItemShapeTriangle.svg" ) ); + } + + return QIcon(); +} + QString QgsLayoutItemShape::displayName() const { if ( !id().isEmpty() ) diff --git a/src/core/layout/qgslayoutitemshape.h b/src/core/layout/qgslayoutitemshape.h index a2e4fde334e..e0495587c46 100644 --- a/src/core/layout/qgslayoutitemshape.h +++ b/src/core/layout/qgslayoutitemshape.h @@ -50,6 +50,7 @@ class CORE_EXPORT QgsLayoutItemShape : public QgsLayoutItem explicit QgsLayoutItemShape( QgsLayout *layout ); int type() const override; + QIcon icon() const override; //Overridden to return shape type QString displayName() const override; diff --git a/src/core/layout/qgslayoutmodel.cpp b/src/core/layout/qgslayoutmodel.cpp index c0ba1788136..3ff07c63a51 100644 --- a/src/core/layout/qgslayoutmodel.cpp +++ b/src/core/layout/qgslayoutmodel.cpp @@ -139,6 +139,16 @@ QVariant QgsLayoutModel::data( const QModelIndex &index, int role ) const return QVariant(); } + case Qt::DecorationRole: + if ( index.column() == ItemId ) + { + return item->icon(); + } + else + { + return QVariant(); + } + case Qt::EditRole: if ( index.column() == ItemId ) { diff --git a/src/core/layout/qgslayoutmultiframe.h b/src/core/layout/qgslayoutmultiframe.h index 82d7a286c72..8b6cef3b3de 100644 --- a/src/core/layout/qgslayoutmultiframe.h +++ b/src/core/layout/qgslayoutmultiframe.h @@ -20,6 +20,7 @@ #include "qgis.h" #include "qgslayoutobject.h" #include "qgslayoutundocommand.h" +#include #include #include #include @@ -102,6 +103,11 @@ class CORE_EXPORT QgsLayoutMultiFrame: public QgsLayoutObject, public QgsLayoutU */ virtual int type() const = 0; + /** + * Returns the item's icon. + */ + virtual QIcon icon() const { return QgsApplication::getThemeIcon( QStringLiteral( "/mLayoutItem.svg" ) ); } + /** * Returns the fixed size for a frame, if desired. If the fixed frame size changes, * the sizes of all frames can be recalculated by calling recalculateFrameRects().