24 : mCurrentSortColumn( 0 ), mAscending( true )
35 if ( v1.type() == QVariant::String && v2.type() == QVariant::String )
37 less = v1.toString() < v2.toString();
41 less = v1.toDouble() < v2.toDouble();
51 , mMaximumNumberOfFeatures( 5 )
52 , mShowOnlyVisibleFeatures( true )
56 QMap<QString, QgsMapLayer*>::const_iterator mapIt = layerMap.constBegin();
57 for ( ; mapIt != layerMap.constEnd(); ++mapIt )
88 for (
int idx = 0; idx < fields.
count(); ++idx )
91 if ( !currentAlias.isEmpty() )
129 attributeMaps.clear();
153 if ( !selectionRect.
isEmpty() )
169 for (
int i = 0; i < f.
attributes().size(); i++ )
174 attributeMaps.last().insert( i, f.
attributes()[i] );
186 qStableSort( attributeMaps.begin(), attributeMaps.end(), c );
193 QMap<int, QString> header;
197 for (
int idx = 0; idx < vectorFields.
count(); ++idx )
229 if (( rectangle.height() - titleHeight ) > 0 )
243 QDomElement composerTableElem = doc.createElement(
"ComposerAttributeTable" );
249 composerTableElem.setAttribute(
"composerMap",
mComposerMap->
id() );
253 composerTableElem.setAttribute(
"composerMap", -1 );
257 composerTableElem.setAttribute(
"vectorLayer",
mVectorLayer->
id() );
261 QDomElement displayAttributesElem = doc.createElement(
"displayAttributes" );
265 QDomElement attributeIndexElem = doc.createElement(
"attributeEntry" );
266 attributeIndexElem.setAttribute(
"index", *attIt );
267 displayAttributesElem.appendChild( attributeIndexElem );
269 composerTableElem.appendChild( displayAttributesElem );
272 QDomElement aliasMapElem = doc.createElement(
"attributeAliasMap" );
273 QMap<int, QString>::const_iterator aliasIt =
mFieldAliasMap.constBegin();
276 QDomElement mapEntryElem = doc.createElement(
"aliasEntry" );
277 mapEntryElem.setAttribute(
"key", aliasIt.key() );
278 mapEntryElem.setAttribute(
"value", aliasIt.value() );
279 aliasMapElem.appendChild( mapEntryElem );
281 composerTableElem.appendChild( aliasMapElem );
284 QDomElement sortColumnsElem = doc.createElement(
"sortColumns" );
285 QList< QPair<int, bool> >::const_iterator sortIt =
mSortInformation.constBegin();
288 QDomElement columnElem = doc.createElement(
"column" );
289 columnElem.setAttribute(
"index", QString::number( sortIt->first ) );
290 columnElem.setAttribute(
"ascending", sortIt->second ==
true ?
"true" :
"false" );
291 sortColumnsElem.appendChild( columnElem );
293 composerTableElem.appendChild( sortColumnsElem );
294 elem.appendChild( composerTableElem );
301 if ( itemElem.isNull() )
309 int composerMapId = itemElem.attribute(
"composerMap",
"-1" ).toInt();
310 if ( composerMapId == -1 )
325 QString layerId = itemElem.attribute(
"vectorLayer",
"not_existing" );
326 if ( layerId ==
"not_existing" )
341 QDomNodeList displayAttributeList = itemElem.elementsByTagName(
"displayAttributes" );
342 if ( displayAttributeList.size() > 0 )
344 QDomElement displayAttributesElem = displayAttributeList.at( 0 ).toElement();
345 QDomNodeList attributeEntryList = displayAttributesElem.elementsByTagName(
"attributeEntry" );
346 for (
int i = 0; i < attributeEntryList.size(); ++i )
348 QDomElement attributeEntryElem = attributeEntryList.at( i ).toElement();
349 int index = attributeEntryElem.attribute(
"index",
"-1" ).toInt();
359 QDomNodeList aliasMapNodeList = itemElem.elementsByTagName(
"attributeAliasMap" );
360 if ( aliasMapNodeList.size() > 0 )
362 QDomElement attributeAliasMapElem = aliasMapNodeList.at( 0 ).toElement();
363 QDomNodeList aliasMepEntryList = attributeAliasMapElem.elementsByTagName(
"aliasEntry" );
364 for (
int i = 0; i < aliasMepEntryList.size(); ++i )
366 QDomElement aliasEntryElem = aliasMepEntryList.at( i ).toElement();
367 int key = aliasEntryElem.attribute(
"key",
"-1" ).toInt();
368 QString value = aliasEntryElem.attribute(
"value",
"" );
375 QDomElement sortColumnsElem = itemElem.firstChildElement(
"sortColumns" );
376 if ( !sortColumnsElem.isNull() )
378 QDomNodeList columns = sortColumnsElem.elementsByTagName(
"column" );
379 for (
int i = 0; i < columns.size(); ++i )
381 QDomElement columnElem = columns.at( i ).toElement();
382 int attribute = columnElem.attribute(
"index" ).toInt();
383 bool ascending = columnElem.attribute(
"ascending" ) ==
"true" ?
true :
false;
Wrapper for iterator of features from vector data provider or vector layer.
void setVectorLayer(QgsVectorLayer *vl)
A rectangle specified with double values.
Base class for all map layer types.
QMap< int, QString > mFieldAliasMap
Map of attribute name aliases.
bool isEmpty() const
test if rectangle is empty
void setAscending(bool asc)
QMap< int, QVariant > QgsAttributeMap
Use exact geometry intersection (slower) instead of bounding boxes.
bool getFeatureAttributes(QList< QgsAttributeMap > &attributeMaps)
Retrieves feature attributes.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
void setComposerMap(const QgsComposerMap *map)
void maximumNumberOfFeaturesChanged(int n)
This signal is emitted if the maximum number of feature changes (interactively)
bool readXML(const QDomElement &itemElem, const QDomDocument &doc)
sets state from Dom document
bool writeXML(QDomElement &elem, QDomDocument &doc) const
stores state in Dom element
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Container of fields for a vector layer.
void initializeAliasMap()
Inserts aliases from vector layer as starting configuration to the alias map.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
bool operator()(const QgsAttributeMap &m1, const QgsAttributeMap &m2)
QSet< int > mDisplayAttributes
List of attribute indices to display (or all attributes if list is empty)
const QgsComposerMap * mComposerMap
Associated composer map (used to display the visible features)
A class to display feature attributes in the print composer.
QMap< int, QString > getHeaderLabels() const
bool isDrawing() const
True if a draw is already in progress.
void itemChanged()
Used e.g.
QgsVectorLayer * mVectorLayer
Associated vector layer.
QList< QPair< int, bool > > mSortInformation
Contains information about sort attribute index / ascending (true/false).
void setSceneRect(const QRectF &rectangle)
Adapts mMaximumNumberOfFeatures depending on the rectangle height.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
const QgsMapRenderer * mapRenderer() const
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint.
bool tableWriteXML(QDomElement &itemElem, QDomDocument &doc) const
This class wraps a request for features to a vector layer (or directly its vector data provider)...
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget)
Reimplementation of QCanvasItem::paint.
const QgsAttributes & attributes() const
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
int count() const
Return number of items.
QgsComposerAttributeTable(QgsComposition *composition)
QString attributeAlias(int attributeIndex) const
Returns the alias of an attribute name or an empty string if there is no alias.
Graphics scene for map printing.
Object representing map window.
QgsRectangle * currentMapExtent()
Returns a pointer to the current map extent, which is either the original user specified extent or th...
QgsComposerAttributeTableCompare()
int id() const
Get identification number.
void removeLayer(QString layerId)
Checks if this vector layer will be removed (and sets mVectorLayer to 0 if yes)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
int mMaximumNumberOfFeatures
Maximum number of features that is displayed.
bool tableReadXML(const QDomElement &itemElem, const QDomDocument &doc)
void setSortColumn(int col)
virtual void setSceneRect(const QRectF &rectangle)
Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size un...
const QgsComposition * composition() const
const QMap< QString, QgsMapLayer * > & mapLayers()
Retrieve the mapLayers collection (mainly intended for use by projection)
double mLineTextDistance
Distance between table lines and text.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
~QgsComposerAttributeTable()
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
Custom exception class for Coordinate Reference System related exceptions.
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
bool nextFeature(QgsFeature &f)
bool mShowOnlyVisibleFeatures
Shows only the features that are visible in the associated composer map (true by default) ...
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QString attributeDisplayName(int attributeIndex, const QString &name) const
Returns the attribute name to display in the item (attribute name or an alias if present) ...
Represents a vector layer which manages a vector based data sets.
const QgsComposerMap * getComposerMapById(int id) const
Returns the composer map with specified id.
QgsFeatureRequest & setFlags(Flags flags)
Set flags that affect how features will be fetched.
Helper class for sorting, takes into account sorting column and ascending / descending.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
double fontAscentMillimeters(const QFont &font) const
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCAL...