26#include "moc_qgstableeditorformattingwidget.cpp"
28using namespace Qt::StringLiterals;
36 mFormatNumbersCheckBox->setTristate(
false );
38 mFontButton->setShowNullFormat(
true );
39 mFontButton->setNoFormatString( tr(
"Clear Formatting" ) );
41 mBackgroundColorButton->setAllowOpacity(
true );
42 mBackgroundColorButton->setColorDialogTitle( tr(
"Background Color" ) );
43 mBackgroundColorButton->setDefaultColor( QColor( 255, 255, 255 ) );
44 mBackgroundColorButton->setShowNull(
true );
46 mHorizontalAlignComboBox->setAvailableAlignments( Qt::AlignLeft | Qt::AlignHCenter | Qt::AlignRight | Qt::AlignJustify );
47 mVerticalAlignComboBox->setAvailableAlignments( Qt::AlignTop | Qt::AlignVCenter | Qt::AlignBottom );
49 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
50 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
61 connect( mFormatNumbersCheckBox, &QCheckBox::stateChanged,
this, [
this](
int state ) {
62 mCustomizeFormatButton->setEnabled( state == Qt::Checked );
63 if ( state != Qt::PartiallyChecked )
64 mFormatNumbersCheckBox->setTristate(
false );
74 mCustomizeFormatButton->setEnabled(
false );
75 connect( mCustomizeFormatButton, &QPushButton::clicked,
this, [
this] {
77 widget->
setFormat( mNumericFormat.get() );
80 mNumericFormat.reset( widget->
format() );
86 connect( mRowHeightSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double height ) {
92 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
96 connect( mColumnWidthSpinBox, qOverload<double>( &QDoubleSpinBox::valueChanged ),
this, [
this](
double width ) {
102 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
108 if ( !mBlockSignals )
115 if ( !mBlockSignals )
122 if ( !mBlockSignals )
128 mExpressionEdit->setAllowEmptyFieldName(
true );
130 mExpressionEdit->registerExpressionContextGenerator(
this );
131 mFontButton->registerExpressionContextGenerator(
this );
136 if ( !mNumericFormat || mFormatNumbersCheckBox->checkState() != Qt::Checked )
139 return mNumericFormat->
clone();
144 return mFontButton->textFormat();
150 mBackgroundColorButton->
setColor( color );
156 mNumericFormat.reset( format ? format->
clone() :
nullptr );
158 mFormatNumbersCheckBox->setTristate( isMixedFormat );
159 mFormatNumbersCheckBox->setCheckState( isMixedFormat ? Qt::PartiallyChecked : ( mNumericFormat.get() ? Qt::Checked : Qt::Unchecked ) );
166 mFontButton->setTextFormat( format );
174 mRowHeightSpinBox->setClearValue( 0, tr(
"Mixed" ) );
176 mRowHeightSpinBox->setClearValue( 0, tr(
"Automatic" ) );
177 mRowHeightSpinBox->setValue( height < 0 ? 0 : height );
185 mColumnWidthSpinBox->setClearValue( 0, tr(
"Mixed" ) );
187 mColumnWidthSpinBox->setClearValue( 0, tr(
"Automatic" ) );
188 mColumnWidthSpinBox->setValue( width < 0 ? 0 : width );
195 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
196 mHorizontalAlignComboBox->setCurrentIndex( -1 );
198 mHorizontalAlignComboBox->setCurrentAlignment( alignment );
205 if ( alignment & Qt::AlignHorizontal_Mask && alignment & Qt::AlignVertical_Mask )
206 mVerticalAlignComboBox->setCurrentIndex( -1 );
208 mVerticalAlignComboBox->setCurrentAlignment( alignment );
216 mExpressionEdit->setExpression( QString() );
218 mExpressionEdit->setExpression( property.
asExpression() );
224 mExpressionEdit->setLayer( layer );
229 mContextGenerator = generator;
235 if ( mContextGenerator )
236 context = mContextGenerator->createExpressionContext();
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.