Skip to content
Permalink
Browse files

Make the WMS server select widget on the server select dialog box

remember which server was selected. Serry nice seature.


git-svn-id: http://svn.osgeo.org/qgis/trunk@5276 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m
g_j_m committed Apr 14, 2006
1 parent 15216d8 commit b024796a09982a69f899bffc384daa49be12ab13
Showing with 49 additions and 0 deletions.
  1. +42 −0 src/gui/qgsserversourceselect.cpp
  2. +7 −0 src/gui/qgsserversourceselect.h
@@ -88,6 +88,7 @@ void QgsServerSourceSelect::populateConnectionList()
cmbConnections->insertItem(*it);
++it;
}
setConnectionListPosition();

if (keys.begin() != keys.end())
{
@@ -137,6 +138,7 @@ void QgsServerSourceSelect::on_btnDelete_clicked()
{
settings.remove(key);
cmbConnections->removeItem(cmbConnections->currentItem()); // populateConnectionList();
setConnectionListPosition();
}
}

@@ -593,7 +595,43 @@ QString QgsServerSourceSelect::selectedCrs()
}
}

void QgsServerSourceSelect::serverChanged()
{
// Remember which server was selected.
QSettings settings;
settings.writeEntry("/Qgis/connections-wms/selected",
cmbConnections->currentText());
}

void QgsServerSourceSelect::setConnectionListPosition()
{
QSettings settings;
QString toSelect = settings.readEntry("/Qgis/connections-wms/selected");
// Does toSelect exist in cmbConnections?
bool set = false;
for (int i = 0; i < cmbConnections->count(); ++i)
if (cmbConnections->text(i) == toSelect)
{
cmbConnections->setCurrentItem(i);
set = true;
break;
}
// If we couldn't find the stored item, but there are some,
// default to the last item (this makes some sense when deleting
// items as it allows the user to repeatidly click on delete to
// remove a whole lot of items).
if (!set && cmbConnections->count() > 0)
{
// If toSelect is null, then the selected connection wasn't found
// by QSettings, which probably means that this is the first time
// the user has used qgis with database connections, so default to
// the first in the list of connetions. Otherwise default to the last.
if (toSelect.isNull())
cmbConnections->setCurrentItem(0);
else
cmbConnections->setCurrentItem(cmbConnections->count()-1);
}
}
void QgsServerSourceSelect::showStatusMessage(QString const & theMessage)
{
labelStatus->setText(theMessage);
@@ -624,6 +662,10 @@ void QgsServerSourceSelect::showError(QgsWmsProvider * wms)
delete mv;
}

void QgsServerSourceSelect::on_cmbConnections_activated(int)
{
serverChanged();
}

QString QgsServerSourceSelect::descriptionForEpsg(long epsg)
{
@@ -66,6 +66,11 @@ class QgsServerSourceSelect : public QDialog, private Ui::QgsServerSourceSelectB
//! String containing the selected WMS-format CRS
QString selectedCrs();

//! Stores which server is now selected.
void serverChanged();

//! Set the server connection combo box to that stored in the config file.
void setConnectionListPosition();

public slots:

@@ -99,6 +104,8 @@ public slots:
//! show whatever error is exposed by the QgsWmsProvider.
void showError(QgsWmsProvider * wms);

//! Stores the selected datasource whenerver it is changed
void on_cmbConnections_activated(int);

private:

0 comments on commit b024796

Please sign in to comment.
You can’t perform that action at this time.