Skip to content

Commit

Permalink
Merge pull request #5194 from boundlessgeo/iface_conn_changed
Browse files Browse the repository at this point in the history
Adds connectionsChanged signal to iface
  • Loading branch information
elpaso committed Sep 15, 2017
2 parents c5ae3a0 + a13aa96 commit ea28c2d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
10 changes: 10 additions & 0 deletions python/gui/qgisinterface.sip
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ Add a project
virtual void newProject( bool promptToSaveFlag = false ) = 0; virtual void newProject( bool promptToSaveFlag = false ) = 0;
%Docstring %Docstring
Start a blank project 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
forwarded to the GUI elements that needs to be updated (i.e. the source
select dialogs and the browser widgets)
.. versionadded:: 3.0
%End %End


virtual QgsMapLayer *activeLayer() = 0; virtual QgsMapLayer *activeLayer() = 0;
Expand Down Expand Up @@ -1256,6 +1265,7 @@ Get timeout for timed messages: default of 5 seconds
\note \note
added in version 2.7 added in version 2.7
%End %End

}; };


/************************************************************************ /************************************************************************
Expand Down
7 changes: 6 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh


mInternalClipboard = new QgsClipboard; // create clipboard mInternalClipboard = new QgsClipboard; // create clipboard
connect( mInternalClipboard, &QgsClipboard::changed, this, &QgisApp::clipboardChanged ); connect( mInternalClipboard, &QgsClipboard::changed, this, &QgisApp::clipboardChanged );
mQgisInterface = new QgisAppInterface( this ); // create the interfce mQgisInterface = new QgisAppInterface( this ); // create the interface


#ifdef Q_OS_MAC #ifdef Q_OS_MAC
// action for Window menu (create before generating WindowTitleChange event)) // action for Window menu (create before generating WindowTitleChange event))
Expand Down Expand Up @@ -9666,6 +9666,11 @@ bool QgisApp::setActiveLayer( QgsMapLayer *layer )
return true; return true;
} }


void QgisApp::reloadConnections()
{
emit( connectionsChanged( ) );
}



QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey ) QgsVectorLayer *QgisApp::addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey )
{ {
Expand Down
7 changes: 6 additions & 1 deletion src/app/qgisapp.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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) * \param pageName the page name, usually the provider name or "browser" (for the browser panel)
* or "ogr" (vector layers) or "raster" (raster layers) * or "ogr" (vector layers) or "raster" (raster layers)
*/ */
Expand Down Expand Up @@ -858,6 +858,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! set the active layer //! set the active layer
bool setActiveLayer( QgsMapLayer * ); bool setActiveLayer( QgsMapLayer * );


/** Reload connections emitting the connectionsChanged signal
* \since QGIS 3.0
*/
void reloadConnections();

protected: protected:


//! Handle state changes (WindowTitleChange) //! Handle state changes (WindowTitleChange)
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgisappinterface.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ void QgisAppInterface::newProject( bool promptToSaveFlag )
qgis->fileNew( promptToSaveFlag ); qgis->fileNew( promptToSaveFlag );
} }


void QgisAppInterface::reloadConnections()
{
qgis->reloadConnections( );
}

QgsMapLayer *QgisAppInterface::activeLayer() QgsMapLayer *QgisAppInterface::activeLayer()
{ {
return qgis->activeLayer(); return qgis->activeLayer();
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgisappinterface.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
//! Start a new blank project //! Start a new blank project
void newProject( bool promptToSaveFlag = false ) override; 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) //! Get pointer to the active layer (layer selected in the legend)
QgsMapLayer *activeLayer() override; QgsMapLayer *activeLayer() override;


Expand Down
10 changes: 10 additions & 0 deletions src/gui/qgisinterface.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ class GUI_EXPORT QgisInterface : public QObject
//! Start a blank project //! Start a blank project
virtual void newProject( bool promptToSaveFlag = false ) = 0; 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
* forwarded 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) //! Get pointer to the active layer (layer selected in the legend)
virtual QgsMapLayer *activeLayer() = 0; virtual QgsMapLayer *activeLayer() = 0;


Expand Down Expand Up @@ -796,6 +805,7 @@ class GUI_EXPORT QgisInterface : public QObject
* added in version 2.7 * added in version 2.7
*/ */
void layerSavedAs( QgsMapLayer *l, const QString &path ); void layerSavedAs( QgsMapLayer *l, const QString &path );

}; };
Q_NOWARN_DEPRECATED_POP Q_NOWARN_DEPRECATED_POP


Expand Down

0 comments on commit ea28c2d

Please sign in to comment.