24 , mLineTextDistance( 1.0 )
26 , mGridStrokeWidth( 0.5 )
27 , mGridColor( QColor( 0, 0, 0 ) )
31 QString defaultFontString = settings.value(
"/Composer/defaultFont" ).toString();
32 if ( !defaultFontString.isEmpty() )
46 Q_UNUSED( itemStyle );
54 QList<QgsAttributeMap> attributeMaps;
60 QMap<int, double> maxColumnWidthMap;
67 painter->setPen( Qt::SolidLine );
74 QMap<int, QString>::const_iterator columnIt = headerMap.constBegin();
76 for ( ; columnIt != headerMap.constEnd(); ++columnIt )
88 QList<QgsAttributeMap>::const_iterator attIt = attributeMaps.begin();
89 for ( ; attIt != attributeMaps.end(); ++attIt )
95 QString str = currentAttributeMap[ columnIt.key()].toString();
101 currentX += maxColumnWidthMap[columnIt.key()];
112 gridPen.setJoinStyle( Qt::MiterJoin );
113 painter->setPen( gridPen );
128 QList<QgsAttributeMap> attributes;
132 QMap<int, double> maxWidthMap;
142 elem.setAttribute(
"headerFont",
mHeaderFont.toString() );
143 elem.setAttribute(
"contentFont",
mContentFont.toString() );
144 elem.setAttribute(
"gridStrokeWidth", QString::number(
mGridStrokeWidth ) );
145 elem.setAttribute(
"gridColorRed",
mGridColor.red() );
146 elem.setAttribute(
"gridColorGreen",
mGridColor.green() );
147 elem.setAttribute(
"gridColorBlue",
mGridColor.blue() );
148 elem.setAttribute(
"showGrid",
mShowGrid );
154 if ( itemElem.isNull() )
159 mHeaderFont.fromString( itemElem.attribute(
"headerFont",
"" ) );
160 mContentFont.fromString( itemElem.attribute(
"contentFont",
"" ) );
162 mGridStrokeWidth = itemElem.attribute(
"gridStrokeWidth",
"0.5" ).toDouble();
163 mShowGrid = itemElem.attribute(
"showGrid",
"1" ).toInt();
166 int gridRed = itemElem.attribute(
"gridColorRed",
"0" ).toInt();
167 int gridGreen = itemElem.attribute(
"gridColorGreen",
"0" ).toInt();
168 int gridBlue = itemElem.attribute(
"gridColorBlue",
"0" ).toInt();
169 mGridColor = QColor( gridRed, gridGreen, gridBlue );
172 QDomNodeList composerItemList = itemElem.elementsByTagName(
"ComposerItem" );
173 if ( composerItemList.size() > 0 )
175 QDomElement composerItemElem = composerItemList.at( 0 ).toElement();
185 QMap<int, QString>::const_iterator headerIt = headerMap.constBegin();
186 for ( ; headerIt != headerMap.constEnd(); ++headerIt )
192 QList<QgsAttributeMap>::const_iterator attIt = attributeMaps.constBegin();
194 double currentAttributeTextWidth;
196 for ( ; attIt != attributeMaps.constEnd(); ++attIt )
198 QgsAttributeMap::const_iterator attIt2 = attIt->constBegin();
199 for ( ; attIt2 != attIt->constEnd(); ++attIt2 )
202 if ( currentAttributeTextWidth > maxWidthMap[ attIt2.key()] )
204 maxWidthMap[ attIt2.key()] = currentAttributeTextWidth;
214 int n = attributeMaps.size();
221 double totalWidth = 0;
222 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
223 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
225 totalWidth += maxColWidthIt.value();
228 totalWidth += ( maxWidthMap.size() + 1 ) * mGridStrokeWidth;
237 double currentY = halfGridStrokeWidth;
238 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
241 for (
int i = 0; i < nAttributes; ++i )
243 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
247 p->drawLine( QPointF( halfGridStrokeWidth, currentY ), QPointF( rect().width() - halfGridStrokeWidth, currentY ) );
254 double currentX = halfGridStrokeWidth;
255 p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );
257 QMap<int, double>::const_iterator maxColWidthIt = maxWidthMap.constBegin();
258 for ( ; maxColWidthIt != maxWidthMap.constEnd(); ++maxColWidthIt )
261 p->drawLine( QPointF( currentX, halfGridStrokeWidth ), QPointF( currentX, rect().height() - halfGridStrokeWidth ) );