28 , mEmptyTableMode( HeadersOnly )
29 , mShowEmptyRows( false )
30 , mHeaderFontColor( Qt::black )
31 , mHeaderHAlignment( FollowColumn )
32 , mHeaderMode( FirstFrame )
33 , mContentFontColor( Qt::black )
35 , mGridStrokeWidth( 0.5 )
36 , mGridColor( Qt::black )
37 , mBackgroundColor( Qt::white )
48 if ( !defaultFontString.
isEmpty() )
58 , mEmptyTableMode( HeadersOnly )
59 , mShowEmptyRows( false )
60 , mHeaderFontColor( Qt::black )
61 , mHeaderHAlignment( FollowColumn )
62 , mHeaderMode( FirstFrame )
63 , mContentFontColor( Qt::black )
65 , mGridStrokeWidth( 0.5 )
66 , mGridColor( Qt::black )
67 , mBackgroundColor( Qt::white )
101 ( *columnIt )->writeXML( columnElem, doc );
106 bool state =
_writeXML( elem, doc, ignoreFrames );
115 if ( !
_readXML( itemElem, doc, ignoreFrames ) )
150 if ( columnsList.
size() > 0 )
154 for (
int i = 0; i < columnEntryList.
size(); ++i )
180 bool includeHeader =
false;
184 includeHeader =
true;
192 double headerHeight = 0;
205 double contentHeight = frameHeight - headerHeight;
209 return qMax( floor( contentHeight / rowHeight ), 0.0 );
218 return qMakePair( 0, 0 );
223 int rowsAlreadyShown = 0;
229 double headerHeight = 0;
242 double contentHeight = extent.
height() - headerHeight;
247 int rowsVisible = qMax( floor( contentHeight / rowHeight ), 0.0 );
250 return qMakePair( firstVisible, lastVisible );
293 int numberRowsToDraw = rowsToShow.second - rowsToShow.first;
298 bool mergeCells =
false;
316 double totalHeight = ( drawHeader || ( numberRowsToDraw > 0 ) ? gridSize : 0 ) +
317 ( drawHeader ? cellHeaderHeight + gridSize : 0.0 ) +
318 ( drawContents ? numberRowsToDraw : 1 ) * ( cellBodyHeight + gridSize );
320 if ( totalHeight > 0 )
329 double currentX = gridSize;
331 p->
setPen( Qt::SolidLine );
337 Qt::TextFlag textFlag = ( Qt::TextFlag )0;
338 if (( *columnIt )->width() <= 0 )
343 textFlag = Qt::TextDontClip;
352 Qt::AlignmentFlag headerAlign = Qt::AlignLeft;
356 headerAlign = ( *columnIt )->hAlignment();
359 headerAlign = Qt::AlignLeft;
362 headerAlign = Qt::AlignHCenter;
365 headerAlign = Qt::AlignRight;
371 currentY += cellHeaderHeight;
372 currentY += gridSize;
378 for (
int row = rowsToShow.first; row < rowsToShow.second; ++row )
387 currentY += cellBodyHeight;
388 currentY += gridSize;
394 currentX += gridSize;
414 double messageY = gridSize + ( drawHeader ? cellHeaderHeight + gridSize : 0 );
631 headers.
insert( col, ( *columnIt )->heading() );
639 Q_UNUSED( frameIndex );
652 return QSizeF( 0, height );
683 if (( *columnIt )->width() > 0 )
686 width = ( *columnIt )->width();
699 double currentCellTextWidth;
703 int columnNumber = 0;
704 for ( ; colIt != rowIt->constEnd(); ++colIt )
706 if (
mColumns.
at( columnNumber )->width() <= 0 )
710 mMaxColumnWidthMap[ columnNumber ] = qMax( currentCellTextWidth, mMaxColumnWidthMap[ columnNumber ] );
732 totalWidth += maxColWidthIt.
value();
746 int rowsAlreadyShown = 0;
748 int rowsVisibleInLastFrame = 0;
749 double heightOfLastFrame = 0;
750 for (
int idx = 0; idx < numberExistingFrames; ++idx )
755 rowsVisibleInLastFrame =
rowsVisible( heightOfLastFrame, hasHeader );
756 rowsAlreadyShown += rowsVisibleInLastFrame;
757 height += heightOfLastFrame;
770 rowsVisibleInLastFrame =
rowsVisible( heightOfLastFrame, hasHeader );
776 if ( remainingRows <= 0 )
782 if ( rowsVisibleInLastFrame < 1 )
791 int numberFramesMissing = ceil((
double )remainingRows / (
double )rowsVisibleInLastFrame );
792 height += heightOfLastFrame * numberFramesMissing;
799 if ( rows < 1 && !drawHeaderLines )
806 currentY = halfGridStrokeWidth;
807 if ( drawHeaderLines )
813 for (
int row = 0; row < rows; ++row )
825 if ( numberRows < 1 && !hasHeader )
831 double tableHeight = 0;
837 double headerHeight = tableHeight;
841 double currentX = halfGridStrokeWidth;
842 painter->
drawLine(
QPointF( currentX, halfGridStrokeWidth ),
QPointF( currentX, tableHeight - halfGridStrokeWidth ) );
846 for ( ; maxColWidthIt != maxWidthMap.
constEnd(); ++maxColWidthIt )
849 if ( col == maxWidthMap.
size() || !mergeCells )
851 painter->
drawLine(
QPointF( currentX, halfGridStrokeWidth ),
QPointF( currentX, tableHeight - halfGridStrokeWidth ) );
853 else if ( hasHeader )
855 painter->
drawLine(
QPointF( currentX, halfGridStrokeWidth ),
QPointF( currentX, headerHeight - halfGridStrokeWidth ) );
874 if ( contents.
indexOf( row ) >= 0 )
QColor mContentFontColor
Table contents font color.
QFont mContentFont
Table contents font.
double totalWidth()
Returns total width of table contents.
virtual void recalculateFrameSizes()
Recalculates the portion of the multiframe item which is shown in each of it's component frames...
QDomNodeList elementsByTagName(const QString &tagname) const
virtual QMap< int, QString > headerLabels() const
Returns the text used in the column headers for the table.
virtual QSizeF minFrameSize(const int frameIndex=-1) const override
Returns the minimum size for a frames, if desired.
void setShowGrid(const bool showGrid)
Sets whether grid lines should be drawn in the table.
bool mShowGrid
True if grid should be shown.
void setGridStrokeWidth(const double width)
Sets the width for grid lines in the table.
double mGridStrokeWidth
Width of grid lines.
void setRenderHint(RenderHint hint, bool on)
QDomNode appendChild(const QDomNode &newChild)
void setGridColor(const QColor &color)
Sets color used for grid lines in the table.
QString attribute(const QString &name, const QString &defValue) const
const_iterator constBegin() const
const T & at(int i) const
A item that forms part of a map composition.
virtual bool writeXML(QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const override
Stores state information about multiframe in DOM element.
QFont mHeaderFont
Header font.
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 setEmptyTableBehaviour(const EmptyTableMode mode)
Sets the behaviour for empty tables with no content rows.
void setJoinStyle(Qt::PenJoinStyle style)
static QColor decodeColor(QString str)
static double fontAscentMM(const QFont &font)
Calculate font ascent in millimeters, including workarounds for QT font rendering issues...
virtual void render(QPainter *p, const QRectF &renderExtent, const int frameIndex) override
Renders a portion of the multiframe's content into a painter.
void setShowEmptyRows(const bool showEmpty)
Sets whether empty rows should be drawn.
void drawLine(const QLineF &line)
void recalculateTableSize()
Recalculates and updates the size of the table and all table frames.
double toDouble(bool *ok) const
EmptyTableMode mEmptyTableMode
Behaviour for empty tables.
QColor mHeaderFontColor
Header font color.
QString tr(const char *sourceText, const char *disambiguation, int n)
double mCellMargin
Margin between cell borders and cell text.
void setColumns(QgsComposerTableColumns columns)
Replaces the columns in the table with a specified list of QgsComposerTableColumns.
static QString encodeColor(QColor color)
HeaderMode mHeaderMode
Header display mode.
int indexOf(const T &value, int from) const
void drawVerticalGridLines(QPainter *painter, const QMap< int, double > &maxWidthMap, const int numberRows, const bool hasHeader, const bool mergeCells=false) const
Draws the vertical grid lines for the table.
QDomElement toElement() const
bool _readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false)
Restores state information about base multiframe object from a DOM element.
void drawRect(const QRectF &rectangle)
void setContentFontColor(const QColor &color)
Sets the color used to draw text in table body cells.
QString number(int n, int base)
void append(const T &value)
bool mShowEmptyRows
True if empty rows should be shown in the table.
bool contentsContainsRow(const QgsComposerTableContents &contents, const QgsComposerTableRow &row) const
Checks whether a table contents contains a given row.
void recalculateFrameRects()
Forces a recalculation of all the associated frame's scene rectangles.
bool fromString(const QString &descrip)
virtual QSizeF fixedFrameSize(const int frameIndex=-1) const override
Returns the fixed size for a frame, if desired.
QPair< int, int > rowRange(const QRectF &extent, const int frameIndex) const
Calculates a range of rows which should be visible in a given frame extent.
void setPen(const QColor &color)
void setAttribute(const QString &name, const QString &value)
double totalHeight() const
Returns total height of table contents.
int toInt(bool *ok, int base) const
Abstract base class for composer items with the ability to distribute the content to several frames (...
const_iterator constEnd() const
bool _writeXML(QDomElement &elem, QDomDocument &doc, bool ignoreFrames=false) const
Stores state information about base multiframe object in DOM element.
HeaderHAlignment mHeaderHAlignment
Alignment for table headers.
void setWidthF(qreal width)
void setBrush(const QBrush &brush)
void setEmptyTableMessage(const QString message)
Sets the message for empty tables with no content rows.
void recalculateFrameSizes() override
QMap< int, double > mMaxColumnWidthMap
Map of maximum width for each column.
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.
int frameCount() const
Returns the number of frames associated with this multiframe.
Stores properties of a column in a QgsComposerTable.
void setColor(const QColor &color)
virtual bool readXML(const QDomElement &itemElem, const QDomDocument &doc, bool ignoreFrames=false) override
Reads multiframe state information from a DOM element.
virtual bool calculateMaxColumnWidths()
Calculates the maximum width of text shown in columns.
Graphics scene for map printing.
void setHeaderMode(const HeaderMode mode)
Sets the display mode for headers in the table.
void setBackgroundColor(const QColor &color)
Sets color used for background of table.
QColor mGridColor
Color for grid lines.
void setHeaderHAlignment(const HeaderHAlignment alignment)
Sets the horizontal alignment for table headers.
QgsComposerTableContents mTableContents
Contents to show in table.
QString mEmptyTableMessage
String to show in empty tables.
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
void deleteFrames()
Removes and deletes all child frames.
QgsComposerTableColumns mColumns
Columns to show in table.
QVariant value(const QString &key, const QVariant &defaultValue) const
void setHeaderFontColor(const QColor &color)
Sets the color used to draw header text in the table.
void setHeaderFont(const QFont &font)
Sets the font used to draw header text in the table.
QRectF extent() const
Returns the visible portion of the multi frame's content which is shown in this frame.
virtual void refreshAttributes()
Refreshes the contents shown in the table by querying for new data.
void setFamily(const QString &family)
double paperHeight() const
Height of paper item.
void drawHorizontalGridLines(QPainter *painter, const int rows, const bool drawHeaderLines) const
Draws the horizontal grid lines for the table.
virtual ~QgsComposerTableV2()
void setCellMargin(const double margin)
Sets the margin distance between cell borders and their contents.
bool showGrid() const
Returns whether grid lines are drawn in the table.
int frameIndex(QgsComposerFrame *frame) const
Returns the index of a frame within the multiframe.
virtual bool getTableContents(QgsComposerTableContents &contents)=0
Fetches the contents used for the cells in the table.
iterator insert(const Key &key, const T &value)
int rowsVisible(const int frameIndex) const
Calculates how many content rows are visible within a given frame.
QgsComposerFrame * frame(int i) const
Returns a child frame from the multiframe.
virtual bool readXML(const QDomElement &columnElem)
Reads the column's properties from xml.
void update()
Forces a redraw of all child frames.
static QDomElement toXmlElement(const QFont &font, QDomDocument &document, const QString &elementName)
Returns a DOM element containing the properties of the font.
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
void setContentFont(const QFont &font)
Sets the font used to draw text in table body cells.
const_iterator constBegin() const
QColor mBackgroundColor
Color for table background.
QgsComposition::PlotStyle plotStyle() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void handleFrameRemoval(QgsComposerItem *item)
Called before a frame is going to be removed.
virtual QSizeF totalSize() const override
Returns the total size of the multiframe's content.
void changed()
Emitted when the properties of a multi frame have changed, and the GUI item widget must be updated...
QDomNode at(int index) const
const T value(const Key &key) const