@@ -43,16 +43,16 @@ void QgsCompositionConverter::initPropertyDefinitions()
43
43
{
44
44
{ QgsCompositionConverter::TestProperty, QgsPropertyDefinition ( " dataDefinedProperty" , QgsPropertyDefinition::DataTypeString, " invalid property" , QString () ) },
45
45
{
46
- QgsCompositionConverter::PresetPaperSize, QgsPropertyDefinition ( " dataDefinedPaperSize" , QgsPropertyDefinition::DataTypeString, QObject::tr ( " Paper size" ), QObject::tr ( " string " ) + QLatin1String ( " [<b>A5</b>|<b>A4</b>|<b>A3</b>|<b>A2</b>|<b>A1</b>|<b>A0</b>"
46
+ QgsCompositionConverter::PresetPaperSize, QgsPropertyDefinition ( " dataDefinedPaperSize" , QgsPropertyDefinition::DataTypeString, QObject::tr ( " Paper size" ), QObject::tr ( " string " ) + QStringLiteral ( " [<b>A5</b>|<b>A4</b>|<b>A3</b>|<b>A2</b>|<b>A1</b>|<b>A0</b>"
47
47
" <b>B5</b>|<b>B4</b>|<b>B3</b>|<b>B2</b>|<b>B1</b>|<b>B0</b>"
48
48
" <b>Legal</b>|<b>Ansi A</b>|<b>Ansi B</b>|<b>Ansi C</b>|<b>Ansi D</b>|<b>Ansi E</b>"
49
49
" <b>Arch A</b>|<b>Arch B</b>|<b>Arch C</b>|<b>Arch D</b>|<b>Arch E</b>|<b>Arch E1</b>]"
50
- ) )
50
+ ) )
51
51
},
52
52
{ QgsCompositionConverter::PaperWidth, QgsPropertyDefinition ( " dataDefinedPaperWidth" , QObject::tr ( " Page width" ), QgsPropertyDefinition::DoublePositive ) },
53
53
{ QgsCompositionConverter::PaperHeight, QgsPropertyDefinition ( " dataDefinedPaperHeight" , QObject::tr ( " Page height" ), QgsPropertyDefinition::DoublePositive ) },
54
54
{ QgsCompositionConverter::NumPages, QgsPropertyDefinition ( " dataDefinedNumPages" , QObject::tr ( " Number of pages" ), QgsPropertyDefinition::IntegerPositive ) },
55
- { QgsCompositionConverter::PaperOrientation, QgsPropertyDefinition ( " dataDefinedPaperOrientation" , QgsPropertyDefinition::DataTypeString, QObject::tr ( " Symbol size" ), QObject::tr ( " string " ) + QLatin1String ( " [<b>portrait</b>|<b>landscape</b>]" ) ) },
55
+ { QgsCompositionConverter::PaperOrientation, QgsPropertyDefinition ( " dataDefinedPaperOrientation" , QgsPropertyDefinition::DataTypeString, QObject::tr ( " Symbol size" ), QObject::tr ( " string " ) + QStringLiteral ( " [<b>portrait</b>|<b>landscape</b>]" ) ) },
56
56
{ QgsCompositionConverter::PageNumber, QgsPropertyDefinition ( " dataDefinedPageNumber" , QObject::tr ( " Page number" ), QgsPropertyDefinition::IntegerPositive ) },
57
57
{ QgsCompositionConverter::PositionX, QgsPropertyDefinition ( " dataDefinedPositionX" , QObject::tr ( " Position (X)" ), QgsPropertyDefinition::Double ) },
58
58
{ QgsCompositionConverter::PositionY, QgsPropertyDefinition ( " dataDefinedPositionY" , QObject::tr ( " Position (Y)" ), QgsPropertyDefinition::Double ) },
@@ -145,6 +145,29 @@ void QgsCompositionConverter::adjustPos( QgsLayout *layout, QgsLayoutItem *layou
145
145
layoutItem->setZValue ( layoutItem->zValue () + zOrderOffset );
146
146
}
147
147
148
+ void QgsCompositionConverter::restoreGeneralComposeItemProperties ( QgsLayoutItem *layoutItem, const QDomElement &itemElem )
149
+ {
150
+ // restore general composer item properties
151
+ QDomNodeList composerItemList = itemElem.elementsByTagName ( QStringLiteral ( " ComposerItem" ) );
152
+ if ( !composerItemList.isEmpty () )
153
+ {
154
+ QDomElement composerItemElem = composerItemList.at ( 0 ).toElement ();
155
+
156
+ // rotation
157
+ if ( !qgsDoubleNear ( composerItemElem.attribute ( QStringLiteral ( " rotation" ), QStringLiteral ( " 0" ) ).toDouble (), 0.0 ) )
158
+ {
159
+ // check for old (pre 2.1) rotation attribute
160
+ layoutItem->setItemRotation ( composerItemElem.attribute ( QStringLiteral ( " rotation" ), QStringLiteral ( " 0" ) ).toDouble (), false );
161
+ }
162
+
163
+ QgsCompositionConverter::readXml ( layoutItem, composerItemElem );
164
+
165
+ // Frame color
166
+
167
+ // Background color
168
+ }
169
+ }
170
+
148
171
QList<QgsLayoutItem *> QgsCompositionConverter::addItemsFromCompositionXml ( QgsLayout *layout, const QDomElement &parentElement, const QgsReadWriteContext &context, QPointF *position, bool pasteInPlace )
149
172
{
150
173
@@ -227,6 +250,8 @@ bool QgsCompositionConverter::readLabelXml( QgsLayoutItemLabel *label, const QDo
227
250
return false ;
228
251
}
229
252
253
+ restoreGeneralComposeItemProperties ( label, itemElem );
254
+
230
255
// restore label specific properties
231
256
232
257
// text
@@ -277,21 +302,6 @@ bool QgsCompositionConverter::readLabelXml( QgsLayoutItemLabel *label, const QDo
277
302
label->setFontColor ( QColor ( 0 , 0 , 0 ) );
278
303
}
279
304
280
- // restore general composer item properties
281
- QDomNodeList composerItemList = itemElem.elementsByTagName ( QStringLiteral ( " ComposerItem" ) );
282
- if ( !composerItemList.isEmpty () )
283
- {
284
- QDomElement composerItemElem = composerItemList.at ( 0 ).toElement ();
285
-
286
- // rotation
287
- if ( !qgsDoubleNear ( composerItemElem.attribute ( QStringLiteral ( " rotation" ), QStringLiteral ( " 0" ) ).toDouble (), 0.0 ) )
288
- {
289
- // check for old (pre 2.1) rotation attribute
290
- label->setItemRotation ( composerItemElem.attribute ( QStringLiteral ( " rotation" ), QStringLiteral ( " 0" ) ).toDouble (), false );
291
- }
292
-
293
- QgsCompositionConverter::readXml ( label, composerItemElem );
294
- }
295
305
return true ;
296
306
}
297
307
@@ -300,30 +310,24 @@ bool QgsCompositionConverter::readShapeXml( QgsLayoutItemShape *layoutItem, cons
300
310
layoutItem->setShapeType ( static_cast <QgsLayoutItemShape::Shape>( itemElem.attribute ( QStringLiteral ( " shapeType" ), QStringLiteral ( " 0" ) ).toInt () ) );
301
311
layoutItem->setCornerRadius ( QgsLayoutMeasurement ( itemElem.attribute ( QStringLiteral ( " cornerRadius" ), QStringLiteral ( " 0" ) ).toDouble () ) );
302
312
303
- // restore general composer item properties
304
- QDomNodeList composerItemList = itemElem.elementsByTagName ( QStringLiteral ( " ComposerItem" ) );
305
- if ( !composerItemList.isEmpty () )
306
- {
307
- QDomElement composerItemElem = composerItemList.at ( 0 ).toElement ();
308
-
309
- // rotation
310
- if ( !qgsDoubleNear ( composerItemElem.attribute ( QStringLiteral ( " rotation" ), QStringLiteral ( " 0" ) ).toDouble (), 0.0 ) )
311
- {
312
- // check for old (pre 2.1) rotation attribute
313
- layoutItem->setItemRotation ( composerItemElem.attribute ( QStringLiteral ( " rotation" ), QStringLiteral ( " 0" ) ).toDouble () );
314
- }
313
+ restoreGeneralComposeItemProperties ( layoutItem, itemElem );
315
314
316
- readXml ( layoutItem, composerItemElem );
317
- }
318
315
319
316
QgsReadWriteContext context;
320
317
context.setPathResolver ( QgsProject::instance ()->pathResolver () );
321
318
319
+ if ( itemElem.elementsByTagName ( QStringLiteral ( " symbol" ) ).size () )
320
+ {
321
+ QDomElement symbolElement = itemElem.elementsByTagName ( QStringLiteral ( " symbol" ) ).at ( 0 ).toElement ();
322
+ QgsFillSymbol *shapeStyleSymbol = QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( symbolElement, context );
323
+ if ( shapeStyleSymbol )
324
+ layoutItem->setSymbol ( shapeStyleSymbol );
325
+ } /*
322
326
QDomElement shapeStyleSymbolElem = itemElem.firstChildElement( QStringLiteral( "symbol" ) );
323
327
if ( !shapeStyleSymbolElem.isNull() )
324
328
{
325
329
layoutItem->setSymbol( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( shapeStyleSymbolElem, context ) );
326
- }
330
+ } */
327
331
else
328
332
{
329
333
// upgrade project file from 2.0 to use symbol styling
@@ -399,6 +403,8 @@ bool QgsCompositionConverter::readShapeXml( QgsLayoutItemShape *layoutItem, cons
399
403
400
404
layoutItem->setSymbol ( QgsFillSymbol::createSimple ( properties ) );
401
405
}
406
+
407
+ return true ;
402
408
}
403
409
404
410
@@ -418,23 +424,23 @@ bool QgsCompositionConverter::readXml( QgsLayoutItem *layoutItem, const QDomElem
418
424
layoutItem->mTemplateUuid = itemElem.attribute ( QStringLiteral ( " templateUuid" ) );
419
425
420
426
// id
421
- QString id = itemElem.attribute ( QStringLiteral ( " id" ), QLatin1String ( " " ) );
427
+ QString id = itemElem.attribute ( QStringLiteral ( " id" ), QStringLiteral ( " " ) );
422
428
layoutItem->setId ( id );
423
429
424
430
// frame
425
431
QString frame = itemElem.attribute ( QStringLiteral ( " frame" ) );
426
- layoutItem->setFrameEnabled ( frame.compare ( QLatin1String ( " true" ), Qt::CaseInsensitive ) == 0 ) ;
432
+ layoutItem->setFrameEnabled ( frame.compare ( QStringLiteral ( " true" ), Qt::CaseInsensitive ) == 0 ) ;
427
433
428
434
// frame
429
435
QString background = itemElem.attribute ( QStringLiteral ( " background" ) );
430
- layoutItem->setBackgroundEnabled ( background.compare ( QLatin1String ( " true" ), Qt::CaseInsensitive ) == 0 );
436
+ layoutItem->setBackgroundEnabled ( background.compare ( QStringLiteral ( " true" ), Qt::CaseInsensitive ) == 0 );
431
437
432
438
// position lock for mouse moves/resizes
433
439
QString positionLock = itemElem.attribute ( QStringLiteral ( " positionLock" ) );
434
- layoutItem->setLocked ( positionLock.compare ( QLatin1String ( " true" ), Qt::CaseInsensitive ) == 0 );
440
+ layoutItem->setLocked ( positionLock.compare ( QStringLiteral ( " true" ), Qt::CaseInsensitive ) == 0 );
435
441
436
442
// visibility
437
- layoutItem->setVisibility ( itemElem.attribute ( QStringLiteral ( " visibility" ), QStringLiteral ( " 1" ) ) != QLatin1String ( " 0" ) );
443
+ layoutItem->setVisibility ( itemElem.attribute ( QStringLiteral ( " visibility" ), QStringLiteral ( " 1" ) ) != QStringLiteral ( " 0" ) );
438
444
439
445
layoutItem->mParentGroupUuid = itemElem.attribute ( QStringLiteral ( " groupUuid" ) );
440
446
if ( !layoutItem->mParentGroupUuid .isEmpty () )
@@ -636,7 +642,7 @@ QgsProperty QgsCompositionConverter::readOldDataDefinedProperty( const QgsCompos
636
642
637
643
QString active = ddElem.attribute ( QStringLiteral ( " active" ) );
638
644
bool isActive = false ;
639
- if ( active.compare ( QLatin1String ( " true" ), Qt::CaseInsensitive ) == 0 )
645
+ if ( active.compare ( QStringLiteral ( " true" ), Qt::CaseInsensitive ) == 0 )
640
646
{
641
647
isActive = true ;
642
648
}
@@ -645,7 +651,7 @@ QgsProperty QgsCompositionConverter::readOldDataDefinedProperty( const QgsCompos
645
651
646
652
QString useExpr = ddElem.attribute ( QStringLiteral ( " useExpr" ) );
647
653
bool isExpression = false ;
648
- if ( useExpr.compare ( QLatin1String ( " true" ), Qt::CaseInsensitive ) == 0 )
654
+ if ( useExpr.compare ( QStringLiteral ( " true" ), Qt::CaseInsensitive ) == 0 )
649
655
{
650
656
isExpression = true ;
651
657
}
0 commit comments