35  connect( mSetContentsButton, &QPushButton::clicked, 
this, &QgsLayoutManualTableWidget::setTableContents );
 
   36  connect( mMarginSpinBox, 
static_cast < void ( QDoubleSpinBox::* )( 
double ) 
> ( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutManualTableWidget::mMarginSpinBox_valueChanged );
 
   37  connect( mGridStrokeWidthSpinBox, 
static_cast < void ( QDoubleSpinBox::* )( 
double ) 
> ( &QDoubleSpinBox::valueChanged ), 
this, &QgsLayoutManualTableWidget::mGridStrokeWidthSpinBox_valueChanged );
 
   39  connect( mBackgroundColorButton, &
QgsColorButton::colorChanged, 
this, &QgsLayoutManualTableWidget::mBackgroundColorButton_colorChanged );
 
   40  connect( mDrawHorizontalGrid, &QCheckBox::toggled, 
this, &QgsLayoutManualTableWidget::mDrawHorizontalGrid_toggled );
 
   41  connect( mDrawVerticalGrid, &QCheckBox::toggled, 
this, &QgsLayoutManualTableWidget::mDrawVerticalGrid_toggled );
 
   42  connect( mShowGridGroupCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, 
this, &QgsLayoutManualTableWidget::mShowGridGroupCheckBox_toggled );
 
   43  connect( mHeaderHAlignmentComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutManualTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged );
 
   44  connect( mHeaderModeComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutManualTableWidget::mHeaderModeComboBox_currentIndexChanged );
 
   45  connect( mAddFramePushButton, &QPushButton::clicked, 
this, &QgsLayoutManualTableWidget::mAddFramePushButton_clicked );
 
   46  connect( mResizeModeComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutManualTableWidget::mResizeModeComboBox_currentIndexChanged );
 
   47  connect( mDrawEmptyCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutManualTableWidget::mDrawEmptyCheckBox_toggled );
 
   48  connect( mEmptyFrameCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutManualTableWidget::mEmptyFrameCheckBox_toggled );
 
   49  connect( mHideEmptyBgCheckBox, &QCheckBox::toggled, 
this, &QgsLayoutManualTableWidget::mHideEmptyBgCheckBox_toggled );
 
   50  connect( mWrapBehaviorComboBox, 
static_cast<void ( QComboBox::* )( 
int )
>( &QComboBox::currentIndexChanged ), 
this, &QgsLayoutManualTableWidget::mWrapBehaviorComboBox_currentIndexChanged );
 
   51  connect( mAdvancedCustomizationButton, &QPushButton::clicked, 
this, &QgsLayoutManualTableWidget::mAdvancedCustomizationButton_clicked );
 
   57  mContentFontToolButton->registerExpressionContextGenerator( 
this );
 
   58  mHeaderFontToolButton->registerExpressionContextGenerator( 
this );
 
   60  blockAllSignals( 
true );
 
   78  mGridColorButton->setColorDialogTitle( tr( 
"Select Grid Color" ) );
 
   79  mGridColorButton->setAllowOpacity( 
true );
 
   80  mGridColorButton->setContext( QStringLiteral( 
"composer" ) );
 
   81  mGridColorButton->setDefaultColor( Qt::black );
 
   82  mBackgroundColorButton->setColorDialogTitle( tr( 
"Select Background Color" ) );
 
   83  mBackgroundColorButton->setAllowOpacity( 
true );
 
   84  mBackgroundColorButton->setContext( QStringLiteral( 
"composer" ) );
 
   85  mBackgroundColorButton->setShowNoColor( 
true );
 
   86  mBackgroundColorButton->setNoColorString( tr( 
"No Background" ) );
 
  100    mainLayout->addWidget( mItemPropertiesWidget );
 
  103  connect( mHeaderFontToolButton, &
QgsFontButton::changed, 
this, &QgsLayoutManualTableWidget::headerFontChanged );
 
  104  connect( mContentFontToolButton, &
QgsFontButton::changed, 
this, &QgsLayoutManualTableWidget::contentFontChanged );
 
 
  109  if ( mItemPropertiesWidget )
 
 
  119    context = mFrame->createExpressionContext();
 
  121    context = mTable->createExpressionContext();
 
  123  std::unique_ptr< QgsExpressionContextScope > cellScope = std::make_unique< QgsExpressionContextScope >();
 
  124  cellScope->setVariable( QStringLiteral( 
"row_number" ), 1, 
true );
 
  125  cellScope->setVariable( QStringLiteral( 
"column_number" ), 1, 
true );
 
  129                                     QStringLiteral( 
"column_number" )} );
 
 
  153    mEditorDialog->close();
 
  156  mTable = qobject_cast< QgsLayoutItemManualTable * >( multiFrame );
 
  158  mItemPropertiesWidget->
setItem( frame );
 
 
  170void QgsLayoutManualTableWidget::setTableContents()
 
  180    mEditorDialog->show();
 
  181    mEditorDialog->raise();
 
  182    mEditorDialog->setWindowState( windowState() & ~Qt::WindowMinimized );
 
  183    mEditorDialog->activateWindow();
 
  188    mEditorDialog->registerExpressionContextGenerator( mTable );
 
  189    connect( 
this, &QWidget::destroyed, mEditorDialog, &QMainWindow::close );
 
  191    mEditorDialog->setIncludeTableHeader( mTable->includeTableHeader() );
 
  192    mEditorDialog->setTableContents( mTable->tableContents() );
 
  195    const QList< double > rowHeights = mTable->rowHeights();
 
  196    for ( 
const double height : rowHeights )
 
  198      mEditorDialog->setTableRowHeight( row, height );
 
  202    const QList< double > columnWidths = mTable->columnWidths();
 
  203    QVariantList headers;
 
  204    headers.reserve( columnWidths.size() );
 
  205    for ( 
const double width : columnWidths )
 
  207      mEditorDialog->setTableColumnWidth( col, width );
 
  208      headers << ( col < mTable->headers().count() ? mTable->headers().value( col ).heading() : QVariant() );
 
  211    mEditorDialog->setTableHeaders( headers );
 
  217        mTable->beginCommand( tr( 
"Change Table Contents" ) );
 
  218        mTable->setTableContents( mEditorDialog->tableContents() );
 
  220        const QVariantList headerText = mEditorDialog->tableHeaders();
 
  221        if ( mEditorDialog->includeTableHeader() )
 
  224          for ( 
const QVariant &h : headerText )
 
  228          mTable->setHeaders( headers );
 
  231        const int rowCount = mTable->tableContents().size();
 
  232        QList< double > rowHeights;
 
  233        rowHeights.reserve( rowCount );
 
  234        for ( 
int row = 0; row < rowCount; ++row )
 
  236          rowHeights << mEditorDialog->tableRowHeight( row );
 
  238        mTable->setRowHeights( rowHeights );
 
  240        if ( !mTable->tableContents().empty() )
 
  242          const int columnCount = mTable->tableContents().at( 0 ).size();
 
  243          QList< double > columnWidths;
 
  244          columnWidths.reserve( columnCount );
 
  245          for ( 
int col = 0; col < columnCount; ++col )
 
  247            columnWidths << mEditorDialog->tableColumnWidth( col );
 
  249          mTable->setColumnWidths( columnWidths );
 
  252        mTable->endCommand();
 
  260        mTable->beginCommand( tr( 
"Change Table Header" ) );
 
  261        mTable->setIncludeTableHeader( included );
 
  262        mTable->endCommand();
 
  265    mEditorDialog->show();
 
  269void QgsLayoutManualTableWidget::mMarginSpinBox_valueChanged( 
double d )
 
  277  mTable->setCellMargin( d );
 
  278  mTable->endCommand();
 
  281void QgsLayoutManualTableWidget::contentFontChanged()
 
  288  mTable->beginCommand( tr( 
"Change Table Font" ) );
 
  289  mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
 
  290  mTable->endCommand();
 
  293void QgsLayoutManualTableWidget::mGridStrokeWidthSpinBox_valueChanged( 
double d )
 
  301  mTable->setGridStrokeWidth( d );
 
  302  mTable->endCommand();
 
  305void QgsLayoutManualTableWidget::mGridColorButton_colorChanged( 
const QColor &newColor )
 
  313  mTable->setGridColor( newColor );
 
  314  mTable->endCommand();
 
  317void QgsLayoutManualTableWidget::mDrawHorizontalGrid_toggled( 
bool state )
 
  324  mTable->beginCommand( tr( 
"Toggle Table Grid" ) );
 
  325  mTable->setHorizontalGrid( state );
 
  326  mTable->endCommand();
 
  329void QgsLayoutManualTableWidget::mDrawVerticalGrid_toggled( 
bool state )
 
  336  mTable->beginCommand( tr( 
"Toggled Table Grid" ) );
 
  337  mTable->setVerticalGrid( state );
 
  338  mTable->endCommand();
 
  341void QgsLayoutManualTableWidget::mShowGridGroupCheckBox_toggled( 
bool state )
 
  348  mTable->beginCommand( tr( 
"Toggle Table Grid" ) );
 
  349  mTable->setShowGrid( state );
 
  350  mTable->endCommand();
 
  353void QgsLayoutManualTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged( 
int )
 
  360  mTable->beginCommand( tr( 
"Change Table Alignment" ) );
 
  362  mTable->endCommand();
 
  365void QgsLayoutManualTableWidget::mHeaderModeComboBox_currentIndexChanged( 
int )
 
  372  mTable->beginCommand( tr( 
"Change Table Header Mode" ) );
 
  374  mTable->endCommand();
 
  377void QgsLayoutManualTableWidget::mBackgroundColorButton_colorChanged( 
const QColor &newColor )
 
  385  mTable->setBackgroundColor( newColor );
 
  386  mTable->endCommand();
 
  389void QgsLayoutManualTableWidget::headerFontChanged()
 
  394  mTable->beginCommand( tr( 
"Change Table Font" ) );
 
  395  mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
 
  396  mTable->endCommand();
 
  399void QgsLayoutManualTableWidget::updateGuiElements()
 
  401  if ( !mTable || !mFrame )
 
  406  blockAllSignals( 
true );
 
  408  mMarginSpinBox->setValue( mTable->cellMargin() );
 
  409  mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
 
  410  mGridColorButton->setColor( mTable->gridColor() );
 
  411  mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
 
  412  mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
 
  413  if ( mTable->showGrid() )
 
  415    mShowGridGroupCheckBox->setChecked( 
true );
 
  419    mShowGridGroupCheckBox->setChecked( 
false );
 
  421  mBackgroundColorButton->setColor( mTable->backgroundColor() );
 
  423  mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
 
  424  mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
 
  426  mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
 
  427  mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
 
  429  mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
 
  432  mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
 
  433  mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
 
  435  mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
 
  436  mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
 
  438  blockAllSignals( 
false );
 
  441void QgsLayoutManualTableWidget::blockAllSignals( 
bool b )
 
  443  mMarginSpinBox->blockSignals( b );
 
  444  mGridColorButton->blockSignals( b );
 
  445  mGridStrokeWidthSpinBox->blockSignals( b );
 
  446  mBackgroundColorButton->blockSignals( b );
 
  447  mDrawHorizontalGrid->blockSignals( b );
 
  448  mDrawVerticalGrid->blockSignals( b );
 
  449  mShowGridGroupCheckBox->blockSignals( b );
 
  450  mResizeModeComboBox->blockSignals( b );
 
  451  mEmptyFrameCheckBox->blockSignals( b );
 
  452  mHideEmptyBgCheckBox->blockSignals( b );
 
  453  mDrawEmptyCheckBox->blockSignals( b );
 
  454  mWrapBehaviorComboBox->blockSignals( b );
 
  455  mContentFontToolButton->blockSignals( b );
 
  456  mHeaderHAlignmentComboBox->blockSignals( b );
 
  457  mHeaderModeComboBox->blockSignals( b );
 
  458  mHeaderFontToolButton->blockSignals( b );
 
  461void QgsLayoutManualTableWidget::mEmptyFrameCheckBox_toggled( 
bool checked )
 
  468  mFrame->beginCommand( tr( 
"Toggle Empty Frame Mode" ) );
 
  469  mFrame->setHidePageIfEmpty( checked );
 
  470  mFrame->endCommand();
 
  473void QgsLayoutManualTableWidget::mHideEmptyBgCheckBox_toggled( 
bool checked )
 
  480  mFrame->beginCommand( tr( 
"Toggle Background Display" ) );
 
  481  mFrame->setHideBackgroundIfEmpty( checked );
 
  482  mFrame->endCommand();
 
  485void QgsLayoutManualTableWidget::mAddFramePushButton_clicked()
 
  487  if ( !mTable || !mFrame )
 
  493  QPointF pos = mFrame->pos();
 
  495  pos.ry() += mFrame->rect().height() + 10;
 
  497  QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
 
  498  mTable->recalculateFrameSizes();
 
  501  if ( 
QgsLayout *layout = mTable->layout() )
 
  503    layout->setSelectedItem( newFrame );
 
  507void QgsLayoutManualTableWidget::mResizeModeComboBox_currentIndexChanged( 
int index )
 
  514  mTable->beginCommand( tr( 
"Change Resize Mode" ) );
 
  516  mTable->endCommand();
 
  521void QgsLayoutManualTableWidget::mWrapBehaviorComboBox_currentIndexChanged( 
int index )
 
  528  mTable->beginCommand( tr( 
"Change Table Wrap Mode" ) );
 
  530  mTable->endCommand();
 
  533void QgsLayoutManualTableWidget::mAdvancedCustomizationButton_clicked()
 
  545void QgsLayoutManualTableWidget::mDrawEmptyCheckBox_toggled( 
bool checked )
 
  552  mTable->beginCommand( tr( 
"Change Show Empty Rows" ) );
 
  553  mTable->setShowEmptyRows( checked );
 
  554  mTable->endCommand();
 
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 frame items, which form a layout multiframe item.
 
QgsLayoutMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
 
A layout table subclass that displays manually entered (and formatted) content.
 
@ LayoutManualTable
Manual (fixed) table.
 
Base class for graphical items within a QgsLayout.
 
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
 
virtual int type() const =0
Returns unique multiframe type id.
 
ResizeMode
Specifies the behavior for creating new frames to fit the multiframe's content.
 
@ UseExistingFrames
Don't automatically create new frames, just use existing frames.
 
@ ExtendToNextPage
Creates new full page frames on the following page(s) until the entire multiframe content is visible.
 
@ UndoTableBackgroundColor
Table background color.
 
@ UndoTableGridStrokeWidth
Table grid stroke width.
 
@ UndoTableGridColor
Table grid color.
 
@ UndoTableMargin
Table margins.
 
void changed()
Emitted when the object's properties change.
 
A dialog for customization of the cell background colors for a QgsLayoutTable.
 
Stores properties of a column for a QgsLayoutTable.
 
HeaderMode
Controls where headers are shown in the table.
 
@ FirstFrame
Header shown on first frame only.
 
@ AllFrames
Headers shown on all frames.
 
@ NoHeaders
No headers shown for table.
 
WrapBehavior
Controls how long strings in the table are handled.
 
@ WrapText
Text which doesn't fit inside the cell is wrapped. Note that this only applies to text in columns wit...
 
@ TruncateText
Text which doesn't fit inside the cell is truncated.
 
HeaderHAlignment
Controls how headers are horizontally aligned in a table.
 
@ HeaderRight
Align headers right.
 
@ HeaderLeft
Align headers left.
 
@ HeaderCenter
Align headers to center.
 
@ FollowColumn
Header uses the same alignment as the column.
 
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
 
Interface for master layout type objects, such as print layouts and reports.
 
A reusable window for editing simple spreadsheet-style tables.
 
void includeHeaderChanged(bool included)
Emitted whenever the "include table header" setting is changed.
 
void tableChanged()
Emitted whenever the table contents are changed.
 
QVector< QgsLayoutTableColumn > QgsLayoutTableColumns
List of column definitions for a QgsLayoutTable.