Skip to content

Commit

Permalink
Enable wfs extent option again
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 9, 2011
1 parent b4fb1ef commit 05fd598
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 23 deletions.
23 changes: 14 additions & 9 deletions src/app/qgisapp.cpp
Expand Up @@ -1730,7 +1730,7 @@ void QgisApp::initLegend()

QWidget *w = new QWidget( this );
QLayout *l = new QVBoxLayout;
l->setMargin(0);
l->setMargin( 0 );
l->addWidget( mMapLegend );
l->addWidget( legendCb );
w->setLayout( l );
Expand All @@ -1747,7 +1747,7 @@ void QgisApp::initLegend()

w = new QWidget( this );
l = new QVBoxLayout;
l->setMargin(0);
l->setMargin( 0 );
l->addWidget( mMapLayerOrder );
l->addWidget( orderCb );
w->setLayout( l );
Expand Down Expand Up @@ -2445,6 +2445,11 @@ void QgisApp::addWfsLayer()
connect( wfss , SIGNAL( addWfsLayer( QString, QString ) ),
this , SLOT( addWfsLayer( QString, QString ) ) );

if ( mapCanvas() )
{
wfss->setProperty( "MapExtent", mapCanvas()->extent().toString() ); //hack to reenable wfs with extent setting
}

wfss->exec();
delete wfss;
}
Expand Down Expand Up @@ -6390,14 +6395,14 @@ void QgisApp::oldProjectVersionWarning( QString oldVersion )

#ifdef ANDROID
//this is needed to deal with http://hub.qgis.org/issues/4573
QMessageBox box(QMessageBox::Warning,title, tr("This project file was saved by an older version of QGIS"), QMessageBox::Ok, NULL);
QMessageBox box( QMessageBox::Warning, title, tr( "This project file was saved by an older version of QGIS" ), QMessageBox::Ok, NULL );
box.setDetailedText(
text.remove(0, 3)
.replace(QString("<p>"),QString("\n\n"))
.replace(QString("<br>"),QString("\n"))
.replace(QString("<a href=\"http://hub.qgis.org/projects/quantum-gis\">http://hub.qgis.org/projects/quantum-gis</a> "),QString("\nhttp://hub.qgis.org/projects/quantum-gis"))
.replace(QRegExp("</?tt>"),QString(""))
);
text.remove( 0, 3 )
.replace( QString( "<p>" ), QString( "\n\n" ) )
.replace( QString( "<br>" ), QString( "\n" ) )
.replace( QString( "<a href=\"http://hub.qgis.org/projects/quantum-gis\">http://hub.qgis.org/projects/quantum-gis</a> " ), QString( "\nhttp://hub.qgis.org/projects/quantum-gis" ) )
.replace( QRegExp( "</?tt>" ), QString( "" ) )
);
box.exec();
#else
QMessageBox::warning( NULL, title, text );
Expand Down
12 changes: 10 additions & 2 deletions src/providers/wfs/qgswfsconnection.cpp
Expand Up @@ -53,15 +53,23 @@ QString QgsWFSConnection::uriGetFeature( QString typeName, QString crsString, QS
}

QString filterString;

//if the xml comes from the dialog, it needs to be a string to pass the validity test
if ( filter.startsWith( "'" ) && filter.endsWith( "'" ) && filter.size() > 1 )
{
filter.chop( 1 );
filter.remove( 0, 1 );
}

if ( !filter.isEmpty() )
{
//test if filterString is already an OGC filter xml
QDomDocument filterDoc;
if( !filterDoc.setContent( filter ) )
if ( !filterDoc.setContent( filter ) )
{
//if not, if must be a QGIS expression
QgsExpression filterExpression( filter );
if( !filterExpression.toOGCFilter( filterDoc ) )
if ( !filterExpression.toOGCFilter( filterDoc ) )
{
//error
}
Expand Down
39 changes: 27 additions & 12 deletions src/providers/wfs/qgswfssourceselect.cpp
Expand Up @@ -51,10 +51,6 @@ QgsWFSSourceSelect::QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl, bool emb
buttonBox->button( QDialogButtonBox::Cancel )->hide();
}

// keep the "use current view extent" checkbox hidden until
// the functionality is reintroduced [MD]
mBboxCheckBox->hide();

connect( buttonBox, SIGNAL( accepted() ), this, SLOT( addLayer() ) );
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
connect( btnNew, SIGNAL( clicked() ), this, SLOT( addEntryToServerList() ) );
Expand Down Expand Up @@ -265,15 +261,12 @@ void QgsWFSSourceSelect::addLayer()
}

QgsRectangle bBox;
#if 0
// TODO: resolve [MD]
//get current extent
QgsMapCanvas* canvas = mIface->mapCanvas();
if ( canvas && mBboxCheckBox->isChecked() )
QgsRectangle currentRectangle;
if ( mBboxCheckBox->isChecked() )
{
QgsRectangle currentExtent = canvas->extent();
currentRectangle = mExtent;
}
#endif


QList<QTreeWidgetItem*> selectedItems = treeWidget->selectedItems();
QList<QTreeWidgetItem*>::const_iterator sIt = selectedItems.constBegin();
Expand All @@ -285,7 +278,7 @@ void QgsWFSSourceSelect::addLayer()

//add a wfs layer to the map
QgsWFSConnection conn( cmbConnections->currentText() );
QString uri = conn.uriGetFeature( typeName, crs, filter, bBox );
QString uri = conn.uriGetFeature( typeName, crs, filter, currentRectangle );
emit addWfsLayer( uri, typeName );
}
}
Expand Down Expand Up @@ -406,3 +399,25 @@ void QgsWFSSourceSelect::on_treeWidget_itemDoubleClicked( QTreeWidgetItem* item,
}
}
}

void QgsWFSSourceSelect::showEvent( QShowEvent* event )
{
Q_UNUSED( event );
QVariant extentVariant = property( "MapExtent" );
if ( extentVariant.isValid() )
{
QString extentString = extentVariant.toString();
QStringList minMaxSplit = extentString.split( ":" );
if ( minMaxSplit.size() > 1 )
{
QStringList xyMinSplit = minMaxSplit[0].split( "," );
QStringList xyMaxSplit = minMaxSplit[1].split( "," );
if ( xyMinSplit.size() > 1 && xyMaxSplit.size() > 1 )
{
mExtent.set( xyMinSplit[0].toDouble(), xyMinSplit[1].toDouble(), xyMaxSplit[0].toDouble(), xyMaxSplit[1].toDouble() );
return;
}
}
}
mBboxCheckBox->hide();
}
5 changes: 5 additions & 0 deletions src/providers/wfs/qgswfssourceselect.h
Expand Up @@ -20,6 +20,7 @@

#include "ui_qgswfssourceselectbase.h"
#include "qgscontexthelp.h"
#include "qgsrectangle.h"

class QgsGenericProjectionSelector;
class QgsWFSConnection;
Expand All @@ -46,6 +47,7 @@ class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase
std::map<QString, std::list<QString> > mAvailableCRS;
QAbstractButton* btnAdd;
QgsWFSConnection* mConn;
QgsRectangle mExtent;

void populateConnectionList();

Expand All @@ -71,6 +73,9 @@ class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase
void on_treeWidget_itemDoubleClicked( QTreeWidgetItem* item, int column );

void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

protected:
void showEvent( QShowEvent* event );
};

#endif

0 comments on commit 05fd598

Please sign in to comment.