Skip to content
Permalink
Browse files
Clean up GUI for properties
  • Loading branch information
nyalldawson committed Jan 23, 2017
1 parent ffaa40e commit d5664ed635e5c1492afd5b911d07e4ea032cf930
Show file tree
Hide file tree
Showing 54 changed files with 556 additions and 444 deletions.
@@ -5,9 +5,9 @@ class QgsPropertyTransformer
%End

%ConvertToSubClassCode
if (sipCpp->transformType() == QgsPropertyTransformer::SizeScaleTransformer)
if (sipCpp->transformerType() == QgsPropertyTransformer::SizeScaleTransformer)
sipType = sipType_QgsSizeScaleTransformer;
else if (sipCpp->transformType() == QgsPropertyTransformer::ColorRampTransformer)
else if (sipCpp->transformerType() == QgsPropertyTransformer::ColorRampTransformer)
sipType = sipType_QgsColorRampTransformer;
else
sipType = sipType_QgsPropertyTransformer;
@@ -143,6 +143,7 @@
%Include qgsprevieweffect.sip
%Include qgsprojectionselectionwidget.sip
%Include qgsprojectionselector.sip
%Include qgspropertyoverridebutton.sip
%Include qgsquerybuilder.sip
%Include qgsrasterformatsaveoptionswidget.sip
%Include qgsrasterlayersaveasdialog.sip
@@ -0,0 +1,58 @@
class QgsPropertyOverrideButton : QToolButton
{
%TypeHeaderCode
#include <qgspropertyoverridebutton.h>
%End
public:

QgsPropertyOverrideButton( QWidget* parent /TransferThis/ = nullptr,
const QgsVectorLayer* layer = nullptr );

void init( int propertyKey,
const QgsProperty& property,
const QgsPropertiesDefinition& definitions,
const QgsVectorLayer* layer = nullptr );

void init( int propertyKey,
const QgsAbstractPropertyCollection& collection,
const QgsPropertiesDefinition& definitions,
const QgsVectorLayer* layer = nullptr );

QgsProperty toProperty() const;

void setToProperty( const QgsProperty& property );

int propertyKey() const;

bool isActive() const;

QgsPropertyDefinition::DataType validDataType() const;

QString fullDescription() const;

QString usageInfo() const;

void setUsageInfo( const QString& info );

void setVectorLayer( const QgsVectorLayer* layer );

const QgsVectorLayer* vectorLayer() const;

void registerCheckedWidget( QWidget* widget );

void registerExpressionContextGenerator( QgsExpressionContextGenerator* generator );

public slots:

void setActive( bool active );

signals:

void changed();

void activated( bool isActive );

protected:
void mouseReleaseEvent( QMouseEvent *event );
};

@@ -65,7 +65,7 @@ QgsComposerHtmlWidget::QgsComposerHtmlWidget( QgsComposerHtml* html, QgsComposer
}

//connections for data defined buttons
connect( mUrlDDBtn, &QgsDataDefinedButtonV2::activated, mUrlLineEdit, &QLineEdit::setDisabled );
connect( mUrlDDBtn, &QgsPropertyOverrideButton::activated, mUrlLineEdit, &QLineEdit::setDisabled );
registerDataDefinedButton( mUrlDDBtn, QgsComposerObject::SourceUrl );
}

@@ -21,7 +21,7 @@
#include "qgsatlascomposition.h"
#include "qgscomposition.h"
#include "qgspoint.h"
#include "qgsdatadefinedbuttonv2.h"
#include "qgspropertyoverridebutton.h"
#include "qgsexpressioncontext.h"
#include "qgsproject.h"
#include <QColorDialog>
@@ -46,7 +46,7 @@ QgsComposerConfigObject::~QgsComposerConfigObject()
void QgsComposerConfigObject::updateDataDefinedProperty()
{
//match data defined button to item's data defined property
QgsDataDefinedButtonV2* ddButton = qobject_cast<QgsDataDefinedButtonV2*>( sender() );
QgsPropertyOverrideButton* ddButton = qobject_cast<QgsPropertyOverrideButton*>( sender() );
if ( !ddButton )
{
return;
@@ -68,22 +68,22 @@ void QgsComposerConfigObject::updateDataDefinedProperty()

void QgsComposerConfigObject::updateDataDefinedButtons()
{
Q_FOREACH ( QgsDataDefinedButtonV2* button, findChildren< QgsDataDefinedButtonV2* >() )
Q_FOREACH ( QgsPropertyOverrideButton* button, findChildren< QgsPropertyOverrideButton* >() )
{
button->setVectorLayer( atlasCoverageLayer() );
}
}

void QgsComposerConfigObject::initializeDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty key )
void QgsComposerConfigObject::initializeDataDefinedButton( QgsPropertyOverrideButton* button, QgsComposerObject::DataDefinedProperty key )
{
button->blockSignals( true );
button->init( key, mComposerObject->dataDefinedProperties(), QgsComposerObject::PROPERTY_DEFINITIONS, atlasCoverageLayer() );
connect( button, &QgsDataDefinedButtonV2::changed, this, &QgsComposerConfigObject::updateDataDefinedProperty );
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsComposerConfigObject::updateDataDefinedProperty );
button->registerExpressionContextGenerator( mComposerObject );
button->blockSignals( false );
}

void QgsComposerConfigObject::updateDataDefinedButton( QgsDataDefinedButtonV2* button )
void QgsComposerConfigObject::updateDataDefinedButton( QgsPropertyOverrideButton* button )
{
if ( !button )
return;
@@ -551,7 +551,7 @@ void QgsComposerItemWidget::initializeDataDefinedButtons()

void QgsComposerItemWidget::populateDataDefinedButtons()
{
Q_FOREACH ( QgsDataDefinedButtonV2* button, findChildren< QgsDataDefinedButtonV2* >() )
Q_FOREACH ( QgsPropertyOverrideButton* button, findChildren< QgsPropertyOverrideButton* >() )
{
mConfigObject->updateDataDefinedButton( button );
}
@@ -781,12 +781,12 @@ QgsComposerItemBaseWidget::QgsComposerItemBaseWidget( QWidget* parent, QgsCompos

}

void QgsComposerItemBaseWidget::registerDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty property )
void QgsComposerItemBaseWidget::registerDataDefinedButton( QgsPropertyOverrideButton* button, QgsComposerObject::DataDefinedProperty property )
{
mConfigObject->initializeDataDefinedButton( button, property );
}

void QgsComposerItemBaseWidget::updateDataDefinedButton( QgsDataDefinedButtonV2* button )
void QgsComposerItemBaseWidget::updateDataDefinedButton( QgsPropertyOverrideButton* button )
{
mConfigObject->updateDataDefinedButton( button );
}
@@ -60,12 +60,12 @@ class QgsComposerConfigObject: public QObject
* @param button button to register
* @param key corresponding data defined property key
*/
void initializeDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty key );
void initializeDataDefinedButton( QgsPropertyOverrideButton* button, QgsComposerObject::DataDefinedProperty key );

/**
* Updates a data defined button to reflect the item's current properties.
*/
void updateDataDefinedButton( QgsDataDefinedButtonV2* button );
void updateDataDefinedButton( QgsPropertyOverrideButton* button );

//! Returns the current atlas coverage layer (if set)
QgsVectorLayer* atlasCoverageLayer() const;
@@ -102,12 +102,12 @@ class QgsComposerItemBaseWidget: public QgsPanelWidget
* @param button button to register
* @param property corresponding data defined property key
*/
void registerDataDefinedButton( QgsDataDefinedButtonV2* button, QgsComposerObject::DataDefinedProperty property );
void registerDataDefinedButton( QgsPropertyOverrideButton* button, QgsComposerObject::DataDefinedProperty property );

/**
* Updates a previously registered data defined button to reflect the item's current properties.
*/
void updateDataDefinedButton( QgsDataDefinedButtonV2* button );
void updateDataDefinedButton( QgsPropertyOverrideButton* button );

//! Returns the current atlas coverage layer (if set)
QgsVectorLayer* atlasCoverageLayer() const;
@@ -77,7 +77,7 @@ QgsComposerPictureWidget::QgsComposerPictureWidget( QgsComposerPicture* picture
connect( mPicture, SIGNAL( pictureRotationChanged( double ) ), this, SLOT( setPicRotationSpinValue( double ) ) );

//connections for data defined buttons
connect( mSourceDDBtn, &QgsDataDefinedButtonV2::activated, mPictureLineEdit, &QLineEdit::setDisabled );
connect( mSourceDDBtn, &QgsPropertyOverrideButton::activated, mPictureLineEdit, &QLineEdit::setDisabled );
registerDataDefinedButton( mSourceDDBtn, QgsComposerObject::PictureSource );
registerDataDefinedButton( mFillColorDDBtn, QgsComposerObject::PictureSvgBackgroundColor );
registerDataDefinedButton( mOutlineColorDDBtn, QgsComposerObject::PictureSvgOutlineColor );
@@ -108,11 +108,11 @@ QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )
connect( mBottomMarginSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( resizeMarginsChanged() ) );
connect( mLeftMarginSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( resizeMarginsChanged() ) );

connect( mPaperSizeDDBtn, &QgsDataDefinedButtonV2::activated, mPaperSizeComboBox, &QComboBox::setDisabled );
connect( mPaperWidthDDBtn, &QgsDataDefinedButtonV2::activated, mPaperWidthDoubleSpinBox, &QgsDoubleSpinBox::setDisabled );
connect( mPaperHeightDDBtn, &QgsDataDefinedButtonV2::activated, mPaperHeightDoubleSpinBox, &QgsDoubleSpinBox::setDisabled );
connect( mNumPagesDDBtn, &QgsDataDefinedButtonV2::activated, mNumPagesSpinBox, &QgsSpinBox::setDisabled );
connect( mPaperOrientationDDBtn, &QgsDataDefinedButtonV2::activated, mPaperOrientationComboBox, &QComboBox::setDisabled );
connect( mPaperSizeDDBtn, &QgsPropertyOverrideButton::activated, mPaperSizeComboBox, &QComboBox::setDisabled );
connect( mPaperWidthDDBtn, &QgsPropertyOverrideButton::activated, mPaperWidthDoubleSpinBox, &QgsDoubleSpinBox::setDisabled );
connect( mPaperHeightDDBtn, &QgsPropertyOverrideButton::activated, mPaperHeightDoubleSpinBox, &QgsDoubleSpinBox::setDisabled );
connect( mNumPagesDDBtn, &QgsPropertyOverrideButton::activated, mNumPagesSpinBox, &QgsSpinBox::setDisabled );
connect( mPaperOrientationDDBtn, &QgsPropertyOverrideButton::activated, mPaperOrientationComboBox, &QComboBox::setDisabled );

connect( mReferenceMapComboBox, &QgsComposerItemComboBox::itemChanged, this, &QgsCompositionWidget::referenceMapChanged );

@@ -149,11 +149,11 @@ void QgsCompositionWidget::populateDataDefinedButtons()
vl = atlas->coverageLayer();
}

Q_FOREACH ( QgsDataDefinedButtonV2* button, findChildren< QgsDataDefinedButtonV2* >() )
Q_FOREACH ( QgsPropertyOverrideButton* button, findChildren< QgsPropertyOverrideButton* >() )
{
button->blockSignals( true );
button->registerExpressionContextGenerator( mComposition );
connect( button, &QgsDataDefinedButtonV2::changed, this, &QgsCompositionWidget::updateDataDefinedProperty );
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsCompositionWidget::updateDataDefinedProperty );
}

mPaperSizeDDBtn->init( QgsComposerObject::PresetPaperSize, mComposition->dataDefinedProperties(), QgsComposerObject::PROPERTY_DEFINITIONS, vl );
@@ -165,7 +165,7 @@ void QgsCompositionWidget::populateDataDefinedButtons()
//initial state of controls - disable related controls when dd buttons are active
mPaperSizeComboBox->setEnabled( !mPaperSizeDDBtn->isActive() );

Q_FOREACH ( QgsDataDefinedButtonV2* button, findChildren< QgsDataDefinedButtonV2* >() )
Q_FOREACH ( QgsPropertyOverrideButton* button, findChildren< QgsPropertyOverrideButton* >() )
{
button->blockSignals( false );
}
@@ -216,7 +216,7 @@ void QgsCompositionWidget::cleanUpStyleSelector( QgsPanelWidget* container )

void QgsCompositionWidget::updateDataDefinedProperty()
{
QgsDataDefinedButtonV2* ddButton = qobject_cast<QgsDataDefinedButtonV2*>( sender() );
QgsPropertyOverrideButton* ddButton = qobject_cast<QgsPropertyOverrideButton*>( sender() );
if ( !ddButton || !mComposition )
{
return;
@@ -114,6 +114,6 @@ class QgsCompositionWidget: public QgsPanelWidget, private Ui::QgsCompositionWid
void blockSignals( bool block );

//! Sets a data defined property for the item from its current data defined button settings
void setDataDefinedProperty( const QgsDataDefinedButtonV2 *ddBtn, QgsComposerObject::DataDefinedProperty property );
void setDataDefinedProperty( const QgsPropertyOverrideButton *ddBtn, QgsComposerObject::DataDefinedProperty property );

};
@@ -427,16 +427,16 @@ QgsDiagramProperties::~QgsDiagramProperties()
settings.setValue( QStringLiteral( "/Windows/Diagrams/Tab" ), mDiagramOptionsListWidget->currentRow() );
}

void QgsDiagramProperties::registerDataDefinedButton( QgsDataDefinedButtonV2 * button, QgsDiagramLayerSettings::Property key )
void QgsDiagramProperties::registerDataDefinedButton( QgsPropertyOverrideButton * button, QgsDiagramLayerSettings::Property key )
{
button->init( key, mProperties, QgsDiagramLayerSettings::PROPERTY_DEFINITIONS, mLayer );
connect( button, &QgsDataDefinedButtonV2::changed, this, &QgsDiagramProperties::updateProperty );
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsDiagramProperties::updateProperty );
button->registerExpressionContextGenerator( this );
}

void QgsDiagramProperties::updateProperty()
{
QgsDataDefinedButtonV2* button = qobject_cast<QgsDataDefinedButtonV2*>( sender() );
QgsPropertyOverrideButton* button = qobject_cast<QgsPropertyOverrideButton*>( sender() );
QgsDiagramLayerSettings::Property key = static_cast< QgsDiagramLayerSettings::Property >( button->propertyKey() );
mProperties.setProperty( key, button->toProperty() );
}
@@ -87,7 +87,7 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr

QgsExpressionContext createExpressionContext() const override;

void registerDataDefinedButton( QgsDataDefinedButtonV2 *button, QgsDiagramLayerSettings::Property key );
void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsDiagramLayerSettings::Property key );

private slots:

@@ -42,16 +42,16 @@ QgsExpressionContext QgsLabelingGui::createExpressionContext() const
return expContext;
}

void QgsLabelingGui::registerDataDefinedButton( QgsDataDefinedButtonV2* button, QgsPalLayerSettings::Property key )
void QgsLabelingGui::registerDataDefinedButton( QgsPropertyOverrideButton* button, QgsPalLayerSettings::Property key )
{
button->init( key, mProperties, QgsPalLayerSettings::PROPERTY_DEFINITIONS, mLayer );
connect( button, &QgsDataDefinedButtonV2::changed, this, &QgsLabelingGui::updateProperty );
connect( button, &QgsPropertyOverrideButton::changed, this, &QgsLabelingGui::updateProperty );
button->registerExpressionContextGenerator( this );
}

void QgsLabelingGui::updateProperty()
{
QgsDataDefinedButtonV2* button = qobject_cast<QgsDataDefinedButtonV2*>( sender() );
QgsPropertyOverrideButton* button = qobject_cast<QgsPropertyOverrideButton*>( sender() );
QgsPalLayerSettings::Property key = static_cast< QgsPalLayerSettings::Property >( button->propertyKey() );
mProperties.setProperty( key, button->toProperty() );
}
@@ -552,7 +552,7 @@ void QgsLabelingGui::populateDataDefinedButtons()

// TODO: is this necessary? maybe just use the data defined-only rotation?
//mPointAngleDDBtn, QgsPalLayerSettings::OffsetRotation,
// QgsDataDefinedButtonV2::AnyType, QgsDataDefinedButtonV2::double180RotDesc() );
// QgsPropertyOverrideButton::AnyType, QgsPropertyOverrideButton::double180RotDesc() );
registerDataDefinedButton( mMaxCharAngleDDBtn, QgsPalLayerSettings::CurvedCharAngleInOut );
registerDataDefinedButton( mRepeatDistanceDDBtn, QgsPalLayerSettings::RepeatDistance );
registerDataDefinedButton( mRepeatDistanceUnitDDBtn, QgsPalLayerSettings::RepeatDistanceUnit );
@@ -596,7 +596,7 @@ void QgsLabelingGui::populateDataDefinedButtons()
registerDataDefinedButton( mZIndexDDBtn, QgsPalLayerSettings::ZIndex );
}

void QgsLabelingGui::syncDefinedCheckboxFrame( QgsDataDefinedButtonV2* ddBtn, QCheckBox* chkBx, QFrame* f )
void QgsLabelingGui::syncDefinedCheckboxFrame( QgsPropertyOverrideButton* ddBtn, QCheckBox* chkBx, QFrame* f )
{
if ( ddBtn->isActive() && !chkBx->isChecked() )
{
@@ -20,7 +20,7 @@

#include "qgspallabeling.h"
#include "qgstextformatwidget.h"
#include "qgsdatadefinedbuttonv2.h"
#include "qgspropertyoverridebutton.h"
#include "qgis_app.h"

class APP_EXPORT QgsLabelingGui : public QgsTextFormatWidget, private QgsExpressionContextGenerator
@@ -52,7 +52,7 @@ class APP_EXPORT QgsLabelingGui : public QgsTextFormatWidget, private QgsExpress

protected:
void blockInitSignals( bool block );
void syncDefinedCheckboxFrame( QgsDataDefinedButtonV2* ddBtn, QCheckBox* chkBx, QFrame* f );
void syncDefinedCheckboxFrame( QgsPropertyOverrideButton* ddBtn, QCheckBox* chkBx, QFrame* f );

private:
QgsVectorLayer* mLayer;
@@ -63,7 +63,7 @@ class APP_EXPORT QgsLabelingGui : public QgsTextFormatWidget, private QgsExpress
QgsExpressionContext createExpressionContext() const override;

void populateDataDefinedButtons();
void registerDataDefinedButton( QgsDataDefinedButtonV2 *button, QgsPalLayerSettings::Property key );
void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsPalLayerSettings::Property key );

private slots:

@@ -235,7 +235,6 @@ class CORE_EXPORT QgsAbstractPropertyCollection
private:

QString mName;
int mCount = 0;
};

/**
@@ -313,6 +312,7 @@ class CORE_EXPORT QgsPropertyCollection : public QgsAbstractPropertyCollection
mutable bool mDirty;
mutable bool mHasActiveProperties;
mutable bool mHasActiveDynamicProperties;
mutable int mCount = 0;

//! Scans through properties and updates cached values
void rescan() const;
@@ -196,7 +196,6 @@ SET(QGIS_GUI_SRCS
qgscursors.cpp
qgscustomdrophandler.cpp
qgsdatadefinedbutton.cpp
qgsdatadefinedbuttonv2.cpp
qgsdatumtransformdialog.cpp
qgsdetaileditemdata.cpp
qgsdetaileditemdelegate.cpp
@@ -286,6 +285,7 @@ SET(QGIS_GUI_SRCS
qgsprevieweffect.cpp
qgsprojectionselectionwidget.cpp
qgsprojectionselector.cpp
qgspropertyoverridebutton.cpp
qgsquerybuilder.cpp
qgsrasterformatsaveoptionswidget.cpp
qgsrasterlayersaveasdialog.cpp
@@ -367,7 +367,6 @@ SET(QGIS_GUI_MOC_HDRS
qgsconfigureshortcutsdialog.h
qgscredentialdialog.h
qgsdatadefinedbutton.h
qgsdatadefinedbuttonv2.h
qgsdatumtransformdialog.h
qgsdetaileditemdelegate.h
qgsdetaileditemwidget.h
@@ -449,6 +448,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsprevieweffect.h
qgsprojectionselectionwidget.h
qgsprojectionselector.h
qgspropertyoverridebutton.h
qgsquerybuilder.h
qgsrasterformatsaveoptionswidget.h
qgsrasterlayersaveasdialog.h

0 comments on commit d5664ed

Please sign in to comment.