Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add help text in data defined dialog
  • Loading branch information
mhugent committed May 7, 2013
1 parent 469fb25 commit dd9c563
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 3 deletions.
62 changes: 62 additions & 0 deletions src/gui/symbology-ng/qgsdatadefinedsymboldialog.cpp
Expand Up @@ -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()
{

Expand Down
14 changes: 14 additions & 0 deletions src/gui/symbology-ng/qgsdatadefinedsymboldialog.h
Expand Up @@ -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;

Expand Down
12 changes: 11 additions & 1 deletion src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/ui/qgsdatadefinedsymboldialogbase.ui
Expand Up @@ -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">
Expand Down Expand Up @@ -87,6 +87,11 @@
<string>Expression</string>
</property>
</column>
<column>
<property name="text">
<string>Help</string>
</property>
</column>
</widget>
</item>
</layout>
Expand Down

0 comments on commit dd9c563

Please sign in to comment.