File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,10 @@ bool QgsLayoutNorthArrowValidityCheck::prepareCheck( const QgsValidityCheckConte
105
105
layoutContext->layout ->layoutItems ( pictureItems );
106
106
for ( QgsLayoutItemPicture *picture : qgis::as_const ( pictureItems ) )
107
107
{
108
- // look for pictures which use the default north arrow svg, but aren't actually linked to maps
109
- if ( !picture->linkedMap () && picture->picturePath () == QStringLiteral ( " :/images/north_arrows/layout_default_north_arrow.svg" ) )
108
+ // look for pictures which use the default north arrow svg, but aren't actually linked to maps.
109
+ // alternatively identify them by looking for the default "North Arrow" string in their id
110
+ if ( !picture->linkedMap () && ( picture->picturePath () == QStringLiteral ( " :/images/north_arrows/layout_default_north_arrow.svg" )
111
+ || picture->id ().contains ( QObject::tr ( " North Arrow" ), Qt::CaseInsensitive ) ) )
110
112
{
111
113
QgsValidityCheckResult res;
112
114
res.type = QgsValidityCheckResult::Warning;
Original file line number Diff line number Diff line change @@ -134,6 +134,24 @@ void TestQgsLayoutValidityChecks::testNorthArrowValidity()
134
134
QVERIFY ( check2.prepareCheck ( &context, &f ) );
135
135
res = check2.runCheck ( &context, &f );
136
136
QCOMPARE ( res.size (), 0 );
137
+
138
+ // test with ID check
139
+ picture->setPicturePath ( QStringLiteral ( " a" ) );
140
+ picture->setId ( QStringLiteral ( " north arrow 2" ) );
141
+ picture->setLinkedMap ( nullptr );
142
+
143
+ QgsLayoutNorthArrowValidityCheck check3;
144
+ QVERIFY ( check3.prepareCheck ( &context, &f ) );
145
+ res = check3.runCheck ( &context, &f );
146
+ QCOMPARE ( res.size (), 1 );
147
+ QCOMPARE ( res.at ( 0 ).type , QgsValidityCheckResult::Warning );
148
+
149
+ // no longer looks like a north arrow
150
+ picture->setId ( QStringLiteral ( " a" ) );
151
+ QgsLayoutNorthArrowValidityCheck check4;
152
+ QVERIFY ( check4.prepareCheck ( &context, &f ) );
153
+ res = check4.runCheck ( &context, &f );
154
+ QCOMPARE ( res.size (), 0 );
137
155
}
138
156
139
157
void TestQgsLayoutValidityChecks::testOverviewValidity ()
You can’t perform that action at this time.
0 commit comments