@@ -38,7 +38,7 @@ QgsWFSSourceSelect::QgsWFSSourceSelect(QWidget* parent, QgisIface* iface): QDial
38
38
connect (btnDelete, SIGNAL (clicked ()), this , SLOT (deleteEntryOfServerList ()));
39
39
connect (btnConnect,SIGNAL (clicked ()), this , SLOT (connectToServer ()));
40
40
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 ()));
42
42
populateConnectionList ();
43
43
44
44
mProjectionSelector = new QgsLayerProjectionSelector (this );
@@ -78,21 +78,21 @@ void QgsWFSSourceSelect::populateConnectionList()
78
78
}
79
79
}
80
80
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 )
82
82
{
83
83
switch (e)
84
84
{
85
85
case QgsWFSSourceSelect::GET:
86
- return getCapabilitiesGET (uri, typenames, crs);
86
+ return getCapabilitiesGET (uri, typenames, crs, titles, abstracts );
87
87
case QgsWFSSourceSelect::POST:
88
- return getCapabilitiesPOST (uri, typenames, crs);
88
+ return getCapabilitiesPOST (uri, typenames, crs, titles, abstracts );
89
89
case QgsWFSSourceSelect::SOAP:
90
- return getCapabilitiesSOAP (uri, typenames, crs);
90
+ return getCapabilitiesSOAP (uri, typenames, crs, titles, abstracts );
91
91
}
92
92
return 1 ;
93
93
}
94
94
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 )
96
96
{
97
97
QString request = uri + " SERVICE=WFS&REQUEST=GetCapabilities&VERSION=1.1.1" ;
98
98
QByteArray result;
@@ -111,16 +111,29 @@ int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString
111
111
QDomNodeList featureTypeList = capabilitiesDocument.elementsByTagNameNS (WFS_NAMESPACE, " FeatureType" );
112
112
for (unsigned int i = 0 ; i < featureTypeList.length (); ++i)
113
113
{
114
+ QString tname, title, abstract;
114
115
QDomElement featureTypeElem = featureTypeList.at (i).toElement ();
115
116
std::list<QString> featureSRSList; // SRS list for this feature
116
117
117
118
// Name
118
119
QDomNodeList nameList = featureTypeElem.elementsByTagNameNS (WFS_NAMESPACE, " Name" );
119
120
if (nameList.length () > 0 )
120
121
{
121
- typenames. push_back ( nameList.at (0 ).toElement ().text () );
122
+ tname = nameList.at (0 ).toElement ().text ();
122
123
}
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
+
124
137
// DefaultSRS is always the first entry in the feature crs list
125
138
QDomNodeList defaultSRSList = featureTypeElem.elementsByTagNameNS (WFS_NAMESPACE, " DefaultSRS" );
126
139
if (defaultSRSList.length () > 0 )
@@ -143,6 +156,9 @@ int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString
143
156
}
144
157
145
158
crs.push_back (featureSRSList);
159
+ typenames.push_back (tname);
160
+ titles.push_back (title);
161
+ abstracts.push_back (abstract);
146
162
}
147
163
148
164
@@ -153,12 +169,12 @@ int QgsWFSSourceSelect::getCapabilitiesGET(const QString& uri, std::list<QString
153
169
return 0 ;
154
170
}
155
171
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 )
157
173
{
158
174
return 1 ; // soon...
159
175
}
160
176
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 )
162
178
{
163
179
return 1 ; // soon...
164
180
}
@@ -209,7 +225,10 @@ void QgsWFSSourceSelect::connectToServer()
209
225
// make a GetCapabilities request
210
226
std::list<QString> typenames;
211
227
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 )
213
232
{
214
233
qWarning (" error during GetCapabilities request" );
215
234
}
@@ -228,17 +247,24 @@ void QgsWFSSourceSelect::connectToServer()
228
247
mAvailableCRS .insert (std::make_pair (*typeNameIter, currentCRSList));
229
248
}
230
249
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)
234
256
{
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);
236
262
}
237
263
238
264
if (typenames.size () > 0 )
239
265
{
240
266
btnAdd->setEnabled (true );
241
- lstWidget-> setCurrentRow ( 0 );
267
+ treeWidget-> setCurrentItem (treeWidget-> topLevelItem ( 0 ) );
242
268
btnChangeSpatialRefSys->setEnabled (true );
243
269
}
244
270
else
@@ -252,12 +278,12 @@ void QgsWFSSourceSelect::connectToServer()
252
278
void QgsWFSSourceSelect::addLayer ()
253
279
{
254
280
// get selected entry in lstWidget
255
- QListWidgetItem* cItem = lstWidget ->currentItem ();
256
- if (!cItem )
281
+ QTreeWidgetItem* tItem = treeWidget ->currentItem ();
282
+ if (!tItem )
257
283
{
258
284
return ;
259
285
}
260
- QString typeName = cItem ->text ();
286
+ QString typeName = tItem ->text (1 );
261
287
qWarning (mUri + " SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + typeName);
262
288
263
289
// get CRS
@@ -290,10 +316,10 @@ void QgsWFSSourceSelect::changeCRS()
290
316
void QgsWFSSourceSelect::changeCRSFilter ()
291
317
{
292
318
// 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 )
295
321
{
296
- QString currentTypename = currentListItem ->text ();
322
+ QString currentTypename = currentTreeItem ->text (1 );
297
323
qWarning (" the current typename is: " + currentTypename);
298
324
299
325
std::map<QString, std::list<QString> >::const_iterator crsIterator = mAvailableCRS .find (currentTypename);
0 commit comments