Skip to content

Commit

Permalink
[style dock] Add better API for panels
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jun 13, 2016
1 parent 16eb1e1 commit e926e2d
Show file tree
Hide file tree
Showing 48 changed files with 1,018 additions and 822 deletions.
23 changes: 2 additions & 21 deletions python/gui/effects/qgseffectstackpropertieswidget.sip
Expand Up @@ -9,7 +9,7 @@
* \see QgsEffectStackCompactWidget
*/

class QgsEffectStackPropertiesWidget : QWidget
class QgsEffectStackPropertiesWidget : QgsPanelWidget
{
%TypeHeaderCode
#include <qgseffectstackpropertieswidget.h>
Expand Down Expand Up @@ -66,18 +66,6 @@ class QgsEffectStackPropertiesWidget : QWidget
*/
void changeEffect( QgsPaintEffect* newEffect );

signals:
/**
* Emitted when something in the widget changes.
*/
void widgetChanged();

/** Emitted when a panel is shown in the widget.
* @param widget widget panel which was shown
* @note added in QGIS 2.16
*/
void showPanel( QgsRendererWidgetContainer* widget );

protected:

/** Refreshes the widget to reflect the current state of the stack.
Expand Down Expand Up @@ -159,7 +147,7 @@ class QgsEffectStackPropertiesDialog : QgsDialog
* \see QgsEffectStackPropertiesDialog
*/

class QgsEffectStackCompactWidget : QWidget
class QgsEffectStackCompactWidget : QgsPanelWidget
{
%TypeHeaderCode
#include <qgseffectstackpropertieswidget.h>
Expand Down Expand Up @@ -206,11 +194,4 @@ class QgsEffectStackCompactWidget : QWidget
/** Emitted when the paint effect properties change
*/
void changed();

/** Emitted when a panel is shown in the widget.
* @param widget widget panel which was shown
* @note added in QGIS 2.16
*/
void showPanel( QgsRendererWidgetContainer* widget );

};
2 changes: 1 addition & 1 deletion python/gui/gui.sip
Expand Up @@ -135,6 +135,7 @@
%Include qgsoptionsdialogbase.sip
%Include qgsorderbydialog.sip
%Include qgsowssourceselect.sip
%Include qgspanelwidget.sip
%Include qgspixmaplabel.sip
%Include qgspluginmanagerinterface.sip
%Include qgsprevieweffect.sip
Expand Down Expand Up @@ -252,7 +253,6 @@
%Include symbology-ng/qgsvectorfieldsymbollayerwidget.sip
%Include symbology-ng/qgsvectorgradientcolorrampv2dialog.sip
%Include symbology-ng/qgsvectorrandomcolorrampv2dialog.sip
%Include symbology-ng/qgsrendererwidgetcontainer.sip

%Include effects/qgseffectdrawmodecombobox.sip
%Include effects/qgseffectstackpropertieswidget.sip
Expand Down
4 changes: 2 additions & 2 deletions python/gui/qgisinterface.sip
Expand Up @@ -293,10 +293,10 @@ class QgisInterface : QObject
virtual void unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory* factory ) = 0;

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

/** Unregister a previously registered tab in the layer properties dialog */
virtual void unregisterMapStylePanelFactory( QgsMapStylePanelFactory* factory ) = 0;
virtual void unregisterMapStylePanelFactory( QgsMapStylingPanelFactory* 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
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 : QgsMapStylePanel
class QgsMapLayerStyleManagerWidget : QgsMapStylingPanel
{
%TypeHeaderCode
#include "qgsmaplayerstylemanagerwidget.h"
Expand Down
12 changes: 6 additions & 6 deletions python/gui/qgsmapstylepanel.sip
Expand Up @@ -2,7 +2,7 @@
* \class A panel widget that can be shown in the map style dock
* \note added in QGIS 2.16
*/
class QgsMapStylePanel : public QWidget
class QgsMapStylingPanel : public QgsPanelWidget
{
%TypeHeaderCode
#include <qgsmapstylepanel.h>
Expand All @@ -16,7 +16,7 @@ public:
* @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.
*/
QgsMapStylePanel(QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0);
QgsMapStylingPanel(QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget *parent = 0);

signals:
/**
Expand All @@ -41,7 +41,7 @@ public slots:
* \class QgsMapStylePanelFactory
* \note added in QGIS 2.16
*/
class QgsMapStylePanelFactory
class QgsMapStylingPanelFactory
{
%TypeHeaderCode
#include <qgsmapstylepanel.h>
Expand All @@ -50,10 +50,10 @@ class QgsMapStylePanelFactory
typedef QFlags<QgsMapLayer::LayerType> LayerTypesFlags;

/** Constructor */
QgsMapStylePanelFactory();
QgsMapStylingPanelFactory();

/** Destructor */
virtual ~QgsMapStylePanelFactory();
virtual ~QgsMapStylingPanelFactory();

/**
* @brief The icon that will be shown in the UI for the panel.
Expand Down Expand Up @@ -82,5 +82,5 @@ class QgsMapStylePanelFactory
* @param parent The parent of the widget.
* @return A new QgsMapStylePanel which is shown in the map style dock.
*/
virtual QgsMapStylePanel* createPanel( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget* parent /TransferThis/ ) = 0 /Factory/;
virtual QgsMapStylingPanel* createPanel( QgsMapLayer* layer, QgsMapCanvas *canvas, QWidget* parent /TransferThis/ ) = 0 /Factory/;
};
2 changes: 1 addition & 1 deletion python/gui/raster/qgsrendererrasterpropertieswidget.sip
@@ -1,4 +1,4 @@
class QgsRendererRasterPropertiesWidget : QgsMapStylePanel
class QgsRendererRasterPropertiesWidget : QgsMapStylingPanel
{
%TypeHeaderCode
#include <qgsrendererrasterpropertieswidget.h>
Expand Down
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgslayerpropertieswidget.sip
@@ -1,4 +1,4 @@
class QgsLayerPropertiesWidget : QWidget
class QgsLayerPropertiesWidget : QgsPanelWidget
{
%TypeHeaderCode
#include <qgslayerpropertieswidget.h>
Expand Down
14 changes: 2 additions & 12 deletions python/gui/symbology-ng/qgsrendererv2propertiesdialog.sip
Expand Up @@ -24,6 +24,8 @@ class QgsRendererV2PropertiesDialog : QDialog
*/
void setMapCanvas( QgsMapCanvas* canvas );

void setDockMode( bool dockMode );

signals:
/**
* Emitted when expression context variables on the associated
Expand All @@ -48,18 +50,6 @@ class QgsRendererV2PropertiesDialog : QDialog
//! Apply and accept the changes for the dialog.
void onOK();

/** Shows a panel widget inside the renderer widget.
* @param container widget panel to show
* @note added in QGIS 2.16
*/
void showPanel( QgsRendererWidgetContainer *container );

/**
* Closes the given panel in the stack of panels.
* @param container The container widget to close.
*/
void closePanel( QgsRendererWidgetContainer *container );

protected:
/**
* Connect the given slot to the value changed event for the set of widgets
Expand Down
21 changes: 8 additions & 13 deletions python/gui/symbology-ng/qgsrendererv2widget.sip
@@ -1,4 +1,4 @@
class QgsRendererV2Widget : QWidget
class QgsRendererV2Widget : QgsPanelWidget
{
%TypeHeaderCode
#include <qgsrendererv2widget.h>
Expand Down Expand Up @@ -39,6 +39,13 @@ class QgsRendererV2Widget : QWidget
*/
void applyChanges();

/**
* Set the widget in dock mode which tells the widget to emit panel
* widgets and not open dialogs
* @param dockMode True to enable dock mode.
*/
virtual void setDockMode( bool dockMode);

signals:
/**
* Emitted when expression context variables on the associated
Expand All @@ -47,18 +54,6 @@ class QgsRendererV2Widget : QWidget
*/
void layerVariablesChanged();

/**
* Emitted when something on the widget has changed.
* All widgets will fire this event to notify of an internal change.
*/
void widgetChanged();

/** Shows a panel widget inside the renderer widget.
* @param widget widget panel to show
* @note added in QGIS 2.16
*/
void showPanel( QgsRendererWidgetContainer* widget );

protected:
/** Subclasses may provide the capability of changing multiple symbols at once by implementing the following two methods
and by connecting the slot contextMenuViewCategories(const QPoint&)*/
Expand Down
55 changes: 0 additions & 55 deletions python/gui/symbology-ng/qgsrendererwidgetcontainer.sip

This file was deleted.

2 changes: 2 additions & 0 deletions python/gui/symbology-ng/qgssinglesymbolrendererv2widget.sip
Expand Up @@ -13,6 +13,8 @@ class QgsSingleSymbolRendererV2Widget : QgsRendererV2Widget

virtual void setMapCanvas( QgsMapCanvas* canvas );

virtual void setDockMode( bool dockMode );

public slots:
void changeSingleSymbol();

Expand Down
98 changes: 98 additions & 0 deletions python/gui/symbology-ng/qgssymbolv2selectordialog.sip
@@ -1,3 +1,101 @@
class QgsSymbolV2SelectorWidget : QgsPanelWidget
{
%TypeHeaderCode
#include <qgssymbolv2selectordialog.h>
%End

public:
QgsSymbolV2SelectorWidget( QgsSymbolV2* symbol, QgsStyleV2* style, const QgsVectorLayer* vl, QWidget* parent /TransferThis/ = 0);

//! return menu for "advanced" button - create it if doesn't exist and show the advanced button
QMenu* advancedMenu();

/** Sets the optional expression context used for the widget. This expression context is used for
* evaluating data defined symbol properties and for populating based expression widgets in
* the layer widget.
* @param context expression context pointer. Ownership is transferred to the dialog.
* @note added in QGIS 2.12
* @see expressionContext()
*/
void setExpressionContext( QgsExpressionContext* context /Transfer/ );

/** Returns the expression context used for the dialog, if set. This expression context is used for
* evaluating data defined symbol properties and for populating based expression widgets in
* the dialog.
* @note added in QGIS 2.12
* @see setExpressionContext()
*/
QgsExpressionContext* expressionContext() const;

/** Sets the map canvas associated with the dialog. This allows the widget to retrieve the current
* map scale and other properties from the canvas.
* @param canvas map canvas
* @note added in QGIS 2.12
*/
void setMapCanvas( QgsMapCanvas* canvas );

/**
* @brief Return the symbol that is currently active in the widget. Can be null.
* @return The active symbol.
*/
QgsSymbolV2* symbol();

/**
* Set the widget in dock mode which will emit showPanel when a sub widget requests
* to show a widget.
* @param dockMode True to enable dock mode.
*/
void setDockMode( bool dockMode );
protected:
//! Reimplements dialog keyPress event so we can ignore it
void keyPressEvent( QKeyEvent * event );

void loadSymbol();
//! @note not available in python bindings
// void loadSymbol( QgsSymbolV2* symbol, SymbolLayerItem* parent );

void updateUi();

void updateLockButton();

//! @note not available in python bindings
// SymbolLayerItem* currentLayerItem();
QgsSymbolLayerV2* currentLayer();

void moveLayerByOffset( int offset );

void setWidget( QWidget* widget );

signals:
void symbolModified();

public slots:
void moveLayerDown();
void moveLayerUp();

void addLayer();
void removeLayer();

void lockLayer();

void saveSymbol() /Deprecated/;

//! Duplicates the current symbol layer and places the duplicated layer above the current symbol layer
//! @note added in QGIS 2.14
void duplicateLayer();

void layerChanged();

void updateLayerPreview();
void updatePreview();

//! Slot to update tree when a new symbol from style
void symbolChanged();
//! alters tree and sets proper widget when Layer Type is changed
//! @note: The layer is received from the LayerPropertiesWidget
void changeLayer( QgsSymbolLayerV2* layer );
};

class QgsSymbolV2SelectorDialog : QDialog
{
%TypeHeaderCode
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -9063,12 +9063,12 @@ void QgisApp::unregisterMapLayerPropertiesFactory( QgsMapLayerPropertiesFactory*
mMapLayerPropertiesFactories.removeAll( factory );
}

void QgisApp::registerMapStylePanelFactory( QgsMapStylePanelFactory *factory )
void QgisApp::registerMapStylePanelFactory( QgsMapStylingPanelFactory *factory )
{
mMapStylePanelFactories << factory;
}

void QgisApp::unregisterMapStylePanelFactory( QgsMapStylePanelFactory *factory )
void QgisApp::unregisterMapStylePanelFactory( QgsMapStylingPanelFactory *factory )
{
mMapStylePanelFactories.removeAll( factory );
}
Expand Down

0 comments on commit e926e2d

Please sign in to comment.