Skip to content
Permalink
Browse files
Start on GUI for properties
  • Loading branch information
nyalldawson committed Jan 23, 2017
1 parent 4018863 commit eade998a0efec60a971e8a59a97d9d907f88e5ff
Showing with 1,527 additions and 158 deletions.
  1. +45 −6 src/app/qgsdiagramproperties.cpp
  2. +9 −0 src/app/qgsdiagramproperties.h
  3. +2 −0 src/gui/CMakeLists.txt
  4. +781 −0 src/gui/qgsdatadefinedbuttonv2.cpp
  5. +220 −0 src/gui/qgsdatadefinedbuttonv2.h
  6. +470 −152 src/ui/qgsdiagrampropertiesbase.ui
@@ -100,8 +100,8 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
mDiagramAttributesTreeWidget->setItemDelegateForColumn( ColumnAttributeExpression, new EditBlockerDelegate( this ) );
mDiagramAttributesTreeWidget->setItemDelegateForColumn( ColumnColor, new EditBlockerDelegate( this ) );

connect( mFixedSizeRadio, SIGNAL( toggled( bool ) ), this, SLOT( scalingTypeChanged() ) );
connect( mAttributeBasedScalingRadio, SIGNAL( toggled( bool ) ), this, SLOT( scalingTypeChanged() ) );
connect( mFixedSizeRadio, &QRadioButton::toggled, this, &QgsDiagramProperties::scalingTypeChanged );
connect( mAttributeBasedScalingRadio, &QRadioButton::toggled, this, &QgsDiagramProperties::scalingTypeChanged );

mDiagramUnitComboBox->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderMapUnits << QgsUnitTypes::RenderPixels
<< QgsUnitTypes::RenderPoints << QgsUnitTypes::RenderInches );
@@ -382,6 +382,8 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
chkLineOrientationDependent->setChecked( true );

mShowAllCheckBox->setChecked( dls->showAllDiagrams() );

mProperties = dls->properties();
}

if ( dr->diagram() )
@@ -400,11 +402,32 @@ QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* pare
mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData( DIAGRAM_NAME_PIE ) );
}
}
} // if ( !dr )
}

connect( mAddAttributeExpression, SIGNAL( clicked() ), this, SLOT( showAddAttributeExpressionDialog() ) );
connect( mTransparencySlider, SIGNAL( valueChanged( int ) ), mTransparencySpinBox, SLOT( setValue( int ) ) );
connect( mTransparencySpinBox, SIGNAL( valueChanged( int ) ), mTransparencySlider, SLOT( setValue( int ) ) );
connect( mAddAttributeExpression, &QPushButton::clicked, this, &QgsDiagramProperties::showAddAttributeExpressionDialog );
connect( mTransparencySlider, &QSlider::valueChanged, mTransparencySpinBox, &QgsSpinBox::setValue );
connect( mTransparencySpinBox, static_cast<void (QgsSpinBox::*)(int)>(&QSpinBox::valueChanged), mTransparencySlider, &QSlider::setValue );

registerDataDefinedButton( mBackgroundColorDDBtn, QgsDiagramLayerSettings::BackgroundColor,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::colorAlphaDesc() );
registerDataDefinedButton( mLineColorDDBtn, QgsDiagramLayerSettings::OutlineColor,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::colorAlphaDesc() );
registerDataDefinedButton( mLineWidthDDBtn, QgsDiagramLayerSettings::OutlineWidth,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doublePosDesc() );
registerDataDefinedButton( mCoordXDDBtn, QgsDiagramLayerSettings::PositionX,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doubleDesc() );
registerDataDefinedButton( mCoordYDDBtn, QgsDiagramLayerSettings::PositionY,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doubleDesc() );
registerDataDefinedButton( mPriorityDDBtn, QgsDiagramLayerSettings::Priority,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doubleDesc() );
registerDataDefinedButton( mZOrderDDBtn, QgsDiagramLayerSettings::ZIndex,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doubleDesc() );
registerDataDefinedButton( mShowDiagramDDBtn, QgsDiagramLayerSettings::Show,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doubleDesc() );
registerDataDefinedButton( mAlwaysShowDDBtn, QgsDiagramLayerSettings::AlwaysShow,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doubleDesc() );
registerDataDefinedButton( mStartAngleDDBtn, QgsDiagramLayerSettings::StartAngle,
QgsDataDefinedButtonV2::String, QgsDataDefinedButtonV2::doubleDesc() );
}

QgsDiagramProperties::~QgsDiagramProperties()
@@ -414,6 +437,21 @@ QgsDiagramProperties::~QgsDiagramProperties()
settings.setValue( QStringLiteral( "/Windows/Diagrams/Tab" ), mDiagramOptionsListWidget->currentRow() );
}

void QgsDiagramProperties::registerDataDefinedButton( QgsDataDefinedButtonV2 * button, QgsDiagramLayerSettings::Property key, QgsDataDefinedButtonV2::DataType type, const QString & description )
{
button->init( mLayer, mProperties.property( key ), type, description );
button->setProperty( "propertyKey", key );
connect( button, &QgsDataDefinedButtonV2::changed, this, &QgsDiagramProperties::updateProperty );
button->registerExpressionContextGenerator( this );
}

void QgsDiagramProperties::updateProperty()
{
QgsDataDefinedButtonV2* button = qobject_cast<QgsDataDefinedButtonV2*>( sender() );
QgsDiagramLayerSettings::Property key = static_cast< QgsDiagramLayerSettings::Property >( button->property( "propertyKey" ).toInt() );
mProperties.setProperty( key, button->toProperty() );
}

void QgsDiagramProperties::on_mDiagramTypeComboBox_currentIndexChanged( int index )
{
if ( index == 0 )
@@ -794,6 +832,7 @@ void QgsDiagramProperties::apply()
mLayer->setDiagramRenderer( renderer );

QgsDiagramLayerSettings dls;
dls.setProperties( mProperties );
dls.setDistance( mDiagramDistanceSpinBox->value() );
dls.setPriority( mPrioritySlider->value() );
dls.setZIndex( mZIndexSpinBox->value() );
@@ -19,6 +19,7 @@
#define QGSDIAGRAMPROPERTIES_H

#include <QDialog>
#include "qgsdiagramrenderer.h"
#include <ui_qgsdiagrampropertiesbase.h>
#include <QStyledItemDelegate>
#include "qgis_app.h"
@@ -75,6 +76,8 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr

QString showExpressionBuilder( const QString& initialExpression );

QgsPropertyCollection mProperties;

// Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
QString mDiagramType;
QScopedPointer< QgsMarkerSymbol > mSizeLegendSymbol;
@@ -83,6 +86,12 @@ class APP_EXPORT QgsDiagramProperties : public QWidget, private Ui::QgsDiagramPr
QgsMapCanvas *mMapCanvas;

QgsExpressionContext createExpressionContext() const override;

void registerDataDefinedButton( QgsDataDefinedButtonV2 *button, QgsDiagramLayerSettings::Property key, QgsDataDefinedButtonV2::DataType type, const QString &description );

private slots:

void updateProperty();
};

class EditBlockerDelegate: public QStyledItemDelegate
@@ -196,6 +196,7 @@ SET(QGIS_GUI_SRCS
qgscursors.cpp
qgscustomdrophandler.cpp
qgsdatadefinedbutton.cpp
qgsdatadefinedbuttonv2.cpp
qgsdatumtransformdialog.cpp
qgsdetaileditemdata.cpp
qgsdetaileditemdelegate.cpp
@@ -366,6 +367,7 @@ SET(QGIS_GUI_MOC_HDRS
qgsconfigureshortcutsdialog.h
qgscredentialdialog.h
qgsdatadefinedbutton.h
qgsdatadefinedbuttonv2.h
qgsdatumtransformdialog.h
qgsdetaileditemdelegate.h
qgsdetaileditemwidget.h

0 comments on commit eade998

Please sign in to comment.