mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
Correctly set context for annotation items (map canvas, message bar)
This commit is contained in:
parent
00177d5932
commit
76e20c608e
@ -36,6 +36,20 @@ Sets the ``item`` whose properties should be shown in the widget.
|
||||
void updateItem( QgsAnnotationItem *item );
|
||||
%Docstring
|
||||
Updates an ``item``, setting the properties defined in the widget.
|
||||
%End
|
||||
|
||||
void setContext( const QgsSymbolWidgetContext &context );
|
||||
%Docstring
|
||||
Sets the ``context`` in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
|
||||
.. seealso:: :py:func:`context`
|
||||
%End
|
||||
|
||||
QgsSymbolWidgetContext context() const;
|
||||
%Docstring
|
||||
Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
|
||||
.. seealso:: :py:func:`setContext`
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
@ -49,6 +49,19 @@ If ``False`` is returned, then the widget could not be successfully updated
|
||||
to show the properties of ``item``.
|
||||
%End
|
||||
|
||||
virtual void setContext( const QgsSymbolWidgetContext &context );
|
||||
%Docstring
|
||||
Sets the ``context`` in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
|
||||
.. seealso:: :py:func:`context`
|
||||
%End
|
||||
|
||||
QgsSymbolWidgetContext context() const;
|
||||
%Docstring
|
||||
Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
|
||||
.. seealso:: :py:func:`setContext`
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@ -73,6 +73,14 @@ void QgsAnnotationItemPropertiesWidget::setMapLayerConfigWidgetContext( const Qg
|
||||
{
|
||||
QgsMapLayerConfigWidget::setMapLayerConfigWidgetContext( context );
|
||||
setItemId( context.annotationId() );
|
||||
|
||||
if ( mItemWidget )
|
||||
{
|
||||
QgsSymbolWidgetContext symbolWidgetContext;
|
||||
symbolWidgetContext.setMapCanvas( context.mapCanvas() );
|
||||
symbolWidgetContext.setMessageBar( context.messageBar() );
|
||||
mItemWidget->setContext( symbolWidgetContext );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsAnnotationItemPropertiesWidget::setDockMode( bool dockMode )
|
||||
@ -143,6 +151,11 @@ void QgsAnnotationItemPropertiesWidget::setItemId( const QString &itemId )
|
||||
connect( mItemWidget, &QgsAnnotationItemBaseWidget::itemChanged, this, &QgsAnnotationItemPropertiesWidget::onChanged );
|
||||
mItemWidget->setDockMode( dockMode() );
|
||||
connect( mItemWidget, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
||||
|
||||
QgsSymbolWidgetContext symbolWidgetContext;
|
||||
symbolWidgetContext.setMapCanvas( mMapLayerConfigWidgetContext.mapCanvas() );
|
||||
symbolWidgetContext.setMessageBar( mMapLayerConfigWidgetContext.messageBar() );
|
||||
mItemWidget->setContext( symbolWidgetContext );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,3 +53,16 @@ void QgsAnnotationItemCommonPropertiesWidget::updateItem( QgsAnnotationItem *ite
|
||||
item->setUseSymbologyReferenceScale( mReferenceScaleGroup->isChecked() );
|
||||
item->setSymbologyReferenceScale( mReferenceScaleWidget->scale() );
|
||||
}
|
||||
|
||||
void QgsAnnotationItemCommonPropertiesWidget::setContext( const QgsSymbolWidgetContext &context )
|
||||
{
|
||||
mContext = context;
|
||||
mReferenceScaleWidget->setMapCanvas( context.mapCanvas() );
|
||||
if ( context.mapCanvas() )
|
||||
mReferenceScaleWidget->setShowCurrentScaleButton( true );
|
||||
}
|
||||
|
||||
QgsSymbolWidgetContext QgsAnnotationItemCommonPropertiesWidget::context() const
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "qgis_sip.h"
|
||||
|
||||
#include "ui_qgsannotationcommonpropertieswidgetbase.h"
|
||||
#include "qgssymbolwidgetcontext.h"
|
||||
|
||||
class QgsAnnotationItem;
|
||||
|
||||
@ -51,6 +52,18 @@ class GUI_EXPORT QgsAnnotationItemCommonPropertiesWidget: public QWidget, privat
|
||||
*/
|
||||
void updateItem( QgsAnnotationItem *item );
|
||||
|
||||
/**
|
||||
* Sets the \a context in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
* \see context()
|
||||
*/
|
||||
void setContext( const QgsSymbolWidgetContext &context );
|
||||
|
||||
/**
|
||||
* Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
* \see setContext()
|
||||
*/
|
||||
QgsSymbolWidgetContext context() const;
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
@ -62,6 +75,8 @@ class GUI_EXPORT QgsAnnotationItemCommonPropertiesWidget: public QWidget, privat
|
||||
|
||||
bool mBlockChangedSignal = false;
|
||||
|
||||
//! Context in which widget is shown
|
||||
QgsSymbolWidgetContext mContext;
|
||||
};
|
||||
|
||||
#endif // QGSANNOTATIONITEMCOMMONPROPERTIESWIDGET_H
|
||||
|
||||
@ -26,6 +26,16 @@ bool QgsAnnotationItemBaseWidget::setItem( QgsAnnotationItem *item )
|
||||
return setNewItem( item );
|
||||
}
|
||||
|
||||
void QgsAnnotationItemBaseWidget::setContext( const QgsSymbolWidgetContext &context )
|
||||
{
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
QgsSymbolWidgetContext QgsAnnotationItemBaseWidget::context() const
|
||||
{
|
||||
return mContext;
|
||||
}
|
||||
|
||||
bool QgsAnnotationItemBaseWidget::setNewItem( QgsAnnotationItem * )
|
||||
{
|
||||
return false;
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "qgis_gui.h"
|
||||
#include "qgis_sip.h"
|
||||
#include "qgspanelwidget.h"
|
||||
#include "qgssymbolwidgetcontext.h"
|
||||
|
||||
class QgsAnnotationItem;
|
||||
|
||||
@ -62,6 +63,17 @@ class GUI_EXPORT QgsAnnotationItemBaseWidget: public QgsPanelWidget
|
||||
*/
|
||||
bool setItem( QgsAnnotationItem *item );
|
||||
|
||||
/**
|
||||
* Sets the \a context in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
* \see context()
|
||||
*/
|
||||
virtual void setContext( const QgsSymbolWidgetContext &context );
|
||||
|
||||
/**
|
||||
* Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.
|
||||
* \see setContext()
|
||||
*/
|
||||
QgsSymbolWidgetContext context() const;
|
||||
|
||||
signals:
|
||||
|
||||
@ -83,6 +95,8 @@ class GUI_EXPORT QgsAnnotationItemBaseWidget: public QgsPanelWidget
|
||||
*/
|
||||
virtual bool setNewItem( QgsAnnotationItem *item );
|
||||
|
||||
//! Context in which widget is shown
|
||||
QgsSymbolWidgetContext mContext;
|
||||
};
|
||||
|
||||
#endif // QGSANNOTATIONITEMWIDGET_H
|
||||
|
||||
@ -77,6 +77,14 @@ void QgsAnnotationPolygonItemWidget::setDockMode( bool dockMode )
|
||||
mSelector->setDockMode( dockMode );
|
||||
}
|
||||
|
||||
void QgsAnnotationPolygonItemWidget::setContext( const QgsSymbolWidgetContext &context )
|
||||
{
|
||||
QgsAnnotationItemBaseWidget::setContext( context );
|
||||
if ( mSelector )
|
||||
mSelector->setContext( context );
|
||||
mPropertiesWidget->setContext( context );
|
||||
}
|
||||
|
||||
QgsAnnotationPolygonItemWidget::~QgsAnnotationPolygonItemWidget() = default;
|
||||
|
||||
bool QgsAnnotationPolygonItemWidget::setNewItem( QgsAnnotationItem *item )
|
||||
@ -158,6 +166,14 @@ void QgsAnnotationLineItemWidget::setDockMode( bool dockMode )
|
||||
mSelector->setDockMode( dockMode );
|
||||
}
|
||||
|
||||
void QgsAnnotationLineItemWidget::setContext( const QgsSymbolWidgetContext &context )
|
||||
{
|
||||
QgsAnnotationItemBaseWidget::setContext( context );
|
||||
if ( mSelector )
|
||||
mSelector->setContext( context );
|
||||
mPropertiesWidget->setContext( context );
|
||||
}
|
||||
|
||||
QgsAnnotationLineItemWidget::~QgsAnnotationLineItemWidget() = default;
|
||||
|
||||
bool QgsAnnotationLineItemWidget::setNewItem( QgsAnnotationItem *item )
|
||||
@ -239,6 +255,14 @@ void QgsAnnotationMarkerItemWidget::setDockMode( bool dockMode )
|
||||
mSelector->setDockMode( dockMode );
|
||||
}
|
||||
|
||||
void QgsAnnotationMarkerItemWidget::setContext( const QgsSymbolWidgetContext &context )
|
||||
{
|
||||
QgsAnnotationItemBaseWidget::setContext( context );
|
||||
if ( mSelector )
|
||||
mSelector->setContext( context );
|
||||
mPropertiesWidget->setContext( context );
|
||||
}
|
||||
|
||||
QgsAnnotationMarkerItemWidget::~QgsAnnotationMarkerItemWidget() = default;
|
||||
|
||||
bool QgsAnnotationMarkerItemWidget::setNewItem( QgsAnnotationItem *item )
|
||||
@ -328,6 +352,14 @@ void QgsAnnotationPointTextItemWidget::setDockMode( bool dockMode )
|
||||
mTextFormatWidget->setDockMode( dockMode );
|
||||
}
|
||||
|
||||
void QgsAnnotationPointTextItemWidget::setContext( const QgsSymbolWidgetContext &context )
|
||||
{
|
||||
QgsAnnotationItemBaseWidget::setContext( context );
|
||||
if ( mTextFormatWidget )
|
||||
mTextFormatWidget->setContext( context );
|
||||
mPropertiesWidget->setContext( context );
|
||||
}
|
||||
|
||||
QgsAnnotationPointTextItemWidget::~QgsAnnotationPointTextItemWidget() = default;
|
||||
|
||||
bool QgsAnnotationPointTextItemWidget::setNewItem( QgsAnnotationItem *item )
|
||||
|
||||
@ -48,6 +48,7 @@ class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget, priva
|
||||
QgsAnnotationItem *createItem() override;
|
||||
void updateItem( QgsAnnotationItem *item ) override;
|
||||
void setDockMode( bool dockMode ) override;
|
||||
void setContext( const QgsSymbolWidgetContext &context ) override;
|
||||
|
||||
protected:
|
||||
bool setNewItem( QgsAnnotationItem *item ) override;
|
||||
@ -70,6 +71,7 @@ class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget, private
|
||||
QgsAnnotationItem *createItem() override;
|
||||
void updateItem( QgsAnnotationItem *item ) override;
|
||||
void setDockMode( bool dockMode ) override;
|
||||
void setContext( const QgsSymbolWidgetContext &context ) override;
|
||||
|
||||
protected:
|
||||
bool setNewItem( QgsAnnotationItem *item ) override;
|
||||
@ -92,6 +94,7 @@ class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget, privat
|
||||
QgsAnnotationItem *createItem() override;
|
||||
void updateItem( QgsAnnotationItem *item ) override;
|
||||
void setDockMode( bool dockMode ) override;
|
||||
void setContext( const QgsSymbolWidgetContext &context ) override;
|
||||
|
||||
protected:
|
||||
bool setNewItem( QgsAnnotationItem *item ) override;
|
||||
@ -115,6 +118,7 @@ class QgsAnnotationPointTextItemWidget : public QgsAnnotationItemBaseWidget, pri
|
||||
QgsAnnotationItem *createItem() override;
|
||||
void updateItem( QgsAnnotationItem *item ) override;
|
||||
void setDockMode( bool dockMode ) override;
|
||||
void setContext( const QgsSymbolWidgetContext &context ) override;
|
||||
|
||||
protected:
|
||||
bool setNewItem( QgsAnnotationItem *item ) override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user