Skip to content

Commit aae81cc

Browse files
author
g_j_m
committed
Provide the means to add some pre-defined wms servers to the server
list. Addresses ticket #341. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5942 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9465dc5 commit aae81cc

File tree

3 files changed

+253
-207
lines changed

3 files changed

+253
-207
lines changed

src/gui/qgsserversourceselect.cpp

+46-13
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,20 @@ void QgsServerSourceSelect::populateConnectionList()
113113
}
114114
setConnectionListPosition();
115115

116-
if (keys.begin() != keys.end())
117-
{
118-
// Connections available - enable various buttons
119-
btnConnect->setEnabled(TRUE);
120-
btnEdit->setEnabled(TRUE);
121-
btnDelete->setEnabled(TRUE);
122-
}
116+
if (keys.begin() == keys.end())
117+
{
118+
// No connections - disable various buttons
119+
btnConnect->setEnabled(FALSE);
120+
btnEdit->setEnabled(FALSE);
121+
btnDelete->setEnabled(FALSE);
122+
}
123123
else
124-
{
125-
// No connections available - disable various buttons
126-
btnConnect->setEnabled(FALSE);
127-
btnEdit->setEnabled(FALSE);
128-
btnDelete->setEnabled(FALSE);
129-
}
124+
{
125+
// Connections - enable various buttons
126+
btnConnect->setEnabled(TRUE);
127+
btnEdit->setEnabled(TRUE);
128+
btnDelete->setEnabled(TRUE);
129+
}
130130
}
131131
void QgsServerSourceSelect::on_btnNew_clicked()
132132
{
@@ -726,6 +726,11 @@ void QgsServerSourceSelect::on_cmbConnections_activated(int)
726726
serverChanged();
727727
}
728728

729+
void QgsServerSourceSelect::on_btnAddDefault_clicked()
730+
{
731+
addDefaultServers();
732+
}
733+
729734
QString QgsServerSourceSelect::descriptionForEpsg(long epsg)
730735
{
731736
// We'll assume this function isn't called very often,
@@ -736,5 +741,33 @@ QString QgsServerSourceSelect::descriptionForEpsg(long epsg)
736741
return qgisSrs.description();
737742
}
738743

744+
void QgsServerSourceSelect::addDefaultServers()
745+
{
746+
QMap<QString, QString> exampleServers;
747+
exampleServers["NASA (JPL)"] = "http://wms.jpl.nasa.gov/wms.cgi";
748+
exampleServers["DM Solutions GMap"] = "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap";
749+
exampleServers["TerraService"] = "http://terraservice.net/ogccapabilities.ashx";
750+
// Nice to have the qgis users map, but I'm not sure of the URL at the moment.
751+
// exampleServers["Qgis users map"] = "http://qgis.org/wms.cgi";
752+
753+
QSettings settings;
754+
QString basePath("/Qgis/connections-wms/");
755+
QMap<QString, QString>::const_iterator i = exampleServers.constBegin();
756+
for (; i != exampleServers.constEnd(); ++i)
757+
{
758+
// Only do a server if it's name doesn't already exist.
759+
QStringList keys = settings.subkeyList(basePath);
760+
if (!keys.contains(i.key()))
761+
{
762+
QString path = basePath + i.key();
763+
settings.setValue(path + "/proxyhost", "");
764+
settings.setValue(path + "/proxyport", 80);
765+
settings.setValue(path + "/proxyuser", "");
766+
settings.setValue(path + "/proxypassword", "");
767+
settings.setValue(path + "/url", i.value());
768+
}
769+
}
770+
populateConnectionList();
771+
}
739772

740773
// ENDS

src/gui/qgsserversourceselect.h

+6
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ public slots:
121121
//! Stores the selected datasource whenerver it is changed
122122
void on_cmbConnections_activated(int);
123123

124+
//! Add some default wms servers to the list
125+
void on_btnAddDefault_clicked();
126+
124127
private:
125128

129+
//! Add a few example servers to the list.
130+
void addDefaultServers();
131+
126132
/**
127133
* \brief Populate the layer list - private for now.
128134
*

0 commit comments

Comments
 (0)