Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 committed Apr 14, 2006
1 parent 15216d8 commit b024796
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/gui/qgsserversourceselect.cpp
Expand Up @@ -88,6 +88,7 @@ void QgsServerSourceSelect::populateConnectionList()
cmbConnections->insertItem(*it);
++it;
}
setConnectionListPosition();

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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -624,6 +662,10 @@ void QgsServerSourceSelect::showError(QgsWmsProvider * wms)
delete mv;
}

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

QString QgsServerSourceSelect::descriptionForEpsg(long epsg)
{
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsserversourceselect.h
Expand Up @@ -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:

Expand Down Expand Up @@ -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:

Expand Down

0 comments on commit b024796

Please sign in to comment.