From 91a98902a10d20e6cf12fe370cc65fe3dde7d428 Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Thu, 14 Sep 2017 14:08:59 +0200 Subject: [PATCH 1/3] Adds connectionsChanged signal to iface This is meant to be used by plugins (DBManager is the first candidate) to notify the application that the GUI elements that handle connections needs to be updated (i.e. the data source manager dialog and the browsers) --- python/gui/qgisinterface.sip | 9 +++++++++ src/app/qgisapp.cpp | 2 ++ src/gui/qgisinterface.h | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index ce148fe136f..35a85cc8736 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -1256,6 +1256,15 @@ Get timeout for timed messages: default of 5 seconds \note added in version 2.7 %End + + void connectionsChanged(); +%Docstring + Emitted when connections have changed, this signal is forwarded + to the GUI elements that needs to be updated (i.e. the source + select dialogs and the browser widgets) +.. versionadded:: 3.0 +%End + }; /************************************************************************ diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index f24080d14b9..be272b7b045 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -934,6 +934,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh mInternalClipboard = new QgsClipboard; // create clipboard connect( mInternalClipboard, &QgsClipboard::changed, this, &QgisApp::clipboardChanged ); mQgisInterface = new QgisAppInterface( this ); // create the interfce + // Forward signal + connect( mQgisInterface, &QgisInterface::connectionsChanged, this, &QgisApp::connectionsChanged ); #ifdef Q_OS_MAC // action for Window menu (create before generating WindowTitleChange event)) diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index 171cb5f68cc..0f637d6798d 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -796,6 +796,15 @@ class GUI_EXPORT QgisInterface : public QObject * added in version 2.7 */ void layerSavedAs( QgsMapLayer *l, const QString &path ); + + /** + * Emitted when connections have changed, this signal is forwarded + * to the GUI elements that needs to be updated (i.e. the source + * select dialogs and the browser widgets) + * \since QGIS 3.0 + */ + void connectionsChanged(); + }; Q_NOWARN_DEPRECATED_POP From c1f765aadb542ac5aab57b233a3917249fd31e6f Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Fri, 15 Sep 2017 08:09:23 +0200 Subject: [PATCH 2/3] Add reloadConnections to the app and expose to iface --- python/gui/qgisinterface.sip | 17 +++++++++-------- src/app/qgisapp.cpp | 9 ++++++--- src/app/qgisapp.h | 7 ++++++- src/app/qgisappinterface.cpp | 5 +++++ src/app/qgisappinterface.h | 8 ++++++++ src/gui/qgisinterface.h | 17 +++++++++-------- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index 35a85cc8736..73b00e56ac3 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -155,6 +155,15 @@ Add a project virtual void newProject( bool promptToSaveFlag = false ) = 0; %Docstring Start a blank project +%End + + virtual void reloadConnections( ) = 0; +%Docstring + Triggered when connections have changed. + This calls reloadConnections in the main application and triggers a signal that is + forwarder to the GUI elements that needs to be updated (i.e. the source + select dialogs and the browser widgets) +.. versionadded:: 3.0 %End virtual QgsMapLayer *activeLayer() = 0; @@ -1257,14 +1266,6 @@ Get timeout for timed messages: default of 5 seconds added in version 2.7 %End - void connectionsChanged(); -%Docstring - Emitted when connections have changed, this signal is forwarded - to the GUI elements that needs to be updated (i.e. the source - select dialogs and the browser widgets) -.. versionadded:: 3.0 -%End - }; /************************************************************************ diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index be272b7b045..20d73949b40 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -933,9 +933,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh mInternalClipboard = new QgsClipboard; // create clipboard connect( mInternalClipboard, &QgsClipboard::changed, this, &QgisApp::clipboardChanged ); - mQgisInterface = new QgisAppInterface( this ); // create the interfce - // Forward signal - connect( mQgisInterface, &QgisInterface::connectionsChanged, this, &QgisApp::connectionsChanged ); + mQgisInterface = new QgisAppInterface( this ); // create the interface #ifdef Q_OS_MAC // action for Window menu (create before generating WindowTitleChange event)) @@ -9668,6 +9666,11 @@ bool QgisApp::setActiveLayer( QgsMapLayer *layer ) return true; } +void QgisApp::reloadConnections() +{ + emit( connectionsChanged( ) ); +} + QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) { diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index b2c24085fe4..84958ed9ed1 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -792,7 +792,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow /** - * \brief dataSourceManager Open the DataSourceManager dialog/dock + * \brief dataSourceManager Open the DataSourceManager dialog * \param pageName the page name, usually the provider name or "browser" (for the browser panel) * or "ogr" (vector layers) or "raster" (raster layers) */ @@ -858,6 +858,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //! set the active layer bool setActiveLayer( QgsMapLayer * ); + /** Reload connections emitting the connectionsChanged signal + * \since QGIS 3.0 + */ + void reloadConnections(); + protected: //! Handle state changes (WindowTitleChange) diff --git a/src/app/qgisappinterface.cpp b/src/app/qgisappinterface.cpp index 38c1c63c7d8..7165924320f 100644 --- a/src/app/qgisappinterface.cpp +++ b/src/app/qgisappinterface.cpp @@ -171,6 +171,11 @@ void QgisAppInterface::newProject( bool promptToSaveFlag ) qgis->fileNew( promptToSaveFlag ); } +void QgisAppInterface::reloadConnections() +{ + qgis->reloadConnections( ); +} + QgsMapLayer *QgisAppInterface::activeLayer() { return qgis->activeLayer(); diff --git a/src/app/qgisappinterface.h b/src/app/qgisappinterface.h index ae6225b36cb..d7abb5cf506 100644 --- a/src/app/qgisappinterface.h +++ b/src/app/qgisappinterface.h @@ -81,6 +81,14 @@ class APP_EXPORT QgisAppInterface : public QgisInterface //! Start a new blank project void newProject( bool promptToSaveFlag = false ) override; + /** + * Triggered by plugins when connections have changed. + * This is forwarded to the GUI elements that needs to be updated (i.e. the source + * select dialogs and the browser widgets) + * \since QGIS 3.0 + */ + void reloadConnections( ) override; + //! Get pointer to the active layer (layer selected in the legend) QgsMapLayer *activeLayer() override; diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index 0f637d6798d..ba18725dda4 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -165,6 +165,15 @@ class GUI_EXPORT QgisInterface : public QObject //! Start a blank project virtual void newProject( bool promptToSaveFlag = false ) = 0; + /** + * Triggered when connections have changed. + * This calls reloadConnections in the main application and triggers a signal that is + * forwarder to the GUI elements that needs to be updated (i.e. the source + * select dialogs and the browser widgets) + * \since QGIS 3.0 + */ + virtual void reloadConnections( ) = 0; + //! Get pointer to the active layer (layer selected in the legend) virtual QgsMapLayer *activeLayer() = 0; @@ -797,14 +806,6 @@ class GUI_EXPORT QgisInterface : public QObject */ void layerSavedAs( QgsMapLayer *l, const QString &path ); - /** - * Emitted when connections have changed, this signal is forwarded - * to the GUI elements that needs to be updated (i.e. the source - * select dialogs and the browser widgets) - * \since QGIS 3.0 - */ - void connectionsChanged(); - }; Q_NOWARN_DEPRECATED_POP From a13aa96b6ae7374cb8f6f3e94e330e4a55c3ef0c Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Fri, 15 Sep 2017 08:18:43 +0200 Subject: [PATCH 3/3] Typo forwarder->forwarded --- python/gui/qgisinterface.sip | 2 +- src/gui/qgisinterface.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/gui/qgisinterface.sip b/python/gui/qgisinterface.sip index 73b00e56ac3..1ac30a40de4 100644 --- a/python/gui/qgisinterface.sip +++ b/python/gui/qgisinterface.sip @@ -161,7 +161,7 @@ Start a blank project %Docstring Triggered when connections have changed. This calls reloadConnections in the main application and triggers a signal that is - forwarder to the GUI elements that needs to be updated (i.e. the source + forwarded to the GUI elements that needs to be updated (i.e. the source select dialogs and the browser widgets) .. versionadded:: 3.0 %End diff --git a/src/gui/qgisinterface.h b/src/gui/qgisinterface.h index ba18725dda4..040aadc832d 100644 --- a/src/gui/qgisinterface.h +++ b/src/gui/qgisinterface.h @@ -168,7 +168,7 @@ class GUI_EXPORT QgisInterface : public QObject /** * Triggered when connections have changed. * This calls reloadConnections in the main application and triggers a signal that is - * forwarder to the GUI elements that needs to be updated (i.e. the source + * forwarded to the GUI elements that needs to be updated (i.e. the source * select dialogs and the browser widgets) * \since QGIS 3.0 */