Skip to content
Permalink
Browse files

Merge branch 'dd_symbology_help'

  • Loading branch information
mhugent committed May 8, 2013
2 parents 4c7f51e + c054c30 commit e80d8c3343712ed18d4b9255d3d0abc346f48306
@@ -5,8 +5,7 @@
#include <QComboBox>
#include <QPushButton>

QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QMap< QString, QPair< QString, QString > >& properties, const QgsVectorLayer* vl,
QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f ), mVectorLayer( vl )
QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QList< DataDefinedSymbolEntry >& entries, const QgsVectorLayer* vl, QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f ), mVectorLayer( vl )
{
setupUi( this );

@@ -16,26 +15,26 @@ QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QMap< QString, QPa
attributeFields = mVectorLayer->pendingFields();
}

mTableWidget->setRowCount( properties.size() );
mTableWidget->setRowCount( entries.size() );

int i = 0;
QMap< QString, QPair< QString, QString > >::const_iterator it = properties.constBegin();
for ( ; it != properties.constEnd(); ++it )
QList< DataDefinedSymbolEntry >::const_iterator entryIt = entries.constBegin();
for ( ; entryIt != entries.constEnd(); ++entryIt )
{
//check box
QCheckBox* cb = new QCheckBox( this );
cb->setChecked( !it.value().second.isEmpty() );
cb->setChecked( !entryIt->initialValue.isEmpty() );
mTableWidget->setCellWidget( i, 0, cb );
mTableWidget->setColumnWidth( 0, cb->width() );


//property name
QTableWidgetItem* propertyItem = new QTableWidgetItem( it.value().first );
propertyItem->setData( Qt::UserRole, it.key() );
QTableWidgetItem* propertyItem = new QTableWidgetItem( entryIt->title );
propertyItem->setData( Qt::UserRole, entryIt->property );
mTableWidget->setItem( i, 1, propertyItem );

//attribute list
QString expressionString = it.value().second;
QString expressionString = entryIt->initialValue;
QComboBox* attributeComboBox = new QComboBox( this );
attributeComboBox->addItem( QString() );
for ( int j = 0; j < attributeFields.count(); ++j )
@@ -59,6 +58,11 @@ QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QMap< QString, QPa
QPushButton* expressionButton = new QPushButton( "...", this );
QObject::connect( expressionButton, SIGNAL( clicked() ), this, SLOT( expressionButtonClicked() ) );
mTableWidget->setCellWidget( i, 3, expressionButton );

//help text
QTableWidgetItem* helpItem = new QTableWidgetItem( entryIt->helpText );
mTableWidget->setItem( i, 4, helpItem );

++i;
}
}
@@ -158,3 +162,23 @@ int QgsDataDefinedSymbolDialog::comboIndexForExpressionString( const QString& ex
}
return comboIndex;
}

QString QgsDataDefinedSymbolDialog::doubleHelpText()
{
return tr( "double" );
}

QString QgsDataDefinedSymbolDialog::colorHelpText()
{
return tr( "'<red>,<green>,<blue>,<alpha>'" );
}

QString QgsDataDefinedSymbolDialog::offsetHelpText()
{
return "<x>,<y>";
}

QString QgsDataDefinedSymbolDialog::fileNameHelpText()
{
return tr( "'<filename>'" );
}
@@ -7,14 +7,33 @@
class QgsVectorLayer;
class QComboBox;



class GUI_EXPORT QgsDataDefinedSymbolDialog: public QDialog, private Ui::QgsDataDefinedSymbolDialog
{
Q_OBJECT
public:
QgsDataDefinedSymbolDialog( const QMap< QString, QPair< QString, QString > >& properties, const QgsVectorLayer* vl, QWidget * parent = 0, Qt::WindowFlags f = 0 );

struct DataDefinedSymbolEntry
{
DataDefinedSymbolEntry( const QString& p, const QString& t, const QString& v, const QString& h ):
property( p ), title( t ), initialValue( v ), helpText( h ) {}
QString property;
QString title;
QString initialValue;
QString helpText;
};

QgsDataDefinedSymbolDialog( const QList< DataDefinedSymbolEntry >& entries, const QgsVectorLayer* vl, QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsDataDefinedSymbolDialog();
QMap< QString, QString > dataDefinedProperties() const;

//common help texts
static QString doubleHelpText();
static QString colorHelpText();
static QString offsetHelpText();
static QString fileNameHelpText();

private slots:
void expressionButtonClicked();

@@ -211,16 +211,23 @@ void QgsEllipseSymbolLayerV2Widget::on_mDataDefinedPropertiesButton_clicked()
return;
}

QMap<QString, QPair< QString, QString> > dataDefinedProperties;
dataDefinedProperties.insert( "width", qMakePair( tr( "Symbol width" ), mLayer->dataDefinedPropertyString( "width" ) ) );
dataDefinedProperties.insert( "height", qMakePair( tr( "Symbol height" ), mLayer->dataDefinedPropertyString( "height" ) ) );
dataDefinedProperties.insert( "rotation", qMakePair( tr( "Rotation" ), mLayer->dataDefinedPropertyString( "rotation" ) ) );
dataDefinedProperties.insert( "outline_width", qMakePair( tr( "Outline width" ), mLayer->dataDefinedPropertyString( "outline_width" ) ) );
dataDefinedProperties.insert( "fill_color", qMakePair( tr( "Fill color" ), mLayer->dataDefinedPropertyString( "fill_color" ) ) );
dataDefinedProperties.insert( "outline_color", qMakePair( tr( "Border color" ), mLayer->dataDefinedPropertyString( "outline_color" ) ) );
dataDefinedProperties.insert( "symbol_name", qMakePair( tr( "Symbol name" ), mLayer->dataDefinedPropertyString( "symbol_name" ) ) );
dataDefinedProperties.insert( "offset", qMakePair( tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ) ) );

QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Symbol width" ), mLayer->dataDefinedPropertyString( "width" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "height", tr( "Symbol height" ), mLayer->dataDefinedPropertyString( "height" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "rotation", tr( "Rotation" ), mLayer->dataDefinedPropertyString( "rotation" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline_width", tr( "Outline width" ), mLayer->dataDefinedPropertyString( "outline_width" ),
QgsDataDefinedSymbolDialog::doubleHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "fill_color", tr( "Fill color" ), mLayer->dataDefinedPropertyString( "fill_color" ),
QgsDataDefinedSymbolDialog::colorHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "outline_color", tr( "Border color" ), mLayer->dataDefinedPropertyString( "outline_color" ),
QgsDataDefinedSymbolDialog::colorHelpText() );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "symbol_name", tr( "Symbol name" ), mLayer->dataDefinedPropertyString( "symbol_name" ),
"'circle'|'rectangle'|'cross'|'triangle'" );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ),
QgsDataDefinedSymbolDialog::offsetHelpText() );
QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );
if ( d.exec() == QDialog::Accepted )
{

0 comments on commit e80d8c3

Please sign in to comment.
You can’t perform that action at this time.