-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose GeoPackage to the browser tree
- Loading branch information
Showing
16 changed files
with
539 additions
and
10 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,89 @@ | ||
/*************************************************************************** | ||
qgsgeopackageconnection.cpp - selector for geopackage | ||
------------------- | ||
begin : August 2017 | ||
copyright : (C) 2017 by Alessandro Pasotti | ||
email : apasotti at boundlessgeo 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 "qgis.h" | ||
#include "qgsdatasourceuri.h" | ||
#include "qgssettings.h" | ||
#include "qgsgeopackageconnection.h" | ||
#include "qgslogger.h" | ||
#include <QInputDialog> | ||
#include <QMessageBox> | ||
|
||
const QString QgsGeoPackageConnection::SETTINGS_PREFIX = QStringLiteral( "providers/geopackage" ); | ||
|
||
|
||
QgsGeoPackageConnection::QgsGeoPackageConnection( const QString &connName ) | ||
: mConnName( connName ) | ||
{ | ||
QgsSettings settings; | ||
|
||
QString key = QStringLiteral( "%1/%2/path" ).arg( connectionsPath( ), mConnName ); | ||
mPath = settings.value( key ).toString(); | ||
} | ||
|
||
QgsGeoPackageConnection::~QgsGeoPackageConnection() | ||
{ | ||
|
||
} | ||
|
||
QgsDataSourceUri QgsGeoPackageConnection::uri() | ||
{ | ||
QgsDataSourceUri uri; | ||
uri.setEncodedUri( mPath ); | ||
return uri; | ||
} | ||
|
||
void QgsGeoPackageConnection::setPath( QString &path ) | ||
{ | ||
mPath = path; | ||
} | ||
|
||
void QgsGeoPackageConnection::save( ) | ||
{ | ||
QgsSettings settings; | ||
settings.setValue( QStringLiteral( "%1/%2/path" ).arg( connectionsPath( ), mConnName ), mPath ); | ||
} | ||
|
||
QString QgsGeoPackageConnection::connectionsPath() | ||
{ | ||
return QStringLiteral( "%1/connections" ).arg( SETTINGS_PREFIX ); | ||
} | ||
|
||
QStringList QgsGeoPackageConnection::connectionList() | ||
{ | ||
QgsSettings settings; | ||
settings.beginGroup( connectionsPath( ) ); | ||
return settings.childGroups(); | ||
} | ||
|
||
QString QgsGeoPackageConnection::selectedConnection() | ||
{ | ||
QgsSettings settings; | ||
return settings.value( QStringLiteral( "%1/selected" ).arg( SETTINGS_PREFIX ) ).toString(); | ||
} | ||
|
||
void QgsGeoPackageConnection::setSelectedConnection( const QString &name ) | ||
{ | ||
QgsSettings settings; | ||
settings.setValue( QStringLiteral( "%1/selected" ).arg( SETTINGS_PREFIX ), name ); | ||
} | ||
|
||
void QgsGeoPackageConnection::deleteConnection( const QString &name ) | ||
{ | ||
QgsSettings settings; | ||
settings.remove( QStringLiteral( "%1/%2" ).arg( connectionsPath(), name ) ); | ||
} |
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,67 @@ | ||
/*************************************************************************** | ||
qgsgeopackageconnection.h - GeoPackage connection | ||
------------------- | ||
begin : August 2017 | ||
copyright : (C) 2017 by Alessandro Pasotti | ||
email : apasotti at boundlessgeo 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 QGSGEOPACKAGECONNECTION_H | ||
#define QGSGEOPACKAGECONNECTION_H | ||
|
||
#include "qgsdatasourceuri.h" | ||
|
||
#include <QStringList> | ||
|
||
/*! | ||
* \brief Connections management | ||
*/ | ||
class QgsGeoPackageConnection : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
//! Constructor | ||
explicit QgsGeoPackageConnection( const QString &connName ); | ||
|
||
~QgsGeoPackageConnection(); | ||
|
||
static QStringList connectionList(); | ||
|
||
static void deleteConnection( const QString &name ); | ||
|
||
static QString selectedConnection(); | ||
static void setSelectedConnection( const QString &name ); | ||
|
||
public: | ||
//! Return the uri | ||
//! \see QgsDataSourceUri | ||
QgsDataSourceUri uri(); | ||
//! Return the path | ||
QString path( ) { return mPath; } | ||
//! Returns the connection name | ||
QString name() { return mConnName; } | ||
//! Set the \a path fo the connection | ||
void setPath( QString &path ); | ||
//! Store the connection data in the settings | ||
void save(); | ||
const static QString SETTINGS_PREFIX; | ||
|
||
private: | ||
|
||
static QString connectionsPath( ); | ||
QString mConnName; | ||
QString mPath; | ||
|
||
}; | ||
|
||
#endif // QGSGEOPACKAGECONNECTION_H |
Oops, something went wrong.