31 mDeleteButton->hide();
33 connect( fieldRadio, SIGNAL( clicked() ), SLOT( reloadStyles() ) );
34 connect( rowRadio, SIGNAL( clicked() ), SLOT( reloadStyles() ) );
35 connect( mNewButton, SIGNAL( clicked() ), SLOT( addNewRule() ) );
36 connect( mSaveRule, SIGNAL( clicked() ), SLOT( saveRule() ) );
37 connect( mCancelButton, SIGNAL( clicked() ), SLOT( cancelRule() ) );
38 connect( mDeleteButton, SIGNAL( clicked() ), SLOT( deleteRule() ) );
40 connect( btnChangeIcon , SIGNAL( clicked() ), SLOT( updateIcon() ) );
41 connect( btnBuildExpression , SIGNAL( clicked() ), SLOT( setExpression() ) );
42 connect( mPresetsList , SIGNAL( currentIndexChanged(
int ) ), SLOT( presetSet(
int ) ) );
43 btnBackgroundColor->setAllowAlpha(
true );
44 btnBackgroundColor->setShowNoColor(
true );
45 btnTextColor->setAllowAlpha(
true );
46 btnTextColor->setShowNoColor(
true );
49 listView->setModel( mModel );
50 mPresetsList->setModel( mPresetsModel );
60 void QgsFieldConditionalFormatWidget::updateIcon()
71 btnChangeIcon->setIcon( icon );
74 void QgsFieldConditionalFormatWidget::setExpression()
88 QString expression = dlg.expressionBuilder()->expressionText();
89 mRuleEdit->setText( expression );
93 void QgsFieldConditionalFormatWidget::presetSet(
int index )
95 if ( index == -1 || mPresets.
isEmpty() )
99 setFormattingFromStyle( style );
105 mFieldCombo->setLayer( theLayer );
106 mFieldCombo->setCurrentIndex( 0 );
109 void QgsFieldConditionalFormatWidget::ruleClicked(
const QModelIndex&
index )
118 pages->setCurrentIndex( 1 );
119 mEditIndex = editIndex;
121 mDeleteButton->show();
127 mRuleEdit->setText( style.
rule() );
128 mNameEdit->setText( style.
name() );
129 setFormattingFromStyle( style );
134 btnTextColor->setColor( style.
textColor() );
137 checkIcon->setChecked(
true );
139 btnChangeIcon->setIcon(
icon );
143 checkIcon->setChecked(
false );
144 btnChangeIcon->setIcon(
QIcon() );
155 mFontBoldBtn->setChecked( font.
bold() );
156 mFontItalicBtn->setChecked( font.
italic() );
157 mFontStrikethroughBtn->setChecked( font.
strikeOut() );
158 mFontUnderlineBtn->setChecked( font.
underline() );
159 mFontFamilyCmbBx->setFont( font );
165 if ( fieldRadio->isChecked() )
169 if ( rowRadio->isChecked() )
176 void QgsFieldConditionalFormatWidget::deleteRule()
181 if ( fieldRadio->isChecked() )
183 fieldName = mFieldCombo->currentField();
186 if ( rowRadio->isChecked() )
191 pages->setCurrentIndex( 0 );
196 void QgsFieldConditionalFormatWidget::cancelRule()
198 pages->setCurrentIndex( 0 );
203 void QgsFieldConditionalFormatWidget::addNewRule()
205 pages->setCurrentIndex( 1 );
214 if ( fieldRadio->isChecked() )
216 mRuleEdit->setText(
"@value " );
219 btnTextColor->setColor(
QColor() );
220 mPresetsList->setCurrentIndex( 0 );
221 mDeleteButton->hide();
223 checkIcon->setChecked(
false );
224 btnChangeIcon->setIcon(
QIcon() );
225 btnBackgroundColor->setToNoColor();
226 btnTextColor->setToNoColor();
228 mFontBoldBtn->setChecked(
false );
229 mFontItalicBtn->setChecked(
false );
230 mFontStrikethroughBtn->setChecked(
false );
231 mFontUnderlineBtn->setChecked(
false );
238 mPresetsModel->
clear();
255 mPresetsList->setCurrentIndex( 0 );
282 void QgsFieldConditionalFormatWidget::saveRule()
288 style.
setRule( mRuleEdit->text() );
289 style.
setName( mNameEdit->text() );
291 QColor backColor = btnBackgroundColor->color();
292 QColor fontColor = btnTextColor->color();
294 QFont font = mFontFamilyCmbBx->currentFont();
295 font.
setBold( mFontBoldBtn->isChecked() );
296 font.
setItalic( mFontItalicBtn->isChecked() );
297 font.
setStrikeOut( mFontStrikethroughBtn->isChecked() );
302 if ( mSymbol && checkIcon->isChecked() )
312 styles.
replace( mEditIndex, style );
320 if ( fieldRadio->isChecked() )
322 fieldName = mFieldCombo->currentField();
325 if ( rowRadio->isChecked() )
329 pages->setCurrentIndex( 0 );
335 void QgsFieldConditionalFormatWidget::reloadStyles()
347 void QgsFieldConditionalFormatWidget::fieldChanged(
const QString& fieldName )
349 Q_UNUSED( fieldName );
355 pages->setCurrentIndex( 0 );
358 bool QgsFieldConditionalFormatWidget::isCustomSet()
360 return ( btnBackgroundColor->color().isValid()
361 || btnTextColor->color().isValid()
362 || mFontButtons->checkedId() != -1 );
QString name() const
The name of the style.
void setName(const QString &value)
Set the name of the style.
Single variable definition for use within a QgsExpressionContextScope.
void setIcon(const QIcon &icon)
void setRule(const QString &value)
Set the rule for the style.
void setBackground(const QBrush &brush)
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)
QPixmap icon() const
The icon set for style generated from the set symbol.
QString tr(const char *sourceText, const char *disambiguation, int n)
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
QgsConditionalLayerStyles * conditionalStyles() const
Return the conditional styles that are set for this layer.
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...
Conditional styling for a rule.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
bool isValid() const
isValid Check if this rule is valid.
static QgsStyleV2 * defaultStyle()
return default application-wide style
QColor backgroundColor() const
The background color for style.
void setFont(const QFont &font)
void setBackgroundColor(const QColor &value)
Set the background color for the style.
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)
QColor textColor() const
The text color set for style.
QPixmap renderPreview() const
Render a preview icon of the rule.
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 displayText() const
The name of the style.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user...
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
QgsSymbolV2 * symbol() const
The symbol used to generate the icon for the style.
QFont font() const
The font for the style.
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.
QString rule() const
The condition rule set for the style.
void appendRow(const QList< QStandardItem * > &items)
A generic dialog for building expression strings.
void replace(int i, const T &value)
void setTextColor(const QColor &value)
Set the text color for the style.