From ee77ad5e5f5a8b1f859ded3b8016c08bfca68e2f Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Mon, 11 Mar 2019 22:12:35 +0300 Subject: [PATCH] createPreviewScene(QObject *parent = 0); from now return QGraphicsScene* --- include/lrreportengine.h | 3 ++- limereport/lrpagedesignintf.cpp | 24 ++++++++++++++---------- limereport/lrreportengine.cpp | 4 +++- limereport/lrreportengine.h | 3 ++- limereport/lrreportengine_p.h | 2 +- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/include/lrreportengine.h b/include/lrreportengine.h index 00185d8..79090f9 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -42,6 +42,7 @@ #include "lrreportdesignwindowintrerface.h" class QPrinter; +class QGraphicsScene; namespace LimeReport { @@ -83,7 +84,7 @@ public: bool printReport(QMap printers, bool printToAllPrinters = false); bool printPages(ReportPages pages, QPrinter *printer); void printToFile(const QString& fileName); - PageDesignIntf *createPreviewScene(QObject *parent = 0); + QGraphicsScene* createPreviewScene(QObject *parent = 0); bool printToPDF(const QString& fileName); bool exportReport(QString exporterName, const QString &fileName = "", const QMap& params = QMap()); void previewReport(PreviewHints hints = PreviewBarsUserSetting); diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 6ef7815..8d87789 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1767,17 +1767,21 @@ void PageDesignIntf::removeAllItems() m_commandsList.clear(); } -void PageDesignIntf::setItemMode(BaseDesignIntf::ItemMode state) +void PageDesignIntf::setItemMode(BaseDesignIntf::ItemMode mode) { - m_itemMode = state; -// foreach(QGraphicsItem * item, items()) { -// BaseDesignIntf *reportItem = dynamic_cast(item); - -// if (reportItem) { -// reportItem->setItemMode(itemMode()); -// } -// } - if (m_currentPage) m_currentPage->setItemMode(state); + if (m_itemMode != mode){ + m_itemMode = mode; + if (m_currentPage) { + m_currentPage->setItemMode(mode); + } else { + foreach(QGraphicsItem * item, items()) { + BaseDesignIntf *reportItem = dynamic_cast(item); + if (reportItem) { + reportItem->setItemMode(itemMode()); + } + } + } + } } BaseDesignIntf* PageDesignIntf::reportItemByName(const QString &name) diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 7cd13a4..3420639 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include "time.h" @@ -593,6 +594,7 @@ PageDesignIntf* ReportEnginePrivate::createPreviewScene(QObject* parent){ ReportPages pages = renderToPages(); result = new PageDesignIntf(parent); result->setPageItems(pages); + result->setItemMode(PrintMode); } catch (ReportError &exception){ saveError(exception.what()); showError(exception.what()); @@ -719,7 +721,7 @@ void ReportEnginePrivate::cancelRender() m_reportRendering = false; } -PageDesignIntf* ReportEngine::createPreviewScene(QObject* parent){ +QGraphicsScene* ReportEngine::createPreviewScene(QObject* parent){ Q_D(ReportEngine); return d->createPreviewScene(parent); } diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 00185d8..79090f9 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -42,6 +42,7 @@ #include "lrreportdesignwindowintrerface.h" class QPrinter; +class QGraphicsScene; namespace LimeReport { @@ -83,7 +84,7 @@ public: bool printReport(QMap printers, bool printToAllPrinters = false); bool printPages(ReportPages pages, QPrinter *printer); void printToFile(const QString& fileName); - PageDesignIntf *createPreviewScene(QObject *parent = 0); + QGraphicsScene* createPreviewScene(QObject *parent = 0); bool printToPDF(const QString& fileName); bool exportReport(QString exporterName, const QString &fileName = "", const QMap& params = QMap()); void previewReport(PreviewHints hints = PreviewBarsUserSetting); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 3210e64..4c82a0e 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -147,7 +147,7 @@ public: } void clearReport(); - bool printReport(QPrinter *printer=0); + bool printReport(QPrinter* printer=0); bool printReport(QMapprinters, bool printToAllPrinters); bool printPages(ReportPages pages, QPrinter *printer); void printToFile(const QString& fileName);