Skip to content
Permalink
Browse files

Merge pull request #4737 from boundlessgeo/browser-sync

[bugfix] Sync the browser connections when changed from the select dialogs
  • Loading branch information
elpaso committed Jul 18, 2017
2 parents 6acd326 + 8544309 commit 0b263f9ac634422b9aafc0c44d73a75243a8a054
Showing with 662 additions and 304 deletions.
  1. +4 −0 python/core/qgsbrowsermodel.sip
  2. +9 −0 python/core/qgsdataitem.sip
  3. +1 −1 python/gui/gui_auto.sip
  4. +109 −0 python/gui/qgsabstractdatasourcewidget.sip
  5. +5 −1 python/gui/qgsbrowserdockwidget.sip
  6. +10 −11 python/gui/qgsowssourceselect.sip
  7. +7 −2 src/app/qgisapp.cpp
  8. +6 −0 src/app/qgisapp.h
  9. +8 −0 src/core/qgsbrowsermodel.cpp
  10. +3 −0 src/core/qgsbrowsermodel.h
  11. +6 −0 src/core/qgsdataitem.cpp
  12. +8 −0 src/core/qgsdataitem.h
  13. +4 −3 src/gui/CMakeLists.txt
  14. +42 −0 src/gui/qgsabstractdatasourcewidget.cpp
  15. +102 −0 src/gui/qgsabstractdatasourcewidget.h
  16. +8 −2 src/gui/qgsbrowserdockwidget.cpp
  17. +3 −1 src/gui/qgsbrowserdockwidget.h
  18. +1 −1 src/gui/qgsbrowserdockwidget_p.h
  19. +38 −34 src/gui/qgsdatasourcemanagerdialog.cpp
  20. +21 −12 src/gui/qgsdatasourcemanagerdialog.h
  21. +8 −4 src/gui/qgsowssourceselect.cpp
  22. +8 −13 src/gui/qgsowssourceselect.h
  23. +4 −0 src/providers/arcgisrest/CMakeLists.txt
  24. +1 −1 src/providers/arcgisrest/qgsafsdataitems.cpp
  25. +1 −1 src/providers/arcgisrest/qgsafssourceselect.cpp
  26. +2 −2 src/providers/arcgisrest/qgsafssourceselect.h
  27. +4 −4 src/providers/arcgisrest/qgsamsdataitems.cpp
  28. +1 −1 src/providers/arcgisrest/qgsamssourceselect.cpp
  29. +2 −7 src/providers/arcgisrest/qgsamssourceselect.h
  30. +58 −52 src/{gui/qgssourceselectdialog.cpp → providers/arcgisrest/qgsarcgisservicesourceselect.cpp}
  31. +26 −16 src/{gui/qgssourceselectdialog.h → providers/arcgisrest/qgsarcgisservicesourceselect.h}
  32. +3 −3 src/providers/db2/qgsdb2dataitems.cpp
  33. +9 −5 src/providers/db2/qgsdb2sourceselect.cpp
  34. +5 −9 src/providers/db2/qgsdb2sourceselect.h
  35. +4 −4 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  36. +3 −3 src/providers/delimitedtext/qgsdelimitedtextsourceselect.h
  37. +3 −3 src/providers/mssql/qgsmssqldataitems.cpp
  38. +9 −5 src/providers/mssql/qgsmssqlsourceselect.cpp
  39. +7 −8 src/providers/mssql/qgsmssqlsourceselect.h
  40. +3 −3 src/providers/oracle/qgsoracledataitems.cpp
  41. +2 −3 src/providers/oracle/qgsoraclesourceselect.cpp
  42. +3 −6 src/providers/oracle/qgsoraclesourceselect.h
  43. +3 −3 src/providers/ows/qgsowsdataitems.cpp
  44. +9 −5 src/providers/postgres/qgspgsourceselect.cpp
  45. +4 −6 src/providers/postgres/qgspgsourceselect.h
  46. +8 −3 src/providers/postgres/qgspostgresdataitems.cpp
  47. +2 −2 src/providers/spatialite/qgsspatialitedataitems.cpp
  48. +8 −4 src/providers/spatialite/qgsspatialitesourceselect.cpp
  49. +6 −9 src/providers/spatialite/qgsspatialitesourceselect.h
  50. +9 −4 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  51. +7 −3 src/providers/virtual/qgsvirtuallayersourceselect.h
  52. +3 −3 src/providers/wcs/qgswcsdataitems.cpp
  53. +3 −3 src/providers/wfs/qgswfsdataitems.cpp
  54. +9 −5 src/providers/wfs/qgswfssourceselect.cpp
  55. +8 −8 src/providers/wfs/qgswfssourceselect.h
  56. +3 −9 src/providers/wms/qgswmsdataitems.cpp
  57. +1 −1 src/providers/wms/qgswmsdataitems.h
  58. +11 −4 src/providers/wms/qgswmssourceselect.cpp
  59. +5 −9 src/providers/wms/qgswmssourceselect.h
  60. +2 −2 src/ui/{qgssourceselectdialogbase.ui → qgsarcgisservicesourceselectbase.ui}
@@ -138,6 +138,10 @@ Refresh item children
void stateChanged( const QModelIndex &index, QgsDataItem::State oldState );
%Docstring
Emitted when item children fetch was finished
%End
void connectionsChanged( );
%Docstring
notify the provider dialogs of a changed connection
%End

public slots:
@@ -304,6 +304,11 @@ Remove children recursively and set as not populated. This is used when refreshi

virtual void refresh();

virtual void refreshConnections();
%Docstring
Refresh connections: update GUI and emit signal
%End

virtual void childrenCreated();

signals:
@@ -313,6 +318,10 @@ Remove children recursively and set as not populated. This is used when refreshi
void endRemoveItems();
void dataChanged( QgsDataItem *item );
void stateChanged( QgsDataItem *item, QgsDataItem::State oldState );
void connectionsChanged( );
%Docstring
open browsers
%End

protected slots:

@@ -21,6 +21,7 @@
%Include qgsbrowserdockwidget.sip
%Include qgsvertexmarker.sip
%Include qgsfiledownloader.sip
%Include qgsabstractdatasourcewidget.sip
%Include attributetable/qgsfeaturemodel.sip
%Include auth/qgsauthauthoritieseditor.sip
%Include auth/qgsauthcertificateinfo.sip
@@ -158,7 +159,6 @@
%Include qgsoptionswidgetfactory.sip
%Include qgsorderbydialog.sip
%Include qgsowssourceselect.sip
%Include qgssourceselectdialog.sip
%Include qgspanelwidget.sip
%Include qgspanelwidgetstack.sip
%Include qgspasswordlineedit.sip
@@ -0,0 +1,109 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsabstractdatasourcewidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsAbstractDataSourceWidget : QDialog
{
%Docstring
Abstract base Data Source Widget to create connections and add layers
This class provides common functionality and the interface for all
source select dialogs used by data providers to configure data sources
and add layers.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsabstractdatasourcewidget.h"
%End
public:

~QgsAbstractDataSourceWidget( );
%Docstring
Destructor
%End

void setMapCanvas( const QgsMapCanvas *mapCanvas );
%Docstring
Store a pointer to the map canvas to retrieve extent and CRS
Used to select an appropriate CRS and possibly to retrieve data only in the current extent
%End


public slots:

virtual void refresh( );
%Docstring
Triggered when the provider's connections need to be refreshed
The default implementation does nothing
%End

signals:

void connectionsChanged();
%Docstring
Emitted when the provider's connections have changed
This signal is normally forwarded the app and used to refresh browser items
%End

void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
%Docstring
Emitted when a DB layer has been selected for addition
%End

void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
%Docstring
Emitted when a raster layer has been selected for addition
%End

void addVectorLayer( const QString &uri, const QString &layerName );
%Docstring
Emitted when a vector layer has been selected for addition
%End

void progress( int, int );
%Docstring
Emitted when a progress dialog is shown by the provider dialog
%End

void progressMessage( QString message );
%Docstring
Emitted when a progress dialog is shown by the provider dialog
%End

protected:

QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
%Docstring
Constructor
%End

QgsProviderRegistry::WidgetMode widgetMode( ) const;
%Docstring
Return the widget mode
:rtype: QgsProviderRegistry.WidgetMode
%End

const QgsMapCanvas *mapCanvas( ) const;
%Docstring
Return the map canvas (can be null)
:rtype: QgsMapCanvas
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgsabstractdatasourcewidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -105,7 +105,7 @@ Toggle fast scan

void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
%Docstring
Selection hass changed
Selection has changed
%End
void splitterMoved();
%Docstring
@@ -120,6 +120,10 @@ Emitted when a file needs to be opened
void handleDropUriList( const QgsMimeDataUtils::UriList & );
%Docstring
Emitted when drop uri list needs to be handled
%End
void connectionsChanged( );
%Docstring
Connections changed in the browser
%End

protected:
@@ -11,16 +11,16 @@



class QgsOWSSourceSelect : QDialog, protected Ui::QgsOWSSourceSelectBase
class QgsOWSSourceSelect : QgsAbstractDataSourceWidget, protected Ui::QgsOWSSourceSelectBase
{
%Docstring
Dialog to create connections and add layers from WMS, WFS, WCS etc.
Dialog to create connections and add layers WCS etc.

This dialog allows the user to define and save connection information
for WMS servers, etc.

The user can then connect and add
layers from the WMS server to the map canvas.
layers from the WCS server to the map canvas.
%End

%TypeHeaderCode
@@ -42,6 +42,12 @@ Constructor

public slots:

virtual void refresh( );

%Docstring
Triggered when the provider's connections need to be refreshed
%End

void on_mNewButton_clicked();
%Docstring
Opens the create connection dialog to build a new connection
@@ -106,12 +112,6 @@ Stores the selected datasource whenerver it is changed
Add some default wms servers to the list
%End

signals:
void addRasterLayer( const QString &rasterLayerPath,
const QString &baseName,
const QString &providerKey );
void connectionsChanged();

protected:

virtual QList<QgsOWSSourceSelect::SupportedFormat> providerFormats();
@@ -198,8 +198,6 @@ Add a few example servers to the list.
%End




virtual void populateLayerList();
%Docstring
Populate the layer list.
@@ -253,6 +251,7 @@ Returns currently selected cache load control




};

/************************************************************************
@@ -248,7 +248,6 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgsshortcutsmanager.h"
#include "qgssinglebandgrayrenderer.h"
#include "qgssnappingwidget.h"
#include "qgssourceselectdialog.h"
#include "qgsstatisticalsummarydockwidget.h"
#include "qgsstatusbar.h"
#include "qgsstatusbarcoordinateswidget.h"
@@ -889,6 +888,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget );
mBrowserWidget->hide();
connect( this, &QgisApp::newProject, mBrowserWidget, &QgsBrowserDockWidget::updateProjectHome );
connect( this, &QgisApp::connectionsChanged, mBrowserWidget, &QgsBrowserDockWidget::refresh );
connect( mBrowserWidget, &QgsBrowserDockWidget::connectionsChanged, this, &QgisApp::connectionsChanged );
connect( mBrowserWidget, &QgsBrowserDockWidget::openFile, this, &QgisApp::openFile );
connect( mBrowserWidget, &QgsBrowserDockWidget::handleDropUriList, this, &QgisApp::handleDropUriList );

@@ -897,6 +898,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
addDockWidget( Qt::LeftDockWidgetArea, mBrowserWidget2 );
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 );

@@ -1605,8 +1608,10 @@ void QgisApp::dataSourceManager( QString pageName )
{
if ( ! mDataSourceManagerDialog )
{
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( mapCanvas( ), this );
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( this, mapCanvas( ) );
// Forward signals to this
connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh );
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 & ) ) );
connect( mDataSourceManagerDialog, SIGNAL( addVectorLayer( QString const &, QString const &, QString const & ) ),
@@ -1494,6 +1494,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

signals:

/**
* Emitted when a connection has been added/removed or changed by the provider
* selection dialogs
*/
void connectionsChanged( );

/** Emitted when a key is pressed and we want non widget sublasses to be able
to pick up on this (e.g. maplayer) */
void keyPressed( QKeyEvent *e );
@@ -139,6 +139,8 @@ void QgsBrowserModel::addRootItems()
QgsDataItem *item = pr->createDataItem( QLatin1String( "" ), nullptr ); // empty path -> top level
if ( item )
{
// Forward the signal from the root items to the model (and then to the app)
connect( item, &QgsDataItem::connectionsChanged, this, &QgsBrowserModel::connectionsChanged );
QgsDebugMsgLevel( "Add new top level item : " + item->name(), 4 );
connectItem( item );
providerMap.insertMulti( capabilities, item );
@@ -411,6 +413,7 @@ void QgsBrowserModel::itemStateChanged( QgsDataItem *item, QgsDataItem::State ol
QgsDebugMsgLevel( QString( "item %1 state changed %2 -> %3" ).arg( item->path() ).arg( oldState ).arg( item->state() ), 4 );
emit stateChanged( idx, oldState );
}

void QgsBrowserModel::connectItem( QgsDataItem *item )
{
connect( item, &QgsDataItem::beginInsertItems,
@@ -425,6 +428,11 @@ void QgsBrowserModel::connectItem( QgsDataItem *item )
this, &QgsBrowserModel::itemDataChanged );
connect( item, &QgsDataItem::stateChanged,
this, &QgsBrowserModel::itemStateChanged );

// if it's a collection item, also forwards connectionsChanged
QgsDataCollectionItem *collectionItem = dynamic_cast<QgsDataCollectionItem *>( item );
if ( collectionItem )
connect( collectionItem, &QgsDataCollectionItem::connectionsChanged, this, &QgsBrowserModel::connectionsChanged );
}

QStringList QgsBrowserModel::mimeTypes() const
@@ -134,6 +134,9 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
signals:
//! Emitted when item children fetch was finished
void stateChanged( const QModelIndex &index, QgsDataItem::State oldState );
//! Connections changed in the browser, forwarded to the widget and used to
//! notify the provider dialogs of a changed connection
void connectionsChanged( );

public slots:
//! Reload the whole model
@@ -342,6 +342,12 @@ void QgsDataItem::refresh()
}
}

void QgsDataItem::refreshConnections()
{
refresh( );
emit connectionsChanged( );
}

void QgsDataItem::refresh( const QVector<QgsDataItem *> &children )
{
QgsDebugMsgLevel( "mPath = " + mPath, 2 );
@@ -283,6 +283,9 @@ class CORE_EXPORT QgsDataItem : public QObject

virtual void refresh();

//! Refresh connections: update GUI and emit signal
virtual void refreshConnections();

virtual void childrenCreated();

signals:
@@ -292,6 +295,11 @@ class CORE_EXPORT QgsDataItem : public QObject
void endRemoveItems();
void dataChanged( QgsDataItem *item );
void stateChanged( QgsDataItem *item, QgsDataItem::State oldState );
//! Emitted when the provider's connections of the child items have changed
//! This signal is normally forwarded to the app in order to refresh the connection
//! item in the provider dialogs and to refresh the connection items in the other
//! open browsers
void connectionsChanged( );

protected slots:

0 comments on commit 0b263f9

Please sign in to comment.
You can’t perform that action at this time.