29 QDomElement bgColorElem = doc.createElement( QStringLiteral(
"backgroundColor" ) );
30 bgColorElem.setAttribute( QStringLiteral(
"red" ), QString::number( mBackgroundColor.red() ) );
31 bgColorElem.setAttribute( QStringLiteral(
"green" ), QString::number( mBackgroundColor.green() ) );
32 bgColorElem.setAttribute( QStringLiteral(
"blue" ), QString::number( mBackgroundColor.blue() ) );
33 bgColorElem.setAttribute( QStringLiteral(
"alpha" ), QString::number( mBackgroundColor.alpha() ) );
34 columnElem.appendChild( bgColorElem );
36 columnElem.setAttribute( QStringLiteral(
"hAlignment" ), mHAlignment );
37 columnElem.setAttribute( QStringLiteral(
"vAlignment" ), mVAlignment );
39 columnElem.setAttribute( QStringLiteral(
"heading" ), mHeading );
40 columnElem.setAttribute( QStringLiteral(
"attribute" ), mAttribute );
42 columnElem.setAttribute( QStringLiteral(
"sortByRank" ), QString::number( mSortByRank ) );
43 columnElem.setAttribute( QStringLiteral(
"sortOrder" ), QString::number( mSortOrder ) );
45 columnElem.setAttribute( QStringLiteral(
"width" ), QString::number( mWidth ) );
52 mHAlignment =
static_cast< Qt::AlignmentFlag
>( columnElem.attribute( QStringLiteral(
"hAlignment" ), QString::number( Qt::AlignLeft ) ).toInt() );
53 mVAlignment =
static_cast< Qt::AlignmentFlag
>( columnElem.attribute( QStringLiteral(
"vAlignment" ), QString::number( Qt::AlignVCenter ) ).toInt() );
54 mHeading = columnElem.attribute( QStringLiteral(
"heading" ), QString() );
55 mAttribute = columnElem.attribute( QStringLiteral(
"attribute" ), QString() );
56 mSortByRank = columnElem.attribute( QStringLiteral(
"sortByRank" ), QStringLiteral(
"0" ) ).toInt();
57 mSortOrder =
static_cast< Qt::SortOrder
>( columnElem.attribute( QStringLiteral(
"sortOrder" ), QString::number( Qt::AscendingOrder ) ).toInt() );
58 mWidth = columnElem.attribute( QStringLiteral(
"width" ), QStringLiteral(
"0.0" ) ).toDouble();
60 const QDomNodeList bgColorList = columnElem.elementsByTagName( QStringLiteral(
"backgroundColor" ) );
61 if ( !bgColorList.isEmpty() )
63 const QDomElement bgColorElem = bgColorList.at( 0 ).toElement();
64 bool redOk, greenOk, blueOk, alphaOk;
65 int bgRed, bgGreen, bgBlue, bgAlpha;
66 bgRed = bgColorElem.attribute( QStringLiteral(
"red" ) ).toDouble( &redOk );
67 bgGreen = bgColorElem.attribute( QStringLiteral(
"green" ) ).toDouble( &greenOk );
68 bgBlue = bgColorElem.attribute( QStringLiteral(
"blue" ) ).toDouble( &blueOk );
69 bgAlpha = bgColorElem.attribute( QStringLiteral(
"alpha" ) ).toDouble( &alphaOk );
70 if ( redOk && greenOk && blueOk && alphaOk )
72 mBackgroundColor = QColor( bgRed, bgGreen, bgBlue, bgAlpha );
bool readXml(const QDomElement &columnElem)
Reads the column's properties from xml.
bool writeXml(QDomElement &columnElem, QDomDocument &doc) const
Writes the column's properties to xml for storage.
QgsLayoutTableColumn(const QString &heading=QString())
Constructor for QgsLayoutTableColumn.