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);