From d26b7abc576e7b97bf2647b243c713630bc37ba7 Mon Sep 17 00:00:00 2001 From: nirvn Date: Mon, 26 Aug 2019 10:50:05 +0700 Subject: [PATCH] QgsSymbolSelector{Widget,Dialog} class cleanup --- .../symbology/qgssymbolselectordialog.sip.in | 84 ++-------- src/gui/symbology/qgssymbolselectordialog.cpp | 8 +- src/gui/symbology/qgssymbolselectordialog.h | 155 +++++++++--------- 3 files changed, 100 insertions(+), 147 deletions(-) diff --git a/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in b/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in index cf7245ec7cf..9c3945c21dd 100644 --- a/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in +++ b/python/gui/auto_generated/symbology/qgssymbolselectordialog.sip.in @@ -72,52 +72,6 @@ Returns the symbol that is currently active in the widget. Can be ``None``. %End - protected: - - void loadSymbol(); -%Docstring -Reload the current symbol in the view. -%End - - void updateUi(); -%Docstring -Update the state of the UI based on the currently set symbol layer. -%End - - void updateLockButton(); -%Docstring -Update the lock button states based on the current symbol layer. -%End - - - QgsSymbolLayer *currentLayer(); -%Docstring -The current symbol layer that is active in the interface. - -:return: The active symbol layer. -%End - - void moveLayerByOffset( int offset ); -%Docstring -Move the current active layer by a set offset in the list. - -:param offset: The offset to move the layer by -%End - - void setWidget( QWidget *widget ); -%Docstring -Set the properties widget for the active symbol layer. - -:param widget: The widget to set to configure the active symbol layer. -%End - - signals: - - void symbolModified(); -%Docstring -Emiited when a symbol is modified in the widget. -%End - public slots: void moveLayerDown(); @@ -179,9 +133,12 @@ alters tree and sets proper widget when Layer Type is changed \note: The layer is received from the LayerPropertiesWidget %End + signals: - protected: // data - + void symbolModified(); +%Docstring +Emiited when a symbol is modified in the widget. +%End }; @@ -236,6 +193,7 @@ Returns the symbol that is currently active in the widget. Can be ``None``. :return: The active symbol. %End + QDialogButtonBox *buttonBox() const; %Docstring Returns a reference to the dialog's button box. @@ -243,27 +201,8 @@ Returns a reference to the dialog's button box. .. versionadded:: 3.10 %End - protected: - virtual void keyPressEvent( QKeyEvent *e ); - - - void loadSymbol(); - - - void updateUi(); - - void updateLockButton(); - - QgsSymbolLayer *currentLayer(); - - void moveLayerByOffset( int offset ); - - void setWidget( QWidget *widget ); - - signals: - void symbolModified(); - public slots: + void moveLayerDown(); void moveLayerUp(); @@ -295,6 +234,15 @@ alters tree and sets proper widget when Layer Type is changed \note: The layer is received from the LayerPropertiesWidget %End + protected: + + virtual void keyPressEvent( QKeyEvent *e ); + + + signals: + + void symbolModified(); + }; /************************************************************************ diff --git a/src/gui/symbology/qgssymbolselectordialog.cpp b/src/gui/symbology/qgssymbolselectordialog.cpp index 99a80df14b6..20daecc5500 100644 --- a/src/gui/symbology/qgssymbolselectordialog.cpp +++ b/src/gui/symbology/qgssymbolselectordialog.cpp @@ -414,7 +414,7 @@ void QgsSymbolSelectorWidget::loadSymbol( QgsSymbol *symbol, SymbolLayerItem *pa } -void QgsSymbolSelectorWidget::loadSymbol() +void QgsSymbolSelectorWidget::reloadSymbol() { model->clear(); loadSymbol( mSymbol, static_cast( model->invisibleRootItem() ) ); @@ -553,7 +553,7 @@ void QgsSymbolSelectorWidget::symbolChanged() else { //it is the symbol itself - loadSymbol(); + reloadSymbol(); QModelIndex newIndex = layersTree->model()->index( 0, 0 ); layersTree->setCurrentIndex( newIndex ); } @@ -824,9 +824,9 @@ void QgsSymbolSelectorDialog::keyPressEvent( QKeyEvent *e ) } } -void QgsSymbolSelectorDialog::loadSymbol() +void QgsSymbolSelectorDialog::reloadSymbol() { - mSelectorWidget->loadSymbol(); + mSelectorWidget->reloadSymbol(); } void QgsSymbolSelectorDialog::loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent ) diff --git a/src/gui/symbology/qgssymbolselectordialog.h b/src/gui/symbology/qgssymbolselectordialog.h index dd55c1f4053..7799b8b5eb9 100644 --- a/src/gui/symbology/qgssymbolselectordialog.h +++ b/src/gui/symbology/qgssymbolselectordialog.h @@ -128,58 +128,12 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs QgsSymbol *symbol() { return mSymbol; } /** - * Load the given symbol into the widget. + * Loads the given symbol into the widget. * \param symbol The symbol to load. * \param parent The parent symbol layer item. If the parent parameter is null, the whole symbol and model will be reset. - * \note not available in Python bindings */ void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP; - protected: - - /** - * Reload the current symbol in the view. - */ - void loadSymbol(); - - /** - * Update the state of the UI based on the currently set symbol layer. - */ - void updateUi(); - - /** - * Update the lock button states based on the current symbol layer. - */ - void updateLockButton(); - - //! \note not available in Python bindings - SymbolLayerItem *currentLayerItem() SIP_SKIP; - - /** - * The current symbol layer that is active in the interface. - * \returns The active symbol layer. - */ - QgsSymbolLayer *currentLayer(); - - /** - * Move the current active layer by a set offset in the list. - * \param offset The offset to move the layer by - */ - void moveLayerByOffset( int offset ); - - /** - * Set the properties widget for the active symbol layer. - * \param widget The widget to set to configure the active symbol layer. - */ - void setWidget( QWidget *widget ); - - signals: - - /** - * Emiited when a symbol is modified in the widget. - */ - void symbolModified(); - public slots: /** @@ -238,8 +192,50 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs */ void changeLayer( QgsSymbolLayer *layer ); + signals: + + /** + * Emiited when a symbol is modified in the widget. + */ + void symbolModified(); + + private: + + /** + * Reload the current symbol in the view. + */ + void reloadSymbol(); + + /** + * Update the state of the UI based on the currently set symbol layer. + */ + void updateUi(); + + /** + * Update the lock button states based on the current symbol layer. + */ + void updateLockButton(); + + SymbolLayerItem *currentLayerItem(); + + /** + * The current symbol layer that is active in the interface. + * \returns The active symbol layer. + */ + QgsSymbolLayer *currentLayer(); + + /** + * Move the current active layer by a set offset in the list. + * \param offset The offset to move the layer by + */ + void moveLayerByOffset( int offset ); + + /** + * Set the properties widget for the active symbol layer. + * \param widget The widget to set to configure the active symbol layer. + */ + void setWidget( QWidget *widget ); - protected: // data QgsStyle *mStyle = nullptr; QgsSymbol *mSymbol = nullptr; QMenu *mAdvancedMenu = nullptr; @@ -248,7 +244,6 @@ class GUI_EXPORT QgsSymbolSelectorWidget: public QgsPanelWidget, private Ui::Qgs QStandardItemModel *model = nullptr; QWidget *mPresentWidget = nullptr; - private: std::unique_ptr mDataDefineRestorer; QgsSymbolWidgetContext mContext; QgsFeature mPreviewFeature; @@ -302,37 +297,21 @@ class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog */ QgsSymbol *symbol(); + /** + * Loads the given symbol into the widget. + * \param symbol The symbol to load. + * \param parent The parent symbol layer item. If the parent parameter is null, the whole symbol and model will be reset. + */ + void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent = nullptr ) SIP_SKIP; + /** * Returns a reference to the dialog's button box. * \since QGIS 3.10 */ QDialogButtonBox *buttonBox() const; - protected: - // Reimplements dialog keyPress event so we can ignore it - void keyPressEvent( QKeyEvent *e ) override; - - void loadSymbol(); - - //! \note not available in Python bindings - void loadSymbol( QgsSymbol *symbol, SymbolLayerItem *parent ) SIP_SKIP; - - void updateUi(); - - void updateLockButton(); - - //! \note not available in Python bindings - SymbolLayerItem *currentLayerItem() SIP_SKIP; - QgsSymbolLayer *currentLayer(); - - void moveLayerByOffset( int offset ); - - void setWidget( QWidget *widget ); - - signals: - void symbolModified(); - public slots: + void moveLayerDown(); void moveLayerUp(); @@ -361,13 +340,39 @@ class GUI_EXPORT QgsSymbolSelectorDialog : public QDialog */ void changeLayer( QgsSymbolLayer *layer ); + protected: + + // Reimplements dialog keyPress event so we can ignore it + void keyPressEvent( QKeyEvent *e ) override; + + private slots: + + void showHelp(); + + signals: + + void symbolModified(); + private: + + void reloadSymbol(); + + void updateUi(); + + void updateLockButton(); + + SymbolLayerItem *currentLayerItem(); + + QgsSymbolLayer *currentLayer(); + + void moveLayerByOffset( int offset ); + + void setWidget( QWidget *widget ); + QgsSymbolSelectorWidget *mSelectorWidget = nullptr; QDialogButtonBox *mButtonBox = nullptr; QgsSymbolWidgetContext mContext; - private slots: - void showHelp(); }; #endif