mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Remove outdated icon support for item metadata
Now handled in QgsLayoutItem directly
This commit is contained in:
parent
aafe1cc477
commit
49eaebbf40
@ -40,11 +40,6 @@ and ``visibleName``.
|
||||
int type() const;
|
||||
%Docstring
|
||||
Returns the unique item type code for the layout item class.
|
||||
%End
|
||||
|
||||
virtual QIcon icon() const;
|
||||
%Docstring
|
||||
Returns an icon representing the layout item type.
|
||||
%End
|
||||
|
||||
QString visibleName() const;
|
||||
|
@ -56,29 +56,29 @@ bool QgsLayoutItemRegistry::populate()
|
||||
return new TestLayoutItem( layout );
|
||||
};
|
||||
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 1002, QStringLiteral( "temp type" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLabel.svg" ) ), createTemporaryItem ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 1002, QStringLiteral( "temp type" ), createTemporaryItem ) );
|
||||
#endif
|
||||
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutGroup, QObject::tr( "Group" ), QIcon(), QgsLayoutItemGroup::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutFrame, QObject::tr( "Frame" ), QIcon(), QgsLayoutFrame::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPage, QObject::tr( "Page" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionFileNew.svg" ) ), QgsLayoutItemPage::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutMap, QObject::tr( "Map" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddMap.svg" ) ), QgsLayoutItemMap::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPicture, QObject::tr( "Picture" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddImage.svg" ) ), QgsLayoutItemPicture::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLabel, QObject::tr( "Label" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionLabel.svg" ) ), QgsLayoutItemLabel::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLegend, QObject::tr( "Legend" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLegend.svg" ) ), QgsLayoutItemLegend::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutScaleBar, QObject::tr( "Scalebar" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionScaleBar.svg" ) ), QgsLayoutItemScaleBar::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutShape, QObject::tr( "Shape" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ), []( QgsLayout * layout )
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutGroup, QObject::tr( "Group" ), QgsLayoutItemGroup::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutFrame, QObject::tr( "Frame" ), QgsLayoutFrame::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPage, QObject::tr( "Page" ), QgsLayoutItemPage::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutMap, QObject::tr( "Map" ), QgsLayoutItemMap::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPicture, QObject::tr( "Picture" ), QgsLayoutItemPicture::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLabel, QObject::tr( "Label" ), QgsLayoutItemLabel::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutLegend, QObject::tr( "Legend" ), QgsLayoutItemLegend::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutScaleBar, QObject::tr( "Scalebar" ), QgsLayoutItemScaleBar::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutShape, QObject::tr( "Shape" ), []( QgsLayout * layout )
|
||||
{
|
||||
QgsLayoutItemShape *shape = new QgsLayoutItemShape( layout );
|
||||
shape->setShapeType( QgsLayoutItemShape::Rectangle );
|
||||
return shape;
|
||||
} ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolygon, QObject::tr( "Polygon" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolygon.svg" ) ), QgsLayoutItemPolygon::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolyline, QObject::tr( "Polyline" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddPolyline.svg" ) ), QgsLayoutItemPolyline::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolygon, QObject::tr( "Polygon" ), QgsLayoutItemPolygon::create ) );
|
||||
addLayoutItemType( new QgsLayoutItemMetadata( LayoutPolyline, QObject::tr( "Polyline" ), QgsLayoutItemPolyline::create ) );
|
||||
|
||||
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutHtml, QObject::tr( "HTML" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddHtml.svg" ) ), QgsLayoutItemHtml::create ) );
|
||||
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutAttributeTable, QObject::tr( "Attribute Table" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddTable.svg" ) ), QgsLayoutItemAttributeTable::create ) );
|
||||
addLayoutMultiFrameType( new QgsLayoutMultiFrameMetadata( LayoutTextTable, QObject::tr( "Text Table" ), QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddTable.svg" ) ), QgsLayoutItemTextTable::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 ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -62,11 +62,6 @@ class CORE_EXPORT QgsLayoutItemAbstractMetadata
|
||||
*/
|
||||
int type() const { return mType; }
|
||||
|
||||
/**
|
||||
* Returns an icon representing the layout item type.
|
||||
*/
|
||||
virtual QIcon icon() const { return QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ); }
|
||||
|
||||
/**
|
||||
* Returns a translated, user visible name for the layout item class.
|
||||
*/
|
||||
@ -119,11 +114,10 @@ class CORE_EXPORT QgsLayoutItemMetadata : public QgsLayoutItemAbstractMetadata
|
||||
* Constructor for QgsLayoutItemMetadata with the specified class \a type
|
||||
* and \a visibleName, and function pointers for the various item creation functions.
|
||||
*/
|
||||
QgsLayoutItemMetadata( int type, const QString &visibleName, const QIcon &icon,
|
||||
QgsLayoutItemMetadata( int type, const QString &visibleName,
|
||||
QgsLayoutItemCreateFunc pfCreate,
|
||||
QgsLayoutItemPathResolverFunc pfPathResolver = nullptr )
|
||||
: QgsLayoutItemAbstractMetadata( type, visibleName )
|
||||
, mIcon( icon )
|
||||
, mCreateFunc( pfCreate )
|
||||
, mPathResolverFunc( pfPathResolver )
|
||||
{}
|
||||
@ -138,7 +132,6 @@ class CORE_EXPORT QgsLayoutItemMetadata : public QgsLayoutItemAbstractMetadata
|
||||
*/
|
||||
QgsLayoutItemPathResolverFunc pathResolverFunction() const { return mPathResolverFunc; }
|
||||
|
||||
QIcon icon() const override { return mIcon.isNull() ? QgsLayoutItemAbstractMetadata::icon() : mIcon; }
|
||||
QgsLayoutItem *createItem( QgsLayout *layout ) override { return mCreateFunc ? mCreateFunc( layout ) : nullptr; }
|
||||
|
||||
void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) override
|
||||
@ -148,7 +141,6 @@ class CORE_EXPORT QgsLayoutItemMetadata : public QgsLayoutItemAbstractMetadata
|
||||
}
|
||||
|
||||
protected:
|
||||
QIcon mIcon;
|
||||
QgsLayoutItemCreateFunc mCreateFunc = nullptr;
|
||||
QgsLayoutItemPathResolverFunc mPathResolverFunc = nullptr;
|
||||
|
||||
@ -243,11 +235,10 @@ class CORE_EXPORT QgsLayoutMultiFrameMetadata : public QgsLayoutMultiFrameAbstra
|
||||
* Constructor for QgsLayoutMultiFrameMetadata with the specified class \a type
|
||||
* and \a visibleName, and function pointers for the various item creation functions.
|
||||
*/
|
||||
QgsLayoutMultiFrameMetadata( int type, const QString &visibleName, const QIcon &icon,
|
||||
QgsLayoutMultiFrameMetadata( int type, const QString &visibleName,
|
||||
QgsLayoutMultiFrameCreateFunc pfCreate,
|
||||
QgsLayoutMultiFramePathResolverFunc pfPathResolver = nullptr )
|
||||
: QgsLayoutMultiFrameAbstractMetadata( type, visibleName )
|
||||
, mIcon( icon )
|
||||
, mCreateFunc( pfCreate )
|
||||
, mPathResolverFunc( pfPathResolver )
|
||||
{}
|
||||
@ -262,7 +253,6 @@ class CORE_EXPORT QgsLayoutMultiFrameMetadata : public QgsLayoutMultiFrameAbstra
|
||||
*/
|
||||
QgsLayoutMultiFramePathResolverFunc pathResolverFunction() const { return mPathResolverFunc; }
|
||||
|
||||
QIcon icon() const override { return mIcon.isNull() ? QgsLayoutMultiFrameAbstractMetadata::icon() : mIcon; }
|
||||
QgsLayoutMultiFrame *createMultiFrame( QgsLayout *layout ) override { return mCreateFunc ? mCreateFunc( layout ) : nullptr; }
|
||||
|
||||
void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving ) override
|
||||
@ -272,7 +262,6 @@ class CORE_EXPORT QgsLayoutMultiFrameMetadata : public QgsLayoutMultiFrameAbstra
|
||||
}
|
||||
|
||||
protected:
|
||||
QIcon mIcon;
|
||||
QgsLayoutMultiFrameCreateFunc mCreateFunc = nullptr;
|
||||
QgsLayoutMultiFramePathResolverFunc mPathResolverFunc = nullptr;
|
||||
|
||||
|
@ -257,7 +257,7 @@ void TestQgsLayoutItem::registry()
|
||||
|
||||
QSignalSpy spyTypeAdded( ®istry, &QgsLayoutItemRegistry::typeAdded );
|
||||
|
||||
QgsLayoutItemMetadata *metadata = new QgsLayoutItemMetadata( 2, QStringLiteral( "my type" ), QIcon(), create, resolve );
|
||||
QgsLayoutItemMetadata *metadata = new QgsLayoutItemMetadata( 2, QStringLiteral( "my type" ), create, resolve );
|
||||
QVERIFY( registry.addLayoutItemType( metadata ) );
|
||||
QCOMPARE( spyTypeAdded.count(), 1 );
|
||||
QCOMPARE( spyTypeAdded.value( 0 ).at( 0 ).toInt(), 2 );
|
||||
|
@ -530,7 +530,7 @@ void TestQgsLayoutMultiFrame::registry()
|
||||
|
||||
QSignalSpy spyTypeAdded( ®istry, &QgsLayoutItemRegistry::multiFrameTypeAdded );
|
||||
|
||||
QgsLayoutMultiFrameMetadata *metadata = new QgsLayoutMultiFrameMetadata( QgsLayoutItemRegistry::PluginItem + 1, QStringLiteral( "TestMultiFrame" ), QIcon(), create, resolve );
|
||||
QgsLayoutMultiFrameMetadata *metadata = new QgsLayoutMultiFrameMetadata( QgsLayoutItemRegistry::PluginItem + 1, QStringLiteral( "TestMultiFrame" ), create, resolve );
|
||||
QVERIFY( registry.addLayoutMultiFrameType( metadata ) );
|
||||
QCOMPARE( spyTypeAdded.count(), 1 );
|
||||
QCOMPARE( spyTypeAdded.value( 0 ).at( 0 ).toInt(), QgsLayoutItemRegistry::PluginItem + 1 );
|
||||
|
@ -320,7 +320,7 @@ void TestQgsLayoutView::guiRegistry()
|
||||
//creating item
|
||||
QgsLayoutItem *item = registry.createItem( uuid, nullptr );
|
||||
QVERIFY( !item );
|
||||
QgsApplication::layoutItemRegistry()->addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 101, QStringLiteral( "my type" ), QIcon(), []( QgsLayout * layout )->QgsLayoutItem*
|
||||
QgsApplication::layoutItemRegistry()->addLayoutItemType( new QgsLayoutItemMetadata( QgsLayoutItemRegistry::LayoutItem + 101, QStringLiteral( "my type" ), []( QgsLayout * layout )->QgsLayoutItem*
|
||||
{
|
||||
return new TestItem( layout );
|
||||
} ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user