QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgscompositionconverter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgscompositionconverter.cpp - QgsCompositionConverter
3 
4  ---------------------
5  begin : 13.12.2017
6  copyright : (C) 2017 by Alessandro Pasotti
7  email : elpaso at itopen dot it
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include <QObject>
18 
20 #include "qgsreadwritecontext.h"
21 #include "qgslayertree.h"
22 #include "qgslayoutmodel.h"
23 #include "qgslayoutitemgroup.h"
24 #include "qgslayoutobject.h"
25 #include "qgsfontutils.h"
26 #include "qgspainting.h"
27 #include "qgsproperty.h"
28 #include "qgssymbollayerutils.h"
29 #include "qgssymbollayer.h"
30 #include "qgsproject.h"
32 #include "qgsvectorlayer.h"
33 #include "qgslinesymbollayer.h"
34 
35 #include "qgsprintlayout.h"
36 #include "qgslayoutatlas.h"
37 
38 #include "qgslayoutundostack.h"
40 #include "qgslayoutitemregistry.h"
41 #include "qgslayoutitemlabel.h"
42 #include "qgslayoutitemshape.h"
43 #include "qgslayoutitempicture.h"
44 #include "qgslayoutitempolygon.h"
45 #include "qgslayoutitempolyline.h"
46 #include "qgslayoutitemmap.h"
47 #include "qgslayoutitemmapgrid.h"
48 #include "qgslayoutitemscalebar.h"
49 #include "qgslayoutitemlegend.h"
50 #include "qgslayoutitemhtml.h"
51 #include "qgslayouttable.h"
53 #include "qgslayouttablecolumn.h"
54 #include "qgslayoutmultiframe.h"
55 #include "qgslayoutframe.h"
58 
59 QgsPropertiesDefinition QgsCompositionConverter::sPropertyDefinitions;
60 
61 void QgsCompositionConverter::initPropertyDefinitions()
62 {
63  if ( !sPropertyDefinitions.isEmpty() )
64  return;
65 
66  sPropertyDefinitions = QgsPropertiesDefinition
67  {
68  { QgsCompositionConverter::TestProperty, QgsPropertyDefinition( "dataDefinedProperty", QgsPropertyDefinition::DataTypeString, "invalid property", QString() ) },
69  {
70  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>"
71  "|<b>B5</b>|<b>B4</b>|<b>B3</b>|<b>B2</b>|<b>B1</b>|<b>B0</b>"
72  "|<b>Legal</b>|<b>Ansi A</b>|<b>Ansi B</b>|<b>Ansi C</b>|<b>Ansi D</b>|<b>Ansi E</b>"
73  "|<b>Arch A</b>|<b>Arch B</b>|<b>Arch C</b>|<b>Arch D</b>|<b>Arch E</b>|<b>Arch E1</b>]"
74  ) )
75  },
76  { QgsCompositionConverter::PaperWidth, QgsPropertyDefinition( "dataDefinedPaperWidth", QObject::tr( "Page width" ), QgsPropertyDefinition::DoublePositive ) },
77  { QgsCompositionConverter::PaperHeight, QgsPropertyDefinition( "dataDefinedPaperHeight", QObject::tr( "Page height" ), QgsPropertyDefinition::DoublePositive ) },
78  { QgsCompositionConverter::NumPages, QgsPropertyDefinition( "dataDefinedNumPages", QObject::tr( "Number of pages" ), QgsPropertyDefinition::IntegerPositive ) },
79  { QgsCompositionConverter::PaperOrientation, QgsPropertyDefinition( "dataDefinedPaperOrientation", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), QObject::tr( "string " ) + QStringLiteral( "[<b>portrait</b>|<b>landscape</b>]" ) ) },
80  { QgsCompositionConverter::PageNumber, QgsPropertyDefinition( "dataDefinedPageNumber", QObject::tr( "Page number" ), QgsPropertyDefinition::IntegerPositive ) },
81  { QgsCompositionConverter::PositionX, QgsPropertyDefinition( "dataDefinedPositionX", QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double ) },
82  { QgsCompositionConverter::PositionY, QgsPropertyDefinition( "dataDefinedPositionY", QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double ) },
84  { QgsCompositionConverter::ItemHeight, QgsPropertyDefinition( "dataDefinedHeight", QObject::tr( "Height" ), QgsPropertyDefinition::DoublePositive ) },
85  { QgsCompositionConverter::ItemRotation, QgsPropertyDefinition( "dataDefinedRotation", QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Rotation ) },
86  { QgsCompositionConverter::Transparency, QgsPropertyDefinition( "dataDefinedTransparency", QObject::tr( "Transparency" ), QgsPropertyDefinition::Opacity ) },
87  { QgsCompositionConverter::Opacity, QgsPropertyDefinition( "dataDefinedOpacity", QObject::tr( "Opacity" ), QgsPropertyDefinition::Opacity ) },
88  { QgsCompositionConverter::BlendMode, QgsPropertyDefinition( "dataDefinedBlendMode", QObject::tr( "Blend mode" ), QgsPropertyDefinition::BlendMode ) },
89  { QgsCompositionConverter::ExcludeFromExports, QgsPropertyDefinition( "dataDefinedExcludeExports", QObject::tr( "Exclude item from exports" ), QgsPropertyDefinition::Boolean ) },
90  { QgsCompositionConverter::FrameColor, QgsPropertyDefinition( "dataDefinedFrameColor", QObject::tr( "Frame color" ), QgsPropertyDefinition::ColorWithAlpha ) },
91  { QgsCompositionConverter::BackgroundColor, QgsPropertyDefinition( "dataDefinedBackgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
92  { QgsCompositionConverter::MapRotation, QgsPropertyDefinition( "dataDefinedMapRotation", QObject::tr( "Map rotation" ), QgsPropertyDefinition::Rotation ) },
93  { QgsCompositionConverter::MapScale, QgsPropertyDefinition( "dataDefinedMapScale", QObject::tr( "Map scale" ), QgsPropertyDefinition::DoublePositive ) },
94  { QgsCompositionConverter::MapXMin, QgsPropertyDefinition( "dataDefinedMapXMin", QObject::tr( "Extent minimum X" ), QgsPropertyDefinition::Double ) },
95  { QgsCompositionConverter::MapYMin, QgsPropertyDefinition( "dataDefinedMapYMin", QObject::tr( "Extent minimum Y" ), QgsPropertyDefinition::Double ) },
96  { QgsCompositionConverter::MapXMax, QgsPropertyDefinition( "dataDefinedMapXMax", QObject::tr( "Extent maximum X" ), QgsPropertyDefinition::Double ) },
97  { QgsCompositionConverter::MapYMax, QgsPropertyDefinition( "dataDefinedMapYMax", QObject::tr( "Extent maximum Y" ), QgsPropertyDefinition::Double ) },
98  { QgsCompositionConverter::MapAtlasMargin, QgsPropertyDefinition( "dataDefinedMapAtlasMargin", QObject::tr( "Atlas margin" ), QgsPropertyDefinition::DoublePositive ) },
99  { QgsCompositionConverter::MapLayers, QgsPropertyDefinition( "dataDefinedMapLayers", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), QObject::tr( "list of map layer names separated by | characters" ) ) },
100  { QgsCompositionConverter::MapStylePreset, QgsPropertyDefinition( "dataDefinedMapStylePreset", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), QObject::tr( "list of map layer names separated by | characters" ) ) },
101  { QgsCompositionConverter::PictureSource, QgsPropertyDefinition( "dataDefinedSource", QObject::tr( "Picture source (URL)" ), QgsPropertyDefinition::String ) },
102  { QgsCompositionConverter::SourceUrl, QgsPropertyDefinition( "dataDefinedSourceUrl", QObject::tr( "Source URL" ), QgsPropertyDefinition::String ) },
103  { QgsCompositionConverter::PictureSvgBackgroundColor, QgsPropertyDefinition( "dataDefinedSvgBackgroundColor", QObject::tr( "SVG background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
104  { QgsCompositionConverter::PictureSvgStrokeColor, QgsPropertyDefinition( "dataDefinedSvgStrokeColor", QObject::tr( "SVG stroke color" ), QgsPropertyDefinition::ColorWithAlpha ) },
105  { QgsCompositionConverter::PictureSvgStrokeWidth, QgsPropertyDefinition( "dataDefinedSvgStrokeWidth", QObject::tr( "SVG stroke width" ), QgsPropertyDefinition::StrokeWidth ) },
106  { QgsCompositionConverter::LegendTitle, QgsPropertyDefinition( "dataDefinedLegendTitle", QObject::tr( "Legend title" ), QgsPropertyDefinition::String ) },
107  { QgsCompositionConverter::LegendColumnCount, QgsPropertyDefinition( "dataDefinedLegendColumns", QObject::tr( "Number of columns" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) },
108  { QgsCompositionConverter::ScalebarFillColor, QgsPropertyDefinition( "dataDefinedScalebarFill", QObject::tr( "Fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
109  { QgsCompositionConverter::ScalebarFillColor2, QgsPropertyDefinition( "dataDefinedScalebarFill2", QObject::tr( "Secondary fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
110  { QgsCompositionConverter::ScalebarLineColor, QgsPropertyDefinition( "dataDefinedScalebarLineColor", QObject::tr( "Line color" ), QgsPropertyDefinition::ColorWithAlpha ) },
111  { QgsCompositionConverter::ScalebarLineWidth, QgsPropertyDefinition( "dataDefinedScalebarLineWidth", QObject::tr( "Line width" ), QgsPropertyDefinition::StrokeWidth ) },
112  };
113 }
114 
115 QgsPropertiesDefinition QgsCompositionConverter::propertyDefinitions()
116 {
117  QgsCompositionConverter::initPropertyDefinitions();
118  return sPropertyDefinitions;
119 }
120 
121 
122 std::unique_ptr< QgsPrintLayout > QgsCompositionConverter::createLayoutFromCompositionXml( const QDomElement &composerElement, QgsProject *project )
123 {
124  initPropertyDefinitions();
125 
126  QDomElement parentElement = composerElement.parentNode().toElement();
127 
128  std::unique_ptr< QgsPrintLayout > layout = qgis::make_unique< QgsPrintLayout >( project );
129  layout->undoStack()->blockCommands( true );
130 
131  layout->mCustomProperties.readXml( composerElement );
132 
133  // Guides
134  layout->guides().setVisible( composerElement.attribute( QStringLiteral( "guidesVisible" ), QStringLiteral( "1" ) ).toInt() != 0 );
135 
136  int printResolution = composerElement.attribute( QStringLiteral( "printResolution" ), QStringLiteral( "300" ) ).toInt();
137  layout->renderContext().setDpi( printResolution );
138 
139  // Create pages
140  int pages = composerElement.attribute( QStringLiteral( "numPages" ) ).toInt( );
141  float paperHeight = composerElement.attribute( QStringLiteral( "paperHeight" ) ).toDouble( );
142  float paperWidth = composerElement.attribute( QStringLiteral( "paperWidth" ) ).toDouble( );
143 
144  QString name = composerElement.attribute( QStringLiteral( "name" ) );
145  // Try title
146  if ( name.isEmpty() )
147  name = composerElement.attribute( QStringLiteral( "title" ) );
148  // Try title on parent element
149  if ( name.isEmpty() )
150  name = parentElement.attribute( QStringLiteral( "title" ) );
151  layout->setName( name );
152  QgsLayoutSize pageSize( paperWidth, paperHeight );
153  for ( int j = 0; j < pages; j++ )
154  {
155  QgsLayoutItemPage *page = QgsLayoutItemPage::create( layout.get() );
156  page->setPageSize( pageSize );
157  layout->pageCollection()->addPage( page );
158  //custom snap lines
159  QDomNodeList snapLineNodes = composerElement.elementsByTagName( QStringLiteral( "SnapLine" ) );
160  for ( int i = 0; i < snapLineNodes.size(); ++i )
161  {
162  QDomElement snapLineElem = snapLineNodes.at( i ).toElement();
163  double x1 = snapLineElem.attribute( QStringLiteral( "x1" ) ).toDouble();
164  double y1 = snapLineElem.attribute( QStringLiteral( "y1" ) ).toDouble();
165  double x2 = snapLineElem.attribute( QStringLiteral( "x2" ) ).toDouble();
166  // Not necessary: double y2 = snapLineElem.attribute( QStringLiteral( "y2" ) ).toDouble();
167  Qt::Orientation orientation( x1 == x2 ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal );
168  QgsLayoutMeasurement position( x1 == x2 ? x1 : y1 );
169  std::unique_ptr< QgsLayoutGuide > guide = qgis::make_unique< QgsLayoutGuide >( orientation, position, page );
170  layout->guides().addGuide( guide.release() );
171  }
172  }
173 
174 
175  if ( composerElement.elementsByTagName( QStringLiteral( "symbol" ) ).size() )
176  {
177  QDomElement symbolElement = composerElement.elementsByTagName( QStringLiteral( "symbol" ) ).at( 0 ).toElement();
178  QgsReadWriteContext context;
179  if ( project )
180  context.setPathResolver( project->pathResolver() );
181  std::unique_ptr< QgsFillSymbol > symbol( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( symbolElement, context ) );
182  if ( symbol )
183  layout->pageCollection()->setPageStyleSymbol( symbol.get() );
184  }
185 
186  addItemsFromCompositionXml( layout.get(), composerElement );
187 
188  // Read atlas from the parent element (Composer)
189  if ( parentElement.elementsByTagName( QStringLiteral( "Atlas" ) ).size() )
190  {
191  QDomElement atlasElement = parentElement.elementsByTagName( QStringLiteral( "Atlas" ) ).at( 0 ).toElement();
192  readAtlasXml( layout->atlas(), atlasElement, layout->project() );
193  }
194 
195  layout->undoStack()->blockCommands( false );
196  return layout;
197 }
198 
199 
200 void QgsCompositionConverter::adjustPos( QgsPrintLayout *layout, QgsLayoutItem *layoutItem, QPointF *position, bool &pasteInPlace, int zOrderOffset, QPointF &pasteShiftPos, int &pageNumber )
201 {
202  if ( position )
203  {
204  if ( pasteInPlace )
205  {
206  layoutItem->attemptMove( QgsLayoutPoint( *position ), true, false, pageNumber );
207  }
208  else
209  {
210  layoutItem->attemptMoveBy( pasteShiftPos.x(), pasteShiftPos.y() );
211  }
212  }
213 
214  if ( !layoutItem->scene() )
215  layout->addLayoutItem( layoutItem );
216  layoutItem->setZValue( layoutItem->zValue() + zOrderOffset );
217 }
218 
219 void QgsCompositionConverter::restoreGeneralComposeItemProperties( QgsLayoutItem *layoutItem, const QDomElement &itemElem )
220 {
221  //restore general composer item properties
222  QDomNodeList composerItemList = itemElem.elementsByTagName( QStringLiteral( "ComposerItem" ) );
223  if ( !composerItemList.isEmpty() )
224  {
225  QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
226 
227  //rotation
228  if ( !qgsDoubleNear( composerItemElem.attribute( QStringLiteral( "rotation" ), QStringLiteral( "0" ) ).toDouble(), 0.0 ) )
229  {
230  //check for old (pre 2.1) rotation attribute
231  layoutItem->setItemRotation( composerItemElem.attribute( QStringLiteral( "rotation" ), QStringLiteral( "0" ) ).toDouble(), false );
232  }
233  QgsCompositionConverter::readXml( layoutItem, composerItemElem );
234  }
235 }
236 
237 QRectF QgsCompositionConverter::itemPosition( QgsLayoutItem *layoutItem, const QDomElement &itemElem )
238 {
239  int page;
240  double x, y, pagex, pagey, width, height;
241  bool xOk, yOk, pageOk, pagexOk, pageyOk, widthOk, heightOk, positionModeOk;
242 
243  x = itemElem.attribute( QStringLiteral( "x" ) ).toDouble( &xOk );
244  y = itemElem.attribute( QStringLiteral( "y" ) ).toDouble( &yOk );
245  page = itemElem.attribute( QStringLiteral( "page" ) ).toInt( &pageOk );
246  pagex = itemElem.attribute( QStringLiteral( "pagex" ) ).toDouble( &pagexOk );
247  pagey = itemElem.attribute( QStringLiteral( "pagey" ) ).toDouble( &pageyOk );
248  width = itemElem.attribute( QStringLiteral( "width" ) ).toDouble( &widthOk );
249  height = itemElem.attribute( QStringLiteral( "height" ) ).toDouble( &heightOk );
250 
251 
252  layoutItem->mReferencePoint = static_cast< QgsLayoutItem::ReferencePoint >( itemElem.attribute( QStringLiteral( "positionMode" ) ).toInt( &positionModeOk ) );
253  if ( !positionModeOk )
254  {
255  layoutItem->setReferencePoint( QgsLayoutItem::ReferencePoint::UpperLeft );
256  }
257 
258  if ( pageOk && pagexOk && pageyOk )
259  {
260  xOk = true;
261  yOk = true;
262  x = pagex;
263  // position in the page (1-based)
264  if ( page <= layoutItem->layout()->pageCollection()->pageCount() )
265  {
266  QgsLayoutItemPage *pageObject = layoutItem->layout()->pageCollection()->pages().at( page - 1 );
267  y = ( page - 1 )
268  * ( pageObject->sizeWithUnits().height()
269  + layoutItem->layout()->pageCollection()->spaceBetweenPages() )
270  + pagey;
271  }
272  else
273  {
274  y = pagey;
275  }
276  }
277  return QRectF( x, y, width, height );
278 }
279 
280 QPointF QgsCompositionConverter::minPointFromXml( const QDomElement &elem )
281 {
282  double minX = std::numeric_limits<double>::max();
283  double minY = std::numeric_limits<double>::max();
284  QDomNodeList composerItemList = elem.elementsByTagName( QStringLiteral( "ComposerItem" ) );
285  for ( int i = 0; i < composerItemList.size(); ++i )
286  {
287  QDomElement currentComposerItemElem = composerItemList.at( i ).toElement();
288  double x, y;
289  bool xOk, yOk;
290  x = currentComposerItemElem.attribute( QStringLiteral( "x" ) ).toDouble( &xOk );
291  y = currentComposerItemElem.attribute( QStringLiteral( "y" ) ).toDouble( &yOk );
292  if ( !xOk || !yOk )
293  {
294  continue;
295  }
296  minX = std::min( minX, x );
297  minY = std::min( minY, y );
298  }
299  if ( minX < std::numeric_limits<double>::max() )
300  {
301  return QPointF( minX, minY );
302  }
303  else
304  {
305  return QPointF( 0, 0 );
306  }
307 }
308 
309 QList<QgsLayoutObject *> QgsCompositionConverter::addItemsFromCompositionXml( QgsPrintLayout *layout, const QDomElement &parentElement, QPointF *position, bool pasteInPlace )
310 {
311 
312  initPropertyDefinitions();
313 
314  QList< QgsLayoutObject * > newItems;
315 
316  //if we are adding items to a layout which already contains items, we need to make sure
317  //these items are placed at the top of the layout and that zValues are not duplicated
318  //so, calculate an offset which needs to be added to the zValue of created items
319  int zOrderOffset = layout->mItemsModel->zOrderListSize();
320 
321  QPointF pasteShiftPos;
322  int pageNumber = -1;
323  if ( position )
324  {
325  //If we are placing items relative to a certain point, then calculate how much we need
326  //to shift the items by so that they are placed at this point
327  //First, calculate the minimum position from the xml
328  QPointF minItemPos = minPointFromXml( parentElement );
329  //next, calculate how much each item needs to be shifted from its original position
330  //so that it's placed at the correct relative position
331  pasteShiftPos = *position - minItemPos;
332  if ( pasteInPlace )
333  {
334  pageNumber = layout->mPageCollection->pageNumberForPoint( *position );
335  }
336  }
337 
338  QgsStringMap mapIdUiidMap;
339 
340  // Map (this needs to come first to build the uuid <-> ID map for map composer items
341  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerMap" ) ).size(); i++ )
342  {
343  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerMap" ) ).at( i ) );
344  QgsLayoutItemMap *layoutItem = new QgsLayoutItemMap( layout );
345  readMapXml( layoutItem, itemNode.toElement(), layout->project(), mapIdUiidMap );
346  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
347  newItems << layoutItem ;
348  }
349 
350  // Label
351  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerLabel" ) ).size(); i++ )
352  {
353  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerLabel" ) ).at( i ) );
354  QgsLayoutItemLabel *layoutItem = new QgsLayoutItemLabel( layout );
355  readLabelXml( layoutItem, itemNode.toElement(), layout->project() );
356  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
357  newItems << layoutItem ;
358  }
359 
360  // Shape
361  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerShape" ) ).size(); i++ )
362  {
363  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerShape" ) ).at( i ) );
364  QgsLayoutItemShape *layoutItem = new QgsLayoutItemShape( layout );
365  readShapeXml( layoutItem, itemNode.toElement(), layout->project() );
366  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
367  newItems << layoutItem ;
368  }
369 
370  // Picture
371  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerPicture" ) ).size(); i++ )
372  {
373  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerPicture" ) ).at( i ) );
374  QgsLayoutItemPicture *layoutItem = new QgsLayoutItemPicture( layout );
375  readPictureXml( layoutItem, itemNode.toElement(), layout->project(), mapIdUiidMap );
376  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
377  newItems << layoutItem ;
378  }
379 
380  // Polygon
381  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerPolygon" ) ).size(); i++ )
382  {
383  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerPolygon" ) ).at( i ) );
384  QgsLayoutItemPolygon *layoutItem = new QgsLayoutItemPolygon( layout );
385  readPolyXml<QgsLayoutItemPolygon, QgsFillSymbol>( layoutItem, itemNode.toElement(), layout->project() );
386  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
387  newItems << layoutItem ;
388  }
389 
390  // Polyline
391  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerPolyline" ) ).size(); i++ )
392  {
393  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerPolyline" ) ).at( i ) );
394  QgsLayoutItemPolyline *layoutItem = new QgsLayoutItemPolyline( layout );
395  readPolyXml<QgsLayoutItemPolyline, QgsLineSymbol>( layoutItem, itemNode.toElement(), layout->project() );
396  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
397  newItems << layoutItem ;
398  }
399 
400  // Arrow
401  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerArrow" ) ).size(); i++ )
402  {
403  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerArrow" ) ).at( i ) );
404  QgsLayoutItemPolyline *layoutItem = new QgsLayoutItemPolyline( layout );
405  readArrowXml( layoutItem, itemNode.toElement(), layout->project() );
406  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
407  newItems << layoutItem ;
408  }
409 
410  // Scalebar
411  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerScaleBar" ) ).size(); i++ )
412  {
413  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerScaleBar" ) ).at( i ) );
414  QgsLayoutItemScaleBar *layoutItem = new QgsLayoutItemScaleBar( layout );
415  readScaleBarXml( layoutItem, itemNode.toElement(), layout->project(), mapIdUiidMap );
416  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
417  newItems << layoutItem ;
418  }
419 
420  // Legend
421  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerLegend" ) ).size(); i++ )
422  {
423  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerLegend" ) ).at( i ) );
424  QgsLayoutItemLegend *layoutItem = new QgsLayoutItemLegend( layout );
425  readLegendXml( layoutItem, itemNode.toElement(), layout->project(), mapIdUiidMap );
426  adjustPos( layout, layoutItem, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
427  newItems << layoutItem ;
428  }
429 
430  // Html
431  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerHtml" ) ).size(); i++ )
432  {
433  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerHtml" ) ).at( i ) );
434  QgsLayoutItemHtml *layoutItem = new QgsLayoutItemHtml( layout );
435  readHtmlXml( layoutItem, itemNode.toElement(), layout->project() );
436  // Adjust position for frames
437  const QList<QgsLayoutFrame *> framesList( layoutItem->frames() );
438  for ( const auto &frame : framesList )
439  {
440  adjustPos( layout, frame, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
441  }
442  newItems << layoutItem ;
443  }
444 
445  // Attribute Table
446  for ( int i = 0; i < parentElement.elementsByTagName( QStringLiteral( "ComposerAttributeTableV2" ) ).size(); i++ )
447  {
448  QDomNode itemNode( parentElement.elementsByTagName( QStringLiteral( "ComposerAttributeTableV2" ) ).at( i ) );
449  QgsLayoutItemAttributeTable *layoutItem = new QgsLayoutItemAttributeTable( layout );
450  readTableXml( layoutItem, itemNode.toElement(), layout->project() );
451  // Adjust position for frames
452  const QList<QgsLayoutFrame *> framesList( layoutItem->frames() );
453  for ( const auto &frame : framesList )
454  {
455  adjustPos( layout, frame, position, pasteInPlace, zOrderOffset, pasteShiftPos, pageNumber );
456  }
457  newItems << layoutItem ;
458  }
459 
460  return newItems;
461 }
462 
463 bool QgsCompositionConverter::isCompositionTemplate( const QDomDocument &document )
464 {
465  return document.elementsByTagName( QStringLiteral( "Composition" ) ).count() > 0;
466 }
467 
468 QDomDocument QgsCompositionConverter::convertCompositionTemplate( const QDomDocument &document, QgsProject *project )
469 {
470  QDomDocument doc;
471  QgsReadWriteContext context;
472  if ( project )
473  context.setPathResolver( project->pathResolver() );
474  if ( document.elementsByTagName( QStringLiteral( "Composition" ) ).count( ) > 0 )
475  {
476  QDomElement composerElem = document.elementsByTagName( QStringLiteral( "Composition" ) ).at( 0 ).toElement( );
477 
478  std::unique_ptr<QgsLayout> layout = createLayoutFromCompositionXml( composerElem,
479  project );
480  QDomElement elem = layout->writeXml( doc, context );
481  doc.appendChild( elem );
482  }
483  return doc;
484 }
485 
486 bool QgsCompositionConverter::readLabelXml( QgsLayoutItemLabel *layoutItem, const QDomElement &itemElem, const QgsProject *project )
487 {
488  Q_UNUSED( project )
489  if ( itemElem.isNull() )
490  {
491  return false;
492  }
493 
494  restoreGeneralComposeItemProperties( layoutItem, itemElem );
495 
496  //text
497  layoutItem->setText( itemElem.attribute( QStringLiteral( "labelText" ) ) );
498 
499  //html state
500  layoutItem->setMode( itemElem.attribute( QStringLiteral( "htmlState" ) ).toInt() == Qt::Checked ? QgsLayoutItemLabel::Mode::ModeHtml : QgsLayoutItemLabel::Mode::ModeFont );
501 
502  //margin
503  bool marginXOk = false;
504  bool marginYOk = false;
505  double marginX = itemElem.attribute( QStringLiteral( "marginX" ) ).toDouble( &marginXOk );
506  double marginY = itemElem.attribute( QStringLiteral( "marginY" ) ).toDouble( &marginYOk );
507  if ( !marginXOk || !marginYOk )
508  {
509  //upgrade old projects where margins where stored in a single attribute
510  double margin = itemElem.attribute( QStringLiteral( "margin" ), QStringLiteral( "1.0" ) ).toDouble();
511  marginX = margin;
512  marginY = margin;
513  }
514  layoutItem->setMarginX( marginX );
515  layoutItem->setMarginY( marginY );
516 
517  //Horizontal alignment
518  layoutItem->setHAlign( static_cast< Qt::AlignmentFlag >( itemElem.attribute( QStringLiteral( "halign" ) ).toInt() ) );
519 
520  //Vertical alignment
521  layoutItem->setVAlign( static_cast< Qt::AlignmentFlag >( itemElem.attribute( QStringLiteral( "valign" ) ).toInt() ) );
522 
523 
524  QFont font;
525  //font
526  QgsFontUtils::setFromXmlChildNode( font, itemElem, QStringLiteral( "LabelFont" ) );
527  layoutItem->setFont( font );
528 
529  //font color
530  QDomNodeList fontColorList = itemElem.elementsByTagName( QStringLiteral( "FontColor" ) );
531  if ( !fontColorList.isEmpty() )
532  {
533  QDomElement fontColorElem = fontColorList.at( 0 ).toElement();
534  int red = fontColorElem.attribute( QStringLiteral( "red" ), QStringLiteral( "0" ) ).toInt();
535  int green = fontColorElem.attribute( QStringLiteral( "green" ), QStringLiteral( "0" ) ).toInt();
536  int blue = fontColorElem.attribute( QStringLiteral( "blue" ), QStringLiteral( "0" ) ).toInt();
537  layoutItem->setFontColor( QColor( red, green, blue ) );
538  }
539  else
540  {
541  layoutItem->setFontColor( QColor( 0, 0, 0 ) );
542  }
543 
544  return true;
545 }
546 
547 bool QgsCompositionConverter::readShapeXml( QgsLayoutItemShape *layoutItem, const QDomElement &itemElem, const QgsProject *project )
548 {
549  Q_UNUSED( project )
550  layoutItem->setShapeType( static_cast<QgsLayoutItemShape::Shape>( itemElem.attribute( QStringLiteral( "shapeType" ), QStringLiteral( "0" ) ).toInt() ) );
551  layoutItem->setCornerRadius( QgsLayoutMeasurement( itemElem.attribute( QStringLiteral( "cornerRadius" ), QStringLiteral( "0" ) ).toDouble() ) );
552 
553  restoreGeneralComposeItemProperties( layoutItem, itemElem );
554 
555  QgsReadWriteContext context;
556  if ( project )
557  context.setPathResolver( project->pathResolver() );
558 
559  if ( itemElem.elementsByTagName( QStringLiteral( "symbol" ) ).size() )
560  {
561  QDomElement symbolElement = itemElem.elementsByTagName( QStringLiteral( "symbol" ) ).at( 0 ).toElement();
562  std::unique_ptr< QgsFillSymbol > shapeStyleSymbol( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( symbolElement, context ) );
563  if ( shapeStyleSymbol )
564  layoutItem->setSymbol( shapeStyleSymbol.get() );
565  }
566  else
567  {
568  //upgrade project file from 2.0 to use symbol styling
569  QgsStringMap properties;
570  properties.insert( QStringLiteral( "color" ), QgsSymbolLayerUtils::encodeColor( layoutItem->brush().color() ) );
571  if ( layoutItem->hasBackground() )
572  {
573  properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) );
574  }
575  else
576  {
577  properties.insert( QStringLiteral( "style" ), QStringLiteral( "no" ) );
578  }
579  if ( layoutItem->frameEnabled() )
580  {
581  properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "solid" ) );
582  }
583  else
584  {
585  properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "no" ) );
586  }
587  properties.insert( QStringLiteral( "color_border" ), QgsSymbolLayerUtils::encodeColor( layoutItem->pen().color() ) );
588  properties.insert( QStringLiteral( "width_border" ), QString::number( layoutItem->pen().widthF() ) );
589 
590  //for pre 2.0 projects, shape color and outline were specified in a different element...
591  QDomNodeList outlineColorList = itemElem.elementsByTagName( QStringLiteral( "OutlineColor" ) );
592  if ( !outlineColorList.isEmpty() )
593  {
594  QDomElement frameColorElem = outlineColorList.at( 0 ).toElement();
595  bool redOk, greenOk, blueOk, alphaOk, widthOk;
596  int penRed, penGreen, penBlue, penAlpha;
597  double penWidth;
598 
599  penWidth = itemElem.attribute( QStringLiteral( "outlineWidth" ) ).toDouble( &widthOk );
600  penRed = frameColorElem.attribute( QStringLiteral( "red" ) ).toInt( &redOk );
601  penGreen = frameColorElem.attribute( QStringLiteral( "green" ) ).toInt( &greenOk );
602  penBlue = frameColorElem.attribute( QStringLiteral( "blue" ) ).toInt( &blueOk );
603  penAlpha = frameColorElem.attribute( QStringLiteral( "alpha" ) ).toInt( &alphaOk );
604 
605  if ( redOk && greenOk && blueOk && alphaOk && widthOk )
606  {
607  properties.insert( QStringLiteral( "color_border" ), QgsSymbolLayerUtils::encodeColor( QColor( penRed, penGreen, penBlue, penAlpha ) ) );
608  properties.insert( QStringLiteral( "width_border" ), QString::number( penWidth ) );
609  }
610  }
611  QDomNodeList fillColorList = itemElem.elementsByTagName( QStringLiteral( "FillColor" ) );
612  if ( !fillColorList.isEmpty() )
613  {
614  QDomElement fillColorElem = fillColorList.at( 0 ).toElement();
615  bool redOk, greenOk, blueOk, alphaOk;
616  int fillRed, fillGreen, fillBlue, fillAlpha;
617 
618  fillRed = fillColorElem.attribute( QStringLiteral( "red" ) ).toInt( &redOk );
619  fillGreen = fillColorElem.attribute( QStringLiteral( "green" ) ).toInt( &greenOk );
620  fillBlue = fillColorElem.attribute( QStringLiteral( "blue" ) ).toInt( &blueOk );
621  fillAlpha = fillColorElem.attribute( QStringLiteral( "alpha" ) ).toInt( &alphaOk );
622 
623  if ( redOk && greenOk && blueOk && alphaOk )
624  {
625  properties.insert( QStringLiteral( "color" ), QgsSymbolLayerUtils::encodeColor( QColor( fillRed, fillGreen, fillBlue, fillAlpha ) ) );
626  properties.insert( QStringLiteral( "style" ), QStringLiteral( "solid" ) );
627  }
628  }
629  if ( itemElem.hasAttribute( QStringLiteral( "transparentFill" ) ) )
630  {
631  //old style (pre 2.0) of specifying that shapes had no fill
632  bool hasOldTransparentFill = itemElem.attribute( QStringLiteral( "transparentFill" ), QStringLiteral( "0" ) ).toInt();
633  if ( hasOldTransparentFill )
634  {
635  properties.insert( QStringLiteral( "style" ), QStringLiteral( "no" ) );
636  }
637  }
638 
639  std::unique_ptr< QgsFillSymbol > shapeStyleSymbol( QgsFillSymbol::createSimple( properties ) );
640  layoutItem->setSymbol( shapeStyleSymbol.get() );
641  }
642  // Disable frame for shapes
643  layoutItem->setFrameEnabled( false );
644  layoutItem->setBackgroundEnabled( false );
645 
646  return true;
647 }
648 
649 bool QgsCompositionConverter::readPictureXml( QgsLayoutItemPicture *layoutItem, const QDomElement &itemElem, const QgsProject *project, const QgsStringMap &mapId2Uuid )
650 {
651  restoreGeneralComposeItemProperties( layoutItem, itemElem );
652 
653  layoutItem->mResizeMode = QgsLayoutItemPicture::ResizeMode( itemElem.attribute( QStringLiteral( "resizeMode" ), QStringLiteral( "0" ) ).toInt() );
654  //when loading from xml, default to anchor point of middle to match pre 2.4 behavior
655  bool positionModeOk = false;
656  layoutItem->mReferencePoint = static_cast< QgsLayoutItem::ReferencePoint >( itemElem.attribute( QStringLiteral( "positionMode" ) ).toInt( &positionModeOk ) );
657  if ( !positionModeOk )
658  {
659  layoutItem->mReferencePoint = QgsLayoutItem::ReferencePoint::UpperLeft;
660  }
661  bool anchorPointOk = false;
662 
663  layoutItem->setPictureAnchor( static_cast< QgsLayoutItem::ReferencePoint >( itemElem.attribute( QStringLiteral( "anchorPoint" ), QString::number( QgsLayoutItem::ReferencePoint::Middle ) ).toInt( &anchorPointOk ) ) );
664  if ( !anchorPointOk )
665  {
666  layoutItem->mPictureAnchor = QgsLayoutItem::ReferencePoint::UpperLeft;
667  }
668  layoutItem->mSvgFillColor = QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "svgFillColor" ), QgsSymbolLayerUtils::encodeColor( QColor( 255, 255, 255 ) ) ) );
669  layoutItem->mSvgStrokeColor = QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "svgBorderColor" ), QgsSymbolLayerUtils::encodeColor( QColor( 0, 0, 0 ) ) ) );
670  layoutItem->mSvgStrokeWidth = itemElem.attribute( QStringLiteral( "svgBorderWidth" ), QStringLiteral( "0.2" ) ).toDouble();
671 
672  QString imagePath = itemElem.attribute( QStringLiteral( "file" ) );
673  if ( project )
674  {
675  // convert from relative path to absolute. For SVG we also need to consider system SVG paths
676  QgsPathResolver pathResolver = project->pathResolver();
677  if ( imagePath.endsWith( QLatin1String( ".svg" ), Qt::CaseInsensitive ) )
678  imagePath = QgsSymbolLayerUtils::svgSymbolNameToPath( imagePath, pathResolver );
679  else
680  imagePath = pathResolver.readPath( imagePath );
681  }
682  layoutItem->setPicturePath( imagePath );
683  layoutItem->mPictureHeight = itemElem.attribute( QStringLiteral( "pictureHeight" ), QStringLiteral( "10" ) ).toDouble();
684  layoutItem->mPictureWidth = itemElem.attribute( QStringLiteral( "pictureWidth" ), QStringLiteral( "10" ) ).toDouble();
685 
686  //picture rotation
687  if ( !qgsDoubleNear( itemElem.attribute( QStringLiteral( "pictureRotation" ), QStringLiteral( "0" ) ).toDouble(), 0.0 ) )
688  {
689  layoutItem->mPictureRotation = itemElem.attribute( QStringLiteral( "pictureRotation" ), QStringLiteral( "0" ) ).toDouble();
690  }
691 
692  //rotation map
693  layoutItem->mNorthArrowHandler->setNorthMode( static_cast< QgsLayoutNorthArrowHandler::NorthMode >( itemElem.attribute( QStringLiteral( "northMode" ), QStringLiteral( "0" ) ).toInt() ) );
694  layoutItem->mNorthArrowHandler->setNorthOffset( itemElem.attribute( QStringLiteral( "northOffset" ), QStringLiteral( "0" ) ).toDouble() );
695 
696  QString rotationMapId = itemElem.attribute( QStringLiteral( "mapId" ), QStringLiteral( "-1" ) );
697  if ( rotationMapId != QLatin1String( "-1" ) )
698  {
699  // Find uuid for map with given id
700  QgsLayoutItemMap *mapInstance = qobject_cast<QgsLayoutItemMap *>( layoutItem->layout()->itemByUuid( mapId2Uuid[ rotationMapId ] ) );
701  if ( mapInstance )
702  {
703  layoutItem->setLinkedMap( mapInstance );
704  }
705  }
706  return true;
707 }
708 
709 bool QgsCompositionConverter::readArrowXml( QgsLayoutItemPolyline *layoutItem, const QDomElement &itemElem, const QgsProject *project )
710 {
711  readPolyXml<QgsLayoutItemPolyline, QgsLineSymbol>( layoutItem, itemElem, project );
712  QPolygonF polygon;
713  QDomNodeList startPointList = itemElem.elementsByTagName( QStringLiteral( "StartPoint" ) );
714  if ( ! startPointList.isEmpty() )
715  {
716  QDomElement node = startPointList.at( 0 ).toElement();
717  polygon.append( QPointF( node.attribute( QStringLiteral( "x" ) ).toDouble( ), node.attribute( QStringLiteral( "y" ) ).toDouble() ) );
718  }
719  QDomNodeList stopPointList = itemElem.elementsByTagName( QStringLiteral( "StopPoint" ) );
720  if ( ! stopPointList.isEmpty() )
721  {
722  QDomElement node = stopPointList.at( 0 ).toElement();
723  polygon.append( QPointF( node.attribute( QStringLiteral( "x" ) ).toDouble( ), node.attribute( QStringLiteral( "y" ) ).toDouble() ) );
724  }
725 
726  QgsCompositionConverter::MarkerMode markerMode = static_cast< QgsCompositionConverter::MarkerMode>( itemElem.attribute( QStringLiteral( "markerMode" ), QStringLiteral( "0" ) ).toInt( ) );
727 
728  if ( markerMode == QgsCompositionConverter::MarkerMode::DefaultMarker )
729  {
730  layoutItem->setEndMarker( QgsLayoutItemPolyline::MarkerMode::ArrowHead );
731  layoutItem->setStartMarker( QgsLayoutItemPolyline::MarkerMode::NoMarker );
732  layoutItem->setArrowHeadFillColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "arrowHeadFillColor" ), QgsSymbolLayerUtils::encodeColor( QColor( 255, 255, 255 ) ) ) ) );
733  layoutItem->setArrowHeadStrokeColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "arrowHeadOutlineColor" ), QgsSymbolLayerUtils::encodeColor( QColor( 255, 255, 255 ) ) ) ) );
734  layoutItem->setArrowHeadStrokeWidth( itemElem.attribute( QStringLiteral( "outlineWidth" ), QStringLiteral( "1.0" ) ).toDouble( ) );
735  layoutItem->setArrowHeadWidth( itemElem.attribute( QStringLiteral( "arrowHeadWidth" ), QStringLiteral( "1.0" ) ).toDouble( ) );
736  }
737  else if ( markerMode == QgsCompositionConverter::MarkerMode::SVGMarker )
738  {
739  QString endMarkerFile = itemElem.attribute( QStringLiteral( "endMarkerFile" ) );
740  QString startMarkerFile = itemElem.attribute( QStringLiteral( "endMarkerFile" ) );
741 
742  // Fix the paths
743  if ( project )
744  {
745  // convert from relative path to absolute. For SVG we also need to consider system SVG paths
746  QgsPathResolver pathResolver = project->pathResolver();
747  if ( !endMarkerFile.isEmpty() )
748  {
749  if ( endMarkerFile.endsWith( QLatin1String( ".svg" ), Qt::CaseInsensitive ) )
750  endMarkerFile = QgsSymbolLayerUtils::svgSymbolNameToPath( endMarkerFile, pathResolver );
751  else
752  endMarkerFile = pathResolver.readPath( endMarkerFile );
753  }
754  if ( !startMarkerFile.isEmpty() )
755  {
756  if ( startMarkerFile.endsWith( QLatin1String( ".svg" ), Qt::CaseInsensitive ) )
757  startMarkerFile = QgsSymbolLayerUtils::svgSymbolNameToPath( startMarkerFile, pathResolver );
758  else
759  startMarkerFile = pathResolver.readPath( startMarkerFile );
760  }
761  }
762  if ( !endMarkerFile.isEmpty() )
763  {
764  layoutItem->setEndMarker( QgsLayoutItemPolyline::MarkerMode::SvgMarker );
765  layoutItem->setEndSvgMarkerPath( endMarkerFile );
766  }
767  if ( !startMarkerFile.isEmpty() )
768  {
769  layoutItem->setStartMarker( QgsLayoutItemPolyline::MarkerMode::SvgMarker );
770  layoutItem->setStartSvgMarkerPath( startMarkerFile );
771  }
772  }
773  else // NoMarker
774  {
775  layoutItem->setEndMarker( QgsLayoutItemPolyline::MarkerMode::NoMarker );
776  layoutItem->setStartMarker( QgsLayoutItemPolyline::MarkerMode::NoMarker );
777  }
778  // Calculate the margin
779  double margin = polygon.boundingRect().left() - layoutItem->pos().x();
780  polygon.translate( - polygon.boundingRect().left() + margin, - polygon.boundingRect().top() + margin );
781  layoutItem->setNodes( polygon );
782 
783  return true;
784 }
785 
786 bool QgsCompositionConverter::readMapXml( QgsLayoutItemMap *layoutItem, const QDomElement &itemElem, const QgsProject *project, QgsStringMap &mapId2Uuid )
787 {
788  restoreGeneralComposeItemProperties( layoutItem, itemElem );
789 
790  mapId2Uuid[ itemElem.attribute( QStringLiteral( "id" ) ) ] = layoutItem->uuid();
791 
792  // TODO: Unused but all the layouts readXML require it (I'd suggest to remove it from the API)
793  QDomDocument doc;
794 
795  QgsReadWriteContext context;
796 
797  if ( project )
798  context.setPathResolver( project->pathResolver() );
799 
800  //extent
801  QDomNodeList extentNodeList = itemElem.elementsByTagName( QStringLiteral( "Extent" ) );
802  if ( !extentNodeList.isEmpty() )
803  {
804  QDomElement extentElem = extentNodeList.at( 0 ).toElement();
805  double xmin, xmax, ymin, ymax;
806  xmin = extentElem.attribute( QStringLiteral( "xmin" ) ).toDouble();
807  xmax = extentElem.attribute( QStringLiteral( "xmax" ) ).toDouble();
808  ymin = extentElem.attribute( QStringLiteral( "ymin" ) ).toDouble();
809  ymax = extentElem.attribute( QStringLiteral( "ymax" ) ).toDouble();
810  layoutItem->setExtent( QgsRectangle( xmin, ymin, xmax, ymax ) );
811  }
812 
813  QDomNodeList crsNodeList = itemElem.elementsByTagName( QStringLiteral( "crs" ) );
814  if ( !crsNodeList.isEmpty() )
815  {
816  QDomElement crsElem = crsNodeList.at( 0 ).toElement();
817  layoutItem->crs().readXml( crsElem );
818  }
819  else
820  {
821  layoutItem->setCrs( QgsCoordinateReferenceSystem() );
822  }
823 
824  //map rotation
825  if ( !qgsDoubleNear( itemElem.attribute( QStringLiteral( "mapRotation" ), QStringLiteral( "0" ) ).toDouble(), 0.0 ) )
826  {
827  layoutItem->setMapRotation( itemElem.attribute( QStringLiteral( "mapRotation" ), QStringLiteral( "0" ) ).toDouble() );
828  }
829 
830  // follow map theme
831  layoutItem->setFollowVisibilityPreset( itemElem.attribute( QStringLiteral( "followPreset" ) ).compare( QLatin1String( "true" ) ) == 0 );
832  layoutItem->setFollowVisibilityPresetName( itemElem.attribute( QStringLiteral( "followPresetName" ) ) );
833 
834  //mKeepLayerSet flag
835  QString keepLayerSetFlag = itemElem.attribute( QStringLiteral( "keepLayerSet" ) );
836  if ( keepLayerSetFlag.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
837  {
838  layoutItem->setKeepLayerSet( true );
839  }
840  else
841  {
842  layoutItem->setKeepLayerSet( false );
843  }
844 
845  QString drawCanvasItemsFlag = itemElem.attribute( QStringLiteral( "drawCanvasItems" ), QStringLiteral( "true" ) );
846  if ( drawCanvasItemsFlag.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
847  {
848  layoutItem->setDrawAnnotations( true );
849  }
850  else
851  {
852  layoutItem->setDrawAnnotations( false );
853  }
854 
855  layoutItem->mLayerStyleOverrides.clear();
856 
857  //mLayers
858  layoutItem->mLayers.clear();
859 
860  QDomNodeList layerSetNodeList = itemElem.elementsByTagName( QStringLiteral( "LayerSet" ) );
861  if ( !layerSetNodeList.isEmpty() )
862  {
863  QDomElement layerSetElem = layerSetNodeList.at( 0 ).toElement();
864  QDomNodeList layerIdNodeList = layerSetElem.elementsByTagName( QStringLiteral( "Layer" ) );
865  layoutItem->mLayers.reserve( layerIdNodeList.size() );
866  for ( int i = 0; i < layerIdNodeList.size(); ++i )
867  {
868  QDomElement layerElem = layerIdNodeList.at( i ).toElement();
869  QString layerId = layerElem.text();
870  QString layerName = layerElem.attribute( QStringLiteral( "name" ) );
871  QString layerSource = layerElem.attribute( QStringLiteral( "source" ) );
872  QString layerProvider = layerElem.attribute( QStringLiteral( "provider" ) );
873 
874  QgsMapLayerRef ref( layerId, layerName, layerSource, layerProvider );
875  ref.resolveWeakly( project );
876  layoutItem->mLayers << ref;
877  }
878  }
879 
880  // override styles
881  QDomNodeList layerStylesNodeList = itemElem.elementsByTagName( QStringLiteral( "LayerStyles" ) );
882  layoutItem->mKeepLayerStyles = !layerStylesNodeList.isEmpty();
883  if ( layoutItem->mKeepLayerStyles )
884  {
885  QDomElement layerStylesElem = layerStylesNodeList.at( 0 ).toElement();
886  QDomNodeList layerStyleNodeList = layerStylesElem.elementsByTagName( QStringLiteral( "LayerStyle" ) );
887  for ( int i = 0; i < layerStyleNodeList.size(); ++i )
888  {
889  const QDomElement &layerStyleElement = layerStyleNodeList.at( i ).toElement();
890  QString layerId = layerStyleElement.attribute( QStringLiteral( "layerid" ) );
891  QString layerName = layerStyleElement.attribute( QStringLiteral( "name" ) );
892  QString layerSource = layerStyleElement.attribute( QStringLiteral( "source" ) );
893  QString layerProvider = layerStyleElement.attribute( QStringLiteral( "provider" ) );
894  QgsMapLayerRef ref( layerId, layerName, layerSource, layerProvider );
895  ref.resolveWeakly( project );
896 
897  QgsMapLayerStyle style;
898  style.readXml( layerStyleElement );
899  layoutItem->mLayerStyleOverrides.insert( ref.layerId, style.xmlData() );
900  }
901  }
902 
903  layoutItem->mDrawing = false;
904  layoutItem->mNumCachedLayers = 0;
905  layoutItem->mCacheInvalidated = true;
906 
907  //overviews
908  //read overview stack
909  QDomNodeList mapOverviewNodeList = itemElem.elementsByTagName( QStringLiteral( "ComposerMapOverview" ) );
910  for ( int i = 0; i < mapOverviewNodeList.size(); ++i )
911  {
912  QDomElement mapOverviewElem = mapOverviewNodeList.at( i ).toElement();
913  std::unique_ptr<QgsLayoutItemMapOverview> mapOverview( new QgsLayoutItemMapOverview( mapOverviewElem.attribute( QStringLiteral( "name" ) ), layoutItem ) );
914  mapOverview->readXml( mapOverviewElem, doc, context );
915  QString frameMapId = mapOverviewElem.attribute( QStringLiteral( "frameMap" ), QStringLiteral( "-1" ) );
916  if ( frameMapId != QLatin1String( "-1" ) && mapId2Uuid.contains( frameMapId ) )
917  {
918  QgsLayoutItemMap *mapInstance = qobject_cast<QgsLayoutItemMap *>( layoutItem->layout()->itemByUuid( mapId2Uuid[ frameMapId ] ) );
919  if ( mapInstance )
920  {
921  mapOverview->setLinkedMap( mapInstance );
922  }
923  layoutItem->mOverviewStack->addOverview( mapOverview.release() );
924  }
925  }
926 
927  //grids
928  layoutItem->mGridStack->readXml( itemElem, doc, context );
929 
930  //load grid / grid annotation in old xml format
931  //only do this if the grid stack didn't load any grids, otherwise this will
932  //be the dummy element created by QGIS >= 2.5 (refs #10905)
933  QDomNodeList gridNodeList = itemElem.elementsByTagName( QStringLiteral( "Grid" ) );
934  if ( layoutItem->mGridStack->size() == 0 && !gridNodeList.isEmpty() )
935  {
936  QDomElement gridElem = gridNodeList.at( 0 ).toElement();
937  QgsLayoutItemMapGrid *mapGrid = new QgsLayoutItemMapGrid( QObject::tr( "Grid %1" ).arg( 1 ), layoutItem );
938  mapGrid->setEnabled( gridElem.attribute( QStringLiteral( "show" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
939  mapGrid->setStyle( QgsLayoutItemMapGrid::GridStyle( gridElem.attribute( QStringLiteral( "gridStyle" ), QStringLiteral( "0" ) ).toInt() ) );
940  mapGrid->setIntervalX( gridElem.attribute( QStringLiteral( "intervalX" ), QStringLiteral( "0" ) ).toDouble() );
941  mapGrid->setIntervalY( gridElem.attribute( QStringLiteral( "intervalY" ), QStringLiteral( "0" ) ).toDouble() );
942  mapGrid->setOffsetX( gridElem.attribute( QStringLiteral( "offsetX" ), QStringLiteral( "0" ) ).toDouble() );
943  mapGrid->setOffsetY( gridElem.attribute( QStringLiteral( "offsetY" ), QStringLiteral( "0" ) ).toDouble() );
944  mapGrid->setCrossLength( gridElem.attribute( QStringLiteral( "crossLength" ), QStringLiteral( "3" ) ).toDouble() );
945  mapGrid->setFrameStyle( static_cast< QgsLayoutItemMapGrid::FrameStyle >( gridElem.attribute( QStringLiteral( "gridFrameStyle" ), QStringLiteral( "0" ) ).toInt() ) );
946  mapGrid->setFrameWidth( gridElem.attribute( QStringLiteral( "gridFrameWidth" ), QStringLiteral( "2.0" ) ).toDouble() );
947  mapGrid->setFramePenSize( gridElem.attribute( QStringLiteral( "gridFramePenThickness" ), QStringLiteral( "0.5" ) ).toDouble() );
948  mapGrid->setFramePenColor( QgsSymbolLayerUtils::decodeColor( gridElem.attribute( QStringLiteral( "framePenColor" ), QStringLiteral( "0,0,0" ) ) ) );
949  mapGrid->setFrameFillColor1( QgsSymbolLayerUtils::decodeColor( gridElem.attribute( QStringLiteral( "frameFillColor1" ), QStringLiteral( "255,255,255,255" ) ) ) );
950  mapGrid->setFrameFillColor2( QgsSymbolLayerUtils::decodeColor( gridElem.attribute( QStringLiteral( "frameFillColor2" ), QStringLiteral( "0,0,0,255" ) ) ) );
951  mapGrid->setBlendMode( QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( itemElem.attribute( QStringLiteral( "gridBlendMode" ), QStringLiteral( "0" ) ).toUInt() ) ) );
952  QDomElement gridSymbolElem = gridElem.firstChildElement( QStringLiteral( "symbol" ) );
953  QgsLineSymbol *lineSymbol = nullptr;
954  if ( gridSymbolElem.isNull() )
955  {
956  //old project file, read penWidth /penColorRed, penColorGreen, penColorBlue
957  lineSymbol = QgsLineSymbol::createSimple( QgsStringMap() );
958  lineSymbol->setWidth( gridElem.attribute( QStringLiteral( "penWidth" ), QStringLiteral( "0" ) ).toDouble() );
959  lineSymbol->setColor( QColor( gridElem.attribute( QStringLiteral( "penColorRed" ), QStringLiteral( "0" ) ).toInt(),
960  gridElem.attribute( QStringLiteral( "penColorGreen" ), QStringLiteral( "0" ) ).toInt(),
961  gridElem.attribute( QStringLiteral( "penColorBlue" ), QStringLiteral( "0" ) ).toInt() ) );
962  }
963  else
964  {
965  lineSymbol = QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( gridSymbolElem, context );
966  }
967  mapGrid->setLineSymbol( lineSymbol );
968 
969  //annotation
970  QDomNodeList annotationNodeList = gridElem.elementsByTagName( QStringLiteral( "Annotation" ) );
971  if ( !annotationNodeList.isEmpty() )
972  {
973  QDomElement annotationElem = annotationNodeList.at( 0 ).toElement();
974  mapGrid->setAnnotationEnabled( annotationElem.attribute( QStringLiteral( "show" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
975  mapGrid->setAnnotationFormat( QgsLayoutItemMapGrid::AnnotationFormat( annotationElem.attribute( QStringLiteral( "format" ), QStringLiteral( "0" ) ).toInt() ) );
976  mapGrid->setAnnotationPosition( QgsLayoutItemMapGrid::AnnotationPosition( annotationElem.attribute( QStringLiteral( "leftPosition" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Left );
977  mapGrid->setAnnotationPosition( QgsLayoutItemMapGrid::AnnotationPosition( annotationElem.attribute( QStringLiteral( "rightPosition" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Right );
978  mapGrid->setAnnotationPosition( QgsLayoutItemMapGrid::AnnotationPosition( annotationElem.attribute( QStringLiteral( "topPosition" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Top );
979  mapGrid->setAnnotationPosition( QgsLayoutItemMapGrid::AnnotationPosition( annotationElem.attribute( QStringLiteral( "bottomPosition" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Bottom );
980  mapGrid->setAnnotationDirection( QgsLayoutItemMapGrid::AnnotationDirection( annotationElem.attribute( QStringLiteral( "leftDirection" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Left );
981  mapGrid->setAnnotationDirection( QgsLayoutItemMapGrid::AnnotationDirection( annotationElem.attribute( QStringLiteral( "rightDirection" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Right );
982  mapGrid->setAnnotationDirection( QgsLayoutItemMapGrid::AnnotationDirection( annotationElem.attribute( QStringLiteral( "topDirection" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Top );
983  mapGrid->setAnnotationDirection( QgsLayoutItemMapGrid::AnnotationDirection( annotationElem.attribute( QStringLiteral( "bottomDirection" ), QStringLiteral( "0" ) ).toInt() ), QgsLayoutItemMapGrid::Bottom );
984  mapGrid->setAnnotationFrameDistance( annotationElem.attribute( QStringLiteral( "frameDistance" ), QStringLiteral( "0" ) ).toDouble() );
985  QFont annotationFont;
986  annotationFont.fromString( annotationElem.attribute( QStringLiteral( "font" ), QString() ) );
987 
988  QgsTextFormat annotationFormat = mapGrid->annotationTextFormat();
989  annotationFormat.setFont( annotationFont );
990  if ( annotationFont.pointSizeF() > 0 )
991  {
992  annotationFormat.setSize( annotationFont.pointSizeF() );
993  annotationFormat.setSizeUnit( QgsUnitTypes::RenderPoints );
994  }
995  else if ( annotationFont.pixelSize() > 0 )
996  {
997  annotationFormat.setSize( annotationFont.pixelSize() );
998  annotationFormat.setSizeUnit( QgsUnitTypes::RenderPixels );
999  }
1000  annotationFormat.setColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "fontColor" ), QStringLiteral( "0,0,0,255" ) ) ) );
1001  mapGrid->setAnnotationTextFormat( annotationFormat );
1002 
1003  mapGrid->setAnnotationPrecision( annotationElem.attribute( QStringLiteral( "precision" ), QStringLiteral( "3" ) ).toInt() );
1004  }
1005  layoutItem->mGridStack->addGrid( mapGrid );
1006  }
1007 
1008  //atlas
1009  QDomNodeList atlasNodeList = itemElem.elementsByTagName( QStringLiteral( "AtlasMap" ) );
1010  if ( !atlasNodeList.isEmpty() )
1011  {
1012  QDomElement atlasElem = atlasNodeList.at( 0 ).toElement();
1013  layoutItem->mAtlasDriven = ( atlasElem.attribute( QStringLiteral( "atlasDriven" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) );
1014  if ( atlasElem.hasAttribute( QStringLiteral( "fixedScale" ) ) ) // deprecated XML
1015  {
1016  layoutItem->setAtlasScalingMode( atlasElem.attribute( QStringLiteral( "fixedScale" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) ? QgsLayoutItemMap::AtlasScalingMode::Fixed : QgsLayoutItemMap::AtlasScalingMode::Auto );
1017  }
1018  else if ( atlasElem.hasAttribute( QStringLiteral( "scalingMode" ) ) )
1019  {
1020  layoutItem->setAtlasScalingMode( static_cast<QgsLayoutItemMap::AtlasScalingMode>( atlasElem.attribute( QStringLiteral( "scalingMode" ) ).toInt() ) );
1021  }
1022  layoutItem->setAtlasMargin( atlasElem.attribute( QStringLiteral( "margin" ), QStringLiteral( "0.1" ) ).toDouble() );
1023  }
1024 
1025  layoutItem->updateBoundingRect();
1026 
1027  return true;
1028 }
1029 
1030 bool QgsCompositionConverter::readScaleBarXml( QgsLayoutItemScaleBar *layoutItem, const QDomElement &itemElem, const QgsProject *project, const QgsStringMap &mapId2Uuid )
1031 {
1032  Q_UNUSED( project )
1033  restoreGeneralComposeItemProperties( layoutItem, itemElem );
1034 
1035  layoutItem->setHeight( itemElem.attribute( QStringLiteral( "height" ), QStringLiteral( "5.0" ) ).toDouble() );
1036  layoutItem->setHeight( itemElem.attribute( QStringLiteral( "height" ), QStringLiteral( "5.0" ) ).toDouble() );
1037  layoutItem->setLabelBarSpace( itemElem.attribute( QStringLiteral( "labelBarSpace" ), QStringLiteral( "3.0" ) ).toDouble() );
1038  layoutItem->setBoxContentSpace( itemElem.attribute( QStringLiteral( "boxContentSpace" ), QStringLiteral( "1.0" ) ).toDouble() );
1039  layoutItem->setNumberOfSegments( itemElem.attribute( QStringLiteral( "numSegments" ), QStringLiteral( "2" ) ).toInt() );
1040  layoutItem->setNumberOfSegmentsLeft( itemElem.attribute( QStringLiteral( "numSegmentsLeft" ), QStringLiteral( "0" ) ).toInt() );
1041  layoutItem->setUnitsPerSegment( itemElem.attribute( QStringLiteral( "numUnitsPerSegment" ), QStringLiteral( "1.0" ) ).toDouble() );
1042  layoutItem->setSegmentSizeMode( static_cast<QgsScaleBarSettings::SegmentSizeMode>( itemElem.attribute( QStringLiteral( "segmentSizeMode" ), QStringLiteral( "0" ) ).toInt() ) );
1043  layoutItem->setMinimumBarWidth( itemElem.attribute( QStringLiteral( "minBarWidth" ), QStringLiteral( "50" ) ).toDouble() );
1044  layoutItem->setMaximumBarWidth( itemElem.attribute( QStringLiteral( "maxBarWidth" ), QStringLiteral( "150" ) ).toDouble() );
1045  layoutItem->mSegmentMillimeters = itemElem.attribute( QStringLiteral( "segmentMillimeters" ), QStringLiteral( "0.0" ) ).toDouble();
1046  layoutItem->setMapUnitsPerScaleBarUnit( itemElem.attribute( QStringLiteral( "numMapUnitsPerScaleBarUnit" ), QStringLiteral( "1.0" ) ).toDouble() );
1047  layoutItem->setUnitLabel( itemElem.attribute( QStringLiteral( "unitLabel" ) ) );
1048 
1049  QFont f;
1050  if ( !QgsFontUtils::setFromXmlChildNode( f, itemElem, QStringLiteral( "scaleBarFont" ) ) )
1051  {
1052  f.fromString( itemElem.attribute( QStringLiteral( "font" ), QString() ) );
1053  }
1055  layoutItem->setFont( f );
1057 
1058  //colors
1059  //fill color
1060  QDomNodeList fillColorList = itemElem.elementsByTagName( QStringLiteral( "fillColor" ) );
1061  if ( !fillColorList.isEmpty() )
1062  {
1063  QDomElement fillColorElem = fillColorList.at( 0 ).toElement();
1064  bool redOk, greenOk, blueOk, alphaOk;
1065  int fillRed, fillGreen, fillBlue, fillAlpha;
1066 
1067  fillRed = fillColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
1068  fillGreen = fillColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
1069  fillBlue = fillColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
1070  fillAlpha = fillColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
1071 
1072  if ( redOk && greenOk && blueOk && alphaOk )
1073  {
1074  layoutItem->fillSymbol()->setColor( QColor( fillRed, fillGreen, fillBlue, fillAlpha ) );
1075  }
1076  }
1077  else
1078  {
1079  layoutItem->fillSymbol()->setColor( QColor( itemElem.attribute( QStringLiteral( "brushColor" ), QStringLiteral( "#000000" ) ) ) );
1080  }
1081 
1082  //fill color 2
1083  QDomNodeList fillColor2List = itemElem.elementsByTagName( QStringLiteral( "fillColor2" ) );
1084  if ( !fillColor2List.isEmpty() )
1085  {
1086  QDomElement fillColor2Elem = fillColor2List.at( 0 ).toElement();
1087  bool redOk, greenOk, blueOk, alphaOk;
1088  int fillRed, fillGreen, fillBlue, fillAlpha;
1089 
1090  fillRed = fillColor2Elem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
1091  fillGreen = fillColor2Elem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
1092  fillBlue = fillColor2Elem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
1093  fillAlpha = fillColor2Elem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
1094 
1095  if ( redOk && greenOk && blueOk && alphaOk )
1096  {
1097  layoutItem->alternateFillSymbol()->setColor( QColor( fillRed, fillGreen, fillBlue, fillAlpha ) );
1098  }
1099  }
1100  else
1101  {
1102  layoutItem->alternateFillSymbol()->setColor( QColor( itemElem.attribute( QStringLiteral( "brush2Color" ), QStringLiteral( "#ffffff" ) ) ) );
1103  }
1104 
1105  std::unique_ptr< QgsLineSymbol > lineSymbol = qgis::make_unique< QgsLineSymbol >();
1106  std::unique_ptr< QgsSimpleLineSymbolLayer > lineSymbolLayer = qgis::make_unique< QgsSimpleLineSymbolLayer >();
1107  lineSymbolLayer->setWidth( itemElem.attribute( QStringLiteral( "outlineWidth" ), QStringLiteral( "0.3" ) ).toDouble() );
1108  lineSymbolLayer->setWidthUnit( QgsUnitTypes::RenderMillimeters );
1109  lineSymbolLayer->setPenJoinStyle( QgsSymbolLayerUtils::decodePenJoinStyle( itemElem.attribute( QStringLiteral( "lineJoinStyle" ), QStringLiteral( "miter" ) ) ) );
1110  lineSymbolLayer->setPenCapStyle( QgsSymbolLayerUtils::decodePenCapStyle( itemElem.attribute( QStringLiteral( "lineCapStyle" ), QStringLiteral( "square" ) ) ) );
1111  //stroke color
1112  QDomNodeList strokeColorList = itemElem.elementsByTagName( QStringLiteral( "strokeColor" ) );
1113  if ( !strokeColorList.isEmpty() )
1114  {
1115  QDomElement strokeColorElem = strokeColorList.at( 0 ).toElement();
1116  bool redOk, greenOk, blueOk, alphaOk;
1117  int strokeRed, strokeGreen, strokeBlue, strokeAlpha;
1118 
1119  strokeRed = strokeColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
1120  strokeGreen = strokeColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
1121  strokeBlue = strokeColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
1122  strokeAlpha = strokeColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
1123 
1124  if ( redOk && greenOk && blueOk && alphaOk )
1125  {
1126  lineSymbolLayer->setColor( QColor( strokeRed, strokeGreen, strokeBlue, strokeAlpha ) );
1127  }
1128  }
1129  else
1130  {
1131  lineSymbolLayer->setColor( QColor( itemElem.attribute( QStringLiteral( "penColor" ), QStringLiteral( "#000000" ) ) ) );
1132  }
1133  lineSymbol->changeSymbolLayer( 0, lineSymbolLayer.release() );
1134  layoutItem->setDivisionLineSymbol( lineSymbol->clone() );
1135  layoutItem->setSubdivisionLineSymbol( lineSymbol->clone() );
1136  layoutItem->setLineSymbol( lineSymbol.release() );
1137 
1138  //font color
1139  QDomNodeList textColorList = itemElem.elementsByTagName( QStringLiteral( "textColor" ) );
1140  if ( !textColorList.isEmpty() )
1141  {
1142  QDomElement textColorElem = textColorList.at( 0 ).toElement();
1143  bool redOk, greenOk, blueOk, alphaOk;
1144  int textRed, textGreen, textBlue, textAlpha;
1145 
1146  textRed = textColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
1147  textGreen = textColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
1148  textBlue = textColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
1149  textAlpha = textColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
1150 
1151  if ( redOk && greenOk && blueOk && alphaOk )
1152  {
1154  layoutItem->setFontColor( QColor( textRed, textGreen, textBlue, textAlpha ) );
1156  }
1157  }
1158  else
1159  {
1160  QColor c;
1161  c.setNamedColor( itemElem.attribute( QStringLiteral( "fontColor" ), QStringLiteral( "#000000" ) ) );
1163  layoutItem->setFontColor( c );
1165  }
1166 
1167  //style
1168  QString styleString = itemElem.attribute( QStringLiteral( "style" ), QString() );
1169  layoutItem->setStyle( QObject::tr( styleString.toLocal8Bit().data() ) );
1170 
1171  if ( itemElem.attribute( QStringLiteral( "unitType" ) ).isEmpty() )
1172  {
1174  switch ( itemElem.attribute( QStringLiteral( "units" ) ).toInt() )
1175  {
1176  case 0:
1178  break;
1179  case 1:
1181  break;
1182  case 2:
1184  break;
1185  case 3:
1187  break;
1188  }
1189  layoutItem->setUnits( u );
1190  }
1191  else
1192  {
1193  layoutItem->setUnits( QgsUnitTypes::decodeDistanceUnit( itemElem.attribute( QStringLiteral( "unitType" ) ) ) );
1194  }
1195  layoutItem->setAlignment( static_cast< QgsScaleBarSettings::Alignment >( itemElem.attribute( QStringLiteral( "alignment" ), QStringLiteral( "0" ) ).toInt() ) );
1196 
1197  //composer map: use uuid
1198  QString mapId = itemElem.attribute( QStringLiteral( "mapId" ), QStringLiteral( "-1" ) );
1199  if ( mapId != QLatin1String( "-1" ) && mapId2Uuid.contains( mapId ) )
1200  {
1201  QgsLayoutItemMap *mapInstance = qobject_cast<QgsLayoutItemMap *>( layoutItem->layout()->itemByUuid( mapId2Uuid[ mapId ] ) );
1202  if ( mapInstance )
1203  {
1204  layoutItem->setLinkedMap( mapInstance );
1205  }
1206  }
1207 
1208  return true;
1209 }
1210 
1211 bool QgsCompositionConverter::readLegendXml( QgsLayoutItemLegend *layoutItem, const QDomElement &itemElem, const QgsProject *project, const QgsStringMap &mapId2Uuid )
1212 {
1213  restoreGeneralComposeItemProperties( layoutItem, itemElem );
1214 
1215  QgsPathResolver pathResolver;
1216  if ( project )
1217  pathResolver = project->pathResolver();
1218  QgsReadWriteContext context;
1219  context.setPathResolver( pathResolver );
1220  context.setProjectTranslator( const_cast<QgsProject *>( project ) );
1221 
1222  //composer map: use uuid
1223  QString mapId = itemElem.attribute( QStringLiteral( "map" ), QStringLiteral( "-1" ) );
1224  if ( mapId != QLatin1String( "-1" ) && mapId2Uuid.contains( mapId ) )
1225  {
1226  QgsLayoutItemMap *mapInstance = qobject_cast<QgsLayoutItemMap *>( layoutItem->layout()->itemByUuid( mapId2Uuid[ mapId ] ) );
1227  if ( mapInstance )
1228  {
1229  layoutItem->setLinkedMap( mapInstance );
1230  }
1231  }
1232 
1233  //read general properties
1234  layoutItem->setTitle( itemElem.attribute( QStringLiteral( "title" ) ) );
1235  if ( !itemElem.attribute( QStringLiteral( "titleAlignment" ) ).isEmpty() )
1236  {
1237  layoutItem->setTitleAlignment( static_cast< Qt::AlignmentFlag >( itemElem.attribute( QStringLiteral( "titleAlignment" ) ).toInt() ) );
1238  }
1239  int colCount = itemElem.attribute( QStringLiteral( "columnCount" ), QStringLiteral( "1" ) ).toInt();
1240  if ( colCount < 1 ) colCount = 1;
1241  layoutItem->setColumnCount( colCount );
1242  layoutItem->setSplitLayer( itemElem.attribute( QStringLiteral( "splitLayer" ), QStringLiteral( "0" ) ).toInt() == 1 );
1243  layoutItem->setEqualColumnWidth( itemElem.attribute( QStringLiteral( "equalColumnWidth" ), QStringLiteral( "0" ) ).toInt() == 1 );
1244 
1245  QDomNodeList stylesNodeList = itemElem.elementsByTagName( QStringLiteral( "styles" ) );
1246  if ( !stylesNodeList.isEmpty() )
1247  {
1248  QDomNode stylesNode = stylesNodeList.at( 0 );
1249  for ( int i = 0; i < stylesNode.childNodes().size(); i++ )
1250  {
1251  QDomElement styleElem = stylesNode.childNodes().at( i ).toElement();
1252  QgsLegendStyle style;
1253  style.readXml( styleElem, QDomDocument() );
1254  QString name = styleElem.attribute( QStringLiteral( "name" ) );
1256  if ( name == QLatin1String( "title" ) ) s = QgsLegendStyle::Title;
1257  else if ( name == QLatin1String( "group" ) ) s = QgsLegendStyle::Group;
1258  else if ( name == QLatin1String( "subgroup" ) ) s = QgsLegendStyle::Subgroup;
1259  else if ( name == QLatin1String( "symbol" ) ) s = QgsLegendStyle::Symbol;
1260  else if ( name == QLatin1String( "symbolLabel" ) ) s = QgsLegendStyle::SymbolLabel;
1261  else continue;
1262  layoutItem->setStyle( s, style );
1263  }
1264  }
1265 
1266  //font color
1267  QColor fontClr;
1268  fontClr.setNamedColor( itemElem.attribute( QStringLiteral( "fontColor" ), QStringLiteral( "#000000" ) ) );
1269  layoutItem->setFontColor( fontClr );
1270 
1271  //spaces
1272  layoutItem->setBoxSpace( itemElem.attribute( QStringLiteral( "boxSpace" ), QStringLiteral( "2.0" ) ).toDouble() );
1273  layoutItem->setColumnSpace( itemElem.attribute( QStringLiteral( "columnSpace" ), QStringLiteral( "2.0" ) ).toDouble() );
1274 
1275  layoutItem->setSymbolWidth( itemElem.attribute( QStringLiteral( "symbolWidth" ), QStringLiteral( "7.0" ) ).toDouble() );
1276  layoutItem->setSymbolHeight( itemElem.attribute( QStringLiteral( "symbolHeight" ), QStringLiteral( "14.0" ) ).toDouble() );
1277  layoutItem->setWmsLegendWidth( itemElem.attribute( QStringLiteral( "wmsLegendWidth" ), QStringLiteral( "50" ) ).toDouble() );
1278  layoutItem->setWmsLegendHeight( itemElem.attribute( QStringLiteral( "wmsLegendHeight" ), QStringLiteral( "25" ) ).toDouble() );
1279  layoutItem->setLineSpacing( itemElem.attribute( QStringLiteral( "lineSpacing" ), QStringLiteral( "1.0" ) ).toDouble() );
1280 
1281  layoutItem->setDrawRasterStroke( itemElem.attribute( QStringLiteral( "rasterBorder" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) );
1282  layoutItem->setRasterStrokeColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "rasterBorderColor" ), QStringLiteral( "0,0,0" ) ) ) );
1283  layoutItem->setRasterStrokeWidth( itemElem.attribute( QStringLiteral( "rasterBorderWidth" ), QStringLiteral( "0" ) ).toDouble() );
1284 
1285  layoutItem->setWrapString( itemElem.attribute( QStringLiteral( "wrapChar" ) ) );
1286 
1287  layoutItem->mSizeToContents = itemElem.attribute( QStringLiteral( "resizeToContents" ), QStringLiteral( "1" ) ) != QLatin1String( "0" );
1288  layoutItem->mLegendFilterByMap = itemElem.attribute( QStringLiteral( "legendFilterByMap" ), QStringLiteral( "0" ) ).toInt();
1289  layoutItem->mFilterOutAtlas = itemElem.attribute( QStringLiteral( "legendFilterByAtlas" ), QStringLiteral( "0" ) ).toInt();
1290 
1291  // QGIS >= 2.6
1292  QDomElement layerTreeElem = itemElem.firstChildElement( QStringLiteral( "layer-tree" ) );
1293  if ( layerTreeElem.isNull() )
1294  layerTreeElem = itemElem.firstChildElement( QStringLiteral( "layer-tree-group" ) );
1295 
1296  if ( !layerTreeElem.isNull() )
1297  {
1298  QgsLayerTree *tree( QgsLayerTree::readXml( layerTreeElem, context ) );
1299  if ( project )
1300  tree->resolveReferences( project, true );
1301  layoutItem->setCustomLayerTree( tree );
1302  }
1303  else
1304  {
1305  layoutItem->setCustomLayerTree( nullptr );
1306  }
1307 
1308  return true;
1309 }
1310 
1311 bool QgsCompositionConverter::readAtlasXml( QgsLayoutAtlas *atlasItem, const QDomElement &itemElem, const QgsProject *project )
1312 {
1313  atlasItem->setEnabled( itemElem.attribute( QStringLiteral( "enabled" ), QStringLiteral( "false" ) ) == QLatin1String( "true" ) );
1314 
1315  // look for stored layer name
1316  QString layerId = itemElem.attribute( QStringLiteral( "coverageLayer" ) );
1317  QString layerName = itemElem.attribute( QStringLiteral( "coverageLayerName" ) );
1318  QString layerSource = itemElem.attribute( QStringLiteral( "coverageLayerSource" ) );
1319  QString layerProvider = itemElem.attribute( QStringLiteral( "coverageLayerProvider" ) );
1320 
1321  QgsVectorLayerRef layerRef( layerId, layerName, layerSource, layerProvider );
1322  atlasItem->setCoverageLayer( layerRef.resolveWeakly( project ) );
1323 
1324  atlasItem->setPageNameExpression( itemElem.attribute( QStringLiteral( "pageNameExpression" ), QString() ) );
1325  QString errorString;
1326  atlasItem->setFilenameExpression( itemElem.attribute( QStringLiteral( "filenamePattern" ), QString() ), errorString );
1327  // note: no error reporting for errorString
1328  atlasItem->setSortFeatures( itemElem.attribute( QStringLiteral( "sortFeatures" ), QStringLiteral( "false" ) ) == QLatin1String( "true" ) );
1329  if ( atlasItem->sortFeatures() )
1330  {
1331  atlasItem->setSortExpression( itemElem.attribute( QStringLiteral( "sortKey" ), QString() ) );
1332  atlasItem->setSortAscending( itemElem.attribute( QStringLiteral( "sortAscending" ), QStringLiteral( "true" ) ) == QLatin1String( "true" ) );
1333  }
1334  atlasItem->setFilterFeatures( itemElem.attribute( QStringLiteral( "filterFeatures" ), QStringLiteral( "false" ) ) == QLatin1String( "true" ) );
1335  if ( atlasItem->filterFeatures( ) )
1336  {
1337  QString expErrorString;
1338  atlasItem->setFilterExpression( itemElem.attribute( QStringLiteral( "featureFilter" ), QString() ), expErrorString );
1339  // note: no error reporting for errorString
1340  }
1341 
1342  atlasItem->setHideCoverage( itemElem.attribute( QStringLiteral( "hideCoverage" ), QStringLiteral( "false" ) ) == QLatin1String( "true" ) );
1343 
1344  return true;
1345 
1346 }
1347 
1348 bool QgsCompositionConverter::readHtmlXml( QgsLayoutItemHtml *layoutItem, const QDomElement &itemElem, const QgsProject *project )
1349 {
1350  Q_UNUSED( project )
1351  readOldComposerObjectXml( layoutItem, itemElem );
1352 
1353  //first create the frames
1354  layoutItem->setResizeMode( static_cast< QgsLayoutMultiFrame::ResizeMode >( itemElem.attribute( QStringLiteral( "resizeMode" ), QStringLiteral( "0" ) ).toInt() ) );
1355  QDomNodeList frameList = itemElem.elementsByTagName( QStringLiteral( "ComposerFrame" ) );
1356  for ( int i = 0; i < frameList.size(); ++i )
1357  {
1358  QDomElement frameElem = frameList.at( i ).toElement();
1359  QgsLayoutFrame *newFrame = new QgsLayoutFrame( layoutItem->layout(), layoutItem );
1360  restoreGeneralComposeItemProperties( newFrame, frameElem );
1361  // Read frame XML
1362  double x = itemElem.attribute( QStringLiteral( "sectionX" ) ).toDouble();
1363  double y = itemElem.attribute( QStringLiteral( "sectionY" ) ).toDouble();
1364  double width = itemElem.attribute( QStringLiteral( "sectionWidth" ) ).toDouble();
1365  double height = itemElem.attribute( QStringLiteral( "sectionHeight" ) ).toDouble();
1366  newFrame->setContentSection( QRectF( x, y, width, height ) );
1367  newFrame->setHidePageIfEmpty( itemElem.attribute( QStringLiteral( "hidePageIfEmpty" ), QStringLiteral( "0" ) ).toInt() );
1368  newFrame->setHideBackgroundIfEmpty( itemElem.attribute( QStringLiteral( "hideBackgroundIfEmpty" ), QStringLiteral( "0" ) ).toInt() );
1369  layoutItem->addFrame( newFrame, false );
1370  }
1371 
1372  bool contentModeOK;
1373  layoutItem->setContentMode( static_cast< QgsLayoutItemHtml::ContentMode >( itemElem.attribute( QStringLiteral( "contentMode" ) ).toInt( &contentModeOK ) ) );
1374  if ( !contentModeOK )
1375  {
1376  layoutItem->setContentMode( QgsLayoutItemHtml::ContentMode::Url );
1377  }
1378  layoutItem->setEvaluateExpressions( itemElem.attribute( QStringLiteral( "evaluateExpressions" ), QStringLiteral( "true" ) ) == QLatin1String( "true" ) );
1379  layoutItem->setUseSmartBreaks( itemElem.attribute( QStringLiteral( "useSmartBreaks" ), QStringLiteral( "true" ) ) == QLatin1String( "true" ) );
1380  layoutItem->setMaxBreakDistance( itemElem.attribute( QStringLiteral( "maxBreakDistance" ), QStringLiteral( "10" ) ).toDouble() );
1381  layoutItem->setHtml( itemElem.attribute( QStringLiteral( "html" ) ) );
1382  layoutItem->setUserStylesheet( itemElem.attribute( QStringLiteral( "stylesheet" ) ) );
1383  layoutItem->setUserStylesheetEnabled( itemElem.attribute( QStringLiteral( "stylesheetEnabled" ), QStringLiteral( "false" ) ) == QLatin1String( "true" ) );
1384 
1385  //finally load the set url
1386  QString urlString = itemElem.attribute( QStringLiteral( "url" ) );
1387  if ( !urlString.isEmpty() )
1388  {
1389  layoutItem->setUrl( urlString );
1390  }
1391  layoutItem->loadHtml( true );
1392 
1393  return true;
1394 }
1395 
1396 bool QgsCompositionConverter::readTableXml( QgsLayoutItemAttributeTable *layoutItem, const QDomElement &itemElem, const QgsProject *project )
1397 {
1398 
1399  Q_UNUSED( project )
1400  readOldComposerObjectXml( layoutItem, itemElem );
1401 
1402  //first create the frames
1403  layoutItem->setResizeMode( static_cast< QgsLayoutMultiFrame::ResizeMode >( itemElem.attribute( QStringLiteral( "resizeMode" ), QStringLiteral( "0" ) ).toInt() ) );
1404  QDomNodeList frameList = itemElem.elementsByTagName( QStringLiteral( "ComposerFrame" ) );
1405  for ( int i = 0; i < frameList.size(); ++i )
1406  {
1407  QDomElement frameElem = frameList.at( i ).toElement();
1408  QgsLayoutFrame *newFrame = new QgsLayoutFrame( layoutItem->layout(), layoutItem );
1409  restoreGeneralComposeItemProperties( newFrame, frameElem );
1410  // Read frame XML
1411  double x = itemElem.attribute( QStringLiteral( "sectionX" ) ).toDouble();
1412  double y = itemElem.attribute( QStringLiteral( "sectionY" ) ).toDouble();
1413  double width = itemElem.attribute( QStringLiteral( "sectionWidth" ) ).toDouble();
1414  double height = itemElem.attribute( QStringLiteral( "sectionHeight" ) ).toDouble();
1415  newFrame->setContentSection( QRectF( x, y, width, height ) );
1416  newFrame->setHidePageIfEmpty( itemElem.attribute( QStringLiteral( "hidePageIfEmpty" ), QStringLiteral( "0" ) ).toInt() );
1417  newFrame->setHideBackgroundIfEmpty( itemElem.attribute( QStringLiteral( "hideBackgroundIfEmpty" ), QStringLiteral( "0" ) ).toInt() );
1418  layoutItem->addFrame( newFrame, false );
1419  }
1420 
1421  layoutItem->setEmptyTableBehavior( static_cast<QgsLayoutTable::EmptyTableMode>( itemElem.attribute( QStringLiteral( "emptyTableMode" ), QStringLiteral( "0" ) ).toInt() ) );
1422  layoutItem->setEmptyTableMessage( itemElem.attribute( QStringLiteral( "emptyTableMessage" ), QObject::tr( "No matching records" ) ) );
1423  layoutItem->setShowEmptyRows( itemElem.attribute( QStringLiteral( "showEmptyRows" ), QStringLiteral( "0" ) ).toInt() );
1424  QFont headerFont;
1425  if ( !QgsFontUtils::setFromXmlChildNode( headerFont, itemElem, QStringLiteral( "headerFontProperties" ) ) )
1426  {
1427  headerFont.fromString( itemElem.attribute( QStringLiteral( "headerFont" ), QString() ) );
1428  }
1429  QgsTextFormat headerFormat = layoutItem->headerTextFormat();
1430  headerFormat.setFont( headerFont );
1431  if ( headerFont.pointSizeF() > 0 )
1432  {
1433  headerFormat.setSize( headerFont.pointSizeF() );
1434  headerFormat.setSizeUnit( QgsUnitTypes::RenderPoints );
1435  }
1436  else if ( headerFont.pixelSize() > 0 )
1437  {
1438  headerFormat.setSize( headerFont.pixelSize() );
1439  headerFormat.setSizeUnit( QgsUnitTypes::RenderPixels );
1440  }
1441  headerFormat.setColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "headerFontColor" ), QStringLiteral( "0,0,0,255" ) ) ) );
1442  layoutItem->setHeaderTextFormat( headerFormat );
1443  layoutItem->setHeaderHAlignment( static_cast<QgsLayoutTable::HeaderHAlignment>( itemElem.attribute( QStringLiteral( "headerHAlignment" ), QStringLiteral( "0" ) ).toInt() ) ) ;
1444  layoutItem->setHeaderMode( static_cast<QgsLayoutTable::HeaderMode>( itemElem.attribute( QStringLiteral( "headerMode" ), QStringLiteral( "0" ) ).toInt() ) );
1445 
1446  QFont contentFont;
1447  if ( !QgsFontUtils::setFromXmlChildNode( contentFont, itemElem, QStringLiteral( "contentFontProperties" ) ) )
1448  {
1449  contentFont.fromString( itemElem.attribute( QStringLiteral( "contentFont" ), QString() ) );
1450  }
1451  QgsTextFormat contentFormat = layoutItem->contentTextFormat();
1452  contentFormat.setFont( contentFont );
1453  if ( contentFont.pointSizeF() > 0 )
1454  {
1455  contentFormat.setSize( contentFont.pointSizeF() );
1456  contentFormat.setSizeUnit( QgsUnitTypes::RenderPoints );
1457  }
1458  else if ( contentFont.pixelSize() > 0 )
1459  {
1460  contentFormat.setSize( contentFont.pixelSize() );
1461  contentFormat.setSizeUnit( QgsUnitTypes::RenderPixels );
1462  }
1463  contentFormat.setColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "contentFontColor" ), QStringLiteral( "0,0,0,255" ) ) ) );
1464  layoutItem->setContentTextFormat( contentFormat );
1465 
1466  layoutItem->setCellMargin( itemElem.attribute( QStringLiteral( "cellMargin" ), QStringLiteral( "1.0" ) ).toDouble() );
1467  layoutItem->setGridStrokeWidth( itemElem.attribute( QStringLiteral( "gridStrokeWidth" ), QStringLiteral( "0.5" ) ).toDouble() );
1468  layoutItem->setHorizontalGrid( itemElem.attribute( QStringLiteral( "horizontalGrid" ), QStringLiteral( "1" ) ).toInt() );
1469  layoutItem->setVerticalGrid( itemElem.attribute( QStringLiteral( "verticalGrid" ), QStringLiteral( "1" ) ).toInt() );
1470  layoutItem->setShowGrid( itemElem.attribute( QStringLiteral( "showGrid" ), QStringLiteral( "1" ) ).toInt() );
1471  layoutItem->setGridColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "gridColor" ), QStringLiteral( "0,0,0,255" ) ) ) );
1472  layoutItem->setBackgroundColor( QgsSymbolLayerUtils::decodeColor( itemElem.attribute( QStringLiteral( "backgroundColor" ), QStringLiteral( "255,255,255,0" ) ) ) );
1473  layoutItem->setWrapBehavior( static_cast<QgsLayoutTable::WrapBehavior>( itemElem.attribute( QStringLiteral( "wrapBehavior" ), QStringLiteral( "0" ) ).toInt() ) );
1474 
1475  //restore column specifications
1476  layoutItem->mColumns.clear();
1477  layoutItem->mSortColumns.clear();
1478 
1479  QDomNodeList columnsList = itemElem.elementsByTagName( QStringLiteral( "displayColumns" ) );
1480  if ( !columnsList.isEmpty() )
1481  {
1482  QDomElement columnsElem = columnsList.at( 0 ).toElement();
1483  QDomNodeList columnEntryList = columnsElem.elementsByTagName( QStringLiteral( "column" ) );
1484  for ( int i = 0; i < columnEntryList.size(); ++i )
1485  {
1486  QDomElement columnElem = columnEntryList.at( i ).toElement();
1487  QgsLayoutTableColumn column;
1488  column.mHAlignment = static_cast< Qt::AlignmentFlag >( columnElem.attribute( QStringLiteral( "hAlignment" ), QString::number( Qt::AlignLeft ) ).toInt() );
1489  column.mVAlignment = static_cast< Qt::AlignmentFlag >( columnElem.attribute( QStringLiteral( "vAlignment" ), QString::number( Qt::AlignVCenter ) ).toInt() );
1490  column.mHeading = columnElem.attribute( QStringLiteral( "heading" ), QString() );
1491  column.mAttribute = columnElem.attribute( QStringLiteral( "attribute" ), QString() );
1492  column.mSortByRank = columnElem.attribute( QStringLiteral( "sortByRank" ), QStringLiteral( "0" ) ).toInt();
1493  column.mSortOrder = static_cast< Qt::SortOrder >( columnElem.attribute( QStringLiteral( "sortOrder" ), QString::number( Qt::AscendingOrder ) ).toInt() );
1494  column.mWidth = columnElem.attribute( QStringLiteral( "width" ), QStringLiteral( "0.0" ) ).toDouble();
1495 
1496  QDomNodeList bgColorList = columnElem.elementsByTagName( QStringLiteral( "backgroundColor" ) );
1497  if ( !bgColorList.isEmpty() )
1498  {
1499  QDomElement bgColorElem = bgColorList.at( 0 ).toElement();
1500  bool redOk, greenOk, blueOk, alphaOk;
1501  int bgRed, bgGreen, bgBlue, bgAlpha;
1502  bgRed = bgColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
1503  bgGreen = bgColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
1504  bgBlue = bgColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
1505  bgAlpha = bgColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
1506  if ( redOk && greenOk && blueOk && alphaOk )
1507  {
1508  column.mBackgroundColor = QColor( bgRed, bgGreen, bgBlue, bgAlpha );
1509  }
1510  }
1511  layoutItem->mColumns.append( column );
1512 
1513  // sorting columns are now (QGIS 3.14+) handled in a dedicated list
1514  // copy the display columns if sortByRank > 0 and then, sort them by rank
1516  std::copy_if( layoutItem->mColumns.begin(), layoutItem->mColumns.end(), std::back_inserter( layoutItem->mSortColumns ), []( const QgsLayoutTableColumn & col ) {return col.sortByRank() > 0;} );
1517  std::sort( layoutItem->mSortColumns.begin(), layoutItem->mSortColumns.end(), []( const QgsLayoutTableColumn & a, const QgsLayoutTableColumn & b ) {return a.sortByRank() < b.sortByRank();} );
1519  }
1520  }
1521 
1522  //restore cell styles
1523  QDomNodeList stylesList = itemElem.elementsByTagName( QStringLiteral( "cellStyles" ) );
1524  if ( !stylesList.isEmpty() )
1525  {
1526  QDomElement stylesElem = stylesList.at( 0 ).toElement();
1527 
1528  QMap< QgsLayoutTable::CellStyleGroup, QString >::const_iterator it = layoutItem->mCellStyleNames.constBegin();
1529  for ( ; it != layoutItem->mCellStyleNames.constEnd(); ++it )
1530  {
1531  QString styleName = it.value();
1532  QDomNodeList styleList = stylesElem.elementsByTagName( styleName );
1533  if ( !styleList.isEmpty() )
1534  {
1535  QDomElement styleElem = styleList.at( 0 ).toElement();
1536  QgsLayoutTableStyle *style = layoutItem->mCellStyles.value( it.key() );
1537  if ( style )
1538  style->readXml( styleElem );
1539  }
1540  }
1541  }
1542 
1543  // look for stored layer name
1544  QString layerId = itemElem.attribute( QStringLiteral( "vectorLayer" ) );
1545  QString layerName = itemElem.attribute( QStringLiteral( "vectorLayerName" ) );
1546  QString layerSource = itemElem.attribute( QStringLiteral( "vectorLayerSource" ) );
1547  QString layerProvider = itemElem.attribute( QStringLiteral( "vectorLayerProvider" ) );
1548 
1549  QgsVectorLayerRef layerRef( layerId, layerName, layerSource, layerProvider );
1550  layoutItem->setVectorLayer( layerRef.resolveWeakly( project ) );
1551 
1552  return true;
1553 }
1554 
1555 
1556 template <class T, class T2>
1557 bool QgsCompositionConverter::readPolyXml( T *layoutItem, const QDomElement &itemElem, const QgsProject *project )
1558 {
1559  restoreGeneralComposeItemProperties( layoutItem, itemElem );
1560  QDomNodeList nodeList = itemElem.elementsByTagName( QStringLiteral( "node" ) );
1561  if ( !nodeList.isEmpty() )
1562  {
1563  QPolygonF polygon;
1564  for ( int i = 0; i < nodeList.length(); i++ )
1565  {
1566  QDomElement node = nodeList.at( i ).toElement();
1567  polygon.append( QPointF( node.attribute( QStringLiteral( "x" ) ).toDouble( ), node.attribute( QStringLiteral( "y" ) ).toDouble() ) );
1568  }
1569  layoutItem->setNodes( polygon );
1570  }
1571  if ( itemElem.elementsByTagName( QStringLiteral( "symbol" ) ).size() )
1572  {
1573  QDomElement symbolElement = itemElem.elementsByTagName( QStringLiteral( "symbol" ) ).at( 0 ).toElement();
1574  QgsReadWriteContext context;
1575  if ( project )
1576  context.setPathResolver( project->pathResolver( ) );
1577  T2 *styleSymbol = QgsSymbolLayerUtils::loadSymbol<T2>( symbolElement, context );
1578  if ( styleSymbol )
1579  layoutItem->setSymbol( styleSymbol );
1580  }
1581  // Disable frame for shapes
1582  layoutItem->setFrameEnabled( false );
1583  layoutItem->setBackgroundEnabled( false );
1584  return true;
1585 }
1586 
1587 
1588 bool QgsCompositionConverter::readXml( QgsLayoutItem *layoutItem, const QDomElement &itemElem )
1589 {
1590  if ( itemElem.isNull() )
1591  {
1592  return false;
1593  }
1594 
1595  readOldComposerObjectXml( layoutItem, itemElem );
1596 
1597  //uuid
1598  layoutItem->mUuid = itemElem.attribute( QStringLiteral( "uuid" ), QUuid::createUuid().toString() );
1599 
1600  // temporary for groups imported from templates
1601  layoutItem->mTemplateUuid = itemElem.attribute( QStringLiteral( "templateUuid" ) );
1602 
1603  //id
1604  QString id = itemElem.attribute( QStringLiteral( "id" ), QString() );
1605  layoutItem->setId( id );
1606 
1607  //frame
1608  QString frame = itemElem.attribute( QStringLiteral( "frame" ) );
1609  layoutItem->setFrameEnabled( frame.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 ) ;
1610 
1611  //frame
1612  QString background = itemElem.attribute( QStringLiteral( "background" ) );
1613  layoutItem->setBackgroundEnabled( background.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 );
1614 
1615  //position lock for mouse moves/resizes
1616  QString positionLock = itemElem.attribute( QStringLiteral( "positionLock" ) );
1617  layoutItem->setLocked( positionLock.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 );
1618 
1619  //visibility
1620  layoutItem->setVisibility( itemElem.attribute( QStringLiteral( "visibility" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) );
1621 
1622  layoutItem->mParentGroupUuid = itemElem.attribute( QStringLiteral( "groupUuid" ) );
1623  if ( !layoutItem->mParentGroupUuid.isEmpty() )
1624  {
1625  if ( QgsLayoutItemGroup *group = layoutItem->parentGroup() )
1626  {
1627  group->addItem( layoutItem );
1628  }
1629  }
1630  layoutItem->mTemplateUuid = itemElem.attribute( QStringLiteral( "templateUuid" ) );
1631 
1632 
1633  QRectF position = itemPosition( layoutItem, itemElem );
1634 
1635  // TODO: missing?
1636  // mLastValidViewScaleFactor = itemElem.attribute( QStringLiteral( "lastValidViewScaleFactor" ), QStringLiteral( "-1" ) ).toDouble();
1637 
1638  layoutItem->setZValue( itemElem.attribute( QStringLiteral( "zValue" ) ).toDouble() );
1639 
1640  //pen
1641  QDomNodeList frameColorList = itemElem.elementsByTagName( QStringLiteral( "FrameColor" ) );
1642  if ( !frameColorList.isEmpty() )
1643  {
1644  QDomElement frameColorElem = frameColorList.at( 0 ).toElement();
1645  bool redOk, greenOk, blueOk, alphaOk, widthOk;
1646  int penRed, penGreen, penBlue, penAlpha;
1647  double penWidth;
1648 
1649  penWidth = itemElem.attribute( QStringLiteral( "outlineWidth" ) ).toDouble( &widthOk );
1650  penRed = frameColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
1651  penGreen = frameColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
1652  penBlue = frameColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
1653  penAlpha = frameColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
1654  layoutItem->setFrameJoinStyle( QgsSymbolLayerUtils::decodePenJoinStyle( itemElem.attribute( QStringLiteral( "frameJoinStyle" ), QStringLiteral( "miter" ) ) ) );
1655 
1656  if ( redOk && greenOk && blueOk && alphaOk && widthOk )
1657  {
1658  layoutItem->setFrameStrokeColor( QColor( penRed, penGreen, penBlue, penAlpha ) );
1659  layoutItem->setFrameStrokeWidth( QgsLayoutMeasurement( penWidth ) );
1660  QPen framePen( layoutItem->frameStrokeColor() );
1661  framePen.setWidthF( layoutItem->frameStrokeWidth( ).length() );
1662  framePen.setJoinStyle( layoutItem->frameJoinStyle( ) );
1663  layoutItem->setPen( framePen );
1664  //apply any data defined settings
1665  layoutItem->refreshFrame( false );
1666  }
1667  }
1668 
1669  //brush
1670  QDomNodeList bgColorList = itemElem.elementsByTagName( QStringLiteral( "BackgroundColor" ) );
1671  if ( !bgColorList.isEmpty() )
1672  {
1673  QDomElement bgColorElem = bgColorList.at( 0 ).toElement();
1674  bool redOk, greenOk, blueOk, alphaOk;
1675  int bgRed, bgGreen, bgBlue, bgAlpha;
1676  bgRed = bgColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
1677  bgGreen = bgColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
1678  bgBlue = bgColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
1679  bgAlpha = bgColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
1680  if ( redOk && greenOk && blueOk && alphaOk )
1681  {
1682  layoutItem->mBackgroundColor = QColor( bgRed, bgGreen, bgBlue, bgAlpha );
1683  layoutItem->setBrush( QBrush( layoutItem->mBackgroundColor, Qt::SolidPattern ) );
1684  }
1685  //apply any data defined settings
1686  layoutItem->refreshBackgroundColor( false );
1687  }
1688 
1689  //blend mode
1690  layoutItem->setBlendMode( QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( itemElem.attribute( QStringLiteral( "blendMode" ), QStringLiteral( "0" ) ).toUInt() ) ) );
1691 
1692  //opacity
1693  if ( itemElem.hasAttribute( QStringLiteral( "opacity" ) ) )
1694  {
1695  layoutItem->setItemOpacity( itemElem.attribute( QStringLiteral( "opacity" ), QStringLiteral( "1" ) ).toDouble() );
1696  }
1697  else
1698  {
1699  layoutItem->setItemOpacity( 1.0 - itemElem.attribute( QStringLiteral( "transparency" ), QStringLiteral( "0" ) ).toInt() / 100.0 );
1700  }
1701 
1702  layoutItem->mExcludeFromExports = itemElem.attribute( QStringLiteral( "excludeFromExports" ), QStringLiteral( "0" ) ).toInt();
1703  layoutItem->mEvaluatedExcludeFromExports = layoutItem->mExcludeFromExports;
1704 
1705  // positioning
1706  layoutItem->attemptSetSceneRect( position );
1707  //rotation
1708  layoutItem->setItemRotation( itemElem.attribute( QStringLiteral( "itemRotation" ), QStringLiteral( "0" ) ).toDouble(), false );
1709 
1710  layoutItem->mBlockUndoCommands = false;
1711 
1712  return true;
1713 }
1714 
1715 
1716 
1717 bool QgsCompositionConverter::readOldComposerObjectXml( QgsLayoutObject *layoutItem,
1718  const QDomElement &itemElem )
1719 {
1720  if ( itemElem.isNull() )
1721  {
1722  return false;
1723  }
1724 
1725  //old (pre 3.0) data defined properties
1726  QgsCompositionConverter::readOldDataDefinedPropertyMap( itemElem, layoutItem->mDataDefinedProperties );
1727 
1728  QDomNode propsNode = itemElem.namedItem( QStringLiteral( "dataDefinedProperties" ) );
1729  if ( !propsNode.isNull() )
1730  {
1731  layoutItem->mDataDefinedProperties.readXml( propsNode.toElement(), sPropertyDefinitions );
1732  }
1734  {
1735  // upgrade transparency -> opacity
1737  exp = QStringLiteral( "100.0 - (%1)" ).arg( exp );
1740  }
1741 
1742  //custom properties
1743  layoutItem->mCustomProperties.readXml( itemElem );
1744 
1745  return true;
1746 }
1747 
1748 
1749 void QgsCompositionConverter::readOldDataDefinedPropertyMap( const QDomElement &itemElem, QgsPropertyCollection &dataDefinedProperties )
1750 {
1751  const QgsPropertiesDefinition defs = QgsCompositionConverter::propertyDefinitions();
1752  QgsPropertiesDefinition::const_iterator i = defs.constBegin();
1753  for ( ; i != defs.constEnd(); ++i )
1754  {
1755  QString elemName = i.value().name();
1756  QDomNodeList ddNodeList = itemElem.elementsByTagName( elemName );
1757  if ( !ddNodeList.isEmpty() )
1758  {
1759  QDomElement ddElem = ddNodeList.at( 0 ).toElement();
1760  QgsProperty prop = readOldDataDefinedProperty( static_cast< QgsCompositionConverter::DataDefinedProperty >( i.key() ), ddElem );
1761  if ( prop )
1762  dataDefinedProperties.setProperty( i.key(), prop );
1763  }
1764  }
1765 }
1766 
1767 QgsProperty QgsCompositionConverter::readOldDataDefinedProperty( const QgsCompositionConverter::DataDefinedProperty property, const QDomElement &ddElem )
1768 {
1770  {
1771  //invalid property
1772  return QgsProperty();
1773  }
1774 
1775  QString active = ddElem.attribute( QStringLiteral( "active" ) );
1776  bool isActive = false;
1777  if ( active.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
1778  {
1779  isActive = true;
1780  }
1781  QString field = ddElem.attribute( QStringLiteral( "field" ) );
1782  QString expr = ddElem.attribute( QStringLiteral( "expr" ) );
1783 
1784  QString useExpr = ddElem.attribute( QStringLiteral( "useExpr" ) );
1785  bool isExpression = false;
1786  if ( useExpr.compare( QLatin1String( "true" ), Qt::CaseInsensitive ) == 0 )
1787  {
1788  isExpression = true;
1789  }
1790 
1791  if ( isExpression )
1792  return QgsProperty::fromExpression( expr, isActive );
1793  else
1794  return QgsProperty::fromField( field, isActive );
1795 }
QgsCompositionConverter::ItemHeight
@ ItemHeight
Height of item.
Definition: qgscompositionconverter.h:77
QgsScaleBarSettings::SegmentSizeMode
SegmentSizeMode
Modes for setting size for scale bar segments.
Definition: qgsscalebarsettings.h:58
QgsLayoutItem::parentGroup
QgsLayoutItemGroup * parentGroup() const
Returns the item's parent group, if the item is part of a QgsLayoutItemGroup group.
Definition: qgslayoutitem.cpp:230
QgsLayoutTable::setHeaderMode
void setHeaderMode(HeaderMode mode)
Sets the display mode for headers in the table.
Definition: qgslayouttable.cpp:776
QgsLayoutItemScaleBar::setFontColor
Q_DECL_DEPRECATED void setFontColor(const QColor &color)
Sets the color used for drawing text in the scalebar.
Definition: qgslayoutitemscalebar.cpp:664
QgsLayoutObject::layout
const QgsLayout * layout() const
Returns the layout the object is attached to.
Definition: qgslayoutobject.cpp:126
qgslayoutitemgroup.h
QgsLayoutItemPicture::setLinkedMap
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map object for rotation.
Definition: qgslayoutitempicture.cpp:666
QgsLayoutItemScaleBar::setFont
Q_DECL_DEPRECATED void setFont(const QFont &font)
Sets the font used for drawing text in the scalebar.
Definition: qgslayoutitemscalebar.cpp:648
QgsLayoutAtlas::setPageNameExpression
void setPageNameExpression(const QString &expression)
Sets the expression (or field name) used for calculating the page name.
Definition: qgslayoutatlas.cpp:165
QgsReadWriteContext::setPathResolver
void setPathResolver(const QgsPathResolver &resolver)
Sets up path resolver for conversion between relative and absolute paths.
Definition: qgsreadwritecontext.cpp:52
QgsLayoutItemPolyline::setArrowHeadStrokeWidth
void setArrowHeadStrokeWidth(double width)
Sets the pen width in millimeters for the stroke of the arrow head.
Definition: qgslayoutitempolyline.cpp:383
QgsLayoutItemMapGrid
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapgrid.h:141
QgsLegendStyle::Symbol
@ Symbol
Symbol icon (excluding label)
Definition: qgslegendstyle.h:47
qgslayoutitemmapgrid.h
qgslayoutitempolygon.h
QgsProperty::fromField
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
Definition: qgsproperty.cpp:220
QgsLayout::addLayoutItem
void addLayoutItem(QgsLayoutItem *item)
Adds an item to the layout.
Definition: qgslayout.cpp:540
QgsLegendStyle::Style
Style
Component of legends which can be styled.
Definition: qgslegendstyle.h:41
QgsSymbolLayerUtils::encodeColor
static QString encodeColor(const QColor &color)
Definition: qgssymbollayerutils.cpp:52
QgsLayoutItemShape
Layout item for basic filled shapes (e.g.
Definition: qgslayoutitemshape.h:33
QgsLayoutNodesItem::setNodes
void setNodes(const QPolygonF &nodes)
Sets the nodes the shape consists of.
Definition: qgslayoutitemnodeitem.cpp:27
QgsLayoutItemMapGrid::setFrameWidth
void setFrameWidth(const double width)
Sets the grid frame width (in layout units).
Definition: qgslayoutitemmapgrid.cpp:2424
QgsCompositionConverter::MapXMin
@ MapXMin
Map extent x minimum.
Definition: qgscompositionconverter.h:88
qgsmaplayerstylemanager.h
QgsLayoutItemHtml::setUserStylesheetEnabled
void setUserStylesheetEnabled(bool enabled)
Sets whether user stylesheets are enabled for the HTML content.
Definition: qgslayoutitemhtml.cpp:443
QgsCompositionConverter::MapScale
@ MapScale
Map scale.
Definition: qgscompositionconverter.h:87
qgslayoutitemattributetable.h
qgslayoutundostack.h
QgsLayoutTable::setHeaderHAlignment
void setHeaderHAlignment(HeaderHAlignment alignment)
Sets the horizontal alignment for table headers.
Definition: qgslayouttable.cpp:763
QgsLayoutTable::HeaderHAlignment
HeaderHAlignment
Controls how headers are horizontally aligned in a table.
Definition: qgslayouttable.h:122
QgsTextFormat::setFont
void setFont(const QFont &font)
Sets the font used for rendering text.
Definition: qgstextformat.cpp:177
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsLayoutItemPage
Item representing the paper in a layout.
Definition: qgslayoutitempage.h:55
QgsLayoutTable::setContentTextFormat
void setContentTextFormat(const QgsTextFormat &format)
Sets the format used to draw content text in the table.
Definition: qgslayouttable.cpp:832
QgsLayoutItemMapGrid::setOffsetX
void setOffsetX(double offset)
Sets the offset for grid lines in the x-direction.
Definition: qgslayoutitemmapgrid.cpp:2280
QgsLayoutItem::setFrameEnabled
virtual void setFrameEnabled(bool drawFrame)
Sets whether this item has a frame drawn around it or not.
Definition: qgslayoutitem.cpp:833
QgsLayoutItem::frameEnabled
bool frameEnabled() const
Returns true if the item includes a frame.
Definition: qgslayoutitem.h:730
QgsPainting::BlendMode
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Definition: qgspainting.h:37
QgsLayoutItemScaleBar::setAlignment
void setAlignment(QgsScaleBarSettings::Alignment alignment)
Sets the scalebar alignment.
Definition: qgslayoutitemscalebar.cpp:407
QgsLayoutItemHtml::setUseSmartBreaks
void setUseSmartBreaks(bool useSmartBreaks)
Sets whether the html item should use smart breaks.
Definition: qgslayoutitemhtml.cpp:420
QgsLayoutItemMap::updateBoundingRect
void updateBoundingRect()
Updates the bounding rect of this item. Call this function before doing any changes related to annota...
Definition: qgslayoutitemmap.cpp:1824
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsCompositionConverter::PositionY
@ PositionY
Y position on page.
Definition: qgscompositionconverter.h:75
QgsLayoutFrame::setHideBackgroundIfEmpty
void setHideBackgroundIfEmpty(bool hideBackgroundIfEmpty)
Sets whether the background and frame stroke should be hidden if this frame is empty.
Definition: qgslayoutframe.cpp:94
QgsLayoutItemMapGrid::setOffsetY
void setOffsetY(double offset)
Sets the offset for grid lines in the y-direction.
Definition: qgslayoutitemmapgrid.cpp:2291
QgsPropertyDefinition::BlendMode
@ BlendMode
Blend mode.
Definition: qgsproperty.h:68
QgsCompositionConverter::BlendMode
@ BlendMode
Item blend mode.
Definition: qgscompositionconverter.h:81
QgsLayoutItemPolyline::setArrowHeadFillColor
void setArrowHeadFillColor(const QColor &color)
Sets the color used to fill the arrow head.
Definition: qgslayoutitempolyline.cpp:377
QgsLayout::itemByUuid
QgsLayoutItem * itemByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not...
Definition: qgslayout.cpp:238
QgsUnitTypes::DistanceUnknownUnit
@ DistanceUnknownUnit
Unknown distance unit.
Definition: qgsunittypes.h:78
QgsLayoutItemPolyline::setEndSvgMarkerPath
void setEndSvgMarkerPath(const QString &path)
Sets the path to a SVG marker to draw at the end of the line.
Definition: qgslayoutitempolyline.cpp:354
QgsLayoutItem::setFrameStrokeWidth
virtual void setFrameStrokeWidth(QgsLayoutMeasurement width)
Sets the frame stroke width.
Definition: qgslayoutitem.cpp:859
QgsLayoutItemScaleBar::setSegmentSizeMode
void setSegmentSizeMode(QgsScaleBarSettings::SegmentSizeMode mode)
Sets the size mode for scale bar segments.
Definition: qgslayoutitemscalebar.cpp:139
QgsLayoutItemLegend::setTitle
void setTitle(const QString &title)
Sets the legend title.
Definition: qgslayoutitemlegend.cpp:295
QgsLayoutMeasurement::length
double length() const
Returns the length of the measurement.
Definition: qgslayoutmeasurement.h:48
QgsLayoutItemMapGrid::setFramePenSize
void setFramePenSize(const double width)
Sets the width of the stroke drawn in the grid frame.
Definition: qgslayoutitemmapgrid.cpp:2436
QgsCompositionConverter::PaperWidth
@ PaperWidth
Paper width.
Definition: qgscompositionconverter.h:68
QgsPropertyDefinition::DataTypeString
@ DataTypeString
Property requires a string value.
Definition: qgsproperty.h:93
QgsLayoutItemLabel::setMarginY
void setMarginY(double margin)
Sets the vertical margin between the edge of the frame and the label contents, in layout units.
Definition: qgslayoutitemlabel.cpp:332
qgsreadwritecontext.h
QgsCompositionConverter::convertCompositionTemplate
static QDomDocument convertCompositionTemplate(const QDomDocument &document, QgsProject *project)
Convert a composition template document to a layout template.
Definition: qgscompositionconverter.cpp:468
QgsCompositionConverter::BackgroundColor
@ BackgroundColor
Item background color.
Definition: qgscompositionconverter.h:84
QgsLayoutItem::attemptMoveBy
void attemptMoveBy(double deltaX, double deltaY)
Attempts to shift the item's position by a specified deltaX and deltaY, in layout units.
Definition: qgslayoutitem.cpp:526
QgsCompositionConverter::MapXMax
@ MapXMax
Map extent x maximum.
Definition: qgscompositionconverter.h:90
QgsLayoutItemHtml::setHtml
void setHtml(const QString &html)
Sets the html to display in the item when the item is using the QgsLayoutItemHtml::ManualHtml mode.
Definition: qgslayoutitemhtml.cpp:110
QgsLayoutItemPolyline
Layout item for node based polyline shapes.
Definition: qgslayoutitempolyline.h:33
QgsCompositionConverter::MapStylePreset
@ MapStylePreset
Layer and style map theme.
Definition: qgscompositionconverter.h:94
QgsLayoutObject::mCustomProperties
QgsObjectCustomProperties mCustomProperties
Custom properties for object.
Definition: qgslayoutobject.h:348
QgsLayoutItemMap::setFollowVisibilityPresetName
void setFollowVisibilityPresetName(const QString &name)
Sets preset name for map rendering.
Definition: qgslayoutitemmap.cpp:350
qgslayoutnortharrowhandler.h
QgsProject::pathResolver
QgsPathResolver pathResolver() const
Returns path resolver object with considering whether the project uses absolute or relative paths and...
Definition: qgsproject.cpp:2674
QgsUnitTypes::RenderPoints
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:172
qgssymbollayerutils.h
QgsLayoutItemScaleBar::setBoxContentSpace
void setBoxContentSpace(double space)
Sets the space (margin) between the scalebar box and content in millimeters.
Definition: qgslayoutitemscalebar.cpp:248
QgsAbstractPropertyCollection::readXml
virtual bool readXml(const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
Reads property collection state from an XML element.
Definition: qgspropertycollection.cpp:108
QgsLayoutItemLabel::setFontColor
void setFontColor(const QColor &color)
Sets the label font color.
Definition: qgslayoutitemlabel.h:198
QgsLayoutItemMapGrid::setBlendMode
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blending mode used for drawing the grid.
Definition: qgslayoutitemmapgrid.h:302
QgsCompositionConverter::createLayoutFromCompositionXml
static std::unique_ptr< QgsPrintLayout > createLayoutFromCompositionXml(const QDomElement &composerElement, QgsProject *project)
createLayoutFromCompositionXml is a factory that creates layout instances from a QGIS 2....
Definition: qgscompositionconverter.cpp:122
QgsCompositionConverter::TestProperty
@ TestProperty
Dummy property with no effect on item.
Definition: qgscompositionconverter.h:65
QgsLayoutItemScaleBar::setLinkedMap
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map item linked to the scalebar.
Definition: qgslayoutitemscalebar.cpp:259
QgsLayoutPageCollection::spaceBetweenPages
double spaceBetweenPages() const
Returns the space between pages, in layout units.
Definition: qgslayoutpagecollection.cpp:273
QgsLayoutItem::attemptSetSceneRect
void attemptSetSceneRect(const QRectF &rect, bool includesFrame=false)
Attempts to update the item's position and size to match the passed rect in layout coordinates.
Definition: qgslayoutitem.cpp:510
QgsLayoutItem::refreshBackgroundColor
void refreshBackgroundColor(bool updateItem=true)
Refresh item's background color, considering data defined colors.
Definition: qgslayoutitem.cpp:1493
qgslayoutmultiframe.h
QgsProperty::asExpression
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
Definition: qgsproperty.cpp:332
QgsCompositionConverter::MapRotation
@ MapRotation
Map rotation.
Definition: qgscompositionconverter.h:86
QgsPropertyDefinition::IntegerPositiveGreaterZero
@ IntegerPositiveGreaterZero
Non-zero positive integer values.
Definition: qgsproperty.h:57
QgsLayoutTable::setGridColor
void setGridColor(const QColor &color)
Sets the color used for grid lines in the table.
Definition: qgslayouttable.cpp:875
QgsLayoutItemHtml
A layout multiframe subclass for HTML content.
Definition: qgslayoutitemhtml.h:37
QgsLayoutItemScaleBar::setLineSymbol
void setLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render the scalebar (only used for some scalebar types).
Definition: qgslayoutitemscalebar.cpp:192
QgsLayoutObject::mDataDefinedProperties
QgsPropertyCollection mDataDefinedProperties
Definition: qgslayoutobject.h:345
QgsLayoutItemMapGrid::setStyle
void setStyle(GridStyle style)
Sets the grid style, which controls how the grid is drawn over the map's contents.
Definition: qgslayoutitemmapgrid.cpp:2324
QgsLayoutItemMapGrid::GridStyle
GridStyle
Grid drawing style.
Definition: qgslayoutitemmapgrid.h:162
QgsLayoutTable::setBackgroundColor
void setBackgroundColor(const QColor &color)
Sets the color used for background of table.
Definition: qgslayouttable.cpp:916
QgsLayoutItemShape::setCornerRadius
void setCornerRadius(QgsLayoutMeasurement radius)
Sets the corner radius for rounded rectangle corners.
Definition: qgslayoutitemshape.cpp:154
QgsLayoutItemPage::setPageSize
void setPageSize(const QgsLayoutSize &size)
Sets the size of the page.
Definition: qgslayoutitempage.cpp:70
QgsLayoutItemMap::AtlasScalingMode
AtlasScalingMode
Scaling modes used for the serial rendering (atlas)
Definition: qgslayoutitemmap.h:328
QgsPropertyDefinition::Double
@ Double
Double value (including negative values)
Definition: qgsproperty.h:58
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsLayoutTable::setGridStrokeWidth
void setGridStrokeWidth(double width)
Sets the width in mm for grid lines in the table.
Definition: qgslayouttable.cpp:861
QgsObjectCustomProperties::readXml
void readXml(const QDomNode &parentNode, const QString &keyStartsWith=QString())
Read store contents from an XML node.
Definition: qgsobjectcustomproperties.cpp:50
QgsLayoutItemLegend::setFontColor
void setFontColor(const QColor &color)
Sets the legend font color.
Definition: qgslayoutitemlegend.cpp:391
QgsLayoutItemScaleBar::setMaximumBarWidth
void setMaximumBarWidth(double maxWidth)
Sets the maximum width (in millimeters) for scale bar segments.
Definition: qgslayoutitemscalebar.cpp:163
QgsLayoutAtlas::setEnabled
void setEnabled(bool enabled)
Sets whether the atlas is enabled.
Definition: qgslayoutatlas.cpp:123
QgsLayoutItemMapGrid::setFramePenColor
void setFramePenColor(const QColor &color)
Sets the color of the stroke drawn in the grid frame.
Definition: qgslayoutitemmapgrid.h:962
qgslayoutitemlabel.h
QgsLayoutItemHtml::setUserStylesheet
void setUserStylesheet(const QString &stylesheet)
Sets the user stylesheet CSS rules to use while rendering the HTML content.
Definition: qgslayoutitemhtml.cpp:434
QgsLayoutItemLabel::setHAlign
void setHAlign(Qt::AlignmentFlag alignment)
Sets the horizontal alignment of the label.
Definition: qgslayoutitemlabel.h:140
QgsLayoutItemMap::setCrs
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the map's preset crs (coordinate reference system).
Definition: qgslayoutitemmap.cpp:301
QgsProperty::fromExpression
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
Definition: qgsproperty.cpp:212
field
const QgsField & field
Definition: qgsfield.h:456
qgsfontutils.h
QgsUnitTypes::DistanceUnit
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:68
QgsLayoutItemHtml::setUrl
void setUrl(const QUrl &url)
Sets the url for content to display in the item when the item is using the QgsLayoutItemHtml::Url mod...
Definition: qgslayoutitemhtml.cpp:98
QgsLayoutItemLabel::setVAlign
void setVAlign(Qt::AlignmentFlag alignment)
Sets for the vertical alignment of the label.
Definition: qgslayoutitemlabel.h:147
QgsLayoutItemPolyline::setStartSvgMarkerPath
void setStartSvgMarkerPath(const QString &path)
Sets the path to a SVG marker to draw at the start of the line.
Definition: qgslayoutitempolyline.cpp:337
QgsReadWriteContext::setProjectTranslator
void setProjectTranslator(QgsProjectTranslator *projectTranslator)
Sets the project translator.
Definition: qgsreadwritecontext.cpp:87
QgsCoordinateReferenceSystem::readXml
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
Definition: qgscoordinatereferencesystem.cpp:2018
QgsLegendStyle::SymbolLabel
@ SymbolLabel
Symbol label (excluding icon)
Definition: qgslegendstyle.h:48
QgsLayoutTable::setEmptyTableBehavior
void setEmptyTableBehavior(EmptyTableMode mode)
Sets the behavior mode for empty tables with no content rows.
Definition: qgslayouttable.cpp:663
QgsSymbolLayerUtils::decodeColor
static QColor decodeColor(const QString &str)
Definition: qgssymbollayerutils.cpp:57
QgsLayoutItemScaleBar::setHeight
void setHeight(double height)
Sets the scalebar height (in millimeters).
Definition: qgslayoutitemscalebar.h:464
QgsLayoutTable::setShowGrid
void setShowGrid(bool showGrid)
Sets whether grid lines should be drawn in the table.
Definition: qgslayouttable.cpp:847
QgsLayoutItem::ReferencePoint
ReferencePoint
Fixed position reference point.
Definition: qgslayoutitem.h:202
QgsLineSymbol::setWidth
void setWidth(double width)
Sets the width for the whole line symbol.
Definition: qgssymbol.cpp:1960
QgsCompositionConverter::ItemRotation
@ ItemRotation
Rotation of item.
Definition: qgscompositionconverter.h:78
QgsLayoutItem::sizeWithUnits
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
Definition: qgslayoutitem.h:671
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsLayoutItem::refreshFrame
void refreshFrame(bool updateItem=true)
Refresh item's frame, considering data defined colors and frame size.
Definition: qgslayoutitem.cpp:1458
QgsCompositionConverter::PageNumber
@ PageNumber
Page number for item placement.
Definition: qgscompositionconverter.h:73
QgsCompositionConverter::Transparency
@ Transparency
Item transparency (deprecated)
Definition: qgscompositionconverter.h:79
QgsProject
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:95
QgsPropertyCollection::property
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
Definition: qgspropertycollection.cpp:214
QgsPropertyDefinition::String
@ String
Any string value.
Definition: qgsproperty.h:62
QgsLayoutItemScaleBar::setLabelBarSpace
void setLabelBarSpace(double space)
Sets the spacing (in millimeters) between labels and the scalebar.
Definition: qgslayoutitemscalebar.h:488
QgsLayoutAtlas::filterFeatures
bool filterFeatures() const
Returns true if features should be filtered in the coverage layer.
Definition: qgslayoutatlas.h:208
qgslayoutframe.h
QgsLayoutItemLegend
A layout item subclass for map legends.
Definition: qgslayoutitemlegend.h:114
QgsLegendStyle::Title
@ Title
Legend title.
Definition: qgslegendstyle.h:44
QgsLayoutItemPolyline::setArrowHeadStrokeColor
void setArrowHeadStrokeColor(const QColor &color)
Sets the color used to draw the stroke around the arrow head.
Definition: qgslayoutitempolyline.cpp:371
QgsPropertyDefinition::Rotation
@ Rotation
Rotation (value between 0-360 degrees)
Definition: qgsproperty.h:61
QgsLayoutTable::mSortColumns
QgsLayoutTableSortColumns mSortColumns
Columns to sort the table.
Definition: qgslayouttable.h:618
QgsCompositionConverter::MapYMax
@ MapYMax
Map extent y maximum.
Definition: qgscompositionconverter.h:91
QgsUnitTypes::decodeDistanceUnit
static Q_INVOKABLE QgsUnitTypes::DistanceUnit decodeDistanceUnit(const QString &string, bool *ok=nullptr)
Decodes a distance unit from a string.
Definition: qgsunittypes.cpp:165
QgsLayoutItemScaleBar::setNumberOfSegments
void setNumberOfSegments(int segments)
Sets the number of segments included in the scalebar.
Definition: qgslayoutitemscalebar.cpp:116
QgsLayoutItemPolyline::setStartMarker
void setStartMarker(MarkerMode mode)
Sets the start marker mode, which controls what marker is drawn at the start of the line.
Definition: qgslayoutitempolyline.cpp:305
Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:797
QgsLayoutItem::hasBackground
bool hasBackground() const
Returns true if the item has a background.
Definition: qgslayoutitem.h:800
QgsTextFormat
Container for all settings relating to text rendering.
Definition: qgstextformat.h:40
QgsTextFormat::setColor
void setColor(const QColor &color)
Sets the color that text will be rendered in.
Definition: qgstextformat.cpp:237
QgsLayoutItemHtml::loadHtml
void loadHtml(bool useCache=false, const QgsExpressionContext *context=nullptr)
Reloads the html source from the url and redraws the item.
Definition: qgslayoutitemhtml.cpp:126
QgsLayoutItemHtml::ContentMode
ContentMode
Source modes for the HTML content to render in the item.
Definition: qgslayoutitemhtml.h:44
QgsPropertiesDefinition
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Definition: qgspropertycollection.h:29
QgsCompositionConverter::MapAtlasMargin
@ MapAtlasMargin
Map atlas margin.
Definition: qgscompositionconverter.h:92
QgsLayoutItem::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the item's composition blending mode.
Definition: qgslayoutitem.cpp:899
QgsLayerTree
Namespace with helper functions for layer tree operations.
Definition: qgslayertree.h:33
QgsPrintLayout
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Definition: qgsprintlayout.h:31
QgsLayoutItem::frameStrokeWidth
QgsLayoutMeasurement frameStrokeWidth() const
Returns the frame's stroke width.
Definition: qgslayoutitem.h:775
qgslayouttable.h
QgsCompositionConverter::LegendColumnCount
@ LegendColumnCount
Legend column count.
Definition: qgscompositionconverter.h:104
QgsLayoutTable::setVerticalGrid
void setVerticalGrid(bool verticalGrid)
Sets whether the grid's vertical lines should be drawn in the table.
Definition: qgslayouttable.cpp:902
QgsLayoutItemLegend::setLineSpacing
void setLineSpacing(double spacing)
Sets the spacing in-between multiple lines.
Definition: qgslayoutitemlegend.cpp:361
QgsScaleBarSettings::Alignment
Alignment
Scalebar alignment.
Definition: qgsscalebarsettings.h:48
QgsLayoutFrame
Base class for frame items, which form a layout multiframe item.
Definition: qgslayoutframe.h:32
QgsLayoutItemLegend::setStyle
void setStyle(QgsLegendStyle::Style component, const QgsLegendStyle &style)
Sets the style of component to style for the legend.
Definition: qgslayoutitemlegend.cpp:331
QgsLayoutItemScaleBar::setSubdivisionLineSymbol
void setSubdivisionLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render the scalebar subdivisions (only used for some scalebar types).
Definition: qgslayoutitemscalebar.cpp:212
QgsLayoutItemLegend::setSplitLayer
void setSplitLayer(bool enabled)
Sets whether the legend items from a single layer can be split over multiple columns.
Definition: qgslayoutitemlegend.cpp:491
QgsLayoutFrame::setHidePageIfEmpty
void setHidePageIfEmpty(bool hidePageIfEmpty)
Sets whether the page should be hidden (ie, not included in layout exports) if this frame is empty.
Definition: qgslayoutframe.cpp:89
QgsLayoutItemScaleBar::setUnits
void setUnits(QgsUnitTypes::DistanceUnit units)
Sets the distance units used by the scalebar.
Definition: qgslayoutitemscalebar.cpp:414
QgsLayoutItemScaleBar::fillSymbol
QgsFillSymbol * fillSymbol() const
Returns the primary fill symbol used to render the scalebar (only used for some scalebar types).
Definition: qgslayoutitemscalebar.cpp:217
QgsLayoutItemMapGrid::AnnotationDirection
AnnotationDirection
Direction of grid annotations.
Definition: qgslayoutitemmapgrid.h:193
QgsLayoutItemMap::setAtlasScalingMode
void setAtlasScalingMode(AtlasScalingMode mode)
Sets the current atlas scaling mode.
Definition: qgslayoutitemmap.h:665
QgsLayoutItem::frameJoinStyle
Qt::PenJoinStyle frameJoinStyle() const
Returns the join style used for drawing the item's frame.
Definition: qgslayoutitem.h:784
qgsDoubleNear
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:315
QgsPropertyDefinition::ColorWithAlpha
@ ColorWithAlpha
Color with alpha channel.
Definition: qgsproperty.h:65
QgsLayoutFrame::setContentSection
void setContentSection(const QRectF &section)
Sets the visible part of the multiframe's content which is visible within this frame (relative to the...
Definition: qgslayoutframe.h:61
QgsCompositionConverter::isCompositionTemplate
static bool isCompositionTemplate(const QDomDocument &document)
Check if the given document is a composition template.
Definition: qgscompositionconverter.cpp:463
QgsLayoutTable::setCellMargin
void setCellMargin(double margin)
Sets the margin distance in mm between cell borders and their contents.
Definition: qgslayouttable.cpp:648
QgsLayoutItemLegend::setEqualColumnWidth
void setEqualColumnWidth(bool equalize)
Sets whether column widths should be equalized.
Definition: qgslayoutitemlegend.cpp:501
QgsLayoutItemLabel::setText
void setText(const QString &text)
Sets the label's preset text.
Definition: qgslayoutitemlabel.cpp:224
QgsLayoutNorthArrowHandler::setNorthOffset
void setNorthOffset(double offset)
Sets the offset added to the arrows's rotation from a map's North.
Definition: qgslayoutnortharrowhandler.cpp:118
QgsLayoutItemLegend::setRasterStrokeColor
void setRasterStrokeColor(const QColor &color)
Sets the stroke color for the stroke drawn around raster symbol items.
Definition: qgslayoutitemlegend.cpp:521
QgsLayoutTable::setHorizontalGrid
void setHorizontalGrid(bool horizontalGrid)
Sets whether the grid's horizontal lines should be drawn in the table.
Definition: qgslayouttable.cpp:888
QgsPainting::getCompositionMode
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
QgsLayoutItem::setLocked
void setLocked(bool locked)
Sets whether the item is locked, preventing mouse interactions with the item.
Definition: qgslayoutitem.cpp:200
QgsLayoutItem::setVisibility
virtual void setVisibility(bool visible)
Sets whether the item is visible.
Definition: qgslayoutitem.cpp:170
QgsLayoutItemMapGrid::setIntervalY
void setIntervalY(double interval)
Sets the interval between grid lines in the y-direction.
Definition: qgslayoutitemmapgrid.cpp:2269
QgsCompositionConverter::PictureSvgStrokeWidth
@ PictureSvgStrokeWidth
SVG stroke width.
Definition: qgscompositionconverter.h:99
QgsLayoutPageCollection::pages
QList< QgsLayoutItemPage * > pages()
Returns a list of pages in the collection.
Definition: qgslayoutpagecollection.cpp:450
QgsLayoutItem::setBackgroundEnabled
void setBackgroundEnabled(bool drawBackground)
Sets whether this item has a background drawn under it or not.
Definition: qgslayoutitem.cpp:886
QgsLayoutItemMapGrid::setFrameFillColor1
void setFrameFillColor1(const QColor &color)
Sets the first fill color used for the grid frame.
Definition: qgslayoutitemmapgrid.h:979
QgsCompositionConverter::PaperOrientation
@ PaperOrientation
Paper orientation.
Definition: qgscompositionconverter.h:71
QgsLayoutMultiFrame::ResizeMode
ResizeMode
Specifies the behavior for creating new frames to fit the multiframe's content.
Definition: qgslayoutmultiframe.h:102
qgslayoutguidecollection.h
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1131
QgsLayoutItemLegend::setBoxSpace
void setBoxSpace(double space)
Sets the legend box space.
Definition: qgslayoutitemlegend.cpp:371
QgsLayoutItemLabel::setFont
void setFont(const QFont &font)
Sets the label's current font.
Definition: qgslayoutitemlabel.cpp:314
qgspainting.h
QgsCompositionConverter::ScalebarLineColor
@ ScalebarLineColor
Scalebar line color.
Definition: qgscompositionconverter.h:108
QgsLayoutItemHtml::setEvaluateExpressions
void setEvaluateExpressions(bool evaluateExpressions)
Sets whether the html item will evaluate QGIS expressions prior to rendering the HTML content.
Definition: qgslayoutitemhtml.cpp:119
QgsCompositionConverter::ExcludeFromExports
@ ExcludeFromExports
Exclude item from exports.
Definition: qgscompositionconverter.h:82
QgsUnitTypes::DistanceFeet
@ DistanceFeet
Imperial feet.
Definition: qgsunittypes.h:71
QgsLayoutItemMapGrid::Right
@ Right
Right border.
Definition: qgslayoutitemmapgrid.h:225
QgsLayoutItemMapGrid::setLineSymbol
void setLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used for drawing grid lines.
Definition: qgslayoutitemmapgrid.cpp:2072
QgsLayoutItem::setFrameStrokeColor
void setFrameStrokeColor(const QColor &color)
Sets the frame stroke color.
Definition: qgslayoutitem.cpp:846
QgsUnitTypes::DistanceMeters
@ DistanceMeters
Meters.
Definition: qgsunittypes.h:69
QgsPropertyDefinition
Definition for a property.
Definition: qgsproperty.h:48
QgsCompositionConverter::PictureSvgBackgroundColor
@ PictureSvgBackgroundColor
SVG background color.
Definition: qgscompositionconverter.h:97
QgsLayoutItem::setFrameJoinStyle
void setFrameJoinStyle(Qt::PenJoinStyle style)
Sets the join style used when drawing the item's frame.
Definition: qgslayoutitem.cpp:871
qgssymbollayer.h
QgsCompositionConverter::AllProperties
@ AllProperties
All properties for item.
Definition: qgscompositionconverter.h:64
QgsLayoutTable::contentTextFormat
QgsTextFormat contentTextFormat() const
Returns the format used to draw content text in the table.
Definition: qgslayouttable.cpp:842
QgsLayoutItemLabel::setMarginX
void setMarginX(double margin)
Sets the horizontal margin between the edge of the frame and the label contents, in layout units.
Definition: qgslayoutitemlabel.cpp:326
QgsLayoutItemPicture::setPicturePath
void setPicturePath(const QString &path, Format format=FormatUnknown)
Sets the source path of the image (may be svg or a raster format).
Definition: qgslayoutitempicture.cpp:703
QgsLayoutItemScaleBar::setMinimumBarWidth
void setMinimumBarWidth(double minWidth)
Sets the minimum width (in millimeters) for scale bar segments.
Definition: qgslayoutitemscalebar.cpp:151
QgsLayoutItemMapGrid::AnnotationPosition
AnnotationPosition
Position for grid annotations.
Definition: qgslayoutitemmapgrid.h:184
QgsLayoutItemAttributeTable
A layout table subclass that displays attributes from a vector layer.
Definition: qgslayoutitemattributetable.h:35
QgsLayoutItemPicture::ResizeMode
ResizeMode
Controls how pictures are scaled within the item's frame.
Definition: qgslayoutitempicture.h:44
QgsLayoutItemMapGrid::setAnnotationFormat
void setAnnotationFormat(const AnnotationFormat format)
Sets the format for drawing grid annotations.
Definition: qgslayoutitemmapgrid.h:708
QgsLayoutTable::HeaderMode
HeaderMode
Controls where headers are shown in the table.
Definition: qgslayouttable.h:133
QgsCompositionConverter::PictureSvgStrokeColor
@ PictureSvgStrokeColor
SVG stroke color.
Definition: qgscompositionconverter.h:98
QgsLayoutItem
Base class for graphical items within a QgsLayout.
Definition: qgslayoutitem.h:113
QgsLayoutNorthArrowHandler::setNorthMode
void setNorthMode(NorthMode mode)
Sets the mode used to calculate the arrow rotation.
Definition: qgslayoutnortharrowhandler.cpp:112
QgsLayoutItemScaleBar::setMapUnitsPerScaleBarUnit
void setMapUnitsPerScaleBarUnit(double units)
Sets the number of map units per scale bar unit used by the scalebar.
Definition: qgslayoutitemscalebar.h:199
QgsLayoutTable::WrapBehavior
WrapBehavior
Controls how long strings in the table are handled.
Definition: qgslayouttable.h:153
QgsCompositionConverter::ScalebarLineWidth
@ ScalebarLineWidth
Scalebar line width.
Definition: qgscompositionconverter.h:109
QgsCompositionConverter::PaperHeight
@ PaperHeight
Paper height.
Definition: qgscompositionconverter.h:69
qgslayertree.h
QgsLayoutItemMap::crs
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used for rendering the map.
Definition: qgslayoutitemmap.cpp:292
QgsLayoutItemScaleBar::setStyle
void setStyle(const QString &name)
Sets the scale bar style by name.
Definition: qgslayoutitemscalebar.cpp:609
QgsLayoutTable::EmptyTableMode
EmptyTableMode
Controls how empty tables are displayed.
Definition: qgslayouttable.h:143
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
QgsLayoutAtlas::setSortAscending
void setSortAscending(bool ascending)
Sets whether features should be sorted in an ascending order.
Definition: qgslayoutatlas.cpp:191
QgsLayoutItemLegend::setLinkedMap
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map to associate with the legend.
Definition: qgslayoutitemlegend.cpp:750
QgsLayoutItemGroup
A container for grouping several QgsLayoutItems.
Definition: qgslayoutitemgroup.h:29
QgsCompositionConverter::Opacity
@ Opacity
Item opacity.
Definition: qgscompositionconverter.h:80
QgsLayoutItemMapGrid::Bottom
@ Bottom
Bottom border.
Definition: qgslayoutitemmapgrid.h:226
QgsLayoutMultiFrame::frames
QList< QgsLayoutFrame * > frames() const
Returns a list of all child frames for this multiframe.
Definition: qgslayoutmultiframe.cpp:91
QgsLayoutItemPage::create
static QgsLayoutItemPage * create(QgsLayout *layout)
Returns a new page item for the specified layout.
Definition: qgslayoutitempage.cpp:55
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:170
QgsLayoutAtlas::setHideCoverage
void setHideCoverage(bool hide)
Sets whether the coverage layer should be hidden in map items in the layouts.
Definition: qgslayoutatlas.cpp:471
QgsLayoutItemLegend::setSymbolWidth
void setSymbolWidth(double width)
Sets the legend symbol width.
Definition: qgslayoutitemlegend.cpp:401
QgsLayoutItemMapGrid::setEnabled
void setEnabled(bool enabled) override
Controls whether the item will be drawn.
Definition: qgslayoutitemmapgrid.cpp:2242
QgsLayoutSize::height
double height() const
Returns the height of the size.
Definition: qgslayoutsize.h:90
QgsLayoutItemPicture
A layout item subclass that displays SVG files or raster format images (jpg, png, ....
Definition: qgslayoutitempicture.h:36
qgsvectorlayer.h
QgsCompositionConverter::MapLayers
@ MapLayers
Map layer set.
Definition: qgscompositionconverter.h:93
QgsLayoutItemPolyline::setArrowHeadWidth
void setArrowHeadWidth(double width)
Sets the width of line arrow heads in mm.
Definition: qgslayoutitempolyline.cpp:317
QgsLayoutItemMapOverview
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
Definition: qgslayoutitemmapoverview.h:127
QgsLayoutNorthArrowHandler::NorthMode
NorthMode
Method for syncing rotation to a map's North direction.
Definition: qgslayoutnortharrowhandler.h:39
QgsCompositionConverter::MarkerMode
MarkerMode
The MarkerMode enum is the old QGIS 2.x arrow marker mode.
Definition: qgscompositionconverter.h:116
QgsPropertyDefinition::IntegerPositive
@ IntegerPositive
Positive integer values (including 0)
Definition: qgsproperty.h:56
QgsCompositionConverter::ScalebarFillColor
@ ScalebarFillColor
Scalebar fill color.
Definition: qgscompositionconverter.h:106
QgsSymbolLayerUtils::decodePenCapStyle
static Qt::PenCapStyle decodePenCapStyle(const QString &str)
Definition: qgssymbollayerutils.cpp:238
qgslayoutitemlegend.h
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:318
QgsLayoutItemLabel::setMode
void setMode(Mode mode)
Sets the label's current mode, allowing the label to switch between font based and HTML based renderi...
Definition: qgslayoutitemlabel.cpp:238
QgsLayoutItem::setId
virtual void setId(const QString &id)
Set the item's id name.
Definition: qgslayoutitem.cpp:134
QgsLayoutItemMapGrid::setFrameStyle
void setFrameStyle(const FrameStyle style)
Sets the grid frame style.
Definition: qgslayoutitemmapgrid.h:738
QgsLayoutItemMapGrid::setAnnotationTextFormat
void setAnnotationTextFormat(const QgsTextFormat &format)
Sets the text format to use when rendering grid annotations.
Definition: qgslayoutitemmapgrid.h:584
QgsLayoutTable::setShowEmptyRows
void setShowEmptyRows(bool showEmpty)
Sets whether empty rows should be drawn.
Definition: qgslayouttable.cpp:693
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:319
QgsLayoutItem::attemptMove
virtual void attemptMove(const QgsLayoutPoint &point, bool useReferencePoint=true, bool includesFrame=false, int page=-1)
Attempts to move the item to a specified point.
Definition: qgslayoutitem.cpp:466
QgsCompositionConverter::DataDefinedProperty
DataDefinedProperty
Composition data defined properties for different item types.
Definition: qgscompositionconverter.h:62
QgsPathResolver::readPath
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Definition: qgspathresolver.cpp:35
QgsLayoutItem::setReferencePoint
void setReferencePoint(ReferencePoint point)
Sets the reference point for positioning of the layout item.
Definition: qgslayoutitem.cpp:414
QgsFontUtils::setFromXmlChildNode
static bool setFromXmlChildNode(QFont &font, const QDomElement &element, const QString &childNode)
Sets the properties of a font to match the properties stored in an XML child node.
Definition: qgsfontutils.cpp:348
QgsLayoutItem::uuid
virtual QString uuid() const
Returns the item identification string.
Definition: qgslayoutitem.h:343
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
QgsLayoutTableStyle
Styling option for a layout table cell.
Definition: qgslayouttable.h:77
QgsLayoutItemLegend::setColumnCount
void setColumnCount(int count)
Sets the legend column count.
Definition: qgslayoutitemlegend.cpp:480
QgsLayoutItemLegend::setDrawRasterStroke
void setDrawRasterStroke(bool enabled)
Sets whether a stroke will be drawn around raster symbol items.
Definition: qgslayoutitemlegend.cpp:511
qgslinesymbollayer.h
QgsLayoutItemLegend::setWmsLegendHeight
void setWmsLegendHeight(double height)
Sets the WMS legend height.
Definition: qgslayoutitemlegend.cpp:460
QgsLayoutTable::mCellStyles
QMap< CellStyleGroup, QgsLayoutTableStyle * > mCellStyles
Definition: qgslayouttable.h:633
QgsLayout::pageCollection
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
Definition: qgslayout.cpp:459
QgsPropertyDefinition::Boolean
@ Boolean
Boolean value.
Definition: qgsproperty.h:54
QgsLayoutAtlas::setSortExpression
void setSortExpression(const QString &expression)
Sets the expression (or field name) to use for sorting features.
Definition: qgslayoutatlas.cpp:200
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsSymbol::setColor
void setColor(const QColor &color)
Sets the color for the symbol.
Definition: qgssymbol.cpp:504
QgsCompositionConverter::SourceUrl
@ SourceUrl
Html source url.
Definition: qgscompositionconverter.h:101
QgsCompositionConverter::addItemsFromCompositionXml
static QList< QgsLayoutObject * > addItemsFromCompositionXml(QgsPrintLayout *layout, const QDomElement &parentElement, QPointF *position=nullptr, bool pasteInPlace=false)
addItemsFromCompositionXml parse a QGIS 2.x composition XML in the parentElement, converts the 2....
Definition: qgscompositionconverter.cpp:309
qgscompositionconverter.h
QgsLayoutItemLegend::setTitleAlignment
void setTitleAlignment(Qt::AlignmentFlag alignment)
Sets the alignment of the legend title.
Definition: qgslayoutitemlegend.cpp:316
QgsLineSymbol::createSimple
static QgsLineSymbol * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties.
Definition: qgssymbol.cpp:1470
QgsSymbolLayerUtils::svgSymbolNameToPath
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
Definition: qgssymbollayerutils.cpp:3941
QgsLayoutTable::setWrapBehavior
void setWrapBehavior(WrapBehavior behavior)
Sets the wrap behavior for the table, which controls how text within cells is automatically wrapped.
Definition: qgslayouttable.cpp:929
QgsLayoutItemMap::setMapRotation
void setMapRotation(double rotation)
Sets the rotation for the map - this does not affect the layout item shape, only the way the map is d...
Definition: qgslayoutitemmap.cpp:491
QgsLayoutItemHtml::setMaxBreakDistance
void setMaxBreakDistance(double distance)
Sets the maximum distance allowed when calculating where to place page breaks in the html.
Definition: qgslayoutitemhtml.cpp:427
QgsLayoutItemPicture::setPictureAnchor
void setPictureAnchor(QgsLayoutItem::ReferencePoint anchor)
Sets the picture's anchor point, which controls how it is placed within the picture item's frame.
Definition: qgslayoutitempicture.cpp:841
qgslayouttablecolumn.h
QgsLayoutItem::setItemRotation
virtual void setItemRotation(double rotation, bool adjustPosition=true)
Sets the layout item's rotation, in degrees clockwise.
Definition: qgslayoutitem.cpp:1126
qgsprintlayout.h
QgsLayoutItemShape::setShapeType
void setShapeType(QgsLayoutItemShape::Shape type)
Sets the type of shape (e.g.
Definition: qgslayoutitemshape.cpp:102
qgslayoutitempicture.h
qgsproperty.h
QgsLayoutTable::setHeaderTextFormat
void setHeaderTextFormat(const QgsTextFormat &format)
Sets the format used to draw header text in the table.
Definition: qgslayouttable.cpp:748
QgsLayoutItemMap::setFollowVisibilityPreset
void setFollowVisibilityPreset(bool follow)
Sets whether the map should follow a map theme.
Definition: qgslayoutitemmap.cpp:340
QgsLayoutItemMap::setAtlasMargin
void setAtlasMargin(double margin)
Sets the margin size (percentage) used when the map is in atlas mode.
Definition: qgslayoutitemmap.h:686
QgsMapLayerStyle::xmlData
QString xmlData() const
Returns XML content of the style.
Definition: qgsmaplayerstyle.cpp:43
QgsLayoutItemMapGrid::setCrossLength
void setCrossLength(const double length)
Sets the length (in layout units) of the cross segments drawn for the grid.
Definition: qgslayoutitemmapgrid.cpp:2334
QgsLayoutItemScaleBar::setUnitsPerSegment
void setUnitsPerSegment(double units)
Sets the number of scalebar units per segment.
Definition: qgslayoutitemscalebar.cpp:127
QgsLayoutItemMapGrid::Top
@ Top
Top border.
Definition: qgslayoutitemmapgrid.h:227
QgsLayoutAtlas::setCoverageLayer
void setCoverageLayer(QgsVectorLayer *layer)
Sets the coverage layer to use for the atlas features.
Definition: qgslayoutatlas.cpp:154
QgsLayoutTable::headerTextFormat
QgsTextFormat headerTextFormat() const
Returns the format used to draw header text in the table.
Definition: qgslayouttable.cpp:758
QgsLayoutItemMapGrid::AnnotationFormat
AnnotationFormat
Format for displaying grid annotations.
Definition: qgslayoutitemmapgrid.h:207
qgslayoutitempolyline.h
QgsLayoutItemLegend::setColumnSpace
void setColumnSpace(double spacing)
Sets the legend column spacing.
Definition: qgslayoutitemlegend.cpp:381
QgsSymbolLayerUtils::decodePenJoinStyle
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
Definition: qgssymbollayerutils.cpp:188
qgslayoutpagecollection.h
qgslayoutitemshape.h
QgsLayoutItemPolygon
Layout item for node based polygon shapes.
Definition: qgslayoutitempolygon.h:30
QgsTextFormat::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
Definition: qgstextformat.cpp:204
QgsLayoutSize
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Definition: qgslayoutsize.h:41
QgsLayoutItemAttributeTable::setVectorLayer
void setVectorLayer(QgsVectorLayer *layer)
Sets the vector layer from which to display feature attributes.
Definition: qgslayoutitemattributetable.cpp:72
QgsLayoutItemScaleBar::alternateFillSymbol
QgsFillSymbol * alternateFillSymbol() const
Returns the secondary fill symbol used to render the scalebar (only used for some scalebar types).
Definition: qgslayoutitemscalebar.cpp:227
QgsLayoutItemLegend::setRasterStrokeWidth
void setRasterStrokeWidth(double width)
Sets the stroke width for the stroke drawn around raster symbol items.
Definition: qgslayoutitemlegend.cpp:531
QgsCompositionConverter::LegendTitle
@ LegendTitle
Legend title.
Definition: qgscompositionconverter.h:103
QgsLayoutItemScaleBar::setDivisionLineSymbol
void setDivisionLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render the scalebar divisions (only used for some scalebar types).
Definition: qgslayoutitemscalebar.cpp:202
QgsLayoutItemLegend::setWmsLegendWidth
void setWmsLegendWidth(double width)
Sets the WMS legend width.
Definition: qgslayoutitemlegend.cpp:451
QgsLayoutItemShape::Shape
Shape
Shape type.
Definition: qgslayoutitemshape.h:40
QgsLayoutItemMapGrid::setAnnotationDirection
void setAnnotationDirection(AnnotationDirection direction, BorderSide side)
Sets the direction for drawing frame annotations for the specified map side.
Definition: qgslayoutitemmapgrid.cpp:2340
QgsLayoutTableStyle::readXml
bool readXml(const QDomElement &styleElem)
Reads the style's properties from XML.
Definition: qgslayouttable.cpp:42
QgsUnitTypes::DistanceNauticalMiles
@ DistanceNauticalMiles
Nautical miles.
Definition: qgsunittypes.h:72
QgsFillSymbol::createSimple
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties.
Definition: qgssymbol.cpp:1481
QgsLayoutItem::frameStrokeColor
QColor frameStrokeColor() const
Returns the frame's stroke color.
Definition: qgslayoutitem.h:757
QgsPropertyCollection::setProperty
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
Definition: qgspropertycollection.cpp:187
_LayerRef< QgsMapLayer >
QgsPropertyDefinition::Opacity
@ Opacity
Opacity (0-100)
Definition: qgsproperty.h:63
QgsCompositionConverter::FrameColor
@ FrameColor
Item frame color.
Definition: qgscompositionconverter.h:83
qgslayoutobject.h
QgsLayoutAtlas::setFilterExpression
bool setFilterExpression(const QString &expression, QString &errorString)
Sets the expression used for filtering features in the coverage layer.
Definition: qgslayoutatlas.cpp:218
QgsMapLayerStyle
Stores style information (renderer, opacity, labeling, diagrams etc.) applicable to a map layer.
Definition: qgsmaplayerstyle.h:43
QgsLayoutTable::mColumns
QgsLayoutTableColumns mColumns
Columns to show in table.
Definition: qgslayouttable.h:615
QgsLayoutTableColumn
Stores properties of a column for a QgsLayoutTable.
Definition: qgslayouttablecolumn.h:37
QgsLayoutItemMapGrid::setAnnotationPosition
void setAnnotationPosition(AnnotationPosition position, BorderSide side)
Sets the position for the grid annotations on a specified side of the map frame.
Definition: qgslayoutitemmapgrid.cpp:2450
QgsLayoutMultiFrame::setResizeMode
void setResizeMode(ResizeMode mode)
Sets the resize mode for the multiframe, and recalculates frame sizes to match.
Definition: qgslayoutmultiframe.cpp:79
QgsLayoutItemMapGrid::annotationTextFormat
QgsTextFormat annotationTextFormat() const
Returns the text format used when rendering grid annotations.
Definition: qgslayoutitemmapgrid.h:592
QgsCompositionConverter::ItemWidth
@ ItemWidth
Width of item.
Definition: qgscompositionconverter.h:76
QgsLayoutItemLabel
A layout item subclass for text labels.
Definition: qgslayoutitemlabel.h:35
QgsLayoutItemScaleBar
A layout item subclass for scale bars.
Definition: qgslayoutitemscalebar.h:36
QgsLayoutItemMapGrid::setIntervalX
void setIntervalX(double interval)
Sets the interval between grid lines in the x-direction.
Definition: qgslayoutitemmapgrid.cpp:2258
QgsLayout::project
QgsProject * project() const
The project associated with the layout.
Definition: qgslayout.cpp:132
QgsLayoutItem::setItemOpacity
void setItemOpacity(double opacity)
Sets the item's opacity.
Definition: qgslayoutitem.cpp:906
QgsTextFormat::setSize
void setSize(double size)
Sets the size for rendered text.
Definition: qgstextformat.cpp:226
QgsLayoutMultiFrame::addFrame
virtual void addFrame(QgsLayoutFrame *frame, bool recalcFrameSizes=true)
Adds a frame to the multiframe.
Definition: qgslayoutmultiframe.cpp:56
QgsLayoutItemLegend::setSymbolHeight
void setSymbolHeight(double height)
Sets the legend symbol height.
Definition: qgslayoutitemlegend.cpp:441
QgsLayoutItemMapGrid::setFrameFillColor2
void setFrameFillColor2(const QColor &color)
Sets the second fill color used for the grid frame.
Definition: qgslayoutitemmapgrid.h:995
QgsLayoutItemMapGrid::setAnnotationFrameDistance
void setAnnotationFrameDistance(const double distance)
Sets the distance between the map frame and annotations.
Definition: qgslayoutitemmapgrid.cpp:2491
QgsLayoutPageCollection::pageCount
int pageCount() const
Returns the number of pages in the collection.
Definition: qgslayoutpagecollection.cpp:455
QgsCompositionConverter::PictureSource
@ PictureSource
Picture source url.
Definition: qgscompositionconverter.h:96
QgsPropertyCollection::isActive
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition: qgspropertycollection.cpp:268
QgsLayerTree::readXml
static QgsLayerTree * readXml(QDomElement &element, const QgsReadWriteContext &context)
Load the layer tree from an XML element.
Definition: qgslayertree.cpp:114
QgsLayoutAtlas::setFilterFeatures
void setFilterFeatures(bool filtered)
Sets whether features should be filtered in the coverage layer.
Definition: qgslayoutatlas.cpp:209
QgsLayoutPoint
This class provides a method of storing points, consisting of an x and y coordinate,...
Definition: qgslayoutpoint.h:40
qgslayoutitemregistry.h
Q_NOWARN_DEPRECATED_PUSH
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:796
QgsLayoutTable::setEmptyTableMessage
void setEmptyTableMessage(const QString &message)
Sets the message for empty tables with no content rows.
Definition: qgslayouttable.cpp:678
QgsLegendStyle::readXml
void readXml(const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads the component's style definition from an XML element.
Definition: qgslegendstyle.cpp:67
QgsLayoutItemMap::setExtent
void setExtent(const QgsRectangle &extent)
Sets a new extent for the map.
Definition: qgslayoutitemmap.cpp:201
QgsLayoutItemMap::setKeepLayerSet
void setKeepLayerSet(bool enabled)
Sets whether the stored layer set should be used or the current layer set of the associated project.
Definition: qgslayoutitemmap.h:505
QgsPropertyDefinition::StrokeWidth
@ StrokeWidth
Line stroke width.
Definition: qgsproperty.h:73
QgsLayoutAtlas
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
Definition: qgslayoutatlas.h:42
qgslayoutitemscalebar.h
QgsLayoutItemPolyline::setEndMarker
void setEndMarker(MarkerMode mode)
Sets the end marker mode, which controls what marker is drawn at the end of the line.
Definition: qgslayoutitempolyline.cpp:311
QgsLegendStyle::Group
@ Group
Legend group title.
Definition: qgslegendstyle.h:45
QgsLegendStyle::Subgroup
@ Subgroup
Legend subgroup title.
Definition: qgslegendstyle.h:46
qgslayoutmodel.h
QgsPathResolver
Resolves relative paths into absolute paths and vice versa.
Definition: qgspathresolver.h:32
QgsCompositionConverter::NoProperty
@ NoProperty
No property.
Definition: qgscompositionconverter.h:63
QgsLayoutItemMapGrid::setAnnotationEnabled
void setAnnotationEnabled(const bool enabled)
Sets whether annotations should be shown for the grid.
Definition: qgslayoutitemmapgrid.h:570
QgsCompositionConverter::NumPages
@ NumPages
Number of pages in composition.
Definition: qgscompositionconverter.h:70
QgsLayoutItemMapGrid::setAnnotationPrecision
void setAnnotationPrecision(const int precision)
Sets the coordinate precision for grid annotations.
Definition: qgslayoutitemmapgrid.h:631
qgsproject.h
QgsCompositionConverter::MapYMin
@ MapYMin
Map extent y minimum.
Definition: qgscompositionconverter.h:89
QgsCompositionConverter::PresetPaperSize
@ PresetPaperSize
Preset paper size for composition.
Definition: qgscompositionconverter.h:67
QgsLayoutItemHtml::setContentMode
void setContentMode(ContentMode mode)
Sets the source mode for item's HTML content.
Definition: qgslayoutitemhtml.h:72
QgsLayoutMeasurement
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
Definition: qgslayoutmeasurement.h:34
QgsLayoutItemShape::setSymbol
void setSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used to draw the shape.
Definition: qgslayoutitemshape.cpp:145
QgsLayoutItemScaleBar::setNumberOfSegmentsLeft
void setNumberOfSegmentsLeft(int segments)
Sets the number of segments included in the left part of the scalebar.
Definition: qgslayoutitemscalebar.cpp:237
QgsLayoutAtlas::setSortFeatures
void setSortFeatures(bool enabled)
Sets whether features should be sorted in the atlas.
Definition: qgslayoutatlas.cpp:182
QgsLayoutItemMapGrid::FrameStyle
FrameStyle
Style for grid frame.
Definition: qgslayoutitemmapgrid.h:234
QgsLayoutAtlas::setFilenameExpression
bool setFilenameExpression(const QString &expression, QString &errorString)
Sets the filename expression used for generating output filenames for each atlas page.
Definition: qgslayoutatlas.cpp:482
qgslayoutitemhtml.h
QgsLayoutItemLegend::setWrapString
void setWrapString(const QString &string)
Sets the legend text wrapping string.
Definition: qgslayoutitemlegend.cpp:465
QgsLayoutObject
A base class for objects which belong to a layout.
Definition: qgslayoutobject.h:40
QgsLayoutItemMap::setDrawAnnotations
void setDrawAnnotations(bool draw)
Sets whether annotations are drawn within the map.
Definition: qgslayoutitemmap.h:620
QgsMapLayerStyle::readXml
void readXml(const QDomElement &styleElement)
Read style configuration (for project file reading)
Definition: qgsmaplayerstyle.cpp:86
QgsLegendStyle
Contains detailed styling information relating to how a layout legend should be rendered.
Definition: qgslegendstyle.h:36
qgslayoutitemmap.h
QgsCompositionConverter::ScalebarFillColor2
@ ScalebarFillColor2
Scalebar secondary fill color.
Definition: qgscompositionconverter.h:107
QgsLayoutItemScaleBar::setUnitLabel
void setUnitLabel(const QString &label)
Sets the label for units.
Definition: qgslayoutitemscalebar.h:211
QgsLayoutItemMapGrid::Left
@ Left
Left border.
Definition: qgslayoutitemmapgrid.h:224
QgsPropertyDefinition::DoublePositive
@ DoublePositive
Positive double value (including 0)
Definition: qgsproperty.h:59
QgsLayoutAtlas::sortFeatures
bool sortFeatures() const
Returns true if features should be sorted in the atlas.
Definition: qgslayoutatlas.h:149
qgslayoutatlas.h
QgsCompositionConverter::PositionX
@ PositionX
X position on page.
Definition: qgscompositionconverter.h:74