From 5108c3a49db47b28ef98d6d3316e039bbfa3224b Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Sat, 20 Feb 2016 13:37:18 +0300 Subject: [PATCH] =?UTF-8?q?fix=20#3=20ReportEngine=20=D0=BA=D1=80=D0=B0?= =?UTF-8?q?=D1=88=D0=B8=D1=82=D1=81=D1=8F,=20=D0=B5=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=8B=D1=82=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=BE?= =?UTF-8?q?=D0=BC=20preview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lrreportengine.cpp | 16 ++++++++++++++-- src/lrreportengine_p.h | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lrreportengine.cpp b/src/lrreportengine.cpp index fcb482a..acfa4aa 100644 --- a/src/lrreportengine.cpp +++ b/src/lrreportengine.cpp @@ -55,7 +55,7 @@ QSettings* ReportEngine::m_settings = 0; ReportEnginePrivate::ReportEnginePrivate(QObject *parent) : QObject(parent), m_fileName(""), m_settings(0), m_ownedSettings(false), m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false), - m_showProgressDialog(true), m_reportName("") + m_showProgressDialog(true), m_reportName(""), m_activePreview(0) { m_datasources= new DataSourceManager(this); m_datasources->setObjectName("datasources"); @@ -64,6 +64,9 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) : ReportEnginePrivate::~ReportEnginePrivate() { + if (m_activePreview){ + m_activePreview->close(); + } foreach(PageDesignIntf* page,m_pages) delete page; m_pages.clear(); if (m_ownedSettings&&m_settings) delete m_settings; @@ -81,7 +84,7 @@ QObject *ReportEnginePrivate::elementAt(const QString &, int index) PageDesignIntf *ReportEnginePrivate::createPage(const QString &pageName) { - PageDesignIntf* page =new PageDesignIntf(this); + PageDesignIntf* page =new PageDesignIntf(); page->setObjectName(pageName); page->setReportEditor(this); return page; @@ -130,6 +133,13 @@ void ReportEnginePrivate::slotDataSourceCollectionLoaded(const QString &collecti emit datasourceCollectionLoadFinished(collectionName); } +void ReportEnginePrivate::slotPreviewWindowDestroed(QObject* window) +{ + if (m_activePreview == window){ + m_activePreview = 0; + } +} + void ReportEnginePrivate::clearReport() { foreach(PageDesignIntf* page,m_pages) delete page; @@ -291,6 +301,8 @@ void ReportEnginePrivate::previewReport() if (!dataManager()->errorsList().isEmpty()){ w->setErrorMessages(dataManager()->errorsList()); } + m_activePreview = w; + connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroed(QObject*))); qDebug()<<"render time ="<exec(); } diff --git a/src/lrreportengine_p.h b/src/lrreportengine_p.h index d45f311..5fbcd9d 100644 --- a/src/lrreportengine_p.h +++ b/src/lrreportengine_p.h @@ -32,6 +32,7 @@ #include #include +#include #include "lrreportengine.h" #include "lrcollection.h" #include "lrglobal.h" @@ -100,6 +101,7 @@ public: QString currentReportsDir(){ return m_reportsDir;} void setReportName(const QString& reportName){ m_reportName=reportName;} QString reportName(){ return m_reportName;} + bool hasActivePreview(){return m_activePreview;} signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName); @@ -115,6 +117,8 @@ protected: PageDesignIntf* createPage(const QString& pageName=""); protected slots: void slotDataSourceCollectionLoaded(const QString& collectionName); +private slots: + void slotPreviewWindowDestroed(QObject *window); private: //ICollectionContainer virtual QObject* createElement(const QString&,const QString&); @@ -139,6 +143,7 @@ private: bool m_showProgressDialog; QString m_reportsDir; QString m_reportName; + QMainWindow* m_activePreview; }; }