LCOV - code coverage report
Current view: top level - src/converters - convertertoqwidget.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 356 374 95.2 %
Date: 2019-05-08 03:46:12 Functions: 19 19 100.0 %

          Line data    Source code
       1             : #include "convertertoqwidget.hpp"
       2             : 
       3             : #include <QFrame>
       4             : #include <QLabel>
       5             : #include <QPainter>
       6             : #include <QDebug>
       7             : #include <QList>
       8             : 
       9             : #include "utils/replacer.hpp"
      10             : 
      11             : namespace qtreports
      12             : {
      13             :     namespace detail
      14             :     {
      15             : 
      16          17 :         ConverterToQWidget::ConverterToQWidget(const ReportPtr & report) :
      17             :             m_report(report),
      18             :             m_type(WidgetType::Report),
      19          17 :             m_currentHeight(0)
      20          17 :         {}
      21             : 
      22          17 :         ConverterToQWidget::~ConverterToQWidget() {}
      23             : 
      24          11 :         bool    ConverterToQWidget::convert(WidgetType type)
      25             :         {
      26          11 :             m_type = type;
      27          11 :             return createQWidget(m_report);
      28             :         }
      29             : 
      30          10 :         bool    ConverterToQWidget::isReport() const
      31             :         {
      32          10 :             return m_type == WidgetType::Report;
      33             :         }
      34             : 
      35         576 :         bool    ConverterToQWidget::isLayout() const
      36             :         {
      37         576 :             return m_type == WidgetType::Layout;
      38             :         }
      39             : 
      40           3 :         ConverterToQWidget::WidgetType  ConverterToQWidget::getType() const
      41             :         {
      42           3 :             return m_type;
      43             :         }
      44             : 
      45           5 :         const QWidgetPtr    ConverterToQWidget::getQWidget() const
      46             :         {
      47           5 :             return m_qwidget;
      48             :         }
      49             : 
      50           3 :         const QWidgetPtr    ConverterToQWidget::getPage(int i) const
      51             :         {
      52           3 :             return m_pages.value(i);
      53             :         }
      54             : 
      55           4 :         const QVector< QWidgetPtr >     ConverterToQWidget::getPages() const
      56             :         {
      57           4 :             return m_pages;
      58             :         }
      59             : 
      60           9 :         const QString       ConverterToQWidget::getLastError() const
      61             :         {
      62           9 :             return m_lastError;
      63             :         }
      64             : 
      65          30 :         QHBoxLayout * createLayout(QWidget * left, QWidget * center, QWidget * right)
      66             :         {
      67          30 :             auto layout = new QHBoxLayout();
      68          30 :             layout->setMargin(0);
      69          30 :             layout->setSpacing(0);
      70             : 
      71          30 :             layout->addWidget(left);
      72          30 :             layout->addWidget(center);
      73          30 :             layout->addWidget(right);
      74             : 
      75          30 :             return layout;
      76             :         }
      77             : 
      78          14 :         void    ConverterToQWidget::addVerticalBorder(QBoxLayout * parent, const QMargins & margins, int height)
      79             :         {
      80          14 :             auto leftFrame = new QFrame();
      81          14 :             leftFrame->setFixedWidth(margins.left());
      82          14 :             leftFrame->setFixedHeight(height);
      83             : 
      84          14 :             auto centerFrame = new QFrame();
      85          14 :             centerFrame->setFixedHeight(height);
      86             : 
      87          14 :             auto rightFrame = new QFrame();
      88          14 :             rightFrame->setFixedWidth(margins.right());
      89          14 :             rightFrame->setFixedHeight(height);
      90             : 
      91          14 :             if(isLayout())
      92             :             {
      93          12 :                 QString style = "border: 1px solid gray; ";
      94           6 :                 leftFrame->setStyleSheet(style + "border-width: 0px 1px 0px 0px; ");
      95           6 :                 rightFrame->setStyleSheet(style + "border-width: 0px 0px 0px 1px; ");
      96             :             }
      97             : 
      98          14 :             auto layout = createLayout(leftFrame, centerFrame, rightFrame);
      99          14 :             parent->addLayout(layout);
     100          14 :         }
     101             : 
     102           7 :         void    ConverterToQWidget::addEmptySection(QBoxLayout * parent, const QMargins & margins)
     103             :         {
     104           7 :             auto leftFrame = new QFrame();
     105           7 :             leftFrame->setFixedWidth(margins.left());
     106             : 
     107           7 :             auto centerFrame = new QFrame();
     108             : 
     109           7 :             auto rightFrame = new QFrame();
     110           7 :             rightFrame->setFixedWidth(margins.right());
     111             : 
     112           7 :             if(isLayout())
     113             :             {
     114           6 :                 QString style = "border: 1px solid gray; ";
     115           3 :                 leftFrame->setStyleSheet(style + "border-width: 1px 1px 1px 0px; ");
     116           3 :                 centerFrame->setObjectName("frame");
     117           3 :                 centerFrame->setStyleSheet("#frame{" + style + "border-width: 1px 0px 1px 0px; }");
     118           3 :                 rightFrame->setStyleSheet(style + "border-width: 1px 0px 1px 1px; ");
     119             :             }
     120             : 
     121           7 :             auto layout = createLayout(leftFrame, centerFrame, rightFrame);
     122           7 :             parent->addLayout(layout);
     123           7 :         }
     124             : 
     125           9 :         QFrame *    ConverterToQWidget::addSectionLayout(QBoxLayout * parent, const QMargins & margins, int height)
     126             :         {
     127           9 :             auto leftFrame = new QFrame();
     128           9 :             leftFrame->setFixedHeight(height);
     129           9 :             leftFrame->setFixedWidth(margins.left());
     130             : 
     131           9 :             auto centerFrame = new QFrame();
     132           9 :             centerFrame->setFixedHeight(height);
     133             : 
     134           9 :             auto rightFrame = new QFrame();
     135           9 :             rightFrame->setFixedHeight(height);
     136           9 :             rightFrame->setFixedWidth(margins.right());
     137             : 
     138           9 :             if(isLayout())
     139             :             {
     140          18 :                 QString style = "border: 1px solid gray; ";
     141           9 :                 leftFrame->setStyleSheet(style + "border-width: 1px 1px 0px 0px; ");
     142           9 :                 centerFrame->setObjectName("frame");
     143           9 :                 centerFrame->setStyleSheet("#frame{" + style + "border-width: 1px 0px 0px 0px; }");
     144           9 :                 rightFrame->setStyleSheet(style + "border-width: 1px 0px 0px 1px; ");
     145             :             }
     146             : 
     147           9 :             auto layout = createLayout(leftFrame, centerFrame, rightFrame);
     148           9 :             parent->addLayout(layout);
     149             : 
     150           9 :             return centerFrame;
     151             :         }
     152             : 
     153          29 :         void    ConverterToQWidget::addPage()
     154             :         {
     155          58 :             QWidgetPtr widget(new QWidget());
     156          29 :             widget->resize(m_report->getSize());
     157          29 :             widget->setStyleSheet("background-color: white; ");
     158          29 :             m_pages.append(widget);
     159          29 :         }
     160             : 
     161          11 :         bool    ConverterToQWidget::createQWidget(const ReportPtr & report)
     162             :         {
     163          11 :             if(report.isNull())
     164             :             {
     165           1 :                 m_lastError = "Report is empty";
     166           1 :                 return false;
     167             :             }
     168             : 
     169          20 :             auto detail = report->getDetail();
     170          10 :             if(detail.isNull())
     171             :             {
     172           3 :                 m_lastError = "Report->Detail is empty";
     173           3 :                 return false;
     174             :             }
     175             : 
     176           7 :             m_qwidget = QWidgetPtr(new QWidget());
     177           7 :             m_qwidget->setStyleSheet("background-color: white; ");//border: 1px solid gray;
     178             :             //m_qwidget->setContentsMargins(m_report->getMargins());
     179             : 
     180           7 :             addPage();
     181             : 
     182           7 :             auto layout = new QVBoxLayout(m_qwidget.data());
     183           7 :             layout->setMargin(0);
     184           7 :             layout->setSpacing(0);
     185           7 :             addVerticalBorder(layout, report->getMargins(), report->getTopMargin());
     186             : 
     187          14 :             auto title = report->getTitle();
     188           7 :             if(!title.isNull())
     189             :             {
     190           4 :                 QWidget * sectionWidget = isLayout() ? addSectionLayout(layout, report->getMargins(), title->getHeight()) : nullptr;
     191           4 :                 if(!createSection(sectionWidget, title, 0))
     192             :                 {
     193           0 :                     return false;
     194             :                 }
     195             :             }
     196             : 
     197           7 :             if(!addGroupsIntoReport(report, detail, layout))
     198           0 :                 return false;
     199             : 
     200          14 :             auto summary = report->getSummary();
     201           7 :             if(!summary.isNull())
     202             :             {
     203           4 :                 int lastField = m_report->getFieldsDataCount() - 1;
     204           4 :                 QWidget * sectionWidget = isLayout() ? addSectionLayout(layout, report->getMargins(), summary->getHeight()) : nullptr;
     205           4 :                 if(!createSection(sectionWidget, summary, lastField))
     206             :                 {
     207           0 :                     return false;
     208             :                 }
     209             :             }
     210             : 
     211           7 :             addEmptySection(layout, report->getMargins());
     212           7 :             addVerticalBorder(layout, report->getMargins(), report->getBottomMargin());
     213           7 :             return true;
     214             :         }
     215             : 
     216           7 :         bool ConverterToQWidget::addGroupsIntoReport(const ReportPtr & report, const DetailPtr & detail, QVBoxLayout* layout)
     217             :         {
     218          14 :             detail::Replacer replacer;
     219             : 
     220          14 :             QList<GroupPtr> groups = report->getGroups().values();
     221          14 :             QList<QString> groupNames;
     222             :             //Сюда помещаем конкретные имена по которым группируем
     223          14 :             QList<QString> particularNames;
     224           9 :             for (int i = 0; i<groups.length(); i++)
     225             :             {
     226           4 :                 auto groupExpression = groups[i]->getExpression();
     227           2 :                 if(groupExpression == "")
     228             :                 {
     229           0 :                     return false;
     230             :                 }
     231           2 :                 groupNames.append(groupExpression);
     232           2 :                 particularNames.append(replacer.replaceField(groupNames[i], report, 0));
     233             :             }
     234             :             //Открываем хедеры групп
     235           9 :             for (int i = 0; i<groups.length(); i++)
     236             :             {
     237           4 :                 auto header = groups[i]->getHeader();
     238           2 :                 if (!header.isNull())
     239             :                 {
     240           2 :                     QWidget * sectionWidget = isLayout() ? addSectionLayout(layout, report->getMargins(), header->getHeight()) : nullptr;
     241           2 :                     if (!createSection(sectionWidget, header, 0))
     242             :                     {
     243           0 :                         return false;
     244             :                     }
     245             :                 }
     246             :             }
     247             : 
     248           7 :             int rowCount = isReport()? report->getRowCount() : 1;
     249          41 :             for(int i = 0; i < rowCount; i++)
     250             :             {
     251          34 :                 QWidget * sectionWidget = isLayout() ? addSectionLayout(layout, report->getMargins(), detail->getHeight()) : nullptr;
     252             : 
     253             :                 //Закрываем футеры, если группа закончилась
     254          46 :                 for(int j = groups.length() - 1; j >= 0; j--)
     255             :                 {
     256             :                     //сверяем поле в заголовке и текущее поле
     257          12 :                     if(particularNames[j] != replacer.replaceField(groupNames[j], report, i))
     258             :                     {
     259          14 :                         auto footer = report->getGroupByIndex(j)->getFooter();
     260           7 :                         if (!footer.isNull())
     261             :                         {
     262           7 :                             QWidget * sectionWidgetFooter = isLayout() ? addSectionLayout(layout, report->getMargins(), footer->getHeight()) : nullptr;
     263           7 :                             if (!createSection(sectionWidgetFooter, footer, i - 1))
     264             :                             {
     265           0 :                                 return false;
     266             :                             }
     267             :                         }
     268             :                     }
     269             :                 }
     270             :                 //Аналогично открываем хедеры
     271          46 :                 for(int j = 0; j < groupNames.length(); j++)
     272             :                 {                    
     273             :                     //сверяем поле в заголовке и текущее поле
     274          12 :                     if(particularNames[j] != replacer.replaceField(groupNames[j], report, i))
     275             :                     {
     276          14 :                         auto header = report->getGroupByIndex(j)->getHeader();
     277           7 :                         if (!header.isNull())
     278             :                         {
     279           7 :                             QWidget * sectionWidgetHeader = isLayout() ? addSectionLayout(layout, report->getMargins(), header->getHeight()) : nullptr;
     280           7 :                             if (!createSection(sectionWidgetHeader, header, i))
     281             :                             {
     282           0 :                                 return false;
     283             :                             }
     284             :                         }
     285             :                     }
     286             :                 }
     287             :                 //Переписываем имена для сравнения
     288          46 :                 for(int j = 0; j < groupNames.length(); j++)
     289             :                 {
     290          12 :                     particularNames[j] = replacer.replaceField(groupNames[j], report, i);
     291             :                 }
     292             :                 //Выводим поле
     293          34 :                 if (!createSection(sectionWidget, detail, i))
     294             :                 {
     295           0 :                     return false;
     296             :                 }
     297             :             }
     298             :             //Закрываем хедеры групп
     299           9 :             for(int i = groups.length() - 1; i >= 0; i--)
     300             :             {
     301           4 :                 auto footer = groups[i]->getFooter();
     302           2 :                             if (!footer.isNull())
     303             :                             {
     304           2 :                                 QWidget * sectionWidget = isLayout() ? addSectionLayout(layout, report->getMargins(), footer->getHeight()) : nullptr;
     305           2 :                                 if (!createSection(sectionWidget, footer, (rowCount - 1)))
     306             :                                 {
     307           0 :                                     return false;
     308             :                                 }
     309             :                             }
     310             :             }
     311           7 :             return true;
     312             :         }
     313             : 
     314             : 
     315          60 :         bool    ConverterToQWidget::createSection(QWidget * parent, const SectionPtr & section, int i)
     316             :         {
     317          60 :             if(isLayout())
     318             :             {
     319           9 :                 auto label = new QLabel(parent);
     320           9 :                 label->setText(section->getTagName());
     321           9 :                 label->setStyleSheet("font-size: 26px; color: gray");
     322           9 :                 label->setAlignment(Qt::AlignCenter);
     323           9 :                 label->setAttribute(Qt::WA_TranslucentBackground);
     324           9 :                 label->resize(parent->size());
     325             :             }
     326             :             else
     327             :             {
     328         102 :                 detail::Replacer replacer;
     329          51 :                 if(!replacer.replace(section, m_report, i))
     330             :                 {
     331           0 :                     m_lastError = "Error in replacing process: " + replacer.getLastError();
     332           0 :                     return false;
     333             :                 }
     334             :             }
     335             : 
     336          60 :             if(!createBands(parent, section))
     337             :             {
     338           0 :                 return false;
     339             :             }
     340             : 
     341          60 :             return true;
     342             :         }
     343             : 
     344          60 :         bool    ConverterToQWidget::createBands(QWidget * parent, const SectionPtr & section)
     345             :         {
     346          60 :             auto dy = 0;
     347         131 :             for(auto && band : section->getBands())
     348             :             {
     349          71 :                 if(m_currentHeight + band->getHeight() > m_report->getHeight())
     350             :                 {
     351          22 :                     addPage();
     352          22 :                     m_currentHeight = 0;
     353             :                 }
     354             : 
     355          71 :                 auto frame = new QFrame(isLayout() ? parent : m_pages.last().data());
     356          71 :                 frame->setStyleSheet("background-color: transparent; ");
     357          71 :                 frame->move(frame->x(), isLayout() ? dy : m_currentHeight);
     358             : 
     359          71 :                 m_currentHeight += band->getHeight();
     360          71 :                 dy += band->getHeight();
     361             : 
     362         196 :                 for(auto && textWidget : band->getTextWidgets())
     363             :                 {
     364         125 :                     auto label = new QLabel(frame);
     365         250 :                     QString style = "";
     366         125 :                     if(textWidget->isBold())
     367             :                     {
     368          56 :                         style += "font-weight: bold; ";
     369             :                     }
     370         125 :                     if(isLayout())
     371             :                     {
     372          18 :                         style += "border: 1px solid gray; ";
     373             :                     }
     374         125 :                     label->setStyleSheet("background-color: transparent; " + style);
     375         125 :                     label->setGeometry(textWidget->getRect());
     376         125 :                     label->setAlignment(textWidget->getAlignment());
     377         250 :                     auto text = isLayout() ? textWidget->getOriginalText() : textWidget->getText();
     378         125 :                     label->setText(text);
     379             :                 }
     380          99 :                 for(auto && line : band->getLines())
     381             :                 {
     382          28 :                     auto label = new QLabel(frame);
     383          56 :                     QString style = "";
     384          28 :                     if(line->isBold())
     385             :                     {
     386          24 :                         style += "font-weight: bold; ";
     387             :                     }
     388             :                     //if(isLayout())
     389             :                     {
     390          28 :                         style += "border: 1px solid gray; ";
     391             :                     }
     392          28 :                     label->setStyleSheet("background-color: transparent; " + style);
     393          28 :                     label->setGeometry(line->getRect());
     394          28 :                     label->setAlignment(line->getAlignment());
     395             :                     //label->setText("----------------------");
     396             :                 }
     397          85 :                 for(auto && imageWidget : band->getImages())
     398             :                 {
     399          14 :                     if(imageWidget->getRect().isEmpty())
     400             :                     {
     401           0 :                         m_lastError = "Ellipse \"" + imageWidget->getName() + "\" rect is empty";
     402           0 :                         return false;
     403             :                     }
     404             : 
     405          14 :                     auto label = new QLabel(frame);
     406          28 :                     QString style = "";
     407          14 :                     if(isLayout())
     408             :                     {
     409           2 :                         style += "border: 1px solid gray; ";
     410             :                     }
     411          14 :                     label->setStyleSheet("background-color: transparent; " + style);
     412          14 :                     label->setGeometry(imageWidget->getRect());
     413          14 :                     label->setAlignment(imageWidget->getAlignment());
     414          14 :                     label->setPixmap(QPixmap::fromImage(imageWidget->getImage()));
     415             :                 }
     416          89 :                 for(auto && rect : band->getRects())
     417             :                 {
     418          18 :                     if(rect->getRect().isEmpty())
     419             :                     {
     420           0 :                         m_lastError = "Rect \"" + rect->getName() + "\" rect is empty";
     421           0 :                         return false;
     422             :                     }
     423             : 
     424          18 :                     auto label = new QLabel(frame);
     425          36 :                     QString style = "";
     426          18 :                     if(rect->isBold())
     427             :                     {
     428          14 :                         style += "font-weight: bold; ";
     429             :                     }
     430             :                     //if(isLayout())
     431             :                     {
     432          18 :                         style += "border: 1px solid gray; ";
     433             :                     }
     434          18 :                     label->setStyleSheet("background-color: transparent; " + style);
     435          18 :                     label->setGeometry(rect->getRect());
     436          18 :                     label->setAlignment(rect->getAlignment());
     437             :                     //label->setText("----------------------");
     438             :                 }
     439          85 :                 for(auto && ellipse : band->getEllipses())
     440             :                 {
     441          14 :                     if(ellipse->getSize().isEmpty())
     442             :                     {
     443           0 :                         m_lastError = "Ellipse \"" + ellipse->getName() + "\" size is empty";
     444           0 :                         return false;
     445             :                     }
     446             : 
     447          14 :                     auto label = new QLabel(frame);
     448          28 :                     QString style = "";
     449          14 :                     if(isLayout())
     450             :                     {
     451           2 :                         style += "border: 1px solid gray; ";
     452             :                     }
     453             : 
     454          28 :                     QPixmap pixmap(ellipse->getSize());
     455          14 :                     pixmap.fill(Qt::GlobalColor::transparent);
     456             : 
     457          28 :                     QPainter painter(&pixmap);
     458          14 :                     painter.setRenderHint(QPainter::Antialiasing);
     459          14 :                     painter.drawEllipse(ellipse->getRect());
     460          14 :                     painter.end();
     461          14 :                     label->setPixmap(pixmap);
     462             : 
     463          14 :                     label->setStyleSheet("background-color: transparent; " + style);
     464          14 :                     label->setGeometry(ellipse->getRect());
     465          14 :                     label->setAlignment(ellipse->getAlignment());
     466             :                 }
     467          73 :                 for(auto && crosstab : band->getCrosstabs())
     468             :                 {
     469           2 :                     if(isLayout())
     470             :                     {
     471             :                         /*
     472             :                          * +---------+---------+
     473             :                          * |_________|_$F{col}_|
     474             :                          * |_$F{row}_|$F{cell}_|
     475             :                          * +-------------------+
     476             :                         */
     477           1 :                         auto labelEmpty = new QLabel(frame);
     478           1 :                         auto labelRow   = new QLabel(frame);
     479           1 :                         auto labelCol   = new QLabel(frame);
     480           1 :                         auto labelCell  = new QLabel(frame);
     481           2 :                         QString style = "";
     482           1 :                         if(isLayout())
     483             :                         {
     484           1 :                             style += "border: 1px solid gray; ";
     485             :                         }
     486           1 :                         auto crosstabAligment = crosstab->getAlignment();
     487           2 :                         auto rowGroup = crosstab->getRowGroup();
     488           2 :                         auto colGroup = crosstab->getColumnGroup();
     489           2 :                         auto cell     = crosstab->getCrosstabCell();
     490             : 
     491           1 :                         QRect crosstabRect = crosstab->getRect();
     492             : 
     493           1 :                         QRect emptyRect = QRect();
     494           1 :                         emptyRect.setX(crosstabRect.x());
     495           1 :                         emptyRect.setY(crosstabRect.y());
     496           1 :                         emptyRect.setWidth(rowGroup->getWidth());
     497           1 :                         emptyRect.setHeight(cell->getHeight());
     498             : 
     499           1 :                         QRect colRect = QRect();
     500           1 :                         colRect.setX(emptyRect.x() + emptyRect.width());
     501           1 :                         colRect.setY(crosstabRect.y());
     502           1 :                         colRect.setWidth(cell->getWidth());
     503           1 :                         colRect.setHeight(colGroup->getHeight());
     504             : 
     505           1 :                         QRect rowRect = QRect();
     506           1 :                         rowRect.setX(crosstabRect.x());
     507           1 :                         rowRect.setY(emptyRect.y() + emptyRect.height());
     508           1 :                         rowRect.setWidth(rowGroup->getWidth());
     509           1 :                         rowRect.setHeight(cell->getHeight());
     510             : 
     511           1 :                         QRect cellRect = QRect();
     512           1 :                         cellRect.setX(colRect.x());
     513           1 :                         cellRect.setY(rowRect.y());
     514           1 :                         cellRect.setWidth(cell->getWidth());
     515           1 :                         cellRect.setHeight(cell->getHeight());
     516             : 
     517           2 :                         auto textFieldRow  = crosstab->getRowGroup()->getHeader()->getCellContents()->getTextField();
     518           2 :                         auto textFieldCol  = crosstab->getColumnGroup()->getHeader()->getCellContents()->getTextField();
     519           2 :                         auto textFieldCell = crosstab->getCrosstabCell()->getCellContents()->getTextField();
     520             : 
     521           2 :                         auto textRow  = textFieldRow->getOriginalText();
     522           2 :                         auto textCol  = textFieldCol->getOriginalText();
     523           2 :                         auto textCell = textFieldCell->getOriginalText();
     524             : 
     525           1 :                         labelEmpty->setStyleSheet("background-color: transparent; " + style);
     526           1 :                         labelEmpty->setGeometry(emptyRect);
     527           1 :                         labelEmpty->setAlignment(crosstabAligment);
     528             : 
     529           1 :                         labelRow->setStyleSheet("background-color: transparent; " + style);
     530           1 :                         labelRow->setGeometry(rowRect);
     531           1 :                         labelRow->setAlignment(crosstabAligment);
     532           1 :                         labelRow->setText(textRow);
     533             : 
     534           1 :                         labelCol->setStyleSheet("background-color: transparent; " + style);
     535           1 :                         labelCol->setGeometry(colRect);
     536           1 :                         labelCol->setAlignment(crosstabAligment);
     537           1 :                         labelCol->setText(textCol);
     538             : 
     539           1 :                         labelCell->setStyleSheet("background-color: transparent; " + style);
     540           1 :                         labelCell->setGeometry(cellRect);
     541           1 :                         labelCell->setAlignment(crosstabAligment);
     542           1 :                         labelCell->setText(textCell);
     543             :                     }
     544             :                     else
     545             :                     {
     546           2 :                         detail::Replacer replacer;
     547             : 
     548           2 :                         QList<QString> colGroups;
     549           1 :                         replacer.replaceColumnGroupsInCrosstab(crosstab, m_report, colGroups);
     550             : 
     551           2 :                         QList<QString> rowGroups;
     552           1 :                         replacer.replaceRowGroupsInCrosstab(crosstab, m_report, rowGroups);
     553             : 
     554           2 :                         QList<QString> cells;
     555           1 :                         replacer.replaceCellsInCrosstab(crosstab, m_report, cells);
     556             : 
     557           1 :                         QRect crosstabRect = crosstab->getRect();
     558             : 
     559           1 :                         auto crosstabAligment = crosstab->getAlignment();
     560           2 :                         auto rowGroup = crosstab->getRowGroup();
     561           2 :                         auto colGroup = crosstab->getColumnGroup();
     562           2 :                         auto cell     = crosstab->getCrosstabCell();
     563             : 
     564           1 :                         auto labelEmpty = new QLabel(frame);
     565           1 :                         QRect emptyRect = QRect();
     566           1 :                         emptyRect.setX(crosstabRect.x());
     567           1 :                         emptyRect.setY(crosstabRect.y());
     568           1 :                         emptyRect.setWidth(rowGroup->getWidth());
     569           1 :                         emptyRect.setHeight(cell->getHeight());
     570             : 
     571           2 :                         QString style = "border: 1px solid gray;";
     572           1 :                         labelEmpty->setStyleSheet("background-color: transparent; " + style);
     573           1 :                         labelEmpty->setGeometry(emptyRect);
     574           1 :                         labelEmpty->setAlignment(crosstabAligment);
     575             : 
     576           1 :                         int colX = crosstabRect.x() + emptyRect.width();
     577           5 :                         for (int i = 0; i < colGroups.size(); i++)
     578             :                         {
     579           4 :                             auto labelCol = new QLabel(frame);
     580             : 
     581           4 :                             QRect colRect = QRect();
     582           4 :                             colRect.setX(colX);
     583           4 :                             colRect.setY(crosstabRect.y());
     584           4 :                             colRect.setWidth(cell->getWidth());
     585           4 :                             colRect.setHeight(colGroup->getHeight());
     586             : 
     587           4 :                             labelCol->setStyleSheet("background-color: transparent; " + style);
     588           4 :                             labelCol->setGeometry(colRect);
     589           4 :                             labelCol->setAlignment(colGroup->getHeader()->getCellContents()->getAlignment());
     590           4 :                             labelCol->setText(colGroups[i]);
     591             : 
     592           4 :                             colX += cell->getWidth();
     593             :                         }
     594             : 
     595           1 :                         int rowY = crosstabRect.y();
     596           5 :                         for (int i = 0; i < rowGroups.size(); i++)
     597             :                         {
     598           4 :                             rowY += cell->getHeight();
     599             : 
     600           4 :                             auto labelRow = new QLabel(frame);
     601             : 
     602           4 :                             QRect rowRect = QRect();
     603           4 :                             rowRect.setX(crosstabRect.x());
     604           4 :                             rowRect.setY(rowY);
     605           4 :                             rowRect.setWidth(rowGroup->getWidth());
     606           4 :                             rowRect.setHeight(cell->getHeight());
     607             : 
     608           4 :                             labelRow->setStyleSheet("background-color: transparent; " + style);
     609           4 :                             labelRow->setGeometry(rowRect);
     610           4 :                             labelRow->setAlignment(rowGroup->getHeader()->getCellContents()->getAlignment());
     611           4 :                             labelRow->setText(rowGroups[i]);
     612             :                         }
     613             : 
     614           1 :                         int cellX = crosstabRect.x();
     615           1 :                         int cellY = crosstabRect.y();
     616             : 
     617           1 :                         int cellCount = 0;
     618           5 :                         for (int i = 0; i < rowGroups.size(); i++)
     619             :                         {
     620           4 :                             cellX += emptyRect.width();
     621           4 :                             cellY += emptyRect.height();
     622          20 :                             for(int j = 0; j < colGroups.size(); j++)
     623             :                             {
     624          16 :                                 auto labelCell = new QLabel(frame);
     625             : 
     626          16 :                                 QRect cellRect = QRect();
     627          16 :                                 cellRect.setX(cellX);
     628          16 :                                 cellRect.setY(cellY);
     629          16 :                                 cellRect.setWidth(cell->getWidth());
     630          16 :                                 cellRect.setHeight(cell->getHeight());
     631             : 
     632          16 :                                 labelCell->setStyleSheet("background-color: transparent; " + style);
     633          16 :                                 labelCell->setGeometry(cellRect);
     634          16 :                                 labelCell->setAlignment(cell->getCellContents()->getAlignment());
     635             : 
     636          32 :                                 auto text = cells[cellCount];
     637          16 :                                 labelCell->setText(text);
     638             : 
     639          16 :                                 cellCount++;
     640          16 :                                 cellX += cell->getWidth();
     641             :                             }
     642           4 :                             cellX = crosstabRect.x();
     643             :                         }
     644             :                     }
     645             :                 }
     646             :             }
     647             : 
     648          60 :             return true;
     649             :         }
     650             : 
     651             :     }
     652             : }

Generated by: LCOV version 1.14-2-gaa56a43