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