createPreviewWidget(QWidget* parent=0) method has been added to ReportEngine

This commit is contained in:
Arin Alexander 2016-03-31 00:21:44 +04:00
parent a7192c350c
commit cdd46ff863
4 changed files with 31 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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