mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Avoid slowdown when changing composer data defined properties
This commit is contained in:
parent
934c7c9173
commit
a67c84b9a9
@ -65,7 +65,9 @@ QgsComposerHtmlWidget::QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposer
|
||||
}
|
||||
|
||||
//connections for data defined buttons
|
||||
connect( mUrlDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mUrlLineEdit, SLOT( setDisabled( bool ) ) );
|
||||
connect( mUrlDDBtn, &QgsDataDefinedButtonV2::activated, mUrlLineEdit, &QLineEdit::setDisabled );
|
||||
registerDataDefinedButton( mUrlDDBtn, QgsComposerObject::SourceUrl,
|
||||
QgsDataDefinedButtonV2::AnyType, tr( "url string" ) );
|
||||
}
|
||||
|
||||
QgsComposerHtmlWidget::QgsComposerHtmlWidget()
|
||||
@ -465,8 +467,7 @@ void QgsComposerHtmlWidget::setGuiElementValues()
|
||||
|
||||
void QgsComposerHtmlWidget::populateDataDefinedButtons()
|
||||
{
|
||||
registerDataDefinedButton( mUrlDDBtn, QgsComposerObject::SourceUrl,
|
||||
QgsDataDefinedButtonV2::AnyType, tr( "url string" ) );
|
||||
updateDataDefinedButton( mUrlDDBtn );
|
||||
|
||||
//initial state of controls - disable related controls when dd buttons are active
|
||||
mUrlLineEdit->setEnabled( !mUrlDDBtn->isActive() );
|
||||
|
@ -74,7 +74,7 @@ void QgsComposerConfigObject::updateDataDefinedButtons()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposerConfigObject::registerDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty key,
|
||||
void QgsComposerConfigObject::initializeDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty key,
|
||||
QgsDataDefinedButtonV2::DataType type, const QString& description )
|
||||
{
|
||||
button->blockSignals( true );
|
||||
@ -85,6 +85,18 @@ void QgsComposerConfigObject::registerDataDefinedButton( QgsDataDefinedButtonV2*
|
||||
button->blockSignals( false );
|
||||
}
|
||||
|
||||
void QgsComposerConfigObject::updateDataDefinedButton( QgsDataDefinedButtonV2* button )
|
||||
{
|
||||
if ( !button )
|
||||
return;
|
||||
|
||||
if ( !button->property( "propertyKey" ).isValid() )
|
||||
return;
|
||||
|
||||
QgsComposerObject::DataDefinedProperty key = static_cast< QgsComposerObject::DataDefinedProperty >( button->property( "propertyKey" ).toInt() );
|
||||
whileBlocking( button )->setToProperty( mComposerObject->dataDefinedProperties().property( key ) );
|
||||
}
|
||||
|
||||
QgsAtlasComposition* QgsComposerConfigObject::atlasComposition() const
|
||||
{
|
||||
if ( !mComposerObject )
|
||||
@ -152,6 +164,8 @@ QgsComposerItemWidget::QgsComposerItemWidget( QWidget* parent, QgsComposerItem*
|
||||
buttonGroup->addButton( mLowerRightCheckBox );
|
||||
buttonGroup->setExclusive( true );
|
||||
|
||||
initializeDataDefinedButtons();
|
||||
|
||||
setValuesForGuiElements();
|
||||
connect( mItem->composition(), SIGNAL( paperSizeChanged() ), this, SLOT( setValuesForGuiPositionElements() ) );
|
||||
connect( mItem, SIGNAL( sizeChanged() ), this, SLOT( setValuesForGuiPositionElements() ) );
|
||||
@ -523,28 +537,36 @@ void QgsComposerItemWidget::setValuesForGuiNonPositionElements()
|
||||
mExcludeFromPrintsCheckBox->blockSignals( false );
|
||||
}
|
||||
|
||||
void QgsComposerItemWidget::initializeDataDefinedButtons()
|
||||
{
|
||||
mConfigObject->initializeDataDefinedButton( mXPositionDDBtn, QgsComposerObject::PositionX,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mYPositionDDBtn, QgsComposerObject::PositionY,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mWidthDDBtn, QgsComposerObject::ItemWidth,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mHeightDDBtn, QgsComposerObject::ItemHeight,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mItemRotationDDBtn, QgsComposerObject::ItemRotation,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::double180RotDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mTransparencyDDBtn, QgsComposerObject::Transparency,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::intTranspDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mBlendModeDDBtn, QgsComposerObject::BlendMode,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::blendModesDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mExcludePrintsDDBtn, QgsComposerObject::ExcludeFromExports,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::boolDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mItemFrameColorDDBtn, QgsComposerObject::FrameColor,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
mConfigObject->initializeDataDefinedButton( mItemBackgroundColorDDBtn, QgsComposerObject::BackgroundColor,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
}
|
||||
|
||||
void QgsComposerItemWidget::populateDataDefinedButtons()
|
||||
{
|
||||
mConfigObject->registerDataDefinedButton( mXPositionDDBtn, QgsComposerObject::PositionX,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mYPositionDDBtn, QgsComposerObject::PositionY,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mWidthDDBtn, QgsComposerObject::ItemWidth,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mHeightDDBtn, QgsComposerObject::ItemHeight,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mItemRotationDDBtn, QgsComposerObject::ItemRotation,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::double180RotDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mTransparencyDDBtn, QgsComposerObject::Transparency,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::intTranspDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mBlendModeDDBtn, QgsComposerObject::BlendMode,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::blendModesDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mExcludePrintsDDBtn, QgsComposerObject::ExcludeFromExports,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::boolDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mItemFrameColorDDBtn, QgsComposerObject::FrameColor,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
mConfigObject->registerDataDefinedButton( mItemBackgroundColorDDBtn, QgsComposerObject::BackgroundColor,
|
||||
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
Q_FOREACH ( QgsDataDefinedButtonV2* button, findChildren< QgsDataDefinedButtonV2* >() )
|
||||
{
|
||||
mConfigObject->updateDataDefinedButton( button );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsComposerItemWidget::setValuesForGuiElements()
|
||||
@ -773,7 +795,12 @@ QgsComposerItemBaseWidget::QgsComposerItemBaseWidget( QWidget* parent, QgsCompos
|
||||
|
||||
void QgsComposerItemBaseWidget::registerDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty property, QgsDataDefinedButtonV2::DataType type, const QString& description )
|
||||
{
|
||||
mConfigObject->registerDataDefinedButton( button, property, type, description );
|
||||
mConfigObject->initializeDataDefinedButton( button, property, type, description );
|
||||
}
|
||||
|
||||
void QgsComposerItemBaseWidget::updateDataDefinedButton( QgsDataDefinedButtonV2* button )
|
||||
{
|
||||
mConfigObject->updateDataDefinedButton( button );
|
||||
}
|
||||
|
||||
QgsVectorLayer* QgsComposerItemBaseWidget::atlasCoverageLayer() const
|
||||
|
@ -62,8 +62,13 @@ class QgsComposerConfigObject: public QObject
|
||||
* @param type valid data types for button
|
||||
* @param description user visible description for data defined property
|
||||
*/
|
||||
void registerDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty key,
|
||||
QgsDataDefinedButtonV2::DataType type, const QString& description );
|
||||
void initializeDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty key,
|
||||
QgsDataDefinedButtonV2::DataType type, const QString& description );
|
||||
|
||||
/**
|
||||
* Updates a data defined button to reflect the item's current properties.
|
||||
*/
|
||||
void updateDataDefinedButton( QgsDataDefinedButtonV2* button );
|
||||
|
||||
//! Returns the current atlas coverage layer (if set)
|
||||
QgsVectorLayer* atlasCoverageLayer() const;
|
||||
@ -105,6 +110,11 @@ class QgsComposerItemBaseWidget: public QgsPanelWidget
|
||||
void registerDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty property,
|
||||
QgsDataDefinedButtonV2::DataType type, const QString& description );
|
||||
|
||||
/**
|
||||
* Updates a previously registered data defined button to reflect the item's current properties.
|
||||
*/
|
||||
void updateDataDefinedButton( QgsDataDefinedButtonV2* button );
|
||||
|
||||
//! Returns the current atlas coverage layer (if set)
|
||||
QgsVectorLayer* atlasCoverageLayer() const;
|
||||
|
||||
@ -182,6 +192,8 @@ class QgsComposerItemWidget: public QWidget, private Ui::QgsComposerItemWidgetBa
|
||||
|
||||
protected slots:
|
||||
//! Initializes data defined buttons to current atlas coverage layer
|
||||
void initializeDataDefinedButtons();
|
||||
//! Sets data defined button state to match item
|
||||
void populateDataDefinedButtons();
|
||||
|
||||
private:
|
||||
|
@ -105,19 +105,6 @@ QgsComposerMapWidget::QgsComposerMapWidget( QgsComposerMap* composerMap )
|
||||
|
||||
connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsComposerMapWidget::mapCrsChanged );
|
||||
|
||||
updateGuiElements();
|
||||
loadGridEntries();
|
||||
loadOverviewEntries();
|
||||
populateDataDefinedButtons();
|
||||
blockAllSignals( false );
|
||||
}
|
||||
|
||||
QgsComposerMapWidget::~QgsComposerMapWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsComposerMapWidget::populateDataDefinedButtons()
|
||||
{
|
||||
registerDataDefinedButton( mScaleDDBtn, QgsComposerObject::MapScale,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doubleDesc() );
|
||||
registerDataDefinedButton( mMapRotationDDBtn, QgsComposerObject::MapRotation,
|
||||
@ -136,6 +123,29 @@ void QgsComposerMapWidget::populateDataDefinedButtons()
|
||||
QgsDataDefinedButtonV2::String, tr( "string matching a style preset name" ) );
|
||||
registerDataDefinedButton( mLayersDDBtn, QgsComposerObject::MapLayers,
|
||||
QgsDataDefinedButtonV2::String, tr( "list of map layer names separated by | characters" ) );
|
||||
|
||||
updateGuiElements();
|
||||
loadGridEntries();
|
||||
loadOverviewEntries();
|
||||
|
||||
blockAllSignals( false );
|
||||
}
|
||||
|
||||
QgsComposerMapWidget::~QgsComposerMapWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void QgsComposerMapWidget::populateDataDefinedButtons()
|
||||
{
|
||||
updateDataDefinedButton( mScaleDDBtn );
|
||||
updateDataDefinedButton( mMapRotationDDBtn );
|
||||
updateDataDefinedButton( mXMinDDBtn );
|
||||
updateDataDefinedButton( mYMinDDBtn );
|
||||
updateDataDefinedButton( mXMaxDDBtn );
|
||||
updateDataDefinedButton( mYMaxDDBtn );
|
||||
updateDataDefinedButton( mAtlasMarginDDBtn );
|
||||
updateDataDefinedButton( mStylePresetsDDBtn );
|
||||
updateDataDefinedButton( mLayersDDBtn );
|
||||
}
|
||||
|
||||
void QgsComposerMapWidget::compositionAtlasToggled( bool atlasEnabled )
|
||||
|
@ -78,6 +78,14 @@ QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture
|
||||
|
||||
//connections for data defined buttons
|
||||
connect( mSourceDDBtn, &QgsDataDefinedButtonV2::activated, mPictureLineEdit, &QLineEdit::setDisabled );
|
||||
registerDataDefinedButton( mSourceDDBtn, QgsComposerObject::PictureSource,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::anyStringDesc() );
|
||||
registerDataDefinedButton( mFillColorDDBtn, QgsComposerObject::PictureSvgBackgroundColor,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
registerDataDefinedButton( mOutlineColorDDBtn, QgsComposerObject::PictureSvgOutlineColor,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
registerDataDefinedButton( mOutlineWidthDDBtn, QgsComposerObject::PictureSvgOutlineWidth,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doublePosDesc() );
|
||||
}
|
||||
|
||||
QgsComposerPictureWidget::~QgsComposerPictureWidget()
|
||||
@ -700,20 +708,10 @@ void QgsComposerPictureWidget::resizeEvent( QResizeEvent * event )
|
||||
|
||||
void QgsComposerPictureWidget::populateDataDefinedButtons()
|
||||
{
|
||||
registerDataDefinedButton( mSourceDDBtn, QgsComposerObject::PictureSource,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::anyStringDesc() );
|
||||
mFillColorDDBtn->blockSignals( true );
|
||||
registerDataDefinedButton( mFillColorDDBtn, QgsComposerObject::PictureSvgBackgroundColor,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
mFillColorDDBtn->blockSignals( false );
|
||||
mOutlineColorDDBtn->blockSignals( true );
|
||||
registerDataDefinedButton( mOutlineColorDDBtn, QgsComposerObject::PictureSvgOutlineColor,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::colorAlphaDesc() );
|
||||
mOutlineColorDDBtn->blockSignals( false );
|
||||
mOutlineWidthDDBtn->blockSignals( true );
|
||||
registerDataDefinedButton( mOutlineWidthDDBtn, QgsComposerObject::PictureSvgOutlineWidth,
|
||||
QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::doublePosDesc() );
|
||||
mOutlineWidthDDBtn->blockSignals( false );
|
||||
updateDataDefinedButton( mSourceDDBtn );
|
||||
updateDataDefinedButton( mFillColorDDBtn );
|
||||
updateDataDefinedButton( mOutlineColorDDBtn );
|
||||
updateDataDefinedButton( mOutlineWidthDDBtn );
|
||||
|
||||
//initial state of controls - disable related controls when dd buttons are active
|
||||
mPictureLineEdit->setEnabled( !mSourceDDBtn->isActive() );
|
||||
|
@ -242,6 +242,7 @@ void QgsDataDefinedButtonV2::setToProperty( const QgsAbstractProperty *property
|
||||
mExpressionString.clear();
|
||||
}
|
||||
setActive( property && property->isActive() );
|
||||
updateGui();
|
||||
}
|
||||
|
||||
void QgsDataDefinedButtonV2::aboutToShowMenu()
|
||||
|
@ -84,6 +84,8 @@ class GUI_EXPORT QgsDataDefinedButtonV2: public QToolButton
|
||||
|
||||
QgsAbstractProperty* toProperty();
|
||||
|
||||
void setToProperty( const QgsAbstractProperty* property );
|
||||
|
||||
/**
|
||||
* Returns true if the button has an active property.
|
||||
*/
|
||||
@ -220,7 +222,7 @@ class GUI_EXPORT QgsDataDefinedButtonV2: public QToolButton
|
||||
private:
|
||||
|
||||
void updateFieldLists();
|
||||
void setToProperty( const QgsAbstractProperty* property );
|
||||
|
||||
void showDescriptionDialog();
|
||||
void showExpressionDialog();
|
||||
void updateGui();
|
||||
|
Loading…
x
Reference in New Issue
Block a user