Skip to content

Commit

Permalink
Small cleanups for QgsColorRampButton
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 1, 2016
1 parent c9058ed commit 968c82a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 deletions python/gui/qgscolorrampbutton.sip
Expand Up @@ -25,11 +25,10 @@ class QgsColorRampButton : QToolButton

virtual QSize sizeHint() const;

/** Return the current color ramp.
* @returns currently selected color
* @see setColor
/** Return a copy of the current color ramp.
* @see setColorRamp()
*/
QgsColorRamp* colorRamp() const;
QgsColorRamp* colorRamp() const /Factory/;

/** Set the title for the color ramp dialog window.
* @param title Title for the color ramp dialog
Expand Down Expand Up @@ -72,18 +71,18 @@ class QgsColorRampButton : QToolButton
/** Sets the default color ramp for the button, which is shown in the button's drop down menu for the
* "default color ramp" option.
* @param colorramp default color ramp for the button. Set to a null pointer to disable the default color
* ramp option.
* ramp option. The ramp will be cloned and ownership is not transferred.
* @see defaultColorRamp
*/
void setDefaultColorRamp( QgsColorRamp* colorramp );

/** Returns the default color ramp for the button, which is shown in the button's drop down menu for the
/** Returns a copy of the default color ramp for the button, which is shown in the button's drop down menu for the
* "default color ramp" option.
* @returns default color ramp for the button. Returns a null pointer if the default color ramp
* option is disabled.
* @see setDefaultColorRamp
*/
QgsColorRamp* defaultColorRamp() const;
QgsColorRamp* defaultColorRamp() const /Factory/;

/** Sets whether a random colors option is shown in the button's drop down menu.
* @param showNull set to true to show a null option
Expand Down Expand Up @@ -152,7 +151,7 @@ class QgsColorRampButton : QToolButton

/** Sets the current color ramp for the button. Will emit a colorRampChanged() signal if the color ramp is different
* to the previous color ramp.
* @param colorramp New color ramp for the button
* @param colorramp New color ramp for the button. The ramp will be cloned and ownership is not transferred.
* @see setRandomColorRamp, setColorRampFromName, colorRamp
*/
void setColorRamp( QgsColorRamp* colorramp );
Expand All @@ -168,7 +167,7 @@ class QgsColorRampButton : QToolButton
* @param name Name of saved color ramp
* @see setColorRamp, setRandomColorRamp, colorRamp
*/
void setColorRampFromName( QString name = QString() );
void setColorRampFromName( const QString& name = QString() );

/** Sets the background pixmap for the button based upon current color ramp.
* @param colorramp Color ramp for button background. If no color ramp is specified, the button's current
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgscolorrampbutton.cpp
Expand Up @@ -412,7 +412,7 @@ void QgsColorRampButton::setColorRamp( QgsColorRamp* colorramp )
mColorRampSet = true;
}

void QgsColorRampButton::setColorRampFromName( QString name )
void QgsColorRampButton::setColorRampFromName( const QString& name )
{
if ( !name.isEmpty() )
{
Expand Down
15 changes: 7 additions & 8 deletions src/gui/qgscolorrampbutton.h
Expand Up @@ -53,9 +53,8 @@ class GUI_EXPORT QgsColorRampButton : public QToolButton

virtual QSize sizeHint() const override;

/** Return the current color ramp.
* @returns currently selected color
* @see setColor
/** Return a copy of the current color ramp.
* @see setColorRamp()
*/
QgsColorRamp* colorRamp() const;

Expand Down Expand Up @@ -100,18 +99,18 @@ class GUI_EXPORT QgsColorRampButton : public QToolButton
/** Sets the default color ramp for the button, which is shown in the button's drop down menu for the
* "default color ramp" option.
* @param colorramp default color ramp for the button. Set to a null pointer to disable the default color
* ramp option.
* ramp option. The ramp will be cloned and ownership is not transferred.
* @see defaultColorRamp
*/
void setDefaultColorRamp( QgsColorRamp* colorramp );

/** Returns the default color ramp for the button, which is shown in the button's drop down menu for the
/** Returns a copy of the default color ramp for the button, which is shown in the button's drop down menu for the
* "default color ramp" option.
* @returns default color ramp for the button. Returns a null pointer if the default color ramp
* option is disabled.
* @see setDefaultColorRamp
*/
QgsColorRamp* defaultColorRamp() const { return mDefaultColorRamp; }
QgsColorRamp* defaultColorRamp() const { return mDefaultColorRamp ? mDefaultColorRamp->clone() : nullptr ; }

/** Sets whether a random colors option is shown in the button's drop down menu.
* @param showRandom set to true to show a random colors option
Expand Down Expand Up @@ -180,7 +179,7 @@ class GUI_EXPORT QgsColorRampButton : public QToolButton

/** Sets the current color ramp for the button. Will emit a colorRampChanged() signal if the color ramp is different
* to the previous color ramp.
* @param colorramp New color ramp for the button
* @param colorramp New color ramp for the button. The ramp will be cloned and ownership is not transferred.
* @see setRandomColorRamp, setColorRampFromName, colorRamp
*/
void setColorRamp( QgsColorRamp* colorramp );
Expand All @@ -196,7 +195,7 @@ class GUI_EXPORT QgsColorRampButton : public QToolButton
* @param name Name of saved color ramp
* @see setColorRamp, setRandomColorRamp, colorRamp
*/
void setColorRampFromName( QString name = QString() );
void setColorRampFromName( const QString& name = QString() );

/** Sets the background pixmap for the button based upon current color ramp.
* @param colorramp Color ramp for button background. If no color ramp is specified, the button's current
Expand Down

1 comment on commit 968c82a

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 968c82a Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that doubles as educational material too over here ;)

Please sign in to comment.