Skip to content

Commit

Permalink
Browser: removed redundant refresh signals
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Sep 12, 2017
1 parent 6f0950f commit 22bd2a3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions python/core/qgsbrowsermodel.sip
Expand Up @@ -183,9 +183,9 @@ Returns true if the model has been initialized
:rtype: bool
%End

void init();
void initialize();
%Docstring
Delayied initialization
Delayied initialization, needed because the provider registry must be already populated
%End

protected:
Expand Down
3 changes: 2 additions & 1 deletion python/gui/qgsbrowserdockwidget.sip
Expand Up @@ -21,10 +21,11 @@ class QgsBrowserDockWidget : QgsDockWidget
%End
public:

explicit QgsBrowserDockWidget( const QString &name, QgsBrowserModel *model, QWidget *parent /TransferThis/ = 0 );
explicit QgsBrowserDockWidget( const QString &name, QgsBrowserModel *browserModel, QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsBrowserDockWidget
\param name name of the widget
\param browserModel instance of the (shared) browser model
\param parent parent widget
%End
~QgsBrowserDockWidget();
Expand Down
5 changes: 2 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -873,6 +873,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget );
mBrowserWidget->hide();
connect( this, &QgisApp::newProject, mBrowserWidget, &QgsBrowserDockWidget::updateProjectHome );
// Only connect the first widget: the model is shared, there is no need to refresh multiple times.
connect( this, &QgisApp::connectionsChanged, mBrowserWidget, &QgsBrowserDockWidget::refresh );
connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, &QgisApp::connectionsChanged );
connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, &QgisApp::openFile );
Expand All @@ -884,7 +885,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mBrowserWidget2->hide();
connect( this, &QgisApp::newProject, mBrowserWidget2, &QgsBrowserDockWidget::updateProjectHome );
connect( mBrowserWidget2, &QgsBrowserDockWidget::connectionsChanged, this, &QgisApp::connectionsChanged );
connect( this, &QgisApp::connectionsChanged, mBrowserWidget2, &QgsBrowserDockWidget::refresh );
connect( mBrowserWidget2, &QgsBrowserDockWidget::openFile, this, &QgisApp::openFile );
connect( mBrowserWidget2, &QgsBrowserDockWidget::handleDropUriList, this, &QgisApp::handleDropUriList );

Expand Down Expand Up @@ -1512,8 +1512,7 @@ void QgisApp::dataSourceManager( const QString &pageName )
if ( ! mDataSourceManagerDialog )
{
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( mBrowserModel, this, mapCanvas() );
// Forward signals to this
connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh );
// Forward signals to this. No need to connect refresh: the browser model is shared
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::connectionsChanged, this, &QgisApp::connectionsChanged );
connect( mDataSourceManagerDialog, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this, SLOT( addRasterLayer( QString const &, QString const &, QString const & ) ) );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsbrowsermodel.cpp
Expand Up @@ -169,7 +169,7 @@ void QgsBrowserModel::removeRootItems()
mRootItems.clear();
}

void QgsBrowserModel::init()
void QgsBrowserModel::initialize()
{
if ( ! mInitialized )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsbrowsermodel.h
Expand Up @@ -170,8 +170,8 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
//! Returns true if the model has been initialized
bool initialized( ) { return mInitialized; }

//! Delayied initialization
void init();
//! Delayied initialization, needed because the provider registry must be already populated
void initialize();

protected:
//! Populates the model
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsbrowserdockwidget.cpp
Expand Up @@ -38,9 +38,9 @@

#include <QDragEnterEvent>

QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserModel *model, QWidget *parent )
QgsBrowserDockWidget::QgsBrowserDockWidget( const QString &name, QgsBrowserModel *browserModel, QWidget *parent )
: QgsDockWidget( parent )
, mModel( model )
, mModel( browserModel )
, mProxyModel( nullptr )
, mPropertiesWidgetEnabled( false )
, mPropertiesWidgetHeight( 0 )
Expand Down Expand Up @@ -114,7 +114,7 @@ void QgsBrowserDockWidget::showEvent( QShowEvent *e )
// delayed initialization of the model
if ( !mModel->initialized( ) )
{
mModel->init();
mModel->initialize();
}
if ( ! mProxyModel )
{
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsbrowserdockwidget.h
Expand Up @@ -47,9 +47,10 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBro
/**
* Constructor for QgsBrowserDockWidget
* \param name name of the widget
* \param browserModel instance of the (shared) browser model
* \param parent parent widget
*/
explicit QgsBrowserDockWidget( const QString &name, QgsBrowserModel *model, QWidget *parent SIP_TRANSFERTHIS = nullptr );
explicit QgsBrowserDockWidget( const QString &name, QgsBrowserModel *browserModel, QWidget *parent SIP_TRANSFERTHIS = nullptr );
~QgsBrowserDockWidget();
//! Add directory to favorites
void addFavoriteDirectory( const QString &favDir );
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsdatasourcemanagerdialog.h
Expand Up @@ -49,6 +49,7 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
public:

/** QgsDataSourceManagerDialog constructor
* \param browserModel instance of the (shared) browser model
* \param parent the object
* \param canvas a pointer to the map canvas
* \param fl window flags
Expand Down

0 comments on commit 22bd2a3

Please sign in to comment.