mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-14 00:08:51 -05:00
[bugfix] Prevent expansion of WMS connection layers when restoring the browser
This was causing unwanted connections to WMS when QGIS starts.
This commit is contained in:
parent
d9d6872434
commit
cf0ffefc1a
@ -176,7 +176,8 @@ Create new data item.
|
|||||||
NoCapabilities,
|
NoCapabilities,
|
||||||
SetCrs,
|
SetCrs,
|
||||||
Fertile,
|
Fertile,
|
||||||
Fast
|
Fast,
|
||||||
|
Collapse
|
||||||
};
|
};
|
||||||
typedef QFlags<QgsDataItem::Capability> Capabilities;
|
typedef QFlags<QgsDataItem::Capability> Capabilities;
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,11 @@ class QgsBrowserTreeView : QTreeView
|
|||||||
QgsBrowserTreeView( QWidget *parent /TransferThis/ = 0 );
|
QgsBrowserTreeView( QWidget *parent /TransferThis/ = 0 );
|
||||||
|
|
||||||
virtual void setModel( QAbstractItemModel *model );
|
virtual void setModel( QAbstractItemModel *model );
|
||||||
|
void setBrowserModel( QgsBrowserModel *model );
|
||||||
|
QgsBrowserModel *browserModel( );
|
||||||
|
%Docstring
|
||||||
|
:rtype: QgsBrowserModel
|
||||||
|
%End
|
||||||
virtual void showEvent( QShowEvent *e );
|
virtual void showEvent( QShowEvent *e );
|
||||||
virtual void hideEvent( QHideEvent *e );
|
virtual void hideEvent( QHideEvent *e );
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,8 @@ class CORE_EXPORT QgsDataItem : public QObject
|
|||||||
NoCapabilities = 0,
|
NoCapabilities = 0,
|
||||||
SetCrs = 1 << 0, //!< Can set CRS on layer or group of layers
|
SetCrs = 1 << 0, //!< Can set CRS on layer or group of layers
|
||||||
Fertile = 1 << 1, //!< Can create children. Even items without this capability may have children, but cannot create them, it means that children are created by item ancestors.
|
Fertile = 1 << 1, //!< Can create children. Even items without this capability may have children, but cannot create them, it means that children are created by item ancestors.
|
||||||
Fast = 1 << 2 //!< CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,wfs,wcs,postgres...) are considered fast because they are reading data only from QgsSettings
|
Fast = 1 << 2, //!< CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,wfs,wcs,postgres...) are considered fast because they are reading data only from QgsSettings
|
||||||
|
Collapse = 1 << 3 //!< The collapse/expand status for this items children should be ignored in order to avoid undesired network connections (wms etc.)
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS( Capabilities, Capability )
|
Q_DECLARE_FLAGS( Capabilities, Capability )
|
||||||
|
|
||||||
|
|||||||
@ -118,6 +118,7 @@ void QgsBrowserDockWidget::showEvent( QShowEvent *e )
|
|||||||
mProxyModel = new QgsBrowserTreeFilterProxyModel( this );
|
mProxyModel = new QgsBrowserTreeFilterProxyModel( this );
|
||||||
mProxyModel->setBrowserModel( mModel );
|
mProxyModel->setBrowserModel( mModel );
|
||||||
mBrowserView->setSettingsSection( objectName().toLower() ); // to distinguish 2 instances ow browser
|
mBrowserView->setSettingsSection( objectName().toLower() ); // to distinguish 2 instances ow browser
|
||||||
|
mBrowserView->setBrowserModel( mModel );
|
||||||
mBrowserView->setModel( mProxyModel );
|
mBrowserView->setModel( mProxyModel );
|
||||||
// provide a horizontal scroll bar instead of using ellipse (...) for longer items
|
// provide a horizontal scroll bar instead of using ellipse (...) for longer items
|
||||||
mBrowserView->setTextElideMode( Qt::ElideNone );
|
mBrowserView->setTextElideMode( Qt::ElideNone );
|
||||||
|
|||||||
@ -212,6 +212,8 @@ class QgsBrowserTreeFilterProxyModel : public QSortFilterProxyModel
|
|||||||
explicit QgsBrowserTreeFilterProxyModel( QObject *parent );
|
explicit QgsBrowserTreeFilterProxyModel( QObject *parent );
|
||||||
//! Set the browser model
|
//! Set the browser model
|
||||||
void setBrowserModel( QgsBrowserModel *model );
|
void setBrowserModel( QgsBrowserModel *model );
|
||||||
|
//! Get the browser model
|
||||||
|
QgsBrowserModel *browserModel( ) { return mModel; }
|
||||||
//! Set the filter syntax
|
//! Set the filter syntax
|
||||||
void setFilterSyntax( const QString &syntax );
|
void setFilterSyntax( const QString &syntax );
|
||||||
//! Set the filter
|
//! Set the filter
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
QgsBrowserTreeView::QgsBrowserTreeView( QWidget *parent )
|
QgsBrowserTreeView::QgsBrowserTreeView( QWidget *parent )
|
||||||
: QTreeView( parent )
|
: QTreeView( parent )
|
||||||
, mSettingsSection( QStringLiteral( "browser" ) )
|
, mSettingsSection( QStringLiteral( "browser" ) )
|
||||||
|
, mBrowserModel( nullptr )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +34,11 @@ void QgsBrowserTreeView::setModel( QAbstractItemModel *model )
|
|||||||
restoreState();
|
restoreState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsBrowserTreeView::setBrowserModel( QgsBrowserModel *model )
|
||||||
|
{
|
||||||
|
mBrowserModel = model;
|
||||||
|
}
|
||||||
|
|
||||||
void QgsBrowserTreeView::showEvent( QShowEvent *e )
|
void QgsBrowserTreeView::showEvent( QShowEvent *e )
|
||||||
{
|
{
|
||||||
Q_UNUSED( e );
|
Q_UNUSED( e );
|
||||||
@ -72,7 +78,24 @@ void QgsBrowserTreeView::restoreState()
|
|||||||
{
|
{
|
||||||
QModelIndex expandIndex = QgsBrowserModel::findPath( model(), path, Qt::MatchStartsWith );
|
QModelIndex expandIndex = QgsBrowserModel::findPath( model(), path, Qt::MatchStartsWith );
|
||||||
if ( expandIndex.isValid() )
|
if ( expandIndex.isValid() )
|
||||||
|
{
|
||||||
|
QModelIndex modelIndex = browserModel()->findPath( path, Qt::MatchExactly );
|
||||||
|
if ( modelIndex.isValid() )
|
||||||
|
{
|
||||||
|
QgsDataItem *ptr = browserModel()->dataItem( modelIndex );
|
||||||
|
if ( ptr && ( ptr->capabilities2() & QgsDataItem::Capability::Collapse ) )
|
||||||
|
{
|
||||||
|
QgsDebugMsgLevel( "do not expand index for path " + path, 4 );
|
||||||
|
QModelIndex parentIndex = model()->parent( expandIndex );
|
||||||
|
if ( parentIndex.isValid() )
|
||||||
|
expandIndexSet.insert( parentIndex );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
expandIndexSet.insert( expandIndex );
|
expandIndexSet.insert( expandIndex );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QgsDebugMsgLevel( "index for path " + path + " not found", 4 );
|
QgsDebugMsgLevel( "index for path " + path + " not found", 4 );
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#include "qgis.h"
|
#include "qgis.h"
|
||||||
#include "qgis_gui.h"
|
#include "qgis_gui.h"
|
||||||
|
|
||||||
//class QgsBrowserModel;
|
class QgsBrowserModel;
|
||||||
|
|
||||||
/** \ingroup gui
|
/** \ingroup gui
|
||||||
* The QgsBrowserTreeView class extends QTreeView with save/restore tree state functionality.
|
* The QgsBrowserTreeView class extends QTreeView with save/restore tree state functionality.
|
||||||
@ -35,6 +35,8 @@ class GUI_EXPORT QgsBrowserTreeView : public QTreeView
|
|||||||
QgsBrowserTreeView( QWidget *parent SIP_TRANSFERTHIS = 0 );
|
QgsBrowserTreeView( QWidget *parent SIP_TRANSFERTHIS = 0 );
|
||||||
|
|
||||||
virtual void setModel( QAbstractItemModel *model ) override;
|
virtual void setModel( QAbstractItemModel *model ) override;
|
||||||
|
void setBrowserModel( QgsBrowserModel *model );
|
||||||
|
QgsBrowserModel *browserModel( ) { return mBrowserModel; }
|
||||||
virtual void showEvent( QShowEvent *e ) override;
|
virtual void showEvent( QShowEvent *e ) override;
|
||||||
virtual void hideEvent( QHideEvent *e ) override;
|
virtual void hideEvent( QHideEvent *e ) override;
|
||||||
|
|
||||||
@ -64,6 +66,7 @@ class GUI_EXPORT QgsBrowserTreeView : public QTreeView
|
|||||||
|
|
||||||
// returns true if expanded from root to item
|
// returns true if expanded from root to item
|
||||||
bool treeExpanded( const QModelIndex &index );
|
bool treeExpanded( const QModelIndex &index );
|
||||||
|
QgsBrowserModel *mBrowserModel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QGSBROWSERTREEVIEW_H
|
#endif // QGSBROWSERTREEVIEW_H
|
||||||
|
|||||||
@ -35,6 +35,7 @@ QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem *parent, QString name, Q
|
|||||||
, mCapabilitiesDownload( nullptr )
|
, mCapabilitiesDownload( nullptr )
|
||||||
{
|
{
|
||||||
mIconName = QStringLiteral( "mIconConnect.png" );
|
mIconName = QStringLiteral( "mIconConnect.png" );
|
||||||
|
mCapabilities |= Collapse;
|
||||||
mCapabilitiesDownload = new QgsWmsCapabilitiesDownload( false );
|
mCapabilitiesDownload = new QgsWmsCapabilitiesDownload( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user