LCOV - code coverage report
Current view: top level - core/layout - qgslayouttablecolumn.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 44 0.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :                         QgsLayoutTableColumn.cpp
       3                 :            :                          ------------------------
       4                 :            :     begin                : November 2017
       5                 :            :     copyright            : (C) 2017 by Nyall Dawson
       6                 :            :     email                : nyall dot dawson at gmail dot com
       7                 :            :  ***************************************************************************/
       8                 :            : 
       9                 :            : /***************************************************************************
      10                 :            :  *                                                                         *
      11                 :            :  *   This program is free software; you can redistribute it and/or modify  *
      12                 :            :  *   it under the terms of the GNU General Public License as published by  *
      13                 :            :  *   the Free Software Foundation; either version 2 of the License, or     *
      14                 :            :  *   (at your option) any later version.                                   *
      15                 :            :  *                                                                         *
      16                 :            :  ***************************************************************************/
      17                 :            : 
      18                 :            : #include "qgslayouttablecolumn.h"
      19                 :            : #include "qgis.h"
      20                 :            : #include <memory>
      21                 :            : 
      22                 :          0 : QgsLayoutTableColumn::QgsLayoutTableColumn( const QString &heading )
      23                 :          0 :   : mHeading( heading )
      24                 :          0 : {}
      25                 :            : 
      26                 :          0 : bool QgsLayoutTableColumn::writeXml( QDomElement &columnElem, QDomDocument &doc ) const
      27                 :            : {
      28                 :            :   //background color
      29                 :          0 :   QDomElement bgColorElem = doc.createElement( QStringLiteral( "backgroundColor" ) );
      30                 :          0 :   bgColorElem.setAttribute( QStringLiteral( "red" ), QString::number( mBackgroundColor.red() ) );
      31                 :          0 :   bgColorElem.setAttribute( QStringLiteral( "green" ), QString::number( mBackgroundColor.green() ) );
      32                 :          0 :   bgColorElem.setAttribute( QStringLiteral( "blue" ), QString::number( mBackgroundColor.blue() ) );
      33                 :          0 :   bgColorElem.setAttribute( QStringLiteral( "alpha" ), QString::number( mBackgroundColor.alpha() ) );
      34                 :          0 :   columnElem.appendChild( bgColorElem );
      35                 :            : 
      36                 :          0 :   columnElem.setAttribute( QStringLiteral( "hAlignment" ), mHAlignment );
      37                 :          0 :   columnElem.setAttribute( QStringLiteral( "vAlignment" ), mVAlignment );
      38                 :            : 
      39                 :          0 :   columnElem.setAttribute( QStringLiteral( "heading" ), mHeading );
      40                 :          0 :   columnElem.setAttribute( QStringLiteral( "attribute" ), mAttribute );
      41                 :            : 
      42                 :          0 :   columnElem.setAttribute( QStringLiteral( "sortByRank" ), QString::number( mSortByRank ) );
      43                 :          0 :   columnElem.setAttribute( QStringLiteral( "sortOrder" ), QString::number( mSortOrder ) );
      44                 :            : 
      45                 :          0 :   columnElem.setAttribute( QStringLiteral( "width" ), QString::number( mWidth ) );
      46                 :            : 
      47                 :            :   return true;
      48                 :          0 : }
      49                 :            : 
      50                 :          0 : bool QgsLayoutTableColumn::readXml( const QDomElement &columnElem )
      51                 :            : {
      52                 :          0 :   mHAlignment = static_cast< Qt::AlignmentFlag >( columnElem.attribute( QStringLiteral( "hAlignment" ), QString::number( Qt::AlignLeft ) ).toInt() );
      53                 :          0 :   mVAlignment = static_cast< Qt::AlignmentFlag >( columnElem.attribute( QStringLiteral( "vAlignment" ), QString::number( Qt::AlignVCenter ) ).toInt() );
      54                 :          0 :   mHeading = columnElem.attribute( QStringLiteral( "heading" ), QString() );
      55                 :          0 :   mAttribute = columnElem.attribute( QStringLiteral( "attribute" ), QString() );
      56                 :          0 :   mSortByRank = columnElem.attribute( QStringLiteral( "sortByRank" ), QStringLiteral( "0" ) ).toInt();
      57                 :          0 :   mSortOrder = static_cast< Qt::SortOrder >( columnElem.attribute( QStringLiteral( "sortOrder" ), QString::number( Qt::AscendingOrder ) ).toInt() );
      58                 :          0 :   mWidth = columnElem.attribute( QStringLiteral( "width" ), QStringLiteral( "0.0" ) ).toDouble();
      59                 :            : 
      60                 :          0 :   QDomNodeList bgColorList = columnElem.elementsByTagName( QStringLiteral( "backgroundColor" ) );
      61                 :          0 :   if ( !bgColorList.isEmpty() )
      62                 :            :   {
      63                 :          0 :     QDomElement bgColorElem = bgColorList.at( 0 ).toElement();
      64                 :            :     bool redOk, greenOk, blueOk, alphaOk;
      65                 :            :     int bgRed, bgGreen, bgBlue, bgAlpha;
      66                 :          0 :     bgRed = bgColorElem.attribute( QStringLiteral( "red" ) ).toDouble( &redOk );
      67                 :          0 :     bgGreen = bgColorElem.attribute( QStringLiteral( "green" ) ).toDouble( &greenOk );
      68                 :          0 :     bgBlue = bgColorElem.attribute( QStringLiteral( "blue" ) ).toDouble( &blueOk );
      69                 :          0 :     bgAlpha = bgColorElem.attribute( QStringLiteral( "alpha" ) ).toDouble( &alphaOk );
      70                 :          0 :     if ( redOk && greenOk && blueOk && alphaOk )
      71                 :            :     {
      72                 :          0 :       mBackgroundColor = QColor( bgRed, bgGreen, bgBlue, bgAlpha );
      73                 :          0 :     }
      74                 :          0 :   }
      75                 :            : 
      76                 :            :   return true;
      77                 :          0 : }

Generated by: LCOV version 1.14