30 QComboBox( parent ), mStyle( nullptr ), mSourceColorRamp( nullptr ), mShowGradientOnly( false )
53 if ( !mShowGradientOnly || ramp->
type() ==
"gradient" )
62 if ( !mShowGradientOnly )
72 if ( rampName ==
tr(
"Random colors" ) )
85 return index ==
count() - 1;
103 if ( index !=
count() - 1 )
108 if ( !mShowGradientOnly )
144 if ( newRamp->type() ==
"gradient" )
148 if ( dlg.
exec() && gradRamp )
154 else if ( newRamp->type() ==
"random" )
164 else if ( newRamp->type() ==
"colorbrewer" )
174 else if ( newRamp->type() ==
"cpt-city" )
178 if ( dlg.
exec() && cptCityRamp )
QgsVectorColorRampV2 * currentColorRamp()
return new instance of the current color ramp or NULL if there is no active color ramp ...
QgsVectorColorRampV2 * colorRamp(const QString &name)
return a NEW copy of color ramp
QgsColorRampComboBox(QWidget *parent=nullptr)
static QIcon colorRampPreviewIcon(QgsVectorColorRampV2 *ramp, QSize size)
virtual QString type() const =0
void setIconSize(const QSize &size)
QString itemText(int index) const
QStringList colorRampNames()
return a list of names of color ramps
QString tr(const char *sourceText, const char *disambiguation, int n)
void insertItem(int index, const QString &text, const QVariant &userData)
bool save(QString filename=QString())
save style into a file (will use current filename if empty string is passed)
void addItem(const QString &text, const QVariant &userData)
virtual QgsVectorColorRampV2 * clone() const =0
void activated(int index)
void colorRampChanged(int index)
void editSourceRamp()
Triggers a dialog which allows users to edit the current source ramp for the combo box...
bool blockSignals(bool block)
void setSourceColorRamp(QgsVectorColorRampV2 *sourceRamp)
add/select color ramp which was used previously by the renderer
bool createNewColorRampSelected() const
Returns true if the current selection in the combo box is the option for creating a new color ramp...
QgsVectorColorRampV2 * mSourceColorRamp
void setItemIcon(int index, const QIcon &icon)
static QString addColorRampStatic(QWidget *parent, QgsStyleV2 *style, QString RampType=QString())
open add color ramp dialog, return color ramp's name if the ramp has been added
static QSize rampIconSize
QString currentText() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void sourceRampEdited()
Emitted when the user has edited the current source ramp.
void populate(QgsStyleV2 *style)
initialize the combo box with color ramps from the style