Skip to content
Permalink
Browse files
Enable wfs extent option again
  • Loading branch information
mhugent committed Dec 9, 2011
1 parent b4fb1ef commit 05fd5983f0a5235a28d0357086b6a3dccb0f5e64
@@ -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 );
@@ -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 );
@@ -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;
}
@@ -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 );
@@ -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
}
@@ -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() ) );
@@ -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();
@@ -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 );
}
}
@@ -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();
}
@@ -20,6 +20,7 @@

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

class QgsGenericProjectionSelector;
class QgsWFSConnection;
@@ -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();

@@ -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.