2
2
* Attribute table item for map composer.
3
3
*/
4
4
5
+ /**Helper class for sorting tables, takes into account sorting column and ascending / descending*/
5
6
class QgsComposerAttributeTableCompare
6
7
{
7
8
%TypeHeaderCode
@@ -11,7 +12,15 @@ class QgsComposerAttributeTableCompare
11
12
public:
12
13
QgsComposerAttributeTableCompare();
13
14
// bool operator()( const QgsAttributeMap& m1, const QgsAttributeMap& m2 );
15
+
16
+ /**Sets column number to sort by
17
+ * @param col column number for sorting
18
+ */
14
19
void setSortColumn( int col );
20
+
21
+ /**Sets sort order for column sorting
22
+ * @param asc set to true to sort in ascending order, false to sort in descending order
23
+ */
15
24
void setAscending( bool asc );
16
25
};
17
26
@@ -32,85 +41,94 @@ class QgsComposerAttributeTable : QgsComposerTable
32
41
/** \brief Reimplementation of QCanvasItem::paint*/
33
42
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
34
43
44
+ /**Writes properties specific to attribute tables
45
+ * @param elem an existing QDomElement in which to store the attribute table's properties.
46
+ * @param doc QDomDocument for the destination xml.
47
+ * @see readXML
48
+ */
35
49
bool writeXML( QDomElement& elem, QDomDocument & doc ) const;
50
+
51
+ /**Reads the properties specific to an attribute table from xml.
52
+ * @param itemElem a QDomElement holding the attribute table's desired properties.
53
+ * @param doc QDomDocument for the source xml.
54
+ * @see writeXML
55
+ */
36
56
bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
37
57
38
58
/**Sets the vector layer from which to display feature attributes
39
59
* @param layer Vector layer for attribute table
40
- * @note added in 2.3
41
60
* @see vectorLayer
42
- */
61
+ */
43
62
void setVectorLayer( QgsVectorLayer* layer );
44
63
45
64
/**Returns the vector layer the attribute table is currently using
46
65
* @returns attribute table's current vector layer
47
- * @note added in 2.3
48
66
* @see setVectorLayer
49
- */
67
+ */
50
68
QgsVectorLayer* vectorLayer() const;
69
+
70
+ /**Resets the attribute table's columns to match the vector layer's fields
71
+ * @note added in 2.3
72
+ * @see setVectorLayer
73
+ */
74
+ void resetColumns();
51
75
52
76
/**Sets the composer map to use to limit the extent of features shown in the
53
77
* attribute table. This setting only has an effect if setDisplayOnlyVisibleFeatures is
54
78
* set to true. Changing the composer map forces the table to refetch features from its
55
79
* vector layer, and may result in the table changing size to accomodate the new displayed
56
80
* feature attributes.
57
81
* @param map QgsComposerMap which drives the extents of the table's features
58
- * @note added in 2.3
59
82
* @see composerMap
60
83
* @see setDisplayOnlyVisibleFeatures
61
- */
84
+ */
62
85
void setComposerMap( const QgsComposerMap* map /TransferThis/ );
63
86
64
87
/**Returns the composer map whose extents are controlling the features shown in the
65
88
* table. The extents of the map are only used if displayOnlyVisibleFeatures() is true.
66
89
* @returns composer map controlling the attribute table
67
- * @note added in 2.3
68
90
* @see setComposerMap
69
91
* @see displayOnlyVisibleFeatures
70
- */
92
+ */
71
93
const QgsComposerMap* composerMap() const;
72
94
73
95
/**Sets the maximum number of features shown by the table. Changing this setting may result
74
96
* in the attribute table changing its size to accomodate the new number of rows, and requires
75
97
* the table to refetch features from its vector layer.
76
98
* @param features maximum number of features to show in the table
77
- * @note added in 2.3
78
99
* @see maximumNumberOfFeatures
79
- */
100
+ */
80
101
void setMaximumNumberOfFeatures( int features );
81
102
82
103
/**Returns the maximum number of features to be shown by the table.
83
104
* @returns maximum number of features
84
- * @note added in 2.3
85
105
* @see setMaximumNumberOfFeatures
86
- */
106
+ */
87
107
int maximumNumberOfFeatures() const;
88
108
89
109
/**Sets attribute table to only show features which are visible in a composer map item. Changing
90
110
* this setting forces the table to refetch features from its vector layer, and may result in
91
111
* the table changing size to accomodate the new displayed feature attributes.
92
112
* @param visibleOnly set to true to show only visible features
93
- * @note added in 2.3
94
113
* @see displayOnlyVisibleFeatures
95
114
* @see setComposerMap
96
- */
115
+ */
97
116
void setDisplayOnlyVisibleFeatures( bool b );
98
117
99
118
/**Returns true if the table is set to show only features visible on a corresponding
100
119
* composer map item.
101
120
* @returns true if table only shows visible features
102
- * @note added in 2.3
103
121
* @see composerMap
104
122
* @see setDisplayOnlyVisibleFeatures
105
- */
123
+ */
106
124
bool displayOnlyVisibleFeatures() const;
107
125
108
126
/**Returns true if a feature filter is active on the attribute table
109
127
* @returns bool state of the feature filter
110
128
* @note added in 2.3
111
129
* @see setFilterFeatures
112
130
* @see featureFilter
113
- */
131
+ */
114
132
bool filterFeatures() const;
115
133
116
134
/**Sets whether the feature filter is active for the attribute table. Changing
@@ -120,7 +138,7 @@ class QgsComposerAttributeTable : QgsComposerTable
120
138
* @note added in 2.3
121
139
* @see filterFeatures
122
140
* @see setFeatureFilter
123
- */
141
+ */
124
142
void setFilterFeatures( bool filter );
125
143
126
144
/**Returns the current expression used to filter features for the table. The filter is only
@@ -129,7 +147,7 @@ class QgsComposerAttributeTable : QgsComposerTable
129
147
* @note added in 2.3
130
148
* @see setFeatureFilter
131
149
* @see filterFeatures
132
- */
150
+ */
133
151
QString featureFilter() const;
134
152
135
153
/**Sets the expression used for filtering features in the table. The filter is only
@@ -140,50 +158,51 @@ class QgsComposerAttributeTable : QgsComposerTable
140
158
* @note added in 2.3
141
159
* @see featureFilter
142
160
* @see setFilterFeatures
143
- */
161
+ */
144
162
void setFeatureFilter( const QString& expression );
145
163
146
164
/**Returns the attributes fields which are shown by the table.
147
165
* @returns a QSet of integers refering to the attributes in the vector layer. If
148
166
* result is an empty QSet than all feature attributes will be shown.
149
167
* @see setDisplayAttributes
150
- */
151
- QSet<int> displayAttributes() const;
168
+ * @deprecated use QgsComposerTable::columns() instead
169
+ */
170
+ QSet<int> displayAttributes() const /Deprecated/;
152
171
153
172
/**Sets the attributes to display in the table.
154
- * @param attr QSet of integer values refering to the attributes from the vector layer to show
173
+ * @param attr QSet of integer values refering to the attributes from the vector layer to show.
155
174
* Set to an empty QSet to show all feature attributes.
156
175
* @param refresh set to true to force the table to refetch features from its vector layer
157
176
* and immediately update the display of the table. This may result in the table changing size
158
177
* to accomodate the new displayed feature attributes.
159
178
* @see displayAttributes
160
- */
179
+ */
161
180
void setDisplayAttributes( const QSet<int>& attr );
162
181
163
182
/**Returns the attribute field aliases, which control how fields are named in the table's
164
183
* header row.
165
- * @returns a QMap of integers to strings, where the string is the field's alias.
184
+ * @returns a QMap of integers to strings, where the string is the field's alias and the
185
+ * integer is the field index from the associated vector layer.
166
186
* @see setFieldAliasMap
167
- */
168
- QMap<int, QString> fieldAliasMap() const;
187
+ * @deprecated use QgsComposerTable::columns() instead
188
+ */
189
+ QMap<int, QString> fieldAliasMap() const /Deprecated/;
169
190
170
191
/**Sets the attribute field aliases, which control how fields are named in the table's
171
192
* header row.
172
193
* @param map QMap of integers to strings, where the string is the alias to use for the
173
- * corresponding field.
174
- * @param refresh set to true to force the table to refetch features from its vector layer
175
- * and immediately update the display of the table. This may result in the table changing size
176
- * to accomodate the new displayed feature attributes and field aliases.
194
+ * corresponding field, and the integer is the field index from the vector layer
177
195
* @see fieldAliasMap
178
- */
179
- void setFieldAliasMap( const QMap<int, QString>& map );
196
+ * @deprecated use QgsComposerTable::columns() instead
197
+ */
198
+ void setFieldAliasMap( const QMap<int, QString>& map ) /Deprecated/;
180
199
181
200
/**Adapts mMaximumNumberOfFeatures depending on the rectangle height. Calling this forces
182
201
* the table to refetch features from its vector layer and immediately updates the display
183
202
* of the table.
184
203
* @see maximumNumberOfFeatures
185
204
* @see setMaximumNumberOfFeatures
186
- */
205
+ */
187
206
void setSceneRect( const QRectF& rectangle );
188
207
189
208
// @note not available in python bindings
0 commit comments