Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
GUI for XYZ tile layers: browser items + actions to add/remove them
- Loading branch information
Showing
5 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*************************************************************************** | ||
qgsxyzconnection.h | ||
--------------------- | ||
begin : August 2016 | ||
copyright : (C) 2016 by Martin Dobias | ||
email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsxyzconnection.h" | ||
|
||
#include "qgsdatasourceuri.h" | ||
|
||
#include <QSettings> | ||
|
||
QString QgsXyzConnection::encodedUri() const | ||
{ | ||
QgsDataSourceUri uri; | ||
uri.setParam( "type", "xyz" ); | ||
uri.setParam( "url", url ); | ||
return uri.encodedUri(); | ||
} | ||
|
||
QStringList QgsXyzConnectionUtils::connectionList() | ||
{ | ||
QSettings settings; | ||
settings.beginGroup( "/Qgis/connections-xyz" ); | ||
return settings.childGroups(); | ||
} | ||
|
||
QgsXyzConnection QgsXyzConnectionUtils::connection( const QString &name ) | ||
{ | ||
QSettings settings; | ||
settings.beginGroup( "/Qgis/connections-xyz/" + name ); | ||
|
||
QgsXyzConnection conn; | ||
conn.name = name; | ||
conn.url = settings.value( "url" ).toString(); | ||
return conn; | ||
} | ||
|
||
void QgsXyzConnectionUtils::deleteConnection( const QString& name ) | ||
{ | ||
QSettings settings; | ||
settings.remove( "/Qgis/connections-xyz/" + name ); | ||
} | ||
|
||
void QgsXyzConnectionUtils::addConnection( const QgsXyzConnection &conn ) | ||
{ | ||
QSettings settings; | ||
settings.beginGroup( "/Qgis/connections-xyz/" + conn.name ); | ||
settings.setValue( "url", conn.url ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*************************************************************************** | ||
qgsxyzconnection.h | ||
--------------------- | ||
begin : August 2016 | ||
copyright : (C) 2016 by Martin Dobias | ||
email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSXYZCONNECTION_H | ||
#define QGSXYZCONNECTION_H | ||
|
||
#include <QStringList> | ||
|
||
struct QgsXyzConnection | ||
{ | ||
QString name; | ||
QString url; | ||
|
||
QString encodedUri() const; | ||
}; | ||
|
||
/** Utility class for handling list of connections to XYZ tile layers */ | ||
class QgsXyzConnectionUtils | ||
{ | ||
public: | ||
//! Returns list of existing connections | ||
static QStringList connectionList(); | ||
|
||
//! Returns connection details | ||
static QgsXyzConnection connection( const QString& name ); | ||
|
||
//! Removes a connection from the list | ||
static void deleteConnection( const QString& name ); | ||
|
||
//! Adds a new connection to the list | ||
static void addConnection( const QgsXyzConnection& conn ); | ||
}; | ||
|
||
|
||
#endif // QGSXYZCONNECTION_H |