QGIS API Documentation 4.3.0-Master (dfb0041329c)
Loading...
Searching...
No Matches
qgslayoutmanualtablewidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutmanualtablewidget.h
3 ---------------------------------
4 begin : January 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19
20#include "qgsguiutils.h"
21#include "qgslayout.h"
22#include "qgslayoutatlas.h"
23#include "qgslayoutframe.h"
25#include "qgslayoutitemwidget.h"
29#include "qgsprintlayout.h"
30
31#include <QString>
32
33#include "moc_qgslayoutmanualtablewidget.cpp"
34
35using namespace Qt::StringLiterals;
36
37QPointer<QgsTableEditorDialog> QgsLayoutManualTableWidget::sEditorDialog = nullptr;
38
40 : QgsLayoutItemBaseWidget( nullptr, frame ? qobject_cast<QgsLayoutItemManualTable *>( frame->multiFrame() ) : nullptr )
41 , mTable( frame ? qobject_cast<QgsLayoutItemManualTable *>( frame->multiFrame() ) : nullptr )
42 , mFrame( frame )
43{
44 setupUi( this );
45
46 connect( mSetContentsButton, &QPushButton::clicked, this, &QgsLayoutManualTableWidget::setTableContents );
47 connect( mMarginSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutManualTableWidget::mMarginSpinBox_valueChanged );
48 connect( mGridStrokeWidthSpinBox, static_cast<void ( QDoubleSpinBox::* )( double )>( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutManualTableWidget::mGridStrokeWidthSpinBox_valueChanged );
49 connect( mGridColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutManualTableWidget::mGridColorButton_colorChanged );
50 connect( mBackgroundColorButton, &QgsColorButton::colorChanged, this, &QgsLayoutManualTableWidget::mBackgroundColorButton_colorChanged );
51 connect( mDrawHorizontalGrid, &QCheckBox::toggled, this, &QgsLayoutManualTableWidget::mDrawHorizontalGrid_toggled );
52 connect( mDrawVerticalGrid, &QCheckBox::toggled, this, &QgsLayoutManualTableWidget::mDrawVerticalGrid_toggled );
53 connect( mShowGridGroupCheckBox, &QgsCollapsibleGroupBoxBasic::toggled, this, &QgsLayoutManualTableWidget::mShowGridGroupCheckBox_toggled );
54 connect( mHeaderHAlignmentComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutManualTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged );
55 connect( mHeaderModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutManualTableWidget::mHeaderModeComboBox_currentIndexChanged );
56 connect( mAddFramePushButton, &QPushButton::clicked, this, &QgsLayoutManualTableWidget::mAddFramePushButton_clicked );
57 connect( mResizeModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutManualTableWidget::mResizeModeComboBox_currentIndexChanged );
58 connect( mDrawEmptyCheckBox, &QCheckBox::toggled, this, &QgsLayoutManualTableWidget::mDrawEmptyCheckBox_toggled );
59 connect( mEmptyFrameCheckBox, &QCheckBox::toggled, this, &QgsLayoutManualTableWidget::mEmptyFrameCheckBox_toggled );
60 connect( mHideEmptyBgCheckBox, &QCheckBox::toggled, this, &QgsLayoutManualTableWidget::mHideEmptyBgCheckBox_toggled );
61 connect( mWrapBehaviorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutManualTableWidget::mWrapBehaviorComboBox_currentIndexChanged );
62 connect( mAdvancedCustomizationButton, &QPushButton::clicked, this, &QgsLayoutManualTableWidget::mAdvancedCustomizationButton_clicked );
63 setPanelTitle( tr( "Table Properties" ) );
64
65 mContentFontToolButton->setMode( QgsFontButton::ModeTextRenderer );
66 mHeaderFontToolButton->setMode( QgsFontButton::ModeTextRenderer );
67
68 mContentFontToolButton->registerExpressionContextGenerator( this );
69 mHeaderFontToolButton->registerExpressionContextGenerator( this );
70
71 blockAllSignals( true );
72
73 mResizeModeComboBox->addItem( tr( "Use Existing Frames" ), QgsLayoutMultiFrame::UseExistingFrames );
74 mResizeModeComboBox->addItem( tr( "Extend to Next Page" ), QgsLayoutMultiFrame::ExtendToNextPage );
75 mResizeModeComboBox->addItem( tr( "Repeat Until Finished" ), QgsLayoutMultiFrame::RepeatUntilFinished );
76
77 mWrapBehaviorComboBox->addItem( tr( "Truncate Text" ), QgsLayoutTable::TruncateText );
78 mWrapBehaviorComboBox->addItem( tr( "Wrap Text" ), QgsLayoutTable::WrapText );
79
80 mHeaderModeComboBox->addItem( tr( "On First Frame" ), QgsLayoutTable::FirstFrame );
81 mHeaderModeComboBox->addItem( tr( "On All Frames" ), QgsLayoutTable::AllFrames );
82 mHeaderModeComboBox->addItem( tr( "No Header" ), QgsLayoutTable::NoHeaders );
83
84 mHeaderHAlignmentComboBox->addItem( tr( "Follow Column Alignment" ), QgsLayoutTable::FollowColumn );
85 mHeaderHAlignmentComboBox->addItem( tr( "Left" ), QgsLayoutTable::HeaderLeft );
86 mHeaderHAlignmentComboBox->addItem( tr( "Center" ), QgsLayoutTable::HeaderCenter );
87 mHeaderHAlignmentComboBox->addItem( tr( "Right" ), QgsLayoutTable::HeaderRight );
88
89 mGridColorButton->setColorDialogTitle( tr( "Select Grid Color" ) );
90 mGridColorButton->setAllowOpacity( true );
91 mGridColorButton->setContext( u"composer"_s );
92 mGridColorButton->setDefaultColor( Qt::black );
93 mBackgroundColorButton->setColorDialogTitle( tr( "Select Background Color" ) );
94 mBackgroundColorButton->setAllowOpacity( true );
95 mBackgroundColorButton->setContext( u"composer"_s );
96 mBackgroundColorButton->setShowNoColor( true );
97 mBackgroundColorButton->setNoColorString( tr( "No Background" ) );
98 mBackgroundColorButton->setOpaqueColorString( tr( "Opaque Background" ) );
99
100 updateGuiElements();
101
102 if ( mTable )
103 {
104 connect( mTable, &QgsLayoutMultiFrame::changed, this, &QgsLayoutManualTableWidget::updateGuiElements );
105 }
106
107 //embed widget for general options
108 if ( mFrame )
109 {
110 //add widget for general composer item properties
111 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget( this, mFrame );
112 mainLayout->addWidget( mItemPropertiesWidget );
113 }
114
115 connect( mHeaderFontToolButton, &QgsFontButton::changed, this, &QgsLayoutManualTableWidget::headerFontChanged );
116 connect( mContentFontToolButton, &QgsFontButton::changed, this, &QgsLayoutManualTableWidget::contentFontChanged );
117}
118
120{
121 if ( mItemPropertiesWidget )
122 mItemPropertiesWidget->setMasterLayout( masterLayout );
123}
124
126{
127 QgsExpressionContext context;
128
129 // frames include their parent multiframe's context, so prefer that if possible
130 if ( mFrame )
131 context = mFrame->createExpressionContext();
132 else if ( mTable )
133 context = mTable->createExpressionContext();
134
135 auto cellScope = std::make_unique<QgsExpressionContextScope>();
136 cellScope->setVariable( u"row_number"_s, 1, true );
137 cellScope->setVariable( u"column_number"_s, 1, true );
138 context.appendScope( cellScope.release() );
139
140 context.setHighlightedVariables( { u"row_number"_s, u"column_number"_s } );
141
142 return context;
143}
144
146{
147 QgsLayoutFrame *frame = qobject_cast<QgsLayoutFrame *>( item );
148 if ( !frame )
149 return false;
150
151 QgsLayoutMultiFrame *multiFrame = frame->multiFrame();
152 if ( !multiFrame )
153 return false;
154
155 if ( multiFrame->type() != QgsLayoutItemRegistry::LayoutManualTable )
156 return false;
157
158 if ( mTable )
159 {
160 disconnect( mTable, &QgsLayoutObject::changed, this, &QgsLayoutManualTableWidget::updateGuiElements );
161 }
162 if ( sEditorDialog && sEditorDialog->table() != mTable )
163 {
164 sEditorDialog->close();
165 }
166
167 mTable = qobject_cast<QgsLayoutItemManualTable *>( multiFrame );
168 mFrame = frame;
169 mItemPropertiesWidget->setItem( frame );
170
171 if ( mTable )
172 {
173 connect( mTable, &QgsLayoutObject::changed, this, &QgsLayoutManualTableWidget::updateGuiElements );
174 }
175
176 updateGuiElements();
177
178 return true;
179}
180
182{
183 QgsLayoutItemManualTable *table = frame ? qobject_cast<QgsLayoutItemManualTable *>( frame->multiFrame() ) : nullptr;
184 if ( !table )
185 {
186 return;
187 }
188
189 if ( sEditorDialog )
190 {
191 // Dialog already exists, and linked to the same table => display it
192 if ( sEditorDialog->table() == table )
193 {
194 // the unholy quadfecta
195 sEditorDialog->show();
196 sEditorDialog->raise();
197 if ( parent )
198 {
199 sEditorDialog->setWindowState( parent->windowState() & ~Qt::WindowMinimized );
200 }
201 sEditorDialog->activateWindow();
202 return;
203 }
204 // Otherwise, close (and delete) the dialog
205 sEditorDialog->close();
206 }
207
208 sEditorDialog = new QgsTableEditorDialog( parent );
209 sEditorDialog->setTable( table );
210
211 connect( frame, &QgsLayoutFrame::destroyed, sEditorDialog, &QMainWindow::close );
212 auto updateName = [frame] { sEditorDialog->setWindowTitle( QString( "%1 - %2 " ).arg( tr( "Table Designer" ) ).arg( frame->displayName() ) ); };
213 connect( frame, &QgsLayoutFrame::changed, sEditorDialog, updateName );
214 updateName();
215
216 if ( parent )
217 connect( parent, &QWidget::destroyed, sEditorDialog, &QMainWindow::close );
218
219 connect( sEditorDialog, &QgsTableEditorDialog::tableChanged, table, [table] {
220 table->beginCommand( tr( "Change Table Contents" ) );
221 table->setTableContents( sEditorDialog->tableContents() );
222
223 const QVariantList headerText = sEditorDialog->tableHeaders();
224 if ( sEditorDialog->includeTableHeader() )
225 {
226 QgsLayoutTableColumns headers;
227 for ( const QVariant &h : headerText )
228 {
229 headers << QgsLayoutTableColumn( h.toString() );
230 }
231 table->setHeaders( headers );
232 }
233
234 const int rowCount = table->tableContents().size();
235 QList<double> rowHeights;
236 rowHeights.reserve( rowCount );
237 for ( int row = 0; row < rowCount; ++row )
238 {
239 rowHeights << sEditorDialog->tableRowHeight( row );
240 }
241 table->setRowHeights( rowHeights );
242
243 if ( !table->tableContents().empty() )
244 {
245 const int columnCount = table->tableContents().at( 0 ).size();
246 QList<double> columnWidths;
247 columnWidths.reserve( columnCount );
248 for ( int col = 0; col < columnCount; ++col )
249 {
250 columnWidths << sEditorDialog->tableColumnWidth( col );
251 }
252 table->setColumnWidths( columnWidths );
253 }
254
255 table->endCommand();
256 } );
257
258 connect( sEditorDialog, &QgsTableEditorDialog::includeHeaderChanged, table, [table]( bool included ) {
259 table->beginCommand( tr( "Change Table Header" ) );
260 table->setIncludeTableHeader( included );
261 table->endCommand();
262 } );
263 sEditorDialog->show();
264}
265
266void QgsLayoutManualTableWidget::setTableContents()
267{
268 openTableDesigner( mFrame, this );
269}
270
271void QgsLayoutManualTableWidget::mMarginSpinBox_valueChanged( double d )
272{
273 if ( !mTable )
274 {
275 return;
276 }
277
278 mTable->beginCommand( tr( "Change Table Margin" ), QgsLayoutMultiFrame::UndoTableMargin );
279 mTable->setCellMargin( d );
280 mTable->endCommand();
281}
282
283void QgsLayoutManualTableWidget::contentFontChanged()
284{
285 if ( !mTable )
286 {
287 return;
288 }
289
290 mTable->beginCommand( tr( "Change Table Font" ) );
291 mTable->setContentTextFormat( mContentFontToolButton->textFormat() );
292 mTable->endCommand();
293}
294
295void QgsLayoutManualTableWidget::mGridStrokeWidthSpinBox_valueChanged( double d )
296{
297 if ( !mTable )
298 {
299 return;
300 }
301
302 mTable->beginCommand( tr( "Change Table Line Width" ), QgsLayoutMultiFrame::UndoTableGridStrokeWidth );
303 mTable->setGridStrokeWidth( d );
304 mTable->endCommand();
305}
306
307void QgsLayoutManualTableWidget::mGridColorButton_colorChanged( const QColor &newColor )
308{
309 if ( !mTable )
310 {
311 return;
312 }
313
314 mTable->beginCommand( tr( "Change Table Grid Color" ), QgsLayoutMultiFrame::UndoTableGridColor );
315 mTable->setGridColor( newColor );
316 mTable->endCommand();
317}
318
319void QgsLayoutManualTableWidget::mDrawHorizontalGrid_toggled( bool state )
320{
321 if ( !mTable )
322 {
323 return;
324 }
325
326 mTable->beginCommand( tr( "Toggle Table Grid" ) );
327 mTable->setHorizontalGrid( state );
328 mTable->endCommand();
329}
330
331void QgsLayoutManualTableWidget::mDrawVerticalGrid_toggled( bool state )
332{
333 if ( !mTable )
334 {
335 return;
336 }
337
338 mTable->beginCommand( tr( "Toggled Table Grid" ) );
339 mTable->setVerticalGrid( state );
340 mTable->endCommand();
341}
342
343void QgsLayoutManualTableWidget::mShowGridGroupCheckBox_toggled( bool state )
344{
345 if ( !mTable )
346 {
347 return;
348 }
349
350 mTable->beginCommand( tr( "Toggle Table Grid" ) );
351 mTable->setShowGrid( state );
352 mTable->endCommand();
353}
354
355void QgsLayoutManualTableWidget::mHeaderHAlignmentComboBox_currentIndexChanged( int )
356{
357 if ( !mTable )
358 {
359 return;
360 }
361
362 mTable->beginCommand( tr( "Change Table Alignment" ) );
363 mTable->setHeaderHAlignment( static_cast<QgsLayoutTable::HeaderHAlignment>( mHeaderHAlignmentComboBox->currentData().toInt() ) );
364 mTable->endCommand();
365}
366
367void QgsLayoutManualTableWidget::mHeaderModeComboBox_currentIndexChanged( int )
368{
369 if ( !mTable )
370 {
371 return;
372 }
373
374 mTable->beginCommand( tr( "Change Table Header Mode" ) );
375 mTable->setHeaderMode( static_cast<QgsLayoutTable::HeaderMode>( mHeaderModeComboBox->currentData().toInt() ) );
376 mTable->endCommand();
377}
378
379void QgsLayoutManualTableWidget::mBackgroundColorButton_colorChanged( const QColor &newColor )
380{
381 if ( !mTable )
382 {
383 return;
384 }
385
386 mTable->beginCommand( tr( "Change Table Color" ), QgsLayoutMultiFrame::UndoTableBackgroundColor );
387 mTable->setBackgroundColor( newColor );
388 mTable->endCommand();
389}
390
391void QgsLayoutManualTableWidget::headerFontChanged()
392{
393 if ( !mTable )
394 return;
395
396 mTable->beginCommand( tr( "Change Table Font" ) );
397 mTable->setHeaderTextFormat( mHeaderFontToolButton->textFormat() );
398 mTable->endCommand();
399}
400
401void QgsLayoutManualTableWidget::updateGuiElements()
402{
403 if ( !mTable || !mFrame )
404 {
405 return;
406 }
407
408 blockAllSignals( true );
409
410 mMarginSpinBox->setValue( mTable->cellMargin() );
411 mGridStrokeWidthSpinBox->setValue( mTable->gridStrokeWidth() );
412 mGridColorButton->setColor( mTable->gridColor() );
413 mDrawHorizontalGrid->setChecked( mTable->horizontalGrid() );
414 mDrawVerticalGrid->setChecked( mTable->verticalGrid() );
415 if ( mTable->showGrid() )
416 {
417 mShowGridGroupCheckBox->setChecked( true );
418 }
419 else
420 {
421 mShowGridGroupCheckBox->setChecked( false );
422 }
423 mBackgroundColorButton->setColor( mTable->backgroundColor() );
424
425 mHeaderFontToolButton->setTextFormat( mTable->headerTextFormat() );
426 mContentFontToolButton->setTextFormat( mTable->contentTextFormat() );
427
428 mDrawEmptyCheckBox->setChecked( mTable->showEmptyRows() );
429 mWrapBehaviorComboBox->setCurrentIndex( mWrapBehaviorComboBox->findData( mTable->wrapBehavior() ) );
430
431 mResizeModeComboBox->setCurrentIndex( mResizeModeComboBox->findData( mTable->resizeMode() ) );
432 mAddFramePushButton->setEnabled( mTable->resizeMode() == QgsLayoutMultiFrame::UseExistingFrames );
433
434 mHeaderHAlignmentComboBox->setCurrentIndex( mHeaderHAlignmentComboBox->findData( mTable->headerHAlignment() ) );
435 mHeaderModeComboBox->setCurrentIndex( mHeaderModeComboBox->findData( mTable->headerMode() ) );
436
437 mEmptyFrameCheckBox->setChecked( mFrame->hidePageIfEmpty() );
438 mHideEmptyBgCheckBox->setChecked( mFrame->hideBackgroundIfEmpty() );
439
440 blockAllSignals( false );
441}
442
443void QgsLayoutManualTableWidget::blockAllSignals( bool b )
444{
445 mMarginSpinBox->blockSignals( b );
446 mGridColorButton->blockSignals( b );
447 mGridStrokeWidthSpinBox->blockSignals( b );
448 mBackgroundColorButton->blockSignals( b );
449 mDrawHorizontalGrid->blockSignals( b );
450 mDrawVerticalGrid->blockSignals( b );
451 mShowGridGroupCheckBox->blockSignals( b );
452 mResizeModeComboBox->blockSignals( b );
453 mEmptyFrameCheckBox->blockSignals( b );
454 mHideEmptyBgCheckBox->blockSignals( b );
455 mDrawEmptyCheckBox->blockSignals( b );
456 mWrapBehaviorComboBox->blockSignals( b );
457 mContentFontToolButton->blockSignals( b );
458 mHeaderHAlignmentComboBox->blockSignals( b );
459 mHeaderModeComboBox->blockSignals( b );
460 mHeaderFontToolButton->blockSignals( b );
461}
462
463void QgsLayoutManualTableWidget::mEmptyFrameCheckBox_toggled( bool checked )
464{
465 if ( !mFrame )
466 {
467 return;
468 }
469
470 mFrame->beginCommand( tr( "Toggle Empty Frame Mode" ) );
471 mFrame->setHidePageIfEmpty( checked );
472 mFrame->endCommand();
473}
474
475void QgsLayoutManualTableWidget::mHideEmptyBgCheckBox_toggled( bool checked )
476{
477 if ( !mFrame )
478 {
479 return;
480 }
481
482 mFrame->beginCommand( tr( "Toggle Background Display" ) );
483 mFrame->setHideBackgroundIfEmpty( checked );
484 mFrame->endCommand();
485}
486
487void QgsLayoutManualTableWidget::mAddFramePushButton_clicked()
488{
489 if ( !mTable || !mFrame )
490 {
491 return;
492 }
493
494 //create a new frame based on the current frame
495 QPointF pos = mFrame->pos();
496 //shift new frame so that it sits 10 units below current frame
497 pos.ry() += mFrame->rect().height() + 10;
498
499 QgsLayoutFrame *newFrame = mTable->createNewFrame( mFrame, pos, mFrame->rect().size() );
500 mTable->recalculateFrameSizes();
501
502 //set new frame as selection
503 if ( QgsLayout *layout = mTable->layout() )
504 {
505 layout->setSelectedItem( newFrame );
506 }
507}
508
509void QgsLayoutManualTableWidget::mResizeModeComboBox_currentIndexChanged( int index )
510{
511 if ( !mTable )
512 {
513 return;
514 }
515
516 mTable->beginCommand( tr( "Change Resize Mode" ) );
517 mTable->setResizeMode( static_cast<QgsLayoutMultiFrame::ResizeMode>( mResizeModeComboBox->itemData( index ).toInt() ) );
518 mTable->endCommand();
519
520 mAddFramePushButton->setEnabled( mTable->resizeMode() == QgsLayoutMultiFrame::UseExistingFrames );
521}
522
523void QgsLayoutManualTableWidget::mWrapBehaviorComboBox_currentIndexChanged( int index )
524{
525 if ( !mTable )
526 {
527 return;
528 }
529
530 mTable->beginCommand( tr( "Change Table Wrap Mode" ) );
531 mTable->setWrapBehavior( static_cast<QgsLayoutTable::WrapBehavior>( mWrapBehaviorComboBox->itemData( index ).toInt() ) );
532 mTable->endCommand();
533}
534
535void QgsLayoutManualTableWidget::mAdvancedCustomizationButton_clicked()
536{
537 if ( !mTable )
538 {
539 return;
540 }
541
542 QgsLayoutTableBackgroundColorsDialog d( mTable, this );
543
544 d.exec();
545}
546
547void QgsLayoutManualTableWidget::mDrawEmptyCheckBox_toggled( bool checked )
548{
549 if ( !mTable )
550 {
551 return;
552 }
553
554 mTable->beginCommand( tr( "Change Show Empty Rows" ) );
555 mTable->setShowEmptyRows( checked );
556 mTable->endCommand();
557}
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
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.
@ ModeTextRenderer
Configure font settings for use with QgsTextRenderer.
void changed()
Emitted when the widget's text format settings are changed.
Base class for frame items, which form a layout multiframe item.
QgsLayoutMultiFrame * multiFrame() const
Returns the parent multiframe for the frame.
QString displayName() const override
Gets item display name.
QgsLayoutItemBaseWidget(QWidget *parent SIP_TRANSFERTHIS, QgsLayoutObject *layoutObject)
Constructor for QgsLayoutItemBaseWidget, linked with the specified layoutObject.
A layout table subclass that displays manually entered (and formatted) content.
void setColumnWidths(const QList< double > &widths)
Sets the list of column widths (in millimeters) to use when rendering the table.
void setIncludeTableHeader(bool included)
Sets whether the table includes a header row.
void setHeaders(const QgsLayoutTableColumns &headers)
Replaces the headers in the table with a specified list of QgsLayoutTableColumns.
void setTableContents(const QgsTableContents &contents)
Sets the contents of the table.
void setRowHeights(const QList< double > &heights)
Sets the list of row heights (in millimeters) to use when rendering the table.
QgsTableContents tableContents() const
Returns the contents of the table.
A widget for controlling the common properties of layout items (e.g.
@ LayoutManualTable
Manual (fixed) table.
Base class for graphical items within a QgsLayout.
static void openTableDesigner(QgsLayoutFrame *frame, QWidget *parent=nullptr)
Creates and open the table editor dialog.
void setMasterLayout(QgsMasterLayoutInterface *masterLayout) override
Sets the master layout associated with the item.
bool setNewItem(QgsLayoutItem *item) override
Attempts to update the widget to show the properties for the specified item.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsLayoutManualTableWidget(QgsLayoutFrame *frame)
constructor
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.
void endCommand()
Completes the current item command and push it onto the layout's undo stack.
void beginCommand(const QString &commandText, UndoCommand command=UndoNone)
Starts new undo command for this item.
@ 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.
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.
Interface for master layout type objects, such as print layouts and reports.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
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.