Skip to content
Permalink
Browse files

Add icon to provider connections

  • Loading branch information
nyalldawson committed Mar 7, 2020
1 parent f7731bc commit 26df3028b2294e57a3eea1db4b72344887c17dae
@@ -72,6 +72,11 @@ Stores the connection in the settings.
virtual void remove( const QString &name ) const = 0;
%Docstring
Deletes the connection from the settings.
%End

virtual QIcon icon() const;
%Docstring
Returns an icon representing the connection.
%End

QString uri() const;
@@ -19,6 +19,7 @@
#include "qgsogrprovider.h"
#include "qgsmessagelog.h"
#include "qgsproviderregistry.h"
#include "qgsapplication.h"

QgsGeoPackageProviderConnection::QgsGeoPackageProviderConnection( const QString &name )
: QgsAbstractDatabaseProviderConnection( name )
@@ -262,6 +263,11 @@ QList<QgsGeoPackageProviderConnection::TableProperty> QgsGeoPackageProviderConne
return tableInfo ;
}

QIcon QgsGeoPackageProviderConnection::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "mGeoPackage.svg" ) );
}

void QgsGeoPackageProviderConnection::setDefaultCapabilities()
{
mCapabilities =
@@ -42,6 +42,7 @@ class QgsGeoPackageProviderConnection : public QgsAbstractDatabaseProviderConnec
void vacuum( const QString &schema, const QString &name ) const override;
QList<QgsAbstractDatabaseProviderConnection::TableProperty> tables( const QString &schema = QString(),
const TableFlags &flags = nullptr ) const override;
QIcon icon() const override;

private:

@@ -14,7 +14,7 @@
* *
***************************************************************************/
#include "qgsabstractproviderconnection.h"

#include <QIcon>

QgsAbstractProviderConnection::QgsAbstractProviderConnection( const QString &name )
{
@@ -30,6 +30,11 @@ QgsAbstractProviderConnection::QgsAbstractProviderConnection( const QString &uri

}

QIcon QgsAbstractProviderConnection::icon() const
{
return QIcon();
}

QString QgsAbstractProviderConnection::uri() const
{
return mUri;
@@ -89,6 +89,11 @@ class CORE_EXPORT QgsAbstractProviderConnection
*/
virtual void remove( const QString &name ) const = 0;

/**
* Returns an icon representing the connection.
*/
virtual QIcon icon() const;

/**
* Returns the connection data source URI string representation
*/
@@ -83,6 +83,16 @@ QVariant QgsProviderConnectionModel::data( const QModelIndex &index, int role )
return connectionName;
}

case Qt::DecorationRole:
if ( const QgsAbstractProviderConnection *connection = mMetadata->findConnection( connectionName ) )
{
return connection->icon();
}
else
{
return QIcon();
}

case Qt::ToolTipRole:
case RoleUri:
{
@@ -19,7 +19,7 @@
#include "qgssettings.h"
#include "qgspostgresprovider.h"
#include "qgsexception.h"

#include "qgsapplication.h"

extern "C"
{
@@ -499,3 +499,8 @@ void QgsPostgresProviderConnection::remove( const QString &name ) const
QgsPostgresConn::deleteConnection( name );
}

QIcon QgsPostgresProviderConnection::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "mIconPostgis.svg" ) );
}

@@ -52,7 +52,7 @@ class QgsPostgresProviderConnection : public QgsAbstractDatabaseProviderConnecti
QStringList schemas( ) const override;
void store( const QString &name ) const override;
void remove( const QString &name ) const override;

QIcon icon() const override;

private:

@@ -20,7 +20,7 @@
#include "qgssettings.h"
#include "qgsmessagelog.h"
#include "qgsproviderregistry.h"

#include "qgsapplication.h"

QgsSpatiaLiteProviderConnection::QgsSpatiaLiteProviderConnection( const QString &name )
: QgsAbstractDatabaseProviderConnection( name )
@@ -317,6 +317,11 @@ QList<QgsSpatiaLiteProviderConnection::TableProperty> QgsSpatiaLiteProviderConne
return tableInfo ;
}

QIcon QgsSpatiaLiteProviderConnection::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "mIconSpatialite.svg" ) );
}

void QgsSpatiaLiteProviderConnection::setDefaultCapabilities()
{
mCapabilities =
@@ -42,6 +42,7 @@ class QgsSpatiaLiteProviderConnection : public QgsAbstractDatabaseProviderConnec
void vacuum( const QString &schema, const QString &name ) const override;
QList<QgsAbstractDatabaseProviderConnection::TableProperty> tables( const QString &schema = QString(),
const TableFlags &flags = nullptr ) const override;
QIcon icon() const override;

private:

0 comments on commit 26df302

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