29 , mLineTextDistance( 1.0 )
30 , mHeaderFontColor( Qt::black )
31 , mContentFontColor( Qt::black )
32 , mHeaderHAlignment( FollowColumn )
34 , mGridStrokeWidth( 0.5 )
35 , mGridColor(
QColor( 0, 0, 0 ) )
40 if ( !defaultFontString.
isEmpty() )
71 Q_UNUSED( itemStyle );
95 painter->
setPen( Qt::SolidLine );
115 Qt::AlignmentFlag headerAlign = Qt::AlignLeft;
119 headerAlign = ( *columnIt )->hAlignment();
122 headerAlign = Qt::AlignLeft;
125 headerAlign = Qt::AlignHCenter;
128 headerAlign = Qt::AlignRight;
134 currentY += cellHeaderHeight;
144 QString str = currentAttributeMap[ col ].toString();
147 currentY += cellBodyHeight;
164 painter->
setPen( gridPen );
253 headers.
insert( col, ( *columnIt )->heading() );
286 ( *columnIt )->writeXML( columnElem, doc );
325 int gridGreen = itemElem.
attribute(
"gridColorGreen",
"0" ).
toInt();
326 int gridBlue = itemElem.
attribute(
"gridColorBlue",
"0" ).
toInt();
327 int gridAlpha = itemElem.
attribute(
"gridColorAlpha",
"255" ).
toInt();
335 if ( columnsList.
size() > 0 )
339 for (
int i = 0; i < columnEntryList.
size(); ++i )
350 if ( composerItemList.
size() > 0 )
373 double currentAttributeTextWidth;
375 for ( ; attIt != attributeMaps.
constEnd(); ++attIt )
377 QgsAttributeMap::const_iterator attIt2 = attIt->constBegin();
378 for ( ; attIt2 != attIt->constEnd(); ++attIt2 )
381 if ( currentAttributeTextWidth > maxWidthMap[ attIt2.key()] )
383 maxWidthMap[ attIt2.key()] = currentAttributeTextWidth;
393 int n = attributeMaps.
size();
400 double totalWidth = 0;
402 for ( ; maxColWidthIt != maxWidthMap.
constEnd(); ++maxColWidthIt )
404 totalWidth += maxColWidthIt.
value();
407 totalWidth += ( maxWidthMap.
size() + 1 ) * mGridStrokeWidth;
419 double currentY = halfGridStrokeWidth;
423 for (
int i = 0; i < nAttributes; ++i )
436 double currentX = halfGridStrokeWidth;
440 for ( ; maxColWidthIt != maxWidthMap.
constEnd(); ++maxColWidthIt )
QDomNodeList elementsByTagName(const QString &tagname) const
void setLineTextDistance(double d)
Sets the margin distance between cell borders and their contents.
void setContentFont(const QFont &f)
Sets the font used to draw text in table body cells.
void setRenderHint(RenderHint hint, bool on)
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
void setGridStrokeWidth(double w)
Sets the width for grid lines in the table.
virtual QMap< int, QString > headerLabels() const
Returns the text used in the column headers for the table.
const_iterator constBegin() const
A item that forms part of a map composition.
void setHeaderFontColor(const QColor &color)
Sets the color used to draw header text in the table.
void setColumns(QList< QgsComposerTableColumn * > columns)
Replaces the columns in the table with a specified list of QgsComposerTableColumns.
void setShowGrid(bool show)
Sets whether grid lines should be drawn in the table.
static void drawText(QPainter *painter, const QPointF &pos, const QString &text, const QFont &font, const QColor &color=QColor())
Draws text on a painter at a specific position, taking care of composer specific issues (calculation ...
void setContentFontColor(const QColor &color)
Sets the color used to draw text in table body cells.
void setJoinStyle(Qt::PenJoinStyle style)
static QColor decodeColor(QString str)
HeaderHAlignment mHeaderHAlignment
static double fontAscentMM(const QFont &font)
Calculate font ascent in millimeters, including workarounds for QT font rendering issues...
virtual void drawFrame(QPainter *p)
Draw black frame around item.
void drawLine(const QLineF &line)
double toDouble(bool *ok) const
static QString encodeColor(QColor color)
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads parameter that are not subclass specific in document.
QDomElement toElement() const
void drawHorizontalGridLines(QPainter *p, int nAttributes)
Draws the horizontal grid lines for the table.
QString number(int n, int base)
void append(const T &value)
bool fromString(const QString &descrip)
bool hasAttribute(const QString &name) const
virtual void drawSelectionBoxes(QPainter *p)
Draws additional graphics on selected items.
void setPen(const QColor &color)
void setAttribute(const QString &name, const QString &value)
int toInt(bool *ok, int base) const
const_iterator constEnd() const
bool tableWriteXML(QDomElement &itemElem, QDomDocument &doc) const
Writes common table properties to xml for storage.
void setWidthF(qreal width)
static bool setFromXmlChildNode(QFont &font, const QDomElement &element, const QString &childNode)
Sets the properties of a font to match the properties stored in an XML child node.
bool shouldDrawItem() const
Returns whether the item should be drawn in the current context.
Stores properties of a column in a QgsComposerTable.
virtual ~QgsComposerTable()
void setColor(const QColor &color)
Graphics scene for map printing.
virtual bool getFeatureAttributes(QList< QgsAttributeMap > &attributeMaps)
Fetches the text used for the rows of the table.
void setHeaderHAlignment(const HeaderHAlignment alignment)
Sets the horizontal alignment for table headers.
QList< QgsComposerTableColumn * > mColumns
static double textWidthMM(const QFont &font, const QString &text)
Calculate font width in millimeters for a string, including workarounds for QT font rendering issues...
QgsComposition * mComposition
virtual void refreshAttributes()
Refreshes the attributes shown in the table by querying the vector layer for new data.
QgsComposerTable(QgsComposition *composition)
void setHeaderFont(const QFont &f)
Sets the font used to draw header text in the table.
QVariant value(const QString &key, const QVariant &defaultValue) const
QRectF evalItemRect(const QRectF &newRect, const bool resizeOnly=false)
Evaluates an item's bounding rect to consider data defined position and size of item and reference po...
bool _writeXML(QDomElement &itemElem, QDomDocument &doc) const
Writes parameter that are not subclass specific in document.
QList< QgsAttributeMap > mAttributeMaps
bool tableReadXML(const QDomElement &itemElem, const QDomDocument &doc)
Reads the table's common properties from xml.
virtual void adjustFrameToSize()
Adapts the size of the frame to match the content.
virtual void drawBackground(QPainter *p)
Draw background.
void setFamily(const QString &family)
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...
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Reimplementation of QCanvasItem::paint.
double mLineTextDistance
Distance between table lines and text.
iterator insert(const Key &key, const T &value)
virtual bool readXML(const QDomElement &columnElem)
Reads the column's properties from xml.
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
QMap< int, double > mMaxColumnWidthMap
void adaptItemFrame(const QMap< int, double > &maxWidthMap, const QList< QgsAttributeMap > &attributeMaps)
Adapts the size of the item frame to match the table's content.
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
const_iterator constBegin() const
QgsComposition::PlotStyle plotStyle() const
virtual bool calculateMaxColumnWidths(QMap< int, double > &maxWidthMap, const QList< QgsAttributeMap > &attributeMaps) const
Calculates the maximum width of text shown in columns.
QDomNode at(int index) const
const T value(const Key &key) const
void drawVerticalGridLines(QPainter *p, const QMap< int, double > &maxWidthMap)
Draws the vertical grid lines for the table.