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" ) );
55 connect( mFormatNumbersCheckBox, &QCheckBox::stateChanged,
this, [=](
int state ) {
56 mCustomizeFormatButton->setEnabled( state == Qt::Checked );
57 if ( state != Qt::PartiallyChecked )
58 mFormatNumbersCheckBox->setTristate(
false );
68 mCustomizeFormatButton->setEnabled(
false );
69 connect( mCustomizeFormatButton, &QPushButton::clicked,
this, [=] {
71 widget->
setFormat( mNumericFormat.get() );
74 mNumericFormat.reset( widget->
format() );
80 connect( mRowHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double height ) {
86 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
90 connect( mColumnWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [=](
double width ) {
96 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
102 if ( !mBlockSignals )
109 if ( !mBlockSignals )
116 if ( !mBlockSignals )
122 mExpressionEdit->setAllowEmptyFieldName(
true );
124 mExpressionEdit->registerExpressionContextGenerator(
this );
125 mFontButton->registerExpressionContextGenerator(
this );
130 if ( !mNumericFormat || mFormatNumbersCheckBox->checkState() != Qt::Checked )
133 return mNumericFormat->clone();
138 return mFontButton->textFormat();
144 mBackgroundColorButton->setColor( color );
150 mNumericFormat.reset( format ? format->
clone() : nullptr );
152 mFormatNumbersCheckBox->setTristate( isMixedFormat );
153 mFormatNumbersCheckBox->setCheckState( isMixedFormat ? Qt::PartiallyChecked : ( mNumericFormat.get() ? Qt::Checked : Qt::Unchecked ) );
160 mFontButton->setTextFormat( format );
168 mRowHeightSpinBox->setClearValue( 0, tr(
"Mixed" ) );
170 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
171 mRowHeightSpinBox->setValue( height < 0 ? 0 : height );
179 mColumnWidthSpinBox->setClearValue( 0, tr(
"Mixed" ) );
181 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
182 mColumnWidthSpinBox->setValue( width < 0 ? 0 : width );
189 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
190 mHorizontalAlignComboBox->setCurrentIndex( -1 );
192 mHorizontalAlignComboBox->setCurrentAlignment( alignment );
199 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
200 mVerticalAlignComboBox->setCurrentIndex( -1 );
202 mVerticalAlignComboBox->setCurrentAlignment( alignment );
210 mExpressionEdit->setExpression( QString() );
212 mExpressionEdit->setExpression( property.
asExpression() );
218 mExpressionEdit->setLayer( layer );
223 mContextGenerator = generator;
229 if ( mContextGenerator )
234 cellScope->
setVariable( QStringLiteral(
"row_number" ), 0 );
235 cellScope->
setVariable( QStringLiteral(
"column_number" ), 0 );
238 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.