Skip to content

Commit 49eaebb

Browse files
committedJan 5, 2018
Remove outdated icon support for item metadata
Now handled in QgsLayoutItem directly
1 parent aafe1cc commit 49eaebb

File tree

6 files changed

+20
-36
lines changed

6 files changed

+20
-36
lines changed
 

‎python/core/layout/qgslayoutitemregistry.sip

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ and ``visibleName``.
4040
int type() const;
4141
%Docstring
4242
Returns the unique item type code for the layout item class.
43-
%End
44-
45-
virtual QIcon icon() const;
46-
%Docstring
47-
Returns an icon representing the layout item type.
4843
%End
4944

5045
QString visibleName() const;

‎src/core/layout/qgslayoutitemregistry.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,29 @@ bool QgsLayoutItemRegistry::populate()
5656
return new TestLayoutItem( layout );
5757
};
5858

59-
addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 1002, QStringLiteral( "temp type" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLabel.svg" ) ), createTemporaryItem ) );
59+
addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 1002, QStringLiteral( "temp type" ), createTemporaryItem ) );
6060
#endif
6161

62-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutGroup, QObject::tr( "Group" ), QIcon(), QgsLayoutItemGroup::create ) );
63-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutFrame, QObject::tr( "Frame" ), QIcon(), QgsLayoutFrame::create ) );
64-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPage, QObject::tr( "Page" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionFileNew.svg" ) ), QgsLayoutItemPage::create ) );
65-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutMap, QObject::tr( "Map" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddMap.svg" ) ), QgsLayoutItemMap::create ) );
66-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPicture, QObject::tr( "Picture" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddImage.svg" ) ), QgsLayoutItemPicture::create ) );
67-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLabel, QObject::tr( "Label" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionLabel.svg" ) ), QgsLayoutItemLabel::create ) );
68-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLegend, QObject::tr( "Legend" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLegend.svg" ) ), QgsLayoutItemLegend::create ) );
69-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutScaleBar, QObject::tr( "Scalebar" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionScaleBar.svg" ) ), QgsLayoutItemScaleBar::create ) );
70-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutShape, QObject::tr( "Shape" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ), []( QgsLayout * layout )
62+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutGroup, QObject::tr( "Group" ), QgsLayoutItemGroup::create ) );
63+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutFrame, QObject::tr( "Frame" ), QgsLayoutFrame::create ) );
64+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPage, QObject::tr( "Page" ), QgsLayoutItemPage::create ) );
65+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutMap, QObject::tr( "Map" ), QgsLayoutItemMap::create ) );
66+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPicture, QObject::tr( "Picture" ), QgsLayoutItemPicture::create ) );
67+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLabel, QObject::tr( "Label" ), QgsLayoutItemLabel::create ) );
68+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLegend, QObject::tr( "Legend" ), QgsLayoutItemLegend::create ) );
69+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutScaleBar, QObject::tr( "Scalebar" ), QgsLayoutItemScaleBar::create ) );
70+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutShape, QObject::tr( "Shape" ), []( QgsLayout * layout )
7171
{
7272
QgsLayoutItemShape *shape = new QgsLayoutItemShape( layout );
7373
shape->setShapeType( QgsLayoutItemShape::Rectangle );
7474
return shape;
7575
} ) );
76-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolygon, QObject::tr( "Polygon" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolygon.svg" ) ), QgsLayoutItemPolygon::create ) );
77-
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolyline, QObject::tr( "Polyline" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolyline.svg" ) ), QgsLayoutItemPolyline::create ) );
76+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolygon, QObject::tr( "Polygon" ), QgsLayoutItemPolygon::create ) );
77+
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolyline, QObject::tr( "Polyline" ), QgsLayoutItemPolyline::create ) );
7878

79-
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutHtml, QObject::tr( "HTML" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddHtml.svg" ) ), QgsLayoutItemHtml::create ) );
80-
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutAttributeTable, QObject::tr( "Attribute Table" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddTable.svg" ) ), QgsLayoutItemAttributeTable::create ) );
81-
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutTextTable, QObject::tr( "Text Table" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddTable.svg" ) ), QgsLayoutItemTextTable::create ) );
79+
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutHtml, QObject::tr( "HTML" ), QgsLayoutItemHtml::create ) );
80+
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutAttributeTable, QObject::tr( "Attribute Table" ), QgsLayoutItemAttributeTable::create ) );
81+
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutTextTable, QObject::tr( "Text Table" ), QgsLayoutItemTextTable::create ) );
8282

8383
return true;
8484
}

‎src/core/layout/qgslayoutitemregistry.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ class CORE_EXPORT QgsLayoutItemAbstractMetadata
6262
*/
6363
int type() const { return mType; }
6464

65-
/**
66-
* Returns an icon representing the layout item type.
67-
*/
68-
virtual QIcon icon() const { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ); }
69-
7065
/**
7166
* Returns a translated, user visible name for the layout item class.
7267
*/
@@ -119,11 +114,10 @@ class CORE_EXPORT QgsLayoutItemMetadata : public QgsLayoutItemAbstractMetadata
119114
* Constructor for QgsLayoutItemMetadata with the specified class \a type
120115
* and \a visibleName, and function pointers for the various item creation functions.
121116
*/
122-
QgsLayoutItemMetadata( int type, const QString &visibleName, const QIcon &icon,
117+
QgsLayoutItemMetadata( int type, const QString &visibleName,
123118
QgsLayoutItemCreateFunc pfCreate,
124119
QgsLayoutItemPathResolverFunc pfPathResolver = nullptr )
125120
: QgsLayoutItemAbstractMetadata( type, visibleName )
126-
, mIcon( icon )
127121
, mCreateFunc( pfCreate )
128122
, mPathResolverFunc( pfPathResolver )
129123
{}
@@ -138,7 +132,6 @@ class CORE_EXPORT QgsLayoutItemMetadata : public QgsLayoutItemAbstractMetadata
138132
*/
139133
QgsLayoutItemPathResolverFunc pathResolverFunction() const { return mPathResolverFunc; }
140134

141-
QIcon icon() const override { return mIcon.isNull() ? QgsLayoutItemAbstractMetadata::icon() : mIcon; }
142135
QgsLayoutItem *createItem( QgsLayout *layout ) override { return mCreateFunc ? mCreateFunc( layout ) : nullptr; }
143136

144137
void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) override
@@ -148,7 +141,6 @@ class CORE_EXPORT QgsLayoutItemMetadata : public QgsLayoutItemAbstractMetadata
148141
}
149142

150143
protected:
151-
QIcon mIcon;
152144
QgsLayoutItemCreateFunc mCreateFunc = nullptr;
153145
QgsLayoutItemPathResolverFunc mPathResolverFunc = nullptr;
154146

@@ -243,11 +235,10 @@ class CORE_EXPORT QgsLayoutMultiFrameMetadata : public QgsLayoutMultiFrameAbstra
243235
* Constructor for QgsLayoutMultiFrameMetadata with the specified class \a type
244236
* and \a visibleName, and function pointers for the various item creation functions.
245237
*/
246-
QgsLayoutMultiFrameMetadata( int type, const QString &visibleName, const QIcon &icon,
238+
QgsLayoutMultiFrameMetadata( int type, const QString &visibleName,
247239
QgsLayoutMultiFrameCreateFunc pfCreate,
248240
QgsLayoutMultiFramePathResolverFunc pfPathResolver = nullptr )
249241
: QgsLayoutMultiFrameAbstractMetadata( type, visibleName )
250-
, mIcon( icon )
251242
, mCreateFunc( pfCreate )
252243
, mPathResolverFunc( pfPathResolver )
253244
{}
@@ -262,7 +253,6 @@ class CORE_EXPORT QgsLayoutMultiFrameMetadata : public QgsLayoutMultiFrameAbstra
262253
*/
263254
QgsLayoutMultiFramePathResolverFunc pathResolverFunction() const { return mPathResolverFunc; }
264255

265-
QIcon icon() const override { return mIcon.isNull() ? QgsLayoutMultiFrameAbstractMetadata::icon() : mIcon; }
266256
QgsLayoutMultiFrame *createMultiFrame( QgsLayout *layout ) override { return mCreateFunc ? mCreateFunc( layout ) : nullptr; }
267257

268258
void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) override
@@ -272,7 +262,6 @@ class CORE_EXPORT QgsLayoutMultiFrameMetadata : public QgsLayoutMultiFrameAbstra
272262
}
273263

274264
protected:
275-
QIcon mIcon;
276265
QgsLayoutMultiFrameCreateFunc mCreateFunc = nullptr;
277266
QgsLayoutMultiFramePathResolverFunc mPathResolverFunc = nullptr;
278267

‎tests/src/core/testqgslayoutitem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void TestQgsLayoutItem::registry()
257257

258258
QSignalSpy spyTypeAdded( &registry, &QgsLayoutItemRegistry::typeAdded );
259259

260-
QgsLayoutItemMetadata *metadata = new QgsLayoutItemMetadata( 2, QStringLiteral( "my type" ), QIcon(), create, resolve );
260+
QgsLayoutItemMetadata *metadata = new QgsLayoutItemMetadata( 2, QStringLiteral( "my type" ), create, resolve );
261261
QVERIFY( registry.addLayoutItemType( metadata ) );
262262
QCOMPARE( spyTypeAdded.count(), 1 );
263263
QCOMPARE( spyTypeAdded.value( 0 ).at( 0 ).toInt(), 2 );

‎tests/src/core/testqgslayoutmultiframe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ void TestQgsLayoutMultiFrame::registry()
530530

531531
QSignalSpy spyTypeAdded( &registry, &QgsLayoutItemRegistry::multiFrameTypeAdded );
532532

533-
QgsLayoutMultiFrameMetadata *metadata = new QgsLayoutMultiFrameMetadata( QgsLayoutItemRegistry::PluginItem + 1, QStringLiteral( "TestMultiFrame" ), QIcon(), create, resolve );
533+
QgsLayoutMultiFrameMetadata *metadata = new QgsLayoutMultiFrameMetadata( QgsLayoutItemRegistry::PluginItem + 1, QStringLiteral( "TestMultiFrame" ), create, resolve );
534534
QVERIFY( registry.addLayoutMultiFrameType( metadata ) );
535535
QCOMPARE( spyTypeAdded.count(), 1 );
536536
QCOMPARE( spyTypeAdded.value( 0 ).at( 0 ).toInt(), QgsLayoutItemRegistry::PluginItem + 1 );

‎tests/src/gui/testqgslayoutview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void TestQgsLayoutView::guiRegistry()
320320
//creating item
321321
QgsLayoutItem *item = registry.createItem( uuid, nullptr );
322322
QVERIFY( !item );
323-
QgsApplication::layoutItemRegistry()->addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 101, QStringLiteral( "my type" ), QIcon(), []( QgsLayout * layout )->QgsLayoutItem*
323+
QgsApplication::layoutItemRegistry()->addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 101, QStringLiteral( "my type" ), []( QgsLayout * layout )->QgsLayoutItem*
324324
{
325325
return new TestItem( layout );
326326
} ) );

0 commit comments

Comments
 (0)
Please sign in to comment.