Small cleanups for QgsColorRampButton

This commit is contained in:
Nyall Dawson 2016-12-02 09:47:35 +10:00
parent c9058eddf7
commit 968c82a30b
3 changed files with 16 additions and 18 deletions

View File

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

View File

@ -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() )
{

View File

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