60 QList<QgsLayoutItemMap *> mapItems;
66 if ( map->isSelected() )
73 double largestZValue = std::numeric_limits< double >::lowest();
76 if ( map->collidesWithItem( referenceItem ) && map->zValue() > largestZValue )
79 largestZValue = map->zValue();
118 return new QgsLayoutMapWidget( qobject_cast< QgsLayoutItemMap * >( item ), mapCanvas );
119 }, createRubberBand );
120 mapItemMetadata->setItemAddedToLayoutFunction( [ = ](
QgsLayoutItem * item )
141 }, createRubberBand ) );
150 }, createRubberBand );
151 labelItemMetadata->setItemAddedToLayoutFunction( [ = ](
QgsLayoutItem * item )
156 label->
setText( QObject::tr(
"Lorem ipsum" ) );
157 if ( QApplication::isRightToLeft() )
162 QSizeF currentSize = label->rect().size();
165 double labelWidth = std::max( minSize.width(), currentSize.width() );
166 double labelHeight = std::max( minSize.height(), currentSize.height() );
167 label->
attemptSetSceneRect( QRectF( label->pos().x(), label->pos().y(), labelWidth, labelHeight ) );
178 return new QgsLayoutLegendWidget( qobject_cast< QgsLayoutItemLegend * >( item ), mapCanvas );
179 }, createRubberBand );
180 legendItemMetadata->setItemAddedToLayoutFunction( [ = ](
QgsLayoutItem * item )
188 if ( QApplication::isRightToLeft() )
200 const QString defaultFontString = settings.
value( QStringLiteral(
"LayoutDesigner/defaultFont" ), QVariant(),
QgsSettings::Gui ).toString();
201 if ( !defaultFontString.isEmpty() )
220 }, createRubberBand );
221 scalebarItemMetadata->setItemAddedToLayoutFunction( [ = ](
QgsLayoutItem * item )
224 Q_ASSERT( scalebar );
238 std::unique_ptr< QgsLayoutItemGuiMetadata > northArrowMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata>(
243 }, createRubberBand );
244 northArrowMetadata->setItemCreationFunction( [](
QgsLayout * layout )->QgsLayoutItem *
248 QList< QgsLayoutItemPicture * > pictureItems;
250 int northArrowCount = 0;
253 const QString defaultPath = settings.
value( QStringLiteral(
"LayoutDesigner/defaultNorthArrow" ), QStringLiteral(
":/images/north_arrows/layout_default_north_arrow.svg" ),
QgsSettings::Gui ).toString();
258 if ( p->picturePath() == defaultPath )
262 std::unique_ptr< QgsLayoutItemPicture > picture = qgis::make_unique< QgsLayoutItemPicture >( layout );
264 picture->setPicturePath( defaultPath );
266 picture->setId( northArrowCount > 0 ? QObject::tr(
"North Arrow %1" ).arg( northArrowCount + 1 ) : QObject::tr(
"North Arrow" ) );
267 return picture.release();
269 northArrowMetadata->setItemAddedToLayoutFunction( [ = ](
QgsLayoutItem * item )
274 QList<QgsLayoutItemMap *> mapItems;
284 auto createShapeWidget =
292 std::unique_ptr< QgsLayoutItemShape > shape = qgis::make_unique< QgsLayoutItemShape >( layout );
294 return shape.release();
298 std::unique_ptr< QgsLayoutItemShape > shape = qgis::make_unique< QgsLayoutItemShape >( layout );
300 return shape.release();
304 std::unique_ptr< QgsLayoutItemShape > shape = qgis::make_unique< QgsLayoutItemShape >( layout );
306 return shape.release();
317 std::unique_ptr< QgsLayoutItemGuiMetadata > arrowMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata>(
322 }, createRubberBand, QString(), true );
323 arrowMetadata->setItemCreationFunction( [](
QgsLayout * layout )->QgsLayoutItem *
325 std::unique_ptr< QgsLayoutItemPolyline > arrow = qgis::make_unique< QgsLayoutItemPolyline >( layout );
327 return arrow.release();
329 arrowMetadata->setNodeRubberBandCreationFunction( [](
QgsLayoutView * )->QGraphicsPathItem*
331 std::unique_ptr< QGraphicsPathItem > band = qgis::make_unique< QGraphicsPathItem >();
332 band->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) );
334 return band.release();
340 std::unique_ptr< QgsLayoutItemGuiMetadata > polygonMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata >(
345 }, createRubberBand, QStringLiteral(
"nodes" ), true );
346 polygonMetadata->setNodeRubberBandCreationFunction( [](
QgsLayoutView * )->QGraphicsPolygonItem*
348 std::unique_ptr< QGraphicsPolygonItem > band = qgis::make_unique< QGraphicsPolygonItem >();
349 band->setBrush( Qt::NoBrush );
350 band->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) );
352 return band.release();
356 std::unique_ptr< QgsLayoutItemGuiMetadata > polylineMetadata = qgis::make_unique< QgsLayoutItemGuiMetadata>(
361 }, createRubberBand, QStringLiteral(
"nodes" ), true );
362 polylineMetadata->setNodeRubberBandCreationFunction( [](
QgsLayoutView * )->QGraphicsPathItem*
364 std::unique_ptr< QGraphicsPathItem > band = qgis::make_unique< QGraphicsPathItem >();
365 band->setPen( QPen( QBrush( QColor( 227, 22, 22, 200 ) ), 0 ) );
367 return band.release();
378 }, createRubberBand );
379 htmlItemMetadata->setItemCreationFunction( [ = ](
QgsLayout * layout )->QgsLayoutItem *
381 std::unique_ptr< QgsLayoutItemHtml > htmlMultiFrame = qgis::make_unique< QgsLayoutItemHtml >( layout );
384 std::unique_ptr< QgsLayoutFrame > frame = qgis::make_unique< QgsLayoutFrame >( layout, html );
397 }, createRubberBand );
398 attributeTableItemMetadata->setItemCreationFunction( [ = ](
QgsLayout * layout )->QgsLayoutItem *
400 std::unique_ptr< QgsLayoutItemAttributeTable > tableMultiFrame = qgis::make_unique< QgsLayoutItemAttributeTable >( layout );
405 for (
auto it = layerMap.constBegin() ; it != layerMap.constEnd(); ++it )
407 if (
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( it.value() ) )
416 const QString defaultFontString = settings.
value( QStringLiteral(
"LayoutDesigner/defaultFont" ), QVariant(),
QgsSettings::Gui ).toString();
417 if ( !defaultFontString.isEmpty() )
420 QFont f = format.
font();
421 f.setFamily( defaultFontString );
423 tableMultiFrame->setContentTextFormat( format );
426 tableMultiFrame->setHeaderTextFormat( format );
430 std::unique_ptr< QgsLayoutFrame > frame = qgis::make_unique< QgsLayoutFrame >( layout, table );
443 }, createRubberBand );
444 manualTableItemMetadata->setItemCreationFunction( [ = ](
QgsLayout * layout )->QgsLayoutItem *
446 std::unique_ptr< QgsLayoutItemManualTable > tableMultiFrame = qgis::make_unique< QgsLayoutItemManualTable >( layout );
457 const QString defaultFontString = settings.
value( QStringLiteral(
"LayoutDesigner/defaultFont" ), QVariant(),
QgsSettings::Gui ).toString();
458 if ( !defaultFontString.isEmpty() )
461 QFont f = format.
font();
462 f.setFamily( defaultFontString );
464 tableMultiFrame->setContentTextFormat( format );
467 tableMultiFrame->setHeaderTextFormat( format );
472 std::unique_ptr< QgsLayoutFrame > frame = qgis::make_unique< QgsLayoutFrame >( layout, table );