Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#include "qgswfsdataitems.h" | ||
|
||
#include "qgswfsprovider.h" | ||
#include "qgswfsconnection.h" | ||
#include "qgswfssourceselect.h" | ||
|
||
#include <QSettings> | ||
#include <QCoreApplication> | ||
|
||
|
||
QgsWFSLayerItem::QgsWFSLayerItem( QgsDataItem* parent, QString connName, QString name, QString title ) | ||
: QgsLayerItem( parent, title, parent->path() + "/" + name, QString(), QgsLayerItem::Vector, "WFS" ) | ||
{ | ||
mUri = QgsWFSConnection( connName ).uriGetFeature( name ); | ||
mPopulated = true; | ||
} | ||
|
||
QgsWFSLayerItem::~QgsWFSLayerItem() | ||
{ | ||
} | ||
|
||
//// | ||
|
||
QgsWFSConnectionItem::QgsWFSConnectionItem( QgsDataItem* parent, QString name, QString path ) | ||
: QgsDataCollectionItem( parent, name, path ), mName( name ), mConn( NULL ) | ||
{ | ||
} | ||
|
||
QgsWFSConnectionItem::~QgsWFSConnectionItem() | ||
{ | ||
} | ||
|
||
QVector<QgsDataItem*> QgsWFSConnectionItem::createChildren() | ||
{ | ||
mGotCapabilities = false; | ||
mConn = new QgsWFSConnection( mName, this ); | ||
connect( mConn, SIGNAL( gotCapabilities() ), this, SLOT( gotCapabilities() ) ); | ||
|
||
mConn->requestCapabilities(); | ||
|
||
while ( !mGotCapabilities ) | ||
{ | ||
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); | ||
} | ||
|
||
QVector<QgsDataItem*> layers; | ||
if ( mConn->errorCode() == QgsWFSConnection::NoError ) | ||
{ | ||
QgsWFSConnection::GetCapabilities caps = mConn->capabilities(); | ||
foreach( const QgsWFSConnection::FeatureType& featureType, caps.featureTypes ) | ||
{ | ||
QgsWFSLayerItem* layer = new QgsWFSLayerItem( this, mName, featureType.name, featureType.title ); | ||
layers.append( layer ); | ||
} | ||
} | ||
else | ||
{ | ||
// TODO: return an "error" item | ||
} | ||
|
||
mConn->deleteLater(); | ||
mConn = NULL; | ||
|
||
return layers; | ||
} | ||
|
||
void QgsWFSConnectionItem::gotCapabilities() | ||
{ | ||
mGotCapabilities = true; | ||
} | ||
|
||
////// | ||
|
||
|
||
QgsWFSRootItem::QgsWFSRootItem( QgsDataItem* parent, QString name, QString path ) | ||
: QgsDataCollectionItem( parent, name, path ) | ||
{ | ||
mIcon = QIcon( getThemePixmap( "mIconWms.png" ) ); | ||
|
||
populate(); | ||
} | ||
|
||
QgsWFSRootItem::~QgsWFSRootItem() | ||
{ | ||
} | ||
|
||
QVector<QgsDataItem*> QgsWFSRootItem::createChildren() | ||
{ | ||
QVector<QgsDataItem*> connections; | ||
QSettings settings; | ||
|
||
settings.beginGroup( "/Qgis/connections-wfs" ); | ||
foreach( QString connName, settings.childGroups() ) | ||
{ | ||
QgsDataItem * conn = new QgsWFSConnectionItem( this, connName, mPath + "/" + connName ); | ||
connections.append( conn ); | ||
} | ||
return connections; | ||
} | ||
|
||
QWidget * QgsWFSRootItem::paramWidget() | ||
{ | ||
QgsWFSSourceSelect *select = new QgsWFSSourceSelect( 0, 0 ); | ||
connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) ); | ||
return select; | ||
} | ||
|
||
void QgsWFSRootItem::connectionsChanged() | ||
{ | ||
refresh(); | ||
} | ||
|
||
|
||
QGISEXTERN int dataCapabilities() | ||
{ | ||
return QgsDataProvider::Net; | ||
} | ||
|
||
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) | ||
{ | ||
Q_UNUSED( thePath ); | ||
|
||
return new QgsWFSRootItem( parentItem, "WFS", "wfs:" ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#ifndef QGSWFSDATAITEMS_H | ||
#define QGSWFSDATAITEMS_H | ||
|
||
#include "qgsdataitem.h" | ||
|
||
class QgsWFSRootItem : public QgsDataCollectionItem | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsWFSRootItem( QgsDataItem* parent, QString name, QString path ); | ||
~QgsWFSRootItem(); | ||
|
||
QVector<QgsDataItem*> createChildren(); | ||
|
||
virtual QWidget * paramWidget(); | ||
|
||
public slots: | ||
void connectionsChanged(); | ||
}; | ||
|
||
class QgsWFSConnection; | ||
|
||
class QgsWFSConnectionItem : public QgsDataCollectionItem | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsWFSConnectionItem( QgsDataItem* parent, QString name, QString path ); | ||
~QgsWFSConnectionItem(); | ||
|
||
QVector<QgsDataItem*> createChildren(); | ||
//virtual bool equal( const QgsDataItem *other ); | ||
|
||
private slots: | ||
void gotCapabilities(); | ||
|
||
private: | ||
QString mName; | ||
|
||
QgsWFSConnection* mConn; | ||
bool mGotCapabilities; | ||
}; | ||
|
||
|
||
class QgsWFSLayerItem : public QgsLayerItem | ||
{ | ||
public: | ||
QgsWFSLayerItem( QgsDataItem* parent, QString connName, QString name, QString title ); | ||
~QgsWFSLayerItem(); | ||
|
||
}; | ||
|
||
|
||
#endif // QGSWFSDATAITEMS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters