22 * Attribute table item for map composer.
33 */
44
5+ /**Helper class for sorting tables, takes into account sorting column and ascending / descending*/
56class QgsComposerAttributeTableCompare
67{
78%TypeHeaderCode
@@ -11,7 +12,15 @@ class QgsComposerAttributeTableCompare
1112 public:
1213 QgsComposerAttributeTableCompare();
1314 // bool operator()( const QgsAttributeMap& m1, const QgsAttributeMap& m2 );
15+
16+ /**Sets column number to sort by
17+ * @param col column number for sorting
18+ */
1419 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+ */
1524 void setAscending( bool asc );
1625};
1726
@@ -32,85 +41,94 @@ class QgsComposerAttributeTable : QgsComposerTable
3241 /** \brief Reimplementation of QCanvasItem::paint*/
3342 virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget );
3443
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+ */
3549 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+ */
3656 bool readXML( const QDomElement& itemElem, const QDomDocument& doc );
3757
3858 /**Sets the vector layer from which to display feature attributes
3959 * @param layer Vector layer for attribute table
40- * @note added in 2.3
4160 * @see vectorLayer
42- */
61+ */
4362 void setVectorLayer( QgsVectorLayer* layer );
4463
4564 /**Returns the vector layer the attribute table is currently using
4665 * @returns attribute table's current vector layer
47- * @note added in 2.3
4866 * @see setVectorLayer
49- */
67+ */
5068 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();
5175
5276 /**Sets the composer map to use to limit the extent of features shown in the
5377 * attribute table. This setting only has an effect if setDisplayOnlyVisibleFeatures is
5478 * set to true. Changing the composer map forces the table to refetch features from its
5579 * vector layer, and may result in the table changing size to accomodate the new displayed
5680 * feature attributes.
5781 * @param map QgsComposerMap which drives the extents of the table's features
58- * @note added in 2.3
5982 * @see composerMap
6083 * @see setDisplayOnlyVisibleFeatures
61- */
84+ */
6285 void setComposerMap( const QgsComposerMap* map /TransferThis/ );
6386
6487 /**Returns the composer map whose extents are controlling the features shown in the
6588 * table. The extents of the map are only used if displayOnlyVisibleFeatures() is true.
6689 * @returns composer map controlling the attribute table
67- * @note added in 2.3
6890 * @see setComposerMap
6991 * @see displayOnlyVisibleFeatures
70- */
92+ */
7193 const QgsComposerMap* composerMap() const;
7294
7395 /**Sets the maximum number of features shown by the table. Changing this setting may result
7496 * in the attribute table changing its size to accomodate the new number of rows, and requires
7597 * the table to refetch features from its vector layer.
7698 * @param features maximum number of features to show in the table
77- * @note added in 2.3
7899 * @see maximumNumberOfFeatures
79- */
100+ */
80101 void setMaximumNumberOfFeatures( int features );
81102
82103 /**Returns the maximum number of features to be shown by the table.
83104 * @returns maximum number of features
84- * @note added in 2.3
85105 * @see setMaximumNumberOfFeatures
86- */
106+ */
87107 int maximumNumberOfFeatures() const;
88108
89109 /**Sets attribute table to only show features which are visible in a composer map item. Changing
90110 * this setting forces the table to refetch features from its vector layer, and may result in
91111 * the table changing size to accomodate the new displayed feature attributes.
92112 * @param visibleOnly set to true to show only visible features
93- * @note added in 2.3
94113 * @see displayOnlyVisibleFeatures
95114 * @see setComposerMap
96- */
115+ */
97116 void setDisplayOnlyVisibleFeatures( bool b );
98117
99118 /**Returns true if the table is set to show only features visible on a corresponding
100119 * composer map item.
101120 * @returns true if table only shows visible features
102- * @note added in 2.3
103121 * @see composerMap
104122 * @see setDisplayOnlyVisibleFeatures
105- */
123+ */
106124 bool displayOnlyVisibleFeatures() const;
107125
108126 /**Returns true if a feature filter is active on the attribute table
109127 * @returns bool state of the feature filter
110128 * @note added in 2.3
111129 * @see setFilterFeatures
112130 * @see featureFilter
113- */
131+ */
114132 bool filterFeatures() const;
115133
116134 /**Sets whether the feature filter is active for the attribute table. Changing
@@ -120,7 +138,7 @@ class QgsComposerAttributeTable : QgsComposerTable
120138 * @note added in 2.3
121139 * @see filterFeatures
122140 * @see setFeatureFilter
123- */
141+ */
124142 void setFilterFeatures( bool filter );
125143
126144 /**Returns the current expression used to filter features for the table. The filter is only
@@ -129,7 +147,7 @@ class QgsComposerAttributeTable : QgsComposerTable
129147 * @note added in 2.3
130148 * @see setFeatureFilter
131149 * @see filterFeatures
132- */
150+ */
133151 QString featureFilter() const;
134152
135153 /**Sets the expression used for filtering features in the table. The filter is only
@@ -140,50 +158,51 @@ class QgsComposerAttributeTable : QgsComposerTable
140158 * @note added in 2.3
141159 * @see featureFilter
142160 * @see setFilterFeatures
143- */
161+ */
144162 void setFeatureFilter( const QString& expression );
145163
146164 /**Returns the attributes fields which are shown by the table.
147165 * @returns a QSet of integers refering to the attributes in the vector layer. If
148166 * result is an empty QSet than all feature attributes will be shown.
149167 * @see setDisplayAttributes
150- */
151- QSet<int> displayAttributes() const;
168+ * @deprecated use QgsComposerTable::columns() instead
169+ */
170+ QSet<int> displayAttributes() const /Deprecated/;
152171
153172 /**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.
155174 * Set to an empty QSet to show all feature attributes.
156175 * @param refresh set to true to force the table to refetch features from its vector layer
157176 * and immediately update the display of the table. This may result in the table changing size
158177 * to accomodate the new displayed feature attributes.
159178 * @see displayAttributes
160- */
179+ */
161180 void setDisplayAttributes( const QSet<int>& attr );
162181
163182 /**Returns the attribute field aliases, which control how fields are named in the table's
164183 * 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.
166186 * @see setFieldAliasMap
167- */
168- QMap<int, QString> fieldAliasMap() const;
187+ * @deprecated use QgsComposerTable::columns() instead
188+ */
189+ QMap<int, QString> fieldAliasMap() const /Deprecated/;
169190
170191 /**Sets the attribute field aliases, which control how fields are named in the table's
171192 * header row.
172193 * @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
177195 * @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/;
180199
181200 /**Adapts mMaximumNumberOfFeatures depending on the rectangle height. Calling this forces
182201 * the table to refetch features from its vector layer and immediately updates the display
183202 * of the table.
184203 * @see maximumNumberOfFeatures
185204 * @see setMaximumNumberOfFeatures
186- */
205+ */
187206 void setSceneRect( const QRectF& rectangle );
188207
189208 // @note not available in python bindings
0 commit comments