Skip to content
Permalink
Browse files

Minor housekeeping in WMS and WFS

  • Loading branch information
wonder-sk committed Oct 11, 2011
1 parent 0591288 commit e57c55787658c27afd93a7e2a98bf4e78532cd46
@@ -125,10 +125,8 @@ QgsWFSRootItem::~QgsWFSRootItem()
QVector<QgsDataItem*> QgsWFSRootItem::createChildren()
{
QVector<QgsDataItem*> connections;
QSettings settings;

settings.beginGroup( "/Qgis/connections-wfs" );
foreach( QString connName, settings.childGroups() )
foreach( QString connName, QgsWFSConnection::connectionList() )
{
QgsDataItem * conn = new QgsWFSConnectionItem( this, connName, mPath + "/" + connName );
connections.append( conn );
@@ -128,3 +128,30 @@ QgsWmsProvider * QgsWMSConnection::provider( )
return wmsProvider;
}



QStringList QgsWMSConnection::connectionList()
{
QSettings settings;
settings.beginGroup( "/Qgis/connections-wms" );
return settings.childGroups();
}

QString QgsWMSConnection::selectedConnection()
{
QSettings settings;
return settings.value( "/Qgis/connections-wms/selected" ).toString();
}

void QgsWMSConnection::setSelectedConnection( QString name )
{
QSettings settings;
settings.setValue( "/Qgis/connections-wms/selected", name );
}

void QgsWMSConnection::deleteConnection( QString name )
{
QSettings settings;
settings.remove( "/Qgis/connections-wms/" + name );
settings.remove( "/Qgis/WMS/" + name );
}
@@ -43,6 +43,14 @@ class QgsWMSConnection : public QObject
//! Destructor
~QgsWMSConnection();

static QStringList connectionList();

static void deleteConnection( QString name );

static QString selectedConnection();
static void setSelectedConnection( QString name );


public:
QgsWmsProvider *provider();
QString connectionInfo();
@@ -3321,10 +3321,8 @@ QgsWMSRootItem::~QgsWMSRootItem()
QVector<QgsDataItem*>QgsWMSRootItem::createChildren()
{
QVector<QgsDataItem*> connections;
QSettings settings;

settings.beginGroup( "/Qgis/connections-wms" );
foreach( QString connName, settings.childGroups() )
foreach( QString connName, QgsWMSConnection::connectionList() )
{
QgsDataItem * conn = new QgsWMSConnectionItem( this, connName, mPath + "/" + connName );
connections.append( conn );
@@ -154,11 +154,8 @@ QgsWMSSourceSelect::~QgsWMSSourceSelect()

void QgsWMSSourceSelect::populateConnectionList()
{
QSettings settings;
settings.beginGroup( "/Qgis/connections-wms" );
cmbConnections->clear();
cmbConnections->addItems( settings.childGroups() );
settings.endGroup();
cmbConnections->addItems( QgsWMSConnection::connectionList() );

setConnectionListPosition();

@@ -205,15 +202,12 @@ void QgsWMSSourceSelect::on_btnEdit_clicked()

void QgsWMSSourceSelect::on_btnDelete_clicked()
{
QSettings settings;
QString key = "/Qgis/connections-wms/" + cmbConnections->currentText();
QString msg = tr( "Are you sure you want to remove the %1 connection and all associated settings?" )
.arg( cmbConnections->currentText() );
QMessageBox::StandardButton result = QMessageBox::information( this, tr( "Confirm Delete" ), msg, QMessageBox::Ok | QMessageBox::Cancel );
if ( result == QMessageBox::Ok )
{
settings.remove( key );
settings.remove( "/Qgis/WMS/" + cmbConnections->currentText() );
QgsWMSConnection::deleteConnection( cmbConnections->currentText() );
cmbConnections->removeItem( cmbConnections->currentIndex() ); // populateConnectionList();
setConnectionListPosition();
emit connectionsChanged();
@@ -926,8 +920,7 @@ QString QgsWMSSourceSelect::selectedImageEncoding()

void QgsWMSSourceSelect::setConnectionListPosition()
{
QSettings settings;
QString toSelect = settings.value( "/Qgis/connections-wms/selected" ).toString();
QString toSelect = QgsWMSConnection::selectedConnection();

cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );

@@ -968,8 +961,7 @@ void QgsWMSSourceSelect::showError( QgsWmsProvider * wms )
void QgsWMSSourceSelect::on_cmbConnections_activated( int )
{
// Remember which server was selected.
QSettings settings;
settings.setValue( "/Qgis/connections-wms/selected", cmbConnections->currentText() );
QgsWMSConnection::setSelectedConnection( cmbConnections->currentText() );
}

void QgsWMSSourceSelect::on_btnAddDefault_clicked()
@@ -1127,7 +1119,7 @@ void QgsWMSSourceSelect::on_btnAddWMS_clicked()

// add selected WMS to config and mark as current
settings.setValue( QString( "Qgis/connections-wms/%1/url" ).arg( wmsTitle ), wmsUrl );
settings.setValue( "/Qgis/connections-wms/selected", wmsTitle );
QgsWMSConnection::setSelectedConnection( wmsTitle );
populateConnectionList();

tabServers->setCurrentIndex( 0 );

0 comments on commit e57c557

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