Skip to content
Permalink
Browse files

Add help text in data defined dialog

  • Loading branch information
mhugent committed May 7, 2013
1 parent 469fb25 commit dd9c563fd74b218206e9ac6600cb2b3eb8a555ab
@@ -63,6 +63,68 @@ QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QMap< QString, QPa
}
}

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

QgsFields attributeFields;
if ( mVectorLayer )
{
attributeFields = mVectorLayer->pendingFields();
}

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

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


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

//attribute list
QString expressionString = entryIt->initialValue;
QComboBox* attributeComboBox = new QComboBox( this );
attributeComboBox->addItem( QString() );
for ( int j = 0; j < attributeFields.count(); ++j )
{
attributeComboBox->addItem( attributeFields.at( j ).name() );
}

int attrComboIndex = comboIndexForExpressionString( expressionString, attributeComboBox );
if ( attrComboIndex >= 0 )
{
attributeComboBox->setCurrentIndex( attrComboIndex );
}
else
{
attributeComboBox->setItemText( 0, expressionString );
}

mTableWidget->setCellWidget( i, 2, attributeComboBox );

//expression button
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;
}
}

QgsDataDefinedSymbolDialog::~QgsDataDefinedSymbolDialog()
{

@@ -7,11 +7,25 @@
class QgsVectorLayer;
class QComboBox;



class GUI_EXPORT QgsDataDefinedSymbolDialog: public QDialog, private Ui::QgsDataDefinedSymbolDialog
{
Q_OBJECT
public:

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 QMap< QString, QPair< QString, QString > >& properties, const QgsVectorLayer* vl, QWidget * parent = 0, Qt::WindowFlags f = 0 );
QgsDataDefinedSymbolDialog( const QList< DataDefinedSymbolEntry >& entries, const QgsVectorLayer* vl, QWidget * parent = 0, Qt::WindowFlags f = 0 );
~QgsDataDefinedSymbolDialog();
QMap< QString, QString > dataDefinedProperties() const;

@@ -196,15 +196,25 @@ void QgsSimpleLineSymbolLayerV2Widget::on_mDataDefinedPropertiesButton_clicked()
return;
}

QMap<QString, QPair< QString, QString> > dataDefinedProperties;
/*QMap<QString, QPair< QString, QString> > dataDefinedProperties;
dataDefinedProperties.insert( "color", qMakePair( tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ) ) );
dataDefinedProperties.insert( "width", qMakePair( tr( "Pen width" ), mLayer->dataDefinedPropertyString( "width" ) ) );
dataDefinedProperties.insert( "offset", qMakePair( tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ) ) );
dataDefinedProperties.insert( "customdash", qMakePair( tr( "Dash pattern" ), mLayer->dataDefinedPropertyString( "customdash" ) ) );
dataDefinedProperties.insert( "joinstyle", qMakePair( tr( "Join style" ), mLayer->dataDefinedPropertyString( "joinstyle" ) ) );
dataDefinedProperties.insert( "capstyle", qMakePair( tr( "Cap style" ), mLayer->dataDefinedPropertyString( "capstyle" ) ) );
QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );*/

QList< QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry > dataDefinedProperties;
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "color", tr( "Color" ), mLayer->dataDefinedPropertyString( "color" ), tr( "'<red>,<green>,<blue>,<alpha>'" ) );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "width", tr( "Pen width" ), mLayer->dataDefinedPropertyString( "width" ), tr( "double" ) );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "offset", tr( "Offset" ), mLayer->dataDefinedPropertyString( "offset" ), tr( "double" ) );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "customdash", tr( "Dash pattern" ), mLayer->dataDefinedPropertyString( "customdash" ), "" );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "joinstyle", tr( "Join style" ), mLayer->dataDefinedPropertyString( "joinstyle" ), "" );
dataDefinedProperties << QgsDataDefinedSymbolDialog::DataDefinedSymbolEntry( "capstyle", tr( "Cap style" ), mLayer->dataDefinedPropertyString( "capstyle" ), "" );
QgsDataDefinedSymbolDialog d( dataDefinedProperties, mVectorLayer );

if ( d.exec() == QDialog::Accepted )
{
//empty all existing properties first
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>406</width>
<height>282</height>
<width>409</width>
<height>299</height>
</rect>
</property>
<property name="windowTitle">
@@ -87,6 +87,11 @@
<string>Expression</string>
</property>
</column>
<column>
<property name="text">
<string>Help</string>
</property>
</column>
</widget>
</item>
</layout>

0 comments on commit dd9c563

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