Skip to content

Commit

Permalink
Rename QgsLayerStylingPanelFactory to QgsMapLayerConfigWidgetFactory
Browse files Browse the repository at this point in the history
- Move QgsMapLayerPropertiesFactory into single factory object for
  dock and properties
  • Loading branch information
NathanW2 committed Jul 6, 2016
1 parent 38e65c3 commit fdf16e3
Show file tree
Hide file tree
Showing 36 changed files with 243 additions and 455 deletions.
5 changes: 2 additions & 3 deletions python/gui/gui.sip
Expand Up @@ -105,7 +105,8 @@
%Include qgsmaplayeractionregistry.sip
%Include qgsmaplayercombobox.sip
%Include qgsmaplayermodel.sip
%Include qgsmaplayerpropertiesfactory.sip
%Include qgsmaplayerconfigwidget.sip
%Include qgsmaplayerconfigwidgetfactory.sip
%Include qgsmaplayerproxymodel.sip
%Include qgsmapmouseevent.sip
%Include qgsmapoverviewcanvas.sip
Expand All @@ -120,7 +121,6 @@
%Include qgsmaptoolpan.sip
%Include qgsmaptooltouch.sip
%Include qgsmaptoolzoom.sip
%Include qgsmapstylepanel.sip
%Include qgsmaplayerstylemanagerwidget.sip
%Include qgsmessagebar.sip
%Include qgsmessagebaritem.sip
Expand Down Expand Up @@ -164,7 +164,6 @@
%Include qgsunitselectionwidget.sip
%Include qgsuserinputdockwidget.sip
%Include qgsvariableeditorwidget.sip
%Include qgsvectorlayerpropertiespage.sip
%Include qgsvectorlayertools.sip
%Include qgsvertexmarker.sip

Expand Down
10 changes: 2 additions & 8 deletions python/gui/qgisinterface.sip
Expand Up @@ -284,19 +284,13 @@ class QgisInterface : QObject
* @note Ownership of the factory is not transferred, and the factory must
* be unregistered when plugin is unloaded.
* @see unregisterMapLayerPropertiesFactory() */
virtual void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;

/** Unregister a previously registered tab in the vector layer properties dialog.
* @note added in QGIS 2.16
* @see registerMapLayerPropertiesFactory()
*/
virtual void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;

/** Register a new tab in the layer properties dialog */
virtual void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;

/** Unregister a previously registered tab in the layer properties dialog */
virtual void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;

// @todo is this deprecated in favour of QgsContextHelp?
/** Open a url in the users browser. By default the QGIS doc directory is used
Expand Down
29 changes: 29 additions & 0 deletions python/gui/qgsmaplayerconfigwidget.sip
@@ -0,0 +1,29 @@
/** \ingroup gui
* \class QgsMapLayerConfigWidget
* \class A panel widget that can be shown in the map style dock
* \note added in QGIS 2.16
*/
class QgsMapLayerConfigWidget : public QgsPanelWidget
{
%TypeHeaderCode
#include <qgsmaplayerconfigwidget.h>
%End
public:
/**
* @brief A panel widget that can be shown in the map style dock
* @param layer The layer active in the dock.
* @param canvas The canvas object.
* @param parent The parent of the widget.
* @note The widget is created each time the panel is selected in the dock.
* Keep the loading light as possible for speed in the UI.
*/
QgsMapLayerConfigWidget(QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0);

public slots:

/**
* @brief Called when changes to the layer need to be made.
* Will be called when live update is enabled.
*/
virtual void apply() = 0;
};
48 changes: 48 additions & 0 deletions python/gui/qgsmaplayerconfigwidgetfactory.sip
@@ -0,0 +1,48 @@
/** \ingroup gui
* \class QgsMapLayerConfigWidgetFactory
* \note added in QGIS 2.16
* Factory class for creating custom map layer property pages
*/
class QgsMapLayerConfigWidgetFactory
{
%TypeHeaderCode
#include <qgsmaplayerconfigwidgetfactory.h>
%End

public:
/** Constructor */
QgsMapLayerConfigWidgetFactory();

/** Destructor */
virtual ~QgsMapLayerConfigWidgetFactory();

/**
* @brief The icon that will be shown in the UI for the panel.
* @return A QIcon for the panel icon.
*/
virtual QIcon icon() const;

/**
* @brief The title of the panel.
* @note This may or may not be shown to the user.
* @return Title of the panel
*/
virtual QString title() const;

/**
* @brief Check if the layer is supported for this widget.
* @return True if this layer is supported for this widget
*/
virtual bool supportsLayer( QgsMapLayer *layer ) const;

/**
* @brief Factory fucntion to create the widget on demand as needed by the dock.
* @note This function is called each time the panel is selected. Keep it light for better UX.
* @param layer The active layer in the dock.
* @param canvas The map canvas.
* @param dockWidget True of the widget will be shown a dock style widget.
* @param parent The parent of the widget.
* @return A new QgsMapStylePanel which is shown in the map style dock.
*/
virtual QgsMapLayerConfigWidget* createWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget* parent /TransferThis/ = 0) const = 0 /Factory/;
};
34 changes: 0 additions & 34 deletions python/gui/qgsmaplayerpropertiesfactory.sip

This file was deleted.

2 changes: 1 addition & 1 deletion python/gui/qgsmaplayerstylemanagerwidget.sip
Expand Up @@ -2,7 +2,7 @@
* @brief The QgsMapLayerStyleManagerWidget class which is used to visually manage
* the layer styles.
*/
class QgsMapLayerStyleManagerWidget : QgsLayerStylingPanel
class QgsMapLayerStyleManagerWidget : QgsMapLayerConfigWidget
{
%TypeHeaderCode
#include "qgsmaplayerstylemanagerwidget.h"
Expand Down
86 changes: 0 additions & 86 deletions python/gui/qgsmapstylepanel.sip

This file was deleted.

22 changes: 0 additions & 22 deletions python/gui/qgsvectorlayerpropertiespage.sip

This file was deleted.

2 changes: 1 addition & 1 deletion python/gui/raster/qgsrendererrasterpropertieswidget.sip
@@ -1,4 +1,4 @@
class QgsRendererRasterPropertiesWidget : QgsLayerStylingPanel
class QgsRendererRasterPropertiesWidget : QgsMapLayerConfigWidget
{
%TypeHeaderCode
#include <qgsrendererrasterpropertieswidget.h>
Expand Down
26 changes: 8 additions & 18 deletions src/app/qgisapp.cpp
Expand Up @@ -776,7 +776,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mMapStylingDock = new QgsDockWidget( this );
mMapStylingDock->setWindowTitle( tr( "Layer Styling" ) );
mMapStylingDock->setObjectName( "LayerStyling" );
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapStylePanelFactories );
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapLayerPanelFactories );
mMapStylingDock->setWidget( mMapStyleWidget );
connect( mMapStyleWidget, SIGNAL( styleChanged( QgsMapLayer* ) ), this, SLOT( updateLabelToolButtons() ) );
connect( mMapStylingDock, SIGNAL( visibilityChanged( bool ) ), mActionStyleDock, SLOT( setChecked( bool ) ) );
Expand Down Expand Up @@ -9123,28 +9123,18 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory )
#endif
}

void QgisApp::registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
void QgisApp::registerMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory )
{
mMapLayerPropertiesFactories << factory;
}

void QgisApp::unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
{
mMapLayerPropertiesFactories.removeAll( factory );
}

void QgisApp::registerMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
{
mMapStylePanelFactories << factory;
mMapLayerPanelFactories << factory;
if ( mMapStyleWidget )
mMapStyleWidget->setPageFactories( mMapStylePanelFactories );
mMapStyleWidget->setPageFactories( mMapLayerPanelFactories );
}

void QgisApp::unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
void QgisApp::unregisterMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory )
{
mMapStylePanelFactories.removeAll( factory );
mMapLayerPanelFactories.removeAll( factory );
if ( mMapStyleWidget )
mMapStyleWidget->setPageFactories( mMapStylePanelFactories );
mMapStyleWidget->setPageFactories( mMapLayerPanelFactories );
}

/** Get a pointer to the currently selected map layer */
Expand Down Expand Up @@ -11367,7 +11357,7 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
#else
QgsVectorLayerProperties *vlp = new QgsVectorLayerProperties( vlayer, this );
#endif
Q_FOREACH ( QgsMapLayerPropertiesFactory* factory, mMapLayerPropertiesFactories )
Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mMapLayerPanelFactories )
{
vlp->addPropertiesPageFactory( factory );
}
Expand Down
16 changes: 4 additions & 12 deletions src/app/qgisapp.h
Expand Up @@ -57,8 +57,7 @@ class QgsLayerTreeMapCanvasBridge;
class QgsLayerTreeView;
class QgsMapCanvas;
class QgsMapLayer;
class QgsMapLayerPropertiesFactory;
class QgsLayerStylingPanelFactory;
class QgsMapLayerConfigWidgetFactory;
class QgsMapTip;
class QgsMapTool;
class QgsMapToolAdvancedDigitizing;
Expand Down Expand Up @@ -508,16 +507,10 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void parseVersionInfo( QNetworkReply* reply, int& latestVersion, QStringList& versionInfo );

/** Register a new tab in the layer properties dialog */
void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory );
void registerMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory );

/** Unregister a previously registered tab in the layer properties dialog */
void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory );

/** Register a new tab in the layer properties dialog */
void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory );

/** Unregister a previously registered tab in the layer properties dialog */
void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory );
void unregisterMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory );

public slots:
void layerTreeViewDoubleClicked( const QModelIndex& index );
Expand Down Expand Up @@ -1779,8 +1772,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

QgsSnappingUtils* mSnappingUtils;

QList<QgsMapLayerPropertiesFactory*> mMapLayerPropertiesFactories;
QList<QgsLayerStylingPanelFactory*> mMapStylePanelFactories;
QList<QgsMapLayerConfigWidgetFactory*> mMapLayerPanelFactories;

QDateTime mProjectLastModified;

Expand Down

2 comments on commit fdf16e3

@jef-n
Copy link
Member

@jef-n jef-n commented on fdf16e3 Jul 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaks the globe plugin - what does it fix?

@NathanW2
Copy link
Member Author

@NathanW2 NathanW2 commented on fdf16e3 Jul 6, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.