Skip to content
Permalink
Browse files

Small cleanups for QgsColorRampButton

  • Loading branch information
nyalldawson committed Dec 1, 2016
1 parent c9058ed commit 968c82a30b08b1ac01c31fcb4720ccf20c6d21ca
Showing with 16 additions and 18 deletions.
  1. +8 −9 python/gui/qgscolorrampbutton.sip
  2. +1 −1 src/gui/qgscolorrampbutton.cpp
  3. +7 −8 src/gui/qgscolorrampbutton.h
@@ -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
@@ -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
@@ -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 );
@@ -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
@@ -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() )
{
@@ -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;

@@ -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
@@ -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 );
@@ -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

1 comment on commit 968c82a

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn commented on 968c82a Dec 2, 2016

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

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