From cdd46ff8632bfe6037e6bc79fe31fdeaf182cc63 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 31 Mar 2016 00:21:44 +0400 Subject: [PATCH] createPreviewWidget(QWidget* parent=0) method has been added to ReportEngine --- include/lrreportengine.h | 3 ++- limereport/lrreportengine.cpp | 24 ++++++++++++++++++++++++ limereport/lrreportengine.h | 3 ++- limereport/lrreportengine_p.h | 4 +++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/lrreportengine.h b/include/lrreportengine.h index 1eb4966..3506f1b 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -37,6 +37,7 @@ #include "lrglobal.h" #include "lrdatasourcemanagerintf.h" #include "lrscriptenginemanagerintf.h" +#include "lrpreviewreportwidget.h" class QPrinter; @@ -75,7 +76,6 @@ public: void setShowProgressDialog(bool value); IDataSourceManager* dataManager(); IScriptEngineManager* scriptManager(); - bool loadFromFile(const QString& fileName); bool loadFromByteArray(QByteArray *data); bool loadFromString(const QString& data); @@ -88,6 +88,7 @@ public: void setCurrentReportsDir(const QString& dirName); void setReportName(const QString& name); QString reportName(); + PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); signals: void renderStarted(); void renderFinished(); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 1985b16..51bc4a5 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -47,6 +47,8 @@ #include "serializators/lrxmlreader.h" #include "lrreportrender.h" #include "lrpreviewreportwindow.h" +#include "lrpreviewreportwidget.h" +#include "lrpreviewreportwidget_p.h" namespace LimeReport{ @@ -312,6 +314,22 @@ void ReportEnginePrivate::previewReport() } } +PreviewReportWidget* ReportEnginePrivate::createPreviewWidget(QWidget* parent){ + + PreviewReportWidget* widget = new PreviewReportWidget(this, parent); + try{ + dataManager()->setDesignTime(false); + ReportPages pages = renderToPages(); + dataManager()->setDesignTime(true); + if (pages.count()>0) + widget->d_ptr->setPages(pages); + } catch (ReportError &exception){ + saveError(exception.what()); + showError(exception.what()); + } + return widget; +} + PageDesignIntf* ReportEnginePrivate::createPreviewScene(QObject* parent){ PageDesignIntf* result = 0; try { @@ -595,6 +613,12 @@ void ReportEngine::designReport() d->designReport(); } +PreviewReportWidget* ReportEngine::createPreviewWidget(QWidget *parent) +{ + Q_D(ReportEngine); + return d->createPreviewWidget(parent); +} + void ReportEngine::setShowProgressDialog(bool value) { Q_D(ReportEngine); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 1eb4966..3506f1b 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -37,6 +37,7 @@ #include "lrglobal.h" #include "lrdatasourcemanagerintf.h" #include "lrscriptenginemanagerintf.h" +#include "lrpreviewreportwidget.h" class QPrinter; @@ -75,7 +76,6 @@ public: void setShowProgressDialog(bool value); IDataSourceManager* dataManager(); IScriptEngineManager* scriptManager(); - bool loadFromFile(const QString& fileName); bool loadFromByteArray(QByteArray *data); bool loadFromString(const QString& data); @@ -88,6 +88,7 @@ public: void setCurrentReportsDir(const QString& dirName); void setReportName(const QString& name); QString reportName(); + PreviewReportWidget *createPreviewWidget(QWidget *parent = 0); signals: void renderStarted(); void renderFinished(); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 5fbcd9d..9177639 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -55,6 +55,7 @@ class ReportEnginePrivate : public QObject, public ICollectionContainer Q_DECLARE_PUBLIC(ReportEngine) Q_PROPERTY(ACollectionProperty pages READ fakeCollectionReader()) Q_PROPERTY(QObject* datasourcesManager READ dataManager()) + friend class PreviewReportWidget; public: static void printReport(ItemsReaderIntf::Ptr reader, QPrinter &printer); static void printReport(ReportPages pages, QPrinter &printer, const PrintRange &printRange); @@ -93,7 +94,6 @@ public: bool isNeedToSave(); QString lastError(); ReportEngine * q_ptr; - PageDesignIntf *createPreviewScene(QObject *parent); void emitSaveReport(); bool emitLoadReport(); bool isSaved(); @@ -102,6 +102,8 @@ public: void setReportName(const QString& reportName){ m_reportName=reportName;} QString reportName(){ return m_reportName;} bool hasActivePreview(){return m_activePreview;} + PageDesignIntf *createPreviewScene(QObject *parent); + PreviewReportWidget *createPreviewWidget(QWidget *parent); signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName);