Skip to content

Commit e4080ed

Browse files
committedJul 7, 2016
Streamline QgsMapLayerConfigWidgetFactory interface
1 parent 382986f commit e4080ed

File tree

5 files changed

+60
-11
lines changed

5 files changed

+60
-11
lines changed
 

‎python/gui/qgsmaplayerconfigwidgetfactory.sip

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class QgsMapLayerConfigWidgetFactory
1313
/** Constructor */
1414
QgsMapLayerConfigWidgetFactory();
1515

16+
/** Constructor */
17+
QgsMapLayerConfigWidgetFactory(QString title, QIcon icon);
18+
1619
/** Destructor */
1720
virtual ~QgsMapLayerConfigWidgetFactory();
1821

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

28+
void setIcon(QIcon icon);
29+
2530
/**
2631
* @brief The title of the panel.
2732
* @note This may or may not be shown to the user.
2833
* @return Title of the panel
2934
*/
3035
virtual QString title() const;
3136

37+
void setTitlte(QString title);
38+
3239
virtual bool supportsStyleDock() const;
3340

41+
void setSupportsStyleDock(bool supports);
42+
3443
virtual bool supportLayerPropertiesDialog() const;
3544

45+
void setSupportLayerPropertiesDialog(bool supports);
46+
3647
/**
3748
* @brief Check if the layer is supported for this widget.
3849
* @return True if this layer is supported for this widget

‎src/app/qgslayerstylingwidget.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,10 @@ bool QgsMapLayerStyleCommand::mergeWith( const QUndoCommand* other )
505505
return true;
506506
}
507507

508-
QIcon QgsLayerStyleManagerWidgetFactory::icon() const
508+
QgsLayerStyleManagerWidgetFactory::QgsLayerStyleManagerWidgetFactory()
509509
{
510-
return QgsApplication::getThemeIcon( "propertyicons/stylepreset.svg" );
511-
}
512-
513-
QString QgsLayerStyleManagerWidgetFactory::title() const
514-
{
515-
return QObject::tr( "Style Manager" );
510+
setIcon( QgsApplication::getThemeIcon( "propertyicons/stylepreset.svg" ) );
511+
setTitlte( QObject::tr( "Style Manager" ) );
516512
}
517513

518514
QgsMapLayerConfigWidget *QgsLayerStyleManagerWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const

‎src/app/qgslayerstylingwidget.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class QgsMapLayerStyleManagerWidget;
4242
class APP_EXPORT QgsLayerStyleManagerWidgetFactory : public QgsMapLayerConfigWidgetFactory
4343
{
4444
public:
45-
QIcon icon() const override;
46-
QString title() const override;
45+
QgsLayerStyleManagerWidgetFactory();
4746
bool supportsStyleDock() const override { return true; }
4847
QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const override;
4948
bool supportsLayer( QgsMapLayer *layer ) const override;

‎src/gui/qgsmaplayerconfigwidgetfactory.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717

1818
QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory()
1919
{
20+
21+
}
22+
23+
QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory( QString title, QIcon icon )
24+
: mIcon( icon )
25+
, mTitle( title )
26+
{
2027
}
2128

2229
QgsMapLayerConfigWidgetFactory::~QgsMapLayerConfigWidgetFactory()

‎src/gui/qgsmaplayerconfigwidgetfactory.h

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,67 @@
2828
class GUI_EXPORT QgsMapLayerConfigWidgetFactory
2929
{
3030
public:
31+
3132
/** Constructor */
3233
QgsMapLayerConfigWidgetFactory();
3334

35+
/** Constructor */
36+
QgsMapLayerConfigWidgetFactory( QString title, QIcon icon );
37+
3438
/** Destructor */
3539
virtual ~QgsMapLayerConfigWidgetFactory();
3640

3741
/**
3842
* @brief The icon that will be shown in the UI for the panel.
3943
* @return A QIcon for the panel icon.
4044
*/
41-
virtual QIcon icon() const { return QIcon(); }
45+
virtual QIcon icon() const { return mIcon; }
46+
47+
/**
48+
* Set the icon for the factory object.
49+
* @param icon The icon to show in the interface.
50+
*/
51+
void setIcon( QIcon icon ) { mIcon = icon; }
4252

4353
/**
4454
* @brief The title of the panel.
4555
* @note This may or may not be shown to the user.
4656
* @return Title of the panel
4757
*/
48-
virtual QString title() const { return QString(); }
58+
virtual QString title() const { return mTitle; }
59+
60+
/**
61+
* Set the title for the interface
62+
* @note Not all users may show this as a label
63+
* e.g style dock uses this as a tooltip.
64+
* @param title The title to set.
65+
*/
66+
void setTitlte( QString title ) { mTitle = title; }
Code has comments. Press enter to view.
4967

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

74+
/**
75+
* Set support flag for style dock
76+
* @param supports True if this widget is supported in the style dock.
77+
*/
78+
void setSupportsStyleDock( bool supports ) { mSuppprtsDock = supports; }
79+
5680
/**
5781
* Flag if widget is supported for use in layer properties dialog.
5882
* @return True if supported
5983
*/
6084
virtual bool supportLayerPropertiesDialog() const { return false; }
6185

86+
/**
87+
* Set support flag for style dock
88+
* @param supports True if this widget is supported in the style dock.
89+
*/
90+
void setSupportLayerPropertiesDialog( bool supports ) { mSuppprtsProperties = supports; }
91+
6292
/**
6393
* @brief Check if the layer is supported for this widget.
6494
* @return True if this layer is supported for this widget
@@ -75,6 +105,12 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
75105
* @return A new QgsMapStylePanel which is shown in the map style dock.
76106
*/
77107
virtual QgsMapLayerConfigWidget* createWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget* parent = 0 ) const = 0;
108+
109+
private:
110+
QIcon mIcon;
111+
QString mTitle;
112+
bool mSuppprtsDock;
113+
bool mSuppprtsProperties;
78114
};
79115

80116
#endif // QGSMAPLAYERCONFIGWIDGETFACTORY_H

0 commit comments

Comments
 (0)
Please sign in to comment.