20#include "moc_qgslayoutmapwidget.cpp"
41#include <QStringListModel>
46 , mMapCanvas( mapCanvas )
51 connect( mScaleLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
52 connect( mActionSetToCanvasExtent, &QAction::triggered,
this, &QgsLayoutMapWidget::setToMapCanvasExtent );
53 connect( mActionViewExtentInCanvas, &QAction::triggered,
this, &QgsLayoutMapWidget::viewExtentInCanvas );
54 connect( mActionSetToCanvasScale, &QAction::triggered,
this, &QgsLayoutMapWidget::setToMapCanvasScale );
55 connect( mActionViewScaleInCanvas, &QAction::triggered,
this, &QgsLayoutMapWidget::viewScaleInCanvas );
56 connect( mActionUpdatePreview, &QAction::triggered,
this, &QgsLayoutMapWidget::updatePreview );
57 connect( mFollowVisibilityPresetCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged );
58 connect( mKeepLayerListCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
59 connect( mKeepLayerStylesCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
60 connect( mDrawCanvasItemsCheckBox, &QCheckBox::stateChanged,
this, &QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged );
61 connect( mOverviewBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged );
62 connect( mOverviewInvertCheckbox, &QCheckBox::toggled,
this, &QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled );
63 connect( mOverviewCenterCheckbox, &QCheckBox::toggled,
this, &QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled );
64 connect( mOverviewPositionComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::overviewStackingChanged );
66 connect( mXMinLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mXMinLineEdit_editingFinished );
67 connect( mXMaxLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mXMaxLineEdit_editingFinished );
68 connect( mYMinLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mYMinLineEdit_editingFinished );
69 connect( mYMaxLineEdit, &QLineEdit::editingFinished,
this, &QgsLayoutMapWidget::mYMaxLineEdit_editingFinished );
70 connect( mAtlasMarginRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasMarginRadio_toggled );
71 connect( mAtlasCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mAtlasCheckBox_toggled );
72 connect( mAtlasMarginSpinBox,
static_cast < void ( QSpinBox::* )(
int )
> ( &QSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged );
73 connect( mAtlasFixedScaleRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled );
74 connect( mAtlasPredefinedScaleRadio, &QRadioButton::toggled,
this, &QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled );
75 connect( mAddGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mAddGridPushButton_clicked );
76 connect( mRemoveGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mRemoveGridPushButton_clicked );
77 connect( mCopyGridPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mCopyGridPushButton_clicked );
78 connect( mGridUpButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridUpButton_clicked );
79 connect( mGridDownButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridDownButton_clicked );
80 connect( mGridListWidget, &QListWidget::currentItemChanged,
this, &QgsLayoutMapWidget::mGridListWidget_currentItemChanged );
81 connect( mGridListWidget, &QListWidget::itemChanged,
this, &QgsLayoutMapWidget::mGridListWidget_itemChanged );
82 connect( mGridPropertiesButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mGridPropertiesButton_clicked );
83 connect( mAddOverviewPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mAddOverviewPushButton_clicked );
84 connect( mRemoveOverviewPushButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked );
85 connect( mOverviewUpButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mOverviewUpButton_clicked );
86 connect( mOverviewDownButton, &QPushButton::clicked,
this, &QgsLayoutMapWidget::mOverviewDownButton_clicked );
87 connect( mOverviewCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mOverviewCheckBox_toggled );
88 connect( mOverviewListWidget, &QListWidget::currentItemChanged,
this, &QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged );
89 connect( mOverviewListWidget, &QListWidget::itemChanged,
this, &QgsLayoutMapWidget::mOverviewListWidget_itemChanged );
90 connect( mActionLabelSettings, &QAction::triggered,
this, &QgsLayoutMapWidget::showLabelSettings );
91 connect( mActionClipSettings, &QAction::triggered,
this, &QgsLayoutMapWidget::showClipSettings );
93 connect( mTemporalCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mTemporalCheckBox_toggled );
94 connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged,
this, &QgsLayoutMapWidget::updateTemporalExtent );
95 connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged,
this, &QgsLayoutMapWidget::updateTemporalExtent );
99 connect( mElevationRangeCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutMapWidget::mElevationRangeCheckBox_toggled );
100 connect( mZLowerSpin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::updateZRange );
101 connect( mZUpperSpin, qOverload< double >( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::updateZRange );
103 mStartDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
104 mEndDateTime->setDateTimeRange( QDateTime( QDate( 1, 1, 1 ), QTime( 0, 0, 0 ) ), mStartDateTime->maximumDateTime() );
105 mStartDateTime->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
106 mEndDateTime->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
108 connect( mActionMoveContent, &QAction::triggered,
this, &QgsLayoutMapWidget::switchToMoveContentTool );
110 mMapRotationSpinBox->setClearValue( 0 );
114 mBookmarkMenu =
new QMenu(
this );
115 QToolButton *btnBookmarks =
new QToolButton(
this );
116 btnBookmarks->setAutoRaise(
true );
117 btnBookmarks->setToolTip( tr(
"Bookmarks" ) );
119 btnBookmarks->setPopupMode( QToolButton::InstantPopup );
120 btnBookmarks->setMenu( mBookmarkMenu );
122 mDockToolbar->insertWidget( mActionMoveContent, btnBookmarks );
123 connect( mBookmarkMenu, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowBookmarkMenu );
127 mainLayout->addWidget( mItemPropertiesWidget );
129 mScaleLineEdit->setValidator(
new QDoubleValidator( mScaleLineEdit ) );
131 mXMinLineEdit->setValidator(
new QDoubleValidator( mXMinLineEdit ) );
132 mXMaxLineEdit->setValidator(
new QDoubleValidator( mXMaxLineEdit ) );
133 mYMinLineEdit->setValidator(
new QDoubleValidator( mYMinLineEdit ) );
134 mYMaxLineEdit->setValidator(
new QDoubleValidator( mYMaxLineEdit ) );
142 blockAllSignals(
true );
145 mCrsSelector->setNotSetText( tr(
"Use Project CRS" ) );
146 mCrsSelector->setDialogTitle( tr(
"Map Item CRS" ) );
151 mFollowVisibilityPresetCombo->setModel(
new QStringListModel( mFollowVisibilityPresetCombo ) );
152 connect( mFollowVisibilityPresetCombo,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutMapWidget::followVisibilityPresetSelected );
154 this, &QgsLayoutMapWidget::onMapThemesChanged );
155 onMapThemesChanged();
158 QMenu *menuKeepLayers =
new QMenu(
this );
159 mLayerListFromPresetButton->setMenu( menuKeepLayers );
161 mLayerListFromPresetButton->setToolTip( tr(
"Set layer list from a map theme" ) );
162 connect( menuKeepLayers, &QMenu::aboutToShow,
this, &QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu );
167 this, &QgsLayoutMapWidget::atlasLayerChanged );
171 compositionAtlasToggled( atlas->enabled() );
174 mOverviewFrameMapComboBox->setCurrentLayout( item->
layout() );
176 mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
182 mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
207 loadOverviewEntries();
209 connect( mMapRotationSpinBox,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapWidget::rotationChanged );
213 blockAllSignals(
false );
218 if ( mItemPropertiesWidget )
224 mReportTypeString = string;
225 mAtlasCheckBox->setTitle( tr(
"Controlled by %1" ).arg(
string == tr(
"atlas" ) ? tr(
"Atlas" ) : tr(
"Report" ) ) );
226 mAtlasPredefinedScaleRadio->setToolTip( tr(
"Use one of the predefined scales of the project where the %1 feature best fits." ).arg(
string ) );
229 mClipWidget->setReportTypeString(
string );
231 mLabelWidget->setReportTypeString(
string );
252 mMapItem = qobject_cast< QgsLayoutItemMap * >( item );
253 mItemPropertiesWidget->
setItem( mMapItem );
255 mLabelWidget->setItem( mMapItem );
257 mClipWidget->setItem( mMapItem );
264 mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
288void QgsLayoutMapWidget::compositionAtlasToggled(
bool atlasEnabled )
291 mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
294 mAtlasCheckBox->setEnabled(
true );
298 mAtlasCheckBox->setEnabled(
false );
299 mAtlasCheckBox->setChecked(
false );
303void QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu()
308 QMenu *menu = qobject_cast<QMenu *>( sender() );
314 for (
const QString &presetName : constMapThemes )
316 menu->addAction( presetName,
this, &QgsLayoutMapWidget::keepLayersVisibilityPresetSelected );
319 if ( menu->actions().isEmpty() )
320 menu->addAction( tr(
"No presets defined" ) )->setEnabled(
false );
323void QgsLayoutMapWidget::followVisibilityPresetSelected(
int currentIndex )
328 if ( mBlockThemeComboChanges != 0 )
331 if ( currentIndex == -1 )
335 if ( currentIndex != 0 )
337 presetName = mFollowVisibilityPresetCombo->currentText();
340 if ( presetName == mMapItem->followVisibilityPresetName() )
343 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
344 mFollowVisibilityPresetCheckBox->setChecked(
true );
345 mMapItem->setFollowVisibilityPresetName( presetName );
346 mMapItem->layout()->undoStack()->endCommand();
348 mMapItem->invalidateCache();
351void QgsLayoutMapWidget::keepLayersVisibilityPresetSelected()
353 QAction *action = qobject_cast<QAction *>( sender() );
357 const QString presetName = action->text();
358 const QList<QgsMapLayer *> lst = orderedPresetVisibleLayers( presetName );
361 mKeepLayerListCheckBox->setChecked(
true );
362 mMapItem->setLayers( lst );
364 mKeepLayerStylesCheckBox->setChecked(
true );
366 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
367 mMapItem->setLayerStyleOverrides(
QgsProject::instance()->mapThemeCollection()->mapThemeStyleOverrides( presetName ) );
368 mMapItem->layout()->undoStack()->endCommand();
370 mMapItem->invalidateCache();
374void QgsLayoutMapWidget::onMapThemesChanged()
376 if ( QStringListModel *model = qobject_cast<QStringListModel *>( mFollowVisibilityPresetCombo->model() ) )
378 mBlockThemeComboChanges++;
380 lst.append( tr(
"(none)" ) );
382 model->setStringList( lst );
385 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
386 mFollowVisibilityPresetCombo->blockSignals(
true );
387 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
388 mFollowVisibilityPresetCombo->blockSignals(
false );
389 mBlockThemeComboChanges--;
400 if ( mMapItem->presetCrs() ==
crs )
406 bool updateExtent =
false;
413 newExtent = xForm.transformBoundingBox( prevExtent );
421 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map CRS" ) );
422 mMapItem->setCrs(
crs );
424 mMapItem->zoomToExtent( newExtent );
425 mMapItem->layout()->undoStack()->endCommand();
426 mMapItem->invalidateCache();
429void QgsLayoutMapWidget::overviewSymbolChanged()
437 mMapItem->endCommand();
438 mMapItem->invalidateCache();
441void QgsLayoutMapWidget::showLabelSettings()
445 if ( !mReportTypeString.isEmpty() )
446 mLabelWidget->setReportTypeString( mReportTypeString );
451void QgsLayoutMapWidget::showClipSettings()
454 if ( !mReportTypeString.isEmpty() )
455 mClipWidget->setReportTypeString( mReportTypeString );
459void QgsLayoutMapWidget::switchToMoveContentTool()
465void QgsLayoutMapWidget::aboutToShowBookmarkMenu()
467 mBookmarkMenu->clear();
471 if ( !mBookmarkModel )
474 QMap< QString, QMenu * > groupMenus;
475 for (
int i = 0; i < mBookmarkModel->rowCount(); ++i )
478 QMenu *destMenu = mBookmarkMenu;
479 if ( !group.isEmpty() )
481 destMenu = groupMenus.value( group );
484 destMenu =
new QMenu( group, mBookmarkMenu );
485 groupMenus[ group ] = destMenu;
490 connect( action, &QAction::triggered,
this, [ = ]
500 if ( extent.
crs() != mMapItem->crs() )
504 QgsCoordinateTransform xForm( extent.crs(), mMapItem->crs(), QgsProject::instance() );
505 xForm.setBallparkTransformsAreAppropriate( true );
506 newExtent = xForm.transformBoundingBox( newExtent );
515 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
516 mMapItem->zoomToExtent( newExtent );
517 mMapItem->layout()->undoStack()->endCommand();
519 destMenu->addAction( action );
522 QStringList groupKeys = groupMenus.keys();
523 groupKeys.sort( Qt::CaseInsensitive );
524 for (
int i = 0; i < groupKeys.count(); ++i )
526 if ( mBookmarkMenu->actions().value( i ) )
527 mBookmarkMenu->insertMenu( mBookmarkMenu->actions().at( i ), groupMenus.value( groupKeys.at( i ) ) );
529 mBookmarkMenu->addMenu( groupMenus.value( groupKeys.at( i ) ) );
533void QgsLayoutMapWidget::mTemporalCheckBox_toggled(
bool checked )
540 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Temporal Range" ) );
541 mMapItem->setIsTemporal( checked );
542 mMapItem->layout()->undoStack()->endCommand();
546 whileBlocking( mStartDateTime )->setDateTime( mMapItem->temporalRange().begin() );
547 whileBlocking( mEndDateTime )->setDateTime( mMapItem->temporalRange().end() );
553void QgsLayoutMapWidget::updateTemporalExtent()
560 const QDateTime begin = mStartDateTime->dateTime();
561 const QDateTime end = mEndDateTime->dateTime();
564 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Temporal Range" ) );
565 mMapItem->setTemporalRange( range );
566 mMapItem->layout()->undoStack()->endCommand();
571void QgsLayoutMapWidget::mElevationRangeCheckBox_toggled(
bool checked )
578 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Z Range" ) );
579 mMapItem->setZRangeEnabled( checked );
580 mMapItem->layout()->undoStack()->endCommand();
585void QgsLayoutMapWidget::updateZRange()
592 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Z Range" ) );
593 double zLower = mZLowerSpin->value();
594 if ( zLower == mZLowerSpin->clearValue() )
595 zLower = std::numeric_limits< double >::lowest();
596 double zUpper = mZUpperSpin->value();
597 if ( zUpper == mZUpperSpin->clearValue() )
598 zUpper = std::numeric_limits< double >::max();
601 mMapItem->layout()->undoStack()->endCommand();
606void QgsLayoutMapWidget::mAtlasCheckBox_toggled(
bool checked )
613 mAtlasFixedScaleRadio->setEnabled( checked );
614 mAtlasMarginRadio->setEnabled( checked );
616 if ( mAtlasMarginRadio->isEnabled() && mAtlasMarginRadio->isChecked() )
618 mAtlasMarginSpinBox->setEnabled(
true );
622 mAtlasMarginSpinBox->setEnabled(
false );
625 mAtlasPredefinedScaleRadio->setEnabled( checked );
630 if ( mMapItem->layout() )
632 toggleAtlasScalingOptionsByLayerType();
637 if ( !hasPredefinedScales() )
639 mAtlasPredefinedScaleRadio->setEnabled(
false );
642 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Set Atlas Driven" ) );
643 mMapItem->setAtlasDriven( checked );
644 mMapItem->layout()->undoStack()->endCommand();
648void QgsLayoutMapWidget::updateMapForAtlas()
651 if ( mMapItem->atlasDriven() )
658 mMapItem->invalidateCache();
662void QgsLayoutMapWidget::mAtlasMarginRadio_toggled(
bool checked )
664 mAtlasMarginSpinBox->setEnabled( checked );
666 if ( checked && mMapItem )
668 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
670 mMapItem->layout()->undoStack()->endCommand();
675void QgsLayoutMapWidget::mAtlasMarginSpinBox_valueChanged(
int value )
683 mMapItem->setAtlasMargin( value / 100. );
684 mMapItem->layout()->undoStack()->endCommand();
688void QgsLayoutMapWidget::mAtlasFixedScaleRadio_toggled(
bool checked )
697 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
699 mMapItem->layout()->undoStack()->endCommand();
704void QgsLayoutMapWidget::mAtlasPredefinedScaleRadio_toggled(
bool checked )
711 if ( hasPredefinedScales() )
715 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Scales" ) );
717 mMapItem->layout()->undoStack()->endCommand();
725 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Atlas Mode" ) );
727 mMapItem->layout()->undoStack()->endCommand();
731void QgsLayoutMapWidget::mScaleLineEdit_editingFinished()
738 bool conversionSuccess =
false;
739 const double scaleDenominator = QLocale().toDouble( mScaleLineEdit->text(), &conversionSuccess );
740 if ( !conversionSuccess )
748 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Scale" ) );
749 mMapItem->setScale( scaleDenominator );
750 mMapItem->layout()->undoStack()->endCommand();
753void QgsLayoutMapWidget::rotationChanged(
double value )
761 mMapItem->setMapRotation( value );
762 mMapItem->layout()->undoStack()->endCommand();
763 mMapItem->invalidateCache();
766void QgsLayoutMapWidget::setToMapCanvasExtent()
783 xForm.setBallparkTransformsAreAppropriate(
true );
784 newExtent = xForm.transformBoundingBox( newExtent );
793 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
794 mMapItem->zoomToExtent( newExtent );
795 mMapItem->layout()->undoStack()->endCommand();
798void QgsLayoutMapWidget::setToMapCanvasScale()
805 const double newScale = mMapCanvas->
scale();
807 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Scale" ) );
808 mMapItem->setScale( newScale );
809 mMapItem->layout()->undoStack()->endCommand();
812void QgsLayoutMapWidget::viewExtentInCanvas()
819 const QgsRectangle currentMapExtent = mMapItem->extent();
821 if ( !currentMapExtent.
isEmpty() )
836void QgsLayoutMapWidget::viewScaleInCanvas()
843 const double currentScale = mMapItem->scale();
844 mMapCanvas->
zoomScale( currentScale,
true );
847void QgsLayoutMapWidget::mXMinLineEdit_editingFinished()
849 updateComposerExtentFromGui();
852void QgsLayoutMapWidget::mXMaxLineEdit_editingFinished()
854 updateComposerExtentFromGui();
857void QgsLayoutMapWidget::mYMinLineEdit_editingFinished()
859 updateComposerExtentFromGui();
862void QgsLayoutMapWidget::mYMaxLineEdit_editingFinished()
864 updateComposerExtentFromGui();
867void QgsLayoutMapWidget::updateGuiElements()
874 blockAllSignals(
true );
875 mLabel->setText( mMapItem->displayName() );
877 whileBlocking( mCrsSelector )->setCrs( mMapItem->presetCrs() );
880 const double scale = mMapItem->scale();
883 if ( scale >= 10000 )
886 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 0 ) );
888 else if ( scale >= 10 )
890 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 3 ) );
892 else if ( scale >= 1 )
895 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 4 ) );
900 mScaleLineEdit->setText( QLocale().toString( mMapItem->scale(),
'f', 10 ) );
904 const QgsRectangle composerMapExtent = mMapItem->extent();
905 mXMinLineEdit->setText( QLocale().toString( composerMapExtent.
xMinimum(),
'f', 3 ) );
906 mXMaxLineEdit->setText( QLocale().toString( composerMapExtent.
xMaximum(),
'f', 3 ) );
907 mYMinLineEdit->setText( QLocale().toString( composerMapExtent.
yMinimum(),
'f', 3 ) );
908 mYMaxLineEdit->setText( QLocale().toString( composerMapExtent.
yMaximum(),
'f', 3 ) );
913 mFollowVisibilityPresetCheckBox->setCheckState(
914 mMapItem->followVisibilityPreset() ? Qt::Checked : Qt::Unchecked );
915 const int presetModelIndex = mFollowVisibilityPresetCombo->findText( mMapItem->followVisibilityPresetName() );
916 mFollowVisibilityPresetCombo->setCurrentIndex( presetModelIndex != -1 ? presetModelIndex : 0 );
919 if ( mMapItem->keepLayerSet() )
921 mKeepLayerListCheckBox->setCheckState( Qt::Checked );
925 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
928 mKeepLayerStylesCheckBox->setEnabled( mMapItem->keepLayerSet() );
929 mKeepLayerStylesCheckBox->setCheckState( mMapItem->keepLayerStyles() ? Qt::Checked : Qt::Unchecked );
932 if ( mMapItem->drawAnnotations() )
934 mDrawCanvasItemsCheckBox->setCheckState( Qt::Checked );
938 mDrawCanvasItemsCheckBox->setCheckState( Qt::Unchecked );
942 mAtlasCheckBox->setChecked( mMapItem->atlasDriven() );
945 mAtlasFixedScaleRadio->setEnabled( mMapItem->atlasDriven() );
948 mAtlasMarginRadio->setEnabled( mMapItem->atlasDriven() );
950 mAtlasPredefinedScaleRadio->setEnabled( mMapItem->atlasDriven() );
953 if ( mMapItem->atlasDriven() )
955 toggleAtlasScalingOptionsByLayerType();
958 if ( !hasPredefinedScales() )
960 mAtlasPredefinedScaleRadio->setEnabled(
false );
963 mTemporalCheckBox->setChecked( mMapItem->isTemporal() );
964 mTemporalCheckBox->setCollapsed( !mMapItem->isTemporal() );
965 mStartDateTime->setEnabled( mMapItem->isTemporal() );
966 mEndDateTime->setEnabled( mMapItem->isTemporal() );
967 if ( mMapItem->isTemporal() )
969 mStartDateTime->setDateTime( mMapItem->temporalRange().begin() );
970 mEndDateTime->setDateTime( mMapItem->temporalRange().end() );
973 whileBlocking( mElevationRangeCheckBox )->setChecked( mMapItem->zRangeEnabled() );
974 mElevationRangeCheckBox->setCollapsed( !mMapItem->zRangeEnabled() );
975 if ( mMapItem->zRange().lower() != std::numeric_limits< double >::lowest() )
976 whileBlocking( mZLowerSpin )->setValue( mMapItem->zRange().lower() );
979 if ( mMapItem->zRange().upper() != std::numeric_limits< double >::max() )
980 whileBlocking( mZUpperSpin )->setValue( mMapItem->zRange().upper() );
986 loadOverviewEntries();
988 blockAllSignals(
false );
991void QgsLayoutMapWidget::toggleAtlasScalingOptionsByLayerType()
1009 mAtlasFixedScaleRadio->setChecked(
true );
1010 mAtlasMarginRadio->setEnabled(
false );
1015 mAtlasMarginRadio->setEnabled(
true );
1019void QgsLayoutMapWidget::updateComposerExtentFromGui()
1026 double xmin, ymin, xmax, ymax;
1027 bool conversionSuccess;
1029 xmin = QLocale().toDouble( mXMinLineEdit->text(), &conversionSuccess );
1030 if ( !conversionSuccess )
1032 xmax = QLocale().toDouble( mXMaxLineEdit->text(), &conversionSuccess );
1033 if ( !conversionSuccess )
1035 ymin = QLocale().toDouble( mYMinLineEdit->text(), &conversionSuccess );
1036 if ( !conversionSuccess )
1038 ymax = QLocale().toDouble( mYMaxLineEdit->text(), &conversionSuccess );
1039 if ( !conversionSuccess )
1042 const QgsRectangle newExtent( xmin, ymin, xmax, ymax );
1044 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Extent" ) );
1045 mMapItem->setExtent( newExtent );
1046 mMapItem->layout()->undoStack()->endCommand();
1049void QgsLayoutMapWidget::blockAllSignals(
bool b )
1051 mScaleLineEdit->blockSignals( b );
1052 mXMinLineEdit->blockSignals( b );
1053 mXMaxLineEdit->blockSignals( b );
1054 mYMinLineEdit->blockSignals( b );
1055 mYMaxLineEdit->blockSignals( b );
1056 mDrawCanvasItemsCheckBox->blockSignals( b );
1057 mOverviewFrameMapComboBox->blockSignals( b );
1058 mOverviewFrameStyleButton->blockSignals( b );
1059 mOverviewBlendModeComboBox->blockSignals( b );
1060 mOverviewInvertCheckbox->blockSignals( b );
1061 mOverviewCenterCheckbox->blockSignals( b );
1062 mAtlasCheckBox->blockSignals( b );
1063 mAtlasMarginSpinBox->blockSignals( b );
1064 mAtlasFixedScaleRadio->blockSignals( b );
1065 mAtlasMarginRadio->blockSignals( b );
1066 mFollowVisibilityPresetCheckBox->blockSignals( b );
1067 mFollowVisibilityPresetCombo->blockSignals( b );
1068 mKeepLayerListCheckBox->blockSignals( b );
1069 mKeepLayerStylesCheckBox->blockSignals( b );
1070 mActionSetToCanvasExtent->blockSignals( b );
1071 mActionUpdatePreview->blockSignals( b );
1072 mTemporalCheckBox->blockSignals( b );
1073 mStartDateTime->blockSignals( b );
1074 mEndDateTime->blockSignals( b );
1076 blockOverviewItemsSignals( b );
1079void QgsLayoutMapWidget::updatePreview()
1085 mMapItem->refresh();
1088void QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged(
int state )
1095 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1096 if ( state == Qt::Checked )
1098 mMapItem->setFollowVisibilityPreset(
true );
1101 mKeepLayerListCheckBox->setCheckState( Qt::Unchecked );
1102 mKeepLayerStylesCheckBox->setCheckState( Qt::Unchecked );
1104 mMapItem->invalidateCache();
1108 mMapItem->setFollowVisibilityPreset(
false );
1110 mMapItem->layout()->undoStack()->endCommand();
1113void QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged(
int state )
1121 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Map Preset Changed" ) );
1122 storeCurrentLayerSet();
1123 mMapItem->setKeepLayerSet( state == Qt::Checked );
1124 if ( state == Qt::Unchecked )
1126 mMapItem->setLayers( QList< QgsMapLayer * >() );
1128 mMapItem->layout()->undoStack()->endCommand();
1131 if ( state == Qt::Checked )
1134 mFollowVisibilityPresetCheckBox->setCheckState( Qt::Unchecked );
1138 mKeepLayerStylesCheckBox->setChecked( Qt::Unchecked );
1139 mMapItem->invalidateCache();
1142 mKeepLayerStylesCheckBox->setEnabled( state == Qt::Checked );
1145void QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged(
int state )
1152 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Map Preset" ) );
1153 if ( state == Qt::Checked )
1155 mMapItem->storeCurrentLayerStyles();
1156 mMapItem->setKeepLayerStyles(
true );
1160 mMapItem->setLayerStyleOverrides( QMap<QString, QString>() );
1161 mMapItem->setKeepLayerStyles(
false );
1163 mMapItem->layout()->undoStack()->endCommand();
1166void QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged(
int state )
1173 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Toggle Map Item" ) );
1174 mMapItem->setDrawAnnotations( state == Qt::Checked );
1175 mMapItem->invalidateCache();
1176 mMapItem->layout()->undoStack()->endCommand();
1179void QgsLayoutMapWidget::atlasLayerChanged(
QgsVectorLayer *layer )
1184 mAtlasCheckBox->setChecked(
false );
1185 mAtlasCheckBox->setEnabled(
false );
1190 mAtlasCheckBox->setEnabled(
true );
1194 if ( mAtlasCheckBox->isChecked() )
1195 toggleAtlasScalingOptionsByLayerType();
1198bool QgsLayoutMapWidget::hasPredefinedScales()
const
1203 if ( !hasProjectScales || scales.isEmpty() )
1208 return !scales.isEmpty() && !scales[0].isEmpty();
1213void QgsLayoutMapWidget::mAddGridPushButton_clicked()
1220 const QString itemName = tr(
"Grid %1" ).arg( mMapItem->grids()->size() + 1 );
1222 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Grid" ) );
1223 mMapItem->grids()->addGrid( grid );
1224 mMapItem->layout()->undoStack()->endCommand();
1225 mMapItem->updateBoundingRect();
1228 addGridListItem( grid->
id(), grid->
name() );
1229 mGridListWidget->setCurrentRow( 0 );
1230 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1233void QgsLayoutMapWidget::mRemoveGridPushButton_clicked()
1235 QListWidgetItem *item = mGridListWidget->currentItem();
1241 mMapItem->beginCommand( tr(
"Remove Grid" ) );
1242 mMapItem->grids()->removeGrid( item->data( Qt::UserRole ).toString() );
1243 QListWidgetItem *delItem = mGridListWidget->takeItem( mGridListWidget->row( item ) );
1245 mMapItem->endCommand();
1246 mMapItem->updateBoundingRect();
1250void QgsLayoutMapWidget::mCopyGridPushButton_clicked()
1252 QListWidgetItem *item = mGridListWidget->currentItem();
1258 QgsLayoutItemMapGrid *sourceGrid = mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1264 QString itemName = tr(
"%1 - Copy" ).arg( sourceGrid->
name() );
1265 QList< QgsLayoutItemMapGrid * > grids = mMapItem->grids()->asList();
1268 const auto it = std::find_if( grids.begin(), grids.end(), [&itemName](
const QgsLayoutItemMapGrid * grd ) { return grd->name() == itemName; } );
1269 if ( it != grids.end() )
1272 itemName = tr(
"%1 - Copy %2" ).arg( sourceGrid->
name() ).arg( i );
1280 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Duplicate Map Grid" ) );
1281 mMapItem->grids()->addGrid( grid );
1282 mMapItem->layout()->undoStack()->endCommand();
1283 mMapItem->updateBoundingRect();
1286 addGridListItem( grid->
id(), grid->
name() );
1287 mGridListWidget->setCurrentRow( 0 );
1288 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1291void QgsLayoutMapWidget::mGridUpButton_clicked()
1293 QListWidgetItem *item = mGridListWidget->currentItem();
1299 const int row = mGridListWidget->row( item );
1304 mGridListWidget->takeItem( row );
1305 mGridListWidget->insertItem( row - 1, item );
1306 mGridListWidget->setCurrentItem( item );
1307 mMapItem->beginCommand( tr(
"Move Grid Up" ) );
1308 mMapItem->grids()->moveGridUp( item->data( Qt::UserRole ).toString() );
1309 mMapItem->endCommand();
1313void QgsLayoutMapWidget::mGridDownButton_clicked()
1315 QListWidgetItem *item = mGridListWidget->currentItem();
1321 const int row = mGridListWidget->row( item );
1322 if ( mGridListWidget->count() <= row )
1326 mGridListWidget->takeItem( row );
1327 mGridListWidget->insertItem( row + 1, item );
1328 mGridListWidget->setCurrentItem( item );
1329 mMapItem->beginCommand( tr(
"Move Grid Down" ) );
1330 mMapItem->grids()->moveGridDown( item->data( Qt::UserRole ).toString() );
1331 mMapItem->endCommand();
1342 QListWidgetItem *item = mGridListWidget->currentItem();
1347 return mMapItem->grids()->grid( item->data( Qt::UserRole ).toString() );
1350void QgsLayoutMapWidget::mGridListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem * )
1352 mGridPropertiesButton->setEnabled(
static_cast< bool >( current ) );
1355void QgsLayoutMapWidget::mGridListWidget_itemChanged( QListWidgetItem *item )
1368 mMapItem->beginCommand( tr(
"Rename Grid" ) );
1369 grid->
setName( item->text() );
1370 mMapItem->endCommand();
1373void QgsLayoutMapWidget::mGridPropertiesButton_clicked()
1390QListWidgetItem *QgsLayoutMapWidget::addGridListItem(
const QString &
id,
const QString &name )
1392 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1393 item->setData( Qt::UserRole,
id );
1394 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1395 mGridListWidget->insertItem( 0, item );
1399void QgsLayoutMapWidget::loadGridEntries()
1402 QSet<QString> selectedIds;
1403 const QList<QListWidgetItem *> itemSelection = mGridListWidget->selectedItems();
1404 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1405 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1407 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1410 mGridListWidget->clear();
1416 const QList< QgsLayoutItemMapGrid * > grids = mMapItem->grids()->asList();
1417 QList< QgsLayoutItemMapGrid * >::const_iterator gridIt = grids.constBegin();
1418 for ( ; gridIt != grids.constEnd(); ++gridIt )
1420 QListWidgetItem *item = addGridListItem( ( *gridIt )->id(), ( *gridIt )->name() );
1421 if ( selectedIds.contains( ( *gridIt )->id() ) )
1423 item->setSelected(
true );
1424 mGridListWidget->setCurrentItem( item );
1428 if ( mGridListWidget->currentItem() )
1430 mGridListWidget_currentItemChanged( mGridListWidget->currentItem(),
nullptr );
1434 mGridListWidget_currentItemChanged(
nullptr,
nullptr );
1438void QgsLayoutMapWidget::mAddOverviewPushButton_clicked()
1445 const QString itemName = tr(
"Overview %1" ).arg( mMapItem->overviews()->size() + 1 );
1447 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Add Map Overview" ) );
1448 mMapItem->overviews()->addOverview( overview );
1449 mMapItem->layout()->undoStack()->endCommand();
1450 mMapItem->invalidateCache();
1452 addOverviewListItem( overview->
id(), overview->
name() );
1454 mOverviewListWidget->setCurrentRow( 0 );
1457void QgsLayoutMapWidget::mRemoveOverviewPushButton_clicked()
1459 QListWidgetItem *item = mOverviewListWidget->currentItem();
1464 mMapItem->beginCommand( tr(
"Remove Map Overview" ) );
1465 mMapItem->overviews()->removeOverview( item->data( Qt::UserRole ).toString() );
1466 mMapItem->endCommand();
1467 QListWidgetItem *delItem = mOverviewListWidget->takeItem( mOverviewListWidget->row( item ) );
1469 mMapItem->invalidateCache();
1472void QgsLayoutMapWidget::mOverviewUpButton_clicked()
1474 QListWidgetItem *item = mOverviewListWidget->currentItem();
1480 const int row = mOverviewListWidget->row( item );
1485 mOverviewListWidget->takeItem( row );
1486 mOverviewListWidget->insertItem( row - 1, item );
1487 mOverviewListWidget->setCurrentItem( item );
1488 mMapItem->beginCommand( tr(
"Move Overview Up" ) );
1489 mMapItem->overviews()->moveOverviewUp( item->data( Qt::UserRole ).toString() );
1490 mMapItem->endCommand();
1491 mMapItem->invalidateCache();
1494void QgsLayoutMapWidget::mOverviewDownButton_clicked()
1496 QListWidgetItem *item = mOverviewListWidget->currentItem();
1502 const int row = mOverviewListWidget->row( item );
1503 if ( mOverviewListWidget->count() <= row )
1507 mOverviewListWidget->takeItem( row );
1508 mOverviewListWidget->insertItem( row + 1, item );
1509 mOverviewListWidget->setCurrentItem( item );
1510 mMapItem->beginCommand( tr(
"Move Overview Down" ) );
1511 mMapItem->overviews()->moveOverviewDown( item->data( Qt::UserRole ).toString() );
1512 mMapItem->endCommand();
1513 mMapItem->invalidateCache();
1523 QListWidgetItem *item = mOverviewListWidget->currentItem();
1529 return mMapItem->overviews()->overview( item->data( Qt::UserRole ).toString() );
1532void QgsLayoutMapWidget::mOverviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous )
1534 Q_UNUSED( previous )
1537 mOverviewCheckBox->setEnabled(
false );
1541 mOverviewCheckBox->setEnabled(
true );
1542 setOverviewItems( mMapItem->overviews()->overview( current->data( Qt::UserRole ).toString() ) );
1545void QgsLayoutMapWidget::mOverviewListWidget_itemChanged( QListWidgetItem *item )
1558 mMapItem->beginCommand( QStringLiteral(
"Rename Overview" ) );
1559 overview->
setName( item->text() );
1560 mMapItem->endCommand();
1561 if ( item->isSelected() )
1564 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1568void QgsLayoutMapWidget::setOverviewItemsEnabled(
bool enabled )
1570 mOverviewFrameMapLabel->setEnabled( enabled );
1571 mOverviewFrameMapComboBox->setEnabled( enabled );
1572 mOverviewFrameStyleLabel->setEnabled( enabled );
1573 mOverviewFrameStyleButton->setEnabled( enabled );
1574 mOverviewBlendModeLabel->setEnabled( enabled );
1575 mOverviewBlendModeComboBox->setEnabled( enabled );
1576 mOverviewInvertCheckbox->setEnabled( enabled );
1577 mOverviewCenterCheckbox->setEnabled( enabled );
1578 mOverviewPositionComboBox->setEnabled( enabled );
1584void QgsLayoutMapWidget::blockOverviewItemsSignals(
const bool block )
1586 mOverviewFrameMapComboBox->blockSignals( block );
1587 mOverviewFrameStyleButton->blockSignals( block );
1588 mOverviewBlendModeComboBox->blockSignals( block );
1589 mOverviewInvertCheckbox->blockSignals( block );
1590 mOverviewCenterCheckbox->blockSignals( block );
1591 mOverviewPositionComboBox->blockSignals( block );
1592 mOverviewStackingLayerComboBox->blockSignals( block );
1602 blockOverviewItemsSignals(
true );
1604 mOverviewCheckBox->setTitle( tr(
"Draw \"%1\" overview" ).arg( overview->
name() ) );
1605 mOverviewCheckBox->setChecked( overview->
enabled() );
1608 mOverviewFrameMapComboBox->setItem( overview->
linkedMap() );
1611 mOverviewBlendModeComboBox->setBlendMode( overview->
blendMode() );
1613 mOverviewInvertCheckbox->setChecked( overview->
inverted() );
1615 mOverviewCenterCheckbox->setChecked( overview->
centered() );
1617 mOverviewPositionComboBox->setCurrentIndex( mOverviewPositionComboBox->findData( overview->
stackingPosition() ) );
1618 mOverviewStackingLayerComboBox->setLayer( overview->
stackingLayer() );
1624 blockOverviewItemsSignals(
false );
1627void QgsLayoutMapWidget::storeCurrentLayerSet()
1634 mMapItem->setLayers( layers );
1636 if ( mMapItem->keepLayerStyles() )
1639 mMapItem->storeCurrentLayerStyles();
1643QList<QgsMapLayer *> QgsLayoutMapWidget::orderedPresetVisibleLayers(
const QString &name )
const
1648 QList<QgsMapLayer *> lst;
1652 if ( visibleIds.contains( layer->
id() ) )
1660QListWidgetItem *QgsLayoutMapWidget::addOverviewListItem(
const QString &
id,
const QString &name )
1662 QListWidgetItem *item =
new QListWidgetItem( name,
nullptr );
1663 item->setData( Qt::UserRole,
id );
1664 item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
1665 mOverviewListWidget->insertItem( 0, item );
1669void QgsLayoutMapWidget::loadOverviewEntries()
1672 QSet<QString> selectedIds;
1673 const QList<QListWidgetItem *> itemSelection = mOverviewListWidget->selectedItems();
1674 QList<QListWidgetItem *>::const_iterator sIt = itemSelection.constBegin();
1675 for ( ; sIt != itemSelection.constEnd(); ++sIt )
1677 selectedIds.insert( ( *sIt )->data( Qt::UserRole ).toString() );
1680 mOverviewListWidget->clear();
1686 mOverviewFrameMapComboBox->setExceptedItemList( QList< QgsLayoutItem * >() << mMapItem );
1689 const QList< QgsLayoutItemMapOverview * > overviews = mMapItem->overviews()->asList();
1690 QList< QgsLayoutItemMapOverview * >::const_iterator overviewIt = overviews.constBegin();
1691 for ( ; overviewIt != overviews.constEnd(); ++overviewIt )
1693 QListWidgetItem *item = addOverviewListItem( ( *overviewIt )->id(), ( *overviewIt )->name() );
1694 if ( selectedIds.contains( ( *overviewIt )->id() ) )
1696 item->setSelected(
true );
1697 mOverviewListWidget->setCurrentItem( item );
1701 if ( mOverviewListWidget->currentItem() )
1703 mOverviewListWidget_currentItemChanged( mOverviewListWidget->currentItem(),
nullptr );
1707 mOverviewListWidget_currentItemChanged(
nullptr,
nullptr );
1711void QgsLayoutMapWidget::mOverviewCheckBox_toggled(
bool state )
1719 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Overview Display Toggled" ) );
1721 mMapItem->invalidateCache();
1722 mMapItem->layout()->undoStack()->endCommand();
1725void QgsLayoutMapWidget::overviewMapChanged(
QgsLayoutItem *item )
1737 mMapItem->beginCommand( tr(
"Change Overview Map" ) );
1739 mMapItem->invalidateCache();
1740 mMapItem->endCommand();
1743void QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged(
int index )
1752 mMapItem->beginCommand( tr(
"Change Overview Blend Mode" ) );
1753 overview->
setBlendMode( mOverviewBlendModeComboBox->blendMode() );
1754 mMapItem->invalidateCache();
1755 mMapItem->endCommand();
1758void QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled(
bool state )
1766 mMapItem->beginCommand( tr(
"Toggle Overview Inverted" ) );
1768 mMapItem->invalidateCache();
1769 mMapItem->endCommand();
1772void QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled(
bool state )
1780 mMapItem->beginCommand( tr(
"Toggle Overview Centered" ) );
1782 mMapItem->invalidateCache();
1783 mMapItem->endCommand();
1786void QgsLayoutMapWidget::overviewStackingChanged(
int )
1794 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1796 mMapItem->invalidateCache();
1797 mMapItem->endCommand();
1804 mOverviewStackingLayerComboBox->setEnabled(
false );
1809 mOverviewStackingLayerComboBox->setEnabled(
true );
1814void QgsLayoutMapWidget::overviewStackingLayerChanged(
QgsMapLayer *layer )
1822 mMapItem->beginCommand( tr(
"Change Overview Position" ) );
1824 mMapItem->invalidateCache();
1825 mMapItem->endCommand();
1839 mLabelBoundarySpinBox->setClearValue( 0 );
1840 mLabelBoundarySpinBox->setShowClearButton(
true );
1842 mLabelBoundaryUnitsCombo->linkToWidget( mLabelBoundarySpinBox );
1843 mLabelBoundaryUnitsCombo->setConverter( &mMapItem->layout()->renderContext().measurementConverter() );
1846 connect( mLabelBoundarySpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsLayoutMapLabelingWidget::labelMarginChanged );
1847 connect( mShowPartialLabelsCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showPartialsToggled );
1848 connect( mShowUnplacedCheckBox, &QCheckBox::toggled,
this, &QgsLayoutMapLabelingWidget::showUnplacedToggled );
1865 mMapItem = qobject_cast< QgsLayoutItemMap * >( item );
1872 updateGuiElements();
1877void QgsLayoutMapLabelingWidget::updateGuiElements()
1879 whileBlocking( mLabelBoundarySpinBox )->setValue( mMapItem->labelMargin().length() );
1880 whileBlocking( mLabelBoundaryUnitsCombo )->setUnit( mMapItem->labelMargin().units() );
1884 if ( mBlockingItemsListView->model() )
1886 QAbstractItemModel *oldModel = mBlockingItemsListView->model();
1887 mBlockingItemsListView->setModel(
nullptr );
1888 oldModel->deleteLater();
1892 mBlockingItemsListView->setModel( model );
1897void QgsLayoutMapLabelingWidget::labelMarginChanged(
double val )
1904 mMapItem->layout()->undoStack()->endCommand();
1905 mMapItem->invalidateCache();
1908void QgsLayoutMapLabelingWidget::labelMarginUnitsChanged()
1914 mMapItem->setLabelMargin(
QgsLayoutMeasurement( mLabelBoundarySpinBox->value(), mLabelBoundaryUnitsCombo->unit() ) );
1915 mMapItem->layout()->undoStack()->endCommand();
1916 mMapItem->invalidateCache();
1919void QgsLayoutMapLabelingWidget::showPartialsToggled(
bool checked )
1924 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
1930 mMapItem->setMapFlags( flags );
1931 mMapItem->layout()->undoStack()->endCommand();
1932 mMapItem->invalidateCache();
1935void QgsLayoutMapLabelingWidget::showUnplacedToggled(
bool checked )
1940 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Visibility" ) );
1946 mMapItem->setMapFlags( flags );
1947 mMapItem->layout()->undoStack()->endCommand();
1948 mMapItem->invalidateCache();
1952 : QSortFilterProxyModel( parent )
1953 , mLayoutModel( layoutModel )
1956 setSourceModel( layoutModel );
1969 if ( i.column() != 0 )
1982 case Qt::CheckStateRole:
1983 switch ( i.column() )
1986 return mMapItem ? ( mMapItem->isLabelBlockingItem( item ) ? Qt::Checked : Qt::Unchecked ) : Qt::Unchecked;
1992 return mLayoutModel->
data( sourceIndex, role );
2000 if ( !index.isValid() )
2004 if ( !item || !mMapItem )
2009 mMapItem->layout()->undoStack()->beginCommand( mMapItem, tr(
"Change Label Blocking Items" ) );
2011 if ( value.toBool() )
2013 mMapItem->addLabelBlockingItem( item );
2017 mMapItem->removeLabelBlockingItem( item );
2019 emit dataChanged( index, index, QVector<int>() << role );
2021 mMapItem->layout()->undoStack()->endCommand();
2022 mMapItem->invalidateCache();
2029 Qt::ItemFlags
flags = QSortFilterProxyModel::flags( index );
2031 if ( ! index.isValid() )
2036 switch ( index.column() )
2039 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
2041 return flags | Qt::ItemIsEnabled | Qt::ItemIsSelectable;
2048 if ( !item || item == mMapItem )
2071 mLayersTreeView->setModel( mLayerModel );
2077 for (
int i = 0; i < mAtlasClippingTypeComboBox->count(); ++i )
2079 mItemClippingTypeComboBox->addItem( mAtlasClippingTypeComboBox->itemText( i ), mAtlasClippingTypeComboBox->itemData( i ) );
2082 mClipItemComboBox->setCurrentLayout( map->
layout() );
2085 connect( mRadioClipSelectedLayers, &QRadioButton::toggled,
this, &QgsLayoutMapClippingWidget::toggleLayersSelectionGui );
2086 mLayersTreeView->setEnabled(
false );
2087 mSelectAllButton->setEnabled(
false );
2088 mDeselectAllButton->setEnabled(
false );
2089 mInvertSelectionButton->setEnabled(
false );
2090 mRadioClipAllLayers->setChecked(
true );
2092 connect( mClipToAtlasCheckBox, &QGroupBox::toggled,
this, [ = ](
bool active )
2094 if ( !mBlockUpdates )
2096 mMapItem->beginCommand( tr(
"Toggle Atlas Clipping" ) );
2097 mMapItem->atlasClippingSettings()->setEnabled( active );
2098 mMapItem->endCommand();
2101 connect( mForceLabelsInsideCheckBox, &QCheckBox::toggled,
this, [ = ](
bool active )
2103 if ( !mBlockUpdates )
2105 mMapItem->beginCommand( tr(
"Change Atlas Clipping Label Behavior" ) );
2106 mMapItem->atlasClippingSettings()->setForceLabelsInsideFeature( active );
2107 mMapItem->endCommand();
2110 connect( mAtlasClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
2112 if ( !mBlockUpdates )
2114 mMapItem->beginCommand( tr(
"Change Atlas Clipping Behavior" ) );
2116 mMapItem->endCommand();
2120 connect( mRadioClipSelectedLayers, &QCheckBox::toggled,
this, [ = ](
bool active )
2122 if ( active && !mBlockUpdates )
2124 mBlockUpdates =
true;
2125 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2126 mMapItem->atlasClippingSettings()->setRestrictToLayers(
true );
2127 mMapItem->endCommand();
2128 mBlockUpdates =
false;
2132 connect( mSelectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::selectAll );
2133 connect( mDeselectAllButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::deselectAll );
2134 connect( mInvertSelectionButton, &QPushButton::clicked,
this, &QgsLayoutMapClippingWidget::invertSelection );
2136 connect( mRadioClipAllLayers, &QCheckBox::toggled,
this, [ = ](
bool active )
2138 if ( active && !mBlockUpdates )
2140 mBlockUpdates =
true;
2141 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2142 mMapItem->atlasClippingSettings()->setRestrictToLayers(
false );
2143 mMapItem->endCommand();
2144 mBlockUpdates =
false;
2147 connect( mLayerModel, &QgsMapLayerModel::dataChanged,
this, [ = ](
const QModelIndex &,
const QModelIndex &,
const QVector<int> &roles = QVector<int>() )
2149 if ( !roles.contains( Qt::CheckStateRole ) )
2152 if ( !mBlockUpdates )
2154 mBlockUpdates =
true;
2155 mMapItem->beginCommand( tr(
"Change Atlas Clipping Layers" ) );
2156 mMapItem->atlasClippingSettings()->setLayersToClip( mLayerModel->
layersChecked() );
2157 mMapItem->endCommand();
2158 mBlockUpdates =
false;
2164 connect( mClipToItemCheckBox, &QGroupBox::toggled,
this, [ = ](
bool active )
2166 if ( !mBlockUpdates )
2168 mMapItem->beginCommand( tr(
"Toggle Map Clipping" ) );
2169 mMapItem->itemClippingSettings()->setEnabled( active );
2170 mMapItem->endCommand();
2173 connect( mItemClippingTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [ = ]
2175 if ( !mBlockUpdates )
2177 mMapItem->beginCommand( tr(
"Change Map Clipping Behavior" ) );
2179 mMapItem->endCommand();
2182 connect( mForceLabelsInsideItemCheckBox, &QCheckBox::toggled,
this, [ = ](
bool active )
2184 if ( !mBlockUpdates )
2186 mMapItem->beginCommand( tr(
"Change Map Clipping Label Behavior" ) );
2187 mMapItem->itemClippingSettings()->setForceLabelsInsideClipPath( active );
2188 mMapItem->endCommand();
2193 if ( !mBlockUpdates )
2195 mMapItem->beginCommand( tr(
"Change Map Clipping Item" ) );
2196 mMapItem->itemClippingSettings()->setSourceItem( item );
2197 mMapItem->endCommand();
2204 this, &QgsLayoutMapClippingWidget::atlasLayerChanged );
2208 atlasToggled( atlas->enabled() );
2214 mClipToAtlasCheckBox->setTitle( tr(
"Clip to %1 feature" ).arg(
string ) );
2215 mClipToAtlasLabel->setText( tr(
"<b>When enabled, map layers will be automatically clipped to the boundary of the current %1 feature.</b>" ).arg(
string ) );
2216 mForceLabelsInsideCheckBox->setText( tr(
"Force labels inside %1 feature" ).arg(
string ) );
2229 mMapItem = qobject_cast< QgsLayoutItemMap * >( item );
2236 updateGuiElements();
2241void QgsLayoutMapClippingWidget::updateGuiElements()
2243 if ( mBlockUpdates )
2246 mBlockUpdates =
true;
2247 mClipToAtlasCheckBox->setChecked( mMapItem->atlasClippingSettings()->enabled() );
2248 mAtlasClippingTypeComboBox->setCurrentIndex( mAtlasClippingTypeComboBox->findData(
static_cast< int >( mMapItem->atlasClippingSettings()->featureClippingType() ) ) );
2249 mForceLabelsInsideCheckBox->setChecked( mMapItem->atlasClippingSettings()->forceLabelsInsideFeature() );
2251 mRadioClipAllLayers->setChecked( !mMapItem->atlasClippingSettings()->restrictToLayers() );
2252 mRadioClipSelectedLayers->setChecked( mMapItem->atlasClippingSettings()->restrictToLayers() );
2253 mLayerModel->
setLayersChecked( mMapItem->atlasClippingSettings()->layersToClip() );
2255 mClipToItemCheckBox->setChecked( mMapItem->itemClippingSettings()->enabled() );
2256 mItemClippingTypeComboBox->setCurrentIndex( mItemClippingTypeComboBox->findData(
static_cast< int >( mMapItem->itemClippingSettings()->featureClippingType() ) ) );
2257 mForceLabelsInsideItemCheckBox->setChecked( mMapItem->itemClippingSettings()->forceLabelsInsideClipPath() );
2258 mClipItemComboBox->setItem( mMapItem->itemClippingSettings()->sourceItem() );
2260 mBlockUpdates =
false;
2263void QgsLayoutMapClippingWidget::atlasLayerChanged(
QgsVectorLayer *layer )
2268 mClipToAtlasCheckBox->setChecked(
false );
2269 mClipToAtlasCheckBox->setEnabled(
false );
2274 mClipToAtlasCheckBox->setEnabled(
true );
2278void QgsLayoutMapClippingWidget::atlasToggled(
bool atlasEnabled )
2280 if ( atlasEnabled &&
2281 mMapItem && mMapItem->layout() && mMapItem->layout()->reportContext().layer()
2284 mClipToAtlasCheckBox->setEnabled(
true );
2288 mClipToAtlasCheckBox->setEnabled(
false );
2289 mClipToAtlasCheckBox->setChecked(
false );
2293void QgsLayoutMapClippingWidget::invertSelection()
2295 for (
int i = 0; i < mLayerModel->
rowCount( QModelIndex() ); i++ )
2297 QModelIndex index = mLayerModel->
index( i, 0 );
2298 Qt::CheckState currentState = Qt::CheckState( mLayerModel->
data( index, Qt::CheckStateRole ).toInt() );
2299 Qt::CheckState newState = ( currentState == Qt::Checked ) ? Qt::Unchecked : Qt::Checked;
2300 mLayerModel->
setData( index, newState, Qt::CheckStateRole );
2304void QgsLayoutMapClippingWidget::selectAll()
2306 for (
int i = 0; i < mLayerModel->
rowCount( QModelIndex() ); i++ )
2308 QModelIndex index = mLayerModel->
index( i, 0 );
2309 mLayerModel->
setData( index, Qt::Checked, Qt::CheckStateRole );
2313void QgsLayoutMapClippingWidget::deselectAll()
2315 for (
int i = 0; i < mLayerModel->
rowCount( QModelIndex() ); i++ )
2317 QModelIndex index = mLayerModel->
index( i, 0 );
2318 mLayerModel->
setData( index, Qt::Unchecked, Qt::CheckStateRole );
2322void QgsLayoutMapClippingWidget::toggleLayersSelectionGui(
bool toggled )
2324 mLayersTreeView->setEnabled( toggled );
2325 mSelectAllButton->setEnabled( toggled );
2326 mDeselectAllButton->setEnabled( toggled );
2327 mInvertSelectionButton->setEnabled( toggled );
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsBookmarkManager * bookmarkManager()
Returns the application's bookmark manager, used for storing installation-wide bookmarks.
@ Extent
Bookmark extent as a QgsReferencedRectangle.
A QSortFilterProxyModel subclass for sorting the entries in a QgsBookmarkManagerModel.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Custom exception class for Coordinate Reference System related exceptions.
QgsRange which stores a range of double values.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
@ MinimumValue
Reset value to minimum()
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
QList< QgsMapLayer * > layerOrder() const
The order in which layers will be rendered on the canvas.
Class used to render QgsLayout as an atlas, by iterating over the features from an associated vector ...
void toggled(bool enabled)
Emitted when atlas is enabled or disabled.
A common interface for layout designer dialogs and widgets.
virtual void activateTool(StandardTool tool)=0
Activates a standard layout designer tool.
@ ToolMoveItemContent
Move item content tool.
void itemChanged(QgsLayoutItem *item)
Emitted whenever the currently selected item changes.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
void copyProperties(const QgsLayoutItemMapGrid *other)
Copies properties from specified map grid.
QString id() const
Returns the unique id for the map item.
StackingPosition
Item stacking position, specifies where the in the map's stack the item should be rendered.
@ StackBelowMapLabels
Render above all map layers, but below map labels.
@ StackAboveMapLabels
Render above all map layers and labels.
@ StackBelowMapLayer
Render below a specific map layer (see stackingLayer())
@ StackAboveMapLayer
Render above a specific map layer (see stackingLayer())
@ StackBelowMap
Render below all map layers.
void setStackingLayer(QgsMapLayer *layer)
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rende...
virtual void setEnabled(bool enabled)
Controls whether the item will be drawn.
void setStackingPosition(StackingPosition position)
Sets the item's stacking position, which specifies where the in the map's stack the item should be re...
StackingPosition stackingPosition() const
Returns the item's stacking position, which specifies where the in the map's stack the item should be...
QString name() const
Returns the friendly display name for the item.
void setName(const QString &name)
Sets the friendly display name for the item.
bool enabled() const
Returns whether the item will be drawn.
QgsMapLayer * stackingLayer() const
Returns the item's stacking layer, which specifies where the in the map's stack the item should be re...
An individual overview which is drawn above the map content in a QgsLayoutItemMap,...
QgsFillSymbol * frameSymbol()
Returns the fill symbol used for drawing the overview extent.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the overview.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the overview.
bool centered() const
Returns whether the extent of the map is forced to center on the overview.
void setLinkedMap(QgsLayoutItemMap *map)
Sets the map to show the overview extent of.
void setFrameSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used for drawing the overview extent.
bool inverted() const
Returns whether the overview frame is inverted, ie, whether the shaded area is drawn outside the exte...
void setInverted(bool inverted)
Sets whether the overview frame is inverted, ie, whether the shaded area is drawn outside the extent ...
void setCentered(bool centered)
Sets whether the extent of the map is forced to center on the overview.
QgsLayoutItemMap * linkedMap()
Returns the source map to show the overview extent of.
Layout graphical items for displaying a map.
void extentChanged()
Emitted when the map's extent changes.
@ Predefined
A scale is chosen from the predefined scales.
@ Auto
The extent is adjusted so that each feature is fully visible.
@ Fixed
The current scale of the map is used for each feature of the atlas.
void mapRotationChanged(double newRotation)
Emitted when the map's rotation changes.
QFlags< MapItemFlag > MapItemFlags
@ ShowPartialLabels
Whether to draw labels which are partially outside of the map view.
@ ShowUnplacedLabels
Whether to render unplaced labels in the map view.
Base class for graphical items within a QgsLayout.
@ UndoOverviewStyle
Map overview style.
@ UndoMapRotation
Map rotation changed.
@ UndoAtlasMargin
Map atlas margin changed.
@ UndoMapLabelMargin
Margin for labels from edge of map.
int type() const override
Returns a unique graphics item type identifier.
@ FlagProvidesClipPath
Item can act as a clipping path provider (see clipPath())
Model for label blocking items.
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
QgsLayoutMapItemBlocksLabelsModel(QgsLayoutItemMap *map, QgsLayoutModel *layoutModel, QObject *parent=nullptr)
constructor
Qt::ItemFlags flags(const QModelIndex &index) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QVariant data(const QModelIndex &index, int role) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
A model for items attached to a layout.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
QgsLayoutItem * itemFromIndex(const QModelIndex &index) const
Returns the QgsLayoutItem corresponding to a QModelIndex index, if possible.
const QgsLayout * layout() const
Returns the layout the object is attached to.
void changed()
Emitted when the object's properties change.
@ MapYMin
Map extent y minimum.
@ MapZRangeUpper
Map frame Z-range lower value.
@ StartDateTime
Temporal range's start DateTime.
@ MapLayers
Map layer set.
@ MapZRangeLower
Map frame Z-range lower value.
@ MapRotation
Map rotation.
@ MapXMax
Map extent x maximum.
@ MapStylePreset
Layer and style map theme.
@ MapYMax
Map extent y maximum.
@ MapAtlasMargin
Map atlas margin.
@ EndDateTime
Temporal range's end DateTime.
@ MapXMin
Map extent x minimum.
@ MapLabelMargin
Map label margin.
@ OriginalValue
Return the original, user set value.
void layerChanged(QgsVectorLayer *layer)
Emitted when the context's layer is changed.
void unitChanged(Qgis::LayoutUnit unit)
Emitted when the unit is changed.
QgsLayoutReportContext & reportContext()
Returns a reference to the layout's report context, which stores information relating to the current ...
Map canvas is a class for displaying all GIS data types on a canvas.
void zoomScale(double scale, bool ignoreScaleLock=false)
Zooms the canvas to a specific scale.
bool setReferencedExtent(const QgsReferencedRectangle &extent)
Sets the canvas to the specified extent.
double scale() const
Returns the last reported scale of the canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
void refresh()
Repaints the canvas map.
FeatureClippingType
Feature clipping behavior, which controls how features from vector layers will be clipped.
@ NoClipping
Only render features which intersect the clipping region, but do not clip these features to the regio...
@ ClipPainterOnly
Applying clipping on the painter only (i.e. feature boundaries will be unchanged, but may be invisibl...
@ ClipToIntersection
Clip the geometry of these features to the region prior to rendering (i.e. feature boundaries will fo...
void layerChanged(QgsMapLayer *layer)
Emitted whenever the currently selected layer changes.
The QgsMapLayerModel class is a model to display layers in widgets.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QList< QgsMapLayer * > layersChecked(Qt::CheckState checkState=Qt::Checked)
Returns the list of layers which are checked (or unchecked)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void setItemsCheckable(bool checkable)
Defines if layers should be selectable in the widget.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
void setLayersChecked(const QList< QgsMapLayer * > &layers)
Sets which layers are checked in the model.
Base class for all map layer types.
QList< QgsMapLayer * > layers(bool expandGroupLayers=false) const
Returns the list of layers which will be rendered in the map.
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
void mapThemesChanged()
Emitted when map themes within the collection are changed.
QStringList mapThemeVisibleLayerIds(const QString &name) const
Returns the list of layer IDs that are visible for the specified map theme.
Interface for master layout type objects, such as print layouts and reports.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsMapThemeCollection * mapThemeCollection
QgsLayerTree * layerTreeRoot() const
Returns pointer to the root (invisible) node of the project's layer tree.
A rectangle specified with double values.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
A QgsRectangle with associated coordinate reference system.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
static const QgsSettingsEntryStringList * settingsMapScales
This class is a composition of two QSettings instances:
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE Qgis::WkbType wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
const QgsCoordinateReferenceSystem & crs