40 QList<QgsAttributeMap> attributeList;
46 QMap<int, double> maxColumnWidthMap;
59 QMap<int, QString>::const_iterator columnIt = headerMap.constBegin();
61 for ( ; columnIt != headerMap.constEnd(); ++columnIt )
73 QList<QgsAttributeMap>::const_iterator attIt = attributeList.begin();
74 for ( ; attIt != attributeList.end(); ++attIt )
80 QgsAttributeMap::const_iterator attMapIt = currentAttributeMap.find( columnIt.key() );
81 if ( attMapIt != currentAttributeMap.constEnd() )
89 currentX += maxColumnWidthMap[columnIt.key()];
100 painter->setPen( gridPen );
115 QList<QgsAttributeMap> attributes;
121 QMap<int, double> maxWidthMap;
132 elem.setAttribute(
"headerFont",
mHeaderFont.toString() );
133 elem.setAttribute(
"contentFont",
mContentFont.toString() );
135 elem.setAttribute(
"gridColorRed",
mGridColor.red() );
136 elem.setAttribute(
"gridColorGreen",
mGridColor.green() );
137 elem.setAttribute(
"gridColorBlue",
mGridColor.blue() );
138 elem.setAttribute(
"showGrid",
mShowGrid );
144 if ( itemElem.isNull() )
149 mHeaderFont.fromString( itemElem.attribute(
"headerFont",
"" ) );
150 mContentFont.fromString( itemElem.attribute(
"contentFont",
"" ) );
152 mGridStrokeWidth = itemElem.attribute(
"gridStrokeWidth",
"0.5" ).toDouble();
153 mShowGrid = itemElem.attribute(
"showGrid",
"1" ).toInt();
156 int gridRed = itemElem.attribute(
"gridColorRed",
"0" ).toInt();
157 int gridGreen = itemElem.attribute(
"gridColorGreen",
"0" ).toInt();
158 int gridBlue = itemElem.attribute(
"gridColorBlue",
"0" ).toInt();
159 mGridColor = QColor( gridRed, gridGreen, gridBlue );
162 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
163 if ( composerItemList.size() > 0 )
165 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
175 QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
176 for ( ; headerIt != headerMap.constEnd(); ++headerIt )
182 QList<QgsAttributeMap>::const_iterator attIt = attributeList.constBegin();
185 double currentAttributeTextWidth;
187 for ( ; attIt != attributeList.constEnd(); ++attIt )
189 currentAttributeMap = *attIt;
190 QgsAttributeMap::const_iterator attMapIt = currentAttributeMap.constBegin();
191 for ( ; attMapIt != currentAttributeMap.constEnd(); ++attMapIt )
194 if ( currentAttributeTextWidth > maxWidthMap[attMapIt.key()] )
196 maxWidthMap[attMapIt.key()] = currentAttributeTextWidth;
214 double totalWidth = 0;
215 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
216 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
218 totalWidth += maxColWidthIt.value();
222 QTransform t = transform();
230 double currentY = halfGridStrokeWidth;
231 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
234 for (
int i = 0; i < nAttributes; ++i )
236 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
240 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
247 double currentX = halfGridStrokeWidth;
248 p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );
250 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
251 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
254 p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );