Skip to content

Commit fdf16e3

Browse files
committed
Rename QgsLayerStylingPanelFactory to QgsMapLayerConfigWidgetFactory
- Move QgsMapLayerPropertiesFactory into single factory object for dock and properties
1 parent 38e65c3 commit fdf16e3

36 files changed

+243
-455
lines changed

python/gui/gui.sip

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@
105105
%Include qgsmaplayeractionregistry.sip
106106
%Include qgsmaplayercombobox.sip
107107
%Include qgsmaplayermodel.sip
108-
%Include qgsmaplayerpropertiesfactory.sip
108+
%Include qgsmaplayerconfigwidget.sip
109+
%Include qgsmaplayerconfigwidgetfactory.sip
109110
%Include qgsmaplayerproxymodel.sip
110111
%Include qgsmapmouseevent.sip
111112
%Include qgsmapoverviewcanvas.sip
@@ -120,7 +121,6 @@
120121
%Include qgsmaptoolpan.sip
121122
%Include qgsmaptooltouch.sip
122123
%Include qgsmaptoolzoom.sip
123-
%Include qgsmapstylepanel.sip
124124
%Include qgsmaplayerstylemanagerwidget.sip
125125
%Include qgsmessagebar.sip
126126
%Include qgsmessagebaritem.sip
@@ -164,7 +164,6 @@
164164
%Include qgsunitselectionwidget.sip
165165
%Include qgsuserinputdockwidget.sip
166166
%Include qgsvariableeditorwidget.sip
167-
%Include qgsvectorlayerpropertiespage.sip
168167
%Include qgsvectorlayertools.sip
169168
%Include qgsvertexmarker.sip
170169

python/gui/qgisinterface.sip

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,13 @@ class QgisInterface : QObject
284284
* @note Ownership of the factory is not transferred, and the factory must
285285
* be unregistered when plugin is unloaded.
286286
* @see unregisterMapLayerPropertiesFactory() */
287-
virtual void registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
287+
virtual void registerMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
288288

289289
/** Unregister a previously registered tab in the vector layer properties dialog.
290290
* @note added in QGIS 2.16
291291
* @see registerMapLayerPropertiesFactory()
292292
*/
293-
virtual void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;
294-
295-
/** Register a new tab in the layer properties dialog */
296-
virtual void registerMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
297-
298-
/** Unregister a previously registered tab in the layer properties dialog */
299-
virtual void unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory* factory ) = 0;
293+
virtual void unregisterMapLayerConfigWidgetFactory( QgsMapLayerConfigWidgetFactory* factory ) = 0;
300294

301295
// @todo is this deprecated in favour of QgsContextHelp?
302296
/** Open a url in the users browser. By default the QGIS doc directory is used
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/** \ingroup gui
2+
* \class QgsMapLayerConfigWidget
3+
* \class A panel widget that can be shown in the map style dock
4+
* \note added in QGIS 2.16
5+
*/
6+
class QgsMapLayerConfigWidget : public QgsPanelWidget
7+
{
8+
%TypeHeaderCode
9+
#include <qgsmaplayerconfigwidget.h>
10+
%End
11+
public:
12+
/**
13+
* @brief A panel widget that can be shown in the map style dock
14+
* @param layer The layer active in the dock.
15+
* @param canvas The canvas object.
16+
* @param parent The parent of the widget.
17+
* @note The widget is created each time the panel is selected in the dock.
18+
* Keep the loading light as possible for speed in the UI.
19+
*/
20+
QgsMapLayerConfigWidget(QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0);
21+
22+
public slots:
23+
24+
/**
25+
* @brief Called when changes to the layer need to be made.
26+
* Will be called when live update is enabled.
27+
*/
28+
virtual void apply() = 0;
29+
};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/** \ingroup gui
2+
* \class QgsMapLayerConfigWidgetFactory
3+
* \note added in QGIS 2.16
4+
* Factory class for creating custom map layer property pages
5+
*/
6+
class QgsMapLayerConfigWidgetFactory
7+
{
8+
%TypeHeaderCode
9+
#include <qgsmaplayerconfigwidgetfactory.h>
10+
%End
11+
12+
public:
13+
/** Constructor */
14+
QgsMapLayerConfigWidgetFactory();
15+
16+
/** Destructor */
17+
virtual ~QgsMapLayerConfigWidgetFactory();
18+
19+
/**
20+
* @brief The icon that will be shown in the UI for the panel.
21+
* @return A QIcon for the panel icon.
22+
*/
23+
virtual QIcon icon() const;
24+
25+
/**
26+
* @brief The title of the panel.
27+
* @note This may or may not be shown to the user.
28+
* @return Title of the panel
29+
*/
30+
virtual QString title() const;
31+
32+
/**
33+
* @brief Check if the layer is supported for this widget.
34+
* @return True if this layer is supported for this widget
35+
*/
36+
virtual bool supportsLayer( QgsMapLayer *layer ) const;
37+
38+
/**
39+
* @brief Factory fucntion to create the widget on demand as needed by the dock.
40+
* @note This function is called each time the panel is selected. Keep it light for better UX.
41+
* @param layer The active layer in the dock.
42+
* @param canvas The map canvas.
43+
* @param dockWidget True of the widget will be shown a dock style widget.
44+
* @param parent The parent of the widget.
45+
* @return A new QgsMapStylePanel which is shown in the map style dock.
46+
*/
47+
virtual QgsMapLayerConfigWidget* createWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget* parent /TransferThis/ = 0) const = 0 /Factory/;
48+
};

python/gui/qgsmaplayerpropertiesfactory.sip

Lines changed: 0 additions & 34 deletions
This file was deleted.

python/gui/qgsmaplayerstylemanagerwidget.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @brief The QgsMapLayerStyleManagerWidget class which is used to visually manage
33
* the layer styles.
44
*/
5-
class QgsMapLayerStyleManagerWidget : QgsLayerStylingPanel
5+
class QgsMapLayerStyleManagerWidget : QgsMapLayerConfigWidget
66
{
77
%TypeHeaderCode
88
#include "qgsmaplayerstylemanagerwidget.h"

python/gui/qgsmapstylepanel.sip

Lines changed: 0 additions & 86 deletions
This file was deleted.

python/gui/qgsvectorlayerpropertiespage.sip

Lines changed: 0 additions & 22 deletions
This file was deleted.

python/gui/raster/qgsrendererrasterpropertieswidget.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class QgsRendererRasterPropertiesWidget : QgsLayerStylingPanel
1+
class QgsRendererRasterPropertiesWidget : QgsMapLayerConfigWidget
22
{
33
%TypeHeaderCode
44
#include <qgsrendererrasterpropertieswidget.h>

src/app/qgisapp.cpp

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
776776
mMapStylingDock = new QgsDockWidget( this );
777777
mMapStylingDock->setWindowTitle( tr( "Layer Styling" ) );
778778
mMapStylingDock->setObjectName( "LayerStyling" );
779-
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapStylePanelFactories );
779+
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapLayerPanelFactories );
780780
mMapStylingDock->setWidget( mMapStyleWidget );
781781
connect( mMapStyleWidget, SIGNAL( styleChanged( QgsMapLayer* ) ), this, SLOT( updateLabelToolButtons() ) );
782782
connect( mMapStylingDock, SIGNAL( visibilityChanged( bool ) ), mActionStyleDock, SLOT( setChecked( bool ) ) );
@@ -9123,28 +9123,18 @@ void QgisApp::openURL( QString url, bool useQgisDocDirectory )
91239123
#endif
91249124
}
91259125

9126-
void QgisApp::registerMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
9126+
void QgisApp::registerMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory )
91279127
{
9128-
mMapLayerPropertiesFactories << factory;
9129-
}
9130-
9131-
void QgisApp::unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory )
9132-
{
9133-
mMapLayerPropertiesFactories.removeAll( factory );
9134-
}
9135-
9136-
void QgisApp::registerMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
9137-
{
9138-
mMapStylePanelFactories << factory;
9128+
mMapLayerPanelFactories << factory;
91399129
if ( mMapStyleWidget )
9140-
mMapStyleWidget->setPageFactories( mMapStylePanelFactories );
9130+
mMapStyleWidget->setPageFactories( mMapLayerPanelFactories );
91419131
}
91429132

9143-
void QgisApp::unregisterMapStylePanelFactory( QgsLayerStylingPanelFactory *factory )
9133+
void QgisApp::unregisterMapLayerPropertiesFactory( QgsMapLayerConfigWidgetFactory* factory )
91449134
{
9145-
mMapStylePanelFactories.removeAll( factory );
9135+
mMapLayerPanelFactories.removeAll( factory );
91469136
if ( mMapStyleWidget )
9147-
mMapStyleWidget->setPageFactories( mMapStylePanelFactories );
9137+
mMapStyleWidget->setPageFactories( mMapLayerPanelFactories );
91489138
}
91499139

91509140
/** Get a pointer to the currently selected map layer */
@@ -11367,7 +11357,7 @@ void QgisApp::showLayerProperties( QgsMapLayer *ml )
1136711357
#else
1136811358
QgsVectorLayerProperties *vlp = new QgsVectorLayerProperties( vlayer, this );
1136911359
#endif
11370-
Q_FOREACH ( QgsMapLayerPropertiesFactory* factory, mMapLayerPropertiesFactories )
11360+
Q_FOREACH ( QgsMapLayerConfigWidgetFactory* factory, mMapLayerPanelFactories )
1137111361
{
1137211362
vlp->addPropertiesPageFactory( factory );
1137311363
}

0 commit comments

Comments
 (0)