Skip to content
Permalink
Browse files

Add tooltips and tests for the provider class

  • Loading branch information
elpaso committed Sep 5, 2017
1 parent e43cb79 commit 08588a54da21914aea2b34a7989a871ddaf94b48
Showing with 20 additions and 6 deletions.
  1. +12 −6 src/gui/qgsdatasourcemanagerdialog.cpp
  2. +8 −0 tests/src/python/test_qgssourceselectprovider.py
@@ -14,7 +14,6 @@
* *
***************************************************************************/

#include <QMessageBox>
#include <QListWidgetItem>

#include "qgsdatasourcemanagerdialog.h"
@@ -26,6 +25,7 @@
#include "qgssourceselectproviderregistry.h"
#include "qgsabstractdatasourcewidget.h"
#include "qgsmapcanvas.h"
#include "qgsmessagelog.h"
#include "qgsgui.h"

QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapCanvas *canvas, Qt::WindowFlags fl ) :
@@ -65,10 +65,10 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
QgsAbstractDataSourceWidget *dlg = provider->createDataSourceWidget( this );
if ( !dlg )
{
QMessageBox::warning( this, provider->name(), tr( "Cannot get %1 select dialog from source select provider %2." ).arg( provider->name(), provider->providerKey() ) );
QgsMessageLog::logMessage( tr( "Cannot get %1 select dialog from source select provider %2." ).arg( provider->name(), provider->providerKey() ), QStringLiteral( "DataSourceManager" ), QgsMessageLog::CRITICAL );
continue;
}
addProviderDialog( dlg, provider->providerKey(), provider->text(), provider->icon( ) );
addProviderDialog( dlg, provider->providerKey(), provider->text(), provider->icon( ), provider->toolTip( ) );
}

}
@@ -150,14 +150,20 @@ void QgsDataSourceManagerDialog::makeConnections( QgsAbstractDataSourceWidget *d
this, SIGNAL( showStatusMessage( QString ) ) );
// Vector
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
{ this->vectorLayerAdded( vectorLayerPath, baseName, providerKey ); } );
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayers, this, &QgsDataSourceManagerDialog::vectorLayersAdded ); connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
{
this->vectorLayerAdded( vectorLayerPath, baseName, providerKey );
}
);
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayers,
this, &QgsDataSourceManagerDialog::vectorLayersAdded );
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
// Raster
connect( dlg, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ) );

// Virtual
connect( dlg, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ), this, SIGNAL( replaceSelectedVectorLayer( QString, QString, QString, QString ) ) );
connect( dlg, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ),
this, SIGNAL( replaceSelectedVectorLayer( QString, QString, QString, QString ) ) );
// Common
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
@@ -61,6 +61,9 @@ def text(self):
def name(self):
return "MyName"

def toolTip(self):
return "MyToolTip"

def icon(self):
return QIcon()

@@ -88,9 +91,14 @@ def testConcreteClass(self):
self.assertEqual(provider.providerKey(), "MyTestProviderKey")
self.assertEqual(provider.name(), "MyTestProviderKey")
self.assertEqual(provider.text(), "MyTestProviderText")
self.assertEqual(provider.toolTip(), "")
self.assertEqual(provider.ordering(), 1)
self.assertTrue(isinstance(provider.icon(), QIcon))

# test toolTip
provider = ConcreteSourceSelectProvider2()
self.assertEqual(provider.toolTip(), "MyToolTip")

def _testRegistry(self, registry):

registry.addProvider(ConcreteSourceSelectProvider())

0 comments on commit 08588a5

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