Skip to content
Permalink
Browse files

Streamline QgsMapLayerConfigWidgetFactory interface

  • Loading branch information
NathanW2 committed Jul 7, 2016
1 parent 382986f commit e4080edaa72f4f405abb90542c99dc27ffebb6d0
@@ -13,6 +13,9 @@ class QgsMapLayerConfigWidgetFactory
/** Constructor */
QgsMapLayerConfigWidgetFactory();

/** Constructor */
QgsMapLayerConfigWidgetFactory(QString title, QIcon icon);

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

@@ -22,17 +25,25 @@ class QgsMapLayerConfigWidgetFactory
*/
virtual QIcon icon() const;

void setIcon(QIcon icon);

/**
* @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;

void setTitlte(QString title);

virtual bool supportsStyleDock() const;

void setSupportsStyleDock(bool supports);

virtual bool supportLayerPropertiesDialog() const;

void setSupportLayerPropertiesDialog(bool supports);

/**
* @brief Check if the layer is supported for this widget.
* @return True if this layer is supported for this widget
@@ -505,14 +505,10 @@ bool QgsMapLayerStyleCommand::mergeWith( const QUndoCommand* other )
return true;
}

QIcon QgsLayerStyleManagerWidgetFactory::icon() const
QgsLayerStyleManagerWidgetFactory::QgsLayerStyleManagerWidgetFactory()
{
return QgsApplication::getThemeIcon( "propertyicons/stylepreset.svg" );
}

QString QgsLayerStyleManagerWidgetFactory::title() const
{
return QObject::tr( "Style Manager" );
setIcon( QgsApplication::getThemeIcon( "propertyicons/stylepreset.svg" ) );
setTitlte( QObject::tr( "Style Manager" ) );
}

QgsMapLayerConfigWidget *QgsLayerStyleManagerWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const
@@ -42,8 +42,7 @@ class QgsMapLayerStyleManagerWidget;
class APP_EXPORT QgsLayerStyleManagerWidgetFactory : public QgsMapLayerConfigWidgetFactory
{
public:
QIcon icon() const override;
QString title() const override;
QgsLayerStyleManagerWidgetFactory();
bool supportsStyleDock() const override { return true; }
QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const override;
bool supportsLayer( QgsMapLayer *layer ) const override;
@@ -17,6 +17,13 @@

QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory()
{

}

QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory( QString title, QIcon icon )
: mIcon( icon )
, mTitle( title )
{
}

QgsMapLayerConfigWidgetFactory::~QgsMapLayerConfigWidgetFactory()
@@ -28,37 +28,67 @@
class GUI_EXPORT QgsMapLayerConfigWidgetFactory
{
public:

/** Constructor */
QgsMapLayerConfigWidgetFactory();

/** Constructor */
QgsMapLayerConfigWidgetFactory( QString title, QIcon icon );

/** 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 { return QIcon(); }
virtual QIcon icon() const { return mIcon; }

/**
* Set the icon for the factory object.
* @param icon The icon to show in the interface.
*/
void setIcon( QIcon icon ) { mIcon = icon; }

/**
* @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 { return QString(); }
virtual QString title() const { return mTitle; }

/**
* Set the title for the interface
* @note Not all users may show this as a label
* e.g style dock uses this as a tooltip.
* @param title The title to set.
*/
void setTitlte( QString title ) { mTitle = title; }

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Jul 7, 2016

Collaborator

setTitle ;)

can you also make this take a const reference (same with setIcon)

This comment has been minimized.

Copy link
@NathanW2

NathanW2 via email Jul 7, 2016

Author Member

/**
* Flag if widget is supported for use in style dock.
* @return True if supported
*/
virtual bool supportsStyleDock() const { return false; }

/**
* Set support flag for style dock
* @param supports True if this widget is supported in the style dock.
*/
void setSupportsStyleDock( bool supports ) { mSuppprtsDock = supports; }

/**
* Flag if widget is supported for use in layer properties dialog.
* @return True if supported
*/
virtual bool supportLayerPropertiesDialog() const { return false; }

/**
* Set support flag for style dock
* @param supports True if this widget is supported in the style dock.
*/
void setSupportLayerPropertiesDialog( bool supports ) { mSuppprtsProperties = supports; }

/**
* @brief Check if the layer is supported for this widget.
* @return True if this layer is supported for this widget
@@ -75,6 +105,12 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
* @return A new QgsMapStylePanel which is shown in the map style dock.
*/
virtual QgsMapLayerConfigWidget* createWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget* parent = 0 ) const = 0;

private:
QIcon mIcon;
QString mTitle;
bool mSuppprtsDock;
bool mSuppprtsProperties;
};

#endif // QGSMAPLAYERCONFIGWIDGETFACTORY_H

0 comments on commit e4080ed

Please sign in to comment.
You can’t perform that action at this time.