17#include "moc_qgstableeditorformattingwidget.cpp"
30 mFormatNumbersCheckBox->setTristate(
false );
32 mFontButton->setShowNullFormat(
true );
33 mFontButton->setNoFormatString( tr(
"Clear Formatting" ) );
35 mBackgroundColorButton->setAllowOpacity(
true );
36 mBackgroundColorButton->setColorDialogTitle( tr(
"Background Color" ) );
37 mBackgroundColorButton->setDefaultColor( QColor( 255, 255, 255 ) );
38 mBackgroundColorButton->setShowNull(
true );
40 mHorizontalAlignComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
41 mVerticalAlignComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
43 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
44 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
57 connect( mFormatNumbersCheckBox, &QCheckBox::stateChanged,
this, [ = ](
int state )
59 mCustomizeFormatButton->setEnabled( state == Qt::Checked );
60 if ( state != Qt::PartiallyChecked )
61 mFormatNumbersCheckBox->setTristate(
false );
72 mCustomizeFormatButton->setEnabled(
false );
73 connect( mCustomizeFormatButton, &QPushButton::clicked,
this, [ = ]
76 widget->
setFormat( mNumericFormat.get() );
80 mNumericFormat.reset( widget->
format() );
86 connect( mRowHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double height )
93 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
97 connect( mColumnWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [ = ](
double width )
104 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
111 if ( !mBlockSignals )
119 if ( !mBlockSignals )
127 if ( !mBlockSignals )
133 mExpressionEdit->setAllowEmptyFieldName(
true );
135 mExpressionEdit->registerExpressionContextGenerator(
this );
136 mFontButton->registerExpressionContextGenerator(
this );
141 if ( !mNumericFormat || mFormatNumbersCheckBox->checkState() != Qt::Checked )
144 return mNumericFormat->clone();
149 return mFontButton->textFormat();
155 mBackgroundColorButton->setColor( color );
161 mNumericFormat.reset( format ? format->
clone() : nullptr );
163 mFormatNumbersCheckBox->setTristate( isMixedFormat );
164 mFormatNumbersCheckBox->setCheckState( isMixedFormat ? Qt::PartiallyChecked : ( mNumericFormat.get() ? Qt::Checked : Qt::Unchecked ) );
171 mFontButton->setTextFormat( format );
179 mRowHeightSpinBox->setClearValue( 0, tr(
"Mixed" ) );
181 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
182 mRowHeightSpinBox->setValue( height < 0 ? 0 : height );
190 mColumnWidthSpinBox->setClearValue( 0, tr(
"Mixed" ) );
192 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
193 mColumnWidthSpinBox->setValue( width < 0 ? 0 : width );
200 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
201 mHorizontalAlignComboBox->setCurrentIndex( -1 );
203 mHorizontalAlignComboBox->setCurrentAlignment( alignment );
210 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
211 mVerticalAlignComboBox->setCurrentIndex( -1 );
213 mVerticalAlignComboBox->setCurrentAlignment( alignment );
221 mExpressionEdit->setExpression( QString() );
223 mExpressionEdit->setExpression( property.
asExpression() );
229 mExpressionEdit->setLayer( layer );
234 mContextGenerator = generator;
240 if ( mContextGenerator )
245 cellScope->
setVariable( QStringLiteral(
"row_number" ), 0 );
246 cellScope->
setVariable( QStringLiteral(
"column_number" ), 0 );
249 context.
setHighlightedVariables( QStringList() << QStringLiteral(
"row_number" ) << QStringLiteral(
"column_number" ) );
void changed()
Emitted when the alignment is changed.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
Base class for all map layer types.
A store for object properties.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
bool isActive() const
Returns whether the property is currently active.
Container for all settings relating to text rendering.