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( mHeaderFontColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutManualTableWidget::mHeaderFontColorButton_colorChanged );
41 connect( mContentFontColorButton, &
QgsColorButton::colorChanged,
this, &QgsLayoutManualTableWidget::mContentFontColorButton_colorChanged );
42 connect( mDrawHorizontalGrid, &QCheckBox::toggled,
this, &QgsLayoutManualTableWidget::mDrawHorizontalGrid_toggled );
43 connect( mDrawVerticalGrid, &QCheckBox::toggled,
this, &QgsLayoutManualTableWidget::mDrawVerticalGrid_toggled );
44 connect( mShowGridGroupCheckBox, &QgsCollapsibleGroupBoxBasic::toggled,
this, &QgsLayoutManualTableWidget::mShowGridGroupCheckBox_toggled );
45 connect( mHeaderHAlignmentComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutManualTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged );
46 connect( mHeaderModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutManualTableWidget::mHeaderModeComboBox_currentIndexChanged );
47 connect( mAddFramePushButton, &QPushButton::clicked,
this, &QgsLayoutManualTableWidget::mAddFramePushButton_clicked );
48 connect( mResizeModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutManualTableWidget::mResizeModeComboBox_currentIndexChanged );
49 connect( mDrawEmptyCheckBox, &QCheckBox::toggled,
this, &QgsLayoutManualTableWidget::mDrawEmptyCheckBox_toggled );
50 connect( mEmptyFrameCheckBox, &QCheckBox::toggled,
this, &QgsLayoutManualTableWidget::mEmptyFrameCheckBox_toggled );
51 connect( mHideEmptyBgCheckBox, &QCheckBox::toggled,
this, &QgsLayoutManualTableWidget::mHideEmptyBgCheckBox_toggled );
52 connect( mWrapBehaviorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLayoutManualTableWidget::mWrapBehaviorComboBox_currentIndexChanged );
53 connect( mAdvancedCustomizationButton, &QPushButton::clicked,
this, &QgsLayoutManualTableWidget::mAdvancedCustomizationButton_clicked );
59 blockAllSignals(
true );
77 mHeaderFontColorButton->setColorDialogTitle( tr(
"Select Header Font Color" ) );
78 mHeaderFontColorButton->setAllowOpacity(
true );
79 mHeaderFontColorButton->setContext( QStringLiteral(
"composer" ) );
80 mContentFontColorButton->setColorDialogTitle( tr(
"Select Content Font Color" ) );
81 mContentFontColorButton->setAllowOpacity(
true );
82 mContentFontColorButton->setContext( QStringLiteral(
"composer" ) );
83 mGridColorButton->setColorDialogTitle( tr(
"Select Grid Color" ) );
84 mGridColorButton->setAllowOpacity(
true );
85 mGridColorButton->setContext( QStringLiteral(
"composer" ) );
86 mGridColorButton->setDefaultColor( Qt::black );
87 mBackgroundColorButton->setColorDialogTitle( tr(
"Select Background Color" ) );
88 mBackgroundColorButton->setAllowOpacity(
true );
89 mBackgroundColorButton->setContext( QStringLiteral(
"composer" ) );
90 mBackgroundColorButton->setShowNoColor(
true );
91 mBackgroundColorButton->setNoColorString( tr(
"No Background" ) );
105 mainLayout->addWidget( mItemPropertiesWidget );
108 connect( mHeaderFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutManualTableWidget::headerFontChanged );
109 connect( mContentFontToolButton, &
QgsFontButton::changed,
this, &QgsLayoutManualTableWidget::contentFontChanged );
114 if ( mItemPropertiesWidget )
137 mEditorDialog->close();
142 mItemPropertiesWidget->
setItem( frame );
154 void QgsLayoutManualTableWidget::setTableContents()
164 mEditorDialog->show();
165 mEditorDialog->raise();
166 mEditorDialog->setWindowState( windowState() & ~Qt::WindowMinimized );
167 mEditorDialog->activateWindow();
171 mEditorDialog =
new QgsTableEditorDialog(
this );
172 connect(
this, &QWidget::destroyed, mEditorDialog, &QMainWindow::close );
174 mEditorDialog->setIncludeTableHeader( mTable->includeTableHeader() );
175 mEditorDialog->setTableContents( mTable->tableContents() );
178 const QList< double > rowHeights = mTable->rowHeights();
179 for (
double height : rowHeights )
181 mEditorDialog->setTableRowHeight( row, height );
185 const QList< double > columnWidths = mTable->columnWidths();
186 QVariantList headers;
187 headers.reserve( columnWidths.size() );
188 for (
double width : columnWidths )
190 mEditorDialog->setTableColumnWidth( col, width );
191 headers << mTable->headers().value( col )->heading();
194 mEditorDialog->setTableHeaders( headers );
196 connect( mEditorDialog, &QgsTableEditorDialog::tableChanged,
this, [ = ]
200 mTable->beginCommand( tr(
"Change Table Contents" ) );
201 mTable->setTableContents( mEditorDialog->tableContents() );
203 const QVariantList headerText = mEditorDialog->tableHeaders();
204 if ( mEditorDialog->includeTableHeader() )
207 for (
const QVariant &h : headerText )
211 mTable->setHeaders( headers );
214 const int rowCount = mTable->tableContents().size();
215 QList< double > rowHeights;
216 rowHeights.reserve( rowCount );
217 for (
int row = 0; row < rowCount; ++row )
219 rowHeights << mEditorDialog->tableRowHeight( row );
221 mTable->setRowHeights( rowHeights );
223 if ( !mTable->tableContents().empty() )
225 const int columnCount = mTable->tableContents().at( 0 ).size();
226 QList< double > columnWidths;
227 columnWidths.reserve( columnCount );
228 for (
int col = 0; col < columnCount; ++col )
230 columnWidths << mEditorDialog->tableColumnWidth( col );
232 mTable->setColumnWidths( columnWidths );
235 mTable->endCommand();
239 connect( mEditorDialog, &QgsTableEditorDialog::includeHeaderChanged,
this, [ = ](
bool included )
243 mTable->beginCommand( tr(
"Change Table Header" ) );
244 mTable->setIncludeTableHeader( included );
245 mTable->endCommand();
248 mEditorDialog->show();
252 void QgsLayoutManualTableWidget::mMarginSpinBox_valueChanged(
double d )
260 mTable->setCellMargin( d );
261 mTable->endCommand();
264 void QgsLayoutManualTableWidget::contentFontChanged()
271 mTable->beginCommand( tr(
"Change Table Font" ) );
272 mTable->setContentFont( mContentFontToolButton->currentFont() );
273 mTable->endCommand();
276 void QgsLayoutManualTableWidget::mContentFontColorButton_colorChanged(
const QColor &newColor )
284 mTable->setContentFontColor( newColor );
285 mTable->endCommand();
288 void QgsLayoutManualTableWidget::mHeaderFontColorButton_colorChanged(
const QColor &newColor )
296 mTable->setHeaderFontColor( newColor );
297 mTable->endCommand();
300 void QgsLayoutManualTableWidget::mGridStrokeWidthSpinBox_valueChanged(
double d )
308 mTable->setGridStrokeWidth( d );
309 mTable->endCommand();
312 void QgsLayoutManualTableWidget::mGridColorButton_colorChanged(
const QColor &newColor )
320 mTable->setGridColor( newColor );
321 mTable->endCommand();
324 void QgsLayoutManualTableWidget::mDrawHorizontalGrid_toggled(
bool state )
331 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
332 mTable->setHorizontalGrid( state );
333 mTable->endCommand();
336 void QgsLayoutManualTableWidget::mDrawVerticalGrid_toggled(
bool state )
343 mTable->beginCommand( tr(
"Toggled Table Grid" ) );
344 mTable->setVerticalGrid( state );
345 mTable->endCommand();
348 void QgsLayoutManualTableWidget::mShowGridGroupCheckBox_toggled(
bool state )
355 mTable->beginCommand( tr(
"Toggle Table Grid" ) );
356 mTable->setShowGrid( state );
357 mTable->endCommand();
360 void QgsLayoutManualTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged(
int )
367 mTable->beginCommand( tr(
"Change Table Alignment" ) );
368 mTable->setHeaderHAlignment( static_cast< QgsLayoutTable::HeaderHAlignment >( mHeaderHAlignmentComboBox->currentData().toInt() ) );
369 mTable->endCommand();
372 void QgsLayoutManualTableWidget::mHeaderModeComboBox_currentIndexChanged(
int )
379 mTable->beginCommand( tr(
"Change Table Header Mode" ) );
380 mTable->setHeaderMode( static_cast< QgsLayoutTable::HeaderMode >( mHeaderModeComboBox->currentData().toInt() ) );
381 mTable->endCommand();
384 void QgsLayoutManualTableWidget::mBackgroundColorButton_colorChanged(
const QColor &newColor )
392 mTable->setBackgroundColor( newColor );
393 mTable->endCommand();
396 void QgsLayoutManualTableWidget::headerFontChanged()
401 mTable->beginCommand( tr(
"Change Table Font" ) );
402 mTable->setHeaderFont( mHeaderFontToolButton->currentFont() );
403 mTable->endCommand();
406 void QgsLayoutManualTableWidget::updateGuiElements()
408 if ( !mTable || !mFrame )
413 blockAllSignals(
true );
415 mMarginSpinBox->setValue( mTable->cellMargin() );
416 mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
417 mGridColorButton->setColor( mTable->gridColor() );
418 mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
419 mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
420 if ( mTable->showGrid() )
422 mShowGridGroupCheckBox->setChecked(
true );
426 mShowGridGroupCheckBox->setChecked(
false );
428 mBackgroundColorButton->setColor( mTable->backgroundColor() );
430 mHeaderFontColorButton->setColor( mTable->headerFontColor() );
431 mContentFontColorButton->setColor( mTable->contentFontColor() );
432 mHeaderFontToolButton->setCurrentFont( mTable->headerFont() );
433 mContentFontToolButton->setCurrentFont( mTable->contentFont() );
435 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
436 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
438 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
441 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
442 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
444 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
445 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
447 blockAllSignals(
false );
450 void QgsLayoutManualTableWidget::blockAllSignals(
bool b )
452 mMarginSpinBox->blockSignals( b );
453 mGridColorButton->blockSignals( b );
454 mGridStrokeWidthSpinBox->blockSignals( b );
455 mBackgroundColorButton->blockSignals( b );
456 mDrawHorizontalGrid->blockSignals( b );
457 mDrawVerticalGrid->blockSignals( b );
458 mShowGridGroupCheckBox->blockSignals( b );
459 mContentFontColorButton->blockSignals( b );
460 mHeaderFontColorButton->blockSignals( b );
461 mResizeModeComboBox->blockSignals( b );
462 mEmptyFrameCheckBox->blockSignals( b );
463 mHideEmptyBgCheckBox->blockSignals( b );
464 mDrawEmptyCheckBox->blockSignals( b );
465 mWrapBehaviorComboBox->blockSignals( b );
466 mContentFontToolButton->blockSignals( b );
467 mHeaderHAlignmentComboBox->blockSignals( b );
468 mHeaderModeComboBox->blockSignals( b );
469 mHeaderFontToolButton->blockSignals( b );
472 void QgsLayoutManualTableWidget::mEmptyFrameCheckBox_toggled(
bool checked )
479 mFrame->beginCommand( tr(
"Toggle Empty Frame Mode" ) );
480 mFrame->setHidePageIfEmpty( checked );
481 mFrame->endCommand();
484 void QgsLayoutManualTableWidget::mHideEmptyBgCheckBox_toggled(
bool checked )
491 mFrame->beginCommand( tr(
"Toggle Background Display" ) );
492 mFrame->setHideBackgroundIfEmpty( checked );
493 mFrame->endCommand();
496 void QgsLayoutManualTableWidget::mAddFramePushButton_clicked()
498 if ( !mTable || !mFrame )
504 QPointF pos = mFrame->pos();
506 pos.ry() += mFrame->rect().height() + 10;
508 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
509 mTable->recalculateFrameSizes();
512 if (
QgsLayout *layout = mTable->layout() )
514 layout->setSelectedItem( newFrame );
518 void QgsLayoutManualTableWidget::mResizeModeComboBox_currentIndexChanged(
int index )
525 mTable->beginCommand( tr(
"Change Resize Mode" ) );
526 mTable->setResizeMode( static_cast< QgsLayoutMultiFrame::ResizeMode >( mResizeModeComboBox->itemData( index ).toInt() ) );
527 mTable->endCommand();
532 void QgsLayoutManualTableWidget::mWrapBehaviorComboBox_currentIndexChanged(
int index )
539 mTable->beginCommand( tr(
"Change Table Wrap Mode" ) );
540 mTable->setWrapBehavior( static_cast< QgsLayoutTable::WrapBehavior >( mWrapBehaviorComboBox->itemData( index ).toInt() ) );
541 mTable->endCommand();
544 void QgsLayoutManualTableWidget::mAdvancedCustomizationButton_clicked()
556 void QgsLayoutManualTableWidget::mDrawEmptyCheckBox_toggled(
bool checked )
563 mTable->beginCommand( tr(
"Change Show Empty Rows" ) );
564 mTable->setShowEmptyRows( checked );
565 mTable->endCommand();
Base class for graphical items within a QgsLayout.
Header uses the same alignment as the column.
Don't automatically create new frames, just use existing frames.
QVector< QgsLayoutTableColumn *> QgsLayoutTableColumns
List of column definitions for a QgsLayoutTable.
Text which doesn't fit inside the cell is truncated.
Text which doesn't fit inside the cell is wrapped. Note that this only applies to text in columns wit...
Creates new full page frames on the following page(s) until the entire multiframe content is visible...
A dialog for customization of the cell background colors for a QgsLayoutTable.
Stores properties of a column for a QgsLayoutTable.
Abstract base class for layout items with the ability to distribute the content to several frames (Qg...
No headers shown for table.
Table content font color.
QgsLayoutMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
Header shown on first frame only.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
virtual int type() const =0
Returns unique multiframe type id.
Headers shown on all frames.
A layout table subclass that displays manually entered (and formatted) content.
Interface for master layout type objects, such as print layouts and reports.
void changed()
Emitted when the object's properties change.
Base class for frame items, which form a layout multiframe item.