24 , mLineTextDistance( 1.0 )
26 , mGridStrokeWidth( 0.5 )
27 , mGridColor( QColor( 0, 0, 0 ) )
38 Q_UNUSED( itemStyle );
46 QList<QgsAttributeMap> attributeMaps;
52 QMap<int, double> maxColumnWidthMap;
59 painter->setPen( Qt::SolidLine );
66 QMap<int, QString>::const_iterator columnIt = headerMap.constBegin();
68 for ( ; columnIt != headerMap.constEnd(); ++columnIt )
80 QList<QgsAttributeMap>::const_iterator attIt = attributeMaps.begin();
81 for ( ; attIt != attributeMaps.end(); ++attIt )
87 QString str = currentAttributeMap[ columnIt.key()].toString();
93 currentX += maxColumnWidthMap[columnIt.key()];
104 painter->setPen( gridPen );
119 QList<QgsAttributeMap> attributes;
123 QMap<int, double> maxWidthMap;
133 elem.setAttribute(
"headerFont",
mHeaderFont.toString() );
134 elem.setAttribute(
"contentFont",
mContentFont.toString() );
135 elem.setAttribute(
"gridStrokeWidth", QString::number(
mGridStrokeWidth ) );
136 elem.setAttribute(
"gridColorRed",
mGridColor.red() );
137 elem.setAttribute(
"gridColorGreen",
mGridColor.green() );
138 elem.setAttribute(
"gridColorBlue",
mGridColor.blue() );
139 elem.setAttribute(
"showGrid",
mShowGrid );
145 if ( itemElem.isNull() )
150 mHeaderFont.fromString( itemElem.attribute(
"headerFont",
"" ) );
151 mContentFont.fromString( itemElem.attribute(
"contentFont",
"" ) );
153 mGridStrokeWidth = itemElem.attribute(
"gridStrokeWidth",
"0.5" ).toDouble();
154 mShowGrid = itemElem.attribute(
"showGrid",
"1" ).toInt();
157 int gridRed = itemElem.attribute(
"gridColorRed",
"0" ).toInt();
158 int gridGreen = itemElem.attribute(
"gridColorGreen",
"0" ).toInt();
159 int gridBlue = itemElem.attribute(
"gridColorBlue",
"0" ).toInt();
160 mGridColor = QColor( gridRed, gridGreen, gridBlue );
163 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
164 if ( composerItemList.size() > 0 )
166 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
176 QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
177 for ( ; headerIt != headerMap.constEnd(); ++headerIt )
183 QList<QgsAttributeMap>::const_iterator attIt = attributeMaps.constBegin();
185 double currentAttributeTextWidth;
187 for ( ; attIt != attributeMaps.constEnd(); ++attIt )
189 QgsAttributeMap::const_iterator attIt2 = attIt->constBegin();
190 for ( ; attIt2 != attIt->constEnd(); ++attIt2 )
193 if ( currentAttributeTextWidth > maxWidthMap[ attIt2.key()] )
195 maxWidthMap[ attIt2.key()] = currentAttributeTextWidth;
205 int n = attributeMaps.size();
212 double totalWidth = 0;
213 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
214 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
216 totalWidth += maxColWidthIt.value();
219 totalWidth += ( maxWidthMap.size() + 1 ) * mGridStrokeWidth;
220 QTransform t = transform();
228 double currentY = halfGridStrokeWidth;
229 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
232 for (
int i = 0; i < nAttributes; ++i )
234 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
238 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
245 double currentX = halfGridStrokeWidth;
246 p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );
248 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
249 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
252 p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );