17 mDeleteButton->hide();
19 connect( fieldRadio, SIGNAL( clicked() ), SLOT( reloadStyles() ) );
20 connect( rowRadio, SIGNAL( clicked() ), SLOT( reloadStyles() ) );
21 connect( mNewButton, SIGNAL( clicked() ), SLOT( addNewRule() ) );
22 connect( mSaveRule, SIGNAL( clicked() ), SLOT( saveRule() ) );
23 connect( mCancelButton, SIGNAL( clicked() ), SLOT( cancelRule() ) );
24 connect( mDeleteButton, SIGNAL( clicked() ), SLOT( deleteRule() ) );
26 connect( btnChangeIcon , SIGNAL( clicked() ), SLOT( updateIcon() ) );
27 connect( btnBuildExpression , SIGNAL( clicked() ), SLOT( setExpression() ) );
28 connect( mPresetsList , SIGNAL( currentIndexChanged(
int ) ), SLOT( presetSet(
int ) ) );
29 btnBackgroundColor->setAllowAlpha(
true );
30 btnBackgroundColor->setShowNoColor(
true );
31 btnTextColor->setAllowAlpha(
true );
32 btnTextColor->setShowNoColor(
true );
35 listView->setModel( mModel );
36 mPresetsList->setModel( mPresetsModel );
46 void QgsFieldConditionalFormatWidget::updateIcon()
57 btnChangeIcon->setIcon( icon );
60 void QgsFieldConditionalFormatWidget::setExpression()
74 QString expression = dlg.expressionBuilder()->expressionText();
75 mRuleEdit->setText( expression );
79 void QgsFieldConditionalFormatWidget::presetSet(
int index )
81 if ( index == -1 || mPresets.
isEmpty() )
85 setFormattingFromStyle( style );
91 mFieldCombo->setLayer( theLayer );
92 mFieldCombo->setCurrentIndex( 0 );
95 void QgsFieldConditionalFormatWidget::ruleClicked(
const QModelIndex&
index )
104 pages->setCurrentIndex( 1 );
105 mEditIndex = editIndex;
107 mDeleteButton->show();
113 mRuleEdit->setText( style.
rule() );
114 mNameEdit->setText( style.
name() );
115 setFormattingFromStyle( style );
120 btnTextColor->setColor( style.
textColor() );
123 checkIcon->setChecked(
true );
125 btnChangeIcon->setIcon(
icon );
129 checkIcon->setChecked(
false );
130 btnChangeIcon->setIcon(
QIcon() );
141 mFontBoldBtn->setChecked( font.
bold() );
142 mFontItalicBtn->setChecked( font.
italic() );
143 mFontStrikethroughBtn->setChecked( font.
strikeOut() );
144 mFontUnderlineBtn->setChecked( font.
underline() );
145 mFontFamilyCmbBx->setFont( font );
151 if ( fieldRadio->isChecked() )
155 if ( rowRadio->isChecked() )
162 void QgsFieldConditionalFormatWidget::deleteRule()
167 if ( fieldRadio->isChecked() )
169 fieldName = mFieldCombo->currentField();
172 if ( rowRadio->isChecked() )
177 pages->setCurrentIndex( 0 );
182 void QgsFieldConditionalFormatWidget::cancelRule()
184 pages->setCurrentIndex( 0 );
189 void QgsFieldConditionalFormatWidget::addNewRule()
191 pages->setCurrentIndex( 1 );
200 if ( fieldRadio->isChecked() )
202 mRuleEdit->setText(
"@value " );
205 btnTextColor->setColor(
QColor() );
206 mPresetsList->setCurrentIndex( 0 );
207 mDeleteButton->hide();
209 checkIcon->setChecked(
false );
210 btnChangeIcon->setIcon(
QIcon() );
211 btnBackgroundColor->setToNoColor();
212 btnTextColor->setToNoColor();
214 mFontBoldBtn->setChecked(
false );
215 mFontItalicBtn->setChecked(
false );
216 mFontStrikethroughBtn->setChecked(
false );
217 mFontUnderlineBtn->setChecked(
false );
224 mPresetsModel->
clear();
241 mPresetsList->setCurrentIndex( 0 );
268 void QgsFieldConditionalFormatWidget::saveRule()
274 style.
setRule( mRuleEdit->text() );
275 style.
setName( mNameEdit->text() );
277 QColor backColor = btnBackgroundColor->color();
278 QColor fontColor = btnTextColor->color();
280 QFont font = mFontFamilyCmbBx->currentFont();
281 font.
setBold( mFontBoldBtn->isChecked() );
282 font.
setItalic( mFontItalicBtn->isChecked() );
283 font.
setStrikeOut( mFontStrikethroughBtn->isChecked() );
288 if ( mSymbol && checkIcon->isChecked() )
298 styles.
replace( mEditIndex, style );
306 if ( fieldRadio->isChecked() )
308 fieldName = mFieldCombo->currentField();
311 if ( rowRadio->isChecked() )
315 pages->setCurrentIndex( 0 );
321 void QgsFieldConditionalFormatWidget::reloadStyles()
333 void QgsFieldConditionalFormatWidget::fieldChanged(
const QString& fieldName )
335 Q_UNUSED( fieldName );
341 pages->setCurrentIndex( 0 );
344 bool QgsFieldConditionalFormatWidget::isCustomSet()
346 return ( btnBackgroundColor->color().isValid()
347 || btnTextColor->color().isValid()
348 || mFontButtons->checkedId() != -1 );
void setName(const QString &value)
Set the name of the style.
void setIcon(const QIcon &icon)
QColor textColor() const
The text color set for style.
void setRule(const QString &value)
Set the rule for the style.
void setBackground(const QBrush &brush)
QFont font() const
The font for the style.
virtual QgsSymbolV2 * clone() const =0
QList< QgsConditionalStyle > fieldStyles(const QString &fieldName)
Returns the conditional styles set for the field UI properties.
const T & at(int i) const
void setUnderline(bool enable)
QgsConditionalLayerStyles * conditionalStyles() const
Return the conditional styles that are set for this layer.
QString tr(const char *sourceText, const char *disambiguation, int n)
void setVariable(const QString &name, const QVariant &value)
Convenience method for setting a variable in the context scope by name and value. ...
void setBold(bool enable)
void setColor(const QColor &color)
QList< QgsConditionalStyle > rowStyles()
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
void append(const T &value)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QPixmap icon() const
The icon set for style generated from the set symbol.
Conditional styling for a rule.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QgsStyleV2 * defaultStyle()
return default application-wide style
QColor backgroundColor() const
The background color for style.
QString name() const
The name of the style.
void setFont(const QFont &font)
void setBackgroundColor(const QColor &value)
Set the background color for the style.
QPixmap renderPreview() const
Render a preview icon of the rule.
void setItalic(bool enable)
void setFont(const QFont &value)
Set the font for the the style.
void setRowStyles(const QList< QgsConditionalStyle > &styles)
Set the conditional styles that apply to full rows of data in the attribute table.
void setForeground(const QBrush &brush)
void setSymbol(QgsSymbolV2 *value)
Set the icon for the style.
static QgsSymbolV2 * defaultSymbol(QGis::GeometryType geomType)
return new default symbol for specified geometry type
void setStrikeOut(bool enable)
QString rule() const
The condition rule set for the style.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
bool isValid() const
isValid Check if this rule is valid.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
void setFieldStyles(const QString &fieldName, const QList< QgsConditionalStyle > &styles)
Set the conditional styles for the field UI properties.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
void appendRow(const QList< QStandardItem * > &items)
QString displayText() const
The name of the style.
A generic dialog for building expression strings.
QgsSymbolV2 * symbol() const
The symbol used to generate the icon for the style.
void replace(int i, const T &value)
void setTextColor(const QColor &value)
Set the text color for the style.