mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
Add tooltips and tests for the provider class
This commit is contained in:
parent
e43cb79630
commit
08588a54da
@ -14,7 +14,6 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
#include "qgsdatasourcemanagerdialog.h"
|
#include "qgsdatasourcemanagerdialog.h"
|
||||||
@ -26,6 +25,7 @@
|
|||||||
#include "qgssourceselectproviderregistry.h"
|
#include "qgssourceselectproviderregistry.h"
|
||||||
#include "qgsabstractdatasourcewidget.h"
|
#include "qgsabstractdatasourcewidget.h"
|
||||||
#include "qgsmapcanvas.h"
|
#include "qgsmapcanvas.h"
|
||||||
|
#include "qgsmessagelog.h"
|
||||||
#include "qgsgui.h"
|
#include "qgsgui.h"
|
||||||
|
|
||||||
QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapCanvas *canvas, Qt::WindowFlags fl ) :
|
QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapCanvas *canvas, Qt::WindowFlags fl ) :
|
||||||
@ -65,10 +65,10 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
|
|||||||
QgsAbstractDataSourceWidget *dlg = provider->createDataSourceWidget( this );
|
QgsAbstractDataSourceWidget *dlg = provider->createDataSourceWidget( this );
|
||||||
if ( !dlg )
|
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;
|
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 ) ) );
|
this, SIGNAL( showStatusMessage( QString ) ) );
|
||||||
// Vector
|
// Vector
|
||||||
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
|
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
|
// Raster
|
||||||
connect( dlg, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
|
connect( dlg, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
|
||||||
this, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ) );
|
this, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ) );
|
||||||
|
|
||||||
// Virtual
|
// 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
|
// Common
|
||||||
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
|
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
|
||||||
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
|
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
|
||||||
|
@ -61,6 +61,9 @@ class ConcreteSourceSelectProvider2(QgsSourceSelectProvider):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return "MyName"
|
return "MyName"
|
||||||
|
|
||||||
|
def toolTip(self):
|
||||||
|
return "MyToolTip"
|
||||||
|
|
||||||
def icon(self):
|
def icon(self):
|
||||||
return QIcon()
|
return QIcon()
|
||||||
|
|
||||||
@ -88,9 +91,14 @@ class TestQgsSourceSelectProvider(unittest.TestCase):
|
|||||||
self.assertEqual(provider.providerKey(), "MyTestProviderKey")
|
self.assertEqual(provider.providerKey(), "MyTestProviderKey")
|
||||||
self.assertEqual(provider.name(), "MyTestProviderKey")
|
self.assertEqual(provider.name(), "MyTestProviderKey")
|
||||||
self.assertEqual(provider.text(), "MyTestProviderText")
|
self.assertEqual(provider.text(), "MyTestProviderText")
|
||||||
|
self.assertEqual(provider.toolTip(), "")
|
||||||
self.assertEqual(provider.ordering(), 1)
|
self.assertEqual(provider.ordering(), 1)
|
||||||
self.assertTrue(isinstance(provider.icon(), QIcon))
|
self.assertTrue(isinstance(provider.icon(), QIcon))
|
||||||
|
|
||||||
|
# test toolTip
|
||||||
|
provider = ConcreteSourceSelectProvider2()
|
||||||
|
self.assertEqual(provider.toolTip(), "MyToolTip")
|
||||||
|
|
||||||
def _testRegistry(self, registry):
|
def _testRegistry(self, registry):
|
||||||
|
|
||||||
registry.addProvider(ConcreteSourceSelectProvider())
|
registry.addProvider(ConcreteSourceSelectProvider())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user