25#include "moc_qgstableeditorformattingwidget.cpp"
33 mFormatNumbersCheckBox->setTristate(
false );
35 mFontButton->setShowNullFormat(
true );
36 mFontButton->setNoFormatString( tr(
"Clear Formatting" ) );
38 mBackgroundColorButton->setAllowOpacity(
true );
39 mBackgroundColorButton->setColorDialogTitle( tr(
"Background Color" ) );
40 mBackgroundColorButton->setDefaultColor( QColor( 255, 255, 255 ) );
41 mBackgroundColorButton->setShowNull(
true );
43 mHorizontalAlignComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
44 mVerticalAlignComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
46 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
47 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
58 connect( mFormatNumbersCheckBox, &QCheckBox::stateChanged,
this, [
this](
int state ) {
59 mCustomizeFormatButton->setEnabled( state == Qt::Checked );
60 if ( state != Qt::PartiallyChecked )
61 mFormatNumbersCheckBox->setTristate(
false );
71 mCustomizeFormatButton->setEnabled(
false );
72 connect( mCustomizeFormatButton, &QPushButton::clicked,
this, [
this] {
74 widget->
setFormat( mNumericFormat.get() );
77 mNumericFormat.reset( widget->
format() );
83 connect( mRowHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double height ) {
89 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
93 connect( mColumnWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double width ) {
99 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
105 if ( !mBlockSignals )
112 if ( !mBlockSignals )
119 if ( !mBlockSignals )
125 mExpressionEdit->setAllowEmptyFieldName(
true );
127 mExpressionEdit->registerExpressionContextGenerator(
this );
128 mFontButton->registerExpressionContextGenerator(
this );
133 if ( !mNumericFormat || mFormatNumbersCheckBox->checkState() != Qt::Checked )
136 return mNumericFormat->
clone();
141 return mFontButton->textFormat();
147 mBackgroundColorButton->
setColor( color );
153 mNumericFormat.reset( format ? format->
clone() :
nullptr );
155 mFormatNumbersCheckBox->setTristate( isMixedFormat );
156 mFormatNumbersCheckBox->setCheckState( isMixedFormat ? Qt::PartiallyChecked : ( mNumericFormat.get() ? Qt::Checked : Qt::Unchecked ) );
163 mFontButton->setTextFormat( format );
171 mRowHeightSpinBox->setClearValue( 0, tr(
"Mixed" ) );
173 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
174 mRowHeightSpinBox->setValue( height < 0 ? 0 : height );
182 mColumnWidthSpinBox->setClearValue( 0, tr(
"Mixed" ) );
184 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
185 mColumnWidthSpinBox->setValue( width < 0 ? 0 : width );
192 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
193 mHorizontalAlignComboBox->setCurrentIndex( -1 );
195 mHorizontalAlignComboBox->setCurrentAlignment( alignment );
202 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
203 mVerticalAlignComboBox->setCurrentIndex( -1 );
205 mVerticalAlignComboBox->setCurrentAlignment( alignment );
213 mExpressionEdit->setExpression( QString() );
215 mExpressionEdit->setExpression( property.
asExpression() );
221 mExpressionEdit->setLayer( layer );
226 mContextGenerator = generator;
232 if ( mContextGenerator )
233 context = mContextGenerator->createExpressionContext();
237 cellScope->
setVariable( QStringLiteral(
"row_number" ), 0 );
238 cellScope->
setVariable( QStringLiteral(
"column_number" ), 0 );
241 context.
setHighlightedVariables( QStringList() << QStringLiteral(
"row_number" ) << QStringLiteral(
"column_number" ) );
void changed()
Emitted when the alignment is changed.
Abstract interface for generating an expression context.
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.
void setColor(const QColor &color)
Sets the color that text will be rendered in.