Skip to content

Commit c1f765a

Browse files
committed
Add reloadConnections to the app and expose to iface
1 parent 91a9890 commit c1f765a

File tree

6 files changed

+43
-20
lines changed

6 files changed

+43
-20
lines changed

python/gui/qgisinterface.sip

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ Add a project
155155
virtual void newProject( bool promptToSaveFlag = false ) = 0;
156156
%Docstring
157157
Start a blank project
158+
%End
159+
160+
virtual void reloadConnections( ) = 0;
161+
%Docstring
162+
Triggered when connections have changed.
163+
This calls reloadConnections in the main application and triggers a signal that is
164+
forwarder to the GUI elements that needs to be updated (i.e. the source
165+
select dialogs and the browser widgets)
166+
.. versionadded:: 3.0
158167
%End
159168

160169
virtual QgsMapLayer *activeLayer() = 0;
@@ -1257,14 +1266,6 @@ Get timeout for timed messages: default of 5 seconds
12571266
added in version 2.7
12581267
%End
12591268

1260-
void connectionsChanged();
1261-
%Docstring
1262-
Emitted when connections have changed, this signal is forwarded
1263-
to the GUI elements that needs to be updated (i.e. the source
1264-
select dialogs and the browser widgets)
1265-
.. versionadded:: 3.0
1266-
%End
1267-
12681269
};
12691270

12701271
/************************************************************************

src/app/qgisapp.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -933,9 +933,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
933933

934934
mInternalClipboard = new QgsClipboard; // create clipboard
935935
connect( mInternalClipboard, &QgsClipboard::changed, this, &QgisApp::clipboardChanged );
936-
mQgisInterface = new QgisAppInterface( this ); // create the interfce
937-
// Forward signal
938-
connect( mQgisInterface, &QgisInterface::connectionsChanged, this, &QgisApp::connectionsChanged );
936+
mQgisInterface = new QgisAppInterface( this ); // create the interface
939937

940938
#ifdef Q_OS_MAC
941939
// action for Window menu (create before generating WindowTitleChange event))
@@ -9668,6 +9666,11 @@ bool QgisApp::setActiveLayer( QgsMapLayer *layer )
96689666
return true;
96699667
}
96709668

9669+
void QgisApp::reloadConnections()
9670+
{
9671+
emit( connectionsChanged( ) );
9672+
}
9673+
96719674

96729675
QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey )
96739676
{

src/app/qgisapp.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
792792

793793

794794
/**
795-
* \brief dataSourceManager Open the DataSourceManager dialog/dock
795+
* \brief dataSourceManager Open the DataSourceManager dialog
796796
* \param pageName the page name, usually the provider name or "browser" (for the browser panel)
797797
* or "ogr" (vector layers) or "raster" (raster layers)
798798
*/
@@ -858,6 +858,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
858858
//! set the active layer
859859
bool setActiveLayer( QgsMapLayer * );
860860

861+
/** Reload connections emitting the connectionsChanged signal
862+
* \since QGIS 3.0
863+
*/
864+
void reloadConnections();
865+
861866
protected:
862867

863868
//! Handle state changes (WindowTitleChange)

src/app/qgisappinterface.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ void QgisAppInterface::newProject( bool promptToSaveFlag )
171171
qgis->fileNew( promptToSaveFlag );
172172
}
173173

174+
void QgisAppInterface::reloadConnections()
175+
{
176+
qgis->reloadConnections( );
177+
}
178+
174179
QgsMapLayer *QgisAppInterface::activeLayer()
175180
{
176181
return qgis->activeLayer();

src/app/qgisappinterface.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
8181
//! Start a new blank project
8282
void newProject( bool promptToSaveFlag = false ) override;
8383

84+
/**
85+
* Triggered by plugins when connections have changed.
86+
* This is forwarded to the GUI elements that needs to be updated (i.e. the source
87+
* select dialogs and the browser widgets)
88+
* \since QGIS 3.0
89+
*/
90+
void reloadConnections( ) override;
91+
8492
//! Get pointer to the active layer (layer selected in the legend)
8593
QgsMapLayer *activeLayer() override;
8694

src/gui/qgisinterface.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ class GUI_EXPORT QgisInterface : public QObject
165165
//! Start a blank project
166166
virtual void newProject( bool promptToSaveFlag = false ) = 0;
167167

168+
/**
169+
* Triggered when connections have changed.
170+
* This calls reloadConnections in the main application and triggers a signal that is
171+
* forwarder to the GUI elements that needs to be updated (i.e. the source
172+
* select dialogs and the browser widgets)
173+
* \since QGIS 3.0
174+
*/
175+
virtual void reloadConnections( ) = 0;
176+
168177
//! Get pointer to the active layer (layer selected in the legend)
169178
virtual QgsMapLayer *activeLayer() = 0;
170179

@@ -797,14 +806,6 @@ class GUI_EXPORT QgisInterface : public QObject
797806
*/
798807
void layerSavedAs( QgsMapLayer *l, const QString &path );
799808

800-
/**
801-
* Emitted when connections have changed, this signal is forwarded
802-
* to the GUI elements that needs to be updated (i.e. the source
803-
* select dialogs and the browser widgets)
804-
* \since QGIS 3.0
805-
*/
806-
void connectionsChanged();
807-
808809
};
809810
Q_NOWARN_DEPRECATED_POP
810811

0 commit comments

Comments
 (0)