1/************************************************************************
2 * This file has been generated automatically from                      *
3 *                                                                      *
4 * src/core/layout/qgslayouttable.h                                     *
5 *                                                                      *
6 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
7 ************************************************************************/
8
9
10
11
12
13typedef QVector< QVariant > QgsLayoutTableRow;
14
15typedef QVector< QVector< QVariant > > QgsLayoutTableContents;
16
17
18typedef QVector<QgsLayoutTableColumn> QgsLayoutTableColumns;
19
20typedef QVector<QgsLayoutTableColumn> QgsLayoutTableSortColumns;
21
22
23
24
25class QgsLayoutTableStyle
26{
27%Docstring(signature="appended")
28Styling option for a layout table cell
29
30.. versionadded:: 3.0
31%End
32
33%TypeHeaderCode
34#include "qgslayouttable.h"
35%End
36  public:
37
38    QgsLayoutTableStyle();
39%Docstring
40Constructor for QgsLayoutTableStyle
41%End
42
43    bool enabled;
44
45    QColor cellBackgroundColor;
46
47    bool writeXml( QDomElement &styleElem, QDomDocument &doc ) const;
48%Docstring
49Writes the style's properties to XML for storage.
50
51:param styleElem: an existing QDomElement in which to store the style's properties.
52:param doc: QDomDocument for the destination XML.
53
54.. seealso:: :py:func:`readXml`
55%End
56
57    bool readXml( const QDomElement &styleElem );
58%Docstring
59Reads the style's properties from XML.
60
61:param styleElem: a QDomElement holding the style's desired properties.
62
63.. seealso:: :py:func:`writeXml`
64%End
65
66};
67
68class QgsLayoutTable: QgsLayoutMultiFrame
69{
70%Docstring(signature="appended")
71A class to display a table in the print layout, and allow
72the table to span over multiple frames
73
74.. versionadded:: 3.0
75%End
76
77%TypeHeaderCode
78#include "qgslayouttable.h"
79%End
80  public:
81
82    enum HeaderHAlignment
83    {
84      FollowColumn,
85      HeaderLeft,
86      HeaderCenter,
87      HeaderRight
88    };
89
90    enum HeaderMode
91    {
92      FirstFrame,
93      AllFrames,
94      NoHeaders
95    };
96
97    enum EmptyTableMode
98    {
99      HeadersOnly,
100      HideTable,
101      ShowMessage
102    };
103
104    enum WrapBehavior
105    {
106      TruncateText,
107      WrapText
108    };
109
110    enum CellStyleGroup
111    {
112      OddColumns,
113      EvenColumns,
114      OddRows,
115      EvenRows,
116      FirstColumn,
117      LastColumn,
118      HeaderRow,
119      FirstRow,
120      LastRow
121    };
122
123    QgsLayoutTable( QgsLayout *layout );
124%Docstring
125Constructor for QgsLayoutTable, belonging to the specified ``layout``.
126%End
127
128    ~QgsLayoutTable();
129
130    void setCellMargin( double margin );
131%Docstring
132Sets the ``margin`` distance in mm between cell borders and their contents.
133
134.. seealso:: :py:func:`cellMargin`
135%End
136
137    double cellMargin() const;
138%Docstring
139Returns the margin distance between cell borders and their contents in mm.
140
141.. seealso:: :py:func:`setCellMargin`
142%End
143
144    void setEmptyTableBehavior( EmptyTableMode mode );
145%Docstring
146Sets the behavior ``mode`` for empty tables with no content rows.
147
148.. seealso:: :py:func:`emptyTableBehavior`
149%End
150
151    EmptyTableMode emptyTableBehavior() const;
152%Docstring
153Returns the behavior mode for empty tables. This property controls
154how the table is drawn if it contains no content rows.
155
156.. seealso:: :py:func:`setEmptyTableBehavior`
157%End
158
159    void setEmptyTableMessage( const QString &message );
160%Docstring
161Sets the ``message`` for empty tables with no content rows. This message
162is displayed in the table body if the empty table behavior is
163set to ShowMessage.
164
165.. seealso:: :py:func:`emptyTableMessage`
166
167.. seealso:: :py:func:`setEmptyTableBehavior`
168%End
169
170    QString emptyTableMessage() const;
171%Docstring
172Returns the message for empty tables with no content rows. This message
173is displayed in the table body if the empty table behavior is
174set to ShowMessage.
175
176.. seealso:: :py:func:`setEmptyTableMessage`
177
178.. seealso:: :py:func:`emptyTableBehavior`
179%End
180
181    void setShowEmptyRows( bool showEmpty );
182%Docstring
183Sets whether empty rows should be drawn. Tables default to hiding empty rows.
184
185:param showEmpty: set to ``True`` to show empty rows in the table
186
187.. seealso:: :py:func:`showEmptyRows`
188%End
189
190    bool showEmptyRows() const;
191%Docstring
192Returns whether empty rows are drawn in the table.
193
194.. seealso:: :py:func:`setShowEmptyRows`
195%End
196
197 void setHeaderFont( const QFont &font ) /Deprecated/;
198%Docstring
199Sets the ``font`` used to draw header text in the table.
200
201.. seealso:: :py:func:`headerFont`
202
203.. seealso:: :py:func:`setContentFont`
204
205.. deprecated::
206   use :py:func:`~QgsLayoutTable.setHeaderTextFormat` instead
207%End
208
209 QFont headerFont() const /Deprecated/;
210%Docstring
211Returns the font used to draw header text in the table.
212
213.. seealso:: :py:func:`setHeaderFont`
214
215.. seealso:: :py:func:`contentFont`
216
217.. deprecated::
218   use :py:func:`~QgsLayoutTable.headerTextFormat` instead
219%End
220
221 void setHeaderFontColor( const QColor &color ) /Deprecated/;
222%Docstring
223Sets the ``color`` used to draw header text in the table.
224
225.. seealso:: :py:func:`headerFontColor`
226
227.. seealso:: :py:func:`setHeaderFont`
228
229.. seealso:: :py:func:`setContentFontColor`
230
231.. deprecated::
232   use :py:func:`~QgsLayoutTable.setHeaderTextFormat` instead
233%End
234
235 QColor headerFontColor() const /Deprecated/;
236%Docstring
237Returns the color used to draw header text in the table.
238
239.. seealso:: :py:func:`setHeaderFontColor`
240
241.. seealso:: :py:func:`headerFont`
242
243.. seealso:: :py:func:`contentFontColor`
244
245.. deprecated::
246   use :py:func:`~QgsLayoutTable.headerTextFormat` instead
247%End
248
249    void setHeaderTextFormat( const QgsTextFormat &format );
250%Docstring
251Sets the ``format`` used to draw header text in the table.
252
253.. seealso:: :py:func:`headerTextFormat`
254
255.. seealso:: :py:func:`setContentTextFormat`
256
257.. versionadded:: 3.16
258%End
259
260    QgsTextFormat headerTextFormat() const;
261%Docstring
262Returns the format used to draw header text in the table.
263
264.. seealso:: :py:func:`setHeaderTextFormat`
265
266.. seealso:: :py:func:`contentTextFormat`
267
268.. versionadded:: 3.16
269%End
270
271    void setHeaderHAlignment( HeaderHAlignment alignment );
272%Docstring
273Sets the horizontal ``alignment`` for table headers.
274
275.. seealso:: :py:func:`headerHAlignment`
276%End
277
278    HeaderHAlignment headerHAlignment() const;
279%Docstring
280Returns the horizontal alignment for table headers.
281
282.. seealso:: :py:func:`setHeaderHAlignment`
283%End
284
285    void setHeaderMode( HeaderMode mode );
286%Docstring
287Sets the display ``mode`` for headers in the table. This property controls
288if and where headers are shown in the table.
289
290.. seealso:: :py:func:`headerMode`
291%End
292
293    HeaderMode headerMode() const;
294%Docstring
295Returns the display mode for headers in the table. This property controls
296if and where headers are shown in the table.
297
298.. seealso:: :py:func:`setHeaderMode`
299%End
300
301 void setContentFont( const QFont &font ) /Deprecated/;
302%Docstring
303Sets the ``font`` used to draw text in table body cells.
304
305.. seealso:: :py:func:`contentFont`
306
307.. seealso:: :py:func:`setHeaderFont`
308
309.. deprecated::
310   use :py:func:`~QgsLayoutTable.setContentTextFormat` instead
311%End
312
313 QFont contentFont() const /Deprecated/;
314%Docstring
315Returns the font used to draw text in table body cells.
316
317.. seealso:: :py:func:`setContentFont`
318
319.. seealso:: :py:func:`headerFont`
320
321.. deprecated::
322   use :py:func:`~QgsLayoutTable.contextTextFormat` instead
323%End
324
325 void setContentFontColor( const QColor &color ) /Deprecated/;
326%Docstring
327Sets the ``color`` used to draw text in table body cells.
328
329.. seealso:: :py:func:`contentFontColor`
330
331.. seealso:: :py:func:`setContentFont`
332
333.. seealso:: :py:func:`setHeaderFontColor`
334
335.. deprecated::
336   use :py:func:`~QgsLayoutTable.setContentTextFormat` instead
337%End
338
339 QColor contentFontColor() const /Deprecated/;
340%Docstring
341Returns the color used to draw text in table body cells.
342
343.. seealso:: :py:func:`setContentFontColor`
344
345.. seealso:: :py:func:`contentFont`
346
347.. seealso:: :py:func:`headerFontColor`
348
349.. deprecated::
350   use :py:func:`~QgsLayoutTable.contextTextFormat` instead
351%End
352
353    void setContentTextFormat( const QgsTextFormat &format );
354%Docstring
355Sets the ``format`` used to draw content text in the table.
356
357.. seealso:: :py:func:`contentTextFormat`
358
359.. seealso:: :py:func:`setHeaderTextFormat`
360
361.. versionadded:: 3.16
362%End
363
364    QgsTextFormat contentTextFormat() const;
365%Docstring
366Returns the format used to draw content text in the table.
367
368.. seealso:: :py:func:`setContentTextFormat`
369
370.. seealso:: :py:func:`headerTextFormat`
371
372.. versionadded:: 3.16
373%End
374
375    void setShowGrid( bool showGrid );
376%Docstring
377Sets whether grid lines should be drawn in the table
378
379:param showGrid: set to ``True`` to show grid lines
380
381.. seealso:: :py:func:`showGrid`
382
383.. seealso:: :py:func:`setGridStrokeWidth`
384
385.. seealso:: :py:func:`setGridColor`
386%End
387
388    bool showGrid() const;
389%Docstring
390Returns whether grid lines are drawn in the table
391
392.. seealso:: :py:func:`setShowGrid`
393
394.. seealso:: :py:func:`gridStrokeWidth`
395
396.. seealso:: :py:func:`gridColor`
397%End
398
399    void setGridStrokeWidth( double width );
400%Docstring
401Sets the ``width`` in mm for grid lines in the table.
402
403.. seealso:: :py:func:`gridStrokeWidth`
404
405.. seealso:: :py:func:`setShowGrid`
406
407.. seealso:: :py:func:`setGridColor`
408%End
409
410    double gridStrokeWidth() const;
411%Docstring
412Returns the width of grid lines in the table in mm.
413
414.. seealso:: :py:func:`setGridStrokeWidth`
415
416.. seealso:: :py:func:`showGrid`
417
418.. seealso:: :py:func:`gridColor`
419%End
420
421    void setGridColor( const QColor &color );
422%Docstring
423Sets the ``color`` used for grid lines in the table.
424
425.. seealso:: :py:func:`gridColor`
426
427.. seealso:: :py:func:`setShowGrid`
428
429.. seealso:: :py:func:`setGridStrokeWidth`
430%End
431
432    QColor gridColor() const;
433%Docstring
434Returns the color used for grid lines in the table.
435
436.. seealso:: :py:func:`setGridColor`
437
438.. seealso:: :py:func:`showGrid`
439
440.. seealso:: :py:func:`gridStrokeWidth`
441%End
442
443    void setHorizontalGrid( bool horizontalGrid );
444%Docstring
445Sets whether the grid's horizontal lines should be drawn in the table
446
447:param horizontalGrid: set to ``True`` to draw grid's horizontal lines
448
449.. seealso:: :py:func:`setShowGrid`
450
451.. seealso:: :py:func:`setGridStrokeWidth`
452
453.. seealso:: :py:func:`setGridColor`
454
455.. seealso:: :py:func:`setVerticalGrid`
456%End
457
458    bool horizontalGrid() const;
459%Docstring
460Returns whether the grid's horizontal lines are drawn in the table.
461
462.. seealso:: :py:func:`setShowGrid`
463
464.. seealso:: :py:func:`setGridStrokeWidth`
465
466.. seealso:: :py:func:`setGridColor`
467
468.. seealso:: :py:func:`setVerticalGrid`
469%End
470
471    void setVerticalGrid( bool verticalGrid );
472%Docstring
473Sets whether the grid's vertical lines should be drawn in the table
474
475:param verticalGrid: set to ``True`` to draw grid's vertical lines
476
477.. seealso:: :py:func:`setShowGrid`
478
479.. seealso:: :py:func:`setGridStrokeWidth`
480
481.. seealso:: :py:func:`setGridColor`
482
483.. seealso:: :py:func:`setHorizontalGrid`
484%End
485
486    bool verticalGrid() const;
487%Docstring
488Returns whether the grid's vertical lines are drawn in the table.
489
490.. seealso:: :py:func:`setShowGrid`
491
492.. seealso:: :py:func:`setGridStrokeWidth`
493
494.. seealso:: :py:func:`setGridColor`
495
496.. seealso:: :py:func:`setHorizontalGrid`
497%End
498
499    void setBackgroundColor( const QColor &color );
500%Docstring
501Sets the ``color`` used for background of table.
502
503.. seealso:: :py:func:`backgroundColor`
504
505.. seealso:: :py:func:`setGridColor`
506%End
507
508    QColor backgroundColor() const;
509%Docstring
510Returns the color used for the background of the table.
511
512.. seealso:: :py:func:`setBackgroundColor`
513
514.. seealso:: :py:func:`gridColor`
515%End
516
517    void setWrapBehavior( WrapBehavior behavior );
518%Docstring
519Sets the wrap ``behavior`` for the table, which controls how text within cells is
520automatically wrapped.
521
522.. seealso:: :py:func:`wrapBehavior`
523%End
524
525    WrapBehavior wrapBehavior() const;
526%Docstring
527Returns the wrap behavior for the table, which controls how text within cells is
528automatically wrapped.
529
530.. seealso:: :py:func:`setWrapBehavior`
531%End
532
533    QgsLayoutTableColumns &columns();
534%Docstring
535Returns a reference to the list of :py:class:`QgsLayoutTableColumns` shown in the table
536
537.. seealso:: :py:func:`setColumns`
538%End
539
540    void setColumns( const QgsLayoutTableColumns &columns );
541%Docstring
542Replaces the columns in the table with a specified list of :py:class:`QgsLayoutTableColumns`.
543
544:param columns: list of :py:class:`QgsLayoutTableColumns` to show in table.
545
546.. seealso:: :py:func:`columns`
547%End
548
549    QgsLayoutTableSortColumns &sortColumns();
550%Docstring
551Returns a reference to the list of :py:class:`QgsLayoutTableSortColumns` shown in the table
552
553.. seealso:: :py:func:`setSortColumns`
554
555.. versionadded:: 3.14
556%End
557
558    void setSortColumns( const QgsLayoutTableSortColumns &sortColumns );
559%Docstring
560Replaces the sorting columns in the table with a specified list of :py:class:`QgsLayoutTableSortColumns`.
561
562:param sortColumns: list of :py:class:`QgsLayoutTableColumns` used to sort the table.
563
564.. seealso:: :py:func:`sortColumns`
565
566.. versionadded:: 3.14
567%End
568
569    void setCellStyle( CellStyleGroup group, const QgsLayoutTableStyle &style );
570%Docstring
571Sets the cell ``style`` for a cell ``group``.
572
573.. seealso:: :py:func:`cellStyle`
574%End
575
576    const QgsLayoutTableStyle *cellStyle( CellStyleGroup group ) const;
577%Docstring
578Returns the cell style for a cell ``group``.
579
580.. seealso:: :py:func:`setCellStyle`
581%End
582
583
584    virtual bool getTableContents( QgsLayoutTableContents &contents ) = 0;
585%Docstring
586Fetches the contents used for the cells in the table.
587
588:return: ``True`` if table contents were successfully retrieved.
589
590:param contents: :py:class:`QgsLayoutTableContents` to store retrieved row data in
591%End
592
593    virtual QgsConditionalStyle conditionalCellStyle( int row, int column ) const;
594%Docstring
595Returns the conditional style to use for the cell at ``row``, ``column``.
596
597.. versionadded:: 3.12
598%End
599
600    virtual QgsExpressionContextScope *scopeForCell( int row, int column ) const /Factory/;
601%Docstring
602Creates a new :py:class:`QgsExpressionContextScope` for the cell at ``row``, ``column``.
603
604.. versionadded:: 3.16
605%End
606
607    QgsLayoutTableContents &contents();
608%Docstring
609Returns the current contents of the table. Excludes header cells.
610%End
611
612    virtual QSizeF fixedFrameSize( int frameIndex = -1 ) const;
613
614    virtual QSizeF minFrameSize( int frameIndex = -1 ) const;
615
616
617    virtual bool writePropertiesToElement( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const;
618
619    virtual bool readPropertiesFromElement( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context );
620
621    virtual QSizeF totalSize() const;
622
623    virtual void render( QgsLayoutItemRenderContext &context, const QRectF &renderExtent, int frameIndex );
624
625
626  public slots:
627
628    virtual void refresh();
629
630
631    virtual void refreshAttributes();
632%Docstring
633Refreshes the contents shown in the table by querying for new data.
634This also causes the column widths and size of the table to change to accommodate the
635new data.
636%End
637
638    virtual void recalculateFrameSizes();
639
640
641  protected:
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664    virtual bool calculateMaxColumnWidths();
665%Docstring
666Calculates the maximum width of text shown in columns.
667%End
668
669    virtual bool calculateMaxRowHeights();
670%Docstring
671Calculates the maximum height of text shown in rows.
672%End
673
674    double totalWidth();
675
676    double totalHeight();
677
678    int rowsVisible( QgsRenderContext &context, double frameHeight, int firstRow, bool includeHeader, bool includeEmptyRows ) const;
679%Docstring
680Calculates how many content rows would be visible within a frame of the specified
681height.
682
683:param context: render context
684:param frameHeight: height of frame
685:param firstRow: index of first row visible in frame (where 0 = first row in table)
686:param includeHeader: set to ``True`` if frame would include a header row
687:param includeEmptyRows: set to ``True`` to also include rows which would be empty in the returned count. For instance,
688                         if the frame would include all table content rows and have space left for extra rows then setting this parameter
689                         to ``True`` would also include a count of these extra blank rows.
690
691:return: number of visible content rows (excluding header row)
692%End
693
694    int rowsVisible( QgsRenderContext &context, int frameIndex, int firstRow, bool includeEmptyRows ) const;
695%Docstring
696Calculates how many content rows are visible within a given frame.
697
698:param context: render context
699:param frameIndex: index number for frame
700:param firstRow: index of first row visible in frame (where 0 = first row in table)
701:param includeEmptyRows: set to ``True`` to also include rows which would be empty in the returned count. For instance,
702                         if the frame would include all table content rows and have space left for extra rows then setting this parameter
703                         to ``True`` would also include a count of these extra blank rows.
704
705:return: number of visible content rows (excludes header rows)
706%End
707
708    QPair<int, int> rowRange( QgsRenderContext &context, int frameIndex ) const;
709%Docstring
710Calculates a range of rows which should be visible in a given frame.
711
712:param context: render context
713:param frameIndex: index number for frame
714
715:return: row range
716%End
717
718    void drawHorizontalGridLines( QgsLayoutItemRenderContext &context, int firstRow, int lastRow, bool drawHeaderLines ) const;
719%Docstring
720Draws the horizontal grid lines for the table.
721
722:param context: destination render context
723:param firstRow: index corresponding to first row shown in frame
724:param lastRow: index corresponding to last row shown in frame. If greater than the number of content rows in the
725                table, then the default row height will be used for the remaining rows.
726:param drawHeaderLines: set to ``True`` to include for the table header
727
728.. seealso:: :py:func:`drawVerticalGridLines`
729%End
730
731
732    void recalculateTableSize();
733%Docstring
734Recalculates and updates the size of the table and all table frames.
735%End
736
737    bool contentsContainsRow( const QgsLayoutTableContents &contents, const QgsLayoutTableRow &row ) const;
738%Docstring
739Checks whether a table contents contains a given row
740
741:param contents: table contents to check
742:param row: row to check for
743
744:return: ``True`` if contents contains rows
745%End
746
747    virtual QgsTextFormat textFormatForCell( int row, int column ) const;
748%Docstring
749Returns the text format to use for the cell at the specified ``row`` and ``column``.
750
751.. seealso:: :py:func:`textFormatForHeader`
752
753.. versionadded:: 3.16
754%End
755
756    virtual QgsTextFormat textFormatForHeader( int column ) const;
757%Docstring
758Returns the text format to use for the header cell at the specified ``column``.
759
760.. seealso:: :py:func:`textFormatForCell`
761
762.. versionadded:: 3.16
763%End
764
765    virtual Qt::Alignment horizontalAlignmentForCell( int row, int column ) const;
766%Docstring
767Returns the horizontal alignment to use for the cell at the specified ``row`` and ``column``.
768
769.. seealso:: :py:func:`verticalAlignmentForCell`
770
771.. versionadded:: 3.16
772%End
773
774    virtual Qt::Alignment verticalAlignmentForCell( int row, int column ) const;
775%Docstring
776Returns the vertical alignment to use for the cell at the specified ``row`` and ``column``.
777
778.. seealso:: :py:func:`horizontalAlignmentForCell`
779
780.. versionadded:: 3.16
781%End
782
783};
784
785/************************************************************************
786 * This file has been generated automatically from                      *
787 *                                                                      *
788 * src/core/layout/qgslayouttable.h                                     *
789 *                                                                      *
790 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
791 ************************************************************************/
792