/
qgstableeditorformattingwidget.h
222 lines (190 loc) · 6.33 KB
/
qgstableeditorformattingwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/***************************************************************************
qgstableeditorformattingwidget.h
--------------------------------
begin : January 2020
copyright : (C) 2020 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSTABLEEDITORFORMATTINGWIDGET_H
#define QGSTABLEEDITORFORMATTINGWIDGET_H
#include "qgis_gui.h"
#include "ui_qgstableeditorformattingwidgetbase.h"
#include "qgspanelwidget.h"
#include "qgsexpressioncontextgenerator.h"
#include <memory>
#define SIP_NO_FILE
class QgsNumericFormat;
class QgsProperty;
/**
* \ingroup gui
* \class QgsTableEditorFormattingWidget
*
* A reusable widget for formatting the contents of a QgsTableCell.
*
* The editor has support for table foreground and background colors, and numeric formats.
*
* \note Not available in Python bindings
*
* \since QGIS 3.12
*/
class GUI_EXPORT QgsTableEditorFormattingWidget : public QgsPanelWidget, public QgsExpressionContextGenerator, private Ui::QgsTableEditorFormattingWidgetBase
{
Q_OBJECT
public:
/**
* Constructor for QgsTableEditorFormattingWidget with the specified \a parent widget.
*/
QgsTableEditorFormattingWidget( QWidget *parent = nullptr );
~QgsTableEditorFormattingWidget() override;
/**
* Returns the current numeric format shown in the widget, or a NULLPTR
* if no numeric format is set.
*
* The caller takes ownership of the returned object.
*
* \see setNumericFormat()
*/
QgsNumericFormat *numericFormat() SIP_TRANSFERBACK;
/**
* Returns the current text format shown in the widget.
*
* \see setTextFormat()
* \since QGIS 3.16
*/
QgsTextFormat textFormat() const;
/**
* Sets the cell foreground \a color to show in the widget.
*
* \see foregroundColorChanged()
* \see setBackgroundColor()
*/
void setForegroundColor( const QColor &color );
/**
* Sets the cell background \a color to show in the widget.
*
* \see backgroundColorChanged()
* \see setForegroundColor()
*/
void setBackgroundColor( const QColor &color );
/**
* Sets the numeric \a format to show in the widget, or NULLPTR if no numeric format is set.
*
* if \a isMixedFormat is TRUE then the widget will be set to indicate a "mixed format" setting.
*
* \see numericFormat()
*/
void setNumericFormat( QgsNumericFormat *format, bool isMixedFormat );
/**
* Sets the text \a format to show in the widget.
*
* \see textFormat()
* \since QGIS 3.16
*/
void setTextFormat( const QgsTextFormat &format );
/**
* Sets the row \a height to show in the widget, or 0 for automatic height.
*
* \see rowHeightChanged()
* \see setColumnWidth()
*/
void setRowHeight( double height );
/**
* Sets the column \a width to show in the widget, or 0 for automatic width.
*
* \see columnWidthChanged()
* \see setRowHeight()
*/
void setColumnWidth( double width );
/**
* Sets the horizontal \a alignment to show in the widget.
*
* \see horizontalAlignmentChanged()
* \see setVerticalAlignment()
*
* \since QGIS 3.16
*/
void setHorizontalAlignment( Qt::Alignment alignment );
/**
* Sets the vertical \a alignment to show in the widget.
*
* \see verticalAlignmentChanged()
* \see setHorizontalAlignment()
*
* \since QGIS 3.16
*/
void setVerticalAlignment( Qt::Alignment alignment );
/**
* Sets the cell content's \a property to show in the widget.
*
* \since QGIS 3.16
*/
void setCellProperty( const QgsProperty &property );
/**
* Register an expression context generator class that will be used to retrieve
* an expression context for the widget when required.
* \since QGIS 3.16
*/
void registerExpressionContextGenerator( QgsExpressionContextGenerator *generator );
QgsExpressionContext createExpressionContext() const override;
signals:
/**
* Emitted whenever the cell foreground \a color is changed in the widget.
*
* \see setForegroundColor()
*/
void foregroundColorChanged( const QColor &color );
/**
* Emitted whenever the cell background \a color is changed in the widget.
*
* \see setBackgroundColor()
*/
void backgroundColorChanged( const QColor &color );
/**
* Emitted whenever the numeric format shown in the widget is changed.
*/
void numberFormatChanged();
/**
* Emitted whenever the text format shown in the widget is changed.
*
* \since QGIS 3.16
*/
void textFormatChanged();
/**
* Emitted whenever the row \a height shown in the widget is changed.
*/
void rowHeightChanged( double height );
/**
* Emitted whenever the column \a width shown in the widget is changed.
*/
void columnWidthChanged( double width );
/**
* Emitted when the horizontal \a alignment shown in the widget is changed.
*
* \since QGIS 3.16
*/
void horizontalAlignmentChanged( Qt::Alignment alignment );
/**
* Emitted when the vertical \a alignment shown in the widget is changed.
*
* \since QGIS 3.16
*/
void verticalAlignmentChanged( Qt::Alignment alignment );
/**
* Emitted when the cell contents \a property shown in the widget is changed.
*
* \since QGIS 3.16
*/
void cellPropertyChanged( const QgsProperty &property );
private:
std::unique_ptr< QgsNumericFormat > mNumericFormat;
int mBlockSignals = 0;
QgsExpressionContextGenerator *mContextGenerator = nullptr;
};
#endif // QGSTABLEEDITORFORMATTINGWIDGET_H