Skip to content

Commit 1aca82d

Browse files
author
mhugent
committed
Show wfs names, titles and abstracts in the wfs select dialog. Changed QgsProjectionSelector::setOgcWmsCrsFilter such that the list of showed projections is updated in an existing dialog
git-svn-id: http://svn.osgeo.org/qgis/trunk@5964 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e790874 commit 1aca82d

File tree

4 files changed

+129
-83
lines changed

4 files changed

+129
-83
lines changed

src/plugins/wfs/qgswfssourceselect.cpp

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ QgsWFSSourceSelect::QgsWFSSourceSelect(QWidget* parent, QgisIface* iface): QDial
3838
connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteEntryOfServerList()));
3939
connect(btnConnect,SIGNAL(clicked()), this, SLOT(connectToServer()));
4040
connect(btnChangeSpatialRefSys, SIGNAL(clicked()), this, SLOT(changeCRS()));
41-
connect(lstWidget, SIGNAL(currentRowChanged(int)), this, SLOT(changeCRSFilter()));
41+
connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(changeCRSFilter()));
4242
populateConnectionList();
4343

4444
mProjectionSelector = new QgsLayerProjectionSelector(this);
@@ -78,21 +78,21 @@ void QgsWFSSourceSelect::populateConnectionList()
7878
}
7979
}
8080

81-
int QgsWFSSourceSelect::getCapabilities(const QString& uri, QgsWFSSourceSelect::REQUEST_ENCODING e, std::list<QString>& typenames, std::list< std::list<QString> >& crs)
81+
int QgsWFSSourceSelect::getCapabilities(const QString& uri, QgsWFSSourceSelect::REQUEST_ENCODING e, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts)
8282
{
8383
switch(e)
8484
{
8585
case QgsWFSSourceSelect::GET:
86-
return getCapabilitiesGET(uri, typenames, crs);
86+
return getCapabilitiesGET(uri, typenames, crs, titles, abstracts);
8787
case QgsWFSSourceSelect::POST:
88-
return getCapabilitiesPOST(uri, typenames, crs);
88+
return getCapabilitiesPOST(uri, typenames, crs, titles, abstracts);
8989
case QgsWFSSourceSelect::SOAP:
90-
return getCapabilitiesSOAP(uri, typenames, crs);
90+
return getCapabilitiesSOAP(uri, typenames, crs, titles, abstracts);
9191
}
9292
return 1;
9393
}
9494

95-
int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs)
95+
int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts)
9696
{
9797
QString request = uri + "SERVICE=WFS&REQUEST=GetCapabilities&VERSION=1.1.1";
9898
QByteArray result;
@@ -111,16 +111,29 @@ int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString
111111
QDomNodeList featureTypeList = capabilitiesDocument.elementsByTagNameNS(WFS_NAMESPACE, "FeatureType");
112112
for(unsigned int i = 0; i < featureTypeList.length(); ++i)
113113
{
114+
QString tname, title, abstract;
114115
QDomElement featureTypeElem = featureTypeList.at(i).toElement();
115116
std::list<QString> featureSRSList; //SRS list for this feature
116117

117118
//Name
118119
QDomNodeList nameList = featureTypeElem.elementsByTagNameNS(WFS_NAMESPACE, "Name");
119120
if(nameList.length() > 0)
120121
{
121-
typenames.push_back(nameList.at(0).toElement().text());
122+
tname = nameList.at(0).toElement().text();
122123
}
123-
124+
//Title
125+
QDomNodeList titleList = featureTypeElem.elementsByTagNameNS(WFS_NAMESPACE, "Title");
126+
if(titleList.length() > 0)
127+
{
128+
title = titleList.at(0).toElement().text();
129+
}
130+
//Abstract
131+
QDomNodeList abstractList = featureTypeElem.elementsByTagNameNS(WFS_NAMESPACE, "Abstract");
132+
if(abstractList.length() > 0)
133+
{
134+
abstract = abstractList.at(0).toElement().text();
135+
}
136+
124137
//DefaultSRS is always the first entry in the feature crs list
125138
QDomNodeList defaultSRSList = featureTypeElem.elementsByTagNameNS(WFS_NAMESPACE, "DefaultSRS");
126139
if(defaultSRSList.length() > 0)
@@ -143,6 +156,9 @@ int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString
143156
}
144157

145158
crs.push_back(featureSRSList);
159+
typenames.push_back(tname);
160+
titles.push_back(title);
161+
abstracts.push_back(abstract);
146162
}
147163

148164

@@ -153,12 +169,12 @@ int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString
153169
return 0;
154170
}
155171

156-
int QgsWFSSourceSelect::getCapabilitiesPOST(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs)
172+
int QgsWFSSourceSelect::getCapabilitiesPOST(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts)
157173
{
158174
return 1; //soon...
159175
}
160176

161-
int QgsWFSSourceSelect::getCapabilitiesSOAP(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs)
177+
int QgsWFSSourceSelect::getCapabilitiesSOAP(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts)
162178
{
163179
return 1; //soon...
164180
}
@@ -209,7 +225,10 @@ void QgsWFSSourceSelect::connectToServer()
209225
//make a GetCapabilities request
210226
std::list<QString> typenames;
211227
std::list< std::list<QString> > crsList;
212-
if(getCapabilities(mUri, QgsWFSSourceSelect::GET, typenames, crsList) != 0)
228+
std::list<QString> titles;
229+
std::list<QString> abstracts;
230+
231+
if(getCapabilities(mUri, QgsWFSSourceSelect::GET, typenames, crsList, titles, abstracts) != 0)
213232
{
214233
qWarning("error during GetCapabilities request");
215234
}
@@ -228,17 +247,24 @@ void QgsWFSSourceSelect::connectToServer()
228247
mAvailableCRS.insert(std::make_pair(*typeNameIter, currentCRSList));
229248
}
230249

231-
//insert the typenames into the list view
232-
lstWidget->clear();
233-
for(std::list<QString>::const_iterator it = typenames.begin(); it != typenames.end(); ++it)
250+
//insert the typenames, titles and abstracts into the tree view
251+
treeWidget->clear();
252+
std::list<QString>::const_iterator t_it = titles.begin();
253+
std::list<QString>::const_iterator n_it = typenames.begin();
254+
std::list<QString>::const_iterator a_it = abstracts.begin();
255+
for(; t_it != titles.end(); ++t_it, ++n_it, ++a_it)
234256
{
235-
lstWidget->addItem(*it);
257+
QTreeWidgetItem* newItem = new QTreeWidgetItem();
258+
newItem->setText(0, *t_it);
259+
newItem->setText(1, *n_it);
260+
newItem->setText(2, *a_it);
261+
treeWidget->addTopLevelItem(newItem);
236262
}
237263

238264
if(typenames.size() > 0)
239265
{
240266
btnAdd->setEnabled(true);
241-
lstWidget->setCurrentRow(0);
267+
treeWidget->setCurrentItem(treeWidget->topLevelItem(0));
242268
btnChangeSpatialRefSys->setEnabled(true);
243269
}
244270
else
@@ -252,12 +278,12 @@ void QgsWFSSourceSelect::connectToServer()
252278
void QgsWFSSourceSelect::addLayer()
253279
{
254280
//get selected entry in lstWidget
255-
QListWidgetItem* cItem = lstWidget->currentItem();
256-
if(!cItem)
281+
QTreeWidgetItem* tItem = treeWidget->currentItem();
282+
if(!tItem)
257283
{
258284
return;
259285
}
260-
QString typeName = cItem->text();
286+
QString typeName = tItem->text(1);
261287
qWarning(mUri + "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + typeName);
262288

263289
//get CRS
@@ -290,10 +316,10 @@ void QgsWFSSourceSelect::changeCRS()
290316
void QgsWFSSourceSelect::changeCRSFilter()
291317
{
292318
//evaluate currently selected typename and set the CRS filter in mProjectionSelector
293-
QListWidgetItem* currentListItem = lstWidget->currentItem();
294-
if(currentListItem)
319+
QTreeWidgetItem* currentTreeItem = treeWidget->currentItem();
320+
if(currentTreeItem)
295321
{
296-
QString currentTypename = currentListItem->text();
322+
QString currentTypename = currentTreeItem->text(1);
297323
qWarning("the current typename is: " + currentTypename);
298324

299325
std::map<QString, std::list<QString> >::const_iterator crsIterator = mAvailableCRS.find(currentTypename);

src/plugins/wfs/qgswfssourceselect.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase
5151

5252
/**Makes a GetCapabilities and returns the typenamse and crs supported by the server.
5353
@param typenames a list of layers provided by the server
54-
@param a list of crs supported by the server. The place in the list corresponds to the \
54+
@param crs a list of crs supported by the server. The place in the list corresponds to the \
5555
typenames list (means that the crs list at position 0 is a crs for typename at position 0 etc.)
56+
@param title title list
57+
@param abstract textual descriptions for the types
5658
@return 0 in case of success*/
57-
int getCapabilities(const QString& uri, QgsWFSSourceSelect::REQUEST_ENCODING e, std::list<QString>& typenames, std::list< std::list<QString> >& crs);
59+
int getCapabilities(const QString& uri, QgsWFSSourceSelect::REQUEST_ENCODING e, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts);
5860
//encoding specific methods of getCapabilities
59-
int getCapabilitiesGET(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs);
60-
int getCapabilitiesPOST(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs);
61-
int getCapabilitiesSOAP(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs);
61+
int getCapabilitiesGET(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts);
62+
int getCapabilitiesPOST(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts);
63+
int getCapabilitiesSOAP(const QString& uri, std::list<QString>& typenames, std::list< std::list<QString> >& crs, std::list<QString>& titles, std::list<QString>& abstracts);
6264

6365
private slots:
6466
void addEntryToServerList();

0 commit comments

Comments
 (0)