Skip to content

Commit

Permalink
Streamline QgsMapLayerConfigWidgetFactory interface
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Jul 7, 2016
1 parent 382986f commit e4080ed
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 11 deletions.
11 changes: 11 additions & 0 deletions python/gui/qgsmaplayerconfigwidgetfactory.sip
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class QgsMapLayerConfigWidgetFactory
/** Constructor */
QgsMapLayerConfigWidgetFactory();

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

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

Expand All @@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/app/qgslayerstylingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgslayerstylingwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsmaplayerconfigwidgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory()
{

}

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

QgsMapLayerConfigWidgetFactory::~QgsMapLayerConfigWidgetFactory()
Expand Down
40 changes: 38 additions & 2 deletions src/gui/qgsmaplayerconfigwidgetfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.