Skip to content

Commit fe8812c

Browse files
author
g_j_m
committedApr 14, 2006
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/qgis@5276 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
 

‎src/gui/qgsserversourceselect.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void QgsServerSourceSelect::populateConnectionList()
8888
cmbConnections->insertItem(*it);
8989
++it;
9090
}
91+
setConnectionListPosition();
9192

9293
if (keys.begin() != keys.end())
9394
{
@@ -137,6 +138,7 @@ void QgsServerSourceSelect::on_btnDelete_clicked()
137138
{
138139
settings.remove(key);
139140
cmbConnections->removeItem(cmbConnections->currentItem()); // populateConnectionList();
141+
setConnectionListPosition();
140142
}
141143
}
142144

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

598+
void QgsServerSourceSelect::serverChanged()
599+
{
600+
// Remember which server was selected.
601+
QSettings settings;
602+
settings.writeEntry("/Qgis/connections-wms/selected",
603+
cmbConnections->currentText());
604+
}
596605

606+
void QgsServerSourceSelect::setConnectionListPosition()
607+
{
608+
QSettings settings;
609+
QString toSelect = settings.readEntry("/Qgis/connections-wms/selected");
610+
// Does toSelect exist in cmbConnections?
611+
bool set = false;
612+
for (int i = 0; i < cmbConnections->count(); ++i)
613+
if (cmbConnections->text(i) == toSelect)
614+
{
615+
cmbConnections->setCurrentItem(i);
616+
set = true;
617+
break;
618+
}
619+
// If we couldn't find the stored item, but there are some,
620+
// default to the last item (this makes some sense when deleting
621+
// items as it allows the user to repeatidly click on delete to
622+
// remove a whole lot of items).
623+
if (!set && cmbConnections->count() > 0)
624+
{
625+
// If toSelect is null, then the selected connection wasn't found
626+
// by QSettings, which probably means that this is the first time
627+
// the user has used qgis with database connections, so default to
628+
// the first in the list of connetions. Otherwise default to the last.
629+
if (toSelect.isNull())
630+
cmbConnections->setCurrentItem(0);
631+
else
632+
cmbConnections->setCurrentItem(cmbConnections->count()-1);
633+
}
634+
}
597635
void QgsServerSourceSelect::showStatusMessage(QString const & theMessage)
598636
{
599637
labelStatus->setText(theMessage);
@@ -624,6 +662,10 @@ void QgsServerSourceSelect::showError(QgsWmsProvider * wms)
624662
delete mv;
625663
}
626664

665+
void QgsServerSourceSelect::on_cmbConnections_activated(int)
666+
{
667+
serverChanged();
668+
}
627669

628670
QString QgsServerSourceSelect::descriptionForEpsg(long epsg)
629671
{

‎src/gui/qgsserversourceselect.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class QgsServerSourceSelect : public QDialog, private Ui::QgsServerSourceSelectB
6666
//! String containing the selected WMS-format CRS
6767
QString selectedCrs();
6868

69+
//! Stores which server is now selected.
70+
void serverChanged();
71+
72+
//! Set the server connection combo box to that stored in the config file.
73+
void setConnectionListPosition();
6974

7075
public slots:
7176

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

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

103110
private:
104111

0 commit comments

Comments
 (0)
Please sign in to comment.