Skip to content

Commit

Permalink
Add option for using WFS type name title for the added layer name
Browse files Browse the repository at this point in the history
  • Loading branch information
palmerj committed Apr 2, 2013
1 parent 7fff3b1 commit e6b624c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
14 changes: 11 additions & 3 deletions src/providers/wfs/qgswfssourceselect.cpp
Expand Up @@ -78,8 +78,9 @@ QgsWFSSourceSelect::QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl, bool emb
treeView->setItemDelegate( mItemDelegate );

QSettings settings;
QgsDebugMsg( "restoring geometry" );
QgsDebugMsg( "restoring settings" );
restoreGeometry( settings.value( "/Windows/WFSSourceSelect/geometry" ).toByteArray() );
cbxUseTitleLayerName->setChecked( settings.value( "/Windows/WFSSourceSelect/UseTitleLayerName", false ).toBool() );

mModel = new QStandardItemModel();
mModel->setHorizontalHeaderItem( 0, new QStandardItem( "Title" ) );
Expand All @@ -100,8 +101,9 @@ QgsWFSSourceSelect::QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl, bool emb
QgsWFSSourceSelect::~QgsWFSSourceSelect()
{
QSettings settings;
QgsDebugMsg( "saving geometry" );
QgsDebugMsg( "saving settings" );
settings.setValue( "/Windows/WFSSourceSelect/geometry", saveGeometry() );
settings.setValue( "/Windows/WFSSourceSelect/UseTitleLayerName", cbxUseTitleLayerName->isChecked() );

delete mItemDelegate;
delete mProjectionSelector;
Expand Down Expand Up @@ -377,7 +379,13 @@ void QgsWFSSourceSelect::addLayer()
}
int row = idx.row();
QString typeName = mModel->item( row, 1 )->text(); //WFS repository's name for layer
QString titleName = mModel->item( row, 0 )->text(); //WFS type name title for layer name (if option is set)
QString filter = mModel->item( row, 4 )->text(); //optional filter specified by user
QString layerName = typeName;
if ( cbxUseTitleLayerName->isChecked() && !titleName.isEmpty() )
{
layerName = titleName;
}
QgsDebugMsg( "Layer " + typeName + " Filter is " + filter );
//is "cache features" checked?
if ( mModel->item( row, 3 )->checkState() == Qt::Checked )
Expand All @@ -388,7 +396,7 @@ void QgsWFSSourceSelect::addLayer()
{ //no: include BBOX of current canvas extent in URI
mUri = conn.uriGetFeature( typeName, pCrsString, filter, extent );
}
emit addWfsLayer( mUri, typeName );
emit addWfsLayer( mUri, layerName );
}
accept();
}
Expand Down
29 changes: 18 additions & 11 deletions src/ui/qgswfssourceselectbase.ui
Expand Up @@ -14,7 +14,17 @@
<string>Add WFS Layer from a Server</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<item row="5" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="gbCRS">
<property name="title">
<string>Coordinate reference system</string>
Expand Down Expand Up @@ -62,16 +72,6 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayoutFilter">
<item>
Expand Down Expand Up @@ -210,6 +210,13 @@
</attribute>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="cbxUseTitleLayerName">
<property name="text">
<string>Use title for layer name</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
Expand Down

0 comments on commit e6b624c

Please sign in to comment.