Skip to content

Commit

Permalink
Add tooltips and tests for the provider class
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Sep 5, 2017
1 parent e43cb79 commit 08588a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/gui/qgsdatasourcemanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* *
***************************************************************************/

#include <QMessageBox>
#include <QListWidgetItem>

#include "qgsdatasourcemanagerdialog.h"
Expand All @@ -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 ) :
Expand Down Expand Up @@ -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( ) );
}

}
Expand Down Expand Up @@ -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() ) );
Expand Down
8 changes: 8 additions & 0 deletions tests/src/python/test_qgssourceselectprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def text(self):
def name(self):
return "MyName"

def toolTip(self):
return "MyToolTip"

def icon(self):
return QIcon()

Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 08588a5

Please sign in to comment.